@ashx-j/lunr 0.2.19 → 0.2.21

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 (259) hide show
  1. package/CHANGELOG.md +36 -1
  2. package/README.md +2 -2
  3. package/dist/builtin-extensions/index.d.ts.map +1 -1
  4. package/dist/builtin-extensions/index.js +0 -2
  5. package/dist/builtin-extensions/index.js.map +1 -1
  6. package/dist/builtin-extensions/lunr-todos.d.ts +6 -5
  7. package/dist/builtin-extensions/lunr-todos.d.ts.map +1 -1
  8. package/dist/builtin-extensions/lunr-todos.js +9 -7
  9. package/dist/builtin-extensions/lunr-todos.js.map +1 -1
  10. package/dist/builtin-extensions/pi-intercom/broker/spawn.d.ts +6 -4
  11. package/dist/builtin-extensions/pi-intercom/broker/spawn.d.ts.map +1 -1
  12. package/dist/builtin-extensions/pi-intercom/broker/spawn.js +114 -61
  13. package/dist/builtin-extensions/pi-intercom/broker/spawn.js.map +1 -1
  14. package/dist/builtin-extensions/pi-intercom/index.d.ts.map +1 -1
  15. package/dist/builtin-extensions/pi-intercom/index.js +360 -351
  16. package/dist/builtin-extensions/pi-intercom/index.js.map +1 -1
  17. package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.d.ts.map +1 -1
  18. package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.js +2 -2
  19. package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.js.map +1 -1
  20. package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts +8 -6
  21. package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts.map +1 -1
  22. package/dist/builtin-extensions/pi-subagents/src/extension/index.js +128 -57
  23. package/dist/builtin-extensions/pi-subagents/src/extension/index.js.map +1 -1
  24. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.d.ts +18 -8
  25. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.d.ts.map +1 -1
  26. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js +38 -13
  27. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js.map +1 -1
  28. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts +4 -3
  29. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts.map +1 -1
  30. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js +24 -14
  31. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js.map +1 -1
  32. package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.d.ts +8 -1
  33. package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.d.ts.map +1 -1
  34. package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.js +247 -18
  35. package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.js.map +1 -1
  36. package/dist/builtin-extensions/pi-subagents/src/intercom/result-intercom.d.ts +1 -0
  37. package/dist/builtin-extensions/pi-subagents/src/intercom/result-intercom.d.ts.map +1 -1
  38. package/dist/builtin-extensions/pi-subagents/src/intercom/result-intercom.js +1 -1
  39. package/dist/builtin-extensions/pi-subagents/src/intercom/result-intercom.js.map +1 -1
  40. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.d.ts +29 -0
  41. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.d.ts.map +1 -0
  42. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.js +179 -0
  43. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.js.map +1 -0
  44. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.d.ts +89 -0
  45. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.d.ts.map +1 -0
  46. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.js +541 -0
  47. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.js.map +1 -0
  48. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.d.ts +11 -1
  49. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.d.ts.map +1 -1
  50. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.js +38 -12
  51. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.js.map +1 -1
  52. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.d.ts.map +1 -1
  53. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.js +3 -2
  54. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.js.map +1 -1
  55. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.d.ts +2 -1
  56. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.d.ts.map +1 -1
  57. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.js +35 -8
  58. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.js.map +1 -1
  59. package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.d.ts +7 -3
  60. package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.d.ts.map +1 -1
  61. package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.js +26 -4
  62. package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.js.map +1 -1
  63. package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.d.ts +1 -0
  64. package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.d.ts.map +1 -1
  65. package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.js +55 -38
  66. package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.js.map +1 -1
  67. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.d.ts +100 -0
  68. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.d.ts.map +1 -1
  69. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js +46 -31
  70. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js.map +1 -1
  71. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.d.ts +3 -6
  72. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.d.ts.map +1 -1
  73. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.js +64 -5
  74. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.js.map +1 -1
  75. package/dist/builtin-extensions/pi-subagents/src/runs/background/top-level-async.d.ts +15 -2
  76. package/dist/builtin-extensions/pi-subagents/src/runs/background/top-level-async.d.ts.map +1 -1
  77. package/dist/builtin-extensions/pi-subagents/src/runs/background/top-level-async.js +14 -4
  78. package/dist/builtin-extensions/pi-subagents/src/runs/background/top-level-async.js.map +1 -1
  79. package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.d.ts.map +1 -1
  80. package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js +2 -1
  81. package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js.map +1 -1
  82. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.d.ts.map +1 -1
  83. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.js +21 -8
  84. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.js.map +1 -1
  85. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.d.ts.map +1 -1
  86. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js +1 -1
  87. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js.map +1 -1
  88. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts +0 -1
  89. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts.map +1 -1
  90. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js +71 -25
  91. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js.map +1 -1
  92. package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.d.ts +2 -0
  93. package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.d.ts.map +1 -1
  94. package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.js +75 -18
  95. package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.js.map +1 -1
  96. package/dist/builtin-extensions/pi-subagents/src/runs/shared/completion-guard.d.ts +1 -1
  97. package/dist/builtin-extensions/pi-subagents/src/runs/shared/completion-guard.d.ts.map +1 -1
  98. package/dist/builtin-extensions/pi-subagents/src/runs/shared/completion-guard.js +1 -1
  99. package/dist/builtin-extensions/pi-subagents/src/runs/shared/completion-guard.js.map +1 -1
  100. package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.d.ts +13 -1
  101. package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.d.ts.map +1 -1
  102. package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.js +67 -11
  103. package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.js.map +1 -1
  104. package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.d.ts +1 -0
  105. package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.d.ts.map +1 -1
  106. package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.js.map +1 -1
  107. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.d.ts +3 -0
  108. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.d.ts.map +1 -1
  109. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.js +7 -2
  110. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.js.map +1 -1
  111. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.d.ts.map +1 -1
  112. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.js +13 -3
  113. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.js.map +1 -1
  114. package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.d.ts +2 -2
  115. package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.d.ts.map +1 -1
  116. package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.js +5 -10
  117. package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.js.map +1 -1
  118. package/dist/builtin-extensions/pi-subagents/src/shared/async-guidance.d.ts +2 -0
  119. package/dist/builtin-extensions/pi-subagents/src/shared/async-guidance.d.ts.map +1 -0
  120. package/dist/builtin-extensions/pi-subagents/src/shared/async-guidance.js +3 -0
  121. package/dist/builtin-extensions/pi-subagents/src/shared/async-guidance.js.map +1 -0
  122. package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.d.ts +3 -0
  123. package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.d.ts.map +1 -1
  124. package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.js +68 -11
  125. package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.js.map +1 -1
  126. package/dist/builtin-extensions/pi-subagents/src/shared/formatters.d.ts +12 -1
  127. package/dist/builtin-extensions/pi-subagents/src/shared/formatters.d.ts.map +1 -1
  128. package/dist/builtin-extensions/pi-subagents/src/shared/formatters.js +21 -2
  129. package/dist/builtin-extensions/pi-subagents/src/shared/formatters.js.map +1 -1
  130. package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts +21 -4
  131. package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts.map +1 -1
  132. package/dist/builtin-extensions/pi-subagents/src/shared/types.js +1 -1
  133. package/dist/builtin-extensions/pi-subagents/src/shared/types.js.map +1 -1
  134. package/dist/builtin-extensions/pi-subagents/src/slash/delegation-adapters.d.ts.map +1 -1
  135. package/dist/builtin-extensions/pi-subagents/src/slash/delegation-adapters.js.map +1 -1
  136. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.d.ts +7 -0
  137. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.d.ts.map +1 -1
  138. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.js +11 -7
  139. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.js.map +1 -1
  140. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts +6 -0
  141. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts.map +1 -1
  142. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js +46 -29
  143. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js.map +1 -1
  144. package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts +46 -4
  145. package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts.map +1 -1
  146. package/dist/builtin-extensions/pi-subagents/src/tui/render.js +407 -450
  147. package/dist/builtin-extensions/pi-subagents/src/tui/render.js.map +1 -1
  148. package/dist/builtin-extensions/pi-subagents/src/watchdog/register-main.d.ts.map +1 -1
  149. package/dist/builtin-extensions/pi-subagents/src/watchdog/register-main.js +1 -1
  150. package/dist/builtin-extensions/pi-subagents/src/watchdog/register-main.js.map +1 -1
  151. package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.d.ts +2 -13
  152. package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.d.ts.map +1 -1
  153. package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.js +5 -91
  154. package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.js.map +1 -1
  155. package/dist/core/customize.d.ts +2 -0
  156. package/dist/core/customize.d.ts.map +1 -1
  157. package/dist/core/customize.js +3 -0
  158. package/dist/core/customize.js.map +1 -1
  159. package/dist/core/permissions.d.ts +1 -0
  160. package/dist/core/permissions.d.ts.map +1 -1
  161. package/dist/core/permissions.js +8 -4
  162. package/dist/core/permissions.js.map +1 -1
  163. package/dist/core/plan-mode.d.ts.map +1 -1
  164. package/dist/core/plan-mode.js +0 -5
  165. package/dist/core/plan-mode.js.map +1 -1
  166. package/dist/core/runtime-bridges.d.ts.map +1 -1
  167. package/dist/core/runtime-bridges.js +0 -2
  168. package/dist/core/runtime-bridges.js.map +1 -1
  169. package/dist/core/settings-manager.d.ts +4 -0
  170. package/dist/core/settings-manager.d.ts.map +1 -1
  171. package/dist/core/settings-manager.js +11 -0
  172. package/dist/core/settings-manager.js.map +1 -1
  173. package/dist/core/subagent-cancellation.d.ts +21 -0
  174. package/dist/core/subagent-cancellation.d.ts.map +1 -0
  175. package/dist/core/subagent-cancellation.js +53 -0
  176. package/dist/core/subagent-cancellation.js.map +1 -0
  177. package/dist/core/subagent-spinner-setting.d.ts +6 -0
  178. package/dist/core/subagent-spinner-setting.d.ts.map +1 -0
  179. package/dist/core/subagent-spinner-setting.js +12 -0
  180. package/dist/core/subagent-spinner-setting.js.map +1 -0
  181. package/dist/core/subagent-spinner.d.ts +4 -0
  182. package/dist/core/subagent-spinner.d.ts.map +1 -0
  183. package/dist/core/subagent-spinner.js +6 -0
  184. package/dist/core/subagent-spinner.js.map +1 -0
  185. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  186. package/dist/modes/interactive/components/assistant-message.js +12 -18
  187. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  188. package/dist/modes/interactive/components/settings-selector.d.ts +4 -0
  189. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  190. package/dist/modes/interactive/components/settings-selector.js +73 -1
  191. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  192. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  193. package/dist/modes/interactive/components/tool-execution.js +12 -0
  194. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  195. package/dist/modes/interactive/extension-widget-order.d.ts +8 -0
  196. package/dist/modes/interactive/extension-widget-order.d.ts.map +1 -0
  197. package/dist/modes/interactive/extension-widget-order.js +37 -0
  198. package/dist/modes/interactive/extension-widget-order.js.map +1 -0
  199. package/dist/modes/interactive/interactive-mode.d.ts +1 -0
  200. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  201. package/dist/modes/interactive/interactive-mode.js +44 -22
  202. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  203. package/dist/node-runtime/{agent-session-services-35WNVGMR.js → agent-session-services-C743TYQE.js} +6 -5
  204. package/dist/node-runtime/{builtin-extensions-322XDDEM.js → builtin-extensions-JCOPAAB5.js} +3 -2
  205. package/dist/node-runtime/{chunk-XATUM2HK.js → chunk-25I2BHAA.js} +1 -1
  206. package/dist/node-runtime/{chunk-TXHKBRHZ.js → chunk-2BUAYZ7K.js} +136 -53
  207. package/dist/node-runtime/chunk-5ZH3ZFIZ.js +308 -0
  208. package/dist/node-runtime/{chunk-J26TSGDL.js → chunk-6N22HULO.js} +8 -5
  209. package/dist/node-runtime/chunk-A3KMVBZV.js +60 -0
  210. package/dist/node-runtime/{chunk-4FX25LWP.js → chunk-AWVD5IEY.js} +20 -421
  211. package/dist/node-runtime/{chunk-ZRCBN365.js → chunk-GB2MGFLI.js} +12 -12
  212. package/dist/node-runtime/chunk-LISUTZS3.js +19 -0
  213. package/dist/node-runtime/{chunk-PNJSG3IZ.js → chunk-LTYWTR3V.js} +1 -369
  214. package/dist/node-runtime/{chunk-TFBIJTM3.js → chunk-PDNXVXMD.js} +13 -13
  215. package/dist/node-runtime/{chunk-MCUNIRD5.js → chunk-SY2TFMLO.js} +532 -261
  216. package/dist/node-runtime/{chunk-HQCKFM2O.js → chunk-VGYZ3APQ.js} +3 -0
  217. package/dist/node-runtime/{chunk-4DJ6HEGH.js → chunk-VZR3NCM7.js} +3 -3
  218. package/dist/node-runtime/chunk-W3SILANP.js +24 -0
  219. package/dist/node-runtime/{chunk-CBGB57XT.js → chunk-WLLDXJRT.js} +10 -0
  220. package/dist/node-runtime/{chunk-ATGA2WLC.js → chunk-XI77KVKA.js} +399 -36
  221. package/dist/node-runtime/{chunk-4CSFRBCN.js → chunk-Y5KOEMBH.js} +1 -1
  222. package/dist/node-runtime/{chunk-AROOY4BB.js → chunk-YMEAYRBE.js} +1 -1
  223. package/dist/node-runtime/{command-DWUM5X3U.js → command-P4NYCJ2M.js} +1 -1
  224. package/dist/node-runtime/{customize-XEXL2DGQ.js → customize-LF5VST47.js} +1 -1
  225. package/dist/node-runtime/{gateway-UZXMFGWY.js → gateway-BM6NLOH4.js} +2 -2
  226. package/dist/node-runtime/index.js +16 -13
  227. package/dist/node-runtime/{interactive-mode-QT5IKGQ5.js → interactive-mode-EVVBA64D.js} +11 -8
  228. package/dist/node-runtime/{lunr-cron-QPBTKBGI.js → lunr-cron-4VHP4E4B.js} +2 -2
  229. package/dist/node-runtime/main.js +14 -12
  230. package/dist/node-runtime/{package-manager-cli-7RKSZGEN.js → package-manager-cli-N37546V5.js} +5 -4
  231. package/dist/node-runtime/{pi-intercom-EEMBGQID.js → pi-intercom-NV2LW6X7.js} +108 -87
  232. package/dist/node-runtime/{pi-subagents-7YJ3I4VE.js → pi-subagents-6MUIFNDM.js} +1262 -599
  233. package/dist/node-runtime/rpc-entry.js +14 -12
  234. package/dist/node-runtime/{runtime-bridges-3RKBDLNA.js → runtime-bridges-2VQTLPOZ.js} +3 -5
  235. package/dist/node-runtime/{settings-manager-GHPTUN7R.js → settings-manager-CUGAZWAB.js} +2 -1
  236. package/dist/node-runtime/{subagent-executor-5Q5A4HJ2.js → subagent-executor-MH4A7CCF.js} +181 -294
  237. package/dist/node-runtime/{update-cli-L3JIBH2U.js → update-cli-XTZMZGOL.js} +2 -1
  238. package/docs/features.md +22 -4
  239. package/docs/keybindings.md +3 -1
  240. package/docs/settings.md +3 -2
  241. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  242. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  243. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  244. package/examples/extensions/gondolin/package-lock.json +2 -2
  245. package/examples/extensions/gondolin/package.json +1 -1
  246. package/examples/extensions/sandbox/package-lock.json +2 -2
  247. package/examples/extensions/sandbox/package.json +1 -1
  248. package/examples/extensions/with-deps/package-lock.json +2 -2
  249. package/examples/extensions/with-deps/package.json +1 -1
  250. package/package.json +4 -4
  251. package/dist/builtin-extensions/lunr-settings-tools.d.ts +0 -4
  252. package/dist/builtin-extensions/lunr-settings-tools.d.ts.map +0 -1
  253. package/dist/builtin-extensions/lunr-settings-tools.js +0 -120
  254. package/dist/builtin-extensions/lunr-settings-tools.js.map +0 -1
  255. package/dist/core/settings-tools-bridge.d.ts +0 -35
  256. package/dist/core/settings-tools-bridge.d.ts.map +0 -1
  257. package/dist/core/settings-tools-bridge.js +0 -56
  258. package/dist/core/settings-tools-bridge.js.map +0 -1
  259. package/dist/node-runtime/chunk-3NMWLTPV.js +0 -64
@@ -3,7 +3,7 @@ import { randomUUID } from "crypto";
3
3
  import { Type } from "typebox";
4
4
  import { Text } from "@ashx-j/lunr-tui";
5
5
  import { IntercomClient } from "./broker/client.js";
6
- import { spawnBrokerIfNeeded } from "./broker/spawn.js";
6
+ import { isNativeSupervisorChannelActive, spawnBrokerIfNeeded } from "./broker/spawn.js";
7
7
  import { SessionListOverlay } from "./ui/session-list.js";
8
8
  import { ComposeOverlay } from "./ui/compose.js";
9
9
  import { InlineMessageComponent } from "./ui/inline-message.js";
@@ -310,7 +310,8 @@ function parseSubagentIntercomPayload(payload) {
310
310
  return null;
311
311
  }
312
312
  const requestId = typeof record.requestId === "string" ? record.requestId : undefined;
313
- return { to: record.to, message: record.message, ...(requestId ? { requestId } : {}) };
313
+ const ownerNotificationSessionId = typeof record.ownerNotificationSessionId === "string" ? record.ownerNotificationSessionId : undefined;
314
+ return { to: record.to, message: record.message, ...(requestId ? { requestId } : {}), ...(ownerNotificationSessionId ? { ownerNotificationSessionId } : {}) };
314
315
  }
315
316
  function resolveIntercomPresenceName(sessionName, sessionId) {
316
317
  const trimmedName = sessionName?.trim();
@@ -875,6 +876,9 @@ export default function piIntercomExtension(pi) {
875
876
  agentRunning = false;
876
877
  activeTools.clear();
877
878
  startNamePoll();
879
+ if (isNativeSupervisorChannelActive()) {
880
+ return;
881
+ }
878
882
  const startupGeneration = runtimeGeneration;
879
883
  startupConnectTimer = setTimeout(() => {
880
884
  startupConnectTimer = null;
@@ -899,67 +903,70 @@ export default function piIntercomExtension(pi) {
899
903
  ...(error ? { error: getErrorMessage(error) } : {}),
900
904
  });
901
905
  }
906
+ const resultDeliveries = new Map();
907
+ const acknowledgedResults = [];
902
908
  function relaySubagentIntercomPayload(payload, options) {
903
909
  const parsed = parseSubagentIntercomPayload(payload);
904
910
  if (!parsed)
905
911
  return;
906
912
  const relayGeneration = runtimeGeneration;
907
- void (async () => {
908
- const relayStillLive = () => !runtimeStarted || Boolean(getLiveContext(runtimeContext, relayGeneration));
909
- if (!relayStillLive()) {
910
- return;
911
- }
912
- if (currentSessionTargetMatches(parsed.to)) {
913
- deliverLocalSubagentRelayMessage(options.sender, options.status, parsed.message);
914
- if (options.acknowledge)
915
- emitResultDelivery(parsed.requestId, true);
916
- return;
917
- }
918
- let activeClient;
919
- let target;
920
- try {
921
- activeClient = await ensureConnected("background");
922
- target = await resolveSessionTarget(activeClient, parsed.to) ?? parsed.to;
923
- }
924
- catch (error) {
925
- if (!relayStillLive())
926
- return;
927
- recordSubagentDeliveryError(options.errorEntryType, parsed.to, parsed.message, error);
928
- if (options.acknowledge)
929
- emitResultDelivery(parsed.requestId, false, error);
930
- return;
931
- }
932
- if (!relayStillLive()) {
933
- return;
934
- }
935
- if (currentSessionTargetMatches(parsed.to, target, activeClient)) {
936
- deliverLocalSubagentRelayMessage(options.sender, options.status, parsed.message);
937
- if (options.acknowledge)
938
- emitResultDelivery(parsed.requestId, true);
913
+ const deliverLocal = () => {
914
+ const ctx = getLiveContext(runtimeContext, relayGeneration);
915
+ const ownerSessionId = ctx?.sessionManager.getSessionFile?.() ?? ctx?.sessionManager.getSessionId();
916
+ // The owner already receives subagent-notify; keep the relay ACK without another model message.
917
+ if (options.sender === "subagent-result" && ownerSessionId && parsed.ownerNotificationSessionId === ownerSessionId)
939
918
  return;
940
- }
941
- try {
942
- const result = await activeClient.send(target, { text: parsed.message });
943
- if (!relayStillLive())
944
- return;
945
- if (!result.delivered) {
946
- const error = new Error(result.reason ?? "Session may not exist or has disconnected.");
947
- recordSubagentDeliveryError(options.errorEntryType, parsed.to, parsed.message, error);
948
- if (options.acknowledge)
949
- emitResultDelivery(parsed.requestId, false, error);
950
- return;
919
+ deliverLocalSubagentRelayMessage(options.sender, options.status, parsed.message);
920
+ };
921
+ const key = options.acknowledge && parsed.requestId ? `${relayGeneration}:${parsed.requestId}` : undefined;
922
+ let delivery = key ? resultDeliveries.get(key) : undefined;
923
+ if (!delivery) {
924
+ delivery = (async () => {
925
+ const relayStillLive = () => !runtimeStarted || Boolean(getLiveContext(runtimeContext, relayGeneration));
926
+ try {
927
+ if (!relayStillLive())
928
+ return false;
929
+ if (currentSessionTargetMatches(parsed.to)) {
930
+ deliverLocal();
931
+ return true;
932
+ }
933
+ const activeClient = await ensureConnected("background");
934
+ const target = await resolveSessionTarget(activeClient, parsed.to) ?? parsed.to;
935
+ if (!relayStillLive())
936
+ return false;
937
+ if (currentSessionTargetMatches(parsed.to, target, activeClient)) {
938
+ deliverLocal();
939
+ return true;
940
+ }
941
+ const result = await activeClient.send(target, { text: parsed.message });
942
+ if (!result.delivered)
943
+ throw new Error(result.reason ?? "Session may not exist or has disconnected.");
944
+ return true;
951
945
  }
952
- if (options.acknowledge)
953
- emitResultDelivery(parsed.requestId, true);
954
- }
955
- catch (error) {
956
- if (!relayStillLive())
957
- return;
958
- recordSubagentDeliveryError(options.errorEntryType, parsed.to, parsed.message, error);
959
- if (options.acknowledge)
960
- emitResultDelivery(parsed.requestId, false, error);
946
+ catch (error) {
947
+ if (relayStillLive())
948
+ recordSubagentDeliveryError(options.errorEntryType, parsed.to, parsed.message, error);
949
+ return false;
950
+ }
951
+ })();
952
+ if (key) {
953
+ resultDeliveries.set(key, delivery);
954
+ void delivery.then((delivered) => {
955
+ if (!delivered) {
956
+ if (resultDeliveries.get(key) === delivery)
957
+ resultDeliveries.delete(key);
958
+ return;
959
+ }
960
+ acknowledgedResults.push(key);
961
+ while (acknowledgedResults.length > 1024)
962
+ resultDeliveries.delete(acknowledgedResults.shift());
963
+ });
961
964
  }
962
- })();
965
+ }
966
+ void delivery.then((delivered) => {
967
+ if (options.acknowledge)
968
+ emitResultDelivery(parsed.requestId, delivered);
969
+ });
963
970
  }
964
971
  const unsubscribeSubagentControlIntercom = pi.events.on(SUBAGENT_CONTROL_INTERCOM_EVENT, (payload) => {
965
972
  relaySubagentIntercomPayload(payload, {
@@ -1100,7 +1107,8 @@ export default function piIntercomExtension(pi) {
1100
1107
  }
1101
1108
  });
1102
1109
  const childOrchestratorMetadata = readChildOrchestratorMetadata();
1103
- if (childOrchestratorMetadata) {
1110
+ const nativeSupervisorChannel = isNativeSupervisorChannelActive();
1111
+ if (childOrchestratorMetadata && !nativeSupervisorChannel) {
1104
1112
  pi.registerTool({
1105
1113
  name: "contact_supervisor",
1106
1114
  label: "Contact Supervisor",
@@ -1361,10 +1369,11 @@ export default function piIntercomExtension(pi) {
1361
1369
  },
1362
1370
  });
1363
1371
  }
1364
- pi.registerTool({
1365
- name: "intercom",
1366
- label: "Intercom",
1367
- description: `Send a message to another pi session running on this machine.
1372
+ if (!nativeSupervisorChannel)
1373
+ pi.registerTool({
1374
+ name: "intercom",
1375
+ label: "Intercom",
1376
+ description: `Send a message to another pi session running on this machine.
1368
1377
  Use this to communicate findings, request help, or coordinate work with other sessions.
1369
1378
 
1370
1379
  Usage:
@@ -1374,158 +1383,131 @@ Usage:
1374
1383
  intercom({ action: "reply", message: "..." }) → Reply to the active/single pending ask
1375
1384
  intercom({ action: "pending" }) → List unresolved inbound asks
1376
1385
  intercom({ action: "status" }) → Show connection status`,
1377
- promptSnippet: "Use to coordinate with other local pi sessions: list peers, send updates, ask for help, or check intercom connectivity.",
1378
- parameters: Type.Object({
1379
- action: StringEnum(["list", "send", "ask", "reply", "pending", "status"], {
1380
- description: "Action: 'list', 'send', 'ask', 'reply', 'pending', or 'status'",
1386
+ promptSnippet: "Use to coordinate with other local pi sessions: list peers, send updates, ask for help, or check intercom connectivity.",
1387
+ parameters: Type.Object({
1388
+ action: StringEnum(["list", "send", "ask", "reply", "pending", "status"], {
1389
+ description: "Action: 'list', 'send', 'ask', 'reply', 'pending', or 'status'",
1390
+ }),
1391
+ to: Type.Optional(Type.String({
1392
+ description: "Target session name or ID (for 'send', 'ask', or disambiguating 'reply')",
1393
+ })),
1394
+ message: Type.Optional(Type.String({
1395
+ description: "Message to send (for 'send', 'ask', or 'reply' action)",
1396
+ })),
1397
+ attachments: Type.Optional(Type.Array(Type.Object({
1398
+ type: StringEnum(["file", "snippet", "context"]),
1399
+ name: Type.String(),
1400
+ content: Type.String(),
1401
+ language: Type.Optional(Type.String()),
1402
+ }))),
1403
+ replyTo: Type.Optional(Type.String({
1404
+ description: "Message ID to reply to (for threading or responding to an 'ask')",
1405
+ })),
1381
1406
  }),
1382
- to: Type.Optional(Type.String({
1383
- description: "Target session name or ID (for 'send', 'ask', or disambiguating 'reply')",
1384
- })),
1385
- message: Type.Optional(Type.String({
1386
- description: "Message to send (for 'send', 'ask', or 'reply' action)",
1387
- })),
1388
- attachments: Type.Optional(Type.Array(Type.Object({
1389
- type: StringEnum(["file", "snippet", "context"]),
1390
- name: Type.String(),
1391
- content: Type.String(),
1392
- language: Type.Optional(Type.String()),
1393
- }))),
1394
- replyTo: Type.Optional(Type.String({
1395
- description: "Message ID to reply to (for threading or responding to an 'ask')",
1396
- })),
1397
- }),
1398
- async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
1399
- let connectedClient;
1400
- try {
1401
- connectedClient = await ensureConnected("tool");
1402
- }
1403
- catch (error) {
1404
- return {
1405
- content: [{ type: "text", text: `Intercom not connected: ${getErrorMessage(error)}` }],
1406
- details: { error: true },
1407
- };
1408
- }
1409
- syncPresenceIdentity(ctx.sessionManager.getSessionId());
1410
- const { action, to, message, attachments, replyTo } = params;
1411
- switch (action) {
1412
- case "list": {
1413
- try {
1414
- const mySessionId = connectedClient.sessionId;
1415
- const sessions = await connectedClient.listSessions();
1416
- const currentSession = sessions.find(s => s.id === mySessionId);
1417
- const otherSessions = sessions.filter(s => s.id !== mySessionId);
1418
- if (!currentSession) {
1407
+ async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
1408
+ let connectedClient;
1409
+ try {
1410
+ connectedClient = await ensureConnected("tool");
1411
+ }
1412
+ catch (error) {
1413
+ return {
1414
+ content: [{ type: "text", text: `Intercom not connected: ${getErrorMessage(error)}` }],
1415
+ details: { error: true },
1416
+ };
1417
+ }
1418
+ syncPresenceIdentity(ctx.sessionManager.getSessionId());
1419
+ const { action, to, message, attachments, replyTo } = params;
1420
+ switch (action) {
1421
+ case "list": {
1422
+ try {
1423
+ const mySessionId = connectedClient.sessionId;
1424
+ const sessions = await connectedClient.listSessions();
1425
+ const currentSession = sessions.find(s => s.id === mySessionId);
1426
+ const otherSessions = sessions.filter(s => s.id !== mySessionId);
1427
+ if (!currentSession) {
1428
+ return {
1429
+ content: [{ type: "text", text: "Current session is missing from intercom session list." }],
1430
+ details: { error: true },
1431
+ };
1432
+ }
1433
+ const currentSection = `**Current session:**\n${formatSessionListRow(currentSession, currentSession.cwd, true)}`;
1434
+ const otherSection = otherSessions.length === 0
1435
+ ? "**Other sessions:**\nNo other sessions connected."
1436
+ : `**Other sessions:**\n${otherSessions.map(s => formatSessionListRow(s, currentSession.cwd, false)).join("\n")}`;
1437
+ return {
1438
+ content: [{ type: "text", text: `${currentSection}\n\n${otherSection}` }],
1439
+ details: {},
1440
+ };
1441
+ }
1442
+ catch (error) {
1419
1443
  return {
1420
- content: [{ type: "text", text: "Current session is missing from intercom session list." }],
1444
+ content: [{ type: "text", text: `Failed to list sessions: ${getErrorMessage(error)}` }],
1421
1445
  details: { error: true },
1422
1446
  };
1423
1447
  }
1424
- const currentSection = `**Current session:**\n${formatSessionListRow(currentSession, currentSession.cwd, true)}`;
1425
- const otherSection = otherSessions.length === 0
1426
- ? "**Other sessions:**\nNo other sessions connected."
1427
- : `**Other sessions:**\n${otherSessions.map(s => formatSessionListRow(s, currentSession.cwd, false)).join("\n")}`;
1428
- return {
1429
- content: [{ type: "text", text: `${currentSection}\n\n${otherSection}` }],
1430
- details: {},
1431
- };
1432
- }
1433
- catch (error) {
1434
- return {
1435
- content: [{ type: "text", text: `Failed to list sessions: ${getErrorMessage(error)}` }],
1436
- details: { error: true },
1437
- };
1438
- }
1439
- }
1440
- case "send": {
1441
- if (!to || !message) {
1442
- return {
1443
- content: [{ type: "text", text: "Missing 'to' or 'message' parameter" }],
1444
- details: { error: true },
1445
- };
1446
1448
  }
1447
- try {
1448
- const sendTo = await resolveSessionTarget(connectedClient, to) ?? to;
1449
- if (sendTo === connectedClient.sessionId) {
1449
+ case "send": {
1450
+ if (!to || !message) {
1450
1451
  return {
1451
- content: [{ type: "text", text: "Cannot message the current session" }],
1452
+ content: [{ type: "text", text: "Missing 'to' or 'message' parameter" }],
1452
1453
  details: { error: true },
1453
1454
  };
1454
1455
  }
1455
- if (!replyTo && config.confirmSend && ctx.hasUI) {
1456
- const attachmentText = attachments?.length ? formatAttachments(attachments) : "";
1457
- const confirmed = await ctx.ui.confirm("Send Message", `Send to "${to}":\n\n${message}${attachmentText}`);
1458
- if (!confirmed) {
1456
+ try {
1457
+ const sendTo = await resolveSessionTarget(connectedClient, to) ?? to;
1458
+ if (sendTo === connectedClient.sessionId) {
1459
1459
  return {
1460
- content: [{ type: "text", text: "Message cancelled by user" }],
1461
- details: {},
1460
+ content: [{ type: "text", text: "Cannot message the current session" }],
1461
+ details: { error: true },
1462
1462
  };
1463
1463
  }
1464
- }
1465
- const result = await connectedClient.send(sendTo, {
1466
- text: message,
1467
- attachments,
1468
- replyTo,
1469
- });
1470
- if (!result.delivered) {
1471
- const errorText = result.reason ?? "Session may not exist or has disconnected.";
1464
+ if (!replyTo && config.confirmSend && ctx.hasUI) {
1465
+ const attachmentText = attachments?.length ? formatAttachments(attachments) : "";
1466
+ const confirmed = await ctx.ui.confirm("Send Message", `Send to "${to}":\n\n${message}${attachmentText}`);
1467
+ if (!confirmed) {
1468
+ return {
1469
+ content: [{ type: "text", text: "Message cancelled by user" }],
1470
+ details: {},
1471
+ };
1472
+ }
1473
+ }
1474
+ const result = await connectedClient.send(sendTo, {
1475
+ text: message,
1476
+ attachments,
1477
+ replyTo,
1478
+ });
1479
+ if (!result.delivered) {
1480
+ const errorText = result.reason ?? "Session may not exist or has disconnected.";
1481
+ return {
1482
+ content: [{ type: "text", text: `Message to "${to}" was not delivered: ${errorText}` }],
1483
+ details: { messageId: result.id, delivered: false, reason: result.reason },
1484
+ };
1485
+ }
1486
+ pi.appendEntry("intercom_sent", {
1487
+ to,
1488
+ message: { text: message, attachments, replyTo },
1489
+ messageId: result.id,
1490
+ timestamp: Date.now(),
1491
+ });
1492
+ if (replyTo) {
1493
+ replyTracker.markReplied(replyTo);
1494
+ }
1472
1495
  return {
1473
- content: [{ type: "text", text: `Message to "${to}" was not delivered: ${errorText}` }],
1474
- details: { messageId: result.id, delivered: false, reason: result.reason },
1496
+ content: [{ type: "text", text: `Message sent to ${to}` }],
1497
+ details: { messageId: result.id, delivered: true },
1475
1498
  };
1476
1499
  }
1477
- pi.appendEntry("intercom_sent", {
1478
- to,
1479
- message: { text: message, attachments, replyTo },
1480
- messageId: result.id,
1481
- timestamp: Date.now(),
1482
- });
1483
- if (replyTo) {
1484
- replyTracker.markReplied(replyTo);
1485
- }
1486
- return {
1487
- content: [{ type: "text", text: `Message sent to ${to}` }],
1488
- details: { messageId: result.id, delivered: true },
1489
- };
1490
- }
1491
- catch (error) {
1492
- return {
1493
- content: [{ type: "text", text: `Failed to send: ${getErrorMessage(error)}` }],
1494
- details: { error: true },
1495
- };
1496
- }
1497
- }
1498
- case "ask": {
1499
- if (!to || !message) {
1500
- return {
1501
- content: [{ type: "text", text: "Missing 'to' or 'message' parameter" }],
1502
- details: { error: true },
1503
- };
1504
- }
1505
- if (replyWaiter) {
1506
- return {
1507
- content: [{ type: "text", text: "Already waiting for a reply" }],
1508
- details: { error: true },
1509
- };
1510
- }
1511
- if (_signal?.aborted) {
1512
- return {
1513
- content: [{ type: "text", text: "Cancelled" }],
1514
- details: { error: true },
1515
- };
1516
- }
1517
- let replyPromise = null;
1518
- try {
1519
- const sendTo = await resolveSessionTarget(connectedClient, to) ?? to;
1520
- if (_signal?.aborted) {
1500
+ catch (error) {
1521
1501
  return {
1522
- content: [{ type: "text", text: "Cancelled" }],
1502
+ content: [{ type: "text", text: `Failed to send: ${getErrorMessage(error)}` }],
1523
1503
  details: { error: true },
1524
1504
  };
1525
1505
  }
1526
- if (sendTo === connectedClient.sessionId) {
1506
+ }
1507
+ case "ask": {
1508
+ if (!to || !message) {
1527
1509
  return {
1528
- content: [{ type: "text", text: "Cannot message the current session" }],
1510
+ content: [{ type: "text", text: "Missing 'to' or 'message' parameter" }],
1529
1511
  details: { error: true },
1530
1512
  };
1531
1513
  }
@@ -1535,198 +1517,225 @@ Usage:
1535
1517
  details: { error: true },
1536
1518
  };
1537
1519
  }
1538
- const questionId = randomUUID();
1539
- replyPromise = waitForReply(sendTo, questionId, _signal, () => connectedClient.cancelAsk(questionId));
1540
- replyPromise.catch(() => undefined);
1541
- const sendResult = await connectedClient.send(sendTo, {
1542
- messageId: questionId,
1543
- text: message,
1544
- attachments,
1545
- replyTo,
1546
- expectsReply: true,
1547
- });
1548
- if (!sendResult.delivered) {
1549
- const errorText = sendResult.reason ?? "Session may not exist or has disconnected.";
1550
- rejectReplyWaiter(new Error(`Message to "${to}" was not delivered: ${errorText}`));
1520
+ if (_signal?.aborted) {
1521
+ return {
1522
+ content: [{ type: "text", text: "Cancelled" }],
1523
+ details: { error: true },
1524
+ };
1525
+ }
1526
+ let replyPromise = null;
1527
+ try {
1528
+ const sendTo = await resolveSessionTarget(connectedClient, to) ?? to;
1529
+ if (_signal?.aborted) {
1530
+ return {
1531
+ content: [{ type: "text", text: "Cancelled" }],
1532
+ details: { error: true },
1533
+ };
1534
+ }
1535
+ if (sendTo === connectedClient.sessionId) {
1536
+ return {
1537
+ content: [{ type: "text", text: "Cannot message the current session" }],
1538
+ details: { error: true },
1539
+ };
1540
+ }
1541
+ if (replyWaiter) {
1542
+ return {
1543
+ content: [{ type: "text", text: "Already waiting for a reply" }],
1544
+ details: { error: true },
1545
+ };
1546
+ }
1547
+ const questionId = randomUUID();
1548
+ replyPromise = waitForReply(sendTo, questionId, _signal, () => connectedClient.cancelAsk(questionId));
1549
+ replyPromise.catch(() => undefined);
1550
+ const sendResult = await connectedClient.send(sendTo, {
1551
+ messageId: questionId,
1552
+ text: message,
1553
+ attachments,
1554
+ replyTo,
1555
+ expectsReply: true,
1556
+ });
1557
+ if (!sendResult.delivered) {
1558
+ const errorText = sendResult.reason ?? "Session may not exist or has disconnected.";
1559
+ rejectReplyWaiter(new Error(`Message to "${to}" was not delivered: ${errorText}`));
1560
+ if (replyPromise) {
1561
+ try {
1562
+ await replyPromise;
1563
+ }
1564
+ catch {
1565
+ // The waiter was already rejected above. Keep the delivery failure as the only error here.
1566
+ }
1567
+ }
1568
+ return {
1569
+ content: [{ type: "text", text: `Message to "${to}" was not delivered: ${errorText}` }],
1570
+ details: { error: true },
1571
+ };
1572
+ }
1573
+ pi.appendEntry("intercom_sent", {
1574
+ to,
1575
+ message: { text: message, attachments, replyTo },
1576
+ messageId: sendResult.id,
1577
+ timestamp: Date.now(),
1578
+ });
1579
+ const replyMessage = await replyPromise;
1580
+ const replyText = replyMessage.content.text;
1581
+ const replyAttachments = replyMessage.content.attachments?.length
1582
+ ? formatAttachments(replyMessage.content.attachments)
1583
+ : "";
1584
+ pi.appendEntry("intercom_received", {
1585
+ from: to,
1586
+ message: { text: replyText, attachments: replyMessage.content.attachments },
1587
+ messageId: replyMessage.id,
1588
+ timestamp: replyMessage.timestamp,
1589
+ });
1590
+ return {
1591
+ content: [{ type: "text", text: `**Reply from ${to}:**\n${replyText}${replyAttachments}` }],
1592
+ details: {},
1593
+ };
1594
+ }
1595
+ catch (error) {
1596
+ rejectReplyWaiter(toError(error));
1551
1597
  if (replyPromise) {
1552
1598
  try {
1553
1599
  await replyPromise;
1554
1600
  }
1555
1601
  catch {
1556
- // The waiter was already rejected above. Keep the delivery failure as the only error here.
1602
+ // The waiter is cleanup-only on this path. The real failure is the one from the outer catch.
1557
1603
  }
1558
1604
  }
1559
1605
  return {
1560
- content: [{ type: "text", text: `Message to "${to}" was not delivered: ${errorText}` }],
1606
+ content: [{ type: "text", text: `Failed: ${getErrorMessage(error)}` }],
1561
1607
  details: { error: true },
1562
1608
  };
1563
1609
  }
1564
- pi.appendEntry("intercom_sent", {
1565
- to,
1566
- message: { text: message, attachments, replyTo },
1567
- messageId: sendResult.id,
1568
- timestamp: Date.now(),
1569
- });
1570
- const replyMessage = await replyPromise;
1571
- const replyText = replyMessage.content.text;
1572
- const replyAttachments = replyMessage.content.attachments?.length
1573
- ? formatAttachments(replyMessage.content.attachments)
1574
- : "";
1575
- pi.appendEntry("intercom_received", {
1576
- from: to,
1577
- message: { text: replyText, attachments: replyMessage.content.attachments },
1578
- messageId: replyMessage.id,
1579
- timestamp: replyMessage.timestamp,
1580
- });
1581
- return {
1582
- content: [{ type: "text", text: `**Reply from ${to}:**\n${replyText}${replyAttachments}` }],
1583
- details: {},
1584
- };
1585
1610
  }
1586
- catch (error) {
1587
- rejectReplyWaiter(toError(error));
1588
- if (replyPromise) {
1589
- try {
1590
- await replyPromise;
1611
+ case "reply": {
1612
+ if (!message) {
1613
+ return {
1614
+ content: [{ type: "text", text: "Missing 'message' parameter" }],
1615
+ details: { error: true },
1616
+ };
1617
+ }
1618
+ try {
1619
+ const target = replyTracker.resolveReplyTarget({ to, replyTo });
1620
+ if (target.from.id === connectedClient.sessionId) {
1621
+ return {
1622
+ content: [{ type: "text", text: "Cannot message the current session" }],
1623
+ details: { error: true },
1624
+ };
1591
1625
  }
1592
- catch {
1593
- // The waiter is cleanup-only on this path. The real failure is the one from the outer catch.
1626
+ const result = await connectedClient.send(target.from.id, {
1627
+ text: message,
1628
+ replyTo: target.message.id,
1629
+ });
1630
+ if (!result.delivered) {
1631
+ const errorText = result.reason ?? "Session may not exist or has disconnected.";
1632
+ if (result.reason === "Session not found") {
1633
+ replyTracker.dismissPendingAsk(target.message.id);
1634
+ }
1635
+ return {
1636
+ content: [{ type: "text", text: `Reply to "${target.from.name || target.from.id}" was not delivered: ${errorText}` }],
1637
+ details: { messageId: result.id, delivered: false, reason: result.reason },
1638
+ };
1594
1639
  }
1640
+ replyTracker.markReplied(target.message.id);
1641
+ pi.appendEntry("intercom_sent", {
1642
+ to: target.from.name || target.from.id,
1643
+ message: { text: message, replyTo: target.message.id },
1644
+ messageId: result.id,
1645
+ timestamp: Date.now(),
1646
+ });
1647
+ return {
1648
+ content: [{ type: "text", text: `Reply sent to ${target.from.name || target.from.id}` }],
1649
+ details: { messageId: result.id, delivered: true, replyTo: target.message.id },
1650
+ };
1595
1651
  }
1596
- return {
1597
- content: [{ type: "text", text: `Failed: ${getErrorMessage(error)}` }],
1598
- details: { error: true },
1599
- };
1600
- }
1601
- }
1602
- case "reply": {
1603
- if (!message) {
1604
- return {
1605
- content: [{ type: "text", text: "Missing 'message' parameter" }],
1606
- details: { error: true },
1607
- };
1608
- }
1609
- try {
1610
- const target = replyTracker.resolveReplyTarget({ to, replyTo });
1611
- if (target.from.id === connectedClient.sessionId) {
1652
+ catch (error) {
1612
1653
  return {
1613
- content: [{ type: "text", text: "Cannot message the current session" }],
1654
+ content: [{ type: "text", text: `Failed to reply: ${getErrorMessage(error)}` }],
1614
1655
  details: { error: true },
1615
1656
  };
1616
1657
  }
1617
- const result = await connectedClient.send(target.from.id, {
1618
- text: message,
1619
- replyTo: target.message.id,
1620
- });
1621
- if (!result.delivered) {
1622
- const errorText = result.reason ?? "Session may not exist or has disconnected.";
1623
- if (result.reason === "Session not found") {
1624
- replyTracker.dismissPendingAsk(target.message.id);
1625
- }
1658
+ }
1659
+ case "pending": {
1660
+ const pendingAsks = replyTracker.listPending();
1661
+ if (pendingAsks.length === 0) {
1626
1662
  return {
1627
- content: [{ type: "text", text: `Reply to "${target.from.name || target.from.id}" was not delivered: ${errorText}` }],
1628
- details: { messageId: result.id, delivered: false, reason: result.reason },
1663
+ content: [{ type: "text", text: "No unresolved inbound asks." }],
1664
+ details: {},
1629
1665
  };
1630
1666
  }
1631
- replyTracker.markReplied(target.message.id);
1632
- pi.appendEntry("intercom_sent", {
1633
- to: target.from.name || target.from.id,
1634
- message: { text: message, replyTo: target.message.id },
1635
- messageId: result.id,
1636
- timestamp: Date.now(),
1667
+ const now = Date.now();
1668
+ const lines = pendingAsks.map(({ from, message, receivedAt }) => {
1669
+ const preview = message.content.text.replace(/\s+/g, " ").slice(0, 80);
1670
+ const elapsedSeconds = Math.max(0, Math.floor((now - receivedAt) / 1000));
1671
+ return `- ${from.name || from.id} · ${message.id} · ${elapsedSeconds}s ago · ${preview}`;
1637
1672
  });
1638
1673
  return {
1639
- content: [{ type: "text", text: `Reply sent to ${target.from.name || target.from.id}` }],
1640
- details: { messageId: result.id, delivered: true, replyTo: target.message.id },
1641
- };
1642
- }
1643
- catch (error) {
1644
- return {
1645
- content: [{ type: "text", text: `Failed to reply: ${getErrorMessage(error)}` }],
1646
- details: { error: true },
1647
- };
1648
- }
1649
- }
1650
- case "pending": {
1651
- const pendingAsks = replyTracker.listPending();
1652
- if (pendingAsks.length === 0) {
1653
- return {
1654
- content: [{ type: "text", text: "No unresolved inbound asks." }],
1674
+ content: [{ type: "text", text: `**Pending asks:**\n${lines.join("\n")}` }],
1655
1675
  details: {},
1656
1676
  };
1657
1677
  }
1658
- const now = Date.now();
1659
- const lines = pendingAsks.map(({ from, message, receivedAt }) => {
1660
- const preview = message.content.text.replace(/\s+/g, " ").slice(0, 80);
1661
- const elapsedSeconds = Math.max(0, Math.floor((now - receivedAt) / 1000));
1662
- return `- ${from.name || from.id} · ${message.id} · ${elapsedSeconds}s ago · ${preview}`;
1663
- });
1664
- return {
1665
- content: [{ type: "text", text: `**Pending asks:**\n${lines.join("\n")}` }],
1666
- details: {},
1667
- };
1668
- }
1669
- case "status": {
1670
- try {
1671
- const mySessionId = connectedClient.sessionId;
1672
- const sessions = await connectedClient.listSessions();
1673
- return {
1674
- content: [{
1675
- type: "text",
1676
- text: `**Intercom Status:**\nConnected: Yes\nSession ID: ${mySessionId}\nActive sessions: ${sessions.length}`,
1677
- }],
1678
- details: {},
1679
- };
1678
+ case "status": {
1679
+ try {
1680
+ const mySessionId = connectedClient.sessionId;
1681
+ const sessions = await connectedClient.listSessions();
1682
+ return {
1683
+ content: [{
1684
+ type: "text",
1685
+ text: `**Intercom Status:**\nConnected: Yes\nSession ID: ${mySessionId}\nActive sessions: ${sessions.length}`,
1686
+ }],
1687
+ details: {},
1688
+ };
1689
+ }
1690
+ catch (error) {
1691
+ return {
1692
+ content: [{ type: "text", text: `Failed to get status: ${getErrorMessage(error)}` }],
1693
+ details: { error: true },
1694
+ };
1695
+ }
1680
1696
  }
1681
- catch (error) {
1697
+ default:
1682
1698
  return {
1683
- content: [{ type: "text", text: `Failed to get status: ${getErrorMessage(error)}` }],
1699
+ content: [{ type: "text", text: `Unknown action: ${action}` }],
1684
1700
  details: { error: true },
1685
1701
  };
1686
- }
1687
1702
  }
1688
- default:
1689
- return {
1690
- content: [{ type: "text", text: `Unknown action: ${action}` }],
1691
- details: { error: true },
1692
- };
1693
- }
1694
- },
1695
- renderCall(args, theme) {
1696
- const action = typeof args.action === "string" ? args.action : "intercom";
1697
- const target = typeof args.to === "string" && args.to.trim() ? args.to.trim() : undefined;
1698
- const messagePreview = previewText(args.message, 96);
1699
- const attachmentCount = Array.isArray(args.attachments) ? args.attachments.length : 0;
1700
- let text = theme.fg("toolTitle", theme.bold("intercom "));
1701
- text += theme.fg(action === "ask" ? "warning" : action === "reply" ? "success" : "accent", action);
1702
- if (target) {
1703
- text += " " + theme.fg("muted", "→") + " " + theme.fg("accent", target);
1704
- }
1705
- if (attachmentCount > 0) {
1706
- text += " " + theme.fg("dim", `(${attachmentCount} attachment${attachmentCount === 1 ? "" : "s"})`);
1707
- }
1708
- if (messagePreview) {
1709
- text += "\n " + theme.fg("dim", messagePreview);
1710
- }
1711
- return new Text(text, 0, 0);
1712
- },
1713
- renderResult(result, { isPartial }, theme, context) {
1714
- if (isPartial) {
1715
- return new Text(theme.fg("warning", "Intercom working..."), 0, 0);
1716
- }
1717
- const details = result.details;
1718
- const failed = Boolean(context.isError || details?.error === true || details?.delivered === false);
1719
- let text = failed ? theme.fg("error", "✗ ") : theme.fg("success", "✓ ");
1720
- text += theme.fg(failed ? "error" : "text", firstTextContent(result));
1721
- if (details?.messageId && !context.expanded) {
1722
- text += theme.fg("dim", ` (${details.messageId.slice(0, 8)})`);
1723
- }
1724
- if (details?.reason && context.expanded) {
1725
- text += "\n" + theme.fg("dim", `Reason: ${details.reason}`);
1726
- }
1727
- return new Text(text, 0, 0);
1728
- },
1729
- });
1703
+ },
1704
+ renderCall(args, theme) {
1705
+ const action = typeof args.action === "string" ? args.action : "intercom";
1706
+ const target = typeof args.to === "string" && args.to.trim() ? args.to.trim() : undefined;
1707
+ const messagePreview = previewText(args.message, 96);
1708
+ const attachmentCount = Array.isArray(args.attachments) ? args.attachments.length : 0;
1709
+ let text = theme.fg("toolTitle", theme.bold("intercom "));
1710
+ text += theme.fg(action === "ask" ? "warning" : action === "reply" ? "success" : "accent", action);
1711
+ if (target) {
1712
+ text += " " + theme.fg("muted", "→") + " " + theme.fg("accent", target);
1713
+ }
1714
+ if (attachmentCount > 0) {
1715
+ text += " " + theme.fg("dim", `(${attachmentCount} attachment${attachmentCount === 1 ? "" : "s"})`);
1716
+ }
1717
+ if (messagePreview) {
1718
+ text += "\n " + theme.fg("dim", messagePreview);
1719
+ }
1720
+ return new Text(text, 0, 0);
1721
+ },
1722
+ renderResult(result, { isPartial }, theme, context) {
1723
+ if (isPartial) {
1724
+ return new Text(theme.fg("warning", "Intercom working..."), 0, 0);
1725
+ }
1726
+ const details = result.details;
1727
+ const failed = Boolean(context.isError || details?.error === true || details?.delivered === false);
1728
+ let text = failed ? theme.fg("error", "✗ ") : theme.fg("success", "✓ ");
1729
+ text += theme.fg(failed ? "error" : "text", firstTextContent(result));
1730
+ if (details?.messageId && !context.expanded) {
1731
+ text += theme.fg("dim", ` (${details.messageId.slice(0, 8)})`);
1732
+ }
1733
+ if (details?.reason && context.expanded) {
1734
+ text += "\n" + theme.fg("dim", `Reason: ${details.reason}`);
1735
+ }
1736
+ return new Text(text, 0, 0);
1737
+ },
1738
+ });
1730
1739
  async function openIntercomOverlay(ctx) {
1731
1740
  const overlayGeneration = runtimeGeneration;
1732
1741
  const liveContext = getLiveContext(ctx, overlayGeneration);