wave-agent-sdk 0.19.6 → 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 (349) hide show
  1. package/dist/agent.d.ts +9 -14
  2. package/dist/agent.js +49 -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 +1 -1
  12. package/dist/managers/aiManager.js +26 -9
  13. package/dist/managers/backgroundTaskManager.d.ts +0 -2
  14. package/dist/managers/backgroundTaskManager.js +16 -19
  15. package/dist/managers/bangManager.d.ts +0 -1
  16. package/dist/managers/cronManager.d.ts +0 -1
  17. package/dist/managers/foregroundTaskManager.d.ts +0 -1
  18. package/dist/managers/forkedAgentManager.d.ts +0 -1
  19. package/dist/managers/goalManager.d.ts +0 -1
  20. package/dist/managers/hookManager.d.ts +0 -1
  21. package/dist/managers/liveConfigManager.d.ts +0 -1
  22. package/dist/managers/lspManager.d.ts +0 -1
  23. package/dist/managers/mcpManager.d.ts +0 -1
  24. package/dist/managers/messageManager.d.ts +0 -1
  25. package/dist/managers/messageQueue.d.ts +17 -2
  26. package/dist/managers/messageQueue.js +40 -1
  27. package/dist/managers/permissionManager.d.ts +0 -1
  28. package/dist/managers/planManager.d.ts +0 -1
  29. package/dist/managers/pluginManager.d.ts +0 -1
  30. package/dist/managers/pluginScopeManager.d.ts +0 -1
  31. package/dist/managers/reversionManager.d.ts +0 -1
  32. package/dist/managers/skillManager.d.ts +0 -1
  33. package/dist/managers/slashCommandManager.d.ts +0 -1
  34. package/dist/managers/subagentManager.d.ts +0 -3
  35. package/dist/managers/subagentManager.js +8 -13
  36. package/dist/managers/toolManager.d.ts +0 -1
  37. package/dist/managers/workflowManager.d.ts +1 -2
  38. package/dist/managers/workflowManager.js +4 -4
  39. package/dist/prompts/autoMemory.d.ts +0 -1
  40. package/dist/prompts/autoMemoryExtraction.d.ts +0 -1
  41. package/dist/prompts/index.d.ts +0 -1
  42. package/dist/prompts/planModeReminders.d.ts +0 -1
  43. package/dist/services/GitService.d.ts +0 -1
  44. package/dist/services/MarketplaceService.d.ts +0 -1
  45. package/dist/services/MemoryRuleService.d.ts +0 -1
  46. package/dist/services/aiService.d.ts +0 -1
  47. package/dist/services/authService.d.ts +0 -1
  48. package/dist/services/autoMemoryService.d.ts +0 -1
  49. package/dist/services/configurationService.d.ts +0 -1
  50. package/dist/services/fileWatcher.d.ts +0 -1
  51. package/dist/services/hook.d.ts +0 -1
  52. package/dist/services/initializationService.d.ts +0 -1
  53. package/dist/services/interactionService.d.ts +0 -1
  54. package/dist/services/interactionService.js +10 -0
  55. package/dist/services/jsonlHandler.d.ts +0 -1
  56. package/dist/services/memory.d.ts +0 -1
  57. package/dist/services/pluginLoader.d.ts +0 -1
  58. package/dist/services/remoteSettingsService.d.ts +0 -1
  59. package/dist/services/reversionService.d.ts +0 -1
  60. package/dist/services/session.d.ts +0 -1
  61. package/dist/services/taskManager.d.ts +0 -1
  62. package/dist/services/taskManager.js +8 -1
  63. package/dist/telemetry/events.d.ts +0 -1
  64. package/dist/telemetry/instrumentation.d.ts +0 -1
  65. package/dist/telemetry/sessionTracing.d.ts +0 -1
  66. package/dist/tools/agentTool.d.ts +0 -1
  67. package/dist/tools/askUserQuestion.d.ts +0 -1
  68. package/dist/tools/bashTool.d.ts +0 -1
  69. package/dist/tools/buildTool.d.ts +0 -1
  70. package/dist/tools/cronCreateTool.d.ts +0 -1
  71. package/dist/tools/cronDeleteTool.d.ts +0 -1
  72. package/dist/tools/cronListTool.d.ts +0 -1
  73. package/dist/tools/editTool.d.ts +0 -1
  74. package/dist/tools/enterPlanMode.d.ts +0 -1
  75. package/dist/tools/enterWorktreeTool.d.ts +0 -1
  76. package/dist/tools/exitPlanMode.d.ts +0 -1
  77. package/dist/tools/exitWorktreeTool.d.ts +0 -1
  78. package/dist/tools/globTool.d.ts +0 -1
  79. package/dist/tools/grepTool.d.ts +0 -1
  80. package/dist/tools/lspTool.d.ts +0 -1
  81. package/dist/tools/readTool.d.ts +0 -1
  82. package/dist/tools/skillTool.d.ts +0 -1
  83. package/dist/tools/taskManagementTools.d.ts +0 -1
  84. package/dist/tools/taskStopTool.d.ts +0 -1
  85. package/dist/tools/types.d.ts +0 -1
  86. package/dist/tools/webFetchTool.d.ts +0 -1
  87. package/dist/tools/workflowTool.d.ts +0 -1
  88. package/dist/tools/writeTool.d.ts +0 -1
  89. package/dist/types/agent.d.ts +0 -1
  90. package/dist/types/auth.d.ts +0 -1
  91. package/dist/types/commands.d.ts +0 -1
  92. package/dist/types/config.d.ts +0 -1
  93. package/dist/types/configuration.d.ts +0 -1
  94. package/dist/types/core.d.ts +0 -1
  95. package/dist/types/cron.d.ts +0 -1
  96. package/dist/types/environment.d.ts +0 -1
  97. package/dist/types/fileSearch.d.ts +0 -1
  98. package/dist/types/history.d.ts +0 -1
  99. package/dist/types/hooks.d.ts +0 -1
  100. package/dist/types/index.d.ts +0 -1
  101. package/dist/types/lsp.d.ts +0 -1
  102. package/dist/types/marketplace.d.ts +0 -1
  103. package/dist/types/mcp.d.ts +0 -1
  104. package/dist/types/memoryRule.d.ts +0 -1
  105. package/dist/types/messaging.d.ts +0 -1
  106. package/dist/types/permissions.d.ts +0 -1
  107. package/dist/types/plugins.d.ts +0 -1
  108. package/dist/types/processes.d.ts +0 -1
  109. package/dist/types/reversion.d.ts +0 -1
  110. package/dist/types/session.d.ts +0 -1
  111. package/dist/types/skills.d.ts +0 -1
  112. package/dist/types/tasks.d.ts +0 -1
  113. package/dist/types/telemetry.d.ts +0 -1
  114. package/dist/types/tools.d.ts +0 -1
  115. package/dist/types/workflow.d.ts +0 -1
  116. package/dist/utils/abortUtils.d.ts +0 -1
  117. package/dist/utils/atomicWrite.d.ts +0 -1
  118. package/dist/utils/bashParser.d.ts +0 -1
  119. package/dist/utils/cacheControlUtils.d.ts +0 -1
  120. package/dist/utils/commandArgumentParser.d.ts +0 -1
  121. package/dist/utils/commandPathResolver.d.ts +0 -1
  122. package/dist/utils/configPaths.d.ts +0 -1
  123. package/dist/utils/configValidator.d.ts +0 -1
  124. package/dist/utils/constants.d.ts +0 -1
  125. package/dist/utils/container.d.ts +0 -1
  126. package/dist/utils/containerSetup.d.ts +0 -1
  127. package/dist/utils/containerSetup.js +0 -3
  128. package/dist/utils/convertMessagesForAPI.d.ts +0 -1
  129. package/dist/utils/cronTasks.d.ts +0 -1
  130. package/dist/utils/cronTasksLock.d.ts +0 -1
  131. package/dist/utils/cronToHuman.d.ts +0 -1
  132. package/dist/utils/customCommands.d.ts +0 -1
  133. package/dist/utils/editUtils.d.ts +0 -1
  134. package/dist/utils/fileFormat.d.ts +0 -1
  135. package/dist/utils/fileSearch.d.ts +0 -1
  136. package/dist/utils/fileUtils.d.ts +0 -1
  137. package/dist/utils/gitUtils.d.ts +0 -1
  138. package/dist/utils/globalLogger.d.ts +0 -1
  139. package/dist/utils/groupMessagesByApiRound.d.ts +0 -1
  140. package/dist/utils/hookMatcher.d.ts +0 -1
  141. package/dist/utils/markdownParser.d.ts +0 -1
  142. package/dist/utils/mcpUtils.d.ts +0 -1
  143. package/dist/utils/messageOperations.d.ts +0 -1
  144. package/dist/utils/modelCapabilities.d.ts +0 -1
  145. package/dist/utils/nameGenerator.d.ts +0 -1
  146. package/dist/utils/notificationXml.d.ts +0 -1
  147. package/dist/utils/openaiClient.d.ts +0 -1
  148. package/dist/utils/parseCronExpression.d.ts +0 -1
  149. package/dist/utils/path.d.ts +0 -1
  150. package/dist/utils/pathEncoder.d.ts +0 -1
  151. package/dist/utils/pathSafety.d.ts +0 -1
  152. package/dist/utils/promptHistory.d.ts +0 -1
  153. package/dist/utils/ripgrep.d.ts +0 -1
  154. package/dist/utils/shellResolver.d.ts +0 -1
  155. package/dist/utils/skillParser.d.ts +0 -1
  156. package/dist/utils/stringUtils.d.ts +0 -1
  157. package/dist/utils/subagentParser.d.ts +0 -1
  158. package/dist/utils/taskReminder.d.ts +0 -1
  159. package/dist/utils/tokenCalculation.d.ts +0 -1
  160. package/dist/utils/tokenEstimate.d.ts +0 -1
  161. package/dist/utils/toolResultStorage.d.ts +0 -1
  162. package/dist/utils/worktreeSession.d.ts +0 -1
  163. package/dist/utils/worktreeUtils.d.ts +0 -1
  164. package/dist/workflow/budgetTracker.d.ts +0 -1
  165. package/dist/workflow/concurrencyLimiter.d.ts +0 -1
  166. package/dist/workflow/journal.d.ts +0 -1
  167. package/dist/workflow/progressReporter.d.ts +0 -1
  168. package/dist/workflow/runState.d.ts +0 -1
  169. package/dist/workflow/scriptRuntime.d.ts +0 -1
  170. package/dist/workflow/structuredOutput.d.ts +0 -1
  171. package/dist/workflow/types.d.ts +0 -1
  172. package/dist/workflow/workflowApis.d.ts +0 -1
  173. package/package.json +1 -1
  174. package/src/agent.ts +49 -67
  175. package/src/managers/aiManager.ts +30 -10
  176. package/src/managers/backgroundTaskManager.ts +17 -21
  177. package/src/managers/messageQueue.ts +43 -2
  178. package/src/managers/subagentManager.ts +9 -15
  179. package/src/managers/workflowManager.ts +5 -5
  180. package/src/services/interactionService.ts +11 -0
  181. package/src/services/taskManager.ts +8 -1
  182. package/src/utils/containerSetup.ts +0 -4
  183. package/dist/agent.d.ts.map +0 -1
  184. package/dist/constants/goalPrompts.d.ts.map +0 -1
  185. package/dist/constants/subagents.d.ts.map +0 -1
  186. package/dist/constants/toolLimits.d.ts.map +0 -1
  187. package/dist/constants/tools.d.ts.map +0 -1
  188. package/dist/core/plugin.d.ts.map +0 -1
  189. package/dist/core/session.d.ts.map +0 -1
  190. package/dist/index.d.ts.map +0 -1
  191. package/dist/managers/MemoryRuleManager.d.ts.map +0 -1
  192. package/dist/managers/aiManager.d.ts.map +0 -1
  193. package/dist/managers/backgroundTaskManager.d.ts.map +0 -1
  194. package/dist/managers/bangManager.d.ts.map +0 -1
  195. package/dist/managers/cronManager.d.ts.map +0 -1
  196. package/dist/managers/foregroundTaskManager.d.ts.map +0 -1
  197. package/dist/managers/forkedAgentManager.d.ts.map +0 -1
  198. package/dist/managers/goalManager.d.ts.map +0 -1
  199. package/dist/managers/hookManager.d.ts.map +0 -1
  200. package/dist/managers/liveConfigManager.d.ts.map +0 -1
  201. package/dist/managers/lspManager.d.ts.map +0 -1
  202. package/dist/managers/mcpManager.d.ts.map +0 -1
  203. package/dist/managers/messageManager.d.ts.map +0 -1
  204. package/dist/managers/messageQueue.d.ts.map +0 -1
  205. package/dist/managers/notificationQueue.d.ts +0 -8
  206. package/dist/managers/notificationQueue.d.ts.map +0 -1
  207. package/dist/managers/notificationQueue.js +0 -17
  208. package/dist/managers/permissionManager.d.ts.map +0 -1
  209. package/dist/managers/planManager.d.ts.map +0 -1
  210. package/dist/managers/pluginManager.d.ts.map +0 -1
  211. package/dist/managers/pluginScopeManager.d.ts.map +0 -1
  212. package/dist/managers/reversionManager.d.ts.map +0 -1
  213. package/dist/managers/skillManager.d.ts.map +0 -1
  214. package/dist/managers/slashCommandManager.d.ts.map +0 -1
  215. package/dist/managers/subagentManager.d.ts.map +0 -1
  216. package/dist/managers/toolManager.d.ts.map +0 -1
  217. package/dist/managers/workflowManager.d.ts.map +0 -1
  218. package/dist/prompts/autoMemory.d.ts.map +0 -1
  219. package/dist/prompts/autoMemoryExtraction.d.ts.map +0 -1
  220. package/dist/prompts/index.d.ts.map +0 -1
  221. package/dist/prompts/planModeReminders.d.ts.map +0 -1
  222. package/dist/services/GitService.d.ts.map +0 -1
  223. package/dist/services/MarketplaceService.d.ts.map +0 -1
  224. package/dist/services/MemoryRuleService.d.ts.map +0 -1
  225. package/dist/services/aiService.d.ts.map +0 -1
  226. package/dist/services/authService.d.ts.map +0 -1
  227. package/dist/services/autoMemoryService.d.ts.map +0 -1
  228. package/dist/services/configurationService.d.ts.map +0 -1
  229. package/dist/services/fileWatcher.d.ts.map +0 -1
  230. package/dist/services/hook.d.ts.map +0 -1
  231. package/dist/services/initializationService.d.ts.map +0 -1
  232. package/dist/services/interactionService.d.ts.map +0 -1
  233. package/dist/services/jsonlHandler.d.ts.map +0 -1
  234. package/dist/services/memory.d.ts.map +0 -1
  235. package/dist/services/pluginLoader.d.ts.map +0 -1
  236. package/dist/services/remoteSettingsService.d.ts.map +0 -1
  237. package/dist/services/reversionService.d.ts.map +0 -1
  238. package/dist/services/session.d.ts.map +0 -1
  239. package/dist/services/taskManager.d.ts.map +0 -1
  240. package/dist/telemetry/events.d.ts.map +0 -1
  241. package/dist/telemetry/instrumentation.d.ts.map +0 -1
  242. package/dist/telemetry/sessionTracing.d.ts.map +0 -1
  243. package/dist/tools/agentTool.d.ts.map +0 -1
  244. package/dist/tools/askUserQuestion.d.ts.map +0 -1
  245. package/dist/tools/bashTool.d.ts.map +0 -1
  246. package/dist/tools/buildTool.d.ts.map +0 -1
  247. package/dist/tools/cronCreateTool.d.ts.map +0 -1
  248. package/dist/tools/cronDeleteTool.d.ts.map +0 -1
  249. package/dist/tools/cronListTool.d.ts.map +0 -1
  250. package/dist/tools/editTool.d.ts.map +0 -1
  251. package/dist/tools/enterPlanMode.d.ts.map +0 -1
  252. package/dist/tools/enterWorktreeTool.d.ts.map +0 -1
  253. package/dist/tools/exitPlanMode.d.ts.map +0 -1
  254. package/dist/tools/exitWorktreeTool.d.ts.map +0 -1
  255. package/dist/tools/globTool.d.ts.map +0 -1
  256. package/dist/tools/grepTool.d.ts.map +0 -1
  257. package/dist/tools/lspTool.d.ts.map +0 -1
  258. package/dist/tools/readTool.d.ts.map +0 -1
  259. package/dist/tools/skillTool.d.ts.map +0 -1
  260. package/dist/tools/taskManagementTools.d.ts.map +0 -1
  261. package/dist/tools/taskStopTool.d.ts.map +0 -1
  262. package/dist/tools/types.d.ts.map +0 -1
  263. package/dist/tools/webFetchTool.d.ts.map +0 -1
  264. package/dist/tools/workflowTool.d.ts.map +0 -1
  265. package/dist/tools/writeTool.d.ts.map +0 -1
  266. package/dist/types/agent.d.ts.map +0 -1
  267. package/dist/types/auth.d.ts.map +0 -1
  268. package/dist/types/commands.d.ts.map +0 -1
  269. package/dist/types/config.d.ts.map +0 -1
  270. package/dist/types/configuration.d.ts.map +0 -1
  271. package/dist/types/core.d.ts.map +0 -1
  272. package/dist/types/cron.d.ts.map +0 -1
  273. package/dist/types/environment.d.ts.map +0 -1
  274. package/dist/types/fileSearch.d.ts.map +0 -1
  275. package/dist/types/history.d.ts.map +0 -1
  276. package/dist/types/hooks.d.ts.map +0 -1
  277. package/dist/types/index.d.ts.map +0 -1
  278. package/dist/types/lsp.d.ts.map +0 -1
  279. package/dist/types/marketplace.d.ts.map +0 -1
  280. package/dist/types/mcp.d.ts.map +0 -1
  281. package/dist/types/memoryRule.d.ts.map +0 -1
  282. package/dist/types/messaging.d.ts.map +0 -1
  283. package/dist/types/permissions.d.ts.map +0 -1
  284. package/dist/types/plugins.d.ts.map +0 -1
  285. package/dist/types/processes.d.ts.map +0 -1
  286. package/dist/types/reversion.d.ts.map +0 -1
  287. package/dist/types/session.d.ts.map +0 -1
  288. package/dist/types/skills.d.ts.map +0 -1
  289. package/dist/types/tasks.d.ts.map +0 -1
  290. package/dist/types/telemetry.d.ts.map +0 -1
  291. package/dist/types/tools.d.ts.map +0 -1
  292. package/dist/types/workflow.d.ts.map +0 -1
  293. package/dist/utils/abortUtils.d.ts.map +0 -1
  294. package/dist/utils/atomicWrite.d.ts.map +0 -1
  295. package/dist/utils/bashParser.d.ts.map +0 -1
  296. package/dist/utils/cacheControlUtils.d.ts.map +0 -1
  297. package/dist/utils/commandArgumentParser.d.ts.map +0 -1
  298. package/dist/utils/commandPathResolver.d.ts.map +0 -1
  299. package/dist/utils/configPaths.d.ts.map +0 -1
  300. package/dist/utils/configValidator.d.ts.map +0 -1
  301. package/dist/utils/constants.d.ts.map +0 -1
  302. package/dist/utils/container.d.ts.map +0 -1
  303. package/dist/utils/containerSetup.d.ts.map +0 -1
  304. package/dist/utils/convertMessagesForAPI.d.ts.map +0 -1
  305. package/dist/utils/cronTasks.d.ts.map +0 -1
  306. package/dist/utils/cronTasksLock.d.ts.map +0 -1
  307. package/dist/utils/cronToHuman.d.ts.map +0 -1
  308. package/dist/utils/customCommands.d.ts.map +0 -1
  309. package/dist/utils/editUtils.d.ts.map +0 -1
  310. package/dist/utils/fileFormat.d.ts.map +0 -1
  311. package/dist/utils/fileSearch.d.ts.map +0 -1
  312. package/dist/utils/fileUtils.d.ts.map +0 -1
  313. package/dist/utils/gitUtils.d.ts.map +0 -1
  314. package/dist/utils/globalLogger.d.ts.map +0 -1
  315. package/dist/utils/groupMessagesByApiRound.d.ts.map +0 -1
  316. package/dist/utils/hookMatcher.d.ts.map +0 -1
  317. package/dist/utils/markdownParser.d.ts.map +0 -1
  318. package/dist/utils/mcpUtils.d.ts.map +0 -1
  319. package/dist/utils/messageOperations.d.ts.map +0 -1
  320. package/dist/utils/modelCapabilities.d.ts.map +0 -1
  321. package/dist/utils/nameGenerator.d.ts.map +0 -1
  322. package/dist/utils/notificationXml.d.ts.map +0 -1
  323. package/dist/utils/openaiClient.d.ts.map +0 -1
  324. package/dist/utils/parseCronExpression.d.ts.map +0 -1
  325. package/dist/utils/path.d.ts.map +0 -1
  326. package/dist/utils/pathEncoder.d.ts.map +0 -1
  327. package/dist/utils/pathSafety.d.ts.map +0 -1
  328. package/dist/utils/promptHistory.d.ts.map +0 -1
  329. package/dist/utils/ripgrep.d.ts.map +0 -1
  330. package/dist/utils/shellResolver.d.ts.map +0 -1
  331. package/dist/utils/skillParser.d.ts.map +0 -1
  332. package/dist/utils/stringUtils.d.ts.map +0 -1
  333. package/dist/utils/subagentParser.d.ts.map +0 -1
  334. package/dist/utils/taskReminder.d.ts.map +0 -1
  335. package/dist/utils/tokenCalculation.d.ts.map +0 -1
  336. package/dist/utils/tokenEstimate.d.ts.map +0 -1
  337. package/dist/utils/toolResultStorage.d.ts.map +0 -1
  338. package/dist/utils/worktreeSession.d.ts.map +0 -1
  339. package/dist/utils/worktreeUtils.d.ts.map +0 -1
  340. package/dist/workflow/budgetTracker.d.ts.map +0 -1
  341. package/dist/workflow/concurrencyLimiter.d.ts.map +0 -1
  342. package/dist/workflow/journal.d.ts.map +0 -1
  343. package/dist/workflow/progressReporter.d.ts.map +0 -1
  344. package/dist/workflow/runState.d.ts.map +0 -1
  345. package/dist/workflow/scriptRuntime.d.ts.map +0 -1
  346. package/dist/workflow/structuredOutput.d.ts.map +0 -1
  347. package/dist/workflow/types.d.ts.map +0 -1
  348. package/dist/workflow/workflowApis.d.ts.map +0 -1
  349. package/src/managers/notificationQueue.ts +0 -19
package/dist/agent.d.ts CHANGED
@@ -22,9 +22,8 @@ export declare class Agent {
22
22
  private goalManager;
23
23
  private hookManager;
24
24
  private reversionManager;
25
- private notificationQueue;
26
25
  private messageQueue;
27
- private pendingNotificationPromises;
26
+ private dispatchPromise;
28
27
  private memoryRuleManager;
29
28
  private liveConfigManager;
30
29
  private taskManager;
@@ -90,7 +89,7 @@ export declare class Agent {
90
89
  get isCompacting(): boolean;
91
90
  /** Get bash command execution status */
92
91
  get isCommandRunning(): boolean;
93
- /** Get queued messages */
92
+ /** Get queued user-facing messages (excludes background notifications) */
94
93
  get queuedMessages(): QueuedMessage[];
95
94
  /** Get goal status string */
96
95
  get goalStatus(): string;
@@ -128,13 +127,15 @@ export declare class Agent {
128
127
  type?: "message" | "bang";
129
128
  }): boolean;
130
129
  /**
131
- * Unified dequeue trigger — checks state machine before processing.
132
- * Called from onMessageEnqueued, onLoadingChange(false), and
133
- * onCommandRunningChange(false).
130
+ * Unified dispatch trigger — checks state machine before processing.
131
+ * Handles user messages, bang commands, and background task notifications
132
+ * through a single serialized path. Called from onMessageEnqueued,
133
+ * onLoadingChange(false), and onCommandRunningChange(false).
134
134
  */
135
- private tryDequeue;
135
+ private tryDispatch;
136
136
  /**
137
- * Process the next queued message when the agent becomes idle.
137
+ * Process the next queued item when the agent becomes idle.
138
+ * Handles three item types: user messages, bang commands, and notifications.
138
139
  */
139
140
  private processQueuedMessage;
140
141
  /** Get background bash shell output */
@@ -221,11 +222,6 @@ export declare class Agent {
221
222
  */
222
223
  restoreSession(sessionId: string): Promise<void>;
223
224
  abortAIMessage(): void;
224
- /**
225
- * Process pending background task notifications by injecting them as user messages
226
- * and triggering a new AI response cycle.
227
- */
228
- private processPendingNotifications;
229
225
  /** Execute bash command (bang command) */
230
226
  bang(command: string): Promise<void>;
231
227
  clearMessages(): Promise<void>;
@@ -395,4 +391,3 @@ export declare class Agent {
395
391
  */
396
392
  get hasRunningBackgroundWork(): boolean;
397
393
  }
398
- //# sourceMappingURL=agent.d.ts.map
package/dist/agent.js CHANGED
@@ -51,7 +51,7 @@ export class Agent {
51
51
  */
52
52
  constructor(options) {
53
53
  this.bangManager = null;
54
- this.pendingNotificationPromises = []; // Track pending notification processing
54
+ this.dispatchPromise = null; // Track current dispatch for teardown
55
55
  this.sessionStartTime = Date.now();
56
56
  const { logger, workdir, systemPrompt, stream = true } = options;
57
57
  // Set working directory early as we need it for loading configuration
@@ -111,36 +111,27 @@ export class Agent {
111
111
  this.bangManager = this.container.get("BangManager");
112
112
  this.cronManager = this.container.get("CronManager");
113
113
  this.goalManager = this.container.get("GoalManager");
114
- this.notificationQueue = this.container.get("NotificationQueue");
115
114
  this.messageQueue = this.container.get("MessageQueue");
116
- // Wire up notification queue to trigger AI when notifications arrive while idle
117
- this.notificationQueue.onNotificationsEnqueued = () => {
118
- // If the AI is NOT loading (idle), trigger a new AI cycle to process notifications
119
- if (!this.aiManager.isLoading) {
120
- const pendingPromise = this.processPendingNotifications().catch((error) => {
121
- this.logger?.error("Failed to process pending notifications:", error);
122
- });
123
- this.pendingNotificationPromises.push(pendingPromise);
124
- }
125
- };
126
115
  // Wire up CWD change callback from AIManager to sync Agent's workdir
127
116
  this.aiManager.setOnCwdChange((newCwd) => {
128
117
  this.workdir = newCwd;
129
118
  this.container.register("Workdir", newCwd);
130
119
  this.options.callbacks?.onWorkdirChange?.(newCwd);
131
120
  });
132
- // Wire up message queue to process when agent becomes idle
133
- this.messageQueue.onMessageEnqueued = () => this.tryDequeue();
121
+ // Wire up message queue to process when agent becomes idle.
122
+ // Both user messages and background task notifications enqueue here,
123
+ // unified through a single dispatch path (tryDispatch).
124
+ this.messageQueue.onMessageEnqueued = () => this.tryDispatch();
134
125
  // Wire up AI loading changes to process queue when AI becomes idle
135
126
  this.aiManager.onLoadingChange = (loading) => {
136
127
  if (!loading)
137
- this.tryDequeue();
128
+ this.tryDispatch();
138
129
  };
139
130
  // Wire up bang manager callback for command running changes
140
131
  this.bangManager.onCommandRunningChange = (running) => {
141
132
  this.options.callbacks?.onCommandRunningChange?.(running);
142
133
  if (!running)
143
- this.tryDequeue();
134
+ this.tryDispatch();
144
135
  };
145
136
  // Set initial permission mode if provided
146
137
  if (options.permissionMode) {
@@ -218,9 +209,11 @@ export class Agent {
218
209
  get isCommandRunning() {
219
210
  return this.bangManager?.isCommandRunning ?? false;
220
211
  }
221
- /** Get queued messages */
212
+ /** Get queued user-facing messages (excludes background notifications) */
222
213
  get queuedMessages() {
223
- return this.messageQueue.getQueue();
214
+ return this.messageQueue
215
+ .getQueue()
216
+ .filter((m) => m.type !== "notification");
224
217
  }
225
218
  /** Get goal status string */
226
219
  get goalStatus() {
@@ -279,11 +272,12 @@ export class Agent {
279
272
  return updated;
280
273
  }
281
274
  /**
282
- * Unified dequeue trigger — checks state machine before processing.
283
- * Called from onMessageEnqueued, onLoadingChange(false), and
284
- * onCommandRunningChange(false).
275
+ * Unified dispatch trigger — checks state machine before processing.
276
+ * Handles user messages, bang commands, and background task notifications
277
+ * through a single serialized path. Called from onMessageEnqueued,
278
+ * onLoadingChange(false), and onCommandRunningChange(false).
285
279
  */
286
- tryDequeue() {
280
+ tryDispatch() {
287
281
  if (this.messageQueue.state !== "idle")
288
282
  return;
289
283
  if (!this.messageQueue.hasPending())
@@ -291,17 +285,19 @@ export class Agent {
291
285
  if (this.aiManager.isLoading || this.isCommandRunning)
292
286
  return;
293
287
  this.messageQueue.transitionTo("dispatching");
294
- this.processQueuedMessage()
288
+ this.dispatchPromise = this.processQueuedMessage()
295
289
  .catch((error) => {
296
290
  this.logger?.error("Failed to process queued message:", error);
297
291
  })
298
292
  .finally(() => {
299
293
  this.messageQueue.transitionTo("idle");
300
- this.tryDequeue(); // Re-check after processing
294
+ this.dispatchPromise = null;
295
+ this.tryDispatch(); // Re-check after processing
301
296
  });
302
297
  }
303
298
  /**
304
- * Process the next queued message when the agent becomes idle.
299
+ * Process the next queued item when the agent becomes idle.
300
+ * Handles three item types: user messages, bang commands, and notifications.
305
301
  */
306
302
  async processQueuedMessage() {
307
303
  const next = this.messageQueue.dequeue();
@@ -313,6 +309,26 @@ export class Agent {
313
309
  await this.bangManager?.executeCommand(next.content);
314
310
  await this.messageManager.saveSession();
315
311
  }
312
+ else if (next.type === "notification") {
313
+ // Drain all pending notifications and batch them into a single AI turn
314
+ const allNotifications = [
315
+ next.content,
316
+ ...this.messageQueue.drainNotifications(),
317
+ ];
318
+ for (const xml of allNotifications) {
319
+ const block = parseTaskNotificationXml(xml);
320
+ if (block) {
321
+ this.messageManager.addNotificationMessage({
322
+ taskId: block.taskId,
323
+ taskType: block.taskType,
324
+ status: block.status,
325
+ summary: block.summary,
326
+ outputFile: block.outputFile,
327
+ });
328
+ }
329
+ }
330
+ await this.aiManager.sendAIMessage({ recursionDepth: 0 });
331
+ }
316
332
  else {
317
333
  await this.sendMessage(next.content, next.images);
318
334
  }
@@ -489,29 +505,6 @@ export class Agent {
489
505
  abortAIMessage() {
490
506
  this.aiManager.abortAIMessage();
491
507
  }
492
- /**
493
- * Process pending background task notifications by injecting them as user messages
494
- * and triggering a new AI response cycle.
495
- */
496
- async processPendingNotifications() {
497
- const notifications = this.notificationQueue.dequeueAll();
498
- if (notifications.length === 0)
499
- return;
500
- for (const notification of notifications) {
501
- const block = parseTaskNotificationXml(notification);
502
- if (block) {
503
- this.messageManager.addNotificationMessage({
504
- taskId: block.taskId,
505
- taskType: block.taskType,
506
- status: block.status,
507
- summary: block.summary,
508
- outputFile: block.outputFile,
509
- });
510
- }
511
- }
512
- // Trigger AI to process the notifications
513
- await this.aiManager.sendAIMessage({ recursionDepth: 0 });
514
- }
515
508
  /** Execute bash command (bang command) */
516
509
  async bang(command) {
517
510
  // If the agent is busy, enqueue the bang command
@@ -640,8 +633,9 @@ export class Agent {
640
633
  /** Unified interrupt method, interrupts both AI messages and command execution */
641
634
  abortMessage() {
642
635
  if (this.aiManager.isLoading || this.isCommandRunning) {
643
- // Clear queue first to prevent processQueuedMessage from dequeuing
644
- // when abortAIMessage triggers onLoadingChange(false)
636
+ // Clear user-facing queue items first to prevent processQueuedMessage
637
+ // from dequeuing when abortAIMessage triggers onLoadingChange(false).
638
+ // Notifications are preserved so background task results aren't lost.
645
639
  this.messageQueue.clear();
646
640
  this.options.callbacks?.onQueuedMessagesChange?.(this.queuedMessages);
647
641
  }
@@ -715,14 +709,13 @@ export class Agent {
715
709
  exitReason: "destroy",
716
710
  }).catch(() => { });
717
711
  await shutdownTelemetry();
718
- // Clear notification callback first to prevent any late triggers from
712
+ // Clear message queue callback first to prevent any late triggers from
719
713
  // starting async work during teardown
720
- this.notificationQueue.onNotificationsEnqueued = undefined;
721
- // Await any pending notification processing to prevent race conditions
714
+ this.messageQueue.onMessageEnqueued = undefined;
715
+ // Await any pending dispatch to prevent race conditions
722
716
  // with test teardown (e.g., V8 coverage stream cleanup)
723
- if (this.pendingNotificationPromises.length > 0) {
724
- await Promise.allSettled(this.pendingNotificationPromises);
725
- this.pendingNotificationPromises = [];
717
+ if (this.dispatchPromise) {
718
+ await this.dispatchPromise.catch(() => { });
726
719
  }
727
720
  // Fire SessionEnd hooks (fire-and-forget, don't block shutdown)
728
721
  try {
@@ -1,2 +1 @@
1
1
  export declare const GOAL_EVALUATION_SYSTEM_PROMPT = "You are a goal evaluator. Given a goal condition and a conversation, determine whether the goal has been achieved.\n\nRules:\n- Judge ONLY based on what the conversation shows \u2014 tool outputs, test results, file contents, etc.\n- Do NOT assume work is done without evidence in the conversation.\n- Be strict and conservative: when uncertain, return met: false.\n- Be concise: your reason should be 1-2 sentences.\n\nRespond with JSON only, no other text:\n{\"met\": boolean, \"reason\": \"short explanation\"}";
2
- //# sourceMappingURL=goalPrompts.d.ts.map
@@ -2,4 +2,3 @@ export declare const BASH_SUBAGENT_TYPE = "Bash";
2
2
  export declare const EXPLORE_SUBAGENT_TYPE = "Explore";
3
3
  export declare const PLAN_SUBAGENT_TYPE = "Plan";
4
4
  export declare const GENERAL_PURPOSE_SUBAGENT_TYPE = "general-purpose";
5
- //# sourceMappingURL=subagents.d.ts.map
@@ -9,4 +9,3 @@ export declare const BASH_MAX_OUTPUT_CHARS = 30000;
9
9
  export declare const SKILL_BASH_MAX_OUTPUT_CHARS = 30000;
10
10
  /** Preview size in characters when output is persisted to disk. */
11
11
  export declare const PREVIEW_SIZE_BYTES = 2048;
12
- //# sourceMappingURL=toolLimits.d.ts.map
@@ -22,4 +22,3 @@ export declare const WEB_FETCH_TOOL_NAME = "WebFetch";
22
22
  export declare const ENTER_WORKTREE_TOOL_NAME = "EnterWorktree";
23
23
  export declare const EXIT_WORKTREE_TOOL_NAME = "ExitWorktree";
24
24
  export declare const WORKFLOW_TOOL_NAME = "Workflow";
25
- //# sourceMappingURL=tools.d.ts.map
@@ -87,4 +87,3 @@ export declare class PluginCore {
87
87
  */
88
88
  removeEnabledPlugin(scope: Scope, pluginId: string): Promise<void>;
89
89
  }
90
- //# sourceMappingURL=plugin.d.ts.map
@@ -1,3 +1,2 @@
1
1
  export { listSessions, listAllSessions, truncateContent, loadSessionFromJsonl, loadFullMessageThread, deleteSession, } from "../services/session.js";
2
2
  export type { SessionMetadata, SessionData } from "../services/session.js";
3
- //# sourceMappingURL=session.d.ts.map
package/dist/index.d.ts CHANGED
@@ -25,4 +25,3 @@ export * from "./utils/worktreeSession.js";
25
25
  export * from "./types/index.js";
26
26
  export * from "./tools/buildTool.js";
27
27
  export type { ToolPlugin, ToolResult, ToolContext } from "./tools/types.js";
28
- //# sourceMappingURL=index.d.ts.map
@@ -39,4 +39,3 @@ export declare class MemoryRuleManager {
39
39
  */
40
40
  reload(): Promise<void>;
41
41
  }
42
- //# sourceMappingURL=MemoryRuleManager.d.ts.map
@@ -21,6 +21,7 @@ export interface AIManagerOptions {
21
21
  export declare class AIManager {
22
22
  private container;
23
23
  isLoading: boolean;
24
+ private turnGeneration;
24
25
  private abortController;
25
26
  onLoadingChange?: (loading: boolean) => void;
26
27
  private toolAbortController;
@@ -139,4 +140,3 @@ export declare class AIManager {
139
140
  */
140
141
  private executePostToolUseHooks;
141
142
  }
142
- //# sourceMappingURL=aiManager.d.ts.map
@@ -53,6 +53,7 @@ export class AIManager {
53
53
  constructor(container, options) {
54
54
  this.container = container;
55
55
  this.isLoading = false;
56
+ this.turnGeneration = 0; // Guards against concurrent sendAIMessage turns
56
57
  this.abortController = null;
57
58
  this.toolAbortController = null;
58
59
  this.consecutiveCompactionFailures = 0;
@@ -241,6 +242,9 @@ export class AIManager {
241
242
  options?.callbacks?.onLoadingChange?.(isLoading);
242
243
  }
243
244
  abortAIMessage() {
245
+ // Bump generation so the in-flight turn's end-of-turn setIsLoading(false)
246
+ // is skipped (generation mismatch), preventing it from racing with this abort.
247
+ this.turnGeneration++;
244
248
  // Interrupt AI service
245
249
  if (this.abortController) {
246
250
  try {
@@ -560,6 +564,14 @@ export class AIManager {
560
564
  async sendAIMessage(options = {}) {
561
565
  const { recursionDepth = 0, model, allowedRules, maxTokens } = options;
562
566
  let turnOffset = recursionDepth;
567
+ // Reserve this turn synchronously before any async work. Bumping the
568
+ // generation invalidates any in-flight turn's end-of-turn cleanup, and
569
+ // recording myGeneration lets us skip cleanup if a newer turn (or abort)
570
+ // has superseded us. setIsLoading(true) here also closes the "idle but
571
+ // previous turn not finished" race window by marking us busy immediately.
572
+ this.turnGeneration++;
573
+ const myGeneration = this.turnGeneration;
574
+ this.setIsLoading(true);
563
575
  outer: while (true) {
564
576
  let shouldRestart = false;
565
577
  // OpenTelemetry: start interaction span for this turn (initial call only)
@@ -577,9 +589,8 @@ export class AIManager {
577
589
  prompt_length: String(userPromptText.length),
578
590
  }).catch(() => { }); // Non-blocking
579
591
  }
580
- // Set loading state early for the initial call, before any async work
592
+ // Apply allowed rules for the initial call
581
593
  if (turnOffset === 0) {
582
- this.setIsLoading(true);
583
594
  if (allowedRules && allowedRules.length > 0) {
584
595
  this.permissionManager?.addTemporaryRules(allowedRules);
585
596
  }
@@ -976,8 +987,6 @@ export class AIManager {
976
987
  endInteractionSpan();
977
988
  // Save session in each iteration to ensure message persistence
978
989
  await this.messageManager.saveSession();
979
- // Set loading to false first
980
- this.setIsLoading(false);
981
990
  // Clear temporary rules
982
991
  this.permissionManager?.clearTemporaryRules();
983
992
  // Clear abort controllers
@@ -1058,11 +1067,11 @@ export class AIManager {
1058
1067
  }
1059
1068
  // Inject pending notifications from background tasks (after Stop hooks,
1060
1069
  // aligned with Claude Code which fires Stop hooks unconditionally)
1061
- const notificationQueue = this.container.has("NotificationQueue")
1062
- ? this.container.get("NotificationQueue")
1070
+ const messageQueue = this.container.has("MessageQueue")
1071
+ ? this.container.get("MessageQueue")
1063
1072
  : undefined;
1064
- if (notificationQueue && notificationQueue.hasPending()) {
1065
- const notifications = notificationQueue.dequeueAll();
1073
+ if (messageQueue && messageQueue.hasNotifications()) {
1074
+ const notifications = messageQueue.drainNotifications();
1066
1075
  for (const notification of notifications) {
1067
1076
  const block = parseTaskNotificationXml(notification);
1068
1077
  if (block) {
@@ -1080,8 +1089,16 @@ export class AIManager {
1080
1089
  turnOffset = 0;
1081
1090
  }
1082
1091
  }
1083
- if (!shouldRestart)
1092
+ if (!shouldRestart) {
1093
+ // Release loading state only after ALL cleanup is done (session save,
1094
+ // Stop hooks, notification injection). Generation check ensures a
1095
+ // superseded (aborted or newer) turn doesn't clobber the current
1096
+ // loading state.
1097
+ if (myGeneration === this.turnGeneration) {
1098
+ this.setIsLoading(false);
1099
+ }
1084
1100
  break outer;
1101
+ }
1085
1102
  }
1086
1103
  }
1087
1104
  /**
@@ -15,7 +15,6 @@ export declare class BackgroundTaskManager {
15
15
  private callbacks;
16
16
  private workdir;
17
17
  constructor(container: Container, options: BackgroundTaskManagerOptions);
18
- private get notificationQueue();
19
18
  /**
20
19
  * Fire the onBackgroundTasksChange callback so UI consumers refresh.
21
20
  * Public so other managers (e.g. WorkflowManager) can trigger a refresh
@@ -43,4 +42,3 @@ export declare class BackgroundTaskManager {
43
42
  stopTask(id: string): boolean;
44
43
  cleanup(): void;
45
44
  }
46
- //# sourceMappingURL=backgroundTaskManager.d.ts.map
@@ -13,9 +13,6 @@ export class BackgroundTaskManager {
13
13
  this.callbacks = options.callbacks || {};
14
14
  this.workdir = options.workdir;
15
15
  }
16
- get notificationQueue() {
17
- return this.container.get("NotificationQueue");
18
- }
19
16
  /**
20
17
  * Fire the onBackgroundTasksChange callback so UI consumers refresh.
21
18
  * Public so other managers (e.g. WorkflowManager) can trigger a refresh
@@ -141,13 +138,13 @@ export class BackgroundTaskManager {
141
138
  this.notifyTasksChange();
142
139
  // Skip notification if task was manually killed (user/agent-initiated stop)
143
140
  if (!wasKilled) {
144
- const notificationQueue = this.container.has("NotificationQueue")
145
- ? this.container.get("NotificationQueue")
141
+ const messageQueue = this.container.has("MessageQueue")
142
+ ? this.container.get("MessageQueue")
146
143
  : undefined;
147
- if (notificationQueue) {
144
+ if (messageQueue) {
148
145
  const statusStr = shell.status;
149
146
  const summary = `Command "${command}" ${statusStr} with exit code ${code ?? 0}`;
150
- notificationQueue.enqueue(`<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>`);
147
+ messageQueue.enqueueNotification(`<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>`);
151
148
  }
152
149
  }
153
150
  };
@@ -167,12 +164,12 @@ export class BackgroundTaskManager {
167
164
  shell.runtime = shell.endTime - startTime;
168
165
  this.notifyTasksChange();
169
166
  // Enqueue error notification
170
- const notificationQueue = this.container.has("NotificationQueue")
171
- ? this.container.get("NotificationQueue")
167
+ const messageQueue = this.container.has("MessageQueue")
168
+ ? this.container.get("MessageQueue")
172
169
  : undefined;
173
- if (notificationQueue) {
170
+ if (messageQueue) {
174
171
  const summary = `Command "${command}" failed with error: ${stripAnsiColors(error.message)}`;
175
- notificationQueue.enqueue(`<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>`);
172
+ messageQueue.enqueueNotification(`<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>`);
176
173
  }
177
174
  };
178
175
  child.stdout?.on("data", onStdout);
@@ -278,13 +275,13 @@ export class BackgroundTaskManager {
278
275
  this.notifyTasksChange();
279
276
  // Skip notification if task was manually killed (user/agent-initiated stop)
280
277
  if (!wasKilled) {
281
- const notificationQueue = this.container.has("NotificationQueue")
282
- ? this.container.get("NotificationQueue")
278
+ const messageQueue = this.container.has("MessageQueue")
279
+ ? this.container.get("MessageQueue")
283
280
  : undefined;
284
- if (notificationQueue) {
281
+ if (messageQueue) {
285
282
  const statusStr = shell.status;
286
283
  const summary = `Command "${command}" ${statusStr} with exit code ${code ?? 0}`;
287
- notificationQueue.enqueue(`<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>`);
284
+ messageQueue.enqueueNotification(`<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>`);
288
285
  }
289
286
  }
290
287
  });
@@ -301,12 +298,12 @@ export class BackgroundTaskManager {
301
298
  shell.runtime = shell.endTime - startTime;
302
299
  this.notifyTasksChange();
303
300
  // Enqueue error notification
304
- const notificationQueue = this.container.has("NotificationQueue")
305
- ? this.container.get("NotificationQueue")
301
+ const messageQueue = this.container.has("MessageQueue")
302
+ ? this.container.get("MessageQueue")
306
303
  : undefined;
307
- if (notificationQueue) {
304
+ if (messageQueue) {
308
305
  const summary = `Command "${command}" failed with error: ${stripAnsiColors(error.message)}`;
309
- notificationQueue.enqueue(`<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>`);
306
+ messageQueue.enqueueNotification(`<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>`);
310
307
  }
311
308
  });
312
309
  return id;
@@ -18,4 +18,3 @@ export declare class BangManager {
18
18
  executeCommand(command: string): Promise<number>;
19
19
  abortCommand(): void;
20
20
  }
21
- //# sourceMappingURL=bangManager.d.ts.map
@@ -23,4 +23,3 @@ export declare class CronManager {
23
23
  private getDeterministicRandom;
24
24
  private checkJobs;
25
25
  }
26
- //# sourceMappingURL=cronManager.d.ts.map
@@ -9,4 +9,3 @@ export declare class ForegroundTaskManager implements IForegroundTaskManager {
9
9
  backgroundCurrentTask(): Promise<void>;
10
10
  hasActiveTasks(): boolean;
11
11
  }
12
- //# sourceMappingURL=foregroundTaskManager.d.ts.map
@@ -48,4 +48,3 @@ export declare class ForkedAgentManager {
48
48
  getActiveForks(): ForkedAgentEntry[];
49
49
  private notifyChange;
50
50
  }
51
- //# sourceMappingURL=forkedAgentManager.d.ts.map
@@ -40,4 +40,3 @@ export declare class GoalManager {
40
40
  private parseEvaluationResponse;
41
41
  private formatElapsed;
42
42
  }
43
- //# sourceMappingURL=goalManager.d.ts.map
@@ -143,4 +143,3 @@ export declare class HookManager {
143
143
  */
144
144
  executePostCompactHooks(sessionId: string, transcriptPath: string, compactSummary: string): Promise<HookExecutionResult[]>;
145
145
  }
146
- //# sourceMappingURL=hookManager.d.ts.map
@@ -83,4 +83,3 @@ export declare class LiveConfigManager {
83
83
  */
84
84
  private getConfigurationPaths;
85
85
  }
86
- //# sourceMappingURL=liveConfigManager.d.ts.map
@@ -39,4 +39,3 @@ export declare class LspManager implements ILspManager {
39
39
  cleanup(): Promise<void>;
40
40
  }
41
41
  export {};
42
- //# sourceMappingURL=lspManager.d.ts.map
@@ -85,4 +85,3 @@ export declare class McpManager {
85
85
  */
86
86
  isMcpTool(name: string): boolean;
87
87
  }
88
- //# sourceMappingURL=mcpManager.d.ts.map
@@ -254,4 +254,3 @@ export declare class MessageManager {
254
254
  */
255
255
  rebuildLoadedRuleIds(): void;
256
256
  }
257
- //# sourceMappingURL=messageManager.d.ts.map
@@ -1,7 +1,7 @@
1
1
  export type QueueState = "idle" | "dispatching" | "running";
2
2
  export interface QueuedMessage {
3
3
  id?: string;
4
- type?: "message" | "bang";
4
+ type?: "message" | "bang" | "notification";
5
5
  content: string;
6
6
  images?: Array<{
7
7
  path: string;
@@ -19,6 +19,10 @@ export declare class MessageQueue {
19
19
  transitionTo(newState: QueueState): boolean;
20
20
  enqueue(message: QueuedMessage): void;
21
21
  dequeue(): QueuedMessage | null;
22
+ /**
23
+ * Clear user-facing items (messages, bang commands) but preserve pending
24
+ * notifications so background task results are not lost on abort.
25
+ */
22
26
  clear(): void;
23
27
  hasPending(): boolean;
24
28
  getQueue(): QueuedMessage[];
@@ -34,5 +38,16 @@ export declare class MessageQueue {
34
38
  }): boolean;
35
39
  popLastEditable(): QueuedMessage | null;
36
40
  popAllEditable(): QueuedMessage[];
41
+ /**
42
+ * Enqueue a background task notification (XML string). Notifications are
43
+ * not user-editable and not surfaced in the queued-messages UI.
44
+ */
45
+ enqueueNotification(xml: string): void;
46
+ /** Whether any notification items are pending. */
47
+ hasNotifications(): boolean;
48
+ /**
49
+ * Drain all notification items, returning their XML content. Non-notification
50
+ * items (messages, bang commands) are preserved in the queue.
51
+ */
52
+ drainNotifications(): string[];
37
53
  }
38
- //# sourceMappingURL=messageQueue.d.ts.map
@@ -30,8 +30,12 @@ export class MessageQueue {
30
30
  dequeue() {
31
31
  return this.queue.shift() ?? null;
32
32
  }
33
+ /**
34
+ * Clear user-facing items (messages, bang commands) but preserve pending
35
+ * notifications so background task results are not lost on abort.
36
+ */
33
37
  clear() {
34
- this.queue = [];
38
+ this.queue = this.queue.filter((m) => m.type === "notification");
35
39
  this._state = "idle";
36
40
  }
37
41
  hasPending() {
@@ -91,4 +95,39 @@ export class MessageQueue {
91
95
  this.queue = remaining;
92
96
  return editable;
93
97
  }
98
+ /**
99
+ * Enqueue a background task notification (XML string). Notifications are
100
+ * not user-editable and not surfaced in the queued-messages UI.
101
+ */
102
+ enqueueNotification(xml) {
103
+ this.queue.push({
104
+ id: `mq-${this.nextId++}`,
105
+ type: "notification",
106
+ content: xml,
107
+ editable: false,
108
+ });
109
+ this.onMessageEnqueued?.();
110
+ }
111
+ /** Whether any notification items are pending. */
112
+ hasNotifications() {
113
+ return this.queue.some((m) => m.type === "notification");
114
+ }
115
+ /**
116
+ * Drain all notification items, returning their XML content. Non-notification
117
+ * items (messages, bang commands) are preserved in the queue.
118
+ */
119
+ drainNotifications() {
120
+ const notifications = [];
121
+ const remaining = [];
122
+ for (const msg of this.queue) {
123
+ if (msg.type === "notification") {
124
+ notifications.push(msg.content);
125
+ }
126
+ else {
127
+ remaining.push(msg);
128
+ }
129
+ }
130
+ this.queue = remaining;
131
+ return notifications;
132
+ }
94
133
  }
@@ -183,4 +183,3 @@ export declare class PermissionManager {
183
183
  */
184
184
  addPermissionRule(rule: string): Promise<void>;
185
185
  }
186
- //# sourceMappingURL=permissionManager.d.ts.map