@withbuddi/buddi 0.1.0-pre.20 → 0.1.0-pre.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 (400) hide show
  1. package/node_modules/@buddi/cli/dist/.tsbuildinfo +1 -1
  2. package/node_modules/@buddi/cli/dist/args.d.ts +6 -0
  3. package/node_modules/@buddi/cli/dist/args.d.ts.map +1 -1
  4. package/node_modules/@buddi/cli/dist/args.js +15 -0
  5. package/node_modules/@buddi/cli/dist/args.js.map +1 -1
  6. package/node_modules/@buddi/cli/dist/commands.d.ts.map +1 -1
  7. package/node_modules/@buddi/cli/dist/commands.js +17 -0
  8. package/node_modules/@buddi/cli/dist/commands.js.map +1 -1
  9. package/node_modules/@buddi/cli/dist/main.d.ts.map +1 -1
  10. package/node_modules/@buddi/cli/dist/main.js +7 -0
  11. package/node_modules/@buddi/cli/dist/main.js.map +1 -1
  12. package/node_modules/@buddi/core/dist/.tsbuildinfo +1 -1
  13. package/node_modules/@buddi/core/dist/host/build.d.ts.map +1 -1
  14. package/node_modules/@buddi/core/dist/host/build.js +33 -16
  15. package/node_modules/@buddi/core/dist/host/build.js.map +1 -1
  16. package/node_modules/@buddi/core/dist/host/types.d.ts +17 -0
  17. package/node_modules/@buddi/core/dist/host/types.d.ts.map +1 -1
  18. package/node_modules/@buddi/core/dist/pages/__fixtures__/demo.d.ts.map +1 -1
  19. package/node_modules/@buddi/core/dist/pages/__fixtures__/demo.js +1 -0
  20. package/node_modules/@buddi/core/dist/pages/__fixtures__/demo.js.map +1 -1
  21. package/node_modules/@buddi/core/dist/pages.d.ts +74 -0
  22. package/node_modules/@buddi/core/dist/pages.d.ts.map +1 -1
  23. package/node_modules/@buddi/core/dist/pages.js +27 -1
  24. package/node_modules/@buddi/core/dist/pages.js.map +1 -1
  25. package/node_modules/@buddi/core/dist/plugin/index.d.ts +2 -2
  26. package/node_modules/@buddi/core/dist/plugin/index.d.ts.map +1 -1
  27. package/node_modules/@buddi/core/dist/plugin/version.d.ts +1 -1
  28. package/node_modules/@buddi/core/dist/plugin/version.js +1 -1
  29. package/node_modules/@buddi/core/dist/provider-accounts.d.ts +8 -0
  30. package/node_modules/@buddi/core/dist/provider-accounts.d.ts.map +1 -1
  31. package/node_modules/@buddi/core/dist/provider-accounts.js +8 -0
  32. package/node_modules/@buddi/core/dist/provider-accounts.js.map +1 -1
  33. package/node_modules/@buddi/core/dist/surfaces.d.ts +11 -0
  34. package/node_modules/@buddi/core/dist/surfaces.d.ts.map +1 -1
  35. package/node_modules/@buddi/core/dist/surfaces.js +4 -0
  36. package/node_modules/@buddi/core/dist/surfaces.js.map +1 -1
  37. package/node_modules/@buddi/core/migrations/048_surface_chat_voice.sql +13 -0
  38. package/node_modules/@buddi/core/migrations/049_surface_chat_voice_form.sql +8 -0
  39. package/node_modules/@buddi/gateway/dist/.tsbuildinfo +1 -1
  40. package/node_modules/@buddi/gateway/dist/agents-cli.d.ts +2 -0
  41. package/node_modules/@buddi/gateway/dist/agents-cli.d.ts.map +1 -1
  42. package/node_modules/@buddi/gateway/dist/agents-cli.js +5 -3
  43. package/node_modules/@buddi/gateway/dist/agents-cli.js.map +1 -1
  44. package/node_modules/@buddi/gateway/dist/chat/session.d.ts.map +1 -1
  45. package/node_modules/@buddi/gateway/dist/chat/session.js +2 -2
  46. package/node_modules/@buddi/gateway/dist/chat/session.js.map +1 -1
  47. package/node_modules/@buddi/gateway/dist/chat/usage.d.ts +16 -0
  48. package/node_modules/@buddi/gateway/dist/chat/usage.d.ts.map +1 -1
  49. package/node_modules/@buddi/gateway/dist/chat/usage.js +53 -11
  50. package/node_modules/@buddi/gateway/dist/chat/usage.js.map +1 -1
  51. package/node_modules/@buddi/gateway/dist/index.d.ts +1 -0
  52. package/node_modules/@buddi/gateway/dist/index.d.ts.map +1 -1
  53. package/node_modules/@buddi/gateway/dist/index.js +1 -0
  54. package/node_modules/@buddi/gateway/dist/index.js.map +1 -1
  55. package/node_modules/@buddi/gateway/dist/provider-accounts.d.ts +4 -0
  56. package/node_modules/@buddi/gateway/dist/provider-accounts.d.ts.map +1 -1
  57. package/node_modules/@buddi/gateway/dist/provider-accounts.js +3 -1
  58. package/node_modules/@buddi/gateway/dist/provider-accounts.js.map +1 -1
  59. package/node_modules/@buddi/gateway/dist/speech-cli.d.ts +43 -0
  60. package/node_modules/@buddi/gateway/dist/speech-cli.d.ts.map +1 -0
  61. package/node_modules/@buddi/gateway/dist/speech-cli.js +105 -0
  62. package/node_modules/@buddi/gateway/dist/speech-cli.js.map +1 -0
  63. package/node_modules/@buddi/gateway/dist/telegram/api.d.ts +10 -0
  64. package/node_modules/@buddi/gateway/dist/telegram/api.d.ts.map +1 -1
  65. package/node_modules/@buddi/gateway/dist/telegram/api.js +12 -0
  66. package/node_modules/@buddi/gateway/dist/telegram/api.js.map +1 -1
  67. package/node_modules/@buddi/gateway/dist/telegram/browser-view.d.ts +2 -1
  68. package/node_modules/@buddi/gateway/dist/telegram/browser-view.d.ts.map +1 -1
  69. package/node_modules/@buddi/gateway/dist/telegram/browser-view.js +4 -2
  70. package/node_modules/@buddi/gateway/dist/telegram/browser-view.js.map +1 -1
  71. package/node_modules/@buddi/gateway/dist/telegram/main.d.ts.map +1 -1
  72. package/node_modules/@buddi/gateway/dist/telegram/main.js +10 -2
  73. package/node_modules/@buddi/gateway/dist/telegram/main.js.map +1 -1
  74. package/node_modules/@buddi/gateway/dist/telegram/surface.d.ts +25 -0
  75. package/node_modules/@buddi/gateway/dist/telegram/surface.d.ts.map +1 -1
  76. package/node_modules/@buddi/gateway/dist/telegram/surface.js +212 -10
  77. package/node_modules/@buddi/gateway/dist/telegram/surface.js.map +1 -1
  78. package/node_modules/@buddi/gateway/dist/telegram/voice.d.ts +112 -0
  79. package/node_modules/@buddi/gateway/dist/telegram/voice.d.ts.map +1 -0
  80. package/node_modules/@buddi/gateway/dist/telegram/voice.js +220 -0
  81. package/node_modules/@buddi/gateway/dist/telegram/voice.js.map +1 -0
  82. package/node_modules/@buddi/gateway/dist/web/chat.d.ts +31 -8
  83. package/node_modules/@buddi/gateway/dist/web/chat.d.ts.map +1 -1
  84. package/node_modules/@buddi/gateway/dist/web/chat.js +3 -2
  85. package/node_modules/@buddi/gateway/dist/web/chat.js.map +1 -1
  86. package/node_modules/@buddi/gateway/dist/web/onboarding.d.ts +13 -2
  87. package/node_modules/@buddi/gateway/dist/web/onboarding.d.ts.map +1 -1
  88. package/node_modules/@buddi/gateway/dist/web/onboarding.js +24 -3
  89. package/node_modules/@buddi/gateway/dist/web/onboarding.js.map +1 -1
  90. package/node_modules/@buddi/gateway/dist/web/read.d.ts +15 -12
  91. package/node_modules/@buddi/gateway/dist/web/read.d.ts.map +1 -1
  92. package/node_modules/@buddi/gateway/dist/web/read.js +9 -10
  93. package/node_modules/@buddi/gateway/dist/web/read.js.map +1 -1
  94. package/node_modules/@buddi/gateway/dist/web/server.d.ts.map +1 -1
  95. package/node_modules/@buddi/gateway/dist/web/server.js +13 -0
  96. package/node_modules/@buddi/gateway/dist/web/server.js.map +1 -1
  97. package/node_modules/@buddi/gateway/dist/web/speech.d.ts +47 -0
  98. package/node_modules/@buddi/gateway/dist/web/speech.d.ts.map +1 -0
  99. package/node_modules/@buddi/gateway/dist/web/speech.js +83 -0
  100. package/node_modules/@buddi/gateway/dist/web/speech.js.map +1 -0
  101. package/node_modules/@buddi/gateway/dist/web/stream.d.ts +0 -24
  102. package/node_modules/@buddi/gateway/dist/web/stream.d.ts.map +1 -1
  103. package/node_modules/@buddi/gateway/dist/web/stream.js +26 -2
  104. package/node_modules/@buddi/gateway/dist/web/stream.js.map +1 -1
  105. package/node_modules/@buddi/gateway/dist/web/usage-view.d.ts +15 -0
  106. package/node_modules/@buddi/gateway/dist/web/usage-view.d.ts.map +1 -0
  107. package/node_modules/@buddi/gateway/dist/web/usage-view.js +20 -0
  108. package/node_modules/@buddi/gateway/dist/web/usage-view.js.map +1 -0
  109. package/node_modules/@buddi/install/dist/.tsbuildinfo +1 -1
  110. package/node_modules/@buddi/runtime/dist/.tsbuildinfo +1 -1
  111. package/node_modules/@buddi/runtime/dist/anthropic.d.ts +18 -0
  112. package/node_modules/@buddi/runtime/dist/anthropic.d.ts.map +1 -1
  113. package/node_modules/@buddi/runtime/dist/anthropic.js +65 -13
  114. package/node_modules/@buddi/runtime/dist/anthropic.js.map +1 -1
  115. package/node_modules/@buddi/runtime/dist/codex-direct.d.ts.map +1 -1
  116. package/node_modules/@buddi/runtime/dist/codex-direct.js +11 -3
  117. package/node_modules/@buddi/runtime/dist/codex-direct.js.map +1 -1
  118. package/node_modules/@buddi/runtime/dist/context-window.d.ts.map +1 -1
  119. package/node_modules/@buddi/runtime/dist/context-window.js +13 -4
  120. package/node_modules/@buddi/runtime/dist/context-window.js.map +1 -1
  121. package/node_modules/@buddi/runtime/dist/loop.d.ts.map +1 -1
  122. package/node_modules/@buddi/runtime/dist/loop.js +6 -0
  123. package/node_modules/@buddi/runtime/dist/loop.js.map +1 -1
  124. package/node_modules/@buddi/runtime/dist/openai.d.ts +16 -4
  125. package/node_modules/@buddi/runtime/dist/openai.d.ts.map +1 -1
  126. package/node_modules/@buddi/runtime/dist/openai.js +23 -4
  127. package/node_modules/@buddi/runtime/dist/openai.js.map +1 -1
  128. package/node_modules/@buddi/runtime/dist/provider-models.d.ts.map +1 -1
  129. package/node_modules/@buddi/runtime/dist/provider-models.js +5 -1
  130. package/node_modules/@buddi/runtime/dist/provider-models.js.map +1 -1
  131. package/node_modules/@buddi/tool-artifacts/dist/.tsbuildinfo +1 -1
  132. package/node_modules/@buddi/tool-browser/dist/.tsbuildinfo +1 -1
  133. package/node_modules/@buddi/tool-browser/dist/computer.d.ts +53 -1
  134. package/node_modules/@buddi/tool-browser/dist/computer.d.ts.map +1 -1
  135. package/node_modules/@buddi/tool-browser/dist/computer.js +154 -5
  136. package/node_modules/@buddi/tool-browser/dist/computer.js.map +1 -1
  137. package/node_modules/@buddi/tool-browser/dist/controller.d.ts +20 -3
  138. package/node_modules/@buddi/tool-browser/dist/controller.d.ts.map +1 -1
  139. package/node_modules/@buddi/tool-browser/dist/controller.js +170 -5
  140. package/node_modules/@buddi/tool-browser/dist/controller.js.map +1 -1
  141. package/node_modules/@buddi/tool-browser/dist/index.d.ts.map +1 -1
  142. package/node_modules/@buddi/tool-browser/dist/index.js +9 -1
  143. package/node_modules/@buddi/tool-browser/dist/index.js.map +1 -1
  144. package/node_modules/@buddi/tool-browser/dist/service.d.ts +14 -1
  145. package/node_modules/@buddi/tool-browser/dist/service.d.ts.map +1 -1
  146. package/node_modules/@buddi/tool-browser/dist/service.js +28 -5
  147. package/node_modules/@buddi/tool-browser/dist/service.js.map +1 -1
  148. package/node_modules/@buddi/tool-browser/dist/types.d.ts +11 -0
  149. package/node_modules/@buddi/tool-browser/dist/types.d.ts.map +1 -1
  150. package/node_modules/@buddi/tool-browser/dist/types.js +16 -3
  151. package/node_modules/@buddi/tool-browser/dist/types.js.map +1 -1
  152. package/node_modules/@buddi/tool-browser/package.json +1 -1
  153. package/node_modules/@buddi/tool-email/dist/.tsbuildinfo +1 -1
  154. package/node_modules/@buddi/tool-host/dist/.tsbuildinfo +1 -1
  155. package/node_modules/@buddi/tool-memory/dist/.tsbuildinfo +1 -1
  156. package/node_modules/@buddi/tool-web/dist/.tsbuildinfo +1 -1
  157. package/node_modules/imapflow/CHANGELOG.md +29 -0
  158. package/node_modules/imapflow/dist/cjs/commands/append.js +12 -12
  159. package/node_modules/imapflow/dist/cjs/commands/authenticate.d.ts +3 -8
  160. package/node_modules/imapflow/dist/cjs/commands/close.js +2 -1
  161. package/node_modules/imapflow/dist/cjs/commands/copy.js +4 -4
  162. package/node_modules/imapflow/dist/cjs/commands/create.js +2 -3
  163. package/node_modules/imapflow/dist/cjs/commands/delete.js +4 -4
  164. package/node_modules/imapflow/dist/cjs/commands/expunge.js +8 -5
  165. package/node_modules/imapflow/dist/cjs/commands/fetch.js +12 -10
  166. package/node_modules/imapflow/dist/cjs/commands/idle.js +6 -2
  167. package/node_modules/imapflow/dist/cjs/commands/list.js +22 -18
  168. package/node_modules/imapflow/dist/cjs/commands/move.js +11 -6
  169. package/node_modules/imapflow/dist/cjs/commands/namespace.js +1 -1
  170. package/node_modules/imapflow/dist/cjs/commands/quota.js +10 -9
  171. package/node_modules/imapflow/dist/cjs/commands/rename.js +4 -4
  172. package/node_modules/imapflow/dist/cjs/commands/search.js +7 -8
  173. package/node_modules/imapflow/dist/cjs/commands/select.js +12 -9
  174. package/node_modules/imapflow/dist/cjs/commands/status.js +11 -11
  175. package/node_modules/imapflow/dist/cjs/commands/store.js +5 -5
  176. package/node_modules/imapflow/dist/cjs/commands/subscribe.js +2 -17
  177. package/node_modules/imapflow/dist/cjs/commands/subscription.d.ts +10 -0
  178. package/node_modules/imapflow/dist/cjs/commands/subscription.js +29 -0
  179. package/node_modules/imapflow/dist/cjs/commands/unsubscribe.js +2 -17
  180. package/node_modules/imapflow/dist/cjs/download.d.ts +22 -0
  181. package/node_modules/imapflow/dist/cjs/download.js +588 -0
  182. package/node_modules/imapflow/dist/cjs/errors.d.ts +50 -1
  183. package/node_modules/imapflow/dist/cjs/errors.js +53 -1
  184. package/node_modules/imapflow/dist/cjs/handler/imap-compiler.js +1 -1
  185. package/node_modules/imapflow/dist/cjs/handler/imap-stream.d.ts +13 -2
  186. package/node_modules/imapflow/dist/cjs/handler/imap-stream.js +51 -30
  187. package/node_modules/imapflow/dist/cjs/handler/parser-instance.js +2 -2
  188. package/node_modules/imapflow/dist/cjs/handler/token-parser.js +15 -9
  189. package/node_modules/imapflow/dist/cjs/imap-flow.d.ts +30 -84
  190. package/node_modules/imapflow/dist/cjs/imap-flow.js +282 -734
  191. package/node_modules/imapflow/dist/cjs/jp-decoder.js +1 -1
  192. package/node_modules/imapflow/dist/cjs/package-info.d.ts +1 -1
  193. package/node_modules/imapflow/dist/cjs/package-info.js +3 -3
  194. package/node_modules/imapflow/dist/cjs/search-compiler.js +5 -12
  195. package/node_modules/imapflow/dist/cjs/tools.d.ts +52 -11
  196. package/node_modules/imapflow/dist/cjs/tools.js +86 -23
  197. package/node_modules/imapflow/dist/cjs/types.d.ts +30 -16
  198. package/node_modules/imapflow/dist/esm/commands/append.js +13 -13
  199. package/node_modules/imapflow/dist/esm/commands/authenticate.d.ts +3 -8
  200. package/node_modules/imapflow/dist/esm/commands/close.js +2 -1
  201. package/node_modules/imapflow/dist/esm/commands/copy.js +5 -5
  202. package/node_modules/imapflow/dist/esm/commands/create.js +3 -4
  203. package/node_modules/imapflow/dist/esm/commands/delete.js +5 -5
  204. package/node_modules/imapflow/dist/esm/commands/expunge.js +9 -6
  205. package/node_modules/imapflow/dist/esm/commands/fetch.js +13 -11
  206. package/node_modules/imapflow/dist/esm/commands/idle.js +7 -3
  207. package/node_modules/imapflow/dist/esm/commands/list.js +22 -18
  208. package/node_modules/imapflow/dist/esm/commands/move.js +12 -7
  209. package/node_modules/imapflow/dist/esm/commands/namespace.js +2 -2
  210. package/node_modules/imapflow/dist/esm/commands/quota.js +11 -10
  211. package/node_modules/imapflow/dist/esm/commands/rename.js +5 -5
  212. package/node_modules/imapflow/dist/esm/commands/search.js +8 -9
  213. package/node_modules/imapflow/dist/esm/commands/select.js +13 -10
  214. package/node_modules/imapflow/dist/esm/commands/status.js +12 -12
  215. package/node_modules/imapflow/dist/esm/commands/store.js +6 -6
  216. package/node_modules/imapflow/dist/esm/commands/subscribe.js +2 -17
  217. package/node_modules/imapflow/dist/esm/commands/subscription.d.ts +10 -0
  218. package/node_modules/imapflow/dist/esm/commands/subscription.js +26 -0
  219. package/node_modules/imapflow/dist/esm/commands/unsubscribe.js +2 -17
  220. package/node_modules/imapflow/dist/esm/download.d.ts +22 -0
  221. package/node_modules/imapflow/dist/esm/download.js +581 -0
  222. package/node_modules/imapflow/dist/esm/errors.d.ts +50 -1
  223. package/node_modules/imapflow/dist/esm/errors.js +52 -0
  224. package/node_modules/imapflow/dist/esm/handler/imap-compiler.js +1 -1
  225. package/node_modules/imapflow/dist/esm/handler/imap-stream.d.ts +13 -2
  226. package/node_modules/imapflow/dist/esm/handler/imap-stream.js +51 -30
  227. package/node_modules/imapflow/dist/esm/handler/parser-instance.js +2 -2
  228. package/node_modules/imapflow/dist/esm/handler/token-parser.js +15 -9
  229. package/node_modules/imapflow/dist/esm/imap-flow.d.ts +30 -84
  230. package/node_modules/imapflow/dist/esm/imap-flow.js +282 -735
  231. package/node_modules/imapflow/dist/esm/jp-decoder.js +1 -1
  232. package/node_modules/imapflow/dist/esm/package-info.d.ts +1 -1
  233. package/node_modules/imapflow/dist/esm/package-info.js +3 -3
  234. package/node_modules/imapflow/dist/esm/search-compiler.js +5 -12
  235. package/node_modules/imapflow/dist/esm/tools.d.ts +52 -11
  236. package/node_modules/imapflow/dist/esm/tools.js +79 -21
  237. package/node_modules/imapflow/dist/esm/types.d.ts +30 -16
  238. package/node_modules/imapflow/package.json +4 -4
  239. package/package.json +2 -2
  240. package/packages/cli/dist/.tsbuildinfo +1 -1
  241. package/packages/cli/dist/args.d.ts +6 -0
  242. package/packages/cli/dist/args.d.ts.map +1 -1
  243. package/packages/cli/dist/args.js +15 -0
  244. package/packages/cli/dist/args.js.map +1 -1
  245. package/packages/cli/dist/commands.d.ts.map +1 -1
  246. package/packages/cli/dist/commands.js +17 -0
  247. package/packages/cli/dist/commands.js.map +1 -1
  248. package/packages/cli/dist/main.d.ts.map +1 -1
  249. package/packages/cli/dist/main.js +7 -0
  250. package/packages/cli/dist/main.js.map +1 -1
  251. package/packages/core/dist/.tsbuildinfo +1 -1
  252. package/packages/core/dist/host/build.d.ts.map +1 -1
  253. package/packages/core/dist/host/build.js +33 -16
  254. package/packages/core/dist/host/build.js.map +1 -1
  255. package/packages/core/dist/host/types.d.ts +17 -0
  256. package/packages/core/dist/host/types.d.ts.map +1 -1
  257. package/packages/core/dist/pages/__fixtures__/demo.d.ts.map +1 -1
  258. package/packages/core/dist/pages/__fixtures__/demo.js +1 -0
  259. package/packages/core/dist/pages/__fixtures__/demo.js.map +1 -1
  260. package/packages/core/dist/pages.d.ts +74 -0
  261. package/packages/core/dist/pages.d.ts.map +1 -1
  262. package/packages/core/dist/pages.js +27 -1
  263. package/packages/core/dist/pages.js.map +1 -1
  264. package/packages/core/dist/plugin/index.d.ts +2 -2
  265. package/packages/core/dist/plugin/index.d.ts.map +1 -1
  266. package/packages/core/dist/plugin/version.d.ts +1 -1
  267. package/packages/core/dist/plugin/version.js +1 -1
  268. package/packages/core/dist/provider-accounts.d.ts +8 -0
  269. package/packages/core/dist/provider-accounts.d.ts.map +1 -1
  270. package/packages/core/dist/provider-accounts.js +8 -0
  271. package/packages/core/dist/provider-accounts.js.map +1 -1
  272. package/packages/core/dist/surfaces.d.ts +11 -0
  273. package/packages/core/dist/surfaces.d.ts.map +1 -1
  274. package/packages/core/dist/surfaces.js +4 -0
  275. package/packages/core/dist/surfaces.js.map +1 -1
  276. package/packages/core/migrations/048_surface_chat_voice.sql +13 -0
  277. package/packages/core/migrations/049_surface_chat_voice_form.sql +8 -0
  278. package/packages/gateway/dist/.tsbuildinfo +1 -1
  279. package/packages/gateway/dist/agents-cli.d.ts +2 -0
  280. package/packages/gateway/dist/agents-cli.d.ts.map +1 -1
  281. package/packages/gateway/dist/agents-cli.js +5 -3
  282. package/packages/gateway/dist/agents-cli.js.map +1 -1
  283. package/packages/gateway/dist/chat/session.d.ts.map +1 -1
  284. package/packages/gateway/dist/chat/session.js +2 -2
  285. package/packages/gateway/dist/chat/session.js.map +1 -1
  286. package/packages/gateway/dist/chat/usage.d.ts +16 -0
  287. package/packages/gateway/dist/chat/usage.d.ts.map +1 -1
  288. package/packages/gateway/dist/chat/usage.js +53 -11
  289. package/packages/gateway/dist/chat/usage.js.map +1 -1
  290. package/packages/gateway/dist/index.d.ts +1 -0
  291. package/packages/gateway/dist/index.d.ts.map +1 -1
  292. package/packages/gateway/dist/index.js +1 -0
  293. package/packages/gateway/dist/index.js.map +1 -1
  294. package/packages/gateway/dist/provider-accounts.d.ts +4 -0
  295. package/packages/gateway/dist/provider-accounts.d.ts.map +1 -1
  296. package/packages/gateway/dist/provider-accounts.js +3 -1
  297. package/packages/gateway/dist/provider-accounts.js.map +1 -1
  298. package/packages/gateway/dist/speech-cli.d.ts +43 -0
  299. package/packages/gateway/dist/speech-cli.d.ts.map +1 -0
  300. package/packages/gateway/dist/speech-cli.js +105 -0
  301. package/packages/gateway/dist/speech-cli.js.map +1 -0
  302. package/packages/gateway/dist/telegram/api.d.ts +10 -0
  303. package/packages/gateway/dist/telegram/api.d.ts.map +1 -1
  304. package/packages/gateway/dist/telegram/api.js +12 -0
  305. package/packages/gateway/dist/telegram/api.js.map +1 -1
  306. package/packages/gateway/dist/telegram/browser-view.d.ts +2 -1
  307. package/packages/gateway/dist/telegram/browser-view.d.ts.map +1 -1
  308. package/packages/gateway/dist/telegram/browser-view.js +4 -2
  309. package/packages/gateway/dist/telegram/browser-view.js.map +1 -1
  310. package/packages/gateway/dist/telegram/main.d.ts.map +1 -1
  311. package/packages/gateway/dist/telegram/main.js +10 -2
  312. package/packages/gateway/dist/telegram/main.js.map +1 -1
  313. package/packages/gateway/dist/telegram/surface.d.ts +25 -0
  314. package/packages/gateway/dist/telegram/surface.d.ts.map +1 -1
  315. package/packages/gateway/dist/telegram/surface.js +212 -10
  316. package/packages/gateway/dist/telegram/surface.js.map +1 -1
  317. package/packages/gateway/dist/telegram/voice.d.ts +112 -0
  318. package/packages/gateway/dist/telegram/voice.d.ts.map +1 -0
  319. package/packages/gateway/dist/telegram/voice.js +220 -0
  320. package/packages/gateway/dist/telegram/voice.js.map +1 -0
  321. package/packages/gateway/dist/web/chat.d.ts +31 -8
  322. package/packages/gateway/dist/web/chat.d.ts.map +1 -1
  323. package/packages/gateway/dist/web/chat.js +3 -2
  324. package/packages/gateway/dist/web/chat.js.map +1 -1
  325. package/packages/gateway/dist/web/onboarding.d.ts +13 -2
  326. package/packages/gateway/dist/web/onboarding.d.ts.map +1 -1
  327. package/packages/gateway/dist/web/onboarding.js +24 -3
  328. package/packages/gateway/dist/web/onboarding.js.map +1 -1
  329. package/packages/gateway/dist/web/read.d.ts +15 -12
  330. package/packages/gateway/dist/web/read.d.ts.map +1 -1
  331. package/packages/gateway/dist/web/read.js +9 -10
  332. package/packages/gateway/dist/web/read.js.map +1 -1
  333. package/packages/gateway/dist/web/server.d.ts.map +1 -1
  334. package/packages/gateway/dist/web/server.js +13 -0
  335. package/packages/gateway/dist/web/server.js.map +1 -1
  336. package/packages/gateway/dist/web/speech.d.ts +47 -0
  337. package/packages/gateway/dist/web/speech.d.ts.map +1 -0
  338. package/packages/gateway/dist/web/speech.js +83 -0
  339. package/packages/gateway/dist/web/speech.js.map +1 -0
  340. package/packages/gateway/dist/web/stream.d.ts +0 -24
  341. package/packages/gateway/dist/web/stream.d.ts.map +1 -1
  342. package/packages/gateway/dist/web/stream.js +26 -2
  343. package/packages/gateway/dist/web/stream.js.map +1 -1
  344. package/packages/gateway/dist/web/usage-view.d.ts +15 -0
  345. package/packages/gateway/dist/web/usage-view.d.ts.map +1 -0
  346. package/packages/gateway/dist/web/usage-view.js +20 -0
  347. package/packages/gateway/dist/web/usage-view.js.map +1 -0
  348. package/packages/install/dist/.tsbuildinfo +1 -1
  349. package/packages/runtime/dist/.tsbuildinfo +1 -1
  350. package/packages/runtime/dist/anthropic.d.ts +18 -0
  351. package/packages/runtime/dist/anthropic.d.ts.map +1 -1
  352. package/packages/runtime/dist/anthropic.js +65 -13
  353. package/packages/runtime/dist/anthropic.js.map +1 -1
  354. package/packages/runtime/dist/codex-direct.d.ts.map +1 -1
  355. package/packages/runtime/dist/codex-direct.js +11 -3
  356. package/packages/runtime/dist/codex-direct.js.map +1 -1
  357. package/packages/runtime/dist/context-window.d.ts.map +1 -1
  358. package/packages/runtime/dist/context-window.js +13 -4
  359. package/packages/runtime/dist/context-window.js.map +1 -1
  360. package/packages/runtime/dist/loop.d.ts.map +1 -1
  361. package/packages/runtime/dist/loop.js +6 -0
  362. package/packages/runtime/dist/loop.js.map +1 -1
  363. package/packages/runtime/dist/openai.d.ts +16 -4
  364. package/packages/runtime/dist/openai.d.ts.map +1 -1
  365. package/packages/runtime/dist/openai.js +23 -4
  366. package/packages/runtime/dist/openai.js.map +1 -1
  367. package/packages/runtime/dist/provider-models.d.ts.map +1 -1
  368. package/packages/runtime/dist/provider-models.js +5 -1
  369. package/packages/runtime/dist/provider-models.js.map +1 -1
  370. package/packages/tools/artifacts/dist/.tsbuildinfo +1 -1
  371. package/packages/tools/browser/dist/.tsbuildinfo +1 -1
  372. package/packages/tools/browser/dist/computer.d.ts +53 -1
  373. package/packages/tools/browser/dist/computer.d.ts.map +1 -1
  374. package/packages/tools/browser/dist/computer.js +154 -5
  375. package/packages/tools/browser/dist/computer.js.map +1 -1
  376. package/packages/tools/browser/dist/controller.d.ts +20 -3
  377. package/packages/tools/browser/dist/controller.d.ts.map +1 -1
  378. package/packages/tools/browser/dist/controller.js +170 -5
  379. package/packages/tools/browser/dist/controller.js.map +1 -1
  380. package/packages/tools/browser/dist/index.d.ts.map +1 -1
  381. package/packages/tools/browser/dist/index.js +9 -1
  382. package/packages/tools/browser/dist/index.js.map +1 -1
  383. package/packages/tools/browser/dist/service.d.ts +14 -1
  384. package/packages/tools/browser/dist/service.d.ts.map +1 -1
  385. package/packages/tools/browser/dist/service.js +28 -5
  386. package/packages/tools/browser/dist/service.js.map +1 -1
  387. package/packages/tools/browser/dist/types.d.ts +11 -0
  388. package/packages/tools/browser/dist/types.d.ts.map +1 -1
  389. package/packages/tools/browser/dist/types.js +16 -3
  390. package/packages/tools/browser/dist/types.js.map +1 -1
  391. package/packages/tools/browser/package.json +1 -1
  392. package/packages/tools/email/dist/.tsbuildinfo +1 -1
  393. package/packages/tools/host/dist/.tsbuildinfo +1 -1
  394. package/packages/tools/memory/dist/.tsbuildinfo +1 -1
  395. package/packages/tools/web/dist/.tsbuildinfo +1 -1
  396. package/packages/web/dist/assets/index-D5cRFcgm.css +1 -0
  397. package/packages/web/dist/assets/index-GCFB1vBV.js +125 -0
  398. package/packages/web/dist/index.html +2 -2
  399. package/packages/web/dist/assets/index-BRc5auXm.js +0 -123
  400. package/packages/web/dist/assets/index-DwUpotTR.css +0 -1
@@ -1,4 +1,4 @@
1
- import { enhanceCommandError, hasCapability, parseBigIntValue } from '../tools.js';
1
+ import { hasCapability, parseBigIntValue, reportCommandError, getSelectedMailbox } from '../tools.js';
2
2
  /**
3
3
  * Deletes specified messages by flagging them as Deleted and expunging.
4
4
  *
@@ -9,14 +9,19 @@ import { enhanceCommandError, hasCapability, parseBigIntValue } from '../tools.j
9
9
  * @returns True on success, false on failure, or undefined if preconditions not met
10
10
  */
11
11
  export default async function expunge(connection, range, options) {
12
- if (connection.state !== connection.states.SELECTED || !range) {
12
+ let mailbox = getSelectedMailbox(connection);
13
+ if (!mailbox || !range) {
13
14
  // nothing to do here
14
15
  return;
15
16
  }
16
17
  options = options || {};
17
18
  // Two-step deletion process per IMAP protocol:
18
19
  // Step 1: Mark the target messages with the \Deleted flag.
19
- await connection.messageFlagsAdd(range, ['\\Deleted'], options);
20
+ // If that failed, EXPUNGE would not remove the target messages (and without
21
+ // UIDPLUS it would remove unrelated \Deleted messages), so report the failure instead.
22
+ if (!(await connection.messageFlagsAdd(range, ['\\Deleted'], options))) {
23
+ return false;
24
+ }
20
25
  // Step 2: Issue EXPUNGE to permanently remove \Deleted messages.
21
26
  // With UIDPLUS (RFC 4315): "UID EXPUNGE <uids>" removes only the specified UIDs,
22
27
  // leaving other \Deleted messages untouched, important for concurrent access.
@@ -35,7 +40,6 @@ export default async function expunge(connection, range, options) {
35
40
  if (responseCode.toUpperCase() === 'HIGHESTMODSEQ') {
36
41
  // A response code always comes with its section, see responseCode above
37
42
  let codeSection = section;
38
- let mailbox = connection.mailbox;
39
43
  // Bounded digit runs only: isNaN() also passes '1e5', which BigInt() rejects with
40
44
  // a throw that the catch below would swallow, making messageDelete() report false
41
45
  // even though the server expunged the messages.
@@ -48,8 +52,7 @@ export default async function expunge(connection, range, options) {
48
52
  return true;
49
53
  }
50
54
  catch (err) {
51
- await enhanceCommandError(err);
52
- connection.log.warn({ err, cid: connection.id });
55
+ await reportCommandError(connection, err);
53
56
  return false;
54
57
  }
55
58
  }
@@ -1,4 +1,4 @@
1
- import { formatMessageResponse, isRev2Active } from '../tools.js';
1
+ import { formatMessageResponse, isRev2Active, getSelectedMailbox } from '../tools.js';
2
2
  /**
3
3
  * Fetches emails from the server.
4
4
  *
@@ -9,23 +9,23 @@ import { formatMessageResponse, isRev2Active } from '../tools.js';
9
9
  * @returns Object with message count and list, or undefined if not in SELECTED state
10
10
  */
11
11
  export default async function fetch(connection, range, query, options) {
12
- if (connection.state !== connection.states.SELECTED || !range) {
12
+ let mailbox = getSelectedMailbox(connection);
13
+ if (!mailbox || !range) {
13
14
  // nothing to do here
14
15
  return;
15
16
  }
16
17
  options = options || {};
17
- let mailbox = connection.mailbox;
18
18
  // Use BINARY extension for fetching if supported and requested, otherwise fall back to BODY.
19
19
  // RFC 9051 folds the FETCH side of the BINARY extension into base IMAP4rev2, so an active
20
20
  // rev2 session can use it even without the BINARY capability token (the APPEND side is NOT
21
21
  // folded in and stays gated on the token in append.ts)
22
22
  const canUseBinary = connection.capabilities.has('BINARY') || isRev2Active(connection);
23
23
  const commandKey = canUseBinary && options.binary && !connection.disableBinary ? 'BINARY' : 'BODY';
24
- // Retry logic for ETHROTTLE errors (server rate limiting) with exponential backoff
25
- let retryCount = 0;
24
+ // Retry logic for ETHROTTLE errors (server rate limiting) with exponential backoff.
25
+ // Every pass returns or throws: the last throttled attempt throws instead of retrying.
26
26
  const maxRetries = 4;
27
27
  const baseDelay = 1000; // Start with 1 second delay
28
- while (retryCount < maxRetries) {
28
+ for (let retryCount = 0;; retryCount++) {
29
29
  let messages = {
30
30
  count: 0,
31
31
  list: []
@@ -202,15 +202,18 @@ export default async function fetch(connection, range, query, options) {
202
202
  return messages;
203
203
  }
204
204
  catch (err) {
205
- if (err.code === 'ETHROTTLE') {
205
+ // The last throttled attempt falls through and throws, so running out of retries
206
+ // is never mistaken for an empty result
207
+ if (err.code === 'ETHROTTLE' && retryCount < maxRetries - 1) {
206
208
  // Server returned a throttle error (rate limiting). Retry with exponential backoff.
207
- // Delay doubles each retry: 1s, 2s, 4s, 8s (capped at 30s).
209
+ // Delay doubles each retry: 1s, 2s, 4s.
208
210
  // If server provides a throttleReset hint, use that if longer.
209
211
  const backoffDelay = Math.min(baseDelay * Math.pow(2, retryCount), 30000); // Cap at 30 seconds
210
212
  // Use throttle reset time if provided and longer than backoff. The hint is
211
213
  // server-controlled, so the wait goes through connection.throttleWait(), which caps
212
- // it and keeps the timer tracked and abortable.
213
- const delay = err.throttleReset && err.throttleReset > backoffDelay ? err.throttleReset : backoffDelay;
214
+ // it and keeps the timer tracked and abortable. The connection already waited
215
+ // part of the back-off before rejecting (throttleWaited), so only the rest is left.
216
+ const delay = Math.max(err.throttleReset || 0, backoffDelay) - (err.throttleWaited || 0);
214
217
  connection.log.warn({
215
218
  msg: 'Retrying throttled request with exponential backoff',
216
219
  cid: connection.id,
@@ -226,7 +229,6 @@ export default async function fetch(connection, range, query, options) {
226
229
  if (aborted) {
227
230
  throw connection.createNoConnectionError(connection.byeReason, { rejectedFrom: 'throttleAbort', command: 'FETCH' });
228
231
  }
229
- retryCount++;
230
232
  continue;
231
233
  }
232
234
  connection.log.warn({ err, cid: connection.id });
@@ -1,4 +1,4 @@
1
- import { guardedPromise, hasCapability, logConnectionError, restampConnectionError, unrefTimer, clearTimer } from '../tools.js';
1
+ import { guardedPromise, hasCapability, logConnectionError, restampConnectionError, unrefTimer, clearTimer, getSelectedMailbox } from '../tools.js';
2
2
  const NOOP_INTERVAL = 2 * 60 * 1000;
3
3
  /**
4
4
  * Marks the connection as idling on behalf of one session and returns a release function.
@@ -121,7 +121,11 @@ async function runIdle(connection) {
121
121
  }
122
122
  catch (err) {
123
123
  logConnectionError(connection, 'IDLE session failed', err);
124
- if (preCheckWaitQueue.length) {
124
+ // A tagged NO or BAD only means the server refused IDLE; the connection is still usable,
125
+ // so the waiters are released by the finally block below and their own commands run.
126
+ // Anything else (close, lost socket, parser failure) fails the waiters too.
127
+ let refusedByServer = ['NO', 'BAD'].includes(err.responseStatus);
128
+ if (preCheckWaitQueue.length && !refusedByServer) {
125
129
  // One error for the whole queue: every waiter failed at the same site, for the same
126
130
  // reason. Built inside the guard so a teardown with nothing queued - the common case -
127
131
  // does not pay for an Error and its stack capture.
@@ -237,7 +241,7 @@ async function runPollingFallback(connection, maxIdleTime) {
237
241
  return;
238
242
  }
239
243
  // The transport or the mailbox may be gone by the time the timer fires
240
- if (!connection.socket || connection.socket.destroyed || connection.state !== connection.states.SELECTED || !connection.mailbox) {
244
+ if (!connection.socket || connection.socket.destroyed || !getSelectedMailbox(connection)) {
241
245
  return cancel();
242
246
  }
243
247
  pollOnce(connection, session)
@@ -181,7 +181,7 @@ export default async function list(connection, reference, mailbox, options) {
181
181
  entry.path = entry.path.slice(1);
182
182
  }
183
183
  // Build parent path hierarchy for tree construction and sorting
184
- entry.parentPath = entry.delimiter && entry.path ? entry.path.substr(0, entry.path.lastIndexOf(entry.delimiter)) : '';
184
+ entry.parentPath = entry.delimiter && entry.path ? entry.path.substring(0, entry.path.lastIndexOf(entry.delimiter)) : '';
185
185
  entry.parent = entry.delimiter ? entry.path.split(entry.delimiter) : [entry.path];
186
186
  entry.name = entry.parent.pop();
187
187
  // Try to detect special-use from server flags or well-known names
@@ -392,7 +392,7 @@ export default async function list(connection, reference, mailbox, options) {
392
392
  if (entry.delimiter && entry.path.charAt(0) === entry.delimiter) {
393
393
  entry.path = entry.path.slice(1);
394
394
  }
395
- entry.parentPath = entry.delimiter && entry.path ? entry.path.substr(0, entry.path.lastIndexOf(entry.delimiter)) : '';
395
+ entry.parentPath = entry.delimiter && entry.path ? entry.path.substring(0, entry.path.lastIndexOf(entry.delimiter)) : '';
396
396
  entry.parent = entry.delimiter ? entry.path.split(entry.delimiter) : [entry.path];
397
397
  entry.name = entry.parent.pop();
398
398
  // Merge LSUB data into existing LIST entry if found
@@ -444,23 +444,27 @@ export default async function list(connection, reference, mailbox, options) {
444
444
  connection.log.warn({ msg: 'Failed to request subscription info', err, cid: connection.id });
445
445
  }
446
446
  }
447
- // Resolve special-use conflicts: for each type, pick the best candidate
448
- // based on source priority (user > extension > name), then alphabetically.
449
- // Only the winning entry gets the specialUse property set.
450
- for (let type of Object.keys(specialUseMatches)) {
451
- let sortedEntries = specialUseMatches[type].sort((a, b) => {
452
- let aSource = SOURCE_SORT_ORDER.indexOf(a.source);
453
- let bSource = SOURCE_SORT_ORDER.indexOf(b.source);
454
- if (aSource === bSource) {
455
- return a.entry.path.localeCompare(b.entry.path);
456
- }
457
- return aSource - bSource;
458
- });
459
- if (!sortedEntries[0].entry.specialUse) {
460
- let source = sortedEntries[0].source;
461
- sortedEntries[0].entry.specialUse = type;
462
- sortedEntries[0].entry.specialUseSource = PUBLIC_SOURCE[source] || source;
447
+ // Resolve special-use conflicts. Each type goes to one mailbox and each mailbox gets
448
+ // at most one type. Candidates are taken in priority order across all types (user >
449
+ // extension > name, then alphabetically), so a mailbox claimed by a stronger match
450
+ // leaves its other type to that type's next candidate instead of to nobody.
451
+ let candidates = Object.entries(specialUseMatches).flatMap(([type, matches]) => matches.map(match => ({ type, ...match })));
452
+ candidates.sort((a, b) => {
453
+ let aSource = SOURCE_SORT_ORDER.indexOf(a.source);
454
+ let bSource = SOURCE_SORT_ORDER.indexOf(b.source);
455
+ if (aSource === bSource) {
456
+ return a.entry.path.localeCompare(b.entry.path);
457
+ }
458
+ return aSource - bSource;
459
+ });
460
+ let assignedTypes = new Set();
461
+ for (let { type, entry, source } of candidates) {
462
+ if (assignedTypes.has(type) || entry.specialUse) {
463
+ continue;
463
464
  }
465
+ entry.specialUse = type;
466
+ entry.specialUseSource = PUBLIC_SOURCE[source] || source;
467
+ assignedTypes.add(type);
464
468
  }
465
469
  // No source answered, so "not subscribed" was never actually reported for any of
466
470
  // these folders - the state is unknown, not false. Reporting the whole listing as
@@ -1,4 +1,4 @@
1
- import { normalizePath, encodePath, enhanceCommandError, hasCapability } from '../tools.js';
1
+ import { normalizePath, encodePath, hasCapability, reportCommandError, getSelectedMailbox } from '../tools.js';
2
2
  import { parseCopyUid } from './copyuid-parser.js';
3
3
  /**
4
4
  * Moves messages from the current mailbox to another mailbox.
@@ -11,7 +11,8 @@ import { parseCopyUid } from './copyuid-parser.js';
11
11
  * @returns Move result with UID mapping if available, false on failure, or undefined if preconditions not met
12
12
  */
13
13
  export default async function move(connection, range, destination, options) {
14
- if (connection.state !== connection.states.SELECTED || !range || !destination) {
14
+ let mailbox = getSelectedMailbox(connection);
15
+ if (!mailbox || !range || !destination) {
15
16
  // nothing to do here
16
17
  return;
17
18
  }
@@ -21,13 +22,18 @@ export default async function move(connection, range, destination, options) {
21
22
  { type: 'SEQUENCE', value: range },
22
23
  { type: 'ATOM', value: encodePath(connection, destination) }
23
24
  ];
24
- let map = { path: connection.mailbox.path, destination };
25
+ let map = { path: mailbox.path, destination };
25
26
  // Fallback for servers without the MOVE extension (RFC 6851):
26
27
  // emulate MOVE using COPY + flag as \Deleted + EXPUNGE.
27
28
  if (!hasCapability(connection, 'MOVE')) {
28
29
  let result = await connection.messageCopy(range, destination, options);
29
- await connection.messageDelete(range, Object.assign({ silent: true }, options));
30
- return result;
30
+ if (!result) {
31
+ // The source must stay untouched when the copy failed, otherwise the messages are lost
32
+ return result;
33
+ }
34
+ let deleted = await connection.messageDelete(range, Object.assign({ silent: true }, options));
35
+ // Messages that were copied but not removed from the source mean the move did not complete
36
+ return deleted ? result : false;
31
37
  }
32
38
  let response;
33
39
  try {
@@ -45,8 +51,7 @@ export default async function move(connection, range, destination, options) {
45
51
  return map;
46
52
  }
47
53
  catch (err) {
48
- await enhanceCommandError(err);
49
- connection.log.warn({ err, cid: connection.id });
54
+ await reportCommandError(connection, err);
50
55
  return false;
51
56
  }
52
57
  }
@@ -1,4 +1,4 @@
1
- import { hasCapability, getStringList } from '../tools.js';
1
+ import { hasCapability, getStringList, isAuthenticatedState } from '../tools.js';
2
2
  /**
3
3
  * Requests NAMESPACE info from the server.
4
4
  *
@@ -6,7 +6,7 @@ import { hasCapability, getStringList } from '../tools.js';
6
6
  * @returns The primary personal namespace, or an error object on failure
7
7
  */
8
8
  export default async function namespace(connection) {
9
- if (![connection.states.AUTHENTICATED, connection.states.SELECTED].includes(connection.state)) {
9
+ if (!isAuthenticatedState(connection)) {
10
10
  // nothing to do here
11
11
  return;
12
12
  }
@@ -1,4 +1,4 @@
1
- import { encodePath, normalizePath, enhanceCommandError, parseUintValue, isUnsafeKey } from '../tools.js';
1
+ import { encodePath, normalizePath, parseUintValue, isUnsafeKey, isAuthenticatedState, reportCommandError } from '../tools.js';
2
2
  /**
3
3
  * Requests quota information for a mailbox.
4
4
  *
@@ -7,7 +7,7 @@ import { encodePath, normalizePath, enhanceCommandError, parseUintValue, isUnsaf
7
7
  * @returns Quota information object, false if QUOTA not supported or on failure, or undefined if preconditions not met
8
8
  */
9
9
  export default async function quota(connection, path) {
10
- if (![connection.states.AUTHENTICATED, connection.states.SELECTED].includes(connection.state) || !path) {
10
+ if (!isAuthenticatedState(connection) || !path) {
11
11
  // nothing to do here
12
12
  return;
13
13
  }
@@ -47,19 +47,21 @@ export default async function quota(connection, path) {
47
47
  if (isUnsafeKey(key) || key === 'path' || key === 'quotaroot') {
48
48
  return;
49
49
  }
50
- if (!map[key]) {
51
- map[key] = {};
50
+ let resource = map[key];
51
+ if (typeof resource !== 'object') {
52
+ resource = {};
53
+ map[key] = resource;
52
54
  }
53
55
  // Storage quota is reported in KB by IMAP; convert to bytes for consistency
54
56
  const multiplier = key === 'storage' ? 1024 : 1;
55
57
  if (position === 1) {
56
- map[key].usage = value * multiplier;
58
+ resource.usage = value * multiplier;
57
59
  }
58
60
  else if (position === 2) {
59
- map[key].limit = value * multiplier;
61
+ resource.limit = value * multiplier;
60
62
  // Calculate usage percentage for convenient display
61
- if (map[key].limit) {
62
- map[key].status = Math.round(((map[key].usage || 0) / map[key].limit) * 100) + '%';
63
+ if (resource.limit) {
64
+ resource.status = Math.round(((resource.usage || 0) / resource.limit) * 100) + '%';
63
65
  }
64
66
  }
65
67
  });
@@ -107,8 +109,7 @@ export default async function quota(connection, path) {
107
109
  return map;
108
110
  }
109
111
  catch (err) {
110
- await enhanceCommandError(err);
111
- connection.log.warn({ err, cid: connection.id });
112
+ await reportCommandError(connection, err);
112
113
  return false;
113
114
  }
114
115
  }
@@ -1,4 +1,4 @@
1
- import { encodePath, normalizePath, enhanceCommandError } from '../tools.js';
1
+ import { encodePath, normalizePath, isAuthenticatedState, reportCommandError, getSelectedMailbox } from '../tools.js';
2
2
  /**
3
3
  * Renames an existing mailbox.
4
4
  *
@@ -9,7 +9,7 @@ import { encodePath, normalizePath, enhanceCommandError } from '../tools.js';
9
9
  * @throws If the RENAME command fails
10
10
  */
11
11
  export default async function rename(connection, path, newPath) {
12
- if (![connection.states.AUTHENTICATED, connection.states.SELECTED].includes(connection.state)) {
12
+ if (!isAuthenticatedState(connection)) {
13
13
  // nothing to do here
14
14
  return;
15
15
  }
@@ -19,7 +19,8 @@ export default async function rename(connection, path, newPath) {
19
19
  newPath = normalizePath(connection, newPath);
20
20
  // Must close/deselect the mailbox before renaming if it's currently selected,
21
21
  // as IMAP servers will not rename an active mailbox.
22
- if (connection.state === connection.states.SELECTED && connection.mailbox.path === path) {
22
+ let selected = getSelectedMailbox(connection);
23
+ if (selected && selected.path === path) {
23
24
  await connection.run('CLOSE');
24
25
  }
25
26
  let response;
@@ -36,8 +37,7 @@ export default async function rename(connection, path, newPath) {
36
37
  return map;
37
38
  }
38
39
  catch (err) {
39
- await enhanceCommandError(err);
40
- connection.log.warn({ err, cid: connection.id });
40
+ await reportCommandError(connection, err);
41
41
  throw err;
42
42
  }
43
43
  }
@@ -1,4 +1,4 @@
1
- import { enhanceCommandError, hasCapability, isValidSequenceValue, EXPANDED_RANGE_LIMIT } from '../tools.js';
1
+ import { hasCapability, isValidSequenceValue, EXPANDED_RANGE_LIMIT, reportCommandError, getSelectedMailbox } from '../tools.js';
2
2
  import { searchCompiler } from '../search-compiler.js';
3
3
  import { parseEsearchResponse } from './esearch-parser.js';
4
4
  /**
@@ -31,7 +31,8 @@ const stripEsearchPrefix = (attrs) => {
31
31
  * When server lacks ESEARCH, falls back to plain SEARCH and returns number[].
32
32
  */
33
33
  export default async function search(connection, query, options) {
34
- if (connection.state !== connection.states.SELECTED) {
34
+ const mailbox = getSelectedMailbox(connection);
35
+ if (!mailbox) {
35
36
  // nothing to do here
36
37
  return false;
37
38
  }
@@ -89,8 +90,7 @@ export default async function search(connection, query, options) {
89
90
  return esearchResult;
90
91
  }
91
92
  catch (err) {
92
- await enhanceCommandError(err);
93
- connection.log.warn({ err, cid: connection.id });
93
+ await reportCommandError(connection, err);
94
94
  return false;
95
95
  }
96
96
  }
@@ -160,7 +160,7 @@ export default async function search(connection, query, options) {
160
160
  // for message sequence numbers, while server-sent UID sets may
161
161
  // not contain '*' at all (RFC 9051 section 4.1.1), so UID
162
162
  // parts with '*' are dropped
163
- let existsCount = () => (connection.mailbox && connection.mailbox.exists) || 0;
163
+ let existsCount = () => mailbox.exists || 0;
164
164
  // The mailbox EXISTS count is itself server-supplied and can be
165
165
  // absurdly large, so the budget is additionally capped at the same
166
166
  // absolute ceiling expandRange() uses - a hostile server cannot
@@ -185,8 +185,8 @@ export default async function search(connection, query, options) {
185
185
  results.add(value);
186
186
  continue;
187
187
  }
188
- let first = resolveId(part.substr(0, colon));
189
- let second = resolveId(part.substr(colon + 1));
188
+ let first = resolveId(part.substring(0, colon));
189
+ let second = resolveId(part.slice(colon + 1));
190
190
  if (!isValidSequenceValue(first) || !isValidSequenceValue(second)) {
191
191
  discarded = true;
192
192
  continue;
@@ -216,8 +216,7 @@ export default async function search(connection, query, options) {
216
216
  return Array.from(results).sort((a, b) => a - b);
217
217
  }
218
218
  catch (err) {
219
- await enhanceCommandError(err);
220
- connection.log.warn({ err, cid: connection.id });
219
+ await reportCommandError(connection, err);
221
220
  return false;
222
221
  }
223
222
  }
@@ -1,4 +1,4 @@
1
- import { encodePath, normalizePath, enhanceCommandError, parseBigIntValue, parseUintValue, getStringList, MAX_UINT32_DIGITS } from '../tools.js';
1
+ import { encodePath, normalizePath, parseBigIntValue, parseUintValue, getStringList, MAX_UINT32_DIGITS, emitSafe, isAuthenticatedState, reportCommandError } from '../tools.js';
2
2
  // Response codes carrying a value that SELECT/EXAMINE may write to the mailbox object, keyed by
3
3
  // the lowercased code, mapped to the fixed public property name and the parser for the value.
4
4
  // Every parser returns false for a value it cannot use, and the field is then left unset.
@@ -56,7 +56,7 @@ const VALUED_RESPONSE_CODES = Object.assign(Object.create(null), {
56
56
  * @throws If the SELECT/EXAMINE command fails
57
57
  */
58
58
  export default async function select(connection, pathInput, options) {
59
- if (![connection.states.AUTHENTICATED, connection.states.SELECTED].includes(connection.state)) {
59
+ if (!isAuthenticatedState(connection)) {
60
60
  // nothing to do here
61
61
  return;
62
62
  }
@@ -92,12 +92,16 @@ export default async function select(connection, pathInput, options) {
92
92
  // QRESYNC (RFC 7162): allows efficient mailbox resynchronization by sending
93
93
  // the last known UIDVALIDITY and HIGHESTMODSEQ. Server responds with only
94
94
  // the changes (new flags, expunged UIDs) since that point.
95
+ // The caller may pass UIDVALIDITY as a bigint, a number or a string. It is parsed once,
96
+ // so the value that is sent is also the one checked against the server's below, and a
97
+ // value that is not a plain decimal skips QRESYNC instead of reaching the server.
98
+ let uidValidity = options.uidValidity !== undefined ? parseBigIntValue(String(options.uidValidity)) : false;
95
99
  let extraArgs = [];
96
- if (connection.enabled.has('QRESYNC') && options.changedSince && options.uidValidity) {
100
+ if (connection.enabled.has('QRESYNC') && options.changedSince && uidValidity) {
97
101
  extraArgs.push([
98
102
  { type: 'ATOM', value: 'QRESYNC' },
99
103
  [
100
- { type: 'ATOM', value: options.uidValidity?.toString() },
104
+ { type: 'ATOM', value: uidValidity.toString() },
101
105
  { type: 'ATOM', value: options.changedSince.toString() }
102
106
  ]
103
107
  ]);
@@ -202,7 +206,7 @@ export default async function select(connection, pathInput, options) {
202
206
  // QRESYNC results are only valid if UIDVALIDITY matches, HIGHESTMODSEQ is
203
207
  // present, and the mailbox supports mod-sequences. If any condition fails,
204
208
  // the client cannot trust the incremental updates and must do a full resync.
205
- if (map.qresync && (options.uidValidity !== map.uidValidity || !map.highestModseq || map.noModseq)) {
209
+ if (map.qresync && (uidValidity !== map.uidValidity || !map.highestModseq || map.noModseq)) {
206
210
  map.qresync = false;
207
211
  }
208
212
  // Transition mailbox state: save previous mailbox reference, temporarily
@@ -212,7 +216,7 @@ export default async function select(connection, pathInput, options) {
212
216
  // Emit mailboxClose if we're switching from a different mailbox.
213
217
  // Re-selecting the same mailbox (e.g., for resync) does not trigger close/open.
214
218
  if (currentMailbox && currentMailbox.path !== path) {
215
- connection.emit('mailboxClose', currentMailbox);
219
+ emitSafe(connection, 'mailboxClose', currentMailbox);
216
220
  }
217
221
  connection.mailbox = map;
218
222
  // Save the SELECT command for potential re-use (e.g., NOOP fallback polling
@@ -220,13 +224,13 @@ export default async function select(connection, pathInput, options) {
220
224
  connection.currentSelectCommand = selectCommand;
221
225
  connection.state = connection.states.SELECTED;
222
226
  if (!currentMailbox || currentMailbox.path !== path) {
223
- connection.emit('mailboxOpen', connection.mailbox);
227
+ emitSafe(connection, 'mailboxOpen', connection.mailbox);
224
228
  }
225
229
  response.next();
226
230
  return map;
227
231
  }
228
232
  catch (err) {
229
- await enhanceCommandError(err);
233
+ await reportCommandError(connection, err);
230
234
  // If SELECT/EXAMINE fails while a mailbox was already selected, we must
231
235
  // reset to AUTHENTICATED state since the server has implicitly deselected
232
236
  // the previous mailbox on failure (RFC 3501 Section 6.3.1).
@@ -236,10 +240,9 @@ export default async function select(connection, pathInput, options) {
236
240
  connection.currentSelectCommand = false;
237
241
  connection.state = connection.states.AUTHENTICATED;
238
242
  if (currentMailbox) {
239
- connection.emit('mailboxClose', currentMailbox);
243
+ emitSafe(connection, 'mailboxClose', currentMailbox);
240
244
  }
241
245
  }
242
- connection.log.warn({ err, cid: connection.id });
243
246
  throw err;
244
247
  }
245
248
  }
@@ -1,21 +1,20 @@
1
- import { encodePath, normalizePath, buildStatusQueryAttributes, isRev2Active } from '../tools.js';
1
+ import { encodePath, normalizePath, buildStatusQueryAttributes, isRev2Active, isAuthenticatedState, emitSafe, getSelectedMailbox } from '../tools.js';
2
2
  import { parseStatusList } from './status-fields.js';
3
3
  // STATUS fields that also refresh the live mailbox state when the queried mailbox is the
4
4
  // currently selected one. Keyed by the output property name parseStatusList() reports.
5
5
  const MAILBOX_UPDATERS = {
6
- messages: (value, connection, path) => {
7
- let mailbox = connection.mailbox;
6
+ messages: (value, mailbox, connection, path) => {
8
7
  let prevCount = mailbox.exists;
9
8
  if (prevCount !== value) {
10
9
  mailbox.exists = value;
11
- connection.emit('exists', { path, count: value, prevCount });
10
+ emitSafe(connection, 'exists', { path, count: value, prevCount });
12
11
  }
13
12
  },
14
- uidNext: (value, connection) => {
15
- connection.mailbox.uidNext = value;
13
+ uidNext: (value, mailbox) => {
14
+ mailbox.uidNext = value;
16
15
  },
17
- highestModseq: (value, connection) => {
18
- connection.mailbox.highestModseq = value;
16
+ highestModseq: (value, mailbox) => {
17
+ mailbox.highestModseq = value;
19
18
  }
20
19
  };
21
20
  /**
@@ -28,7 +27,7 @@ const MAILBOX_UPDATERS = {
28
27
  * @throws {Error} If the mailbox does not exist
29
28
  */
30
29
  export default async function status(connection, path, query) {
31
- if (![connection.states.AUTHENTICATED, connection.states.SELECTED].includes(connection.state) || !path) {
30
+ if (!isAuthenticatedState(connection) || !path) {
32
31
  // nothing to do here
33
32
  return false;
34
33
  }
@@ -59,7 +58,8 @@ export default async function status(connection, path, query) {
59
58
  STATUS: async (untagged) => {
60
59
  // If querying the currently selected mailbox, also update the
61
60
  // connection's live mailbox state and emit events for changes.
62
- let updateCurrent = connection.state === connection.states.SELECTED && path === connection.mailbox.path;
61
+ let selected = getSelectedMailbox(connection);
62
+ let currentMailbox = selected && selected.path === path ? selected : false;
63
63
  let list = untagged.attributes && Array.isArray(untagged.attributes[1]) ? untagged.attributes[1] : false;
64
64
  if (!list) {
65
65
  return;
@@ -67,8 +67,8 @@ export default async function status(connection, path, query) {
67
67
  parseStatusList(list, (key, value) => {
68
68
  map[key] = value;
69
69
  let updater = MAILBOX_UPDATERS[key];
70
- if (updateCurrent && updater) {
71
- updater(value, connection, path);
70
+ if (currentMailbox && updater) {
71
+ updater(value, currentMailbox, connection, path);
72
72
  }
73
73
  });
74
74
  }
@@ -1,4 +1,4 @@
1
- import { formatFlag, canUseFlag, enhanceCommandError } from '../tools.js';
1
+ import { formatFlag, canUseFlag, reportCommandError, getSelectedMailbox } from '../tools.js';
2
2
  /**
3
3
  * Updates flags or labels for messages in the selected mailbox.
4
4
  *
@@ -9,7 +9,8 @@ import { formatFlag, canUseFlag, enhanceCommandError } from '../tools.js';
9
9
  * @returns True on success, false on failure or if nothing to do
10
10
  */
11
11
  export default async function store(connection, range, flags, options) {
12
- if (connection.state !== connection.states.SELECTED || !range || (options.useLabels && !connection.capabilities.has('X-GM-EXT-1'))) {
12
+ let mailbox = getSelectedMailbox(connection);
13
+ if (!mailbox || !range || (options.useLabels && !connection.capabilities.has('X-GM-EXT-1'))) {
13
14
  // nothing to do here
14
15
  return false;
15
16
  }
@@ -45,7 +46,7 @@ export default async function store(connection, range, flags, options) {
45
46
  flags = (Array.isArray(flags) ? flags : [].concat(flags || []))
46
47
  .map(flag => {
47
48
  let formatted = formatFlag(flag);
48
- if (!canUseFlag(connection.mailbox, formatted) && options.operation !== 'remove') {
49
+ if (!canUseFlag(mailbox, formatted) && options.operation !== 'remove') {
49
50
  return false;
50
51
  }
51
52
  return formatted;
@@ -62,7 +63,7 @@ export default async function store(connection, range, flags, options) {
62
63
  ];
63
64
  // CONDSTORE (RFC 7162): UNCHANGEDSINCE modifier prevents updating messages whose
64
65
  // mod-sequence is higher than the specified value, avoiding overwriting concurrent changes.
65
- if (options.unchangedSince && connection.enabled.has('CONDSTORE') && !connection.mailbox.noModseq) {
66
+ if (options.unchangedSince && connection.enabled.has('CONDSTORE') && !mailbox.noModseq) {
66
67
  attributes.push([
67
68
  {
68
69
  type: 'ATOM',
@@ -81,8 +82,7 @@ export default async function store(connection, range, flags, options) {
81
82
  return true;
82
83
  }
83
84
  catch (err) {
84
- await enhanceCommandError(err);
85
- connection.log.warn({ err, cid: connection.id });
85
+ await reportCommandError(connection, err);
86
86
  return false;
87
87
  }
88
88
  }
@@ -1,4 +1,4 @@
1
- import { encodePath, normalizePath, enhanceCommandError } from '../tools.js';
1
+ import { setSubscription } from './subscription.js';
2
2
  /**
3
3
  * Subscribes to a mailbox.
4
4
  *
@@ -7,20 +7,5 @@ import { encodePath, normalizePath, enhanceCommandError } from '../tools.js';
7
7
  * @returns True on success, false on failure, or undefined if preconditions not met
8
8
  */
9
9
  export default async function subscribe(connection, path) {
10
- if (![connection.states.AUTHENTICATED, connection.states.SELECTED].includes(connection.state)) {
11
- // nothing to do here
12
- return;
13
- }
14
- path = normalizePath(connection, path);
15
- let response;
16
- try {
17
- response = await connection.exec('SUBSCRIBE', [{ type: 'ATOM', value: encodePath(connection, path) }]);
18
- response.next();
19
- return true;
20
- }
21
- catch (err) {
22
- await enhanceCommandError(err);
23
- connection.log.warn({ err, cid: connection.id });
24
- return false;
25
- }
10
+ return await setSubscription(connection, 'SUBSCRIBE', path);
26
11
  }
@@ -0,0 +1,10 @@
1
+ import type { ImapFlow } from '../imap-flow.js';
2
+ /**
3
+ * Runs SUBSCRIBE or UNSUBSCRIBE for a mailbox, the shared body of the two commands.
4
+ *
5
+ * @param connection - IMAP connection instance
6
+ * @param command - SUBSCRIBE or UNSUBSCRIBE
7
+ * @param path - Mailbox path
8
+ * @returns True on success, false on failure, or undefined if preconditions not met
9
+ */
10
+ export declare function setSubscription(connection: ImapFlow, command: 'SUBSCRIBE' | 'UNSUBSCRIBE', path: string | string[]): Promise<boolean | undefined>;