@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
@@ -21,7 +21,6 @@ import {
21
21
  SUBAGENT_LIFECYCLE_ARTIFACT_VERSION,
22
22
  Semaphore,
23
23
  TEMP_ROOT_DIR,
24
- THINKING_LEVELS,
25
24
  acceptChildWatchdogEvent,
26
25
  acceptanceFailureMessage,
27
26
  aggregateAcceptanceReport,
@@ -30,7 +29,6 @@ import {
30
29
  appendTurnBudgetSystemPrompt,
31
30
  applyIntercomBridgeToAgent,
32
31
  applyThinkingSuffix,
33
- assertSafeNestedId,
34
32
  attachNestedChildrenToResultChildren,
35
33
  attachRootChildrenToSteps,
36
34
  buildChainInstructions,
@@ -69,11 +67,9 @@ import {
69
67
  expectsImplementationMutation,
70
68
  extractTextFromContent,
71
69
  extractToolArgsPreview,
72
- findAsyncRunPrefixMatches,
73
70
  findLatestSessionFile,
74
71
  findModelInfo,
75
72
  findNestedRouteForRootId,
76
- findNestedRunMatchesById,
77
73
  flatToLogicalStepIndex,
78
74
  formatAcceptancePrompt,
79
75
  formatActivityLabel,
@@ -116,7 +112,6 @@ import {
116
112
  normalizeChildSpec,
117
113
  normalizeParallelGroups,
118
114
  normalizeSkillInput,
119
- parseWatchdogThinkingInput,
120
115
  projectNestedRegistryForRoot,
121
116
  readChildToolDiagnosticError,
122
117
  readNestedControlResults,
@@ -140,6 +135,7 @@ import {
140
135
  resolveEffectiveAcceptance,
141
136
  resolveEffectiveSubagentModel,
142
137
  resolveEffectiveThinking,
138
+ resolveExecutableChildModel,
143
139
  resolveInheritedNestedRouteFromEnv,
144
140
  resolveIntercomBridge,
145
141
  resolveIntercomSessionTarget,
@@ -148,16 +144,17 @@ import {
148
144
  resolveNestedAsyncDir,
149
145
  resolveNestedParentAddressFromEnv,
150
146
  resolveParallelBehaviors,
151
- resolveRequiredTierModel,
152
147
  resolveSkillsWithFallback,
153
148
  resolveStepBehavior,
154
149
  resolveSubagentIntercomTarget,
155
150
  resolveSubagentResultStatus,
151
+ resolveSubagentRunId,
156
152
  resolveTopLevelParallelConcurrency,
157
153
  resolveTopLevelParallelMaxTasks,
158
154
  resolveTurnBudgetConfig,
159
155
  resolveWatchdogConfig,
160
156
  resolveWatchdogModelInput,
157
+ restorePersistedAcceptance,
161
158
  shouldAbortForTurnBudget,
162
159
  shouldNotifyControlEvent,
163
160
  splitKnownThinkingSuffix,
@@ -186,14 +183,13 @@ import {
186
183
  writeMetadata,
187
184
  writeNestedControlRequest,
188
185
  writeNestedEvent,
189
- writePrivateAtomicJson,
190
- writeWatchdogModelSettings
191
- } from "./chunk-MCUNIRD5.js";
186
+ writePrivateAtomicJson
187
+ } from "./chunk-46ECNOLF.js";
192
188
  import {
193
189
  PLAN_MODE_WRITE_SPAWN_ERROR,
194
190
  resolveChildPermissions,
195
191
  snapshotParentPermissionMode
196
- } from "./chunk-XATUM2HK.js";
192
+ } from "./chunk-25I2BHAA.js";
197
193
  import "./chunk-WKDK4C5P.js";
198
194
  import "./chunk-53YJI7JU.js";
199
195
  import "./chunk-KBKMCJDU.js";
@@ -203,7 +199,7 @@ import {
203
199
  } from "./chunk-GKLEQ3I4.js";
204
200
  import "./chunk-FVDOXRUD.js";
205
201
  import "./chunk-AD6VXAO7.js";
206
- import "./chunk-J26TSGDL.js";
202
+ import "./chunk-6N22HULO.js";
207
203
  import "./chunk-M3LZLQW2.js";
208
204
  import "./chunk-RQ2Q5IYR.js";
209
205
  import "./chunk-DDWHZ633.js";
@@ -214,8 +210,8 @@ import "./chunk-BRJX2PRC.js";
214
210
 
215
211
  // packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js
216
212
  import { randomUUID as randomUUID4 } from "node:crypto";
217
- import * as fs16 from "node:fs";
218
- import * as path16 from "node:path";
213
+ import * as fs15 from "node:fs";
214
+ import * as path15 from "node:path";
219
215
 
220
216
  // packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-clarify.js
221
217
  import { matchesKey, visibleWidth, truncateToWidth } from "@ashx-j/lunr-tui";
@@ -1260,20 +1256,20 @@ function resolvePiPackageRoot() {
1260
1256
  return;
1261
1257
  }
1262
1258
  }
1263
- function isRunnableNodeScript(filePath, existsSync12) {
1264
- return existsSync12(filePath) ? /\.(?:mjs|cjs|js)$/i.test(filePath) : !1;
1259
+ function isRunnableNodeScript(filePath, existsSync11) {
1260
+ return existsSync11(filePath) ? /\.(?:mjs|cjs|js)$/i.test(filePath) : !1;
1265
1261
  }
1266
1262
  function normalizePath(filePath) {
1267
1263
  return path2.isAbsolute(filePath) ? filePath : path2.resolve(filePath);
1268
1264
  }
1269
1265
  function resolvePiCliScript(deps = {}) {
1270
- let existsSync12 = deps.existsSync ?? fs2.existsSync, realpathSync5 = deps.realpathSync ?? fs2.realpathSync, readFileSync8 = deps.readFileSync ?? ((filePath, encoding) => fs2.readFileSync(filePath, encoding)), argv1 = deps.argv1 ?? process.argv[1];
1266
+ let existsSync11 = deps.existsSync ?? fs2.existsSync, realpathSync5 = deps.realpathSync ?? fs2.realpathSync, readFileSync8 = deps.readFileSync ?? ((filePath, encoding) => fs2.readFileSync(filePath, encoding)), argv1 = deps.argv1 ?? process.argv[1];
1271
1267
  if (argv1) {
1272
1268
  let argvPath = normalizePath(argv1);
1273
- if (isRunnableNodeScript(argvPath, existsSync12))
1269
+ if (isRunnableNodeScript(argvPath, existsSync11))
1274
1270
  try {
1275
1271
  let canonicalArgvPath = realpathSync5(argvPath);
1276
- if (isRunnableNodeScript(canonicalArgvPath, existsSync12) && findPiPackageRootFromEntry(canonicalArgvPath))
1272
+ if (isRunnableNodeScript(canonicalArgvPath, existsSync11) && findPiPackageRootFromEntry(canonicalArgvPath))
1277
1273
  return canonicalArgvPath;
1278
1274
  } catch {
1279
1275
  }
@@ -1291,7 +1287,7 @@ function resolvePiCliScript(deps = {}) {
1291
1287
  if (!binPath)
1292
1288
  return;
1293
1289
  let candidate = path2.resolve(path2.dirname(packageJsonPath), binPath);
1294
- if (isRunnableNodeScript(candidate, existsSync12))
1290
+ if (isRunnableNodeScript(candidate, existsSync11))
1295
1291
  return candidate;
1296
1292
  } catch {
1297
1293
  return;
@@ -3294,10 +3290,13 @@ function resolveChainToolBudget(input) {
3294
3290
  return { toolBudget: resolved.budget, error: resolved.error };
3295
3291
  }
3296
3292
  async function runParallelChainTasks(input) {
3297
- let concurrency = input.step.concurrency ?? MAX_CONCURRENCY, failFast = input.step.failFast ?? !1, aborted = !1, effectiveModels = input.step.parallel.map((task) => {
3298
- let taskChildConfig = input.agents.find((child) => child.name === task.agent);
3299
- return resolveRequiredTierModel(task.tier, input.availableModels, input.ctx.model?.provider);
3300
- });
3293
+ let concurrency = input.step.concurrency ?? MAX_CONCURRENCY, failFast = input.step.failFast ?? !1, aborted = !1, effectiveModels = input.step.parallel.map((task) => resolveExecutableChildModel({
3294
+ model: task.model,
3295
+ tier: task.tier,
3296
+ thinking: task.thinking,
3297
+ availableModels: input.availableModels,
3298
+ preferredProvider: input.ctx.model?.provider
3299
+ }));
3301
3300
  for (let taskIndex = 0; taskIndex < input.step.parallel.length; taskIndex++) {
3302
3301
  let task = input.step.parallel[taskIndex];
3303
3302
  input.sessionFileForTask?.(task.agent, input.globalTaskIndex + taskIndex, effectiveModels[taskIndex]);
@@ -3327,9 +3326,10 @@ async function runParallelChainTasks(input) {
3327
3326
  task: taskStr,
3328
3327
  description: task.description,
3329
3328
  permissions: task.permissions,
3330
- model: effectiveModel ?? task.model,
3329
+ model: task.model,
3331
3330
  tier: task.tier,
3332
- modelSelection: captureModelSelection({ tier: task.tier }),
3331
+ thinking: task.thinking,
3332
+ modelSelection: captureModelSelection({ model: task.model, tier: task.tier }),
3333
3333
  skill: task.skill,
3334
3334
  cwd: taskCwd,
3335
3335
  output: task.output,
@@ -3834,7 +3834,13 @@ ${failureSummary}`;
3834
3834
  stepTask = stepTask.replace(/\{task\}/g, originalTask), stepTask = stepTask.replace(/\{previous\}/g, prev), stepTask = stepTask.replace(/\{chain_dir\}/g, chainDir);
3835
3835
  let cleanTask = stepTask;
3836
3836
  stepTask = prefix + stepTask + suffix;
3837
- let effectiveModel = resolveRequiredTierModel(seqStep.tier, availableModels, ctx.model?.provider), outputPath = typeof behavior.output == "string" ? path6.isAbsolute(behavior.output) ? behavior.output : path6.join(chainDir, behavior.output) : void 0;
3837
+ let effectiveModel = resolveExecutableChildModel({
3838
+ model: seqStep.model,
3839
+ tier: seqStep.tier,
3840
+ thinking: seqStep.thinking,
3841
+ availableModels,
3842
+ preferredProvider: ctx.model?.provider
3843
+ }), outputPath = typeof behavior.output == "string" ? path6.isAbsolute(behavior.output) ? behavior.output : path6.join(chainDir, behavior.output) : void 0;
3838
3844
  stepTask = injectSingleOutputInstruction(stepTask, outputPath, agentConfig);
3839
3845
  let validationError = validateFileOnlyOutputMode(behavior.outputMode, outputPath, `Chain step ${stepIndex + 1} (${seqStep.agent})`);
3840
3846
  if (validationError)
@@ -3863,9 +3869,10 @@ ${failureSummary}`;
3863
3869
  task: stepTask,
3864
3870
  description: seqStep.description,
3865
3871
  permissions: seqStep.permissions,
3866
- model: effectiveModel ?? seqStep.model,
3872
+ model: seqStep.model,
3867
3873
  tier: seqStep.tier,
3868
- modelSelection: captureModelSelection({ tier: seqStep.tier }),
3874
+ thinking: seqStep.thinking,
3875
+ modelSelection: captureModelSelection({ model: seqStep.model, tier: seqStep.tier }),
3869
3876
  skill: seqStep.skill,
3870
3877
  cwd: seqStep.cwd,
3871
3878
  output: seqStep.output,
@@ -4264,7 +4271,14 @@ ${injection}` : injection;
4264
4271
  taskTemplate = taskTemplate.replace(/\{task\}/g, originalTask ?? ""), taskTemplate = taskTemplate.replace(/\{chain_dir\}/g, runnerCwd);
4265
4272
  let taskText = `${readInstructions.prefix}${taskTemplate}${progressInstructions.suffix}`, task = namespaceOutputPath ? taskText : injectSingleOutputInstruction(taskText, outputPath, {
4266
4273
  tools: spec.effectivePermissions === "read-only" ? ["read", "grep", "find", "ls", "bash"] : void 0
4267
- }), primaryModel = resolveRequiredTierModel(spec.tier, availableModels, ctx.currentModelProvider), thinkingOverride = flatIndex === void 0 ? void 0 : thinkingOverridesByFlatIndex?.[flatIndex], effectiveThinking = thinkingOverride, model = applyThinkingSuffix(primaryModel, effectiveThinking, thinkingOverride !== void 0);
4274
+ }), primaryModel = resolveExecutableChildModel({
4275
+ modelSelection: spec.modelSelection,
4276
+ model: spec.model,
4277
+ tier: spec.tier,
4278
+ thinking: spec.thinking,
4279
+ availableModels,
4280
+ preferredProvider: ctx.currentModelProvider
4281
+ }), thinkingOverride = flatIndex === void 0 ? void 0 : thinkingOverridesByFlatIndex?.[flatIndex], effectiveThinking = thinkingOverride, model = applyThinkingSuffix(primaryModel, effectiveThinking, thinkingOverride !== void 0);
4268
4282
  return {
4269
4283
  parentSessionId: ctx.parentSessionId ?? ctx.currentSessionId,
4270
4284
  parentPermissionMode: snapshotParentPermissionMode(ctx.parentSessionId ?? ctx.currentSessionId),
@@ -4556,6 +4570,16 @@ function executeAsyncChain(id, params) {
4556
4570
  details: { mode: resultMode, runId: id, results: [], asyncId: id, asyncDir, workflowGraph, ...params.timeoutMs !== void 0 ? { timeoutMs: params.timeoutMs, deadlineAt } : {}, ...params.turnBudget ? { turnBudget: params.turnBudget } : {}, ...params.toolBudget ? { toolBudget: params.toolBudget } : {} }
4557
4571
  };
4558
4572
  }
4573
+ function resolveAsyncSingleAcceptance(input) {
4574
+ return input.restoredAcceptance ? input.restoredAcceptance : resolveEffectiveAcceptance({
4575
+ explicit: input.launchAcceptance,
4576
+ agentName: input.agentName,
4577
+ permissions: input.permissions,
4578
+ task: input.task,
4579
+ mode: "single",
4580
+ async: !0
4581
+ });
4582
+ }
4559
4583
  function executeAsyncSingle(id, params) {
4560
4584
  let { spec, ctx, cwd, maxOutput, artifactsDir, artifactConfig, shareEnabled, sessionRoot, sessionFile, maxSubagentDepth, worktreeSetupHook, worktreeSetupHookTimeoutMs, worktreeBaseDir, controlConfig, controlIntercomTarget, childIntercomTarget, nestedRoute } = params, agent = spec.description, task = spec.task, runnerCwd = resolveChildCwd(ctx.cwd, cwd), skillNames = params.skills ?? (spec.skill === !1 ? [] : normalizeSkillInput(spec.skill) ?? []), availableModels = params.availableModels, { resolved: resolvedSkills, missing: missingSkills } = resolveSkillsWithFallback(skillNames, runnerCwd, ctx.cwd, void 0, runnerCwd);
4561
4585
  if (missingSkills.includes("pi-subagents"))
@@ -4583,19 +4607,25 @@ ${injection}` : injection;
4583
4607
  let outputMode = params.outputMode ?? spec.outputMode ?? "inline", validationError = validateFileOnlyOutputMode(outputMode, outputPath, `Async single run (${agent})`);
4584
4608
  if (validationError)
4585
4609
  return formatAsyncStartError("single", validationError);
4586
- let taskWithOutputInstruction = injectSingleOutputInstruction(task, outputPath, childToolShape), primaryModel = resolveRequiredTierModel(spec.tier, availableModels, ctx.currentModelProvider), effectiveThinking = params.thinkingOverride, model = applyThinkingSuffix(primaryModel, effectiveThinking, params.thinkingOverride !== void 0), toolBudgetInput = params.toolBudget ?? spec.toolBudget ?? params.configToolBudget, resolvedToolBudget = validateToolBudgetConfig(toolBudgetInput, params.toolBudget || spec.toolBudget ? "toolBudget" : "config.toolBudget");
4610
+ let taskWithOutputInstruction = injectSingleOutputInstruction(task, outputPath, childToolShape), primaryModel = resolveExecutableChildModel({
4611
+ modelSelection: spec.modelSelection,
4612
+ model: spec.model,
4613
+ tier: spec.tier,
4614
+ thinking: spec.thinking,
4615
+ availableModels,
4616
+ preferredProvider: ctx.currentModelProvider
4617
+ }), effectiveThinking = params.thinkingOverride, model = applyThinkingSuffix(primaryModel, effectiveThinking, params.thinkingOverride !== void 0), toolBudgetInput = params.toolBudget ?? spec.toolBudget ?? params.configToolBudget, resolvedToolBudget = validateToolBudgetConfig(toolBudgetInput, params.toolBudget || spec.toolBudget ? "toolBudget" : "config.toolBudget");
4587
4618
  if (resolvedToolBudget.error)
4588
4619
  return formatAsyncStartError("single", resolvedToolBudget.error);
4589
4620
  let deadlineAt = params.absoluteDeadlineAt ?? (params.timeoutMs !== void 0 ? Date.now() + params.timeoutMs : void 0), timeoutMs = params.absoluteDeadlineAt !== void 0 && deadlineAt !== void 0 ? deadlineAt - Date.now() : params.timeoutMs;
4590
4621
  if (timeoutMs !== void 0 && timeoutMs <= 0)
4591
4622
  return formatAsyncStartError("single", "The source run's absolute deadline expired before recovery could launch.");
4592
- let initialTurnBudget = params.turnBudget ? initialTurnBudgetState(params.turnBudget) : void 0, resolvedSessionDir = params.sessionDir ?? (sessionRoot ? path7.join(sessionRoot, `async-${id}`) : void 0), resolvedAcceptance = resolveEffectiveAcceptance({
4593
- explicit: params.acceptance ?? spec.acceptance,
4623
+ let initialTurnBudget = params.turnBudget ? initialTurnBudgetState(params.turnBudget) : void 0, resolvedSessionDir = params.sessionDir ?? (sessionRoot ? path7.join(sessionRoot, `async-${id}`) : void 0), resolvedAcceptance = resolveAsyncSingleAcceptance({
4624
+ restoredAcceptance: params.restoredAcceptance,
4625
+ launchAcceptance: params.acceptance ?? spec.acceptance,
4594
4626
  agentName: agent,
4595
4627
  permissions: spec.effectivePermissions,
4596
- task,
4597
- mode: "single",
4598
- async: !0
4628
+ task
4599
4629
  }), recoveryDescriptor = {
4600
4630
  version: 4,
4601
4631
  lifecycleArtifactVersion: SUBAGENT_LIFECYCLE_ARTIFACT_VERSION,
@@ -4607,8 +4637,8 @@ ${injection}` : injection;
4607
4637
  ...sessionFile ? { sessionFile } : {},
4608
4638
  cwd: runnerCwd,
4609
4639
  ...model ? { model } : {},
4610
- tier: spec.tier,
4611
- ...effectiveThinking ? { thinking: resolveEffectiveThinking(model, effectiveThinking) } : {},
4640
+ ...spec.tier ? { tier: spec.tier } : {},
4641
+ ...effectiveThinking || spec.thinking ? { thinking: resolveEffectiveThinking(model, effectiveThinking ?? spec.thinking) } : {},
4612
4642
  ...spec.modelSelection ? { modelSelection: spec.modelSelection } : {},
4613
4643
  ...resolvedSkills.length ? { skills: resolvedSkills.map((skill) => skill.name) } : {},
4614
4644
  ...outputPath ? { outputPath } : {},
@@ -4887,62 +4917,13 @@ function result(text, isError = !1) {
4887
4917
  function messageFromError(error) {
4888
4918
  return error instanceof Error ? error.message : String(error);
4889
4919
  }
4890
- function parseScope(raw) {
4891
- if (raw === void 0 || raw === "session")
4892
- return "session";
4893
- if (raw === "user" || raw === "project")
4894
- return raw;
4895
- throw new Error("watchdog.configure scope must be 'session', 'user', or 'project'.");
4896
- }
4897
- function parseTarget(params) {
4898
- let target = params.target ?? "main";
4899
- if (target === "main")
4900
- return { kind: "main" };
4901
- if (target === "children")
4902
- return { kind: "children" };
4903
- if (target === "child") {
4904
- if (!params.agent?.trim())
4905
- throw new Error("watchdog.configure target='child' requires agent.");
4906
- return { kind: "child", agent: params.agent.trim() };
4907
- }
4908
- throw new Error("watchdog.configure target must be 'main', 'children', or 'child'.");
4909
- }
4910
- function parseThinking(raw) {
4911
- if (raw !== void 0)
4912
- return raw === "inherit" ? null : parseWatchdogThinkingInput(raw, "watchdog.configure thinking") ?? void 0;
4913
- }
4914
- function resolveConfiguredValue(ctx, params) {
4915
- let thinking = parseThinking(params.thinking), rawModel = params.model?.trim();
4916
- if (!rawModel) {
4917
- if (thinking === void 0)
4918
- throw new Error("watchdog.configure requires model, thinking, or both.");
4919
- return { thinking, description: `thinking ${thinking === null ? "inherit" : thinking === !1 ? "off" : thinking}` };
4920
- }
4921
- if (rawModel === "inherit")
4922
- return { model: null, thinking: thinking ?? null, description: "inherit" };
4923
- if (rawModel === "recommended") {
4924
- let recommendation = recommendStrongWatchdogModel(ctx);
4925
- return {
4926
- model: recommendation.model,
4927
- thinking: recommendation.thinking,
4928
- description: `${recommendation.model}:${recommendation.thinking}`
4929
- };
4930
- }
4931
- let resolved = resolveWatchdogModelInput(ctx, rawModel);
4932
- return {
4933
- model: resolved.model,
4934
- thinking: resolved.thinking ?? thinking,
4935
- description: `${resolved.model}${resolved.thinking ?? thinking ? `:${resolved.thinking ?? thinking}` : ""}`
4936
- };
4937
- }
4938
4920
  function buildRecommendationText(ctx) {
4939
4921
  let recommendation = recommendStrongWatchdogModel(ctx);
4940
4922
  return [
4941
4923
  "Subagent watchdog recommended model",
4942
4924
  `Recommended: ${recommendation.model}:${recommendation.thinking}`,
4943
4925
  `Reason: ${recommendation.reason}`,
4944
- 'Apply temporarily with subagent({ action: "watchdog.configure", scope: "session", model: "recommended" }).',
4945
- 'Persist with scope: "project" or scope: "user" only when the user asks for that scope.'
4926
+ "Watchdog settings are user-managed through /subagents-watchdog."
4946
4927
  ].join(`
4947
4928
  `);
4948
4929
  }
@@ -4969,44 +4950,14 @@ function buildCheckText(runtime, ctx) {
4969
4950
  return lines.join(`
4970
4951
  `);
4971
4952
  }
4972
- function handleWatchdogToolAction(action, params, ctx, runtime) {
4953
+ function handleWatchdogToolAction(action, _params, ctx, runtime) {
4973
4954
  try {
4974
- if (action === "watchdog.status")
4975
- return runtime ? result(buildWatchdogStatus(runtime.getSnapshot(ctx.cwd), ctx)) : result("Subagent watchdog runtime is unavailable.", !0);
4976
- if (action === "watchdog.recommend-model")
4977
- return result(buildRecommendationText(ctx));
4978
- if (action === "watchdog.check")
4979
- return result(buildCheckText(runtime, ctx));
4980
- if (action !== "watchdog.configure")
4981
- return result(`Unknown watchdog action: ${action}`, !0);
4982
- let scope = parseScope(params.scope), target = parseTarget(params), value = resolveConfiguredValue(ctx, params);
4983
- if (scope === "session")
4984
- return runtime ? target.kind !== "main" ? result("Session-scoped watchdog.configure currently supports target='main' only.", !0) : (runtime.setSessionModel({ model: value.model, thinking: value.thinking }, ctx.cwd), result([
4985
- `Subagent watchdog session model configured: ${value.description}.`,
4986
- "No settings files were changed.",
4987
- "",
4988
- buildWatchdogStatus(runtime.getSnapshot(ctx.cwd), ctx)
4989
- ].join(`
4990
- `))) : result("Subagent watchdog runtime is unavailable.", !0);
4991
- let settingsPath = writeWatchdogModelSettings({
4992
- scope,
4993
- cwd: ctx.cwd,
4994
- target,
4995
- model: value.model,
4996
- thinking: value.thinking
4997
- });
4998
- runtime?.refreshConfig(ctx.cwd);
4999
- let targetLabel = target.kind === "child" ? `child ${target.agent}` : target.kind;
5000
- return result([
5001
- `Subagent watchdog ${targetLabel} model configured: ${value.description}.`,
5002
- `Updated: ${settingsPath}`
5003
- ].join(`
5004
- `));
4955
+ return action === "watchdog.status" ? runtime ? result(buildWatchdogStatus(runtime.getSnapshot(ctx.cwd), ctx)) : result("Subagent watchdog runtime is unavailable.", !0) : action === "watchdog.recommend-model" ? result(buildRecommendationText(ctx)) : action === "watchdog.check" ? result(buildCheckText(runtime, ctx)) : result(`Unknown watchdog action: ${action}`, !0);
5005
4956
  } catch (error) {
5006
4957
  return result(`Subagent watchdog action failed: ${messageFromError(error)}`, !0);
5007
4958
  }
5008
4959
  }
5009
- var WATCHDOG_TOOL_ACTIONS = ["watchdog.status", "watchdog.check", "watchdog.configure", "watchdog.recommend-model"], WATCHDOG_THINKING_VALUES = ["inherit", ...THINKING_LEVELS];
4960
+ var WATCHDOG_TOOL_ACTIONS = ["watchdog.status", "watchdog.check", "watchdog.recommend-model"];
5010
4961
 
5011
4962
  // packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/background/chain-append.js
5012
4963
  import { randomUUID } from "node:crypto";
@@ -5488,81 +5439,11 @@ function resolveAsyncRootResultPath(resultsDir, runId) {
5488
5439
  return path13.join(resultsDir, `${runId}.json`);
5489
5440
  }
5490
5441
 
5491
- // packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/background/run-id-resolver.js
5442
+ // packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/background/run-status.js
5492
5443
  import * as fs14 from "node:fs";
5493
5444
  import * as path14 from "node:path";
5494
- function exactAsyncLocation(id, asyncDirRoot, resultsDir) {
5495
- let asyncDir = path14.join(asyncDirRoot, id), resultPath = path14.join(resultsDir, `${id}.json`);
5496
- if (!(!fs14.existsSync(asyncDir) && !fs14.existsSync(resultPath)))
5497
- return {
5498
- asyncDir: fs14.existsSync(asyncDir) ? asyncDir : null,
5499
- resultPath: fs14.existsSync(resultPath) ? resultPath : null,
5500
- resolvedId: id
5501
- };
5502
- }
5503
- function foregroundIds(state) {
5504
- if (!state)
5505
- return [];
5506
- let remembered = state.currentSessionId ? [...state.foregroundRuns?.values() ?? []].filter((run) => run.sessionId === state.currentSessionId).map((run) => run.runId) : [];
5507
- return [.../* @__PURE__ */ new Set([...state.foregroundControls.keys(), ...remembered])];
5508
- }
5509
- function hasExactForegroundId(state, id) {
5510
- if (!state)
5511
- return !1;
5512
- if (state.foregroundControls.has(id))
5513
- return !0;
5514
- let remembered = state.foregroundRuns?.get(id);
5515
- return !!(remembered && state.currentSessionId && remembered.sessionId === state.currentSessionId);
5516
- }
5517
- function nestedScopeFromState(state) {
5518
- if (!state)
5519
- return;
5520
- let routes = [], seen = /* @__PURE__ */ new Set(), add = (route) => {
5521
- if (!route)
5522
- return;
5523
- let key = `${route.rootRunId}:${route.eventSink}:${route.controlInbox}`;
5524
- seen.has(key) || (seen.add(key), routes.push(route));
5525
- };
5526
- for (let control of state.foregroundControls.values())
5527
- add(control.nestedRoute);
5528
- for (let job of state.asyncJobs.values())
5529
- add(job.nestedRoute);
5530
- return { routes };
5531
- }
5532
- function asyncPrefixMatches(prefix, asyncDirRoot, resultsDir) {
5533
- return findAsyncRunPrefixMatches(prefix, asyncDirRoot, resultsDir);
5534
- }
5535
- function resolveSubagentRunId(id, deps = {}) {
5536
- assertSafeNestedId("id", id);
5537
- let asyncDirRoot = deps.asyncDirRoot ?? ASYNC_DIR, resultsDir = deps.resultsDir ?? RESULTS_DIR, nestedScope = deps.nested ?? nestedScopeFromState(deps.state);
5538
- if (hasExactForegroundId(deps.state, id))
5539
- return { kind: "foreground", id };
5540
- let exactAsync = exactAsyncLocation(id, asyncDirRoot, resultsDir);
5541
- if (exactAsync)
5542
- return { kind: "async", id, location: exactAsync };
5543
- let exactNested = findNestedRunMatchesById(id, nestedScope ? { scope: nestedScope } : {});
5544
- if (exactNested.length > 1)
5545
- throw new Error(`Nested run id '${id}' is ambiguous across authorized registries. Provide the full id after stale registries are cleaned up.`);
5546
- if (exactNested[0])
5547
- return { kind: "nested", id, match: exactNested[0] };
5548
- let matches = [];
5549
- for (let foregroundId of foregroundIds(deps.state).filter((candidate) => candidate.startsWith(id)))
5550
- matches.push({ kind: "foreground", id: foregroundId });
5551
- for (let match of asyncPrefixMatches(id, asyncDirRoot, resultsDir))
5552
- matches.push({ kind: "async", id: match.id, location: match.location });
5553
- for (let match of findNestedRunMatchesById(id, nestedScope ? { prefix: !0, scope: nestedScope } : { prefix: !0 }))
5554
- matches.push({ kind: "nested", id: match.run.id, match });
5555
- let values = [...new Map(matches.map((match) => [`${match.kind}:${match.id}`, match])).values()];
5556
- if (values.length > 1)
5557
- throw new Error(`Ambiguous subagent run id prefix '${id}' matched: ${values.map((match) => `${match.kind}:${match.id}`).join(", ")}. Provide a longer id.`);
5558
- return values[0];
5559
- }
5560
-
5561
- // packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/background/run-status.js
5562
- import * as fs15 from "node:fs";
5563
- import * as path15 from "node:path";
5564
5445
  function hasExistingSessionFile(value) {
5565
- return typeof value == "string" && fs15.existsSync(value);
5446
+ return typeof value == "string" && fs14.existsSync(value);
5566
5447
  }
5567
5448
  function formatResumeGuidance(runId, children, fallbackSessionFile, options = {}) {
5568
5449
  if (options.stopped)
@@ -5598,9 +5479,9 @@ function formatSteeringSummary(input) {
5598
5479
  }
5599
5480
  function rememberedForegroundChildOutput(child) {
5600
5481
  let outputPath = child.artifactPaths?.outputPath ?? child.savedOutputPath;
5601
- if (outputPath && fs15.existsSync(outputPath))
5482
+ if (outputPath && fs14.existsSync(outputPath))
5602
5483
  try {
5603
- let artifactOutput = fs15.readFileSync(outputPath, "utf-8").trim();
5484
+ let artifactOutput = fs14.readFileSync(outputPath, "utf-8").trim();
5604
5485
  if (artifactOutput)
5605
5486
  return artifactOutput;
5606
5487
  } catch {
@@ -5773,7 +5654,7 @@ function inspectSubagentStatus(params, deps = {}) {
5773
5654
  details: { mode: "single", results: [] }
5774
5655
  };
5775
5656
  }
5776
- let status = reconciliation.status, effectiveRunId = status?.runId ?? resolvedId ?? "unknown", logPath = path15.join(asyncDir, `subagent-log-${effectiveRunId}.md`), eventsPath = path15.join(asyncDir, "events.jsonl");
5657
+ let status = reconciliation.status, effectiveRunId = status?.runId ?? resolvedId ?? "unknown", logPath = path14.join(asyncDir, `subagent-log-${effectiveRunId}.md`), eventsPath = path14.join(asyncDir, "events.jsonl");
5777
5658
  if (status) {
5778
5659
  if (params.view === "transcript") {
5779
5660
  if (currentSessionId && status.sessionId !== currentSessionId)
@@ -5817,22 +5698,22 @@ function inspectSubagentStatus(params, deps = {}) {
5817
5698
  `Dir: ${asyncDir}`,
5818
5699
  outputPath ? `Output: ${outputPath}` : void 0,
5819
5700
  reconciliation.message ? `Diagnosis: ${reconciliation.message}` : void 0,
5820
- reconciliation.resultPath && fs15.existsSync(reconciliation.resultPath) ? `Result: ${reconciliation.resultPath}` : void 0
5701
+ reconciliation.resultPath && fs14.existsSync(reconciliation.resultPath) ? `Result: ${reconciliation.resultPath}` : void 0
5821
5702
  ].filter((line) => !!line);
5822
5703
  for (let [index, step] of (status.steps ?? []).entries()) {
5823
5704
  let stepActivityText = step.status === "running" ? formatActivityLabel(step.lastActivityAt, step.activityState) : void 0, modelThinking = formatModelSelection(step.modelSelection, step.model, step.thinking), modelText = modelThinking ? ` (${modelThinking})` : "", steeringText2 = formatSteeringSummary(step), steeringSuffix = steeringText2 ? `, steering: ${steeringText2}` : "", errorText2 = step.error ? `, error: ${step.error}` : "", acceptanceText = step.acceptance?.status ? `, acceptance: ${step.acceptance.status}` : "", budgetText = step.turnBudget ? `, turn budget: ${step.turnBudget.turnCount}/${step.turnBudget.maxTurns}+${step.turnBudget.graceTurns} (${step.turnBudget.outcome})` : "", display = step.label ? `${step.label} (${step.agent})` : step.agent, phase = step.phase ? `[${step.phase}] ` : "";
5824
5705
  lines.push(`${stepLineLabel(status, index)}: ${phase}${display} ${step.status}${modelText}${stepActivityText ? `, ${stepActivityText}` : ""}${steeringSuffix}${acceptanceText}${budgetText}${errorText2}`), lines.push(...formatNestedRunStatusLines(step.children, { indent: " ", commandHints: !0, maxLines: 20 }));
5825
- let stepOutputPath = path15.join(asyncDir, `output-${index}.log`);
5826
- stepOutputPath !== outputPath && fs15.existsSync(stepOutputPath) && lines.push(` Output: ${stepOutputPath}`), step.status === "running" && (lines.push(` Intercom target: ${resolveSubagentIntercomTarget(status.runId, step.childId ?? step.agent, index)} (if registered)`), lines.push(` Steer: subagent({ action: "steer", id: "${status.runId}", index: ${index}, message: "..." })`));
5706
+ let stepOutputPath = path14.join(asyncDir, `output-${index}.log`);
5707
+ stepOutputPath !== outputPath && fs14.existsSync(stepOutputPath) && lines.push(` Output: ${stepOutputPath}`), step.status === "running" && (lines.push(` Intercom target: ${resolveSubagentIntercomTarget(status.runId, step.childId ?? step.agent, index)} (if registered)`), lines.push(` Steer: subagent({ action: "steer", id: "${status.runId}", index: ${index}, message: "..." })`));
5827
5708
  }
5828
5709
  let attached = new Set((status.steps ?? []).flatMap((step) => step.children?.map((child) => child.id) ?? [])), unattached = nestedChildren.filter((child) => !attached.has(child.id));
5829
- return lines.push(...formatNestedRunStatusLines(unattached, { indent: "", commandHints: !0, maxLines: 20 })), nestedWarning && lines.push(`Warning: ${nestedWarning}`), status.sessionFile && lines.push(`Session: ${status.sessionFile}`), status.state === "running" && lines.push(`Steer running child: subagent({ action: "steer", id: "${status.runId}", message: "..." })`), status.state !== "running" && lines.push(formatResumeGuidance(status.runId, status.steps ?? [], status.sessionFile, { stopped: status.state === "stopped" || status.stopped === !0 })), fs15.existsSync(logPath) && lines.push(`Log: ${logPath}`), fs15.existsSync(eventsPath) && lines.push(`Events: ${eventsPath}`), { content: [{ type: "text", text: lines.join(`
5710
+ return lines.push(...formatNestedRunStatusLines(unattached, { indent: "", commandHints: !0, maxLines: 20 })), nestedWarning && lines.push(`Warning: ${nestedWarning}`), status.sessionFile && lines.push(`Session: ${status.sessionFile}`), status.state === "running" && lines.push(`Steer running child: subagent({ action: "steer", id: "${status.runId}", message: "..." })`), status.state !== "running" && lines.push(formatResumeGuidance(status.runId, status.steps ?? [], status.sessionFile, { stopped: status.state === "stopped" || status.stopped === !0 })), fs14.existsSync(logPath) && lines.push(`Log: ${logPath}`), fs14.existsSync(eventsPath) && lines.push(`Events: ${eventsPath}`), { content: [{ type: "text", text: lines.join(`
5830
5711
  `) }], details: { mode: "single", results: [] } };
5831
5712
  }
5832
5713
  }
5833
5714
  if (resultPath)
5834
5715
  try {
5835
- let raw = fs15.readFileSync(resultPath, "utf-8"), data = JSON.parse(raw);
5716
+ let raw = fs14.readFileSync(resultPath, "utf-8"), data = JSON.parse(raw);
5836
5717
  if (params.view === "transcript")
5837
5718
  try {
5838
5719
  return { content: [{ type: "text", text: formatAsyncResultTranscript(data, resultPath, { index: params.index, lines: params.lines }) }], details: { mode: "single", results: [] } };
@@ -5862,9 +5743,9 @@ function applyForceTopLevelAsyncOverride(params, depth, forceTopLevelAsync) {
5862
5743
  }
5863
5744
 
5864
5745
  // packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js
5865
- var MUTATING_MANAGEMENT_ACTIONS = /* @__PURE__ */ new Set(["create", "update", "delete", "eject", "disable", "enable", "reset", "watchdog.configure"]);
5746
+ var MUTATING_MANAGEMENT_ACTIONS = /* @__PURE__ */ new Set(["create", "update", "delete", "eject", "disable", "enable", "reset"]);
5866
5747
  function resolveRequestedCwd(runtimeCwd, requestedCwd) {
5867
- return requestedCwd ? path16.resolve(runtimeCwd, requestedCwd) : runtimeCwd;
5748
+ return requestedCwd ? path15.resolve(runtimeCwd, requestedCwd) : runtimeCwd;
5868
5749
  }
5869
5750
  function getForegroundControl(state, runId) {
5870
5751
  if (runId)
@@ -5896,7 +5777,7 @@ function nestedResolutionScopeForExecutor(deps) {
5896
5777
  };
5897
5778
  }
5898
5779
  function trustedSessionRootsForStatus(ctx, deps) {
5899
- let roots = deps.config.defaultSessionDir ? [path16.resolve(deps.expandTilde(deps.config.defaultSessionDir))] : [], parentSessionFile = ctx.sessionManager.getSessionFile() ?? null;
5780
+ let roots = deps.config.defaultSessionDir ? [path15.resolve(deps.expandTilde(deps.config.defaultSessionDir))] : [], parentSessionFile = ctx.sessionManager.getSessionFile() ?? null;
5900
5781
  return parentSessionFile && roots.push(deps.getSubagentSessionRoot(parentSessionFile)), [...new Set(roots)];
5901
5782
  }
5902
5783
  function reserveSubagentSpawns(input) {
@@ -6043,10 +5924,10 @@ function resolveForegroundResumeTarget(params, state) {
6043
5924
  let child = run.children[index];
6044
5925
  if (!child.sessionFile)
6045
5926
  throw new Error(`Foreground run '${run.runId}' child ${index} does not have a persisted session file to resume from.`);
6046
- if (path16.extname(child.sessionFile) !== ".jsonl")
5927
+ if (path15.extname(child.sessionFile) !== ".jsonl")
6047
5928
  throw new Error(`Foreground run '${run.runId}' child ${index} session file must be a .jsonl file: ${child.sessionFile}`);
6048
- let sessionFile = path16.resolve(child.sessionFile);
6049
- if (!fs16.existsSync(sessionFile))
5929
+ let sessionFile = path15.resolve(child.sessionFile);
5930
+ if (!fs15.existsSync(sessionFile))
6050
5931
  throw new Error(`Foreground run '${run.runId}' child ${index} session file does not exist: ${child.sessionFile}`);
6051
5932
  return { runId: run.runId, mode: run.mode, state: "complete", agent: child.agent, index, intercomTarget: resolveSubagentIntercomTarget(run.runId, child.agent, index), cwd: run.cwd, sessionFile };
6052
5933
  }
@@ -6101,7 +5982,7 @@ function resolveResumeTarget(params, state, options = {}) {
6101
5982
  function getAsyncInterruptTarget(state, runId, location, options = {}) {
6102
5983
  if (location?.asyncDir)
6103
5984
  return {
6104
- asyncId: location.resolvedId ?? runId ?? path16.basename(location.asyncDir),
5985
+ asyncId: location.resolvedId ?? runId ?? path15.basename(location.asyncDir),
6105
5986
  asyncDir: location.asyncDir
6106
5987
  };
6107
5988
  if (runId) {
@@ -6366,27 +6247,27 @@ function nestedRunAgent(run) {
6366
6247
  return run.agent ?? run.agents?.[0] ?? (run.steps?.length === 1 ? run.steps[0]?.agent : void 0);
6367
6248
  }
6368
6249
  function pathWithin(base, candidate) {
6369
- let resolvedBase = path16.resolve(base), resolvedCandidate = path16.resolve(candidate);
6370
- return resolvedCandidate === resolvedBase || resolvedCandidate.startsWith(`${resolvedBase}${path16.sep}`);
6250
+ let resolvedBase = path15.resolve(base), resolvedCandidate = path15.resolve(candidate);
6251
+ return resolvedCandidate === resolvedBase || resolvedCandidate.startsWith(`${resolvedBase}${path15.sep}`);
6371
6252
  }
6372
6253
  function validateNestedSessionFile(run, trustedSessionRoots) {
6373
6254
  let sessionFile = nestedRunSessionFile(run);
6374
6255
  if (!sessionFile)
6375
6256
  throw new Error(`Nested run '${run.id}' does not have a persisted session file to resume from.`);
6376
- if (path16.extname(sessionFile) !== ".jsonl")
6257
+ if (path15.extname(sessionFile) !== ".jsonl")
6377
6258
  throw new Error(`Nested run '${run.id}' session file must be a .jsonl file: ${sessionFile}`);
6378
- let resolved = path16.resolve(sessionFile);
6379
- if (!path16.isAbsolute(sessionFile))
6259
+ let resolved = path15.resolve(sessionFile);
6260
+ if (!path15.isAbsolute(sessionFile))
6380
6261
  throw new Error(`Nested run '${run.id}' session file must be absolute: ${sessionFile}`);
6381
- if (!fs16.existsSync(resolved))
6262
+ if (!fs15.existsSync(resolved))
6382
6263
  throw new Error(`Nested run '${run.id}' session file does not exist: ${sessionFile}`);
6383
- let stat = fs16.lstatSync(resolved);
6264
+ let stat = fs15.lstatSync(resolved);
6384
6265
  if (!stat.isFile() || stat.isSymbolicLink())
6385
6266
  throw new Error(`Nested run '${run.id}' session file is not a regular file: ${sessionFile}`);
6386
- let realSessionFile = fs16.realpathSync(resolved);
6387
- if (!trustedSessionRoots.filter((root) => fs16.existsSync(root)).map((root) => fs16.realpathSync(root)).some((root) => pathWithin(root, realSessionFile)))
6267
+ let realSessionFile = fs15.realpathSync(resolved);
6268
+ if (!trustedSessionRoots.filter((root) => fs15.existsSync(root)).map((root) => fs15.realpathSync(root)).some((root) => pathWithin(root, realSessionFile)))
6388
6269
  throw new Error(`Nested run '${run.id}' session file is outside trusted nested session roots: ${sessionFile}`);
6389
- if (!realSessionFile.split(path16.sep).includes(run.id))
6270
+ if (!realSessionFile.split(path15.sep).includes(run.id))
6390
6271
  throw new Error(`Nested run '${run.id}' session file is not under that nested run's session directory: ${sessionFile}`);
6391
6272
  return realSessionFile;
6392
6273
  }
@@ -6406,7 +6287,7 @@ function resolveNestedResumeTarget(match, trustedSessionRoots) {
6406
6287
  agent,
6407
6288
  index: 0,
6408
6289
  intercomTarget: resolveSubagentIntercomTarget(run.id, agent, 0),
6409
- cwd: asyncDir ? path16.dirname(asyncDir) : void 0,
6290
+ cwd: asyncDir ? path15.dirname(asyncDir) : void 0,
6410
6291
  sessionFile: validateNestedSessionFile(run, trustedSessionRoots)
6411
6292
  };
6412
6293
  }
@@ -6433,7 +6314,7 @@ function directNestedAsyncInterrupt(target) {
6433
6314
  let run = target.match.run, asyncDir = resolveNestedAsyncDir(target.match.rootRunId, run);
6434
6315
  if (!asyncDir)
6435
6316
  return;
6436
- let status = reconcileAsyncRun(asyncDir, { resultsDir: path16.join(RESULTS_DIR, "nested", target.match.rootRunId) }).status, pid = typeof status?.pid == "number" && status.pid > 0 ? status.pid : run.pid;
6317
+ let status = reconcileAsyncRun(asyncDir, { resultsDir: path15.join(RESULTS_DIR, "nested", target.match.rootRunId) }).status, pid = typeof status?.pid == "number" && status.pid > 0 ? status.pid : run.pid;
6437
6318
  if (!(!status || status.state !== "running" || typeof pid != "number" || pid <= 0))
6438
6319
  try {
6439
6320
  return deliverInterruptRequest({ asyncDir, pid, source: "nested-interrupt" }), { content: [{ type: "text", text: `Interrupt requested for nested async run ${run.id}.` }], details: { mode: "management", results: [] } };
@@ -6446,7 +6327,7 @@ async function directNestedAsyncSteer(input) {
6446
6327
  let run = input.target.match.run, asyncDir = resolveNestedAsyncDir(input.target.match.rootRunId, run);
6447
6328
  if (!asyncDir)
6448
6329
  return;
6449
- let status = reconcileAsyncRun(asyncDir, { resultsDir: path16.join(RESULTS_DIR, "nested", input.target.match.rootRunId) }).status;
6330
+ let status = reconcileAsyncRun(asyncDir, { resultsDir: path15.join(RESULTS_DIR, "nested", input.target.match.rootRunId) }).status;
6450
6331
  if (!status || status.state !== "running" && status.state !== "queued")
6451
6332
  return;
6452
6333
  let steps = status.steps ?? [];
@@ -6540,7 +6421,7 @@ async function resumeAsyncRun(input) {
6540
6421
  if (resolved.match.run.state === "running" || resolved.match.run.state === "queued")
6541
6422
  return resumeLiveNestedRun({ target: resolved, message: followUp });
6542
6423
  let trustedSessionRoots = [
6543
- ...input.deps.config.defaultSessionDir ? [path16.resolve(input.deps.expandTilde(input.deps.config.defaultSessionDir))] : [],
6424
+ ...input.deps.config.defaultSessionDir ? [path15.resolve(input.deps.expandTilde(input.deps.config.defaultSessionDir))] : [],
6544
6425
  ...parentSessionFile ? [input.deps.getSubagentSessionRoot(parentSessionFile)] : []
6545
6426
  ];
6546
6427
  target = resolveNestedResumeTarget(resolved, trustedSessionRoots);
@@ -6605,7 +6486,7 @@ ${followUp}`, 500, { source: "async-resume", runId: target.runId, agent: target.
6605
6486
  goal,
6606
6487
  attachRoot: {
6607
6488
  runId: target.runId,
6608
- asyncDir: target.asyncDir ?? path16.join(ASYNC_DIR, target.runId),
6489
+ asyncDir: target.asyncDir ?? path15.join(ASYNC_DIR, target.runId),
6609
6490
  resultPath: resolveAsyncRootResultPath(RESULTS_DIR, target.runId),
6610
6491
  index: target.index,
6611
6492
  agent: target.agent,
@@ -6651,26 +6532,36 @@ ${followUp}`, 500, { source: "async-resume", runId: target.runId, agent: target.
6651
6532
  return { content: [{ type: "text", text: formatAsyncStartedMessage(lines2.join(`
6652
6533
  `)) }], details: result3.details };
6653
6534
  }
6654
- let runId = randomUUID4().slice(0, 8), artifactConfig = recoveryDescriptor?.artifactConfig ?? { ...DEFAULT_ARTIFACT_CONFIG, enabled: input.params.artifacts !== !1 }, artifactsDir = recoveryDescriptor?.artifactsDir ?? getArtifactsDir(parentSessionFile, effectiveCwd), availableModels = input.ctx.modelRegistry.getAvailable().map(toModelInfo), recoverySpec;
6535
+ let runId = randomUUID4().slice(0, 8), artifactConfig = recoveryDescriptor?.artifactConfig ?? { ...DEFAULT_ARTIFACT_CONFIG, enabled: input.params.artifacts !== !1 }, artifactsDir = recoveryDescriptor?.artifactsDir ?? getArtifactsDir(parentSessionFile, effectiveCwd), availableModels = input.ctx.modelRegistry.getAvailable().map(toModelInfo), restoredAcceptance;
6536
+ if (recoveryDescriptor?.acceptance !== void 0 && input.params.acceptance === void 0)
6537
+ try {
6538
+ restoredAcceptance = restorePersistedAcceptance(recoveryDescriptor.acceptance, "recoveryDescriptor.acceptance");
6539
+ } catch (error) {
6540
+ return { content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }], isError: !0, details: { mode: "management", results: [] } };
6541
+ }
6542
+ let recoverySpec;
6655
6543
  try {
6544
+ let recoverySelection = recoveryDescriptor?.modelSelection ?? target.modelSelection, recoveryIsExplicitModel = recoverySelection?.kind === "model";
6656
6545
  recoverySpec = normalizeChildSpec({
6657
6546
  task: buildRevivedAsyncTask(target, followUp),
6658
6547
  description: recoveryDescriptor?.description ?? target.description ?? target.agent,
6659
6548
  permissions: recoveryDescriptor?.permissions ?? target.permissions ?? "read-only",
6660
- model: recoveryDescriptor?.model ?? target.model,
6661
- tier: input.params.tier ?? recoveryDescriptor?.tier ?? recoveryDescriptor?.modelSelection?.tier,
6662
- modelSelection: recoveryDescriptor?.modelSelection,
6549
+ model: recoveryIsExplicitModel ? recoverySelection.model ?? recoveryDescriptor?.model ?? target.model : void 0,
6550
+ tier: recoveryIsExplicitModel ? void 0 : input.params.tier ?? recoverySelection?.tier ?? recoveryDescriptor?.tier,
6551
+ thinking: recoveryIsExplicitModel ? recoveryDescriptor?.thinking ?? target.thinking : void 0,
6552
+ modelSelection: recoverySelection,
6663
6553
  skill: recoveryDescriptor?.skills,
6664
6554
  cwd: effectiveCwd,
6665
6555
  output: recoveryDescriptor?.outputPath,
6666
6556
  outputMode: recoveryDescriptor?.outputMode,
6667
- acceptance: input.params.acceptance ?? recoveryDescriptor?.acceptance,
6557
+ acceptance: input.params.acceptance,
6668
6558
  toolBudget: recoveryDescriptor?.initialToolBudget
6669
6559
  }, {
6670
6560
  parentMode: snapshotParentPermissionMode(input.deps.state.currentSessionId),
6671
6561
  runId,
6672
6562
  index: 0,
6673
- childId: recoveryDescriptor?.childId ?? target.childId ?? `${runId}-0`
6563
+ childId: recoveryDescriptor?.childId ?? target.childId ?? `${runId}-0`,
6564
+ resolvedModelIsRuntime: !recoveryIsExplicitModel && !!(recoveryDescriptor?.model ?? target.model)
6674
6565
  });
6675
6566
  } catch (error) {
6676
6567
  return { content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }], isError: !0, details: { mode: "management", results: [] } };
@@ -6716,7 +6607,7 @@ ${followUp}`, 500, { source: "async-resume", runId: target.runId, agent: target.
6716
6607
  output: recoveryDescriptor?.outputPath,
6717
6608
  outputMode: recoveryDescriptor?.outputMode,
6718
6609
  ...recoveryDescriptor?.skills ? { skills: [...recoveryDescriptor.skills] } : {},
6719
- ...recoveryDescriptor?.acceptance !== void 0 && input.params.acceptance === void 0 ? { acceptance: recoveryDescriptor.acceptance } : {},
6610
+ ...restoredAcceptance ? { restoredAcceptance } : {},
6720
6611
  ...input.params.timeoutMs !== void 0 ? { timeoutMs: input.params.timeoutMs } : {},
6721
6612
  ...input.absoluteDeadlineAt !== void 0 ? { absoluteDeadlineAt: input.absoluteDeadlineAt } : {},
6722
6613
  ...input.params.turnBudget !== void 0 ? { turnBudget: input.params.turnBudget } : {},
@@ -6984,6 +6875,7 @@ function internalizePromptDrivenChildren(params, options) {
6984
6875
  cwd: params.cwd,
6985
6876
  model: params.model,
6986
6877
  tier: params.tier,
6878
+ thinking: params.thinking,
6987
6879
  skill: params.skill,
6988
6880
  output: params.output,
6989
6881
  outputMode: params.outputMode,
@@ -7328,13 +7220,21 @@ function runAsyncPath(data, deps) {
7328
7220
  isError: !0,
7329
7221
  details: { mode: "single", results: [] }
7330
7222
  };
7331
- let rawOutput = params.output !== void 0 ? params.output : a.output, effectiveOutput = normalizeSingleOutputOverride(rawOutput, a.output), effectiveOutputMode = params.outputMode ?? "inline", normalizedSkills = normalizeSkillInput(params.skill), skills = normalizedSkills === !1 ? [] : normalizedSkills, maxSubagentDepth = resolveChildMaxSubagentDepth(currentMaxSubagentDepth, a.maxSubagentDepth), modelOverride = resolveRequiredTierModel(params.tier, availableModels, currentProvider), spec = normalizeChildSpec({
7223
+ let rawOutput = params.output !== void 0 ? params.output : a.output, effectiveOutput = normalizeSingleOutputOverride(rawOutput, a.output), effectiveOutputMode = params.outputMode ?? "inline", normalizedSkills = normalizeSkillInput(params.skill), skills = normalizedSkills === !1 ? [] : normalizedSkills, maxSubagentDepth = resolveChildMaxSubagentDepth(currentMaxSubagentDepth, a.maxSubagentDepth), modelSelection = captureModelSelection({ model: params.model, tier: params.tier }), modelOverride = resolveExecutableChildModel({
7224
+ modelSelection,
7225
+ model: params.model,
7226
+ tier: params.tier,
7227
+ thinking: params.thinking,
7228
+ availableModels,
7229
+ preferredProvider: currentProvider
7230
+ }), spec = normalizeChildSpec({
7332
7231
  task: shouldForkAgent(contextPolicy, params.agent) ? wrapForkTask(params.task ?? "") : params.task ?? "",
7333
7232
  description: params.description,
7334
7233
  permissions: params.permissions,
7335
- model: modelOverride,
7234
+ model: params.model,
7336
7235
  tier: params.tier,
7337
- modelSelection: captureModelSelection({ tier: params.tier }),
7236
+ thinking: params.thinking,
7237
+ modelSelection,
7338
7238
  skill: params.skill,
7339
7239
  cwd: effectiveCwd,
7340
7240
  output: effectiveOutput,
@@ -7520,7 +7420,7 @@ function buildParallelWorktreeTaskCwdError(tasks, sharedCwd) {
7520
7420
  return formatWorktreeTaskCwdConflict(conflict, sharedCwd);
7521
7421
  }
7522
7422
  function resolveSingleRunOutputBaseDir(deps, artifactsDir, runId) {
7523
- return deps.config.singleRunOutputBaseDir ? path16.resolve(deps.expandTilde(deps.config.singleRunOutputBaseDir)) : path16.join(artifactsDir, "outputs", runId);
7423
+ return deps.config.singleRunOutputBaseDir ? path15.resolve(deps.expandTilde(deps.config.singleRunOutputBaseDir)) : path15.join(artifactsDir, "outputs", runId);
7524
7424
  }
7525
7425
  function buildChainWorktreeTaskCwdError(chain, sharedCwd) {
7526
7426
  for (let stepIndex = 0; stepIndex < chain.length; stepIndex++) {
@@ -7540,7 +7440,7 @@ function resolveParallelTaskCwd(task, paramsCwd, worktreeSetup, index) {
7540
7440
  function buildParallelWorktreeSuffix(worktreeSetup, artifactsDir, tasks) {
7541
7441
  if (!worktreeSetup)
7542
7442
  return "";
7543
- let diffsDir = path16.join(artifactsDir, "worktree-diffs"), diffs = diffWorktrees(worktreeSetup, tasks.map((task) => task.agent), diffsDir);
7443
+ let diffsDir = path15.join(artifactsDir, "worktree-diffs"), diffs = diffWorktrees(worktreeSetup, tasks.map((task) => task.agent), diffsDir);
7544
7444
  return formatWorktreeDiffSummary(diffs);
7545
7445
  }
7546
7446
  function findDuplicateParallelOutputPath(input) {
@@ -7563,13 +7463,16 @@ async function runForegroundParallelTasks(input) {
7563
7463
  input.sessionFileForTask(input.tasks[i].agent, i, input.modelOverrides[i]);
7564
7464
  return mapConcurrent(input.tasks, input.concurrencyLimit, async (task, index) => {
7565
7465
  let behavior = input.behaviors[index], effectiveSkills = behavior?.skills, taskCwd = resolveParallelTaskCwd(task, input.paramsCwd, input.worktreeSetup, index), readInstructions = behavior ? buildChainInstructions({ ...behavior, output: !1, progress: !1 }, taskCwd, !1) : { prefix: "", suffix: "" }, progressInstructions = behavior ? buildChainInstructions({ ...behavior, output: !1, reads: !1 }, input.progressDir, index === input.firstProgressIndex) : { prefix: "", suffix: "" }, outputPath = resolveSingleOutputPath(behavior?.output, input.ctx.cwd, taskCwd, input.outputBaseDir), agentConfig = input.agents.find((agent) => agent.name === task.agent), taskText = injectSingleOutputInstruction(`${readInstructions.prefix}${input.taskTexts[index]}${progressInstructions.suffix}`, outputPath, agentConfig), interruptController = new AbortController();
7566
- return input.foregroundControl && (input.foregroundControl.currentAgent = task.description || task.agent, input.foregroundControl.currentChildId = task.agent, input.foregroundControl.currentIndex = index, input.foregroundControl.currentActivityState = void 0, input.foregroundControl.updatedAt = Date.now(), input.foregroundControl.interrupt = () => interruptController.signal.aborted ? !1 : (interruptController.abort(), input.foregroundControl.currentActivityState = void 0, input.foregroundControl.updatedAt = Date.now(), !0)), runSync(input.ctx.cwd, normalizeChildSpec({
7466
+ input.foregroundControl && (input.foregroundControl.currentAgent = task.description || task.agent, input.foregroundControl.currentChildId = task.agent, input.foregroundControl.currentIndex = index, input.foregroundControl.currentActivityState = void 0, input.foregroundControl.updatedAt = Date.now(), input.foregroundControl.interrupt = () => interruptController.signal.aborted ? !1 : (interruptController.abort(), input.foregroundControl.currentActivityState = void 0, input.foregroundControl.updatedAt = Date.now(), !0));
7467
+ let modelSelection = input.modelSelections[index] ?? captureModelSelection({ model: task.model, tier: task.tier });
7468
+ return runSync(input.ctx.cwd, normalizeChildSpec({
7567
7469
  task: taskText,
7568
7470
  description: task.description,
7569
7471
  permissions: task.permissions,
7570
- model: input.modelOverrides[index] ?? task.model,
7472
+ model: task.model,
7571
7473
  tier: task.tier,
7572
- modelSelection: input.modelSelections[index] ?? captureModelSelection({ tier: task.tier }),
7474
+ thinking: task.thinking,
7475
+ modelSelection,
7573
7476
  skill: task.skill,
7574
7477
  cwd: taskCwd,
7575
7478
  output: task.output,
@@ -7674,7 +7577,14 @@ async function runParallelPath(data, deps) {
7674
7577
  ...task.reads !== void 0 && task.reads !== !0 ? { reads: task.reads } : {},
7675
7578
  ...task.progress !== void 0 ? { progress: task.progress } : {},
7676
7579
  ...skillOverrides[index] !== void 0 ? { skills: skillOverrides[index] } : {}
7677
- })), modelOverrides = tasks.map((task, i) => resolveRequiredTierModel(task.tier, availableModels, currentProvider)), modelSelections = tasks.map((task) => captureModelSelection({ tier: task.tier }));
7580
+ })), modelSelections = tasks.map((task) => captureModelSelection({ model: task.model, tier: task.tier })), modelOverrides = tasks.map((task, index) => resolveExecutableChildModel({
7581
+ modelSelection: modelSelections[index],
7582
+ model: task.model,
7583
+ tier: task.tier,
7584
+ thinking: task.thinking,
7585
+ availableModels,
7586
+ preferredProvider: currentProvider
7587
+ }));
7678
7588
  if (params.clarify === !0 && ctx.hasUI) {
7679
7589
  let behaviors2 = agentConfigs.map((_c, i) => resolveStepBehavior(behaviorOverrides[i])), availableSkills = discoverAvailableSkills(effectiveCwd), result2 = await ctx.ui.custom((tui, theme, _kb, done) => new ChainClarifyComponent(tui, theme, agentConfigs, taskTexts, "", void 0, behaviors2, availableModels, currentProvider, availableSkills, done, "parallel"), { overlay: !0, overlayOptions: { anchor: "center", width: 84, maxHeight: "80%" } });
7680
7590
  if (!result2 || !result2.confirmed)
@@ -7750,7 +7660,7 @@ async function runParallelPath(data, deps) {
7750
7660
  if (errorResult)
7751
7661
  return errorResult;
7752
7662
  try {
7753
- let outputBaseDir = path16.join(artifactsDir, "outputs", runId), duplicateOutputError = findDuplicateParallelOutputPath({
7663
+ let outputBaseDir = path15.join(artifactsDir, "outputs", runId), duplicateOutputError = findDuplicateParallelOutputPath({
7754
7664
  tasks,
7755
7665
  behaviors,
7756
7666
  paramsCwd: effectiveCwd,
@@ -7765,7 +7675,7 @@ async function runParallelPath(data, deps) {
7765
7675
  if (validationError)
7766
7676
  return buildParallelModeError(validationError);
7767
7677
  }
7768
- let parallelProgressPrecreated = firstProgressIndex !== -1, parallelProgressDir = path16.join(artifactsDir, "progress", runId);
7678
+ let parallelProgressPrecreated = firstProgressIndex !== -1, parallelProgressDir = path15.join(artifactsDir, "progress", runId);
7769
7679
  parallelProgressPrecreated && writeInitialProgressFile(parallelProgressDir);
7770
7680
  for (let i = 0; i < taskTexts.length; i++)
7771
7681
  shouldForkAgent(contextPolicy, tasks[i].agent) && (taskTexts[i] = wrapForkTask(taskTexts[i]));
@@ -7883,7 +7793,9 @@ async function runSinglePath(data, deps) {
7883
7793
  task: params.task,
7884
7794
  description: params.description,
7885
7795
  permissions: params.permissions,
7796
+ model: params.model,
7886
7797
  tier: params.tier,
7798
+ thinking: params.thinking,
7887
7799
  skill: params.skill,
7888
7800
  cwd: effectiveCwd,
7889
7801
  output: params.output,
@@ -7912,7 +7824,14 @@ async function runSinglePath(data, deps) {
7912
7824
  }, effectiveToolBudget = resolveEffectiveToolBudget({ runBudget: data.toolBudget, agentBudget: spec.toolBudget, configBudget: data.configToolBudget });
7913
7825
  if (effectiveToolBudget.error)
7914
7826
  return toExecutionErrorResult(params, new Error(effectiveToolBudget.error));
7915
- let currentProvider = ctx.model?.provider, availableModels = ctx.modelRegistry.getAvailable().map(toModelInfo), task = params.task ?? "", modelOverride = resolveRequiredTierModel(params.tier, availableModels, currentProvider), skillOverride = normalizeSkillInput(params.skill), rawOutput = params.output !== void 0 ? params.output : agentConfig.output, effectiveOutput = normalizeSingleOutputOverride(rawOutput, agentConfig.output), effectiveOutputMode = params.outputMode ?? "inline", currentMaxSubagentDepth = resolveCurrentMaxSubagentDepth(deps.config.maxSubagentDepth), maxSubagentDepth = resolveChildMaxSubagentDepth(currentMaxSubagentDepth, agentConfig.maxSubagentDepth);
7827
+ let currentProvider = ctx.model?.provider, availableModels = ctx.modelRegistry.getAvailable().map(toModelInfo), task = params.task ?? "", modelSelection = captureModelSelection({ model: params.model, tier: params.tier }), modelOverride = resolveExecutableChildModel({
7828
+ modelSelection,
7829
+ model: params.model,
7830
+ tier: params.tier,
7831
+ thinking: params.thinking,
7832
+ availableModels,
7833
+ preferredProvider: currentProvider
7834
+ }), skillOverride = normalizeSkillInput(params.skill), rawOutput = params.output !== void 0 ? params.output : agentConfig.output, effectiveOutput = normalizeSingleOutputOverride(rawOutput, agentConfig.output), effectiveOutputMode = params.outputMode ?? "inline", currentMaxSubagentDepth = resolveCurrentMaxSubagentDepth(deps.config.maxSubagentDepth), maxSubagentDepth = resolveChildMaxSubagentDepth(currentMaxSubagentDepth, agentConfig.maxSubagentDepth);
7916
7835
  if (params.clarify === !0 && ctx.hasUI) {
7917
7836
  let behavior = resolveStepBehavior({ output: effectiveOutput, skills: skillOverride }), availableSkills = discoverAvailableSkills(effectiveCwd), result2 = await ctx.ui.custom((tui, theme, _kb, done) => new ChainClarifyComponent(tui, theme, [agentConfig], [task], task, void 0, [behavior], availableModels, currentProvider, availableSkills, done, "single"), { overlay: !0, overlayOptions: { anchor: "center", width: 84, maxHeight: "80%" } });
7918
7837
  if (!result2 || !result2.confirmed)
@@ -8174,7 +8093,7 @@ function createSubagentExecutor(deps) {
8174
8093
  let targetRunId = paramsWithResolvedCwd.runId ?? paramsWithResolvedCwd.id;
8175
8094
  if (paramsWithResolvedCwd.dir)
8176
8095
  try {
8177
- let location = resolveAsyncRunLocation(paramsWithResolvedCwd, ASYNC_DIR, RESULTS_DIR), runId2 = location.resolvedId ?? targetRunId ?? path16.basename(location.asyncDir ?? paramsWithResolvedCwd.dir);
8096
+ let location = resolveAsyncRunLocation(paramsWithResolvedCwd, ASYNC_DIR, RESULTS_DIR), runId2 = location.resolvedId ?? targetRunId ?? path15.basename(location.asyncDir ?? paramsWithResolvedCwd.dir);
8178
8097
  return steerAsyncRun({ state: deps.state, runId: runId2, message, index: paramsWithResolvedCwd.index, kill: deps.kill, location, signal, recover: ({ absoluteDeadlineAt, ...limits }) => resumeAsyncRun({ params: { ...limits, action: "resume", id: runId2, message }, requestCwd, ctx, deps, absoluteDeadlineAt }) });
8179
8098
  } catch (error) {
8180
8099
  return { content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }], isError: !0, details: { mode: "management", results: [] } };
@@ -8202,7 +8121,7 @@ function createSubagentExecutor(deps) {
8202
8121
  if (paramsWithResolvedCwd.dir)
8203
8122
  try {
8204
8123
  let location = resolveAsyncRunLocation(paramsWithResolvedCwd, ASYNC_DIR, RESULTS_DIR);
8205
- return stopAsyncRun(deps.state, location.resolvedId ?? targetRunId ?? path16.basename(location.asyncDir ?? paramsWithResolvedCwd.dir), deps.kill, location);
8124
+ return stopAsyncRun(deps.state, location.resolvedId ?? targetRunId ?? path15.basename(location.asyncDir ?? paramsWithResolvedCwd.dir), deps.kill, location);
8206
8125
  } catch (error) {
8207
8126
  return { content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }], isError: !0, details: { mode: "management", results: [] } };
8208
8127
  }
@@ -8328,18 +8247,18 @@ function createSubagentExecutor(deps) {
8328
8247
  enabled: effectiveParams.artifacts !== !1
8329
8248
  }, artifactsDir = getArtifactsDir(parentSessionFile, effectiveCwd), sessionRoot;
8330
8249
  if (effectiveParams.sessionDir)
8331
- sessionRoot = path16.resolve(deps.expandTilde(effectiveParams.sessionDir));
8250
+ sessionRoot = path15.resolve(deps.expandTilde(effectiveParams.sessionDir));
8332
8251
  else {
8333
- let baseSessionRoot = deps.config.defaultSessionDir ? path16.resolve(deps.expandTilde(deps.config.defaultSessionDir)) : deps.getSubagentSessionRoot(parentSessionFile);
8334
- sessionRoot = path16.join(baseSessionRoot, runId);
8252
+ let baseSessionRoot = deps.config.defaultSessionDir ? path15.resolve(deps.expandTilde(deps.config.defaultSessionDir)) : deps.getSubagentSessionRoot(parentSessionFile);
8253
+ sessionRoot = path15.join(baseSessionRoot, runId);
8335
8254
  }
8336
8255
  try {
8337
- fs16.mkdirSync(sessionRoot, { recursive: !0 });
8256
+ fs15.mkdirSync(sessionRoot, { recursive: !0 });
8338
8257
  } catch (error) {
8339
8258
  let message = error instanceof Error ? error.message : String(error);
8340
8259
  return toExecutionErrorResult(effectiveParams, new Error(`Failed to create session directory '${sessionRoot}': ${message}`));
8341
8260
  }
8342
- let sessionDirForIndex = (idx) => path16.join(sessionRoot, `run-${idx ?? 0}`), forkSessionFileForTask = (agentName, idx = 0, modelOverride) => {
8261
+ let sessionDirForIndex = (idx) => path15.join(sessionRoot, `run-${idx ?? 0}`), forkSessionFileForTask = (agentName, idx = 0, modelOverride) => {
8343
8262
  if (shouldForkAgent(contextPolicy, agentName))
8344
8263
  return prepareForkThinking(agentName, idx, modelOverride), forkSessionFileForIndex(idx);
8345
8264
  }, forkThinkingOverrideForTask = (agentName, idx = 0, modelOverride) => {
@@ -8348,7 +8267,7 @@ function createSubagentExecutor(deps) {
8348
8267
  prepareForkThinking(agentName, idx, modelOverride);
8349
8268
  let override = forkThinkingOverrideForIndex(idx);
8350
8269
  return override === "off" && forkThinkingDowngrades.set(idx, agentName), override;
8351
- }, childSessionFileForTask = (agentName, idx, modelOverride) => forkSessionFileForTask(agentName, idx, modelOverride) ?? path16.join(sessionDirForIndex(idx), "session.jsonl"), childSessionFileForIndex = (idx) => path16.join(sessionDirForIndex(idx), "session.jsonl");
8270
+ }, childSessionFileForTask = (agentName, idx, modelOverride) => forkSessionFileForTask(agentName, idx, modelOverride) ?? path15.join(sessionDirForIndex(idx), "session.jsonl"), childSessionFileForIndex = (idx) => path15.join(sessionDirForIndex(idx), "session.jsonl");
8352
8271
  try {
8353
8272
  effectiveParams.clarify === !0 && ctx.hasUI || preflightForkSessionsForStaticTasks(effectiveParams, contextPolicy, forkSessionFileForTask, deps.config.chain?.dynamicFanout?.maxItems);
8354
8273
  } catch (error) {