wave-agent-sdk 0.19.5 → 0.19.7

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 (371) hide show
  1. package/dist/agent.d.ts +30 -14
  2. package/dist/agent.js +70 -56
  3. package/dist/constants/goalPrompts.d.ts +0 -1
  4. package/dist/constants/subagents.d.ts +0 -1
  5. package/dist/constants/toolLimits.d.ts +0 -1
  6. package/dist/constants/tools.d.ts +0 -1
  7. package/dist/core/plugin.d.ts +0 -1
  8. package/dist/core/session.d.ts +0 -1
  9. package/dist/index.d.ts +0 -1
  10. package/dist/managers/MemoryRuleManager.d.ts +0 -1
  11. package/dist/managers/aiManager.d.ts +15 -2
  12. package/dist/managers/aiManager.js +65 -11
  13. package/dist/managers/backgroundTaskManager.d.ts +1 -3
  14. package/dist/managers/backgroundTaskManager.js +20 -22
  15. package/dist/managers/bangManager.d.ts +0 -1
  16. package/dist/managers/bangManager.js +2 -1
  17. package/dist/managers/cronManager.d.ts +0 -1
  18. package/dist/managers/foregroundTaskManager.d.ts +0 -1
  19. package/dist/managers/forkedAgentManager.d.ts +0 -1
  20. package/dist/managers/goalManager.d.ts +0 -1
  21. package/dist/managers/hookManager.d.ts +0 -1
  22. package/dist/managers/liveConfigManager.d.ts +0 -1
  23. package/dist/managers/lspManager.d.ts +0 -1
  24. package/dist/managers/mcpManager.d.ts +0 -1
  25. package/dist/managers/messageManager.d.ts +7 -1
  26. package/dist/managers/messageManager.js +64 -5
  27. package/dist/managers/messageQueue.d.ts +25 -2
  28. package/dist/managers/messageQueue.js +53 -1
  29. package/dist/managers/permissionManager.d.ts +0 -1
  30. package/dist/managers/permissionManager.js +3 -3
  31. package/dist/managers/planManager.d.ts +0 -1
  32. package/dist/managers/pluginManager.d.ts +0 -1
  33. package/dist/managers/pluginScopeManager.d.ts +0 -1
  34. package/dist/managers/reversionManager.d.ts +0 -1
  35. package/dist/managers/skillManager.d.ts +0 -1
  36. package/dist/managers/slashCommandManager.d.ts +0 -1
  37. package/dist/managers/subagentManager.d.ts +0 -3
  38. package/dist/managers/subagentManager.js +15 -14
  39. package/dist/managers/toolManager.d.ts +0 -1
  40. package/dist/managers/workflowManager.d.ts +1 -2
  41. package/dist/managers/workflowManager.js +4 -4
  42. package/dist/prompts/autoMemory.d.ts +0 -1
  43. package/dist/prompts/autoMemoryExtraction.d.ts +0 -1
  44. package/dist/prompts/index.d.ts +3 -2
  45. package/dist/prompts/index.js +2 -4
  46. package/dist/prompts/planModeReminders.d.ts +0 -1
  47. package/dist/services/GitService.d.ts +0 -1
  48. package/dist/services/MarketplaceService.d.ts +0 -1
  49. package/dist/services/MemoryRuleService.d.ts +0 -1
  50. package/dist/services/aiService.d.ts +0 -1
  51. package/dist/services/authService.d.ts +0 -1
  52. package/dist/services/autoMemoryService.d.ts +0 -1
  53. package/dist/services/configurationService.d.ts +0 -1
  54. package/dist/services/fileWatcher.d.ts +0 -1
  55. package/dist/services/hook.d.ts +0 -1
  56. package/dist/services/hook.js +6 -0
  57. package/dist/services/initializationService.d.ts +0 -1
  58. package/dist/services/interactionService.d.ts +0 -1
  59. package/dist/services/interactionService.js +10 -0
  60. package/dist/services/jsonlHandler.d.ts +0 -1
  61. package/dist/services/memory.d.ts +0 -1
  62. package/dist/services/pluginLoader.d.ts +0 -1
  63. package/dist/services/remoteSettingsService.d.ts +0 -1
  64. package/dist/services/reversionService.d.ts +0 -1
  65. package/dist/services/session.d.ts +0 -1
  66. package/dist/services/taskManager.d.ts +0 -1
  67. package/dist/services/taskManager.js +8 -1
  68. package/dist/telemetry/events.d.ts +0 -1
  69. package/dist/telemetry/instrumentation.d.ts +0 -1
  70. package/dist/telemetry/sessionTracing.d.ts +0 -1
  71. package/dist/tools/agentTool.d.ts +0 -1
  72. package/dist/tools/askUserQuestion.d.ts +0 -1
  73. package/dist/tools/bashTool.d.ts +0 -1
  74. package/dist/tools/bashTool.js +7 -5
  75. package/dist/tools/buildTool.d.ts +0 -1
  76. package/dist/tools/cronCreateTool.d.ts +0 -1
  77. package/dist/tools/cronDeleteTool.d.ts +0 -1
  78. package/dist/tools/cronListTool.d.ts +0 -1
  79. package/dist/tools/editTool.d.ts +0 -1
  80. package/dist/tools/enterPlanMode.d.ts +0 -1
  81. package/dist/tools/enterWorktreeTool.d.ts +0 -1
  82. package/dist/tools/enterWorktreeTool.js +3 -8
  83. package/dist/tools/exitPlanMode.d.ts +0 -1
  84. package/dist/tools/exitWorktreeTool.d.ts +0 -1
  85. package/dist/tools/exitWorktreeTool.js +5 -8
  86. package/dist/tools/globTool.d.ts +0 -1
  87. package/dist/tools/grepTool.d.ts +0 -1
  88. package/dist/tools/lspTool.d.ts +0 -1
  89. package/dist/tools/readTool.d.ts +0 -1
  90. package/dist/tools/skillTool.d.ts +0 -1
  91. package/dist/tools/taskManagementTools.d.ts +0 -1
  92. package/dist/tools/taskStopTool.d.ts +0 -1
  93. package/dist/tools/types.d.ts +0 -1
  94. package/dist/tools/webFetchTool.d.ts +0 -1
  95. package/dist/tools/workflowTool.d.ts +0 -1
  96. package/dist/tools/writeTool.d.ts +0 -1
  97. package/dist/types/agent.d.ts +0 -1
  98. package/dist/types/auth.d.ts +0 -1
  99. package/dist/types/commands.d.ts +0 -1
  100. package/dist/types/config.d.ts +0 -1
  101. package/dist/types/configuration.d.ts +0 -1
  102. package/dist/types/core.d.ts +0 -1
  103. package/dist/types/cron.d.ts +0 -1
  104. package/dist/types/environment.d.ts +0 -1
  105. package/dist/types/fileSearch.d.ts +0 -1
  106. package/dist/types/history.d.ts +0 -1
  107. package/dist/types/hooks.d.ts +2 -1
  108. package/dist/types/index.d.ts +0 -1
  109. package/dist/types/lsp.d.ts +0 -1
  110. package/dist/types/marketplace.d.ts +0 -1
  111. package/dist/types/mcp.d.ts +0 -1
  112. package/dist/types/memoryRule.d.ts +0 -1
  113. package/dist/types/messaging.d.ts +2 -1
  114. package/dist/types/permissions.d.ts +0 -1
  115. package/dist/types/plugins.d.ts +0 -1
  116. package/dist/types/processes.d.ts +0 -1
  117. package/dist/types/reversion.d.ts +0 -1
  118. package/dist/types/session.d.ts +0 -1
  119. package/dist/types/skills.d.ts +0 -1
  120. package/dist/types/tasks.d.ts +0 -1
  121. package/dist/types/telemetry.d.ts +0 -1
  122. package/dist/types/tools.d.ts +0 -1
  123. package/dist/types/workflow.d.ts +0 -1
  124. package/dist/utils/abortUtils.d.ts +0 -1
  125. package/dist/utils/atomicWrite.d.ts +0 -1
  126. package/dist/utils/bashParser.d.ts +0 -1
  127. package/dist/utils/cacheControlUtils.d.ts +0 -1
  128. package/dist/utils/commandArgumentParser.d.ts +0 -1
  129. package/dist/utils/commandPathResolver.d.ts +0 -1
  130. package/dist/utils/configPaths.d.ts +0 -1
  131. package/dist/utils/configValidator.d.ts +0 -1
  132. package/dist/utils/constants.d.ts +0 -1
  133. package/dist/utils/container.d.ts +0 -1
  134. package/dist/utils/containerSetup.d.ts +0 -1
  135. package/dist/utils/containerSetup.js +3 -3
  136. package/dist/utils/convertMessagesForAPI.d.ts +0 -1
  137. package/dist/utils/cronTasks.d.ts +0 -1
  138. package/dist/utils/cronTasksLock.d.ts +0 -1
  139. package/dist/utils/cronToHuman.d.ts +0 -1
  140. package/dist/utils/customCommands.d.ts +0 -1
  141. package/dist/utils/editUtils.d.ts +0 -1
  142. package/dist/utils/fileFormat.d.ts +0 -1
  143. package/dist/utils/fileSearch.d.ts +0 -1
  144. package/dist/utils/fileUtils.d.ts +0 -1
  145. package/dist/utils/gitUtils.d.ts +0 -1
  146. package/dist/utils/globalLogger.d.ts +0 -1
  147. package/dist/utils/groupMessagesByApiRound.d.ts +0 -1
  148. package/dist/utils/hookMatcher.d.ts +0 -1
  149. package/dist/utils/markdownParser.d.ts +0 -1
  150. package/dist/utils/mcpUtils.d.ts +0 -1
  151. package/dist/utils/messageOperations.d.ts +0 -1
  152. package/dist/utils/modelCapabilities.d.ts +0 -1
  153. package/dist/utils/nameGenerator.d.ts +0 -1
  154. package/dist/utils/notificationXml.d.ts +0 -1
  155. package/dist/utils/openaiClient.d.ts +0 -1
  156. package/dist/utils/parseCronExpression.d.ts +0 -1
  157. package/dist/utils/path.d.ts +0 -1
  158. package/dist/utils/pathEncoder.d.ts +0 -1
  159. package/dist/utils/pathSafety.d.ts +0 -1
  160. package/dist/utils/promptHistory.d.ts +0 -1
  161. package/dist/utils/ripgrep.d.ts +0 -1
  162. package/dist/utils/shellResolver.d.ts +0 -1
  163. package/dist/utils/shellResolver.js +156 -7
  164. package/dist/utils/skillParser.d.ts +0 -1
  165. package/dist/utils/stringUtils.d.ts +0 -1
  166. package/dist/utils/subagentParser.d.ts +0 -1
  167. package/dist/utils/taskReminder.d.ts +0 -1
  168. package/dist/utils/tokenCalculation.d.ts +0 -1
  169. package/dist/utils/tokenEstimate.d.ts +0 -1
  170. package/dist/utils/toolResultStorage.d.ts +0 -1
  171. package/dist/utils/worktreeSession.d.ts +6 -7
  172. package/dist/utils/worktreeSession.js +7 -11
  173. package/dist/utils/worktreeUtils.d.ts +0 -1
  174. package/dist/workflow/budgetTracker.d.ts +0 -1
  175. package/dist/workflow/concurrencyLimiter.d.ts +0 -1
  176. package/dist/workflow/journal.d.ts +0 -1
  177. package/dist/workflow/progressReporter.d.ts +0 -1
  178. package/dist/workflow/runState.d.ts +0 -1
  179. package/dist/workflow/scriptRuntime.d.ts +0 -1
  180. package/dist/workflow/structuredOutput.d.ts +0 -1
  181. package/dist/workflow/types.d.ts +0 -1
  182. package/dist/workflow/workflowApis.d.ts +0 -1
  183. package/package.json +1 -1
  184. package/src/agent.ts +80 -67
  185. package/src/managers/aiManager.ts +79 -12
  186. package/src/managers/backgroundTaskManager.ts +21 -23
  187. package/src/managers/bangManager.ts +2 -1
  188. package/src/managers/messageManager.ts +72 -6
  189. package/src/managers/messageQueue.ts +60 -2
  190. package/src/managers/permissionManager.ts +6 -3
  191. package/src/managers/subagentManager.ts +22 -16
  192. package/src/managers/workflowManager.ts +5 -5
  193. package/src/prompts/index.ts +4 -4
  194. package/src/services/hook.ts +9 -0
  195. package/src/services/interactionService.ts +11 -0
  196. package/src/services/taskManager.ts +8 -1
  197. package/src/tools/bashTool.ts +11 -5
  198. package/src/tools/enterWorktreeTool.ts +4 -14
  199. package/src/tools/exitWorktreeTool.ts +5 -13
  200. package/src/types/hooks.ts +2 -0
  201. package/src/types/messaging.ts +2 -0
  202. package/src/utils/containerSetup.ts +3 -3
  203. package/src/utils/shellResolver.ts +167 -8
  204. package/src/utils/worktreeSession.ts +6 -16
  205. package/dist/agent.d.ts.map +0 -1
  206. package/dist/constants/goalPrompts.d.ts.map +0 -1
  207. package/dist/constants/subagents.d.ts.map +0 -1
  208. package/dist/constants/toolLimits.d.ts.map +0 -1
  209. package/dist/constants/tools.d.ts.map +0 -1
  210. package/dist/core/plugin.d.ts.map +0 -1
  211. package/dist/core/session.d.ts.map +0 -1
  212. package/dist/index.d.ts.map +0 -1
  213. package/dist/managers/MemoryRuleManager.d.ts.map +0 -1
  214. package/dist/managers/aiManager.d.ts.map +0 -1
  215. package/dist/managers/backgroundTaskManager.d.ts.map +0 -1
  216. package/dist/managers/bangManager.d.ts.map +0 -1
  217. package/dist/managers/cronManager.d.ts.map +0 -1
  218. package/dist/managers/foregroundTaskManager.d.ts.map +0 -1
  219. package/dist/managers/forkedAgentManager.d.ts.map +0 -1
  220. package/dist/managers/goalManager.d.ts.map +0 -1
  221. package/dist/managers/hookManager.d.ts.map +0 -1
  222. package/dist/managers/liveConfigManager.d.ts.map +0 -1
  223. package/dist/managers/lspManager.d.ts.map +0 -1
  224. package/dist/managers/mcpManager.d.ts.map +0 -1
  225. package/dist/managers/messageManager.d.ts.map +0 -1
  226. package/dist/managers/messageQueue.d.ts.map +0 -1
  227. package/dist/managers/notificationQueue.d.ts +0 -8
  228. package/dist/managers/notificationQueue.d.ts.map +0 -1
  229. package/dist/managers/notificationQueue.js +0 -17
  230. package/dist/managers/permissionManager.d.ts.map +0 -1
  231. package/dist/managers/planManager.d.ts.map +0 -1
  232. package/dist/managers/pluginManager.d.ts.map +0 -1
  233. package/dist/managers/pluginScopeManager.d.ts.map +0 -1
  234. package/dist/managers/reversionManager.d.ts.map +0 -1
  235. package/dist/managers/skillManager.d.ts.map +0 -1
  236. package/dist/managers/slashCommandManager.d.ts.map +0 -1
  237. package/dist/managers/subagentManager.d.ts.map +0 -1
  238. package/dist/managers/toolManager.d.ts.map +0 -1
  239. package/dist/managers/workflowManager.d.ts.map +0 -1
  240. package/dist/prompts/autoMemory.d.ts.map +0 -1
  241. package/dist/prompts/autoMemoryExtraction.d.ts.map +0 -1
  242. package/dist/prompts/index.d.ts.map +0 -1
  243. package/dist/prompts/planModeReminders.d.ts.map +0 -1
  244. package/dist/services/GitService.d.ts.map +0 -1
  245. package/dist/services/MarketplaceService.d.ts.map +0 -1
  246. package/dist/services/MemoryRuleService.d.ts.map +0 -1
  247. package/dist/services/aiService.d.ts.map +0 -1
  248. package/dist/services/authService.d.ts.map +0 -1
  249. package/dist/services/autoMemoryService.d.ts.map +0 -1
  250. package/dist/services/configurationService.d.ts.map +0 -1
  251. package/dist/services/fileWatcher.d.ts.map +0 -1
  252. package/dist/services/hook.d.ts.map +0 -1
  253. package/dist/services/initializationService.d.ts.map +0 -1
  254. package/dist/services/interactionService.d.ts.map +0 -1
  255. package/dist/services/jsonlHandler.d.ts.map +0 -1
  256. package/dist/services/memory.d.ts.map +0 -1
  257. package/dist/services/pluginLoader.d.ts.map +0 -1
  258. package/dist/services/remoteSettingsService.d.ts.map +0 -1
  259. package/dist/services/reversionService.d.ts.map +0 -1
  260. package/dist/services/session.d.ts.map +0 -1
  261. package/dist/services/taskManager.d.ts.map +0 -1
  262. package/dist/telemetry/events.d.ts.map +0 -1
  263. package/dist/telemetry/instrumentation.d.ts.map +0 -1
  264. package/dist/telemetry/sessionTracing.d.ts.map +0 -1
  265. package/dist/tools/agentTool.d.ts.map +0 -1
  266. package/dist/tools/askUserQuestion.d.ts.map +0 -1
  267. package/dist/tools/bashTool.d.ts.map +0 -1
  268. package/dist/tools/buildTool.d.ts.map +0 -1
  269. package/dist/tools/cronCreateTool.d.ts.map +0 -1
  270. package/dist/tools/cronDeleteTool.d.ts.map +0 -1
  271. package/dist/tools/cronListTool.d.ts.map +0 -1
  272. package/dist/tools/editTool.d.ts.map +0 -1
  273. package/dist/tools/enterPlanMode.d.ts.map +0 -1
  274. package/dist/tools/enterWorktreeTool.d.ts.map +0 -1
  275. package/dist/tools/exitPlanMode.d.ts.map +0 -1
  276. package/dist/tools/exitWorktreeTool.d.ts.map +0 -1
  277. package/dist/tools/globTool.d.ts.map +0 -1
  278. package/dist/tools/grepTool.d.ts.map +0 -1
  279. package/dist/tools/lspTool.d.ts.map +0 -1
  280. package/dist/tools/readTool.d.ts.map +0 -1
  281. package/dist/tools/skillTool.d.ts.map +0 -1
  282. package/dist/tools/taskManagementTools.d.ts.map +0 -1
  283. package/dist/tools/taskStopTool.d.ts.map +0 -1
  284. package/dist/tools/types.d.ts.map +0 -1
  285. package/dist/tools/webFetchTool.d.ts.map +0 -1
  286. package/dist/tools/workflowTool.d.ts.map +0 -1
  287. package/dist/tools/writeTool.d.ts.map +0 -1
  288. package/dist/types/agent.d.ts.map +0 -1
  289. package/dist/types/auth.d.ts.map +0 -1
  290. package/dist/types/commands.d.ts.map +0 -1
  291. package/dist/types/config.d.ts.map +0 -1
  292. package/dist/types/configuration.d.ts.map +0 -1
  293. package/dist/types/core.d.ts.map +0 -1
  294. package/dist/types/cron.d.ts.map +0 -1
  295. package/dist/types/environment.d.ts.map +0 -1
  296. package/dist/types/fileSearch.d.ts.map +0 -1
  297. package/dist/types/history.d.ts.map +0 -1
  298. package/dist/types/hooks.d.ts.map +0 -1
  299. package/dist/types/index.d.ts.map +0 -1
  300. package/dist/types/lsp.d.ts.map +0 -1
  301. package/dist/types/marketplace.d.ts.map +0 -1
  302. package/dist/types/mcp.d.ts.map +0 -1
  303. package/dist/types/memoryRule.d.ts.map +0 -1
  304. package/dist/types/messaging.d.ts.map +0 -1
  305. package/dist/types/permissions.d.ts.map +0 -1
  306. package/dist/types/plugins.d.ts.map +0 -1
  307. package/dist/types/processes.d.ts.map +0 -1
  308. package/dist/types/reversion.d.ts.map +0 -1
  309. package/dist/types/session.d.ts.map +0 -1
  310. package/dist/types/skills.d.ts.map +0 -1
  311. package/dist/types/tasks.d.ts.map +0 -1
  312. package/dist/types/telemetry.d.ts.map +0 -1
  313. package/dist/types/tools.d.ts.map +0 -1
  314. package/dist/types/workflow.d.ts.map +0 -1
  315. package/dist/utils/abortUtils.d.ts.map +0 -1
  316. package/dist/utils/atomicWrite.d.ts.map +0 -1
  317. package/dist/utils/bashParser.d.ts.map +0 -1
  318. package/dist/utils/cacheControlUtils.d.ts.map +0 -1
  319. package/dist/utils/commandArgumentParser.d.ts.map +0 -1
  320. package/dist/utils/commandPathResolver.d.ts.map +0 -1
  321. package/dist/utils/configPaths.d.ts.map +0 -1
  322. package/dist/utils/configValidator.d.ts.map +0 -1
  323. package/dist/utils/constants.d.ts.map +0 -1
  324. package/dist/utils/container.d.ts.map +0 -1
  325. package/dist/utils/containerSetup.d.ts.map +0 -1
  326. package/dist/utils/convertMessagesForAPI.d.ts.map +0 -1
  327. package/dist/utils/cronTasks.d.ts.map +0 -1
  328. package/dist/utils/cronTasksLock.d.ts.map +0 -1
  329. package/dist/utils/cronToHuman.d.ts.map +0 -1
  330. package/dist/utils/customCommands.d.ts.map +0 -1
  331. package/dist/utils/editUtils.d.ts.map +0 -1
  332. package/dist/utils/fileFormat.d.ts.map +0 -1
  333. package/dist/utils/fileSearch.d.ts.map +0 -1
  334. package/dist/utils/fileUtils.d.ts.map +0 -1
  335. package/dist/utils/gitUtils.d.ts.map +0 -1
  336. package/dist/utils/globalLogger.d.ts.map +0 -1
  337. package/dist/utils/groupMessagesByApiRound.d.ts.map +0 -1
  338. package/dist/utils/hookMatcher.d.ts.map +0 -1
  339. package/dist/utils/markdownParser.d.ts.map +0 -1
  340. package/dist/utils/mcpUtils.d.ts.map +0 -1
  341. package/dist/utils/messageOperations.d.ts.map +0 -1
  342. package/dist/utils/modelCapabilities.d.ts.map +0 -1
  343. package/dist/utils/nameGenerator.d.ts.map +0 -1
  344. package/dist/utils/notificationXml.d.ts.map +0 -1
  345. package/dist/utils/openaiClient.d.ts.map +0 -1
  346. package/dist/utils/parseCronExpression.d.ts.map +0 -1
  347. package/dist/utils/path.d.ts.map +0 -1
  348. package/dist/utils/pathEncoder.d.ts.map +0 -1
  349. package/dist/utils/pathSafety.d.ts.map +0 -1
  350. package/dist/utils/promptHistory.d.ts.map +0 -1
  351. package/dist/utils/ripgrep.d.ts.map +0 -1
  352. package/dist/utils/shellResolver.d.ts.map +0 -1
  353. package/dist/utils/skillParser.d.ts.map +0 -1
  354. package/dist/utils/stringUtils.d.ts.map +0 -1
  355. package/dist/utils/subagentParser.d.ts.map +0 -1
  356. package/dist/utils/taskReminder.d.ts.map +0 -1
  357. package/dist/utils/tokenCalculation.d.ts.map +0 -1
  358. package/dist/utils/tokenEstimate.d.ts.map +0 -1
  359. package/dist/utils/toolResultStorage.d.ts.map +0 -1
  360. package/dist/utils/worktreeSession.d.ts.map +0 -1
  361. package/dist/utils/worktreeUtils.d.ts.map +0 -1
  362. package/dist/workflow/budgetTracker.d.ts.map +0 -1
  363. package/dist/workflow/concurrencyLimiter.d.ts.map +0 -1
  364. package/dist/workflow/journal.d.ts.map +0 -1
  365. package/dist/workflow/progressReporter.d.ts.map +0 -1
  366. package/dist/workflow/runState.d.ts.map +0 -1
  367. package/dist/workflow/scriptRuntime.d.ts.map +0 -1
  368. package/dist/workflow/structuredOutput.d.ts.map +0 -1
  369. package/dist/workflow/types.d.ts.map +0 -1
  370. package/dist/workflow/workflowApis.d.ts.map +0 -1
  371. package/src/managers/notificationQueue.ts +0 -19
@@ -39,4 +39,3 @@ export declare function countWorktreeChanges(worktreePath: string, originalHeadC
39
39
  changedFiles: number;
40
40
  commits: number;
41
41
  } | null;
42
- //# sourceMappingURL=worktreeUtils.d.ts.map
@@ -9,4 +9,3 @@ export declare class BudgetTracker {
9
9
  get total(): number | null;
10
10
  toBudgetInfo(): import("./types.js").BudgetInfo;
11
11
  }
12
- //# sourceMappingURL=budgetTracker.d.ts.map
@@ -11,4 +11,3 @@ export declare class ConcurrencyLimiter {
11
11
  get activeCount(): number;
12
12
  get pendingCount(): number;
13
13
  }
14
- //# sourceMappingURL=concurrencyLimiter.d.ts.map
@@ -16,4 +16,3 @@ export declare class Journal {
16
16
  close(): Promise<void>;
17
17
  static load(filePath: string): Promise<Journal>;
18
18
  }
19
- //# sourceMappingURL=journal.d.ts.map
@@ -18,4 +18,3 @@ export declare class ProgressReporter {
18
18
  onEvent(listener: (event: WorkflowProgressEvent) => void): void;
19
19
  private emit;
20
20
  }
21
- //# sourceMappingURL=progressReporter.d.ts.map
@@ -13,4 +13,3 @@ export declare class RunStateStore {
13
13
  /** List all persisted run IDs */
14
14
  listRuns(): Promise<string[]>;
15
15
  }
16
- //# sourceMappingURL=runState.d.ts.map
@@ -32,4 +32,3 @@ export declare function executeScript(script: string, apis: {
32
32
  meta: WorkflowMeta;
33
33
  result: unknown;
34
34
  }>;
35
- //# sourceMappingURL=scriptRuntime.d.ts.map
@@ -24,4 +24,3 @@ export declare function extractStructuredResult(messages: Array<{
24
24
  }>;
25
25
  }>, schema: object): unknown | null;
26
26
  export { STRUCTURED_OUTPUT_TOOL_NAME };
27
- //# sourceMappingURL=structuredOutput.d.ts.map
@@ -78,4 +78,3 @@ export interface WorkflowProgressEvent {
78
78
  agentIndex?: number;
79
79
  timestamp: number;
80
80
  }
81
- //# sourceMappingURL=types.d.ts.map
@@ -41,4 +41,3 @@ export interface WorkflowApis {
41
41
  }
42
42
  export declare function createWorkflowApis(ctx: WorkflowApiContext): WorkflowApis;
43
43
  export {};
44
- //# sourceMappingURL=workflowApis.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wave-agent-sdk",
3
- "version": "0.19.5",
3
+ "version": "0.19.7",
4
4
  "description": "SDK for building AI-powered development tools and agents",
5
5
  "keywords": [
6
6
  "ai",
package/src/agent.ts CHANGED
@@ -10,7 +10,6 @@ import { BangManager } from "./managers/bangManager.js";
10
10
  import { CronManager } from "./managers/cronManager.js";
11
11
  import { GoalManager } from "./managers/goalManager.js";
12
12
  import { BackgroundTaskManager } from "./managers/backgroundTaskManager.js";
13
- import { NotificationQueue } from "./managers/notificationQueue.js";
14
13
  import { MessageQueue, type QueuedMessage } from "./managers/messageQueue.js";
15
14
  import { SlashCommandManager } from "./managers/slashCommandManager.js";
16
15
  import { PluginManager } from "./managers/pluginManager.js";
@@ -42,6 +41,7 @@ import { TaskManager } from "./services/taskManager.js";
42
41
  import { btw } from "./services/aiService.js";
43
42
  import { convertMessagesForAPI } from "./utils/convertMessagesForAPI.js";
44
43
  import { supportsVision } from "./utils/modelCapabilities.js";
44
+ import type { WorktreeSession } from "./utils/worktreeSession.js";
45
45
  import { parseTaskNotificationXml } from "./utils/notificationXml.js";
46
46
  import { InitializationService } from "./services/initializationService.js";
47
47
  import { InteractionService } from "./services/interactionService.js";
@@ -76,9 +76,8 @@ export class Agent {
76
76
  private goalManager: GoalManager; // Add goal manager instance
77
77
  private hookManager: HookManager; // Add hooks manager instance
78
78
  private reversionManager: ReversionManager;
79
- private notificationQueue: NotificationQueue; // Add notification queue instance
80
- private messageQueue: MessageQueue; // Add message queue instance
81
- private pendingNotificationPromises: Promise<void>[] = []; // Track pending notification processing
79
+ private messageQueue: MessageQueue; // Unified queue for messages, bang commands, and notifications
80
+ private dispatchPromise: Promise<void> | null = null; // Track current dispatch for teardown
82
81
  private memoryRuleManager: MemoryRuleManager; // Add memory rule manager instance
83
82
  private liveConfigManager: LiveConfigManager; // Add live configuration manager
84
83
  private taskManager: TaskManager;
@@ -206,25 +205,8 @@ export class Agent {
206
205
  this.bangManager = this.container.get("BangManager")!;
207
206
  this.cronManager = this.container.get("CronManager")!;
208
207
  this.goalManager = this.container.get("GoalManager")!;
209
- this.notificationQueue = this.container.get("NotificationQueue")!;
210
208
  this.messageQueue = this.container.get("MessageQueue")!;
211
209
 
212
- // Wire up notification queue to trigger AI when notifications arrive while idle
213
- this.notificationQueue.onNotificationsEnqueued = () => {
214
- // If the AI is NOT loading (idle), trigger a new AI cycle to process notifications
215
- if (!this.aiManager.isLoading) {
216
- const pendingPromise = this.processPendingNotifications().catch(
217
- (error) => {
218
- this.logger?.error(
219
- "Failed to process pending notifications:",
220
- error,
221
- );
222
- },
223
- );
224
- this.pendingNotificationPromises.push(pendingPromise);
225
- }
226
- };
227
-
228
210
  // Wire up CWD change callback from AIManager to sync Agent's workdir
229
211
  this.aiManager.setOnCwdChange((newCwd) => {
230
212
  this.workdir = newCwd;
@@ -232,18 +214,20 @@ export class Agent {
232
214
  this.options.callbacks?.onWorkdirChange?.(newCwd);
233
215
  });
234
216
 
235
- // Wire up message queue to process when agent becomes idle
236
- this.messageQueue.onMessageEnqueued = () => this.tryDequeue();
217
+ // Wire up message queue to process when agent becomes idle.
218
+ // Both user messages and background task notifications enqueue here,
219
+ // unified through a single dispatch path (tryDispatch).
220
+ this.messageQueue.onMessageEnqueued = () => this.tryDispatch();
237
221
 
238
222
  // Wire up AI loading changes to process queue when AI becomes idle
239
223
  this.aiManager.onLoadingChange = (loading: boolean) => {
240
- if (!loading) this.tryDequeue();
224
+ if (!loading) this.tryDispatch();
241
225
  };
242
226
 
243
227
  // Wire up bang manager callback for command running changes
244
228
  this.bangManager.onCommandRunningChange = (running: boolean) => {
245
229
  this.options.callbacks?.onCommandRunningChange?.(running);
246
- if (!running) this.tryDequeue();
230
+ if (!running) this.tryDispatch();
247
231
  };
248
232
 
249
233
  // Set initial permission mode if provided
@@ -298,6 +282,15 @@ export class Agent {
298
282
  this.options.callbacks?.onWorkdirChange?.(newCwd);
299
283
  }
300
284
 
285
+ /**
286
+ * Set this session's worktree session state (used by CLI -w startup to inject the
287
+ * session created before the agent existed). Delegates to AIManager so the state is
288
+ * stored in this agent's own DI container.
289
+ */
290
+ public setWorktreeSession(session: WorktreeSession | null): void {
291
+ this.aiManager.setWorktreeSession(session);
292
+ }
293
+
301
294
  /** Get project memory content */
302
295
  public get projectMemory(): string {
303
296
  const memoryService =
@@ -336,9 +329,11 @@ export class Agent {
336
329
  return this.bangManager?.isCommandRunning ?? false;
337
330
  }
338
331
 
339
- /** Get queued messages */
332
+ /** Get queued user-facing messages (excludes background notifications) */
340
333
  public get queuedMessages(): QueuedMessage[] {
341
- return this.messageQueue.getQueue();
334
+ return this.messageQueue
335
+ .getQueue()
336
+ .filter((m) => m.type !== "notification");
342
337
  }
343
338
 
344
339
  /** Get goal status string */
@@ -390,28 +385,52 @@ export class Agent {
390
385
  }
391
386
 
392
387
  /**
393
- * Unified dequeue trigger — checks state machine before processing.
394
- * Called from onMessageEnqueued, onLoadingChange(false), and
395
- * onCommandRunningChange(false).
388
+ * Update a queued message's content by its ID (does not change queue order)
389
+ * @param id - The ID of the message to update
390
+ * @param patch - The fields to update
391
+ * @returns true if the message was updated, false if not found
392
+ */
393
+ public updateQueuedMessageById(
394
+ id: string,
395
+ patch: {
396
+ content?: string;
397
+ images?: Array<{ path: string; mimeType: string }>;
398
+ type?: "message" | "bang";
399
+ },
400
+ ): boolean {
401
+ const updated = this.messageQueue.updateById(id, patch);
402
+ if (updated) {
403
+ this.options.callbacks?.onQueuedMessagesChange?.(this.queuedMessages);
404
+ }
405
+ return updated;
406
+ }
407
+
408
+ /**
409
+ * Unified dispatch trigger — checks state machine before processing.
410
+ * Handles user messages, bang commands, and background task notifications
411
+ * through a single serialized path. Called from onMessageEnqueued,
412
+ * onLoadingChange(false), and onCommandRunningChange(false).
396
413
  */
397
- private tryDequeue(): void {
414
+ private tryDispatch(): void {
398
415
  if (this.messageQueue.state !== "idle") return;
399
416
  if (!this.messageQueue.hasPending()) return;
400
417
  if (this.aiManager.isLoading || this.isCommandRunning) return;
401
418
 
402
419
  this.messageQueue.transitionTo("dispatching");
403
- this.processQueuedMessage()
420
+ this.dispatchPromise = this.processQueuedMessage()
404
421
  .catch((error) => {
405
422
  this.logger?.error("Failed to process queued message:", error);
406
423
  })
407
424
  .finally(() => {
408
425
  this.messageQueue.transitionTo("idle");
409
- this.tryDequeue(); // Re-check after processing
426
+ this.dispatchPromise = null;
427
+ this.tryDispatch(); // Re-check after processing
410
428
  });
411
429
  }
412
430
 
413
431
  /**
414
- * Process the next queued message when the agent becomes idle.
432
+ * Process the next queued item when the agent becomes idle.
433
+ * Handles three item types: user messages, bang commands, and notifications.
415
434
  */
416
435
  private async processQueuedMessage(): Promise<void> {
417
436
  const next = this.messageQueue.dequeue();
@@ -423,6 +442,25 @@ export class Agent {
423
442
  if (next.type === "bang") {
424
443
  await this.bangManager?.executeCommand(next.content);
425
444
  await this.messageManager.saveSession();
445
+ } else if (next.type === "notification") {
446
+ // Drain all pending notifications and batch them into a single AI turn
447
+ const allNotifications = [
448
+ next.content,
449
+ ...this.messageQueue.drainNotifications(),
450
+ ];
451
+ for (const xml of allNotifications) {
452
+ const block = parseTaskNotificationXml(xml);
453
+ if (block) {
454
+ this.messageManager.addNotificationMessage({
455
+ taskId: block.taskId,
456
+ taskType: block.taskType,
457
+ status: block.status,
458
+ summary: block.summary,
459
+ outputFile: block.outputFile,
460
+ });
461
+ }
462
+ }
463
+ await this.aiManager.sendAIMessage({ recursionDepth: 0 });
426
464
  } else {
427
465
  await this.sendMessage(next.content, next.images);
428
466
  }
@@ -650,31 +688,6 @@ export class Agent {
650
688
  this.aiManager.abortAIMessage();
651
689
  }
652
690
 
653
- /**
654
- * Process pending background task notifications by injecting them as user messages
655
- * and triggering a new AI response cycle.
656
- */
657
- private async processPendingNotifications(): Promise<void> {
658
- const notifications = this.notificationQueue.dequeueAll();
659
- if (notifications.length === 0) return;
660
-
661
- for (const notification of notifications) {
662
- const block = parseTaskNotificationXml(notification);
663
- if (block) {
664
- this.messageManager.addNotificationMessage({
665
- taskId: block.taskId,
666
- taskType: block.taskType,
667
- status: block.status,
668
- summary: block.summary,
669
- outputFile: block.outputFile,
670
- });
671
- }
672
- }
673
-
674
- // Trigger AI to process the notifications
675
- await this.aiManager.sendAIMessage({ recursionDepth: 0 });
676
- }
677
-
678
691
  /** Execute bash command (bang command) */
679
692
  public async bang(command: string): Promise<void> {
680
693
  // If the agent is busy, enqueue the bang command
@@ -835,8 +848,9 @@ export class Agent {
835
848
  /** Unified interrupt method, interrupts both AI messages and command execution */
836
849
  public abortMessage(): void {
837
850
  if (this.aiManager.isLoading || this.isCommandRunning) {
838
- // Clear queue first to prevent processQueuedMessage from dequeuing
839
- // when abortAIMessage triggers onLoadingChange(false)
851
+ // Clear user-facing queue items first to prevent processQueuedMessage
852
+ // from dequeuing when abortAIMessage triggers onLoadingChange(false).
853
+ // Notifications are preserved so background task results aren't lost.
840
854
  this.messageQueue.clear();
841
855
  this.options.callbacks?.onQueuedMessagesChange?.(this.queuedMessages);
842
856
  }
@@ -926,15 +940,14 @@ export class Agent {
926
940
  }).catch(() => {});
927
941
  await shutdownTelemetry();
928
942
 
929
- // Clear notification callback first to prevent any late triggers from
943
+ // Clear message queue callback first to prevent any late triggers from
930
944
  // starting async work during teardown
931
- this.notificationQueue.onNotificationsEnqueued = undefined;
945
+ this.messageQueue.onMessageEnqueued = undefined;
932
946
 
933
- // Await any pending notification processing to prevent race conditions
947
+ // Await any pending dispatch to prevent race conditions
934
948
  // with test teardown (e.g., V8 coverage stream cleanup)
935
- if (this.pendingNotificationPromises.length > 0) {
936
- await Promise.allSettled(this.pendingNotificationPromises);
937
- this.pendingNotificationPromises = [];
949
+ if (this.dispatchPromise) {
950
+ await this.dispatchPromise.catch(() => {});
938
951
  }
939
952
 
940
953
  // Fire SessionEnd hooks (fire-and-forget, don't block shutdown)
@@ -38,9 +38,10 @@ import {
38
38
  buildExitedPlanModeReminder,
39
39
  } from "../prompts/planModeReminders.js";
40
40
  import { Container } from "../utils/container.js";
41
+ import type { WorktreeSession } from "../utils/worktreeSession.js";
41
42
  import { recoverTruncatedJson } from "../utils/stringUtils.js";
42
43
  import { ConfigurationService } from "../services/configurationService.js";
43
- import type { NotificationQueue } from "./notificationQueue.js";
44
+ import type { MessageQueue } from "./messageQueue.js";
44
45
 
45
46
  import { logger } from "../utils/globalLogger.js";
46
47
  import {
@@ -114,6 +115,7 @@ export interface AIManagerOptions {
114
115
 
115
116
  export class AIManager {
116
117
  public isLoading: boolean = false;
118
+ private turnGeneration = 0; // Guards against concurrent sendAIMessage turns
117
119
  private abortController: AbortController | null = null;
118
120
  onLoadingChange?: (loading: boolean) => void;
119
121
  private toolAbortController: AbortController | null = null;
@@ -260,11 +262,31 @@ export class AIManager {
260
262
 
261
263
  /**
262
264
  * Update the working directory mid-session (e.g., when entering/exiting a worktree).
263
- * Also updates process.chdir() so bash commands use the new directory.
265
+ * Only updates this session's DI container; it does NOT change the process-level
266
+ * process.cwd(), so concurrent sessions in the same stdio process are unaffected.
267
+ * Triggers `_onCwdChange` (wired by Agent to `onWorkdirChange`) so the host is
268
+ * notified of worktree switches. Unlike bash `cd`, this does NOT run CwdChanged
269
+ * hooks (worktree has its own WorktreeCreate/WorktreeRemove hooks).
264
270
  */
265
271
  public setWorkdir(newWorkdir: string): void {
266
272
  this.container.register("Workdir", newWorkdir);
267
- process.chdir(newWorkdir);
273
+ this._onCwdChange?.(newWorkdir);
274
+ }
275
+
276
+ /**
277
+ * Get this session's worktree session state (null if not in a worktree).
278
+ */
279
+ public getWorktreeSession(): WorktreeSession | null {
280
+ return (
281
+ this.container.get<WorktreeSession | null>("WorktreeSession") ?? null
282
+ );
283
+ }
284
+
285
+ /**
286
+ * Set this session's worktree session state.
287
+ */
288
+ public setWorktreeSession(session: WorktreeSession | null): void {
289
+ this.container.register("WorktreeSession", session);
268
290
  }
269
291
 
270
292
  public setOnCwdChange(callback: (newCwd: string) => void): void {
@@ -376,6 +398,10 @@ export class AIManager {
376
398
  }
377
399
 
378
400
  public abortAIMessage(): void {
401
+ // Bump generation so the in-flight turn's end-of-turn setIsLoading(false)
402
+ // is skipped (generation mismatch), preventing it from racing with this abort.
403
+ this.turnGeneration++;
404
+
379
405
  // Interrupt AI service
380
406
  if (this.abortController) {
381
407
  try {
@@ -797,6 +823,15 @@ export class AIManager {
797
823
  const { recursionDepth = 0, model, allowedRules, maxTokens } = options;
798
824
  let turnOffset = recursionDepth;
799
825
 
826
+ // Reserve this turn synchronously before any async work. Bumping the
827
+ // generation invalidates any in-flight turn's end-of-turn cleanup, and
828
+ // recording myGeneration lets us skip cleanup if a newer turn (or abort)
829
+ // has superseded us. setIsLoading(true) here also closes the "idle but
830
+ // previous turn not finished" race window by marking us busy immediately.
831
+ this.turnGeneration++;
832
+ const myGeneration = this.turnGeneration;
833
+ this.setIsLoading(true);
834
+
800
835
  outer: while (true) {
801
836
  let shouldRestart = false;
802
837
 
@@ -818,9 +853,8 @@ export class AIManager {
818
853
  }).catch(() => {}); // Non-blocking
819
854
  }
820
855
 
821
- // Set loading state early for the initial call, before any async work
856
+ // Apply allowed rules for the initial call
822
857
  if (turnOffset === 0) {
823
- this.setIsLoading(true);
824
858
  if (allowedRules && allowedRules.length > 0) {
825
859
  this.permissionManager?.addTemporaryRules(allowedRules);
826
860
  }
@@ -942,6 +976,7 @@ export class AIManager {
942
976
  originalWorkdir: this.getOriginalWorkdir(),
943
977
  language: this.getLanguage(),
944
978
  isSubagent: !!this.subagentType,
979
+ worktreeSession: this.getWorktreeSession(),
945
980
  autoMemory: autoMemoryOptions,
946
981
  },
947
982
  ), // Pass custom system prompt
@@ -1326,6 +1361,16 @@ export class AIManager {
1326
1361
  message: error instanceof Error ? error.message : String(error),
1327
1362
  }).catch(() => {}); // Non-blocking
1328
1363
 
1364
+ // Finalize any streaming text/reasoning blocks so the UI stops ticking
1365
+ // its in-progress timer (e.g. when the request is aborted mid-thought).
1366
+ this.messageManager.finalizeStreamingBlocks();
1367
+
1368
+ // Finalize any tool blocks stuck in start/streaming/running so the UI
1369
+ // stops showing the yellow "running" spinner (e.g. abort mid-tool-stream).
1370
+ this.messageManager.finalizeAbortedToolBlocks(
1371
+ error instanceof Error ? error.message : undefined,
1372
+ );
1373
+
1329
1374
  this.messageManager.addErrorBlock(
1330
1375
  error instanceof Error ? error.message : "Unknown error occurred",
1331
1376
  );
@@ -1343,8 +1388,6 @@ export class AIManager {
1343
1388
 
1344
1389
  // Save session in each iteration to ensure message persistence
1345
1390
  await this.messageManager.saveSession();
1346
- // Set loading to false first
1347
- this.setIsLoading(false);
1348
1391
 
1349
1392
  // Clear temporary rules
1350
1393
  this.permissionManager?.clearTemporaryRules();
@@ -1443,11 +1486,11 @@ export class AIManager {
1443
1486
 
1444
1487
  // Inject pending notifications from background tasks (after Stop hooks,
1445
1488
  // aligned with Claude Code which fires Stop hooks unconditionally)
1446
- const notificationQueue = this.container.has("NotificationQueue")
1447
- ? this.container.get<NotificationQueue>("NotificationQueue")
1489
+ const messageQueue = this.container.has("MessageQueue")
1490
+ ? this.container.get<MessageQueue>("MessageQueue")
1448
1491
  : undefined;
1449
- if (notificationQueue && notificationQueue.hasPending()) {
1450
- const notifications = notificationQueue.dequeueAll();
1492
+ if (messageQueue && messageQueue.hasNotifications()) {
1493
+ const notifications = messageQueue.drainNotifications();
1451
1494
  for (const notification of notifications) {
1452
1495
  const block = parseTaskNotificationXml(notification);
1453
1496
  if (block) {
@@ -1466,7 +1509,16 @@ export class AIManager {
1466
1509
  }
1467
1510
  }
1468
1511
 
1469
- if (!shouldRestart) break outer;
1512
+ if (!shouldRestart) {
1513
+ // Release loading state only after ALL cleanup is done (session save,
1514
+ // Stop hooks, notification injection). Generation check ensures a
1515
+ // superseded (aborted or newer) turn doesn't clobber the current
1516
+ // loading state.
1517
+ if (myGeneration === this.turnGeneration) {
1518
+ this.setIsLoading(false);
1519
+ }
1520
+ break outer;
1521
+ }
1470
1522
  }
1471
1523
  }
1472
1524
 
@@ -1502,6 +1554,20 @@ export class AIManager {
1502
1554
  }))
1503
1555
  : undefined;
1504
1556
 
1557
+ // Extract text content from the last assistant message so hooks can
1558
+ // inspect the final response without reading the transcript file.
1559
+ const allMessages = this.messageManager.getMessages();
1560
+ const lastAssistant = [...allMessages]
1561
+ .reverse()
1562
+ .find((m) => m.role === "assistant");
1563
+ const lastAssistantText = lastAssistant
1564
+ ? lastAssistant.blocks
1565
+ .filter((b) => b.type === "text")
1566
+ .map((b) => b.content)
1567
+ .join("\n")
1568
+ .trim() || undefined
1569
+ : undefined;
1570
+
1505
1571
  const context: ExtendedHookExecutionContext = {
1506
1572
  event: hookName,
1507
1573
  projectDir: this.getWorkdir(),
@@ -1512,6 +1578,7 @@ export class AIManager {
1512
1578
  subagentType: this.subagentType, // Include subagent type in hook context
1513
1579
  backgroundTasks, // Stop-only: running background tasks snapshot
1514
1580
  sessionCrons, // Stop-only: session cron jobs snapshot
1581
+ lastAssistantMessage: lastAssistantText, // Stop/SubagentStop: last assistant message text
1515
1582
  // Stop hooks don't need toolName, toolInput, toolResponse, or userPrompt
1516
1583
  env: Object.fromEntries(
1517
1584
  Object.entries(process.env).filter((e) => e[1] !== undefined),
@@ -6,7 +6,8 @@ import { BackgroundTask, BackgroundShell } from "../types/processes.js";
6
6
  import { stripAnsiColors } from "../utils/stringUtils.js";
7
7
  import { logger } from "../utils/globalLogger.js";
8
8
  import { Container } from "../utils/container.js";
9
- import { NotificationQueue } from "./notificationQueue.js";
9
+ import { MessageQueue } from "./messageQueue.js";
10
+ import { resolveShellPath } from "../utils/shellResolver.js";
10
11
 
11
12
  export interface BackgroundTaskManagerCallbacks {
12
13
  onBackgroundTasksChange?: (tasks: BackgroundTask[]) => void;
@@ -31,10 +32,6 @@ export class BackgroundTaskManager {
31
32
  this.workdir = options.workdir;
32
33
  }
33
34
 
34
- private get notificationQueue(): NotificationQueue {
35
- return this.container.get<NotificationQueue>("NotificationQueue")!;
36
- }
37
-
38
35
  /**
39
36
  * Fire the onBackgroundTasksChange callback so UI consumers refresh.
40
37
  * Public so other managers (e.g. WorkflowManager) can trigger a refresh
@@ -64,15 +61,16 @@ export class BackgroundTaskManager {
64
61
  public startShell(
65
62
  command: string,
66
63
  timeout?: number,
64
+ cwd?: string,
67
65
  ): { id: string; child: ChildProcess; detach: () => void } {
68
66
  const id = this.generateId();
69
67
  const startTime = Date.now();
70
68
 
71
69
  const child = spawn(command, {
72
- shell: true,
70
+ shell: resolveShellPath() ?? true,
73
71
  stdio: "pipe",
74
72
  detached: true,
75
- cwd: this.workdir,
73
+ cwd: cwd ?? this.workdir,
76
74
  env: {
77
75
  ...process.env,
78
76
  },
@@ -176,13 +174,13 @@ export class BackgroundTaskManager {
176
174
 
177
175
  // Skip notification if task was manually killed (user/agent-initiated stop)
178
176
  if (!wasKilled) {
179
- const notificationQueue = this.container.has("NotificationQueue")
180
- ? this.container.get<NotificationQueue>("NotificationQueue")
177
+ const messageQueue = this.container.has("MessageQueue")
178
+ ? this.container.get<MessageQueue>("MessageQueue")
181
179
  : undefined;
182
- if (notificationQueue) {
180
+ if (messageQueue) {
183
181
  const statusStr = shell.status;
184
182
  const summary = `Command "${command}" ${statusStr} with exit code ${code ?? 0}`;
185
- notificationQueue.enqueue(
183
+ messageQueue.enqueueNotification(
186
184
  `<task-notification>\n<task-id>${id}</task-id>\n<task-type>shell</task-type>\n<output-file>${logPath}</output-file>\n<status>${statusStr}</status>\n<summary>${summary}</summary>\n</task-notification>`,
187
185
  );
188
186
  }
@@ -206,12 +204,12 @@ export class BackgroundTaskManager {
206
204
  this.notifyTasksChange();
207
205
 
208
206
  // Enqueue error notification
209
- const notificationQueue = this.container.has("NotificationQueue")
210
- ? this.container.get<NotificationQueue>("NotificationQueue")
207
+ const messageQueue = this.container.has("MessageQueue")
208
+ ? this.container.get<MessageQueue>("MessageQueue")
211
209
  : undefined;
212
- if (notificationQueue) {
210
+ if (messageQueue) {
213
211
  const summary = `Command "${command}" failed with error: ${stripAnsiColors(error.message)}`;
214
- notificationQueue.enqueue(
212
+ messageQueue.enqueueNotification(
215
213
  `<task-notification>\n<task-id>${id}</task-id>\n<task-type>shell</task-type>\n<output-file>${logPath}</output-file>\n<status>failed</status>\n<summary>${summary}</summary>\n</task-notification>`,
216
214
  );
217
215
  }
@@ -335,13 +333,13 @@ export class BackgroundTaskManager {
335
333
 
336
334
  // Skip notification if task was manually killed (user/agent-initiated stop)
337
335
  if (!wasKilled) {
338
- const notificationQueue = this.container.has("NotificationQueue")
339
- ? this.container.get<NotificationQueue>("NotificationQueue")
336
+ const messageQueue = this.container.has("MessageQueue")
337
+ ? this.container.get<MessageQueue>("MessageQueue")
340
338
  : undefined;
341
- if (notificationQueue) {
339
+ if (messageQueue) {
342
340
  const statusStr = shell.status;
343
341
  const summary = `Command "${command}" ${statusStr} with exit code ${code ?? 0}`;
344
- notificationQueue.enqueue(
342
+ messageQueue.enqueueNotification(
345
343
  `<task-notification>\n<task-id>${id}</task-id>\n<task-type>shell</task-type>\n<output-file>${logPath}</output-file>\n<status>${statusStr}</status>\n<summary>${summary}</summary>\n</task-notification>`,
346
344
  );
347
345
  }
@@ -362,12 +360,12 @@ export class BackgroundTaskManager {
362
360
  this.notifyTasksChange();
363
361
 
364
362
  // Enqueue error notification
365
- const notificationQueue = this.container.has("NotificationQueue")
366
- ? this.container.get<NotificationQueue>("NotificationQueue")
363
+ const messageQueue = this.container.has("MessageQueue")
364
+ ? this.container.get<MessageQueue>("MessageQueue")
367
365
  : undefined;
368
- if (notificationQueue) {
366
+ if (messageQueue) {
369
367
  const summary = `Command "${command}" failed with error: ${stripAnsiColors(error.message)}`;
370
- notificationQueue.enqueue(
368
+ messageQueue.enqueueNotification(
371
369
  `<task-notification>\n<task-id>${id}</task-id>\n<task-type>shell</task-type>\n<output-file>${logPath}</output-file>\n<status>failed</status>\n<summary>${summary}</summary>\n</task-notification>`,
372
370
  );
373
371
  }
@@ -1,6 +1,7 @@
1
1
  import { spawn, type ChildProcess } from "child_process";
2
2
  import type { MessageManager } from "./messageManager.js";
3
3
  import { Container } from "../utils/container.js";
4
+ import { resolveShellPath } from "../utils/shellResolver.js";
4
5
 
5
6
  export interface BangManagerOptions {
6
7
  workdir: string;
@@ -45,7 +46,7 @@ export class BangManager {
45
46
 
46
47
  return new Promise<number>((resolve) => {
47
48
  const child = spawn(command, {
48
- shell: true,
49
+ shell: resolveShellPath() ?? true,
49
50
  stdio: "pipe",
50
51
  cwd: this.workdir,
51
52
  env: {