botmancers 0.5.0 → 0.7.0

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 (993) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/README.md +17 -12
  3. package/app/.next/BUILD_ID +1 -1
  4. package/app/.next/app-path-routes-manifest.json +9 -2
  5. package/app/.next/build-manifest.json +3 -3
  6. package/app/.next/node_modules/@slack/socket-mode-77e8cba3b9ba4738/index.js +1 -0
  7. package/app/.next/node_modules/@slack/socket-mode-77e8cba3b9ba4738/package.json +1 -0
  8. package/app/.next/node_modules/@slack/web-api-d6dbe405b6902642/index.js +1 -0
  9. package/app/.next/node_modules/@slack/web-api-d6dbe405b6902642/package.json +1 -0
  10. package/app/.next/prerender-manifest.json +4 -4
  11. package/app/.next/required-server-files.json +8 -3
  12. package/app/.next/routes-manifest.json +67 -12
  13. package/app/.next/server/app/_global-error/page.js +1 -1
  14. package/app/.next/server/app/_global-error/page.js.nft.json +1 -1
  15. package/app/.next/server/app/_global-error.html +1 -1
  16. package/app/.next/server/app/_global-error.rsc +1 -1
  17. package/app/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  18. package/app/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  19. package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  20. package/app/.next/server/app/_not-found/page.js +1 -1
  21. package/app/.next/server/app/_not-found/page.js.nft.json +1 -1
  22. package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  23. package/app/.next/server/app/_not-found.html +1 -1
  24. package/app/.next/server/app/_not-found.rsc +2 -2
  25. package/app/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  26. package/app/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  27. package/app/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  28. package/app/.next/server/app/api/bots/[id]/config/route.js +3 -3
  29. package/app/.next/server/app/api/bots/[id]/config/route.js.nft.json +1 -1
  30. package/app/.next/server/app/api/bots/[id]/sessions/[ref]/pins/route.js +5 -6
  31. package/app/.next/server/app/api/bots/[id]/sessions/[ref]/pins/route.js.nft.json +1 -1
  32. package/app/.next/server/app/api/bots/[id]/sessions/[ref]/route.js +3 -3
  33. package/app/.next/server/app/api/bots/[id]/sessions/[ref]/route.js.nft.json +1 -1
  34. package/app/.next/server/app/api/bots/[id]/sessions/[ref]/shares/route/app-paths-manifest.json +3 -0
  35. package/app/.next/server/app/api/bots/[id]/sessions/[ref]/shares/route.js +11 -0
  36. package/app/.next/server/app/api/bots/[id]/sessions/[ref]/shares/route.js.nft.json +1 -0
  37. package/app/.next/server/app/api/bots/[id]/sessions/[ref]/shares/route_client-reference-manifest.js +3 -0
  38. package/app/.next/server/app/api/bots/[id]/sessions/route.js +5 -6
  39. package/app/.next/server/app/api/bots/[id]/sessions/route.js.nft.json +1 -1
  40. package/app/.next/server/app/api/bots/[id]/share-policy/route/app-paths-manifest.json +3 -0
  41. package/app/.next/server/app/api/bots/[id]/share-policy/route.js +11 -0
  42. package/app/.next/server/app/api/bots/[id]/share-policy/route.js.nft.json +1 -0
  43. package/app/.next/server/app/api/bots/[id]/share-policy/route_client-reference-manifest.js +3 -0
  44. package/app/.next/server/app/api/bots/[id]/skill/route.js +3 -3
  45. package/app/.next/server/app/api/bots/[id]/skill/route.js.nft.json +1 -1
  46. package/app/.next/server/app/api/bots/availability/route.js +3 -2
  47. package/app/.next/server/app/api/bots/availability/route.js.nft.json +1 -1
  48. package/app/.next/server/app/api/bots/delete-preview/route.js +3 -3
  49. package/app/.next/server/app/api/bots/delete-preview/route.js.nft.json +1 -1
  50. package/app/.next/server/app/api/bots/import/route.js +3 -3
  51. package/app/.next/server/app/api/bots/import/route.js.nft.json +1 -1
  52. package/app/.next/server/app/api/bots/manage/route.js +3 -3
  53. package/app/.next/server/app/api/bots/manage/route.js.nft.json +1 -1
  54. package/app/.next/server/app/api/bots/name-migrations/route.js +3 -3
  55. package/app/.next/server/app/api/bots/name-migrations/route.js.nft.json +1 -1
  56. package/app/.next/server/app/api/bots/route.js +7 -7
  57. package/app/.next/server/app/api/bots/route.js.nft.json +1 -1
  58. package/app/.next/server/app/api/conversations/[id]/approve/route.js +4 -4
  59. package/app/.next/server/app/api/conversations/[id]/approve/route.js.nft.json +1 -1
  60. package/app/.next/server/app/api/conversations/[id]/deny/route.js +4 -4
  61. package/app/.next/server/app/api/conversations/[id]/deny/route.js.nft.json +1 -1
  62. package/app/.next/server/app/api/conversations/[id]/draft/route.js +4 -4
  63. package/app/.next/server/app/api/conversations/[id]/draft/route.js.nft.json +1 -1
  64. package/app/.next/server/app/api/conversations/[id]/messages/[messageId]/stop/route.js +3 -3
  65. package/app/.next/server/app/api/conversations/[id]/messages/[messageId]/stop/route.js.nft.json +1 -1
  66. package/app/.next/server/app/api/conversations/[id]/messages/route.js +7 -7
  67. package/app/.next/server/app/api/conversations/[id]/messages/route.js.nft.json +1 -1
  68. package/app/.next/server/app/api/conversations/[id]/route.js +3 -3
  69. package/app/.next/server/app/api/conversations/[id]/route.js.nft.json +1 -1
  70. package/app/.next/server/app/api/conversations/[id]/stop/route.js +4 -4
  71. package/app/.next/server/app/api/conversations/[id]/stop/route.js.nft.json +1 -1
  72. package/app/.next/server/app/api/conversations/route.js +3 -3
  73. package/app/.next/server/app/api/conversations/route.js.nft.json +1 -1
  74. package/app/.next/server/app/api/exchanges/[id]/cancel/route.js +4 -4
  75. package/app/.next/server/app/api/exchanges/[id]/cancel/route.js.nft.json +1 -1
  76. package/app/.next/server/app/api/exchanges/[id]/route.js +5 -5
  77. package/app/.next/server/app/api/exchanges/[id]/route.js.nft.json +1 -1
  78. package/app/.next/server/app/api/exchanges/route.js +6 -6
  79. package/app/.next/server/app/api/exchanges/route.js.nft.json +1 -1
  80. package/app/.next/server/app/api/files/[name]/route.js +1 -1
  81. package/app/.next/server/app/api/files/[name]/route.js.nft.json +1 -1
  82. package/app/.next/server/app/api/groups/route.js +3 -3
  83. package/app/.next/server/app/api/groups/route.js.nft.json +1 -1
  84. package/app/.next/server/app/api/health/route.js +5 -2
  85. package/app/.next/server/app/api/health/route.js.nft.json +1 -1
  86. package/app/.next/server/app/api/import-capabilities/route.js +1 -1
  87. package/app/.next/server/app/api/import-capabilities/route.js.nft.json +1 -1
  88. package/app/.next/server/app/api/marketplace-handoff/route.js +1 -1
  89. package/app/.next/server/app/api/marketplace-handoff/route.js.nft.json +1 -1
  90. package/app/.next/server/app/api/marketplace-handoff/status/route.js +1 -1
  91. package/app/.next/server/app/api/marketplace-handoff/status/route.js.nft.json +1 -1
  92. package/app/.next/server/app/api/mcp/route.js +3 -3
  93. package/app/.next/server/app/api/mcp/route.js.nft.json +1 -1
  94. package/app/.next/server/app/api/messages/[id]/between/route.js +3 -3
  95. package/app/.next/server/app/api/messages/[id]/between/route.js.nft.json +1 -1
  96. package/app/.next/server/app/api/runtime-connections/route.js +3 -3
  97. package/app/.next/server/app/api/runtime-connections/route.js.nft.json +1 -1
  98. package/app/.next/server/app/api/service-grants/route.js +3 -3
  99. package/app/.next/server/app/api/service-grants/route.js.nft.json +1 -1
  100. package/app/.next/server/app/api/shares/[shareRef]/revoke/route/app-paths-manifest.json +3 -0
  101. package/app/.next/server/app/api/shares/[shareRef]/revoke/route/build-manifest.json +12 -0
  102. package/app/.next/server/app/api/shares/[shareRef]/revoke/route/server-reference-manifest.json +4 -0
  103. package/app/.next/server/app/api/shares/[shareRef]/revoke/route.js +11 -0
  104. package/app/.next/server/app/api/shares/[shareRef]/revoke/route.js.nft.json +1 -0
  105. package/app/.next/server/app/api/shares/[shareRef]/revoke/route_client-reference-manifest.js +3 -0
  106. package/app/.next/server/app/api/shares/route/app-paths-manifest.json +3 -0
  107. package/app/.next/server/app/api/shares/route/build-manifest.json +12 -0
  108. package/app/.next/server/app/api/shares/route/server-reference-manifest.json +4 -0
  109. package/app/.next/server/app/api/shares/route.js +11 -0
  110. package/app/.next/server/app/api/shares/route.js.nft.json +1 -0
  111. package/app/.next/server/app/api/shares/route_client-reference-manifest.js +3 -0
  112. package/app/.next/server/app/api/v0/agents/[agentId]/conversations/[conversationId]/route.js +5 -6
  113. package/app/.next/server/app/api/v0/agents/[agentId]/conversations/[conversationId]/route.js.nft.json +1 -1
  114. package/app/.next/server/app/api/v0/agents/[agentId]/conversations/route.js +5 -6
  115. package/app/.next/server/app/api/v0/agents/[agentId]/conversations/route.js.nft.json +1 -1
  116. package/app/.next/server/app/api/v0/agents/[agentId]/messages/route.js +4 -4
  117. package/app/.next/server/app/api/v0/agents/[agentId]/messages/route.js.nft.json +1 -1
  118. package/app/.next/server/app/api/v0/agents/[agentId]/pins/route.js +5 -6
  119. package/app/.next/server/app/api/v0/agents/[agentId]/pins/route.js.nft.json +1 -1
  120. package/app/.next/server/app/api/v0/agents/[agentId]/route.js +5 -6
  121. package/app/.next/server/app/api/v0/agents/[agentId]/route.js.nft.json +1 -1
  122. package/app/.next/server/app/api/v0/agents/[agentId]/sessions/[ref]/route.js +5 -6
  123. package/app/.next/server/app/api/v0/agents/[agentId]/sessions/[ref]/route.js.nft.json +1 -1
  124. package/app/.next/server/app/api/v0/agents/[agentId]/sessions/route.js +5 -6
  125. package/app/.next/server/app/api/v0/agents/[agentId]/sessions/route.js.nft.json +1 -1
  126. package/app/.next/server/app/api/v0/agents/route.js +5 -6
  127. package/app/.next/server/app/api/v0/agents/route.js.nft.json +1 -1
  128. package/app/.next/server/app/api/v0/capabilities/route.js +5 -6
  129. package/app/.next/server/app/api/v0/capabilities/route.js.nft.json +1 -1
  130. package/app/.next/server/app/api/v0/conversations/[id]/route.js +4 -4
  131. package/app/.next/server/app/api/v0/conversations/[id]/route.js.nft.json +1 -1
  132. package/app/.next/server/app/api/v0/exchanges/[id]/cancel/route.js +5 -6
  133. package/app/.next/server/app/api/v0/exchanges/[id]/cancel/route.js.nft.json +1 -1
  134. package/app/.next/server/app/api/v0/exchanges/[id]/route.js +5 -6
  135. package/app/.next/server/app/api/v0/exchanges/[id]/route.js.nft.json +1 -1
  136. package/app/.next/server/app/api/v0/exchanges/route.js +5 -6
  137. package/app/.next/server/app/api/v0/exchanges/route.js.nft.json +1 -1
  138. package/app/.next/server/app/api/v0/mcp/route.js +6 -7
  139. package/app/.next/server/app/api/v0/mcp/route.js.nft.json +1 -1
  140. package/app/.next/server/app/api/v0/pins/[pinRef]/detach/route.js +5 -6
  141. package/app/.next/server/app/api/v0/pins/[pinRef]/detach/route.js.nft.json +1 -1
  142. package/app/.next/server/app/api/v0/pins/[pinRef]/messages/route.js +5 -6
  143. package/app/.next/server/app/api/v0/pins/[pinRef]/messages/route.js.nft.json +1 -1
  144. package/app/.next/server/app/api/v0/pins/[pinRef]/route.js +5 -6
  145. package/app/.next/server/app/api/v0/pins/[pinRef]/route.js.nft.json +1 -1
  146. package/app/.next/server/app/api/v0/requests/[id]/route.js +4 -4
  147. package/app/.next/server/app/api/v0/requests/[id]/route.js.nft.json +1 -1
  148. package/app/.next/server/app/api/v0/sessions/[ref]/messages/route.js +5 -6
  149. package/app/.next/server/app/api/v0/sessions/[ref]/messages/route.js.nft.json +1 -1
  150. package/app/.next/server/app/api/v0/sessions/[ref]/pins/route.js +5 -6
  151. package/app/.next/server/app/api/v0/sessions/[ref]/pins/route.js.nft.json +1 -1
  152. package/app/.next/server/app/api/v0/sessions/[ref]/shares/route/app-paths-manifest.json +3 -0
  153. package/app/.next/server/app/api/v0/sessions/[ref]/shares/route/build-manifest.json +12 -0
  154. package/app/.next/server/app/api/v0/sessions/[ref]/shares/route/server-reference-manifest.json +4 -0
  155. package/app/.next/server/app/api/v0/sessions/[ref]/shares/route.js +11 -0
  156. package/app/.next/server/app/api/v0/sessions/[ref]/shares/route.js.nft.json +1 -0
  157. package/app/.next/server/app/api/v0/sessions/[ref]/shares/route_client-reference-manifest.js +3 -0
  158. package/app/.next/server/app/api/v0/shares/[shareRef]/revoke/route/app-paths-manifest.json +3 -0
  159. package/app/.next/server/app/api/v0/shares/[shareRef]/revoke/route/build-manifest.json +12 -0
  160. package/app/.next/server/app/api/v0/shares/[shareRef]/revoke/route/server-reference-manifest.json +4 -0
  161. package/app/.next/server/app/api/v0/shares/[shareRef]/revoke/route.js +11 -0
  162. package/app/.next/server/app/api/v0/shares/[shareRef]/revoke/route.js.nft.json +1 -0
  163. package/app/.next/server/app/api/v0/shares/[shareRef]/revoke/route_client-reference-manifest.js +3 -0
  164. package/app/.next/server/app/api/v0/shares/[shareRef]/route/app-paths-manifest.json +3 -0
  165. package/app/.next/server/app/api/v0/shares/[shareRef]/route/build-manifest.json +12 -0
  166. package/app/.next/server/app/api/v0/shares/[shareRef]/route/server-reference-manifest.json +4 -0
  167. package/app/.next/server/app/api/v0/shares/[shareRef]/route.js +11 -0
  168. package/app/.next/server/app/api/v0/shares/[shareRef]/route.js.nft.json +1 -0
  169. package/app/.next/server/app/api/v0/shares/[shareRef]/route_client-reference-manifest.js +3 -0
  170. package/app/.next/server/app/api/v0/shares/current/route/app-paths-manifest.json +3 -0
  171. package/app/.next/server/app/api/v0/shares/current/route/build-manifest.json +12 -0
  172. package/app/.next/server/app/api/v0/shares/current/route/server-reference-manifest.json +4 -0
  173. package/app/.next/server/app/api/v0/shares/current/route.js +11 -0
  174. package/app/.next/server/app/api/v0/shares/current/route.js.nft.json +1 -0
  175. package/app/.next/server/app/api/v0/shares/current/route_client-reference-manifest.js +3 -0
  176. package/app/.next/server/app/api/v0/shares/route/app-paths-manifest.json +3 -0
  177. package/app/.next/server/app/api/v0/shares/route/build-manifest.json +12 -0
  178. package/app/.next/server/app/api/v0/shares/route/server-reference-manifest.json +4 -0
  179. package/app/.next/server/app/api/v0/shares/route.js +11 -0
  180. package/app/.next/server/app/api/v0/shares/route.js.nft.json +1 -0
  181. package/app/.next/server/app/api/v0/shares/route_client-reference-manifest.js +3 -0
  182. package/app/.next/server/app/api/wake-grants/[id]/revoke/route.js +4 -4
  183. package/app/.next/server/app/api/wake-grants/[id]/revoke/route.js.nft.json +1 -1
  184. package/app/.next/server/app/api/wakes/[id]/decision/route.js +4 -4
  185. package/app/.next/server/app/api/wakes/[id]/decision/route.js.nft.json +1 -1
  186. package/app/.next/server/app/api/wakes/[id]/retry/route.js +4 -4
  187. package/app/.next/server/app/api/wakes/[id]/retry/route.js.nft.json +1 -1
  188. package/app/.next/server/app/bots/[id]/config/page.js +1 -1
  189. package/app/.next/server/app/bots/[id]/config/page.js.nft.json +1 -1
  190. package/app/.next/server/app/bots/[id]/config/page_client-reference-manifest.js +1 -1
  191. package/app/.next/server/app/exchanges/page.js +1 -1
  192. package/app/.next/server/app/exchanges/page.js.nft.json +1 -1
  193. package/app/.next/server/app/exchanges/page_client-reference-manifest.js +1 -1
  194. package/app/.next/server/app/exchanges.html +1 -1
  195. package/app/.next/server/app/exchanges.rsc +3 -3
  196. package/app/.next/server/app/exchanges.segments/_full.segment.rsc +3 -3
  197. package/app/.next/server/app/exchanges.segments/_tree.segment.rsc +2 -2
  198. package/app/.next/server/app/exchanges.segments/exchanges/__PAGE__.segment.rsc +3 -3
  199. package/app/.next/server/app/index.html +1 -1
  200. package/app/.next/server/app/index.rsc +3 -3
  201. package/app/.next/server/app/index.segments/__PAGE__.segment.rsc +3 -3
  202. package/app/.next/server/app/index.segments/_full.segment.rsc +3 -3
  203. package/app/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  204. package/app/.next/server/app/page.js +1 -1
  205. package/app/.next/server/app/page.js.nft.json +1 -1
  206. package/app/.next/server/app/page_client-reference-manifest.js +1 -1
  207. package/app/.next/server/app/settings/page.js +1 -1
  208. package/app/.next/server/app/settings/page.js.nft.json +1 -1
  209. package/app/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  210. package/app/.next/server/app/settings.html +1 -1
  211. package/app/.next/server/app/settings.rsc +3 -3
  212. package/app/.next/server/app/settings.segments/_full.segment.rsc +3 -3
  213. package/app/.next/server/app/settings.segments/_tree.segment.rsc +2 -2
  214. package/app/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +3 -3
  215. package/app/.next/server/app/threads/[id]/page.js +1 -1
  216. package/app/.next/server/app/threads/[id]/page.js.nft.json +1 -1
  217. package/app/.next/server/app/threads/[id]/page_client-reference-manifest.js +1 -1
  218. package/app/.next/server/app-paths-manifest.json +9 -2
  219. package/app/.next/server/chunks/1oeh_server_app_api_bots_[id]_sessions_[ref]_shares_route_actions_1jr6f0v.js +3 -0
  220. package/app/.next/server/chunks/[externals]_@slack_0owayck._.js +3 -0
  221. package/app/.next/server/chunks/[externals]__17bolvp._.js +3 -0
  222. package/app/.next/server/chunks/{[externals]__06lqs5i._.js → [externals]__1eaoma8._.js} +1 -1
  223. package/app/.next/server/chunks/[root-of-the-server]__0-vcyi-._.js +3 -0
  224. package/app/.next/server/chunks/[root-of-the-server]__0-w_t2y._.js +3 -0
  225. package/app/.next/server/chunks/{[root-of-the-server]__1_01-13._.js → [root-of-the-server]__029-_9t._.js} +2 -2
  226. package/app/.next/server/chunks/[root-of-the-server]__02vrtib._.js +4 -0
  227. package/app/.next/server/chunks/[root-of-the-server]__04b3ml2._.js +3 -0
  228. package/app/.next/server/chunks/[root-of-the-server]__06w5xhe._.js +3 -0
  229. package/app/.next/server/chunks/[root-of-the-server]__0792yb1._.js +44 -0
  230. package/app/.next/server/chunks/[root-of-the-server]__07q5mnr._.js +3 -0
  231. package/app/.next/server/chunks/[root-of-the-server]__0888o0_._.js +3 -0
  232. package/app/.next/server/chunks/[root-of-the-server]__0aincj4._.js +3 -0
  233. package/app/.next/server/chunks/[root-of-the-server]__0d3fjix._.js +1 -1
  234. package/app/.next/server/chunks/[root-of-the-server]__0e_agq4._.js +3 -0
  235. package/app/.next/server/chunks/[root-of-the-server]__0ey3_2x._.js +3 -0
  236. package/app/.next/server/chunks/[root-of-the-server]__0fku-bw._.js +3 -0
  237. package/app/.next/server/chunks/[root-of-the-server]__0iqh5ta._.js +3 -0
  238. package/app/.next/server/chunks/[root-of-the-server]__0ivjcgs._.js +4 -0
  239. package/app/.next/server/chunks/[root-of-the-server]__0kgnysc._.js +3 -0
  240. package/app/.next/server/chunks/[root-of-the-server]__0mp8bap._.js +3 -0
  241. package/app/.next/server/chunks/[root-of-the-server]__0o9ijih._.js +3 -0
  242. package/app/.next/server/chunks/[root-of-the-server]__0qaiqut._.js +44 -0
  243. package/app/.next/server/chunks/[root-of-the-server]__0zrx1iz._.js +3 -0
  244. package/app/.next/server/chunks/[root-of-the-server]__10b5-i-._.js +3 -0
  245. package/app/.next/server/chunks/[root-of-the-server]__17mum5-._.js +1 -1
  246. package/app/.next/server/chunks/[root-of-the-server]__17xl_55._.js +3 -0
  247. package/app/.next/server/chunks/[root-of-the-server]__1dxr858._.js +3 -0
  248. package/app/.next/server/chunks/[root-of-the-server]__1eps2a4._.js +3 -0
  249. package/app/.next/server/chunks/[root-of-the-server]__1ggmit0._.js +4 -0
  250. package/app/.next/server/chunks/{[root-of-the-server]__1y_j43n._.js → [root-of-the-server]__1hwy3jx._.js} +1 -1
  251. package/app/.next/server/chunks/[root-of-the-server]__1i8glt4._.js +4 -0
  252. package/app/.next/server/chunks/{[root-of-the-server]__0j0i8xz._.js → [root-of-the-server]__1igzl05._.js} +1 -1
  253. package/app/.next/server/chunks/[root-of-the-server]__1j8fg_n._.js +3 -0
  254. package/app/.next/server/chunks/[root-of-the-server]__1kczttr._.js +3 -0
  255. package/app/.next/server/chunks/{[root-of-the-server]__1c3e2ds._.js → [root-of-the-server]__1kik2zt._.js} +1 -1
  256. package/app/.next/server/chunks/[root-of-the-server]__1v3ikuo._.js +3 -0
  257. package/app/.next/server/chunks/[root-of-the-server]__1x8phwp._.js +44 -0
  258. package/app/.next/server/chunks/{[root-of-the-server]__0-45blq._.js → [root-of-the-server]__1z5l5cg._.js} +2 -2
  259. package/app/.next/server/chunks/[root-of-the-server]__200ep0k._.js +3 -0
  260. package/app/.next/server/chunks/_0061c2q._.js +48 -1
  261. package/app/.next/server/chunks/_04e2bgj._.js +3 -0
  262. package/app/.next/server/chunks/_057h7zr._.js +3 -0
  263. package/app/.next/server/chunks/_05po7b4._.js +3 -0
  264. package/app/.next/server/chunks/_06sxx0e._.js +3 -0
  265. package/app/.next/server/chunks/_0a2do3x._.js +1 -1
  266. package/app/.next/server/chunks/_0ar2ooe._.js +3 -0
  267. package/app/.next/server/chunks/_0fmotaz._.js +3 -0
  268. package/app/.next/server/chunks/_0kpfto_._.js +3 -0
  269. package/app/.next/server/chunks/_0lm6uis._.js +3 -0
  270. package/app/.next/server/chunks/_0mpu5tl._.js +3 -0
  271. package/app/.next/server/chunks/_0qv-4by._.js +3 -0
  272. package/app/.next/server/chunks/_0u9cfq9._.js +3 -0
  273. package/app/.next/server/chunks/_0ul8k7g._.js +3 -0
  274. package/app/.next/server/chunks/_1-5mthb._.js +1 -1
  275. package/app/.next/server/chunks/_1-60d3o._.js +3 -0
  276. package/app/.next/server/chunks/_133y3b0._.js +3 -0
  277. package/app/.next/server/chunks/_167960a._.js +3 -0
  278. package/app/.next/server/chunks/_17vgjlt._.js +3 -0
  279. package/app/.next/server/chunks/_1amx9_4._.js +3 -0
  280. package/app/.next/server/chunks/_1b01v-_._.js +3 -0
  281. package/app/.next/server/chunks/_1c-g4gq._.js +3 -0
  282. package/app/.next/server/chunks/_1ey6l4p._.js +3 -0
  283. package/app/.next/server/chunks/_1nlg4x_._.js +3 -0
  284. package/app/.next/server/chunks/_1x4dqzv._.js +3 -0
  285. package/app/.next/server/chunks/_1z0qbzc._.js +3 -0
  286. package/app/.next/server/chunks/_next-internal_server_app_api_bots_[id]_share-policy_route_actions_0x-p250.js +3 -0
  287. package/app/.next/server/chunks/_next-internal_server_app_api_shares_[shareRef]_revoke_route_actions_1cu5kah.js +3 -0
  288. package/app/.next/server/chunks/_next-internal_server_app_api_shares_route_actions_0wk7x1r.js +3 -0
  289. package/app/.next/server/chunks/_next-internal_server_app_api_v0_sessions_[ref]_shares_route_actions_11fh--7.js +3 -0
  290. package/app/.next/server/chunks/_next-internal_server_app_api_v0_shares_[shareRef]_revoke_route_actions_00rzyj9.js +3 -0
  291. package/app/.next/server/chunks/_next-internal_server_app_api_v0_shares_[shareRef]_route_actions_0i1t5qb.js +3 -0
  292. package/app/.next/server/chunks/_next-internal_server_app_api_v0_shares_current_route_actions_1w_bpas.js +3 -0
  293. package/app/.next/server/chunks/_next-internal_server_app_api_v0_shares_route_actions_1b38was.js +3 -0
  294. package/app/.next/server/chunks/lib_0-opbv7._.js +316 -0
  295. package/app/.next/server/chunks/lib_0aejojj._.js +316 -0
  296. package/app/.next/server/chunks/lib_0il0ml1._.js +316 -0
  297. package/app/.next/server/chunks/lib_0iujsdg._.js +316 -0
  298. package/app/.next/server/chunks/lib_0kik6bx._.js +20 -20
  299. package/app/.next/server/chunks/lib_0pe3tiv._.js +20 -20
  300. package/app/.next/server/chunks/lib_15adnlz._.js +2172 -0
  301. package/app/.next/server/chunks/lib_1dehbst._.js +316 -0
  302. package/app/.next/server/chunks/lib_1z4vnh4._.js +316 -0
  303. package/app/.next/server/chunks/lib_1zc7-gl._.js +2172 -0
  304. package/app/.next/server/chunks/lib_agent-api_ts_0iv52-o._.js +3 -0
  305. package/app/.next/server/chunks/{[root-of-the-server]__0izjfmr._.js → lib_db_ts_1ttuckb._.js} +59 -57
  306. package/app/.next/server/chunks/lib_service-api-http_ts_0xzqhny._.js +5 -5
  307. package/app/.next/server/chunks/lib_slack-runtime_ts_0fgsejy._.js +63 -0
  308. package/app/.next/server/chunks/ssr/{[root-of-the-server]__03186rx._.js → [root-of-the-server]__1smmfpx._.js} +1 -1
  309. package/app/.next/server/chunks/ssr/_0_fa0na._.js +3 -0
  310. package/app/.next/server/chunks/ssr/_0a6r_bx._.js +3 -0
  311. package/app/.next/server/chunks/ssr/_14d-lxn._.js +3 -0
  312. package/app/.next/server/chunks/ssr/_1cvuhjt._.js +1 -1
  313. package/app/.next/server/chunks/ssr/_1is_iwu._.js +3 -0
  314. package/app/.next/server/chunks/ssr/_1n5mvo5._.js +1 -1
  315. package/app/.next/server/chunks/ssr/_1o94bnv._.js +1 -1
  316. package/app/.next/server/chunks/ssr/app_bots_[id]_config_page_tsx_1e0uue9._.js +1 -1
  317. package/app/.next/server/instrumentation.js +4 -0
  318. package/app/.next/server/middleware-build-manifest.js +3 -3
  319. package/app/.next/server/middleware.js +1 -1
  320. package/app/.next/server/pages/404.html +1 -1
  321. package/app/.next/server/pages/500.html +1 -1
  322. package/app/.next/server/server-reference-manifest.js +1 -1
  323. package/app/.next/server/server-reference-manifest.json +1 -1
  324. package/app/.next/static/chunks/1ouuczm-gmvxs.js +1 -0
  325. package/app/.next/static/chunks/1w72fds3-utrx.js +1 -0
  326. package/app/.next/static/chunks/2095-o17ji0fs.css +3 -0
  327. package/app/.next/static/chunks/2q-tgwkalrnms.js +1 -0
  328. package/app/.next/static/chunks/34bv9o9bjkwk0.js +3 -0
  329. package/app/.next/static/chunks/3rwwunh5sdjzg.js +1 -0
  330. package/app/.next/static/chunks/3whw2-l4a2sli.js +1 -0
  331. package/app/.next/static/chunks/3z3mn526_3fwd.js +1 -0
  332. package/app/BUILD_INFO.json +2 -2
  333. package/app/node_modules/@slack/logger/dist/index.js +94 -0
  334. package/app/node_modules/@slack/logger/package.json +43 -0
  335. package/app/node_modules/@slack/socket-mode/dist/package.json +67 -0
  336. package/app/node_modules/@slack/socket-mode/dist/src/SlackWebSocket.js +242 -0
  337. package/app/node_modules/@slack/socket-mode/dist/src/SocketModeClient.js +363 -0
  338. package/app/node_modules/@slack/socket-mode/dist/src/UnrecoverableSocketModeStartError.js +14 -0
  339. package/app/node_modules/@slack/socket-mode/dist/src/errors.js +68 -0
  340. package/app/node_modules/@slack/socket-mode/dist/src/index.js +13 -0
  341. package/app/node_modules/@slack/socket-mode/dist/src/logger.js +26 -0
  342. package/app/node_modules/@slack/socket-mode/package.json +67 -0
  343. package/app/node_modules/@slack/types/dist/block-kit/block-elements.js +4 -0
  344. package/app/node_modules/@slack/types/dist/block-kit/blocks.js +3 -0
  345. package/app/node_modules/@slack/types/dist/block-kit/composition-objects.js +4 -0
  346. package/app/node_modules/@slack/types/dist/block-kit/extensions.js +3 -0
  347. package/app/node_modules/@slack/types/dist/calls.js +6 -0
  348. package/app/node_modules/@slack/types/dist/chunk.js +3 -0
  349. package/app/node_modules/@slack/types/dist/dialog.js +3 -0
  350. package/app/node_modules/@slack/types/dist/events/app.js +3 -0
  351. package/app/node_modules/@slack/types/dist/events/assistant.js +3 -0
  352. package/app/node_modules/@slack/types/dist/events/call.js +3 -0
  353. package/app/node_modules/@slack/types/dist/events/channel.js +3 -0
  354. package/app/node_modules/@slack/types/dist/events/dnd.js +3 -0
  355. package/app/node_modules/@slack/types/dist/events/email.js +3 -0
  356. package/app/node_modules/@slack/types/dist/events/emoji.js +3 -0
  357. package/app/node_modules/@slack/types/dist/events/file.js +4 -0
  358. package/app/node_modules/@slack/types/dist/events/function.js +3 -0
  359. package/app/node_modules/@slack/types/dist/events/grid-migration.js +3 -0
  360. package/app/node_modules/@slack/types/dist/events/group.js +3 -0
  361. package/app/node_modules/@slack/types/dist/events/im.js +3 -0
  362. package/app/node_modules/@slack/types/dist/events/index.js +43 -0
  363. package/app/node_modules/@slack/types/dist/events/invite.js +3 -0
  364. package/app/node_modules/@slack/types/dist/events/link-shared.js +3 -0
  365. package/app/node_modules/@slack/types/dist/events/member.js +3 -0
  366. package/app/node_modules/@slack/types/dist/events/message-metadata.js +3 -0
  367. package/app/node_modules/@slack/types/dist/events/message.js +3 -0
  368. package/app/node_modules/@slack/types/dist/events/pin.js +3 -0
  369. package/app/node_modules/@slack/types/dist/events/reaction.js +3 -0
  370. package/app/node_modules/@slack/types/dist/events/shared-channel.js +3 -0
  371. package/app/node_modules/@slack/types/dist/events/star.js +3 -0
  372. package/app/node_modules/@slack/types/dist/events/steps-from-apps.js +3 -0
  373. package/app/node_modules/@slack/types/dist/events/subteam.js +3 -0
  374. package/app/node_modules/@slack/types/dist/events/team.js +3 -0
  375. package/app/node_modules/@slack/types/dist/events/token.js +3 -0
  376. package/app/node_modules/@slack/types/dist/events/user.js +3 -0
  377. package/app/node_modules/@slack/types/dist/index.js +28 -0
  378. package/app/node_modules/@slack/types/dist/message-attachments.js +3 -0
  379. package/app/node_modules/@slack/types/dist/message-metadata.js +27 -0
  380. package/app/node_modules/@slack/types/dist/views.js +3 -0
  381. package/app/node_modules/@slack/types/package.json +47 -0
  382. package/app/node_modules/@slack/web-api/dist/WebClient.js +818 -0
  383. package/app/node_modules/@slack/web-api/dist/chat-stream.js +178 -0
  384. package/app/node_modules/@slack/web-api/dist/errors.js +80 -0
  385. package/app/node_modules/@slack/web-api/dist/file-upload.js +360 -0
  386. package/app/node_modules/@slack/web-api/dist/helpers.js +14 -0
  387. package/app/node_modules/@slack/web-api/dist/index.js +39 -0
  388. package/app/node_modules/@slack/web-api/dist/instrument.js +87 -0
  389. package/app/node_modules/@slack/web-api/dist/logger.js +29 -0
  390. package/app/node_modules/@slack/web-api/dist/methods.js +1647 -0
  391. package/app/node_modules/@slack/web-api/dist/retry-policies.js +34 -0
  392. package/app/node_modules/@slack/web-api/dist/types/helpers.js +3 -0
  393. package/app/node_modules/@slack/web-api/dist/types/request/admin/analytics.js +3 -0
  394. package/app/node_modules/@slack/web-api/dist/types/request/admin/apps.js +3 -0
  395. package/app/node_modules/@slack/web-api/dist/types/request/admin/auth.js +3 -0
  396. package/app/node_modules/@slack/web-api/dist/types/request/admin/barriers.js +3 -0
  397. package/app/node_modules/@slack/web-api/dist/types/request/admin/conversations.js +3 -0
  398. package/app/node_modules/@slack/web-api/dist/types/request/admin/emoji.js +3 -0
  399. package/app/node_modules/@slack/web-api/dist/types/request/admin/functions.js +3 -0
  400. package/app/node_modules/@slack/web-api/dist/types/request/admin/inviteRequests.js +3 -0
  401. package/app/node_modules/@slack/web-api/dist/types/request/admin/roles.js +3 -0
  402. package/app/node_modules/@slack/web-api/dist/types/request/admin/teams.js +3 -0
  403. package/app/node_modules/@slack/web-api/dist/types/request/admin/usergroups.js +3 -0
  404. package/app/node_modules/@slack/web-api/dist/types/request/admin/users.js +3 -0
  405. package/app/node_modules/@slack/web-api/dist/types/request/admin/workflows.js +3 -0
  406. package/app/node_modules/@slack/web-api/dist/types/request/api.js +3 -0
  407. package/app/node_modules/@slack/web-api/dist/types/request/apps.js +3 -0
  408. package/app/node_modules/@slack/web-api/dist/types/request/assistant.js +3 -0
  409. package/app/node_modules/@slack/web-api/dist/types/request/auth.js +3 -0
  410. package/app/node_modules/@slack/web-api/dist/types/request/bookmarks.js +3 -0
  411. package/app/node_modules/@slack/web-api/dist/types/request/bots.js +3 -0
  412. package/app/node_modules/@slack/web-api/dist/types/request/calls.js +3 -0
  413. package/app/node_modules/@slack/web-api/dist/types/request/canvas.js +3 -0
  414. package/app/node_modules/@slack/web-api/dist/types/request/chat.js +3 -0
  415. package/app/node_modules/@slack/web-api/dist/types/request/common.js +4 -0
  416. package/app/node_modules/@slack/web-api/dist/types/request/conversations.js +3 -0
  417. package/app/node_modules/@slack/web-api/dist/types/request/dialog.js +3 -0
  418. package/app/node_modules/@slack/web-api/dist/types/request/dnd.js +3 -0
  419. package/app/node_modules/@slack/web-api/dist/types/request/emoji.js +3 -0
  420. package/app/node_modules/@slack/web-api/dist/types/request/entity.js +3 -0
  421. package/app/node_modules/@slack/web-api/dist/types/request/files.js +3 -0
  422. package/app/node_modules/@slack/web-api/dist/types/request/functions.js +3 -0
  423. package/app/node_modules/@slack/web-api/dist/types/request/index.js +3 -0
  424. package/app/node_modules/@slack/web-api/dist/types/request/manifest.js +3 -0
  425. package/app/node_modules/@slack/web-api/dist/types/request/migration.js +3 -0
  426. package/app/node_modules/@slack/web-api/dist/types/request/oauth.js +3 -0
  427. package/app/node_modules/@slack/web-api/dist/types/request/openid.js +3 -0
  428. package/app/node_modules/@slack/web-api/dist/types/request/pins.js +3 -0
  429. package/app/node_modules/@slack/web-api/dist/types/request/reactions.js +3 -0
  430. package/app/node_modules/@slack/web-api/dist/types/request/reminders.js +3 -0
  431. package/app/node_modules/@slack/web-api/dist/types/request/rtm.js +3 -0
  432. package/app/node_modules/@slack/web-api/dist/types/request/search.js +3 -0
  433. package/app/node_modules/@slack/web-api/dist/types/request/slackLists.js +3 -0
  434. package/app/node_modules/@slack/web-api/dist/types/request/stars.js +3 -0
  435. package/app/node_modules/@slack/web-api/dist/types/request/team.js +3 -0
  436. package/app/node_modules/@slack/web-api/dist/types/request/tooling.js +3 -0
  437. package/app/node_modules/@slack/web-api/dist/types/request/usergroups.js +3 -0
  438. package/app/node_modules/@slack/web-api/dist/types/request/users.js +3 -0
  439. package/app/node_modules/@slack/web-api/dist/types/request/views.js +3 -0
  440. package/app/node_modules/@slack/web-api/dist/types/request/workflows.js +3 -0
  441. package/app/node_modules/@slack/web-api/dist/types/response/AdminAnalyticsGetFileResponse.js +3 -0
  442. package/app/node_modules/@slack/web-api/dist/types/response/AdminAppsActivitiesListResponse.js +11 -0
  443. package/app/node_modules/@slack/web-api/dist/types/response/AdminAppsApproveResponse.js +11 -0
  444. package/app/node_modules/@slack/web-api/dist/types/response/AdminAppsApprovedListResponse.js +11 -0
  445. package/app/node_modules/@slack/web-api/dist/types/response/AdminAppsClearResolutionResponse.js +11 -0
  446. package/app/node_modules/@slack/web-api/dist/types/response/AdminAppsConfigLookupResponse.js +11 -0
  447. package/app/node_modules/@slack/web-api/dist/types/response/AdminAppsConfigSetResponse.js +11 -0
  448. package/app/node_modules/@slack/web-api/dist/types/response/AdminAppsRequestsCancelResponse.js +11 -0
  449. package/app/node_modules/@slack/web-api/dist/types/response/AdminAppsRequestsListResponse.js +11 -0
  450. package/app/node_modules/@slack/web-api/dist/types/response/AdminAppsRestrictResponse.js +11 -0
  451. package/app/node_modules/@slack/web-api/dist/types/response/AdminAppsRestrictedListResponse.js +11 -0
  452. package/app/node_modules/@slack/web-api/dist/types/response/AdminAppsUninstallResponse.js +11 -0
  453. package/app/node_modules/@slack/web-api/dist/types/response/AdminAuthPolicyAssignEntitiesResponse.js +11 -0
  454. package/app/node_modules/@slack/web-api/dist/types/response/AdminAuthPolicyGetEntitiesResponse.js +11 -0
  455. package/app/node_modules/@slack/web-api/dist/types/response/AdminAuthPolicyRemoveEntitiesResponse.js +11 -0
  456. package/app/node_modules/@slack/web-api/dist/types/response/AdminBarriersCreateResponse.js +11 -0
  457. package/app/node_modules/@slack/web-api/dist/types/response/AdminBarriersDeleteResponse.js +11 -0
  458. package/app/node_modules/@slack/web-api/dist/types/response/AdminBarriersListResponse.js +11 -0
  459. package/app/node_modules/@slack/web-api/dist/types/response/AdminBarriersUpdateResponse.js +11 -0
  460. package/app/node_modules/@slack/web-api/dist/types/response/AdminConversationsArchiveResponse.js +11 -0
  461. package/app/node_modules/@slack/web-api/dist/types/response/AdminConversationsBulkArchiveResponse.js +11 -0
  462. package/app/node_modules/@slack/web-api/dist/types/response/AdminConversationsBulkDeleteResponse.js +11 -0
  463. package/app/node_modules/@slack/web-api/dist/types/response/AdminConversationsBulkMoveResponse.js +11 -0
  464. package/app/node_modules/@slack/web-api/dist/types/response/AdminConversationsConvertToPrivateResponse.js +11 -0
  465. package/app/node_modules/@slack/web-api/dist/types/response/AdminConversationsConvertToPublicResponse.js +11 -0
  466. package/app/node_modules/@slack/web-api/dist/types/response/AdminConversationsCreateResponse.js +11 -0
  467. package/app/node_modules/@slack/web-api/dist/types/response/AdminConversationsDeleteResponse.js +11 -0
  468. package/app/node_modules/@slack/web-api/dist/types/response/AdminConversationsDisconnectSharedResponse.js +11 -0
  469. package/app/node_modules/@slack/web-api/dist/types/response/AdminConversationsEkmListOriginalConnectedChannelInfoResponse.js +11 -0
  470. package/app/node_modules/@slack/web-api/dist/types/response/AdminConversationsGetConversationPrefsResponse.js +11 -0
  471. package/app/node_modules/@slack/web-api/dist/types/response/AdminConversationsGetCustomRetentionResponse.js +11 -0
  472. package/app/node_modules/@slack/web-api/dist/types/response/AdminConversationsGetTeamsResponse.js +11 -0
  473. package/app/node_modules/@slack/web-api/dist/types/response/AdminConversationsInviteResponse.js +11 -0
  474. package/app/node_modules/@slack/web-api/dist/types/response/AdminConversationsLookupResponse.js +11 -0
  475. package/app/node_modules/@slack/web-api/dist/types/response/AdminConversationsRemoveCustomRetentionResponse.js +11 -0
  476. package/app/node_modules/@slack/web-api/dist/types/response/AdminConversationsRenameResponse.js +11 -0
  477. package/app/node_modules/@slack/web-api/dist/types/response/AdminConversationsRestrictAccessAddGroupResponse.js +11 -0
  478. package/app/node_modules/@slack/web-api/dist/types/response/AdminConversationsRestrictAccessListGroupsResponse.js +11 -0
  479. package/app/node_modules/@slack/web-api/dist/types/response/AdminConversationsRestrictAccessRemoveGroupResponse.js +11 -0
  480. package/app/node_modules/@slack/web-api/dist/types/response/AdminConversationsSearchResponse.js +11 -0
  481. package/app/node_modules/@slack/web-api/dist/types/response/AdminConversationsSetConversationPrefsResponse.js +11 -0
  482. package/app/node_modules/@slack/web-api/dist/types/response/AdminConversationsSetCustomRetentionResponse.js +11 -0
  483. package/app/node_modules/@slack/web-api/dist/types/response/AdminConversationsSetTeamsResponse.js +11 -0
  484. package/app/node_modules/@slack/web-api/dist/types/response/AdminConversationsUnarchiveResponse.js +11 -0
  485. package/app/node_modules/@slack/web-api/dist/types/response/AdminConversationsWhitelistAddResponse.js +11 -0
  486. package/app/node_modules/@slack/web-api/dist/types/response/AdminConversationsWhitelistListGroupsLinkedToChannelResponse.js +11 -0
  487. package/app/node_modules/@slack/web-api/dist/types/response/AdminConversationsWhitelistRemoveResponse.js +11 -0
  488. package/app/node_modules/@slack/web-api/dist/types/response/AdminEmojiAddAliasResponse.js +11 -0
  489. package/app/node_modules/@slack/web-api/dist/types/response/AdminEmojiAddResponse.js +11 -0
  490. package/app/node_modules/@slack/web-api/dist/types/response/AdminEmojiListResponse.js +11 -0
  491. package/app/node_modules/@slack/web-api/dist/types/response/AdminEmojiRemoveResponse.js +11 -0
  492. package/app/node_modules/@slack/web-api/dist/types/response/AdminEmojiRenameResponse.js +11 -0
  493. package/app/node_modules/@slack/web-api/dist/types/response/AdminFunctionsListResponse.js +11 -0
  494. package/app/node_modules/@slack/web-api/dist/types/response/AdminFunctionsPermissionsLookupResponse.js +11 -0
  495. package/app/node_modules/@slack/web-api/dist/types/response/AdminFunctionsPermissionsSetResponse.js +11 -0
  496. package/app/node_modules/@slack/web-api/dist/types/response/AdminInviteRequestsApproveResponse.js +11 -0
  497. package/app/node_modules/@slack/web-api/dist/types/response/AdminInviteRequestsApprovedListResponse.js +11 -0
  498. package/app/node_modules/@slack/web-api/dist/types/response/AdminInviteRequestsDeniedListResponse.js +11 -0
  499. package/app/node_modules/@slack/web-api/dist/types/response/AdminInviteRequestsDenyResponse.js +11 -0
  500. package/app/node_modules/@slack/web-api/dist/types/response/AdminInviteRequestsListResponse.js +11 -0
  501. package/app/node_modules/@slack/web-api/dist/types/response/AdminRolesAddAssignmentsResponse.js +11 -0
  502. package/app/node_modules/@slack/web-api/dist/types/response/AdminRolesListAssignmentsResponse.js +11 -0
  503. package/app/node_modules/@slack/web-api/dist/types/response/AdminRolesRemoveAssignmentsResponse.js +11 -0
  504. package/app/node_modules/@slack/web-api/dist/types/response/AdminTeamsAdminsListResponse.js +11 -0
  505. package/app/node_modules/@slack/web-api/dist/types/response/AdminTeamsCreateResponse.js +11 -0
  506. package/app/node_modules/@slack/web-api/dist/types/response/AdminTeamsListResponse.js +11 -0
  507. package/app/node_modules/@slack/web-api/dist/types/response/AdminTeamsOwnersListResponse.js +11 -0
  508. package/app/node_modules/@slack/web-api/dist/types/response/AdminTeamsSettingsInfoResponse.js +11 -0
  509. package/app/node_modules/@slack/web-api/dist/types/response/AdminTeamsSettingsSetDefaultChannelsResponse.js +11 -0
  510. package/app/node_modules/@slack/web-api/dist/types/response/AdminTeamsSettingsSetDescriptionResponse.js +11 -0
  511. package/app/node_modules/@slack/web-api/dist/types/response/AdminTeamsSettingsSetDiscoverabilityResponse.js +11 -0
  512. package/app/node_modules/@slack/web-api/dist/types/response/AdminTeamsSettingsSetIconResponse.js +11 -0
  513. package/app/node_modules/@slack/web-api/dist/types/response/AdminTeamsSettingsSetNameResponse.js +11 -0
  514. package/app/node_modules/@slack/web-api/dist/types/response/AdminUsergroupsAddChannelsResponse.js +11 -0
  515. package/app/node_modules/@slack/web-api/dist/types/response/AdminUsergroupsAddTeamsResponse.js +11 -0
  516. package/app/node_modules/@slack/web-api/dist/types/response/AdminUsergroupsListChannelsResponse.js +11 -0
  517. package/app/node_modules/@slack/web-api/dist/types/response/AdminUsergroupsRemoveChannelsResponse.js +11 -0
  518. package/app/node_modules/@slack/web-api/dist/types/response/AdminUsersAssignResponse.js +11 -0
  519. package/app/node_modules/@slack/web-api/dist/types/response/AdminUsersInviteResponse.js +11 -0
  520. package/app/node_modules/@slack/web-api/dist/types/response/AdminUsersListResponse.js +11 -0
  521. package/app/node_modules/@slack/web-api/dist/types/response/AdminUsersRemoveResponse.js +11 -0
  522. package/app/node_modules/@slack/web-api/dist/types/response/AdminUsersSessionClearSettingsResponse.js +11 -0
  523. package/app/node_modules/@slack/web-api/dist/types/response/AdminUsersSessionGetSettingsResponse.js +11 -0
  524. package/app/node_modules/@slack/web-api/dist/types/response/AdminUsersSessionInvalidateResponse.js +11 -0
  525. package/app/node_modules/@slack/web-api/dist/types/response/AdminUsersSessionListResponse.js +11 -0
  526. package/app/node_modules/@slack/web-api/dist/types/response/AdminUsersSessionResetBulkResponse.js +11 -0
  527. package/app/node_modules/@slack/web-api/dist/types/response/AdminUsersSessionResetResponse.js +11 -0
  528. package/app/node_modules/@slack/web-api/dist/types/response/AdminUsersSessionSetSettingsResponse.js +11 -0
  529. package/app/node_modules/@slack/web-api/dist/types/response/AdminUsersSetAdminResponse.js +11 -0
  530. package/app/node_modules/@slack/web-api/dist/types/response/AdminUsersSetExpirationResponse.js +11 -0
  531. package/app/node_modules/@slack/web-api/dist/types/response/AdminUsersSetOwnerResponse.js +11 -0
  532. package/app/node_modules/@slack/web-api/dist/types/response/AdminUsersSetRegularResponse.js +11 -0
  533. package/app/node_modules/@slack/web-api/dist/types/response/AdminUsersUnsupportedVersionsExportResponse.js +11 -0
  534. package/app/node_modules/@slack/web-api/dist/types/response/AdminWorkflowsCollaboratorsAddResponse.js +11 -0
  535. package/app/node_modules/@slack/web-api/dist/types/response/AdminWorkflowsCollaboratorsRemoveResponse.js +11 -0
  536. package/app/node_modules/@slack/web-api/dist/types/response/AdminWorkflowsPermissionsLookupResponse.js +11 -0
  537. package/app/node_modules/@slack/web-api/dist/types/response/AdminWorkflowsSearchResponse.js +11 -0
  538. package/app/node_modules/@slack/web-api/dist/types/response/AdminWorkflowsUnpublishResponse.js +11 -0
  539. package/app/node_modules/@slack/web-api/dist/types/response/ApiTestResponse.js +11 -0
  540. package/app/node_modules/@slack/web-api/dist/types/response/AppsConnectionsOpenResponse.js +11 -0
  541. package/app/node_modules/@slack/web-api/dist/types/response/AppsEventAuthorizationsListResponse.js +11 -0
  542. package/app/node_modules/@slack/web-api/dist/types/response/AppsManifestCreateResponse.js +11 -0
  543. package/app/node_modules/@slack/web-api/dist/types/response/AppsManifestDeleteResponse.js +11 -0
  544. package/app/node_modules/@slack/web-api/dist/types/response/AppsManifestExportResponse.js +11 -0
  545. package/app/node_modules/@slack/web-api/dist/types/response/AppsManifestUpdateResponse.js +11 -0
  546. package/app/node_modules/@slack/web-api/dist/types/response/AppsManifestValidateResponse.js +11 -0
  547. package/app/node_modules/@slack/web-api/dist/types/response/AppsPermissionsInfoResponse.js +11 -0
  548. package/app/node_modules/@slack/web-api/dist/types/response/AppsPermissionsRequestResponse.js +11 -0
  549. package/app/node_modules/@slack/web-api/dist/types/response/AppsPermissionsResourcesListResponse.js +11 -0
  550. package/app/node_modules/@slack/web-api/dist/types/response/AppsPermissionsScopesListResponse.js +11 -0
  551. package/app/node_modules/@slack/web-api/dist/types/response/AppsPermissionsUsersListResponse.js +11 -0
  552. package/app/node_modules/@slack/web-api/dist/types/response/AppsPermissionsUsersRequestResponse.js +11 -0
  553. package/app/node_modules/@slack/web-api/dist/types/response/AppsUninstallResponse.js +11 -0
  554. package/app/node_modules/@slack/web-api/dist/types/response/AppsUserConnectionUpdateResponse.js +11 -0
  555. package/app/node_modules/@slack/web-api/dist/types/response/AssistantThreadsSetStatusResponse.js +11 -0
  556. package/app/node_modules/@slack/web-api/dist/types/response/AssistantThreadsSetSuggestedPromptsResponse.js +11 -0
  557. package/app/node_modules/@slack/web-api/dist/types/response/AssistantThreadsSetTitleResponse.js +11 -0
  558. package/app/node_modules/@slack/web-api/dist/types/response/AuthRevokeResponse.js +11 -0
  559. package/app/node_modules/@slack/web-api/dist/types/response/AuthTeamsListResponse.js +11 -0
  560. package/app/node_modules/@slack/web-api/dist/types/response/AuthTestResponse.js +11 -0
  561. package/app/node_modules/@slack/web-api/dist/types/response/BookmarksAddResponse.js +11 -0
  562. package/app/node_modules/@slack/web-api/dist/types/response/BookmarksEditResponse.js +11 -0
  563. package/app/node_modules/@slack/web-api/dist/types/response/BookmarksListResponse.js +11 -0
  564. package/app/node_modules/@slack/web-api/dist/types/response/BookmarksRemoveResponse.js +11 -0
  565. package/app/node_modules/@slack/web-api/dist/types/response/BotsInfoResponse.js +11 -0
  566. package/app/node_modules/@slack/web-api/dist/types/response/CallsAddResponse.js +11 -0
  567. package/app/node_modules/@slack/web-api/dist/types/response/CallsEndResponse.js +11 -0
  568. package/app/node_modules/@slack/web-api/dist/types/response/CallsInfoResponse.js +11 -0
  569. package/app/node_modules/@slack/web-api/dist/types/response/CallsParticipantsAddResponse.js +11 -0
  570. package/app/node_modules/@slack/web-api/dist/types/response/CallsParticipantsRemoveResponse.js +11 -0
  571. package/app/node_modules/@slack/web-api/dist/types/response/CallsUpdateResponse.js +11 -0
  572. package/app/node_modules/@slack/web-api/dist/types/response/CanvasesAccessDeleteResponse.js +11 -0
  573. package/app/node_modules/@slack/web-api/dist/types/response/CanvasesAccessSetResponse.js +11 -0
  574. package/app/node_modules/@slack/web-api/dist/types/response/CanvasesCreateResponse.js +11 -0
  575. package/app/node_modules/@slack/web-api/dist/types/response/CanvasesDeleteResponse.js +11 -0
  576. package/app/node_modules/@slack/web-api/dist/types/response/CanvasesEditResponse.js +11 -0
  577. package/app/node_modules/@slack/web-api/dist/types/response/CanvasesSectionsLookupResponse.js +11 -0
  578. package/app/node_modules/@slack/web-api/dist/types/response/ChannelsArchiveResponse.js +11 -0
  579. package/app/node_modules/@slack/web-api/dist/types/response/ChannelsCreateResponse.js +11 -0
  580. package/app/node_modules/@slack/web-api/dist/types/response/ChannelsHistoryResponse.js +11 -0
  581. package/app/node_modules/@slack/web-api/dist/types/response/ChannelsInfoResponse.js +11 -0
  582. package/app/node_modules/@slack/web-api/dist/types/response/ChannelsInviteResponse.js +11 -0
  583. package/app/node_modules/@slack/web-api/dist/types/response/ChannelsJoinResponse.js +11 -0
  584. package/app/node_modules/@slack/web-api/dist/types/response/ChannelsKickResponse.js +11 -0
  585. package/app/node_modules/@slack/web-api/dist/types/response/ChannelsLeaveResponse.js +11 -0
  586. package/app/node_modules/@slack/web-api/dist/types/response/ChannelsListResponse.js +11 -0
  587. package/app/node_modules/@slack/web-api/dist/types/response/ChannelsMarkResponse.js +11 -0
  588. package/app/node_modules/@slack/web-api/dist/types/response/ChannelsRenameResponse.js +11 -0
  589. package/app/node_modules/@slack/web-api/dist/types/response/ChannelsRepliesResponse.js +11 -0
  590. package/app/node_modules/@slack/web-api/dist/types/response/ChannelsSetPurposeResponse.js +11 -0
  591. package/app/node_modules/@slack/web-api/dist/types/response/ChannelsSetTopicResponse.js +11 -0
  592. package/app/node_modules/@slack/web-api/dist/types/response/ChannelsUnarchiveResponse.js +11 -0
  593. package/app/node_modules/@slack/web-api/dist/types/response/ChatAppendStreamResponse.js +3 -0
  594. package/app/node_modules/@slack/web-api/dist/types/response/ChatDeleteResponse.js +11 -0
  595. package/app/node_modules/@slack/web-api/dist/types/response/ChatDeleteScheduledMessageResponse.js +11 -0
  596. package/app/node_modules/@slack/web-api/dist/types/response/ChatGetPermalinkResponse.js +11 -0
  597. package/app/node_modules/@slack/web-api/dist/types/response/ChatMeMessageResponse.js +11 -0
  598. package/app/node_modules/@slack/web-api/dist/types/response/ChatPostEphemeralResponse.js +11 -0
  599. package/app/node_modules/@slack/web-api/dist/types/response/ChatPostMessageResponse.js +67 -0
  600. package/app/node_modules/@slack/web-api/dist/types/response/ChatScheduleMessageResponse.js +48 -0
  601. package/app/node_modules/@slack/web-api/dist/types/response/ChatScheduledMessagesListResponse.js +11 -0
  602. package/app/node_modules/@slack/web-api/dist/types/response/ChatStartStreamResponse.js +3 -0
  603. package/app/node_modules/@slack/web-api/dist/types/response/ChatStopStreamResponse.js +3 -0
  604. package/app/node_modules/@slack/web-api/dist/types/response/ChatUnfurlResponse.js +11 -0
  605. package/app/node_modules/@slack/web-api/dist/types/response/ChatUpdateResponse.js +48 -0
  606. package/app/node_modules/@slack/web-api/dist/types/response/ConversationsAcceptSharedInviteResponse.js +11 -0
  607. package/app/node_modules/@slack/web-api/dist/types/response/ConversationsApproveSharedInviteResponse.js +11 -0
  608. package/app/node_modules/@slack/web-api/dist/types/response/ConversationsArchiveResponse.js +11 -0
  609. package/app/node_modules/@slack/web-api/dist/types/response/ConversationsCanvasesCreateResponse.js +11 -0
  610. package/app/node_modules/@slack/web-api/dist/types/response/ConversationsCloseResponse.js +11 -0
  611. package/app/node_modules/@slack/web-api/dist/types/response/ConversationsCreateResponse.js +11 -0
  612. package/app/node_modules/@slack/web-api/dist/types/response/ConversationsDeclineSharedInviteResponse.js +11 -0
  613. package/app/node_modules/@slack/web-api/dist/types/response/ConversationsExternalInvitePermissionsSetResponse.js +11 -0
  614. package/app/node_modules/@slack/web-api/dist/types/response/ConversationsHistoryResponse.js +67 -0
  615. package/app/node_modules/@slack/web-api/dist/types/response/ConversationsInfoResponse.js +11 -0
  616. package/app/node_modules/@slack/web-api/dist/types/response/ConversationsInviteResponse.js +11 -0
  617. package/app/node_modules/@slack/web-api/dist/types/response/ConversationsInviteSharedResponse.js +11 -0
  618. package/app/node_modules/@slack/web-api/dist/types/response/ConversationsJoinResponse.js +11 -0
  619. package/app/node_modules/@slack/web-api/dist/types/response/ConversationsKickResponse.js +11 -0
  620. package/app/node_modules/@slack/web-api/dist/types/response/ConversationsLeaveResponse.js +11 -0
  621. package/app/node_modules/@slack/web-api/dist/types/response/ConversationsListConnectInvitesResponse.js +11 -0
  622. package/app/node_modules/@slack/web-api/dist/types/response/ConversationsListResponse.js +11 -0
  623. package/app/node_modules/@slack/web-api/dist/types/response/ConversationsMarkResponse.js +11 -0
  624. package/app/node_modules/@slack/web-api/dist/types/response/ConversationsMembersResponse.js +11 -0
  625. package/app/node_modules/@slack/web-api/dist/types/response/ConversationsOpenResponse.js +48 -0
  626. package/app/node_modules/@slack/web-api/dist/types/response/ConversationsRenameResponse.js +11 -0
  627. package/app/node_modules/@slack/web-api/dist/types/response/ConversationsRepliesResponse.js +67 -0
  628. package/app/node_modules/@slack/web-api/dist/types/response/ConversationsRequestSharedInviteApproveResponse.js +11 -0
  629. package/app/node_modules/@slack/web-api/dist/types/response/ConversationsRequestSharedInviteDenyResponse.js +11 -0
  630. package/app/node_modules/@slack/web-api/dist/types/response/ConversationsRequestSharedInviteListResponse.js +11 -0
  631. package/app/node_modules/@slack/web-api/dist/types/response/ConversationsSetPurposeResponse.js +11 -0
  632. package/app/node_modules/@slack/web-api/dist/types/response/ConversationsSetTopicResponse.js +11 -0
  633. package/app/node_modules/@slack/web-api/dist/types/response/ConversationsUnarchiveResponse.js +11 -0
  634. package/app/node_modules/@slack/web-api/dist/types/response/DialogOpenResponse.js +11 -0
  635. package/app/node_modules/@slack/web-api/dist/types/response/DndEndDndResponse.js +11 -0
  636. package/app/node_modules/@slack/web-api/dist/types/response/DndEndSnoozeResponse.js +11 -0
  637. package/app/node_modules/@slack/web-api/dist/types/response/DndInfoResponse.js +11 -0
  638. package/app/node_modules/@slack/web-api/dist/types/response/DndSetSnoozeResponse.js +11 -0
  639. package/app/node_modules/@slack/web-api/dist/types/response/DndTeamInfoResponse.js +11 -0
  640. package/app/node_modules/@slack/web-api/dist/types/response/EmojiListResponse.js +11 -0
  641. package/app/node_modules/@slack/web-api/dist/types/response/EntityPresentDetailsResponse.js +11 -0
  642. package/app/node_modules/@slack/web-api/dist/types/response/FilesCommentsAddResponse.js +11 -0
  643. package/app/node_modules/@slack/web-api/dist/types/response/FilesCommentsDeleteResponse.js +11 -0
  644. package/app/node_modules/@slack/web-api/dist/types/response/FilesCommentsEditResponse.js +11 -0
  645. package/app/node_modules/@slack/web-api/dist/types/response/FilesCompleteUploadExternalResponse.js +11 -0
  646. package/app/node_modules/@slack/web-api/dist/types/response/FilesDeleteResponse.js +11 -0
  647. package/app/node_modules/@slack/web-api/dist/types/response/FilesGetUploadURLExternalResponse.js +11 -0
  648. package/app/node_modules/@slack/web-api/dist/types/response/FilesInfoResponse.js +37 -0
  649. package/app/node_modules/@slack/web-api/dist/types/response/FilesListResponse.js +37 -0
  650. package/app/node_modules/@slack/web-api/dist/types/response/FilesRemoteAddResponse.js +37 -0
  651. package/app/node_modules/@slack/web-api/dist/types/response/FilesRemoteInfoResponse.js +37 -0
  652. package/app/node_modules/@slack/web-api/dist/types/response/FilesRemoteListResponse.js +37 -0
  653. package/app/node_modules/@slack/web-api/dist/types/response/FilesRemoteRemoveResponse.js +11 -0
  654. package/app/node_modules/@slack/web-api/dist/types/response/FilesRemoteShareResponse.js +37 -0
  655. package/app/node_modules/@slack/web-api/dist/types/response/FilesRemoteUpdateResponse.js +37 -0
  656. package/app/node_modules/@slack/web-api/dist/types/response/FilesRevokePublicURLResponse.js +37 -0
  657. package/app/node_modules/@slack/web-api/dist/types/response/FilesSharedPublicURLResponse.js +37 -0
  658. package/app/node_modules/@slack/web-api/dist/types/response/FilesUploadResponse.js +37 -0
  659. package/app/node_modules/@slack/web-api/dist/types/response/FunctionsCompleteErrorResponse.js +11 -0
  660. package/app/node_modules/@slack/web-api/dist/types/response/FunctionsCompleteSuccessResponse.js +11 -0
  661. package/app/node_modules/@slack/web-api/dist/types/response/GroupsArchiveResponse.js +11 -0
  662. package/app/node_modules/@slack/web-api/dist/types/response/GroupsCloseResponse.js +11 -0
  663. package/app/node_modules/@slack/web-api/dist/types/response/GroupsCreateChildResponse.js +11 -0
  664. package/app/node_modules/@slack/web-api/dist/types/response/GroupsCreateResponse.js +11 -0
  665. package/app/node_modules/@slack/web-api/dist/types/response/GroupsHistoryResponse.js +11 -0
  666. package/app/node_modules/@slack/web-api/dist/types/response/GroupsInfoResponse.js +11 -0
  667. package/app/node_modules/@slack/web-api/dist/types/response/GroupsInviteResponse.js +11 -0
  668. package/app/node_modules/@slack/web-api/dist/types/response/GroupsKickResponse.js +11 -0
  669. package/app/node_modules/@slack/web-api/dist/types/response/GroupsLeaveResponse.js +11 -0
  670. package/app/node_modules/@slack/web-api/dist/types/response/GroupsListResponse.js +11 -0
  671. package/app/node_modules/@slack/web-api/dist/types/response/GroupsMarkResponse.js +11 -0
  672. package/app/node_modules/@slack/web-api/dist/types/response/GroupsOpenResponse.js +11 -0
  673. package/app/node_modules/@slack/web-api/dist/types/response/GroupsRenameResponse.js +11 -0
  674. package/app/node_modules/@slack/web-api/dist/types/response/GroupsRepliesResponse.js +11 -0
  675. package/app/node_modules/@slack/web-api/dist/types/response/GroupsSetPurposeResponse.js +11 -0
  676. package/app/node_modules/@slack/web-api/dist/types/response/GroupsSetTopicResponse.js +11 -0
  677. package/app/node_modules/@slack/web-api/dist/types/response/GroupsUnarchiveResponse.js +11 -0
  678. package/app/node_modules/@slack/web-api/dist/types/response/ImCloseResponse.js +11 -0
  679. package/app/node_modules/@slack/web-api/dist/types/response/ImHistoryResponse.js +11 -0
  680. package/app/node_modules/@slack/web-api/dist/types/response/ImListResponse.js +11 -0
  681. package/app/node_modules/@slack/web-api/dist/types/response/ImMarkResponse.js +11 -0
  682. package/app/node_modules/@slack/web-api/dist/types/response/ImOpenResponse.js +11 -0
  683. package/app/node_modules/@slack/web-api/dist/types/response/ImRepliesResponse.js +11 -0
  684. package/app/node_modules/@slack/web-api/dist/types/response/MigrationExchangeResponse.js +11 -0
  685. package/app/node_modules/@slack/web-api/dist/types/response/MpimCloseResponse.js +11 -0
  686. package/app/node_modules/@slack/web-api/dist/types/response/MpimHistoryResponse.js +11 -0
  687. package/app/node_modules/@slack/web-api/dist/types/response/MpimListResponse.js +11 -0
  688. package/app/node_modules/@slack/web-api/dist/types/response/MpimMarkResponse.js +11 -0
  689. package/app/node_modules/@slack/web-api/dist/types/response/MpimOpenResponse.js +11 -0
  690. package/app/node_modules/@slack/web-api/dist/types/response/MpimRepliesResponse.js +11 -0
  691. package/app/node_modules/@slack/web-api/dist/types/response/OauthAccessResponse.js +11 -0
  692. package/app/node_modules/@slack/web-api/dist/types/response/OauthTokenResponse.js +11 -0
  693. package/app/node_modules/@slack/web-api/dist/types/response/OauthV2AccessResponse.js +11 -0
  694. package/app/node_modules/@slack/web-api/dist/types/response/OauthV2ExchangeResponse.js +11 -0
  695. package/app/node_modules/@slack/web-api/dist/types/response/OpenIDConnectTokenResponse.js +11 -0
  696. package/app/node_modules/@slack/web-api/dist/types/response/OpenIDConnectUserInfoResponse.js +11 -0
  697. package/app/node_modules/@slack/web-api/dist/types/response/PinsAddResponse.js +11 -0
  698. package/app/node_modules/@slack/web-api/dist/types/response/PinsListResponse.js +37 -0
  699. package/app/node_modules/@slack/web-api/dist/types/response/PinsRemoveResponse.js +11 -0
  700. package/app/node_modules/@slack/web-api/dist/types/response/ReactionsAddResponse.js +11 -0
  701. package/app/node_modules/@slack/web-api/dist/types/response/ReactionsGetResponse.js +48 -0
  702. package/app/node_modules/@slack/web-api/dist/types/response/ReactionsListResponse.js +67 -0
  703. package/app/node_modules/@slack/web-api/dist/types/response/ReactionsRemoveResponse.js +11 -0
  704. package/app/node_modules/@slack/web-api/dist/types/response/RemindersAddResponse.js +11 -0
  705. package/app/node_modules/@slack/web-api/dist/types/response/RemindersCompleteResponse.js +11 -0
  706. package/app/node_modules/@slack/web-api/dist/types/response/RemindersDeleteResponse.js +11 -0
  707. package/app/node_modules/@slack/web-api/dist/types/response/RemindersInfoResponse.js +11 -0
  708. package/app/node_modules/@slack/web-api/dist/types/response/RemindersListResponse.js +11 -0
  709. package/app/node_modules/@slack/web-api/dist/types/response/RtmConnectResponse.js +11 -0
  710. package/app/node_modules/@slack/web-api/dist/types/response/RtmStartResponse.js +77 -0
  711. package/app/node_modules/@slack/web-api/dist/types/response/SearchAllResponse.js +82 -0
  712. package/app/node_modules/@slack/web-api/dist/types/response/SearchFilesResponse.js +63 -0
  713. package/app/node_modules/@slack/web-api/dist/types/response/SearchMessagesResponse.js +67 -0
  714. package/app/node_modules/@slack/web-api/dist/types/response/SlackListsAccessDeleteResponse.js +3 -0
  715. package/app/node_modules/@slack/web-api/dist/types/response/SlackListsAccessSetResponse.js +3 -0
  716. package/app/node_modules/@slack/web-api/dist/types/response/SlackListsCreateResponse.js +3 -0
  717. package/app/node_modules/@slack/web-api/dist/types/response/SlackListsDownloadGetResponse.js +3 -0
  718. package/app/node_modules/@slack/web-api/dist/types/response/SlackListsDownloadStartResponse.js +3 -0
  719. package/app/node_modules/@slack/web-api/dist/types/response/SlackListsItemsCreateResponse.js +3 -0
  720. package/app/node_modules/@slack/web-api/dist/types/response/SlackListsItemsDeleteMultipleResponse.js +3 -0
  721. package/app/node_modules/@slack/web-api/dist/types/response/SlackListsItemsDeleteResponse.js +3 -0
  722. package/app/node_modules/@slack/web-api/dist/types/response/SlackListsItemsInfoResponse.js +3 -0
  723. package/app/node_modules/@slack/web-api/dist/types/response/SlackListsItemsListResponse.js +3 -0
  724. package/app/node_modules/@slack/web-api/dist/types/response/SlackListsItemsUpdateResponse.js +3 -0
  725. package/app/node_modules/@slack/web-api/dist/types/response/SlackListsUpdateResponse.js +3 -0
  726. package/app/node_modules/@slack/web-api/dist/types/response/StarsAddResponse.js +11 -0
  727. package/app/node_modules/@slack/web-api/dist/types/response/StarsListResponse.js +11 -0
  728. package/app/node_modules/@slack/web-api/dist/types/response/StarsRemoveResponse.js +11 -0
  729. package/app/node_modules/@slack/web-api/dist/types/response/TeamAccessLogsResponse.js +11 -0
  730. package/app/node_modules/@slack/web-api/dist/types/response/TeamBillableInfoResponse.js +11 -0
  731. package/app/node_modules/@slack/web-api/dist/types/response/TeamBillingInfoResponse.js +11 -0
  732. package/app/node_modules/@slack/web-api/dist/types/response/TeamExternalTeamsDisconnectResponse.js +11 -0
  733. package/app/node_modules/@slack/web-api/dist/types/response/TeamExternalTeamsListResponse.js +11 -0
  734. package/app/node_modules/@slack/web-api/dist/types/response/TeamInfoResponse.js +11 -0
  735. package/app/node_modules/@slack/web-api/dist/types/response/TeamIntegrationLogsResponse.js +11 -0
  736. package/app/node_modules/@slack/web-api/dist/types/response/TeamPreferencesListResponse.js +11 -0
  737. package/app/node_modules/@slack/web-api/dist/types/response/TeamProfileGetResponse.js +11 -0
  738. package/app/node_modules/@slack/web-api/dist/types/response/ToolingTokensRotateResponse.js +11 -0
  739. package/app/node_modules/@slack/web-api/dist/types/response/UsergroupsCreateResponse.js +11 -0
  740. package/app/node_modules/@slack/web-api/dist/types/response/UsergroupsDisableResponse.js +11 -0
  741. package/app/node_modules/@slack/web-api/dist/types/response/UsergroupsEnableResponse.js +11 -0
  742. package/app/node_modules/@slack/web-api/dist/types/response/UsergroupsListResponse.js +11 -0
  743. package/app/node_modules/@slack/web-api/dist/types/response/UsergroupsUpdateResponse.js +11 -0
  744. package/app/node_modules/@slack/web-api/dist/types/response/UsergroupsUsersListResponse.js +11 -0
  745. package/app/node_modules/@slack/web-api/dist/types/response/UsergroupsUsersUpdateResponse.js +11 -0
  746. package/app/node_modules/@slack/web-api/dist/types/response/UsersConversationsResponse.js +11 -0
  747. package/app/node_modules/@slack/web-api/dist/types/response/UsersDeletePhotoResponse.js +11 -0
  748. package/app/node_modules/@slack/web-api/dist/types/response/UsersDiscoverableContactsLookupResponse.js +11 -0
  749. package/app/node_modules/@slack/web-api/dist/types/response/UsersGetPresenceResponse.js +11 -0
  750. package/app/node_modules/@slack/web-api/dist/types/response/UsersIdentityResponse.js +11 -0
  751. package/app/node_modules/@slack/web-api/dist/types/response/UsersInfoResponse.js +11 -0
  752. package/app/node_modules/@slack/web-api/dist/types/response/UsersListResponse.js +11 -0
  753. package/app/node_modules/@slack/web-api/dist/types/response/UsersLookupByEmailResponse.js +11 -0
  754. package/app/node_modules/@slack/web-api/dist/types/response/UsersProfileGetResponse.js +11 -0
  755. package/app/node_modules/@slack/web-api/dist/types/response/UsersProfileSetResponse.js +11 -0
  756. package/app/node_modules/@slack/web-api/dist/types/response/UsersSetActiveResponse.js +11 -0
  757. package/app/node_modules/@slack/web-api/dist/types/response/UsersSetPhotoResponse.js +11 -0
  758. package/app/node_modules/@slack/web-api/dist/types/response/UsersSetPresenceResponse.js +11 -0
  759. package/app/node_modules/@slack/web-api/dist/types/response/ViewsOpenResponse.js +31 -0
  760. package/app/node_modules/@slack/web-api/dist/types/response/ViewsPublishResponse.js +31 -0
  761. package/app/node_modules/@slack/web-api/dist/types/response/ViewsPushResponse.js +31 -0
  762. package/app/node_modules/@slack/web-api/dist/types/response/ViewsUpdateResponse.js +31 -0
  763. package/app/node_modules/@slack/web-api/dist/types/response/WorkflowsFeaturedAddResponse.js +3 -0
  764. package/app/node_modules/@slack/web-api/dist/types/response/WorkflowsFeaturedListResponse.js +3 -0
  765. package/app/node_modules/@slack/web-api/dist/types/response/WorkflowsFeaturedRemoveResponse.js +3 -0
  766. package/app/node_modules/@slack/web-api/dist/types/response/WorkflowsFeaturedSetResponse.js +3 -0
  767. package/app/node_modules/@slack/web-api/dist/types/response/WorkflowsStepCompletedResponse.js +11 -0
  768. package/app/node_modules/@slack/web-api/dist/types/response/WorkflowsStepFailedResponse.js +11 -0
  769. package/app/node_modules/@slack/web-api/dist/types/response/WorkflowsUpdateStepResponse.js +11 -0
  770. package/app/node_modules/@slack/web-api/dist/types/response/index.js +3 -0
  771. package/app/node_modules/@slack/web-api/package.json +75 -0
  772. package/app/node_modules/agent-base/dist/src/index.js +203 -0
  773. package/app/node_modules/agent-base/dist/src/promisify.js +18 -0
  774. package/app/node_modules/agent-base/package.json +64 -0
  775. package/app/node_modules/asynckit/index.js +6 -0
  776. package/app/node_modules/asynckit/lib/abort.js +29 -0
  777. package/app/node_modules/asynckit/lib/async.js +34 -0
  778. package/app/node_modules/asynckit/lib/defer.js +26 -0
  779. package/app/node_modules/asynckit/lib/iterate.js +75 -0
  780. package/app/node_modules/asynckit/lib/state.js +37 -0
  781. package/app/node_modules/asynckit/lib/terminator.js +29 -0
  782. package/app/node_modules/asynckit/package.json +63 -0
  783. package/app/node_modules/asynckit/parallel.js +43 -0
  784. package/app/node_modules/asynckit/serial.js +17 -0
  785. package/app/node_modules/asynckit/serialOrdered.js +75 -0
  786. package/app/node_modules/axios/dist/node/axios.cjs +6808 -0
  787. package/app/node_modules/axios/package.json +203 -0
  788. package/app/node_modules/call-bind-apply-helpers/actualApply.js +10 -0
  789. package/app/node_modules/call-bind-apply-helpers/functionApply.js +4 -0
  790. package/app/node_modules/call-bind-apply-helpers/functionCall.js +4 -0
  791. package/app/node_modules/call-bind-apply-helpers/index.js +15 -0
  792. package/app/node_modules/call-bind-apply-helpers/package.json +85 -0
  793. package/app/node_modules/call-bind-apply-helpers/reflectApply.js +4 -0
  794. package/app/node_modules/combined-stream/lib/combined_stream.js +208 -0
  795. package/app/node_modules/combined-stream/package.json +25 -0
  796. package/app/node_modules/debug/package.json +64 -0
  797. package/app/node_modules/debug/src/browser.js +272 -0
  798. package/app/node_modules/debug/src/common.js +292 -0
  799. package/app/node_modules/debug/src/index.js +10 -0
  800. package/app/node_modules/debug/src/node.js +263 -0
  801. package/app/node_modules/delayed-stream/lib/delayed_stream.js +107 -0
  802. package/app/node_modules/delayed-stream/package.json +27 -0
  803. package/app/node_modules/dunder-proto/get.js +30 -0
  804. package/app/node_modules/dunder-proto/package.json +76 -0
  805. package/app/node_modules/es-define-property/index.js +14 -0
  806. package/app/node_modules/es-define-property/package.json +81 -0
  807. package/app/node_modules/es-errors/eval.js +4 -0
  808. package/app/node_modules/es-errors/index.js +4 -0
  809. package/app/node_modules/es-errors/package.json +80 -0
  810. package/app/node_modules/es-errors/range.js +4 -0
  811. package/app/node_modules/es-errors/ref.js +4 -0
  812. package/app/node_modules/es-errors/syntax.js +4 -0
  813. package/app/node_modules/es-errors/type.js +4 -0
  814. package/app/node_modules/es-errors/uri.js +4 -0
  815. package/app/node_modules/es-object-atoms/index.js +4 -0
  816. package/app/node_modules/es-object-atoms/package.json +79 -0
  817. package/app/node_modules/es-set-tostringtag/index.js +35 -0
  818. package/app/node_modules/es-set-tostringtag/package.json +78 -0
  819. package/app/node_modules/eventemitter3/index.js +336 -0
  820. package/app/node_modules/eventemitter3/package.json +62 -0
  821. package/app/node_modules/follow-redirects/debug.js +15 -0
  822. package/app/node_modules/follow-redirects/index.js +709 -0
  823. package/app/node_modules/follow-redirects/package.json +58 -0
  824. package/app/node_modules/form-data/lib/browser.js +4 -0
  825. package/app/node_modules/form-data/lib/form_data.js +506 -0
  826. package/app/node_modules/form-data/lib/populate.js +10 -0
  827. package/app/node_modules/form-data/package.json +82 -0
  828. package/app/node_modules/function-bind/implementation.js +84 -0
  829. package/app/node_modules/function-bind/index.js +5 -0
  830. package/app/node_modules/function-bind/package.json +87 -0
  831. package/app/node_modules/get-intrinsic/index.js +378 -0
  832. package/app/node_modules/get-intrinsic/package.json +97 -0
  833. package/app/node_modules/get-proto/Object.getPrototypeOf.js +6 -0
  834. package/app/node_modules/get-proto/Reflect.getPrototypeOf.js +4 -0
  835. package/app/node_modules/get-proto/index.js +27 -0
  836. package/app/node_modules/get-proto/package.json +81 -0
  837. package/app/node_modules/gopd/gOPD.js +4 -0
  838. package/app/node_modules/gopd/index.js +15 -0
  839. package/app/node_modules/gopd/package.json +77 -0
  840. package/app/node_modules/has-flag/index.js +8 -0
  841. package/app/node_modules/has-flag/package.json +46 -0
  842. package/app/node_modules/has-symbols/index.js +14 -0
  843. package/app/node_modules/has-symbols/package.json +111 -0
  844. package/app/node_modules/has-symbols/shams.js +45 -0
  845. package/app/node_modules/has-tostringtag/package.json +108 -0
  846. package/app/node_modules/has-tostringtag/shams.js +8 -0
  847. package/app/node_modules/hasown/index.js +8 -0
  848. package/app/node_modules/hasown/package.json +91 -0
  849. package/app/node_modules/https-proxy-agent/dist/agent.js +177 -0
  850. package/app/node_modules/https-proxy-agent/dist/index.js +14 -0
  851. package/app/node_modules/https-proxy-agent/dist/parse-proxy-response.js +66 -0
  852. package/app/node_modules/https-proxy-agent/package.json +56 -0
  853. package/app/node_modules/is-electron/index.js +21 -0
  854. package/app/node_modules/is-electron/package.json +34 -0
  855. package/app/node_modules/is-stream/index.js +28 -0
  856. package/app/node_modules/is-stream/package.json +42 -0
  857. package/app/node_modules/math-intrinsics/abs.js +4 -0
  858. package/app/node_modules/math-intrinsics/floor.js +4 -0
  859. package/app/node_modules/math-intrinsics/isNaN.js +6 -0
  860. package/app/node_modules/math-intrinsics/max.js +4 -0
  861. package/app/node_modules/math-intrinsics/min.js +4 -0
  862. package/app/node_modules/math-intrinsics/package.json +86 -0
  863. package/app/node_modules/math-intrinsics/pow.js +4 -0
  864. package/app/node_modules/math-intrinsics/round.js +4 -0
  865. package/app/node_modules/math-intrinsics/sign.js +11 -0
  866. package/app/node_modules/mime-db/db.json +8519 -0
  867. package/app/node_modules/mime-db/index.js +12 -0
  868. package/app/node_modules/mime-db/package.json +60 -0
  869. package/app/node_modules/mime-types/index.js +188 -0
  870. package/app/node_modules/mime-types/package.json +44 -0
  871. package/app/node_modules/ms/index.js +162 -0
  872. package/app/node_modules/ms/package.json +38 -0
  873. package/app/node_modules/p-finally/index.js +15 -0
  874. package/app/node_modules/p-finally/package.json +42 -0
  875. package/app/node_modules/p-queue/dist/index.js +279 -0
  876. package/app/node_modules/p-queue/dist/lower-bound.js +21 -0
  877. package/app/node_modules/p-queue/dist/priority-queue.js +32 -0
  878. package/app/node_modules/p-queue/node_modules/eventemitter3/index.js +336 -0
  879. package/app/node_modules/p-queue/node_modules/eventemitter3/package.json +56 -0
  880. package/app/node_modules/p-queue/package.json +92 -0
  881. package/app/node_modules/p-retry/index.js +85 -0
  882. package/app/node_modules/p-retry/package.json +51 -0
  883. package/app/node_modules/p-timeout/index.js +57 -0
  884. package/app/node_modules/p-timeout/package.json +45 -0
  885. package/app/node_modules/retry/index.js +1 -0
  886. package/app/node_modules/retry/lib/retry.js +100 -0
  887. package/app/node_modules/retry/lib/retry_operation.js +162 -0
  888. package/app/node_modules/retry/package.json +36 -0
  889. package/app/node_modules/supports-color/index.js +135 -0
  890. package/app/node_modules/supports-color/package.json +53 -0
  891. package/app/node_modules/ws/index.js +22 -0
  892. package/app/node_modules/ws/lib/buffer-util.js +131 -0
  893. package/app/node_modules/ws/lib/constants.js +19 -0
  894. package/app/node_modules/ws/lib/event-target.js +292 -0
  895. package/app/node_modules/ws/lib/extension.js +203 -0
  896. package/app/node_modules/ws/lib/limiter.js +55 -0
  897. package/app/node_modules/ws/lib/permessage-deflate.js +530 -0
  898. package/app/node_modules/ws/lib/receiver.js +743 -0
  899. package/app/node_modules/ws/lib/sender.js +607 -0
  900. package/app/node_modules/ws/lib/stream.js +161 -0
  901. package/app/node_modules/ws/lib/subprotocol.js +62 -0
  902. package/app/node_modules/ws/lib/validation.js +152 -0
  903. package/app/node_modules/ws/lib/websocket-server.js +562 -0
  904. package/app/node_modules/ws/lib/websocket.js +1421 -0
  905. package/app/node_modules/ws/package.json +74 -0
  906. package/app/package.json +1 -1
  907. package/app/server.js +1 -1
  908. package/dist/cli.d.ts +1 -1
  909. package/dist/cli.js +7 -4
  910. package/dist/product.d.ts +8 -1
  911. package/dist/product.js +79 -23
  912. package/dist/setup.js +9 -9
  913. package/package.json +2 -3
  914. package/schemas/botmancers.mcp.v2.tools.json +770 -5
  915. package/skills/botmancers-collaboration/SKILL.md +5 -1
  916. package/skills/botmancers-collaboration/references/workflows.md +21 -0
  917. package/app/.next/server/app/api/agent-deck/decks/route/app-paths-manifest.json +0 -3
  918. package/app/.next/server/app/api/agent-deck/decks/route.js +0 -9
  919. package/app/.next/server/app/api/agent-deck/decks/route.js.nft.json +0 -1
  920. package/app/.next/server/app/api/agent-deck/decks/route_client-reference-manifest.js +0 -3
  921. package/app/.next/server/app/api/agent-deck/settings/route/app-paths-manifest.json +0 -3
  922. package/app/.next/server/app/api/agent-deck/settings/route.js +0 -9
  923. package/app/.next/server/app/api/agent-deck/settings/route.js.nft.json +0 -1
  924. package/app/.next/server/app/api/agent-deck/settings/route_client-reference-manifest.js +0 -3
  925. package/app/.next/server/chunks/[root-of-the-server]__06qkt0f._.js +0 -3
  926. package/app/.next/server/chunks/[root-of-the-server]__08qhrch._.js +0 -3
  927. package/app/.next/server/chunks/[root-of-the-server]__097ptn_._.js +0 -3
  928. package/app/.next/server/chunks/[root-of-the-server]__09m9-pe._.js +0 -3
  929. package/app/.next/server/chunks/[root-of-the-server]__0b7w1z3._.js +0 -3
  930. package/app/.next/server/chunks/[root-of-the-server]__0f5yqjs._.js +0 -3
  931. package/app/.next/server/chunks/[root-of-the-server]__0g4um3-._.js +0 -44
  932. package/app/.next/server/chunks/[root-of-the-server]__0hro5ey._.js +0 -3
  933. package/app/.next/server/chunks/[root-of-the-server]__0hwpgxq._.js +0 -3
  934. package/app/.next/server/chunks/[root-of-the-server]__0uq7sci._.js +0 -3
  935. package/app/.next/server/chunks/[root-of-the-server]__13cd2fb._.js +0 -44
  936. package/app/.next/server/chunks/[root-of-the-server]__1879cge._.js +0 -3
  937. package/app/.next/server/chunks/[root-of-the-server]__1a2dh11._.js +0 -3
  938. package/app/.next/server/chunks/[root-of-the-server]__1bhzfu_._.js +0 -7
  939. package/app/.next/server/chunks/[root-of-the-server]__1co3sok._.js +0 -44
  940. package/app/.next/server/chunks/[root-of-the-server]__1eh30sp._.js +0 -3
  941. package/app/.next/server/chunks/[root-of-the-server]__1fmsid0._.js +0 -44
  942. package/app/.next/server/chunks/[root-of-the-server]__1kvvs4u._.js +0 -3
  943. package/app/.next/server/chunks/[root-of-the-server]__1qbgs3m._.js +0 -3
  944. package/app/.next/server/chunks/[root-of-the-server]__1s6h1sj._.js +0 -3
  945. package/app/.next/server/chunks/[root-of-the-server]__1slu7d7._.js +0 -7
  946. package/app/.next/server/chunks/[root-of-the-server]__1tuqc5v._.js +0 -3
  947. package/app/.next/server/chunks/[root-of-the-server]__1v609eq._.js +0 -44
  948. package/app/.next/server/chunks/[root-of-the-server]__1zdv-vb._.js +0 -3
  949. package/app/.next/server/chunks/[root-of-the-server]__1zjs2tr._.js +0 -3
  950. package/app/.next/server/chunks/_023se5j._.js +0 -44
  951. package/app/.next/server/chunks/_02pb_qv._.js +0 -44
  952. package/app/.next/server/chunks/_05ro-21._.js +0 -44
  953. package/app/.next/server/chunks/_07on0dc._.js +0 -44
  954. package/app/.next/server/chunks/_08208nz._.js +0 -44
  955. package/app/.next/server/chunks/_0fe5qz5._.js +0 -44
  956. package/app/.next/server/chunks/_0qoji5a._.js +0 -44
  957. package/app/.next/server/chunks/_0uv2pi5._.js +0 -44
  958. package/app/.next/server/chunks/_0wdl90-._.js +0 -44
  959. package/app/.next/server/chunks/_11ijk9k._.js +0 -44
  960. package/app/.next/server/chunks/_198sn69._.js +0 -44
  961. package/app/.next/server/chunks/_1ba_5hd._.js +0 -44
  962. package/app/.next/server/chunks/_1m89jq5._.js +0 -44
  963. package/app/.next/server/chunks/_1n39wr_._.js +0 -44
  964. package/app/.next/server/chunks/_1ryxqo1._.js +0 -44
  965. package/app/.next/server/chunks/_1vemgly._.js +0 -44
  966. package/app/.next/server/chunks/_next-internal_server_app_api_agent-deck_decks_route_actions_0yguyfv.js +0 -3
  967. package/app/.next/server/chunks/_next-internal_server_app_api_agent-deck_settings_route_actions_0z_nbkb.js +0 -3
  968. package/app/.next/server/chunks/lib_0lqoyb4._.js +0 -217
  969. package/app/.next/server/chunks/lib_0riiofz._.js +0 -44
  970. package/app/.next/server/chunks/lib_16j2293._.js +0 -217
  971. package/app/.next/server/chunks/lib_1nb_61e._.js +0 -217
  972. package/app/.next/server/chunks/lib_session-pins_ts_0lmxnwj._.js +0 -20
  973. package/app/.next/server/chunks/ssr/app_components_AgentDeckRuntime_tsx_024janf._.js +0 -3
  974. package/app/.next/server/chunks/ssr/app_components_ExchangeCard_tsx_1shfcgn._.js +0 -3
  975. package/app/.next/server/chunks/ssr/app_settings_page_tsx_1t-rdz-._.js +0 -3
  976. package/app/.next/server/chunks/ssr/node_modules_@swc_helpers_cjs__interop_require_default_cjs_1ztp13a._.js +0 -3
  977. package/app/.next/server/chunks/ssr/node_modules_next_dist_client_components_server-async-storage_0t1dato.js +0 -3
  978. package/app/.next/static/chunks/0bhd8eso48g27.js +0 -1
  979. package/app/.next/static/chunks/1ku9himlsx-hn.js +0 -1
  980. package/app/.next/static/chunks/21aqekm5z0j47.js +0 -1
  981. package/app/.next/static/chunks/2a8bomryx66oj.css +0 -3
  982. package/app/.next/static/chunks/3230ywnpii0s6.js +0 -3
  983. package/app/.next/static/chunks/35l2c95bd-jud.js +0 -1
  984. package/app/.next/static/chunks/3cijpn6vx3yzv.js +0 -1
  985. package/app/.next/static/chunks/3ue9194j59kem.js +0 -1
  986. package/app/.next/static/chunks/44ese2s4gzze_.js +0 -1
  987. /package/app/.next/server/app/api/{agent-deck/decks → bots/[id]/sessions/[ref]/shares}/route/build-manifest.json +0 -0
  988. /package/app/.next/server/app/api/{agent-deck/decks → bots/[id]/sessions/[ref]/shares}/route/server-reference-manifest.json +0 -0
  989. /package/app/.next/server/app/api/{agent-deck/settings → bots/[id]/share-policy}/route/build-manifest.json +0 -0
  990. /package/app/.next/server/app/api/{agent-deck/settings → bots/[id]/share-policy}/route/server-reference-manifest.json +0 -0
  991. /package/app/.next/static/{gh3shm8hnVqXLr75rmvsL → A9sQnaf9i6YzjHNoPgRfU}/_buildManifest.js +0 -0
  992. /package/app/.next/static/{gh3shm8hnVqXLr75rmvsL → A9sQnaf9i6YzjHNoPgRfU}/_clientMiddlewareManifest.js +0 -0
  993. /package/app/.next/static/{gh3shm8hnVqXLr75rmvsL → A9sQnaf9i6YzjHNoPgRfU}/_ssgManifest.js +0 -0
@@ -1,4 +1,4 @@
1
- module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",()=>require("better-sqlite3-90e2652d1716b047"))},62294,18966,64974,11626,40596,28420,35613,30098,e=>{"use strict";let t;var n=e.i(85148),i=e.i(22734),r=e.i(14747),s=e.i(54799),a=e.i(62349);let o=["direct","agent_deck"],_=["read_only","workspace_write"],d=["workspaces","sessions","all_provider_sessions"],E="This computer",u={mode:"read_only",allow_new_sessions:!0,allow_resume_with_edits:!1},c="Runtime connection is required. Pick the runtime this Agent uses.",l="Runtime connection not found.",T="Launch profile is required. Choose direct or agent_deck.",p="Invalid launch profile. Expected direct or agent_deck.",N="A direct launch profile does not use Agent Deck. Remove deck_id or choose agent_deck.",R="working_directory is an Agent Deck setting. Use default_workspace for a direct launch profile.",m="Session scope is required. Select workspaces, select sessions, or explicitly choose all_provider_sessions.",L="A session scope selects workspaces or sessions, not both.",g="Workspaces must be absolute paths (or start with ~/).",O="Launch policy is required. Choose read_only or workspace_write.",I=`Provider is required. Expected one of ${a.AGENTS.join("|")}.`;function A(e){return"string"==typeof e&&o.includes(e)}function S(e){return"string"==typeof e&&d.includes(e)}function k(e){return"string"==typeof e&&_.includes(e)}function f(e){return null==e?null:String(e).trim()||null}function v(e){return`rc-local-${e}`}function h(e){return`${a.AGENT_LABELS[e]} on ${E.toLowerCase()}`}function w(e){return e.startsWith("/")||"~"===e||e.startsWith("~/")}function C(e){return e.length>1?e.replace(/\/+$/,""):e}function q(e,t){let n=C(e),i=C(t);return n===i||i.startsWith("/"===n?"/":`${n}/`)}function y(e){if(null==e)return[];if(!Array.isArray(e))return null;let t=[];for(let n of e){if("string"!=typeof n)return null;let e=n.trim();e&&!t.includes(e)&&t.push(e)}return t}function b(e){let t=e.session_scope_kind;if(!S(t))return null;let n=[];if(e.session_scope_items)try{let t=y(JSON.parse(e.session_scope_items));if(null===t)return null;n=t}catch{return null}return"all_provider_sessions"===t?0===n.length?{kind:t,workspaces:[],sessions:[]}:null:0===n.length?null:"workspaces"===t?{kind:t,workspaces:n,sessions:[]}:{kind:t,workspaces:[],sessions:n}}function D(e){return!0===e||1===e||"1"===e}function U(e){return k(e.policy_mode)?{mode:e.policy_mode,allow_new_sessions:D(e.allow_new_sessions),allow_resume_with_edits:D(e.allow_resume_with_edits)}:null}function F(e){return A(e.launch_profile)?e.launch_profile:null}function W(e){var t;return{runtime_connection_id:e.runtime_connection_id,launch_profile:e.launch_profile,deck_id:"agent_deck"===e.launch_profile?e.deck_id:null,working_directory:"agent_deck"===e.launch_profile?e.working_directory:null,session_scope_kind:e.session_scope.kind,session_scope_items:JSON.stringify("workspaces"===(t=e.session_scope).kind?t.workspaces:"sessions"===t.kind?t.sessions:[]),default_workspace:e.default_workspace,policy_mode:e.policy.mode,allow_new_sessions:+!!e.policy.allow_new_sessions,allow_resume_with_edits:+!!e.policy.allow_resume_with_edits,home_session_id:e.home_session_id,needs_deck_selection:0}}function X(e){let t="hermes";try{t=(0,a.normalizeAgent)(e.agent)??"hermes"}catch{t="hermes"}let n=f(e.deck_id),i=D(e.needs_deck_selection),r=f(e.working_directory)??`~/.botmancers/${e.id}`;return{runtime_connection_id:v(t),provider:t,launch_profile:n&&!i?"agent_deck":null,session_scope_kind:"workspaces",session_scope_items:JSON.stringify([r]),policy_mode:u.mode,allow_new_sessions:+!!u.allow_new_sessions,allow_resume_with_edits:+!!u.allow_resume_with_edits}}let x=["runtime_connection_id","launch_profile","session_scope","default_workspace","policy","home_session_id"];function G(e){return x.some(t=>void 0!==e[t])}function H(e,t){if(null==e||"object"!=typeof e||Array.isArray(e)||void 0===e.kind||null===e.kind||""===e.kind)return t.push(m),null;if(!S(e.kind))return t.push("Invalid session scope kind. Expected workspaces, sessions, or all_provider_sessions."),null;let n=y(e.workspaces),i=y(e.sessions);if(null===n||null===i)return t.push("session_scope.workspaces and session_scope.sessions must be lists of strings."),null;let r=e.kind;return"all_provider_sessions"===r?n.length>0||i.length>0?(t.push("all_provider_sessions takes no workspace or session list."),null):{kind:r,workspaces:[],sessions:[]}:n.length>0&&i.length>0?(t.push(L),null):"workspaces"===r?i.length>0?(t.push(L),null):0===n.length?(t.push("Select at least one workspace. An empty scope is never unrestricted."),null):n.every(w)?{kind:r,workspaces:n,sessions:[]}:(t.push(g),null):n.length>0?(t.push(L),null):0===i.length?(t.push("Select at least one session. An empty scope is never unrestricted."),null):{kind:r,workspaces:[],sessions:i}}function B(e,t){if(null==e||"object"!=typeof e||Array.isArray(e)||void 0===e.mode||null===e.mode||""===e.mode)return t.push(O),null;if(!k(e.mode))return t.push("Invalid policy mode. Expected read_only or workspace_write."),null;let n=[];for(let i of["allow_new_sessions","allow_resume_with_edits"]){let r=e[i];if(void 0===r)n.push(!1);else{if("boolean"!=typeof r)return t.push("Policy flags allow_new_sessions and allow_resume_with_edits must be true or false."),null;n.push(r)}}let i={mode:e.mode,allow_new_sessions:n[0],allow_resume_with_edits:n[1]};return i.allow_resume_with_edits&&"workspace_write"!==i.mode?(t.push("allow_resume_with_edits requires the workspace_write policy mode."),null):i}function M(e,t){if(null==e)return null;if("string"!=typeof e)return t.push(g),null;let n=e.trim();return n?w(n)?n:(t.push(g),null):null}function K(e,t,n,i){"agent_deck"!==e.launch_profile||e.deck_id||i.push(a.DECK_REQUIRED_ERROR);let r=e.session_scope;"sessions"!==r.kind||r.sessions.every(e=>n.sessionBelongsTo(t,e))||i.push("A selected session does not belong to this Agent."),e.default_workspace&&"workspaces"===r.kind&&!r.workspaces.some(t=>q(t,e.default_workspace))&&i.push("default_workspace must be inside one of the selected workspaces."),e.home_session_id&&(n.sessionBelongsTo(t,e.home_session_id)?"sessions"!==r.kind||r.sessions.includes(e.home_session_id)||i.push("home_session_id must be one of the selected sessions."):i.push("home_session_id must be one of this Agent’s own sessions."))}function Y(e,t,n){let i=f(e.runtime_connection_id);if(!i)return n.push(c),null;let r=t.getConnection(i);return r?void 0!==e.agent&&null!==e.agent&&String(e.agent).trim()&&String(e.agent).trim()!==r.provider?(n.push("agent does not match the runtime connection provider."),null):r:(n.push(l),null)}function P(e,t){try{return(0,a.parseRequestDeckId)(e)}catch(e){return t.push(e instanceof Error?e.message:String(e)),null}}function $(e){return!G(e)&&void 0!==e.deck_id}function z(e){return{runtime_connection_id:f(e.runtime_connection_id),launch_profile:F(e),deck_id:f(e.deck_id),working_directory:f(e.working_directory),session_scope:b(e),default_workspace:f(e.default_workspace),policy:U(e),home_session_id:f(e.home_session_id)}}function j(e,t){let n=z(e);return{runtime_connection_id:n.runtime_connection_id,runtime_connection:t?{id:t.id,provider:t.provider,label:t.label,host:t.host}:null,launch_profile:n.launch_profile,needs_launch_profile:null===n.launch_profile,session_scope:n.session_scope,default_workspace:n.default_workspace,policy:n.policy,home_session_id:n.home_session_id}}e.s(["LOCAL_HOST",0,E,"hasRegistrationUpdate",0,G,"isLegacyCreate",0,$,"localConnectionId",0,v,"localConnectionLabel",0,h,"migrateRegistration",0,X,"readStoredPolicy",0,U,"readStoredScope",0,b,"registrationColumns",0,W,"serializeRegistration",0,j,"storedLaunchProfile",0,F,"validateConnectionInput",0,function(e){let t=[],n=null;try{(n=(0,a.normalizeAgent)(e.provider))||t.push(I)}catch(e){t.push(e instanceof Error?e.message:String(e))}let i=f(e.label);i?i.length>80&&t.push("Connection name must be 80 characters or fewer."):t.push("Connection name is required.");let r=f(e.host)??E;for(let n of(r.length>80&&t.push("Host must be 80 characters or fewer."),["token","api_key","apiKey","credentials","password","secret"]))void 0!==e[n]&&t.push("Runtime credentials stay with the runtime; a connection stores no secrets.");return!(t.length>0)&&n&&i?{errors:t,fields:{provider:n,label:i,host:r}}:{errors:[...new Set(t)],fields:null}},"validateCreateRegistration",0,function(e,t){let n=[];if($(e)){let i="hermes";try{i=(0,a.normalizeAgent)(e.agent)??"hermes"}catch(e){n.push(e instanceof Error?e.message:String(e))}let r=P(e.deck_id,n);r||0!==n.length||n.push(a.DECK_REQUIRED_ERROR);let s=f(e.working_directory);return n.length>0?{errors:n,registration:null,provider:null}:{errors:n,provider:i,registration:{runtime_connection_id:t.localConnectionFor(i),launch_profile:"agent_deck",deck_id:r,working_directory:s,session_scope:{kind:"workspaces",workspaces:s?[s]:[],sessions:[]},default_workspace:null,policy:{...u},home_session_id:null}}}let i=Y(e,t,n),r=null;void 0===e.launch_profile||null===e.launch_profile||""===e.launch_profile?n.push(T):A(e.launch_profile)?r=e.launch_profile:n.push(p);let s=null,o=null;"direct"===r?(f(e.deck_id)&&n.push(N),f(e.working_directory)&&n.push(R)):"agent_deck"===r&&(s=P(e.deck_id,n),o=f(e.working_directory));let _=H(e.session_scope,n),d=M(e.default_workspace,n),E=B(e.policy,n),c=f(e.home_session_id);if(!i||!r||!_||!E||n.length>0)return{errors:n,registration:null,provider:null};let l={runtime_connection_id:i.id,launch_profile:r,deck_id:s,working_directory:o,session_scope:_,default_workspace:d,policy:E,home_session_id:c};return K(l,null,t,n),n.length>0?{errors:n,registration:null,provider:null}:{errors:n,registration:l,provider:i.provider}},"validateUpdateRegistration",0,function(e,t,n,i){let r=[],s=z(t),o=null;if(void 0!==n.runtime_connection_id)o=Y(n,i,r);else if(void 0!==n.agent)try{let e=(0,a.normalizeAgent)(n.agent);if(e){let t=s.runtime_connection_id?i.getConnection(s.runtime_connection_id):void 0;o=t&&t.provider===e?t:i.getConnection(i.localConnectionFor(e))??null}else r.push(`Agent is required. Expected one of ${a.AGENTS.join("|")}.`)}catch(e){r.push(e instanceof Error?e.message:String(e))}else s.runtime_connection_id?(o=i.getConnection(s.runtime_connection_id)??null)||r.push(l):r.push(c);let _=s.launch_profile;void 0!==n.launch_profile?A(n.launch_profile)?_=n.launch_profile:(r.push(null===n.launch_profile||""===n.launch_profile?T:p),_=null):void 0!==n.deck_id&&"direct"!==_&&(_="agent_deck");let d=s.deck_id,E=s.working_directory;"direct"===_?(void 0!==n.deck_id&&f(n.deck_id)&&r.push(N),void 0!==n.working_directory&&f(n.working_directory)&&r.push(R),d=null,E=null):"agent_deck"===_?(void 0!==n.deck_id?d=P(n.deck_id,r):("agent_deck"!==s.launch_profile||D(t.needs_deck_selection))&&(d=null),void 0!==n.working_directory&&(E=f(n.working_directory))):0===r.length&&r.push(T);let u=void 0!==n.session_scope?H(n.session_scope,r):s.session_scope;void 0!==n.session_scope||u||r.push(m);let L=void 0!==n.default_workspace?M(n.default_workspace,r):s.default_workspace,g=void 0!==n.policy?B(n.policy,r):s.policy;void 0!==n.policy||g||r.push(O);let I=void 0!==n.home_session_id?f(n.home_session_id):s.home_session_id;if(!o||!_||!u||!g||r.length>0)return{errors:r,registration:null,provider:null};let S={runtime_connection_id:o.id,launch_profile:_,deck_id:"agent_deck"===_?d:null,working_directory:"agent_deck"===_?E:null,session_scope:u,default_workspace:L,policy:g,home_session_id:I};return K(S,e,i,r),r.length>0?{errors:r,registration:null,provider:null}:{errors:r,registration:S,provider:o.provider}},"workspaceContains",0,q],18966);var J=e.i(16979);let Q=Object.freeze(["conversation","implementation","review","revision"]),V=Object.freeze(["readonly","edit"]);Object.freeze(["ui","api","wake","continuation","exchange"]);let Z=Object.freeze({conversation:"readonly",implementation:"edit",review:"readonly",revision:"edit"});function ee(e){return"string"==typeof e&&Q.includes(e)}function et(e,t){return{ok:!1,code:e,reason:t}}function en(e){var t,n,i,r;if(!ee(e.executionKind))return et("unknown_execution_kind",`Unknown execution kind ${JSON.stringify(String(e.executionKind))}.`);let s=e.executionKind,a=(t=e.entryPoint,n=s,i=e.wakeSyntax,r=!0===e.resumesWorkRequest,"ui"===t||"api"===t?"conversation"!==n?{code:"unsupported_authority",reason:`A direct message runs as a read-only conversation turn, not ${n}.`}:"direct_message_conversation":"continuation"===t?"conversation"!==n?{code:"unsupported_authority",reason:`A coordinator continuation runs as a read-only conversation turn, not ${n}.`}:"coordinator_continuation":"exchange"===t?"conversation"!==n?{code:"unsupported_authority",reason:`A session exchange runs as a read-only conversation turn, not ${n}.`}:"session_exchange_conversation":"wake"!==t?{code:"unsupported_authority",reason:"Unknown policy entry point."}:"legacy"===i?"conversation"!==n?{code:"unsupported_authority",reason:`A legacy WAKE directive runs as a conversation turn, not ${n}.`}:"legacy_wake_conversation":"structured"!==i?{code:"unsupported_authority",reason:"Unknown Wake syntax."}:"revision"===n!==r?{code:"unsupported_authority",reason:"revision"===n?"A revision names the Work Request it resumes.":"Only a revision resumes a Work Request."}:"structured_wake");return"string"!=typeof a?et(a.code,a.reason):{ok:!0,policy:Object.freeze({policy_version:1,execution_kind:s,tool_profile:Z[s],entry_point:e.entryPoint,rule:a})}}let ei=new Set(["policy_version","execution_kind","tool_profile","entry_point","rule"]);function er(e){if(!e||"object"!=typeof e||Array.isArray(e))return et("malformed_policy","The execution policy snapshot is missing.");let t=Object.keys(e);if(t.length!==ei.size||t.some(e=>!ei.has(e)))return et("malformed_policy","The execution policy snapshot has unexpected fields.");if(1!==e.policy_version)return et("malformed_policy","Unsupported execution policy version.");if(!ee(e.execution_kind))return et("unknown_execution_kind",`Unknown execution kind ${JSON.stringify(String(e.execution_kind))}.`);if(!V.includes(e.tool_profile))return et("unsupported_authority",`Unsupported tool profile ${JSON.stringify(String(e.tool_profile))}.`);if(Z[e.execution_kind]!==e.tool_profile)return et("unsupported_authority",`Execution kind ${e.execution_kind} requires the ${Z[e.execution_kind]} tool profile.`);let n={direct_message_conversation:{entry:["ui","api"],kinds:["conversation"]},legacy_wake_conversation:{entry:["wake"],kinds:["conversation"]},coordinator_continuation:{entry:["continuation"],kinds:["conversation"]},session_exchange_conversation:{entry:["exchange"],kinds:["conversation"]},structured_wake:{entry:["wake"],kinds:[...Q]}},i="string"==typeof e.rule?n[e.rule]:void 0;return i&&i.entry.includes(e.entry_point)?i.kinds.includes(e.execution_kind)?{ok:!0,policy:Object.freeze({...e})}:et("unsupported_authority",`Rule ${e.rule} does not grant ${e.execution_kind}.`):et("malformed_policy","The execution policy rule does not match its entry point.")}e.s(["TOOL_PROFILE_FOR_KIND",0,Z,"authorizeWorkRequest",0,function(e){let t;if(!ee(e.execution_kind))return et("unknown_execution_kind",`Unknown execution kind ${JSON.stringify(String(e.execution_kind))}.`);try{t="string"==typeof e.policy_snapshot?JSON.parse(e.policy_snapshot):null}catch{return et("malformed_policy","The policy snapshot is not valid JSON.")}let n=er(t&&"object"==typeof t&&!Array.isArray(t)?t.execution_policy:void 0);return n.ok?n.policy.execution_kind!==e.execution_kind||n.policy.tool_profile!==e.tool_profile?et("unsupported_authority","The Work Request authority does not match its policy snapshot."):t.tool_profile!==e.tool_profile?et("malformed_policy","The policy snapshot tool profile does not match the Work Request."):n:n},"isExecutionKind",0,ee,"selectExecutionPolicy",0,en,"validateExecutionPolicy",0,er],64974);let es=Object.freeze({max_attempts:1,base_delay_ms:1e3,max_delay_ms:6e4,attempt_timeout_ms:null});function ea(e){if(void 0===e||!/^\d+$/.test(e.trim()))return null;let t=Number(e.trim());return Number.isSafeInteger(t)&&t>0?t:null}function eo(e=process.env){let t=ea(e.BOTMANCERS_RETRY_MAX_ATTEMPTS),n=ea(e.BOTMANCERS_RETRY_BASE_DELAY_MS)??es.base_delay_ms,i=ea(e.BOTMANCERS_RETRY_MAX_DELAY_MS)??es.max_delay_ms,r=e_({max_attempts:null===t?es.max_attempts:Math.min(t,10),base_delay_ms:n,max_delay_ms:Math.max(i,n),attempt_timeout_ms:ea(e.BOTMANCERS_ATTEMPT_TIMEOUT_MS)});return{deadlineMs:ea(e.BOTMANCERS_REQUEST_DEADLINE_MS),retryPolicy:r.ok?r.policy:{...es}}}function e_(e){if(!e||"object"!=typeof e||Array.isArray(e))return{ok:!1,reason:"A retry policy is an object."};let t=e=>"number"==typeof e&&Number.isSafeInteger(e);if(!t(e.max_attempts)||e.max_attempts<1||e.max_attempts>10)return{ok:!1,reason:"max_attempts must be an integer from 1 to 10."};if(!t(e.base_delay_ms)||e.base_delay_ms<0)return{ok:!1,reason:"base_delay_ms must be a non-negative integer."};if(!t(e.max_delay_ms)||e.max_delay_ms<e.base_delay_ms)return{ok:!1,reason:"max_delay_ms must be an integer no smaller than base_delay_ms."};let n=e.attempt_timeout_ms??null;return null!==n&&(!t(n)||n<1)?{ok:!1,reason:"attempt_timeout_ms must be a positive integer or null."}:{ok:!0,policy:{max_attempts:e.max_attempts,base_delay_ms:e.base_delay_ms,max_delay_ms:e.max_delay_ms,attempt_timeout_ms:n}}}let ed=["agent_deck_token_missing","agent_deck_unauthorized","agent_deck_forbidden"],eE={unavailable:"retryable",runtime_failed:"retryable",timed_out:"retryable",launch_failed:"terminal",unsupported_authority:"terminal",result_contract:"terminal",cancelled:"terminal",session_mismatch:"manual_attention"};e.s(["DEFAULT_RETRY_POLICY",0,es,"attemptDeadline",0,function(e,t,n){let i=null===e.attempt_timeout_ms?null:n+e.attempt_timeout_ms;return null===i?t:null===t?i:Math.min(i,t)},"classifyFailure",0,function(e,t=null){return t&&ed.includes(t)?"manual_attention":eE[e??"runtime_failed"]??"terminal"},"decideRetry",0,function(e){var t;let n;if("terminal"===e.disposition)return{action:"fail",disposition:"terminal"};let i=e.attemptCount<e.policy.max_attempts;if("manual_attention"===e.disposition)return i?{action:"attention"}:{action:"fail",disposition:"terminal"};if(!i)return{action:"exhausted"};let r=e.attemptCount,s=(t=e.policy,n=Math.max(0,r-1),Math.min(t.max_delay_ms,t.base_delay_ms*2**Math.min(n,30))),a=e.now+s;return null!==e.deadlineAt&&a>=e.deadlineAt?{action:"deadline"}:{action:"retry",nextEligibleAt:a,delayMs:s,retry:r}},"requestControlDefaultsFromEnv",0,eo,"storedRetryPolicy",0,function(e){if(!e)return{...es};try{let t=e_(JSON.parse(e));return t.ok?t.policy:{...es}}catch{return{...es}}},"validateRetryPolicy",0,e_],11626);let eu={cached_input_tokens:"cached_input_tokens",cachedInputTokens:"cached_input_tokens",cache_read_input_tokens:"cache_read_input_tokens",cacheReadInputTokens:"cache_read_input_tokens",cacheReadTokens:"cache_read_input_tokens",cache_creation_input_tokens:"cache_creation_input_tokens",cacheCreationInputTokens:"cache_creation_input_tokens",cacheWriteTokens:"cache_creation_input_tokens",reasoning_output_tokens:"reasoning_output_tokens",reasoningOutputTokens:"reasoning_output_tokens",reasoningTokens:"reasoning_output_tokens"};function ec(e){return null===e||"object"!=typeof e||Array.isArray(e)?null:e}function el(e){return"number"==typeof e&&Number.isInteger(e)&&e>=0&&e<=Number.MAX_SAFE_INTEGER?e:null}function eT(e){return"number"==typeof e&&Number.isFinite(e)&&e>=0&&e<1e9?e:null}function ep(e,t,n){for(let i of t)if(i in e){let t=n(e[i]);if(null!==t)return t}return null}function eN(e,t,n){let i=e?ep(e,["input_tokens","inputTokens"],el):null,r=e?ep(e,["output_tokens","outputTokens"],el):null;return null===i&&null===r&&null===t?null:{input_tokens:i,output_tokens:r,cost_usd:t,source:n,breakdown:e?function(e){let t={};for(let[n,i]of Object.entries(eu)){let r=el(e[n]);null!==r&&void 0===t[i]&&(t[i]=r)}return Object.keys(t).length>0?t:null}(e):null}}function eR(e){let t=ec(e);if(!t)return null;let n="string"==typeof t.type?t.type:null,i=ec(t.usage);if("turn.completed"===n)return eN(i,null,"codex.turn_completed");if("result"===n)return eN(i,ep(t,["total_cost_usd","totalCostUsd","cost_usd","costUsd"],eT),"result");if(null===n||"usage"===n){let e=i??t,n=ep(e,["cost_usd","costUsd","total_cost_usd","totalCostUsd"],eT)??(i?ep(t,["cost_usd","costUsd","total_cost_usd","totalCostUsd"],eT):null);return eN(e,n,"normalized")}return null}function em(e,t){return null===e?t:null===t?e:e+t}function eL(e){let t=ec(e);if(!t)return null;let n="codex.turn_completed"===t.source||"result"===t.source||"normalized"===t.source?t.source:"normalized",i=el(t.input_tokens),r=el(t.output_tokens),s=eT(t.cost_usd);if(null===i&&null===r&&null===s)return null;let a=ec(t.breakdown),o={};if(a)for(let e of new Set(Object.values(eu))){let t=el(a[e]);null!==t&&(o[e]=t)}return{input_tokens:i,output_tokens:r,cost_usd:s,source:n,breakdown:Object.keys(o).length>0?o:null}}function eg(e){let t=t=>{var n,i;let r=null,s=0;for(let n of e){let e=n[t];null!=e&&(s++,r=(r??0)+e)}return null!==r&&"cost_usd"===t&&(r=Math.round(1e6*r)/1e6),{sum:r,known:s,total:e.length,quality:(n=s,0===(i=e.length)||0===n?"unavailable":n===i?"complete":"partial")}};return{input_tokens:t("input_tokens"),output_tokens:t("output_tokens"),cost_usd:t("cost_usd")}}function eO(e){return!!e.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'usage_samples'").get()}function eI(e,t,n,i){if(!eO(e))return;let r=eL(i.usage),a=i.now??Date.now();e.prepare(`
1
+ module.exports=[62294,18966,64974,11626,40596,28420,35613,30098,e=>{"use strict";let t;var n=e.i(85148),i=e.i(22734),r=e.i(14747),s=e.i(54799),a=e.i(62349);let o=["read_only","workspace_write"],_=["workspaces","sessions","all_provider_sessions"],d="This computer",E="Runtime connection is required. Pick the runtime this Agent uses.",u="Runtime connection not found.",c="Session scope is required. Select workspaces, select sessions, or explicitly choose all_provider_sessions.",l="A session scope selects workspaces or sessions, not both.",T="Workspaces must be absolute paths (or start with ~/).",p="Launch policy is required. Choose read_only or workspace_write.",N=`Provider is required. Expected one of ${a.AGENTS.join("|")}.`;function R(e){return"string"==typeof e&&_.includes(e)}function m(e){return"string"==typeof e&&o.includes(e)}function L(e){return null==e?null:String(e).trim()||null}function O(e){return`rc-local-${e}`}function g(e){return`${a.AGENT_LABELS[e]} on ${d.toLowerCase()}`}function I(e){return e.startsWith("/")||"~"===e||e.startsWith("~/")}function A(e){return e.length>1?e.replace(/\/+$/,""):e}function S(e,t){let n=A(e),i=A(t);return n===i||i.startsWith("/"===n?"/":`${n}/`)}function v(e){if(null==e)return[];if(!Array.isArray(e))return null;let t=[];for(let n of e){if("string"!=typeof n)return null;let e=n.trim();e&&!t.includes(e)&&t.push(e)}return t}function k(e,t){let n="string"==typeof e?e.trim():"";if(!n)return null;let i=t&&t.trim()?t:(process.env.HOME??"").trim(),r="~"===n?i:n.startsWith("~/")?`${i}/${n.slice(2)}`:n;return r.startsWith("/")?r:null}function f(e){let t=e.session_scope_kind;if(!R(t))return null;let n=[];if(e.session_scope_items)try{let t=v(JSON.parse(e.session_scope_items));if(null===t)return null;n=t}catch{return null}return"all_provider_sessions"===t?0===n.length?{kind:t,workspaces:[],sessions:[]}:null:0===n.length?null:"workspaces"===t?{kind:t,workspaces:n,sessions:[]}:{kind:t,workspaces:[],sessions:n}}function h(e){return!0===e||1===e||"1"===e}function w(e){return m(e.policy_mode)?{mode:e.policy_mode,allow_new_sessions:h(e.allow_new_sessions),allow_resume_with_edits:h(e.allow_resume_with_edits)}:null}function C(e){var t;return{runtime_connection_id:e.runtime_connection_id,launch_profile:"direct",deck_id:null,working_directory:null,session_scope_kind:e.session_scope.kind,session_scope_items:JSON.stringify("workspaces"===(t=e.session_scope).kind?t.workspaces:"sessions"===t.kind?t.sessions:[]),default_workspace:e.default_workspace,policy_mode:e.policy.mode,allow_new_sessions:+!!e.policy.allow_new_sessions,allow_resume_with_edits:+!!e.policy.allow_resume_with_edits,home_session_id:e.home_session_id,needs_deck_selection:0}}function q(e){let t="hermes";try{t=(0,a.normalizeAgent)(e.agent)??"hermes"}catch{t="hermes"}let n=L(e.working_directory)??`~/.botmancers/${e.id}`;return{runtime_connection_id:O(t),provider:t,session_scope_kind:"workspaces",session_scope_items:JSON.stringify([n]),policy_mode:"read_only",allow_new_sessions:1,allow_resume_with_edits:0}}let y=["runtime_connection_id","session_scope","default_workspace","policy","home_session_id"];function b(e,t){if(null==e||"object"!=typeof e||Array.isArray(e)||void 0===e.kind||null===e.kind||""===e.kind)return t.push(c),null;if(!R(e.kind))return t.push("Invalid session scope kind. Expected workspaces, sessions, or all_provider_sessions."),null;let n=v(e.workspaces),i=v(e.sessions);if(null===n||null===i)return t.push("session_scope.workspaces and session_scope.sessions must be lists of strings."),null;let r=e.kind;return"all_provider_sessions"===r?n.length>0||i.length>0?(t.push("all_provider_sessions takes no workspace or session list."),null):{kind:r,workspaces:[],sessions:[]}:n.length>0&&i.length>0?(t.push(l),null):"workspaces"===r?i.length>0?(t.push(l),null):0===n.length?(t.push("Select at least one workspace. An empty scope is never unrestricted."),null):n.every(I)?{kind:r,workspaces:n,sessions:[]}:(t.push(T),null):n.length>0?(t.push(l),null):0===i.length?(t.push("Select at least one session. An empty scope is never unrestricted."),null):{kind:r,workspaces:[],sessions:i}}function U(e,t){if(null==e||"object"!=typeof e||Array.isArray(e)||void 0===e.mode||null===e.mode||""===e.mode)return t.push(p),null;if(!m(e.mode))return t.push("Invalid policy mode. Expected read_only or workspace_write."),null;let n=[];for(let i of["allow_new_sessions","allow_resume_with_edits"]){let r=e[i];if(void 0===r)n.push(!1);else{if("boolean"!=typeof r)return t.push("Policy flags allow_new_sessions and allow_resume_with_edits must be true or false."),null;n.push(r)}}let i={mode:e.mode,allow_new_sessions:n[0],allow_resume_with_edits:n[1]};return i.allow_resume_with_edits&&"workspace_write"!==i.mode?(t.push("allow_resume_with_edits requires the workspace_write policy mode."),null):i}function D(e,t){if(null==e)return null;if("string"!=typeof e)return t.push(T),null;let n=e.trim();return n?I(n)?n:(t.push(T),null):null}function F(e,t,n,i){let r=e.session_scope;"sessions"!==r.kind||r.sessions.every(e=>n.sessionBelongsTo(t,e))||i.push("A selected session does not belong to this Agent."),e.default_workspace&&"workspaces"===r.kind&&!r.workspaces.some(t=>S(t,e.default_workspace))&&i.push("default_workspace must be inside one of the selected workspaces."),e.home_session_id&&(n.sessionBelongsTo(t,e.home_session_id)?"sessions"!==r.kind||r.sessions.includes(e.home_session_id)||i.push("home_session_id must be one of the selected sessions."):i.push("home_session_id must be one of this Agent’s own sessions."))}function W(e,t,n){let i=L(e.runtime_connection_id);if(!i)return n.push(E),null;let r=t.getConnection(i);return r?void 0!==e.agent&&null!==e.agent&&String(e.agent).trim()&&String(e.agent).trim()!==r.provider?(n.push("agent does not match the runtime connection provider."),null):r:(n.push(u),null)}function X(e){return{runtime_connection_id:L(e.runtime_connection_id),session_scope:f(e),default_workspace:L(e.default_workspace),policy:w(e),home_session_id:L(e.home_session_id)}}function x(e,t){let n=X(e);return{runtime_connection_id:n.runtime_connection_id,runtime_connection:t?{id:t.id,provider:t.provider,label:t.label,host:t.host}:null,session_scope:n.session_scope,default_workspace:n.default_workspace,policy:n.policy,home_session_id:n.home_session_id}}e.s(["LOCAL_HOST",0,d,"directLaunchWorkspace",0,function(e,t){let n=k(e.default_workspace,t);if(n)return n;let i=f(e);return i?.kind==="workspaces"&&1===i.workspaces.length?k(i.workspaces[0],t):null},"hasRegistrationUpdate",0,function(e){return y.some(t=>void 0!==e[t])},"localConnectionId",0,O,"localConnectionLabel",0,g,"migrateRegistration",0,q,"readStoredPolicy",0,w,"readStoredScope",0,f,"registrationColumns",0,C,"serializeRegistration",0,x,"validateConnectionInput",0,function(e){let t=[],n=null;try{(n=(0,a.normalizeAgent)(e.provider))||t.push(N)}catch(e){t.push(e instanceof Error?e.message:String(e))}let i=L(e.label);i?i.length>80&&t.push("Connection name must be 80 characters or fewer."):t.push("Connection name is required.");let r=L(e.host)??d;for(let n of(r.length>80&&t.push("Host must be 80 characters or fewer."),["token","api_key","apiKey","credentials","password","secret"]))void 0!==e[n]&&t.push("Runtime credentials stay with the runtime; a connection stores no secrets.");return!(t.length>0)&&n&&i?{errors:t,fields:{provider:n,label:i,host:r}}:{errors:[...new Set(t)],fields:null}},"validateCreateRegistration",0,function(e,t){let n=[],i=W(e,t,n),r=b(e.session_scope,n),s=D(e.default_workspace,n),a=U(e.policy,n),o=L(e.home_session_id);if(!i||!r||!a||n.length>0)return{errors:n,registration:null,provider:null};let _={runtime_connection_id:i.id,session_scope:r,default_workspace:s,policy:a,home_session_id:o};return F(_,null,t,n),n.length>0?{errors:n,registration:null,provider:null}:{errors:n,registration:_,provider:i.provider}},"validateUpdateRegistration",0,function(e,t,n,i){let r=[],s=X(t),o=null;if(void 0!==n.runtime_connection_id)o=W(n,i,r);else if(void 0!==n.agent)try{let e=(0,a.normalizeAgent)(n.agent);if(e){let t=s.runtime_connection_id?i.getConnection(s.runtime_connection_id):void 0;o=t&&t.provider===e?t:i.getConnection(i.localConnectionFor(e))??null}else r.push(`Agent is required. Expected one of ${a.AGENTS.join("|")}.`)}catch(e){r.push(e instanceof Error?e.message:String(e))}else s.runtime_connection_id?(o=i.getConnection(s.runtime_connection_id)??null)||r.push(u):r.push(E);let _=void 0!==n.session_scope?b(n.session_scope,r):s.session_scope;void 0!==n.session_scope||_||r.push(c);let d=void 0!==n.default_workspace?D(n.default_workspace,r):s.default_workspace,l=void 0!==n.policy?U(n.policy,r):s.policy;void 0!==n.policy||l||r.push(p);let T=void 0!==n.home_session_id?L(n.home_session_id):s.home_session_id;if(!o||!_||!l||r.length>0)return{errors:r,registration:null,provider:null};let N={runtime_connection_id:o.id,session_scope:_,default_workspace:d,policy:l,home_session_id:T};return F(N,e,i,r),r.length>0?{errors:r,registration:null,provider:null}:{errors:r,registration:N,provider:o.provider}},"workspaceContains",0,S],18966);var G=e.i(16979);let H=Object.freeze(["conversation","implementation","review","revision"]),B=Object.freeze(["readonly","edit"]);Object.freeze(["ui","api","wake","continuation","exchange"]);let M=Object.freeze({conversation:"readonly",implementation:"edit",review:"readonly",revision:"edit"});function K(e){return"string"==typeof e&&H.includes(e)}function Y(e,t){return{ok:!1,code:e,reason:t}}function P(e){var t,n,i,r;if(!K(e.executionKind))return Y("unknown_execution_kind",`Unknown execution kind ${JSON.stringify(String(e.executionKind))}.`);let s=e.executionKind,a=(t=e.entryPoint,n=s,i=e.wakeSyntax,r=!0===e.resumesWorkRequest,"ui"===t||"api"===t?"conversation"!==n?{code:"unsupported_authority",reason:`A direct message runs as a read-only conversation turn, not ${n}.`}:"direct_message_conversation":"continuation"===t?"conversation"!==n?{code:"unsupported_authority",reason:`A coordinator continuation runs as a read-only conversation turn, not ${n}.`}:"coordinator_continuation":"exchange"===t?"conversation"!==n?{code:"unsupported_authority",reason:`A session exchange runs as a read-only conversation turn, not ${n}.`}:"session_exchange_conversation":"wake"!==t?{code:"unsupported_authority",reason:"Unknown policy entry point."}:"legacy"===i?"conversation"!==n?{code:"unsupported_authority",reason:`A legacy WAKE directive runs as a conversation turn, not ${n}.`}:"legacy_wake_conversation":"structured"!==i?{code:"unsupported_authority",reason:"Unknown Wake syntax."}:"revision"===n!==r?{code:"unsupported_authority",reason:"revision"===n?"A revision names the Work Request it resumes.":"Only a revision resumes a Work Request."}:"structured_wake");return"string"!=typeof a?Y(a.code,a.reason):{ok:!0,policy:Object.freeze({policy_version:1,execution_kind:s,tool_profile:M[s],entry_point:e.entryPoint,rule:a})}}let $=new Set(["policy_version","execution_kind","tool_profile","entry_point","rule"]);function z(e){if(!e||"object"!=typeof e||Array.isArray(e))return Y("malformed_policy","The execution policy snapshot is missing.");let t=Object.keys(e);if(t.length!==$.size||t.some(e=>!$.has(e)))return Y("malformed_policy","The execution policy snapshot has unexpected fields.");if(1!==e.policy_version)return Y("malformed_policy","Unsupported execution policy version.");if(!K(e.execution_kind))return Y("unknown_execution_kind",`Unknown execution kind ${JSON.stringify(String(e.execution_kind))}.`);if(!B.includes(e.tool_profile))return Y("unsupported_authority",`Unsupported tool profile ${JSON.stringify(String(e.tool_profile))}.`);if(M[e.execution_kind]!==e.tool_profile)return Y("unsupported_authority",`Execution kind ${e.execution_kind} requires the ${M[e.execution_kind]} tool profile.`);let n={direct_message_conversation:{entry:["ui","api"],kinds:["conversation"]},legacy_wake_conversation:{entry:["wake"],kinds:["conversation"]},coordinator_continuation:{entry:["continuation"],kinds:["conversation"]},session_exchange_conversation:{entry:["exchange"],kinds:["conversation"]},structured_wake:{entry:["wake"],kinds:[...H]}},i="string"==typeof e.rule?n[e.rule]:void 0;return i&&i.entry.includes(e.entry_point)?i.kinds.includes(e.execution_kind)?{ok:!0,policy:Object.freeze({...e})}:Y("unsupported_authority",`Rule ${e.rule} does not grant ${e.execution_kind}.`):Y("malformed_policy","The execution policy rule does not match its entry point.")}e.s(["TOOL_PROFILE_FOR_KIND",0,M,"authorizeWorkRequest",0,function(e){let t;if(!K(e.execution_kind))return Y("unknown_execution_kind",`Unknown execution kind ${JSON.stringify(String(e.execution_kind))}.`);try{t="string"==typeof e.policy_snapshot?JSON.parse(e.policy_snapshot):null}catch{return Y("malformed_policy","The policy snapshot is not valid JSON.")}let n=z(t&&"object"==typeof t&&!Array.isArray(t)?t.execution_policy:void 0);return n.ok?n.policy.execution_kind!==e.execution_kind||n.policy.tool_profile!==e.tool_profile?Y("unsupported_authority","The Work Request authority does not match its policy snapshot."):t.tool_profile!==e.tool_profile?Y("malformed_policy","The policy snapshot tool profile does not match the Work Request."):n:n},"isExecutionKind",0,K,"selectExecutionPolicy",0,P,"validateExecutionPolicy",0,z],64974);let j=Object.freeze({max_attempts:1,base_delay_ms:1e3,max_delay_ms:6e4,attempt_timeout_ms:null});function J(e){if(void 0===e||!/^\d+$/.test(e.trim()))return null;let t=Number(e.trim());return Number.isSafeInteger(t)&&t>0?t:null}function Q(e=process.env){let t=J(e.BOTMANCERS_RETRY_MAX_ATTEMPTS),n=J(e.BOTMANCERS_RETRY_BASE_DELAY_MS)??j.base_delay_ms,i=J(e.BOTMANCERS_RETRY_MAX_DELAY_MS)??j.max_delay_ms,r=V({max_attempts:null===t?j.max_attempts:Math.min(t,10),base_delay_ms:n,max_delay_ms:Math.max(i,n),attempt_timeout_ms:J(e.BOTMANCERS_ATTEMPT_TIMEOUT_MS)});return{deadlineMs:J(e.BOTMANCERS_REQUEST_DEADLINE_MS),retryPolicy:r.ok?r.policy:{...j}}}function V(e){if(!e||"object"!=typeof e||Array.isArray(e))return{ok:!1,reason:"A retry policy is an object."};let t=e=>"number"==typeof e&&Number.isSafeInteger(e);if(!t(e.max_attempts)||e.max_attempts<1||e.max_attempts>10)return{ok:!1,reason:"max_attempts must be an integer from 1 to 10."};if(!t(e.base_delay_ms)||e.base_delay_ms<0)return{ok:!1,reason:"base_delay_ms must be a non-negative integer."};if(!t(e.max_delay_ms)||e.max_delay_ms<e.base_delay_ms)return{ok:!1,reason:"max_delay_ms must be an integer no smaller than base_delay_ms."};let n=e.attempt_timeout_ms??null;return null!==n&&(!t(n)||n<1)?{ok:!1,reason:"attempt_timeout_ms must be a positive integer or null."}:{ok:!0,policy:{max_attempts:e.max_attempts,base_delay_ms:e.base_delay_ms,max_delay_ms:e.max_delay_ms,attempt_timeout_ms:n}}}let Z=["unavailable","provider_unavailable","agent_not_found","auth_required","permission_denied","incompatible_version","usage_limit"],ee={unavailable:"retryable",runtime_failed:"retryable",timed_out:"retryable",launch_failed:"terminal",unsupported_authority:"terminal",result_contract:"terminal",cancelled:"terminal",session_mismatch:"manual_attention"};e.s(["DEFAULT_RETRY_POLICY",0,j,"attemptDeadline",0,function(e,t,n){let i=null===e.attempt_timeout_ms?null:n+e.attempt_timeout_ms;return null===i?t:null===t?i:Math.min(i,t)},"classifyFailure",0,function(e,t=null){return t&&Z.includes(t)?"manual_attention":ee[e??"runtime_failed"]??"terminal"},"decideRetry",0,function(e){var t;let n;if("terminal"===e.disposition)return{action:"fail",disposition:"terminal"};let i=e.attemptCount<e.policy.max_attempts;if("manual_attention"===e.disposition)return i?{action:"attention"}:{action:"fail",disposition:"terminal"};if(!i)return{action:"exhausted"};let r=e.attemptCount,s=(t=e.policy,n=Math.max(0,r-1),Math.min(t.max_delay_ms,t.base_delay_ms*2**Math.min(n,30))),a=e.now+s;return null!==e.deadlineAt&&a>=e.deadlineAt?{action:"deadline"}:{action:"retry",nextEligibleAt:a,delayMs:s,retry:r}},"requestControlDefaultsFromEnv",0,Q,"storedRetryPolicy",0,function(e){if(!e)return{...j};try{let t=V(JSON.parse(e));return t.ok?t.policy:{...j}}catch{return{...j}}},"validateRetryPolicy",0,V],11626);let et={cached_input_tokens:"cached_input_tokens",cachedInputTokens:"cached_input_tokens",cache_read_input_tokens:"cache_read_input_tokens",cacheReadInputTokens:"cache_read_input_tokens",cacheReadTokens:"cache_read_input_tokens",cache_creation_input_tokens:"cache_creation_input_tokens",cacheCreationInputTokens:"cache_creation_input_tokens",cacheWriteTokens:"cache_creation_input_tokens",reasoning_output_tokens:"reasoning_output_tokens",reasoningOutputTokens:"reasoning_output_tokens",reasoningTokens:"reasoning_output_tokens"};function en(e){return null===e||"object"!=typeof e||Array.isArray(e)?null:e}function ei(e){return"number"==typeof e&&Number.isInteger(e)&&e>=0&&e<=Number.MAX_SAFE_INTEGER?e:null}function er(e){return"number"==typeof e&&Number.isFinite(e)&&e>=0&&e<1e9?e:null}function es(e,t,n){for(let i of t)if(i in e){let t=n(e[i]);if(null!==t)return t}return null}function ea(e,t,n){let i=e?es(e,["input_tokens","inputTokens"],ei):null,r=e?es(e,["output_tokens","outputTokens"],ei):null;return null===i&&null===r&&null===t?null:{input_tokens:i,output_tokens:r,cost_usd:t,source:n,breakdown:e?function(e){let t={};for(let[n,i]of Object.entries(et)){let r=ei(e[n]);null!==r&&void 0===t[i]&&(t[i]=r)}return Object.keys(t).length>0?t:null}(e):null}}function eo(e){let t=en(e);if(!t)return null;let n="codex.turn_completed"===t.source||"result"===t.source||"normalized"===t.source?t.source:"normalized",i=ei(t.input_tokens),r=ei(t.output_tokens),s=er(t.cost_usd);if(null===i&&null===r&&null===s)return null;let a=en(t.breakdown),o={};if(a)for(let e of new Set(Object.values(et))){let t=ei(a[e]);null!==t&&(o[e]=t)}return{input_tokens:i,output_tokens:r,cost_usd:s,source:n,breakdown:Object.keys(o).length>0?o:null}}function e_(e){let t=t=>{var n,i;let r=null,s=0;for(let n of e){let e=n[t];null!=e&&(s++,r=(r??0)+e)}return null!==r&&"cost_usd"===t&&(r=Math.round(1e6*r)/1e6),{sum:r,known:s,total:e.length,quality:(n=s,0===(i=e.length)||0===n?"unavailable":n===i?"complete":"partial")}};return{input_tokens:t("input_tokens"),output_tokens:t("output_tokens"),cost_usd:t("cost_usd")}}function ed(e){return!!e.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'usage_samples'").get()}function eE(e,t,n,i){if(!ed(e))return;let r=eo(i.usage),a=i.now??Date.now();e.prepare(`
2
2
  INSERT INTO usage_samples (
3
3
  id, sample_key, agent_id, attempt_id, session_ref, turn_id, provider, source,
4
4
  input_tokens, output_tokens, cost_usd, breakdown, observed_at, created_at, updated_at
@@ -14,7 +14,7 @@ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",
14
14
  OR (usage_samples.output_tokens IS NULL AND excluded.output_tokens IS NOT NULL)
15
15
  OR (usage_samples.cost_usd IS NULL AND excluded.cost_usd IS NOT NULL)
16
16
  THEN excluded.updated_at ELSE usage_samples.updated_at END
17
- `).run((0,s.randomUUID)(),t,i.agentId,n.attemptId,n.sessionRef,n.turnId,String(i.provider).slice(0,100),r?.source??"none",r?.input_tokens??null,r?.output_tokens??null,r?.cost_usd??null,r?.breakdown?JSON.stringify(r.breakdown):null,i.observedAt,a,a)}function eA(e,t,n){eI(e,`attempt:${t}`,{attemptId:t,sessionRef:null,turnId:null},n)}function eS(e,t,n){if(!eO(e))return[];let i=null===n?"":"AND b.id = ?",r=null===n?"":"AND s.session_ref = ?";return e.prepare(`
17
+ `).run((0,s.randomUUID)(),t,i.agentId,n.attemptId,n.sessionRef,n.turnId,String(i.provider).slice(0,100),r?.source??"none",r?.input_tokens??null,r?.output_tokens??null,r?.cost_usd??null,r?.breakdown?JSON.stringify(r.breakdown):null,i.observedAt,a,a)}function eu(e,t,n){eE(e,`attempt:${t}`,{attemptId:t,sessionRef:null,turnId:null},n)}function ec(e,t,n){if(!ed(e))return[];let i=null===n?"":"AND b.id = ?",r=null===n?"":"AND s.session_ref = ?";return e.prepare(`
18
18
  SELECT b.id AS ref, 'attempt' AS kind, a.attempt_number, a.kind AS turn_kind, s.provider, s.source,
19
19
  s.input_tokens, s.output_tokens, s.cost_usd, s.observed_at, s.sample_key
20
20
  FROM session_bindings b
@@ -35,7 +35,7 @@ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",
35
35
  LEFT JOIN provider_session_turns t ON t.id = s.turn_id
36
36
  WHERE s.agent_id = ? AND s.turn_id IS NOT NULL ${r}
37
37
  ORDER BY observed_at ASC, sample_key ASC
38
- `).all(...null===n?[t,t,t]:[t,n,t,n,t,n])}function ek(e){return{kind:e.kind,attempt_number:e.attempt_number,turn_kind:e.turn_kind,provider:e.provider,source:e.source,input_tokens:e.input_tokens,output_tokens:e.output_tokens,cost_usd:e.cost_usd,observed_at:e.observed_at}}e.s(["aggregateUsage",0,eg,"normalizeUsage",0,eL,"usageFromEvent",0,eR,"usageFromEvents",0,function(e){if(!e)return null;let t=null,n=null,i=null,r=new Set;for(let s of e){let e=ec(s),a=e&&("number"==typeof e.seq||"string"==typeof e.id)?`${e.type}:${e.seq??e.id}`:null;if(a){if(r.has(a))continue;r.add(a)}let o=eR(s);o&&("result"===o.source?t=o:"codex.turn_completed"===o.source?n=null===n?o:{input_tokens:em(n.input_tokens,o.input_tokens),output_tokens:em(n.output_tokens,o.output_tokens),cost_usd:null,source:"codex.turn_completed",breakdown:function(e,t){if(!e)return t;if(!t)return e;let n={...e};for(let[e,i]of Object.entries(t))n[e]=(n[e]??0)+i;return n}(n.breakdown,o.breakdown)}:i=o)}return t??n??i}],40596),e.s(["agentSessionUsage",0,function(e,t){let n=new Map;for(let i of eS(e,t,null)){let e=n.get(i.ref)??[];e.push(i),n.set(i.ref,e)}return new Map([...n].map(([e,t])=>[e,eg(t)]))},"emptyUsage",0,function(){return eg([])},"recordAttemptUsageSample",0,eA,"recordTurnUsageSample",0,function(e,t,n,i){eI(e,`turn:${t}`,{attemptId:null,sessionRef:n,turnId:t},i)},"sessionUsageSamples",0,function(e,t,n){let i=eS(e,t,n);return{usage:eg(i),samples:i.map(ek)}}],28420);let ef=["queued","extracting","delivering","completed","failed","cancelled"],ev=["completed","failed","cancelled"],eh={queued:["extracting","failed","cancelled"],extracting:["delivering","completed","failed","cancelled"],delivering:["completed","failed","cancelled"],completed:[],failed:[],cancelled:[]},ew=Object.freeze({instructionChars:4e3,packetChars:16e3,packetObjectiveChars:2e3,packetListItems:20,packetItemChars:500,answerChars:16e3,replyChars:16e3,extractionOutputChars:32e3,promptChars:24e3}),eC=["queued","blocked","running","waiting","completed","failed","cancelled"],eq=["completed","failed","cancelled"],ey={queued:["running","blocked","cancelled","failed"],blocked:["queued","cancelled","failed"],running:["waiting","queued","completed","failed","cancelled"],waiting:["running","queued","cancelled","failed"],completed:[],failed:[],cancelled:[]},eb=["dispatcher","ui_message","ui_continuation"];class eD extends Error{code;constructor(e,t){super(t),this.code=e}}let eU=eq.map(e=>`'${e}'`).join(", "),eF=eC.map(e=>`'${e}'`).join(", "),eW=[{version:1,name:"core_engine_tables",up:e=>{e.exec(`
38
+ `).all(...null===n?[t,t,t]:[t,n,t,n,t,n])}function el(e){return{kind:e.kind,attempt_number:e.attempt_number,turn_kind:e.turn_kind,provider:e.provider,source:e.source,input_tokens:e.input_tokens,output_tokens:e.output_tokens,cost_usd:e.cost_usd,observed_at:e.observed_at}}e.s(["aggregateUsage",0,e_,"normalizeUsage",0,eo,"usageFromEvent",0,function(e){let t=en(e);if(!t)return null;let n="string"==typeof t.type?t.type:null,i=en(t.usage);if("turn.completed"===n)return ea(i,null,"codex.turn_completed");if("result"===n)return ea(i,es(t,["total_cost_usd","totalCostUsd","cost_usd","costUsd"],er),"result");if(null===n||"usage"===n){let e=i??t,n=es(e,["cost_usd","costUsd","total_cost_usd","totalCostUsd"],er)??(i?es(t,["cost_usd","costUsd","total_cost_usd","totalCostUsd"],er):null);return ea(e,n,"normalized")}return null}],40596),e.s(["agentSessionUsage",0,function(e,t){let n=new Map;for(let i of ec(e,t,null)){let e=n.get(i.ref)??[];e.push(i),n.set(i.ref,e)}return new Map([...n].map(([e,t])=>[e,e_(t)]))},"emptyUsage",0,function(){return e_([])},"recordAttemptUsageSample",0,eu,"recordTurnUsageSample",0,function(e,t,n,i){eE(e,`turn:${t}`,{attemptId:null,sessionRef:n,turnId:t},i)},"sessionUsageSamples",0,function(e,t,n){let i=ec(e,t,n);return{usage:e_(i),samples:i.map(el)}}],28420);let eT=["queued","extracting","delivering","completed","failed","cancelled"],ep=["completed","failed","cancelled"],eN={queued:["extracting","failed","cancelled"],extracting:["delivering","completed","failed","cancelled"],delivering:["completed","failed","cancelled"],completed:[],failed:[],cancelled:[]},eR=Object.freeze({instructionChars:4e3,packetChars:16e3,packetObjectiveChars:2e3,packetListItems:20,packetItemChars:500,answerChars:16e3,replyChars:16e3,extractionOutputChars:32e3,promptChars:24e3}),em=["queued","blocked","running","waiting","completed","failed","cancelled"],eL=["completed","failed","cancelled"],eO={queued:["running","blocked","cancelled","failed"],blocked:["queued","cancelled","failed"],running:["waiting","queued","completed","failed","cancelled"],waiting:["running","queued","cancelled","failed"],completed:[],failed:[],cancelled:[]},eg=["dispatcher","ui_message","ui_continuation"];class eI extends Error{code;constructor(e,t){super(t),this.code=e}}let eA=eL.map(e=>`'${e}'`).join(", "),eS=em.map(e=>`'${e}'`).join(", "),ev=[{version:1,name:"core_engine_tables",up:e=>{e.exec(`
39
39
  CREATE TABLE work_request_transitions (
40
40
  from_state TEXT NOT NULL,
41
41
  to_state TEXT NOT NULL,
@@ -59,7 +59,7 @@ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",
59
59
  idempotency_key TEXT NOT NULL CHECK (length(idempotency_key) > 0),
60
60
  request_hash TEXT NOT NULL,
61
61
  policy_snapshot TEXT NOT NULL,
62
- state TEXT NOT NULL CHECK (state IN (${eF})),
62
+ state TEXT NOT NULL CHECK (state IN (${eS})),
63
63
  state_reason TEXT,
64
64
  result TEXT,
65
65
  error_code TEXT,
@@ -69,7 +69,7 @@ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",
69
69
  created_at INTEGER NOT NULL,
70
70
  updated_at INTEGER NOT NULL,
71
71
  terminal_at INTEGER,
72
- CHECK ((state IN (${eU})) = (terminal_at IS NOT NULL)),
72
+ CHECK ((state IN (${eA})) = (terminal_at IS NOT NULL)),
73
73
  FOREIGN KEY (source_conversation_id) REFERENCES conversations(id),
74
74
  FOREIGN KEY (target_agent_id) REFERENCES bots(id),
75
75
  FOREIGN KEY (parent_request_id) REFERENCES work_requests(id),
@@ -183,7 +183,7 @@ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",
183
183
  END;
184
184
 
185
185
  CREATE TRIGGER trg_work_requests_terminal BEFORE UPDATE ON work_requests
186
- WHEN OLD.state IN (${eU})
186
+ WHEN OLD.state IN (${eA})
187
187
  BEGIN
188
188
  SELECT RAISE(ABORT, 'terminal work_requests are immutable');
189
189
  END;
@@ -255,7 +255,7 @@ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",
255
255
  BEGIN
256
256
  SELECT RAISE(ABORT, 'engine_events are append-only');
257
257
  END;
258
- `);let t=e.prepare("INSERT INTO work_request_transitions (from_state, to_state) VALUES (?, ?)");for(let e of eC)for(let n of ey[e])t.run(e,n)}},{version:2,name:"core_engine_referential_integrity",up:e=>{e.exec(`
258
+ `);let t=e.prepare("INSERT INTO work_request_transitions (from_state, to_state) VALUES (?, ?)");for(let e of em)for(let n of eO[e])t.run(e,n)}},{version:2,name:"core_engine_referential_integrity",up:e=>{e.exec(`
259
259
  -- Foreign keys (delete side): RESTRICT. A referenced row cannot be
260
260
  -- deleted while anything still points at it; deleteEngineRecords
261
261
  -- removes dependants first, in one transaction.
@@ -341,7 +341,7 @@ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",
341
341
  AND (b.request_id IS NULL OR br.root_request_id = r.root_request_id)
342
342
  );
343
343
  END;
344
- `)}},{version:3,name:"core_engine_hardening",up:e=>{let t=eC.flatMap(e=>ey[e].map(t=>`'${e}>${t}'`)).join(", ");e.exec(`
344
+ `)}},{version:3,name:"core_engine_hardening",up:e=>{let t=em.flatMap(e=>eO[e].map(t=>`'${e}>${t}'`)).join(", ");e.exec(`
345
345
  -- The lifecycle allowlist lives in the trigger itself, so no data
346
346
  -- write can widen or break it. work_request_transitions stays as a
347
347
  -- readable copy and is locked against writes.
@@ -539,7 +539,7 @@ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",
539
539
  'request_waiting', 'request_completed', 'request_failed', 'request_cancelled',
540
540
  'question', 'result', 'artifact'
541
541
  )),
542
- state TEXT CHECK (state IN (${eF})),
542
+ state TEXT CHECK (state IN (${eS})),
543
543
  text TEXT NOT NULL,
544
544
  data TEXT NOT NULL,
545
545
  sort_at INTEGER NOT NULL,
@@ -752,7 +752,7 @@ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",
752
752
  'finalization_preparing', 'finalization_committed', 'finalization_blocked',
753
753
  'finalization_failed', 'finalization_canceled', 'finalization_rejected'
754
754
  )),
755
- state TEXT CHECK (state IN (${eF})),
755
+ state TEXT CHECK (state IN (${eS})),
756
756
  text TEXT NOT NULL,
757
757
  data TEXT NOT NULL,
758
758
  sort_at INTEGER NOT NULL,
@@ -897,7 +897,7 @@ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",
897
897
  'finalization_failed', 'finalization_canceled', 'finalization_rejected',
898
898
  'request_cancel_requested', 'request_timed_out', 'request_retry_scheduled', 'request_retries_exhausted'
899
899
  )),
900
- state TEXT CHECK (state IN (${eF})),
900
+ state TEXT CHECK (state IN (${eS})),
901
901
  text TEXT NOT NULL,
902
902
  data TEXT NOT NULL,
903
903
  sort_at INTEGER NOT NULL,
@@ -1018,7 +1018,7 @@ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",
1018
1018
  'request_cancel_requested', 'request_timed_out', 'request_retry_scheduled', 'request_retries_exhausted',
1019
1019
  'wake_rejected', 'lineage_stopped'
1020
1020
  )),
1021
- state TEXT CHECK (state IN (${eF})),
1021
+ state TEXT CHECK (state IN (${eS})),
1022
1022
  text TEXT NOT NULL,
1023
1023
  data TEXT NOT NULL,
1024
1024
  sort_at INTEGER NOT NULL,
@@ -1056,7 +1056,7 @@ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",
1056
1056
  ) VALUES (?, ?, 1, ?, ?, ?, ?, ?, ?, 'allowed', NULL, 'pre_safety_migration', NULL, ?, ?)
1057
1057
  `);for(let r of(e.exec("DROP TRIGGER trg_work_requests_terminal"),t)){let e=n.get(r.root_request_id),t=!!e&&a(r),o=t?_(r):0,u=t&&e?{kind:e.requester_kind,id:e.requester_id}:{kind:"unknown",id:"unknown"};if(d.run(o,u.kind,u.id,r.id),null===r.legacy_agent_request_id&&["queued","running","waiting"].includes(r.state)){let e=i(r),t="wake"===e.source?"agent_principal":"coordinator_continuation"===e.source?"engine":"api"===e.surface?"api_principal":"human_owner";E.run((0,s.randomUUID)(),r.id,r.wake_event_id,t,r.requester_kind,r.requester_id,r.target_agent_id,r.execution_kind,JSON.stringify({safety_version:1,migrated:!0,root_principal:u,wake_depth:o,grant_rule:"pre_safety_migration"}),r.created_at)}}e.exec(`
1058
1058
  CREATE TRIGGER trg_work_requests_terminal BEFORE UPDATE ON work_requests
1059
- WHEN OLD.state IN (${eU})
1059
+ WHEN OLD.state IN (${eA})
1060
1060
  BEGIN
1061
1061
  SELECT RAISE(ABORT, 'terminal work_requests are immutable');
1062
1062
  END;
@@ -1084,7 +1084,7 @@ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",
1084
1084
  idempotency_key, request_hash, policy_snapshot, state, state_reason, result, error_code, error_message,
1085
1085
  version, legacy_agent_request_id, created_at, updated_at, terminal_at, root_principal_kind, root_principal_id
1086
1086
  ) VALUES (?, ?, ?, ?, ?, ?, ?, 'conversation', 'readonly', NULL, ?, NULL, 0, ?, ?, ?, ?, ?, ?, ?, ?, 0, ?, ?, ?, ?, ?, ?)
1087
- `),_=e.prepare("INSERT INTO engine_events (id, request_id, sequence, attempt_id, type, data, created_at) VALUES (?, ?, ?, NULL, ?, ?, ?)"),d=Date.now();for(let e of i){if(r.get(e.principal_kind,e.principal_id,e.idempotency_key))continue;let t=(0,s.randomUUID)(),n=eB({sourceConversationId:e.conversation_id,sourceEventId:e.accepted_message_id,targetAgentId:e.target_bot_id,intent:e.content,executionKind:"conversation",toolProfile:"readonly"}),i="accepted"===e.state||"dispatched"===e.state,E=JSON.stringify({tool_profile:"readonly",source:"legacy_agent_requests",legacy_operation:e.operation,legacy_runtime:e.runtime,...i?{legacy_state:e.state}:{}}),u=i?Math.max(d,e.updated_at):e.updated_at;o.run(t,e.conversation_id,e.accepted_message_id,e.principal_kind,e.principal_id,e.target_bot_id,e.content,t,e.idempotency_key,n,E,i?"failed":e.state,i?eM:null,"completed"===e.state?JSON.stringify({reply_message_id:e.reply_message_id}):null,i?eM:"failed"===e.state?e.failure_code:null,i?eK:"failed"===e.state?e.failure_message:null,e.id,e.created_at,u,u,e.principal_kind,e.principal_id);let c=0;for(let n of a?.all(e.id)??[])_.run((0,s.randomUUID)(),t,++c,n.type,n.data,n.created_at);i&&_.run((0,s.randomUUID)(),t,++c,"state_changed",JSON.stringify({from:"accepted"===e.state?"queued":"running",to:"failed",reason:eM}),u),_.run((0,s.randomUUID)(),t,++c,"backfilled",JSON.stringify({legacy_agent_request_id:e.id}),u)}(function(e){let t=e.prepare(`
1087
+ `),_=e.prepare("INSERT INTO engine_events (id, request_id, sequence, attempt_id, type, data, created_at) VALUES (?, ?, ?, NULL, ?, ?, ?)"),d=Date.now();for(let e of i){if(r.get(e.principal_kind,e.principal_id,e.idempotency_key))continue;let t=(0,s.randomUUID)(),n=eC({sourceConversationId:e.conversation_id,sourceEventId:e.accepted_message_id,targetAgentId:e.target_bot_id,intent:e.content,executionKind:"conversation",toolProfile:"readonly"}),i="accepted"===e.state||"dispatched"===e.state,E=JSON.stringify({tool_profile:"readonly",source:"legacy_agent_requests",legacy_operation:e.operation,legacy_runtime:e.runtime,...i?{legacy_state:e.state}:{}}),u=i?Math.max(d,e.updated_at):e.updated_at;o.run(t,e.conversation_id,e.accepted_message_id,e.principal_kind,e.principal_id,e.target_bot_id,e.content,t,e.idempotency_key,n,E,i?"failed":e.state,i?eq:null,"completed"===e.state?JSON.stringify({reply_message_id:e.reply_message_id}):null,i?eq:"failed"===e.state?e.failure_code:null,i?ey:"failed"===e.state?e.failure_message:null,e.id,e.created_at,u,u,e.principal_kind,e.principal_id);let c=0;for(let n of a?.all(e.id)??[])_.run((0,s.randomUUID)(),t,++c,n.type,n.data,n.created_at);i&&_.run((0,s.randomUUID)(),t,++c,"state_changed",JSON.stringify({from:"accepted"===e.state?"queued":"running",to:"failed",reason:eq}),u),_.run((0,s.randomUUID)(),t,++c,"backfilled",JSON.stringify({legacy_agent_request_id:e.id}),u)}(function(e){let t=e.prepare(`
1088
1088
  SELECT w.id AS request_id, r.principal_kind, r.principal_id, r.idempotency_key, r.payload_hash,
1089
1089
  r.conversation_id, r.target_bot_id, r.accepted_message_id, r.created_at, m.content AS content
1090
1090
  FROM work_requests w
@@ -1100,7 +1100,7 @@ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",
1100
1100
  requester_kind, requester_id, idempotency_key, request_hash, surface,
1101
1101
  conversation_id, source_event_id, work_request_ids, created_at
1102
1102
  ) VALUES (?, ?, ?, ?, 'api', ?, ?, ?, ?)
1103
- `);for(let e of t){let t=[e.conversation_id,null].map(t=>[e.target_bot_id,t,e.content]).find(t=>eJ(JSON.stringify(t))===e.payload_hash);t&&n.run(e.principal_kind,e.principal_id,e.idempotency_key,eJ(JSON.stringify(["api",t])),e.conversation_id,e.accepted_message_id,JSON.stringify([e.request_id]),e.created_at)}})(e),t("legacy_agent_requests_archive")?e.exec("INSERT INTO legacy_agent_requests_archive SELECT * FROM agent_requests; DROP TABLE agent_requests;"):e.exec("ALTER TABLE agent_requests RENAME TO legacy_agent_requests_archive"),n&&(t("legacy_agent_request_events_archive")?e.exec("INSERT INTO legacy_agent_request_events_archive SELECT * FROM agent_request_events; DROP TABLE agent_request_events;"):e.exec("ALTER TABLE agent_request_events RENAME TO legacy_agent_request_events_archive"))}(e)}},{version:15,name:"ui_turns_on_work_requests",up:e=>{e.exec(`
1103
+ `);for(let e of t){let t=[e.conversation_id,null].map(t=>[e.target_bot_id,t,e.content]).find(t=>eX(JSON.stringify(t))===e.payload_hash);t&&n.run(e.principal_kind,e.principal_id,e.idempotency_key,eX(JSON.stringify(["api",t])),e.conversation_id,e.accepted_message_id,JSON.stringify([e.request_id]),e.created_at)}})(e),t("legacy_agent_requests_archive")?e.exec("INSERT INTO legacy_agent_requests_archive SELECT * FROM agent_requests; DROP TABLE agent_requests;"):e.exec("ALTER TABLE agent_requests RENAME TO legacy_agent_requests_archive"),n&&(t("legacy_agent_request_events_archive")?e.exec("INSERT INTO legacy_agent_request_events_archive SELECT * FROM agent_request_events; DROP TABLE agent_request_events;"):e.exec("ALTER TABLE agent_request_events RENAME TO legacy_agent_request_events_archive"))}(e)}},{version:15,name:"ui_turns_on_work_requests",up:e=>{e.exec(`
1104
1104
  ALTER TABLE work_requests ADD COLUMN executor TEXT NOT NULL DEFAULT 'dispatcher'
1105
1105
  CHECK (executor IN ('dispatcher', 'ui_message', 'ui_continuation'));
1106
1106
  CREATE INDEX idx_work_requests_executor ON work_requests(executor, state, created_at);
@@ -1142,7 +1142,7 @@ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",
1142
1142
  idempotency_key, request_hash, policy_snapshot, state, version, created_at, updated_at,
1143
1143
  wake_depth, root_principal_kind, root_principal_id, executor
1144
1144
  ) VALUES (?, ?, ?, ?, ?, ?, ?, 'conversation', 'readonly', NULL, ?, NULL, 0, ?, ?, ?, 'queued', 0, ?, ?, 0, ?, ?, 'ui_continuation')
1145
- `),u=eP(!1),c=0;for(let t of i){if(t.work_request_id){let n=r.get(t.work_request_id);if(!n||"queued"!==n.state)continue;let i=t.started_at??t.created_at,s=Math.max(t.completed_at??i,i);if("pending"===t.status)e.prepare("UPDATE work_requests SET executor = 'ui_message' WHERE id = ?").run(n.id);else if("completed"===t.status||"failed"===t.status)a.run("running",null,i,null,null,null,n.id),_(n.id,"state_changed",{from:"queued",to:"running",reason:null,legacy_queue_id:t.id},i),a.run(t.status,"legacy_queue_turn",s,"failed"===t.status?"ui_turn_failed":null,"failed"===t.status?"The UI turn failed in the retired processing queue.":null,s,n.id),_(n.id,"state_changed",{from:"running",to:t.status,reason:"legacy_queue_turn",legacy_queue_id:t.id},s);else{let e=Math.max(Date.now(),i);a.run("running",null,i,null,null,null,n.id),_(n.id,"state_changed",{from:"queued",to:"running",reason:null,legacy_queue_id:t.id},i),a.run("failed",e$,e,e$,ez,e,n.id),_(n.id,"state_changed",{from:"running",to:"failed",reason:e$,error_code:e$,legacy_queue_id:t.id},e)}c++;continue}if("pending"!==t.status)continue;let n=(0,s.randomUUID)(),i=d.get(t.conversation_id,t.created_at)?.id??t.conversation_id,o={source:"legacy_processing_queue",legacy_queue_id:t.id},l=eB({sourceConversationId:t.conversation_id,sourceEventId:i,targetAgentId:t.bot_id,intent:"turn",executionKind:"conversation",toolProfile:"readonly",policy:{...o,execution_policy:u}});E.run(n,t.conversation_id,i,eY.kind,eY.id,t.bot_id,"turn",n,`legacy-queue:${t.id}`,l,JSON.stringify({...o,execution_policy:u,tool_profile:"readonly"}),t.created_at,t.created_at,eY.kind,eY.id),_(n,"accepted",{state:"queued",execution_kind:"conversation",tool_profile:"readonly"},t.created_at),_(n,"backfilled",{legacy_queue_id:t.id},t.created_at),c++}c+=e.prepare(`
1145
+ `),u=eU(!1),c=0;for(let t of i){if(t.work_request_id){let n=r.get(t.work_request_id);if(!n||"queued"!==n.state)continue;let i=t.started_at??t.created_at,s=Math.max(t.completed_at??i,i);if("pending"===t.status)e.prepare("UPDATE work_requests SET executor = 'ui_message' WHERE id = ?").run(n.id);else if("completed"===t.status||"failed"===t.status)a.run("running",null,i,null,null,null,n.id),_(n.id,"state_changed",{from:"queued",to:"running",reason:null,legacy_queue_id:t.id},i),a.run(t.status,"legacy_queue_turn",s,"failed"===t.status?"ui_turn_failed":null,"failed"===t.status?"The UI turn failed in the retired processing queue.":null,s,n.id),_(n.id,"state_changed",{from:"running",to:t.status,reason:"legacy_queue_turn",legacy_queue_id:t.id},s);else{let e=Math.max(Date.now(),i);a.run("running",null,i,null,null,null,n.id),_(n.id,"state_changed",{from:"queued",to:"running",reason:null,legacy_queue_id:t.id},i),a.run("failed",eD,e,eD,eF,e,n.id),_(n.id,"state_changed",{from:"running",to:"failed",reason:eD,error_code:eD,legacy_queue_id:t.id},e)}c++;continue}if("pending"!==t.status)continue;let n=(0,s.randomUUID)(),i=d.get(t.conversation_id,t.created_at)?.id??t.conversation_id,o={source:"legacy_processing_queue",legacy_queue_id:t.id},l=eC({sourceConversationId:t.conversation_id,sourceEventId:i,targetAgentId:t.bot_id,intent:"turn",executionKind:"conversation",toolProfile:"readonly",policy:{...o,execution_policy:u}});E.run(n,t.conversation_id,i,eb.kind,eb.id,t.bot_id,"turn",n,`legacy-queue:${t.id}`,l,JSON.stringify({...o,execution_policy:u,tool_profile:"readonly"}),t.created_at,t.created_at,eb.kind,eb.id),_(n,"accepted",{state:"queued",execution_kind:"conversation",tool_profile:"readonly"},t.created_at),_(n,"backfilled",{legacy_queue_id:t.id},t.created_at),c++}c+=e.prepare(`
1146
1146
  UPDATE work_requests SET executor = 'ui_message'
1147
1147
  WHERE state = 'queued' AND executor = 'dispatcher' AND legacy_agent_request_id IS NULL
1148
1148
  AND parent_request_id IS NULL AND wake_event_id IS NULL
@@ -1153,7 +1153,7 @@ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",
1153
1153
  WHERE i.surface = 'ui' AND r.value = work_requests.id
1154
1154
  )
1155
1155
  )
1156
- `).run().changes,t("legacy_processing_queue_archive")?e.exec("INSERT INTO legacy_processing_queue_archive SELECT * FROM processing_queue; DROP TABLE processing_queue;"):e.exec("ALTER TABLE processing_queue RENAME TO legacy_processing_queue_archive")}(e)}},{version:16,name:"session_exchanges",up:e=>{let t=ef.flatMap(e=>eh[e].map(t=>`'${e}>${t}'`)).join(", "),n=ef.map(e=>`'${e}'`).join(", "),i=ev.map(e=>`'${e}'`).join(", ");e.exec(`
1156
+ `).run().changes,t("legacy_processing_queue_archive")?e.exec("INSERT INTO legacy_processing_queue_archive SELECT * FROM processing_queue; DROP TABLE processing_queue;"):e.exec("ALTER TABLE processing_queue RENAME TO legacy_processing_queue_archive")}(e)}},{version:16,name:"session_exchanges",up:e=>{let t=eT.flatMap(e=>eN[e].map(t=>`'${e}>${t}'`)).join(", "),n=eT.map(e=>`'${e}'`).join(", "),i=ep.map(e=>`'${e}'`).join(", ");e.exec(`
1157
1157
  -- One row per owner-requested exchange against one selected Session
1158
1158
  -- Binding. It names Botmancers rows only (binding, Work Requests,
1159
1159
  -- Attempts, messages): never a provider session id or credential.
@@ -1172,14 +1172,14 @@ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",
1172
1172
  destination_agent_id TEXT,
1173
1173
  destination_conversation_id TEXT,
1174
1174
  destination_binding_id TEXT,
1175
- instruction TEXT NOT NULL CHECK (length(instruction) BETWEEN 1 AND ${ew.instructionChars}),
1175
+ instruction TEXT NOT NULL CHECK (length(instruction) BETWEEN 1 AND ${eR.instructionChars}),
1176
1176
  state TEXT NOT NULL CHECK (state IN (${n})),
1177
1177
  source_request_id TEXT,
1178
1178
  source_attempt_id TEXT,
1179
1179
  destination_request_id TEXT,
1180
1180
  destination_attempt_id TEXT,
1181
1181
  answer_message_id TEXT,
1182
- packet TEXT CHECK (packet IS NULL OR length(packet) <= ${ew.packetChars}),
1182
+ packet TEXT CHECK (packet IS NULL OR length(packet) <= ${eR.packetChars}),
1183
1183
  failure_code TEXT,
1184
1184
  failure_message TEXT,
1185
1185
  cancel_requested_at INTEGER,
@@ -1471,7 +1471,7 @@ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",
1471
1471
  id, agent_id, runtime_connection_id, provider_kind, provider_session_id, binding_id, origin,
1472
1472
  availability, lifecycle, resumable, busy, created_at, updated_at
1473
1473
  )
1474
- SELECT b.id, b.agent_id, ${eX(t)}, b.adapter, b.external_session_id, b.id, 'binding',
1474
+ SELECT b.id, b.agent_id, ${ek(t)}, b.adapter, b.external_session_id, b.id, 'binding',
1475
1475
  'available', 'open', NULL, 0, b.created_at, COALESCE(b.released_at, b.created_at)
1476
1476
  FROM session_bindings b
1477
1477
  JOIN bots bot ON bot.id = b.agent_id
@@ -1590,42 +1590,42 @@ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",
1590
1590
  BEGIN
1591
1591
  SELECT RAISE(ABORT, 'session_pin_events are append-only');
1592
1592
  END;
1593
- `)}}];function eX(e){return e.prepare("PRAGMA table_info(bots)").all().some(e=>"runtime_connection_id"===e.name)?"COALESCE(bot.runtime_connection_id, 'rc-local-' || b.adapter)":"'rc-local-' || b.adapter"}let ex=new WeakMap;function eG(e){let t=ex.get(e);if(!t){t=new Set,ex.set(e,t);let n=t;e.function("engine_event_purge_authorized",{deterministic:!1},e=>"string"==typeof e&&n.has(e)?1:0)}return t}function eH(e,t={}){eG(e),e.exec(`
1593
+ `)}}];function ek(e){return e.prepare("PRAGMA table_info(bots)").all().some(e=>"runtime_connection_id"===e.name)?"COALESCE(bot.runtime_connection_id, 'rc-local-' || b.adapter)":"'rc-local-' || b.adapter"}let ef=new WeakMap;function eh(e){let t=ef.get(e);if(!t){t=new Set,ef.set(e,t);let n=t;e.function("engine_event_purge_authorized",{deterministic:!1},e=>"string"==typeof e&&n.has(e)?1:0)}return t}function ew(e,t={}){eh(e),e.exec(`
1594
1594
  CREATE TABLE IF NOT EXISTS schema_migrations (
1595
1595
  version INTEGER PRIMARY KEY,
1596
1596
  name TEXT NOT NULL,
1597
1597
  applied_at INTEGER NOT NULL
1598
1598
  );
1599
- `);let n=e.prepare("SELECT 1 FROM schema_migrations WHERE version = ?"),i=e.prepare("INSERT INTO schema_migrations (version, name, applied_at) VALUES (?, ?, ?)");for(let r of eW){if(void 0!==t.through&&r.version>t.through)return;e.transaction(()=>{n.get(r.version)||(r.up(e),i.run(r.version,r.name,Date.now()))}).immediate()}}function eB(e){return eJ(JSON.stringify([e.sourceConversationId,e.sourceEventId,e.targetAgentId,e.intent,e.executionKind,e.toolProfile,e.parentRequestId??null,e.wakeEventId??null,e.policy??null]))}eW[eW.length-1].version;let eM="legacy_interrupted",eK="Accepted before NOT-465 by the retired agent_requests dispatcher; it never reached a terminal state.",eY=Object.freeze({kind:"service",id:"botmancers-ui-turns"});function eP(e){let t=en(e?{entryPoint:"wake",executionKind:"conversation",wakeSyntax:"legacy"}:{entryPoint:"ui",executionKind:"conversation"});if(!t.ok)throw new eD("invalid_input",t.reason);return t.policy}let e$="ui_turn_interrupted",ez="The UI turn was interrupted before it finished; it is not run again.";function ej(e){return"string"==typeof e&&e.trim().length>0}function eJ(e){return(0,s.createHash)("sha256").update(e).digest("hex")}function eQ(e){return null==e?null:JSON.stringify(e)}function eV(e){eG(e);let t=e.prepare("SELECT * FROM work_requests WHERE id = ?"),n=e.prepare("SELECT * FROM work_requests WHERE requester_kind = ? AND requester_id = ? AND idempotency_key = ?"),i=e.prepare("SELECT * FROM work_attempts WHERE id = ?"),r=e.prepare(`
1599
+ `);let n=e.prepare("SELECT 1 FROM schema_migrations WHERE version = ?"),i=e.prepare("INSERT INTO schema_migrations (version, name, applied_at) VALUES (?, ?, ?)");for(let r of ev){if(void 0!==t.through&&r.version>t.through)return;e.transaction(()=>{n.get(r.version)||(r.up(e),i.run(r.version,r.name,Date.now()))}).immediate()}}function eC(e){return eX(JSON.stringify([e.sourceConversationId,e.sourceEventId,e.targetAgentId,e.intent,e.executionKind,e.toolProfile,e.parentRequestId??null,e.wakeEventId??null,e.policy??null]))}ev[ev.length-1].version;let eq="legacy_interrupted",ey="Accepted before NOT-465 by the retired agent_requests dispatcher; it never reached a terminal state.",eb=Object.freeze({kind:"service",id:"botmancers-ui-turns"});function eU(e){let t=P(e?{entryPoint:"wake",executionKind:"conversation",wakeSyntax:"legacy"}:{entryPoint:"ui",executionKind:"conversation"});if(!t.ok)throw new eI("invalid_input",t.reason);return t.policy}let eD="ui_turn_interrupted",eF="The UI turn was interrupted before it finished; it is not run again.";function eW(e){return"string"==typeof e&&e.trim().length>0}function eX(e){return(0,s.createHash)("sha256").update(e).digest("hex")}function ex(e){return null==e?null:JSON.stringify(e)}function eG(e){eh(e);let t=e.prepare("SELECT * FROM work_requests WHERE id = ?"),n=e.prepare("SELECT * FROM work_requests WHERE requester_kind = ? AND requester_id = ? AND idempotency_key = ?"),i=e.prepare("SELECT * FROM work_attempts WHERE id = ?"),r=e.prepare(`
1600
1600
  INSERT INTO engine_events (id, request_id, sequence, attempt_id, type, data, created_at)
1601
1601
  SELECT ?, ?, COALESCE(MAX(sequence), 0) + 1, ?, ?, ?, ? FROM engine_events WHERE request_id = ?
1602
- `),a=e.prepare("SELECT * FROM engine_events WHERE id = ?"),o=e.prepare("SELECT * FROM session_bindings WHERE id = ?");function _(e){let n=t.get(e);if(!n)throw new eD("not_found",`No work request ${e}.`);return n}function d(e){let t=i.get(e);if(!t)throw new eD("not_found",`No attempt ${e}.`);return t}function E(e,t,n,i,o){let _=(0,s.randomUUID)();return r.run(_,e,i,t,eQ(n),o,e),a.get(_)}let u={transaction:t=>e.transaction(t).immediate(),createOrGetWorkRequest(i){if(!ej(i.sourceConversationId))throw new eD("invalid_input","sourceConversationId is required.");if(!ej(i.sourceEventId))throw new eD("invalid_input","sourceEventId is required.");if(!i.requester||!["person","bot","service"].includes(i.requester.kind)||!ej(i.requester.id))throw new eD("invalid_input","A requester principal is required.");if(!ej(i.targetAgentId))throw new eD("invalid_input","targetAgentId is required.");if("string"!=typeof i.intent)throw new eD("invalid_input","intent is required.");if(!ee(i.executionKind))throw new eD("invalid_input","Unknown execution kind.");if(Z[i.executionKind]!==i.toolProfile)throw new eD("invalid_input",`Execution kind ${i.executionKind} requires the ${Z[i.executionKind]} tool profile.`);if(i.policy&&Object.prototype.hasOwnProperty.call(i.policy,"execution_policy"))throw new eD("invalid_input","The execution policy is passed as executionPolicy, never inside policy.");if(void 0!==i.executionPolicy){let e=er(i.executionPolicy);if(!e.ok)throw new eD("invalid_input",e.reason);if(e.policy.execution_kind!==i.executionKind||e.policy.tool_profile!==i.toolProfile)throw new eD("invalid_input","The execution policy does not match the requested execution kind and tool profile.")}if(!ej(i.idempotencyKey))throw new eD("invalid_input","idempotencyKey is required.");if(void 0!==i.executor&&!eb.includes(i.executor))throw new eD("invalid_input","Unknown request executor.");if(i.initialState&&"queued"!==i.initialState&&"blocked"!==i.initialState)throw new eD("invalid_input","A work request starts queued or blocked.");if(void 0!==i.deadlineAt&&null!==i.deadlineAt&&!Number.isSafeInteger(i.deadlineAt))throw new eD("invalid_input","deadlineAt must be an epoch millisecond integer.");if(void 0!==i.retryPolicy){let e=e_(i.retryPolicy);if(!e.ok)throw new eD("invalid_input",e.reason)}let r=i.executionPolicy?{...i.policy??{},execution_policy:i.executionPolicy}:i.policy,a=eB({...i,policy:r});return e.transaction(()=>{let o=n.get(i.requester.kind,i.requester.id,i.idempotencyKey);if(o){if(o.request_hash!==a)throw new eD("idempotency_conflict","The idempotency key was already used with a different request.");return{request:o,created:!1}}let d=i.now??Date.now(),c=(0,s.randomUUID)(),l=c,T=0,p=0,N=i.rootPrincipal??i.requester;if(i.parentRequestId){let e=t.get(i.parentRequestId);if(!e)throw new eD("not_found","Parent work request not found.");l=e.root_request_id,T=e.depth+1,p=i.wakeEventId?e.wake_depth+1:e.wake_depth,N={kind:e.root_principal_kind??"unknown",id:e.root_principal_id??"unknown"}}void 0!==i.wakeDepth&&(p=i.wakeDepth);let R=i.initialState??"queued",m=JSON.stringify({...r??{},...i.safetySnapshot??{},tool_profile:i.toolProfile}),L=eo(),g=i.retryPolicy??L.retryPolicy,O=void 0!==i.deadlineAt?i.deadlineAt:null===L.deadlineMs?null:d+L.deadlineMs;return e.prepare(`
1602
+ `),a=e.prepare("SELECT * FROM engine_events WHERE id = ?"),o=e.prepare("SELECT * FROM session_bindings WHERE id = ?");function _(e){let n=t.get(e);if(!n)throw new eI("not_found",`No work request ${e}.`);return n}function d(e){let t=i.get(e);if(!t)throw new eI("not_found",`No attempt ${e}.`);return t}function E(e,t,n,i,o){let _=(0,s.randomUUID)();return r.run(_,e,i,t,ex(n),o,e),a.get(_)}let u={transaction:t=>e.transaction(t).immediate(),createOrGetWorkRequest(i){if(!eW(i.sourceConversationId))throw new eI("invalid_input","sourceConversationId is required.");if(!eW(i.sourceEventId))throw new eI("invalid_input","sourceEventId is required.");if(!i.requester||!["person","bot","service"].includes(i.requester.kind)||!eW(i.requester.id))throw new eI("invalid_input","A requester principal is required.");if(!eW(i.targetAgentId))throw new eI("invalid_input","targetAgentId is required.");if("string"!=typeof i.intent)throw new eI("invalid_input","intent is required.");if(!K(i.executionKind))throw new eI("invalid_input","Unknown execution kind.");if(M[i.executionKind]!==i.toolProfile)throw new eI("invalid_input",`Execution kind ${i.executionKind} requires the ${M[i.executionKind]} tool profile.`);if(i.policy&&Object.prototype.hasOwnProperty.call(i.policy,"execution_policy"))throw new eI("invalid_input","The execution policy is passed as executionPolicy, never inside policy.");if(void 0!==i.executionPolicy){let e=z(i.executionPolicy);if(!e.ok)throw new eI("invalid_input",e.reason);if(e.policy.execution_kind!==i.executionKind||e.policy.tool_profile!==i.toolProfile)throw new eI("invalid_input","The execution policy does not match the requested execution kind and tool profile.")}if(!eW(i.idempotencyKey))throw new eI("invalid_input","idempotencyKey is required.");if(void 0!==i.executor&&!eg.includes(i.executor))throw new eI("invalid_input","Unknown request executor.");if(i.initialState&&"queued"!==i.initialState&&"blocked"!==i.initialState)throw new eI("invalid_input","A work request starts queued or blocked.");if(void 0!==i.deadlineAt&&null!==i.deadlineAt&&!Number.isSafeInteger(i.deadlineAt))throw new eI("invalid_input","deadlineAt must be an epoch millisecond integer.");if(void 0!==i.retryPolicy){let e=V(i.retryPolicy);if(!e.ok)throw new eI("invalid_input",e.reason)}let r=i.executionPolicy?{...i.policy??{},execution_policy:i.executionPolicy}:i.policy,a=eC({...i,policy:r});return e.transaction(()=>{let o=n.get(i.requester.kind,i.requester.id,i.idempotencyKey);if(o){if(o.request_hash!==a)throw new eI("idempotency_conflict","The idempotency key was already used with a different request.");return{request:o,created:!1}}let d=i.now??Date.now(),c=(0,s.randomUUID)(),l=c,T=0,p=0,N=i.rootPrincipal??i.requester;if(i.parentRequestId){let e=t.get(i.parentRequestId);if(!e)throw new eI("not_found","Parent work request not found.");l=e.root_request_id,T=e.depth+1,p=i.wakeEventId?e.wake_depth+1:e.wake_depth,N={kind:e.root_principal_kind??"unknown",id:e.root_principal_id??"unknown"}}void 0!==i.wakeDepth&&(p=i.wakeDepth);let R=i.initialState??"queued",m=JSON.stringify({...r??{},...i.safetySnapshot??{},tool_profile:i.toolProfile}),L=Q(),O=i.retryPolicy??L.retryPolicy,g=void 0!==i.deadlineAt?i.deadlineAt:null===L.deadlineMs?null:d+L.deadlineMs;return e.prepare(`
1603
1603
  INSERT INTO work_requests (
1604
1604
  id, source_conversation_id, source_event_id, requester_kind, requester_id, target_agent_id,
1605
1605
  intent, execution_kind, tool_profile, parent_request_id, root_request_id, wake_event_id, depth,
1606
1606
  idempotency_key, request_hash, policy_snapshot, state, state_reason, version, created_at, updated_at,
1607
1607
  deadline_at, retry_policy, wake_depth, root_principal_kind, root_principal_id, executor
1608
1608
  ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, ?, ?, ?, ?, ?, ?, ?, ?)
1609
- `).run(c,i.sourceConversationId,i.sourceEventId,i.requester.kind,i.requester.id,i.targetAgentId,i.intent,i.executionKind,i.toolProfile,i.parentRequestId??null,l,i.wakeEventId??null,T,i.idempotencyKey,a,m,R,i.stateReason??null,d,d,O,JSON.stringify(g),p,N.kind,N.id,i.executor??"dispatcher"),E(c,"accepted",{state:R,execution_kind:i.executionKind,tool_profile:i.toolProfile,deadline_at:O,retry_policy:g},null,d),i.executionPolicy&&E(c,"policy_selected",{...i.executionPolicy},null,d),"blocked"===R&&E(c,"state_changed",{from:"queued",to:"blocked",reason:i.stateReason??null},null,d),i.safety&&u.recordSafetyDecision(c,{...i.safety,now:i.safety.now??d}),{request:_(c),created:!0}}).immediate()},getWorkRequest:e=>t.get(e),recordSafetyDecision(t,n){if(!["human_owner","api_principal","agent_principal","engine"].includes(n.principalType))throw new eD("invalid_input","A categorized principal is required.");if(!ej(n.principal?.kind)||!ej(n.principal?.id))throw new eD("invalid_input","A principal is required.");if(!["allowed","blocked","denied"].includes(n.decision))throw new eD("invalid_input","Unknown safety decision.");if("allowed"===n.decision&&!ej(n.grantRule))throw new eD("invalid_input","An allowed decision names its grant rule.");return e.transaction(()=>{let i=_(t),r=(0,s.randomUUID)();return e.prepare(`
1609
+ `).run(c,i.sourceConversationId,i.sourceEventId,i.requester.kind,i.requester.id,i.targetAgentId,i.intent,i.executionKind,i.toolProfile,i.parentRequestId??null,l,i.wakeEventId??null,T,i.idempotencyKey,a,m,R,i.stateReason??null,d,d,g,JSON.stringify(O),p,N.kind,N.id,i.executor??"dispatcher"),E(c,"accepted",{state:R,execution_kind:i.executionKind,tool_profile:i.toolProfile,deadline_at:g,retry_policy:O},null,d),i.executionPolicy&&E(c,"policy_selected",{...i.executionPolicy},null,d),"blocked"===R&&E(c,"state_changed",{from:"queued",to:"blocked",reason:i.stateReason??null},null,d),i.safety&&u.recordSafetyDecision(c,{...i.safety,now:i.safety.now??d}),{request:_(c),created:!0}}).immediate()},getWorkRequest:e=>t.get(e),recordSafetyDecision(t,n){if(!["human_owner","api_principal","agent_principal","engine"].includes(n.principalType))throw new eI("invalid_input","A categorized principal is required.");if(!eW(n.principal?.kind)||!eW(n.principal?.id))throw new eI("invalid_input","A principal is required.");if(!["allowed","blocked","denied"].includes(n.decision))throw new eI("invalid_input","Unknown safety decision.");if("allowed"===n.decision&&!eW(n.grantRule))throw new eI("invalid_input","An allowed decision names its grant rule.");return e.transaction(()=>{let i=_(t),r=(0,s.randomUUID)();return e.prepare(`
1610
1610
  INSERT INTO wake_safety_decisions (
1611
1611
  id, request_id, sequence, wake_id, principal_type, principal_kind, principal_id, target_agent_id, execution_kind,
1612
1612
  decision, reason_code, grant_rule, grant_id, policy_snapshot, created_at
1613
1613
  ) SELECT ?, ?, COALESCE(MAX(sequence), 0) + 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? FROM wake_safety_decisions WHERE request_id = ?
1614
- `).run(r,t,n.wakeId??null,n.principalType,n.principal.kind,n.principal.id,i.target_agent_id,i.execution_kind,n.decision,n.reasonCode??null,n.grantRule??null,n.grantId??null,JSON.stringify(n.snapshot),n.now??Date.now(),t),e.prepare("SELECT * FROM wake_safety_decisions WHERE id = ?").get(r)}).immediate()},listSafetyDecisions:t=>e.prepare("SELECT * FROM wake_safety_decisions WHERE request_id = ? ORDER BY sequence ASC").all(t),latestSafetyDecision:t=>e.prepare("SELECT * FROM wake_safety_decisions WHERE request_id = ? ORDER BY sequence DESC LIMIT 1").get(t),transitionWorkRequest(t,n){if(!ey[n.from]?.includes(n.to))throw new eD("invalid_transition",`Cannot move a work request from ${n.from} to ${n.to}.`);let i=eq.includes(n.to);return e.transaction(()=>{let r=_(t),s=n.now??Date.now();if(1!==e.prepare(`
1614
+ `).run(r,t,n.wakeId??null,n.principalType,n.principal.kind,n.principal.id,i.target_agent_id,i.execution_kind,n.decision,n.reasonCode??null,n.grantRule??null,n.grantId??null,JSON.stringify(n.snapshot),n.now??Date.now(),t),e.prepare("SELECT * FROM wake_safety_decisions WHERE id = ?").get(r)}).immediate()},listSafetyDecisions:t=>e.prepare("SELECT * FROM wake_safety_decisions WHERE request_id = ? ORDER BY sequence ASC").all(t),latestSafetyDecision:t=>e.prepare("SELECT * FROM wake_safety_decisions WHERE request_id = ? ORDER BY sequence DESC LIMIT 1").get(t),transitionWorkRequest(t,n){if(!eO[n.from]?.includes(n.to))throw new eI("invalid_transition",`Cannot move a work request from ${n.from} to ${n.to}.`);let i=eL.includes(n.to);return e.transaction(()=>{let r=_(t),s=n.now??Date.now();if(1!==e.prepare(`
1615
1615
  UPDATE work_requests SET
1616
1616
  state = ?, state_reason = ?, version = version + 1, updated_at = ?,
1617
1617
  result = ?, error_code = ?, error_message = ?, terminal_at = ?
1618
1618
  WHERE id = ? AND state = ? AND (? IS NULL OR version = ?)
1619
- `).run(n.to,n.reason??null,s,i?eQ(n.result):null,i?n.errorCode??null:null,i?n.errorMessage??null:null,i?s:null,t,n.from,n.expectedVersion??null,n.expectedVersion??null).changes)throw new eD("stale_state",`Work request ${t} is ${r.state} at version ${r.version}, not ${n.from}${void 0===n.expectedVersion?"":` at version ${n.expectedVersion}`}.`);return E(t,"state_changed",{...n.data??{},from:n.from,to:n.to,reason:n.reason??null,...n.errorCode?{error_code:n.errorCode}:{}},null,s),i&&null===r.legacy_agent_request_id&&"dispatcher"===r.executor&&e.prepare("INSERT OR IGNORE INTO terminal_followups (request_id, created_at) VALUES (?, ?)").run(t,s),_(t)}).immediate()},reblockWorkRequest:(t,n)=>e.transaction(()=>{let i=n.now??Date.now();if(1!==e.prepare("UPDATE work_requests SET state_reason = ?, version = version + 1, updated_at = ? WHERE id = ? AND state = 'blocked'").run(n.reason,i,t).changes)throw new eD("stale_state",`Work request ${t} is not blocked.`);return E(t,n.type,n.data??{},null,i),_(t)}).immediate(),appendEvent(t,n){if(!ej(n.type))throw new eD("invalid_input","Event type is required.");return e.transaction(()=>{if(_(t),n.attemptId&&d(n.attemptId).request_id!==t)throw new eD("invalid_input","The attempt belongs to another request.");return E(t,n.type,n.data,n.attemptId??null,n.now??Date.now())}).immediate()},listEvents:t=>e.prepare("SELECT * FROM engine_events WHERE request_id = ? ORDER BY sequence ASC").all(t),createAttempt(t,n){if("launch"!==n.kind&&"resume"!==n.kind)throw new eD("invalid_input","Unknown attempt kind.");if(!ej(n.adapter))throw new eD("invalid_input","adapter is required.");if("resume"===n.kind&&!n.resumedSessionBindingId)throw new eD("invalid_input","A resume attempt names the session binding it resumes.");if("launch"===n.kind&&n.resumedSessionBindingId)throw new eD("invalid_input","A launch attempt does not resume a session binding.");let i="string"==typeof n.launchSnapshot?n.launchSnapshot:JSON.stringify(n.launchSnapshot);if("string"!=typeof i||0===i.length)throw new eD("invalid_input","A launch snapshot is required.");return e.transaction(()=>{let r=_(t);if("running"!==r.state)throw new eD("attempt_conflict",`Attempts start only on running requests (request is ${r.state}).`);if(n.toolProfile!==r.tool_profile)throw new eD("invalid_input",`The attempt tool profile must be ${r.tool_profile}.`);if(e.prepare("SELECT id FROM work_attempts WHERE request_id = ? AND finished_at IS NULL").get(t))throw new eD("attempt_conflict","The request already has an open attempt.");if(n.resumedSessionBindingId){let e=o.get(n.resumedSessionBindingId);if(!e)throw new eD("not_found","Session binding not found.");if(null!==e.released_at)throw new eD("session_mismatch","The session binding was released.");if(e.agent_id!==r.target_agent_id||e.adapter!==n.adapter)throw new eD("session_mismatch","The session binding belongs to another Agent or adapter.");if(null!==e.conversation_id&&e.conversation_id!==r.source_conversation_id)throw new eD("session_mismatch","The session binding belongs to another conversation.");if(null!==e.request_id&&_(e.request_id).root_request_id!==r.root_request_id)throw new eD("session_mismatch","The session binding belongs to an unrelated work request.")}let a=n.now??Date.now(),u=(0,s.randomUUID)(),c=e.prepare("SELECT COALESCE(MAX(attempt_number), 0) + 1 AS n FROM work_attempts WHERE request_id = ?").get(t);return e.prepare(`
1619
+ `).run(n.to,n.reason??null,s,i?ex(n.result):null,i?n.errorCode??null:null,i?n.errorMessage??null:null,i?s:null,t,n.from,n.expectedVersion??null,n.expectedVersion??null).changes)throw new eI("stale_state",`Work request ${t} is ${r.state} at version ${r.version}, not ${n.from}${void 0===n.expectedVersion?"":` at version ${n.expectedVersion}`}.`);return E(t,"state_changed",{...n.data??{},from:n.from,to:n.to,reason:n.reason??null,...n.errorCode?{error_code:n.errorCode}:{}},null,s),i&&null===r.legacy_agent_request_id&&"dispatcher"===r.executor&&e.prepare("INSERT OR IGNORE INTO terminal_followups (request_id, created_at) VALUES (?, ?)").run(t,s),_(t)}).immediate()},reblockWorkRequest:(t,n)=>e.transaction(()=>{let i=n.now??Date.now();if(1!==e.prepare("UPDATE work_requests SET state_reason = ?, version = version + 1, updated_at = ? WHERE id = ? AND state = 'blocked'").run(n.reason,i,t).changes)throw new eI("stale_state",`Work request ${t} is not blocked.`);return E(t,n.type,n.data??{},null,i),_(t)}).immediate(),appendEvent(t,n){if(!eW(n.type))throw new eI("invalid_input","Event type is required.");return e.transaction(()=>{if(_(t),n.attemptId&&d(n.attemptId).request_id!==t)throw new eI("invalid_input","The attempt belongs to another request.");return E(t,n.type,n.data,n.attemptId??null,n.now??Date.now())}).immediate()},listEvents:t=>e.prepare("SELECT * FROM engine_events WHERE request_id = ? ORDER BY sequence ASC").all(t),createAttempt(t,n){if("launch"!==n.kind&&"resume"!==n.kind)throw new eI("invalid_input","Unknown attempt kind.");if(!eW(n.adapter))throw new eI("invalid_input","adapter is required.");if("resume"===n.kind&&!n.resumedSessionBindingId)throw new eI("invalid_input","A resume attempt names the session binding it resumes.");if("launch"===n.kind&&n.resumedSessionBindingId)throw new eI("invalid_input","A launch attempt does not resume a session binding.");let i="string"==typeof n.launchSnapshot?n.launchSnapshot:JSON.stringify(n.launchSnapshot);if("string"!=typeof i||0===i.length)throw new eI("invalid_input","A launch snapshot is required.");return e.transaction(()=>{let r=_(t);if("running"!==r.state)throw new eI("attempt_conflict",`Attempts start only on running requests (request is ${r.state}).`);if(n.toolProfile!==r.tool_profile)throw new eI("invalid_input",`The attempt tool profile must be ${r.tool_profile}.`);if(e.prepare("SELECT id FROM work_attempts WHERE request_id = ? AND finished_at IS NULL").get(t))throw new eI("attempt_conflict","The request already has an open attempt.");if(n.resumedSessionBindingId){let e=o.get(n.resumedSessionBindingId);if(!e)throw new eI("not_found","Session binding not found.");if(null!==e.released_at)throw new eI("session_mismatch","The session binding was released.");if(e.agent_id!==r.target_agent_id||e.adapter!==n.adapter)throw new eI("session_mismatch","The session binding belongs to another Agent or adapter.");if(null!==e.conversation_id&&e.conversation_id!==r.source_conversation_id)throw new eI("session_mismatch","The session binding belongs to another conversation.");if(null!==e.request_id&&_(e.request_id).root_request_id!==r.root_request_id)throw new eI("session_mismatch","The session binding belongs to an unrelated work request.")}let a=n.now??Date.now(),u=(0,s.randomUUID)(),c=e.prepare("SELECT COALESCE(MAX(attempt_number), 0) + 1 AS n FROM work_attempts WHERE request_id = ?").get(t);return e.prepare(`
1620
1620
  INSERT INTO work_attempts (
1621
1621
  id, request_id, attempt_number, kind, adapter, tool_profile, launch_snapshot, launch_snapshot_hash,
1622
1622
  resumed_session_binding_id, external_run_id, external_session_id, started_at
1623
1623
  ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
1624
- `).run(u,t,c.n,n.kind,n.adapter,n.toolProfile,i,eJ(i),n.resumedSessionBindingId??null,n.externalRunId??null,n.externalSessionId??null,a),E(t,"attempt_started",{attempt_number:c.n,kind:n.kind,adapter:n.adapter},u,a),d(u)}).immediate()},recordAttemptExternalIds:(t,n)=>e.transaction(()=>{let i=d(t);if(null!==i.finished_at)throw new eD("attempt_conflict","The attempt is already finished.");return e.prepare("UPDATE work_attempts SET external_run_id = ?, external_session_id = ? WHERE id = ?").run(void 0===n.externalRunId?i.external_run_id:n.externalRunId,void 0===n.externalSessionId?i.external_session_id:n.externalSessionId,t),d(t)}).immediate(),finishAttempt(t,n){if(!["succeeded","failed","cancelled","interrupted","timed_out"].includes(n.outcome))throw new eD("invalid_input","Unknown attempt outcome.");return e.transaction(()=>{let i=d(t);if(null!==i.finished_at)throw new eD("attempt_conflict","The attempt is already finished.");let r=n.now??Date.now();return e.prepare(`
1624
+ `).run(u,t,c.n,n.kind,n.adapter,n.toolProfile,i,eX(i),n.resumedSessionBindingId??null,n.externalRunId??null,n.externalSessionId??null,a),E(t,"attempt_started",{attempt_number:c.n,kind:n.kind,adapter:n.adapter},u,a),d(u)}).immediate()},recordAttemptExternalIds:(t,n)=>e.transaction(()=>{let i=d(t);if(null!==i.finished_at)throw new eI("attempt_conflict","The attempt is already finished.");return e.prepare("UPDATE work_attempts SET external_run_id = ?, external_session_id = ? WHERE id = ?").run(void 0===n.externalRunId?i.external_run_id:n.externalRunId,void 0===n.externalSessionId?i.external_session_id:n.externalSessionId,t),d(t)}).immediate(),finishAttempt(t,n){if(!["succeeded","failed","cancelled","interrupted","timed_out"].includes(n.outcome))throw new eI("invalid_input","Unknown attempt outcome.");return e.transaction(()=>{let i=d(t);if(null!==i.finished_at)throw new eI("attempt_conflict","The attempt is already finished.");let r=n.now??Date.now();return e.prepare(`
1625
1625
  UPDATE work_attempts SET outcome = ?, output = ?, error_category = ?, error_message = ?, artifacts = ?,
1626
1626
  external_run_id = ?, external_session_id = ?, finished_at = ?
1627
1627
  WHERE id = ? AND finished_at IS NULL
1628
- `).run(n.outcome,n.output??null,n.errorCategory??null,n.errorMessage??null,JSON.stringify(n.artifacts??[]),void 0===n.externalRunId?i.external_run_id:n.externalRunId,void 0===n.externalSessionId?i.external_session_id:n.externalSessionId,r,t),E(i.request_id,"attempt_finished",{attempt_number:i.attempt_number,outcome:n.outcome,error_category:n.errorCategory??null},t,r),d(t)}).immediate()},recordAttemptUsage(t,n){let i=d(t);eA(e,t,{agentId:_(i.request_id).target_agent_id,provider:i.adapter,usage:n.usage,observedAt:n.observedAt,now:n.now})},getAttempt:e=>i.get(e),listAttempts:t=>e.prepare("SELECT * FROM work_attempts WHERE request_id = ? ORDER BY attempt_number ASC").all(t),bindSession(t){if(!ej(t.agentId))throw new eD("invalid_input","agentId is required.");if(!ej(t.adapter))throw new eD("invalid_input","adapter is required.");if(!ej(t.externalSessionId))throw new eD("invalid_input","externalSessionId is required.");if(!t.conversationId&&!t.requestId)throw new eD("invalid_input","A session binding is scoped to a conversation or work request.");return e.transaction(()=>{let n=t.now??Date.now();if(!e.prepare("SELECT 1 FROM bots WHERE id = ?").get(t.agentId))throw new eD("not_found",`No agent ${t.agentId}.`);if(t.requestId){let e=_(t.requestId);if(e.target_agent_id!==t.agentId)throw new eD("session_mismatch","The work request targets another Agent.");if(t.conversationId&&e.source_conversation_id!==t.conversationId)throw new eD("session_mismatch","The work request belongs to another conversation.")}if(t.sourceAttemptId){let e=d(t.sourceAttemptId),n=_(e.request_id);if(e.adapter!==t.adapter||n.target_agent_id!==t.agentId)throw new eD("session_mismatch","The source attempt ran another Agent or adapter.");if(t.requestId&&e.request_id!==t.requestId)throw new eD("session_mismatch","The source attempt belongs to another work request.");if(t.conversationId&&n.source_conversation_id!==t.conversationId)throw new eD("session_mismatch","The source attempt belongs to another conversation.")}e.prepare(`
1628
+ `).run(n.outcome,n.output??null,n.errorCategory??null,n.errorMessage??null,JSON.stringify(n.artifacts??[]),void 0===n.externalRunId?i.external_run_id:n.externalRunId,void 0===n.externalSessionId?i.external_session_id:n.externalSessionId,r,t),E(i.request_id,"attempt_finished",{attempt_number:i.attempt_number,outcome:n.outcome,error_category:n.errorCategory??null},t,r),d(t)}).immediate()},recordAttemptUsage(t,n){let i=d(t);eu(e,t,{agentId:_(i.request_id).target_agent_id,provider:i.adapter,usage:n.usage,observedAt:n.observedAt,now:n.now})},getAttempt:e=>i.get(e),listAttempts:t=>e.prepare("SELECT * FROM work_attempts WHERE request_id = ? ORDER BY attempt_number ASC").all(t),bindSession(t){if(!eW(t.agentId))throw new eI("invalid_input","agentId is required.");if(!eW(t.adapter))throw new eI("invalid_input","adapter is required.");if(!eW(t.externalSessionId))throw new eI("invalid_input","externalSessionId is required.");if(!t.conversationId&&!t.requestId)throw new eI("invalid_input","A session binding is scoped to a conversation or work request.");return e.transaction(()=>{let n=t.now??Date.now();if(!e.prepare("SELECT 1 FROM bots WHERE id = ?").get(t.agentId))throw new eI("not_found",`No agent ${t.agentId}.`);if(t.requestId){let e=_(t.requestId);if(e.target_agent_id!==t.agentId)throw new eI("session_mismatch","The work request targets another Agent.");if(t.conversationId&&e.source_conversation_id!==t.conversationId)throw new eI("session_mismatch","The work request belongs to another conversation.")}if(t.sourceAttemptId){let e=d(t.sourceAttemptId),n=_(e.request_id);if(e.adapter!==t.adapter||n.target_agent_id!==t.agentId)throw new eI("session_mismatch","The source attempt ran another Agent or adapter.");if(t.requestId&&e.request_id!==t.requestId)throw new eI("session_mismatch","The source attempt belongs to another work request.");if(t.conversationId&&n.source_conversation_id!==t.conversationId)throw new eI("session_mismatch","The source attempt belongs to another conversation.")}e.prepare(`
1629
1629
  UPDATE session_bindings SET released_at = ?
1630
1630
  WHERE agent_id = ? AND adapter = ? AND IFNULL(conversation_id, '') = ? AND IFNULL(request_id, '') = ?
1631
1631
  AND released_at IS NULL
@@ -1637,7 +1637,7 @@ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",
1637
1637
  id, agent_id, runtime_connection_id, provider_kind, provider_session_id, binding_id, origin,
1638
1638
  availability, lifecycle, resumable, busy, created_at, updated_at
1639
1639
  )
1640
- SELECT b.id, b.agent_id, ${eX(e)}, b.adapter, b.external_session_id, b.id, 'binding',
1640
+ SELECT b.id, b.agent_id, ${ek(e)}, b.adapter, b.external_session_id, b.id, 'binding',
1641
1641
  'available', 'open', NULL, 0, b.created_at, b.created_at
1642
1642
  FROM session_bindings b JOIN bots bot ON bot.id = b.agent_id
1643
1643
  WHERE b.id = ?
@@ -1645,13 +1645,13 @@ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",
1645
1645
  SELECT * FROM session_bindings
1646
1646
  WHERE agent_id = ? AND adapter = ? AND IFNULL(conversation_id, '') = ? AND IFNULL(request_id, '') = ?
1647
1647
  AND released_at IS NULL
1648
- `).get(t.agentId,t.adapter,t.conversationId??"",t.requestId??"")};return u}function eZ(e,t){let n=(t,...n)=>e.prepare(t).all(...n).map(e=>e.id),i=new Set(n(t.requests,t.arg)),r=new Set,s=new Set(n(t.bindings,t.arg)),a=new Set,o=(e,t)=>{let n=!1;for(let i of t)e.has(i)||(e.add(i),n=!0);return n},_=e=>JSON.stringify([...e]),d="(SELECT value FROM json_each(?))";for(;;){let e=o(r,n(`SELECT id FROM session_exchanges WHERE (${t.exchanges})
1648
+ `).get(t.agentId,t.adapter,t.conversationId??"",t.requestId??"")};return u}function eH(e,t){let n=(t,...n)=>e.prepare(t).all(...n).map(e=>e.id),i=new Set(n(t.requests,t.arg)),r=new Set,s=new Set(n(t.bindings,t.arg)),a=new Set,o=(e,t)=>{let n=!1;for(let i of t)e.has(i)||(e.add(i),n=!0);return n},_=e=>JSON.stringify([...e]),d="(SELECT value FROM json_each(?))";for(;;){let e=o(r,n(`SELECT id FROM session_exchanges WHERE (${t.exchanges})
1649
1649
  OR source_request_id IN ${d} OR destination_request_id IN ${d} OR source_attempt_id IN ${d}
1650
1650
  OR destination_attempt_id IN ${d} OR source_binding_id IN ${d} OR destination_binding_id IN ${d}`,t.arg,t.arg,_(i),_(i),_(a),_(a),_(s),_(s))),E=o(i,n(`SELECT source_request_id AS id FROM session_exchanges WHERE id IN ${d} AND source_request_id IS NOT NULL
1651
- UNION SELECT destination_request_id AS id FROM session_exchanges WHERE id IN ${d} AND destination_request_id IS NOT NULL`,_(r),_(r))),u=o(i,n(`SELECT id FROM work_requests WHERE parent_request_id IN ${d} OR root_request_id IN ${d}`,_(i),_(i))),c=o(i,n(`SELECT request_id AS id FROM work_attempts WHERE id IN ${d}`,_(a))),l=o(a,n(`SELECT id FROM work_attempts WHERE request_id IN ${d} OR resumed_session_binding_id IN ${d}`,_(i),_(s))),T=o(s,n(`SELECT id FROM session_bindings WHERE request_id IN ${d} OR source_attempt_id IN ${d}`,_(i),_(a)));if(!e&&!E&&!u&&!c&&!l&&!T)break}(function(e,t,...n){let i=e.prepare(`SELECT id FROM session_exchanges WHERE ${t}`).all(...n).map(e=>e.id);if(0===i.length)return;let r=eG(e);for(let e of i)r.add(e);try{e.prepare("DELETE FROM session_exchange_events WHERE exchange_id IN (SELECT value FROM json_each(?))").run(JSON.stringify(i))}finally{r.clear()}e.prepare("DELETE FROM session_exchanges WHERE id IN (SELECT value FROM json_each(?))").run(JSON.stringify(i))})(e,`id IN ${d}`,_(r)),e.prepare(`DELETE FROM conversation_events WHERE request_id IN ${d}`).run(_(i)),e.prepare(`DELETE FROM finalizations WHERE implementation_request_id IN ${d} OR review_request_id IN ${d} OR decision_request_id IN ${d}`).run(_(i),_(i),_(i)),e.prepare(`DELETE FROM candidate_manifests WHERE request_id IN ${d}`).run(_(i)),e.prepare(`DELETE FROM attempt_finalization_baselines WHERE request_id IN ${d}`).run(_(i)),e.prepare(`DELETE FROM conversation_projection_cursors WHERE request_id IN ${d}`).run(_(i)),e.prepare(`DELETE FROM wake_safety_decisions WHERE request_id IN ${d}`).run(_(i)),e.prepare(`DELETE FROM dispatch_leases WHERE request_id IN ${d}`).run(_(i)),e.prepare(`DELETE FROM attempt_launch_intents WHERE request_id IN ${d}`).run(_(i)),e.prepare(`DELETE FROM dispatch_attention WHERE request_id IN ${d}`).run(_(i));let E=eG(e);for(let e of i)E.add(e);try{e.prepare(`DELETE FROM engine_events WHERE request_id IN ${d}`).run(_(i))}finally{E.clear()}for(e0(e,`origin = 'binding' AND binding_id IN ${d}`,_(s)),e.prepare(`UPDATE provider_sessions SET binding_id = NULL WHERE binding_id IN ${d}`).run(_(s)),e.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'usage_samples'").get()&&e.prepare(`DELETE FROM usage_samples WHERE attempt_id IN ${d}`).run(_(a));a.size>0||s.size>0;){let t=n(`SELECT id FROM session_bindings WHERE id IN ${d}
1651
+ UNION SELECT destination_request_id AS id FROM session_exchanges WHERE id IN ${d} AND destination_request_id IS NOT NULL`,_(r),_(r))),u=o(i,n(`SELECT id FROM work_requests WHERE parent_request_id IN ${d} OR root_request_id IN ${d}`,_(i),_(i))),c=o(i,n(`SELECT request_id AS id FROM work_attempts WHERE id IN ${d}`,_(a))),l=o(a,n(`SELECT id FROM work_attempts WHERE request_id IN ${d} OR resumed_session_binding_id IN ${d}`,_(i),_(s))),T=o(s,n(`SELECT id FROM session_bindings WHERE request_id IN ${d} OR source_attempt_id IN ${d}`,_(i),_(a)));if(!e&&!E&&!u&&!c&&!l&&!T)break}(function(e,t,...n){let i=e.prepare(`SELECT id FROM session_exchanges WHERE ${t}`).all(...n).map(e=>e.id);if(0===i.length)return;let r=eh(e);for(let e of i)r.add(e);try{e.prepare("DELETE FROM session_exchange_events WHERE exchange_id IN (SELECT value FROM json_each(?))").run(JSON.stringify(i))}finally{r.clear()}e.prepare("DELETE FROM session_exchanges WHERE id IN (SELECT value FROM json_each(?))").run(JSON.stringify(i))})(e,`id IN ${d}`,_(r)),e.prepare(`DELETE FROM conversation_events WHERE request_id IN ${d}`).run(_(i)),e.prepare(`DELETE FROM finalizations WHERE implementation_request_id IN ${d} OR review_request_id IN ${d} OR decision_request_id IN ${d}`).run(_(i),_(i),_(i)),e.prepare(`DELETE FROM candidate_manifests WHERE request_id IN ${d}`).run(_(i)),e.prepare(`DELETE FROM attempt_finalization_baselines WHERE request_id IN ${d}`).run(_(i)),e.prepare(`DELETE FROM conversation_projection_cursors WHERE request_id IN ${d}`).run(_(i)),e.prepare(`DELETE FROM wake_safety_decisions WHERE request_id IN ${d}`).run(_(i)),e.prepare(`DELETE FROM dispatch_leases WHERE request_id IN ${d}`).run(_(i)),e.prepare(`DELETE FROM attempt_launch_intents WHERE request_id IN ${d}`).run(_(i)),e.prepare(`DELETE FROM dispatch_attention WHERE request_id IN ${d}`).run(_(i));let E=eh(e);for(let e of i)E.add(e);try{e.prepare(`DELETE FROM engine_events WHERE request_id IN ${d}`).run(_(i))}finally{E.clear()}for(eB(e,`origin = 'binding' AND binding_id IN ${d}`,_(s)),e.prepare(`UPDATE provider_sessions SET binding_id = NULL WHERE binding_id IN ${d}`).run(_(s)),e.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'usage_samples'").get()&&e.prepare(`DELETE FROM usage_samples WHERE attempt_id IN ${d}`).run(_(a));a.size>0||s.size>0;){let t=n(`SELECT id FROM session_bindings WHERE id IN ${d}
1652
1652
  AND NOT EXISTS (SELECT 1 FROM work_attempts a WHERE a.resumed_session_binding_id = session_bindings.id)`,_(s));for(let n of t)e.prepare("DELETE FROM session_bindings WHERE id = ?").run(n),s.delete(n);let i=n(`SELECT id FROM work_attempts WHERE id IN ${d}
1653
- AND NOT EXISTS (SELECT 1 FROM session_bindings b WHERE b.source_attempt_id = work_attempts.id)`,_(a));for(let t of i)e.prepare("DELETE FROM work_attempts WHERE id = ?").run(t),a.delete(t);if(0===t.length&&0===i.length)throw Error("Engine records could not be removed: unexpected attempt/binding reference cycle.")}for(let t of(e.prepare(`DELETE FROM conversation_events WHERE request_id IS NULL AND wake_id IN (SELECT id FROM wakes WHERE work_request_id IN ${d} OR parent_request_id IN ${d} OR root_request_id IN ${d})`).run(_(i),_(i),_(i)),e.prepare(`DELETE FROM wakes WHERE work_request_id IN ${d} OR parent_request_id IN ${d} OR root_request_id IN ${d}`).run(_(i),_(i),_(i)),e.prepare(`DELETE FROM terminal_followups WHERE request_id IN ${d}`).run(_(i)),n(`SELECT id FROM work_requests WHERE id IN ${d} ORDER BY depth DESC`,_(i))))e.prepare("DELETE FROM work_requests WHERE id = ?").run(t)}function e0(e,t,...n){if(!e.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'provider_sessions'").get())return;let i=JSON.stringify(e.prepare(`SELECT id FROM provider_sessions WHERE ${t}`).all(...n).map(e=>e.id));e.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'usage_samples'").get()&&e.prepare("DELETE FROM usage_samples WHERE session_ref IN (SELECT value FROM json_each(?))").run(i),e.prepare("DELETE FROM provider_session_events WHERE session_ref IN (SELECT value FROM json_each(?))").run(i),e.prepare("DELETE FROM provider_session_turns WHERE session_ref IN (SELECT value FROM json_each(?))").run(i),e.prepare("DELETE FROM provider_sessions WHERE id IN (SELECT value FROM json_each(?))").run(i)}function e1(e,t,...n){if(!e.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'session_pins'").get())return;let i=JSON.stringify(e.prepare(`SELECT id FROM session_pins WHERE ${t}`).all(...n).map(e=>e.id));e.prepare("DELETE FROM session_pin_events WHERE pin_id IN (SELECT value FROM json_each(?))").run(i),e.prepare("DELETE FROM session_pin_turns WHERE pin_id IN (SELECT value FROM json_each(?))").run(i),e.prepare("DELETE FROM session_pins WHERE id IN (SELECT value FROM json_each(?))").run(i)}function e2(e,t){e.prepare("DELETE FROM conversation_intakes WHERE conversation_id = ?").run(t),e.prepare("DELETE FROM delegation_chains WHERE conversation_id = ?").run(t),e.prepare("DELETE FROM conversation_events WHERE conversation_id = ? AND request_id IS NULL").run(t),e.prepare("DELETE FROM wakes WHERE source_conversation_id = ?").run(t),e1(e,"conversation_id = ?",t),eZ(e,{requests:"SELECT id FROM work_requests WHERE source_conversation_id = ?",bindings:"SELECT id FROM session_bindings WHERE conversation_id = ?",exchanges:"origin_conversation_id = ? OR destination_conversation_id = ?",arg:t})}function e6(e,t){e.prepare(`DELETE FROM conversation_events WHERE request_id IS NULL AND wake_id IN (
1654
- SELECT id FROM wakes WHERE target_agent_id = ? OR (requester_agent_id = ? AND work_request_id IS NULL))`).run(t,t),e.prepare("DELETE FROM wakes WHERE target_agent_id = ? OR (requester_agent_id = ? AND work_request_id IS NULL)").run(t,t),e.prepare("DELETE FROM wake_grants WHERE caller_agent_id = ? OR target_agent_id = ?").run(t,t),e1(e,"agent_id = ?",t),e0(e,"agent_id = ?",t),e.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'usage_samples'").get()&&e.prepare("DELETE FROM usage_samples WHERE agent_id = ?").run(t),e.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'provider_session_events'").get()&&e.prepare("DELETE FROM provider_session_events WHERE agent_id = ?").run(t),eZ(e,{requests:"SELECT id FROM work_requests WHERE target_agent_id = ?",bindings:"SELECT id FROM session_bindings WHERE agent_id = ?",exchanges:"source_agent_id = ? OR destination_agent_id = ?",arg:t})}function e4(e){if(!e)return{};try{let t=JSON.parse(e);return t&&"object"==typeof t&&!Array.isArray(t)?t:{}}catch{return{}}}function e3(e){return"string"==typeof e&&e.length>0?e:null}function e9(e,t){return t?`${e}: ${t}`:e}function e5(e,t,n,i){let r="grant_required"===t,s=r?"needs your approval for edit work":n;return{kind:"wake_blocked",attemptId:null,text:s?`Wake blocked: ${e} — ${s}`:`Wake blocked: ${e}`,data:{...i,target_name:e,reason_code:t,reason:n,actions:r?["allow","deny"]:[]}}}e.s(["EXCHANGE_LIMITS",0,ew,"EXCHANGE_STATES",0,ef,"EXCHANGE_TERMINAL_STATES",0,ev,"EXCHANGE_TRANSITIONS",0,eh,"EngineStoreError",0,eD,"TERMINAL_STATES",0,eq,"UI_TURN_INTERRUPTED",0,e$,"UI_TURN_INTERRUPTED_MESSAGE",0,ez,"UI_TURN_REQUESTER",0,eY,"createEngineStore",0,eV,"deleteEngineRecordsForAgent",0,e6,"deleteEngineRecordsForConversation",0,e2,"migrateEngineSchema",0,eH,"uiTurnExecutionPolicy",0,eP],35613);let e7=/^[A-Za-z0-9][A-Za-z0-9._:@-]{0,127}$/,e8=/^[a-z][a-z0-9_.:-]{0,63}$/;function te(e){return null==e||""===e?null:e7.test(e)?e:"[invalid]"}function tt(e,t){return e&&e8.test(e)?e:t}let tn="agent_name_conflict";function ti(e){return String(e??"").trim()}function tr(e){return ti(e).normalize("NFC").toLowerCase().normalize("NFC")}function ts(e){return`An Agent named "${ti(e)}" already exists. Agent names must be unique, ignoring case and surrounding spaces.`}class ta extends Error{code=tn;requestedName;conflictingAgentId;constructor(e,t){super(ts(e)),this.name="AgentNameConflictError",this.requestedName=ti(e),this.conflictingAgentId=t}}function to(e){let t=[...e].sort((e,t)=>e.created_at-t.created_at||(e.id<t.id?-1:+(e.id>t.id))),n=new Map,i=[],r=[];for(let e of t){let t=tr(e.name);if(n.has(t)){i.push(e);continue}n.set(t,e.id),e.name_key!==t&&r.push({id:e.id,name:e.name,name_key:t})}let s=[];for(let e of i){let t=tr(e.name),i=ti(e.name)||"Agent",a=2;for(;n.has(tr(`${i}-${a}`));)a++;let o=`${i}-${a}`,_=tr(o);n.set(_,e.id),r.push({id:e.id,name:o,name_key:_}),s.push({bot_id:e.id,previous_name:e.name,new_name:o,name_key:t,kept_bot_id:n.get(t)})}return{updates:r,renames:s}}e.s(["AgentNameConflictError",0,ta,"agentDisplayName",0,ti,"agentNameConflictBody",0,function(e,t="name"){return{error:e.message,code:tn,field:t,name:e.requestedName,conflicting_agent_id:e.conflictingAgentId}},"agentNameConflictMessage",0,ts,"agentNameKey",0,tr,"planNameMigration",0,to],30098);let t_=(0,e.i(52036).dbPath)();":memory:"!==t_&&i.default.mkdirSync(r.default.dirname(r.default.resolve(t_)),{recursive:!0});let td=new n.default(t_);td.pragma("journal_mode = WAL"),td.exec(`
1653
+ AND NOT EXISTS (SELECT 1 FROM session_bindings b WHERE b.source_attempt_id = work_attempts.id)`,_(a));for(let t of i)e.prepare("DELETE FROM work_attempts WHERE id = ?").run(t),a.delete(t);if(0===t.length&&0===i.length)throw Error("Engine records could not be removed: unexpected attempt/binding reference cycle.")}for(let t of(e.prepare(`DELETE FROM conversation_events WHERE request_id IS NULL AND wake_id IN (SELECT id FROM wakes WHERE work_request_id IN ${d} OR parent_request_id IN ${d} OR root_request_id IN ${d})`).run(_(i),_(i),_(i)),e.prepare(`DELETE FROM wakes WHERE work_request_id IN ${d} OR parent_request_id IN ${d} OR root_request_id IN ${d}`).run(_(i),_(i),_(i)),e.prepare(`DELETE FROM terminal_followups WHERE request_id IN ${d}`).run(_(i)),n(`SELECT id FROM work_requests WHERE id IN ${d} ORDER BY depth DESC`,_(i))))e.prepare("DELETE FROM work_requests WHERE id = ?").run(t)}function eB(e,t,...n){if(!e.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'provider_sessions'").get())return;let i=JSON.stringify(e.prepare(`SELECT id FROM provider_sessions WHERE ${t}`).all(...n).map(e=>e.id));e.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'usage_samples'").get()&&e.prepare("DELETE FROM usage_samples WHERE session_ref IN (SELECT value FROM json_each(?))").run(i),e.prepare("DELETE FROM provider_session_events WHERE session_ref IN (SELECT value FROM json_each(?))").run(i),e.prepare("DELETE FROM provider_session_turns WHERE session_ref IN (SELECT value FROM json_each(?))").run(i),e.prepare("DELETE FROM provider_sessions WHERE id IN (SELECT value FROM json_each(?))").run(i)}function eM(e,t,...n){if(!e.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'session_pins'").get())return;let i=JSON.stringify(e.prepare(`SELECT id FROM session_pins WHERE ${t}`).all(...n).map(e=>e.id));e.prepare("DELETE FROM session_pin_events WHERE pin_id IN (SELECT value FROM json_each(?))").run(i),e.prepare("DELETE FROM session_pin_turns WHERE pin_id IN (SELECT value FROM json_each(?))").run(i),e.prepare("DELETE FROM session_pins WHERE id IN (SELECT value FROM json_each(?))").run(i)}function eK(e,t){e.prepare("DELETE FROM conversation_intakes WHERE conversation_id = ?").run(t),e.prepare("DELETE FROM delegation_chains WHERE conversation_id = ?").run(t),e.prepare("DELETE FROM conversation_events WHERE conversation_id = ? AND request_id IS NULL").run(t),e.prepare("DELETE FROM wakes WHERE source_conversation_id = ?").run(t),eM(e,"conversation_id = ?",t),eH(e,{requests:"SELECT id FROM work_requests WHERE source_conversation_id = ?",bindings:"SELECT id FROM session_bindings WHERE conversation_id = ?",exchanges:"origin_conversation_id = ? OR destination_conversation_id = ?",arg:t})}function eY(e,t){e.prepare(`DELETE FROM conversation_events WHERE request_id IS NULL AND wake_id IN (
1654
+ SELECT id FROM wakes WHERE target_agent_id = ? OR (requester_agent_id = ? AND work_request_id IS NULL))`).run(t,t),e.prepare("DELETE FROM wakes WHERE target_agent_id = ? OR (requester_agent_id = ? AND work_request_id IS NULL)").run(t,t),e.prepare("DELETE FROM wake_grants WHERE caller_agent_id = ? OR target_agent_id = ?").run(t,t),eM(e,"agent_id = ?",t),eB(e,"agent_id = ?",t),e.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'usage_samples'").get()&&e.prepare("DELETE FROM usage_samples WHERE agent_id = ?").run(t),e.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'provider_session_events'").get()&&e.prepare("DELETE FROM provider_session_events WHERE agent_id = ?").run(t),eH(e,{requests:"SELECT id FROM work_requests WHERE target_agent_id = ?",bindings:"SELECT id FROM session_bindings WHERE agent_id = ?",exchanges:"source_agent_id = ? OR destination_agent_id = ?",arg:t})}function eP(e){if(!e)return{};try{let t=JSON.parse(e);return t&&"object"==typeof t&&!Array.isArray(t)?t:{}}catch{return{}}}function e$(e){return"string"==typeof e&&e.length>0?e:null}function ez(e,t){return t?`${e}: ${t}`:e}function ej(e,t,n,i){let r="grant_required"===t,s=r?"needs your approval for edit work":n;return{kind:"wake_blocked",attemptId:null,text:s?`Wake blocked: ${e} — ${s}`:`Wake blocked: ${e}`,data:{...i,target_name:e,reason_code:t,reason:n,actions:r?["allow","deny"]:[]}}}e.s(["EXCHANGE_LIMITS",0,eR,"EXCHANGE_STATES",0,eT,"EXCHANGE_TERMINAL_STATES",0,ep,"EXCHANGE_TRANSITIONS",0,eN,"EngineStoreError",0,eI,"TERMINAL_STATES",0,eL,"UI_TURN_INTERRUPTED",0,eD,"UI_TURN_INTERRUPTED_MESSAGE",0,eF,"UI_TURN_REQUESTER",0,eb,"createEngineStore",0,eG,"deleteEngineRecordsForAgent",0,eY,"deleteEngineRecordsForConversation",0,eK,"migrateEngineSchema",0,ew,"uiTurnExecutionPolicy",0,eU],35613);let eJ=/^[A-Za-z0-9][A-Za-z0-9._:@-]{0,127}$/,eQ=/^[a-z][a-z0-9_.:-]{0,63}$/;function eV(e){return null==e||""===e?null:eJ.test(e)?e:"[invalid]"}function eZ(e,t){return e&&eQ.test(e)?e:t}let e0="agent_name_conflict";function e1(e){return String(e??"").trim()}function e2(e){return e1(e).normalize("NFC").toLowerCase().normalize("NFC")}function e6(e){return`An Agent named "${e1(e)}" already exists. Agent names must be unique, ignoring case and surrounding spaces.`}class e4 extends Error{code=e0;requestedName;conflictingAgentId;constructor(e,t){super(e6(e)),this.name="AgentNameConflictError",this.requestedName=e1(e),this.conflictingAgentId=t}}function e3(e){let t=[...e].sort((e,t)=>e.created_at-t.created_at||(e.id<t.id?-1:+(e.id>t.id))),n=new Map,i=[],r=[];for(let e of t){let t=e2(e.name);if(n.has(t)){i.push(e);continue}n.set(t,e.id),e.name_key!==t&&r.push({id:e.id,name:e.name,name_key:t})}let s=[];for(let e of i){let t=e2(e.name),i=e1(e.name)||"Agent",a=2;for(;n.has(e2(`${i}-${a}`));)a++;let o=`${i}-${a}`,_=e2(o);n.set(_,e.id),r.push({id:e.id,name:o,name_key:_}),s.push({bot_id:e.id,previous_name:e.name,new_name:o,name_key:t,kept_bot_id:n.get(t)})}return{updates:r,renames:s}}e.s(["AgentNameConflictError",0,e4,"agentDisplayName",0,e1,"agentNameConflictBody",0,function(e,t="name"){return{error:e.message,code:e0,field:t,name:e.requestedName,conflicting_agent_id:e.conflictingAgentId}},"agentNameConflictMessage",0,e6,"agentNameKey",0,e2,"planNameMigration",0,e3],30098);let e9=(0,e.i(52036).dbPath)();":memory:"!==e9&&i.default.mkdirSync(r.default.dirname(r.default.resolve(e9)),{recursive:!0});let e5=new n.default(e9);e5.pragma("journal_mode = WAL"),e5.exec(`
1655
1655
  CREATE TABLE IF NOT EXISTS bots (
1656
1656
  id TEXT PRIMARY KEY,
1657
1657
  name TEXT NOT NULL,
@@ -1801,7 +1801,7 @@ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",
1801
1801
  ON approval_requests(conversation_id, code);
1802
1802
  CREATE INDEX IF NOT EXISTS idx_approval_requests_conversation
1803
1803
  ON approval_requests(conversation_id, status, created_at);
1804
- `);let tE=["#C6F54A","#F0A05A","#E85D75","#C9A0FF","#F2E36B"],tu="9e363764-e0d5-4fff-8ebd-ccbc46ba0ba5",tc="5fbe32c2-79cb-452e-9d9b-f8c9eb63b99b",tl=td.prepare("PRAGMA table_info(bots)").all();tl.some(e=>"color"===e.name)||td.exec("ALTER TABLE bots ADD COLUMN color TEXT"),tl.some(e=>"pinned"===e.name)||td.exec("ALTER TABLE bots ADD COLUMN pinned INTEGER NOT NULL DEFAULT 0"),tl.some(e=>"last_seen"===e.name)||td.exec("ALTER TABLE bots ADD COLUMN last_seen INTEGER"),tl.some(e=>"unread"===e.name)||td.exec("ALTER TABLE bots ADD COLUMN unread INTEGER NOT NULL DEFAULT 0"),tl.some(e=>"hidden"===e.name)||td.exec("ALTER TABLE bots ADD COLUMN hidden INTEGER NOT NULL DEFAULT 0"),tl.some(e=>"source_provider"===e.name)||td.exec("ALTER TABLE bots ADD COLUMN source_provider TEXT"),tl.some(e=>"template_id"===e.name)||td.exec("ALTER TABLE bots ADD COLUMN template_id TEXT"),tl.some(e=>"template_url"===e.name)||td.exec("ALTER TABLE bots ADD COLUMN template_url TEXT"),tl.some(e=>"import_schema_version"===e.name)||td.exec("ALTER TABLE bots ADD COLUMN import_schema_version TEXT"),tl.some(e=>"import_operation_id"===e.name)||td.exec("ALTER TABLE bots ADD COLUMN import_operation_id TEXT"),tl.some(e=>"import_timestamp"===e.name)||td.exec("ALTER TABLE bots ADD COLUMN import_timestamp INTEGER"),tl.some(e=>"hermes_profile"===e.name)||td.exec("ALTER TABLE bots ADD COLUMN hermes_profile TEXT"),tl.some(e=>"persistent_runtime"===e.name)||td.exec("ALTER TABLE bots ADD COLUMN persistent_runtime TEXT NOT NULL DEFAULT 'hermes'"),tl.some(e=>"coding_runtime"===e.name)||td.exec("ALTER TABLE bots ADD COLUMN coding_runtime TEXT"),tl.some(e=>"deck_name"===e.name)||td.exec("ALTER TABLE bots ADD COLUMN deck_name TEXT"),tl.some(e=>"working_directory"===e.name)||td.exec("ALTER TABLE bots ADD COLUMN working_directory TEXT"),tl.some(e=>"runtime"===e.name)||td.exec("ALTER TABLE bots ADD COLUMN runtime TEXT"),tl.some(e=>"agent_client"===e.name)||td.exec("ALTER TABLE bots ADD COLUMN agent_client TEXT"),tl.some(e=>"deck_id"===e.name)||td.exec("ALTER TABLE bots ADD COLUMN deck_id TEXT"),tl.some(e=>"needs_deck_reselection"===e.name)||td.exec("ALTER TABLE bots ADD COLUMN needs_deck_reselection INTEGER NOT NULL DEFAULT 0"),tl.some(e=>"agent"===e.name)||td.exec("ALTER TABLE bots ADD COLUMN agent TEXT"),tl.some(e=>"needs_deck_selection"===e.name)||td.exec("ALTER TABLE bots ADD COLUMN needs_deck_selection INTEGER NOT NULL DEFAULT 0");{let e=td.prepare("SELECT id, agent, runtime, agent_client, persistent_runtime, coding_runtime, deck_id, deck_name, working_directory, needs_deck_reselection, needs_deck_selection FROM bots WHERE agent IS NULL").all(),t=td.prepare("UPDATE bots SET agent = ?, deck_id = ?, deck_name = ?, working_directory = ?, needs_deck_selection = ? WHERE id = ?");td.transaction(e=>{for(let n of e){let e=(0,a.migrateLegacyAgentFields)(n);t.run(e.agent,e.deck_id,e.deck_name,e.working_directory,+!!e.needs_deck_selection,n.id)}})(e)}for(let[e,t]of(tl.some(e=>"avatar_color"===e.name)||td.exec("ALTER TABLE bots ADD COLUMN avatar_color TEXT"),tl.some(e=>"avatar_eyes"===e.name)||td.exec("ALTER TABLE bots ADD COLUMN avatar_eyes TEXT"),tl.some(e=>"avatar_hands"===e.name)||td.exec("ALTER TABLE bots ADD COLUMN avatar_hands TEXT"),tl.some(e=>"avatar_accessory"===e.name)||td.exec("ALTER TABLE bots ADD COLUMN avatar_accessory TEXT"),td.exec(`
1804
+ `);let e8=["#C6F54A","#F0A05A","#E85D75","#C9A0FF","#F2E36B"],e7="9e363764-e0d5-4fff-8ebd-ccbc46ba0ba5",te="5fbe32c2-79cb-452e-9d9b-f8c9eb63b99b",tt=e5.prepare("PRAGMA table_info(bots)").all();tt.some(e=>"color"===e.name)||e5.exec("ALTER TABLE bots ADD COLUMN color TEXT"),tt.some(e=>"pinned"===e.name)||e5.exec("ALTER TABLE bots ADD COLUMN pinned INTEGER NOT NULL DEFAULT 0"),tt.some(e=>"last_seen"===e.name)||e5.exec("ALTER TABLE bots ADD COLUMN last_seen INTEGER"),tt.some(e=>"unread"===e.name)||e5.exec("ALTER TABLE bots ADD COLUMN unread INTEGER NOT NULL DEFAULT 0"),tt.some(e=>"hidden"===e.name)||e5.exec("ALTER TABLE bots ADD COLUMN hidden INTEGER NOT NULL DEFAULT 0"),tt.some(e=>"source_provider"===e.name)||e5.exec("ALTER TABLE bots ADD COLUMN source_provider TEXT"),tt.some(e=>"template_id"===e.name)||e5.exec("ALTER TABLE bots ADD COLUMN template_id TEXT"),tt.some(e=>"template_url"===e.name)||e5.exec("ALTER TABLE bots ADD COLUMN template_url TEXT"),tt.some(e=>"import_schema_version"===e.name)||e5.exec("ALTER TABLE bots ADD COLUMN import_schema_version TEXT"),tt.some(e=>"import_operation_id"===e.name)||e5.exec("ALTER TABLE bots ADD COLUMN import_operation_id TEXT"),tt.some(e=>"import_timestamp"===e.name)||e5.exec("ALTER TABLE bots ADD COLUMN import_timestamp INTEGER"),tt.some(e=>"hermes_profile"===e.name)||e5.exec("ALTER TABLE bots ADD COLUMN hermes_profile TEXT"),tt.some(e=>"persistent_runtime"===e.name)||e5.exec("ALTER TABLE bots ADD COLUMN persistent_runtime TEXT NOT NULL DEFAULT 'hermes'"),tt.some(e=>"coding_runtime"===e.name)||e5.exec("ALTER TABLE bots ADD COLUMN coding_runtime TEXT"),tt.some(e=>"deck_name"===e.name)||e5.exec("ALTER TABLE bots ADD COLUMN deck_name TEXT"),tt.some(e=>"working_directory"===e.name)||e5.exec("ALTER TABLE bots ADD COLUMN working_directory TEXT"),tt.some(e=>"runtime"===e.name)||e5.exec("ALTER TABLE bots ADD COLUMN runtime TEXT"),tt.some(e=>"agent_client"===e.name)||e5.exec("ALTER TABLE bots ADD COLUMN agent_client TEXT"),tt.some(e=>"deck_id"===e.name)||e5.exec("ALTER TABLE bots ADD COLUMN deck_id TEXT"),tt.some(e=>"needs_deck_reselection"===e.name)||e5.exec("ALTER TABLE bots ADD COLUMN needs_deck_reselection INTEGER NOT NULL DEFAULT 0"),tt.some(e=>"agent"===e.name)||e5.exec("ALTER TABLE bots ADD COLUMN agent TEXT"),tt.some(e=>"needs_deck_selection"===e.name)||e5.exec("ALTER TABLE bots ADD COLUMN needs_deck_selection INTEGER NOT NULL DEFAULT 0");{let e=e5.prepare("SELECT id, agent, runtime, agent_client, persistent_runtime, coding_runtime, deck_name, working_directory FROM bots WHERE agent IS NULL").all(),t=e5.prepare("UPDATE bots SET agent = ? WHERE id = ?");e5.transaction(e=>{for(let n of e){let e=(0,a.migrateLegacyAgentFields)(n);t.run(e.agent,n.id)}})(e)}for(let[e,t]of(tt.some(e=>"avatar_color"===e.name)||e5.exec("ALTER TABLE bots ADD COLUMN avatar_color TEXT"),tt.some(e=>"avatar_eyes"===e.name)||e5.exec("ALTER TABLE bots ADD COLUMN avatar_eyes TEXT"),tt.some(e=>"avatar_hands"===e.name)||e5.exec("ALTER TABLE bots ADD COLUMN avatar_hands TEXT"),tt.some(e=>"avatar_accessory"===e.name)||e5.exec("ALTER TABLE bots ADD COLUMN avatar_accessory TEXT"),e5.exec(`
1805
1805
  CREATE TABLE IF NOT EXISTS runtime_connections (
1806
1806
  id TEXT PRIMARY KEY,
1807
1807
  provider TEXT NOT NULL,
@@ -1809,8 +1809,10 @@ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",
1809
1809
  host TEXT NOT NULL,
1810
1810
  created_at INTEGER NOT NULL
1811
1811
  );
1812
- `),[["runtime_connection_id","TEXT"],["launch_profile","TEXT"],["session_scope_kind","TEXT"],["session_scope_items","TEXT"],["default_workspace","TEXT"],["policy_mode","TEXT"],["allow_new_sessions","INTEGER"],["allow_resume_with_edits","INTEGER"],["home_session_id","TEXT"]]))tl.some(t=>t.name===e)||td.exec(`ALTER TABLE bots ADD COLUMN ${e} ${t}`);function tT(e,t=Date.now()){let n=v(e);return td.prepare("INSERT OR IGNORE INTO runtime_connections (id, provider, label, host, created_at) VALUES (?, ?, ?, ?, ?)").run(n,e,h(e),E,t),n}for(let e of a.AGENTS)tT(e,0);td.transaction(()=>{let e=td.prepare("SELECT id, agent, deck_id, working_directory, needs_deck_selection, created_at FROM bots WHERE runtime_connection_id IS NULL").all(),t=td.prepare(`UPDATE bots SET runtime_connection_id = ?, launch_profile = ?, session_scope_kind = ?, session_scope_items = ?,
1813
- policy_mode = ?, allow_new_sessions = ?, allow_resume_with_edits = ? WHERE id = ?`);for(let n of e){let e=X(n);tT(e.provider,n.created_at),t.run(e.runtime_connection_id,e.launch_profile,e.session_scope_kind,e.session_scope_items,e.policy_mode,e.allow_new_sessions,e.allow_resume_with_edits,n.id)}})(),tl.some(e=>"name_key"===e.name)||td.exec("ALTER TABLE bots ADD COLUMN name_key TEXT"),td.exec(`
1812
+ `),[["runtime_connection_id","TEXT"],["launch_profile","TEXT"],["session_scope_kind","TEXT"],["session_scope_items","TEXT"],["default_workspace","TEXT"],["policy_mode","TEXT"],["allow_new_sessions","INTEGER"],["allow_resume_with_edits","INTEGER"],["home_session_id","TEXT"]]))tt.some(t=>t.name===e)||e5.exec(`ALTER TABLE bots ADD COLUMN ${e} ${t}`);function tn(e,t=Date.now()){let n=O(e);return e5.prepare("INSERT OR IGNORE INTO runtime_connections (id, provider, label, host, created_at) VALUES (?, ?, ?, ?, ?)").run(n,e,g(e),d,t),n}for(let e of a.AGENTS)tn(e,0);e5.transaction(()=>{let e=e5.prepare("SELECT id, agent, working_directory, created_at FROM bots WHERE runtime_connection_id IS NULL").all(),t=e5.prepare(`UPDATE bots SET runtime_connection_id = ?, session_scope_kind = ?, session_scope_items = ?,
1813
+ policy_mode = ?, allow_new_sessions = ?, allow_resume_with_edits = ? WHERE id = ?`);for(let n of e){let e=q(n);tn(e.provider,n.created_at),t.run(e.runtime_connection_id,e.session_scope_kind,e.session_scope_items,e.policy_mode,e.allow_new_sessions,e.allow_resume_with_edits,n.id)}})(),e5.exec(`UPDATE bots SET launch_profile = 'direct', deck_id = NULL, working_directory = NULL, needs_deck_selection = 0
1814
+ WHERE launch_profile IS NULL OR launch_profile <> 'direct'
1815
+ OR deck_id IS NOT NULL OR working_directory IS NOT NULL OR needs_deck_selection <> 0`),tt.some(e=>"name_key"===e.name)||e5.exec("ALTER TABLE bots ADD COLUMN name_key TEXT"),e5.exec(`
1814
1816
  CREATE TABLE IF NOT EXISTS agent_name_migrations (
1815
1817
  id TEXT PRIMARY KEY,
1816
1818
  bot_id TEXT NOT NULL,
@@ -1821,10 +1823,10 @@ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",
1821
1823
  reason TEXT NOT NULL,
1822
1824
  created_at INTEGER NOT NULL
1823
1825
  );
1824
- `),td.transaction(()=>{let e=to(td.prepare("SELECT id, name, created_at, name_key FROM bots").all());if(0===e.updates.length)return;let t=td.prepare("UPDATE bots SET name_key = NULL WHERE id = ?");for(let n of e.updates)t.run(n.id);let n=td.prepare("UPDATE bots SET name = ?, name_key = ? WHERE id = ?");for(let t of e.updates)n.run(t.name,t.name_key,t.id);let i=td.prepare("INSERT INTO agent_name_migrations (id, bot_id, previous_name, new_name, name_key, kept_bot_id, reason, created_at) VALUES (?, ?, ?, ?, ?, ?, 'duplicate_name', ?)"),r=Date.now();for(let t of e.renames)i.run((0,s.randomUUID)(),t.bot_id,t.previous_name,t.new_name,t.name_key,t.kept_bot_id,r),console.warn(`[botmancers] Agent ${t.bot_id} renamed "${t.previous_name}" -> "${t.new_name}": name already used by Agent ${t.kept_bot_id}.`)})(),td.exec("CREATE UNIQUE INDEX IF NOT EXISTS idx_bots_name_key ON bots(name_key)"),td.exec(`
1826
+ `),e5.transaction(()=>{let e=e3(e5.prepare("SELECT id, name, created_at, name_key FROM bots").all());if(0===e.updates.length)return;let t=e5.prepare("UPDATE bots SET name_key = NULL WHERE id = ?");for(let n of e.updates)t.run(n.id);let n=e5.prepare("UPDATE bots SET name = ?, name_key = ? WHERE id = ?");for(let t of e.updates)n.run(t.name,t.name_key,t.id);let i=e5.prepare("INSERT INTO agent_name_migrations (id, bot_id, previous_name, new_name, name_key, kept_bot_id, reason, created_at) VALUES (?, ?, ?, ?, ?, ?, 'duplicate_name', ?)"),r=Date.now();for(let t of e.renames)i.run((0,s.randomUUID)(),t.bot_id,t.previous_name,t.new_name,t.name_key,t.kept_bot_id,r),console.warn(`[botmancers] Agent ${t.bot_id} renamed "${t.previous_name}" -> "${t.new_name}": name already used by Agent ${t.kept_bot_id}.`)})(),e5.exec("CREATE UNIQUE INDEX IF NOT EXISTS idx_bots_name_key ON bots(name_key)"),e5.exec(`
1825
1827
  CREATE UNIQUE INDEX IF NOT EXISTS idx_bots_import_operation
1826
1828
  ON bots(import_operation_id) WHERE import_operation_id IS NOT NULL
1827
- `),td.prepare("UPDATE bots SET color = ? WHERE id = ?").run(tE[0],tu),td.prepare("UPDATE bots SET color = ? WHERE id = ?").run(tE[1],tc);let tp=td.prepare("SELECT id FROM bots WHERE id NOT IN (?, ?) ORDER BY created_at ASC").all(tu,tc),tN=td.prepare("UPDATE bots SET color = ? WHERE id = ?");function tR(e,t){let n=ti(e),i=tr(n),r=td.prepare("SELECT id FROM bots WHERE name_key = ?").get(i);if(r&&r.id!==t)throw new ta(n,r.id);return{name:n,name_key:i}}function tm(e,t){try{return t()}catch(t){if(t instanceof Error&&/UNIQUE constraint failed: bots\.name_key/.test(t.message)){let t=td.prepare("SELECT id FROM bots WHERE name_key = ?").get(tr(e));throw new ta(e,t?.id??null)}throw t}}function tL(){return tE[td.prepare("SELECT COUNT(*) AS n FROM bots").get().n%tE.length]}tp.forEach((e,t)=>{tN.run(tE[(t+2)%tE.length],e.id)});let tg=td.prepare("PRAGMA table_info(messages)").all();tg.some(e=>"handoff_targets"===e.name)||td.exec("ALTER TABLE messages ADD COLUMN handoff_targets TEXT"),td.prepare("PRAGMA table_info(groups)").all().some(e=>"owner_bot_id"===e.name)||td.exec("ALTER TABLE groups ADD COLUMN owner_bot_id TEXT"),td.prepare("PRAGMA table_info(launch_snapshots)").all().some(e=>"transport"===e.name)||td.exec("ALTER TABLE launch_snapshots ADD COLUMN transport TEXT NOT NULL DEFAULT 'hermes-gateway'");let tO=td.prepare("PRAGMA table_info(conversations)").all();tO.some(e=>"origin_kind"===e.name)||td.exec("ALTER TABLE conversations ADD COLUMN origin_kind TEXT"),tO.some(e=>"origin_id"===e.name)||td.exec("ALTER TABLE conversations ADD COLUMN origin_id TEXT"),tg.some(e=>"sender_kind"===e.name)||td.exec("ALTER TABLE messages ADD COLUMN sender_kind TEXT"),tg.some(e=>"request_id"===e.name)||td.exec("ALTER TABLE messages ADD COLUMN request_id TEXT"),td.exec(`
1829
+ `),e5.prepare("UPDATE bots SET color = ? WHERE id = ?").run(e8[0],e7),e5.prepare("UPDATE bots SET color = ? WHERE id = ?").run(e8[1],te);let ti=e5.prepare("SELECT id FROM bots WHERE id NOT IN (?, ?) ORDER BY created_at ASC").all(e7,te),tr=e5.prepare("UPDATE bots SET color = ? WHERE id = ?");function ts(e,t){let n=e1(e),i=e2(n),r=e5.prepare("SELECT id FROM bots WHERE name_key = ?").get(i);if(r&&r.id!==t)throw new e4(n,r.id);return{name:n,name_key:i}}function ta(e,t){try{return t()}catch(t){if(t instanceof Error&&/UNIQUE constraint failed: bots\.name_key/.test(t.message)){let t=e5.prepare("SELECT id FROM bots WHERE name_key = ?").get(e2(e));throw new e4(e,t?.id??null)}throw t}}function to(){return e8[e5.prepare("SELECT COUNT(*) AS n FROM bots").get().n%e8.length]}ti.forEach((e,t)=>{tr.run(e8[(t+2)%e8.length],e.id)});let t_=e5.prepare("PRAGMA table_info(messages)").all();t_.some(e=>"handoff_targets"===e.name)||e5.exec("ALTER TABLE messages ADD COLUMN handoff_targets TEXT"),e5.prepare("PRAGMA table_info(groups)").all().some(e=>"owner_bot_id"===e.name)||e5.exec("ALTER TABLE groups ADD COLUMN owner_bot_id TEXT"),e5.prepare("PRAGMA table_info(launch_snapshots)").all().some(e=>"transport"===e.name)||e5.exec("ALTER TABLE launch_snapshots ADD COLUMN transport TEXT NOT NULL DEFAULT 'hermes-gateway'");let td=e5.prepare("PRAGMA table_info(conversations)").all();td.some(e=>"origin_kind"===e.name)||e5.exec("ALTER TABLE conversations ADD COLUMN origin_kind TEXT"),td.some(e=>"origin_id"===e.name)||e5.exec("ALTER TABLE conversations ADD COLUMN origin_id TEXT"),t_.some(e=>"sender_kind"===e.name)||e5.exec("ALTER TABLE messages ADD COLUMN sender_kind TEXT"),t_.some(e=>"request_id"===e.name)||e5.exec("ALTER TABLE messages ADD COLUMN request_id TEXT"),e5.exec(`
1828
1830
  CREATE TABLE IF NOT EXISTS conversation_participants (
1829
1831
  conversation_id TEXT NOT NULL,
1830
1832
  participant_kind TEXT NOT NULL,
@@ -1833,7 +1835,7 @@ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",
1833
1835
  PRIMARY KEY (conversation_id, participant_kind, participant_id),
1834
1836
  FOREIGN KEY (conversation_id) REFERENCES conversations(id)
1835
1837
  );
1836
- `),eH(td);let tI=eV(td),tA=function(e){let t=e.prepare("SELECT * FROM work_requests WHERE id = ?"),n=e.prepare("SELECT * FROM work_attempts WHERE id = ?"),i=e.prepare("SELECT * FROM engine_events WHERE request_id = ? ORDER BY sequence ASC"),r=e.prepare("SELECT sequence FROM conversation_projection_cursors WHERE request_id = ?"),s=e.prepare(`
1838
+ `),ew(e5);let tE=eG(e5),tu=function(e){let t=e.prepare("SELECT * FROM work_requests WHERE id = ?"),n=e.prepare("SELECT * FROM work_attempts WHERE id = ?"),i=e.prepare("SELECT * FROM engine_events WHERE request_id = ? ORDER BY sequence ASC"),r=e.prepare("SELECT sequence FROM conversation_projection_cursors WHERE request_id = ?"),s=e.prepare(`
1837
1839
  INSERT INTO conversation_projection_cursors (request_id, sequence) VALUES (?, ?)
1838
1840
  ON CONFLICT (request_id) DO UPDATE SET sequence = excluded.sequence WHERE excluded.sequence > sequence
1839
1841
  `),a=e.prepare(`
@@ -1841,7 +1843,7 @@ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",
1841
1843
  id, conversation_id, engine_event_id, part, request_id, request_sequence, attempt_id, wake_id,
1842
1844
  kind, state, text, data, sort_at, request_created_at, created_at
1843
1845
  ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
1844
- `);function o(e){return e?n.get(e):void 0}function _(n){return e.transaction(()=>{let e=t.get(n);if(!e)return 0;let _=r.get(n)?.sequence??0,d=i.all(n),E=d.length>0?d[d.length-1].sequence:0;if(E<=_)return 0;let u={state:null,lastFinished:null},c=0,l=0;for(let t of d){c=Math.max(c,t.created_at);let n={...u};!function(e,t){let n=e4(t.data);"accepted"===t.type&&e3(n.state)&&(e.state=n.state),"state_changed"===t.type&&e3(n.to)&&(e.state=n.to),"attempt_finished"===t.type&&t.attempt_id&&(e.lastFinished={attemptId:t.attempt_id,outcome:e3(n.outcome)})}(u,t),t.sequence<=_||null!==e.legacy_agent_request_id||(function(e,t,n){let i=e4(e.data),r=e4(t.policy_snapshot),s=null!==t.wake_event_id,a=e3(r.target_name_snapshot)??t.target_agent_id,_={target_agent_id:t.target_agent_id,execution_kind:t.execution_kind,tool_profile:t.tool_profile};switch(e.type){case"accepted":if("blocked"===i.state)return[];if(s)return[{kind:"wake_accepted",attemptId:null,text:`Wake accepted: ${a} (${t.execution_kind})`,data:{..._,target_name:a,requester_kind:t.requester_kind,requester_id:t.requester_id,parent_request_id:t.parent_request_id,depth:t.depth,wake_depth:t.wake_depth,grant_rule:e3(r.grant_rule),grant_id:e3(r.grant_id)}}];return[{kind:"request_queued",attemptId:null,text:"Queued",data:{..._,requester_kind:t.requester_kind,requester_id:t.requester_id}}];case"state_changed":{let e=e3(i.to),r=e3(i.from),d=e3(i.reason);switch(e){case"blocked":if(s&&"queued"===r&&"blocked"===n.state){let e=function(e){if(!e)return{code:null,reason:null};let t=/^([a-z_]+): ([\s\S]*)$/.exec(e);return t?{code:t[1],reason:t[2]}:{code:null,reason:e}}(d);return[e5(a,e.code,e.reason,_)]}return[{kind:"request_blocked",attemptId:null,text:e9("Blocked",d),data:{from:r,reason:d}}];case"queued":if("retry_scheduled"===d){let e="number"==typeof i.attempt_count?i.attempt_count:null,t="number"==typeof i.max_attempts?i.max_attempts:null;return[{kind:"request_retry_scheduled",attemptId:n.lastFinished?.attemptId??null,text:!0===i.manual?`Retry requested${null!==e&&null!==t?` (Attempt ${e+1} of ${t})`:""}`:`Retry scheduled${null!==e&&null!==t?` (Attempt ${e+1} of ${t})`:""}${"number"==typeof i.delay_ms?` in ${i.delay_ms} ms`:""}`,data:{from:r,reason:d,manual:!0===i.manual,attempt_count:e,max_attempts:t,next_eligible_at:i.next_eligible_at??null,delay_ms:i.delay_ms??null,category:i.category??null,outcome:n.lastFinished?.outcome??null}}]}if(s&&"blocked"===r&&("grant_approved"===d||"target_available"===d))return[{kind:"wake_accepted",attemptId:null,text:`Wake accepted: ${a} (${t.execution_kind})`,data:{..._,target_name:a,requester_kind:t.requester_kind,requester_id:t.requester_id,parent_request_id:t.parent_request_id,depth:t.depth,wake_depth:t.wake_depth,reason:d,grant_rule:i.grant_rule??null,grant_id:i.grant_id??null}}];return[{kind:"request_queued",attemptId:null,text:e9("Queued again",d),data:{from:r,reason:d}}];case"running":return[{kind:"request_running",attemptId:null,text:"Running",data:{phase:"dispatched",from:r}}];case"waiting":return[{kind:"request_waiting",attemptId:null,text:e9("Waiting",d),data:{from:r,reason:d}}];case"completed":{let e=n.lastFinished,i=e?.outcome==="succeeded",r=[{kind:"request_completed",attemptId:e?.attemptId??null,text:i?"Completed":"Completed without a successful Attempt outcome",data:{success:i,outcome:e?.outcome??null}}];if(i&&e){let n=o(e.attemptId),i=e4(t.result);r.push({kind:"result",attemptId:e.attemptId,text:n?.output??"Result recorded",data:{reply_message_id:e3(i.reply_message_id),has_output:"string"==typeof n?.output}})}return r}case"failed":case"cancelled":{let s=n.lastFinished,a=t.error_code??e3(i.error_code),o=t.error_message;if("failed"===e&&"timed_out"===d)return[{kind:"request_timed_out",attemptId:s?.attemptId??null,text:"Timed out: the request passed its deadline",data:{success:!1,error_code:a,reason:d,deadline_at:i.deadline_at??null,from:r,outcome:s?.outcome??null}}];if("failed"===e&&"retries_exhausted"===d)return[{kind:"request_retries_exhausted",attemptId:s?.attemptId??null,text:e9(`Retries exhausted after ${i.attempt_count??"?"} of ${i.max_attempts??"?"} Attempts`,o??a),data:{success:!1,error_code:a,error_message:o,reason:d,attempt_count:i.attempt_count??null,max_attempts:i.max_attempts??null,outcome:s?.outcome??null}}];return[{kind:"failed"===e?"request_failed":"request_cancelled",attemptId:s?.attemptId??null,text:"failed"===e?e9("Failed",o??a):"cancel_requested"===d?e9("Cancelled",t.cancel_reason):"grant_denied"===d?"Cancelled: owner denied edit Wake":e9("Cancelled",d??o),data:{success:!1,error_code:a,error_message:o,reason:d,outcome:s?.outcome??null}}]}default:return[]}}case"runtime_started":{let t=e3(i.adapter);return[{kind:"request_running",attemptId:e.attempt_id,text:t?`Running on ${t}`:"Running",data:{phase:"runtime_started",adapter:t,external_run_id:e3(i.external_run_id),success:!1}}]}case"wake_reblocked":return[e5(a,e3(i.reason_code),e3(i.reason),_)];case"dispatch_deferred":return[{kind:"request_queued",attemptId:null,text:"Queued: waiting for capacity",data:{waiting_for:"capacity",limit:e3(i.reason),active_global:i.active_global??null,active_target:i.active_target??null,max_global:i.max_global??null,max_per_target:i.max_per_target??null}}];case"lineage_stopped":return[{kind:"lineage_stopped",attemptId:null,text:"continuation_budget_exhausted"===i.reason?`Stopped: coordinator continuation limit ${i.limit??"?"} reached`:e9("Stopped",e3(i.reason)),data:i}];case"cancel_requested":{let e=e3(i.reason);return[{kind:"request_cancel_requested",attemptId:null,text:e9("Cancel requested",e),data:{by:e3(i.by),reason:e,state:e3(i.state)}}]}case"question":{let t=e3(i.question)??"";return[{kind:"question",attemptId:e.attempt_id,text:t,data:{question:t}}]}case"attempt_finished":{let t=o(e.attempt_id);if(!t)return[];let n=[];try{let e=JSON.parse(t.artifacts);Array.isArray(e)&&(n=e)}catch{}return n.filter(e=>!(e&&"object"==typeof e&&"candidate_manifest"===e.kind)).map(e=>{let n=e&&"object"==typeof e?e:{ref:String(e)},i=e3(n.kind)??"artifact",r=e3(n.ref)??"";return{kind:"artifact",attemptId:t.id,text:`Artifact (${i}): ${r}`,data:{artifact_kind:i,ref:r,outcome:t.outcome}}})}case"candidate_manifest_recorded":{let t=e3(i.manifest_digest),n="number"==typeof i.file_count?i.file_count:0;return[{kind:"artifact",attemptId:e.attempt_id,text:`Candidate manifest ${t}: ${n} ${1===n?"file":"files"} on base ${e3(i.base_commit)}`,data:{artifact_kind:"candidate_manifest",ref:t,...i}}]}case"candidate_manifest_unavailable":return[{kind:"finalization_blocked",attemptId:e.attempt_id,text:e9("Not finalizable",e3(i.reason_code)),data:{phase:"candidate",...i}}];case"finalization_preparing":return[{kind:"finalization_preparing",attemptId:e.attempt_id,text:`Finalization preparing: manifest ${e3(i.manifest_digest)} (${i.file_count??0} files), review ${e3(i.review_request_id)}`,data:i}];case"finalization_retry_pending":return[{kind:"finalization_preparing",attemptId:e.attempt_id,text:e9("Finalization waiting to retry",e3(i.reason_code)),data:{retry:!0,...i}}];case"finalization_committed":return[{kind:"finalization_committed",attemptId:e.attempt_id,text:`Finalization committed: commit ${e3(i.commit)} (tree ${e3(i.tree)}, manifest ${e3(i.result_manifest_digest)??e3(i.manifest_digest)})`,data:{success:!0,...i}}];case"finalization_blocked":case"finalization_failed":case"finalization_canceled":{let t="finalization_blocked"===e.type?"blocked":"finalization_failed"===e.type?"failed":"canceled";return[{kind:e.type,attemptId:e.attempt_id,text:e9(`Finalization ${t}`,e3(i.reason_code)),data:{success:!1,...i}}]}case"finalization_rejected":return[{kind:"finalization_rejected",attemptId:null,text:e9("Finalization not started",e3(i.reason_code)),data:i}];default:return[]}})(t,e,n).forEach((n,i)=>{l+=a.run(`${t.id}:${i}`,e.source_conversation_id,t.id,i,e.id,t.sequence,n.attemptId,e.wake_event_id,n.kind,u.state,n.text,JSON.stringify(n.data),c,e.created_at,t.created_at).changes})}return s.run(n,E),l}).immediate()}function d(t){return e.transaction(()=>e.prepare("SELECT id FROM work_requests WHERE source_conversation_id = ? ORDER BY created_at ASC, id ASC").all(t).reduce((e,t)=>e+_(t.id),0)+function(t){let n=e.prepare(`
1846
+ `);function o(e){return e?n.get(e):void 0}function _(n){return e.transaction(()=>{let e=t.get(n);if(!e)return 0;let _=r.get(n)?.sequence??0,d=i.all(n),E=d.length>0?d[d.length-1].sequence:0;if(E<=_)return 0;let u={state:null,lastFinished:null},c=0,l=0;for(let t of d){c=Math.max(c,t.created_at);let n={...u};!function(e,t){let n=eP(t.data);"accepted"===t.type&&e$(n.state)&&(e.state=n.state),"state_changed"===t.type&&e$(n.to)&&(e.state=n.to),"attempt_finished"===t.type&&t.attempt_id&&(e.lastFinished={attemptId:t.attempt_id,outcome:e$(n.outcome)})}(u,t),t.sequence<=_||null!==e.legacy_agent_request_id||(function(e,t,n){let i=eP(e.data),r=eP(t.policy_snapshot),s=null!==t.wake_event_id,a=e$(r.target_name_snapshot)??t.target_agent_id,_={target_agent_id:t.target_agent_id,execution_kind:t.execution_kind,tool_profile:t.tool_profile};switch(e.type){case"accepted":if("blocked"===i.state)return[];if(s)return[{kind:"wake_accepted",attemptId:null,text:`Wake accepted: ${a} (${t.execution_kind})`,data:{..._,target_name:a,requester_kind:t.requester_kind,requester_id:t.requester_id,parent_request_id:t.parent_request_id,depth:t.depth,wake_depth:t.wake_depth,grant_rule:e$(r.grant_rule),grant_id:e$(r.grant_id)}}];return[{kind:"request_queued",attemptId:null,text:"Queued",data:{..._,requester_kind:t.requester_kind,requester_id:t.requester_id}}];case"state_changed":{let e=e$(i.to),r=e$(i.from),d=e$(i.reason);switch(e){case"blocked":if(s&&"queued"===r&&"blocked"===n.state){let e=function(e){if(!e)return{code:null,reason:null};let t=/^([a-z_]+): ([\s\S]*)$/.exec(e);return t?{code:t[1],reason:t[2]}:{code:null,reason:e}}(d);return[ej(a,e.code,e.reason,_)]}return[{kind:"request_blocked",attemptId:null,text:ez("Blocked",d),data:{from:r,reason:d}}];case"queued":if("retry_scheduled"===d){let e="number"==typeof i.attempt_count?i.attempt_count:null,t="number"==typeof i.max_attempts?i.max_attempts:null;return[{kind:"request_retry_scheduled",attemptId:n.lastFinished?.attemptId??null,text:!0===i.manual?`Retry requested${null!==e&&null!==t?` (Attempt ${e+1} of ${t})`:""}`:`Retry scheduled${null!==e&&null!==t?` (Attempt ${e+1} of ${t})`:""}${"number"==typeof i.delay_ms?` in ${i.delay_ms} ms`:""}`,data:{from:r,reason:d,manual:!0===i.manual,attempt_count:e,max_attempts:t,next_eligible_at:i.next_eligible_at??null,delay_ms:i.delay_ms??null,category:i.category??null,outcome:n.lastFinished?.outcome??null}}]}if(s&&"blocked"===r&&("grant_approved"===d||"target_available"===d))return[{kind:"wake_accepted",attemptId:null,text:`Wake accepted: ${a} (${t.execution_kind})`,data:{..._,target_name:a,requester_kind:t.requester_kind,requester_id:t.requester_id,parent_request_id:t.parent_request_id,depth:t.depth,wake_depth:t.wake_depth,reason:d,grant_rule:i.grant_rule??null,grant_id:i.grant_id??null}}];return[{kind:"request_queued",attemptId:null,text:ez("Queued again",d),data:{from:r,reason:d}}];case"running":return[{kind:"request_running",attemptId:null,text:"Running",data:{phase:"dispatched",from:r}}];case"waiting":return[{kind:"request_waiting",attemptId:null,text:ez("Waiting",d),data:{from:r,reason:d}}];case"completed":{let e=n.lastFinished,i=e?.outcome==="succeeded",r=[{kind:"request_completed",attemptId:e?.attemptId??null,text:i?"Completed":"Completed without a successful Attempt outcome",data:{success:i,outcome:e?.outcome??null}}];if(i&&e){let n=o(e.attemptId),i=eP(t.result);r.push({kind:"result",attemptId:e.attemptId,text:n?.output??"Result recorded",data:{reply_message_id:e$(i.reply_message_id),has_output:"string"==typeof n?.output}})}return r}case"failed":case"cancelled":{let s=n.lastFinished,a=t.error_code??e$(i.error_code),o=t.error_message;if("failed"===e&&"timed_out"===d)return[{kind:"request_timed_out",attemptId:s?.attemptId??null,text:"Timed out: the request passed its deadline",data:{success:!1,error_code:a,reason:d,deadline_at:i.deadline_at??null,from:r,outcome:s?.outcome??null}}];if("failed"===e&&"retries_exhausted"===d)return[{kind:"request_retries_exhausted",attemptId:s?.attemptId??null,text:ez(`Retries exhausted after ${i.attempt_count??"?"} of ${i.max_attempts??"?"} Attempts`,o??a),data:{success:!1,error_code:a,error_message:o,reason:d,attempt_count:i.attempt_count??null,max_attempts:i.max_attempts??null,outcome:s?.outcome??null}}];return[{kind:"failed"===e?"request_failed":"request_cancelled",attemptId:s?.attemptId??null,text:"failed"===e?ez("Failed",o??a):"cancel_requested"===d?ez("Cancelled",t.cancel_reason):"grant_denied"===d?"Cancelled: owner denied edit Wake":ez("Cancelled",d??o),data:{success:!1,error_code:a,error_message:o,reason:d,outcome:s?.outcome??null}}]}default:return[]}}case"runtime_started":{let t=e$(i.adapter);return[{kind:"request_running",attemptId:e.attempt_id,text:t?`Running on ${t}`:"Running",data:{phase:"runtime_started",adapter:t,external_run_id:e$(i.external_run_id),success:!1}}]}case"wake_reblocked":return[ej(a,e$(i.reason_code),e$(i.reason),_)];case"dispatch_deferred":return[{kind:"request_queued",attemptId:null,text:"Queued: waiting for capacity",data:{waiting_for:"capacity",limit:e$(i.reason),active_global:i.active_global??null,active_target:i.active_target??null,max_global:i.max_global??null,max_per_target:i.max_per_target??null}}];case"lineage_stopped":return[{kind:"lineage_stopped",attemptId:null,text:"continuation_budget_exhausted"===i.reason?`Stopped: coordinator continuation limit ${i.limit??"?"} reached`:ez("Stopped",e$(i.reason)),data:i}];case"cancel_requested":{let e=e$(i.reason);return[{kind:"request_cancel_requested",attemptId:null,text:ez("Cancel requested",e),data:{by:e$(i.by),reason:e,state:e$(i.state)}}]}case"question":{let t=e$(i.question)??"";return[{kind:"question",attemptId:e.attempt_id,text:t,data:{question:t}}]}case"attempt_finished":{let t=o(e.attempt_id);if(!t)return[];let n=[];try{let e=JSON.parse(t.artifacts);Array.isArray(e)&&(n=e)}catch{}return n.filter(e=>!(e&&"object"==typeof e&&"candidate_manifest"===e.kind)).map(e=>{let n=e&&"object"==typeof e?e:{ref:String(e)},i=e$(n.kind)??"artifact",r=e$(n.ref)??"";return{kind:"artifact",attemptId:t.id,text:`Artifact (${i}): ${r}`,data:{artifact_kind:i,ref:r,outcome:t.outcome}}})}case"candidate_manifest_recorded":{let t=e$(i.manifest_digest),n="number"==typeof i.file_count?i.file_count:0;return[{kind:"artifact",attemptId:e.attempt_id,text:`Candidate manifest ${t}: ${n} ${1===n?"file":"files"} on base ${e$(i.base_commit)}`,data:{artifact_kind:"candidate_manifest",ref:t,...i}}]}case"candidate_manifest_unavailable":return[{kind:"finalization_blocked",attemptId:e.attempt_id,text:ez("Not finalizable",e$(i.reason_code)),data:{phase:"candidate",...i}}];case"finalization_preparing":return[{kind:"finalization_preparing",attemptId:e.attempt_id,text:`Finalization preparing: manifest ${e$(i.manifest_digest)} (${i.file_count??0} files), review ${e$(i.review_request_id)}`,data:i}];case"finalization_retry_pending":return[{kind:"finalization_preparing",attemptId:e.attempt_id,text:ez("Finalization waiting to retry",e$(i.reason_code)),data:{retry:!0,...i}}];case"finalization_committed":return[{kind:"finalization_committed",attemptId:e.attempt_id,text:`Finalization committed: commit ${e$(i.commit)} (tree ${e$(i.tree)}, manifest ${e$(i.result_manifest_digest)??e$(i.manifest_digest)})`,data:{success:!0,...i}}];case"finalization_blocked":case"finalization_failed":case"finalization_canceled":{let t="finalization_blocked"===e.type?"blocked":"finalization_failed"===e.type?"failed":"canceled";return[{kind:e.type,attemptId:e.attempt_id,text:ez(`Finalization ${t}`,e$(i.reason_code)),data:{success:!1,...i}}]}case"finalization_rejected":return[{kind:"finalization_rejected",attemptId:null,text:ez("Finalization not started",e$(i.reason_code)),data:i}];default:return[]}})(t,e,n).forEach((n,i)=>{l+=a.run(`${t.id}:${i}`,e.source_conversation_id,t.id,i,e.id,t.sequence,n.attemptId,e.wake_event_id,n.kind,u.state,n.text,JSON.stringify(n.data),c,e.created_at,t.created_at).changes})}return s.run(n,E),l}).immediate()}function d(t){return e.transaction(()=>e.prepare("SELECT id FROM work_requests WHERE source_conversation_id = ? ORDER BY created_at ASC, id ASC").all(t).reduce((e,t)=>e+_(t.id),0)+function(t){let n=e.prepare(`
1845
1847
  SELECT w.* FROM wakes w
1846
1848
  WHERE w.source_conversation_id = ? AND w.status = 'rejected'
1847
1849
  AND NOT EXISTS (SELECT 1 FROM conversation_events e WHERE e.id = 'wake:' || w.id || ':0')
@@ -1849,7 +1851,7 @@ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",
1849
1851
  `).all(t),i=0;for(let e of n){let t={wake_id:e.id,target_name:e.target_name_snapshot??e.requested_target,target_agent_id:e.target_agent_id,execution_kind:e.execution_kind,requester_agent_id:e.requester_agent_id,parent_request_id:e.parent_request_id,reason_code:e.reason_code,reason:e.reason,limit:e.limit_value,observed:e.observed_value,work_request_id:null};i+=a.run(`wake:${e.id}:0`,e.source_conversation_id,null,0,null,0,null,e.id,"wake_rejected",null,function(e){let t=e.target_name_snapshot??e.requested_target??"an unnamed target";switch(e.reason_code){case"untracked_lineage":return"Wake not started: its source turn is not tracked work";case"depth_exceeded":return`Wake not started: ${t} — depth limit ${e.limit_value??"?"} reached`;case"root_budget_exhausted":return`Wake not started: ${t} — this work already used ${e.observed_value??e.limit_value??"?"} Wakes`;default:return e.reason?`Wake not started: ${t} — ${e.reason}`:`Wake not started: ${t}`}}(e),JSON.stringify(t),e.updated_at,e.created_at,e.updated_at).changes}return i}(t)).immediate()}function E(t){return e.prepare(`
1850
1852
  SELECT * FROM conversation_events WHERE conversation_id = ?
1851
1853
  ORDER BY sort_at ASC, request_created_at ASC, COALESCE(request_id, wake_id) ASC, request_sequence ASC, part ASC
1852
- `).all(t)}return{projectRequest:_,projectConversation:d,projectEvent:function(e){return _(e.request_id)},listConversationEventRows:E,listConversationEvents:function(e){return d(e),E(e).map((e,t)=>({eventId:e.id,seq:t+1,kind:e.kind,requestId:e.request_id,requestSequence:e.request_sequence,attemptId:e.attempt_id,wakeId:e.wake_id,engineEventId:e.engine_event_id,state:e.state,text:e.text,data:e4(e.data),createdAt:e.created_at}))}}}(td),tS=(td.exec(`
1854
+ `).all(t)}return{projectRequest:_,projectConversation:d,projectEvent:function(e){return _(e.request_id)},listConversationEventRows:E,listConversationEvents:function(e){return d(e),E(e).map((e,t)=>({eventId:e.id,seq:t+1,kind:e.kind,requestId:e.request_id,requestSequence:e.request_sequence,attemptId:e.attempt_id,wakeId:e.wake_id,engineEventId:e.engine_event_id,state:e.state,text:e.text,data:eP(e.data),createdAt:e.created_at}))}}}(e5),tc=(e5.exec(`
1853
1855
  CREATE TABLE IF NOT EXISTS service_audit_events (
1854
1856
  id INTEGER PRIMARY KEY AUTOINCREMENT,
1855
1857
  at INTEGER NOT NULL,
@@ -1871,13 +1873,13 @@ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",
1871
1873
  BEGIN
1872
1874
  SELECT RAISE(ABORT, 'service_audit_events are append-only');
1873
1875
  END;
1874
- `),t=td.prepare(`
1876
+ `),t=e5.prepare(`
1875
1877
  INSERT INTO service_audit_events (at, principal, operation, capability, target_kind, target_ref, agent_id, outcome, code)
1876
1878
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
1877
- `),{append(e){let n=`${e.principal.kind}:${te(e.principal.id)??"[invalid]"}`;t.run(e.at??Date.now(),n.slice(0,200),tt(e.operation,"unknown"),tt(e.capability,"none"),e.targetKind,te(e.targetRef),te(e.agentId),e.outcome,e.code?tt(e.code,"unknown"):null)},list(e={}){let t=Math.min(Math.max(1,e.limit??50),500);return e.principal?td.prepare("SELECT * FROM service_audit_events WHERE principal = ? ORDER BY id DESC LIMIT ?").all(e.principal,t):td.prepare("SELECT * FROM service_audit_events ORDER BY id DESC LIMIT ?").all(t)}}),tk={kind:"person",id:"local-owner"},tf=td.prepare("INSERT OR IGNORE INTO conversation_participants (conversation_id, participant_kind, participant_id, joined_at) VALUES (?, ?, ?, ?)");function tv(e,t,n){for(let i of(td.prepare("UPDATE conversations SET origin_kind = ?, origin_id = ? WHERE id = ? AND origin_kind IS NULL").run(tk.kind,tk.id,e),tf.run(e,tk.kind,tk.id,n),t))tf.run(e,"bot",i,n)}td.transaction(()=>{td.exec("UPDATE messages SET sender_kind = 'person' WHERE sender_kind IS NULL AND sender_type = 'user'"),td.exec("UPDATE messages SET sender_kind = 'bot' WHERE sender_kind IS NULL AND sender_type = 'bot'");let e=td.prepare("SELECT id, type, bot_id, group_id, created_at FROM conversations WHERE origin_kind IS NULL AND type IN ('bot', 'group')").all(),t=td.prepare("SELECT bot_id FROM group_members WHERE group_id = ?");for(let n of e){let e="bot"===n.type?n.bot_id?[n.bot_id]:[]:n.group_id?t.all(n.group_id).map(e=>e.bot_id):[];tv(n.id,e,n.created_at)}})();let th={getAll:()=>td.prepare("SELECT * FROM runtime_connections ORDER BY created_at ASC, id ASC").all(),getById:e=>{let t=td.prepare("SELECT * FROM runtime_connections WHERE id = ?").get(e);return t&&a.AGENTS.includes(t.provider)?t:void 0},create:e=>{let t={id:`rc-${(0,s.randomUUID)()}`,...e,created_at:Date.now()};return td.prepare("INSERT INTO runtime_connections (id, provider, label, host, created_at) VALUES (?, ?, ?, ?, ?)").run(t.id,t.provider,t.label,t.host,t.created_at),t},ensureLocal:e=>tT(e),agentCount:e=>td.prepare("SELECT COUNT(*) AS n FROM bots WHERE runtime_connection_id = ?").get(e).n},tw=["session_scope_kind","session_scope_items","policy_mode","allow_new_sessions","allow_resume_with_edits"],tC={create:(e,t)=>{let n=tR(e.name),i={id:t?.id||(0,s.randomUUID)(),...e,...n,color:tL(),created_at:t?.created_at??Date.now()};i.agent=i.agent||a.DEFAULT_AGENT,i.deck_id=i.deck_id||null,i.needs_deck_selection=!i.deck_id||i.needs_deck_selection?1:0;let r=X({...i,needs_deck_selection:i.needs_deck_selection});i.runtime_connection_id||(i.runtime_connection_id=tT(r.provider,i.created_at)),void 0===i.launch_profile&&(i.launch_profile=r.launch_profile),"direct"===i.launch_profile&&(i.deck_id=null,i.working_directory=null,i.needs_deck_selection=0),i.session_scope_kind||(i.session_scope_kind=r.session_scope_kind,i.session_scope_items=r.session_scope_items),i.policy_mode||(i.policy_mode=r.policy_mode,i.allow_new_sessions=r.allow_new_sessions,i.allow_resume_with_edits=r.allow_resume_with_edits),tm(i.name,()=>td.prepare(`INSERT INTO bots (id, name, name_key, title, description, avatar, color, hermes_profile, agent, deck_id, deck_name, working_directory, needs_deck_selection,
1879
+ `),{append(e){let n=`${e.principal.kind}:${eV(e.principal.id)??"[invalid]"}`;t.run(e.at??Date.now(),n.slice(0,200),eZ(e.operation,"unknown"),eZ(e.capability,"none"),e.targetKind,eV(e.targetRef),eV(e.agentId),e.outcome,e.code?eZ(e.code,"unknown"):null)},list(e={}){let t=Math.min(Math.max(1,e.limit??50),500);return e.principal?e5.prepare("SELECT * FROM service_audit_events WHERE principal = ? ORDER BY id DESC LIMIT ?").all(e.principal,t):e5.prepare("SELECT * FROM service_audit_events ORDER BY id DESC LIMIT ?").all(t)}}),tl={kind:"person",id:"local-owner"},tT=e5.prepare("INSERT OR IGNORE INTO conversation_participants (conversation_id, participant_kind, participant_id, joined_at) VALUES (?, ?, ?, ?)");function tp(e,t,n){for(let i of(e5.prepare("UPDATE conversations SET origin_kind = ?, origin_id = ? WHERE id = ? AND origin_kind IS NULL").run(tl.kind,tl.id,e),tT.run(e,tl.kind,tl.id,n),t))tT.run(e,"bot",i,n)}e5.transaction(()=>{e5.exec("UPDATE messages SET sender_kind = 'person' WHERE sender_kind IS NULL AND sender_type = 'user'"),e5.exec("UPDATE messages SET sender_kind = 'bot' WHERE sender_kind IS NULL AND sender_type = 'bot'");let e=e5.prepare("SELECT id, type, bot_id, group_id, created_at FROM conversations WHERE origin_kind IS NULL AND type IN ('bot', 'group')").all(),t=e5.prepare("SELECT bot_id FROM group_members WHERE group_id = ?");for(let n of e){let e="bot"===n.type?n.bot_id?[n.bot_id]:[]:n.group_id?t.all(n.group_id).map(e=>e.bot_id):[];tp(n.id,e,n.created_at)}})();let tN={getAll:()=>e5.prepare("SELECT * FROM runtime_connections ORDER BY created_at ASC, id ASC").all(),getById:e=>{let t=e5.prepare("SELECT * FROM runtime_connections WHERE id = ?").get(e);return t&&a.AGENTS.includes(t.provider)?t:void 0},create:e=>{let t={id:`rc-${(0,s.randomUUID)()}`,...e,created_at:Date.now()};return e5.prepare("INSERT INTO runtime_connections (id, provider, label, host, created_at) VALUES (?, ?, ?, ?, ?)").run(t.id,t.provider,t.label,t.host,t.created_at),t},ensureLocal:e=>tn(e),agentCount:e=>e5.prepare("SELECT COUNT(*) AS n FROM bots WHERE runtime_connection_id = ?").get(e).n},tR=["session_scope_kind","session_scope_items","policy_mode","allow_new_sessions","allow_resume_with_edits"],tm={create:(e,t)=>{let n=ts(e.name),i={id:t?.id||(0,s.randomUUID)(),...e,...n,color:to(),created_at:t?.created_at??Date.now()};i.agent=i.agent||a.DEFAULT_AGENT,i.deck_id=null,i.deck_name=i.deck_name||null,i.working_directory=null,i.needs_deck_selection=0,i.launch_profile="direct";let r=q(i);i.runtime_connection_id||(i.runtime_connection_id=tn(r.provider,i.created_at)),i.session_scope_kind||(i.session_scope_kind=r.session_scope_kind,i.session_scope_items=r.session_scope_items),i.policy_mode||(i.policy_mode=r.policy_mode,i.allow_new_sessions=r.allow_new_sessions,i.allow_resume_with_edits=r.allow_resume_with_edits),ta(i.name,()=>e5.prepare(`INSERT INTO bots (id, name, name_key, title, description, avatar, color, hermes_profile, agent, deck_id, deck_name, working_directory, needs_deck_selection,
1878
1880
  runtime_connection_id, launch_profile, session_scope_kind, session_scope_items, default_workspace, policy_mode, allow_new_sessions, allow_resume_with_edits, home_session_id,
1879
1881
  avatar_color, avatar_eyes, avatar_hands, avatar_accessory, created_at)
1880
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(i.id,i.name,i.name_key,i.title,i.description,i.avatar||null,i.color,i.hermes_profile||null,i.agent,i.deck_id,i.deck_name||null,i.working_directory||null,i.needs_deck_selection,i.runtime_connection_id,i.launch_profile??null,i.session_scope_kind,i.session_scope_items??"[]",i.default_workspace||null,i.policy_mode,+!!i.allow_new_sessions,+!!i.allow_resume_with_edits,null,i.avatar_color||null,i.avatar_eyes||null,i.avatar_hands||null,i.avatar_accessory||null,i.created_at));let o=(0,s.randomUUID)();return td.prepare("INSERT INTO conversations (id, type, bot_id, created_at) VALUES (?, ?, ?, ?)").run(o,"bot",i.id,i.created_at),tv(o,[i.id],i.created_at),i},createFromImport:(e,t)=>{let n=tR(e.name),i={id:(0,s.randomUUID)(),...e,...n,color:tL(),created_at:Date.now(),agent:a.DEFAULT_AGENT,deck_id:null,deck_name:null,working_directory:null,needs_deck_selection:1,source_provider:t.source_provider,template_id:t.template_id,template_url:t.template_url,import_schema_version:t.import_schema_version,import_operation_id:t.import_operation_id,import_timestamp:t.import_timestamp},r=X(i);Object.assign(i,{runtime_connection_id:tT(r.provider,i.created_at),launch_profile:null,session_scope_kind:r.session_scope_kind,session_scope_items:r.session_scope_items,policy_mode:r.policy_mode,allow_new_sessions:r.allow_new_sessions,allow_resume_with_edits:r.allow_resume_with_edits}),tm(i.name,()=>td.prepare(`INSERT INTO bots (
1882
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(i.id,i.name,i.name_key,i.title,i.description,i.avatar||null,i.color,i.hermes_profile||null,i.agent,i.deck_id,i.deck_name||null,i.working_directory||null,i.needs_deck_selection,i.runtime_connection_id,i.launch_profile??null,i.session_scope_kind,i.session_scope_items??"[]",i.default_workspace||null,i.policy_mode,+!!i.allow_new_sessions,+!!i.allow_resume_with_edits,null,i.avatar_color||null,i.avatar_eyes||null,i.avatar_hands||null,i.avatar_accessory||null,i.created_at));let o=(0,s.randomUUID)();return e5.prepare("INSERT INTO conversations (id, type, bot_id, created_at) VALUES (?, ?, ?, ?)").run(o,"bot",i.id,i.created_at),tp(o,[i.id],i.created_at),i},createFromImport:(e,t)=>{let n=ts(e.name),i={id:(0,s.randomUUID)(),...e,...n,color:to(),created_at:Date.now(),agent:a.DEFAULT_AGENT,deck_id:null,deck_name:null,working_directory:null,needs_deck_selection:0,launch_profile:"direct",source_provider:t.source_provider,template_id:t.template_id,template_url:t.template_url,import_schema_version:t.import_schema_version,import_operation_id:t.import_operation_id,import_timestamp:t.import_timestamp},r=q(i);Object.assign(i,{runtime_connection_id:tn(r.provider,i.created_at),session_scope_kind:r.session_scope_kind,session_scope_items:r.session_scope_items,policy_mode:r.policy_mode,allow_new_sessions:r.allow_new_sessions,allow_resume_with_edits:r.allow_resume_with_edits}),ta(i.name,()=>e5.prepare(`INSERT INTO bots (
1881
1883
  id, name, name_key, title, description, avatar, color, created_at,
1882
1884
  source_provider, template_id, template_url, import_schema_version,
1883
1885
  import_operation_id, import_timestamp,
@@ -1885,29 +1887,29 @@ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",
1885
1887
  needs_deck_selection,
1886
1888
  runtime_connection_id, launch_profile, session_scope_kind, session_scope_items,
1887
1889
  policy_mode, allow_new_sessions, allow_resume_with_edits
1888
- ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(i.id,i.name,i.name_key,i.title,i.description,i.avatar||null,i.color,i.created_at,i.source_provider,i.template_id,i.template_url,i.import_schema_version,i.import_operation_id,i.import_timestamp,i.agent,i.deck_id,i.deck_name,i.working_directory,i.needs_deck_selection,i.runtime_connection_id,i.launch_profile,i.session_scope_kind,i.session_scope_items,i.policy_mode,i.allow_new_sessions,i.allow_resume_with_edits));let o=(0,s.randomUUID)();return td.prepare("INSERT INTO conversations (id, type, bot_id, created_at) VALUES (?, ?, ?, ?)").run(o,"bot",i.id,i.created_at),tv(o,[i.id],i.created_at),i},getByImportOperationId:e=>td.prepare("SELECT * FROM bots WHERE import_operation_id = ?").get(e),getAll:()=>td.prepare("SELECT * FROM bots ORDER BY created_at DESC").all(),getById:e=>td.prepare("SELECT * FROM bots WHERE id = ?").get(e),setAvatar:(e,t)=>{td.prepare("UPDATE bots SET avatar = ? WHERE id = ?").run(t,e)},getByName:e=>{let t=tr(e);if(t)return td.prepare("SELECT * FROM bots WHERE name_key = ?").get(t)},updateIdentity:(e,t,n,i)=>{let r=tR(t,e);tm(r.name,()=>td.prepare("UPDATE bots SET name = ?, name_key = ?, title = ?, description = ? WHERE id = ?").run(r.name,r.name_key,n,i,e))},setPinned:(e,t)=>{td.prepare("UPDATE bots SET pinned = ? WHERE id = ?").run(+!!t,e)},setHidden:(e,t)=>{td.prepare("UPDATE bots SET hidden = ? WHERE id = ?").run(+!!t,e)},setHermesProfile:(e,t)=>{let n=t&&t.trim()?t.trim():null;td.prepare("UPDATE bots SET hermes_profile = ? WHERE id = ?").run(n,e)},updateRegistration:(e,t,n)=>{let i=tC.getById(e);if(!i)return;let r=W(n),s="agent_deck"===n.launch_profile&&n.deck_id?null:i.deck_name??null;td.prepare(`UPDATE bots SET agent = ?, deck_name = ?, runtime_connection_id = ?, launch_profile = ?, deck_id = ?, working_directory = ?,
1890
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(i.id,i.name,i.name_key,i.title,i.description,i.avatar||null,i.color,i.created_at,i.source_provider,i.template_id,i.template_url,i.import_schema_version,i.import_operation_id,i.import_timestamp,i.agent,i.deck_id,i.deck_name,i.working_directory,i.needs_deck_selection,i.runtime_connection_id,i.launch_profile,i.session_scope_kind,i.session_scope_items,i.policy_mode,i.allow_new_sessions,i.allow_resume_with_edits));let o=(0,s.randomUUID)();return e5.prepare("INSERT INTO conversations (id, type, bot_id, created_at) VALUES (?, ?, ?, ?)").run(o,"bot",i.id,i.created_at),tp(o,[i.id],i.created_at),i},getByImportOperationId:e=>e5.prepare("SELECT * FROM bots WHERE import_operation_id = ?").get(e),getAll:()=>e5.prepare("SELECT * FROM bots ORDER BY created_at DESC").all(),getById:e=>e5.prepare("SELECT * FROM bots WHERE id = ?").get(e),setAvatar:(e,t)=>{e5.prepare("UPDATE bots SET avatar = ? WHERE id = ?").run(t,e)},getByName:e=>{let t=e2(e);if(t)return e5.prepare("SELECT * FROM bots WHERE name_key = ?").get(t)},updateIdentity:(e,t,n,i)=>{let r=ts(t,e);ta(r.name,()=>e5.prepare("UPDATE bots SET name = ?, name_key = ?, title = ?, description = ? WHERE id = ?").run(r.name,r.name_key,n,i,e))},setPinned:(e,t)=>{e5.prepare("UPDATE bots SET pinned = ? WHERE id = ?").run(+!!t,e)},setHidden:(e,t)=>{e5.prepare("UPDATE bots SET hidden = ? WHERE id = ?").run(+!!t,e)},setHermesProfile:(e,t)=>{let n=t&&t.trim()?t.trim():null;e5.prepare("UPDATE bots SET hermes_profile = ? WHERE id = ?").run(n,e)},updateRegistration:(e,t,n)=>{let i=C(n);e5.prepare(`UPDATE bots SET agent = ?, runtime_connection_id = ?, launch_profile = ?, deck_id = ?, working_directory = ?,
1889
1891
  session_scope_kind = ?, session_scope_items = ?, default_workspace = ?, policy_mode = ?, allow_new_sessions = ?,
1890
- allow_resume_with_edits = ?, home_session_id = ?, needs_deck_selection = ? WHERE id = ?`).run(t,s,r.runtime_connection_id,r.launch_profile,r.deck_id,r.working_directory,r.session_scope_kind,r.session_scope_items,r.default_workspace,r.policy_mode,r.allow_new_sessions,r.allow_resume_with_edits,r.home_session_id,r.needs_deck_selection,e)},updateAgentSelection:(e,t)=>{let n=tC.getById(e);if(!n)return;let i=(0,a.applyAgentUpdate)(n,t),r=void 0!==t.deck_id?"agent_deck":n.launch_profile??null,s=n.runtime_connection_id?th.getById(n.runtime_connection_id):void 0,o=s&&s.provider===i.agent?s.id:tT(i.agent);td.prepare("UPDATE bots SET agent = ?, deck_id = ?, deck_name = ?, working_directory = ?, needs_deck_selection = ?, launch_profile = ?, runtime_connection_id = ? WHERE id = ?").run(i.agent,"direct"===r?null:i.deck_id,i.deck_name,"direct"===r?null:i.working_directory,"direct"===r?0:+!!i.needs_deck_selection,r,o,e)},updateAvatarConfig:(e,t)=>{let n=tC.getById(e);if(!n)return;let i=(e,t)=>void 0===e?t||null:e&&String(e).trim()?String(e).trim():null;td.prepare("UPDATE bots SET avatar_color = ?, avatar_eyes = ?, avatar_hands = ?, avatar_accessory = ? WHERE id = ?").run(i(t.avatar_color,n.avatar_color),i(t.avatar_eyes,n.avatar_eyes),i(t.avatar_hands,n.avatar_hands),i(t.avatar_accessory,n.avatar_accessory),e)},touchSeen:()=>{td.prepare("UPDATE bots SET last_seen = ?").run(Date.now())},markUnread:e=>{td.prepare("UPDATE bots SET unread = 1 WHERE id = ?").run(e)},markRead:e=>{td.prepare("UPDATE bots SET unread = 0 WHERE id = ?").run(e)},remove:e=>{tC.removeMany([e])},deletionPreview:e=>{var t;let n=new Set(e),i=[],r=[],s=[],a=new Set(ty());for(let t of e){let e=tC.getById(t);if(!e){r.push(t);continue}i.push({id:e.id,name:e.name}),(0,J.isChiefOfStaffName)(e.name)?s.push({id:e.id,name:e.name,reason:"chief"}):a.has(e.id)&&s.push({id:e.id,name:e.name,reason:"active"})}return{agents:i,groups:0===(t=n).size?[]:td.prepare(`SELECT DISTINCT g.id, g.name, g.owner_bot_id, g.created_at FROM groups g
1892
+ allow_resume_with_edits = ?, home_session_id = ?, needs_deck_selection = ? WHERE id = ?`).run(t,i.runtime_connection_id,i.launch_profile,i.deck_id,i.working_directory,i.session_scope_kind,i.session_scope_items,i.default_workspace,i.policy_mode,i.allow_new_sessions,i.allow_resume_with_edits,i.home_session_id,i.needs_deck_selection,e)},updateAvatarConfig:(e,t)=>{let n=tm.getById(e);if(!n)return;let i=(e,t)=>void 0===e?t||null:e&&String(e).trim()?String(e).trim():null;e5.prepare("UPDATE bots SET avatar_color = ?, avatar_eyes = ?, avatar_hands = ?, avatar_accessory = ? WHERE id = ?").run(i(t.avatar_color,n.avatar_color),i(t.avatar_eyes,n.avatar_eyes),i(t.avatar_hands,n.avatar_hands),i(t.avatar_accessory,n.avatar_accessory),e)},touchSeen:()=>{e5.prepare("UPDATE bots SET last_seen = ?").run(Date.now())},markUnread:e=>{e5.prepare("UPDATE bots SET unread = 1 WHERE id = ?").run(e)},markRead:e=>{e5.prepare("UPDATE bots SET unread = 0 WHERE id = ?").run(e)},remove:e=>{tm.removeMany([e])},deletionPreview:e=>{var t;let n=new Set(e),i=[],r=[],s=[],a=new Set(tO());for(let t of e){let e=tm.getById(t);if(!e){r.push(t);continue}i.push({id:e.id,name:e.name}),(0,G.isChiefOfStaffName)(e.name)?s.push({id:e.id,name:e.name,reason:"chief"}):a.has(e.id)&&s.push({id:e.id,name:e.name,reason:"active"})}return{agents:i,groups:0===(t=n).size?[]:e5.prepare(`SELECT DISTINCT g.id, g.name, g.owner_bot_id, g.created_at FROM groups g
1891
1893
  JOIN group_members gm ON gm.group_id = g.id
1892
1894
  WHERE gm.bot_id IN (${[...t].map(()=>"?").join(", ")})
1893
- ORDER BY g.created_at ASC, g.id ASC`).all(...t).map(e=>{let n=td.prepare(`SELECT b.id, b.name FROM bots b JOIN group_members gm ON gm.bot_id = b.id
1894
- WHERE gm.group_id = ? ORDER BY b.created_at ASC, b.id ASC`).all(e.id).filter(e=>!t.has(e.id));return n.length<2?{id:e.id,name:e.name,outcome:"removed",remaining:n.length,newOwner:null}:e.owner_bot_id&&t.has(e.owner_bot_id)?{id:e.id,name:e.name,outcome:"reassigned",remaining:n.length,newOwner:n[0]}:{id:e.id,name:e.name,outcome:"shrunk",remaining:n.length,newOwner:null}}),missing:r,blocked:s}},removeMany:(e,t)=>td.transaction(()=>{let n=tC.deletionPreview(e);if(n.missing.length>0||n.blocked.length>0)throw new tq(n);let i=new Set(e);for(let e of n.groups){if("removed"===e.outcome){var r=e.id;for(let e of td.prepare("SELECT id FROM conversations WHERE group_id = ?").all(r))tU(e.id);td.prepare("DELETE FROM group_members WHERE group_id = ?").run(r),td.prepare("DELETE FROM groups WHERE id = ?").run(r);continue}let t=td.prepare("SELECT id FROM conversations WHERE group_id = ?").all(e.id).map(e=>e.id);for(let n of i)for(let i of(td.prepare("DELETE FROM group_members WHERE group_id = ? AND bot_id = ?").run(e.id,n),t))td.prepare("DELETE FROM conversation_participants WHERE conversation_id = ? AND participant_kind = 'bot' AND participant_id = ?").run(i,n);e.newOwner&&td.prepare("UPDATE groups SET owner_bot_id = ? WHERE id = ?").run(e.newOwner.id,e.id)}for(let n of e){for(let e of td.prepare("SELECT id FROM conversations WHERE bot_id = ?").all(n))tU(e.id);e6(td,n),tD("bot_id",n),td.prepare("DELETE FROM launch_snapshots WHERE bot_id = ?").run(n),td.prepare("DELETE FROM group_members WHERE bot_id = ?").run(n),td.prepare("DELETE FROM conversation_participants WHERE participant_kind = 'bot' AND participant_id = ? AND conversation_id IN (SELECT id FROM conversations WHERE type = 'group')").run(n),td.prepare("DELETE FROM memories WHERE bot_id = ?").run(n),td.prepare("DELETE FROM one_shots WHERE bot_id = ?").run(n),td.prepare("DELETE FROM routines WHERE bot_id = ?").run(n),td.prepare("DELETE FROM pending_questions WHERE bot_id = ?").run(n),td.prepare("DELETE FROM approval_requests WHERE bot_id = ?").run(n),td.prepare("DELETE FROM wake_targets WHERE target_bot_id = ?").run(n),td.prepare("DELETE FROM bots WHERE id = ?").run(n),t?.onAgentDeleted?.(n)}return n})(),managementRows:()=>{let e=td.prepare("SELECT * FROM bots ORDER BY created_at DESC, id ASC").all(),t=new Set(ty()),n=new Map,i=e=>{for(let t of e)t.id&&t.at&&(n.get(t.id)??0)<t.at&&n.set(t.id,t.at)};return i(td.prepare("SELECT c.bot_id AS id, MAX(m.created_at) AS at FROM messages m JOIN conversations c ON c.id = m.conversation_id WHERE c.type = 'bot' GROUP BY c.bot_id").all()),i(td.prepare("SELECT sender_id AS id, MAX(created_at) AS at FROM messages WHERE sender_type = 'bot' AND sender_id IS NOT NULL GROUP BY sender_id").all()),e.map(e=>({bot:e,last_activity:n.get(e.id)??null,blocked:(0,J.isChiefOfStaffName)(e.name)?"chief":t.has(e.id)?"active":null}))}};class tq extends Error{preview;constructor(e){super(e.missing.length>0?"Agent not found":"Some agents cannot be deleted"),this.preview=e}}function ty(){return td.prepare(`
1895
+ ORDER BY g.created_at ASC, g.id ASC`).all(...t).map(e=>{let n=e5.prepare(`SELECT b.id, b.name FROM bots b JOIN group_members gm ON gm.bot_id = b.id
1896
+ WHERE gm.group_id = ? ORDER BY b.created_at ASC, b.id ASC`).all(e.id).filter(e=>!t.has(e.id));return n.length<2?{id:e.id,name:e.name,outcome:"removed",remaining:n.length,newOwner:null}:e.owner_bot_id&&t.has(e.owner_bot_id)?{id:e.id,name:e.name,outcome:"reassigned",remaining:n.length,newOwner:n[0]}:{id:e.id,name:e.name,outcome:"shrunk",remaining:n.length,newOwner:null}}),missing:r,blocked:s}},removeMany:(e,t)=>e5.transaction(()=>{let n=tm.deletionPreview(e);if(n.missing.length>0||n.blocked.length>0)throw new tL(n);let i=new Set(e);for(let e of n.groups){if("removed"===e.outcome){var r=e.id;for(let e of e5.prepare("SELECT id FROM conversations WHERE group_id = ?").all(r))tA(e.id);e5.prepare("DELETE FROM group_members WHERE group_id = ?").run(r),e5.prepare("DELETE FROM groups WHERE id = ?").run(r);continue}let t=e5.prepare("SELECT id FROM conversations WHERE group_id = ?").all(e.id).map(e=>e.id);for(let n of i)for(let i of(e5.prepare("DELETE FROM group_members WHERE group_id = ? AND bot_id = ?").run(e.id,n),t))e5.prepare("DELETE FROM conversation_participants WHERE conversation_id = ? AND participant_kind = 'bot' AND participant_id = ?").run(i,n);e.newOwner&&e5.prepare("UPDATE groups SET owner_bot_id = ? WHERE id = ?").run(e.newOwner.id,e.id)}for(let n of e){for(let e of e5.prepare("SELECT id FROM conversations WHERE bot_id = ?").all(n))tA(e.id);eY(e5,n),tI("bot_id",n),e5.prepare("DELETE FROM launch_snapshots WHERE bot_id = ?").run(n),e5.prepare("DELETE FROM group_members WHERE bot_id = ?").run(n),e5.prepare("DELETE FROM conversation_participants WHERE participant_kind = 'bot' AND participant_id = ? AND conversation_id IN (SELECT id FROM conversations WHERE type = 'group')").run(n),e5.prepare("DELETE FROM memories WHERE bot_id = ?").run(n),e5.prepare("DELETE FROM one_shots WHERE bot_id = ?").run(n),e5.prepare("DELETE FROM routines WHERE bot_id = ?").run(n),e5.prepare("DELETE FROM pending_questions WHERE bot_id = ?").run(n),e5.prepare("DELETE FROM approval_requests WHERE bot_id = ?").run(n),e5.prepare("DELETE FROM wake_targets WHERE target_bot_id = ?").run(n),e5.prepare("DELETE FROM bots WHERE id = ?").run(n),t?.onAgentDeleted?.(n)}return n})(),managementRows:()=>{let e=e5.prepare("SELECT * FROM bots ORDER BY created_at DESC, id ASC").all(),t=new Set(tO()),n=new Map,i=e=>{for(let t of e)t.id&&t.at&&(n.get(t.id)??0)<t.at&&n.set(t.id,t.at)};return i(e5.prepare("SELECT c.bot_id AS id, MAX(m.created_at) AS at FROM messages m JOIN conversations c ON c.id = m.conversation_id WHERE c.type = 'bot' GROUP BY c.bot_id").all()),i(e5.prepare("SELECT sender_id AS id, MAX(created_at) AS at FROM messages WHERE sender_type = 'bot' AND sender_id IS NOT NULL GROUP BY sender_id").all()),e.map(e=>({bot:e,last_activity:n.get(e.id)??null,blocked:(0,G.isChiefOfStaffName)(e.name)?"chief":t.has(e.id)?"active":null}))}};class tL extends Error{preview;constructor(e){super(e.missing.length>0?"Agent not found":"Some agents cannot be deleted"),this.preview=e}}function tO(){return e5.prepare(`
1895
1897
  SELECT DISTINCT target_agent_id AS bot_id FROM work_requests
1896
1898
  WHERE (executor <> 'dispatcher' AND state IN ('queued', 'running'))
1897
1899
  OR (executor = 'dispatcher' AND state = 'running' AND json_extract(policy_snapshot, '$.surface') = 'ui')
1898
- `).all().map(e=>e.bot_id)}function tb(){return new Set(td.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name IN ('legacy_agent_requests_archive', 'legacy_agent_request_events_archive', 'legacy_processing_queue_archive')").all().map(e=>e.name))}function tD(e,t){tb().has("legacy_processing_queue_archive")&&td.prepare(`DELETE FROM legacy_processing_queue_archive WHERE ${e} = ?`).run(t)}function tU(e){let t;e2(td,e),td.prepare("DELETE FROM draft_actions WHERE message_id IN (SELECT id FROM messages WHERE conversation_id = ?)").run(e),t=tb(),tD("conversation_id",e),t.has("legacy_agent_request_events_archive")&&t.has("legacy_agent_requests_archive")&&td.prepare("DELETE FROM legacy_agent_request_events_archive WHERE request_id IN (SELECT id FROM legacy_agent_requests_archive WHERE conversation_id = ?)").run(e),t.has("legacy_agent_requests_archive")&&td.prepare("DELETE FROM legacy_agent_requests_archive WHERE conversation_id = ?").run(e),td.prepare("DELETE FROM messages WHERE conversation_id = ?").run(e),td.prepare("DELETE FROM pending_questions WHERE conversation_id = ?").run(e),td.prepare("DELETE FROM approvals WHERE conversation_id = ?").run(e),td.prepare("DELETE FROM approval_requests WHERE conversation_id = ?").run(e),td.prepare("DELETE FROM one_shots WHERE conversation_id = ?").run(e),td.prepare("DELETE FROM routines WHERE conversation_id = ?").run(e),td.prepare("DELETE FROM wake_targets WHERE conversation_id = ?").run(e),td.prepare("DELETE FROM conversation_participants WHERE conversation_id = ?").run(e),td.prepare("DELETE FROM conversations WHERE id = ?").run(e)}let tF={getByBotId:e=>td.prepare("SELECT * FROM conversations WHERE bot_id = ?").get(e),getByGroupId:e=>td.prepare("SELECT * FROM conversations WHERE group_id = ?").get(e),getById:e=>td.prepare("SELECT * FROM conversations WHERE id = ?").get(e),getUiById:e=>td.prepare("SELECT * FROM conversations WHERE id = ? AND type != 'agent'").get(e)},tW={create:(e,t,n,i,r)=>{let a={id:(0,s.randomUUID)(),conversation_id:e,sender_type:t,sender_id:i,sender_kind:"bot"===t?"bot":tk.kind,content:n,handoff_targets:r&&r.length>0?JSON.stringify(r):null,created_at:Date.now()};if(td.prepare("INSERT INTO messages (id, conversation_id, sender_type, sender_id, sender_kind, content, handoff_targets, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)").run(a.id,a.conversation_id,a.sender_type,a.sender_id||null,a.sender_kind,a.content,a.handoff_targets||null,a.created_at),"bot"===t){i&&tC.markUnread(i);let t=td.prepare("SELECT bot_id FROM conversations WHERE id = ? AND type = ?").get(e,"bot");t?.bot_id&&t.bot_id!==i&&tC.markUnread(t.bot_id)}return a},getById:e=>td.prepare("SELECT * FROM messages WHERE id = ?").get(e),replaceContent:(e,t)=>{td.prepare("UPDATE messages SET content = ? WHERE id = ?").run(t,e)},getByConversation:e=>td.prepare("SELECT * FROM messages WHERE conversation_id = ? ORDER BY created_at ASC").all(e),getBetween:(e,t)=>{let n=tW.getById(e),i=tW.getById(t);if(!n||!i||n.conversation_id!==i.conversation_id)return null;let r=td.prepare("SELECT * FROM messages WHERE conversation_id = ? ORDER BY created_at ASC, rowid ASC").all(n.conversation_id),s=r.findIndex(t=>t.id===e),a=r.findIndex(e=>e.id===t);if(s<0||a<0)return null;let[o,_]=s<a?[s,a]:[a,s];return r.slice(o+1,_)},latestFromBot:e=>{let t=tF.getByBotId(e);for(let n of td.prepare(`SELECT content, conversation_id, created_at FROM messages
1900
+ `).all().map(e=>e.bot_id)}function tg(){return new Set(e5.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name IN ('legacy_agent_requests_archive', 'legacy_agent_request_events_archive', 'legacy_processing_queue_archive')").all().map(e=>e.name))}function tI(e,t){tg().has("legacy_processing_queue_archive")&&e5.prepare(`DELETE FROM legacy_processing_queue_archive WHERE ${e} = ?`).run(t)}function tA(e){let t;eK(e5,e),e5.prepare("DELETE FROM draft_actions WHERE message_id IN (SELECT id FROM messages WHERE conversation_id = ?)").run(e),t=tg(),tI("conversation_id",e),t.has("legacy_agent_request_events_archive")&&t.has("legacy_agent_requests_archive")&&e5.prepare("DELETE FROM legacy_agent_request_events_archive WHERE request_id IN (SELECT id FROM legacy_agent_requests_archive WHERE conversation_id = ?)").run(e),t.has("legacy_agent_requests_archive")&&e5.prepare("DELETE FROM legacy_agent_requests_archive WHERE conversation_id = ?").run(e),e5.prepare("DELETE FROM messages WHERE conversation_id = ?").run(e),e5.prepare("DELETE FROM pending_questions WHERE conversation_id = ?").run(e),e5.prepare("DELETE FROM approvals WHERE conversation_id = ?").run(e),e5.prepare("DELETE FROM approval_requests WHERE conversation_id = ?").run(e),e5.prepare("DELETE FROM one_shots WHERE conversation_id = ?").run(e),e5.prepare("DELETE FROM routines WHERE conversation_id = ?").run(e),e5.prepare("DELETE FROM wake_targets WHERE conversation_id = ?").run(e),e5.prepare("DELETE FROM conversation_participants WHERE conversation_id = ?").run(e),e5.prepare("DELETE FROM conversations WHERE id = ?").run(e)}let tS={getByBotId:e=>e5.prepare("SELECT * FROM conversations WHERE bot_id = ?").get(e),getByGroupId:e=>e5.prepare("SELECT * FROM conversations WHERE group_id = ?").get(e),getById:e=>e5.prepare("SELECT * FROM conversations WHERE id = ?").get(e),getUiById:e=>e5.prepare("SELECT * FROM conversations WHERE id = ? AND type != 'agent'").get(e)},tv={create:(e,t,n,i,r)=>{let a={id:(0,s.randomUUID)(),conversation_id:e,sender_type:t,sender_id:i,sender_kind:"bot"===t?"bot":tl.kind,content:n,handoff_targets:r&&r.length>0?JSON.stringify(r):null,created_at:Date.now()};if(e5.prepare("INSERT INTO messages (id, conversation_id, sender_type, sender_id, sender_kind, content, handoff_targets, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)").run(a.id,a.conversation_id,a.sender_type,a.sender_id||null,a.sender_kind,a.content,a.handoff_targets||null,a.created_at),"bot"===t){i&&tm.markUnread(i);let t=e5.prepare("SELECT bot_id FROM conversations WHERE id = ? AND type = ?").get(e,"bot");t?.bot_id&&t.bot_id!==i&&tm.markUnread(t.bot_id)}return a},getById:e=>e5.prepare("SELECT * FROM messages WHERE id = ?").get(e),replaceContent:(e,t)=>{e5.prepare("UPDATE messages SET content = ? WHERE id = ?").run(t,e)},getByConversation:e=>e5.prepare("SELECT * FROM messages WHERE conversation_id = ? ORDER BY created_at ASC").all(e),getBetween:(e,t)=>{let n=tv.getById(e),i=tv.getById(t);if(!n||!i||n.conversation_id!==i.conversation_id)return null;let r=e5.prepare("SELECT * FROM messages WHERE conversation_id = ? ORDER BY created_at ASC, rowid ASC").all(n.conversation_id),s=r.findIndex(t=>t.id===e),a=r.findIndex(e=>e.id===t);if(s<0||a<0)return null;let[o,_]=s<a?[s,a]:[a,s];return r.slice(o+1,_)},latestFromBot:e=>{let t=tS.getByBotId(e);for(let n of e5.prepare(`SELECT content, conversation_id, created_at FROM messages
1899
1901
  WHERE sender_type = 'bot' AND sender_id = ?
1900
1902
  ORDER BY created_at DESC, rowid DESC
1901
- LIMIT 20`).all(e)){if(t&&n.conversation_id!==t.id)continue;let e=td.prepare(`SELECT content FROM messages
1903
+ LIMIT 20`).all(e)){if(t&&n.conversation_id!==t.id)continue;let e=e5.prepare(`SELECT content FROM messages
1902
1904
  WHERE conversation_id = ? AND created_at < ?
1903
1905
  ORDER BY created_at DESC, rowid DESC
1904
- LIMIT 1`).get(n.conversation_id,n.created_at);if(!(e&&e.content.startsWith("[From ")))return n.content}return""},priorSentenceForHandoff:e=>{if(!e.handoff_targets)return null;let t=[];try{let n=JSON.parse(e.handoff_targets);if(!Array.isArray(n))return null;t=n.map(e=>String(e))}catch{return null}let n=td.prepare(`
1906
+ LIMIT 1`).get(n.conversation_id,n.created_at);if(!(e&&e.content.startsWith("[From ")))return n.content}return""},priorSentenceForHandoff:e=>{if(!e.handoff_targets)return null;let t=[];try{let n=JSON.parse(e.handoff_targets);if(!Array.isArray(n))return null;t=n.map(e=>String(e))}catch{return null}let n=e5.prepare(`
1905
1907
  SELECT m.conversation_id AS conversation_id, c.type AS type, c.bot_id AS bot_id
1906
1908
  FROM messages m
1907
1909
  JOIN conversations c ON c.id = m.conversation_id
1908
1910
  WHERE m.content = ? AND m.handoff_targets = ?
1909
1911
  ORDER BY m.created_at ASC
1910
- `).all(e.content,e.handoff_targets).find(e=>"group"===e.type||!e.bot_id||!t.includes(e.bot_id)),i=n?.conversation_id||e.conversation_id,r=tW.getByConversation(i),s=[...r].reverse().find(t=>"user"===t.sender_type&&t.content===e.content&&t.handoff_targets===e.handoff_targets),a=s?s.created_at:e.created_at;for(let e=r.length-1;e>=0;e--){let t=r[e];if(s&&t.id===s.id||t.created_at>a||"bot"!==t.sender_type)continue;let n=(t.content||"").trim();if(n)return n}return null}},tX={get:(e,t)=>td.prepare("SELECT * FROM approvals WHERE conversation_id = ? AND code = ?").get(e,t),recordPending:(e,t,n)=>(td.prepare("INSERT OR IGNORE INTO approvals (conversation_id, code, message_id, status, created_at) VALUES (?, ?, ?, ?, ?)").run(e,t,n||null,"pending",Date.now()),tX.get(e,t)),resolve:(e,t,n)=>Number(td.prepare("UPDATE approvals SET status = ?, resolved_at = ? WHERE conversation_id = ? AND code = ? AND status = 'pending'").run(n,Date.now(),e,t).changes)>0},tx=20;function tG(e){let t=tr(e);if(!t)return{ok:!1,reason:"not_found",requested:String(e??"")};let n=td.prepare("SELECT id, name FROM bots WHERE name_key = ? LIMIT 2").all(t);return 0===n.length?{ok:!1,reason:"not_found",requested:e}:n.length>1?{ok:!1,reason:"ambiguous",requested:e}:{ok:!0,agentId:n[0].id,displayName:n[0].name}}td.exec(`
1912
+ `).all(e.content,e.handoff_targets).find(e=>"group"===e.type||!e.bot_id||!t.includes(e.bot_id)),i=n?.conversation_id||e.conversation_id,r=tv.getByConversation(i),s=[...r].reverse().find(t=>"user"===t.sender_type&&t.content===e.content&&t.handoff_targets===e.handoff_targets),a=s?s.created_at:e.created_at;for(let e=r.length-1;e>=0;e--){let t=r[e];if(s&&t.id===s.id||t.created_at>a||"bot"!==t.sender_type)continue;let n=(t.content||"").trim();if(n)return n}return null}},tk={get:(e,t)=>e5.prepare("SELECT * FROM approvals WHERE conversation_id = ? AND code = ?").get(e,t),recordPending:(e,t,n)=>(e5.prepare("INSERT OR IGNORE INTO approvals (conversation_id, code, message_id, status, created_at) VALUES (?, ?, ?, ?, ?)").run(e,t,n||null,"pending",Date.now()),tk.get(e,t)),resolve:(e,t,n)=>Number(e5.prepare("UPDATE approvals SET status = ?, resolved_at = ? WHERE conversation_id = ? AND code = ? AND status = 'pending'").run(n,Date.now(),e,t).changes)>0},tf=20;function th(e){let t=e2(e);if(!t)return{ok:!1,reason:"not_found",requested:String(e??"")};let n=e5.prepare("SELECT id, name FROM bots WHERE name_key = ? LIMIT 2").all(t);return 0===n.length?{ok:!1,reason:"not_found",requested:e}:n.length>1?{ok:!1,reason:"ambiguous",requested:e}:{ok:!0,agentId:n[0].id,displayName:n[0].name}}e5.exec(`
1911
1913
  CREATE TABLE IF NOT EXISTS wake_targets (
1912
1914
  id TEXT PRIMARY KEY,
1913
1915
  conversation_id TEXT NOT NULL,
@@ -1925,17 +1927,17 @@ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",
1925
1927
  ON wake_targets(conversation_id, created_at);
1926
1928
  CREATE INDEX IF NOT EXISTS idx_wake_targets_target
1927
1929
  ON wake_targets(target_bot_id, created_at);
1928
- `),td.exec(`
1930
+ `),e5.exec(`
1929
1931
  CREATE TABLE IF NOT EXISTS workspace_settings (
1930
1932
  key TEXT PRIMARY KEY,
1931
1933
  value TEXT NOT NULL,
1932
1934
  updated_at INTEGER NOT NULL
1933
1935
  );
1934
- `),e.s(["BotDeletionError",0,tq,"UI_OWNER_PRINCIPAL",0,tk,"agentNameMigrations",0,{list:()=>td.prepare("SELECT * FROM agent_name_migrations ORDER BY created_at ASC, rowid ASC").all()},"approvals",0,tX,"bots",0,tC,"conversations",0,tF,"default",0,td,"draftActions",0,{get:e=>td.prepare("SELECT * FROM draft_actions WHERE message_id = ?").get(e),record:(e,t,n)=>Number(td.prepare("INSERT OR IGNORE INTO draft_actions (message_id, status, recipient, acted_at) VALUES (?, ?, ?, ?)").run(e,t,n||null,Date.now()).changes)>0},"engine",0,tI,"groups",0,{create:(e,t,n,i)=>{let r=n&&t.includes(n)?n:t[0],a={id:(0,s.randomUUID)(),name:e,owner_bot_id:r,created_at:i?.created_at??Date.now()},o=td.prepare("INSERT INTO groups (id, name, owner_bot_id, created_at) VALUES (?, ?, ?, ?)"),_=td.prepare("INSERT INTO group_members (group_id, bot_id) VALUES (?, ?)"),d=td.prepare("INSERT INTO conversations (id, type, group_id, created_at) VALUES (?, ?, ?, ?)");return td.transaction(()=>{for(let e of(o.run(a.id,a.name,a.owner_bot_id||null,a.created_at),t))_.run(a.id,e);let e=(0,s.randomUUID)();d.run(e,"group",a.id,a.created_at),tv(e,t,a.created_at)})(),a},getAll:()=>td.prepare("SELECT * FROM groups ORDER BY created_at DESC").all(),getById:e=>td.prepare("SELECT * FROM groups WHERE id = ?").get(e),rename:(e,t)=>{td.prepare("UPDATE groups SET name = ? WHERE id = ?").run(t,e)},getMembers:e=>td.prepare(`
1936
+ `),e.s(["BotDeletionError",0,tL,"UI_OWNER_PRINCIPAL",0,tl,"agentNameMigrations",0,{list:()=>e5.prepare("SELECT * FROM agent_name_migrations ORDER BY created_at ASC, rowid ASC").all()},"approvals",0,tk,"bots",0,tm,"conversations",0,tS,"default",0,e5,"draftActions",0,{get:e=>e5.prepare("SELECT * FROM draft_actions WHERE message_id = ?").get(e),record:(e,t,n)=>Number(e5.prepare("INSERT OR IGNORE INTO draft_actions (message_id, status, recipient, acted_at) VALUES (?, ?, ?, ?)").run(e,t,n||null,Date.now()).changes)>0},"engine",0,tE,"groups",0,{create:(e,t,n,i)=>{let r=n&&t.includes(n)?n:t[0],a={id:(0,s.randomUUID)(),name:e,owner_bot_id:r,created_at:i?.created_at??Date.now()},o=e5.prepare("INSERT INTO groups (id, name, owner_bot_id, created_at) VALUES (?, ?, ?, ?)"),_=e5.prepare("INSERT INTO group_members (group_id, bot_id) VALUES (?, ?)"),d=e5.prepare("INSERT INTO conversations (id, type, group_id, created_at) VALUES (?, ?, ?, ?)");return e5.transaction(()=>{for(let e of(o.run(a.id,a.name,a.owner_bot_id||null,a.created_at),t))_.run(a.id,e);let e=(0,s.randomUUID)();d.run(e,"group",a.id,a.created_at),tp(e,t,a.created_at)})(),a},getAll:()=>e5.prepare("SELECT * FROM groups ORDER BY created_at DESC").all(),getById:e=>e5.prepare("SELECT * FROM groups WHERE id = ?").get(e),rename:(e,t)=>{e5.prepare("UPDATE groups SET name = ? WHERE id = ?").run(t,e)},getMembers:e=>e5.prepare(`
1935
1937
  SELECT b.* FROM bots b
1936
1938
  JOIN group_members gm ON b.id = gm.bot_id
1937
1939
  WHERE gm.group_id = ?
1938
- `).all(e)},"launchSnapshots",0,{record:(e,t,n,i,r="hermes-gateway")=>{td.prepare("INSERT OR IGNORE INTO launch_snapshots (id, bot_id, created_at, hash, snapshot, transport) VALUES (?, ?, ?, ?, ?, ?)").run(e,t,Date.now(),n,i,r)},listByBot:e=>td.prepare("SELECT * FROM launch_snapshots WHERE bot_id = ? ORDER BY created_at DESC, rowid DESC").all(e)},"mcpServers",0,{create:(e,t,n)=>{let i={id:(0,s.randomUUID)(),name:e,command:t,args:JSON.stringify(n),created_at:Date.now()};return td.prepare("INSERT INTO mcp_servers (id, name, command, args, created_at) VALUES (?, ?, ?, ?, ?)").run(i.id,i.name,i.command,i.args,i.created_at),i},list:()=>td.prepare("SELECT * FROM mcp_servers ORDER BY created_at ASC").all()},"memories",0,{rememberStatement:(e,t)=>{var n;let i;if(!e||!(i=t.trim())||/[??]\s*$/.test(i)||/^\[mcp\]/i.test(i)||/^\[tool (?:call|result)\]/i.test(i)||/^\[Handing off to\b/i.test(i)||/^\[From [^\]]+\]/i.test(i)||/^Peer handoff:/i.test(i)||/reply with exactly\b/i.test(i)||(n=i,/^(who|what|when|where|why|how|which|whose|whom)\b/i.test(n)?!/^(what|how|why|where|when|who)\s+i\b/i.test(n):!!(/^(do|does|did|can|could|would|will|should|shall|is|are|am|was|were|have|has)\s+(you|i|we|they|he|she|it|there|the|a|an|my|your|our)\b/i.test(n)||/^(tell me|please tell)\b/i.test(n))))return;let r=t.trim();td.prepare("INSERT INTO memories (id, bot_id, fact, created_at) VALUES (?, ?, ?, ?)").run((0,s.randomUUID)(),e,r,Date.now()),td.prepare(`
1940
+ `).all(e)},"launchSnapshots",0,{record:(e,t,n,i,r="hermes-gateway")=>{e5.prepare("INSERT OR IGNORE INTO launch_snapshots (id, bot_id, created_at, hash, snapshot, transport) VALUES (?, ?, ?, ?, ?, ?)").run(e,t,Date.now(),n,i,r)},listByBot:e=>e5.prepare("SELECT * FROM launch_snapshots WHERE bot_id = ? ORDER BY created_at DESC, rowid DESC").all(e)},"mcpServers",0,{create:(e,t,n)=>{let i={id:(0,s.randomUUID)(),name:e,command:t,args:JSON.stringify(n),created_at:Date.now()};return e5.prepare("INSERT INTO mcp_servers (id, name, command, args, created_at) VALUES (?, ?, ?, ?, ?)").run(i.id,i.name,i.command,i.args,i.created_at),i},list:()=>e5.prepare("SELECT * FROM mcp_servers ORDER BY created_at ASC").all()},"memories",0,{rememberStatement:(e,t)=>{var n;let i;if(!e||!(i=t.trim())||/[??]\s*$/.test(i)||/^\[mcp\]/i.test(i)||/^\[tool (?:call|result)\]/i.test(i)||/^\[Handing off to\b/i.test(i)||/^\[From [^\]]+\]/i.test(i)||/^Peer handoff:/i.test(i)||/reply with exactly\b/i.test(i)||(n=i,/^(who|what|when|where|why|how|which|whose|whom)\b/i.test(n)?!/^(what|how|why|where|when|who)\s+i\b/i.test(n):!!(/^(do|does|did|can|could|would|will|should|shall|is|are|am|was|were|have|has)\s+(you|i|we|they|he|she|it|there|the|a|an|my|your|our)\b/i.test(n)||/^(tell me|please tell)\b/i.test(n))))return;let r=t.trim();e5.prepare("INSERT INTO memories (id, bot_id, fact, created_at) VALUES (?, ?, ?, ?)").run((0,s.randomUUID)(),e,r,Date.now()),e5.prepare(`
1939
1941
  DELETE FROM memories
1940
1942
  WHERE bot_id = ?
1941
1943
  AND id NOT IN (
@@ -1946,6 +1948,6 @@ module.exports=[85148,(e,t,n)=>{t.exports=e.x("better-sqlite3-90e2652d1716b047",
1946
1948
  LIMIT ?
1947
1949
  )
1948
1950
  )
1949
- `).run(e,e,tx)},latestFacts:(e,t=tx)=>{let n=t>0?Math.min(t,tx):tx;return td.prepare("SELECT fact FROM memories WHERE bot_id = ? ORDER BY created_at DESC, rowid DESC LIMIT ?").all(e,n).map(e=>e.fact).reverse()}},"messages",0,tW,"oneShots",0,{create:(e,t,n)=>{let i={id:(0,s.randomUUID)(),conversation_id:e,bot_id:t,due_at:n,fired:0,created_at:Date.now()};return td.prepare("INSERT INTO one_shots (id, conversation_id, bot_id, due_at, fired, created_at) VALUES (?, ?, ?, ?, 0, ?)").run(i.id,i.conversation_id,i.bot_id,i.due_at,i.created_at),i},pending:e=>td.prepare("SELECT * FROM one_shots WHERE conversation_id = ? AND fired = 0 ORDER BY due_at ASC LIMIT 1").get(e),unfired:()=>td.prepare("SELECT * FROM one_shots WHERE fired = 0 ORDER BY due_at ASC").all(),claim:e=>1===td.prepare("UPDATE one_shots SET fired = 1 WHERE id = ? AND fired = 0").run(e).changes},"projector",0,tA,"registrationContext",0,{getConnection:e=>th.getById(e),localConnectionFor:e=>tT(e),sessionBelongsTo:function(e,t){return!!e&&(!!td.prepare("SELECT 1 FROM session_bindings WHERE id = ? AND agent_id = ?").get(t,e)||!!td.prepare("SELECT 1 FROM provider_sessions WHERE id = ? AND agent_id = ?").get(t,e))}},"resolveWakeTarget",0,tG,"routines",0,{create:(e,t,n,i,r)=>{let a={id:(0,s.randomUUID)(),conversation_id:e,bot_id:t,word:n,next_due_at:i,every_ms:r,created_at:Date.now()};return td.prepare("INSERT INTO routines (id, conversation_id, bot_id, word, next_due_at, every_ms, created_at) VALUES (?, ?, ?, ?, ?, ?, ?)").run(a.id,a.conversation_id,a.bot_id,a.word,a.next_due_at,a.every_ms,a.created_at),a},forConversation:e=>td.prepare("SELECT * FROM routines WHERE conversation_id = ? ORDER BY created_at ASC LIMIT 1").get(e),all:()=>td.prepare("SELECT * FROM routines ORDER BY next_due_at ASC").all(),postIfDue:(e,t)=>td.transaction(()=>{let n=td.prepare("SELECT * FROM routines WHERE id = ?").get(e);return!!n&&!(n.next_due_at>t)&&1===td.prepare("UPDATE routines SET next_due_at = next_due_at + every_ms WHERE id = ? AND next_due_at = ?").run(e,n.next_due_at).changes&&(tW.create(n.conversation_id,"bot","[routine]\n"+n.word,n.bot_id),!0)})()},"runtimeConnections",0,th,"serializeAgent",0,function(e){let t=(0,a.serializeBot)(e);for(let e of tw)delete t[e];let n=e.runtime_connection_id?th.getById(e.runtime_connection_id):void 0;return{...t,...j(e,n),launch_profile:F(e)}},"serviceAudit",0,tS,"wakeTargets",0,{accept:e=>{let t=tG(e.requestedTarget);if(!t.ok)return t;let n={id:(0,s.randomUUID)(),conversation_id:e.conversationId,source_bot_id:e.sourceBotId??null,source_message_id:e.sourceMessageId??null,requested_target:e.requestedTarget,target_bot_id:t.agentId,target_name_snapshot:t.displayName,created_at:Date.now()};return td.prepare("INSERT INTO wake_targets (id, conversation_id, source_bot_id, source_message_id, requested_target, target_bot_id, target_name_snapshot, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)").run(n.id,n.conversation_id,n.source_bot_id,n.source_message_id,n.requested_target,n.target_bot_id,n.target_name_snapshot,n.created_at),{ok:!0,wake:n}},listByConversation:e=>td.prepare("SELECT * FROM wake_targets WHERE conversation_id = ? ORDER BY created_at ASC, rowid ASC").all(e)},"workspaceSettings",0,{get:e=>{let t=td.prepare("SELECT value FROM workspace_settings WHERE key = ?").get(e);return t?t.value:null},set:(e,t)=>{td.prepare("INSERT INTO workspace_settings (key, value, updated_at) VALUES (?, ?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value, updated_at = excluded.updated_at").run(e,t,Date.now())},clearForTests:()=>{td.prepare("DELETE FROM workspace_settings").run()}}],62294)}];
1951
+ `).run(e,e,tf)},latestFacts:(e,t=tf)=>{let n=t>0?Math.min(t,tf):tf;return e5.prepare("SELECT fact FROM memories WHERE bot_id = ? ORDER BY created_at DESC, rowid DESC LIMIT ?").all(e,n).map(e=>e.fact).reverse()}},"messages",0,tv,"oneShots",0,{create:(e,t,n)=>{let i={id:(0,s.randomUUID)(),conversation_id:e,bot_id:t,due_at:n,fired:0,created_at:Date.now()};return e5.prepare("INSERT INTO one_shots (id, conversation_id, bot_id, due_at, fired, created_at) VALUES (?, ?, ?, ?, 0, ?)").run(i.id,i.conversation_id,i.bot_id,i.due_at,i.created_at),i},pending:e=>e5.prepare("SELECT * FROM one_shots WHERE conversation_id = ? AND fired = 0 ORDER BY due_at ASC LIMIT 1").get(e),unfired:()=>e5.prepare("SELECT * FROM one_shots WHERE fired = 0 ORDER BY due_at ASC").all(),claim:e=>1===e5.prepare("UPDATE one_shots SET fired = 1 WHERE id = ? AND fired = 0").run(e).changes},"projector",0,tu,"registrationContext",0,{getConnection:e=>tN.getById(e),localConnectionFor:e=>tn(e),sessionBelongsTo:function(e,t){return!!e&&(!!e5.prepare("SELECT 1 FROM session_bindings WHERE id = ? AND agent_id = ?").get(t,e)||!!e5.prepare("SELECT 1 FROM provider_sessions WHERE id = ? AND agent_id = ?").get(t,e))}},"resolveWakeTarget",0,th,"routines",0,{create:(e,t,n,i,r)=>{let a={id:(0,s.randomUUID)(),conversation_id:e,bot_id:t,word:n,next_due_at:i,every_ms:r,created_at:Date.now()};return e5.prepare("INSERT INTO routines (id, conversation_id, bot_id, word, next_due_at, every_ms, created_at) VALUES (?, ?, ?, ?, ?, ?, ?)").run(a.id,a.conversation_id,a.bot_id,a.word,a.next_due_at,a.every_ms,a.created_at),a},forConversation:e=>e5.prepare("SELECT * FROM routines WHERE conversation_id = ? ORDER BY created_at ASC LIMIT 1").get(e),all:()=>e5.prepare("SELECT * FROM routines ORDER BY next_due_at ASC").all(),postIfDue:(e,t)=>e5.transaction(()=>{let n=e5.prepare("SELECT * FROM routines WHERE id = ?").get(e);return!!n&&!(n.next_due_at>t)&&1===e5.prepare("UPDATE routines SET next_due_at = next_due_at + every_ms WHERE id = ? AND next_due_at = ?").run(e,n.next_due_at).changes&&(tv.create(n.conversation_id,"bot","[routine]\n"+n.word,n.bot_id),!0)})()},"runtimeConnections",0,tN,"serializeAgent",0,function(e){let t=(0,a.serializeBot)(e);for(let e of tR)delete t[e];let n=e.runtime_connection_id?tN.getById(e.runtime_connection_id):void 0;return{...t,...x(e,n)}},"serviceAudit",0,tc,"wakeTargets",0,{accept:e=>{let t=th(e.requestedTarget);if(!t.ok)return t;let n={id:(0,s.randomUUID)(),conversation_id:e.conversationId,source_bot_id:e.sourceBotId??null,source_message_id:e.sourceMessageId??null,requested_target:e.requestedTarget,target_bot_id:t.agentId,target_name_snapshot:t.displayName,created_at:Date.now()};return e5.prepare("INSERT INTO wake_targets (id, conversation_id, source_bot_id, source_message_id, requested_target, target_bot_id, target_name_snapshot, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)").run(n.id,n.conversation_id,n.source_bot_id,n.source_message_id,n.requested_target,n.target_bot_id,n.target_name_snapshot,n.created_at),{ok:!0,wake:n}},listByConversation:e=>e5.prepare("SELECT * FROM wake_targets WHERE conversation_id = ? ORDER BY created_at ASC, rowid ASC").all(e)}],62294)}];
1950
1952
 
1951
- //# sourceMappingURL=%5Broot-of-the-server%5D__0izjfmr._.js.map
1953
+ //# sourceMappingURL=lib_db_ts_1ttuckb._.js.map