botmancers 0.3.0 → 0.5.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 (471) hide show
  1. package/CHANGELOG.md +107 -1
  2. package/README.md +178 -32
  3. package/app/.next/BUILD_ID +1 -1
  4. package/app/.next/app-path-routes-manifest.json +27 -1
  5. package/app/.next/build-manifest.json +3 -3
  6. package/app/.next/prerender-manifest.json +33 -5
  7. package/app/.next/required-server-files.json +2 -2
  8. package/app/.next/routes-manifest.json +198 -0
  9. package/app/.next/server/app/_global-error/page.js +1 -1
  10. package/app/.next/server/app/_global-error/page.js.nft.json +1 -1
  11. package/app/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  12. package/app/.next/server/app/_global-error.html +1 -1
  13. package/app/.next/server/app/_global-error.rsc +1 -1
  14. package/app/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  15. package/app/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  16. package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  17. package/app/.next/server/app/_not-found/page.js +1 -1
  18. package/app/.next/server/app/_not-found/page.js.nft.json +1 -1
  19. package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  20. package/app/.next/server/app/_not-found.html +1 -1
  21. package/app/.next/server/app/_not-found.rsc +2 -2
  22. package/app/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  23. package/app/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  24. package/app/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  25. package/app/.next/server/app/api/agent-deck/decks/route.js +3 -3
  26. package/app/.next/server/app/api/agent-deck/decks/route.js.nft.json +1 -1
  27. package/app/.next/server/app/api/agent-deck/settings/route.js +3 -3
  28. package/app/.next/server/app/api/agent-deck/settings/route.js.nft.json +1 -1
  29. package/app/.next/server/app/api/bots/[id]/config/route.js +3 -3
  30. package/app/.next/server/app/api/bots/[id]/config/route.js.nft.json +1 -1
  31. package/app/.next/server/app/api/bots/[id]/sessions/[ref]/pins/route/app-paths-manifest.json +3 -0
  32. package/app/.next/server/app/api/bots/[id]/sessions/[ref]/pins/route/build-manifest.json +12 -0
  33. package/app/.next/server/app/api/bots/[id]/sessions/[ref]/pins/route/server-reference-manifest.json +4 -0
  34. package/app/.next/server/app/api/bots/[id]/sessions/[ref]/pins/route.js +12 -0
  35. package/app/.next/server/app/api/bots/[id]/sessions/[ref]/pins/route.js.nft.json +1 -0
  36. package/app/.next/server/app/api/bots/[id]/sessions/[ref]/pins/route_client-reference-manifest.js +3 -0
  37. package/app/.next/server/app/api/bots/[id]/sessions/[ref]/route/app-paths-manifest.json +3 -0
  38. package/app/.next/server/app/api/bots/[id]/sessions/[ref]/route/build-manifest.json +12 -0
  39. package/app/.next/server/app/api/bots/[id]/sessions/[ref]/route/server-reference-manifest.json +4 -0
  40. package/app/.next/server/app/api/bots/[id]/sessions/[ref]/route.js +9 -0
  41. package/app/.next/server/app/api/bots/[id]/sessions/[ref]/route.js.nft.json +1 -0
  42. package/app/.next/server/app/api/bots/[id]/sessions/[ref]/route_client-reference-manifest.js +3 -0
  43. package/app/.next/server/app/api/bots/[id]/sessions/route/app-paths-manifest.json +3 -0
  44. package/app/.next/server/app/api/bots/[id]/sessions/route/build-manifest.json +12 -0
  45. package/app/.next/server/app/api/bots/[id]/sessions/route/server-reference-manifest.json +4 -0
  46. package/app/.next/server/app/api/bots/[id]/sessions/route.js +12 -0
  47. package/app/.next/server/app/api/bots/[id]/sessions/route.js.nft.json +1 -0
  48. package/app/.next/server/app/api/bots/[id]/sessions/route_client-reference-manifest.js +3 -0
  49. package/app/.next/server/app/api/bots/[id]/skill/route.js +3 -3
  50. package/app/.next/server/app/api/bots/[id]/skill/route.js.nft.json +1 -1
  51. package/app/.next/server/app/api/bots/availability/route.js +2 -2
  52. package/app/.next/server/app/api/bots/availability/route.js.nft.json +1 -1
  53. package/app/.next/server/app/api/bots/delete-preview/route.js +4 -4
  54. package/app/.next/server/app/api/bots/delete-preview/route.js.nft.json +1 -1
  55. package/app/.next/server/app/api/bots/import/route.js +3 -3
  56. package/app/.next/server/app/api/bots/import/route.js.nft.json +1 -1
  57. package/app/.next/server/app/api/bots/manage/route.js +3 -3
  58. package/app/.next/server/app/api/bots/manage/route.js.nft.json +1 -1
  59. package/app/.next/server/app/api/bots/name-migrations/route.js +3 -3
  60. package/app/.next/server/app/api/bots/name-migrations/route.js.nft.json +1 -1
  61. package/app/.next/server/app/api/bots/route.js +7 -7
  62. package/app/.next/server/app/api/bots/route.js.nft.json +1 -1
  63. package/app/.next/server/app/api/conversations/[id]/approve/route.js +3 -3
  64. package/app/.next/server/app/api/conversations/[id]/approve/route.js.nft.json +1 -1
  65. package/app/.next/server/app/api/conversations/[id]/deny/route.js +3 -3
  66. package/app/.next/server/app/api/conversations/[id]/deny/route.js.nft.json +1 -1
  67. package/app/.next/server/app/api/conversations/[id]/draft/route.js +3 -3
  68. package/app/.next/server/app/api/conversations/[id]/draft/route.js.nft.json +1 -1
  69. package/app/.next/server/app/api/conversations/[id]/messages/[messageId]/stop/route.js +3 -3
  70. package/app/.next/server/app/api/conversations/[id]/messages/[messageId]/stop/route.js.nft.json +1 -1
  71. package/app/.next/server/app/api/conversations/[id]/messages/route.js +6 -6
  72. package/app/.next/server/app/api/conversations/[id]/messages/route.js.nft.json +1 -1
  73. package/app/.next/server/app/api/conversations/[id]/route.js +3 -3
  74. package/app/.next/server/app/api/conversations/[id]/route.js.nft.json +1 -1
  75. package/app/.next/server/app/api/conversations/[id]/stop/route.js +4 -4
  76. package/app/.next/server/app/api/conversations/[id]/stop/route.js.nft.json +1 -1
  77. package/app/.next/server/app/api/conversations/route.js +3 -3
  78. package/app/.next/server/app/api/conversations/route.js.nft.json +1 -1
  79. package/app/.next/server/app/api/exchanges/[id]/cancel/route/app-paths-manifest.json +3 -0
  80. package/app/.next/server/app/api/exchanges/[id]/cancel/route/build-manifest.json +12 -0
  81. package/app/.next/server/app/api/exchanges/[id]/cancel/route/server-reference-manifest.json +4 -0
  82. package/app/.next/server/app/api/exchanges/[id]/cancel/route.js +11 -0
  83. package/app/.next/server/app/api/exchanges/[id]/cancel/route.js.nft.json +1 -0
  84. package/app/.next/server/app/api/exchanges/[id]/cancel/route_client-reference-manifest.js +3 -0
  85. package/app/.next/server/app/api/exchanges/[id]/route/app-paths-manifest.json +3 -0
  86. package/app/.next/server/app/api/exchanges/[id]/route/build-manifest.json +12 -0
  87. package/app/.next/server/app/api/exchanges/[id]/route/server-reference-manifest.json +4 -0
  88. package/app/.next/server/app/api/exchanges/[id]/route.js +11 -0
  89. package/app/.next/server/app/api/exchanges/[id]/route.js.nft.json +1 -0
  90. package/app/.next/server/app/api/exchanges/[id]/route_client-reference-manifest.js +3 -0
  91. package/app/.next/server/app/api/exchanges/route/app-paths-manifest.json +3 -0
  92. package/app/.next/server/app/api/exchanges/route/build-manifest.json +12 -0
  93. package/app/.next/server/app/api/exchanges/route/server-reference-manifest.json +4 -0
  94. package/app/.next/server/app/api/exchanges/route.js +12 -0
  95. package/app/.next/server/app/api/exchanges/route.js.nft.json +1 -0
  96. package/app/.next/server/app/api/exchanges/route_client-reference-manifest.js +3 -0
  97. package/app/.next/server/app/api/files/[name]/route.js +3 -2
  98. package/app/.next/server/app/api/files/[name]/route.js.nft.json +1 -1
  99. package/app/.next/server/app/api/groups/route.js +3 -3
  100. package/app/.next/server/app/api/groups/route.js.nft.json +1 -1
  101. package/app/.next/server/app/api/health/route.js +3 -2
  102. package/app/.next/server/app/api/health/route.js.nft.json +1 -1
  103. package/app/.next/server/app/api/import-capabilities/route.js +1 -1
  104. package/app/.next/server/app/api/import-capabilities/route.js.nft.json +1 -1
  105. package/app/.next/server/app/api/marketplace-handoff/route.js +1 -1
  106. package/app/.next/server/app/api/marketplace-handoff/route.js.nft.json +1 -1
  107. package/app/.next/server/app/api/marketplace-handoff/status/route.js +1 -1
  108. package/app/.next/server/app/api/marketplace-handoff/status/route.js.nft.json +1 -1
  109. package/app/.next/server/app/api/mcp/route.js +3 -3
  110. package/app/.next/server/app/api/mcp/route.js.nft.json +1 -1
  111. package/app/.next/server/app/api/messages/[id]/between/route.js +3 -3
  112. package/app/.next/server/app/api/messages/[id]/between/route.js.nft.json +1 -1
  113. package/app/.next/server/app/api/runtime-connections/route/app-paths-manifest.json +3 -0
  114. package/app/.next/server/app/api/runtime-connections/route/build-manifest.json +12 -0
  115. package/app/.next/server/app/api/runtime-connections/route/server-reference-manifest.json +4 -0
  116. package/app/.next/server/app/api/runtime-connections/route.js +9 -0
  117. package/app/.next/server/app/api/runtime-connections/route.js.nft.json +1 -0
  118. package/app/.next/server/app/api/runtime-connections/route_client-reference-manifest.js +3 -0
  119. package/app/.next/server/app/api/service-grants/route/app-paths-manifest.json +3 -0
  120. package/app/.next/server/app/api/service-grants/route/build-manifest.json +12 -0
  121. package/app/.next/server/app/api/service-grants/route/server-reference-manifest.json +4 -0
  122. package/app/.next/server/app/api/service-grants/route.js +9 -0
  123. package/app/.next/server/app/api/service-grants/route.js.nft.json +1 -0
  124. package/app/.next/server/app/api/service-grants/route_client-reference-manifest.js +3 -0
  125. package/app/.next/server/app/api/v0/agents/[agentId]/conversations/[conversationId]/route/app-paths-manifest.json +3 -0
  126. package/app/.next/server/app/api/v0/agents/[agentId]/conversations/[conversationId]/route/build-manifest.json +12 -0
  127. package/app/.next/server/app/api/v0/agents/[agentId]/conversations/[conversationId]/route/server-reference-manifest.json +4 -0
  128. package/app/.next/server/app/api/v0/agents/[agentId]/conversations/[conversationId]/route.js +12 -0
  129. package/app/.next/server/app/api/v0/agents/[agentId]/conversations/[conversationId]/route.js.nft.json +1 -0
  130. package/app/.next/server/app/api/v0/agents/[agentId]/conversations/[conversationId]/route_client-reference-manifest.js +3 -0
  131. package/app/.next/server/app/api/v0/agents/[agentId]/conversations/route/app-paths-manifest.json +3 -0
  132. package/app/.next/server/app/api/v0/agents/[agentId]/conversations/route/build-manifest.json +12 -0
  133. package/app/.next/server/app/api/v0/agents/[agentId]/conversations/route/server-reference-manifest.json +4 -0
  134. package/app/.next/server/app/api/v0/agents/[agentId]/conversations/route.js +12 -0
  135. package/app/.next/server/app/api/v0/agents/[agentId]/conversations/route.js.nft.json +1 -0
  136. package/app/.next/server/app/api/v0/agents/[agentId]/conversations/route_client-reference-manifest.js +3 -0
  137. package/app/.next/server/app/api/v0/agents/[agentId]/messages/route.js +5 -4
  138. package/app/.next/server/app/api/v0/agents/[agentId]/messages/route.js.nft.json +1 -1
  139. package/app/.next/server/app/api/v0/agents/[agentId]/pins/route/app-paths-manifest.json +3 -0
  140. package/app/.next/server/app/api/v0/agents/[agentId]/pins/route/build-manifest.json +12 -0
  141. package/app/.next/server/app/api/v0/agents/[agentId]/pins/route/server-reference-manifest.json +4 -0
  142. package/app/.next/server/app/api/v0/agents/[agentId]/pins/route.js +12 -0
  143. package/app/.next/server/app/api/v0/agents/[agentId]/pins/route.js.nft.json +1 -0
  144. package/app/.next/server/app/api/v0/agents/[agentId]/pins/route_client-reference-manifest.js +3 -0
  145. package/app/.next/server/app/api/v0/agents/[agentId]/route/app-paths-manifest.json +3 -0
  146. package/app/.next/server/app/api/v0/agents/[agentId]/route/build-manifest.json +12 -0
  147. package/app/.next/server/app/api/v0/agents/[agentId]/route/server-reference-manifest.json +4 -0
  148. package/app/.next/server/app/api/v0/agents/[agentId]/route.js +12 -0
  149. package/app/.next/server/app/api/v0/agents/[agentId]/route.js.nft.json +1 -0
  150. package/app/.next/server/app/api/v0/agents/[agentId]/route_client-reference-manifest.js +3 -0
  151. package/app/.next/server/app/api/v0/agents/[agentId]/sessions/[ref]/route/app-paths-manifest.json +3 -0
  152. package/app/.next/server/app/api/v0/agents/[agentId]/sessions/[ref]/route/build-manifest.json +12 -0
  153. package/app/.next/server/app/api/v0/agents/[agentId]/sessions/[ref]/route/server-reference-manifest.json +4 -0
  154. package/app/.next/server/app/api/v0/agents/[agentId]/sessions/[ref]/route.js +12 -0
  155. package/app/.next/server/app/api/v0/agents/[agentId]/sessions/[ref]/route.js.nft.json +1 -0
  156. package/app/.next/server/app/api/v0/agents/[agentId]/sessions/[ref]/route_client-reference-manifest.js +3 -0
  157. package/app/.next/server/app/api/v0/agents/[agentId]/sessions/route/app-paths-manifest.json +3 -0
  158. package/app/.next/server/app/api/v0/agents/[agentId]/sessions/route/build-manifest.json +12 -0
  159. package/app/.next/server/app/api/v0/agents/[agentId]/sessions/route/server-reference-manifest.json +4 -0
  160. package/app/.next/server/app/api/v0/agents/[agentId]/sessions/route.js +12 -0
  161. package/app/.next/server/app/api/v0/agents/[agentId]/sessions/route.js.nft.json +1 -0
  162. package/app/.next/server/app/api/v0/agents/[agentId]/sessions/route_client-reference-manifest.js +3 -0
  163. package/app/.next/server/app/api/v0/agents/route/app-paths-manifest.json +3 -0
  164. package/app/.next/server/app/api/v0/agents/route/build-manifest.json +12 -0
  165. package/app/.next/server/app/api/v0/agents/route/server-reference-manifest.json +4 -0
  166. package/app/.next/server/app/api/v0/agents/route.js +12 -0
  167. package/app/.next/server/app/api/v0/agents/route.js.nft.json +1 -0
  168. package/app/.next/server/app/api/v0/agents/route_client-reference-manifest.js +3 -0
  169. package/app/.next/server/app/api/v0/capabilities/route/app-paths-manifest.json +3 -0
  170. package/app/.next/server/app/api/v0/capabilities/route/build-manifest.json +12 -0
  171. package/app/.next/server/app/api/v0/capabilities/route/server-reference-manifest.json +4 -0
  172. package/app/.next/server/app/api/v0/capabilities/route.js +12 -0
  173. package/app/.next/server/app/api/v0/capabilities/route.js.nft.json +1 -0
  174. package/app/.next/server/app/api/v0/capabilities/route_client-reference-manifest.js +3 -0
  175. package/app/.next/server/app/api/v0/conversations/[id]/route.js +5 -4
  176. package/app/.next/server/app/api/v0/conversations/[id]/route.js.nft.json +1 -1
  177. package/app/.next/server/app/api/v0/exchanges/[id]/cancel/route/app-paths-manifest.json +3 -0
  178. package/app/.next/server/app/api/v0/exchanges/[id]/cancel/route/build-manifest.json +12 -0
  179. package/app/.next/server/app/api/v0/exchanges/[id]/cancel/route/server-reference-manifest.json +4 -0
  180. package/app/.next/server/app/api/v0/exchanges/[id]/cancel/route.js +12 -0
  181. package/app/.next/server/app/api/v0/exchanges/[id]/cancel/route.js.nft.json +1 -0
  182. package/app/.next/server/app/api/v0/exchanges/[id]/cancel/route_client-reference-manifest.js +3 -0
  183. package/app/.next/server/app/api/v0/exchanges/[id]/route/app-paths-manifest.json +3 -0
  184. package/app/.next/server/app/api/v0/exchanges/[id]/route/build-manifest.json +12 -0
  185. package/app/.next/server/app/api/v0/exchanges/[id]/route/server-reference-manifest.json +4 -0
  186. package/app/.next/server/app/api/v0/exchanges/[id]/route.js +12 -0
  187. package/app/.next/server/app/api/v0/exchanges/[id]/route.js.nft.json +1 -0
  188. package/app/.next/server/app/api/v0/exchanges/[id]/route_client-reference-manifest.js +3 -0
  189. package/app/.next/server/app/api/v0/exchanges/route/app-paths-manifest.json +3 -0
  190. package/app/.next/server/app/api/v0/exchanges/route/build-manifest.json +12 -0
  191. package/app/.next/server/app/api/v0/exchanges/route/server-reference-manifest.json +4 -0
  192. package/app/.next/server/app/api/v0/exchanges/route.js +12 -0
  193. package/app/.next/server/app/api/v0/exchanges/route.js.nft.json +1 -0
  194. package/app/.next/server/app/api/v0/exchanges/route_client-reference-manifest.js +3 -0
  195. package/app/.next/server/app/api/v0/mcp/route.js +7 -4
  196. package/app/.next/server/app/api/v0/mcp/route.js.nft.json +1 -1
  197. package/app/.next/server/app/api/v0/pins/[pinRef]/detach/route/app-paths-manifest.json +3 -0
  198. package/app/.next/server/app/api/v0/pins/[pinRef]/detach/route/build-manifest.json +12 -0
  199. package/app/.next/server/app/api/v0/pins/[pinRef]/detach/route/server-reference-manifest.json +4 -0
  200. package/app/.next/server/app/api/v0/pins/[pinRef]/detach/route.js +12 -0
  201. package/app/.next/server/app/api/v0/pins/[pinRef]/detach/route.js.nft.json +1 -0
  202. package/app/.next/server/app/api/v0/pins/[pinRef]/detach/route_client-reference-manifest.js +3 -0
  203. package/app/.next/server/app/api/v0/pins/[pinRef]/messages/route/app-paths-manifest.json +3 -0
  204. package/app/.next/server/app/api/v0/pins/[pinRef]/messages/route/build-manifest.json +12 -0
  205. package/app/.next/server/app/api/v0/pins/[pinRef]/messages/route/server-reference-manifest.json +4 -0
  206. package/app/.next/server/app/api/v0/pins/[pinRef]/messages/route.js +12 -0
  207. package/app/.next/server/app/api/v0/pins/[pinRef]/messages/route.js.nft.json +1 -0
  208. package/app/.next/server/app/api/v0/pins/[pinRef]/messages/route_client-reference-manifest.js +3 -0
  209. package/app/.next/server/app/api/v0/pins/[pinRef]/route/app-paths-manifest.json +3 -0
  210. package/app/.next/server/app/api/v0/pins/[pinRef]/route/build-manifest.json +12 -0
  211. package/app/.next/server/app/api/v0/pins/[pinRef]/route/server-reference-manifest.json +4 -0
  212. package/app/.next/server/app/api/v0/pins/[pinRef]/route.js +12 -0
  213. package/app/.next/server/app/api/v0/pins/[pinRef]/route.js.nft.json +1 -0
  214. package/app/.next/server/app/api/v0/pins/[pinRef]/route_client-reference-manifest.js +3 -0
  215. package/app/.next/server/app/api/v0/requests/[id]/route.js +5 -4
  216. package/app/.next/server/app/api/v0/requests/[id]/route.js.nft.json +1 -1
  217. package/app/.next/server/app/api/v0/sessions/[ref]/messages/route/app-paths-manifest.json +3 -0
  218. package/app/.next/server/app/api/v0/sessions/[ref]/messages/route/build-manifest.json +12 -0
  219. package/app/.next/server/app/api/v0/sessions/[ref]/messages/route/server-reference-manifest.json +4 -0
  220. package/app/.next/server/app/api/v0/sessions/[ref]/messages/route.js +12 -0
  221. package/app/.next/server/app/api/v0/sessions/[ref]/messages/route.js.nft.json +1 -0
  222. package/app/.next/server/app/api/v0/sessions/[ref]/messages/route_client-reference-manifest.js +3 -0
  223. package/app/.next/server/app/api/v0/sessions/[ref]/pins/route/app-paths-manifest.json +3 -0
  224. package/app/.next/server/app/api/v0/sessions/[ref]/pins/route/build-manifest.json +12 -0
  225. package/app/.next/server/app/api/v0/sessions/[ref]/pins/route/server-reference-manifest.json +4 -0
  226. package/app/.next/server/app/api/v0/sessions/[ref]/pins/route.js +12 -0
  227. package/app/.next/server/app/api/v0/sessions/[ref]/pins/route.js.nft.json +1 -0
  228. package/app/.next/server/app/api/v0/sessions/[ref]/pins/route_client-reference-manifest.js +3 -0
  229. package/app/.next/server/app/api/wake-grants/[id]/revoke/route.js +5 -5
  230. package/app/.next/server/app/api/wake-grants/[id]/revoke/route.js.nft.json +1 -1
  231. package/app/.next/server/app/api/wakes/[id]/decision/route.js +5 -5
  232. package/app/.next/server/app/api/wakes/[id]/decision/route.js.nft.json +1 -1
  233. package/app/.next/server/app/api/wakes/[id]/retry/route.js +5 -5
  234. package/app/.next/server/app/api/wakes/[id]/retry/route.js.nft.json +1 -1
  235. package/app/.next/server/app/bots/[id]/config/page.js +1 -1
  236. package/app/.next/server/app/bots/[id]/config/page.js.nft.json +1 -1
  237. package/app/.next/server/app/bots/[id]/config/page_client-reference-manifest.js +1 -1
  238. package/app/.next/server/app/exchanges/page/app-paths-manifest.json +3 -0
  239. package/app/.next/server/app/exchanges/page/build-manifest.json +20 -0
  240. package/app/.next/server/app/exchanges/page/next-font-manifest.json +11 -0
  241. package/app/.next/server/app/exchanges/page/react-loadable-manifest.json +1 -0
  242. package/app/.next/server/app/exchanges/page/server-reference-manifest.json +4 -0
  243. package/app/.next/server/app/exchanges/page.js +13 -0
  244. package/app/.next/server/app/exchanges/page.js.nft.json +1 -0
  245. package/app/.next/server/app/exchanges/page_client-reference-manifest.js +3 -0
  246. package/app/.next/server/app/exchanges.html +1 -0
  247. package/app/.next/server/app/exchanges.meta +34 -0
  248. package/app/.next/server/app/exchanges.rsc +22 -0
  249. package/app/.next/server/app/exchanges.segments/_full.segment.rsc +22 -0
  250. package/app/.next/server/app/exchanges.segments/_tree.segment.rsc +4 -0
  251. package/app/.next/server/app/exchanges.segments/exchanges/__PAGE__.segment.rsc +26 -0
  252. package/app/.next/server/app/index.html +1 -1
  253. package/app/.next/server/app/index.rsc +3 -3
  254. package/app/.next/server/app/index.segments/__PAGE__.segment.rsc +3 -3
  255. package/app/.next/server/app/index.segments/_full.segment.rsc +3 -3
  256. package/app/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  257. package/app/.next/server/app/page.js +1 -1
  258. package/app/.next/server/app/page.js.nft.json +1 -1
  259. package/app/.next/server/app/page_client-reference-manifest.js +1 -1
  260. package/app/.next/server/app/settings/page.js +1 -1
  261. package/app/.next/server/app/settings/page.js.nft.json +1 -1
  262. package/app/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  263. package/app/.next/server/app/settings.html +1 -1
  264. package/app/.next/server/app/settings.rsc +3 -3
  265. package/app/.next/server/app/settings.segments/_full.segment.rsc +3 -3
  266. package/app/.next/server/app/settings.segments/_tree.segment.rsc +2 -2
  267. package/app/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +3 -3
  268. package/app/.next/server/app/threads/[id]/page/app-paths-manifest.json +3 -0
  269. package/app/.next/server/app/threads/[id]/page/build-manifest.json +20 -0
  270. package/app/.next/server/app/threads/[id]/page/next-font-manifest.json +11 -0
  271. package/app/.next/server/app/threads/[id]/page/react-loadable-manifest.json +1 -0
  272. package/app/.next/server/app/threads/[id]/page/server-reference-manifest.json +4 -0
  273. package/app/.next/server/app/threads/[id]/page.js +13 -0
  274. package/app/.next/server/app/threads/[id]/page.js.nft.json +1 -0
  275. package/app/.next/server/app/threads/[id]/page_client-reference-manifest.js +3 -0
  276. package/app/.next/server/app-paths-manifest.json +27 -1
  277. package/app/.next/server/chunks/0ivl_api_v0_agents_[agentId]_conversations_[conversationId]_route_actions_0lvijtu.js +3 -0
  278. package/app/.next/server/chunks/1oeh_server_app_api_bots_[id]_sessions_[ref]_pins_route_actions_0e1st6o.js +3 -0
  279. package/app/.next/server/chunks/1oeh_server_app_api_v0_agents_[agentId]_conversations_route_actions_0ko3117.js +3 -0
  280. package/app/.next/server/chunks/1oeh_server_app_api_v0_agents_[agentId]_sessions_[ref]_route_actions_0o7q3vt.js +3 -0
  281. package/app/.next/server/chunks/{[externals]__18bqksw._.js → [externals]__06lqs5i._.js} +1 -1
  282. package/app/.next/server/chunks/{[root-of-the-server]__1vxmbdl._.js → [root-of-the-server]__0-45blq._.js} +1 -1
  283. package/app/.next/server/chunks/[root-of-the-server]__02kssr-._.js +3 -0
  284. package/app/.next/server/chunks/[root-of-the-server]__06qkt0f._.js +3 -0
  285. package/app/.next/server/chunks/[root-of-the-server]__08qhrch._.js +3 -0
  286. package/app/.next/server/chunks/[root-of-the-server]__097ptn_._.js +3 -0
  287. package/app/.next/server/chunks/[root-of-the-server]__09m9-pe._.js +3 -0
  288. package/app/.next/server/chunks/[root-of-the-server]__0b7w1z3._.js +3 -0
  289. package/app/.next/server/chunks/[root-of-the-server]__0f5yqjs._.js +3 -0
  290. package/app/.next/server/chunks/[root-of-the-server]__0g4um3-._.js +44 -0
  291. package/app/.next/server/chunks/[root-of-the-server]__0hro5ey._.js +3 -0
  292. package/app/.next/server/chunks/[root-of-the-server]__0hwpgxq._.js +3 -0
  293. package/app/.next/server/chunks/[root-of-the-server]__0izjfmr._.js +582 -55
  294. package/app/.next/server/chunks/{[root-of-the-server]__07l_rgn._.js → [root-of-the-server]__0j0i8xz._.js} +1 -1
  295. package/app/.next/server/chunks/[root-of-the-server]__0lwsto-._.js +5 -0
  296. package/app/.next/server/chunks/[root-of-the-server]__0s1enbp._.js +3 -0
  297. package/app/.next/server/chunks/[root-of-the-server]__0uq7sci._.js +3 -0
  298. package/app/.next/server/chunks/[root-of-the-server]__0wg992i._.js +3 -0
  299. package/app/.next/server/chunks/[root-of-the-server]__13cd2fb._.js +44 -0
  300. package/app/.next/server/chunks/[root-of-the-server]__17mum5-._.js +3 -0
  301. package/app/.next/server/chunks/[root-of-the-server]__1879cge._.js +3 -0
  302. package/app/.next/server/chunks/{[root-of-the-server]__17oz13o._.js → [root-of-the-server]__1_01-13._.js} +3 -3
  303. package/app/.next/server/chunks/[root-of-the-server]__1a2dh11._.js +3 -0
  304. package/app/.next/server/chunks/[root-of-the-server]__1bhzfu_._.js +7 -0
  305. package/app/.next/server/chunks/{[root-of-the-server]__1khwkvb._.js → [root-of-the-server]__1c3e2ds._.js} +1 -1
  306. package/app/.next/server/chunks/[root-of-the-server]__1co3sok._.js +44 -0
  307. package/app/.next/server/chunks/[root-of-the-server]__1eh30sp._.js +3 -0
  308. package/app/.next/server/chunks/[root-of-the-server]__1fmsid0._.js +44 -0
  309. package/app/.next/server/chunks/[root-of-the-server]__1i388e2._.js +3 -0
  310. package/app/.next/server/chunks/[root-of-the-server]__1kvvs4u._.js +3 -0
  311. package/app/.next/server/chunks/[root-of-the-server]__1qbgs3m._.js +3 -0
  312. package/app/.next/server/chunks/[root-of-the-server]__1s6h1sj._.js +3 -0
  313. package/app/.next/server/chunks/[root-of-the-server]__1slu7d7._.js +7 -0
  314. package/app/.next/server/chunks/[root-of-the-server]__1tuqc5v._.js +3 -0
  315. package/app/.next/server/chunks/[root-of-the-server]__1v609eq._.js +44 -0
  316. package/app/.next/server/chunks/[root-of-the-server]__1y_j43n._.js +3 -0
  317. package/app/.next/server/chunks/[root-of-the-server]__1zdv-vb._.js +3 -0
  318. package/app/.next/server/chunks/[root-of-the-server]__1zjs2tr._.js +3 -0
  319. package/app/.next/server/chunks/_0061c2q._.js +3 -0
  320. package/app/.next/server/chunks/_023se5j._.js +44 -0
  321. package/app/.next/server/chunks/_02pb_qv._.js +44 -0
  322. package/app/.next/server/chunks/_05ro-21._.js +44 -0
  323. package/app/.next/server/chunks/_07on0dc._.js +44 -0
  324. package/app/.next/server/chunks/_08208nz._.js +44 -0
  325. package/app/.next/server/chunks/_0a2do3x._.js +1 -1
  326. package/app/.next/server/chunks/_0fe5qz5._.js +44 -0
  327. package/app/.next/server/chunks/_0i8_xso._.js +3 -0
  328. package/app/.next/server/chunks/_0qoji5a._.js +44 -0
  329. package/app/.next/server/chunks/_0uv2pi5._.js +44 -0
  330. package/app/.next/server/chunks/_0wdl90-._.js +44 -0
  331. package/app/.next/server/chunks/_1-5mthb._.js +1 -1
  332. package/app/.next/server/chunks/_11-q8k1._.js +3 -0
  333. package/app/.next/server/chunks/_11ijk9k._.js +44 -0
  334. package/app/.next/server/chunks/_198sn69._.js +44 -0
  335. package/app/.next/server/chunks/_1ba_5hd._.js +44 -0
  336. package/app/.next/server/chunks/_1ess5if._.js +3 -0
  337. package/app/.next/server/chunks/_1i0zod4._.js +3 -0
  338. package/app/.next/server/chunks/_1m89jq5._.js +44 -0
  339. package/app/.next/server/chunks/_1n39wr_._.js +44 -0
  340. package/app/.next/server/chunks/_1ryxqo1._.js +44 -0
  341. package/app/.next/server/chunks/_1vemgly._.js +44 -0
  342. package/app/.next/server/chunks/_20azcus._.js +3 -0
  343. package/app/.next/server/chunks/_next-internal_server_app_api_bots_[id]_sessions_[ref]_route_actions_02gp9-5.js +3 -0
  344. package/app/.next/server/chunks/_next-internal_server_app_api_bots_[id]_sessions_route_actions_1s_wxg4.js +3 -0
  345. package/app/.next/server/chunks/_next-internal_server_app_api_exchanges_[id]_cancel_route_actions_0lh0fl4.js +3 -0
  346. package/app/.next/server/chunks/_next-internal_server_app_api_exchanges_[id]_route_actions_1w4jhin.js +3 -0
  347. package/app/.next/server/chunks/_next-internal_server_app_api_exchanges_route_actions_028wchg.js +3 -0
  348. package/app/.next/server/chunks/_next-internal_server_app_api_runtime-connections_route_actions_06rulng.js +3 -0
  349. package/app/.next/server/chunks/_next-internal_server_app_api_service-grants_route_actions_1459xk1.js +3 -0
  350. package/app/.next/server/chunks/_next-internal_server_app_api_v0_agents_[agentId]_pins_route_actions_08uftk9.js +3 -0
  351. package/app/.next/server/chunks/_next-internal_server_app_api_v0_agents_[agentId]_route_actions_127sxvv.js +3 -0
  352. package/app/.next/server/chunks/_next-internal_server_app_api_v0_agents_[agentId]_sessions_route_actions_0pm6tcu.js +3 -0
  353. package/app/.next/server/chunks/_next-internal_server_app_api_v0_agents_route_actions_00azkhd.js +3 -0
  354. package/app/.next/server/chunks/_next-internal_server_app_api_v0_capabilities_route_actions_0d-eefd.js +3 -0
  355. package/app/.next/server/chunks/_next-internal_server_app_api_v0_exchanges_[id]_cancel_route_actions_1hb2q7i.js +3 -0
  356. package/app/.next/server/chunks/_next-internal_server_app_api_v0_exchanges_[id]_route_actions_098f50-.js +3 -0
  357. package/app/.next/server/chunks/_next-internal_server_app_api_v0_exchanges_route_actions_1ftmhhm.js +3 -0
  358. package/app/.next/server/chunks/_next-internal_server_app_api_v0_pins_[pinRef]_detach_route_actions_0nk3268.js +3 -0
  359. package/app/.next/server/chunks/_next-internal_server_app_api_v0_pins_[pinRef]_messages_route_actions_1wenu96.js +3 -0
  360. package/app/.next/server/chunks/_next-internal_server_app_api_v0_pins_[pinRef]_route_actions_0z7fu_c.js +3 -0
  361. package/app/.next/server/chunks/_next-internal_server_app_api_v0_sessions_[ref]_messages_route_actions_1-rgf_k.js +3 -0
  362. package/app/.next/server/chunks/_next-internal_server_app_api_v0_sessions_[ref]_pins_route_actions_0y3ere3.js +3 -0
  363. package/app/.next/server/chunks/lib_0kik6bx._.js +1 -1
  364. package/app/.next/server/chunks/lib_0lqoyb4._.js +217 -0
  365. package/app/.next/server/chunks/lib_0pe3tiv._.js +1 -1
  366. package/app/.next/server/chunks/lib_0riiofz._.js +44 -0
  367. package/app/.next/server/chunks/lib_16j2293._.js +217 -0
  368. package/app/.next/server/chunks/lib_1nb_61e._.js +217 -0
  369. package/app/.next/server/chunks/lib_service-api-http_ts_0xzqhny._.js +25 -0
  370. package/app/.next/server/chunks/lib_session-pins_ts_0lmxnwj._.js +20 -0
  371. package/app/.next/server/chunks/ssr/{[root-of-the-server]__0sq4frf._.js → [root-of-the-server]__03186rx._.js} +1 -1
  372. package/app/.next/server/chunks/ssr/[root-of-the-server]__03xw2d9._.js +3 -0
  373. package/app/.next/server/chunks/ssr/{[root-of-the-server]__1x7o-fe._.js → [root-of-the-server]__0zzcbqg._.js} +1 -1
  374. package/app/.next/server/chunks/ssr/{[root-of-the-server]__029oxo_._.js → [root-of-the-server]__1feicqq._.js} +1 -1
  375. package/app/.next/server/chunks/ssr/[root-of-the-server]__1t063pe._.js +3 -0
  376. package/app/.next/server/chunks/ssr/_0epgorw._.js +3 -0
  377. package/app/.next/server/chunks/ssr/_1cvuhjt._.js +3 -0
  378. package/app/.next/server/chunks/ssr/_1n5mvo5._.js +3 -0
  379. package/app/.next/server/chunks/ssr/_1o94bnv._.js +1 -1
  380. package/app/.next/server/chunks/ssr/_next-internal_server_app_exchanges_page_actions_0hcso2x.js +3 -0
  381. package/app/.next/server/chunks/ssr/_next-internal_server_app_threads_[id]_page_actions_1fte2n3.js +3 -0
  382. package/app/.next/server/chunks/ssr/app_bots_[id]_config_page_tsx_1e0uue9._.js +3 -0
  383. package/app/.next/server/chunks/ssr/app_components_AgentDeckRuntime_tsx_024janf._.js +3 -0
  384. package/app/.next/server/chunks/ssr/app_components_ExchangeCard_tsx_1shfcgn._.js +3 -0
  385. package/app/.next/server/chunks/ssr/app_exchanges_page_tsx_0j-n2a1._.js +3 -0
  386. package/app/.next/server/chunks/ssr/node_modules_1nkgb45._.js +23 -0
  387. package/app/.next/server/chunks/ssr/node_modules_next_0x3i8za._.js +131 -0
  388. package/app/.next/server/middleware-build-manifest.js +3 -3
  389. package/app/.next/server/middleware.js +1 -1
  390. package/app/.next/server/next-font-manifest.js +1 -1
  391. package/app/.next/server/next-font-manifest.json +8 -0
  392. package/app/.next/server/pages/404.html +1 -1
  393. package/app/.next/server/pages/500.html +1 -1
  394. package/app/.next/server/prefetch-hints.json +14 -0
  395. package/app/.next/server/server-reference-manifest.js +1 -1
  396. package/app/.next/server/server-reference-manifest.json +1 -1
  397. package/app/.next/static/chunks/0bhd8eso48g27.js +1 -0
  398. package/app/.next/static/chunks/1ku9himlsx-hn.js +1 -0
  399. package/app/.next/static/chunks/21aqekm5z0j47.js +1 -0
  400. package/app/.next/static/chunks/2a8bomryx66oj.css +3 -0
  401. package/app/.next/static/chunks/3230ywnpii0s6.js +3 -0
  402. package/app/.next/static/chunks/35l2c95bd-jud.js +1 -0
  403. package/app/.next/static/chunks/3cijpn6vx3yzv.js +1 -0
  404. package/app/.next/static/chunks/3ue9194j59kem.js +1 -0
  405. package/app/.next/static/chunks/44ese2s4gzze_.js +1 -0
  406. package/app/BUILD_INFO.json +2 -2
  407. package/app/package.json +1 -1
  408. package/app/server.js +1 -1
  409. package/dist/cli.d.ts +1 -1
  410. package/dist/cli.js +35 -7
  411. package/dist/clients.d.ts +86 -0
  412. package/dist/clients.js +639 -0
  413. package/dist/config.d.ts +2 -1
  414. package/dist/config.js +7 -6
  415. package/dist/contract.d.ts +7 -1
  416. package/dist/contract.js +33 -8
  417. package/dist/home.d.ts +1 -1
  418. package/dist/home.js +1 -1
  419. package/dist/index.d.ts +1 -1
  420. package/dist/index.js +3 -3
  421. package/dist/managed.js +7 -0
  422. package/dist/product.d.ts +2 -0
  423. package/dist/product.js +7 -1
  424. package/dist/server.js +5 -4
  425. package/dist/upstream.js +21 -7
  426. package/package.json +7 -6
  427. package/schemas/botmancers.mcp.v2.tools.json +4565 -0
  428. package/skills/botmancers-collaboration/SKILL.md +114 -0
  429. package/skills/botmancers-collaboration/references/workflows.md +281 -0
  430. package/app/.next/server/chunks/[root-of-the-server]__08i4wq6._.js +0 -3
  431. package/app/.next/server/chunks/[root-of-the-server]__09d-yrq._.js +0 -3
  432. package/app/.next/server/chunks/[root-of-the-server]__0ab4e_k._.js +0 -3
  433. package/app/.next/server/chunks/[root-of-the-server]__0qozubc._.js +0 -3
  434. package/app/.next/server/chunks/[root-of-the-server]__0za34e1._.js +0 -7
  435. package/app/.next/server/chunks/[root-of-the-server]__10m3szc._.js +0 -3
  436. package/app/.next/server/chunks/[root-of-the-server]__19hjzs0._.js +0 -3
  437. package/app/.next/server/chunks/[root-of-the-server]__1afl75n._.js +0 -3
  438. package/app/.next/server/chunks/[root-of-the-server]__1fjpie4._.js +0 -3
  439. package/app/.next/server/chunks/[root-of-the-server]__1kvvdpx._.js +0 -7
  440. package/app/.next/server/chunks/[root-of-the-server]__1qanlbg._.js +0 -3
  441. package/app/.next/server/chunks/[root-of-the-server]__1qoa704._.js +0 -7
  442. package/app/.next/server/chunks/[root-of-the-server]__20wve4_._.js +0 -3
  443. package/app/.next/server/chunks/_0ggf7vy._.js +0 -3
  444. package/app/.next/server/chunks/_0gtqbub._.js +0 -3
  445. package/app/.next/server/chunks/_0i7ga8c._.js +0 -3
  446. package/app/.next/server/chunks/_0orubev._.js +0 -3
  447. package/app/.next/server/chunks/_0sfpe9z._.js +0 -3
  448. package/app/.next/server/chunks/_0th2j4w._.js +0 -3
  449. package/app/.next/server/chunks/_1ee4ej2._.js +0 -3
  450. package/app/.next/server/chunks/_1esxu1s._.js +0 -3
  451. package/app/.next/server/chunks/_1gn7eh7._.js +0 -3
  452. package/app/.next/server/chunks/_1gw7qwf._.js +0 -3
  453. package/app/.next/server/chunks/_1inyx08._.js +0 -3
  454. package/app/.next/server/chunks/_1kjsnlr._.js +0 -3
  455. package/app/.next/server/chunks/_1p8rola._.js +0 -3
  456. package/app/.next/server/chunks/app_api_import-capabilities_route_ts_013w1kt._.js +0 -3
  457. package/app/.next/server/chunks/lib_051fv4x._.js +0 -111
  458. package/app/.next/server/chunks/lib_07adeq3._.js +0 -111
  459. package/app/.next/server/chunks/lib_draft_ts_1atoius._.js +0 -3
  460. package/app/.next/server/chunks/ssr/_0k_7i66._.js +0 -131
  461. package/app/.next/server/chunks/ssr/_1flnty7._.js +0 -23
  462. package/app/.next/server/chunks/ssr/app_components_0bhuhd-._.js +0 -3
  463. package/app/.next/server/chunks/ssr/app_components_0w2_b3t._.js +0 -3
  464. package/app/.next/static/chunks/0774d7ob6aze_.js +0 -1
  465. package/app/.next/static/chunks/0d3ein53nlgja.js +0 -1
  466. package/app/.next/static/chunks/0qbtymorcz-l9.js +0 -3
  467. package/app/.next/static/chunks/3wdlh25l1vww9.js +0 -1
  468. package/app/.next/static/chunks/3zqbpbm93yqzh.css +0 -3
  469. /package/app/.next/static/{u4r8RPgEfpxk-DGXeKV6g → gh3shm8hnVqXLr75rmvsL}/_buildManifest.js +0 -0
  470. /package/app/.next/static/{u4r8RPgEfpxk-DGXeKV6g → gh3shm8hnVqXLr75rmvsL}/_clientMiddlewareManifest.js +0 -0
  471. /package/app/.next/static/{u4r8RPgEfpxk-DGXeKV6g → gh3shm8hnVqXLr75rmvsL}/_ssgManifest.js +0 -0
@@ -1,4 +1,4 @@
1
- module.exports=[60350,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(38246),e=a.i(71987);function f(a){let b,c=a.match(/^\s*\[run\]\s*([\s\S]*)$/);if(!c)return null;try{b=JSON.parse(c[1])}catch{return null}if(!b||"object"!=typeof b)return null;let d=b,e="string"==typeof d.page?d.page:"string"==typeof d.html?d.html:void 0,f=void 0===e?{}:{page:e,html:e};return"running"===d.state||"stopped"===d.state?{state:d.state,...f}:"done"===d.state&&"string"==typeof d.output?{state:"done",output:d.output,...f}:null}function g(a){return"done"===a.state?a.output??"":"stopped"===a.state?"The command was stopped.":"The command is running"}var h=a.i(36391);function i(a){let b,c=a.match(/^\s*\[draft\]\s*([\s\S]*)$/);if(!c)return null;try{b=JSON.parse(c[1])}catch{return null}if(!b||"object"!=typeof b)return null;let d=b;return"email"!==d.channel&&"slack"!==d.channel||"open"!==d.state&&"sent"!==d.state&&"discarded"!==d.state||"string"!=typeof d.recipient||"string"!=typeof d.body?null:{channel:d.channel,recipient:d.recipient,body:d.body,state:d.state}}function j(a){let b=a.match(/approve using the code ([A-Za-z0-9][A-Za-z0-9_-]*)/i);return b?b[1]:null}var k=a.i(20851),l=a.i(39228),m=a.i(2296),n=a.i(80219),o=a.i(60193),p=a.i(35832);function q(a){return String(a).padStart(2,"0")}function r(a){let b=new Date(a);return`${b.getFullYear()}-${q(b.getMonth()+1)}-${q(b.getDate())} ${q(b.getHours())}:${q(b.getMinutes())}`}function s({deckState:a,onClose:d,onDeleted:e}){let f=(0,c.useId)(),[g,h]=(0,c.useState)(null),[i,j]=(0,c.useState)(""),[l,m]=(0,c.useState)(""),[n,q]=(0,c.useState)([]),[t,u]=(0,c.useState)(!1),v=(0,c.useRef)(null),w=(0,c.useRef)(null),x=(0,c.useRef)(null);(0,c.useEffect)(()=>{let a=!1;return fetch("/api/bots/manage",{cache:"no-store"}).then(async b=>{let c=await b.json().catch(()=>null);if(!a){if(!b.ok||!Array.isArray(c))return void j("string"==typeof c?.error?c.error:"Could not load agents.");h(c)}}).catch(()=>{a||j("Could not load agents.")}),v.current?.focus(),()=>{a=!0}},[]);let y=l.trim().toLowerCase(),z=(g??[]).filter(a=>a.name.toLowerCase().includes(y)),A=z.filter(a=>!a.blocked);return(0,c.useEffect)(()=>{if(t)return;let a=a=>{"Escape"===a.key&&d()};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[t,d]),(0,b.jsxs)("div",{className:"modal-scrim manage-scrim",children:[(0,b.jsxs)("div",{ref:x,className:"manage-card",role:"dialog","aria-modal":"true","aria-labelledby":f,onKeyDown:a=>{if("Tab"!==a.key||!x.current)return;let b=Array.from(x.current.querySelectorAll("button:not(:disabled), input:not(:disabled)"));if(0===b.length)return;let c=b[0],d=b[b.length-1];a.shiftKey&&document.activeElement===c?(a.preventDefault(),d.focus()):a.shiftKey||document.activeElement!==d||(a.preventDefault(),c.focus())},children:[(0,b.jsxs)("div",{className:"manage-head",children:[(0,b.jsx)("h2",{id:f,className:"delete-title",children:"Manage agents"}),(0,b.jsx)("button",{type:"button",className:"cancel-btn",onClick:d,children:"Close"})]}),(0,b.jsx)("label",{className:"manage-search-label",htmlFor:`${f}-search`,children:"Filter by name"}),(0,b.jsx)("input",{id:`${f}-search`,ref:v,className:"manage-search",type:"search",value:l,onChange:a=>m(a.target.value),placeholder:"Name contains…"}),(0,b.jsxs)("div",{className:"manage-tools",children:[(0,b.jsx)("button",{type:"button",className:"pin-word",onClick:()=>{q(a=>Array.from(new Set([...a,...A.map(a=>a.id)])))},disabled:0===A.length,children:"Select all shown"}),(0,b.jsx)("button",{type:"button",className:"pin-word",onClick:()=>{q([]),v.current?.focus()},disabled:0===n.length,children:"Clear selection"}),(0,b.jsxs)("span",{className:"manage-count","aria-live":"polite",children:[n.length," selected · ",z.length," shown of ",g?.length??0]})]}),i?(0,b.jsx)("p",{className:"delete-error",role:"alert",children:i}):null,g||i?null:(0,b.jsx)("p",{className:"delete-copy",children:"Loading agents…"}),g?(0,b.jsxs)("ul",{className:"manage-list","aria-label":"Agents",children:[0===z.length?(0,b.jsx)("li",{className:"delete-copy",children:"No agents match."}):null,z.map(c=>{let d=`${f}-row-${c.id}`,e=(0,k.isMigratedPending)(c)?"Not selected":(0,k.deckLabel)(c.deck_id??"",a);return(0,b.jsxs)("li",{className:c.blocked?"manage-row is-blocked":"manage-row","data-agent-id":c.id,children:[(0,b.jsx)("input",{id:d,type:"checkbox",checked:n.includes(c.id),disabled:!!c.blocked,onChange:()=>{var a;return a=c.id,void q(b=>b.includes(a)?b.filter(b=>b!==a):[...b,a])},"aria-describedby":c.blocked?`${d}-reason`:void 0}),(0,b.jsxs)("div",{className:"manage-copy",children:[(0,b.jsxs)("label",{htmlFor:d,className:"manage-name",children:[c.name,c.hidden?(0,b.jsx)("span",{className:"manage-tag",children:"Hidden"}):null]}),(0,b.jsxs)("dl",{className:"manage-meta",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("dt",{children:"Agent"}),(0,b.jsx)("dd",{children:(0,k.botAgentLabel)(c)})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("dt",{children:"Agent Deck"}),(0,b.jsx)("dd",{children:e})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("dt",{children:"Source"}),(0,b.jsx)("dd",{children:c.source_provider||"Created here"})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("dt",{children:"Created"}),(0,b.jsx)("dd",{children:r(c.created_at)})]}),c.last_activity?(0,b.jsxs)("div",{children:[(0,b.jsx)("dt",{children:"Last activity"}),(0,b.jsx)("dd",{children:r(c.last_activity)})]}):null]}),c.blocked?(0,b.jsx)("p",{id:`${d}-reason`,className:"manage-reason",children:(0,p.blockedReasonCopy)(c.blocked)}):null]})]},c.id)})]}):null,(0,b.jsxs)("div",{className:"form-actions manage-actions",children:[(0,b.jsx)("button",{type:"button",className:"cancel-btn",onClick:d,children:"Cancel"}),(0,b.jsxs)("button",{ref:w,type:"button",className:"delete-btn",disabled:0===n.length,onClick:()=>u(!0),children:["Delete selected",n.length>0?` (${n.length})`:""]})]})]}),t?(0,b.jsx)(o.default,{ids:n,onCancel:()=>{u(!1),requestAnimationFrame(()=>w.current?.focus())},onDeleted:e}):null]})}function t({view:a,agentName:c}){if("loading"===a)return(0,b.jsx)("p",{className:"thread-note",role:"status",children:"Loading messages…"});if("error"===a)return(0,b.jsx)("p",{className:"thread-note thread-note-error",role:"alert",children:"Couldn’t load messages. Trying again…"});if("empty"===a){let a={title:`No messages with ${c} yet.`,hint:"Say something below to start the conversation."};return(0,b.jsxs)("div",{className:"thread-empty","data-thread-empty":"",children:[(0,b.jsx)("p",{className:"thread-empty-title",children:a.title}),(0,b.jsx)("p",{className:"thread-empty-hint",children:a.hint})]})}return null}let u={error:"Error"},v=[{kind:"hermes-config-missing",severity:"error",pattern:/^\[Hermes configuration missing: [^\n]*\]$/,title:"Hermes needs configuration",recovery:"This agent can’t reply until the Hermes API key is set on the Botmancers server. Set it, restart, then send your message again."},{kind:"hermes-turn-failed",severity:"error",pattern:/^\[Hermes turn failed for [\s\S]*\]$/,title:"Hermes couldn’t complete the turn",recovery:"Check that the Hermes gateway is running and reachable, then send your message again."}];function w(a){let b=String(a??"").trim();if(!b)return null;let c=v.find(a=>a.pattern.test(b));return c?{kind:c.kind,severity:c.severity,title:c.title,recovery:c.recovery,detail:b}:null}function x({failure:a}){let[d,e]=(0,c.useState)("idle"),f=u[a.severity],g=(0,c.useId)();async function h(){try{await navigator.clipboard.writeText(a.detail),e("copied")}catch{e("failed")}}return(0,b.jsxs)("div",{className:`runtime-failure runtime-failure-${a.severity}`,role:"status","aria-labelledby":g,"data-runtime-failure":a.kind,children:[(0,b.jsxs)("p",{className:"runtime-failure-title",id:g,children:[(0,b.jsx)("span",{className:"runtime-failure-severity",children:f}),a.title]}),(0,b.jsx)("p",{className:"runtime-failure-recovery",children:a.recovery}),(0,b.jsxs)("details",{className:"runtime-failure-details",children:[(0,b.jsx)("summary",{children:"Details"}),(0,b.jsx)("code",{className:"runtime-failure-detail",children:a.detail}),(0,b.jsx)("button",{type:"button",className:"runtime-failure-copy",onClick:()=>{h()},children:"copied"===d?"Copied":"failed"===d?"Copy failed":"Copy details"})]})]})}function y(a){if(!a)return"";let b=f(a);if(b)return g(b);let c=w(a);if(c)return c.title;let d=(0,k.deckEventDisplay)(a);return d?`${d.label} ${d.detail}`.replace(/\s+/g," ").trim():a.replace(/\s+/g," ").trim()}let z={blocked:"Needs approval",rejected:"Not started",allowed:"Allowed",denied:"Denied",waiting:"Queued",stopped:"Stopped"};function A({notice:a,onDone:d}){let[e,f]=(0,c.useState)(!1),[g,h]=(0,c.useState)(""),i="blocked"!==a.tone||a.actionable?z[a.tone]:"Blocked",j=async b=>{if(!e&&a.wakeId){f(!0),h("");try{let c=await fetch(`/api/wakes/${a.wakeId}/decision`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({decision:b})});if(!c.ok){let a=await c.json().catch(()=>null);h("string"==typeof a?.error?.message?a.error.message:"The decision could not be recorded.")}}catch{h("The decision could not be recorded.")}finally{f(!1),d()}}};return(0,b.jsxs)("div",{className:`wake-notice wake-notice-${a.tone}`,role:"status","data-wake-notice":a.tone,"data-wake-id":a.wakeId??void 0,children:[(0,b.jsxs)("p",{className:"wake-notice-line",children:[(0,b.jsx)("span",{className:"wake-notice-label",children:i}),a.text]}),a.actionable?(0,b.jsxs)("div",{className:"wake-notice-actions",children:[(0,b.jsx)("button",{type:"button",className:"approve-control",disabled:e,onClick:()=>{j("allow")},children:"Allow"}),(0,b.jsx)("button",{type:"button",className:"approve-control",style:{marginLeft:8},disabled:e,onClick:()=>{j("deny")},children:"Deny"})]}):null,g?(0,b.jsx)("p",{className:"wake-notice-error",role:"alert",children:g}):null]})}function B(a){return!!a&&"chief-of-staff"===a.name.toLowerCase()}function C(a){return B(a)?0:a.pinned?1:2}function D(a,b,c,d){return a&&b?d-c+(b-a)>15e3?"Stopped":"Heartbeat "+new Intl.DateTimeFormat("en-US",{timeZone:"America/Los_Angeles",hour:"numeric",minute:"2-digit",second:"2-digit"}).format(new Date(a)):"Stopped"}function E(a){let b=a;for(let a=0;a<2;a++){let a=b.replace(/^\s*\[Message from [^\]]+\]\s*(?:\r?\n)?/,"");if(a===b)break;b=a}return b.replace(/^\s+/,"")}function F(a){let b=a;for(let a=0;a<4;a++){let a=b.replace(/^\s*\[(?:Message from|From) [^\]]+\]\s*(?:\r?\n)?/,"");if(a===b)break;b=a}return b}function G({message:a,conversationId:d,status:e,onDone:f}){let g=i(F(a.content)),[h,j]=(0,c.useState)(g?.recipient??""),[k,l]=(0,c.useState)(g?.body??""),[m,n]=(0,c.useState)(!1),[o,p]=(0,c.useState)("open"!==e),q=(0,c.useRef)("open"!==e);if(!g)return null;let r="open"!==e||o,s=r?g.recipient:h,t=r?g.body:k,u=async b=>{if(!r&&!q.current&&!m&&("send"!==b||""!==h.trim())){q.current=!0,p(!0),n(!0);try{(await fetch(`/api/conversations/${d}/draft`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messageId:a.id,action:b,recipient:h,body:k})})).ok||(q.current=!1,p(!1))}finally{n(!1),f()}}};return(0,b.jsxs)("div",{className:"draft-card",children:[(0,b.jsx)("div",{className:"draft-title",children:"email"===g.channel?"New Email":"New Slack Message"}),(0,b.jsx)("input",{type:"text","aria-label":"Recipient",value:s,readOnly:r,disabled:m,onChange:a=>{r||j(a.target.value)}}),(0,b.jsx)("textarea",{rows:3,"aria-label":"Draft body",value:t,readOnly:r,disabled:m,onChange:a=>{r||l(a.target.value)}}),"sent"===e?(0,b.jsx)("span",{className:"draft-mark",children:"Sent"}):null,"discarded"===e?(0,b.jsx)("span",{className:"draft-mark",children:"Discarded"}):null,"discarded"!==e?(0,b.jsx)("button",{type:"button",className:"approve-control",disabled:m,onClick:()=>{u("send")},children:"Send"}):null,"open"===e?(0,b.jsx)("button",{type:"button",className:"approve-control",style:{marginLeft:8},disabled:m,onClick:()=>{u("discard")},children:"Discard"}):null]})}function H({message:a,conversationId:d,status:e,onDone:f}){let g=j(a.content),[h,i]=(0,c.useState)(!1),k=(0,c.useRef)("pending"!==e);if(!g)return null;let l=async b=>{if(!k.current&&!h){k.current=!0,i(!0);try{(await fetch(`/api/conversations/${d}/${b}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:g,messageId:a.id})})).ok||(k.current=!1)}finally{i(!1),f()}}};return"pending"!==e?(0,b.jsx)("span",{className:"draft-mark",children:"approved"===e?"Approved":"Denied"}):(0,b.jsxs)("span",{className:"draft-mark",children:[(0,b.jsx)("button",{type:"button",className:"approve-control",disabled:h,onClick:()=>{l("approve")},children:"Approve"}),(0,b.jsx)("button",{type:"button",className:"approve-control",style:{marginLeft:8},disabled:h,onClick:()=>{l("deny")},children:"Deny"})]})}function I({names:a}){return 0===a.length?null:(0,b.jsx)(b.Fragment,{children:a.map(a=>(0,b.jsxs)("span",{children:[(0,b.jsx)("br",{}),(0,b.jsxs)("a",{className:"file-control",href:`/api/files/${encodeURIComponent(a)}`,download:a,children:["Download ",a]})]},a))})}function J({anchorRef:a,deckState:d,onRetryDecks:e,onClose:f,onCreated:g}){let[h,i]=(0,c.useState)(""),[j,m]=(0,c.useState)(k.DEFAULT_RUNTIME_FORM),[n,o]=(0,c.useState)(""),[p,q]=(0,c.useState)(null),r=(0,c.useRef)(null),s=(0,c.useRef)(null);(0,c.useEffect)(()=>{e()},[e]),(0,c.useLayoutEffect)(()=>{let b=()=>{let b=a.current?.getBoundingClientRect();q(function(a,b){let c=Math.min(358,b.width-32),d=Math.max(16,b.width-16-c),e=16,f=16;if(a){f=Math.min(Math.max(a.left,16),d);let c=a.bottom+8;b.height-c-16>=360&&(e=c)}return{top:e,left:f,maxHeight:Math.max(0,b.height-e-16)}}(b?{left:b.left,bottom:b.bottom}:null,{width:window.innerWidth,height:window.innerHeight}))};return b(),window.addEventListener("resize",b),()=>window.removeEventListener("resize",b)},[a]),(0,c.useEffect)(()=>{s.current?.focus()},[]),(0,c.useEffect)(()=>{let a=a=>{"Escape"===a.key&&(a.stopPropagation(),f())};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[f]);let t=(0,k.runtimeFormView)(j,d),u=async a=>{if(a.preventDefault(),t.submitDisabled)return;if(!j.deckId.trim())return void o(k.SELECT_DECK_ERROR);o("");let b=await fetch("/api/bots",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify((0,k.newBotSubmitBody)({name:h,...j}))});if(!b.ok){let a=await b.json().catch(()=>null);o("string"==typeof a?.error&&a.error?a.error:"Failed to create agent");return}g()};return(0,b.jsx)("div",{className:"modal-scrim new-agent-scrim",onKeyDown:a=>{if("Tab"!==a.key||!r.current)return;let b=function(a,b,c){if(0===a.length)return null;let d=a[0],e=a[a.length-1],f=null!==b&&a.includes(b);return c?f&&b!==d?null:e:f&&b!==e?null:d}(Array.from(r.current.querySelectorAll('a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])')),document.activeElement,a.shiftKey);b&&(a.preventDefault(),b.focus())},children:(0,b.jsxs)("div",{ref:r,className:"form-card new-agent-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"new-agent-title",style:p??void 0,children:[(0,b.jsx)("div",{className:"kind-row",children:(0,b.jsx)("h2",{id:"new-agent-title",className:"kind-word new-agent-title",children:"New Agent"})}),(0,b.jsxs)("form",{onSubmit:u,className:"bot-form",children:[(0,b.jsxs)("div",{className:"new-agent-body",children:[(0,b.jsx)("label",{htmlFor:"bot-name",children:"Name"}),(0,b.jsx)("input",{ref:s,id:"bot-name",type:"text",value:h,onChange:a=>i(a.target.value),required:!0}),(0,b.jsx)(l.AgentSection,{idPrefix:"bot",variant:"modal",form:j,onChange:a=>{o(""),m(b=>({...b,...a}))},deckState:d,onRetry:e,workdirPlaceholder:"",workdirHint:k.NEW_BOT_WORKDIR_HINT}),n?(0,b.jsx)("p",{className:"form-error",role:"alert",children:n}):null]}),(0,b.jsxs)("div",{className:"form-actions",children:[(0,b.jsx)("button",{type:"button",className:"cancel-btn",onClick:f,children:"Cancel"}),(0,b.jsx)("button",{type:"submit",className:"create-btn",disabled:t.submitDisabled,children:"Create"})]})]})]})})}a.s(["default",0,function(){var a;let[q,r]=(0,c.useState)([]),[u,v]=(0,c.useState)(!1),[z,K]=(0,c.useState)(null),L=(0,c.useRef)(!1),[M,N]=(0,c.useState)([]),[O,P]=(0,c.useState)([]),[Q,R]=(0,c.useState)(null),S=(0,c.useRef)(null),[T,U]=(0,c.useState)(""),[V,W]=(0,c.useState)(""),[X,Y]=(0,c.useState)(!1),[Z,$]=(0,c.useState)([]),[_,aa]=(0,c.useState)(""),ab=(0,c.useRef)(null),ac=(0,c.useRef)(null),[ad,ae]=(0,c.useState)(!1),af=(0,c.useRef)(null),[ag,ah]=(0,c.useState)(!1),[ai,aj]=(0,c.useState)(!1),[ak,al]=(0,c.useState)(null),[am,an]=(0,c.useState)(""),[ao,ap]=(0,c.useState)({}),aq=(0,c.useRef)({}),[ar,as]=(0,c.useState)(null),[at,au]=(0,c.useState)(null),av=(0,c.useRef)(null),aw=(0,c.useRef)(null),[ax,ay]=(0,c.useState)(!1),az=(0,c.useRef)(null),[aA,aB]=(0,c.useState)(""),[aC,aD]=(0,c.useState)(!1),aE=(0,c.useRef)(null),aF=(0,c.useRef)(null),aG=(0,c.useRef)(null),aH=(0,c.useRef)(null),aI=(0,c.useRef)(null),aJ=(0,c.useRef)(null),aK=(0,c.useRef)(null),[aL,aM]=(0,c.useState)([]),[aN,aO]=(0,c.useState)({serverNow:0,fetchedAt:0}),[aP,aQ]=(0,c.useState)(()=>Date.now()),aR=(0,c.useRef)({}),aS=(0,c.useRef)(!1),[aT,aU]=(0,c.useState)(!1),{state:aV,retry:aW}=(0,m.useDeckList)();(0,c.useEffect)(()=>{aS.current||0===q.length||(aS.current=!0,aU(!0))},[q.length]),(0,c.useEffect)(()=>{let a=(0,n.importedBotId)(window.location.search);if(a)return void window.location.replace((0,n.importedConfigPath)(a));let b=Number(new URLSearchParams(window.location.search).get("deleted"));b>0&&window.history.replaceState(null,"","/"),a$().then(()=>{b>0&&aB((0,p.deletedStatusLine)(b))});let c=setInterval(a$,2e3),d=setInterval(()=>aQ(Date.now()),1e3);return()=>{clearInterval(c),clearInterval(d)}},[]),(0,c.useEffect)(()=>{if(L.current||0===q.length||z)return;let a=[...q].filter(a=>!a.hidden).sort((a,b)=>C(a)-C(b))[0]||q[0];L.current=!0,a3(a.id)},[q,z]),(0,c.useEffect)(()=>{if(S.current=z?.id??null,z)return a_(),aK.current&&clearInterval(aK.current),aK.current=setInterval(a_,2e3),()=>{aK.current&&clearInterval(aK.current)}},[z]);let aX=z?q.find(a=>a.id===z.details.id)??z.details:void 0,aY=!!z&&B(aX),aZ=aY?function(a){for(let b=a.length-1;b>=0;b--){let c=f(a[b].content);if(c){if("stopped"===c.state)return null;return c.page||c.html||null}}return null}(M):null;async function a$(){let a=await fetch("/api/bots",{cache:"no-store"}),b=await a.json(),c=Date.parse(a.headers.get("date")||"");aO({serverNow:Number.isNaN(c)?Date.now():c,fetchedAt:Date.now()}),Array.isArray(b)&&(r(b),v(!0))}async function a_(){if(!z)return;let a=z.id,b=null,c=!1,d=fetch(`/api/conversations/${a}`).then(async a=>{let b=await a.json();return a.ok&&Array.isArray(b?.events)?b.events:null}).catch(()=>null);try{let d=await fetch(`/api/conversations/${a}/messages`);b=await d.json(),c=d.ok&&Array.isArray(b)}catch{c=!1}let e=await d;if(S.current===a){let d,f;c&&N(b),e&&P((d=[],f=new Map,e.forEach((a,b)=>{let c="string"==typeof a.data.target_name?a.data.target_name:null;a.requestId&&c&&f.set(a.requestId,c);let g=function(a){switch(a.kind){case"wake_blocked":return"blocked";case"wake_rejected":return"rejected";case"lineage_stopped":return"stopped";case"wake_accepted":return"string"==typeof a.data.reason?"allowed":null;case"request_cancelled":return"grant_denied"===a.data.reason?"denied":null;case"request_queued":return"capacity"===a.data.waiting_for?"waiting":null;default:return null}}(a);if(!g)return;let h=Array.isArray(a.data.actions)?a.data.actions:[],i=null!==a.requestId&&e.slice(b+1).some(b=>b.requestId===a.requestId);if("waiting"===g&&i)return;let j=a.requestId?f.get(a.requestId):void 0,k="denied"===g&&j?`Wake denied: ${j} — no work ran`:"waiting"===g&&j?`Queued: ${j} — waiting for capacity`:a.text;d.push({eventId:a.eventId,wakeId:a.wakeId,tone:g,text:k,actionable:"blocked"===g&&!!a.wakeId&&h.includes("allow")&&h.includes("deny")&&!i,createdAt:a.createdAt})}),d)),R({conversationId:a,status:c?"ready":"error"})}}(0,c.useLayoutEffect)(()=>{let a=aG.current?.parentElement;if(!a)return;let b=aH.current,c=aI.current,d=aJ.current;if(aY&&b&&c&&d){let e=e=>{let f=Math.ceil(b.getBoundingClientRect().height);c.style.height=f+16+e+"px";let g=c.getBoundingClientRect().top-a.getBoundingClientRect().top;d.style.height=Math.max(0,a.clientHeight-g)+"px";let h=b.getBoundingClientRect().top-a.getBoundingClientRect().top+a.scrollTop;a.scrollTop=Math.max(0,h-g)};e(0);let f=c.nextElementSibling,g=b.getBoundingClientRect().bottom,h=f?f.getBoundingClientRect().top:c.getBoundingClientRect().bottom;g>=h&&e(Math.max(16,Math.ceil(g-h)));return}d&&(d.style.height="0px"),c&&(c.style.height=""),a.scrollTop=a.scrollHeight},[M,aY]),(0,c.useLayoutEffect)(()=>{aM(a=>{if(0===a.length)return a;let b=a.filter(a=>{let b=aR.current[a]??0;return M.some(c=>"bot"===c.sender_type&&c.sender_id===a&&c.created_at>b&&!/^\[(mcp|tool call|tool result)\]/i.test(c.content.trim()))});if(0===b.length)return a;for(let a of b)delete aR.current[a];return a.filter(a=>!b.includes(a))})},[M]);let a0=async a=>{z&&(await fetch(`/api/conversations/${z.id}/messages/${a}/stop`,{method:"POST"}),await a_())},a1=async()=>{z&&(await fetch(`/api/conversations/${z.id}/stop`,{method:"POST"}),await a_())},a2=async(a,b)=>{if(ao[a.id])return void ap(b=>{let c={...b};return delete c[a.id],c});if(aq.current[a.id])return;let c=M.findIndex(b=>b.id===a.id),d=q.find(a=>a.name===b),e=M.slice(c+1).find(a=>"bot"===a.sender_type&&(d?a.sender_id===d.id:a.sender_name===b));if(e){aq.current[a.id]=!0;try{let b=await fetch(`/api/messages/${a.id}/between?other=${encodeURIComponent(e.id)}`),c=await b.json().catch(()=>null);b.ok&&Array.isArray(c)&&c.length>0&&ap(b=>({...b,[a.id]:c}))}finally{delete aq.current[a.id]}}};async function a3(a){let b=q.find(b=>b.id===a);if(!b)return;let c=await fetch(`/api/conversations?botId=${a}`),d=await c.json();ah(!1),aj(!1),d.id!==z?.id&&(N([]),P([])),S.current=d.id,K({id:d.id,details:b})}let a4=async()=>{if(!z)return;let a=aE.current?.files?.[0];if(!a)return;let b=await new Promise((b,c)=>{let d=new FileReader;d.onload=()=>b(String(d.result||"")),d.onerror=()=>c(d.error),d.readAsDataURL(a)});if(!b.startsWith("data:image/"))return;let c=await fetch("/api/bots",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:z.details.id,avatar:b})});if(!c.ok)return;let d=await c.json();r(a=>a.map(a=>a.id===d.id?{...a,avatar:d.avatar}:a)),K({...z,details:{...z.details,avatar:d.avatar}})},a5=async a=>{if(!a||!z)return;let b=await new Promise((b,c)=>{let d=new FileReader;d.onload=()=>b(String(d.result||"")),d.onerror=()=>c(d.error),d.readAsDataURL(a)});if(!b.startsWith("data:image/"))return;let c=await fetch("/api/bots",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:z.details.id,avatar:b})});if(!c.ok)return;let d=await c.json();r(a=>a.map(a=>a.id===d.id?{...a,avatar:d.avatar}:a)),K({...z,details:{...z.details,avatar:d.avatar}})},a6=async()=>{if(!z)return;let a=await fetch("/api/bots",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:z.details.id,avatar:null})});if(!a.ok)return;let b=await a.json();r(a=>a.map(a=>a.id===b.id?{...a,avatar:b.avatar||""}:a)),K({...z,details:{...z.details,avatar:b.avatar||""}})},a7=u&&0===q.length,a8=[...q].filter(a=>!a.hidden).sort((a,b)=>C(a)-C(b)),a9=q.filter(a=>a.hidden),ba=async a=>{let b=await fetch("/api/bots",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:a.id,pinned:+!a.pinned})});if(!b.ok)return;let c=await b.json();r(a=>a.map(a=>a.id===c.id?{...a,...c}:a))},bb=async(a,b)=>{let c=await fetch("/api/bots",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:a.id,hidden:+!!b})});if(!c.ok)return;let d=await c.json();r(a=>a.map(a=>a.id===d.id?{...a,...d,hidden:+!!d.hidden}:a)),b?requestAnimationFrame(()=>aw.current?.focus()):bf(a.id)},bc=async a=>{(await fetch("/api/bots",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:a.id,unread:1})})).ok&&r(b=>b.map(b=>b.id===a.id?{...b,unread:1}:b))};(0,c.useEffect)(()=>{if(!at)return;let a=a=>{"Escape"===a.key&&(au(null),at.returnTo?.focus())},b=a=>{av.current&&av.current.contains(a.target)||au(null)};return document.addEventListener("keydown",a),document.addEventListener("pointerdown",b),()=>{document.removeEventListener("keydown",a),document.removeEventListener("pointerdown",b)}},[at]);let bd=async a=>{let b=am.trim();if(al(null),!b||b===a.name)return;let c=await fetch("/api/bots",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:a.id,name:b})});if(!c.ok)return;let d=await c.json();r(a=>a.map(a=>a.id===d.id?{...a,...d}:a)),z&&z.details.id===d.id&&K({...z,details:{...z.details,...d}})},be=async a=>{let b=a.map(a=>a.id);as(null),ay(!1),aB((0,p.deletedStatusLine)(b.length)),requestAnimationFrame(()=>az.current?.focus()),r(a=>a.filter(a=>!b.includes(a.id))),z&&b.includes(z.details.id)&&(K(null),N([]),P([])),await a$()},bf=(a,b=30)=>{requestAnimationFrame(()=>{let c=document.querySelector(`[data-open-bot="${a}"]`);c?c.focus():b>0&&bf(a,b-1)})},bg=(a=!0)=>{let b=at?.returnTo;au(null),a&&b&&requestAnimationFrame(()=>{b.isConnected&&b.focus()})},bh=(a,b)=>{a.preventDefault(),au({bot:b,x:a.clientX,y:a.clientY,returnTo:a.currentTarget.querySelector("[data-open-bot]")})},bi=(a,c)=>(0,b.jsx)("input",{className:"bot-name","aria-label":`Rename ${a.name}`,value:am,autoFocus:!0,onChange:a=>an(a.target.value),onBlur:()=>bd(a),onKeyDown:b=>{"Enter"===b.key&&(b.preventDefault(),b.target.blur(),bf(a.id)),"Escape"===b.key&&(al(null),bf(a.id))},style:c}),bj=(a,c)=>(0,b.jsx)("button",{type:"button",className:"bot-name row-open","data-open-bot":a.id,"aria-current":z?.details.id===a.id?"true":void 0,onClick:()=>a3(a.id),style:c,children:a.name}),bk=a=>(0,b.jsx)("button",{type:"button",className:"row-actions","aria-haspopup":"menu","aria-expanded":at?.bot.id===a.id,"aria-label":`Actions for ${a.name}`,title:`Actions for ${a.name}`,onClick:b=>{var c;let d;au({bot:a,x:(d=(c=b.currentTarget).getBoundingClientRect()).left,y:d.bottom+4,returnTo:c})},children:"⋯"}),bl=a=>(0,b.jsxs)("div",{className:"row-tip",children:[a.unread&&z?.details.id!==a.id?(0,b.jsx)("div",{className:"card-role",children:"Unread"}):null,(0,b.jsx)("div",{className:"card-role",children:D(a.last_seen,aN.serverNow,aN.fetchedAt,aP)})]}),bm=a=>(0,b.jsxs)("div",{className:z?.details.id===a.id?"bot-row is-open":"bot-row",onContextMenu:b=>bh(b,a),children:[(0,b.jsxs)("span",{className:"mark-avatar mark-avatar-sm",children:[(0,b.jsx)(h.default,{bot:a,size:36,title:`${a.name} avatar`}),aL.includes(a.id)?(0,b.jsx)("span",{className:"mark-dot"}):null]}),(0,b.jsxs)("div",{className:"bot-copy",children:[ak===a.id?bi(a):bj(a),y(a.latest)?(0,b.jsx)("div",{className:"bot-preview",children:y(a.latest)}):null,(0,b.jsx)(l.RosterRuntimeLine,{bot:a,state:aV})]}),bk(a),bl(a)]},a.id),bn=X?q.filter(a=>a.name.toLowerCase().includes(V.toLowerCase())):[],bo=a=>{let b=ab.current,c=b?b.selectionStart:T.length,d=T.slice(0,c).lastIndexOf("@");if(d<0)return;U(T.slice(0,d)+"@"+a+" "+T.slice(c)),Y(!1);let e=d+a.length+2;requestAnimationFrame(()=>{b?.focus(),b?.setSelectionRange(e,e)})},bp=a=>{if(0===a.length)return;let b=6-Z.length;a.length>b?aa("Up to six attachments."):aa("");let c=a.slice(0,Math.max(b,0));0!==c.length&&$(a=>[...a,...c.map((b,c)=>({id:b.name+"-"+a.length+"-"+c+"-"+b.size,name:b.name}))])},bq=async()=>{let a=Z.map(a=>a.name),b=T.trim();if(!b&&0===a.length||!z)return;let c=[b,...a].filter(a=>a.length>0).join("\n"),d=[z.details.id],e=M.reduce((a,b)=>Math.max(a,b.created_at||0),0);for(let a of d)aR.current[a]=e;aM(a=>Array.from(new Set([...a,...d])));let f=[...q].sort((a,b)=>b.name.length-a.name.length).find(a=>(function(a,b){let c="@"+b,d=0;for(;d<a.length;){let b=a.indexOf(c,d);if(b<0)break;let e=a[b+c.length];if(!e||/[\s.,!?:;]/.test(e))return!0;d=b+c.length}return!1})(c,a.name));if(!(await fetch(`/api/conversations/${z.id}/messages`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:c,mentionedBotId:f?.id,idempotencyKey:crypto.randomUUID()})})).ok){for(let a of d)delete aR.current[a];aM(a=>a.filter(a=>!d.includes(a)))}U(""),$([]),aa(""),Y(!1),a_()},br=z?(a=z.id,M.length>0?"messages":Q&&Q.conversationId===a&&"loading"!==Q.status?"error"===Q.status?"error":"empty":"loading"):"loading",bs=z?(0,b.jsx)(t,{view:br,agentName:z.details.name}):null,bt=(z?.details.title||"").trim(),bu=z?.details.color,bv=new Set,bw=a=>(0,b.jsx)("div",{className:"msg-status",children:(0,b.jsx)(A,{notice:a,onDone:()=>{a_()}})},a.eventId),bx=()=>{ae(!1),requestAnimationFrame(()=>af.current?.focus())};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"field",inert:ad,children:[(0,b.jsxs)("aside",{className:"rail",children:[(0,b.jsxs)("div",{className:"brand",children:[(0,b.jsx)("div",{className:aT?"logo-shape is-settling":"logo-shape",children:(0,b.jsx)(e.default,{src:"/brand/botmancers-logo-filled-256.png",alt:"",width:40,height:40})}),(0,b.jsx)("div",{className:"logo-word",children:"botmancers"})]}),(0,b.jsxs)("div",{className:"bar",children:[(0,b.jsx)("button",{ref:af,type:"button",className:"add-btn","aria-haspopup":"dialog",onClick:()=>ae(!0),children:"New"}),a7?null:(0,b.jsx)("button",{ref:az,type:"button",className:"add-btn","aria-haspopup":"dialog",onClick:()=>{aB(""),ay(!0)},children:"Manage agents"}),(0,b.jsx)(d.default,{href:"/settings",className:"add-btn settings-link",children:"Settings"})]}),(0,b.jsx)("p",{className:"roster-status",role:"status",children:aA}),a7?null:(0,b.jsx)("div",{className:at?"roster menu-open":"roster",children:a8.map(a=>B(a)?(0,b.jsxs)("div",{className:"card",onContextMenu:b=>bh(b,a),children:[(0,b.jsxs)("div",{className:"row-head",children:[(0,b.jsxs)("span",{className:"mark-avatar",children:[(0,b.jsx)(h.default,{bot:a,size:44,title:`${a.name} avatar`}),aL.includes(a.id)?(0,b.jsx)("span",{className:"mark-dot"}):null]}),ak===a.id?bi(a,{color:"#D5D0C3",fontSize:26}):bj(a,{fontSize:26}),bk(a)]}),y(a.latest)?(0,b.jsx)("div",{className:"bot-preview",children:y(a.latest)}):null,(0,b.jsx)(l.RosterRuntimeLine,{bot:a,state:aV}),bl(a)]},a.id):bm(a))}),a9.length>0?(0,b.jsxs)("div",{className:at?"roster menu-open":"roster",children:[(0,b.jsx)("button",{ref:aw,type:"button",className:"pin-word","aria-expanded":aC,onClick:()=>aD(a=>!a),children:"Hidden"}),aC?a9.map(bm):null]}):null]}),(0,b.jsx)("section",{className:"pane",children:z?(0,b.jsxs)("div",{className:"thread",children:[(0,b.jsxs)("div",{className:"thread-bar",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("button",{type:"button",className:"thread-name",style:bu?{color:bu}:void 0,onClick:()=>{ah(!0),aj(!1)},children:z.details.name}),bt?(0,b.jsx)("div",{className:"thread-role",children:bt}):null,(0,b.jsx)("div",{className:"thread-role",children:aL.includes(z.details.id)?"Working":"Not working"}),(0,b.jsx)("div",{className:"thread-role",children:D((aX??z.details).last_seen,aN.serverNow,aN.fetchedAt,aP)}),ag?(0,b.jsx)("button",{type:"button",className:"avatar-pic",onClick:()=>aj(!0),"aria-label":"Picture",children:z.details.avatar?(0,b.jsx)("img",{src:z.details.avatar,alt:""}):(0,b.jsx)(h.default,{bot:z.details,size:46})}):null]}),(0,b.jsxs)("div",{style:{marginLeft:"auto",display:"flex",gap:16,alignItems:"flex-start"},children:[(0,b.jsx)(d.default,{href:`/bots/${z.details.id}/config`,className:"attach-word",style:{textDecoration:"none"},children:"Config"}),(0,b.jsx)("button",{type:"button",className:"attach-word",title:"Stop delegated turns in this thread",onClick:()=>{a1()},children:"Stop"})]})]}),ai?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"avatar-step avatar-desk",children:[(0,b.jsx)("span",{className:"kind-word",children:"Agent"}),(0,b.jsx)("button",{type:"button",className:"kind-word",children:"Generate"}),(0,b.jsxs)("label",{className:"kind-word",children:["Upload",(0,b.jsx)("input",{ref:aE,type:"file",accept:"image/*,.svg"})]}),(0,b.jsx)("button",{type:"button",className:"create-btn",onClick:a4,children:"Set avatar"})]}),(0,b.jsxs)("div",{className:"avatar-step avatar-phone",children:[(0,b.jsx)("button",{type:"button",className:"kind-word",onClick:()=>aF.current?.click(),children:"Gallery"}),(0,b.jsx)("button",{type:"button",className:"kind-word",children:"Generate"}),(0,b.jsx)("button",{type:"button",className:"kind-word",onClick:a6,children:"Remove Photo"}),(0,b.jsx)("input",{ref:aF,type:"file",accept:"image/*,.svg",onChange:a=>{let b=a.target.files?.[0];a.target.value="",a5(b)}})]})]}):null,(0,b.jsxs)("div",{className:"messages-wrap",children:[(0,b.jsxs)("div",{className:"messages",children:[aY?null:bs,M.map(a=>{var d;let e,h,l=O.filter(b=>!bv.has(b.eventId)&&b.createdAt<a.created_at);l.forEach(a=>bv.add(a.eventId));let m="user"===a.sender_type,n=m?null:w(F(a.content));if(n)return(0,b.jsxs)(c.Fragment,{children:[l.map(bw),(0,b.jsx)("div",{className:"msg-status",children:(0,b.jsx)(x,{failure:n})})]},a.id);let o=(d=F(a.content),e=[],{text:E(d.replace(/data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=\s]+/g,a=>(e.push(a.replace(/\s/g,"")),""))),images:e}),p=o.images.map(a=>(0,b.jsx)("img",{src:a,alt:"",style:{display:"block",width:64,height:64}},a.slice(0,48))),q=m?void 0:z.details.color,r=m?null:f(a.content),s=m||r?null:i(F(a.content)),t=m||r?null:j(a.content),u=m||r?[]:function(a){let b=[];for(let c of a.split("\n")){let a=c.match(/^\s*\[file\]\s*(\S+)\s*$/i);a&&!b.includes(a[1])&&b.push(a[1])}return b}(a.content),v=m||r?null:(h=o.text.match(/^\s*\[Handing off to ([^\]]+)\]/))&&h[1].trim()||null,y=a.draftStatus??(s?"open":null),A=a.approvalStatus??(t?"pending":null);return(0,b.jsxs)(c.Fragment,{children:[l.map(bw),(0,b.jsxs)("div",{className:m?"msg-you":"msg-bot",ref:r&&"running"===r.state?aH:void 0,children:[(0,b.jsx)("div",{className:m?"msg-name msg-name-you":"msg-name",style:q?{color:q}:void 0,children:m?"You":a.sender_name||z.details.name}),r?(0,b.jsxs)("div",{className:"msg-body",children:[g(r),"running"===r.state?(0,b.jsxs)(b.Fragment,{children:[" ",(0,b.jsx)("button",{type:"button",className:"attach-word",style:{font:"inherit"},onClick:b=>{b.preventDefault(),b.stopPropagation(),a0(a.id)},children:"Stop"})]}):null]}):s&&y?(0,b.jsx)("div",{className:"msg-body",children:(0,b.jsx)(G,{message:a,conversationId:z.id,status:y,onDone:()=>{a_()}},a.id+y)}):(0,b.jsxs)("div",{className:"msg-body",onClick:v?()=>{a2(a,v)}:void 0,title:v?"Show the replies between this handoff and the reply":void 0,style:v?{cursor:"pointer"}:void 0,children:[function(a,c){let d=String(a??"").split("\n");if(!d.some(a=>null!==(0,k.deckEventDisplay)(a)))return a;let e=[];return d.forEach((a,d)=>{d>0&&e.push((0,b.jsx)("br",{},c+"-br-"+d));let f=(0,k.deckEventDisplay)(a);f?e.push((0,b.jsxs)("span",{className:"deck-event",children:[(0,b.jsx)("span",{className:"deck-event-label",children:f.label}),f.detail?" "+f.detail:""]},c+"-"+d)):e.push((0,b.jsx)("span",{children:a},c+"-"+d))}),e}(o.text,a.id),p,t&&A?(0,b.jsx)(H,{message:a,conversationId:z.id,status:A,onDone:()=>{a_()}},a.id+A):null,(0,b.jsx)(I,{names:u})]}),ao[a.id]?(0,b.jsx)("div",{className:"msg-body",children:ao[a.id].map(a=>(0,b.jsx)("div",{children:(a.sender_name||"Agent")+": "+E(a.content)},a.id))}):null]})]},a.id)}),O.filter(a=>!bv.has(a.eventId)).map(bw),(0,b.jsx)("div",{ref:aJ}),(0,b.jsx)("div",{ref:aG})]}),aY?(0,b.jsxs)("div",{className:"computer-float",children:[(0,b.jsxs)("div",{className:"computer-top",children:[(0,b.jsxs)("span",{className:"computer-lights","aria-hidden":"true",children:[(0,b.jsx)("span",{className:"computer-light computer-light-red"}),(0,b.jsx)("span",{className:"computer-light computer-light-yellow"}),(0,b.jsx)("span",{className:"computer-light computer-light-green"})]}),(0,b.jsxs)("span",{className:"computer-teach",children:[(0,b.jsxs)("span",{className:"computer-teach-pill",children:[(0,b.jsx)("span",{className:"computer-teach-mark","aria-hidden":"true"}),"Teach a task"]}),(0,b.jsx)("span",{className:"computer-expand","aria-hidden":"true",children:(0,b.jsx)("svg",{viewBox:"0 0 16 16",width:"14",height:"14",children:(0,b.jsx)("path",{d:"M9.2 2.6H13.4V6.8M6.8 13.4H2.6V9.2M13.1 2.9L9.4 6.6M2.9 13.1L6.6 9.4",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]}),(0,b.jsx)("div",{className:"messages"===br?"computer-band":"computer-band computer-band-note",ref:aI,children:bs}),(0,b.jsxs)("div",{className:"computer-desk",children:[aZ?(0,b.jsx)("iframe",{className:"computer-page",sandbox:"",srcDoc:aZ,tabIndex:-1}):null,(0,b.jsxs)("div",{className:"computer-dock",children:[(0,b.jsx)("img",{src:"/computer/dock-chrome.png",alt:""}),(0,b.jsx)("img",{src:"/computer/dock-gray.png",alt:""}),(0,b.jsx)("img",{src:"/computer/dock-terminal.png",alt:""})]})]})]}):null]}),(0,b.jsxs)("div",{className:"composer",onPaste:a=>{let b=[],c=a.clipboardData.files;if(c&&c.length>0)b.push(...Array.from(c));else for(let c of Array.from(a.clipboardData.items)){if("file"!==c.kind)continue;let a=c.getAsFile();a&&b.push(a)}0!==b.length&&(a.preventDefault(),bp(b))},children:[X&&bn.length>0?(0,b.jsx)("div",{className:"mention-list",children:bn.map(a=>(0,b.jsxs)("button",{type:"button",onMouseDown:b=>{b.preventDefault(),bo(a.name)},children:["@",a.name]},a.id))}):null,(0,b.jsxs)("div",{className:"composer-box",children:[_?(0,b.jsx)("p",{className:"attach-error",children:_}):null,Z.length>0?(0,b.jsx)("div",{className:"attach-names",children:Z.map(a=>(0,b.jsx)("span",{children:a.name},a.id))}):null,(0,b.jsx)("textarea",{ref:ab,rows:2,value:T,onChange:a=>{var b,c;let d,e;U(a.target.value),b=a.target.value,c=a.target.selectionStart,(e=(d=b.slice(0,c)).lastIndexOf("@"))<0||/\s/.test(d.slice(e+1))?Y(!1):(W(d.slice(e+1)),Y(!0))},onKeyDown:a=>{if("Enter"===a.key&&!a.shiftKey){if(a.preventDefault(),X&&bn.length>0)return void bo(bn[0].name);bq()}},placeholder:"Say something"})]}),(0,b.jsx)("input",{ref:ac,className:"attach-input",type:"file",multiple:!0,onChange:a=>{bp(Array.from(a.target.files||[])),a.target.value=""}}),(0,b.jsx)("button",{type:"button",className:"attach-word",onClick:()=>ac.current?.click(),children:"Attach"}),(0,b.jsx)("button",{type:"button",className:"send-btn",onClick:bq,children:"Send"})]})]}):a7?(0,b.jsxs)("div",{className:"welcome",children:[(0,b.jsx)(e.default,{className:"welcome-mark",src:"/brand/botmancers-logo-outline-256.png",alt:"Botmancers",width:144,height:144,priority:!0}),(0,b.jsx)("p",{className:"empty-line",children:"Pick someone to talk to."})]}):(0,b.jsx)("p",{className:"empty-line",children:"Pick someone to talk to."})}),ar?(0,b.jsx)(o.default,{ids:[ar.id],onCancel:()=>{bf(ar.id),as(null)},onDeleted:a=>{be(a)}}):null,ax?(0,b.jsx)(s,{deckState:aV,onClose:()=>{ay(!1),requestAnimationFrame(()=>az.current?.focus())},onDeleted:a=>{be(a)}}):null,at?(0,b.jsxs)("div",{ref:av,className:"row-menu",role:"menu","aria-label":`Actions for ${at.bot.name}`,style:{left:at.x,top:at.y},onPointerDown:a=>a.stopPropagation(),onClick:a=>a.stopPropagation(),onContextMenu:a=>a.preventDefault(),onKeyDown:a=>{let b=Array.from(a.currentTarget.querySelectorAll("[role=menuitem]")),c=b.indexOf(document.activeElement),d=c=>{a.preventDefault(),b[(c+b.length)%b.length]?.focus()};"ArrowDown"===a.key?d(c+1):"ArrowUp"===a.key?d(c-1):"Home"===a.key?d(0):"End"===a.key?d(b.length-1):"Tab"===a.key&&(a.preventDefault(),bg())},children:[(0,b.jsx)("button",{type:"button",role:"menuitem",tabIndex:-1,autoFocus:!0,onClick:a=>{a.stopPropagation(),bg(),ba(at.bot)},children:at.bot.pinned?"Unpin":"Pin"}),(0,b.jsx)("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:a=>{a.stopPropagation(),bg(),bc(at.bot)},children:"Mark as Unread"}),(0,b.jsx)("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:a=>{a.stopPropagation(),bg(!1),al(at.bot.id),an(at.bot.name)},children:"Rename Agent"}),(0,b.jsx)("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:a=>{a.stopPropagation(),bg(!1),bb(at.bot,!at.bot.hidden)},children:at.bot.hidden?"Unhide":"Hide from sidebar"}),(0,b.jsx)(d.default,{role:"menuitem",tabIndex:-1,href:`/bots/${at.bot.id}/config`,onClick:()=>au(null),children:"Config"}),(0,b.jsx)("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:a=>{a.stopPropagation(),bg(!1),as(at.bot)},children:"Delete agent…"})]}):null]}),ad&&(0,b.jsx)(J,{anchorRef:af,deckState:aV,onRetryDecks:aW,onClose:bx,onCreated:()=>{a$(),bx()}})]})}],60350)},67161,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"Image",{enumerable:!0,get:function(){return v}});let d=a.r(33354),e=a.r(46058),f=a.r(87924),g=e._(a.r(72131)),h=d._(a.r(35112)),i=d._(a.r(58018)),j=a.r(94915),k=a.r(345),l=a.r(4486),m=a.r(53773),n=d._(a.r(2305)),o=a.r(8591),p={deviceSizes:[640,750,828,1080,1200,1920,2048,3840],imageSizes:[32,48,64,96,128,256,384],qualities:[75],path:"/_next/image",loader:"default",dangerouslyAllowSVG:!1,unoptimized:!0};function q(a,b,c,d,e,f,g){let h=a?.src;a&&a["data-loaded-src"]!==h&&(a["data-loaded-src"]=h,("decode"in a?a.decode():Promise.resolve()).catch(()=>{}).then(()=>{if(a.parentElement&&a.isConnected){if("empty"!==b&&e(!0),c?.current){let b=new Event("load");Object.defineProperty(b,"target",{writable:!1,value:a});let d=!1,e=!1;c.current({...b,nativeEvent:b,currentTarget:a,target:a,isDefaultPrevented:()=>d,isPropagationStopped:()=>e,persist:()=>{},preventDefault:()=>{d=!0,b.preventDefault()},stopPropagation:()=>{e=!0,b.stopPropagation()}})}d?.current&&d.current(a)}}))}function r(a){return g.use?{fetchPriority:a}:{fetchpriority:a}}globalThis.__NEXT_IMAGE_IMPORTED=!0;let s=g.useEffect,t=(0,g.forwardRef)(({src:a,srcSet:b,sizes:c,height:d,width:e,decoding:h,className:i,style:j,fetchPriority:k,placeholder:l,loading:m,unoptimized:n,fill:p,onLoadRef:t,onLoadingCompleteRef:u,setBlurComplete:v,setShowAltText:w,sizesInput:x,onLoad:y,onError:z,...A},B)=>{let C=(0,g.useRef)(!1),D=(0,g.useRef)(null);s(()=>{let{current:a}=C,{current:b}=D;a||null===b||(z&&(b.src=b.src),b.complete&&q(b,l,t,u,v,n,x),C.current=!0)},[a,l,t,u,z,n,x]);let E=(0,o.useMergedRef)(B,D);return(0,f.jsx)("img",{...A,...r(k),loading:m,width:e,height:d,decoding:h,"data-nimg":p?"fill":"1",className:i,style:j,sizes:c,srcSet:b,src:a,ref:E,onLoad:a=>{q(a.currentTarget,l,t,u,v,n,x)},onError:a=>{w(!0),"empty"!==l&&v(!0),z&&z(a)}})});function u({isAppRouter:a,imgAttributes:b}){let c={as:"image",imageSrcSet:b.srcSet,imageSizes:b.sizes,crossOrigin:b.crossOrigin,referrerPolicy:b.referrerPolicy,...r(b.fetchPriority)};return a&&h.default.preload?(h.default.preload(b.src,c),null):(0,f.jsx)(i.default,{children:(0,f.jsx)("link",{rel:"preload",href:b.srcSet?void 0:b.src,...c},"__nimg-"+b.src+b.srcSet+b.sizes)})}let v=(0,g.forwardRef)((a,b)=>{let c=(0,g.useContext)(m.RouterContext),d=(0,g.useContext)(l.ImageConfigContext),e=(0,g.useMemo)(()=>{let a=p||d||k.imageConfigDefault,b=[...a.deviceSizes,...a.imageSizes].sort((a,b)=>a-b),c=a.deviceSizes.sort((a,b)=>a-b),e=a.qualities?.sort((a,b)=>a-b);return{...a,allSizes:b,deviceSizes:c,qualities:e,localPatterns:d?.localPatterns}},[d]),{onLoad:h,onLoadingComplete:i}=a,o=(0,g.useRef)(h);(0,g.useEffect)(()=>{o.current=h},[h]);let q=(0,g.useRef)(i);(0,g.useEffect)(()=>{q.current=i},[i]);let[r,s]=(0,g.useState)(!1),[v,w]=(0,g.useState)(!1),{props:x,meta:y}=(0,j.getImgProps)(a,{defaultLoader:n.default,imgConf:e,blurComplete:r,showAltText:v});return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(t,{...x,unoptimized:y.unoptimized,placeholder:y.placeholder,fill:y.fill,onLoadRef:o,onLoadingCompleteRef:q,setBlurComplete:s,setShowAltText:w,sizesInput:a.sizes,ref:b}),y.preload?(0,f.jsx)(u,{isAppRouter:!c,imgAttributes:x}):null]})});("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},33095,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={default:function(){return k},getImageProps:function(){return j}};for(var e in d)Object.defineProperty(c,e,{enumerable:!0,get:d[e]});let f=a.r(33354),g=a.r(94915),h=a.r(67161),i=f._(a.r(2305));function j(a){let{props:b}=(0,g.getImgProps)(a,{defaultLoader:i.default,imgConf:{deviceSizes:[640,750,828,1080,1200,1920,2048,3840],imageSizes:[32,48,64,96,128,256,384],qualities:[75],path:"/_next/image",loader:"default",dangerouslyAllowSVG:!1,unoptimized:!0}});for(let[a,c]of Object.entries(b))void 0===c&&delete b[a];return{props:b}}let k=h.Image},71987,(a,b,c)=>{b.exports=a.r(33095)},92966,(a,b,c)=>{"use strict";b.exports=a.r(42602).vendored.contexts.HeadManagerContext},58018,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={default:function(){return p},defaultHead:function(){return l}};for(var e in d)Object.defineProperty(c,e,{enumerable:!0,get:d[e]});let f=a.r(33354),g=a.r(46058),h=a.r(87924),i=g._(a.r(72131)),j=f._(a.r(94613)),k=a.r(92966);function l(){return[(0,h.jsx)("meta",{charSet:"utf-8"},"charset"),(0,h.jsx)("meta",{name:"viewport",content:"width=device-width"},"viewport")]}function m(a,b){return"string"==typeof b||"number"==typeof b?a:b.type===i.default.Fragment?a.concat(i.default.Children.toArray(b.props.children).reduce((a,b)=>"string"==typeof b||"number"==typeof b?a:a.concat(b),[])):a.concat(b)}let n=["name","httpEquiv","charSet","itemProp"];function o(a){let b,c,d,e;return a.reduce(m,[]).reverse().concat(l().reverse()).filter((b=new Set,c=new Set,d=new Set,e={},a=>{let f=!0,g=!1;if(a.key&&"number"!=typeof a.key&&a.key.indexOf("$")>0){g=!0;let c=a.key.slice(a.key.indexOf("$")+1);b.has(c)?f=!1:b.add(c)}switch(a.type){case"title":case"base":c.has(a.type)?f=!1:c.add(a.type);break;case"meta":for(let b=0,c=n.length;b<c;b++){let c=n[b];if(a.props.hasOwnProperty(c))if("charSet"===c)d.has(c)?f=!1:d.add(c);else{let b=a.props[c],d=e[c]||new Set;("name"!==c||!g)&&d.has(b)?f=!1:(d.add(b),e[c]=d)}}}return f})).reverse().map((a,b)=>{let c=a.key||b;return i.default.cloneElement(a,{key:c})})}let p=function({children:a}){let b=(0,i.useContext)(k.HeadManagerContext);return(0,h.jsx)(j.default,{reduceComponentsToState:o,headManager:b,children:a})};("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},4486,(a,b,c)=>{"use strict";b.exports=a.r(42602).vendored.contexts.ImageConfigContext},53773,(a,b,c)=>{"use strict";b.exports=a.r(42602).vendored.contexts.RouterContext},35444,(a,b,c)=>{"use strict";function d(a,b){let c=a||75;return b?.qualities?.length?b.qualities.reduce((a,b)=>Math.abs(b-c)<Math.abs(a-c)?b:a,b.qualities[0]):c}Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"findClosestQuality",{enumerable:!0,get:function(){return d}})},2305,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"default",{enumerable:!0,get:function(){return g}});let d=a.r(35444),e=a.r(68063);function f({config:a,src:b,width:c,quality:g}){let h=(0,e.getDeploymentId)();if(b.startsWith("/")&&!b.startsWith("//"))if(b.includes("/_next/static/immutable")&&!(0,e.getAssetToken)())h=void 0;else{let a=b.indexOf("?");if(-1!==a){let c=new URLSearchParams(b.slice(a+1)),d=c.get("dpl");if(d){h=d,c.delete("dpl");let e=c.toString();b=b.slice(0,a)+(e?"?"+e:"")}}}if(b.startsWith("/")&&b.includes("?")&&a.localPatterns?.length===1&&"**"===a.localPatterns[0].pathname&&""===a.localPatterns[0].search)throw Object.defineProperty(Error(`Image with src "${b}" is using a query string which is not configured in images.localPatterns.
1
+ module.exports=[60350,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(38246),e=a.i(71987);function f(a){let b,c=a.match(/^\s*\[run\]\s*([\s\S]*)$/);if(!c)return null;try{b=JSON.parse(c[1])}catch{return null}if(!b||"object"!=typeof b)return null;let d=b,e="string"==typeof d.page?d.page:"string"==typeof d.html?d.html:void 0,f=void 0===e?{}:{page:e,html:e};return"running"===d.state||"stopped"===d.state?{state:d.state,...f}:"done"===d.state&&"string"==typeof d.output?{state:"done",output:d.output,...f}:null}function g(a){return"done"===a.state?a.output??"":"stopped"===a.state?"The command was stopped.":"The command is running"}var h=a.i(36391);function i(a){let b,c=a.match(/^\s*\[draft\]\s*([\s\S]*)$/);if(!c)return null;try{b=JSON.parse(c[1])}catch{return null}if(!b||"object"!=typeof b)return null;let d=b;return"email"!==d.channel&&"slack"!==d.channel||"open"!==d.state&&"sent"!==d.state&&"discarded"!==d.state||"string"!=typeof d.recipient||"string"!=typeof d.body?null:{channel:d.channel,recipient:d.recipient,body:d.body,state:d.state}}function j(a){let b=a.match(/approve using the code ([A-Za-z0-9][A-Za-z0-9_-]*)/i);return b?b[1]:null}var k=a.i(20851),l=a.i(1160),m=a.i(39228),n=a.i(22855),o=a.i(2296),p=a.i(79202),q=a.i(80219),r=a.i(60193),s=a.i(35832);function t(a){return String(a).padStart(2,"0")}function u(a){let b=new Date(a);return`${b.getFullYear()}-${t(b.getMonth()+1)}-${t(b.getDate())} ${t(b.getHours())}:${t(b.getMinutes())}`}function v({deckState:a,onClose:d,onDeleted:e}){let f=(0,c.useId)(),[g,h]=(0,c.useState)(null),[i,j]=(0,c.useState)(""),[l,m]=(0,c.useState)(""),[n,o]=(0,c.useState)([]),[p,q]=(0,c.useState)(!1),t=(0,c.useRef)(null),w=(0,c.useRef)(null),x=(0,c.useRef)(null);(0,c.useEffect)(()=>{let a=!1;return fetch("/api/bots/manage",{cache:"no-store"}).then(async b=>{let c=await b.json().catch(()=>null);if(!a){if(!b.ok||!Array.isArray(c))return void j("string"==typeof c?.error?c.error:"Could not load agents.");h(c)}}).catch(()=>{a||j("Could not load agents.")}),t.current?.focus(),()=>{a=!0}},[]);let y=l.trim().toLowerCase(),z=(g??[]).filter(a=>a.name.toLowerCase().includes(y)),A=z.filter(a=>!a.blocked);return(0,c.useEffect)(()=>{if(p)return;let a=a=>{"Escape"===a.key&&d()};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[p,d]),(0,b.jsxs)("div",{className:"modal-scrim manage-scrim",children:[(0,b.jsxs)("div",{ref:x,className:"manage-card",role:"dialog","aria-modal":"true","aria-labelledby":f,onKeyDown:a=>{if("Tab"!==a.key||!x.current)return;let b=Array.from(x.current.querySelectorAll("button:not(:disabled), input:not(:disabled)"));if(0===b.length)return;let c=b[0],d=b[b.length-1];a.shiftKey&&document.activeElement===c?(a.preventDefault(),d.focus()):a.shiftKey||document.activeElement!==d||(a.preventDefault(),c.focus())},children:[(0,b.jsxs)("div",{className:"manage-head",children:[(0,b.jsx)("h2",{id:f,className:"delete-title",children:"Manage agents"}),(0,b.jsx)("button",{type:"button",className:"cancel-btn",onClick:d,children:"Close"})]}),(0,b.jsx)("label",{className:"manage-search-label",htmlFor:`${f}-search`,children:"Filter by name"}),(0,b.jsx)("input",{id:`${f}-search`,ref:t,className:"manage-search",type:"search",value:l,onChange:a=>m(a.target.value),placeholder:"Name contains…"}),(0,b.jsxs)("div",{className:"manage-tools",children:[(0,b.jsx)("button",{type:"button",className:"pin-word",onClick:()=>{o(a=>Array.from(new Set([...a,...A.map(a=>a.id)])))},disabled:0===A.length,children:"Select all shown"}),(0,b.jsx)("button",{type:"button",className:"pin-word",onClick:()=>{o([]),t.current?.focus()},disabled:0===n.length,children:"Clear selection"}),(0,b.jsxs)("span",{className:"manage-count","aria-live":"polite",children:[n.length," selected · ",z.length," shown of ",g?.length??0]})]}),i?(0,b.jsx)("p",{className:"delete-error",role:"alert",children:i}):null,g||i?null:(0,b.jsx)("p",{className:"delete-copy",children:"Loading agents…"}),g?(0,b.jsxs)("ul",{className:"manage-list","aria-label":"Agents",children:[0===z.length?(0,b.jsx)("li",{className:"delete-copy",children:"No agents match."}):null,z.map(c=>{let d=`${f}-row-${c.id}`,e=(0,k.isMigratedPending)(c)?"Not selected":(0,k.deckLabel)(c.deck_id??"",a);return(0,b.jsxs)("li",{className:c.blocked?"manage-row is-blocked":"manage-row","data-agent-id":c.id,children:[(0,b.jsx)("input",{id:d,type:"checkbox",checked:n.includes(c.id),disabled:!!c.blocked,onChange:()=>{var a;return a=c.id,void o(b=>b.includes(a)?b.filter(b=>b!==a):[...b,a])},"aria-describedby":c.blocked?`${d}-reason`:void 0}),(0,b.jsxs)("div",{className:"manage-copy",children:[(0,b.jsxs)("label",{htmlFor:d,className:"manage-name",children:[c.name,c.hidden?(0,b.jsx)("span",{className:"manage-tag",children:"Hidden"}):null]}),(0,b.jsxs)("dl",{className:"manage-meta",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("dt",{children:"Agent"}),(0,b.jsx)("dd",{children:(0,k.botAgentLabel)(c)})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("dt",{children:"Agent Deck"}),(0,b.jsx)("dd",{children:e})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("dt",{children:"Source"}),(0,b.jsx)("dd",{children:c.source_provider||"Created here"})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("dt",{children:"Created"}),(0,b.jsx)("dd",{children:u(c.created_at)})]}),c.last_activity?(0,b.jsxs)("div",{children:[(0,b.jsx)("dt",{children:"Last activity"}),(0,b.jsx)("dd",{children:u(c.last_activity)})]}):null]}),c.blocked?(0,b.jsx)("p",{id:`${d}-reason`,className:"manage-reason",children:(0,s.blockedReasonCopy)(c.blocked)}):null]})]},c.id)})]}):null,(0,b.jsxs)("div",{className:"form-actions manage-actions",children:[(0,b.jsx)("button",{type:"button",className:"cancel-btn",onClick:d,children:"Cancel"}),(0,b.jsxs)("button",{ref:w,type:"button",className:"delete-btn",disabled:0===n.length,onClick:()=>q(!0),children:["Delete selected",n.length>0?` (${n.length})`:""]})]})]}),p?(0,b.jsx)(r.default,{ids:n,onCancel:()=>{q(!1),requestAnimationFrame(()=>w.current?.focus())},onDeleted:e}):null]})}var w=a.i(65221);function x(a,b,c){if(0===a.length)return null;let d=a[0],e=a[a.length-1],f=null!==b&&a.includes(b);return c?f&&b!==d?null:e:f&&b!==e?null:d}let y='a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])';var z=a.i(35099);function A({mode:a,session:d,agents:e,origin:f,onClose:g,onStarted:h}){let i=(0,c.useId)(),j=(0,c.useId)(),k=(0,c.useId)(),l=(0,c.useId)(),[m,n]=(0,c.useState)(""),[o,p]=(0,c.useState)(""),[q,r]=(0,c.useState)(!1),[s,t]=(0,c.useState)({}),[u,v]=(0,c.useState)(""),[B,C]=(0,c.useState)(!1),D=(0,c.useRef)(!1),E=(0,c.useRef)(null),F=(0,c.useRef)(null),G=(0,c.useRef)(null),H=(0,c.useRef)(null),I=(0,c.useRef)(null),J=(0,z.sessionDialogUsesPin)(a,d.route),K=e.filter(a=>a.id!==d.agent.id);(0,c.useEffect)(()=>{("continue"===a?H.current:G.current)?.focus()},[a]),(0,c.useEffect)(()=>{let a=a=>{"Escape"===a.key&&(a.stopPropagation(),g())};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[g]);let L=async b=>{if(b.preventDefault(),D.current)return;let c={mode:"resume"===a?"ask":a,instruction:m,originConversationId:f.conversationId,destinationAgentId:o},e="resume"===a?(0,z.validateResumeDraft)(m,q):(0,z.validateDraft)(c);if(t(e),Object.keys(e).length>0)return void(e.destination?H.current?.focus():e.instruction?G.current?.focus():I.current?.focus());let g="resume"===a?"resume":"ask",i=a=>J?(0,z.pinRequestBody)(g,m,f.conversationId,q,a):(0,z.exchangeRequestBody)(c,{agentId:d.agent.id,sessionRef:d.ref},a),j=JSON.stringify(i(""));E.current&&E.current.payload===j||(E.current={payload:j,key:crypto.randomUUID()}),D.current=!0,C(!0),v("");try{let a=J?`/api/bots/${encodeURIComponent(d.agent.id)}/sessions/${encodeURIComponent(d.ref)}/pins`:"/api/exchanges",b=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i(E.current.key))}),c=await b.json().catch(()=>null);if(!b.ok){let a="string"==typeof c?.error?.code?c.error.code:null;"idempotency_conflict"===a&&(E.current=null),v((0,z.submitErrorMessage)(a,"string"==typeof c?.error?.message?c.error.message:null));return}let e=J?c?.turn?.exchange_id:c?.exchange?.id;h("string"==typeof e?e:null)}catch{v((0,z.submitErrorMessage)(null,"Botmancers could not be reached. Your draft is kept; try again."))}finally{D.current=!1,C(!1)}},M=K.find(a=>a.id===o)?.name,N="ask"===a,O="resume"===a;return(0,b.jsx)("div",{className:"modal-scrim exchange-scrim",onMouseDown:a=>{a.target===a.currentTarget&&g()},onKeyDown:a=>{if("Tab"!==a.key||!F.current)return;let b=x(Array.from(F.current.querySelectorAll(y)),document.activeElement,a.shiftKey);b&&(a.preventDefault(),b.focus())},children:(0,b.jsxs)("div",{ref:F,className:"form-card exchange-dialog",role:"dialog","aria-modal":"true","aria-labelledby":i,"data-exchange-mode":a,children:[(0,b.jsx)("h2",{id:i,className:"delete-title",children:(0,z.sessionDialogTitle)(a)}),(0,b.jsxs)("section",{className:"exchange-source","aria-label":"Source session",children:[(0,b.jsx)("p",{className:"exchange-source-agent",children:d.agent.name}),(0,b.jsx)("p",{className:"exchange-source-title",children:d.title}),(0,b.jsxs)("p",{className:"exchange-source-meta",children:["Last activity ",(0,w.formatSessionDate)(d.last_activity_at),d.origin.conversation?` \xb7 from ${d.origin.conversation.label}`:""]})]}),(0,b.jsxs)("form",{onSubmit:L,noValidate:!0,className:"exchange-form",children:[N||O?null:(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("label",{htmlFor:k,children:"Hand off to"}),(0,b.jsxs)("select",{ref:H,id:k,className:"exchange-select",value:o,"aria-invalid":!!s.destination||void 0,"aria-describedby":s.destination?`${k}-error`:void 0,disabled:B,onChange:a=>{p(a.target.value),t(a=>({...a,destination:void 0}))},children:[(0,b.jsx)("option",{value:"",children:"Choose an Agent"}),K.map(a=>(0,b.jsx)("option",{value:a.id,children:a.name},a.id))]}),s.destination?(0,b.jsx)("p",{id:`${k}-error`,className:"exchange-field-error",children:s.destination}):null]}),(0,b.jsx)("label",{htmlFor:j,children:N?"Question":O?"Instruction":"Objective"}),(0,b.jsx)("textarea",{ref:G,id:j,rows:4,maxLength:z.INSTRUCTION_LIMIT,value:m,readOnly:B,"aria-invalid":!!s.instruction||void 0,"aria-describedby":`${j}-hint${s.instruction?` ${j}-error`:""}`,onChange:a=>{n(a.target.value),t(a=>({...a,instruction:void 0}))}}),s.instruction?(0,b.jsx)("p",{id:`${j}-error`,className:"exchange-field-error",children:s.instruction}):null,(0,b.jsx)("p",{id:`${j}-hint`,className:"exchange-hint",children:N?`${d.agent.name} answers from this exact session, read-only. The answer arrives in ${f.label}.`:O?`${d.agent.name} resumes work in this exact session and may edit its workspace. The turn never moves to another session. Progress shows in ${f.label}.`:`${M??"The Agent you choose"} receives an extracted handoff (objective, decisions, constraints, references, open questions) and starts a new session of its own. ${d.agent.name}’s session is not shared and is not changed. Progress shows in ${f.label}.`}),O?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("label",{className:"exchange-approval",htmlFor:l,children:[(0,b.jsx)("input",{ref:I,id:l,type:"checkbox",checked:q,disabled:B,"aria-invalid":!!s.approval||void 0,"aria-describedby":s.approval?`${l}-error`:void 0,onChange:a=>{r(a.target.checked),t(a=>({...a,approval:void 0}))}})," ","I approve edits by ",d.agent.name," in this session"]}),s.approval?(0,b.jsx)("p",{id:`${l}-error`,className:"exchange-field-error",children:s.approval}):null]}):null,u?(0,b.jsx)("p",{className:"exchange-server-error",role:"alert",children:u}):null,(0,b.jsx)("p",{className:"exchange-sending",role:"status",children:B?"Sending…":""}),(0,b.jsxs)("div",{className:"form-actions",children:[(0,b.jsx)("button",{type:"button",className:"cancel-btn",onClick:g,children:"Cancel"}),(0,b.jsx)("button",{type:"submit",className:"create-btn",disabled:B,"aria-disabled":B,children:u?"Try again":"Send"})]})]})]})})}function B({agentId:a,agentName:e,agents:f,origin:g,onClose:h,onOpenThread:i,onExchangeStarted:j}){let k=(0,c.useId)(),[l,m]=(0,c.useState)("all"),[n,o]=(0,c.useState)(null),[p,q]=(0,c.useState)(""),[r,s]=(0,c.useState)(0),[t,u]=(0,c.useState)(null),v=(0,c.useRef)(null),x=(0,c.useRef)(null),[y,D]=(0,c.useState)(null),[E,F]=(0,c.useState)(null),G=(0,c.useRef)(null),H=()=>{G.current=y?.returnTo??null,D(null)};(0,c.useEffect)(()=>{if(y||!G.current)return;let a=G.current;G.current=null,a.isConnected&&a.focus()},[y]),(0,c.useEffect)(()=>{x.current?.focus()},[]),(0,c.useEffect)(()=>{let b=!1;return fetch(`/api/bots/${encodeURIComponent(a)}/sessions?status=${l}`,{cache:"no-store"}).then(async a=>{let c=await a.json().catch(()=>null);if(!b){if(!a.ok||!Array.isArray(c?.sessions))return void q("string"==typeof c?.error?c.error:"Could not load sessions.");o(c.sessions)}}).catch(()=>{b||q("Could not load sessions.")}),()=>{b=!0}},[a,l,r]);let I=(a=l)=>{o(null),q(""),m(a),s(a=>a+1)};return(0,c.useEffect)(()=>{let a=a=>{"Escape"===a.key&&h()};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[h]),(0,b.jsxs)("div",{className:"modal-scrim sessions-scrim",onMouseDown:a=>{a.target!==a.currentTarget||y||h()},children:[(0,b.jsxs)("div",{ref:v,className:"sessions-drawer",role:"dialog","aria-modal":"true","aria-labelledby":k,onKeyDown:a=>{if("Tab"!==a.key||!v.current)return;let b=Array.from(v.current.querySelectorAll("button:not(:disabled), summary"));if(0===b.length)return;let c=b[0],d=b[b.length-1];a.shiftKey&&document.activeElement===c?(a.preventDefault(),d.focus()):a.shiftKey||document.activeElement!==d||(a.preventDefault(),c.focus())},inert:!!y,children:[(0,b.jsxs)("div",{className:"manage-head",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("h2",{id:k,className:"delete-title sessions-title",children:"Sessions"}),(0,b.jsx)("p",{className:"sessions-sub",children:e})]}),(0,b.jsx)("button",{ref:x,type:"button",className:"cancel-btn",onClick:h,children:"Close"})]}),(0,b.jsxs)("div",{className:"sessions-filter",role:"group","aria-label":"Show sessions",children:[w.SESSION_FILTER_OPTIONS.map(a=>(0,b.jsx)("button",{type:"button",className:"sessions-filter-btn","aria-pressed":l===a.value,onClick:()=>{l!==a.value&&I(a.value)},children:a.label},a.value)),(0,b.jsx)("span",{className:"manage-count","aria-live":"polite",children:n?`${n.length} shown`:""})]}),(0,b.jsx)("div",{className:"exchange-started",role:"status",children:E?(0,b.jsxs)(b.Fragment,{children:[E.text," ",E.id?(0,b.jsx)(d.default,{className:"session-link",href:(0,z.detailsHref)(E.id),children:"View in Exchanges"}):null]}):null}),p?(0,b.jsxs)("div",{className:"sessions-state",role:"alert",children:[(0,b.jsx)("p",{className:"delete-error",children:p}),(0,b.jsx)("button",{type:"button",className:"pin-word",onClick:()=>I(),children:"Retry"})]}):null,n||p?null:(0,b.jsx)("p",{className:"delete-copy sessions-state",role:"status",children:"Loading sessions…"}),n?(0,b.jsxs)("ul",{className:"manage-list sessions-list","aria-label":`Sessions for ${e}`,children:[0===n.length?(0,b.jsx)("li",{className:"delete-copy sessions-state",children:(0,w.emptySessionsCopy)(l,e)}):null,n.map(c=>(0,b.jsx)(C,{agentId:a,row:c,open:t===c.ref,onToggle:()=>u(a=>a===c.ref?null:c.ref),onOpenThread:i,onAction:(a,b)=>{F(null),D({mode:a,row:c,returnTo:b})}},c.ref))]}):null]}),y?(0,b.jsx)(A,{mode:y.mode,session:y.row,agents:f,origin:g,onClose:H,onStarted:a=>{F({id:a,text:"ask"===y.mode?`Asked ${y.row.agent.name}’s session. The answer arrives in ${g.label}.`:"resume"===y.mode?`Resumed work in ${y.row.agent.name}’s session. Progress shows in ${g.label}.`:`Handoff started from ${y.row.agent.name}’s session. Progress shows in ${g.label}.`}),H(),j(a)}}):null]})}function C({agentId:a,row:d,open:e,onToggle:f,onOpenThread:g,onAction:h}){let i=(0,c.useId)(),j=(0,z.sessionRowActions)(d),k=j.filter(a=>a.availability.available),l=j.flatMap(a=>a.availability.available?[]:[a.availability.reason]),m=d.origin.conversation,n=(0,w.workRequestLabel)(d),o=(0,w.sessionUsageLine)(d.usage);return(0,b.jsx)("li",{className:`manage-row session-row is-${d.status}`,"data-session-ref":d.ref,children:(0,b.jsxs)("div",{className:"manage-copy",children:[(0,b.jsxs)("div",{className:"session-head",children:[(0,b.jsx)("span",{className:"session-title",children:d.title}),(0,b.jsx)("span",{className:`manage-tag session-status is-${d.status}`,children:(0,w.statusLabel)(d)}),(0,w.sessionStateTags)(d).map(a=>(0,b.jsx)("span",{className:`manage-tag session-state-tag is-${a.toLowerCase()}`,children:a},a))]}),(0,b.jsxs)("dl",{className:"manage-meta",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("dt",{children:"Last activity"}),(0,b.jsx)("dd",{children:(0,w.formatSessionDate)(d.last_activity_at)})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("dt",{children:"Started"}),(0,b.jsx)("dd",{children:(0,w.formatSessionDate)(d.created_at)})]}),null!==d.ended_at?(0,b.jsxs)("div",{children:[(0,b.jsx)("dt",{children:"Ended"}),(0,b.jsx)("dd",{children:(0,w.formatSessionDate)(d.ended_at)})]}):null,(0,b.jsxs)("div",{children:[(0,b.jsx)("dt",{children:"Runtime"}),(0,b.jsx)("dd",{children:(0,w.runtimeLabel)(d)})]}),(0,b.jsxs)("div",{className:"session-usage-meta",children:[(0,b.jsx)("dt",{children:"Reported usage"}),(0,b.jsxs)("dd",{children:[(0,b.jsx)("span",{className:`session-usage is-${o.quality}`,"aria-hidden":"true",children:o.text}),(0,b.jsx)("span",{className:"session-sr",children:o.label}),o.partial?(0,b.jsx)("span",{className:"manage-tag session-usage-tag",children:"Partial"}):null]})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("dt",{children:"Origin"}),(0,b.jsx)("dd",{children:m?.thread_agent_id?(0,b.jsx)("button",{type:"button",className:"session-link",onClick:()=>g(m.thread_agent_id),children:m.label}):m?.label??"Not recorded"})]}),n?(0,b.jsxs)("div",{children:[(0,b.jsx)("dt",{children:"Work request"}),(0,b.jsx)("dd",{children:n})]}):null,d.context.workspace?(0,b.jsxs)("div",{children:[(0,b.jsx)("dt",{children:"Workspace"}),(0,b.jsx)("dd",{children:d.context.workspace})]}):null,d.context.deck?(0,b.jsxs)("div",{children:[(0,b.jsx)("dt",{children:"Deck"}),(0,b.jsx)("dd",{children:d.context.deck})]}):null]}),k.length>0?(0,b.jsx)("div",{className:"session-actions",role:"group","aria-label":`Actions for ${d.title}`,children:k.map(a=>(0,b.jsx)("button",{type:"button",className:"session-action","data-session-action":a.action,"aria-haspopup":"dialog",onClick:b=>h((0,z.sessionDialogMode)(a.action),b.currentTarget),children:a.label},a.action))}):null,l.length>0?(0,b.jsx)("ul",{className:"session-unavailable","aria-label":`Unavailable actions for ${d.title}`,children:l.map(a=>(0,b.jsx)("li",{children:a},a))}):null,(0,b.jsx)("button",{type:"button",className:"pin-word session-toggle","aria-expanded":e,"aria-controls":i,onClick:f,children:e?"Hide details":"Details"}),e?(0,b.jsx)(D,{id:i,agentId:a,sessionRef:d.ref}):null]})})}function D({id:a,agentId:d,sessionRef:e}){let[f,g]=(0,c.useState)(null),[h,i]=(0,c.useState)(null),[j,k]=(0,c.useState)(""),[l,m]=(0,c.useState)(null),[n,o]=(0,c.useState)(""),[p,q]=(0,c.useState)(!1),r=`/api/bots/${encodeURIComponent(d)}/sessions/${encodeURIComponent(e)}`;(0,c.useEffect)(()=>{let a=!1;return fetch(r,{cache:"no-store"}).then(async b=>{let c=await b.json().catch(()=>null);a||(b.ok&&Array.isArray(c?.session?.attempts)?(g(c.session.attempts),i({totals:c.session.usage,samples:Array.isArray(c.session.usage_samples)?c.session.usage_samples:[]})):k("Could not load session details."))}).catch(()=>{a||k("Could not load session details.")}),()=>{a=!0}},[r]);let s=(0,c.useCallback)(async()=>{if(null===l)try{let a=await fetch(`${r}?debug=external_session_id`,{cache:"no-store"}),b=await a.json().catch(()=>null),c=b?.debug?.external_session_id;a.ok&&"string"==typeof c?m(c):o("Not available.")}catch{o("Not available.")}},[r,l]),t=async()=>{if(l)try{await navigator.clipboard.writeText(l),q(!0)}catch{q(!1)}};return(0,b.jsxs)("div",{id:a,className:"session-detail",children:[j?(0,b.jsx)("p",{className:"delete-error",role:"alert",children:j}):null,f||j?null:(0,b.jsx)("p",{className:"delete-copy",role:"status",children:"Loading details…"}),f?(0,b.jsxs)("ol",{className:"session-attempts","aria-label":"Runs in this session",children:[0===f.length?(0,b.jsx)("li",{children:"No recorded runs."}):null,f.map(a=>(0,b.jsxs)("li",{children:[(0,w.formatSessionDate)(a.started_at)," · ",(0,w.attemptLabel)(a)]},`${a.request_id}-${a.attempt_number}`))]}):null,h?(0,b.jsx)(F,{totals:h.totals,samples:h.samples}):null,(0,b.jsxs)("details",{className:"session-debug",onToggle:a=>{a.currentTarget.open&&s()},children:[(0,b.jsx)("summary",{children:"Local debug: provider session ID"}),(0,b.jsx)("p",{className:"session-debug-note",children:"For local troubleshooting only. Botmancers resumes sessions for you; you never need to copy this."}),n?(0,b.jsx)("p",{className:"delete-error",children:n}):null,l?(0,b.jsxs)("div",{className:"session-debug-value",children:[(0,b.jsx)("code",{children:l}),(0,b.jsx)("button",{type:"button",className:"pin-word",onClick:()=>{t()},children:p?"Copied":"Copy"})]}):null]})]})}let E=["input_tokens","output_tokens","cost_usd"];function F({totals:a,samples:d}){let e=(0,c.useId)();return(0,b.jsxs)("section",{className:"session-usage-detail","aria-labelledby":e,children:[(0,b.jsx)("h3",{id:e,className:"session-usage-head",children:"Reported usage"}),(0,b.jsx)("dl",{className:"session-usage-totals",children:E.map(c=>{let d=(0,w.usageMetricView)(c,a?.[c],!0);return(0,b.jsxs)("div",{children:[(0,b.jsx)("dt",{children:d.name}),(0,b.jsxs)("dd",{children:[(0,b.jsx)("span",{className:`session-usage is-${d.quality}`,"aria-hidden":"true",children:d.text}),(0,b.jsxs)("span",{className:"session-sr",children:[d.label,"."]}),(0,b.jsx)("span",{className:`session-usage-coverage is-${d.quality}`,children:d.coverage})]})]},c)})}),0===d.length?(0,b.jsx)("p",{className:"session-usage-none",children:"No run in this session reported usage."}):(0,b.jsx)("ol",{className:"session-usage-runs","aria-label":"Reported usage by run",children:d.map((a,c)=>{let d=(0,w.usageSampleValues)(a);return(0,b.jsxs)("li",{children:[(0,b.jsxs)("span",{className:"session-usage-run",children:[(0,w.formatSessionDate)(a.observed_at)," · ",(0,w.usageSampleLabel)(a,c)]}),(0,b.jsxs)("span",{className:"session-usage-values",children:[(0,b.jsxs)("span",{className:null===a.input_tokens?"is-unavailable":void 0,children:["In ",d.input]}),(0,b.jsxs)("span",{className:null===a.output_tokens?"is-unavailable":void 0,children:["Out ",d.output]}),(0,b.jsxs)("span",{className:null===a.cost_usd?"is-unavailable":void 0,children:["Cost ",d.cost]})]})]},`${a.observed_at}-${c}`)})})]})}function G({view:a,agentName:c}){if("loading"===a)return(0,b.jsx)("p",{className:"thread-note",role:"status",children:"Loading messages…"});if("error"===a)return(0,b.jsx)("p",{className:"thread-note thread-note-error",role:"alert",children:"Couldn’t load messages. Trying again…"});if("empty"===a){let a={title:`No messages with ${c} yet.`,hint:"Say something below to start the conversation."};return(0,b.jsxs)("div",{className:"thread-empty","data-thread-empty":"",children:[(0,b.jsx)("p",{className:"thread-empty-title",children:a.title}),(0,b.jsx)("p",{className:"thread-empty-hint",children:a.hint})]})}return null}let H={error:"Error"},I=[{kind:"hermes-config-missing",severity:"error",pattern:/^\[Hermes configuration missing: [^\n]*\]$/,title:"Hermes needs configuration",recovery:"This agent can’t reply until the Hermes API key is set on the Botmancers server. Set it, restart, then send your message again."},{kind:"hermes-turn-failed",severity:"error",pattern:/^\[Hermes turn failed for [\s\S]*\]$/,title:"Hermes couldn’t complete the turn",recovery:"Check that the Hermes gateway is running and reachable, then send your message again."}];function J(a){let b=String(a??"").trim();if(!b)return null;let c=I.find(a=>a.pattern.test(b));return c?{kind:c.kind,severity:c.severity,title:c.title,recovery:c.recovery,detail:b}:null}function K({failure:a}){let[d,e]=(0,c.useState)("idle"),f=H[a.severity],g=(0,c.useId)();async function h(){try{await navigator.clipboard.writeText(a.detail),e("copied")}catch{e("failed")}}return(0,b.jsxs)("div",{className:`runtime-failure runtime-failure-${a.severity}`,role:"status","aria-labelledby":g,"data-runtime-failure":a.kind,children:[(0,b.jsxs)("p",{className:"runtime-failure-title",id:g,children:[(0,b.jsx)("span",{className:"runtime-failure-severity",children:f}),a.title]}),(0,b.jsx)("p",{className:"runtime-failure-recovery",children:a.recovery}),(0,b.jsxs)("details",{className:"runtime-failure-details",children:[(0,b.jsx)("summary",{children:"Details"}),(0,b.jsx)("code",{className:"runtime-failure-detail",children:a.detail}),(0,b.jsx)("button",{type:"button",className:"runtime-failure-copy",onClick:()=>{h()},children:"copied"===d?"Copied":"failed"===d?"Copy failed":"Copy details"})]})]})}function L(a){if(!a)return"";let b=f(a);if(b)return g(b);let c=J(a);if(c)return c.title;let d=(0,k.deckEventDisplay)(a);return d?`${d.label} ${d.detail}`.replace(/\s+/g," ").trim():a.replace(/\s+/g," ").trim()}let M={blocked:"Needs approval",rejected:"Not started",allowed:"Allowed",denied:"Denied",waiting:"Queued",stopped:"Stopped"};function N({notice:a,onDone:d}){let[e,f]=(0,c.useState)(!1),[g,h]=(0,c.useState)(""),i="blocked"!==a.tone||a.actionable?M[a.tone]:"Blocked",j=async b=>{if(!e&&a.wakeId){f(!0),h("");try{let c=await fetch(`/api/wakes/${a.wakeId}/decision`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({decision:b})});if(!c.ok){let a=await c.json().catch(()=>null);h("string"==typeof a?.error?.message?a.error.message:"The decision could not be recorded.")}}catch{h("The decision could not be recorded.")}finally{f(!1),d()}}};return(0,b.jsxs)("div",{className:`wake-notice wake-notice-${a.tone}`,role:"status","data-wake-notice":a.tone,"data-wake-id":a.wakeId??void 0,children:[(0,b.jsxs)("p",{className:"wake-notice-line",children:[(0,b.jsx)("span",{className:"wake-notice-label",children:i}),a.text]}),a.actionable?(0,b.jsxs)("div",{className:"wake-notice-actions",children:[(0,b.jsx)("button",{type:"button",className:"approve-control",disabled:e,onClick:()=>{j("allow")},children:"Allow"}),(0,b.jsx)("button",{type:"button",className:"approve-control",style:{marginLeft:8},disabled:e,onClick:()=>{j("deny")},children:"Deny"})]}):null,g?(0,b.jsx)("p",{className:"wake-notice-error",role:"alert",children:g}):null]})}var O=a.i(27828);function P(a){return!!a&&"chief-of-staff"===a.name.toLowerCase()}function Q(a){return P(a)?0:a.pinned?1:2}function R(a,b,c,d){return a&&b?d-c+(b-a)>15e3?"Stopped":"Heartbeat "+new Intl.DateTimeFormat("en-US",{timeZone:"America/Los_Angeles",hour:"numeric",minute:"2-digit",second:"2-digit"}).format(new Date(a)):"Stopped"}function S(a){let b=a;for(let a=0;a<2;a++){let a=b.replace(/^\s*\[Message from [^\]]+\]\s*(?:\r?\n)?/,"");if(a===b)break;b=a}return b.replace(/^\s+/,"")}function T(a){let b=a;for(let a=0;a<4;a++){let a=b.replace(/^\s*\[(?:Message from|From) [^\]]+\]\s*(?:\r?\n)?/,"");if(a===b)break;b=a}return b}function U({message:a,conversationId:d,status:e,onDone:f}){let g=i(T(a.content)),[h,j]=(0,c.useState)(g?.recipient??""),[k,l]=(0,c.useState)(g?.body??""),[m,n]=(0,c.useState)(!1),[o,p]=(0,c.useState)("open"!==e),q=(0,c.useRef)("open"!==e);if(!g)return null;let r="open"!==e||o,s=r?g.recipient:h,t=r?g.body:k,u=async b=>{if(!r&&!q.current&&!m&&("send"!==b||""!==h.trim())){q.current=!0,p(!0),n(!0);try{(await fetch(`/api/conversations/${d}/draft`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messageId:a.id,action:b,recipient:h,body:k})})).ok||(q.current=!1,p(!1))}finally{n(!1),f()}}};return(0,b.jsxs)("div",{className:"draft-card",children:[(0,b.jsx)("div",{className:"draft-title",children:"email"===g.channel?"New Email":"New Slack Message"}),(0,b.jsx)("input",{type:"text","aria-label":"Recipient",value:s,readOnly:r,disabled:m,onChange:a=>{r||j(a.target.value)}}),(0,b.jsx)("textarea",{rows:3,"aria-label":"Draft body",value:t,readOnly:r,disabled:m,onChange:a=>{r||l(a.target.value)}}),"sent"===e?(0,b.jsx)("span",{className:"draft-mark",children:"Sent"}):null,"discarded"===e?(0,b.jsx)("span",{className:"draft-mark",children:"Discarded"}):null,"discarded"!==e?(0,b.jsx)("button",{type:"button",className:"approve-control",disabled:m,onClick:()=>{u("send")},children:"Send"}):null,"open"===e?(0,b.jsx)("button",{type:"button",className:"approve-control",style:{marginLeft:8},disabled:m,onClick:()=>{u("discard")},children:"Discard"}):null]})}function V({message:a,conversationId:d,status:e,onDone:f}){let g=j(a.content),[h,i]=(0,c.useState)(!1),k=(0,c.useRef)("pending"!==e);if(!g)return null;let l=async b=>{if(!k.current&&!h){k.current=!0,i(!0);try{(await fetch(`/api/conversations/${d}/${b}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:g,messageId:a.id})})).ok||(k.current=!1)}finally{i(!1),f()}}};return"pending"!==e?(0,b.jsx)("span",{className:"draft-mark",children:"approved"===e?"Approved":"Denied"}):(0,b.jsxs)("span",{className:"draft-mark",children:[(0,b.jsx)("button",{type:"button",className:"approve-control",disabled:h,onClick:()=>{l("approve")},children:"Approve"}),(0,b.jsx)("button",{type:"button",className:"approve-control",style:{marginLeft:8},disabled:h,onClick:()=>{l("deny")},children:"Deny"})]})}function W({names:a}){return 0===a.length?null:(0,b.jsx)(b.Fragment,{children:a.map(a=>(0,b.jsxs)("span",{children:[(0,b.jsx)("br",{}),(0,b.jsxs)("a",{className:"file-control",href:`/api/files/${encodeURIComponent(a)}`,download:a,children:["Download ",a]})]},a))})}function X({anchorRef:a,deckState:d,onRetryDecks:e,onClose:f,onCreated:g}){let[h,i]=(0,c.useState)(""),[j,m]=(0,c.useState)(l.DEFAULT_REGISTRATION_FORM),[o,q]=(0,c.useState)(""),[r,s]=(0,c.useState)(!1),[t,u]=(0,c.useState)(!1),v=(0,p.useRuntimeConnections)(),[w,z]=(0,c.useState)(null),A=(0,c.useRef)(null),B=(0,c.useRef)(null);(0,c.useLayoutEffect)(()=>{let b=()=>{let b=a.current?.getBoundingClientRect();z(function(a,b){let c=Math.min(358,b.width-32),d=Math.max(16,b.width-16-c),e=16,f=16;if(a){f=Math.min(Math.max(a.left,16),d);let c=a.bottom+8;b.height-c-16>=360&&(e=c)}return{top:e,left:f,maxHeight:Math.max(0,b.height-e-16)}}(b?{left:b.left,bottom:b.bottom}:null,{width:window.innerWidth,height:window.innerHeight}))};return b(),window.addEventListener("resize",b),()=>window.removeEventListener("resize",b)},[a]),(0,c.useEffect)(()=>{B.current?.focus()},[]),(0,c.useEffect)(()=>{let a=a=>{"Escape"===a.key&&(a.stopPropagation(),f())};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[f]);let C=(0,l.registrationFormView)(j,d,v.state),D=async a=>{if(a.preventDefault(),C.submitDisabled||t)return;if((0,l.hasRegistrationErrors)(C)){s(!0),q("Fix the highlighted fields.");return}q(""),u(!0);let b=await fetch("/api/bots",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify((0,l.registrationCreateBody)(h,j))}).finally(()=>u(!1));if(!b.ok){let a=await b.json().catch(()=>null);q("string"==typeof a?.error&&a.error?a.error:"Failed to create agent");return}g()};return(0,b.jsx)("div",{className:"modal-scrim new-agent-scrim",onKeyDown:a=>{if("Tab"!==a.key||!A.current)return;let b=x(Array.from(A.current.querySelectorAll(y)),document.activeElement,a.shiftKey);b&&(a.preventDefault(),b.focus())},children:(0,b.jsxs)("div",{ref:A,className:"form-card new-agent-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"new-agent-title",style:w??void 0,children:[(0,b.jsx)("div",{className:"kind-row",children:(0,b.jsx)("h2",{id:"new-agent-title",className:"kind-word new-agent-title",children:"New Agent"})}),(0,b.jsxs)("form",{onSubmit:D,className:"bot-form",children:[(0,b.jsxs)("div",{className:"new-agent-body",children:[(0,b.jsx)("label",{htmlFor:"bot-name",children:"Name"}),(0,b.jsx)("input",{ref:B,id:"bot-name",type:"text",value:h,onChange:a=>i(a.target.value),required:!0}),(0,b.jsx)(n.RegistrationFields,{idPrefix:"bot",variant:"modal",form:j,onChange:a=>{q(""),"agent_deck"===a.launchProfile&&"agent_deck"!==j.launchProfile&&e(),m(b=>({...b,...a}))},view:C,showErrors:r,connections:v.state,onRetryConnections:v.retry,onAddConnection:v.add,deckState:d,onRetryDecks:e,workdirPlaceholder:"",workdirHint:k.NEW_BOT_WORKDIR_HINT}),o?(0,b.jsx)("p",{className:"form-error",role:"alert",children:o}):null]}),(0,b.jsxs)("div",{className:"form-actions",children:[(0,b.jsx)("button",{type:"button",className:"cancel-btn",onClick:f,children:"Cancel"}),(0,b.jsx)("button",{type:"submit",className:"create-btn",disabled:C.submitDisabled||t,children:t?"Creating…":"Create"})]})]})]})})}a.s(["default",0,function(){var a;let[l,n]=(0,c.useState)([]),[p,t]=(0,c.useState)(!1),[u,w]=(0,c.useState)(null),x=(0,c.useRef)(!1),y=(0,c.useRef)(null),[z,A]=(0,c.useState)([]),[C,D]=(0,c.useState)([]),[E,F]=(0,c.useState)([]),H=(0,c.useRef)(null),[I,M]=(0,c.useState)(null),Y=(0,c.useRef)(null),[Z,$]=(0,c.useState)(""),[_,aa]=(0,c.useState)(""),[ab,ac]=(0,c.useState)(!1),[ad,ae]=(0,c.useState)([]),[af,ag]=(0,c.useState)(""),ah=(0,c.useRef)(null),ai=(0,c.useRef)(null),[aj,ak]=(0,c.useState)(!1),al=(0,c.useRef)(null),[am,an]=(0,c.useState)(!1),[ao,ap]=(0,c.useState)(!1),[aq,ar]=(0,c.useState)(null),[as,at]=(0,c.useState)(""),[au,av]=(0,c.useState)({}),aw=(0,c.useRef)({}),[ax,ay]=(0,c.useState)(null),[az,aA]=(0,c.useState)(null),aB=(0,c.useRef)(null),aC=(0,c.useRef)(null),[aD,aE]=(0,c.useState)(!1),aF=(0,c.useRef)(null),[aG,aH]=(0,c.useState)(!1),aI=(0,c.useRef)(null),[aJ,aK]=(0,c.useState)(""),[aL,aM]=(0,c.useState)(!1),aN=(0,c.useRef)(null),aO=(0,c.useRef)(null),aP=(0,c.useRef)(null),aQ=(0,c.useRef)(null),aR=(0,c.useRef)(null),aS=(0,c.useRef)(null),aT=(0,c.useRef)(null),[aU,aV]=(0,c.useState)([]),[aW,aX]=(0,c.useState)({serverNow:0,fetchedAt:0}),[aY,aZ]=(0,c.useState)(()=>Date.now()),a$=(0,c.useRef)({}),a_=(0,c.useRef)(!1),[a0,a1]=(0,c.useState)(!1),[a2,a3]=(0,c.useState)(!1),a4=a2||l.some(a=>"agent_deck"===a.launch_profile),{state:a5,retry:a6}=(0,o.useDeckList)(a4);(0,c.useEffect)(()=>{a_.current||0===l.length||(a_.current=!0,a1(!0))},[l.length]),(0,c.useEffect)(()=>{let a=(0,q.importedBotId)(window.location.search);if(a)return void window.location.replace((0,q.importedConfigPath)(a));let b=new URLSearchParams(window.location.search),c=Number(b.get("deleted"));c>0&&window.history.replaceState(null,"","/");let d=b.get("agent");d&&(y.current=d,H.current=b.get("exchange"),window.history.replaceState(null,"","/")),ba().then(()=>{c>0&&aK((0,s.deletedStatusLine)(c))});let e=setInterval(ba,2e3),f=setInterval(()=>aZ(Date.now()),1e3);return()=>{clearInterval(e),clearInterval(f)}},[]),(0,c.useEffect)(()=>{if(x.current||0===l.length||u)return;let a=l.find(a=>a.id===y.current)||[...l].filter(a=>!a.hidden).sort((a,b)=>Q(a)-Q(b))[0]||l[0];x.current=!0,bf(a.id)},[l,u]),(0,c.useEffect)(()=>{if(Y.current=u?.id??null,u)return bb(),aT.current&&clearInterval(aT.current),aT.current=setInterval(bb,2e3),()=>{aT.current&&clearInterval(aT.current)}},[u]);let a7=u?l.find(a=>a.id===u.details.id)??u.details:void 0,a8=!!u&&P(a7),a9=a8?function(a){for(let b=a.length-1;b>=0;b--){let c=f(a[b].content);if(c){if("stopped"===c.state)return null;return c.page||c.html||null}}return null}(z):null;async function ba(){let a=await fetch("/api/bots",{cache:"no-store"}),b=await a.json(),c=Date.parse(a.headers.get("date")||"");aX({serverNow:Number.isNaN(c)?Date.now():c,fetchedAt:Date.now()}),Array.isArray(b)&&(n(b),t(!0))}async function bb(){if(!u)return;let a=u.id,b=null,c=!1,d=fetch(`/api/conversations/${a}`).then(async a=>{let b=await a.json();return a.ok&&Array.isArray(b?.events)?b.events:null}).catch(()=>null),e=fetch(`/api/exchanges?conversation=${encodeURIComponent(a)}`,{cache:"no-store"}).then(async a=>{let b=await a.json();return a.ok&&Array.isArray(b?.exchanges)?b.exchanges:null}).catch(()=>null);try{let d=await fetch(`/api/conversations/${a}/messages`);b=await d.json(),c=d.ok&&Array.isArray(b)}catch{c=!1}let f=await d,g=await e;if(Y.current===a){let d,e;c&&A(b),f&&D((d=[],e=new Map,f.forEach((a,b)=>{let c="string"==typeof a.data.target_name?a.data.target_name:null;a.requestId&&c&&e.set(a.requestId,c);let g=function(a){switch(a.kind){case"wake_blocked":return"blocked";case"wake_rejected":return"rejected";case"lineage_stopped":return"stopped";case"wake_accepted":return"string"==typeof a.data.reason?"allowed":null;case"request_cancelled":return"grant_denied"===a.data.reason?"denied":null;case"request_queued":return"capacity"===a.data.waiting_for?"waiting":null;default:return null}}(a);if(!g)return;let h=Array.isArray(a.data.actions)?a.data.actions:[],i=null!==a.requestId&&f.slice(b+1).some(b=>b.requestId===a.requestId);if("waiting"===g&&i)return;let j=a.requestId?e.get(a.requestId):void 0,k="denied"===g&&j?`Wake denied: ${j} — no work ran`:"waiting"===g&&j?`Queued: ${j} — waiting for capacity`:a.text;d.push({eventId:a.eventId,wakeId:a.wakeId,tone:g,text:k,actionable:"blocked"===g&&!!a.wakeId&&h.includes("allow")&&h.includes("deny")&&!i,createdAt:a.createdAt})}),d)),g&&F(g),M({conversationId:a,status:c?"ready":"error"})}}(0,c.useLayoutEffect)(()=>{let a=aP.current?.parentElement;if(!a)return;let b=aQ.current,c=aR.current,d=aS.current;if(a8&&b&&c&&d){let e=e=>{let f=Math.ceil(b.getBoundingClientRect().height);c.style.height=f+16+e+"px";let g=c.getBoundingClientRect().top-a.getBoundingClientRect().top;d.style.height=Math.max(0,a.clientHeight-g)+"px";let h=b.getBoundingClientRect().top-a.getBoundingClientRect().top+a.scrollTop;a.scrollTop=Math.max(0,h-g)};e(0);let f=c.nextElementSibling,g=b.getBoundingClientRect().bottom,h=f?f.getBoundingClientRect().top:c.getBoundingClientRect().bottom;g>=h&&e(Math.max(16,Math.ceil(g-h)));return}d&&(d.style.height="0px"),c&&(c.style.height=""),a.scrollTop=a.scrollHeight},[z,a8]),(0,c.useEffect)(()=>{let a=H.current;if(!a)return;let b=document.getElementById(`exchange-${a}`);b&&(H.current=null,b.scrollIntoView({block:"center"}),b.focus({preventScroll:!0}))},[E]),(0,c.useLayoutEffect)(()=>{aV(a=>{if(0===a.length)return a;let b=a.filter(a=>{let b=a$.current[a]??0;return z.some(c=>"bot"===c.sender_type&&c.sender_id===a&&c.created_at>b&&!/^\[(mcp|tool call|tool result)\]/i.test(c.content.trim()))});if(0===b.length)return a;for(let a of b)delete a$.current[a];return a.filter(a=>!b.includes(a))})},[z]);let bc=async a=>{u&&(await fetch(`/api/conversations/${u.id}/messages/${a}/stop`,{method:"POST"}),await bb())},bd=async()=>{u&&(await fetch(`/api/conversations/${u.id}/stop`,{method:"POST"}),await bb())},be=async(a,b)=>{if(au[a.id])return void av(b=>{let c={...b};return delete c[a.id],c});if(aw.current[a.id])return;let c=z.findIndex(b=>b.id===a.id),d=l.find(a=>a.name===b),e=z.slice(c+1).find(a=>"bot"===a.sender_type&&(d?a.sender_id===d.id:a.sender_name===b));if(e){aw.current[a.id]=!0;try{let b=await fetch(`/api/messages/${a.id}/between?other=${encodeURIComponent(e.id)}`),c=await b.json().catch(()=>null);b.ok&&Array.isArray(c)&&c.length>0&&av(b=>({...b,[a.id]:c}))}finally{delete aw.current[a.id]}}};async function bf(a){let b=l.find(b=>b.id===a);if(!b)return;let c=await fetch(`/api/conversations?botId=${a}`),d=await c.json();an(!1),ap(!1),d.id!==u?.id&&(A([]),D([]),F([])),Y.current=d.id,w({id:d.id,details:b})}let bg=async()=>{if(!u)return;let a=aN.current?.files?.[0];if(!a)return;let b=await new Promise((b,c)=>{let d=new FileReader;d.onload=()=>b(String(d.result||"")),d.onerror=()=>c(d.error),d.readAsDataURL(a)});if(!b.startsWith("data:image/"))return;let c=await fetch("/api/bots",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:u.details.id,avatar:b})});if(!c.ok)return;let d=await c.json();n(a=>a.map(a=>a.id===d.id?{...a,avatar:d.avatar}:a)),w({...u,details:{...u.details,avatar:d.avatar}})},bh=async a=>{if(!a||!u)return;let b=await new Promise((b,c)=>{let d=new FileReader;d.onload=()=>b(String(d.result||"")),d.onerror=()=>c(d.error),d.readAsDataURL(a)});if(!b.startsWith("data:image/"))return;let c=await fetch("/api/bots",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:u.details.id,avatar:b})});if(!c.ok)return;let d=await c.json();n(a=>a.map(a=>a.id===d.id?{...a,avatar:d.avatar}:a)),w({...u,details:{...u.details,avatar:d.avatar}})},bi=async()=>{if(!u)return;let a=await fetch("/api/bots",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:u.details.id,avatar:null})});if(!a.ok)return;let b=await a.json();n(a=>a.map(a=>a.id===b.id?{...a,avatar:b.avatar||""}:a)),w({...u,details:{...u.details,avatar:b.avatar||""}})},bj=p&&0===l.length,bk=[...l].filter(a=>!a.hidden).sort((a,b)=>Q(a)-Q(b)),bl=l.filter(a=>a.hidden),bm=async a=>{let b=await fetch("/api/bots",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:a.id,pinned:+!a.pinned})});if(!b.ok)return;let c=await b.json();n(a=>a.map(a=>a.id===c.id?{...a,...c}:a))},bn=async(a,b)=>{let c=await fetch("/api/bots",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:a.id,hidden:+!!b})});if(!c.ok)return;let d=await c.json();n(a=>a.map(a=>a.id===d.id?{...a,...d,hidden:+!!d.hidden}:a)),b?requestAnimationFrame(()=>aC.current?.focus()):br(a.id)},bo=async a=>{(await fetch("/api/bots",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:a.id,unread:1})})).ok&&n(b=>b.map(b=>b.id===a.id?{...b,unread:1}:b))};(0,c.useEffect)(()=>{if(!az)return;let a=a=>{"Escape"===a.key&&(aA(null),az.returnTo?.focus())},b=a=>{aB.current&&aB.current.contains(a.target)||aA(null)};return document.addEventListener("keydown",a),document.addEventListener("pointerdown",b),()=>{document.removeEventListener("keydown",a),document.removeEventListener("pointerdown",b)}},[az]);let bp=async a=>{let b=as.trim();if(ar(null),!b||b===a.name)return;let c=await fetch("/api/bots",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:a.id,name:b})});if(!c.ok)return;let d=await c.json();n(a=>a.map(a=>a.id===d.id?{...a,...d}:a)),u&&u.details.id===d.id&&w({...u,details:{...u.details,...d}})},bq=async a=>{let b=a.map(a=>a.id);ay(null),aE(!1),aK((0,s.deletedStatusLine)(b.length)),requestAnimationFrame(()=>aF.current?.focus()),n(a=>a.filter(a=>!b.includes(a.id))),u&&b.includes(u.details.id)&&(w(null),A([]),D([])),await ba()},br=(a,b=30)=>{requestAnimationFrame(()=>{let c=document.querySelector(`[data-open-bot="${a}"]`);c?c.focus():b>0&&br(a,b-1)})},bs=(a=!0)=>{let b=az?.returnTo;aA(null),a&&b&&requestAnimationFrame(()=>{b.isConnected&&b.focus()})},bt=(a,b)=>{a.preventDefault(),aA({bot:b,x:a.clientX,y:a.clientY,returnTo:a.currentTarget.querySelector("[data-open-bot]")})},bu=(a,c)=>(0,b.jsx)("input",{className:"bot-name","aria-label":`Rename ${a.name}`,value:as,autoFocus:!0,onChange:a=>at(a.target.value),onBlur:()=>bp(a),onKeyDown:b=>{"Enter"===b.key&&(b.preventDefault(),b.target.blur(),br(a.id)),"Escape"===b.key&&(ar(null),br(a.id))},style:c}),bv=(a,c)=>(0,b.jsx)("button",{type:"button",className:"bot-name row-open","data-open-bot":a.id,"aria-current":u?.details.id===a.id?"true":void 0,onClick:()=>bf(a.id),style:c,children:a.name}),bw=a=>(0,b.jsx)("button",{type:"button",className:"row-actions","aria-haspopup":"menu","aria-expanded":az?.bot.id===a.id,"aria-label":`Actions for ${a.name}`,title:`Actions for ${a.name}`,onClick:b=>{var c;let d;aA({bot:a,x:(d=(c=b.currentTarget).getBoundingClientRect()).left,y:d.bottom+4,returnTo:c})},children:"⋯"}),bx=a=>(0,b.jsxs)("div",{className:"row-tip",children:[a.unread&&u?.details.id!==a.id?(0,b.jsx)("div",{className:"card-role",children:"Unread"}):null,(0,b.jsx)("div",{className:"card-role",children:R(a.last_seen,aW.serverNow,aW.fetchedAt,aY)})]}),by=a=>(0,b.jsxs)("div",{className:u?.details.id===a.id?"bot-row is-open":"bot-row",onContextMenu:b=>bt(b,a),children:[(0,b.jsxs)("span",{className:"mark-avatar mark-avatar-sm",children:[(0,b.jsx)(h.default,{bot:a,size:36,title:`${a.name} avatar`}),aU.includes(a.id)?(0,b.jsx)("span",{className:"mark-dot"}):null]}),(0,b.jsxs)("div",{className:"bot-copy",children:[aq===a.id?bu(a):bv(a),L(a.latest)?(0,b.jsx)("div",{className:"bot-preview",children:L(a.latest)}):null,(0,b.jsx)(m.RosterRuntimeLine,{bot:a,state:a5})]}),bw(a),bx(a)]},a.id),bz=ab?l.filter(a=>a.name.toLowerCase().includes(_.toLowerCase())):[],bA=a=>{let b=ah.current,c=b?b.selectionStart:Z.length,d=Z.slice(0,c).lastIndexOf("@");if(d<0)return;$(Z.slice(0,d)+"@"+a+" "+Z.slice(c)),ac(!1);let e=d+a.length+2;requestAnimationFrame(()=>{b?.focus(),b?.setSelectionRange(e,e)})},bB=a=>{if(0===a.length)return;let b=6-ad.length;a.length>b?ag("Up to six attachments."):ag("");let c=a.slice(0,Math.max(b,0));0!==c.length&&ae(a=>[...a,...c.map((b,c)=>({id:b.name+"-"+a.length+"-"+c+"-"+b.size,name:b.name}))])},bC=async()=>{let a=ad.map(a=>a.name),b=Z.trim();if(!b&&0===a.length||!u)return;let c=[b,...a].filter(a=>a.length>0).join("\n"),d=[u.details.id],e=z.reduce((a,b)=>Math.max(a,b.created_at||0),0);for(let a of d)a$.current[a]=e;aV(a=>Array.from(new Set([...a,...d])));let f=[...l].sort((a,b)=>b.name.length-a.name.length).find(a=>(function(a,b){let c="@"+b,d=0;for(;d<a.length;){let b=a.indexOf(c,d);if(b<0)break;let e=a[b+c.length];if(!e||/[\s.,!?:;]/.test(e))return!0;d=b+c.length}return!1})(c,a.name));if(!(await fetch(`/api/conversations/${u.id}/messages`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:c,mentionedBotId:f?.id,idempotencyKey:crypto.randomUUID()})})).ok){for(let a of d)delete a$.current[a];aV(a=>a.filter(a=>!d.includes(a)))}$(""),ae([]),ag(""),ac(!1),bb()},bD=u?(a=u.id,z.length>0?"messages":I&&I.conversationId===a&&"loading"!==I.status?"error"===I.status?"error":"empty":"loading"):"loading",bE=u?(0,b.jsx)(G,{view:bD,agentName:u.details.name}):null,bF=(u?.details.title||"").trim(),bG=u?.details.color,bH=new Set,bI=a=>(0,b.jsx)("div",{className:"msg-status",children:(0,b.jsx)(N,{notice:a,onDone:()=>{bb()}})},a.eventId),bJ=new Set,bK=a=>(0,b.jsx)("div",{className:"msg-status",children:(0,b.jsx)(O.default,{summary:a,onChanged:()=>{bb()}})},`exchange-${a.id}`),bL=a=>{let b=E.filter(b=>!bJ.has(b.id)&&b.created_at<a).sort((a,b)=>a.created_at-b.created_at||(a.id<b.id?-1:1));return b.forEach(a=>bJ.add(a.id)),b.map(bK)},bM=()=>{ak(!1),requestAnimationFrame(()=>al.current?.focus())};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"field",inert:aj,children:[(0,b.jsxs)("aside",{className:"rail",children:[(0,b.jsxs)("div",{className:"brand",children:[(0,b.jsx)("div",{className:a0?"logo-shape is-settling":"logo-shape",children:(0,b.jsx)(e.default,{src:"/brand/botmancers-logo-filled-256.png",alt:"",width:40,height:40})}),(0,b.jsx)("div",{className:"logo-word",children:"botmancers"})]}),(0,b.jsxs)("div",{className:"bar",children:[(0,b.jsx)("button",{ref:al,type:"button",className:"add-btn","aria-haspopup":"dialog",onClick:()=>ak(!0),children:"New"}),bj?null:(0,b.jsx)("button",{ref:aF,type:"button",className:"add-btn","aria-haspopup":"dialog",onClick:()=>{aK(""),aE(!0)},children:"Manage agents"}),(0,b.jsx)(d.default,{href:"/settings",className:"add-btn settings-link",children:"Settings"})]}),bj?null:(0,b.jsx)("nav",{className:"rail-nav","aria-label":"Workspace",children:(0,b.jsx)(d.default,{href:"/exchanges",className:"add-btn rail-nav-link",children:"Exchanges"})}),(0,b.jsx)("p",{className:"roster-status",role:"status",children:aJ}),bj?null:(0,b.jsx)("div",{className:az?"roster menu-open":"roster",children:bk.map(a=>P(a)?(0,b.jsxs)("div",{className:"card",onContextMenu:b=>bt(b,a),children:[(0,b.jsxs)("div",{className:"row-head",children:[(0,b.jsxs)("span",{className:"mark-avatar",children:[(0,b.jsx)(h.default,{bot:a,size:44,title:`${a.name} avatar`}),aU.includes(a.id)?(0,b.jsx)("span",{className:"mark-dot"}):null]}),aq===a.id?bu(a,{color:"#D5D0C3",fontSize:26}):bv(a,{fontSize:26}),bw(a)]}),L(a.latest)?(0,b.jsx)("div",{className:"bot-preview",children:L(a.latest)}):null,(0,b.jsx)(m.RosterRuntimeLine,{bot:a,state:a5}),bx(a)]},a.id):by(a))}),bl.length>0?(0,b.jsxs)("div",{className:az?"roster menu-open":"roster",children:[(0,b.jsx)("button",{ref:aC,type:"button",className:"pin-word","aria-expanded":aL,onClick:()=>aM(a=>!a),children:"Hidden"}),aL?bl.map(by):null]}):null]}),(0,b.jsx)("section",{className:"pane",children:u?(0,b.jsxs)("div",{className:"thread",children:[(0,b.jsxs)("div",{className:"thread-bar",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("button",{type:"button",className:"thread-name",style:bG?{color:bG}:void 0,onClick:()=>{an(!0),ap(!1)},children:u.details.name}),bF?(0,b.jsx)("div",{className:"thread-role",children:bF}):null,(0,b.jsx)("div",{className:"thread-role",children:aU.includes(u.details.id)?"Working":"Not working"}),(0,b.jsx)("div",{className:"thread-role",children:R((a7??u.details).last_seen,aW.serverNow,aW.fetchedAt,aY)}),am?(0,b.jsx)("button",{type:"button",className:"avatar-pic",onClick:()=>ap(!0),"aria-label":"Picture",children:u.details.avatar?(0,b.jsx)("img",{src:u.details.avatar,alt:""}):(0,b.jsx)(h.default,{bot:u.details,size:46})}):null]}),(0,b.jsxs)("div",{style:{marginLeft:"auto",display:"flex",gap:16,alignItems:"flex-start"},children:[(0,b.jsx)(d.default,{href:`/bots/${u.details.id}/config`,className:"attach-word",style:{textDecoration:"none"},children:"Config"}),(0,b.jsx)("button",{ref:aI,type:"button",className:"attach-word","aria-haspopup":"dialog","aria-expanded":aG,onClick:()=>aH(!0),children:"Sessions"}),(0,b.jsx)("button",{type:"button",className:"attach-word",title:"Stop delegated turns in this thread",onClick:()=>{bd()},children:"Stop"})]})]}),ao?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"avatar-step avatar-desk",children:[(0,b.jsx)("span",{className:"kind-word",children:"Agent"}),(0,b.jsx)("button",{type:"button",className:"kind-word",children:"Generate"}),(0,b.jsxs)("label",{className:"kind-word",children:["Upload",(0,b.jsx)("input",{ref:aN,type:"file",accept:"image/*,.svg"})]}),(0,b.jsx)("button",{type:"button",className:"create-btn",onClick:bg,children:"Set avatar"})]}),(0,b.jsxs)("div",{className:"avatar-step avatar-phone",children:[(0,b.jsx)("button",{type:"button",className:"kind-word",onClick:()=>aO.current?.click(),children:"Gallery"}),(0,b.jsx)("button",{type:"button",className:"kind-word",children:"Generate"}),(0,b.jsx)("button",{type:"button",className:"kind-word",onClick:bi,children:"Remove Photo"}),(0,b.jsx)("input",{ref:aO,type:"file",accept:"image/*,.svg",onChange:a=>{let b=a.target.files?.[0];a.target.value="",bh(b)}})]})]}):null,(0,b.jsxs)("div",{className:"messages-wrap",children:[(0,b.jsxs)("div",{className:"messages",children:[a8?null:bE,z.map(a=>{var d;let e,h,l=C.filter(b=>!bH.has(b.eventId)&&b.createdAt<a.created_at);l.forEach(a=>bH.add(a.eventId));let m=bL(a.created_at),n="user"===a.sender_type,o=n?null:J(T(a.content));if(o)return(0,b.jsxs)(c.Fragment,{children:[l.map(bI),m,(0,b.jsx)("div",{className:"msg-status",children:(0,b.jsx)(K,{failure:o})})]},a.id);let p=(d=T(a.content),e=[],{text:S(d.replace(/data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=\s]+/g,a=>(e.push(a.replace(/\s/g,"")),""))),images:e}),q=p.images.map(a=>(0,b.jsx)("img",{src:a,alt:"",style:{display:"block",width:64,height:64}},a.slice(0,48))),r=n?void 0:u.details.color,s=n?null:f(a.content),t=n||s?null:i(T(a.content)),v=n||s?null:j(a.content),w=n||s?[]:function(a){let b=[];for(let c of a.split("\n")){let a=c.match(/^\s*\[file\]\s*(\S+)\s*$/i);a&&!b.includes(a[1])&&b.push(a[1])}return b}(a.content),x=n||s?null:(h=p.text.match(/^\s*\[Handing off to ([^\]]+)\]/))&&h[1].trim()||null,y=a.draftStatus??(t?"open":null),z=a.approvalStatus??(v?"pending":null);return(0,b.jsxs)(c.Fragment,{children:[l.map(bI),m,(0,b.jsxs)("div",{className:n?"msg-you":"msg-bot",ref:s&&"running"===s.state?aQ:void 0,children:[(0,b.jsx)("div",{className:n?"msg-name msg-name-you":"msg-name",style:r?{color:r}:void 0,children:n?"You":a.sender_name||u.details.name}),s?(0,b.jsxs)("div",{className:"msg-body",children:[g(s),"running"===s.state?(0,b.jsxs)(b.Fragment,{children:[" ",(0,b.jsx)("button",{type:"button",className:"attach-word",style:{font:"inherit"},onClick:b=>{b.preventDefault(),b.stopPropagation(),bc(a.id)},children:"Stop"})]}):null]}):t&&y?(0,b.jsx)("div",{className:"msg-body",children:(0,b.jsx)(U,{message:a,conversationId:u.id,status:y,onDone:()=>{bb()}},a.id+y)}):(0,b.jsxs)("div",{className:"msg-body",onClick:x?()=>{be(a,x)}:void 0,title:x?"Show the replies between this handoff and the reply":void 0,style:x?{cursor:"pointer"}:void 0,children:[function(a,c){let d=String(a??"").split("\n");if(!d.some(a=>null!==(0,k.deckEventDisplay)(a)))return a;let e=[];return d.forEach((a,d)=>{d>0&&e.push((0,b.jsx)("br",{},c+"-br-"+d));let f=(0,k.deckEventDisplay)(a);f?e.push((0,b.jsxs)("span",{className:"deck-event",children:[(0,b.jsx)("span",{className:"deck-event-label",children:f.label}),f.detail?" "+f.detail:""]},c+"-"+d)):e.push((0,b.jsx)("span",{children:a},c+"-"+d))}),e}(p.text,a.id),q,v&&z?(0,b.jsx)(V,{message:a,conversationId:u.id,status:z,onDone:()=>{bb()}},a.id+z):null,(0,b.jsx)(W,{names:w})]}),au[a.id]?(0,b.jsx)("div",{className:"msg-body",children:au[a.id].map(a=>(0,b.jsx)("div",{children:(a.sender_name||"Agent")+": "+S(a.content)},a.id))}):null]})]},a.id)}),C.filter(a=>!bH.has(a.eventId)).map(bI),bL(1/0),(0,b.jsx)("div",{ref:aS}),(0,b.jsx)("div",{ref:aP})]}),a8?(0,b.jsxs)("div",{className:"computer-float",children:[(0,b.jsxs)("div",{className:"computer-top",children:[(0,b.jsxs)("span",{className:"computer-lights","aria-hidden":"true",children:[(0,b.jsx)("span",{className:"computer-light computer-light-red"}),(0,b.jsx)("span",{className:"computer-light computer-light-yellow"}),(0,b.jsx)("span",{className:"computer-light computer-light-green"})]}),(0,b.jsxs)("span",{className:"computer-teach",children:[(0,b.jsxs)("span",{className:"computer-teach-pill",children:[(0,b.jsx)("span",{className:"computer-teach-mark","aria-hidden":"true"}),"Teach a task"]}),(0,b.jsx)("span",{className:"computer-expand","aria-hidden":"true",children:(0,b.jsx)("svg",{viewBox:"0 0 16 16",width:"14",height:"14",children:(0,b.jsx)("path",{d:"M9.2 2.6H13.4V6.8M6.8 13.4H2.6V9.2M13.1 2.9L9.4 6.6M2.9 13.1L6.6 9.4",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]}),(0,b.jsx)("div",{className:"messages"===bD?"computer-band":"computer-band computer-band-note",ref:aR,children:bE}),(0,b.jsxs)("div",{className:"computer-desk",children:[a9?(0,b.jsx)("iframe",{className:"computer-page",sandbox:"",srcDoc:a9,tabIndex:-1}):null,(0,b.jsxs)("div",{className:"computer-dock",children:[(0,b.jsx)("img",{src:"/computer/dock-chrome.png",alt:""}),(0,b.jsx)("img",{src:"/computer/dock-gray.png",alt:""}),(0,b.jsx)("img",{src:"/computer/dock-terminal.png",alt:""})]})]})]}):null]}),(0,b.jsxs)("div",{className:"composer",onPaste:a=>{let b=[],c=a.clipboardData.files;if(c&&c.length>0)b.push(...Array.from(c));else for(let c of Array.from(a.clipboardData.items)){if("file"!==c.kind)continue;let a=c.getAsFile();a&&b.push(a)}0!==b.length&&(a.preventDefault(),bB(b))},children:[ab&&bz.length>0?(0,b.jsx)("div",{className:"mention-list",children:bz.map(a=>(0,b.jsxs)("button",{type:"button",onMouseDown:b=>{b.preventDefault(),bA(a.name)},children:["@",a.name]},a.id))}):null,(0,b.jsxs)("div",{className:"composer-box",children:[af?(0,b.jsx)("p",{className:"attach-error",children:af}):null,ad.length>0?(0,b.jsx)("div",{className:"attach-names",children:ad.map(a=>(0,b.jsx)("span",{children:a.name},a.id))}):null,(0,b.jsx)("textarea",{ref:ah,rows:2,value:Z,onChange:a=>{var b,c;let d,e;$(a.target.value),b=a.target.value,c=a.target.selectionStart,(e=(d=b.slice(0,c)).lastIndexOf("@"))<0||/\s/.test(d.slice(e+1))?ac(!1):(aa(d.slice(e+1)),ac(!0))},onKeyDown:a=>{if("Enter"===a.key&&!a.shiftKey){if(a.preventDefault(),ab&&bz.length>0)return void bA(bz[0].name);bC()}},placeholder:"Say something"})]}),(0,b.jsx)("input",{ref:ai,className:"attach-input",type:"file",multiple:!0,onChange:a=>{bB(Array.from(a.target.files||[])),a.target.value=""}}),(0,b.jsx)("button",{type:"button",className:"attach-word",onClick:()=>ai.current?.click(),children:"Attach"}),(0,b.jsx)("button",{type:"button",className:"send-btn",onClick:bC,children:"Send"})]})]}):bj?(0,b.jsxs)("div",{className:"welcome",children:[(0,b.jsx)(e.default,{className:"welcome-mark",src:"/brand/botmancers-logo-outline-256.png",alt:"Botmancers",width:144,height:144,priority:!0}),(0,b.jsx)("p",{className:"empty-line",children:"Pick someone to talk to."})]}):(0,b.jsx)("p",{className:"empty-line",children:"Pick someone to talk to."})}),ax?(0,b.jsx)(r.default,{ids:[ax.id],onCancel:()=>{br(ax.id),ay(null)},onDeleted:a=>{bq(a)}}):null,aG&&u?(0,b.jsx)(B,{agentId:u.details.id,agentName:u.details.name,agents:l.map(a=>({id:a.id,name:a.name})),origin:{conversationId:u.id,label:`${u.details.name} thread`},onExchangeStarted:()=>{bb()},onClose:()=>{aH(!1),requestAnimationFrame(()=>aI.current?.focus())},onOpenThread:a=>{aH(!1),bf(a).then(()=>requestAnimationFrame(()=>aI.current?.focus()))}},u.details.id):null,aD?(0,b.jsx)(v,{deckState:a5,onClose:()=>{aE(!1),requestAnimationFrame(()=>aF.current?.focus())},onDeleted:a=>{bq(a)}}):null,az?(0,b.jsxs)("div",{ref:aB,className:"row-menu",role:"menu","aria-label":`Actions for ${az.bot.name}`,style:{left:az.x,top:az.y},onPointerDown:a=>a.stopPropagation(),onClick:a=>a.stopPropagation(),onContextMenu:a=>a.preventDefault(),onKeyDown:a=>{let b=Array.from(a.currentTarget.querySelectorAll("[role=menuitem]")),c=b.indexOf(document.activeElement),d=c=>{a.preventDefault(),b[(c+b.length)%b.length]?.focus()};"ArrowDown"===a.key?d(c+1):"ArrowUp"===a.key?d(c-1):"Home"===a.key?d(0):"End"===a.key?d(b.length-1):"Tab"===a.key&&(a.preventDefault(),bs())},children:[(0,b.jsx)("button",{type:"button",role:"menuitem",tabIndex:-1,autoFocus:!0,onClick:a=>{a.stopPropagation(),bs(),bm(az.bot)},children:az.bot.pinned?"Unpin":"Pin"}),(0,b.jsx)("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:a=>{a.stopPropagation(),bs(),bo(az.bot)},children:"Mark as Unread"}),(0,b.jsx)("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:a=>{a.stopPropagation(),bs(!1),ar(az.bot.id),at(az.bot.name)},children:"Rename Agent"}),(0,b.jsx)("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:a=>{a.stopPropagation(),bs(!1),bn(az.bot,!az.bot.hidden)},children:az.bot.hidden?"Unhide":"Hide from sidebar"}),(0,b.jsx)(d.default,{role:"menuitem",tabIndex:-1,href:`/bots/${az.bot.id}/config`,onClick:()=>aA(null),children:"Config"}),(0,b.jsx)("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:a=>{a.stopPropagation(),bs(!1),ay(az.bot)},children:"Delete agent…"})]}):null]}),aj&&(0,b.jsx)(X,{anchorRef:al,deckState:a5,onRetryDecks:()=>{a3(!0),a6()},onClose:bM,onCreated:()=>{ba(),bM()}})]})}],60350)},67161,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"Image",{enumerable:!0,get:function(){return v}});let d=a.r(33354),e=a.r(46058),f=a.r(87924),g=e._(a.r(72131)),h=d._(a.r(35112)),i=d._(a.r(58018)),j=a.r(94915),k=a.r(345),l=a.r(4486),m=a.r(53773),n=d._(a.r(2305)),o=a.r(8591),p={deviceSizes:[640,750,828,1080,1200,1920,2048,3840],imageSizes:[32,48,64,96,128,256,384],qualities:[75],path:"/_next/image",loader:"default",dangerouslyAllowSVG:!1,unoptimized:!0};function q(a,b,c,d,e,f,g){let h=a?.src;a&&a["data-loaded-src"]!==h&&(a["data-loaded-src"]=h,("decode"in a?a.decode():Promise.resolve()).catch(()=>{}).then(()=>{if(a.parentElement&&a.isConnected){if("empty"!==b&&e(!0),c?.current){let b=new Event("load");Object.defineProperty(b,"target",{writable:!1,value:a});let d=!1,e=!1;c.current({...b,nativeEvent:b,currentTarget:a,target:a,isDefaultPrevented:()=>d,isPropagationStopped:()=>e,persist:()=>{},preventDefault:()=>{d=!0,b.preventDefault()},stopPropagation:()=>{e=!0,b.stopPropagation()}})}d?.current&&d.current(a)}}))}function r(a){return g.use?{fetchPriority:a}:{fetchpriority:a}}globalThis.__NEXT_IMAGE_IMPORTED=!0;let s=g.useEffect,t=(0,g.forwardRef)(({src:a,srcSet:b,sizes:c,height:d,width:e,decoding:h,className:i,style:j,fetchPriority:k,placeholder:l,loading:m,unoptimized:n,fill:p,onLoadRef:t,onLoadingCompleteRef:u,setBlurComplete:v,setShowAltText:w,sizesInput:x,onLoad:y,onError:z,...A},B)=>{let C=(0,g.useRef)(!1),D=(0,g.useRef)(null);s(()=>{let{current:a}=C,{current:b}=D;a||null===b||(z&&(b.src=b.src),b.complete&&q(b,l,t,u,v,n,x),C.current=!0)},[a,l,t,u,z,n,x]);let E=(0,o.useMergedRef)(B,D);return(0,f.jsx)("img",{...A,...r(k),loading:m,width:e,height:d,decoding:h,"data-nimg":p?"fill":"1",className:i,style:j,sizes:c,srcSet:b,src:a,ref:E,onLoad:a=>{q(a.currentTarget,l,t,u,v,n,x)},onError:a=>{w(!0),"empty"!==l&&v(!0),z&&z(a)}})});function u({isAppRouter:a,imgAttributes:b}){let c={as:"image",imageSrcSet:b.srcSet,imageSizes:b.sizes,crossOrigin:b.crossOrigin,referrerPolicy:b.referrerPolicy,...r(b.fetchPriority)};return a&&h.default.preload?(h.default.preload(b.src,c),null):(0,f.jsx)(i.default,{children:(0,f.jsx)("link",{rel:"preload",href:b.srcSet?void 0:b.src,...c},"__nimg-"+b.src+b.srcSet+b.sizes)})}let v=(0,g.forwardRef)((a,b)=>{let c=(0,g.useContext)(m.RouterContext),d=(0,g.useContext)(l.ImageConfigContext),e=(0,g.useMemo)(()=>{let a=p||d||k.imageConfigDefault,b=[...a.deviceSizes,...a.imageSizes].sort((a,b)=>a-b),c=a.deviceSizes.sort((a,b)=>a-b),e=a.qualities?.sort((a,b)=>a-b);return{...a,allSizes:b,deviceSizes:c,qualities:e,localPatterns:d?.localPatterns}},[d]),{onLoad:h,onLoadingComplete:i}=a,o=(0,g.useRef)(h);(0,g.useEffect)(()=>{o.current=h},[h]);let q=(0,g.useRef)(i);(0,g.useEffect)(()=>{q.current=i},[i]);let[r,s]=(0,g.useState)(!1),[v,w]=(0,g.useState)(!1),{props:x,meta:y}=(0,j.getImgProps)(a,{defaultLoader:n.default,imgConf:e,blurComplete:r,showAltText:v});return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(t,{...x,unoptimized:y.unoptimized,placeholder:y.placeholder,fill:y.fill,onLoadRef:o,onLoadingCompleteRef:q,setBlurComplete:s,setShowAltText:w,sizesInput:a.sizes,ref:b}),y.preload?(0,f.jsx)(u,{isAppRouter:!c,imgAttributes:x}):null]})});("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},33095,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={default:function(){return k},getImageProps:function(){return j}};for(var e in d)Object.defineProperty(c,e,{enumerable:!0,get:d[e]});let f=a.r(33354),g=a.r(94915),h=a.r(67161),i=f._(a.r(2305));function j(a){let{props:b}=(0,g.getImgProps)(a,{defaultLoader:i.default,imgConf:{deviceSizes:[640,750,828,1080,1200,1920,2048,3840],imageSizes:[32,48,64,96,128,256,384],qualities:[75],path:"/_next/image",loader:"default",dangerouslyAllowSVG:!1,unoptimized:!0}});for(let[a,c]of Object.entries(b))void 0===c&&delete b[a];return{props:b}}let k=h.Image},71987,(a,b,c)=>{b.exports=a.r(33095)},92966,(a,b,c)=>{"use strict";b.exports=a.r(42602).vendored.contexts.HeadManagerContext},58018,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={default:function(){return p},defaultHead:function(){return l}};for(var e in d)Object.defineProperty(c,e,{enumerable:!0,get:d[e]});let f=a.r(33354),g=a.r(46058),h=a.r(87924),i=g._(a.r(72131)),j=f._(a.r(94613)),k=a.r(92966);function l(){return[(0,h.jsx)("meta",{charSet:"utf-8"},"charset"),(0,h.jsx)("meta",{name:"viewport",content:"width=device-width"},"viewport")]}function m(a,b){return"string"==typeof b||"number"==typeof b?a:b.type===i.default.Fragment?a.concat(i.default.Children.toArray(b.props.children).reduce((a,b)=>"string"==typeof b||"number"==typeof b?a:a.concat(b),[])):a.concat(b)}let n=["name","httpEquiv","charSet","itemProp"];function o(a){let b,c,d,e;return a.reduce(m,[]).reverse().concat(l().reverse()).filter((b=new Set,c=new Set,d=new Set,e={},a=>{let f=!0,g=!1;if(a.key&&"number"!=typeof a.key&&a.key.indexOf("$")>0){g=!0;let c=a.key.slice(a.key.indexOf("$")+1);b.has(c)?f=!1:b.add(c)}switch(a.type){case"title":case"base":c.has(a.type)?f=!1:c.add(a.type);break;case"meta":for(let b=0,c=n.length;b<c;b++){let c=n[b];if(a.props.hasOwnProperty(c))if("charSet"===c)d.has(c)?f=!1:d.add(c);else{let b=a.props[c],d=e[c]||new Set;("name"!==c||!g)&&d.has(b)?f=!1:(d.add(b),e[c]=d)}}}return f})).reverse().map((a,b)=>{let c=a.key||b;return i.default.cloneElement(a,{key:c})})}let p=function({children:a}){let b=(0,i.useContext)(k.HeadManagerContext);return(0,h.jsx)(j.default,{reduceComponentsToState:o,headManager:b,children:a})};("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},4486,(a,b,c)=>{"use strict";b.exports=a.r(42602).vendored.contexts.ImageConfigContext},53773,(a,b,c)=>{"use strict";b.exports=a.r(42602).vendored.contexts.RouterContext},35444,(a,b,c)=>{"use strict";function d(a,b){let c=a||75;return b?.qualities?.length?b.qualities.reduce((a,b)=>Math.abs(b-c)<Math.abs(a-c)?b:a,b.qualities[0]):c}Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"findClosestQuality",{enumerable:!0,get:function(){return d}})},2305,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"default",{enumerable:!0,get:function(){return g}});let d=a.r(35444),e=a.r(68063);function f({config:a,src:b,width:c,quality:g}){let h=(0,e.getDeploymentId)();if(b.startsWith("/")&&!b.startsWith("//"))if(b.includes("/_next/static/immutable")&&!(0,e.getAssetToken)())h=void 0;else{let a=b.indexOf("?");if(-1!==a){let c=new URLSearchParams(b.slice(a+1)),d=c.get("dpl");if(d){h=d,c.delete("dpl");let e=c.toString();b=b.slice(0,a)+(e?"?"+e:"")}}}if(b.startsWith("/")&&b.includes("?")&&a.localPatterns?.length===1&&"**"===a.localPatterns[0].pathname&&""===a.localPatterns[0].search)throw Object.defineProperty(Error(`Image with src "${b}" is using a query string which is not configured in images.localPatterns.
2
2
  Read more: https://nextjs.org/docs/messages/next-image-unconfigured-localpatterns`),"__NEXT_ERROR_CODE",{value:"E871",enumerable:!1,configurable:!0});let i=(0,d.findClosestQuality)(g,a);return`${a.path}?url=${encodeURIComponent(b)}&w=${c}&q=${i}${b.startsWith("/")&&h?`&dpl=${h}`:""}`}f.__next_img_default=!0;let g=f},4987,(a,b,c)=>{"use strict";function d({widthInt:a,heightInt:b,blurWidth:c,blurHeight:e,blurDataURL:f,objectFit:g}){let h=c?40*c:a,i=e?40*e:b,j=h&&i?`viewBox='0 0 ${h} ${i}'`:"";return`%3Csvg xmlns='http://www.w3.org/2000/svg' ${j}%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3CfeColorMatrix values='1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 100 -1' result='s'/%3E%3CfeFlood x='0' y='0' width='100%25' height='100%25'/%3E%3CfeComposite operator='out' in='s'/%3E%3CfeComposite in2='SourceGraphic'/%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage width='100%25' height='100%25' x='0' y='0' preserveAspectRatio='${j?"none":"contain"===g?"xMidYMid":"cover"===g?"xMidYMid slice":"none"}' style='filter: url(%23b);' href='${f}'/%3E%3C/svg%3E`}Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"getImageBlurSvg",{enumerable:!0,get:function(){return d}})},345,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={VALID_LOADERS:function(){return f},imageConfigDefault:function(){return g}};for(var e in d)Object.defineProperty(c,e,{enumerable:!0,get:d[e]});let f=["default","imgix","cloudinary","akamai","custom"],g={deviceSizes:[640,750,828,1080,1200,1920,2048,3840],imageSizes:[32,48,64,96,128,256,384],path:"/_next/image",loader:"default",loaderFile:"",domains:[],disableStaticImages:!1,minimumCacheTTL:14400,formats:["image/webp"],maximumDiskCacheSize:void 0,maximumRedirects:3,maximumResponseBody:5e7,dangerouslyAllowLocalIP:!1,dangerouslyAllowSVG:!1,contentSecurityPolicy:"script-src 'none'; frame-src 'none'; sandbox;",contentDispositionType:"attachment",localPatterns:void 0,remotePatterns:[],qualities:[75],unoptimized:!1,customCacheHandler:!1}},94915,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"getImgProps",{enumerable:!0,get:function(){return j}});let d=a.r(68063),e=a.r(4987),f=a.r(345),g=["-moz-initial","fill","none","scale-down",void 0];function h(a){return void 0!==a.default}function i(a){return void 0===a?a:"number"==typeof a?Number.isFinite(a)?a:NaN:"string"==typeof a&&/^[0-9]+$/.test(a)?parseInt(a,10):NaN}function j({src:a,sizes:b,unoptimized:c=!1,priority:k=!1,preload:l=!1,loading:m,className:n,quality:o,width:p,height:q,fill:r=!1,style:s,overrideSrc:t,onLoad:u,onLoadingComplete:v,placeholder:w="empty",blurDataURL:x,fetchPriority:y,decoding:z="async",layout:A,objectFit:B,objectPosition:C,lazyBoundary:D,lazyRoot:E,...F},G){var H;let I,J,K,{imgConf:L,showAltText:M,blurComplete:N,defaultLoader:O}=G,P=L||f.imageConfigDefault;if("allSizes"in P)I=P;else{let a=[...P.deviceSizes,...P.imageSizes].sort((a,b)=>a-b),b=P.deviceSizes.sort((a,b)=>a-b),c=P.qualities?.sort((a,b)=>a-b);I={...P,allSizes:a,deviceSizes:b,qualities:c}}if(void 0===O)throw Object.defineProperty(Error("images.loaderFile detected but the file is missing default export.\nRead more: https://nextjs.org/docs/messages/invalid-images-config"),"__NEXT_ERROR_CODE",{value:"E163",enumerable:!1,configurable:!0});let Q=F.loader||O;delete F.loader,delete F.srcSet;let R="__next_img_default"in Q;if(R){if("custom"===I.loader)throw Object.defineProperty(Error(`Image with src "${a}" is missing "loader" prop.
3
3
  Read more: https://nextjs.org/docs/messages/next-image-missing-loader`),"__NEXT_ERROR_CODE",{value:"E252",enumerable:!1,configurable:!0})}else{let a=Q;Q=b=>{let{config:c,...d}=b;return a(d)}}if(A){"fill"===A&&(r=!0);let a={intrinsic:{maxWidth:"100%",height:"auto"},responsive:{width:"100%",height:"auto"}}[A];a&&(s={...s,...a});let c={responsive:"100vw",fill:"100vw"}[A];c&&!b&&(b=c)}let S="",T=i(p),U=i(q);if((H=a)&&"object"==typeof H&&(h(H)||void 0!==H.src)){let b=h(a)?a.default:a;if(!b.src)throw Object.defineProperty(Error(`An object should only be passed to the image component src parameter if it comes from a static image import. It must include src. Received ${JSON.stringify(b)}`),"__NEXT_ERROR_CODE",{value:"E460",enumerable:!1,configurable:!0});if(!b.height||!b.width)throw Object.defineProperty(Error(`An object should only be passed to the image component src parameter if it comes from a static image import. It must include height and width. Received ${JSON.stringify(b)}`),"__NEXT_ERROR_CODE",{value:"E48",enumerable:!1,configurable:!0});if(J=b.blurWidth,K=b.blurHeight,x=x||b.blurDataURL,S=b.src,!r)if(T||U){if(T&&!U){let a=T/b.width;U=Math.round(b.height*a)}else if(!T&&U){let a=U/b.height;T=Math.round(b.width*a)}}else T=b.width,U=b.height}let V=!k&&!l&&("lazy"===m||void 0===m);(!(a="string"==typeof a?a:S)||a.startsWith("data:")||a.startsWith("blob:"))&&(c=!0,V=!1),I.unoptimized&&(c=!0),R&&!I.dangerouslyAllowSVG&&a.split("?",1)[0].endsWith(".svg")&&(c=!0);let W=i(o),X=Object.assign(r?{position:"absolute",height:"100%",width:"100%",left:0,top:0,right:0,bottom:0,objectFit:B,objectPosition:C}:{},M?{}:{color:"transparent"},s),Y=N||"empty"===w?null:"blur"===w?`url("data:image/svg+xml;charset=utf-8,${(0,e.getImageBlurSvg)({widthInt:T,heightInt:U,blurWidth:J,blurHeight:K,blurDataURL:x||"",objectFit:X.objectFit})}")`:`url("${w}")`,Z=g.includes(X.objectFit)?"fill"===X.objectFit?"100% 100%":"cover":X.objectFit,$=Y?{backgroundSize:Z,backgroundPosition:X.objectPosition||"50% 50%",backgroundRepeat:"no-repeat",backgroundImage:Y}:{},_=function({config:a,src:b,unoptimized:c,width:e,quality:f,sizes:g,loader:h}){if(c){if(b.startsWith("/")&&!b.startsWith("//")){let a=(0,d.getDeploymentId)();if(b.includes("/_next/static/immutable")&&!(0,d.getAssetToken)())a=void 0;else if(a){let c=b.indexOf("?");if(-1!==c){let d=new URLSearchParams(b.slice(c+1));d.get("dpl")||(d.append("dpl",a),b=b.slice(0,c)+"?"+d.toString())}else b+=`?dpl=${a}`}}return{src:b,srcSet:void 0,sizes:void 0}}let{widths:i,kind:j}=function({deviceSizes:a,allSizes:b},c,d){if(d){let c=/(^|\s)(1?\d?\d)vw/g,e=[];for(let a;a=c.exec(d);)e.push(parseInt(a[2]));if(e.length){let c=.01*Math.min(...e);return{widths:b.filter(b=>b>=a[0]*c),kind:"w"}}return{widths:b,kind:"w"}}return"number"!=typeof c?{widths:a,kind:"w"}:{widths:[...new Set([c,2*c].map(a=>b.find(b=>b>=a)||b[b.length-1]))],kind:"x"}}(a,e,g),k=i.length-1;return{sizes:g||"w"!==j?g:"100vw",srcSet:i.map((c,d)=>`${h({config:a,src:b,quality:f,width:c})} ${"w"===j?c:d+1}${j}`).join(", "),src:h({config:a,src:b,quality:f,width:i[k]})}}({config:I,src:a,unoptimized:c,width:T,quality:W,sizes:b,loader:Q}),aa=V?"lazy":m;return{props:{...F,loading:aa,fetchPriority:y,width:T,height:U,decoding:z,className:n,style:{...X,...$},sizes:_.sizes,srcSet:_.srcSet,src:t||_.src},meta:{unoptimized:c,preload:l||k,placeholder:w,fill:r}}}},94613,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"default",{enumerable:!0,get:function(){return f}});let d=a.r(72131),e=()=>{};function f(a){let{headManager:b,reduceComponentsToState:c}=a;return b?.mountedInstances?.add(a.children),function(){if(b&&b.mountedInstances){let a=d.Children.toArray(Array.from(b.mountedInstances).filter(Boolean));b.updateHead(c(a))}}(),e(),e(),null}}];
4
4
 
@@ -0,0 +1,3 @@
1
+ module.exports=[60645,(a,b,c)=>{}];
2
+
3
+ //# sourceMappingURL=_next-internal_server_app_exchanges_page_actions_0hcso2x.js.map
@@ -0,0 +1,3 @@
1
+ module.exports=[67663,(a,b,c)=>{}];
2
+
3
+ //# sourceMappingURL=_next-internal_server_app_threads_%5Bid%5D_page_actions_1fte2n3.js.map
@@ -0,0 +1,3 @@
1
+ module.exports=[25209,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(38246),e=a.i(50944),f=a.i(60193),g=a.i(35832),h=a.i(20851),i=a.i(1160),j=a.i(22855),k=a.i(2296),l=a.i(79202),m=a.i(36391);function n({attribute:a,label:d,options:e,current:f,onPick:g,className:h}){let i=(0,c.useId)(),j=`avatar-${a}`;return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("p",{id:i,className:"avatar-group-label",children:d}),(0,b.jsx)("div",{className:h?`avatar-opt-grid ${h}`:"avatar-opt-grid",role:"radiogroup","aria-labelledby":i,children:e.map(c=>(0,b.jsxs)("label",{title:c.label,className:"avatar-opt",children:[(0,b.jsx)("input",{type:"radio",name:j,value:c.id,checked:f[a]===c.id,onChange:()=>g({[a]:c.id}),className:"avatar-opt-input"}),(0,b.jsx)("span",{className:"avatar-opt-art","aria-hidden":"true",children:(0,b.jsx)(m.default,{config:{...f,[a]:c.id},size:44})}),(0,b.jsx)("span",{children:c.label})]},c.id))})]})}var o=a.i(80219);function p({phase:a,onImport:c}){let d=(0,o.marketImportView)(a);return(0,b.jsxs)("div",{className:"mt-3","data-field":"marketplace-import",children:[(0,b.jsx)("button",{type:"button",onClick:c,disabled:d.busy,"aria-busy":d.busy,"aria-describedby":"cfg-market-import-status",className:"cfg-btn-ghost text-sm w-full sm:w-auto",children:"Import from Grok Marketplace"}),(0,b.jsx)("p",{id:"cfg-market-import-status",role:"status","aria-live":"polite",className:"error"===d.tone?"mt-2 text-sm cfg-error":"mt-2 text-xs cfg-faint",children:d.message})]})}var q=a.i(5020);let r="Fix the highlighted fields.",s=[{key:"avatar_accessory",label:"Avatar accessory"},{key:"avatar_color",label:"Avatar color"},{key:"avatar_eyes",label:"Avatar eyes"},{key:"avatar_hands",label:"Avatar hands"},{key:"description",label:"Description (rules)"},{key:"import_operation_id",label:"Import operation ID"},{key:"import_schema_version",label:"Import schema version"},{key:"memories",label:"Remembered facts"},{key:"name",label:"Name"},{key:"skill_content",label:"Skill content"},{key:"skill_path",label:"Skill path"},{key:"skill_present",label:"Skill present"},{key:"source_provider",label:"Source provider"},{key:"template_id",label:"Template ID"},{key:"template_url",label:"Template URL"},{key:"title",label:"Title"}];function t(a){return String(a).padStart(2,"0")}function u(a){let b=new Date(a);return`${b.getFullYear()}-${t(b.getMonth()+1)}-${t(b.getDate())} ${t(b.getHours())}:${t(b.getMinutes())}`}function v(a){let b=new Date(a);return`${t(b.getHours())}:${t(b.getMinutes())}:${t(b.getSeconds())}`}async function w(a){try{return await navigator.clipboard.writeText(a),!0}catch{return!1}}a.s(["default",0,function(){var a;let t=String((0,e.useParams)().id??""),x=(0,e.useRouter)(),[y,z]=(0,c.useState)(!1),[A,B]=(0,c.useState)(null),[C,D]=(0,c.useState)(!0),[E,F]=(0,c.useState)(!1),[G,H]=(0,c.useState)(!1),[I,J]=(0,c.useState)(0),[K,L]=(0,c.useState)(null),[M,N]=(0,c.useState)("clean"),[O,P]=(0,c.useState)(""),[Q,R]=(0,c.useState)(0),[S,T]=(0,c.useState)(!1),[U,V]=(0,c.useState)(""),[W,X]=(0,c.useState)("clean"),[Y,Z]=(0,c.useState)(""),[$,_]=(0,c.useState)(0),[aa,ab]=(0,c.useState)({}),[ac,ad]=(0,c.useState)(""),[ae,af]=(0,c.useState)(!1),[ag,ah]=(0,c.useState)(null),[ai,aj]=(0,c.useState)(!1),ak=A?.bot.launch_profile==="agent_deck"||ag?.launchProfile==="agent_deck",{state:al,retry:am}=(0,k.useDeckList)(!!ak),an=(0,l.useRuntimeConnections)(),[ao,ap]=(0,c.useState)(void 0),[aq,ar]=(0,c.useState)("clean"),[as,at]=(0,c.useState)(""),[au,av]=(0,c.useState)(0),[aw,ax]=(0,c.useState)(null),[ay,az]=(0,c.useState)("clean"),[aA,aB]=(0,c.useState)(""),[aC,aD]=(0,c.useState)(0),{phase:aE,startImport:aF}=function(a){let[b,d]=(0,c.useState)("idle");return(0,c.useEffect)(()=>{let b=window.location.search;if(null===(0,o.importedBotId)(b))return;let c=new URL(window.location.href);c.searchParams.delete(o.IMPORT_RETURN_QUERY),window.history.replaceState(null,"",c.pathname+c.search);let e=!1;return(0,o.resolveImportReturn)(b,a,async a=>(await fetch(`/api/bots/${encodeURIComponent(a)}/config`,{cache:"no-store"})).ok).then(a=>{e||("open"===a.kind?window.location.replace(a.path):"missing"===a.kind&&d("missing"))}),()=>{e=!0}},[a]),{phase:b,startImport:async function(){d("checking");try{let a=await fetch(o.HANDOFF_STATUS_PATH,{cache:"no-store"}),b=await a.json().catch(()=>null);if(!a.ok)return void d("failed");if(b?.configured!==!0)return void d("unavailable");d("redirecting"),window.location.href=(0,o.handoffStartPath)(window.location.origin,window.location.pathname),setTimeout(()=>d(a=>"redirecting"===a?"idle":a),4e3)}catch{d("failed")}}}}(t);function aG(){D(!0),F(!1),J(a=>a+1)}(0,c.useEffect)(()=>{if(!t)return;let a=!1;return fetch(`/api/bots/${encodeURIComponent(t)}/sessions?status=all`,{cache:"no-store"}).then(a=>a.ok?a.json():null).then(b=>{a||ap((b?.sessions??[]).map(a=>({ref:a.ref,title:a.title,status:a.status})))}).catch(()=>{a||ap([])}),()=>{a=!0}},[t,I]),(0,c.useEffect)(()=>{if(!t)return;let a=!1;return fetch(`/api/bots/${encodeURIComponent(t)}/config`).then(async b=>{if(a)return;if(404===b.status){H(!0),B(null);return}if(!b.ok)throw Error("request failed");let c=await b.json();a||(B(c),L(c.bot.description??""),H(!1),F(!1))}).catch(()=>{a||F(!0)}).finally(()=>{a||D(!1)}),()=>{a=!0}},[t,I]);let aH=A?.bot.description??"",aI=null!==K&&K!==aH,aJ=A?.skill.content??"",aK=S&&U!==aJ,aL=A?(0,i.registrationFormFromBot)(A.bot):null,aM=ae&&null!==ag&&JSON.stringify(ag)!==JSON.stringify(aL),aN=A?.bot.avatar_config??(0,q.resolveAvatar)(A?.bot??{}),aO=aw??aN,aP=null!==aw&&JSON.stringify(aw)!==JSON.stringify(aN),aQ=aI||aK||aM||aP;function aR(a,b){w(b).then(b=>{b&&(ad(a),setTimeout(()=>ad(b=>b===a?"":b),2e3))})}async function aS(){if(A&&null!==K){N("saving"),P("");try{let a=await fetch("/api/bots",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:A.bot.id,description:K})});if(!a.ok){let b="request failed";try{let c=await a.json();c.error&&(b=c.error)}catch{}throw Error(b)}let b=await fetch(`/api/bots/${encodeURIComponent(t)}/config`);if(!b.ok)throw Error("request failed");B(await b.json()),N("confirmed"),R(Date.now()),setTimeout(()=>{N(a=>"confirmed"===a?"clean":a)},5e3)}catch(a){N("error"),P(a instanceof Error?a.message:"request failed")}}}function aT(){A&&(ah((0,i.registrationFormFromBot)(A.bot)),af(!0),aj(!1),ar("clean"),at(""),"agent_deck"===A.bot.launch_profile&&am(),an.retry())}function aU(){af(!1),ah(null),ar("clean"),at("")}function aV(a){ax({...aw??aN,...a}),az("clean"),aB("")}async function aW(){if(A&&aw){az("saving"),aB("");try{let a=await fetch("/api/bots",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:A.bot.id,avatar:aw})});if(!a.ok){let b="request failed";try{let c=await a.json();c.error&&(b=c.error)}catch{}throw Error(b)}let b=await fetch(`/api/bots/${encodeURIComponent(t)}/config`);if(!b.ok)throw Error("request failed");B(await b.json()),ax(null),az("confirmed"),aD(Date.now()),setTimeout(()=>{az(a=>"confirmed"===a?"clean":a)},5e3)}catch(a){az("error"),aB(a instanceof Error?a.message:"request failed")}}}async function aX(){if(A&&ag){if((0,i.hasRegistrationErrors)((0,i.registrationFormView)(ag,al,an.state))){aj(!0),ar("error"),at(r);return}ar("saving"),at("");try{let a=await fetch("/api/bots",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify((0,i.registrationPatchBody)(A.bot.id,ag))});if(!a.ok){let b="request failed";try{let c=await a.json();c.error&&(b=c.error)}catch{}throw Error(b)}let b=await fetch(`/api/bots/${encodeURIComponent(t)}/config`);if(!b.ok)throw Error("request failed");B(await b.json()),af(!1),ah(null),ar("confirmed"),av(Date.now()),setTimeout(()=>{ar(a=>"confirmed"===a?"clean":a)},5e3)}catch(a){ar("error"),at(a instanceof Error?a.message:"request failed")}}}function aY(){V(A?.skill.content??""),T(!0),X("clean"),Z("")}async function aZ(){if(A&&(U.trim()||window.confirm("Delete this skill file?"))){X("saving"),Z("");try{let a=await fetch(`/api/bots/${encodeURIComponent(t)}/skill`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:U})});if(!a.ok){let b="request failed";try{let c=await a.json();c.error&&(b=c.error)}catch{}throw Error(b)}let b=await a.json();B(a=>a?{...a,skill:b.skill,currentHash:b.currentHash}:a),T(!1),X("confirmed"),_(Date.now()),setTimeout(()=>{X(a=>"confirmed"===a?"clean":a)},5e3)}catch(a){X("error"),Z(a instanceof Error?a.message:"request failed")}}}if((0,c.useEffect)(()=>{if(!aQ)return;let a=a=>{a.preventDefault()};return window.addEventListener("beforeunload",a),()=>window.removeEventListener("beforeunload",a)},[aQ]),G)return(0,b.jsx)("div",{className:"cfg-page flex items-center justify-center",children:(0,b.jsxs)("div",{className:"text-center",children:[(0,b.jsx)("p",{className:"mb-4",children:"Agent not found."}),(0,b.jsx)(d.default,{href:"/",className:"cfg-link",children:"← Back to chat"})]})});if(C&&!A)return(0,b.jsx)("div",{className:"cfg-page",children:(0,b.jsxs)("div",{className:"max-w-6xl mx-auto space-y-6",children:[(0,b.jsx)("div",{className:"h-6 w-32 rounded animate-pulse cfg-skel"}),(0,b.jsx)("div",{className:"h-20 rounded-lg animate-pulse cfg-skel"}),(0,b.jsxs)("div",{className:"grid gap-6 lg:grid-cols-2",children:[(0,b.jsx)("div",{className:"space-y-6",children:[0,1,2].map(a=>(0,b.jsx)("div",{className:"h-48 rounded-lg animate-pulse cfg-skel"},a))}),(0,b.jsxs)("div",{className:"space-y-6",children:[(0,b.jsx)("div",{className:"h-64 rounded-lg animate-pulse cfg-skel"}),(0,b.jsx)("div",{className:"h-80 rounded-lg animate-pulse cfg-skel"})]})]})]})});if(E&&!A)return(0,b.jsx)("div",{className:"cfg-page",children:(0,b.jsxs)("div",{className:"max-w-6xl mx-auto",children:[(0,b.jsx)(d.default,{href:"/",className:"cfg-link cfg-back text-sm",children:"← Back to chat"}),(0,b.jsxs)("header",{className:"mt-3 mb-6 flex flex-wrap items-center gap-4",children:[(0,b.jsxs)("div",{className:"min-w-0",children:[(0,b.jsx)("h1",{className:"text-xl font-bold truncate",children:"Agent configuration"}),(0,b.jsx)("p",{className:"text-sm cfg-faint truncate",children:"Couldn't load agent details."})]}),(0,b.jsxs)("div",{className:"ml-auto text-right",children:[(0,b.jsxs)("p",{className:"text-sm cfg-muted",children:["Current config hash: ",(0,b.jsx)("code",{className:"cfg-code",children:"—"})]}),(0,b.jsx)("p",{className:"text-sm mt-1",children:(0,b.jsx)("span",{className:"cfg-faint",children:"○ Not loaded"})})]})]}),(0,b.jsx)("div",{className:"grid gap-6 lg:grid-cols-2 items-start",children:[["Skills","Rules","Agent","Template source"],["Launch snapshots","Avatar"]].map(a=>(0,b.jsx)("div",{className:"min-w-0 space-y-6",children:a.map(a=>(0,b.jsxs)("div",{className:"cfg-card",children:[(0,b.jsx)("h2",{className:"cfg-title mb-2",children:a}),(0,b.jsxs)("p",{className:"text-sm cfg-muted",children:["Couldn't load this section."," ",(0,b.jsx)("button",{onClick:aG,className:"cfg-link",children:"Retry"})]})]},a))},a[0]))})]})});if(!A)return null;let{bot:a$,skill:a_,currentHash:a0,snapshots:a1}=A,a2=!!(a$.source_provider||a$.template_id||a$.template_url||a$.import_schema_version||a$.import_operation_id),a3="saving"===M?(0,b.jsx)("span",{className:"text-sm cfg-faint",children:"Saving…"}):aI||"error"===M?(0,b.jsxs)("span",{className:"text-sm cfg-dirty",children:[(0,b.jsx)("span",{className:"inline-block w-2 h-2 rounded-full cfg-dot-amber mr-1"}),"Unsaved changes"]}):"confirmed"===M?(0,b.jsxs)("span",{className:"text-sm cfg-faint",children:["Saved ",v(Q)]}):(0,b.jsx)("span",{className:"text-sm cfg-faint",children:"Saved"}),a4="saving"===W?(0,b.jsx)("span",{className:"text-sm cfg-faint",children:"Saving…"}):aK||"error"===W?(0,b.jsxs)("span",{className:"text-sm cfg-dirty",children:[(0,b.jsx)("span",{className:"inline-block w-2 h-2 rounded-full cfg-dot-amber mr-1"}),"Unsaved changes"]}):"confirmed"===W?(0,b.jsxs)("span",{className:"text-sm cfg-faint",children:["Saved ",v($)]}):(0,b.jsx)("span",{className:"text-sm cfg-faint",children:"Saved"}),a5="saving"===aq?(0,b.jsx)("span",{className:"text-sm cfg-faint",children:"Saving…"}):aM||"error"===aq?(0,b.jsxs)("span",{className:"text-sm cfg-dirty",children:[(0,b.jsx)("span",{className:"inline-block w-2 h-2 rounded-full cfg-dot-amber mr-1"}),"Unsaved changes"]}):"confirmed"===aq?(0,b.jsxs)("span",{className:"text-sm cfg-faint",children:["Saved ",v(au)]}):(0,b.jsx)("span",{className:"text-sm cfg-faint",children:"Saved"}),a6="saving"===ay?(0,b.jsx)("span",{className:"text-sm cfg-faint",children:"Saving…"}):aP||"error"===ay?(0,b.jsxs)("span",{className:"text-sm cfg-dirty",children:[(0,b.jsx)("span",{className:"inline-block w-2 h-2 rounded-full cfg-dot-amber mr-1"}),"Unsaved changes"]}):"confirmed"===ay?(0,b.jsxs)("span",{className:"text-sm cfg-faint",children:["Saved ",v(aC)]}):(0,b.jsx)("span",{className:"text-sm cfg-faint",children:"Saved"});return(0,b.jsxs)("div",{className:"cfg-page",children:[(0,b.jsxs)("div",{className:"max-w-6xl mx-auto",children:[(0,b.jsx)(d.default,{href:"/",onClick:function(a){aQ&&!window.confirm("You have unsaved changes. Leave without saving?")&&a.preventDefault()},className:"cfg-link cfg-back text-sm",children:"← Back to chat"}),(0,b.jsxs)("header",{className:"mt-3 mb-6 flex flex-wrap items-center gap-4",children:[(0,b.jsx)(m.default,{bot:a$,size:48,title:`${a$.name} avatar`}),(0,b.jsxs)("div",{className:"min-w-0",children:[(0,b.jsx)("h1",{className:"text-xl font-bold truncate",children:a$.name}),(0,b.jsx)("p",{className:"text-sm cfg-faint truncate",children:a$.title||" "})]}),(0,b.jsxs)("div",{className:"ml-auto text-right",children:[(0,b.jsxs)("p",{className:"text-sm cfg-muted",children:["Current config hash:"," ",(0,b.jsx)("code",{className:"cfg-code",title:a0,children:a0.slice(0,8)})," ",(0,b.jsx)("button",{onClick:()=>aR("header",a0),className:"cfg-link text-sm",children:"header"===ac?"Copied":"Copy"})]}),(0,b.jsx)("p",{className:"text-sm mt-1",children:aQ?(0,b.jsxs)("span",{className:"cfg-dirty",children:[(0,b.jsx)("span",{className:"inline-block w-2 h-2 rounded-full cfg-dot-amber mr-1"}),"Unsaved changes"]}):(0,b.jsx)("span",{className:"cfg-faint",children:"● Saved"})})]})]}),(0,b.jsxs)("div",{className:"grid gap-6 lg:grid-cols-2 items-start","data-cfg-layout":"columns",children:[(0,b.jsxs)("div",{className:"min-w-0 space-y-6","data-cfg-column":"primary",children:[(0,b.jsxs)("section",{className:"cfg-card",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,b.jsx)("h2",{className:"cfg-title",children:"Skills"}),a4]}),"unsupported"===a_.status?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("p",{className:"text-sm cfg-muted mb-3",children:"Unsupported name"}),(0,b.jsx)("p",{className:"text-sm cfg-muted",children:"Skill files need an agent name matching /^[A-Za-z0-9_-]+$/ — this name cannot map to a skill path."})]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("p",{className:"text-sm cfg-muted mb-3",children:[a_.path," · ","present"===a_.status?"Present":"Not present"]}),S?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("textarea",{value:U,onChange:a=>V(a.target.value),rows:8,className:"cfg-input text-sm"}),"error"===W&&(0,b.jsxs)("p",{className:"mt-2 text-sm cfg-error",children:["Couldn't save: ",Y,"."," ",(0,b.jsx)("button",{onClick:aZ,className:"underline hover:no-underline",children:"Retry"})]}),(0,b.jsxs)("div",{className:"mt-3 flex gap-2",children:[(0,b.jsx)("button",{onClick:aZ,disabled:!aK||"saving"===W,className:"flex-1 sm:flex-none cfg-btn-primary text-sm",children:"saving"===W?"Saving…":"Save"}),(0,b.jsx)("button",{onClick:function(){T(!1),X("clean"),Z("")},disabled:!aK||"saving"===W,className:"flex-1 sm:flex-none cfg-btn-ghost text-sm",children:"Discard"})]})]}):"present"===a_.status?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("pre",{className:"text-sm cfg-pre max-h-64 overflow-y-auto",children:a_.content}),(0,b.jsx)("button",{onClick:aY,className:"mt-3 cfg-btn-ghost text-sm w-full sm:w-auto",children:"Edit"})]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("p",{className:"text-sm cfg-muted",children:"No skill file yet. Create SKILL.md to give this agent standing instructions."}),(0,b.jsx)("button",{onClick:aY,className:"mt-3 cfg-btn-ghost text-sm w-full sm:w-auto",children:"Create"})]}),(0,b.jsx)("p",{className:"mt-3 text-xs cfg-faint",children:"Appended verbatim as a system message at launch."})]})]}),(0,b.jsxs)("section",{className:"cfg-card",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,b.jsx)("h2",{className:"cfg-title",children:"Rules"}),a3]}),(0,b.jsx)("textarea",{value:K??"",onChange:a=>L(a.target.value),rows:8,className:"cfg-input cfg-input-sans text-sm"}),(0,b.jsx)("p",{className:"mt-2 text-xs cfg-faint",children:"Sent verbatim as the standing-rules system message on every turn. This beats the user's request for detail or length."}),"error"===M&&(0,b.jsxs)("p",{className:"mt-2 text-sm cfg-error",children:["Couldn't save: ",O,"."," ",(0,b.jsx)("button",{onClick:aS,className:"underline hover:no-underline",children:"Retry"})]}),(0,b.jsxs)("div",{className:"mt-3 flex gap-2",children:[(0,b.jsx)("button",{onClick:aS,disabled:!aI||"saving"===M,className:"flex-1 sm:flex-none cfg-btn-primary text-sm",children:"saving"===M?"Saving…":"Save"}),(0,b.jsx)("button",{onClick:function(){L(aH),N("clean"),P("")},disabled:!aI||"saving"===M,className:"flex-1 sm:flex-none cfg-btn-ghost text-sm",children:"Discard"})]})]}),(0,b.jsxs)("section",{className:"cfg-card",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,b.jsx)("h2",{className:"cfg-title",children:"Agent"}),a5]}),(()=>{if(!ae||!ag){let a=(0,i.registrationReadView)(a$,"agent_deck"===a$.launch_profile?al:null,ao);return(0,b.jsxs)("div",{"data-field":"runtime-read",children:[(0,b.jsx)("dl",{className:"text-sm",children:a.rows.map(a=>(0,b.jsxs)("div",{"data-row":a.key,className:"flex flex-col sm:flex-row sm:justify-between gap-x-4 py-1 border-t cfg-line",children:[(0,b.jsx)("dt",{className:"cfg-faint",children:a.label}),(0,b.jsx)("dd",{className:"sm:text-right break-words cfg-muted",children:a.value})]},a.key))}),a.notices.map(a=>(0,b.jsxs)("p",{className:"text-sm cfg-dirty mt-2",children:[a," ",/Settings/.test(a)?(0,b.jsx)(d.default,{href:"/settings",className:"cfg-link",children:"Open Settings"}):null]},a)),(0,b.jsx)("button",{onClick:aT,className:"mt-3 cfg-btn-ghost text-sm w-full sm:w-auto",children:"Edit"})]})}let a=(0,i.registrationFormView)(ag,al,an.state),c="agent_deck"!==a$.launch_profile||(0,h.isMigratedPending)(a$)?null:a$.deck_id;return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(j.RegistrationFields,{idPrefix:"cfg",variant:"config",form:ag,onChange:a=>{"agent_deck"===a.launchProfile&&"agent_deck"!==ag.launchProfile&&am(),ah(b=>b?{...b,...a}:b),at(""),ar(a=>"error"===a?"clean":a)},view:a,showErrors:ai,connections:an.state,onRetryConnections:an.retry,onAddConnection:an.add,deckState:al,onRetryDecks:am,savedDeckId:c,workdirPlaceholder:(0,h.defaultWorkdirFor)(a$.id),workdirHint:(0,h.configWorkdirHint)(a$.id),sessions:ao,includeHomeSession:!0}),"error"===aq&&(0,b.jsxs)("p",{className:"mt-2 text-sm cfg-error",role:"alert",children:[as===r?as:`Couldn't save: ${as}.`," ",as===r?null:(0,b.jsx)("button",{onClick:aX,className:"underline hover:no-underline",children:"Retry"})]}),(0,b.jsxs)("div",{className:"mt-3 flex gap-2",children:[(0,b.jsx)("button",{onClick:aX,disabled:!aM||"saving"===aq||a.submitDisabled,className:"flex-1 sm:flex-none cfg-btn-primary text-sm",children:"saving"===aq?"Saving…":"Save"}),(0,b.jsx)("button",{onClick:aU,disabled:"saving"===aq,className:"flex-1 sm:flex-none cfg-btn-ghost text-sm",children:aM?"Discard":"Cancel"})]})]})})()]}),(0,b.jsxs)("section",{className:"cfg-card",children:[(0,b.jsx)("h2",{className:"cfg-title mb-3",children:"Template source"}),!a2&&(0,b.jsx)("p",{className:"text-sm cfg-muted mb-3",children:"Created manually in Botmancers — no template source."}),(0,b.jsxs)("dl",{className:"text-sm",children:[(0,b.jsxs)("div",{className:"flex justify-between gap-4 py-1 border-t cfg-line",children:[(0,b.jsx)("dt",{className:"cfg-faint",children:"Source provider"}),(0,b.jsx)("dd",{className:"text-right",children:a$.source_provider??"—"})]}),(0,b.jsxs)("div",{className:"flex justify-between gap-4 py-1 border-t cfg-line",children:[(0,b.jsx)("dt",{className:"cfg-faint",children:"Template ID"}),(0,b.jsx)("dd",{className:"text-right",children:a$.template_id??"—"})]}),(0,b.jsxs)("div",{className:"flex justify-between gap-4 py-1 border-t cfg-line",children:[(0,b.jsx)("dt",{className:"cfg-faint",children:"Template URL"}),(0,b.jsx)("dd",{className:"text-right break-all",children:a$.template_url?(a=a$.template_url).startsWith("http://")||a.startsWith("https://")?(0,b.jsx)("a",{href:a$.template_url,className:"cfg-link",children:a$.template_url}):a$.template_url:"—"})]}),(0,b.jsxs)("div",{className:"flex justify-between gap-4 py-1 border-t cfg-line",children:[(0,b.jsx)("dt",{className:"cfg-faint",children:"Import schema version"}),(0,b.jsx)("dd",{className:"text-right",children:a$.import_schema_version??"—"})]}),(0,b.jsxs)("div",{className:"flex justify-between gap-4 py-1 border-t cfg-line",children:[(0,b.jsx)("dt",{className:"cfg-faint",children:"Import operation ID"}),(0,b.jsx)("dd",{className:"text-right break-all",children:a$.import_operation_id??"—"})]}),(0,b.jsxs)("div",{className:"flex justify-between gap-4 py-1 border-y cfg-line",children:[(0,b.jsx)("dt",{className:"cfg-faint",children:"Imported at"}),(0,b.jsx)("dd",{className:"text-right",children:a$.import_timestamp?u(a$.import_timestamp):"—"})]})]}),(0,b.jsx)(p,{phase:aE,onImport:()=>{aF()}})]})]}),(0,b.jsxs)("div",{className:"min-w-0 space-y-6","data-cfg-column":"secondary",children:[(0,b.jsxs)("section",{className:"cfg-card",children:[(0,b.jsx)("h2",{className:"cfg-title mb-3",children:"Launch snapshots"}),0===a1.length?(0,b.jsx)("p",{className:"text-sm cfg-muted",children:"No launches recorded yet."}):(0,b.jsx)("ul",{className:"space-y-3",children:a1.map(a=>{let c=a.hash===a0,d=!!aa[a.id];return(0,b.jsxs)("li",{className:"cfg-row",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,b.jsxs)("p",{className:"text-sm",children:[u(a.created_at)," · ",a.id.slice(0,4),a.transport?` \xb7 ${a.transport}`:null]}),(0,b.jsx)("button",{onClick:()=>ab(b=>({...b,[a.id]:!b[a.id]})),"aria-label":d?"Collapse snapshot detail":"Expand snapshot detail",className:"cfg-chevron px-1",children:d?"▾":"▸"})]}),(0,b.jsxs)("p",{className:"mt-1 text-sm",children:[(0,b.jsx)("code",{className:"cfg-code",children:a.hash.slice(0,12)})," ",(0,b.jsx)("button",{onClick:()=>aR(a.id,a.hash),className:"cfg-link text-sm",children:ac===a.id?"Copied":"Copy"})]}),(0,b.jsx)("p",{className:"mt-1 text-sm",children:c?(0,b.jsx)("span",{className:"cfg-ok",children:"● Matches current config"}):(0,b.jsx)("span",{className:"cfg-faint",children:"○ Config changed since"})}),d&&(0,b.jsxs)("div",{className:"mt-3 pt-3 border-t cfg-line text-sm",children:[(0,b.jsxs)("p",{className:"cfg-muted break-all",children:[(0,b.jsx)("span",{className:"font-medium",children:"Launch ID:"})," ",a.id]}),(0,b.jsxs)("p",{className:"mt-1 cfg-muted break-all",children:[(0,b.jsx)("span",{className:"font-medium",children:"Hash:"})," ",(0,b.jsx)("code",{className:"cfg-code",children:a.hash})]}),(0,b.jsx)("dl",{className:"mt-2",children:s.map(c=>{let d=a.snapshot[c.key];return(0,b.jsxs)("div",{className:"py-1 border-t cfg-line",children:[(0,b.jsx)("dt",{className:"cfg-faint",children:c.label}),(0,b.jsx)("dd",{className:"whitespace-pre-wrap break-words",children:null==d?(0,b.jsx)("span",{className:"cfg-faint",children:"null"}):Array.isArray(d)?0===d.length?(0,b.jsx)("span",{className:"cfg-faint",children:"(none)"}):(0,b.jsx)("span",{className:"block max-h-32 overflow-y-auto",children:d.map(a=>`- ${a}`).join("\n")}):"boolean"==typeof d?String(d):""===d?(0,b.jsx)("span",{className:"cfg-faint",children:"(empty)"}):(0,b.jsx)("span",{className:"block max-h-32 overflow-y-auto",children:d})})]},c.key)})})]})]},a.id)})})]}),(0,b.jsxs)("section",{className:"cfg-card",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,b.jsx)("h2",{className:"cfg-title",children:"Avatar"}),a6]}),(0,b.jsxs)("div",{className:"flex items-center gap-4 mb-4",children:[(0,b.jsx)(m.default,{config:aO,size:96,title:"Avatar live preview"}),(0,b.jsx)("p",{className:"text-sm cfg-muted",children:"Outline style: the color is the line color, nothing is filled. Pick an option to preview, then Save."})]}),(0,b.jsx)(n,{attribute:"color",label:"Color",options:q.AVATAR_COLORS,current:aO,onPick:aV,className:"mb-3"}),(0,b.jsx)(n,{attribute:"eyes",label:"Eyes",options:q.AVATAR_EYES,current:aO,onPick:aV,className:"mb-3"}),(0,b.jsx)(n,{attribute:"hands",label:"Hands",options:q.AVATAR_HANDS,current:aO,onPick:aV,className:"mb-3"}),(0,b.jsx)(n,{attribute:"accessory",label:"Accessory",options:q.AVATAR_ACCESSORIES,current:aO,onPick:aV}),"error"===ay&&(0,b.jsxs)("p",{className:"mt-2 text-sm cfg-error",children:["Couldn't save: ",aA,"."," ",(0,b.jsx)("button",{onClick:aW,className:"underline hover:no-underline",children:"Retry"})]}),(0,b.jsxs)("div",{className:"mt-3 flex gap-2",children:[(0,b.jsx)("button",{onClick:aW,disabled:!aP||"saving"===ay,className:"flex-1 sm:flex-none cfg-btn-primary text-sm",children:"saving"===ay?"Saving…":"Save"}),(0,b.jsx)("button",{onClick:function(){ax(null),az("clean"),aB("")},disabled:!aP||"saving"===ay,className:"flex-1 sm:flex-none cfg-btn-ghost text-sm",children:"Discard"})]})]}),(0,b.jsxs)("section",{className:"cfg-card cfg-danger","aria-labelledby":"cfg-danger-title",children:[(0,b.jsx)("h2",{id:"cfg-danger-title",className:"cfg-title mb-3",children:"Danger zone"}),(0,b.jsx)("p",{className:"text-sm cfg-muted",children:g.DELETE_REMOVES_COPY}),(0,b.jsx)("p",{className:"text-sm cfg-faint mt-2",children:g.DELETE_KEEPS_COPY}),(0,b.jsx)("button",{type:"button",onClick:()=>z(!0),className:"mt-3 delete-btn text-sm w-full sm:w-auto",children:"Delete agent"})]})]})]})]}),y?(0,b.jsx)(f.default,{ids:[a$.id],onCancel:()=>z(!1),onDeleted:a=>x.push(`/?deleted=${Math.max(a.length,1)}`)}):null]})}],25209)}];
2
+
3
+ //# sourceMappingURL=app_bots_%5Bid%5D_config_page_tsx_1e0uue9._.js.map
@@ -0,0 +1,3 @@
1
+ module.exports=[39228,22151,20851,2296,a=>{"use strict";var b=a.i(87924);let c=["hermes","cursor","claude","codex","muse"],d={hermes:"Hermes",cursor:"Cursor",claude:"Claude",codex:"Codex",muse:"Muse Code"},e="hermes";function f(a){return c.includes(String(a))?d[a]:String(a??"")}c.join("|"),a.s(["AGENTS",0,c,"AGENT_LABELS",0,d,"DEFAULT_AGENT",0,e,"agentLabel",0,f],22151);let g=c.map(a=>({value:a,label:d[a]})),h="/settings",i="Select an Agent Deck…",j="Runs use the configured Agent Deck server. Remote execution is unconfirmed — see Settings for the configured server.",k="Runs use the server above. Remote execution is unconfirmed.",l="Configure the Agent Deck server in Settings",m="Saved Agent Deck not on this server — saving keeps it unless you pick another.",n={loading:"Loading decks…",empty:"No decks on this server — add one there, then retry.",malformed:"The deck list came back unreadable. Retry — or fix the server, then retry.",unreachable:"Can't reach the Agent Deck server — fix it in Settings, then retry.",unconfigured:"No Agent Deck server set — add it in Settings."};function o(a=null){return{status:"loading",decks:[],cachedDecks:a,serverUrl:"",checkedAt:0,error:""}}function p(a){return String(a).padStart(2,"0")}function q(a){let b=new Date(a);return`${p(b.getHours())}:${p(b.getMinutes())}:${p(b.getSeconds())}`}function r(a){switch(a.status){case"loading":return"Status: ○ Checking the Agent Deck server…";case"connected":return`Status: ● Connected \xb7 ${a.decks.length} ${1===a.decks.length?"deck":"decks"} \xb7 checked ${q(a.checkedAt)}`;case"empty":return"Status: ○ Connected — no decks on this server.";case"malformed":return"Status: ○ The server returned decks this app can't read.";case"unreachable":return"Status: ○ Can't reach the Agent Deck server.";case"unconfigured":return"Status: ○ No Agent Deck server set."}}function s(a){return"connected"===a.status?null:n[a.status]}function t(a){return"empty"===a.status||"malformed"===a.status||"unreachable"===a.status}async function u(a,b,c=Date.now){let d,e;try{d=await a("/api/agent-deck/decks",{cache:"no-store"})}catch(a){return{status:"unreachable",decks:[],cachedDecks:b.cachedDecks,serverUrl:b.serverUrl,checkedAt:c(),error:a instanceof Error?a.message:String(a)}}try{e=await d.json()}catch{e=void 0}return function(a,b,c){let d="object"==typeof a.body&&null!==a.body?a.body:{},e="string"==typeof d.server_url?d.server_url:b.serverUrl,f={cachedDecks:b.cachedDecks,serverUrl:e,checkedAt:c};if("string"==typeof d.server_url&&!d.server_url.trim())return{...f,status:"unconfigured",decks:[],error:""};if(a.ok){let b=function(a){if("object"!=typeof a||null===a)return null;let b=a.decks;if(!Array.isArray(b))return null;let c=[];for(let a of b){if("object"!=typeof a||null===a)return null;let b=a.id,d=a.name;if("string"!=typeof b||!b.trim()||"string"!=typeof d||!d.trim())return null;c.push({id:b,name:d})}return c}(a.body);return b?{...f,cachedDecks:b,status:b.length>0?"connected":"empty",decks:b,error:""}:{...f,status:"malformed",decks:[],error:"Unexpected deck list shape."}}let g="string"==typeof d.error?d.error:`HTTP ${a.status}`,h="invalid-payload"===d.code||/unexpected deck payload/i.test(g);return{...f,status:h?"malformed":"unreachable",decks:[],error:g}}({ok:d.ok,status:d.status,body:e},b,c())}function v(a,b){let c=String(a??"").trim(),d=b?b.decks.length>0?b.decks:b.cachedDecks??[]:[];return d.find(a=>a.id===c)?.name??c}function w(a){return f((a.agent??"").trim()||e)}function x(a){return!y(a)&&(function(a){let b=a.needs_deck_selection;if(!0===b||1===b)return!0;if("string"==typeof b){let a=b.trim().toLowerCase();return"1"===a||"true"===a}return!1}(a)||!(a.deck_id??"").trim())}function y(a){return"direct"===a.launch_profile}function z(a,b){if(x(a)||y(a))return!1;let c=b?"connected"===b.status||"empty"===b.status?b.decks.map(a=>a.id):"unconfigured"===b.status?null:b.cachedDecks?b.cachedDecks.map(a=>a.id):null:null;return!!c&&!c.includes((a.deck_id??"").trim())}function A(a){return`Agent: ${w(a)} \xb7 Agent Deck: `}function B(a,b){let c,d=(c=y(a)?`Agent: ${w(a)} \xb7 Launch: Direct`:x(a)?`${A(a)}not selected`:A(a)+v(a.deck_id??"",b),x(a)?`${c} — select in Config`:z(a,b)?c+" (deck unavailable — see Config)":c);if(x(a)||y(a))return{prefix:d,deck:"",suffix:""};let e=A(a),f=v(a.deck_id??"",b);return{prefix:e,deck:f,suffix:d.slice(e.length+f.length)}}function C(a){return`~/.botmancers/${a}`}let D=[{prefix:"[Deck handoff]",kind:"handoff",label:"Agent Deck launch"},{prefix:"[Deck run]",kind:"run",label:"Agent Deck run"},{prefix:"[Deck review]",kind:"review",label:"Agent Deck review"},{prefix:"[Deck resume]",kind:"resume",label:"Agent Deck resume"},{prefix:"[Deck result]",kind:"result",label:"Agent Deck result"},{prefix:"[Deck failed]",kind:"failed",label:"Agent Deck failed"},{prefix:"[Deck needs selection]",kind:"reselection",label:"Agent Deck needs a deck"},{prefix:"[Deck needs reselection]",kind:"reselection",label:"Agent Deck needs a deck"}];a.s(["AGENT_OPTIONS",0,g,"DECK_PLACEHOLDER",0,i,"DECK_SLOT_COPY",0,n,"NEW_BOT_WORKDIR_HINT",0,"Default: ~/.botmancers/{agentID} — {agentID} is this agent's ID, assigned at creation.","NON_LOCAL_NOTE",0,j,"SAVED_DECK_MISSING_NOTE",0,m,"SETTINGS_ENDPOINT",0,"/api/agent-deck/settings","SETTINGS_LINK_COPY",0,l,"SETTINGS_NON_LOCAL_NOTE",0,k,"SETTINGS_PATH",0,h,"botAgentLabel",0,w,"configWorkdirHint",0,function(a){return`Default: ${C(a)} — leave blank to use it.`},"deckEventDisplay",0,function(a){let b=String(a??"").trimStart(),c=D.find(a=>b.startsWith(a.prefix));return c?{label:c.label,detail:b.slice(c.prefix.length).trim()}:null},"deckLabel",0,v,"deckSlotCopy",0,s,"deckStateShowsRetry",0,t,"defaultWorkdirFor",0,C,"fetchDeckList",0,u,"formatClock",0,q,"initialDeckListState",0,o,"isDeckUnavailable",0,z,"isMigratedPending",0,x,"rosterRuntimeParts",0,B,"settingsStatusLine",0,r],20851);let E={modal:{label:"",legend:"field-legend",picks:"runtime-picks",pick:"runtime-pick",note:"runtime-note",control:"deck-control",hint:"runtime-hint",link:"runtime-link",retry:"runtime-retry"},config:{label:"block text-sm cfg-muted mt-3 mb-1",legend:"block text-sm cfg-muted mt-3 mb-1 p-0",picks:"flex flex-wrap gap-x-4 gap-y-1 text-sm cfg-muted",pick:"text-sm cfg-muted",note:"text-sm cfg-muted mt-1",control:"cfg-input text-sm",hint:"mt-1 text-xs cfg-faint",link:"cfg-link text-sm",retry:"cfg-link text-sm"}};function F({id:a,labelId:c,state:d,value:e,onChange:f,onRetry:g,savedDeckId:h,variant:j}){let k=E[j],l=s(d),n=(h??"").trim();if(null===l){let c=!!n&&!d.decks.some(a=>a.id===n);return(0,b.jsxs)("div",{"data-field":"deck","data-state":d.status,children:[(0,b.jsxs)("select",{id:a,className:k.control,"aria-required":"true","aria-describedby":c&&e===n?`${a}-saved-note`:void 0,value:e,title:e||void 0,onChange:a=>f(a.target.value),children:[(0,b.jsx)("option",{value:"",disabled:!0,children:i}),c?(0,b.jsxs)("option",{value:n,title:n,children:[n," (saved)"]}):null,d.decks.map(a=>(0,b.jsx)("option",{value:a.id,title:a.id,children:a.name},a.id))]}),c&&e===n?(0,b.jsx)("p",{id:`${a}-saved-note`,className:k.note,children:m}):null]})}return(0,b.jsxs)("div",{"data-field":"deck","data-state":d.status,role:"group","aria-labelledby":c,children:[n?(0,b.jsxs)("p",{className:k.note,children:["Saved Agent Deck: ",(0,b.jsx)("span",{title:n,children:n})]}):null,(0,b.jsxs)("p",{id:a,className:`${k.note} deck-slot`,role:"status",children:[(0,b.jsx)("span",{id:`${a}-copy`,children:l}),t(d)?(0,b.jsxs)(b.Fragment,{children:[" ",(0,b.jsx)("button",{type:"button",className:k.retry,onClick:g,children:"Retry"})]}):null]})]})}a.s(["AgentDeckFields",0,function({idPrefix:a,variant:c,deckId:d,onDeckId:e,deckState:f,onRetry:g,savedDeckId:i,workingDirectory:k,onWorkingDirectory:m,workdirPlaceholder:n,workdirHint:o}){let p=E[c],q=null===s(f);return(0,b.jsxs)("div",{className:"agent-deck-fields",children:[(0,b.jsx)("label",{className:p.label,id:`${a}-deck-label`,htmlFor:q?`${a}-deck`:void 0,children:"Agent Deck"}),(0,b.jsx)(F,{id:`${a}-deck`,labelId:`${a}-deck-label`,state:f,value:d,onChange:e,onRetry:g,savedDeckId:i,variant:c}),(0,b.jsx)("a",{href:h,className:p.link,children:l}),(0,b.jsx)("label",{className:p.label,htmlFor:`${a}-workdir`,children:"Working directory (optional)"}),(0,b.jsx)("input",{id:`${a}-workdir`,type:"text",className:"config"===c?p.control:void 0,"data-field":"workdir","aria-describedby":`${a}-workdir-hint ${a}-workdir-note`,value:k,placeholder:n,onChange:a=>m(a.target.value)}),(0,b.jsx)("p",{id:`${a}-workdir-hint`,className:p.hint,children:o}),(0,b.jsx)("p",{id:`${a}-workdir-note`,className:p.hint,children:j})]})},"RosterRuntimeLine",0,function({bot:a,state:c}){let{prefix:d,deck:e,suffix:f}=B(a,c);return(0,b.jsxs)("div",{className:"bot-runtime",title:d+e+f,children:[d,e?(0,b.jsx)("span",{className:"bot-runtime-deck",children:e}):null,f]})},"SettingsStatus",0,function({state:a,onRetry:c}){return(0,b.jsxs)("div",{"data-field":"status","data-state":a.status,children:[(0,b.jsx)("p",{className:"connected"===a.status?"text-sm cfg-ok":"text-sm cfg-muted",role:"status",children:r(a)}),t(a)?(0,b.jsx)("button",{type:"button",onClick:c,className:"mt-2 cfg-btn-ghost text-sm w-full sm:w-auto",children:"Retry"}):null,"connected"===a.status?(0,b.jsx)("p",{className:"mt-1 text-xs cfg-faint break-words",children:a.decks.map(a=>a.name).join(" · ")}):null,(0,b.jsx)("p",{className:"mt-2 text-xs cfg-faint",children:k})]})}],39228);var G=a.i(72131);let H="botmancers.agentDeck.lastDecks";function I(a){return"object"==typeof a&&null!==a&&"string"==typeof a.id&&"string"==typeof a.name}let J=(a,b)=>{let c=new AbortController,d=setTimeout(()=>c.abort(),1e4);return fetch(a,{cache:"no-store",signal:c.signal,...b}).finally(()=>clearTimeout(d))};a.s(["useDeckList",0,function(a=!0){let[b,c]=(0,G.useState)(()=>o()),[d,e]=(0,G.useState)(0),f=(0,G.useRef)(null);return(0,G.useEffect)(()=>{if(!a)return;let b=!1;return u(J,o(f.current??function(){try{let a=window.localStorage.getItem(H);if(!a)return null;let b=JSON.parse(a);return Array.isArray(b)&&b.every(I)?b:null}catch{return null}}())).then(a=>{if(!b){f.current=a.cachedDecks;var d=a.cachedDecks;if(d)try{window.localStorage.setItem(H,JSON.stringify(d))}catch{}c(a)}}),()=>{b=!0}},[d,a]),{state:b,retry:(0,G.useCallback)(()=>{c(a=>({...a,status:"loading",decks:[],error:""})),e(a=>a+1)},[])}}],2296)}];
2
+
3
+ //# sourceMappingURL=app_components_AgentDeckRuntime_tsx_024janf._.js.map
@@ -0,0 +1,3 @@
1
+ module.exports=[27828,65221,35099,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(38246);function e(a){return`${new Date(a).toISOString().slice(0,16).replace("T"," ")} UTC`}let f="Not reported";function g(a){return a.toFixed(1).replace(/\.0$/,"")}function h(a){return a.toLocaleString("en-US")}function i(a){return 0===a?"$0.00":a>=.01?`$${a.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`:a<1e-4?"<$0.0001":`$${a.toFixed(4)}`}let j={input_tokens:"Input tokens",output_tokens:"Output tokens",cost_usd:"Cost"};function k(a,b,c){return"cost_usd"===a?i(b):c?h(b):b<1e3?String(b):b<999950?`${g(b/1e3)}k`:b<99995e4?`${g(b/1e6)}M`:`${g(b/1e9)}B`}function l(a){return`${a} ${1===a?"run":"runs"}`}function m(a,b,c=!1){let d=j[a];if(!b||"unavailable"===b.quality||null===b.sum)return{name:d,text:f,quality:"unavailable",coverage:b&&b.total>0?`0 of ${l(b.total)} reported`:"No runs recorded",label:`${d}: not reported`};let e=k(a,b.sum,c),g=k(a,b.sum,!0);return"partial"===b.quality?{name:d,text:e,quality:"partial",coverage:`Partial: ${b.known} of ${l(b.total)} reported`,label:`${d}: at least ${g}, partial, reported by ${b.known} of ${l(b.total)}`}:{name:d,text:e,quality:"complete",coverage:`All ${l(b.total)} reported`,label:`${d}: ${g}, reported by all ${l(b.total)}`}}a.s(["SESSION_FILTER_OPTIONS",0,[{value:"all",label:"All"},{value:"active",label:"Active"},{value:"ended",label:"Ended"}],"attemptLabel",0,function(a){let b="source"===a.role?"Started the session":"Resumed the session";return`${b} \xb7 ${a.outcome??"running"}`},"emptySessionsCopy",0,function(a,b){return"active"===a?`${b} has no active sessions.`:"ended"===a?`${b} has no ended sessions.`:`${b} has no sessions yet. One appears after a coding run keeps its runtime context.`},"formatSessionDate",0,e,"runtimeLabel",0,function(a){return a.agent.transport?`${a.agent.adapter} \xb7 ${a.agent.transport}`:a.agent.adapter},"sessionStateTags",0,function(a){let b=[];return(a.home&&b.push("Home"),a.state?.availability==="missing")?[...b,"Missing"]:(a.state?.lifecycle==="archived"&&b.push("Archived"),a.state?.busy&&b.push("Busy"),(a.resumable||a.state?.resumable===!0)&&b.push("Resumable"),b)},"sessionUsageLine",0,function(a){let b=m("input_tokens",a?.input_tokens),c=m("output_tokens",a?.output_tokens),d=m("cost_usd",a?.cost_usd),e=[b,c,d];if(e.every(a=>"unavailable"===a.quality))return{text:f,label:"Usage: not reported",quality:"unavailable",partial:!1};let g=["unavailable"===b.quality?"input not reported":`${b.text} in`,"unavailable"===c.quality?"output not reported":`${c.text} out`,"unavailable"===d.quality?"cost not reported":d.text].join(" · "),h=e.some(a=>"partial"===a.quality),i=h||e.some(a=>"unavailable"===a.quality)?"partial":"complete";return{text:g,label:`Reported usage: ${e.map(a=>a.label).join("; ")}`,quality:i,partial:h}},"statusLabel",0,function(a){return"active"===a.status?"Active":"Ended"},"usageMetricView",0,m,"usageSampleLabel",0,function(a,b){let c="turn"===a.kind?"start"===a.turn_kind?"provider turn, started":"provider turn":"resume"===a.turn_kind?"resumed":"started";return`Run ${b+1} \xb7 ${c}`},"usageSampleValues",0,function(a){return{input:null===a.input_tokens?f:h(a.input_tokens),output:null===a.output_tokens?f:h(a.output_tokens),cost:null===a.cost_usd?f:i(a.cost_usd)}},"workRequestLabel",0,function(a){var b;let c=a.origin.work_request;return c?`${(b=c.execution_kind)?b[0].toUpperCase()+b.slice(1):b} \xb7 ${c.state}`:null}],65221);let n={ask:"Ask from this context",resume:"Resume work here",handoff:"Hand off to…"},o=["queued","extracting","delivering","completed","failed","cancelled"],p=["completed","failed","cancelled"];function q(a){return"ask"===a?"Ask":"Continue"}function r(a,b){switch(b){case"queued":return"Queued";case"extracting":return"ask"===a?"Asking the session":"Extracting handoff";case"delivering":return"Delivering handoff";case"completed":return"ask"===a?"Answered":"Handed off";case"failed":return"Failed";case"cancelled":return"Cancelled"}}function s(a){var b;return a.cancel_requested&&(b=a.state,!p.includes(b))?"Cancelling…":r(a.mode,a.state)}function t(a){return"completed"===a?"done":"failed"===a||"cancelled"===a?"stopped":"active"}function u(a,b=140){let c=String(a??"").split("\n").map(a=>a.trim()).filter(a=>a.length>0).join(" ");return c.length>b?`${c.slice(0,b-1).trimEnd()}…`:c}function v(a){return e(a)}function w(a){return`${a.source.agent_name}'s session “${a.source.session_title}”`}function x(a){return"ask"===a.mode?`You → ${a.source.agent_name}`:`${a.source.agent_name} → ${a.destination?.agent_name??"another Agent"}`}function y(a){return"ask"===a?"Question":"Objective"}function z(a){if("completed"===a.state){if("ask"===a.mode){let b=a.origin?.label??"the origin thread";return a.outcome.answer?`Answer in ${b}: ${u(a.outcome.answer,200)}`:`Answered in ${b}.`}let b=a.destination?.agent_name??"The destination Agent";return a.outcome.reply?`${b} picked it up in a new session: ${u(a.outcome.reply,200)}`:`${b} picked it up in a new session.`}return"failed"===a.state?a.failure?.message||"The exchange failed.":"cancelled"===a.state?"Cancelled before it finished. Nothing more will run.":null}function A(a){if("failed"!==a.state)return null;switch(a.failure?.code){case"packet_invalid":case"packet_missing":return"The source session did not return a usable handoff. Start a new Continue with a clearer objective.";case"destination_session_invalid":return"The destination did not start a fresh session. Check its runtime, then start a new Continue.";case"destination_turn_failed":return"Check the destination Agent’s runtime, then start a new Continue from the source session.";case"source_turn_failed":return"Check the source Agent’s runtime, then start a new exchange from its Sessions.";default:return"Start a new exchange from the session to try again."}}function B(a){return`/exchanges?id=${encodeURIComponent(a)}`}function C(a,b){return b.updated_at-a.updated_at||b.created_at-a.created_at||(a.id<b.id?-1:+(a.id>b.id))}a.s(["DEFAULT_LEDGER_FILTER",0,{mode:"all",state:"all",agentId:""},"INSTRUCTION_LIMIT",0,4e3,"MODE_FILTER_OPTIONS",0,[{value:"all",label:"All"},{value:"ask",label:"Ask"},{value:"continue",label:"Continue"}],"STATE_FILTER_OPTIONS",0,[{value:"all",label:"Any status"},{value:"active",label:"In progress"},{value:"queued",label:"Queued"},{value:"extracting",label:"Asking / extracting"},{value:"delivering",label:"Delivering"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"},{value:"cancelled",label:"Cancelled"}],"detailsHref",0,B,"eventLabel",0,function(a,b){let c=a.data??{},d=b.source.agent_name,e=b.destination?.agent_name??"the destination Agent",f="string"==typeof c.hop?c.hop:null;switch(a.type){case"created":return"ask"===b.mode?`You asked ${d}'s session a question`:`You handed ${d}'s session to ${e}`;case"hop_queued":if("deliver"===f)return`Handoff queued for ${e}'s new session`;return"extract"===f?`Handoff extraction queued in ${d}'s session`:`Question queued for ${d}'s session`;case"hop_started":if("deliver"===f)return`${e} started a new session`;return"extract"===f?`${d}'s session started extracting the handoff`:`${d}'s session started answering`;case"state_changed":{let a="string"==typeof c.to&&o.includes(c.to)?c.to:null;return a?`Now ${r(b.mode,a).toLowerCase()}`:"State changed"}case"answer_returned":return`Answer returned to ${b.origin?.label??"the origin thread"}${c.truncated?" (shortened)":""}`;case"packet_extracted":return"Handoff packet extracted";case"packet_rejected":return`Handoff packet refused${"string"==typeof c.reason?`: ${c.reason}`:""}`;case"destination_replied":return`${e} replied in ${b.destination?.conversation?.label??"its thread"}`;case"destination_session_rejected":return`${e}'s session was not new; the handoff stopped`;case"cancel_requested":return"You asked to cancel";case"hop_result_discarded":return"A late result was discarded";default:return a.type.replace(/_/g," ")}},"excerpt",0,u,"exchangeRequestBody",0,function(a,b,c){let d={mode:a.mode,idempotency_key:c,origin_conversation_id:a.originConversationId,source:{agent_id:b.agentId,session_ref:b.sessionRef},instruction:a.instruction.trim()};return"continue"===a.mode&&(d.destination={agent_id:a.destinationAgentId}),d},"failureAdvice",0,A,"formatExchangeTime",0,v,"instructionHeading",0,y,"ledgerAgents",0,function(a){let b=new Map;for(let c of a)b.set(c.source.agent_id,c.source.agent_name),c.destination&&b.set(c.destination.agent_id,c.destination.agent_name);return[...b.entries()].map(([a,b])=>({id:a,name:b})).sort((a,b)=>a.name.localeCompare(b.name)||a.id.localeCompare(b.id))},"ledgerRows",0,function(a,b){return a.filter(a=>("all"===b.mode||a.mode===b.mode)&&("active"!==b.state||!a.terminal)&&("all"===b.state||"active"===b.state||a.state===b.state)&&(!b.agentId||a.source.agent_id===b.agentId||a.destination?.agent_id===b.agentId)).sort(C)},"ledgerView",0,function(a,b,c){return null===a?b?"error":"loading":0===a.length?"empty":0===c.length?"filtered-out":"rows"},"linkRoleLabel",0,function(a){let b={origin:"Started here",source:"Source session",destination:"Destination"};return a.map(a=>b[a]).join(" · ")},"liveStateLabel",0,s,"modeLabel",0,q,"outcomeLine",0,z,"participantsLabel",0,x,"pinRequestBody",0,function(a,b,c,d,e){return{action:a,content:b.trim(),conversation_id:c,idempotency_key:e,..."resume"===a?{approve_write:d}:{}}},"sessionDialogMode",0,function(a){return"handoff"===a?"continue":a},"sessionDialogTitle",0,function(a){return n["continue"===a?"handoff":a]},"sessionDialogUsesPin",0,function(a,b){return"resume"===a||"ask"===a&&"provider"===b},"sessionLabel",0,w,"sessionRowActions",0,function(a){let b;if(a.actions)b=a.actions;else{let c="ended"===a.status?{available:!1,reason:"Ask from this context and Hand off to… are unavailable: this session has ended. Its history stays here."}:a.resumable?{available:!0}:{available:!1,reason:`Ask from this context and Hand off to… are unavailable: Botmancers can’t resume this session under ${a.agent.name}’s current runtime.`},d=c.available?{available:!0}:{available:!1,code:"ended"===a.status?"session_ended":"session_not_resumable",reason:c.reason,recovery:"choose_session"};b={ask:d,resume:{available:!1,code:"action_unavailable",reason:`${n.resume} is unavailable: this runtime can’t resume a session with edits.`,recovery:"choose_action"},handoff:d}}return["ask","resume","handoff"].map(a=>({action:a,label:n[a],availability:b[a]}))},"stateTone",0,t,"submitErrorMessage",0,function(a,b){switch(a){case"session_ended":return"This session has ended and can’t be resumed.";case"session_not_resumable":return"Botmancers can’t resume this session under the Agent’s current runtime.";case"source_session_busy":return"This session already has an exchange in progress. Wait for it or cancel it from its card.";case"agent_unavailable":return b||"That Agent has no Agent Deck selected.";case"idempotency_conflict":return"This request changed while it was being sent. Send again.";case"session_missing":return"The runtime no longer has this session. Its history stays here; choose another session.";case"approval_required":return"Resume work here needs your approval of edits. Tick the approval, then send again.";case"authority_not_allowed":return b||"This Agent’s policy doesn’t allow edits in a resumed session. Change it in Config.";case"action_unavailable":return b||"This runtime can’t do that in this session. Choose another action.";case"provider_failed":return"The runtime failed this turn. Nothing moved to another session; try again later.";default:return b||"The exchange could not be started. Your draft is kept; try again."}},"threadHref",0,function(a,b){let c=new URLSearchParams;if(a.thread_agent_id)return c.set("agent",a.thread_agent_id),b&&c.set("exchange",b),`/?${c.toString()}`;if("group"!==a.kind)return null;b&&c.set("exchange",b);let d=c.toString();return`/threads/${encodeURIComponent(a.id)}${d?`?${d}`:""}`},"validateDraft",0,function(a){let b={},c=a.instruction.trim(),d="ask"===a.mode?"a question":"an objective";return c?a.instruction.length>4e3&&(b.instruction="Keep it under 4000 characters."):b.instruction=`Enter ${d}.`,a.originConversationId||(b.origin="Choose the thread that follows this exchange."),"continue"!==a.mode||a.destinationAgentId||(b.destination="Choose the Agent who continues the work."),b},"validateResumeDraft",0,function(a,b){let c={};return a.trim()?a.length>4e3&&(c.instruction="Keep it under 4000 characters."):c.instruction="Enter what to work on.",b||(c.approval="Approve edits in this session to resume work here."),c}],35099),a.s(["default",0,function({summary:a,onChanged:e}){let[f,g]=(0,c.useState)(!1),[h,i]=(0,c.useState)(""),j=t(a.state),k=z(a),l=A(a),m=`exchange-${a.id}-title`,n=async()=>{if(!f){g(!0),i("");try{let b=await fetch(`/api/exchanges/${encodeURIComponent(a.id)}/cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"});if(!b.ok){let a=await b.json().catch(()=>null);i("string"==typeof a?.error?.message?a.error.message:"Could not cancel. Try again.")}}catch{i("Could not cancel. Try again.")}finally{g(!1),e?.()}}};return(0,b.jsxs)("article",{id:`exchange-${a.id}`,className:`exchange-card is-${j} is-${a.state}`,"data-exchange-id":a.id,"data-exchange-state":a.state,"aria-labelledby":m,tabIndex:-1,children:[(0,b.jsxs)("p",{className:"exchange-card-line",children:[(0,b.jsx)("span",{className:"exchange-card-mode",children:q(a.mode)}),(0,b.jsx)("span",{id:m,className:"exchange-card-title",children:x(a)}),(0,b.jsx)("span",{className:"exchange-card-state",role:"status",children:s(a)})]}),(0,b.jsx)("p",{className:"exchange-card-session",children:w(a)}),(0,b.jsxs)("p",{className:"exchange-card-instruction",children:[(0,b.jsx)("span",{className:"exchange-card-key",children:y(a.mode)})," ",u(a.instruction,220)]}),k?(0,b.jsx)("p",{className:"failed"===a.state?"exchange-card-outcome is-failure":"exchange-card-outcome",children:k}):null,l?(0,b.jsx)("p",{className:"exchange-card-advice",children:l}):null,h?(0,b.jsx)("p",{className:"exchange-card-error",role:"alert",children:h}):null,(0,b.jsxs)("p",{className:"exchange-card-foot",children:[(0,b.jsxs)("span",{className:"exchange-card-time",children:["Updated ",v(a.updated_at)]}),(0,b.jsx)(d.default,{className:"exchange-card-link",href:B(a.id),"aria-label":`Details: ${q(a.mode)} ${x(a)}`,children:"Details"}),a.can_cancel?(0,b.jsx)("button",{type:"button",className:"exchange-card-cancel",disabled:f,onClick:()=>{n()},children:f?"Cancelling…":"Cancel"}):null]})]})}],27828)}];
2
+
3
+ //# sourceMappingURL=app_components_ExchangeCard_tsx_1shfcgn._.js.map
@@ -0,0 +1,3 @@
1
+ module.exports=[90730,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(38246),e=a.i(27828),f=a.i(35099);let g="botmancers:exchanges-navigate";function h(a){return window.addEventListener("popstate",a),window.addEventListener(g,a),()=>{window.removeEventListener("popstate",a),window.removeEventListener(g,a)}}function i(){return new URLSearchParams(window.location.search).get("id")}function j({id:a,onBack:g,onChanged:h}){let[i,k]=(0,c.useState)(null),[l,m]=(0,c.useState)(""),[n,o]=(0,c.useState)(0),p=(0,c.useRef)(null),q=(0,c.useRef)(!1),r=(0,c.useId)();(0,c.useEffect)(()=>{let b=!1,c=()=>{fetch(`/api/exchanges/${encodeURIComponent(a)}`,{cache:"no-store"}).then(async a=>{let c=await a.json().catch(()=>null);if(!b){if(!a.ok||!c?.detail)return void m(404===a.status?"This exchange no longer exists.":"Could not load this exchange.");m(""),k(c.detail)}}).catch(()=>{b||m("Could not load this exchange.")})};c();let d=setInterval(c,2e3);return()=>{b=!0,clearInterval(d)}},[a,n]),(0,c.useEffect)(()=>{i&&!q.current&&(q.current=!0,p.current?.focus())},[i]);let s=(0,b.jsx)("button",{type:"button",className:"pin-word ledger-detail-back",onClick:g,children:"← All exchanges"});if(!i)return(0,b.jsxs)("div",{className:"ledger-detail",children:[s,l?(0,b.jsxs)("div",{role:"alert",className:"ledger-state",children:[(0,b.jsx)("p",{className:"delete-error",children:l}),(0,b.jsx)("button",{type:"button",className:"pin-word",onClick:()=>o(a=>a+1),children:"Retry"})]}):(0,b.jsx)("p",{className:"ledger-state",role:"status",children:"Loading exchange…"})]});let{summary:t,events:u,packet:v}=i;return(0,b.jsxs)("article",{className:"ledger-detail","aria-labelledby":r,"data-exchange-detail":t.id,children:[s,(0,b.jsxs)("h2",{id:r,ref:p,tabIndex:-1,className:"ledger-detail-title",children:[(0,f.modeLabel)(t.mode),": ",(0,f.participantsLabel)(t)]}),(0,b.jsx)(e.default,{summary:t,onChanged:()=>{o(a=>a+1),h()}}),(0,b.jsxs)("section",{className:"ledger-section","aria-label":(0,f.instructionHeading)(t.mode),children:[(0,b.jsx)("h3",{className:"ledger-section-title",children:(0,f.instructionHeading)(t.mode)}),(0,b.jsx)("p",{className:"ledger-text",children:t.instruction})]}),i.answer?(0,b.jsxs)("section",{className:"ledger-section","aria-label":"Answer",children:[(0,b.jsx)("h3",{className:"ledger-section-title",children:"Answer"}),(0,b.jsx)("p",{className:"ledger-text",children:i.answer})]}):null,v?(0,b.jsxs)("section",{className:"ledger-section","aria-label":"Handoff packet",children:[(0,b.jsx)("h3",{className:"ledger-section-title",children:"Handoff packet"}),(0,b.jsx)("p",{className:"ledger-text",children:v.objective}),[["Decisions",v.decisions],["Constraints",v.constraints],["Artifacts and references",v.artifacts],["Open questions",v.open_questions]].filter(([,a])=>a.length>0).map(([a,c])=>(0,b.jsxs)("div",{className:"ledger-packet-list",children:[(0,b.jsx)("h4",{className:"ledger-packet-title",children:a}),(0,b.jsx)("ul",{children:c.map((a,c)=>(0,b.jsx)("li",{children:a},c))})]},a))]}):null,(0,b.jsxs)("section",{className:"ledger-section","aria-label":"Linked threads",children:[(0,b.jsx)("h3",{className:"ledger-section-title",children:"Linked threads"}),(0,b.jsx)("ul",{className:"ledger-links",children:t.links.map(a=>{let c=(0,f.threadHref)(a,t.id);return(0,b.jsxs)("li",{children:[c?(0,b.jsx)(d.default,{className:"session-link ledger-thread-link",href:c,children:a.label}):(0,b.jsxs)("span",{children:[a.label,"agent_api"===a.kind?(0,b.jsx)("span",{className:"ledger-link-role",children:" (between Agents, not an owner thread)"}):null]}),(0,b.jsxs)("span",{className:"ledger-link-role",children:[" · ",(0,f.linkRoleLabel)(a.roles)]})]},a.id)})})]}),(0,b.jsxs)("section",{className:"ledger-section","aria-label":"Timeline",children:[(0,b.jsx)("h3",{className:"ledger-section-title",children:"Timeline"}),(0,b.jsx)("ol",{className:"ledger-timeline",children:u.map(a=>(0,b.jsxs)("li",{"data-event-type":a.type,children:[(0,b.jsx)("span",{className:"ledger-timeline-time",children:(0,f.formatExchangeTime)(a.at)}),(0,b.jsx)("span",{className:"ledger-timeline-text",children:(0,f.eventLabel)(a,t)})]},a.sequence))})]}),(0,b.jsxs)("p",{className:"ledger-foot",children:[(0,f.excerpt)(`${t.source.agent_name}’s session: ${t.source.session_title}`,200),t.destination?.session_title?` \xb7 ${t.destination.agent_name}’s new session: ${t.destination.session_title}`:""]})]})}a.s(["default",0,function(){let[a,e]=(0,c.useState)(null),[k,l]=(0,c.useState)(""),[m,n]=(0,c.useState)(0),[o,p]=(0,c.useState)(f.DEFAULT_LEDGER_FILTER),q=(0,c.useSyncExternalStore)(h,i,()=>null),r=(0,c.useId)(),s=(0,c.useId)(),t=(0,c.useId)(),u=(0,c.useRef)(null),v=(0,c.useRef)(null);(0,c.useEffect)(()=>{let a=v.current;if(v.current=q,q||!a)return;let b=document.querySelector(`.ledger-row[data-exchange-id="${CSS.escape(a)}"]`);(b??u.current)?.focus()},[q]),(0,c.useEffect)(()=>{let a=!1,b=()=>{fetch("/api/exchanges",{cache:"no-store"}).then(async b=>{let c=await b.json().catch(()=>null);if(!a){if(!b.ok||!Array.isArray(c?.exchanges))return void l("string"==typeof c?.error?.message?c.error.message:"Could not load exchanges.");l(""),e(c.exchanges)}}).catch(()=>{a||l("Could not load exchanges.")})};b();let c=setInterval(b,2e3);return()=>{a=!0,clearInterval(c)}},[m]);let w=a=>{window.history.pushState(null,"",a?`/exchanges?id=${encodeURIComponent(a)}`:"/exchanges"),window.dispatchEvent(new Event(g))},x=a?(0,f.ledgerRows)(a,o):[],y=(0,f.ledgerView)(a,a?"":k,x),z=a?(0,f.ledgerAgents)(a):[];return(0,b.jsxs)("div",{className:q?"ledger-page has-detail":"ledger-page",children:[(0,b.jsxs)("header",{className:"ledger-head",children:[(0,b.jsx)(d.default,{href:"/",className:"cfg-link ledger-back",children:"← Back to chat"}),(0,b.jsx)("h1",{className:"ledger-title",children:"Agent Exchanges"}),(0,b.jsx)("p",{className:"ledger-sub",children:"Every Ask and Continue between Agent sessions, newest activity first."})]}),(0,b.jsxs)("main",{className:"ledger-main",children:[(0,b.jsxs)("section",{className:"ledger-list-pane","aria-labelledby":t,children:[(0,b.jsx)("h2",{id:t,ref:u,tabIndex:-1,className:"ledger-pane-title",children:"Exchanges"}),(0,b.jsxs)("div",{className:"ledger-filters",children:[(0,b.jsx)("div",{className:"sessions-filter ledger-mode",role:"group","aria-label":"Mode",children:f.MODE_FILTER_OPTIONS.map(a=>(0,b.jsx)("button",{type:"button",className:"sessions-filter-btn","aria-pressed":o.mode===a.value,onClick:()=>p(b=>({...b,mode:a.value})),children:a.label},a.value))}),(0,b.jsxs)("div",{className:"ledger-selects",children:[(0,b.jsxs)("label",{className:"ledger-select-label",htmlFor:r,children:["Status",(0,b.jsx)("select",{id:r,className:"exchange-select",value:o.state,onChange:a=>p(b=>({...b,state:a.target.value})),children:f.STATE_FILTER_OPTIONS.map(a=>(0,b.jsx)("option",{value:a.value,children:a.label},a.value))})]}),(0,b.jsxs)("label",{className:"ledger-select-label",htmlFor:s,children:["Agent",(0,b.jsxs)("select",{id:s,className:"exchange-select",value:o.agentId,onChange:a=>p(b=>({...b,agentId:a.target.value})),children:[(0,b.jsx)("option",{value:"",children:"Any Agent"}),z.map(a=>(0,b.jsx)("option",{value:a.id,children:a.name},a.id))]})]})]}),(0,b.jsx)("p",{className:"manage-count ledger-count",role:"status",children:a?`${x.length} of ${a.length} shown`:""})]}),"loading"===y?(0,b.jsx)("p",{className:"ledger-state",role:"status","data-ledger-state":"loading",children:"Loading exchanges…"}):null,"error"===y?(0,b.jsxs)("div",{className:"ledger-state",role:"alert","data-ledger-state":"error",children:[(0,b.jsx)("p",{className:"delete-error",children:k}),(0,b.jsx)("button",{type:"button",className:"pin-word",onClick:()=>{l(""),n(a=>a+1)},children:"Retry"})]}):null,"empty"===y?(0,b.jsx)("p",{className:"ledger-state","data-ledger-state":"empty",children:"No exchanges yet. Open an Agent’s Sessions and choose Ask from this context or Hand off to… to start one."}):null,"filtered-out"===y?(0,b.jsxs)("div",{className:"ledger-state","data-ledger-state":"filtered-out",children:[(0,b.jsx)("p",{children:"No exchanges match these filters."}),(0,b.jsx)("button",{type:"button",className:"pin-word",onClick:()=>p(f.DEFAULT_LEDGER_FILTER),children:"Clear filters"})]}):null,"rows"===y?(0,b.jsx)("ol",{className:"ledger-list","aria-label":"Exchanges, newest activity first",children:x.map(a=>(0,b.jsx)("li",{className:"ledger-row-item",children:(0,b.jsxs)("button",{type:"button",className:`ledger-row is-${(0,f.stateTone)(a.state)}`,"data-exchange-id":a.id,"aria-current":q===a.id?"true":void 0,onClick:()=>w(a.id),children:[(0,b.jsxs)("span",{className:"ledger-row-line",children:[(0,b.jsx)("span",{className:"exchange-card-mode",children:(0,f.modeLabel)(a.mode)}),(0,b.jsx)("span",{className:"ledger-row-who",children:(0,f.participantsLabel)(a)}),(0,b.jsx)("span",{className:"ledger-row-state",children:(0,f.liveStateLabel)(a)})]}),(0,b.jsx)("span",{className:"ledger-row-session",children:a.source.session_title}),(0,b.jsxs)("span",{className:"ledger-row-meta",children:["From ",a.origin?.label??"an unknown thread"," · Started ",(0,f.formatExchangeTime)(a.created_at)," · Updated ",(0,f.formatExchangeTime)(a.updated_at)]})]})},a.id))}):null]}),(0,b.jsx)("section",{className:"ledger-detail-pane","aria-label":"Exchange detail",children:q?(0,b.jsx)(j,{id:q,onBack:()=>w(null),onChanged:()=>n(a=>a+1)},q):(0,b.jsx)("p",{className:"ledger-state ledger-placeholder",children:"Choose an exchange to see its timeline and linked threads."})})]})]})}])}];
2
+
3
+ //# sourceMappingURL=app_exchanges_page_tsx_0j-n2a1._.js.map