@stigmer/server-slim 0.1.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 (564) hide show
  1. package/README.md +3 -0
  2. package/console/404.html +1 -0
  3. package/console/__next.__PAGE__.txt +54 -0
  4. package/console/__next._full.txt +71 -0
  5. package/console/__next._index.txt +62 -0
  6. package/console/__next._tree.txt +6 -0
  7. package/console/_next/static/GjBokeF86FffwftazOhh6/_buildManifest.js +11 -0
  8. package/console/_next/static/GjBokeF86FffwftazOhh6/_clientMiddlewareManifest.js +1 -0
  9. package/console/_next/static/GjBokeF86FffwftazOhh6/_ssgManifest.js +1 -0
  10. package/console/_next/static/chunks/0376wi8qbsw94.js +1 -0
  11. package/console/_next/static/chunks/04cglffeuwumk.js +1 -0
  12. package/console/_next/static/chunks/04d276dp3qb52.js +1 -0
  13. package/console/_next/static/chunks/05526ws9tzwim.js +1 -0
  14. package/console/_next/static/chunks/05t5235u7o-c4.js +25 -0
  15. package/console/_next/static/chunks/06fz-g9t73bd6.js +4 -0
  16. package/console/_next/static/chunks/0789xt7opwvm-.js +24 -0
  17. package/console/_next/static/chunks/07twy5plc911w.js +1 -0
  18. package/console/_next/static/chunks/08-p5zefc1rea.js +1 -0
  19. package/console/_next/static/chunks/085db4op75mf5.js +1 -0
  20. package/console/_next/static/chunks/0923388wak11-.js +1 -0
  21. package/console/_next/static/chunks/0_7s7fzux7kiv.js +1 -0
  22. package/console/_next/static/chunks/0_bjj6hug8d9a.js +1 -0
  23. package/console/_next/static/chunks/0_zscrk6o0d0-.js +1 -0
  24. package/console/_next/static/chunks/0a4x97q7frgj3.js +1 -0
  25. package/console/_next/static/chunks/0ab5jlm8l0aud.js +1 -0
  26. package/console/_next/static/chunks/0c_c2b4z1yc02.js +1 -0
  27. package/console/_next/static/chunks/0cuyycns49hl4.js +1 -0
  28. package/console/_next/static/chunks/0cz1d0mv5g_q7.js +1 -0
  29. package/console/_next/static/chunks/0d8f3-znyc_to.js +1 -0
  30. package/console/_next/static/chunks/0e-f1rkyz_u2k.js +1 -0
  31. package/console/_next/static/chunks/0ffx83gbnwq09.js +28 -0
  32. package/console/_next/static/chunks/0fyno0jk61txk.js +115 -0
  33. package/console/_next/static/chunks/0ggwoicp90w_s.js +1 -0
  34. package/console/_next/static/chunks/0h_7_i44vofe3.js +1 -0
  35. package/console/_next/static/chunks/0hagmppwo8s-f.js +1 -0
  36. package/console/_next/static/chunks/0hfvbn6c9k3pf.js +1 -0
  37. package/console/_next/static/chunks/0hw7vilkfpzlc.js +1 -0
  38. package/console/_next/static/chunks/0kb63xcvghh_3.js +1 -0
  39. package/console/_next/static/chunks/0ko5wsi6kukgd.js +1 -0
  40. package/console/_next/static/chunks/0kq99qin4db-q.js +1 -0
  41. package/console/_next/static/chunks/0kqg4u5n17gje.js +1 -0
  42. package/console/_next/static/chunks/0ky9qppyx1n57.js +62 -0
  43. package/console/_next/static/chunks/0og4_5pph-mhm.js +1 -0
  44. package/console/_next/static/chunks/0p7p-bpdrqx75.js +1 -0
  45. package/console/_next/static/chunks/0q2bnr94vvuc2.js +1 -0
  46. package/console/_next/static/chunks/0q3sxhnylk_gn.js +1 -0
  47. package/console/_next/static/chunks/0qg6l3tattq3j.js +1 -0
  48. package/console/_next/static/chunks/0qwyk_70quvjh.js +1 -0
  49. package/console/_next/static/chunks/0qzyqii8_m5r2.js +1 -0
  50. package/console/_next/static/chunks/0rlfx91598uvc.js +1 -0
  51. package/console/_next/static/chunks/0s9njms3lumhx.js +1 -0
  52. package/console/_next/static/chunks/0srualwd948m1.js +29 -0
  53. package/console/_next/static/chunks/0u4m2805tgi7x.js +1 -0
  54. package/console/_next/static/chunks/0udcs-1vq74rp.js +1 -0
  55. package/console/_next/static/chunks/0vno04lmwdchj.js +1 -0
  56. package/console/_next/static/chunks/0vt1_fu_q116n.js +1 -0
  57. package/console/_next/static/chunks/0vuq85gcb9zcl.js +1 -0
  58. package/console/_next/static/chunks/0wxazby0i4xu3.js +5 -0
  59. package/console/_next/static/chunks/0yeh2zqwmmec0.js +22 -0
  60. package/console/_next/static/chunks/0zvl88sijsrqk.js +1 -0
  61. package/console/_next/static/chunks/110bgpy30m6m6.js +1 -0
  62. package/console/_next/static/chunks/14ipylvs6qyyw.js +1 -0
  63. package/console/_next/static/chunks/1745jt9onokna.js +1 -0
  64. package/console/_next/static/chunks/177rfq0tsoku9.js +4 -0
  65. package/console/_next/static/chunks/17mfsiiquey1d.js +1 -0
  66. package/console/_next/static/chunks/197iuvi8udifl.js +1 -0
  67. package/console/_next/static/chunks/1_2-z0tjk0xio.js +1 -0
  68. package/console/_next/static/chunks/1_gh5a14dqnji.js +1 -0
  69. package/console/_next/static/chunks/1ame8n7x9g3xc.js +1 -0
  70. package/console/_next/static/chunks/1apepr-7dz16b.js +1 -0
  71. package/console/_next/static/chunks/1dtukwrl8nulc.js +1 -0
  72. package/console/_next/static/chunks/1e0br64ibniud.js +24 -0
  73. package/console/_next/static/chunks/1fm-45g777ifx.js +1 -0
  74. package/console/_next/static/chunks/1g_iha5barqef.js +1 -0
  75. package/console/_next/static/chunks/1glr_lki18csr.js +2 -0
  76. package/console/_next/static/chunks/1hl355w6m5bp5.js +1 -0
  77. package/console/_next/static/chunks/1id3p9v9v5knn.js +1 -0
  78. package/console/_next/static/chunks/1j6kp4gg0_ylt.js +80 -0
  79. package/console/_next/static/chunks/1jssq3ch7qgd6.js +60 -0
  80. package/console/_next/static/chunks/1jzfyfh-3gqlb.js +1 -0
  81. package/console/_next/static/chunks/1k3d5c49mpp-2.js +1 -0
  82. package/console/_next/static/chunks/1kte_bxw9m-ie.js +1 -0
  83. package/console/_next/static/chunks/1lw52jm27gon2.js +1 -0
  84. package/console/_next/static/chunks/1m9e28v8syzxx.js +34 -0
  85. package/console/_next/static/chunks/1mrmq_pigo_yb.js +1 -0
  86. package/console/_next/static/chunks/1muf1a96cgbv5.js +1 -0
  87. package/console/_next/static/chunks/1n1x0ykt8by6w.js +1 -0
  88. package/console/_next/static/chunks/1qu0tqybdtj0_.js +1 -0
  89. package/console/_next/static/chunks/1r8itpdfffwxa.js +1 -0
  90. package/console/_next/static/chunks/1r_opkrpbuykx.js +1 -0
  91. package/console/_next/static/chunks/1tl0h3c_bp62t.js +1 -0
  92. package/console/_next/static/chunks/1v1m1fr8f0yle.js +1 -0
  93. package/console/_next/static/chunks/1v34vj52v7q0g.js +1 -0
  94. package/console/_next/static/chunks/1wztfxoxnu5_9.js +1 -0
  95. package/console/_next/static/chunks/1x7exm5d_hhb8.js +153 -0
  96. package/console/_next/static/chunks/1xwdphzrhi9cn.js +1 -0
  97. package/console/_next/static/chunks/1yc4gdqzxa5ie.js +1 -0
  98. package/console/_next/static/chunks/1zunrzvni97zi.js +1 -0
  99. package/console/_next/static/chunks/1zv6mtmekep40.js +36 -0
  100. package/console/_next/static/chunks/2-jaie5wchnsy.js +1 -0
  101. package/console/_next/static/chunks/20aa5hen470pm.js +1 -0
  102. package/console/_next/static/chunks/2116ko93nwgx8.js +1 -0
  103. package/console/_next/static/chunks/23vk0ig36j0he.js +1 -0
  104. package/console/_next/static/chunks/245vlws7l85dk.js +1 -0
  105. package/console/_next/static/chunks/24__o4dkdytc8.js +1 -0
  106. package/console/_next/static/chunks/24iwqo9ejhxl8.js +127 -0
  107. package/console/_next/static/chunks/24o9ia1be2cze.js +1 -0
  108. package/console/_next/static/chunks/25aea0bgjydel.css +1 -0
  109. package/console/_next/static/chunks/26-p2jxr4f20d.js +1 -0
  110. package/console/_next/static/chunks/28c--yt2jaxxf.js +1 -0
  111. package/console/_next/static/chunks/28vym848oh1ng.js +1 -0
  112. package/console/_next/static/chunks/29ou6qb6p1lni.js +1 -0
  113. package/console/_next/static/chunks/2aalpmeu_tni-.js +3 -0
  114. package/console/_next/static/chunks/2c4ifddi2dal0.js +20 -0
  115. package/console/_next/static/chunks/2ckm4edha_gkb.js +43 -0
  116. package/console/_next/static/chunks/2d5ods6a8n6yd.js +1 -0
  117. package/console/_next/static/chunks/2dm5g7ylrulvb.js +15 -0
  118. package/console/_next/static/chunks/2dtosus35_o5k.js +1 -0
  119. package/console/_next/static/chunks/2e0_cm1_wv-b4.js +1 -0
  120. package/console/_next/static/chunks/2fh_0n31hibdi.js +226 -0
  121. package/console/_next/static/chunks/2fjsaw5pgjcqb.js +1 -0
  122. package/console/_next/static/chunks/2h5pk3yu15nwr.js +1 -0
  123. package/console/_next/static/chunks/2i7w4yyf77gzw.js +1 -0
  124. package/console/_next/static/chunks/2jo3q7mfk65kd.js +1 -0
  125. package/console/_next/static/chunks/2jutbapb-t64n.js +31 -0
  126. package/console/_next/static/chunks/2k6tx8-w1creu.js +148 -0
  127. package/console/_next/static/chunks/2kh_m5onqedc5.js +1 -0
  128. package/console/_next/static/chunks/2ltzdgpjq3v6a.js +1 -0
  129. package/console/_next/static/chunks/2o2ftjhtb8od3.js +2 -0
  130. package/console/_next/static/chunks/2pyn841-jq-oo.js +10 -0
  131. package/console/_next/static/chunks/2rn289343m-y_.js +139 -0
  132. package/console/_next/static/chunks/2t2l3h2w_04bb.js +1 -0
  133. package/console/_next/static/chunks/2v11hooq3xd5t.js +15 -0
  134. package/console/_next/static/chunks/2vsg5t3fnqmfn.js +1 -0
  135. package/console/_next/static/chunks/2wayafjfoiq7q.css +6 -0
  136. package/console/_next/static/chunks/2xsvteosdtsb-.js +1 -0
  137. package/console/_next/static/chunks/2y-x8nhnufxzb.js +1 -0
  138. package/console/_next/static/chunks/2za4b-si894xj.js +1 -0
  139. package/console/_next/static/chunks/3-igvp1-n4pxs.js +104 -0
  140. package/console/_next/static/chunks/3-k25f-adpe5f.js +1 -0
  141. package/console/_next/static/chunks/3-pzmot7dbrfa.js +1 -0
  142. package/console/_next/static/chunks/3-x5lrgs3wcpl.js +80 -0
  143. package/console/_next/static/chunks/30nrkrr9518_z.js +1 -0
  144. package/console/_next/static/chunks/316lh1-hzgnod.js +1 -0
  145. package/console/_next/static/chunks/31wj1au8smjge.js +1 -0
  146. package/console/_next/static/chunks/329o6uup9qmb3.js +1 -0
  147. package/console/_next/static/chunks/34_1w929-5o6r.js +287 -0
  148. package/console/_next/static/chunks/35szx1ga574xu.js +1 -0
  149. package/console/_next/static/chunks/36tg522pkl8hm.js +1 -0
  150. package/console/_next/static/chunks/37-y9fgnir35a.js +1 -0
  151. package/console/_next/static/chunks/39wss1g0ffaqt.js +1 -0
  152. package/console/_next/static/chunks/3_cv0gj1bm3l6.js +1 -0
  153. package/console/_next/static/chunks/3_f8gd_6816re.js +101 -0
  154. package/console/_next/static/chunks/3a4qfuhsxefh2.js +12 -0
  155. package/console/_next/static/chunks/3asb3ztrvogwl.js +1 -0
  156. package/console/_next/static/chunks/3bsxbw10qhvqo.js +1 -0
  157. package/console/_next/static/chunks/3by94g38ljxl1.js +1 -0
  158. package/console/_next/static/chunks/3c_6owv8m4rta.js +90 -0
  159. package/console/_next/static/chunks/3ea2eo8b5gmju.js +2 -0
  160. package/console/_next/static/chunks/3ercnb2rksl_a.js +1 -0
  161. package/console/_next/static/chunks/3esxfmmm0ypxb.js +2 -0
  162. package/console/_next/static/chunks/3exiw74xbmika.js +1 -0
  163. package/console/_next/static/chunks/3f88-tc5u2heg.js +1 -0
  164. package/console/_next/static/chunks/3f_axahrombdp.js +1 -0
  165. package/console/_next/static/chunks/3gz91kn_v2lfa.js +1 -0
  166. package/console/_next/static/chunks/3i9z3x7tka5x2.js +1 -0
  167. package/console/_next/static/chunks/3ih4kfufd47st.js +1 -0
  168. package/console/_next/static/chunks/3itfi41ayfopd.js +15 -0
  169. package/console/_next/static/chunks/3iwgig-fgcscf.js +15 -0
  170. package/console/_next/static/chunks/3jf8qh1ev3gb4.js +2 -0
  171. package/console/_next/static/chunks/3l6svfyqdsq6o.js +1 -0
  172. package/console/_next/static/chunks/3lj0i-qlb4ah2.js +64 -0
  173. package/console/_next/static/chunks/3lmx6tkunfd3u.js +1 -0
  174. package/console/_next/static/chunks/3lp4d64he__am.js +152 -0
  175. package/console/_next/static/chunks/3m_jz3b2j38nn.js +1 -0
  176. package/console/_next/static/chunks/3oe9w1b39nzmn.js +3 -0
  177. package/console/_next/static/chunks/3on7r_d8o-kna.js +1 -0
  178. package/console/_next/static/chunks/3pbpowf3kdu5z.js +119 -0
  179. package/console/_next/static/chunks/3pwwv0u29nk8c.js +23 -0
  180. package/console/_next/static/chunks/3rweyye6o1z6b.js +79 -0
  181. package/console/_next/static/chunks/3sdqgrmvxm_u4.js +201 -0
  182. package/console/_next/static/chunks/3t3vbs-x5hixj.js +1 -0
  183. package/console/_next/static/chunks/3thqnz0a5zy-h.js +9 -0
  184. package/console/_next/static/chunks/3udubdawo7583.js +1 -0
  185. package/console/_next/static/chunks/3uz4lg6e199sb.js +1 -0
  186. package/console/_next/static/chunks/3v2mkz_46uei2.js +1 -0
  187. package/console/_next/static/chunks/3w5crjmhb-3um.js +1 -0
  188. package/console/_next/static/chunks/3waxhrmr_82j5.js +93 -0
  189. package/console/_next/static/chunks/3zmlzef_jxopu.js +1 -0
  190. package/console/_next/static/chunks/3zqvalj8nr-1y.js +1 -0
  191. package/console/_next/static/chunks/40igag4gq4k0a.js +77 -0
  192. package/console/_next/static/chunks/40wq034qcdji_.js +1 -0
  193. package/console/_next/static/chunks/44crhetqymq_e.js +34 -0
  194. package/console/_next/static/chunks/44q2pv6a3w19q.js +1 -0
  195. package/console/_next/static/chunks/turbopack-2u1d16houkiyo.js +1 -0
  196. package/console/_next/static/media/GeistMono_Variable-s.p.21mfa-4xv0w3g.woff2 +0 -0
  197. package/console/_next/static/media/Geist_Variable-s.p.217kyf1h_p0cg.woff2 +0 -0
  198. package/console/_next/static/media/IBMPlexMono_Medium-s.2v25u5rd2tsaf.woff2 +0 -0
  199. package/console/_next/static/media/IBMPlexMono_Regular-s.09u63wo58kris.woff2 +0 -0
  200. package/console/_next/static/media/IBMPlexSans_Bold-s.3iicodgz0epim.woff2 +0 -0
  201. package/console/_next/static/media/IBMPlexSans_Light-s.3ntejfdcyftfg.woff2 +0 -0
  202. package/console/_next/static/media/IBMPlexSans_Medium-s.3n25cgfiu6qss.woff2 +0 -0
  203. package/console/_next/static/media/IBMPlexSans_Regular-s.2e_-c_m03txvi.woff2 +0 -0
  204. package/console/_next/static/media/IBMPlexSans_SemiBold-s.2sutjpuns2xc5.woff2 +0 -0
  205. package/console/_next/static/media/Inter_Variable-s.2-lfiv6s83kzn.woff2 +0 -0
  206. package/console/_next/static/media/Nunito_Variable-s.3r4_r9s3kxd_-.woff2 +0 -0
  207. package/console/_not-found/__next._full.txt +73 -0
  208. package/console/_not-found/__next._index.txt +62 -0
  209. package/console/_not-found/__next._not-found.__PAGE__.txt +61 -0
  210. package/console/_not-found/__next._tree.txt +5 -0
  211. package/console/_not-found.html +1 -0
  212. package/console/_not-found.txt +73 -0
  213. package/console/apple-touch-icon-dark.png +0 -0
  214. package/console/apple-touch-icon-light.png +0 -0
  215. package/console/auth/callback/__next._full.txt +82 -0
  216. package/console/auth/callback/__next._index.txt +62 -0
  217. package/console/auth/callback/__next._tree.txt +8 -0
  218. package/console/auth/callback/__next.auth.callback.__PAGE__.txt +67 -0
  219. package/console/auth/callback.html +1 -0
  220. package/console/auth/callback.txt +82 -0
  221. package/console/auth/oauth/callback/__next._full.txt +84 -0
  222. package/console/auth/oauth/callback/__next._index.txt +62 -0
  223. package/console/auth/oauth/callback/__next._tree.txt +9 -0
  224. package/console/auth/oauth/callback/__next.auth.oauth.callback.__PAGE__.txt +69 -0
  225. package/console/auth/oauth/callback.html +1 -0
  226. package/console/auth/oauth/callback.txt +84 -0
  227. package/console/brand-avatar.png +0 -0
  228. package/console/chat/__placeholder__/__next._full.txt +80 -0
  229. package/console/chat/__placeholder__/__next._index.txt +62 -0
  230. package/console/chat/__placeholder__/__next._tree.txt +8 -0
  231. package/console/chat/__placeholder__/__next.chat.$d$channel.__PAGE__.txt +65 -0
  232. package/console/chat/__placeholder__.html +1 -0
  233. package/console/chat/__placeholder__.txt +80 -0
  234. package/console/connect/__placeholder__/__next._full.txt +79 -0
  235. package/console/connect/__placeholder__/__next._index.txt +62 -0
  236. package/console/connect/__placeholder__/__next._tree.txt +8 -0
  237. package/console/connect/__placeholder__/__next.connect.$d$token.__PAGE__.txt +64 -0
  238. package/console/connect/__placeholder__.html +1 -0
  239. package/console/connect/__placeholder__.txt +79 -0
  240. package/console/conversations/__next._full.txt +79 -0
  241. package/console/conversations/__next._index.txt +62 -0
  242. package/console/conversations/__next._tree.txt +7 -0
  243. package/console/conversations/__next.conversations.__PAGE__.txt +64 -0
  244. package/console/conversations/__placeholder__/__placeholder__/__next._full.txt +83 -0
  245. package/console/conversations/__placeholder__/__placeholder__/__next._index.txt +62 -0
  246. package/console/conversations/__placeholder__/__placeholder__/__next._tree.txt +9 -0
  247. package/console/conversations/__placeholder__/__placeholder__/__next.conversations.$d$channelId.$d$key.__PAGE__.txt +68 -0
  248. package/console/conversations/__placeholder__/__placeholder__.html +1 -0
  249. package/console/conversations/__placeholder__/__placeholder__.txt +83 -0
  250. package/console/conversations.html +1 -0
  251. package/console/conversations.txt +79 -0
  252. package/console/dashboard/__next._full.txt +77 -0
  253. package/console/dashboard/__next._index.txt +62 -0
  254. package/console/dashboard/__next._tree.txt +7 -0
  255. package/console/dashboard/__next.dashboard.__PAGE__.txt +62 -0
  256. package/console/dashboard.html +1 -0
  257. package/console/dashboard.txt +77 -0
  258. package/console/desktop/billing/__next._full.txt +82 -0
  259. package/console/desktop/billing/__next._index.txt +62 -0
  260. package/console/desktop/billing/__next._tree.txt +8 -0
  261. package/console/desktop/billing/__next.desktop.billing.__PAGE__.txt +67 -0
  262. package/console/desktop/billing.html +1 -0
  263. package/console/desktop/billing.txt +82 -0
  264. package/console/embed.js +1 -0
  265. package/console/favicon-dark-16x16.png +0 -0
  266. package/console/favicon-dark-32x32.png +0 -0
  267. package/console/favicon-dark.ico +0 -0
  268. package/console/favicon-dark.svg +1 -0
  269. package/console/favicon-light-16x16.png +0 -0
  270. package/console/favicon-light-32x32.png +0 -0
  271. package/console/favicon-light.ico +0 -0
  272. package/console/favicon-light.svg +1 -0
  273. package/console/index.html +1 -0
  274. package/console/index.txt +71 -0
  275. package/console/invite/__placeholder__/__next._full.txt +80 -0
  276. package/console/invite/__placeholder__/__next._index.txt +62 -0
  277. package/console/invite/__placeholder__/__next._tree.txt +8 -0
  278. package/console/invite/__placeholder__/__next.invite.$d$token.__PAGE__.txt +65 -0
  279. package/console/invite/__placeholder__.html +1 -0
  280. package/console/invite/__placeholder__.txt +80 -0
  281. package/console/library/__next._full.txt +89 -0
  282. package/console/library/__next._index.txt +62 -0
  283. package/console/library/__next._tree.txt +7 -0
  284. package/console/library/__next.library.__PAGE__.txt +74 -0
  285. package/console/library/agents/__next._full.txt +94 -0
  286. package/console/library/agents/__next._index.txt +62 -0
  287. package/console/library/agents/__next._tree.txt +8 -0
  288. package/console/library/agents/__next.library.agents.__PAGE__.txt +79 -0
  289. package/console/library/agents/__placeholder__/__placeholder__/__next._full.txt +96 -0
  290. package/console/library/agents/__placeholder__/__placeholder__/__next._index.txt +62 -0
  291. package/console/library/agents/__placeholder__/__placeholder__/__next._tree.txt +10 -0
  292. package/console/library/agents/__placeholder__/__placeholder__/__next.library.agents.$d$org.$d$slug.__PAGE__.txt +81 -0
  293. package/console/library/agents/__placeholder__/__placeholder__.html +1 -0
  294. package/console/library/agents/__placeholder__/__placeholder__.txt +96 -0
  295. package/console/library/agents/new/__next._full.txt +99 -0
  296. package/console/library/agents/new/__next._index.txt +62 -0
  297. package/console/library/agents/new/__next._tree.txt +9 -0
  298. package/console/library/agents/new/__next.library.agents.new.__PAGE__.txt +84 -0
  299. package/console/library/agents/new.html +1 -0
  300. package/console/library/agents/new.txt +99 -0
  301. package/console/library/agents.html +1 -0
  302. package/console/library/agents.txt +94 -0
  303. package/console/library/environments/__next._full.txt +95 -0
  304. package/console/library/environments/__next._index.txt +62 -0
  305. package/console/library/environments/__next._tree.txt +8 -0
  306. package/console/library/environments/__next.library.environments.__PAGE__.txt +80 -0
  307. package/console/library/environments/__placeholder__/__placeholder__/__next._full.txt +97 -0
  308. package/console/library/environments/__placeholder__/__placeholder__/__next._index.txt +62 -0
  309. package/console/library/environments/__placeholder__/__placeholder__/__next._tree.txt +10 -0
  310. package/console/library/environments/__placeholder__/__placeholder__/__next.library.environments.$d$org.$d$slug.__PAGE__.txt +82 -0
  311. package/console/library/environments/__placeholder__/__placeholder__.html +1 -0
  312. package/console/library/environments/__placeholder__/__placeholder__.txt +97 -0
  313. package/console/library/environments/new/__next._full.txt +99 -0
  314. package/console/library/environments/new/__next._index.txt +62 -0
  315. package/console/library/environments/new/__next._tree.txt +9 -0
  316. package/console/library/environments/new/__next.library.environments.new.__PAGE__.txt +84 -0
  317. package/console/library/environments/new.html +1 -0
  318. package/console/library/environments/new.txt +99 -0
  319. package/console/library/environments.html +1 -0
  320. package/console/library/environments.txt +95 -0
  321. package/console/library/files/__next._full.txt +94 -0
  322. package/console/library/files/__next._index.txt +62 -0
  323. package/console/library/files/__next._tree.txt +8 -0
  324. package/console/library/files/__next.library.files.__PAGE__.txt +79 -0
  325. package/console/library/files.html +1 -0
  326. package/console/library/files.txt +94 -0
  327. package/console/library/plugins/__next._full.txt +94 -0
  328. package/console/library/plugins/__next._index.txt +62 -0
  329. package/console/library/plugins/__next._tree.txt +8 -0
  330. package/console/library/plugins/__next.library.plugins.__PAGE__.txt +79 -0
  331. package/console/library/plugins/__placeholder__/__placeholder__/__next._full.txt +97 -0
  332. package/console/library/plugins/__placeholder__/__placeholder__/__next._index.txt +62 -0
  333. package/console/library/plugins/__placeholder__/__placeholder__/__next._tree.txt +10 -0
  334. package/console/library/plugins/__placeholder__/__placeholder__/__next.library.plugins.$d$org.$d$slug.__PAGE__.txt +82 -0
  335. package/console/library/plugins/__placeholder__/__placeholder__.html +1 -0
  336. package/console/library/plugins/__placeholder__/__placeholder__.txt +97 -0
  337. package/console/library/plugins/upload/__next._full.txt +99 -0
  338. package/console/library/plugins/upload/__next._index.txt +62 -0
  339. package/console/library/plugins/upload/__next._tree.txt +9 -0
  340. package/console/library/plugins/upload/__next.library.plugins.upload.__PAGE__.txt +84 -0
  341. package/console/library/plugins/upload.html +1 -0
  342. package/console/library/plugins/upload.txt +99 -0
  343. package/console/library/plugins.html +1 -0
  344. package/console/library/plugins.txt +94 -0
  345. package/console/library/routines/__next._full.txt +94 -0
  346. package/console/library/routines/__next._index.txt +62 -0
  347. package/console/library/routines/__next._tree.txt +8 -0
  348. package/console/library/routines/__next.library.routines.__PAGE__.txt +79 -0
  349. package/console/library/routines/__placeholder__/__placeholder__/__next._full.txt +97 -0
  350. package/console/library/routines/__placeholder__/__placeholder__/__next._index.txt +62 -0
  351. package/console/library/routines/__placeholder__/__placeholder__/__next._tree.txt +10 -0
  352. package/console/library/routines/__placeholder__/__placeholder__/__next.library.routines.$d$org.$d$slug.__PAGE__.txt +82 -0
  353. package/console/library/routines/__placeholder__/__placeholder__.html +1 -0
  354. package/console/library/routines/__placeholder__/__placeholder__.txt +97 -0
  355. package/console/library/routines/new/__next._full.txt +98 -0
  356. package/console/library/routines/new/__next._index.txt +62 -0
  357. package/console/library/routines/new/__next._tree.txt +9 -0
  358. package/console/library/routines/new/__next.library.routines.new.__PAGE__.txt +83 -0
  359. package/console/library/routines/new.html +1 -0
  360. package/console/library/routines/new.txt +98 -0
  361. package/console/library/routines.html +1 -0
  362. package/console/library/routines.txt +94 -0
  363. package/console/library/skills/__next._full.txt +94 -0
  364. package/console/library/skills/__next._index.txt +62 -0
  365. package/console/library/skills/__next._tree.txt +8 -0
  366. package/console/library/skills/__next.library.skills.__PAGE__.txt +79 -0
  367. package/console/library/skills/__placeholder__/__placeholder__/__next._full.txt +96 -0
  368. package/console/library/skills/__placeholder__/__placeholder__/__next._index.txt +62 -0
  369. package/console/library/skills/__placeholder__/__placeholder__/__next._tree.txt +10 -0
  370. package/console/library/skills/__placeholder__/__placeholder__/__next.library.skills.$d$org.$d$slug.__PAGE__.txt +81 -0
  371. package/console/library/skills/__placeholder__/__placeholder__.html +1 -0
  372. package/console/library/skills/__placeholder__/__placeholder__.txt +96 -0
  373. package/console/library/skills/new/__next._full.txt +98 -0
  374. package/console/library/skills/new/__next._index.txt +62 -0
  375. package/console/library/skills/new/__next._tree.txt +9 -0
  376. package/console/library/skills/new/__next.library.skills.new.__PAGE__.txt +83 -0
  377. package/console/library/skills/new.html +1 -0
  378. package/console/library/skills/new.txt +98 -0
  379. package/console/library/skills.html +1 -0
  380. package/console/library/skills.txt +94 -0
  381. package/console/library.html +1 -0
  382. package/console/library.txt +89 -0
  383. package/console/login/__next._full.txt +81 -0
  384. package/console/login/__next._index.txt +62 -0
  385. package/console/login/__next._tree.txt +7 -0
  386. package/console/login/__next.login.__PAGE__.txt +66 -0
  387. package/console/login.html +1 -0
  388. package/console/login.txt +81 -0
  389. package/console/marketplace/__next._full.txt +81 -0
  390. package/console/marketplace/__next._index.txt +62 -0
  391. package/console/marketplace/__next._tree.txt +7 -0
  392. package/console/marketplace/__next.marketplace.__PAGE__.txt +66 -0
  393. package/console/marketplace.html +1 -0
  394. package/console/marketplace.txt +81 -0
  395. package/console/models/__next._full.txt +77 -0
  396. package/console/models/__next._index.txt +62 -0
  397. package/console/models/__next._tree.txt +7 -0
  398. package/console/models/__next.models.__PAGE__.txt +62 -0
  399. package/console/models.html +1 -0
  400. package/console/models.txt +77 -0
  401. package/console/oauth/slack/callback/__next._full.txt +84 -0
  402. package/console/oauth/slack/callback/__next._index.txt +62 -0
  403. package/console/oauth/slack/callback/__next._tree.txt +9 -0
  404. package/console/oauth/slack/callback/__next.oauth.slack.callback.__PAGE__.txt +69 -0
  405. package/console/oauth/slack/callback.html +1 -0
  406. package/console/oauth/slack/callback.txt +84 -0
  407. package/console/runs/__placeholder__/__next._full.txt +77 -0
  408. package/console/runs/__placeholder__/__next._index.txt +62 -0
  409. package/console/runs/__placeholder__/__next._tree.txt +8 -0
  410. package/console/runs/__placeholder__/__next.runs.$d$id.__PAGE__.txt +62 -0
  411. package/console/runs/__placeholder__.html +1 -0
  412. package/console/runs/__placeholder__.txt +77 -0
  413. package/console/sessions/__placeholder__/__next._full.txt +77 -0
  414. package/console/sessions/__placeholder__/__next._index.txt +62 -0
  415. package/console/sessions/__placeholder__/__next._tree.txt +8 -0
  416. package/console/sessions/__placeholder__/__next.sessions.$d$id.__PAGE__.txt +62 -0
  417. package/console/sessions/__placeholder__.html +1 -0
  418. package/console/sessions/__placeholder__.txt +77 -0
  419. package/console/settings/__next._full.txt +85 -0
  420. package/console/settings/__next._index.txt +62 -0
  421. package/console/settings/__next._tree.txt +7 -0
  422. package/console/settings/__next.settings.__PAGE__.txt +70 -0
  423. package/console/settings/access-history/__next._full.txt +87 -0
  424. package/console/settings/access-history/__next._index.txt +62 -0
  425. package/console/settings/access-history/__next._tree.txt +8 -0
  426. package/console/settings/access-history/__next.settings.access-history.__PAGE__.txt +72 -0
  427. package/console/settings/access-history.html +1 -0
  428. package/console/settings/access-history.txt +87 -0
  429. package/console/settings/account-preferences/__next._full.txt +87 -0
  430. package/console/settings/account-preferences/__next._index.txt +62 -0
  431. package/console/settings/account-preferences/__next._tree.txt +8 -0
  432. package/console/settings/account-preferences/__next.settings.account-preferences.__PAGE__.txt +72 -0
  433. package/console/settings/account-preferences.html +1 -0
  434. package/console/settings/account-preferences.txt +87 -0
  435. package/console/settings/api-keys/__next._full.txt +86 -0
  436. package/console/settings/api-keys/__next._index.txt +62 -0
  437. package/console/settings/api-keys/__next._tree.txt +8 -0
  438. package/console/settings/api-keys/__next.settings.api-keys.__PAGE__.txt +71 -0
  439. package/console/settings/api-keys.html +1 -0
  440. package/console/settings/api-keys.txt +86 -0
  441. package/console/settings/billing/__next._full.txt +89 -0
  442. package/console/settings/billing/__next._index.txt +62 -0
  443. package/console/settings/billing/__next._tree.txt +8 -0
  444. package/console/settings/billing/__next.settings.billing.__PAGE__.txt +74 -0
  445. package/console/settings/billing.html +1 -0
  446. package/console/settings/billing.txt +89 -0
  447. package/console/settings/channel-apps/__next._full.txt +87 -0
  448. package/console/settings/channel-apps/__next._index.txt +62 -0
  449. package/console/settings/channel-apps/__next._tree.txt +8 -0
  450. package/console/settings/channel-apps/__next.settings.channel-apps.__PAGE__.txt +72 -0
  451. package/console/settings/channel-apps.html +1 -0
  452. package/console/settings/channel-apps.txt +87 -0
  453. package/console/settings/federation-issuers/__next._full.txt +88 -0
  454. package/console/settings/federation-issuers/__next._index.txt +62 -0
  455. package/console/settings/federation-issuers/__next._tree.txt +8 -0
  456. package/console/settings/federation-issuers/__next.settings.federation-issuers.__PAGE__.txt +73 -0
  457. package/console/settings/federation-issuers.html +1 -0
  458. package/console/settings/federation-issuers.txt +88 -0
  459. package/console/settings/invitations/__next._full.txt +87 -0
  460. package/console/settings/invitations/__next._index.txt +62 -0
  461. package/console/settings/invitations/__next._tree.txt +8 -0
  462. package/console/settings/invitations/__next.settings.invitations.__PAGE__.txt +72 -0
  463. package/console/settings/invitations.html +1 -0
  464. package/console/settings/invitations.txt +87 -0
  465. package/console/settings/licenses/__next._full.txt +90 -0
  466. package/console/settings/licenses/__next._index.txt +62 -0
  467. package/console/settings/licenses/__next._tree.txt +8 -0
  468. package/console/settings/licenses/__next.settings.licenses.__PAGE__.txt +75 -0
  469. package/console/settings/licenses.html +1 -0
  470. package/console/settings/licenses.txt +90 -0
  471. package/console/settings/members/__next._full.txt +86 -0
  472. package/console/settings/members/__next._index.txt +62 -0
  473. package/console/settings/members/__next._tree.txt +8 -0
  474. package/console/settings/members/__next.settings.members.__PAGE__.txt +71 -0
  475. package/console/settings/members.html +1 -0
  476. package/console/settings/members.txt +86 -0
  477. package/console/settings/memory/__next._full.txt +86 -0
  478. package/console/settings/memory/__next._index.txt +62 -0
  479. package/console/settings/memory/__next._tree.txt +8 -0
  480. package/console/settings/memory/__next.settings.memory.__PAGE__.txt +71 -0
  481. package/console/settings/memory.html +1 -0
  482. package/console/settings/memory.txt +86 -0
  483. package/console/settings/model-catalog/__next._full.txt +89 -0
  484. package/console/settings/model-catalog/__next._index.txt +62 -0
  485. package/console/settings/model-catalog/__next._tree.txt +8 -0
  486. package/console/settings/model-catalog/__next.settings.model-catalog.__PAGE__.txt +74 -0
  487. package/console/settings/model-catalog.html +1 -0
  488. package/console/settings/model-catalog.txt +89 -0
  489. package/console/settings/notifications/__next._full.txt +89 -0
  490. package/console/settings/notifications/__next._index.txt +62 -0
  491. package/console/settings/notifications/__next._tree.txt +8 -0
  492. package/console/settings/notifications/__next.settings.notifications.__PAGE__.txt +74 -0
  493. package/console/settings/notifications.html +1 -0
  494. package/console/settings/notifications.txt +89 -0
  495. package/console/settings/oauth-apps/__next._full.txt +87 -0
  496. package/console/settings/oauth-apps/__next._index.txt +62 -0
  497. package/console/settings/oauth-apps/__next._tree.txt +8 -0
  498. package/console/settings/oauth-apps/__next.settings.oauth-apps.__PAGE__.txt +72 -0
  499. package/console/settings/oauth-apps.html +1 -0
  500. package/console/settings/oauth-apps.txt +87 -0
  501. package/console/settings/org-embedding/__next._full.txt +87 -0
  502. package/console/settings/org-embedding/__next._index.txt +62 -0
  503. package/console/settings/org-embedding/__next._tree.txt +8 -0
  504. package/console/settings/org-embedding/__next.settings.org-embedding.__PAGE__.txt +72 -0
  505. package/console/settings/org-embedding.html +1 -0
  506. package/console/settings/org-embedding.txt +87 -0
  507. package/console/settings/org-policies/__next._full.txt +87 -0
  508. package/console/settings/org-policies/__next._index.txt +62 -0
  509. package/console/settings/org-policies/__next._tree.txt +8 -0
  510. package/console/settings/org-policies/__next.settings.org-policies.__PAGE__.txt +72 -0
  511. package/console/settings/org-policies.html +1 -0
  512. package/console/settings/org-policies.txt +87 -0
  513. package/console/settings/org-preferences/__next._full.txt +87 -0
  514. package/console/settings/org-preferences/__next._index.txt +62 -0
  515. package/console/settings/org-preferences/__next._tree.txt +8 -0
  516. package/console/settings/org-preferences/__next.settings.org-preferences.__PAGE__.txt +72 -0
  517. package/console/settings/org-preferences.html +1 -0
  518. package/console/settings/org-preferences.txt +87 -0
  519. package/console/settings/org-profile/__next._full.txt +89 -0
  520. package/console/settings/org-profile/__next._index.txt +62 -0
  521. package/console/settings/org-profile/__next._tree.txt +8 -0
  522. package/console/settings/org-profile/__next.settings.org-profile.__PAGE__.txt +74 -0
  523. package/console/settings/org-profile.html +1 -0
  524. package/console/settings/org-profile.txt +89 -0
  525. package/console/settings/plans/__next._full.txt +89 -0
  526. package/console/settings/plans/__next._index.txt +62 -0
  527. package/console/settings/plans/__next._tree.txt +8 -0
  528. package/console/settings/plans/__next.settings.plans.__PAGE__.txt +74 -0
  529. package/console/settings/plans.html +1 -0
  530. package/console/settings/plans.txt +89 -0
  531. package/console/settings/service-accounts/__next._full.txt +87 -0
  532. package/console/settings/service-accounts/__next._index.txt +62 -0
  533. package/console/settings/service-accounts/__next._tree.txt +8 -0
  534. package/console/settings/service-accounts/__next.settings.service-accounts.__PAGE__.txt +72 -0
  535. package/console/settings/service-accounts.html +1 -0
  536. package/console/settings/service-accounts.txt +87 -0
  537. package/console/settings/teams/__next._full.txt +86 -0
  538. package/console/settings/teams/__next._index.txt +62 -0
  539. package/console/settings/teams/__next._tree.txt +8 -0
  540. package/console/settings/teams/__next.settings.teams.__PAGE__.txt +71 -0
  541. package/console/settings/teams.html +1 -0
  542. package/console/settings/teams.txt +86 -0
  543. package/console/settings/usage/__next._full.txt +86 -0
  544. package/console/settings/usage/__next._index.txt +62 -0
  545. package/console/settings/usage/__next._tree.txt +8 -0
  546. package/console/settings/usage/__next.settings.usage.__PAGE__.txt +71 -0
  547. package/console/settings/usage.html +1 -0
  548. package/console/settings/usage.txt +86 -0
  549. package/console/settings/vaults/__next._full.txt +86 -0
  550. package/console/settings/vaults/__next._index.txt +62 -0
  551. package/console/settings/vaults/__next._tree.txt +8 -0
  552. package/console/settings/vaults/__next.settings.vaults.__PAGE__.txt +71 -0
  553. package/console/settings/vaults.html +1 -0
  554. package/console/settings/vaults.txt +86 -0
  555. package/console/settings.html +1 -0
  556. package/console/settings.txt +85 -0
  557. package/main.js +1656 -0
  558. package/mappings.wasm +0 -0
  559. package/package.json +25 -0
  560. package/workflow-bundle-agent-execution.js +29297 -0
  561. package/workflow-bundle-evals.js +11997 -0
  562. package/workflow-bundle-grading.js +11155 -0
  563. package/workflow-bundle-routine.js +11300 -0
  564. package/workflow-worker-thread.cjs +111 -0
@@ -0,0 +1,20 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,63353,e=>{"use strict";var t=e.i(974265),s=e.i(651023),n=e.i(537097),a=e.i(893976),r=e.i(17616),l=e.i(170255),i=e.i(196716),o=e.i(373860),g=e.i(992999),d=e.i(504788),c=e.i(998127),u=e.i(476007),m=e.i(758960),x=e.i(484763),h=e.i(803874),f=e.i(891287),p=e.i(500343),b=e.i(255817),v=e.i(766330),j=e.i(205413),y=e.i(616701);function N(e,t){let s=(0,b.f)(),n=e?()=>(0,j.T)(n=>s.channel.listByAgent((0,f.f)(p.S,{agentId:e,org:t??"",pageSize:v.J,pageToken:n}))):null,{data:a,isLoading:r,isRefetching:l,error:i,refetch:o}=(0,y.f)(n,[e,t,s],[]);return{channels:a,isLoading:r,isRefetching:l,error:i,refetch:o}}var k=e.i(531245),C=e.i(966992),w=e.i(227516),S=e.i(686311),A=e.i(475254);let $=(0,A.f)("puzzle",[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]]);var T=e.i(618393);let L=(0,A.f)("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);var M=e.i(557702),R=e.i(42592),I=e.i(855811);function z({agent:e,icon:s,visibilityControl:n,versionCount:l,channelCount:i,className:o}){let g=e.metadata,d=e.spec,c=e.status?.audit?.specAudit,u=(0,R.b)(),m=c?.createdBy?.displayName||c?.createdBy?.email||"",x=c?.updatedAt?(0,r.S)(c.updatedAt):null,h=function(e,s){let n=e.spec,{getModel:a}=(0,M.f)({harness:(0,I.Y)(n)}),r=n?.runConfig?.modelName??"",l=""===r?void 0:a(r)?.displayName??r,{versionCount:i,channelCount:o}=s,g=[[(0,t.jsx)(L,{},"skill"),n?.skillRefs.length,"skill"],[(0,t.jsx)($,{},"plugin"),n?.plugins.length,"plugin"],[(0,t.jsx)(T.f,{},"server"),n?.mcpServers.length,"MCP server"],[(0,t.jsx)(k.f,{},"agent"),n?.subagents.length,"sub-agent"],[(0,t.jsx)(S.f,{},"channel"),o,"channel"],[(0,t.jsx)(w.f,{},"version"),i,"version"]];return[{icon:(0,t.jsx)(C.f,{}),label:l??"The conversation's model"},...g.filter(([,e])=>void 0!==e&&e>0).map(([e,t,s])=>{var n,a;return{icon:e,label:(n=t??0,a=s,`${n} ${a}${1===n?"":"s"}`)}})]}(e,{versionCount:l,channelCount:i});return(0,t.jsxs)("div",{className:(0,a.f)("stg:flex stg:min-w-0 stg:items-start stg:gap-4",o),children:[(0,t.jsx)("span",{className:"stg:flex stg:size-14 stg:shrink-0 stg:items-center stg:justify-center stg:overflow-hidden stg:rounded-xl stg:border stg:border-border stg:bg-muted-subtle",children:s}),(0,t.jsxs)("div",{className:"stg:min-w-0 stg:flex-1",children:[(0,t.jsxs)("div",{className:"stg:flex stg:flex-wrap stg:items-center stg:gap-2",children:[(0,t.jsx)("h2",{className:"stg:m-0 stg:truncate stg:text-xl stg:font-semibold stg:tracking-tight stg:text-foreground",children:g?.name||g?.slug}),n]}),d?.description&&(0,t.jsx)("p",{className:"stg:m-0 stg:mt-1 stg:max-w-2xl stg:text-sm stg:text-muted-foreground",children:d.description}),(0,t.jsxs)("p",{className:"stg:m-0 stg:mt-1.5 stg:flex stg:flex-wrap stg:gap-x-1.5 stg:text-xs stg:text-muted-foreground",children:[(0,t.jsxs)("span",{className:"stg:font-mono",children:[u(g?.org??""),"/",g?.slug]}),""!==m&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{"aria-hidden":"true",children:"·"}),(0,t.jsxs)("span",{children:["Made by ",m]})]}),x&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{"aria-hidden":"true",children:"·"}),(0,t.jsxs)("span",{children:["Updated ",x.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})]})]})]}),(0,t.jsx)("ul",{"aria-label":"What the agent is made of",className:"stg:m-0 stg:mt-3 stg:flex stg:list-none stg:flex-wrap stg:gap-1.5 stg:p-0",children:h.map(e=>(0,t.jsxs)("li",{className:"stg:inline-flex stg:items-center stg:gap-1.5 stg:rounded-md stg:border stg:border-border stg:px-2 stg:py-1 stg:text-xs stg:text-foreground stg:[&_svg]:size-3.5 stg:[&_svg]:text-muted-foreground",children:[e.icon,e.label]},e.label))})]})]})}var E=e.i(664659),O=e.i(107233),D=e.i(278950),W=e.i(610595),P=e.i(363077),U=e.i(846696),B=e.i(65642),F=e.i(311015),V=e.i(916624),H=e.i(699187),_=e.i(10337),q=e.i(966205),Y=e.i(616629),J=e.i(971854),K=e.i(630983),X=e.i(468806),Q=e.i(869803),G=e.i(910304),Z=e.i(421415),ee=e.i(934197),et=e.i(927056),es=e.i(586093),en=e.i(166403),ea=e.i(154752),er=e.i(937719),el=e.i(367539),ei=e.i(364802),eo=e.i(891914),eg=e.i(781836);function ed(){let e=(0,b.f)(),[t,n]=(0,s.useState)(!1),[a,r]=(0,s.useState)(null),l=(0,s.useCallback)(()=>r(null),[]);return{createChannel:(0,s.useCallback)(async t=>{n(!0),r(null);try{return await e.channel.create(t)}catch(e){throw r((0,eg.f)(e)),e}finally{n(!1)}},[e]),isPending:t,error:a,clearError:l}}var ec=e.i(118224);function eu(){let e=(0,b.f)(),[t,n]=(0,s.useState)(!1),[a,r]=(0,s.useState)(null),l=(0,s.useCallback)(()=>r(null),[]),i=(0,s.useCallback)(async e=>{n(!0),r(null);try{return await e()}catch(e){throw r((0,eg.f)(e)),e}finally{n(!1)}},[]);return{save:(0,s.useCallback)(t=>i(()=>e.channel.apply(t)),[e,i]),update:(0,s.useCallback)((t,s)=>i(()=>{var n,a;let{resource:r,paths:l}=(0,c.N)(t,ec.i,s);return e.channel.update(r,(n=l,a=s,n.flatMap(e=>{let t=em.find(t=>e===`spec.${t}`),s=void 0===t?void 0:a[t],n=void 0===s?[]:Object.keys(s);return 0===n.length?[e]:n.map(t=>`${e}.${t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}`)})))}),[e,i]),isPending:t,error:a,clearError:l}}let em=["web","slack","whatsapp"];var ex=e.i(487910);function eh(e){return e===ex.N.public?"public":"org"}function ef(e){let t=e?.spec?.type;return t?.case==="web"?t.value:void 0}function ep(e){let t=e?.status?.typeStatus;return t?.case==="web"?t.value.linkToken:""}function eb(e){let t=e?.spec,s=ef(e);return{enabled:t?.enabled??!1,audience:eh(s?.audience),allowedOrigins:s?.allowedOrigins??[],messages:{rateLimited:s?.messages?.rateLimited??"",unavailable:s?.messages?.unavailable??"",conversationEnded:s?.messages?.conversationEnded??""},vaults:(t?.vaults??[]).map(e=>({org:e.org,slug:e.slug})),runConfig:t?.runConfig?{modelName:t.runConfig.modelName,maxCostUsd:t.runConfig.maxCostUsd,maxToolRounds:t.runConfig.maxToolRounds,serviceTier:t.runConfig.serviceTier,thinkingMode:t.runConfig.thinkingMode,maxToolResultChars:t.runConfig.maxToolResultChars}:void 0}}function ev(e){return{audience:"org"===e.audience?ex.N.org:ex.N.public,allowedOrigins:[...e.allowedOrigins],messages:{rateLimited:e.messages.rateLimited,unavailable:e.messages.unavailable,conversationEnded:e.messages.conversationEnded}}}function ej(e){let t=(0,b.f)(),[n,a]=(0,s.useState)(!1),[r,l]=(0,s.useState)(null);return{rotateLink:(0,s.useCallback)(async()=>{if(e){a(!0),l(null);try{return await t.channel.rotateLink((0,f.f)(p.J,{resourceId:e}))}catch(e){throw l((0,eg.f)(e)),e}finally{a(!1)}}},[e,t]),isPending:n,error:r}}let ey={status:"na"},eN={status:"needs-credentials"};function ek(e,t){let n=(0,b.f)(),[a,r]=(0,s.useState)(ey),l=(0,s.useMemo)(()=>t.map(e=>`${e.org}/${e.slug}`).join(","),[t]),i=e&&""!==l;return((0,s.useEffect)(()=>{if(!i)return void r(ey);let e=!1;return r({status:"checking"}),(async()=>{let e=[];for(let t of l.split(",")){let[s,a]=t.split("/");try{let r=await n.vault.getByReference({org:s,slug:a});r.spec?.owner.case!=="org"&&e.push(t)}catch{e.push(t)}}return 0===e.length?{status:"ready"}:{status:"blocked",unusableVaults:e}})().then(t=>{e||r(t)}),()=>{e=!0}},[i,l,n]),e)?""===l?eN:a:ey}var eC=e.i(526584);function ew(e){let t=(0,b.f)(),s=e.spec,n=e.metadata?.org??"",a=(0,eC.D)(s),r=a?"":(0,eC.U)(s,n).join(","),l=""!==r,{data:i}=(0,y.f)(l&&void 0!==s?()=>(0,eC.j)(t,s,n):null,[l,n,r,t],null,{cacheKey:l?`run-uses-tools:${n}:${r}`:void 0});return!!a||!!l&&i}let eS={status:"checking"};var eA=e.i(244908);function e$(e,t){let n=ew(e),[a,r]=(0,s.useState)(!0===n||t),[l,i]=(0,s.useState)(!1);!0!==n||a||l||(r(!0),i(!0));let o=(0,s.useCallback)(()=>{i(!0),r(e=>!e)},[]);return(0,s.useMemo)(()=>({expanded:a,toggle:o}),[a,o])}let eT=[{id:"link",label:"Link"},{id:"embed",label:"Embed"},{id:"developer",label:"Developer"}];function eL({open:e,onOpenChange:n,agent:a,channel:r,buildChatLinkUrl:l,onChannelsChanged:i,modal:o=!0}){let g=(0,s.useId)(),d=(0,s.useCallback)(()=>{n(!1)},[n]);return(0,t.jsx)(X.f,{open:e,onOpenChange:n,modal:o,width:"lg","aria-labelledby":g,children:e&&(0,t.jsx)(eM,{agent:a,channel:r??null,buildChatLinkUrl:l,onChannelsChanged:i,onClose:d,titleId:g})})}function eM({agent:e,channel:n,buildChatLinkUrl:r,onChannelsChanged:l,onClose:i,titleId:o}){let[g,d]=(0,s.useState)(null),c=n??g,u=null===c;return(0,t.jsxs)("div",{className:"stg:flex stg:flex-col",children:[(0,t.jsxs)("div",{className:"stg:flex stg:items-start stg:justify-between stg:border-b stg:border-border stg:px-6 stg:py-4",children:[(0,t.jsxs)("div",{className:"stg:min-w-0",children:[(0,t.jsx)("h2",{id:o,className:"stg:text-base stg:font-semibold stg:text-foreground",children:u?"Create a chat link":"Chat link"}),(0,t.jsx)("p",{className:"stg:mt-0.5 stg:truncate stg:text-xs stg:text-muted-foreground",children:e.metadata?.name||e.metadata?.slug})]}),(0,t.jsx)("button",{type:"button",onClick:i,"aria-label":"Close",className:(0,a.f)("stg:rounded-md stg:p-1 stg:text-muted-foreground","stg:hover:text-foreground stg:hover:bg-accent-hover","stg:focus:outline-none stg:focus:ring-2 stg:focus:ring-ring"),children:(0,t.jsx)(eX,{})})]}),u?(0,t.jsx)(eR,{agent:e,onCreated:e=>{d(e),l?.()}}):(0,t.jsx)(eI,{agent:e,initialChannel:c,buildChatLinkUrl:r,onChannelsChanged:l}),(0,t.jsx)("div",{className:"stg:flex stg:items-center stg:justify-end stg:border-t stg:border-border stg:px-6 stg:py-3",children:(0,t.jsx)("button",{type:"button",onClick:i,className:(0,a.f)("stg:rounded-md stg:px-3 stg:py-1.5 stg:text-sm stg:font-medium",u?"stg:border stg:border-border stg:text-foreground stg:hover:bg-accent-hover":"stg:bg-primary stg:text-primary-foreground stg:hover:bg-primary-hover","stg:focus:outline-none stg:focus:ring-2 stg:focus:ring-ring stg:focus:ring-offset-2"),children:u?"Cancel":"Done"})})]})}function eR({agent:e,onCreated:n}){let r=e.metadata?.name||(e.metadata?.slug??""),l=e.metadata?.org??"",i=(0,s.useId)(),o=`${i}-name`,g=`${i}-slug`,[d,c]=(0,s.useState)(r),[u,m]=(0,s.useState)(e.metadata?.slug??""),[x,h]=(0,s.useState)("org"),p=(0,s.useRef)(!1),[b,v]=(0,s.useState)(null),[j,y]=(0,s.useState)(null),{createChannel:N,isPending:k}=ed(),C=d.trim(),w=u.length>0||C.length>0?(0,eo.N)(Z.h,(0,f.f)(Z.h,{...u.length>0&&{slug:u},...C.length>0&&{name:C}})):[],S=b??(u.length>0?(0,eo.u)(w,"slug"):null),A=C.length>0?(0,eo.u)(w,"name"):null,$=""!==C&&u.length>0&&null===S&&null===A&&!k,T=(0,s.useCallback)(e=>{c(e),p.current||(m((0,el.f)(e.trim())),v(null))},[]),L=(0,s.useCallback)(e=>{p.current=!0,m(e),v(null)},[]),M=(0,s.useCallback)(async t=>{if(t.preventDefault(),$){y(null);try{var s,a;let t,r=await N((s={...eb(null),enabled:!0,audience:x},a={name:C,slug:u},{org:t=e.metadata?.org??"",name:a?.name??"",...a?.slug?{slug:a.slug}:{},agentRef:{org:t,slug:e.metadata?.slug??""},enabled:s.enabled,web:ev(s),vaults:s.vaults.map(e=>({org:e.org,slug:e.slug})),runConfig:s.runConfig}));U.c.success("Chat link created — the link is live"),n(r)}catch(e){e instanceof G.p&&"already-exists"===e.code?v(`"${u}" is already used by another channel in ${l} — pick a different slug`):y((0,W.g)(e))}}},[$,N,e,C,u,x,l,n]);return(0,t.jsxs)("form",{onSubmit:M,className:"stg:flex stg:flex-col stg:gap-4 stg:px-6 stg:py-4",children:[(0,t.jsxs)("p",{className:"stg:text-xs stg:text-muted-foreground",children:["A chat link is its own channel to this agent: a hosted link with its own audience, embed origins, tool credentials, and visitor messages. Visitors chat on"," ",(0,t.jsx)("span",{className:"stg:font-medium",children:l}),"'s own provider keys."]}),(0,t.jsxs)("div",{className:"stg:space-y-1",children:[(0,t.jsx)("label",{htmlFor:o,className:"stg:text-xs stg:font-medium stg:text-foreground",children:"Name"}),(0,t.jsx)("input",{id:o,type:"text",value:d,onChange:e=>T(e.target.value),disabled:k,required:!0,maxLength:63,className:(0,a.f)("stg:w-full stg:rounded-md stg:border stg:bg-input-bg stg:px-2.5 stg:py-1.5 stg:text-xs stg:text-foreground","stg:placeholder:text-muted-foreground","stg:focus:outline-none stg:focus:ring-2 stg:focus:ring-ring","stg:disabled:pointer-events-none stg:disabled:opacity-50",A?"stg:border-destructive":"stg:border-border")}),A?(0,t.jsx)("p",{className:"stg:text-2xs stg:text-destructive",role:"alert",children:A}):(0,t.jsx)("p",{className:"stg:text-2xs stg:text-muted-foreground",children:"A display name for this chat link — e.g. the site or campaign it serves."})]}),(0,t.jsxs)("div",{className:"stg:space-y-1",children:[(0,t.jsx)("label",{htmlFor:g,className:"stg:text-xs stg:font-medium stg:text-foreground",children:"Slug"}),(0,t.jsx)("input",{id:g,type:"text",value:u,onChange:e=>L(e.target.value),disabled:k,required:!0,className:(0,a.f)("stg:w-full stg:rounded-md stg:border stg:bg-input-bg stg:px-2.5 stg:py-1.5 stg:font-mono stg:text-xs stg:text-foreground","stg:placeholder:text-muted-foreground","stg:focus:outline-none stg:focus:ring-2 stg:focus:ring-ring","stg:disabled:pointer-events-none stg:disabled:opacity-50",S?"stg:border-destructive":"stg:border-border")}),S?(0,t.jsx)("p",{className:"stg:text-2xs stg:text-destructive",role:"alert",children:S}):(0,t.jsx)("p",{className:"stg:text-2xs stg:text-muted-foreground",children:"Names this chat link in the CLI and API. The link itself is made when you create it."})]}),(0,t.jsxs)("div",{className:"stg:space-y-1",children:[(0,t.jsx)("span",{className:"stg:block stg:text-xs stg:font-medium stg:text-foreground",children:"Who can chat"}),(0,t.jsx)(eO,{audience:x,onChange:h,disabled:k}),(0,t.jsx)("p",{className:"stg:text-2xs stg:text-muted-foreground",children:"org"===x?"Only signed-in members of the organization can chat. You can change this later.":"Anyone who has the link can chat, without signing in. You can change this later."})]}),j&&(0,t.jsx)("p",{className:"stg:text-xs stg:text-destructive",role:"alert",children:j}),(0,t.jsx)("div",{className:"stg:flex stg:items-center stg:justify-end",children:(0,t.jsx)("button",{type:"submit",disabled:!$,className:(0,a.f)("stg:rounded-md stg:px-3 stg:py-1.5 stg:text-sm stg:font-medium","stg:bg-primary stg:text-primary-foreground stg:hover:bg-primary-hover","stg:focus:outline-none stg:focus:ring-2 stg:focus:ring-ring stg:focus:ring-offset-2","stg:disabled:pointer-events-none stg:disabled:opacity-50"),children:k?"Creating…":"Create chat link"})})]})}function eI({agent:e,initialChannel:n,buildChatLinkUrl:a,onChannelsChanged:r}){let l=e.metadata?.name||(e.metadata?.slug??""),i=(0,s.useId)(),[o,g]=(0,s.useState)(n),[d,c]=(0,s.useState)(()=>eb(n)),[u,m]=(0,s.useState)("link"),{update:x,isPending:h}=eu(),{rotateLink:f,isPending:p}=ej(o.metadata?.id??null),b=o.metadata?.id??"",v=o.metadata?.org??"",j=o.metadata?.slug??"",y=ep(o),N=(0,s.useCallback)(async(e,t)=>{try{let s,n,a,l=await x(o,(s=new Set((void 0)??["enabled","audience","allowedOrigins","messages","vaults","runConfig"]),n=ev(e),a={...s.has("audience")&&{audience:n.audience},...s.has("allowedOrigins")&&{allowedOrigins:n.allowedOrigins},...s.has("messages")&&{messages:n.messages}},{...s.has("enabled")&&{enabled:e.enabled},...Object.keys(a).length>0&&{web:a},...s.has("vaults")&&{vaults:e.vaults.map(e=>({org:e.org,slug:e.slug}))},...s.has("runConfig")&&{runConfig:e.runConfig}}));return g(l),c(eb(l)),U.c.success(t),r?.(),!0}catch(e){return U.c.error((0,W.g)(e)),!1}},[x,o,r]),k=(0,s.useCallback)(async()=>{try{let e=await f();e&&g(e),U.c.success("Link reset — the old link no longer works"),r?.()}catch(e){U.c.error((0,W.g)(e))}},[f,r]),C=(0,s.useCallback)(e=>{N({...d,enabled:e},e?"Chat link resumed":"Chat link paused")},[N,d]),w=(0,s.useCallback)(e=>{if(e===d.audience)return;let t="org"===e&&d.vaults.length>0;N({...d,audience:e,vaults:t?[]:d.vaults},"org"===e?t?"Only organization members can chat now — tool credential bindings were removed (they apply to public links only)":"Only organization members can chat now":"Anyone with the link can chat now")},[N,d]),S="org"===d.audience,A=a?a(b):(0,D.o)(b),$=S?A:(0,D._)(A,y);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"stg:border-b stg:border-border stg:px-6 stg:py-4",children:[(0,t.jsxs)("div",{className:"stg:flex stg:items-start stg:justify-between stg:gap-4",children:[(0,t.jsxs)("div",{className:"stg:min-w-0",children:[(0,t.jsx)("span",{id:i,className:"stg:text-sm stg:font-medium stg:text-foreground",children:S?"Organization members can chat":"Anyone with the link can chat"}),(0,t.jsx)(eD,{org:v,audience:d.audience})]}),(0,t.jsx)(ee.f,{checked:d.enabled,onCheckedChange:C,disabled:h,"aria-labelledby":i})]}),(0,t.jsx)(eO,{audience:d.audience,onChange:w,disabled:h,className:"stg:mt-3"}),(0,t.jsx)(ez,{agent:e,draft:d})]}),(0,t.jsx)("div",{className:"stg:px-6 stg:pb-2 stg:pt-3",children:(0,t.jsx)(et.f,{tabs:eT,activeTab:u,onTabChange:m,"aria-label":"Chat link options",children:(0,t.jsxs)("div",{className:"stg:pt-4",children:["link"===u&&(0,t.jsx)(eP,{linkUrl:$,org:v,agent:e,enabled:d.enabled,draft:d,isPending:h,commit:N,hasLinkToken:""!==y,isRotating:p,onResetLink:k}),"embed"===u&&(0,t.jsx)(eF,{linkUrl:$,channelId:b,agentName:l,linkToken:y,enabled:d.enabled,draft:d,isPending:h,commit:N}),"developer"===u&&(0,t.jsx)(eJ,{org:v,slug:j})]})})})]})}function ez({agent:e,draft:s}){let n,a,r,l,i=(n=(0,J.T)(),a=ew(e),l=ek((r=s.enabled&&"public"===s.audience&&"cloud"===n)&&!0===a,s.vaults),r&&null===a?eS:l);if("needs-credentials"===i.status)return(0,t.jsxs)("p",{className:"stg:mt-2 stg:text-xs stg:text-status-degraded",role:"status",children:["Visitors' chats can't use this agent's tools yet: this chat link names no vault. Name a shared vault under"," ",(0,t.jsx)("span",{className:"stg:font-medium",children:"Tool credentials"})," in the Link tab below."]});if("blocked"!==i.status)return null;let o=i.unusableVaults.join(", "),g=i.unusableVaults.length>1;return(0,t.jsxs)("p",{className:"stg:mt-2 stg:text-xs stg:text-status-degraded",role:"status",children:["Visitors' chats can't use this agent's tools yet: the vault",g?"s":""," ",(0,t.jsx)("span",{className:"stg:font-medium",children:o})," ",g?"are":"is"," not a shared vault you can read. Name a shared vault instead (Settings → Vaults). Saved values stay hidden either way."]})}let eE=[{value:"org",label:"Organization members"},{value:"public",label:"Anyone with the link"}];function eO({audience:e,onChange:s,disabled:n,className:r}){return(0,t.jsx)("div",{role:"radiogroup","aria-label":"Who can chat",className:(0,a.f)("stg:inline-flex stg:rounded-md stg:border stg:border-border stg:p-0.5",r),children:eE.map(({value:r,label:l})=>{let i=e===r;return(0,t.jsx)("button",{type:"button",role:"radio","aria-checked":i,onClick:()=>s(r),disabled:n,className:(0,a.f)("stg:rounded stg:px-2.5 stg:py-1 stg:text-xs stg:font-medium","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring","stg:disabled:pointer-events-none stg:disabled:opacity-50",i?"stg:bg-primary stg:text-primary-foreground":"stg:text-muted-foreground stg:hover:text-foreground"),children:l},r)})})}function eD({org:e,audience:s}){let n=(0,R.b)();return(0,t.jsxs)("p",{className:"stg:mt-0.5 stg:text-xs stg:text-muted-foreground",children:["org"===s?"Members":"Visitors"," chat on"," ",(0,t.jsx)("span",{className:"stg:font-medium",children:n(e)}),"'s own provider keys."]})}function eW({subject:e}){return(0,t.jsxs)("p",{className:"stg:text-xs stg:text-muted-foreground",role:"status",children:["This chat link is paused, so ",e," doesn't work yet — turn on the switch above to resume it."]})}function eP({linkUrl:e,org:s,agent:n,enabled:a,draft:r,isPending:l,commit:i,hasLinkToken:o,isRotating:g,onResetLink:d}){let c=(0,R.b)(),u="org"===r.audience;return(0,t.jsxs)("div",{className:"stg:flex stg:flex-col stg:gap-4",children:[(0,t.jsx)(eK,{label:u?"Member chat link":"Public chat link",value:e,copyLabel:"Link",disabled:!a,openHref:a?e:void 0}),!a&&(0,t.jsx)(eW,{subject:"this link"}),u?(0,t.jsxs)("p",{className:"stg:text-xs stg:text-muted-foreground",children:["Only signed-in members of ",(0,t.jsx)("span",{className:"stg:font-medium",children:c(s)})," ","can chat. Access is checked on every message, so it ends the moment someone leaves the organization. The link is safe to forward — it shows nothing to anyone else."]}):(0,t.jsx)("p",{className:"stg:text-xs stg:text-status-degraded",children:"Public links can be forwarded and indexed by search engines. Don't make public links to agents that know internal or confidential information — or switch the audience to organization members."}),!u&&(0,t.jsx)(eU,{enabled:a,hasLinkToken:o,isRotating:g,onResetLink:d}),!u&&(0,t.jsx)(eB,{org:s,agent:n,draft:r,isPending:l,commit:i}),(0,t.jsx)(eq,{draft:r,isPending:l,commit:i})]})}function eU({enabled:e,hasLinkToken:s,isRotating:n,onResetLink:r}){return(0,t.jsx)("section",{className:(0,a.f)(!e&&"stg:opacity-50"),children:(0,t.jsxs)("div",{className:"stg:flex stg:items-start stg:justify-between stg:gap-4",children:[(0,t.jsxs)("div",{className:"stg:min-w-0",children:[(0,t.jsx)("h3",{className:"stg:text-xs stg:font-medium stg:text-muted-foreground",children:"Reset link"}),(0,t.jsx)("p",{className:"stg:mt-0.5 stg:text-2xs stg:text-muted-foreground",children:s?"Generates a new link and kills the current one immediately — even mid-conversation. Send the new link to the people who should keep access.":"Got forwarded further than you wanted? Resetting locks the link behind a secret and kills the plain address immediately."})]}),(0,t.jsx)("button",{type:"button",onClick:r,disabled:!e||n,className:(0,a.f)("stg:shrink-0 stg:rounded-md stg:px-2.5 stg:py-1.5 stg:text-xs stg:font-medium","stg:border stg:border-border stg:text-foreground stg:hover:bg-accent-hover","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring","stg:disabled:pointer-events-none stg:disabled:opacity-50"),children:n?"Resetting…":"Reset link"})]})})}function eB({org:e,agent:n,draft:r,isPending:l,commit:i}){let{expanded:o,toggle:g}=e$(n,r.vaults.length>0),d=(0,s.useCallback)(e=>{let t=e.length>r.vaults.length;i({...r,vaults:e},t?"Vault added":"Vaults updated")},[i,r]);return(0,t.jsxs)("section",{children:[(0,t.jsxs)("button",{type:"button",onClick:g,"aria-expanded":o,className:(0,a.f)("stg:inline-flex stg:items-center stg:gap-1 stg:text-xs stg:font-medium stg:text-muted-foreground","stg:hover:text-foreground","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring stg:rounded"),children:[(0,t.jsx)(eG,{className:(0,a.f)("stg:size-3 stg:transition-transform",o&&"stg:rotate-90")}),"Tool credentials"]}),o&&(0,t.jsxs)("div",{className:"stg:mt-2 stg:flex stg:flex-col stg:gap-2",children:[(0,t.jsx)("p",{className:"stg:text-2xs stg:text-muted-foreground",children:"Shared vaults whose keys visitors' chats use — name one holding the keys this agent's tools need (a read-only token is safest). You can name only vaults you may use; create one in Settings → Vaults. Saved values stay hidden from visitors."}),(0,t.jsx)(er.f,{org:e,value:r.vaults,onChange:d,disabled:l})]})]})}function eF({linkUrl:e,channelId:n,agentName:a,linkToken:r,enabled:l,draft:i,isPending:o,commit:g}){let d=(0,s.useMemo)(()=>(0,D.y)(function(e){try{return new URL(e).origin}catch{return""}}(e),n,r||void 0),[e,n,r]);return"org"===i.audience?(0,t.jsxs)("p",{className:"stg:text-xs stg:text-muted-foreground",role:"status",children:["Embedding isn't available while only organization members can chat: embeds serve anonymous visitors, and this link requires a signed-in organization member. Switch the audience to"," ",(0,t.jsx)("span",{className:"stg:font-medium",children:"Anyone with the link"})," to embed it on a site."]}):(0,t.jsxs)("div",{className:"stg:flex stg:flex-col stg:gap-4",children:[(0,t.jsx)(eK,{label:"Embed on your site",value:d,copyLabel:"Embed code",disabled:!l,multiline:!0}),!l&&(0,t.jsx)(eW,{subject:"this embed"}),(0,t.jsx)("p",{className:"stg:text-xs stg:text-muted-foreground",children:'The widget hides itself on sites that aren\'t allowed to embed this agent. Free embeds show a "Powered by Stigmer" badge.'}),(0,t.jsx)(eH,{draft:i,isPending:o,commit:g}),(0,t.jsx)(eV,{linkUrl:e,agentName:a,enabled:l})]})}function eV({linkUrl:e,agentName:n,enabled:r}){let[l,i]=(0,s.useState)(!1),o=(0,s.useMemo)(()=>`<iframe
2
+ src="${e}"
3
+ title="${n}"
4
+ width="400"
5
+ height="600"
6
+ style="border: 0; border-radius: 12px;"
7
+ ></iframe>`,[e,n]);return(0,t.jsxs)("section",{children:[(0,t.jsxs)("button",{type:"button",onClick:()=>i(e=>!e),"aria-expanded":l,className:(0,a.f)("stg:inline-flex stg:items-center stg:gap-1 stg:text-xs stg:font-medium stg:text-muted-foreground","stg:hover:text-foreground","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring stg:rounded"),children:[(0,t.jsx)(eG,{className:(0,a.f)("stg:size-3 stg:transition-transform",l&&"stg:rotate-90")}),"No-JavaScript alternative"]}),l&&(0,t.jsxs)("div",{className:"stg:mt-2 stg:flex stg:flex-col stg:gap-2",children:[(0,t.jsx)("p",{className:"stg:text-2xs stg:text-muted-foreground",children:"For sites that can't run scripts. A blocked embed shows an empty frame instead of hiding."}),(0,t.jsx)(eK,{label:"Iframe embed",value:o,copyLabel:"Iframe code",disabled:!r,multiline:!0})]})]})}function eH({draft:e,isPending:n,commit:r}){let[l,i]=(0,s.useState)(""),[o,g]=(0,s.useState)(null),d=(0,s.useCallback)(async()=>{let t=l.trim(),s=(0,D.g)(t);s?g(s):e.allowedOrigins.includes(t)?g("That origin is already in the list"):e.allowedOrigins.length>=D.h?g(`At most ${D.h} origins are allowed`):(g(null),await r({...e,allowedOrigins:[...e.allowedOrigins,t]},"Origin added")&&i(""))},[l,e,r]),c=(0,s.useCallback)(t=>{r({...e,allowedOrigins:e.allowedOrigins.filter(e=>e!==t)},"Origin removed")},[e,r]);return(0,t.jsxs)("section",{children:[(0,t.jsx)("h3",{className:"stg:text-xs stg:font-medium stg:text-muted-foreground",children:"Allowed embed origins"}),(0,t.jsx)("p",{className:"stg:mt-0.5 stg:text-2xs stg:text-muted-foreground",children:"Sites allowed to embed this agent. An empty list allows any site; adding origins restricts embedding to those sites. The hosted link works either way."}),e.allowedOrigins.length>0&&(0,t.jsx)("ul",{className:(0,a.f)(Q.J,"stg:mt-2 stg:flex stg:flex-col stg:divide-y stg:divide-border stg:rounded-md stg:border stg:border-border"),children:e.allowedOrigins.map(e=>(0,t.jsxs)("li",{className:"stg:flex stg:items-center stg:justify-between stg:gap-2 stg:px-2.5 stg:py-1.5",children:[(0,t.jsx)("code",{className:"stg:truncate stg:font-mono stg:text-xs stg:text-foreground",children:e}),(0,t.jsx)("button",{type:"button",onClick:()=>c(e),disabled:n,"aria-label":`Remove ${e}`,className:(0,a.f)("stg:inline-flex stg:size-5 stg:shrink-0 stg:items-center stg:justify-center stg:rounded stg:text-muted-foreground","stg:hover:bg-destructive-subtle stg:hover:text-destructive","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring","stg:disabled:pointer-events-none stg:disabled:opacity-50"),children:(0,t.jsx)(eQ,{})})]},e))}),(0,t.jsxs)("div",{className:"stg:mt-2 stg:flex stg:items-start stg:gap-1.5",children:[(0,t.jsxs)("div",{className:"stg:min-w-0 stg:flex-1",children:[(0,t.jsx)("input",{type:"text",value:l,onChange:e=>{i(e.target.value),o&&g(null)},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),d())},placeholder:"https://example.com","aria-label":"Add allowed origin","aria-invalid":null!=o,className:(0,a.f)("stg:w-full stg:rounded-md stg:border stg:border-border stg:bg-input-bg stg:px-2 stg:py-1.5 stg:font-mono stg:text-xs stg:text-foreground","stg:focus:outline-none stg:focus:ring-2 stg:focus:ring-ring")}),o&&(0,t.jsx)("p",{role:"alert",className:"stg:mt-1 stg:text-xs stg:text-destructive",children:o})]}),(0,t.jsx)("button",{type:"button",onClick:()=>void d(),disabled:n||!l.trim(),className:(0,a.f)("stg:shrink-0 stg:rounded-md stg:px-2.5 stg:py-1.5 stg:text-xs stg:font-medium","stg:border stg:border-border stg:text-foreground stg:hover:bg-accent-hover","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring","stg:disabled:pointer-events-none stg:disabled:opacity-50"),children:"Add"})]})]})}let e_=[{key:"rateLimited",label:"Rate limited",placeholder:"Shown when a visitor sends messages too quickly"},{key:"unavailable",label:"Unavailable",placeholder:"Shown when the agent is temporarily unavailable"},{key:"conversationEnded",label:"Conversation ended",placeholder:"Shown when a conversation reaches its limit"}];function eq({draft:e,isPending:n,commit:r}){let[l,i]=(0,s.useState)(!1),[o,g]=(0,s.useState)(e.messages),d=o.rateLimited!==e.messages.rateLimited||o.unavailable!==e.messages.unavailable||o.conversationEnded!==e.messages.conversationEnded,c=(0,s.useCallback)(()=>{r({...e,messages:o},"Messages saved")},[r,e,o]);return(0,t.jsxs)("section",{children:[(0,t.jsxs)("button",{type:"button",onClick:()=>i(e=>!e),"aria-expanded":l,className:(0,a.f)("stg:inline-flex stg:items-center stg:gap-1 stg:text-xs stg:font-medium stg:text-muted-foreground","stg:hover:text-foreground","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring stg:rounded"),children:[(0,t.jsx)(eG,{className:(0,a.f)("stg:size-3 stg:transition-transform",l&&"stg:rotate-90")}),"Customize visitor messages"]}),l&&(0,t.jsxs)("div",{className:"stg:mt-2 stg:flex stg:flex-col stg:gap-3",children:[(0,t.jsx)("p",{className:"stg:text-2xs stg:text-muted-foreground",children:"Shown to visitors when a limit is reached. Leave empty to use the platform defaults."}),e_.map(({key:e,label:s,placeholder:n})=>(0,t.jsx)(eY,{label:s,placeholder:n,value:o[e],onChange:t=>g(s=>({...s,[e]:t}))},e)),d&&(0,t.jsxs)("div",{className:"stg:flex stg:items-center stg:justify-end stg:gap-1.5",children:[(0,t.jsx)("button",{type:"button",onClick:()=>g(e.messages),disabled:n,className:(0,a.f)("stg:rounded-md stg:px-2.5 stg:py-1 stg:text-xs stg:font-medium","stg:border stg:border-border stg:text-foreground stg:hover:bg-accent-hover","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring"),children:"Reset"}),(0,t.jsx)("button",{type:"button",onClick:c,disabled:n,className:(0,a.f)("stg:rounded-md stg:px-2.5 stg:py-1 stg:text-xs stg:font-medium","stg:bg-primary stg:text-primary-foreground stg:hover:bg-primary-hover","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring","stg:disabled:pointer-events-none stg:disabled:opacity-50"),children:"Save messages"})]})]})]})}function eY({label:e,placeholder:s,value:n,onChange:r}){return(0,t.jsxs)("label",{className:"stg:flex stg:flex-col stg:gap-1",children:[(0,t.jsxs)("span",{className:"stg:flex stg:items-center stg:justify-between stg:text-xs stg:font-medium stg:text-muted-foreground",children:[e,(0,t.jsxs)("span",{className:"stg:tabular-nums stg:text-2xs",children:[n.length,"/",300]})]}),(0,t.jsx)("textarea",{value:n,onChange:e=>r(e.target.value.slice(0,300)),placeholder:s,rows:2,maxLength:300,className:(0,a.f)("stg:w-full stg:resize-y stg:rounded-md stg:border stg:border-border stg:bg-input-bg stg:px-2 stg:py-1.5 stg:text-xs stg:text-foreground","stg:focus:outline-none stg:focus:ring-2 stg:focus:ring-ring")})]})}function eJ({org:e,slug:n}){let r=(0,es.i)(),l=(0,s.useMemo)(()=>{let t;return null===r?null:(t=JSON.stringify((0,eA.f)(r,"/")),`import { createNodeClient } from "@stigmer/client/node";
8
+
9
+ // A key of a service account with the admin role in ${e}
10
+ const stigmer = createNodeClient({
11
+ baseUrl: ${t},
12
+ apiKey: process.env.STIGMER_API_KEY,
13
+ });
14
+
15
+ // Mint tokens for your own users, then chat with ${e}/${n}
16
+ const { accessToken } = await stigmer.tokens.mintUserToken({
17
+ org: ${JSON.stringify(e)},
18
+ userId: "user-123",
19
+ });`)},[r,e,n]);return(0,t.jsxs)("div",{className:"stg:flex stg:flex-col stg:gap-3",children:[(0,t.jsx)("p",{className:"stg:text-xs stg:text-muted-foreground",children:"Need your own auth, branding, or UI? Sign your product's users in with a service account's key and integrate this agent with the Stigmer SDK — the same runtime, full control."}),null!==l?(0,t.jsx)(eK,{label:"SDK integration",value:l,copyLabel:"Code",multiline:!0}):(0,t.jsxs)("section",{children:[(0,t.jsx)("h3",{className:"stg:text-xs stg:font-medium stg:text-muted-foreground",children:"SDK integration"}),(0,t.jsx)("div",{className:"stg:mt-1.5",children:(0,t.jsx)(en.f,{subject:"the integration code"})})]}),(0,t.jsx)("a",{href:"https://stigmer.ai/docs/guides/authentication/product-users",target:"_blank",rel:"noreferrer",className:(0,a.f)("stg:text-xs stg:font-medium stg:text-primary stg:hover:text-primary-muted","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring stg:rounded"),children:"Read the guide to signing your users in →"})]})}function eK({label:e,value:s,copyLabel:n,disabled:r,multiline:l,openHref:i}){let{copy:o}=(0,ea.f)();return(0,t.jsxs)("section",{className:(0,a.f)(r&&"stg:opacity-50"),children:[(0,t.jsx)("h3",{className:"stg:text-xs stg:font-medium stg:text-muted-foreground",children:e}),(0,t.jsxs)("div",{className:"stg:mt-1.5 stg:flex stg:items-start stg:gap-1.5",children:[l?(0,t.jsx)("pre",{className:(0,a.f)("stg:min-w-0 stg:flex-1 stg:overflow-x-auto stg:rounded-md stg:border stg:border-border stg:bg-muted-subtle stg:px-2.5 stg:py-2","stg:font-mono stg:text-xs stg:leading-relaxed stg:text-foreground"),children:s}):(0,t.jsx)(ei.f,{text:s,className:(0,a.f)("stg:min-w-0 stg:flex-1 stg:rounded-md stg:border stg:border-border stg:bg-muted-subtle stg:px-2.5 stg:py-1.5","stg:font-mono stg:text-xs stg:text-foreground")}),(0,t.jsxs)("div",{className:"stg:flex stg:shrink-0 stg:flex-col stg:gap-1.5",children:[(0,t.jsx)("button",{type:"button",onClick:()=>void o(s,n),disabled:r,className:(0,a.f)("stg:rounded-md stg:px-2.5 stg:py-1.5 stg:text-xs stg:font-medium","stg:border stg:border-border stg:text-foreground stg:hover:bg-accent-hover","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring","stg:disabled:pointer-events-none stg:disabled:opacity-50"),children:"Copy"}),i&&(0,t.jsx)("a",{href:i,target:"_blank",rel:"noreferrer",className:(0,a.f)("stg:rounded-md stg:px-2.5 stg:py-1.5 stg:text-center stg:text-xs stg:font-medium","stg:border stg:border-border stg:text-foreground stg:hover:bg-accent-hover","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring"),children:"Open"})]})]})]})}function eX(){return(0,t.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}function eQ(){return(0,t.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"m4 4 8 8M12 4l-8 8"})})}function eG({className:e}){return(0,t.jsx)("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"m6 3 5 5-5 5"})})}var eZ=e.i(284614),e0=e.i(37727),e1=e.i(361353),e2=e.i(526025),e5=e.i(577817),e3=e.i(400019),e4=e.i(321953);function e6({open:e,onOpenChange:n,channel:a,sessionHref:r,modal:l=!0}){let i=(0,s.useId)(),o=(0,s.useCallback)(()=>{n(!1)},[n]);return(0,t.jsx)(X.f,{open:e,onOpenChange:n,modal:l,width:"lg","aria-labelledby":i,children:e&&(0,t.jsx)(e8,{titleId:i,channel:a,sessionHref:r,onClose:o})})}function e8({titleId:e,channel:s,sessionHref:n,onClose:r}){var l;let i,o,g=s.metadata?.name||s.metadata?.slug||"this channel",{sessions:d,isLoading:c,error:u,hasMore:m,loadMore:x,isLoadingMore:h,loadMoreError:p}=(l=s.metadata?.id??"",i=(0,b.f)(),{sessions:(o=(0,e3.f)(l?e=>i.session.listByChannel((0,f.f)(e5.s,{channelId:l,pageToken:e})):null,[l,i],e=>e.metadata?.id??"")).items,hasMore:o.hasMore,loadMore:o.loadMore,isLoadingMore:o.isLoadingMore,loadMoreError:o.loadMoreError,isLoading:o.isLoading,isRefetching:o.isRefetching,error:o.error,refetch:o.refetch});return(0,t.jsxs)("div",{className:"stg:flex stg:max-h-[70vh] stg:flex-col",children:[(0,t.jsxs)("div",{className:"stg:flex stg:items-start stg:justify-between stg:gap-3 stg:border-b stg:border-border stg:px-5 stg:py-4",children:[(0,t.jsxs)("div",{className:"stg:min-w-0",children:[(0,t.jsx)("h2",{id:e,className:"stg:text-sm stg:font-semibold stg:text-popover-foreground",children:"Sessions"}),(0,t.jsxs)("p",{className:"stg:mt-0.5 stg:truncate stg:text-xs stg:text-muted-foreground",children:["The sessions ",g," created — read-only, visible to the channel's owner and org admins."]})]}),(0,t.jsx)(B.f,{variant:"ghost",size:"xs",onClick:r,"aria-label":"Close sessions",children:(0,t.jsx)(e0.X,{className:"stg:size-4"})})]}),(0,t.jsxs)("div",{className:"stg:min-h-0 stg:flex-1 stg:overflow-y-auto stg:p-3",children:[c?(0,t.jsx)(e7,{}):u?(0,t.jsx)("p",{className:"stg:px-2 stg:py-6 stg:text-center stg:text-sm stg:text-destructive",children:(0,W.g)(u)}):0===d.length?(0,t.jsx)(F.f,{variant:"first-use",icon:(0,t.jsx)(S.f,{className:"stg:size-8"}),title:"No sessions yet",description:"When someone messages this channel, the sessions serving them appear here."}):(0,t.jsx)("ul",{className:(0,a.f)(Q.J,"stg:space-y-1"),children:d.map(e=>(0,t.jsx)(e9,{session:e,href:n&&e.metadata?.id?n(e.metadata.id):void 0},e.metadata?.id))}),(0,t.jsx)(e4.f,{hasMore:m,loadMore:x,isLoadingMore:h,loadMoreError:p})]})]})}function e9({session:e,href:s}){var n;let l,i=e.spec?.subject||"Untitled session",o=(0,e2.k)(e),g=(n=e,(l=n.status?.audit?.statusAudit?.updatedAt??n.status?.audit?.specAudit?.createdAt)?(0,r.S)(l):null),d=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"stg:min-w-0 stg:flex-1",children:[(0,t.jsx)(ei.f,{text:i,className:"stg:block stg:text-sm stg:text-foreground"}),o&&(0,t.jsxs)("p",{className:"stg:mt-0.5 stg:flex stg:items-center stg:gap-1 stg:text-xs stg:text-muted-foreground",children:[(0,t.jsx)(eZ.f,{"aria-hidden":"true",className:"stg:size-3"}),o]})]}),g&&(0,t.jsx)("span",{className:"stg:shrink-0 stg:text-xs stg:text-muted-foreground-faint",children:(0,e1.f)(g)})]}),c="stg:flex stg:items-center stg:gap-3 stg:rounded-md stg:px-2 stg:py-2 stg:text-left";return(0,t.jsx)("li",{children:s?(0,t.jsx)("a",{href:s,className:(0,a.f)(c,"stg:hover:bg-accent stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring"),children:d}):(0,t.jsx)("div",{className:c,children:d})})}function e7(){return(0,t.jsx)("div",{className:"stg:space-y-1 stg:p-1",children:[1,2,3].map(e=>(0,t.jsx)("div",{className:"stg:h-12 stg:animate-pulse stg:rounded-md stg:bg-muted-faint"},e))})}let te={status:"checking"};function tt(e,t,s){let n=(0,J.T)(),a=ew(e),r=t&&"cloud"===n,l=ek(r&&!0===a,s);return r&&null===a?te:l}function ts({agent:e,org:s,value:n,onChange:a,disabled:r=!1,enabled:l=!0}){return(0,t.jsxs)("div",{className:"stg:flex stg:flex-col stg:gap-2",children:[(0,t.jsx)("p",{className:"stg:text-2xs stg:text-muted-foreground",children:"Shared vaults whose keys workspace conversations use — name one holding the keys this agent's tools need (a read-only token is safest). You can name only vaults you may use; create one in Settings → Vaults. Saved values stay hidden from everyone."}),(0,t.jsx)(er.f,{org:s,value:n,onChange:a,disabled:r}),(0,t.jsx)(tn,{agent:e,enabled:l,value:n})]})}function tn({agent:e,enabled:s,value:n}){let a=tt(e,s,n);if("needs-credentials"===a.status)return(0,t.jsx)("p",{className:"stg:text-xs stg:text-status-degraded",role:"status",children:"Workspace conversations can't use this agent's tools yet: this channel names no vault. Name a shared vault above."});if("blocked"!==a.status)return null;let r=a.unusableVaults.length>1;return(0,t.jsxs)("p",{className:"stg:text-xs stg:text-status-degraded",role:"status",children:["Workspace conversations can't use this agent's tools yet: the vault",r?"s":""," ",(0,t.jsx)("span",{className:"stg:font-medium",children:a.unusableVaults.join(", ")})," ",r?"are":"is"," not a shared vault you can read. Name a shared vault instead (Settings → Vaults)."]})}var ta=e.i(921321);function tr({open:e,onOpenChange:n,agent:a,channel:r,onSaved:l,modal:i=!0}){let o=(0,s.useId)(),g=(0,s.useCallback)(()=>{n(!1)},[n]);return(0,t.jsx)(X.f,{open:e,onOpenChange:n,modal:i,width:"md","aria-labelledby":o,children:e&&(0,t.jsx)(tl,{agent:a,channel:r,onSaved:l,onClose:g,titleId:o})})}function tl({agent:e,channel:n,onSaved:r,onClose:l,titleId:i}){let o=n.metadata?.name||n.metadata?.slug||"this channel",g=n.metadata?.org??"",{update:d,isPending:u,error:m,clearError:x}=eu(),[h,f]=(0,s.useState)(()=>(n.spec?.vaults??[]).map(e=>({org:e.org,slug:e.slug,...e.id?{id:e.id}:{}}))),p=(0,s.useCallback)(async()=>{try{await d(n,{vaults:h.map(ta.f)}),r?.(),l()}catch{}},[n,h,l,r,d]);return(0,t.jsxs)("div",{className:"stg:flex stg:flex-col",children:[(0,t.jsxs)("div",{className:"stg:flex stg:items-start stg:justify-between stg:gap-3 stg:border-b stg:border-border stg:px-5 stg:py-4",children:[(0,t.jsxs)("div",{className:"stg:min-w-0",children:[(0,t.jsx)("h2",{id:i,className:"stg:text-sm stg:font-semibold stg:text-foreground",children:"Tool credentials"}),(0,t.jsx)("p",{className:"stg:mt-0.5 stg:truncate stg:text-xs stg:text-muted-foreground",children:o})]}),(0,t.jsx)("button",{type:"button",onClick:l,"aria-label":"Close dialog",className:(0,a.f)("stg:rounded stg:p-1 stg:text-muted-foreground","stg:hover:bg-accent-hover stg:hover:text-foreground","stg:focus:outline-none stg:focus:ring-1 stg:focus:ring-ring"),children:(0,t.jsx)(ti,{})})]}),(0,t.jsxs)("div",{className:"stg:px-5 stg:py-4",children:[(0,t.jsx)(ts,{agent:e,org:g,value:h,onChange:f,disabled:u,enabled:n.spec?.enabled??!1}),m&&(0,t.jsx)("div",{role:"alert",className:"stg:mt-3 stg:rounded-md stg:border stg:border-destructive/30 stg:bg-destructive-subtle stg:px-3 stg:py-2 stg:text-xs stg:text-destructive",children:(0,c.q)(m,"channel")})]}),(0,t.jsxs)("div",{className:"stg:flex stg:justify-end stg:gap-2 stg:border-t stg:border-border stg:px-5 stg:py-3",children:[(0,t.jsx)(B.f,{variant:"ghost",size:"sm",onClick:()=>{x(),l()},disabled:u,children:"Cancel"}),(0,t.jsx)(B.f,{variant:"primary",size:"sm",onClick:()=>void p(),disabled:u,children:"Save"})]})]})}function ti(){return(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"m3 3 8 8M11 3l-8 8"})})}var to=e.i(394327),tg=e.i(216386),td=e.i(729728),tc=e.i(752277);function tu({open:e,onOpenChange:n,channel:a,onSaved:r,modal:l=!0}){let i=(0,s.useId)(),o=(0,s.useCallback)(()=>{n(!1)},[n]);return(0,t.jsx)(X.f,{open:e,onOpenChange:n,modal:l,width:"md","aria-labelledby":i,children:e&&(0,t.jsx)(tm,{channel:a,onSaved:r,onClose:o,titleId:i})})}function tm({channel:e,onSaved:n,onClose:r,titleId:l}){let i=e.metadata?.name||e.metadata?.slug||"this channel",o=e.spec?.runConfig,{update:g,isPending:d,error:u,clearError:m}=eu(),[x,h]=(0,s.useState)(o?.modelName??""),[f,p]=(0,s.useState)("stigmer"),[b,v]=(0,s.useState)((0,td.S)(o?.serviceTier)??"standard"),[j,y]=(0,s.useState)((0,tc.o)(o?.thinkingMode)??"disabled"),[N,k]=(0,s.useState)(o&&o.maxCostUsd>0?String(o.maxCostUsd):""),C=(0,s.useCallback)(async()=>{try{var t,s,a,l,i;let d,c,u,m,h,f,p,v;await g(e,{runConfig:(t=x,s=N,a=b,l=j,i=o,d=t.trim(),c=Number.parseFloat(s),u=d===(i?.modelName??"").trim(),m=i?.serviceTier??to.h.UNSPECIFIED,h=i?.thinkingMode??to.c.UNSPECIFIED,f={},""!==d&&(f.modelName=d),Number.isFinite(c)&&c>0&&(f.maxCostUsd=c),(i?.maxToolRounds??0)>0&&(f.maxToolRounds=i?.maxToolRounds),(i?.maxToolResultChars??0)>0&&(f.maxToolResultChars=i?.maxToolResultChars),p=u&&a===((0,td.S)(m)??"standard")?m:"fast"===a&&""!==d?(0,td.Y)(a):to.h.UNSPECIFIED,v=u&&l===((0,tc.o)(h)??"disabled")?h:"enabled"===l&&""!==d?(0,tc.T)(l):to.c.UNSPECIFIED,p!==to.h.UNSPECIFIED&&(f.serviceTier=p),v!==to.c.UNSPECIFIED&&(f.thinkingMode=v),Object.keys(f).length>0?f:void 0)}),n?.(),r()}catch{}},[N,e,x,r,n,g,b,o,j]);return(0,t.jsxs)("div",{className:"stg:flex stg:flex-col",children:[(0,t.jsxs)("div",{className:"stg:flex stg:items-start stg:justify-between stg:gap-3 stg:border-b stg:border-border stg:px-5 stg:py-4",children:[(0,t.jsxs)("div",{className:"stg:min-w-0",children:[(0,t.jsx)("h2",{id:l,className:"stg:text-sm stg:font-semibold stg:text-foreground",children:"Run settings"}),(0,t.jsx)("p",{className:"stg:mt-0.5 stg:truncate stg:text-xs stg:text-muted-foreground",children:i})]}),(0,t.jsx)("button",{type:"button",onClick:r,"aria-label":"Close dialog",className:(0,a.f)("stg:rounded stg:p-1 stg:text-muted-foreground","stg:hover:bg-accent-hover stg:hover:text-foreground","stg:focus:outline-none stg:focus:ring-1 stg:focus:ring-ring"),children:(0,t.jsx)(tp,{})})]}),(0,t.jsxs)("div",{className:"stg:space-y-4 stg:px-5 stg:py-4",children:[(0,t.jsxs)("div",{className:"stg:space-y-1",children:[(0,t.jsxs)("span",{className:tx,children:["Model"," ",(0,t.jsx)("span",{className:"stg:font-normal stg:text-muted-foreground",children:"(optional)"})]}),(0,t.jsxs)("div",{className:"stg:flex stg:items-center stg:gap-2",children:[(0,t.jsx)(tg.f,{value:x,onValueChange:h,initialHarness:f,onHarnessChange:p,serviceTier:b,onServiceTierChange:v,thinkingMode:j,onThinkingModeChange:y,placeholderLabel:"Platform default",disabled:d}),""!==x&&(0,t.jsx)("button",{type:"button",onClick:()=>{h(""),v("standard"),y("disabled")},disabled:d,className:(0,a.f)("stg:rounded-md stg:px-2 stg:py-1 stg:text-2xs stg:text-muted-foreground","stg:hover:text-foreground stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring","stg:disabled:pointer-events-none stg:disabled:opacity-50"),children:"Reset to platform default"})]}),(0,t.jsx)("p",{className:th,children:"Every conversation turn on this channel runs the pinned model. Unpinned, the platform’s default harness and model apply."})]}),(0,t.jsxs)("div",{className:"stg:space-y-1",children:[(0,t.jsxs)("label",{htmlFor:`${l}-budget`,className:tx,children:["Budget per run (USD)"," ",(0,t.jsx)("span",{className:"stg:font-normal stg:text-muted-foreground",children:"(optional)"})]}),(0,t.jsx)("input",{id:`${l}-budget`,type:"number",min:"0",step:"0.5",inputMode:"decimal",value:N,onChange:e=>k(e.target.value),placeholder:"Platform default",disabled:d,className:(0,a.f)(tf,"stg:max-w-40")}),(0,t.jsx)("p",{className:th,children:"Caps each turn’s estimated spend. The platform profile bounds this value; the lower cap wins."})]}),u&&(0,t.jsx)("div",{role:"alert",className:"stg:rounded-md stg:border stg:border-destructive/30 stg:bg-destructive-subtle stg:px-3 stg:py-2 stg:text-xs stg:text-destructive",children:(0,c.q)(u,"channel")})]}),(0,t.jsxs)("div",{className:"stg:flex stg:justify-end stg:gap-2 stg:border-t stg:border-border stg:px-5 stg:py-3",children:[(0,t.jsx)(B.f,{variant:"ghost",size:"sm",onClick:()=>{m(),r()},disabled:d,children:"Cancel"}),(0,t.jsx)(B.f,{variant:"primary",size:"sm",onClick:()=>void C(),disabled:d,children:"Save"})]})]})}let tx="stg:block stg:text-xs stg:font-medium stg:text-foreground",th="stg:text-2xs stg:text-muted-foreground",tf=(0,a.f)("stg:w-full stg:rounded-md stg:border stg:border-input stg:bg-background stg:px-2.5 stg:py-1.5 stg:text-xs stg:text-foreground","stg:placeholder:text-muted-foreground","stg:focus-visible:outline-none stg:focus-visible:ring-1 stg:focus-visible:ring-ring","stg:disabled:pointer-events-none stg:disabled:opacity-50");function tp(){return(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"m3 3 8 8M11 3l-8 8"})})}var tb=e.i(778917),tv=e.i(385663),tj=e.i(266442);let ty={id:"slack",describeChannel:e=>{let t=e.status?.typeStatus?.case==="slack"?e.status.typeStatus.value:null,s=t?.installedAt?(0,r.S)(t.installedAt):null;switch(tC(e)){case P.t.installed:return[t?.teamName?`Workspace: ${t.teamName}`:"Workspace connected",s?`since ${tw(s)}`:null].filter(Boolean).join(" · ");case P.t.revoked:return t?.teamName?`The Slack app was removed from ${t.teamName} — reconnect to resume.`:"The Slack app was removed from the workspace — reconnect to resume.";default:return"The Slack install hasn't been completed yet."}},servingLine:e=>e?`Serving app: ${e} (your app) — members @mention ${e}`:"Serving app: Stigmer — members @mention Stigmer",disconnectDescription:e=>`"${e}" stops serving immediately and its stored Slack install (including credentials) is removed. Members of the workspace can no longer reach the agent. To pause without disconnecting, turn the channel off instead.`},tN=[ty,{id:"whatsapp",describeChannel:e=>{let t=e.status?.typeStatus?.case==="whatsapp"?e.status.typeStatus.value:null,s=t?.installedAt?(0,r.S)(t.installedAt):null;switch(tC(e)){case P.t.installed:{let e=t?.displayPhoneNumber||t?.phoneNumberId||null;return[e?`Number: ${e}`:"Number connected",t?.verifiedName?`(${t.verifiedName})`:null,s?`since ${tw(s)}`:null].filter(Boolean).join(" · ")}case P.t.revoked:return"The WhatsApp connection was revoked — reconnect to resume.";default:return"The WhatsApp connection hasn't been completed yet."}},servingLine:e=>e?`Serving app: ${e} (your Meta app) — people message the connected number`:"Serving app: your Meta app — people message the connected number",disconnectDescription:e=>`"${e}" stops serving immediately and its WhatsApp number binding is removed. People can no longer reach the agent on that number. To pause without disconnecting, turn the channel off instead.`}];function tk(e){return tN.find(t=>t.id===e)??null}function tC(e){return e.status?.installState??P.t.channel_install_state_unspecified}function tw(e){return e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}var tS=e.i(928240),tA=e.i(182990);function t$({open:e,onOpenChange:n,channel:a,onEditYaml:r,modal:l=!0}){let i=(0,s.useId)(),o=(0,s.useCallback)(()=>{n(!1)},[n]);return(0,t.jsx)(X.f,{open:e,onOpenChange:n,modal:l,width:"2xl","aria-labelledby":i,children:e&&(0,t.jsx)(tT,{titleId:i,channel:a,onEditYaml:r,onClose:o})})}function tT({titleId:e,channel:s,onEditYaml:n,onClose:a}){let r=s.metadata?.name||s.metadata?.slug||"this channel";return(0,t.jsxs)("div",{className:"stg:flex stg:max-h-[75vh] stg:flex-col",children:[(0,t.jsxs)("div",{className:"stg:flex stg:items-start stg:justify-between stg:gap-3 stg:border-b stg:border-border stg:px-5 stg:py-4",children:[(0,t.jsxs)("div",{className:"stg:min-w-0",children:[(0,t.jsx)("h2",{id:e,className:"stg:text-sm stg:font-semibold stg:text-popover-foreground",children:"Templates"}),(0,t.jsxs)("p",{className:"stg:mt-0.5 stg:text-xs stg:text-muted-foreground",children:["The message templates WhatsApp holds for ",r," — authored and approved in WhatsApp Manager, listed here as WhatsApp reports them."]})]}),(0,t.jsx)(B.f,{variant:"ghost",size:"xs",onClick:a,"aria-label":"Close templates",children:(0,t.jsx)(e0.X,{className:"stg:size-4"})})]}),(0,t.jsx)("div",{className:"stg:min-h-0 stg:flex-1 stg:overflow-y-auto stg:p-4",children:(0,t.jsx)(tL,{channel:s,onEditYaml:n})})]})}function tL({channel:e,onEditYaml:s}){let n="cloud"!==(0,J.T)()?{status:"cloud-only"}:e.status?.installState!==P.t.installed?{status:"not-installed"}:e.spec?.enabled?e.spec.type?.case==="whatsapp"&&e.spec.type.value.proactiveMessagingEnabled?{status:"ready"}:{status:"not-proactive"}:{status:"channel-off"},a=tk(e.spec?.type?.case)??ty;switch(n.status){case"cloud-only":return(0,t.jsx)(K.f,{children:"Message templates come from the provider through Stigmer Cloud's channel runtime. Channel configuration still works here, but the template registry can only be read on a cloud deployment."});case"not-installed":return(0,t.jsx)(F.f,{variant:"first-use",icon:(0,t.jsx)(tv.f,{className:"stg:size-8"}),title:"Connect this channel first",description:`${a.describeChannel(e)} Templates become readable once the connection is complete.`});case"channel-off":return(0,t.jsx)(F.f,{variant:"first-use",icon:(0,t.jsx)(tv.f,{className:"stg:size-8"}),title:"This channel is turned off",description:"Turn the channel on with the switch on its card, then check back here."});case"not-proactive":return(0,t.jsx)(F.f,{variant:"first-use",icon:(0,t.jsx)(tv.f,{className:"stg:size-8"}),title:"Business-initiated messaging is not enabled",description:"Templates power messages your agent sends first — reminders, invoices, notifications. To allow them, set proactive_messaging_enabled on this channel's definition.",children:s&&(0,t.jsx)(B.f,{variant:"primary",onClick:s,children:"Edit channel YAML"})});case"ready":return(0,t.jsx)(tM,{channel:e})}}function tM({channel:e}){let{templates:s,isLoading:n,error:r}=(0,tA.f)(e.metadata?.slug??"",e.metadata?.org??"");if(n)return(0,t.jsx)(tO,{});if(r)return(0,t.jsx)("p",{className:"stg:px-2 stg:py-6 stg:text-center stg:text-sm stg:text-destructive",children:(0,W.g)(r)});if(0===s.length)return(0,t.jsx)(F.f,{variant:"first-use",icon:(0,t.jsx)(tv.f,{className:"stg:size-8"}),title:"No templates found for this channel",description:"Templates are authored in WhatsApp Manager and approved by WhatsApp — Stigmer keeps no copy. Once a template is approved, it appears here and in your agent's repertoire automatically.",children:(0,t.jsx)(tE,{label:"Open WhatsApp Manager"})});let l=s.filter(e=>"APPROVED"===e.status&&""===e.unsupportedReason).length;return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"stg:flex stg:items-center stg:justify-between stg:gap-3 stg:px-1 stg:pb-3",children:[(0,t.jsxs)("p",{className:"stg:text-xs stg:text-muted-foreground",children:[s.length," ",1===s.length?"template":"templates"," · ",l," ready to send"]}),(0,t.jsx)(tE,{label:"Manage in WhatsApp Manager"})]}),(0,t.jsx)("ul",{className:(0,a.f)(Q.J,"stg:space-y-2"),children:s.map(e=>(0,t.jsx)(tR,{template:e},`${e.name}\0${e.language}`))})]})}function tR({template:e}){return(0,t.jsxs)("li",{className:"stg:rounded-lg stg:border stg:border-border stg:p-3",children:[(0,t.jsxs)("div",{className:"stg:flex stg:items-start stg:justify-between stg:gap-3",children:[(0,t.jsxs)("div",{className:"stg:flex stg:min-w-0 stg:flex-wrap stg:items-center stg:gap-x-2 stg:gap-y-1",children:[(0,t.jsx)(ei.f,{text:e.name,className:"stg:text-sm stg:font-medium stg:text-foreground"}),(0,t.jsx)("span",{className:"stg:shrink-0 stg:text-xs stg:text-muted-foreground",children:e.language}),e.category&&(0,t.jsx)(tz,{children:e.category}),e.headerFormat&&(0,t.jsxs)(tz,{children:[e.headerFormat," header"]})]}),(0,t.jsx)(tj.f,{phase:(0,tS.p)(e.status),label:e.status,className:"stg:shrink-0"})]}),e.bodyText&&(0,t.jsx)(tI,{body:e.bodyText}),e.rejectionReason&&(0,t.jsxs)("p",{className:"stg:mt-2 stg:text-xs stg:text-destructive",children:["Rejected: ",e.rejectionReason]}),e.unsupportedReason&&(0,t.jsxs)("p",{className:"stg:mt-2 stg:text-xs stg:text-status-degraded",role:"status",children:["Not sendable: ",e.unsupportedReason]})]})}function tI({body:e}){return(0,t.jsx)("p",{className:"stg:mt-2 stg:whitespace-pre-wrap stg:text-xs stg:leading-relaxed stg:text-muted-foreground",children:(0,tS.B)(e).map((e,s)=>"placeholder"===e.kind?(0,t.jsx)("code",{className:"stg:rounded stg:bg-muted-subtle stg:px-1 stg:font-mono stg:text-foreground",children:e.value},s):(0,t.jsx)("span",{children:e.value},s))})}function tz({children:e}){return(0,t.jsx)("span",{className:"stg:shrink-0 stg:rounded stg:bg-muted-subtle stg:px-1.5 stg:py-0.5 stg:text-xs stg:text-muted-foreground",children:e})}function tE({label:e}){return(0,t.jsxs)("a",{href:"https://business.facebook.com/wa/manage/message-templates/",target:"_blank",rel:"noreferrer noopener",className:(0,a.f)("stg:inline-flex stg:shrink-0 stg:items-center stg:gap-1 stg:text-xs stg:font-medium stg:text-foreground","stg:underline stg:underline-offset-2 stg:hover:text-muted-foreground","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring stg:rounded"),children:[e,(0,t.jsx)(tb.f,{"aria-hidden":"true",className:"stg:size-3"})]})}function tO(){return(0,t.jsx)("div",{className:"stg:space-y-2 stg:p-1",children:[1,2,3].map(e=>(0,t.jsx)("div",{className:"stg:h-20 stg:animate-pulse stg:rounded-lg stg:bg-muted-faint"},e))})}var tD=e.i(174886),tW=e.i(541071);let tP=(0,A.f)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);var tU=e.i(367240),tB=e.i(727612),tF=e.i(845132);function tV({Icon:e,typeLabel:s,name:n,state:a,details:r,controls:l,children:i}){return(0,t.jsxs)("div",{role:"group","aria-label":`${s}: ${n}`,className:"stg:rounded-lg stg:border stg:border-border stg:p-4",children:[(0,t.jsxs)("div",{className:"stg:flex stg:items-start stg:justify-between stg:gap-3",children:[(0,t.jsxs)("div",{className:"stg:flex stg:min-w-0 stg:items-center stg:gap-2.5",children:[(0,t.jsx)(e,{className:"stg:size-5 stg:shrink-0 stg:text-foreground"}),(0,t.jsxs)("div",{className:"stg:min-w-0",children:[(0,t.jsxs)("div",{className:"stg:flex stg:items-center stg:gap-2",children:[(0,t.jsx)(ei.f,{text:n,className:"stg:text-sm stg:font-medium stg:text-foreground"}),(0,t.jsx)("span",{className:"stg:shrink-0 stg:text-xs stg:text-muted-foreground",children:s}),a]}),r]})]}),(0,t.jsx)("div",{className:"stg:flex stg:shrink-0 stg:items-center stg:gap-2",children:l})]}),i]})}let tH={success:"stg:text-status-ready",destructive:"stg:text-destructive",muted:"stg:text-muted-foreground"};function t_({label:e,tone:s}){return(0,t.jsxs)("span",{className:(0,a.f)("stg:inline-flex stg:shrink-0 stg:items-center stg:gap-1.5 stg:text-xs",tH[s]),children:[(0,t.jsx)("span",{"aria-hidden":"true",className:"stg:size-1.5 stg:rounded-full stg:bg-current"}),e]})}var tq=e.i(221345),tY=e.i(543727);let tJ={id:"web",label:"Chat link",Icon:tq.f,addLabel:"Create a chat link",addCursorTarget:"add-chat-link",deleteLabel:"Delete",provider:null},tK=[tJ,...tY.V.map(e=>({id:e.id,label:e.label,Icon:e.Icon,addLabel:`Connect to ${e.label}`,addCursorTarget:`connect-${e.id}`,deleteLabel:"Disconnect",provider:e}))];function tX({channel:e,buildChatLinkUrl:n,onEditClick:r,onDeleteClick:l,refetch:i}){let o,g=e.metadata,d=g?.id??"",c=g?.name||g?.slug||"—",u=e.spec?.enabled??!1,m=eh(ef(e)?.audience),{copy:x}=(0,ea.f)(),{update:f,isPending:p}=eu(),{rotateLink:b,isPending:v}=ej(d),{allowed:j}=(0,h.f)({kind:"channel",id:d},"can_edit"),{allowed:y}=(0,h.f)({kind:"channel",id:d},"can_delete"),N=(0,D.o)(d),k=(o=n?n(d):N,"org"===m?o:(0,D._)(o,ep(e))),C=(0,s.useCallback)(()=>{x(k,"Link")},[x,k]),w=(0,s.useCallback)(async t=>{try{await f(e,{enabled:t}),U.c.success(t?"Chat link resumed":"Chat link paused"),i()}catch(e){U.c.error((0,W.g)(e))}},[f,e,i]),S=(0,s.useCallback)(async()=>{try{await b(),U.c.success("Link reset — the old link no longer works"),i()}catch(e){U.c.error((0,W.g)(e))}},[b,i]);return(0,t.jsx)(tV,{Icon:tJ.Icon,typeLabel:tJ.label,name:c,state:u?(0,t.jsx)(t_,{label:"Active",tone:"success"}):(0,t.jsx)(t_,{label:"Paused",tone:"muted"}),details:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"stg:mt-0.5 stg:flex stg:min-w-0 stg:items-center stg:gap-1.5",children:[(0,t.jsx)(ei.f,{text:N,className:"stg:font-mono stg:text-xs stg:text-muted-foreground"}),(0,t.jsx)("button",{type:"button",onClick:C,"aria-label":`Copy link for ${c}`,className:(0,a.f)("stg:shrink-0 stg:rounded stg:p-1 stg:text-muted-foreground","stg:hover:bg-accent-hover stg:hover:text-foreground","stg:focus:outline-none stg:focus:ring-1 stg:focus:ring-ring"),children:(0,t.jsx)(tD.f,{className:"stg:size-3","aria-hidden":"true"})})]}),(0,t.jsx)("p",{className:"stg:mt-0.5 stg:text-xs stg:text-muted-foreground-faint",children:"org"===m?"Organization members":"Anyone with the link"})]}),controls:(0,t.jsxs)(t.Fragment,{children:[j&&(0,t.jsx)(ee.f,{checked:u,onCheckedChange:e=>void w(e),disabled:p,"aria-label":`Turn ${c} ${u?"off":"on"}`}),(j||y)&&(0,t.jsxs)(tF.f,{children:[(0,t.jsx)(tF.f.Trigger,{"aria-label":`Actions for ${c}`,children:(0,t.jsx)(tW.f,{className:"stg:size-4"})}),(0,t.jsxs)(tF.f.Content,{children:[j&&(0,t.jsx)(tF.f.Item,{icon:(0,t.jsx)(tP,{}),onSelect:r,children:"Edit"}),j&&"public"===m&&(0,t.jsx)(tF.f.Item,{icon:(0,t.jsx)(tU.f,{}),disabled:v,onSelect:()=>void S(),children:"Reset link"}),j&&y&&(0,t.jsx)(tF.f.Separator,{}),y&&(0,t.jsx)(tF.f.Item,{icon:(0,t.jsx)(tB.f,{}),variant:"destructive",onSelect:l,children:tJ.deleteLabel})]})]})]})})}function tQ({org:e,apps:s,value:n,onChange:a,disabled:r,channelAppsHref:l,idPrefix:i,platformOption:o,appHint:g,emptyBody:d}){return 0===s.length?(0,t.jsxs)("section",{"aria-label":"Connect as",children:[(0,t.jsx)("h3",{className:"stg:mb-1.5 stg:text-xs stg:font-medium stg:text-foreground",children:"Connect as"}),d]}):(0,t.jsxs)("fieldset",{className:Q.n,children:[(0,t.jsx)("legend",{className:"stg:mb-1.5 stg:block stg:text-xs stg:font-medium stg:text-foreground",children:"Connect as"}),(0,t.jsxs)("div",{role:"radiogroup",className:"stg:space-y-1.5",children:[o&&(0,t.jsx)(tZ,{id:`${i}-platform`,name:i,label:o.label,hint:o.hint,checked:null===n,onSelect:()=>a(null),disabled:r}),s.map(s=>{let l=s.metadata?.slug??"",o=n?.slug===l;return(0,t.jsx)(tZ,{id:`${i}-${l}`,name:i,label:s.metadata?.name??l,hint:g,checked:o,onSelect:()=>a({org:e,slug:l}),disabled:r},s.metadata?.id??l)})]}),(0,t.jsxs)("p",{className:"stg:mt-1.5 stg:text-xs stg:text-muted-foreground",children:[(0,t.jsx)(tG,{channelAppsHref:l,children:"Register a channel app"}),"."]})]})}function tG({channelAppsHref:e,children:s}){return e?(0,t.jsx)("a",{href:e,className:(0,a.f)("stg:font-medium stg:underline stg:underline-offset-2","stg:hover:no-underline","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring stg:rounded"),children:s}):(0,t.jsxs)(t.Fragment,{children:[s," under Settings → Channel Apps"]})}function tZ({id:e,name:s,label:n,hint:r,checked:l,onSelect:i,disabled:o}){return(0,t.jsxs)("label",{htmlFor:e,className:(0,a.f)("stg:flex stg:cursor-pointer stg:items-start stg:gap-2 stg:rounded-md stg:border stg:px-2.5 stg:py-1.5",l?"stg:border-ring stg:bg-accent":"stg:border-border stg:hover:bg-accent-hover",o&&"stg:pointer-events-none stg:opacity-50"),children:[(0,t.jsx)("input",{id:e,type:"radio",name:s,checked:l,onChange:i,disabled:o,className:"stg:mt-0.5"}),(0,t.jsxs)("span",{className:"stg:min-w-0",children:[(0,t.jsx)("span",{className:"stg:block stg:text-xs stg:font-medium stg:text-foreground",children:n}),(0,t.jsx)("span",{className:"stg:block stg:text-2xs stg:text-muted-foreground",children:r})]})]})}function t0(){return(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"m3 3 8 8M11 3l-8 8"})})}function t1({className:e}){return(0,t.jsx)("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"m3 8.5 3.5 3.5L13 5"})})}function t2({className:e}){return(0,t.jsx)("svg",{className:e,viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"m4.5 2.5 3.5 3.5-3.5 3.5"})})}function t5({className:e}){return(0,t.jsxs)("svg",{className:(0,a.f)("stg:animate-spin",e),viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[(0,t.jsx)("circle",{cx:"8",cy:"8",r:"6.5",stroke:"currentColor",strokeOpacity:"0.25",strokeWidth:"2"}),(0,t.jsx)("path",{d:"M14.5 8A6.5 6.5 0 0 0 8 1.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function t3({agent:e,org:s,value:n,onChange:r,disabled:l}){let{expanded:i,toggle:o}=e$(e,n.length>0);return(0,t.jsxs)("section",{children:[(0,t.jsxs)("button",{type:"button",onClick:o,"aria-expanded":i,className:(0,a.f)("stg:inline-flex stg:items-center stg:gap-1 stg:text-xs stg:font-medium stg:text-muted-foreground","stg:hover:text-foreground","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring stg:rounded"),children:[(0,t.jsx)(t2,{className:(0,a.f)("stg:size-3 stg:transition-transform",i&&"stg:rotate-90")}),"Tool credentials"]}),i&&(0,t.jsx)("div",{className:"stg:mt-2",children:(0,t.jsx)(ts,{agent:e,org:s,value:n,onChange:r,disabled:l})})]})}function t4({error:e}){return(0,t.jsx)(t6,{children:(0,W.g)(e)})}function t6({children:e}){return(0,t.jsx)("div",{role:"alert",className:"stg:space-y-1 stg:rounded-md stg:border stg:border-destructive/30 stg:bg-destructive-subtle stg:px-3 stg:py-2 stg:text-xs stg:text-destructive",children:e})}var t8=e.i(903198),t9=e.i(752930),t7=e.i(914118);function se({open:e,onOpenChange:n,agent:a,channel:r,onChannelsChanged:l,modal:i=!0,channelAppsHref:o}){let g=(0,s.useId)(),d=(0,s.useCallback)(()=>{n(!1)},[n]);return(0,t.jsx)(X.f,{open:e,onOpenChange:n,modal:i,width:"md","aria-labelledby":g,children:e&&(0,t.jsx)(st,{agent:a,channel:r??null,onChannelsChanged:l,onClose:d,titleId:g,channelAppsHref:o})})}function st({agent:e,channel:n,onChannelsChanged:r,onClose:l,channelAppsHref:i,titleId:o}){let g=(0,R.b)(),d=(0,tY.P)((0,J.T)()),c=e.metadata?.name||e.metadata?.slug||"this agent",u=e.metadata?.org??"",{createChannel:m,isPending:x}=ed(),h=function(){let e=(0,b.f)(),[t,n]=(0,s.useState)("idle"),[a,r]=(0,s.useState)(null),l=(0,s.useRef)(null),i=(0,s.useRef)(null),o=(0,s.useRef)(!1);(0,s.useEffect)(()=>()=>{i.current?.()},[]);let g=(0,s.useCallback)(()=>{(i.current||l.current)&&(o.current=!0,i.current?.(),(0,t8.E)(l.current),l.current=null,i.current=null),n("idle"),r(null)},[]);return{connect:(0,s.useCallback)(async t=>{n("initiating"),r(null),o.current=!1,i.current?.();let s=(0,t8.X)();if(!s){let e=(0,t8.$)();throw r(e),n("idle"),e}l.current=s;try{let a=await e.channel.initiateInstall((0,f.f)(p.k,{resourceId:t}));s.location.href=a.authorizationUrl,n("awaiting-callback");let{code:r,state:l}=await (0,t8.h)(s,a.state,e=>{i.current=e});n("completing");let o=await e.channel.completeInstall((0,f.f)(p.h,{resourceId:t,state:l,code:r}));return n("done"),o}catch(t){let e=(0,eg.f)(t);throw o.current||(r(e),n("idle"),(0,t8.E)(s)),o.current=!1,e}finally{l.current=null,i.current=null}},[e]),isInProgress:"idle"!==t&&"done"!==t,phase:t,error:a,clearError:g}}(),[v,j]=(0,s.useState)(()=>n?n.metadata?.name??"":`${c} Slack`),[y,N]=(0,s.useState)([]),[k,C]=(0,s.useState)(null),[w,S]=(0,s.useState)(null),[A,$]=(0,s.useState)(null),{channelApps:T}=(0,H.f)(u||null),L=(0,s.useMemo)(()=>T.filter(e=>e.spec?.providerConfig?.case==="slack"),[T]),M=n?.spec?.type?.case==="slack"?n.spec.type.value.appRef:void 0,I=n?M?.slug?{org:M.org||u,slug:M.slug}:null:k,z=I?L.find(e=>e.metadata?.slug===I.slug)??null:null,E=I?z?.metadata?.name||I.slug:"Stigmer",O=d&&!n&&!w,{channels:D}=(0,t9.f)(O&&u?u:null),W=(0,s.useMemo)(()=>{let e=I?z?.metadata?.id:"";return void 0===e?[]:D.filter(t=>t.status?.installState===P.t.installed&&t.status?.typeStatus?.case==="slack"&&t.status.typeStatus.value.channelAppId===e)},[D,I,z]),U=(0,s.useCallback)(async()=>{$(null);try{let t=n;t||(t=await m({name:v.trim()||`${c} Slack`,org:u,agentRef:{org:u,slug:e.metadata?.slug??""},enabled:!0,slack:k?{appRef:k}:{},...y.length>0?{vaults:y}:{}}),r?.());let s=await h.connect(t.metadata?.id??"");S(s),r?.()}catch(e){$(h.error??(e instanceof Error?e:Error(String(e))))}},[e,c,k,n,m,y,v,u,r,h]),F=(0,s.useCallback)(()=>{h.clearError(),$(null)},[h]),V=x||h.isInProgress;return(0,t.jsxs)("div",{className:"stg:flex stg:flex-col",children:[(0,t.jsxs)("div",{className:"stg:flex stg:items-start stg:justify-between stg:gap-3 stg:border-b stg:border-border stg:px-5 stg:py-4",children:[(0,t.jsxs)("div",{className:"stg:flex stg:items-center stg:gap-2.5",children:[(0,t.jsx)(t7.f,{className:"stg:size-5 stg:text-foreground"}),(0,t.jsx)("h2",{id:o,className:"stg:text-sm stg:font-semibold stg:text-foreground",children:n?"Reconnect to Slack":"Connect to Slack"})]}),(0,t.jsx)("button",{type:"button",onClick:l,"aria-label":"Close dialog",className:(0,a.f)("stg:rounded stg:p-1 stg:text-muted-foreground","stg:hover:bg-accent-hover stg:hover:text-foreground","stg:focus:outline-none stg:focus:ring-1 stg:focus:ring-ring"),children:(0,t.jsx)(t0,{})})]}),(0,t.jsx)("div",{className:"stg:space-y-4 stg:px-5 stg:py-4",children:d?w?(0,t.jsx)(sl,{channel:w,agentName:c,botName:E}):V?(0,t.jsx)(sr,{phase:h.phase,onCancel:F}):(0,t.jsxs)(t.Fragment,{children:[!n&&(0,t.jsxs)("label",{className:"stg:block",children:[(0,t.jsx)("span",{className:"stg:mb-1.5 stg:block stg:text-xs stg:font-medium stg:text-foreground",children:"Channel name"}),(0,t.jsx)("input",{type:"text",value:v,onChange:e=>j(e.target.value),disabled:V,className:(0,a.f)("stg:w-full stg:rounded-md stg:border stg:border-input stg:bg-background stg:px-3 stg:py-1.5","stg:text-sm stg:text-foreground stg:placeholder:text-muted-foreground","stg:focus:outline-none stg:focus:ring-1 stg:focus:ring-ring")}),(0,t.jsx)("span",{className:"stg:mt-1 stg:block stg:text-xs stg:text-muted-foreground",children:"Names the connection in Stigmer — pick something that identifies the workspace if you connect more than one."})]}),!n&&(0,t.jsx)(tQ,{org:u,apps:L,value:k,onChange:C,disabled:V,channelAppsHref:i,idPrefix:"stgm-slack-app",platformOption:{label:"Stigmer app",hint:"Fastest — no setup, the bot is named Stigmer"},appHint:"Your app — your bot name and icon",emptyBody:(0,t.jsxs)("p",{className:"stg:text-xs stg:text-muted-foreground",children:["The platform"," ",(0,t.jsx)("span",{className:"stg:font-medium stg:text-foreground",children:"Stigmer"})," ","app — no setup needed. Want the bot to carry your own name and icon, or several agents in one workspace?"," ",(0,t.jsx)(tG,{channelAppsHref:i,children:"Register a channel app"}),"."]})}),W.length>0&&(0,t.jsx)(sn,{botName:E,channels:W}),!n&&(0,t.jsx)(t3,{agent:e,org:u,value:y,onChange:N,disabled:V}),(0,t.jsx)("p",{className:"stg:text-sm stg:text-muted-foreground",children:"When you continue, Slack asks which workspace to add the bot to — pick the one where your team should chat with this agent."}),(0,t.jsxs)("p",{className:"stg:text-sm stg:text-muted-foreground",children:["Members reach the agent by opening a direct message with"," ",(0,t.jsx)("span",{className:"stg:font-medium stg:text-foreground",children:E}),", or typing @ in a channel and picking"," ",(0,t.jsx)("span",{className:"stg:font-medium stg:text-foreground",children:E})," ","from the list — it answers as"," ",(0,t.jsx)("span",{className:"stg:font-medium stg:text-foreground",children:c}),"."]}),(0,t.jsxs)("p",{className:"stg:text-xs stg:text-muted-foreground",children:["Conversations from Slack are billed to"," ",(0,t.jsx)("span",{className:"stg:font-medium",children:g(u)}),". A workspace can host one agent per Slack app."]}),A&&(0,t.jsx)(ss,{error:A,channelAppsHref:i})]}):(0,t.jsx)(K.f,{children:"Channel installs require Stigmer Cloud. This server manages channel configuration, but connecting to Slack uses the platform's hosted Slack app."})}),(0,t.jsx)("div",{className:"stg:flex stg:justify-end stg:gap-2 stg:border-t stg:border-border stg:px-5 stg:py-3",children:w||!d?(0,t.jsx)(B.f,{variant:"outline",size:"sm",onClick:l,children:w?"Done":"Close"}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(B.f,{variant:"ghost",size:"sm",onClick:l,disabled:V,children:"Cancel"}),(0,t.jsx)(B.f,{variant:"primary",size:"sm",onClick:()=>void U(),disabled:V,icon:(0,t.jsx)(t7.f,{className:"stg:size-3.5"}),"data-cursor-target":"dialog-connect-slack",children:A?"Try again":n?"Reconnect to Slack":"Connect to Slack"})]})})]})}function ss({error:e,channelAppsHref:s}){let n=(0,W.k)(e);if(n?.reason!=="SLACK_WORKSPACE_ALREADY_CONNECTED")return(0,t.jsx)(t4,{error:e});let a=n.metadata.team_name||"This workspace";return(0,t.jsxs)(t6,{children:[(0,t.jsxs)("p",{children:[(0,t.jsx)("span",{className:"stg:font-medium",children:a})," already hosts an agent through this app — a workspace hosts one agent per Slack app."]}),(0,t.jsxs)("p",{children:["To reach it with this agent, disconnect the existing channel, or"," ",(0,t.jsx)(tG,{channelAppsHref:s,children:"register a channel app"})," ","and connect through that instead."]})]})}function sn({botName:e,channels:s}){return(0,t.jsx)("div",{role:"status",className:"stg:space-y-0.5 stg:text-xs stg:text-status-degraded",children:s.map(s=>{let n=s.status?.typeStatus?.case==="slack"?s.status.typeStatus.value:null,a=n?.teamName||n?.teamId||"a workspace",r=s.spec?.agentRef?.slug||"another agent";return(0,t.jsxs)("p",{children:[(0,t.jsx)("span",{className:"stg:font-medium",children:e})," already serves"," ",(0,t.jsx)("span",{className:"stg:font-medium",children:a})," via ",r," — a workspace hosts one agent per app, so connect through a different channel app to reach it."]},s.metadata?.id??a)})})}let sa=[{phase:"initiating",label:"Contacting Slack"},{phase:"awaiting-callback",label:"Waiting for your approval in the Slack window"},{phase:"completing",label:"Finalizing the connection"}];function sr({phase:e,onCancel:s}){let n=sa.findIndex(t=>t.phase===e);return(0,t.jsxs)("div",{className:"stg:space-y-3","aria-live":"polite",children:[(0,t.jsx)("ul",{className:(0,a.f)(Q.J,"stg:space-y-2"),children:sa.map((e,s)=>{let r=s===n,l=n>s;return(0,t.jsxs)("li",{className:(0,a.f)("stg:flex stg:items-center stg:gap-2 stg:text-sm",r?"stg:text-foreground":l?"stg:text-muted-foreground":"stg:text-muted-foreground-subtle"),children:[l?(0,t.jsx)(t1,{className:"stg:size-3.5 stg:shrink-0 stg:text-status-ready"}):r?(0,t.jsx)(t5,{className:"stg:size-3.5 stg:shrink-0"}):(0,t.jsx)("span",{className:"stg:size-3.5 stg:shrink-0 stg:rounded-full stg:border stg:border-border","aria-hidden":"true"}),e.label]},e.phase)})}),(0,t.jsx)(B.f,{variant:"ghost",size:"xs",onClick:s,children:"Cancel"})]})}function sl({channel:e,agentName:s,botName:n}){let a=e.status?.typeStatus?.case==="slack"?e.status.typeStatus.value:null;return(0,t.jsxs)("div",{className:"stg:space-y-2",role:"status",children:[(0,t.jsxs)("div",{className:"stg:flex stg:items-center stg:gap-2 stg:text-sm stg:font-medium stg:text-foreground",children:[(0,t.jsx)(t1,{className:"stg:size-4 stg:text-status-ready"}),"Connected",a?.teamName?` to ${a.teamName}`:""]}),(0,t.jsxs)("p",{className:"stg:text-sm stg:text-muted-foreground",children:["In Slack, open a direct message with"," ",(0,t.jsx)("span",{className:"stg:font-medium stg:text-foreground",children:n})," — or type @ in any channel and pick"," ",(0,t.jsx)("span",{className:"stg:font-medium stg:text-foreground",children:n})," from the list — then ask your question. Answers come from"," ",(0,t.jsx)("span",{className:"stg:font-medium stg:text-foreground",children:s}),"."]})]})}var si=e.i(582688);function so({open:e,onOpenChange:n,agent:a,channel:r,onChannelsChanged:l,modal:i=!0,channelAppsHref:o}){let g=(0,s.useId)(),d=(0,s.useCallback)(()=>{n(!1)},[n]);return(0,t.jsx)(X.f,{open:e,onOpenChange:n,modal:i,width:"md","aria-labelledby":g,children:e&&(0,t.jsx)(sg,{agent:a,channel:r??null,onChannelsChanged:l,onClose:d,channelAppsHref:o,titleId:g})})}function sg({agent:e,channel:n,onChannelsChanged:r,onClose:l,channelAppsHref:i,titleId:o}){let g=(0,R.b)(),d=(0,b.f)(),c=(0,tY.P)((0,J.T)()),u=e.metadata?.name||e.metadata?.slug||"this agent",m=e.metadata?.org??"",{createChannel:x,isPending:h}=ed(),{update:v,isPending:j}=eu(),y=function(){let e=(0,b.f)(),[t,n]=(0,s.useState)("idle"),[a,r]=(0,s.useState)(null),l=(0,s.useCallback)(()=>{n("idle"),r(null)},[]);return{install:(0,s.useCallback)(async t=>{n("installing"),r(null);try{if(!(await e.channel.initiateInstall((0,f.f)(p.k,{resourceId:t}))).completed)throw Error("This channel's provider requires an interactive install — connect it through its provider flow instead.");n("done")}catch(t){let e=(0,eg.f)(t);throw r(e),n("idle"),e}},[e]),isInProgress:"installing"===t,phase:t,error:a,clearError:l}}(),[N,k]=(0,s.useState)(()=>n?n.metadata?.name??"":`${u} WhatsApp`),[C,w]=(0,s.useState)(()=>n?.spec?.type?.case==="whatsapp"?n.spec.type.value.phoneNumberId:""),[S,A]=(0,s.useState)([]),[$,T]=(0,s.useState)(()=>{let e=n?.spec?.type?.case==="whatsapp"?n.spec.type.value.appRef:void 0;return e?.slug?{org:e.org||m,slug:e.slug}:null}),[L,M]=(0,s.useState)(null),[I,z]=(0,s.useState)(null),{channelApps:E}=(0,H.f)(m||null),O=(0,s.useMemo)(()=>E.filter(e=>e.spec?.providerConfig?.case==="whatsapp"),[E]),D=$??(1===O.length?{org:m,slug:O[0].metadata?.slug??""}:null),W=D?O.find(e=>e.metadata?.slug===D.slug)??null:null,U=c&&!L,{channels:F}=(0,t9.f)(U&&m?m:null),V=C.trim(),_=(0,s.useMemo)(()=>{let e=W?.metadata?.id;return e&&V?F.filter(t=>t.metadata?.id!==n?.metadata?.id&&t.status?.installState===P.t.installed&&t.status?.typeStatus?.case==="whatsapp"&&t.status.typeStatus.value.phoneNumberId===V&&t.status.typeStatus.value.channelAppId===e):[]},[F,W,V,n]),q=(0,s.useCallback)(async()=>{z(null);try{let t=n;if(t){let e=t.spec?.type?.case==="whatsapp"?t.spec.type.value:void 0,s=e?.phoneNumberId??"",n=e?.appRef?.slug??"";(s!==V||n!==(D?.slug??""))&&(t=await v(t,{whatsapp:{phoneNumberId:V,...D?{appRef:D}:{}}}),r?.())}else t=await x({name:N.trim()||`${u} WhatsApp`,org:m,agentRef:{org:m,slug:e.metadata?.slug??""},enabled:!0,whatsapp:{phoneNumberId:V,...D?{appRef:D}:{}},...S.length>0?{vaults:S}:{}}),r?.();await y.install(t.metadata?.id??"");let s=await d.channel.get(t.metadata?.id??"");M(s),r?.()}catch(e){z(y.error??(e instanceof Error?e:Error(String(e))))}},[e,u,n,x,D,S,y,N,m,r,v,d,V]),Y=h||j||y.isInProgress,X=""!==V&&null!==D&&!Y;return(0,t.jsxs)("div",{className:"stg:flex stg:flex-col",children:[(0,t.jsxs)("div",{className:"stg:flex stg:items-start stg:justify-between stg:gap-3 stg:border-b stg:border-border stg:px-5 stg:py-4",children:[(0,t.jsxs)("div",{className:"stg:flex stg:items-center stg:gap-2.5",children:[(0,t.jsx)(si.f,{className:"stg:size-5 stg:text-foreground"}),(0,t.jsx)("h2",{id:o,className:"stg:text-sm stg:font-semibold stg:text-foreground",children:n?"Reconnect to WhatsApp":"Connect to WhatsApp"})]}),(0,t.jsx)("button",{type:"button",onClick:l,"aria-label":"Close dialog",className:(0,a.f)("stg:rounded stg:p-1 stg:text-muted-foreground","stg:hover:bg-accent-hover stg:hover:text-foreground","stg:focus:outline-none stg:focus:ring-1 stg:focus:ring-ring"),children:(0,t.jsx)(t0,{})})]}),(0,t.jsx)("div",{className:"stg:space-y-4 stg:px-5 stg:py-4",children:c?L?(0,t.jsx)(sm,{channel:L,agentName:u}):Y?(0,t.jsx)(su,{}):(0,t.jsxs)(t.Fragment,{children:[!n&&(0,t.jsxs)("label",{className:"stg:block",children:[(0,t.jsx)("span",{className:"stg:mb-1.5 stg:block stg:text-xs stg:font-medium stg:text-foreground",children:"Channel name"}),(0,t.jsx)("input",{type:"text",value:N,onChange:e=>k(e.target.value),disabled:Y,className:(0,a.f)("stg:w-full stg:rounded-md stg:border stg:border-input stg:bg-background stg:px-3 stg:py-1.5","stg:text-sm stg:text-foreground stg:placeholder:text-muted-foreground","stg:focus:outline-none stg:focus:ring-1 stg:focus:ring-ring")}),(0,t.jsx)("span",{className:"stg:mt-1 stg:block stg:text-xs stg:text-muted-foreground",children:"Names the connection in Stigmer — pick something that identifies the number if you connect more than one."})]}),(0,t.jsxs)("label",{className:"stg:block",children:[(0,t.jsx)("span",{className:"stg:mb-1.5 stg:block stg:text-xs stg:font-medium stg:text-foreground",children:"Phone number ID"}),(0,t.jsx)("input",{type:"text",value:C,onChange:e=>w(e.target.value),disabled:Y,required:!0,placeholder:"106540352242922","data-cursor-target":"dialog-whatsapp-number",className:(0,a.f)("stg:w-full stg:rounded-md stg:border stg:border-input stg:bg-background stg:px-3 stg:py-1.5","stg:font-mono stg:text-sm stg:text-foreground stg:placeholder:text-muted-foreground","stg:focus:outline-none stg:focus:ring-1 stg:focus:ring-ring")}),(0,t.jsx)("span",{className:"stg:mt-1 stg:block stg:text-xs stg:text-muted-foreground",children:"From Meta's WhatsApp Manager (API Setup) — the numeric ID of the number this agent should answer, not the phone number itself."})]}),(0,t.jsx)(tQ,{org:m,apps:O,value:D,onChange:T,disabled:Y,channelAppsHref:i,idPrefix:"stgm-whatsapp-app",appHint:"Your Meta app — its credentials verify and serve the number",emptyBody:(0,t.jsxs)("p",{className:"stg:text-xs stg:text-muted-foreground",children:["WhatsApp channels connect through your own Meta app — there is no shared platform app."," ",(0,t.jsx)(tG,{channelAppsHref:i,children:"Register a channel app"})," ","with your Meta app's credentials first, then connect here."]})}),_.length>0&&(0,t.jsx)(sc,{channels:_}),!n&&(0,t.jsx)(t3,{agent:e,org:m,value:S,onChange:A,disabled:Y}),(0,t.jsx)("p",{className:"stg:text-sm stg:text-muted-foreground",children:"When you continue, Stigmer verifies the number with WhatsApp through the selected app's credentials — the connection completes right here, with no browser hand-off."}),(0,t.jsxs)("p",{className:"stg:text-sm stg:text-muted-foreground",children:["People reach the agent by sending a WhatsApp message to the connected number — it answers as"," ",(0,t.jsx)("span",{className:"stg:font-medium stg:text-foreground",children:u}),"."]}),(0,t.jsxs)("p",{className:"stg:text-xs stg:text-muted-foreground",children:["Conversations from WhatsApp are billed to"," ",(0,t.jsx)("span",{className:"stg:font-medium",children:g(m)}),". Each number serves one agent per channel app."]}),I&&(0,t.jsx)(sd,{error:I,channelAppsHref:i})]}):(0,t.jsx)(K.f,{children:"Channel installs require Stigmer Cloud. This server manages channel configuration, but connecting to WhatsApp verifies your number through Stigmer's hosted webhook infrastructure."})}),(0,t.jsx)("div",{className:"stg:flex stg:justify-end stg:gap-2 stg:border-t stg:border-border stg:px-5 stg:py-3",children:L||!c?(0,t.jsx)(B.f,{variant:"outline",size:"sm",onClick:l,children:L?"Done":"Close"}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(B.f,{variant:"ghost",size:"sm",onClick:l,disabled:Y,children:"Cancel"}),(0,t.jsx)(B.f,{variant:"primary",size:"sm",onClick:()=>void q(),disabled:!X,icon:(0,t.jsx)(si.f,{className:"stg:size-3.5"}),"data-cursor-target":"dialog-connect-whatsapp",children:I?"Try again":n?"Reconnect to WhatsApp":"Connect to WhatsApp"})]})})]})}function sd({error:e,channelAppsHref:s}){let n=(0,W.k)(e);if(n?.reason!=="WHATSAPP_NUMBER_ALREADY_CONNECTED")return(0,t.jsx)(t4,{error:e});let a=n.metadata.display_phone_number||"This number";return(0,t.jsxs)(t6,{children:[(0,t.jsxs)("p",{children:[(0,t.jsx)("span",{className:"stg:font-medium",children:a})," is already connected to an agent through this channel app — each number serves one agent."]}),(0,t.jsxs)("p",{children:["To reach it with this agent, disconnect the existing channel, use a different number, or"," ",(0,t.jsx)(tG,{channelAppsHref:s,children:"register a channel app"})," ","and connect through that instead."]})]})}function sc({channels:e}){return(0,t.jsx)("div",{role:"status",className:"stg:space-y-0.5 stg:text-xs stg:text-status-degraded",children:e.map(e=>{let s=e.status?.typeStatus?.case==="whatsapp"?e.status.typeStatus.value:null,n=s?.displayPhoneNumber||s?.phoneNumberId||"this number",a=e.spec?.agentRef?.slug||"another agent";return(0,t.jsxs)("p",{children:[(0,t.jsx)("span",{className:"stg:font-medium",children:n})," is already served via ",a," — each number serves one agent per channel app, so disconnect that channel or pick a different number."]},e.metadata?.id??n)})})}function su(){return(0,t.jsxs)("div",{className:"stg:flex stg:items-center stg:gap-2 stg:text-sm stg:text-foreground","aria-live":"polite",children:[(0,t.jsx)(t5,{className:"stg:size-3.5 stg:shrink-0"}),"Verifying the number with WhatsApp…"]})}function sm({channel:e,agentName:s}){let n=e.status?.typeStatus?.case==="whatsapp"?e.status.typeStatus.value:null,a=n?.displayPhoneNumber||n?.phoneNumberId||null;return(0,t.jsxs)("div",{className:"stg:space-y-2",role:"status",children:[(0,t.jsxs)("div",{className:"stg:flex stg:items-center stg:gap-2 stg:text-sm stg:font-medium stg:text-foreground",children:[(0,t.jsx)(t1,{className:"stg:size-4 stg:text-status-ready"}),"Connected",a?` to ${a}`:"",n?.verifiedName?` (${n.verifiedName})`:""]}),(0,t.jsxs)("p",{className:"stg:text-sm stg:text-muted-foreground",children:["Send a WhatsApp message to"," ",(0,t.jsx)("span",{className:"stg:font-medium stg:text-foreground",children:a??"the connected number"})," ","and ask your question — answers come from"," ",(0,t.jsx)("span",{className:"stg:font-medium stg:text-foreground",children:s}),"."]})]})}var sx=e.i(862749),sh=e.i(465261);let sf=(0,A.f)("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);var sp=e.i(649582);function sb({agent:e,channel:n,channelApps:a,connectAvailable:r,onConnectClick:i,onDeleteClick:o,onEditCredentials:g,onViewConversations:u,onViewTemplates:m,onEditYaml:f,onEditRunConfig:p,refetch:b}){let v=n.metadata,j=v?.id??"",y=n.spec?.enabled??!1,N=sj(n),k=n.spec?.type,C=k?.case==="slack"||k?.case==="whatsapp"?k.value.appRef:void 0,w=C?.slug||null,A=w?a.find(e=>e.metadata?.slug===w)?.metadata?.name||w:null,$=(0,d.Q)(C)?(0,d.$)(l.X.channel_app):A,T=(0,tY.T)(n.spec?.type?.case)??tY.V[0],L=tk(n.spec?.type?.case)??ty,{update:M,isPending:R}=eu(),{allowed:I}=(0,h.f)({kind:"channel",id:j},"can_edit"),{allowed:z}=(0,h.f)({kind:"channel",id:j},"can_delete"),E=(0,x.f)({resource:j?{kind:l.X.channel,kindString:"channel",id:j,org:v?.org??"",name:v?.name||v?.slug}:null}),O=(0,s.useCallback)(async e=>{try{await M(n,{enabled:e}),U.c.success(e?"Channel turned on":"Channel turned off"),b()}catch(e){U.c.error((0,c.q)(e,"channel"))}},[M,n,b]),D=v?.name||v?.slug||"—";return(0,t.jsxs)(tV,{Icon:T.Icon,typeLabel:T.label,name:D,state:(0,t.jsx)(sy,{state:N}),details:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"stg:mt-0.5 stg:text-xs stg:text-muted-foreground",children:L.describeChannel(n)}),(0,t.jsx)("p",{className:"stg:mt-0.5 stg:text-xs stg:text-muted-foreground-faint",children:L.servingLine($)})]}),controls:(0,t.jsxs)(t.Fragment,{children:[I&&N===P.t.installed&&(0,t.jsx)(ee.f,{checked:y,onCheckedChange:e=>void O(e),disabled:R,"aria-label":`Turn ${v?.name||v?.slug||"channel"} ${y?"off":"on"}`}),I&&r&&N!==P.t.installed&&(0,t.jsx)(B.f,{variant:"outline",size:"xs",onClick:i,children:N===P.t.revoked?"Reconnect":"Connect"}),(0,t.jsxs)(tF.f,{children:[(0,t.jsx)(tF.f.Trigger,{"aria-label":`Actions for ${v?.name||v?.slug}`,children:(0,t.jsx)(tW.f,{className:"stg:size-4"})}),(0,t.jsxs)(tF.f.Content,{children:[(0,t.jsx)(tF.f.Item,{icon:(0,t.jsx)(S.f,{}),onSelect:u,"data-cursor-target":"channel-conversations",children:"Sessions"}),E.action&&(0,t.jsx)(tF.f.Item,{icon:(0,t.jsx)(sf,{}),onSelect:E.open,children:"Manage access"}),I&&T.supportsMessageTemplates&&(0,t.jsx)(tF.f.Item,{icon:(0,t.jsx)(tv.f,{}),onSelect:m,"data-cursor-target":"channel-templates",children:"Templates"}),I&&(0,t.jsx)(tF.f.Item,{icon:(0,t.jsx)(sp.f,{}),onSelect:p,"data-cursor-target":"channel-run-config",children:"Run settings"}),I&&(0,t.jsx)(tF.f.Item,{icon:(0,t.jsx)(sh.f,{}),onSelect:g,children:"Tool credentials"}),I&&(0,t.jsx)(tF.f.Item,{icon:(0,t.jsx)(sx.f,{}),onSelect:f,children:"Edit YAML"}),z&&(0,t.jsx)(tF.f.Item,{icon:(0,t.jsx)(tB.f,{}),variant:"destructive",onSelect:o,children:"Disconnect"})]})]})]}),children:[(0,t.jsx)(sv,{agent:e,channel:n,canEdit:I,onEditCredentials:g}),E.dialog]})}function sv({agent:e,channel:s,canEdit:n,onEditCredentials:r}){let l=tt(e,(s.spec?.enabled??!1)&&sj(s)===P.t.installed,s.spec?.vaults??[]);if("needs-credentials"!==l.status&&"blocked"!==l.status)return null;let i="needs-credentials"===l.status?"This agent uses tools, but this channel names no vault — workspace messages that need a tool will be refused.":`Vault${l.unusableVaults.length>1?"s":""} ${l.unusableVaults.join(", ")} ${l.unusableVaults.length>1?"are":"is"} not a shared vault you can read — name a shared vault so workspace messages can use its keys.`;return(0,t.jsxs)("p",{className:"stg:mt-2 stg:text-xs stg:text-status-degraded",role:"status",children:[i,n&&(0,t.jsxs)(t.Fragment,{children:[" ",(0,t.jsx)("button",{type:"button",onClick:r,className:(0,a.f)("stg:font-medium stg:underline stg:underline-offset-2","stg:hover:text-foreground","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring stg:rounded"),children:"Bind credentials"})]})]})}function sj(e){return e.status?.installState??P.t.channel_install_state_unspecified}function sy({state:e}){switch(e){case P.t.installed:return(0,t.jsx)(t_,{label:"Installed",tone:"success"});case P.t.revoked:return(0,t.jsx)(t_,{label:"Revoked",tone:"destructive"});default:return(0,t.jsx)(t_,{label:"Pending install",tone:"muted"})}}function sN({agent:e,buildChatLinkUrl:n,onConnectExternal:r,channelAppsHref:l,sessionHref:i,channelList:o,className:g}){let d=e.metadata?.id??"",c=N(o?"":d,e.metadata?.org??""),{channels:u,isLoading:m,error:x,refetch:f}=o??c,{channelApps:p}=(0,H.f)(e.metadata?.org||null),{canAdd:v,options:j}=function(e,t={}){let{onConnectExternal:n}=t,{allowed:a}=function(e){let t=e?.metadata?.id??"",s=e?.metadata?.org??"",{allowed:n}=(0,h.f)(t?{kind:"agent",id:t}:null,"can_manage_audience"),{allowed:a}=(0,h.f)(s?{kind:"organization",id:s}:null,"can_create_channel");return{allowed:!!e&&n&&a}}(e),r=(0,tY.P)((0,J.T)()),l=void 0!==n;return(0,s.useMemo)(()=>({canAdd:a,options:tK.map(e=>(function(e,t,s,n){if(!t)return{type:e,available:!1,via:null,reason:"Needs an organization admin who owns this agent"};let a=e.provider;return null===a?{type:e,available:!0,via:"dialog",reason:null}:"redirect"===a.installStyle&&n?{type:e,available:!0,via:"external",reason:null}:s?{type:e,available:!0,via:"dialog",reason:null}:{type:e,available:!1,via:null,reason:"Needs Stigmer Cloud"}})(e,a,r,l))}),[a,r,l])}(e,{onConnectExternal:r}),y=(0,tY.P)((0,J.T)()),{deleteChannel:k}=function(){let e=(0,b.f)(),[t,n]=(0,s.useState)(!1),[a,r]=(0,s.useState)(null),l=(0,s.useCallback)(()=>r(null),[]);return{deleteChannel:(0,s.useCallback)(async t=>{n(!0),r(null);try{return await e.channel.delete(t)}catch(e){throw r((0,eg.f)(e)),e}finally{n(!1)}},[e]),isDeleting:t,error:a,clearError:l}}(),{confirmState:C,confirm:w,handleConfirm:S,handleCancel:A}=(0,q.f)(),[$,T]=(0,s.useState)(null),[L,M]=(0,s.useState)(null),[R,I]=(0,s.useState)(null),[z,E]=(0,s.useState)(null),[O,B]=(0,s.useState)(null),[F,V]=(0,s.useState)(null),[X,Q]=(0,s.useState)(null),G=(0,s.useCallback)((e,t)=>{"redirect"===t.installStyle&&r?r(e):M(e?{mode:"reconnect",channel:e}:{mode:"create",provider:t})},[r]),Z=(0,s.useCallback)(e=>{let t=e.type.provider;null===t?T({mode:"create"}):G(null,t)},[G]),ee=(0,s.useCallback)(async e=>{let t=e.metadata?.name||e.metadata?.slug||"this channel",s=e.spec?.type?.case==="web";if(await w(s?{title:"Delete chat link?",description:`The link ${(0,D.o)(e.metadata?.id??"")} stops working immediately — including for visitors mid-conversation — and its configuration (origins, messages, credential bindings) is gone. To stop serving while keeping the configuration, turn it off instead.`,confirmLabel:"Delete",variant:"destructive"}:{title:"Disconnect channel?",description:(tk(e.spec?.type?.case)??ty).disconnectDescription(t),confirmLabel:"Disconnect",variant:"destructive"}))try{await k(e.metadata?.id??""),U.c.success(s?"Chat link deleted":"Channel disconnected"),f()}catch(e){U.c.error((0,W.g)(e))}},[w,k,f]),et=(0,s.useCallback)(e=>y||"redirect"===e.installStyle&&!!r,[y,r]),es=(0,s.useMemo)(()=>u.some(e=>{let t=e.spec?.type?.case;if("web"===t)return!1;let s=(0,tY.T)(t)??tY.V[0];return sj(e)!==P.t.installed&&!et(s)}),[u,et]);if(m)return(0,t.jsx)(sw,{});if(x)return(0,t.jsx)("div",{className:"stg:py-8 stg:text-center stg:text-sm stg:text-destructive",children:"Failed to load channels"});let en=null===L?null:"create"===L.mode?L.provider:(0,tY.T)(L.channel.spec?.type?.case)??tY.V[0];return(0,t.jsxs)("div",{className:(0,a.f)("stg:space-y-3",g),children:[es&&(0,t.jsx)(K.f,{children:"Channel installs require Stigmer Cloud — connecting an agent to Slack or WhatsApp runs through the platform's hosted webhook infrastructure. Channel configuration still works here."}),0===u.length?(0,t.jsx)(sC,{options:v?j:[],onAddClick:Z}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"stg:flex stg:items-center stg:justify-between stg:gap-2",children:[(0,t.jsxs)("h3",{className:"stg:text-sm stg:font-medium stg:text-foreground",children:[u.length," ",1===u.length?"channel":"channels"]}),v&&(0,t.jsx)(sk,{options:j,onAddClick:Z})]}),(0,t.jsx)("div",{className:"stg:space-y-2",children:u.map(s=>{if(s.spec?.type?.case==="web")return(0,t.jsx)(tX,{channel:s,buildChatLinkUrl:n,onEditClick:()=>T({mode:"edit",channel:s}),onDeleteClick:()=>void ee(s),refetch:f},s.metadata?.id);let a=(0,tY.T)(s.spec?.type?.case)??tY.V[0];return(0,t.jsx)(sb,{agent:e,channel:s,channelApps:p,connectAvailable:et(a),onConnectClick:()=>G(s,a),onDeleteClick:()=>void ee(s),onEditCredentials:()=>I(s),onViewConversations:()=>E(s),onViewTemplates:()=>B(s),onEditYaml:()=>V(s),onEditRunConfig:()=>Q(s),refetch:f},s.metadata?.id)})})]}),$&&(0,t.jsx)(eL,{open:!0,onOpenChange:e=>{e||T(null)},agent:e,channel:"edit"===$.mode?$.channel:void 0,buildChatLinkUrl:n,onChannelsChanged:f}),L&&en?.id==="whatsapp"?(0,t.jsx)(so,{open:!0,onOpenChange:e=>{e||M(null)},agent:e,channel:"reconnect"===L.mode?L.channel:void 0,onChannelsChanged:f,channelAppsHref:l}):L?(0,t.jsx)(se,{open:!0,onOpenChange:e=>{e||M(null)},agent:e,channel:"reconnect"===L.mode?L.channel:void 0,onChannelsChanged:f,channelAppsHref:l}):null,R&&(0,t.jsx)(tr,{open:!0,onOpenChange:e=>{e||I(null)},agent:e,channel:R,onSaved:f}),z&&(0,t.jsx)(e6,{open:!0,onOpenChange:e=>{e||E(null)},channel:z,sessionHref:i}),O&&(0,t.jsx)(t$,{open:!0,onOpenChange:e=>{e||B(null)},channel:O,onEditYaml:()=>{B(null),V(O)}}),F&&(0,t.jsx)(Y.f,{open:!0,onOpenChange:e=>{e||V(null)},resource:F,onApplied:f}),X&&(0,t.jsx)(tu,{open:!0,onOpenChange:e=>{e||Q(null)},channel:X,onSaved:f}),(0,t.jsx)(_.f,{state:C,onConfirm:S,onCancel:A})]})}function sk({options:e,onAddClick:s}){return(0,t.jsxs)(V.k,{children:[(0,t.jsxs)(V.g,{render:(0,t.jsx)(B.f,{variant:"outline",size:"xs",icon:(0,t.jsx)(O.f,{className:"stg:size-3"}),"data-cursor-target":"add-channel"}),children:["Add channel",(0,t.jsx)(E.f,{className:"stg:size-3","aria-hidden":"true"})]}),(0,t.jsx)(V.A,{align:"end",className:"stg:w-auto stg:min-w-56",children:e.map(e=>(0,t.jsxs)(V.d,{disabled:!e.available,onClick:()=>s(e),"data-cursor-target":e.type.addCursorTarget,className:"stg:items-start",children:[(0,t.jsx)(e.type.Icon,{className:"stg:mt-0.5 stg:size-4"}),(0,t.jsxs)("span",{className:"stg:flex stg:flex-col",children:[(0,t.jsx)("span",{children:e.type.label}),e.reason&&(0,t.jsx)("span",{className:"stg:text-xs stg:text-muted-foreground",children:e.reason})]})]},e.type.id))})]})}function sC({options:e,onAddClick:s}){let n=e.filter(e=>e.available),a=[...new Set(e.filter(e=>!e.available).map(e=>e.reason))].map(t=>{let s=e.filter(e=>!e.available&&e.reason===t).map(e=>e.type.label),n=s.length>1?"need ":"needs ";return`${s.join(" and ")} ${(t??"").replace(/^Needs /,n)}.`});return(0,t.jsxs)(F.f,{variant:"first-use",icon:(0,t.jsx)("span",{className:"stg:flex stg:items-center stg:gap-2",children:tK.map(e=>(0,t.jsx)(e.Icon,{className:"stg:size-10"},e.id))}),title:"No channels yet",description:"Give this agent a chat link to send or embed, or connect it to Slack or WhatsApp so people chat with it right where they work — with policy, rate limits, and billing enforced by Stigmer.",children:[n.length>0&&(0,t.jsx)("span",{className:"stg:flex stg:flex-wrap stg:items-center stg:justify-center stg:gap-2",children:n.map(e=>(0,t.jsx)(B.f,{variant:"primary",icon:(0,t.jsx)(e.type.Icon,{className:"stg:size-3"}),onClick:()=>s(e),"data-cursor-target":e.type.addCursorTarget,children:e.type.addLabel},e.type.id))}),a.length>0&&n.length>0&&(0,t.jsx)("span",{className:"stg:mt-2 stg:block stg:text-xs stg:text-muted-foreground",children:a.join(" ")})]})}function sw(){return(0,t.jsx)("div",{className:"stg:space-y-2 stg:py-4",children:[1,2].map(e=>(0,t.jsx)("div",{className:"stg:h-20 stg:animate-pulse stg:rounded-lg stg:bg-muted-faint"},e))})}var sS=e.i(668093),sA=e.i(652337),s$=e.i(267912),sT=e.i(141249),sL=e.i(188546);let sM={agent:"Agent",plugin:"Plugin","mcp-server":"MCP server",skill:"Skill",subagent:"Subagent"};function sR({node:e,depth:n,onNodeClick:r,defaultExpanded:l}){let i=e.children.length>0,o="agent"===e.kind,g=!o&&i,d=o&&i,[c,u]=(0,s.useState)(l),m=null!=e.ref&&null!=r,x=d||g&&c,h=(0,s.useCallback)(()=>{g?u(e=>!e):m&&r(e)},[g,m,r,e]),f=(0,s.useCallback)(e=>{g&&("ArrowRight"!==e.key||c?"ArrowLeft"===e.key&&c&&(e.preventDefault(),u(!1)):(e.preventDefault(),u(!0)))},[g,c]),p=(0,t.jsxs)("div",{className:"stg:flex stg:min-w-0 stg:items-center stg:gap-2",children:[g&&(0,t.jsx)(sO,{className:(0,a.f)("stg:size-3.5 stg:shrink-0 stg:text-muted-foreground stg:transition-transform",c&&"stg:rotate-90")}),(0,t.jsx)(sI,{kind:e.kind,className:"stg:size-4 stg:shrink-0 stg:text-muted-foreground"}),!o&&(0,t.jsx)("span",{className:(0,a.f)("stg:shrink-0 stg:rounded stg:px-1.5 stg:py-px stg:text-2xs stg:font-medium stg:leading-tight",function(e){switch(e){case"plugin":case"mcp-server":return"stg:bg-[var(--stgm-status-running-subtle)] stg:text-[var(--stgm-status-running)]";case"skill":return"stg:bg-[var(--stgm-status-pending-subtle)] stg:text-[var(--stgm-status-pending)]";case"subagent":return"stg:bg-[var(--stgm-status-ready-subtle)] stg:text-[var(--stgm-status-ready)]";case"agent":return"stg:bg-muted stg:text-muted-foreground"}}(e.kind)),children:sM[e.kind]}),(0,t.jsx)("span",{className:"stg:min-w-0 stg:truncate stg:text-sm stg:font-medium stg:text-foreground",children:e.qualifiedLabel??e.label}),e.metadata&&Object.entries(e.metadata).map(([e,s])=>(0,t.jsx)("span",{className:"stg:shrink-0 stg:text-xs stg:text-muted-foreground",children:s},e))]}),b=g||m;return(0,t.jsxs)("li",{role:"treeitem","aria-expanded":g?c:!!d||void 0,className:(0,a.f)("stg:list-none",n>0&&"stg:relative stg:before:absolute stg:before:left-[-12px] stg:before:top-[14px] stg:before:h-px stg:before:w-3 stg:before:bg-border stg:before:content-['']"),children:[b?(0,t.jsx)("button",{type:"button",onClick:h,onKeyDown:f,tabIndex:-1,className:(0,a.f)("stg:flex stg:w-full stg:items-center stg:rounded-md stg:px-2 stg:py-1.5 stg:text-left stg:transition-colors","stg:hover:bg-accent-hover","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-inset stg:focus-visible:ring-ring"),children:p}):(0,t.jsx)("div",{className:"stg:flex stg:items-center stg:px-2 stg:py-1.5",children:p}),e.description&&!o&&(0,t.jsx)("p",{className:(0,a.f)("stg:px-2 stg:pb-1 stg:text-xs stg:text-muted-foreground",g?"stg:ml-[calc(0.5rem+14px+0.5rem)]":"stg:ml-2"),children:e.description}),x&&(0,t.jsx)("ul",{role:"group",className:(0,a.f)(Q.J,"stg:relative stg:ml-[11px] stg:border-l stg:border-border stg:pl-3"),children:e.children.map(e=>(0,t.jsx)(sR,{node:e,depth:n+1,onNodeClick:r,defaultExpanded:l},e.id))})]})}function sI({kind:e,className:s}){switch(e){case"agent":case"subagent":return(0,t.jsx)(sz,{className:s});case"plugin":return(0,t.jsx)(sT.f,{className:s});case"mcp-server":return(0,t.jsx)(sL.f,{className:s});case"skill":return(0,t.jsx)(sE,{className:s})}}function sz({className:e}){return(0,t.jsxs)("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,t.jsx)("rect",{x:"3",y:"5",width:"10",height:"8",rx:"1.5"}),(0,t.jsx)("path",{d:"M6 9h.01M10 9h.01",strokeWidth:"2"}),(0,t.jsx)("path",{d:"M8 2v3"})]})}function sE({className:e}){return(0,t.jsx)("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M9 1.5 4 9h4l-1 5.5L12 7H8l1-5.5Z"})})}function sO({className:e}){return(0,t.jsx)("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"m6 3 5 5-5 5"})})}function sD({tree:e,onNodeClick:n,defaultExpanded:r=!0,className:l}){let i=(0,s.useRef)(null),o=(0,s.useCallback)(e=>{let t=i.current;if(!t)return;let s=Array.from(t.querySelectorAll("[role='treeitem'] > button, [role='treeitem'] > div")).filter(e=>{let t=e.closest("[role='treeitem']")?.parentElement?.closest("[role='treeitem']");for(;t;){if("false"===t.getAttribute("aria-expanded"))return!1;t=t.parentElement?.closest("[role='treeitem']")}return!0});if(0===s.length)return;let n=document.activeElement,a=n?s.indexOf(n):-1,r=null;switch(e.key){case"ArrowDown":r=a<s.length-1?a+1:0;break;case"ArrowUp":r=a>0?a-1:s.length-1;break;case"Home":r=0;break;case"End":r=s.length-1;break;default:return}e.preventDefault(),s[r].focus()},[]),{root:g}=e;return(0,t.jsxs)("div",{className:(0,a.f)("stg:py-2",l),children:[(0,t.jsxs)("div",{className:"stg:mb-3 stg:flex stg:items-center stg:gap-2 stg:px-2",children:[(0,t.jsx)(sW,{className:"stg:size-4 stg:text-muted-foreground"}),(0,t.jsx)("h3",{className:"stg:text-xs stg:font-medium stg:uppercase stg:tracking-wider stg:text-muted-foreground",children:"Dependency Tree"}),(0,t.jsxs)("span",{className:"stg:text-xs stg:text-muted-foreground",children:[e.nodeCount," ",1===e.nodeCount?"node":"nodes"]})]}),(0,t.jsx)("ul",{ref:i,role:"tree","aria-label":`Dependencies of ${g.label}`,onKeyDown:o,className:(0,a.f)(Q.J,"stg:rounded-lg stg:border stg:border-border stg:p-2"),children:(0,t.jsx)(sR,{node:g,depth:0,onNodeClick:n,defaultExpanded:r})})]})}function sW({className:e}){return(0,t.jsxs)("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,t.jsx)("path",{d:"M8 2v4M8 6 4 10M8 6l4 4"}),(0,t.jsx)("circle",{cx:"8",cy:"2",r:"1",fill:"currentColor",stroke:"none"}),(0,t.jsx)("circle",{cx:"4",cy:"11",r:"1.5"}),(0,t.jsx)("circle",{cx:"8",cy:"11",r:"1.5"}),(0,t.jsx)("circle",{cx:"12",cy:"11",r:"1.5"})]})}function sP(e){return e.tools.length>0||e.disallowedTools.length>0}function sU({tools:e,disallowedTools:s,density:n="section"}){return sP({tools:e,disallowedTools:s})?(0,t.jsxs)("div",{className:(0,a.f)("stg:flex stg:flex-col","section"===n?"stg:gap-2 stg:p-3":"stg:gap-1.5"),children:[e.length>0&&(0,t.jsx)(sB,{label:"Only these tools",entries:e,density:n}),s.length>0&&(0,t.jsx)(sB,{label:"Never these tools",entries:s,density:n})]}):null}function sB({label:e,entries:s,density:n}){return(0,t.jsxs)("div",{className:"stg:flex stg:flex-col stg:gap-1",role:"group","aria-label":e,children:[(0,t.jsx)("span",{className:(0,a.f)("stg:font-medium stg:text-muted-foreground","section"===n?"stg:text-xs":"stg:text-2xs"),children:e}),(0,t.jsx)("ul",{className:(0,a.f)(Q.J,"stg:flex stg:flex-wrap stg:gap-1"),children:s.map(e=>(0,t.jsx)("li",{children:(0,t.jsx)("code",{className:"stg:rounded stg:bg-muted-subtle stg:px-1.5 stg:py-0.5 stg:font-mono stg:text-xs stg:text-foreground",children:e})},e))})]})}var sF=e.i(452926);function sV({hooks:e}){let s=e.flatMap(e=>"inline"===e.source.case?[e.source.value]:[]);return 0===s.length?null:(0,t.jsx)(sA.f,{title:"Hooks",count:s.length,children:(0,t.jsx)("ul",{className:(0,a.f)(Q.J,"stg:flex stg:flex-col stg:divide-y stg:divide-border"),"aria-label":"Hook sources",children:s.map((e,s)=>(0,t.jsxs)("li",{className:"stg:flex stg:min-w-0 stg:flex-col",children:[(0,t.jsx)("p",{className:"stg:px-3 stg:pt-2.5 stg:text-sm stg:font-medium stg:text-foreground",children:"Written in this agent"}),(0,t.jsx)(sF.f,{config:e})]},`inline:${s}`))})})}var sH=e.i(954884);function s_(e){return(0,ta.f)(e)}function sq({refs:e,agentOrg:n,self:r,editable:l,isSaving:i,error:o,onSave:g,onEditStart:c,onAgentClick:u}){let[m,x]=(0,s.useState)(!1),[h,f]=(0,s.useState)(!1),p=(0,s.useCallback)(()=>{x(e=>(e||c?.(),!e)),f(!1)},[c]),b=(0,s.useMemo)(()=>[...r?[{org:r.org,slug:r.slug}]:[],...e.map(e=>({org:e.org||n,slug:e.slug}))],[r,e,n]),v=(0,s.useCallback)(async t=>{t&&g&&await g([...e.map(s_),{org:t.org,slug:t.slug}])&&f(!1)},[e,g]),j=(0,s.useCallback)(async t=>{await g?.(e.filter((e,s)=>s!==t).map(s_))},[e,g]),y=(0,s.useCallback)(async t=>{await g?.(e.map((e,s)=>s===t?{...(0,ta.f)(e),version:""}:s_(e)))},[e,g]),N=e.length<20;return(0,t.jsx)(sA.f,{title:"Subagents",count:e.length,onEdit:l?p:void 0,children:(0,t.jsxs)("div",{className:"stg:flex stg:flex-col",children:[e.length>0?(0,t.jsx)("ul",{className:"stg:m-0 stg:flex stg:list-none stg:flex-col stg:divide-y stg:divide-border stg:p-0","aria-label":"Subagents",children:e.map((e,s)=>(0,t.jsx)(sY,{reference:e,agentOrg:n,canUpdate:!!l&&!!g,canRemove:!!l&&m,isSaving:i,onUpdate:()=>y(s),onRemove:()=>j(s),onAgentClick:u},(0,d.Q)(e)?`deleted/${s}`:`${e.org||n}/${e.slug}`))}):(0,t.jsx)("p",{className:"stg:px-3 stg:py-3 stg:text-xs stg:text-muted-foreground stg:italic",children:"No subagents. An agent hands work to the saved agents listed here."}),l&&m&&(0,t.jsx)("div",{className:"stg:border-t stg:border-border stg:px-3 stg:py-2",children:N?h?(0,t.jsxs)("div",{className:"stg:flex stg:flex-col stg:gap-2",children:[(0,t.jsx)(sH.f,{org:n,value:null,onChange:e=>void v(e),exclude:b,disabled:i}),(0,t.jsx)("div",{children:(0,t.jsx)("button",{type:"button",onClick:()=>f(!1),className:(0,a.f)("stg:rounded-md stg:px-2.5 stg:py-1 stg:text-xs stg:font-medium","stg:border stg:border-border stg:bg-background stg:text-foreground stg:hover:bg-accent","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring"),children:"Cancel"})})]}):(0,t.jsxs)("button",{type:"button",onClick:()=>f(!0),className:(0,a.f)("stg:inline-flex stg:items-center stg:gap-1 stg:rounded-md stg:px-2.5 stg:py-1.5 stg:text-xs stg:font-medium","stg:border stg:border-dashed stg:border-border stg:text-muted-foreground","stg:hover:border-muted-foreground stg:hover:text-foreground stg:hover:bg-muted-subtle","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring","stg:transition-colors"),children:[(0,t.jsx)(sK,{className:"stg:size-3"}),"Add subagent"]}):(0,t.jsxs)("p",{className:"stg:text-xs stg:text-muted-foreground",children:["An agent lists at most ",20," subagents."]})}),o&&(0,t.jsx)("p",{className:"stg:border-t stg:border-border stg:px-3 stg:py-2 stg:text-xs stg:text-destructive",role:"alert",children:o})]})})}function sY({reference:e,agentOrg:s,canUpdate:n,canRemove:r,isSaving:l,onUpdate:o,onRemove:g,onAgentClick:c}){let u=(0,R.b)(),m=e.org||s,x=(0,d.Q)(e),{agent:h,isLoading:f,error:p}=(0,i.f)(x?null:m,x?null:e.slug),b=x?"deleted agent":e.org&&e.org!==s?`${u(e.org)}/${e.slug}`:e.slug,v=e.version,j=h?.status?.versionHash??"",y=""!==v&&""!==j&&j!==v,N=!x&&!f&&!p&&null===h,k=(0,t.jsxs)("span",{className:"stg:flex stg:min-w-0 stg:items-center stg:gap-3",children:[(0,t.jsx)(sJ,{className:"stg:size-4 stg:shrink-0 stg:text-muted-foreground"}),(0,t.jsx)("span",{className:"stg:truncate stg:text-sm stg:font-medium stg:text-foreground",children:b})]});return(0,t.jsxs)("li",{className:"stg:flex stg:flex-col stg:gap-1 stg:px-3 stg:py-2",children:[(0,t.jsxs)("div",{className:"stg:flex stg:items-center stg:gap-3",children:[c&&!x?(0,t.jsx)("button",{type:"button",onClick:()=>c({org:m,slug:e.slug}),className:(0,a.f)("stg:min-w-0 stg:rounded-md stg:text-left","stg:hover:underline","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring"),children:k}):k,v&&(0,t.jsxs)("span",{className:"stg:shrink-0 stg:rounded stg:bg-muted stg:px-1.5 stg:py-0.5 stg:font-mono stg:text-2xs stg:text-muted-foreground",children:[(0,t.jsx)("span",{className:"stg:sr-only",children:"Pinned version "}),v.slice(0,8)]}),(0,t.jsxs)("span",{className:"stg:ml-auto stg:flex stg:shrink-0 stg:items-center stg:gap-2",children:[y&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"stg:text-xs stg:text-muted-foreground",children:"A newer version exists"}),n&&(0,t.jsx)("button",{type:"button",onClick:o,disabled:l,"aria-label":`Update ${b} to its latest version`,className:(0,a.f)("stg:rounded-md stg:px-2 stg:py-0.5 stg:text-xs stg:font-medium","stg:border stg:border-border stg:bg-background stg:text-foreground stg:hover:bg-accent","stg:disabled:opacity-50","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring"),children:"Update"})]}),r&&(0,t.jsx)("button",{type:"button",onClick:g,disabled:l,"aria-label":`Remove ${b}`,className:(0,a.f)("stg:inline-flex stg:size-6 stg:items-center stg:justify-center stg:rounded-md stg:text-muted-foreground","stg:hover:bg-destructive-subtle stg:hover:text-destructive","stg:disabled:opacity-50","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring"),children:(0,t.jsx)(sX,{className:"stg:size-3.5"})})]})]}),h?.spec?.description&&(0,t.jsx)("p",{className:"stg:pl-7 stg:text-xs stg:text-muted-foreground",children:h.spec.description}),N&&(0,t.jsx)("p",{className:"stg:pl-7 stg:text-xs stg:text-muted-foreground",children:"This agent was not found, or you cannot see it."})]})}function sJ({className:e}){return(0,t.jsxs)("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,t.jsx)("rect",{x:"3",y:"5",width:"10",height:"8",rx:"1.5"}),(0,t.jsx)("path",{d:"M6 9h.01M10 9h.01",strokeWidth:"2"}),(0,t.jsx)("path",{d:"M8 2v3"})]})}function sK({className:e}){return(0,t.jsx)("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M8 3v10M3 8h10"})})}function sX({className:e}){return(0,t.jsx)("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"m4 4 8 8M12 4l-8 8"})})}var sQ=e.i(603951),sG=e.i(962838),sZ=e.i(773624),s0=e.i(39285);function s1({servers:e,org:n,editable:a=!1,isSaving:r,error:l,onSave:i,onEditStart:o}){let[g,d]=(0,s.useState)(!1),c=(0,sG.f)(a?n:null),u=a&&c.allowed&&void 0!==i,m=(0,s.useMemo)(()=>e.map(s0.a),[e]),x=(0,s.useCallback)(()=>{d(e=>(e||o?.(),!e))},[o]),h=(0,s.useCallback)(async e=>await i?.(e.map(e=>({name:e.name,url:e.url,headers:{...e.headers}})))??!1,[i]),f=(0,s.useCallback)(e=>(0,t.jsx)(s2,{org:n,server:e}),[n]);return(0,t.jsxs)(sA.f,{title:"MCP servers",count:e.length,onEdit:u?x:void 0,children:[(0,t.jsx)(sZ.f,{servers:m,editing:u&&g,isSaving:r,onChange:h,renderStatus:f,emptyText:"No MCP servers. Every conversation with this agent dials the servers listed here, beside its plugins' servers."}),a&&!c.isLoading&&!c.allowed&&(0,t.jsx)("p",{className:"stg:border-t stg:border-border stg:px-3 stg:py-2 stg:text-xs stg:text-muted-foreground",children:"Only an organization's admins add or change an agent's MCP servers."}),l&&(0,t.jsx)("p",{className:"stg:border-t stg:border-border stg:px-3 stg:py-2 stg:text-xs stg:text-destructive",role:"alert",children:l})]})}function s2({org:e,server:n}){let a=(0,s.useMemo)(()=>(0,eC.N)(n),[n]);return(0,t.jsx)(sQ.f,{org:e,server:a,optionalSignIn:!0})}var s5=e.i(501785),s3=e.i(210731),s4=e.i(379410);function s6({spec:e,editable:n,isSaving:a,error:r,onSave:l,onEditStart:i}){let[o,g]=(0,s.useState)(!1),d=void 0!==(0,I.Y)(e)||e?.runConfig!==void 0;return n||d?(0,t.jsx)(sA.f,{title:"Run defaults",onEdit:n&&!o?()=>{i?.(),g(!0)}:void 0,children:o?(0,t.jsx)(nt,{spec:e,isSaving:a,error:r,onCancel:()=>g(!1),onSave:async e=>{await l(e)&&g(!1)}}):(0,t.jsx)(s8,{spec:e})}):null}function s8({spec:e}){let s=(0,I.Y)(e),n=e?.runConfig,{getModel:a}=(0,M.f)({harness:s}),r=n?.modelName??"",l=""!==r?a(r):void 0;return(0,t.jsxs)("dl",{className:"stg:grid stg:grid-cols-[auto_1fr] stg:gap-x-4 stg:gap-y-1.5 stg:p-3 stg:text-sm",children:[(0,t.jsx)(s9,{label:"Harness",children:s?s3.H[s].label:"None (the conversation's harness)"}),(0,t.jsx)(s9,{label:"Model",children:""!==r?l?.displayName??r:"None (the harness's default)"}),""!==r&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(s9,{label:"Speed",children:n?.serviceTier===to.h.FAST?"Fast":"Standard"}),(0,t.jsx)(s9,{label:"Thinking",children:n?.thinkingMode===to.c.ENABLED?"On":"Off"})]}),(0,t.jsx)(s9,{label:"Cost cap",children:n&&n.maxCostUsd>0?`$${n.maxCostUsd} per message`:"None"}),n&&n.maxToolRounds>0&&(0,t.jsx)(s9,{label:"Tool rounds",children:`At most ${n.maxToolRounds} per message`}),n&&n.maxToolResultChars>0&&(0,t.jsx)(s9,{label:"Tool result size",children:`At most ${n.maxToolResultChars.toLocaleString()} characters`})]})}function s9({label:e,children:s}){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("dt",{className:"stg:text-xs stg:text-muted-foreground",children:e}),(0,t.jsx)("dd",{className:"stg:text-foreground",children:s})]})}let s7=(0,a.f)("stg:w-full stg:rounded-md stg:border stg:border-input stg:bg-background stg:px-2.5 stg:py-1.5 stg:text-xs stg:text-foreground","stg:placeholder:text-muted-foreground","stg:focus-visible:outline-none stg:focus-visible:ring-1 stg:focus-visible:ring-ring","stg:disabled:pointer-events-none stg:disabled:opacity-50"),ne=(0,a.f)("stg:rounded-md stg:px-2 stg:py-1 stg:text-xs stg:text-muted-foreground stg:hover:text-foreground","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring","stg:disabled:pointer-events-none stg:disabled:opacity-50");function nt({spec:e,isSaving:n,error:r,onCancel:l,onSave:i}){let o=e?.runConfig,[g,d]=(0,s.useState)((0,I.Y)(e)),[c,u]=(0,s.useState)(o?.modelName??""),[m,x]=(0,s.useState)(o?.serviceTier===to.h.FAST?"fast":"standard"),[h,f]=(0,s.useState)(o?.thinkingMode===to.c.ENABLED?"enabled":"disabled"),[p,b]=(0,s.useState)(o&&o.maxCostUsd>0?String(o.maxCostUsd):""),{getModel:v}=(0,M.f)({harness:g}),j=()=>{u(""),x("standard"),f("disabled")},y=e=>{e!==g&&j(),d(e)},N=Number.parseFloat(p),k=""===p.trim()||Number.isFinite(N)&&N>0;return(0,t.jsxs)("div",{className:"stg:flex stg:flex-col stg:gap-3 stg:p-3",children:[(0,t.jsxs)("div",{className:"stg:flex stg:flex-col stg:gap-1.5",children:[(0,t.jsx)("span",{className:"stg:text-xs stg:font-medium stg:text-foreground",children:"Harness and model"}),void 0===g?(0,t.jsx)("div",{children:(0,t.jsx)("button",{type:"button",onClick:()=>y("stigmer"),disabled:n,className:(0,a.f)("stg:rounded-md stg:border stg:border-dashed stg:border-border stg:px-2.5 stg:py-1.5 stg:text-xs stg:text-muted-foreground","stg:hover:text-foreground stg:hover:border-muted-foreground","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring"),children:"Choose a harness"})}):(0,t.jsxs)("div",{className:"stg:flex stg:flex-wrap stg:items-center stg:gap-2",children:[(0,t.jsx)(s5.f,{value:g,onValueChange:y,disabled:n}),(0,t.jsx)(tg.f,{value:c,onValueChange:u,harness:g,serviceTier:m,onServiceTierChange:""!==c?x:void 0,thinkingMode:h,onThinkingModeChange:""!==c?f:void 0,placeholderLabel:"Harness default model",disabled:n}),""!==c&&(0,t.jsx)("button",{type:"button",onClick:j,disabled:n,className:ne,children:"Clear model"}),(0,t.jsx)("button",{type:"button",onClick:()=>y(void 0),disabled:n,className:ne,children:"No harness"})]}),(0,t.jsx)("p",{className:"stg:text-2xs stg:text-muted-foreground",children:"A new conversation on this agent starts on this harness unless the person picks another. The model, its speed and thinking apply on this harness to every message that does not choose its own."})]}),(0,t.jsxs)("label",{className:"stg:flex stg:flex-col stg:gap-1.5",children:[(0,t.jsx)("span",{className:"stg:text-xs stg:font-medium stg:text-foreground",children:"Cost cap per message (USD)"}),(0,t.jsx)("input",{type:"number",min:"0",step:"any",value:p,onChange:e=>b(e.target.value),placeholder:"No cap",disabled:n,"aria-invalid":!k,className:(0,a.f)(s7,"stg:sm:max-w-48")}),(0,t.jsx)("span",{className:"stg:text-2xs stg:text-muted-foreground",children:"A message stops when it reaches this spend. A message can lower it, never raise it."})]}),(0,t.jsxs)("div",{className:"stg:flex stg:flex-col stg:gap-1.5",children:[(0,t.jsxs)("div",{className:"stg:flex stg:items-center stg:justify-end stg:gap-1.5",children:[(0,t.jsx)("button",{type:"button",onClick:l,disabled:n,className:(0,a.f)("stg:rounded-md stg:px-2.5 stg:py-1 stg:text-xs stg:font-medium","stg:border stg:border-border stg:bg-background stg:text-foreground stg:hover:bg-accent stg:hover:text-accent-foreground","stg:disabled:opacity-50","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring"),children:"Cancel"}),(0,t.jsxs)("button",{type:"button",onClick:()=>{let e=void 0!==g?c.trim():"",t=""!==e?v(e):void 0,s=""!==e&&("enabled"===h||void 0!==t&&(0,tc._)(t)),n={...""!==e?{modelName:e}:{},...""!==e&&"fast"===m?{serviceTier:to.h.FAST}:{},...s?{thinkingMode:to.c.ENABLED}:{},...""!==p.trim()?{maxCostUsd:N}:{},...o&&o.maxToolRounds>0?{maxToolRounds:o.maxToolRounds}:{},...o&&o.maxToolResultChars>0?{maxToolResultChars:o.maxToolResultChars}:{}};i({harness:void 0!==g?(0,s3._)(g):void 0,runConfig:Object.keys(n).length>0?n:void 0})},disabled:!k||n,className:(0,a.f)("stg:inline-flex stg:items-center stg:gap-1 stg:rounded-md stg:px-2.5 stg:py-1 stg:text-xs stg:font-medium","stg:bg-primary stg:text-primary-foreground stg:hover:bg-primary-hover","stg:disabled:pointer-events-none stg:disabled:opacity-50","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring"),children:[n&&(0,t.jsx)(s4.f,{size:14}),"Save"]})]}),!k&&(0,t.jsx)("p",{className:"stg:text-xs stg:text-destructive",role:"alert",children:"The cost cap must be a positive number, or empty for no cap."}),r&&(0,t.jsx)("p",{className:"stg:text-xs stg:text-destructive",role:"alert",children:r})]})]})}var ns=e.i(373351),nn=e.i(653650),na=e.i(836959),nr=e.i(348990),nl=e.i(313488),ni=e.i(816418);function no({spec:e,agentOrg:n,editable:r,isSaving:l,error:i,onSave:o,onEditStart:g}){let[d,c]=(0,s.useState)(void 0),[u,m]=(0,s.useState)(!1),x=e?.environmentRef,h=void 0!==x&&(""!==x.slug||""!==x.id),f=r||h,{organization:p}=(0,nl.f)(f&&""!==n?n:null),{environments:b}=(0,nr.s)(f&&""!==n?n:null),v=(0,ni.a)(),j=(0,s.useCallback)(e=>{let t=b.find(t=>t.metadata?.slug===e.slug);return t?(0,nr.B)(t):e.slug},[b]);if(!f)return null;let y=(0,na.g)({organization:p?.spec?.preferences?.defaultEnvironmentRef});return(0,t.jsx)(sA.f,{title:"Environment",onEdit:r&&!u?()=>{g?.(),c(h?{org:x.org||n,slug:x.slug}:void 0),m(!0)}:void 0,children:u?(0,t.jsxs)("div",{className:"stg:flex stg:flex-col stg:gap-2 stg:p-3",children:[(0,t.jsx)(ns.f,{org:n,value:d,onChange:c,defaultLabel:(0,nn.P)(y,j),disabled:l}),(0,t.jsx)("p",{className:"stg:text-2xs stg:text-muted-foreground",children:"The packages and network a conversation on this agent gets when the conversation names no environment."}),(0,t.jsxs)("div",{className:"stg:flex stg:items-center stg:justify-end stg:gap-1.5",children:[(0,t.jsx)("button",{type:"button",onClick:()=>m(!1),disabled:l,className:(0,a.f)("stg:rounded-md stg:px-2.5 stg:py-1 stg:text-xs stg:font-medium","stg:border stg:border-border stg:bg-background stg:text-foreground stg:hover:bg-accent stg:hover:text-accent-foreground","stg:disabled:opacity-50","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring"),children:"Cancel"}),(0,t.jsxs)("button",{type:"button",onClick:async()=>{await o(d)&&m(!1)},disabled:l,className:(0,a.f)("stg:inline-flex stg:items-center stg:gap-1 stg:rounded-md stg:px-2.5 stg:py-1 stg:text-xs stg:font-medium","stg:bg-primary stg:text-primary-foreground stg:hover:bg-primary-hover","stg:disabled:pointer-events-none stg:disabled:opacity-50","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring"),children:[l&&(0,t.jsx)(s4.f,{size:14}),"Save"]})]}),i&&(0,t.jsx)("p",{className:"stg:text-xs stg:text-destructive",role:"alert",children:i})]}):(0,t.jsxs)("div",{className:"stg:flex stg:flex-col stg:gap-1 stg:p-3 stg:text-sm",children:[(0,t.jsx)("p",{className:"stg:text-foreground",children:h?j(x):"chosen"===y.kind?`None \xb7 uses the organization's default, ${j(y.environment)}`:"None"}),v?.applies===!1&&(0,t.jsx)("p",{className:"stg:text-xs stg:text-muted-foreground",children:nn.A["not-on-server"]})]})})}var ng=e.i(261722),nd=e.i(384605);function nc({value:e,onSave:n,fallback:r,size:l="md",disabled:i,isSaving:o,error:g,className:d}){let[c,u]=(0,s.useState)(null),m=(0,s.useRef)(null),{isEditing:x,setIsEditing:h,draft:f,setDraft:p,startEditing:b}=(0,nd.f)(e,m),v=(0,s.useCallback)(()=>{u(null),b()},[b]),j=(0,s.useCallback)(async()=>{let t=f.trim();t===e?h(!1):t&&!function(e){try{return new URL(e),!0}catch{return!1}}(t)?u("Enter a valid URL"):await n(t)&&h(!1)},[f,e,n]),y=(0,s.useCallback)(()=>{h(!1),p(e),u(null)},[e]),N=(0,s.useCallback)(e=>{"Enter"===e.key?(e.preventDefault(),j()):"Escape"===e.key&&y()},[j,y]),k="sm"===l?"stg:size-6":"stg:size-8",C=c||g;return i||!x?(0,t.jsx)("div",{className:(0,a.f)("stg:group/inline-edit stg:inline-flex",d),children:(0,t.jsxs)("button",{type:"button",onClick:()=>{i||v()},disabled:i,className:(0,a.f)("stg:relative stg:rounded-md stg:p-0.5 stg:transition-colors",!i&&"stg:hover:bg-accent-hover stg:cursor-pointer","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring"),"aria-label":"Change icon",children:[e?(0,t.jsx)("img",{src:e,alt:"",className:(0,a.f)(k,"stg:shrink-0 stg:rounded stg:object-cover")}):r??(0,t.jsx)(nh,{className:(0,a.f)(k,"stg:text-muted-foreground")}),!i&&(0,t.jsx)("span",{className:"stg:absolute stg:-bottom-0.5 stg:-right-0.5 stg:flex stg:size-4 stg:items-center stg:justify-center stg:rounded-full stg:bg-muted stg:text-muted-foreground stg:opacity-0 stg:transition-opacity stg:group-hover/inline-edit:opacity-100",children:(0,t.jsx)(nu,{className:"stg:size-2.5"})})]})}):(0,t.jsxs)("div",{className:(0,a.f)("stg:flex stg:flex-col stg:gap-1",d),children:[(0,t.jsxs)("div",{className:"stg:flex stg:items-center stg:gap-1.5",children:[(0,t.jsx)("input",{ref:m,type:"url",value:f,onChange:e=>{p(e.target.value),u(null)},onKeyDown:N,disabled:o,placeholder:"https://example.com/icon.png",className:(0,a.f)("stg:flex-1 stg:rounded-md stg:border stg:border-border stg:bg-input-bg stg:px-2 stg:py-1 stg:text-sm stg:text-foreground","stg:focus:outline-none stg:focus:ring-2 stg:focus:ring-ring","stg:disabled:opacity-50",C&&"stg:border-destructive")}),(0,t.jsx)("button",{type:"button",onClick:j,disabled:o,"aria-label":"Save",className:(0,a.f)("stg:inline-flex stg:size-7 stg:items-center stg:justify-center stg:rounded-md","stg:bg-primary stg:text-primary-foreground stg:hover:bg-primary-hover stg:disabled:opacity-50","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring"),children:o?(0,t.jsx)(nf,{}):(0,t.jsx)(nm,{className:"stg:size-3.5"})}),(0,t.jsx)("button",{type:"button",onClick:y,disabled:o,"aria-label":"Cancel",className:(0,a.f)("stg:inline-flex stg:size-7 stg:items-center stg:justify-center stg:rounded-md","stg:border stg:border-border stg:bg-background stg:text-foreground stg:hover:bg-accent stg:disabled:opacity-50","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring"),children:(0,t.jsx)(nx,{className:"stg:size-3.5"})}),f&&(0,t.jsx)("button",{type:"button",onClick:()=>p(""),disabled:o,"aria-label":"Clear",className:"stg:text-xs stg:text-muted-foreground stg:underline stg:decoration-muted-foreground/40 stg:underline-offset-2 stg:hover:text-foreground",children:"Clear"})]}),C&&(0,t.jsx)("p",{className:"stg:px-1 stg:text-xs stg:text-destructive",role:"alert",children:C})]})}function nu({className:e}){return(0,t.jsx)("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M11.5 1.5a2.121 2.121 0 0 1 3 3L5 14l-4 1 1-4Z"})})}function nm({className:e}){return(0,t.jsx)("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"m3 8.5 3.5 3.5 6.5-8"})})}function nx({className:e}){return(0,t.jsx)("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"m4 4 8 8M12 4l-8 8"})})}function nh({className:e}){return(0,t.jsxs)("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,t.jsx)("rect",{x:"2",y:"2",width:"12",height:"12",rx:"1.5"}),(0,t.jsx)("circle",{cx:"5.5",cy:"5.5",r:"1"}),(0,t.jsx)("path",{d:"m14 10.5-3-3L4 14"})]})}function nf(){return(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"stg:animate-spin","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M8 2a6 6 0 1 0 6 6"})})}function np({value:e,onSave:n,keyLabel:r="Key",showValue:l=!1,valueLabel:i="Value",showSecretToggle:o=!1,showOptionalToggle:g=!1,showDescription:d=!1,editing:c,onEditingChange:u,disabled:m,isSaving:x,error:h,className:f}){let[p,b]=(0,s.useState)(!1),v=c??p,j=(0,s.useCallback)(e=>{b(e),u?.(e)},[u]);(0,s.useEffect)(()=>{void 0!==c&&b(c)},[c]);let[y,N]=(0,s.useState)([...e]);(0,s.useCallback)(()=>{N([...e]),j(!0)},[e,j]);let k=(0,s.useCallback)(()=>{j(!1),N([...e])},[e,j]),C=(0,s.useCallback)(async()=>{let e=y.filter(e=>e.key.trim());await n(e)&&j(!1)},[y,n,j]),w=(0,s.useCallback)((e,t)=>{N(s=>s.map((s,n)=>n===e?{...s,...t}:s))},[]),S=(0,s.useCallback)(e=>{N(t=>t.filter((t,s)=>s!==e))},[]),A=(0,s.useCallback)(()=>{N(e=>[...e,{key:"",value:"",isSecret:!1,description:""}])},[]);return m||!v?(0,t.jsx)("div",{className:(0,a.f)("stg:flex stg:flex-col",f),children:e.length>0?(0,t.jsx)("div",{className:"stg:flex stg:flex-col stg:divide-y stg:divide-border",children:e.map(e=>(0,t.jsxs)("div",{className:"stg:flex stg:items-start stg:gap-3 stg:px-3 stg:py-2.5",children:[(0,t.jsx)("code",{className:"stg:shrink-0 stg:font-mono stg:text-sm stg:font-medium stg:text-foreground",children:e.key}),l&&(0,t.jsx)("span",{className:"stg:min-w-0 stg:break-all stg:font-mono stg:text-xs stg:text-muted-foreground",children:e.value}),o&&(0,t.jsx)("span",{className:"stg:shrink-0 stg:rounded stg:bg-muted stg:px-1.5 stg:py-0.5 stg:text-2xs stg:font-medium stg:text-muted-foreground",children:e.isSecret?"secret":"config"}),g&&e.optional&&(0,t.jsx)("span",{className:"stg:shrink-0 stg:rounded stg:bg-muted stg:px-1.5 stg:py-0.5 stg:text-2xs stg:font-medium stg:text-muted-foreground-subtle",children:"optional"}),e.description&&(0,t.jsx)("span",{className:"stg:text-xs stg:text-muted-foreground",children:e.description})]},e.key))}):(0,t.jsx)("p",{className:"stg:px-3 stg:py-3 stg:text-xs stg:text-muted-foreground stg:italic",children:"No entries"})}):(0,t.jsxs)("div",{className:(0,a.f)("stg:flex stg:flex-col stg:gap-3",f),children:[y.map((e,s)=>(0,t.jsxs)("div",{className:"stg:flex stg:items-start stg:gap-2 stg:rounded-md stg:border stg:border-border stg:bg-muted-faint stg:p-2.5",children:[(0,t.jsxs)("div",{className:"stg:flex stg:flex-1 stg:flex-col stg:gap-1.5",children:[(0,t.jsx)("input",{type:"text",value:e.key,onChange:e=>w(s,{key:e.target.value}),placeholder:r,className:(0,a.f)("stg:rounded-md stg:border stg:border-border stg:bg-input-bg stg:px-2 stg:py-1 stg:font-mono stg:text-sm stg:text-foreground","stg:focus:outline-none stg:focus:ring-2 stg:focus:ring-ring")}),l&&(0,t.jsx)("input",{type:"text",value:e.value,onChange:e=>w(s,{value:e.target.value}),placeholder:i,className:(0,a.f)("stg:rounded-md stg:border stg:border-border stg:bg-input-bg stg:px-2 stg:py-1 stg:font-mono stg:text-sm stg:text-foreground","stg:focus:outline-none stg:focus:ring-2 stg:focus:ring-ring")}),d&&(0,t.jsx)("input",{type:"text",value:e.description??"",onChange:e=>w(s,{description:e.target.value}),placeholder:"Description",className:(0,a.f)("stg:rounded-md stg:border stg:border-border stg:bg-input-bg stg:px-2 stg:py-1 stg:text-xs stg:text-foreground","stg:focus:outline-none stg:focus:ring-2 stg:focus:ring-ring")}),(0,t.jsxs)("div",{className:"stg:flex stg:items-center stg:gap-3",children:[o&&(0,t.jsxs)("label",{className:"stg:inline-flex stg:items-center stg:gap-1.5 stg:text-xs stg:text-muted-foreground stg:cursor-pointer",children:[(0,t.jsx)("input",{type:"checkbox",checked:e.isSecret??!1,onChange:e=>w(s,{isSecret:e.target.checked}),className:"stg:size-3.5 stg:rounded stg:border-border"}),"Secret"]}),g&&(0,t.jsxs)("label",{className:"stg:inline-flex stg:items-center stg:gap-1.5 stg:text-xs stg:text-muted-foreground stg:cursor-pointer",children:[(0,t.jsx)("input",{type:"checkbox",checked:e.optional??!1,onChange:e=>w(s,{optional:e.target.checked}),className:"stg:size-3.5 stg:rounded stg:border-border"}),"Optional"]})]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>S(s),"aria-label":`Remove ${e.key||"entry"}`,className:(0,a.f)("stg:mt-1 stg:inline-flex stg:size-6 stg:items-center stg:justify-center stg:rounded-md stg:text-muted-foreground","stg:hover:bg-destructive-subtle stg:hover:text-destructive","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring"),children:(0,t.jsx)(nv,{className:"stg:size-3.5"})})]},s)),(0,t.jsxs)("button",{type:"button",onClick:A,className:(0,a.f)("stg:inline-flex stg:items-center stg:gap-1 stg:rounded-md stg:px-2.5 stg:py-1.5 stg:text-xs stg:font-medium","stg:border stg:border-dashed stg:border-border stg:text-muted-foreground","stg:hover:border-muted-foreground stg:hover:text-foreground stg:hover:bg-muted-subtle","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring","stg:transition-colors"),children:[(0,t.jsx)(nb,{className:"stg:size-3"}),"Add entry"]}),(0,t.jsxs)("div",{className:"stg:flex stg:items-center stg:justify-end stg:gap-1.5",children:[(0,t.jsx)("button",{type:"button",onClick:k,disabled:x,className:(0,a.f)("stg:rounded-md stg:px-2.5 stg:py-1 stg:text-xs stg:font-medium","stg:border stg:border-border stg:bg-background stg:text-foreground stg:hover:bg-accent","stg:disabled:opacity-50","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring"),children:"Cancel"}),(0,t.jsxs)("button",{type:"button",onClick:C,disabled:x,className:(0,a.f)("stg:inline-flex stg:items-center stg:gap-1 stg:rounded-md stg:px-2.5 stg:py-1 stg:text-xs stg:font-medium","stg:bg-primary stg:text-primary-foreground stg:hover:bg-primary-hover","stg:disabled:opacity-50","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring"),children:[x&&(0,t.jsx)(nj,{}),"Save changes"]})]}),h&&(0,t.jsx)("p",{className:"stg:px-1 stg:text-xs stg:text-destructive",role:"alert",children:h})]})}function nb({className:e}){return(0,t.jsx)("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M8 3v10M3 8h10"})})}function nv({className:e}){return(0,t.jsx)("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M2 4h12M5.333 4V2.667a1.333 1.333 0 0 1 1.334-1.334h2.666a1.333 1.333 0 0 1 1.334 1.334V4M12.667 4v9.333a1.333 1.333 0 0 1-1.334 1.334H4.667a1.333 1.333 0 0 1-1.334-1.334V4"})})}function nj(){return(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"stg:animate-spin","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M8 2a6 6 0 1 0 6 6"})})}function ny({value:e,onSave:n,renderPicker:r,onItemClick:l,itemIcon:i,resourceLabel:o="resource",editing:g,onEditingChange:d,defaultOrg:c="",disabled:u,isSaving:m,error:x,className:h}){let[f,p]=(0,s.useState)(!1),b=g??f,v=(0,s.useCallback)(e=>{p(e),d?.(e)},[d]);(0,s.useEffect)(()=>{void 0!==g&&p(g)},[g]);let[j,y]=(0,s.useState)([...e]),[N,k]=(0,s.useState)(!1),[C,w]=(0,s.useState)(!1),[S,A]=(0,s.useState)(""),$=(0,R.b)(),T=(0,R.w)(),[L,M]=(0,s.useState)(()=>$(c));(0,s.useCallback)(()=>{y([...e]),v(!0),k(!1),w(!1)},[e,v]);let I=(0,s.useCallback)(()=>{v(!1),y([...e]),k(!1),w(!1)},[e,v]),z=(0,s.useCallback)(async()=>{await n(j)&&(v(!1),k(!1),w(!1))},[j,n,v]),E=(0,s.useCallback)(e=>{y(t=>t.filter((t,s)=>s!==e))},[]),O=(0,s.useCallback)(e=>{y(t=>{let s=T(e.org);return t.some(t=>T(t.org)===s&&t.slug===e.slug)?t:[...t,e]}),k(!1)},[T]);return u||!b?(0,t.jsx)("div",{className:(0,a.f)("stg:flex stg:flex-col",h),children:e.length>0?(0,t.jsx)("div",{className:"stg:flex stg:flex-col stg:divide-y stg:divide-border",children:e.map((e,s)=>{let n=e.label??e.slug,r=(0,t.jsxs)("div",{className:"stg:flex stg:items-center stg:gap-3",children:[i&&(0,t.jsx)("span",{className:"stg:size-4 stg:shrink-0 stg:text-muted-foreground",children:i}),(0,t.jsx)("span",{className:"stg:text-sm stg:font-medium stg:text-foreground",children:n})]});return l?(0,t.jsx)("button",{type:"button",onClick:()=>l(e),className:(0,a.f)("stg:w-full stg:px-3 stg:py-2.5 stg:text-left stg:transition-colors","stg:hover:bg-accent-hover","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-inset stg:focus-visible:ring-ring"),children:r},`${e.org}/${e.slug}`||s):(0,t.jsx)("div",{className:"stg:px-3 stg:py-2.5",children:r},`${e.org}/${e.slug}`||s)})}):(0,t.jsxs)("p",{className:"stg:px-3 stg:py-3 stg:text-xs stg:text-muted-foreground stg:italic",children:["No ",o,"s configured"]})}):(0,t.jsxs)("div",{className:(0,a.f)("stg:flex stg:flex-col stg:gap-2",h),children:[j.length>0&&(0,t.jsx)("div",{className:"stg:flex stg:flex-col stg:divide-y stg:divide-border stg:rounded-md stg:border stg:border-border",children:j.map((e,s)=>(0,t.jsxs)("div",{className:"stg:flex stg:items-center stg:gap-2 stg:px-3 stg:py-1.5",children:[i&&(0,t.jsx)("span",{className:"stg:size-4 stg:shrink-0 stg:text-muted-foreground",children:i}),(0,t.jsx)("span",{className:"stg:flex-1 stg:text-sm stg:font-medium stg:text-foreground",children:e.label??e.slug}),(0,t.jsx)("button",{type:"button",onClick:()=>E(s),"aria-label":`Remove ${e.label??e.slug}`,className:(0,a.f)("stg:inline-flex stg:size-6 stg:items-center stg:justify-center stg:rounded-md stg:text-muted-foreground","stg:hover:bg-destructive-subtle stg:hover:text-destructive","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring"),children:(0,t.jsx)(nk,{className:"stg:size-3.5"})})]},`${e.org}/${e.slug}`))}),N&&r?(0,t.jsx)("div",{className:"stg:rounded-md stg:border stg:border-border stg:bg-muted-faint stg:p-2",children:r(O)}):C?(0,t.jsxs)("div",{className:"stg:flex stg:items-center stg:gap-2 stg:rounded-md stg:border stg:border-border stg:bg-muted-faint stg:p-2",children:[(0,t.jsx)("input",{type:"text",value:L,onChange:e=>M(e.target.value),placeholder:"org",className:(0,a.f)("stg:w-24 stg:rounded-md stg:border stg:border-border stg:bg-input-bg stg:px-2 stg:py-1 stg:text-xs stg:text-foreground","stg:focus:outline-none stg:focus:ring-2 stg:focus:ring-ring")}),(0,t.jsx)("span",{className:"stg:text-xs stg:text-muted-foreground",children:"/"}),(0,t.jsx)("input",{type:"text",value:S,onChange:e=>A(e.target.value),placeholder:"slug",onKeyDown:e=>{"Enter"===e.key&&S.trim()?(O({org:T(L.trim())||c,slug:S.trim(),label:S.trim()}),A(""),w(!1)):"Escape"===e.key&&(w(!1),A(""))},className:(0,a.f)("stg:flex-1 stg:rounded-md stg:border stg:border-border stg:bg-input-bg stg:px-2 stg:py-1 stg:text-xs stg:text-foreground","stg:focus:outline-none stg:focus:ring-2 stg:focus:ring-ring")}),(0,t.jsx)("button",{type:"button",onClick:()=>{S.trim()&&(O({org:T(L.trim())||c,slug:S.trim(),label:S.trim()}),A(""),w(!1))},disabled:!S.trim(),className:(0,a.f)("stg:inline-flex stg:size-6 stg:items-center stg:justify-center stg:rounded-md","stg:bg-primary stg:text-primary-foreground stg:hover:bg-primary-hover","stg:disabled:opacity-50","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring"),children:(0,t.jsx)(nN,{className:"stg:size-3"})})]}):(0,t.jsxs)("button",{type:"button",onClick:()=>r?k(!0):w(!0),className:(0,a.f)("stg:inline-flex stg:items-center stg:gap-1 stg:rounded-md stg:px-2.5 stg:py-1.5 stg:text-xs stg:font-medium","stg:border stg:border-dashed stg:border-border stg:text-muted-foreground","stg:hover:border-muted-foreground stg:hover:text-foreground stg:hover:bg-muted-subtle","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring","stg:transition-colors"),children:[(0,t.jsx)(nN,{className:"stg:size-3"}),"Add ",o]}),(0,t.jsxs)("div",{className:"stg:flex stg:items-center stg:justify-end stg:gap-1.5",children:[(0,t.jsx)("button",{type:"button",onClick:I,disabled:m,className:(0,a.f)("stg:rounded-md stg:px-2.5 stg:py-1 stg:text-xs stg:font-medium","stg:border stg:border-border stg:bg-background stg:text-foreground stg:hover:bg-accent","stg:disabled:opacity-50","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring"),children:"Cancel"}),(0,t.jsxs)("button",{type:"button",onClick:z,disabled:m,className:(0,a.f)("stg:inline-flex stg:items-center stg:gap-1 stg:rounded-md stg:px-2.5 stg:py-1 stg:text-xs stg:font-medium","stg:bg-primary stg:text-primary-foreground stg:hover:bg-primary-hover","stg:disabled:opacity-50","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring"),children:[m&&(0,t.jsx)(nC,{}),"Save changes"]})]}),x&&(0,t.jsx)("p",{className:"stg:px-1 stg:text-xs stg:text-destructive",role:"alert",children:x})]})}function nN({className:e}){return(0,t.jsx)("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M8 3v10M3 8h10"})})}function nk({className:e}){return(0,t.jsx)("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"m4 4 8 8M12 4l-8 8"})})}function nC(){return(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"stg:animate-spin","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M8 2a6 6 0 1 0 6 6"})})}var nw=e.i(292420),nS=e.i(473489),nA=e.i(996675),n$=e.i(961658),nT=e.i(906150);let nL={enabled:!0,oneIn:10,monthlyLimitUsd:10,modelName:""};function nM(e){let t=e.spec,s=t?.sampleRate??0;return{enabled:t?.enabled??!1,oneIn:s>0?nI(Math.round(1/s)):nL.oneIn,monthlyLimitUsd:t?.monthlyLimitUsd??nL.monthlyLimitUsd,modelName:t?.modelName??""}}function nR(e){return Number.isFinite(e)&&e>0&&e<=1e5}function nI(e){return Number.isFinite(e)?Math.min(100,Math.max(1,Math.round(e))):nL.oneIn}let nz=["spec.enabled","spec.sample_rate","spec.monthly_limit_usd","spec.model_name"];var nE=e.i(524712),nO=e.i(188482);function nD(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);return null===t?0/0:Date.UTC(Number(t[1]),Number(t[2])-1,Number(t[3]))/864e5}function nW(e,t){let s=t.last-t.first;return 4+(s>0?(nD(e)-t.first)/s:.5)*92}let nP={1:"stg:text-chart-1",2:"stg:text-chart-2",3:"stg:text-chart-3",4:"stg:text-chart-4",5:"stg:text-chart-5"},nU={1:"stg:bg-chart-1",2:"stg:bg-chart-2",3:"stg:bg-chart-3",4:"stg:bg-chart-4",5:"stg:bg-chart-5"},nB="stg:absolute stg:flex stg:size-4 stg:-translate-x-1/2 stg:-translate-y-1/2 stg:items-center stg:justify-center";function nF({label:e,points:n,markers:r=[],from:l,to:i,max:o,formatValue:g=String,formatCount:d=String,series:c=1,description:u,className:m}){let x,h=(0,s.useId)(),f=n.length>0||void 0!==l&&void 0!==i,p=f?(x=n.map(e=>nD(e.date)),{first:void 0!==l?nD(l):Math.min(...x),last:void 0!==i?nD(i):Math.max(...x)}):{first:0,last:0},b=function(e,t){if(void 0!==t&&t>0)return t;let s=Math.max(0,...e.map(e=>e.value??0));return s>0?s:1}(n,o),v=f?function(e,t,s){let n=[...e].sort((e,t)=>nD(e.date)-nD(t.date)),a=[],r=null;for(let e of n){var l;if(null===e.value){r=null;continue}let n={point:e,value:e.value,x:nW(e.date,t),y:(l=e.value,96-(s>0?Math.min(Math.max(l/s,0),1):0)*92)};null===r?(r=[n],a.push(r)):r.push(n)}return a}(n,p,b):[],j=r.filter(e=>{let t=nW(e.date,p);return f&&Number.isFinite(t)&&t>=0&&t<=100}),y=u??function(e,t,s,n,a){let r=t.filter(e=>null!==e.value);if(0===r.length)return`${e}: no data.`;let l=[...r].sort((e,t)=>nD(e.date)-nD(t.date)),i=l[0],o=l[l.length-1],g=t.length-r.length,d=[`${e}: ${r.length} ${1===r.length?"day":"days"} from ${i?.date} to ${o?.date}`,`latest ${n(o?.value??0)} on ${o?.date} (${a(o?.count??0)})`];return g>0&&d.push(`${g} ${1===g?"gap":"gaps"}`),s.length>0&&d.push(`marked: ${s.map(e=>`${e.date} ${e.label}`).join("; ")}`),`${d.join(", ")}.`}(e,n,j,g,d);return(0,t.jsxs)("figure",{className:(0,a.f)("stg:m-0 stg:flex stg:flex-col stg:gap-1",m),children:[(0,t.jsx)("figcaption",{className:"stg:text-xs stg:text-muted-foreground",children:e}),(0,t.jsxs)("div",{className:"stg:flex stg:gap-1.5",children:[(0,t.jsxs)("div",{"aria-hidden":"true",className:"stg:flex stg:h-20 stg:flex-col stg:justify-between stg:text-right stg:text-2xs stg:tabular-nums stg:text-muted-foreground",children:[(0,t.jsx)("span",{children:g(b)}),(0,t.jsx)("span",{children:g(0)})]}),(0,t.jsxs)("div",{className:"stg:flex stg:min-w-0 stg:flex-1 stg:flex-col stg:gap-1",children:[(0,t.jsxs)("div",{role:"img","aria-label":e,"aria-describedby":h,"data-testid":"trend-plot",className:"stg:relative stg:h-20",children:[(0,t.jsxs)("svg",{viewBox:"0 0 100 100",preserveAspectRatio:"none","aria-hidden":"true",className:"stg:absolute stg:inset-0 stg:size-full stg:overflow-visible",children:[[0,50,100].map(e=>(0,t.jsx)("line",{x1:0,x2:100,y1:e,y2:e,stroke:"currentColor",strokeWidth:1,vectorEffect:"non-scaling-stroke",className:"stg:text-border"},e)),j.map(e=>{let s=nW(e.date,p);return(0,t.jsx)("line",{x1:s,x2:s,y1:0,y2:100,stroke:"currentColor",strokeWidth:1,strokeDasharray:"3 3",vectorEffect:"non-scaling-stroke",className:"stg:text-muted-foreground"},`marker-${e.date}`)}),v.filter(e=>e.length>1).map(e=>(0,t.jsx)("polyline",{"data-segment":"",points:e.map(e=>`${e.x},${e.y}`).join(" "),fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke",className:nP[c]},`line-${e[0]?.point.date}`))]}),v.flat().map(e=>(0,t.jsxs)(nO.W,{children:[(0,t.jsx)(nO.y,{render:(0,t.jsx)("span",{"data-point":e.point.date,className:nB,style:{left:`${e.x}%`,top:`${e.y}%`}}),children:(0,t.jsx)("span",{className:(0,a.f)("stg:size-2 stg:rounded-full stg:ring-2 stg:ring-background",nU[c])})}),(0,t.jsxs)(nO.Y,{side:"top",className:"stg:text-xs",children:[e.point.date,": ",g(e.value)," (",d(e.point.count),")"]})]},e.point.date)),j.map(e=>(0,t.jsxs)(nO.W,{children:[(0,t.jsx)(nO.y,{render:(0,t.jsx)("span",{"data-marker":e.date,className:nB,style:{left:`${nW(e.date,p)}%`,top:"100%"}}),children:(0,t.jsx)("span",{className:"stg:size-2 stg:rounded-full stg:bg-muted-foreground stg:ring-2 stg:ring-background"})}),(0,t.jsxs)(nO.Y,{side:"top",className:"stg:text-xs",children:[e.date,": ",e.label]})]},`marker-${e.date}`))]}),f&&(0,t.jsxs)("div",{"aria-hidden":"true",className:"stg:flex stg:justify-between stg:text-2xs stg:tabular-nums stg:text-muted-foreground",children:[(0,t.jsx)("span",{children:l??n.reduce((e,t)=>""===e||t.date<e?t.date:e,"")}),(0,t.jsx)("span",{children:i??n.reduce((e,t)=>t.date>e?t.date:e,"")})]})]})]}),(0,t.jsx)("p",{id:h,className:"stg:sr-only",children:y}),(0,t.jsxs)("table",{className:"stg:sr-only",children:[(0,t.jsx)("caption",{children:e}),(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{scope:"col",children:"Day"}),(0,t.jsx)("th",{scope:"col",children:"Value"}),(0,t.jsx)("th",{scope:"col",children:"Count"})]})}),(0,t.jsxs)("tbody",{children:[[...n].sort((e,t)=>e.date.localeCompare(t.date)).map(e=>(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{scope:"row",children:e.date}),(0,t.jsx)("td",{children:null===e.value?"gap":g(e.value)}),(0,t.jsx)("td",{children:d(e.count)})]},e.date)),j.map(e=>(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{scope:"row",children:e.date}),(0,t.jsx)("td",{colSpan:2,children:e.label})]},`marker-${e.date}`))]})]})]})}var nV=e.i(297629),nH=e.i(231666),n_=e.i(798991),nq=e.i(815453),nY=e.i(682272),nJ=e.i(29168);let nK=[7,30,90];function nX(e,t){let s=e+t;return s>0?{rate:e/s,count:s}:null}function nQ(e){return`${Math.round(100*e)}%`}function nG(e){return null===e?"—":`${nQ(e.rate)} of ${e.count}`}function nZ(e,t,s){return e?.metrics.find(e=>e.metric===t&&(void 0===s||e.evaluatorVersion===s))??null}function n0(e,t){return nZ(e,t)?.evaluatorVersion??null}function n1(e,t,s){let n=nZ(e,t,s);return null===n?null:nX(n.passed,n.failed)}function n2(e,t,s,n){let a=nZ(e,t,s)?.criteria.find(e=>e.name===n);return void 0===a?null:nX(a.passed,a.failed)}function n5(e,t,s,n){let a=[];for(let r of e.days){if(null===nZ(r.summary,t))continue;if(null===nZ(r.summary,t,s)){a.push({date:r.date,value:null,count:0});continue}let e=void 0===n?n1(r.summary,t,s):n2(r.summary,t,s,n);null!==e&&a.push({date:r.date,value:e.rate,count:e.count})}return a}function n3(e){switch(e){case nJ.b:return"Run health";case nJ.T:return"AI judge";case nJ.C:return"Thumbs";default:return e}}function n4(e){let t;return((t=e.status?.phase??n_.U.unspecified)===n_.U.completed||t===n_.U.partial)&&(0,nY.G)(e)?.attached!==!1}var n6=e.i(934149);let n8=[];var n9=e.i(801631);let n7=new Map;function ae({agent:e,onNavigateToRun:n,onOpenEval:r,className:l}){let i,o=e.metadata?.id??"",[g,d]=(0,s.useState)(30),{isLoading:c}=(0,nV.S)(),m=(0,nV.x)(),{report:x,isLoading:h,error:p,refetch:v}=function(e,t){let n=(0,b.f)(),a=(0,nV.x)(),r=""!==e&&""!==a,{data:l,isLoading:i,error:o,refetch:g}=(0,y.f)(r?()=>n.score.getAgentQualityReport((0,f.f)(n6.A,{org:a,agentId:e,days:t})):null,[a,e,t,n],null),d=i||r&&null===l&&null===o;return(0,s.useMemo)(()=>({report:l,isLoading:d,error:o,refetch:g}),[l,d,o,g])}(o,g),{versions:j}=(0,nE.R)(e.metadata?.org??null,e.metadata?.slug??null),N=e=>""===e?"unversioned":(0,nE.s)(j,e);return i=c||h?(0,t.jsx)(nA.f,{label:"Loading how this agent's runs went",className:"stg:grid stg:grid-cols-1 stg:gap-3 stg:sm:grid-cols-2",children:[0,1,2,3].map(e=>(0,t.jsx)("div",{className:"stg:h-36 stg:animate-pulse stg:rounded-lg stg:bg-muted"},e))}):""===m?(0,t.jsx)("p",{className:"stg:text-sm stg:text-muted-foreground",children:"Pick an organization to see how this agent's runs went in it."}):null!==p?(0,t.jsx)(u.f,{error:p,retry:v}):null===x||(x.total?.runs??0)===0?(0,t.jsxs)("p",{className:"stg:text-sm stg:text-muted-foreground",children:["No graded runs in the last ",g," days."]}):(0,t.jsx)(as,{report:x,labelOf:N,agentId:o,onOpenEval:r}),(0,t.jsxs)("div",{className:(0,a.f)("stg:flex stg:flex-col stg:gap-6",l),children:[(0,t.jsx)(sA.f,{title:"How runs went",headerActions:(0,t.jsx)(at,{days:g,onChange:d}),children:i}),(0,t.jsx)(ai,{agentId:o,days:g,labelOf:N,onNavigateToRun:n}),(0,t.jsx)("p",{className:"stg:text-xs stg:text-muted-foreground",children:"Days are UTC. The numbers count everyone's runs of this agent in this organization and show no conversation text; the flagged list shows only runs you can open."})]})}function at({days:e,onChange:s}){return(0,t.jsx)("div",{role:"group","aria-label":"Days shown",className:"stg:flex stg:gap-1.5",children:nK.map(n=>(0,t.jsxs)("button",{type:"button","aria-pressed":n===e,onClick:()=>s(n),className:(0,a.f)("stg:rounded-md stg:px-2.5 stg:py-1 stg:text-xs stg:font-medium stg:transition-colors",n===e?"stg:bg-primary stg:text-primary-foreground":"stg:bg-muted stg:text-muted-foreground stg:hover:bg-accent stg:hover:text-foreground"),children:[n," days"]},n))})}function as({report:e,labelOf:s,agentId:n,onOpenEval:a}){var r,l;let i=e.total,o=n0(i,nJ.b),g=n0(i,nJ.T),d=null===g?[]:(r=nJ.T,nZ(i,r,g)?.criteria.map(e=>e.name)??[]),c=nZ(i,nJ.C),u={markers:(function(e){let t=[...e.versions].filter(e=>""!==e.firstDate).sort((e,t)=>e.firstDate.localeCompare(t.firstDate)),s=t[0]?.firstDate,n=new Map;for(let e of t)e.firstDate===s||n.has(e.firstDate)||n.set(e.firstDate,{date:e.firstDate,agentVersionHash:e.agentVersionHash});return[...n.values()]})(e).map(e=>({date:e.date,label:`agent version ${s(e.agentVersionHash)} first seen`})),from:e.fromDate,to:e.toDate,max:1,formatValue:nQ,formatCount:e=>`${e} ${1===e?"run":"runs"}`};return(0,t.jsxs)("div",{className:"stg:flex stg:flex-col stg:gap-4",children:[(0,t.jsxs)("div",{className:"stg:grid stg:grid-cols-1 stg:gap-3 stg:sm:grid-cols-2",children:[(0,t.jsx)(an,{title:"Runs graded",value:String(i?.runs??0),detail:`${e.fromDate} to ${e.toDate}`,children:(0,t.jsx)(nF,{...u,label:"Runs graded per day",points:e.days.map(e=>{let t=e.summary?.runs??0;return{date:e.date,value:t,count:t}}),max:void 0,formatValue:e=>String(Math.round(e))})}),null!==o&&(0,t.jsx)(aa,{title:"Run health",rate:n1(i,nJ.b,o),countWord:"checked",children:(0,t.jsx)(nF,{...u,label:"Run health, daily pass rate",points:n5(e,nJ.b,o)})}),null!==g&&d.map(s=>(0,t.jsx)(aa,{title:`AI judge: ${s}`,rate:n2(i,nJ.T,g,s),countWord:"graded",children:(0,t.jsx)(nF,{...u,label:`AI judge, ${s}, daily pass rate`,points:n5(e,nJ.T,g,s)})},s)),null!==c&&(0,t.jsx)(an,{title:"Thumbs",value:`${c.passed} up \xb7 ${c.failed} down`,detail:`${c.passed+c.failed} rated`,children:(0,t.jsx)(nF,{...u,label:"Thumbs up, daily share",points:n5(e,nJ.C,c.evaluatorVersion)})})]}),(l=nJ.T,(i?.metrics.filter(e=>e.metric===l).length??0)>1&&(0,t.jsx)("p",{className:"stg:text-xs stg:text-muted-foreground",children:"The AI judge's rules changed in these days. Its rates count only grades under the current rules; a break in its trend is a day graded only under the earlier ones."})),(0,t.jsx)(ar,{report:e,labelOf:s,agentId:n,healthVersion:o,judgeVersion:g,rubrics:d,onOpenEval:a})]})}function an({title:e,value:s,detail:n,children:a}){return(0,t.jsxs)("section",{"aria-label":e,className:"stg:flex stg:flex-col stg:gap-2 stg:rounded-lg stg:border stg:border-border stg:p-3",children:[(0,t.jsxs)("div",{className:"stg:flex stg:flex-col stg:gap-0.5",children:[(0,t.jsx)("h4",{className:"stg:text-xs stg:font-medium stg:text-muted-foreground",children:e}),(0,t.jsx)("p",{className:"stg:text-lg stg:font-semibold stg:tabular-nums stg:text-foreground",children:s}),(0,t.jsx)("p",{className:"stg:text-xs stg:text-muted-foreground",children:n})]}),a]})}function aa({title:e,rate:s,countWord:n,children:a}){return(0,t.jsx)(an,{title:e,value:null===s?"—":`${nQ(s.rate)} passed`,detail:null===s?`No run ${n}`:`of ${s.count} ${1===s.count?"run":"runs"} ${n}`,children:a})}function ar({report:e,labelOf:s,agentId:n,healthVersion:r,judgeVersion:l,rubrics:i,onOpenEval:o}){let g=function(e,t){let s=(0,b.f)(),n=t.join("\n"),{data:a}=(0,y.f)(""!==e&&t.length>0?async()=>{let n=new Set(t),a=[];for await(let t of(0,j.Y)(t=>s.evalrun.listByAgent((0,f.f)(n9.b,{agentId:e,pageSize:v.J,pageToken:t}))))if(a.push(t),n4(t)&&n.delete((0,nY.T)(t)),0===n.size)break;let r=new Map;for(let e of a){if(!n4(e))continue;let t=(0,nY.T)(e);r.has(t)||r.set(t,e)}return r}:null,[e,n,s],n7);return a}(n,e.versions.map(e=>e.agentVersionHash));return(0,t.jsx)("div",{className:"stg:overflow-x-auto",children:(0,t.jsxs)("table",{className:"stg:w-full stg:text-xs",children:[(0,t.jsx)("caption",{className:"stg:pb-1 stg:text-left stg:text-xs stg:font-medium stg:text-muted-foreground",children:"By agent version"}),(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{className:"stg:border-b stg:border-border stg:text-left stg:text-muted-foreground",children:[(0,t.jsx)("th",{scope:"col",className:ag,children:"Version"}),(0,t.jsx)("th",{scope:"col",className:ag,children:"Seen"}),(0,t.jsx)("th",{scope:"col",className:ag,children:"Runs"}),(0,t.jsx)("th",{scope:"col",className:ag,children:"Run health"}),i.map(e=>(0,t.jsxs)("th",{scope:"col",className:ag,children:["AI judge: ",e]},e)),(0,t.jsx)("th",{scope:"col",className:ag,children:"Thumbs"}),(0,t.jsx)("th",{scope:"col",className:ag,children:"Latest eval"})]})}),(0,t.jsx)("tbody",{children:e.versions.map(e=>{let n,d,c=e.summary,u=nZ(c,nJ.C),m=g.get(e.agentVersionHash),x=void 0===m?null:(n=m.status?.aggregates,nX(d=n?.casesPassed??0,(n?.casesTotal??0)-d)),h=m?.metadata?.id??"";return(0,t.jsxs)("tr",{className:"stg:border-b stg:border-border stg:text-foreground stg:last:border-b-0",children:[(0,t.jsx)("th",{scope:"row",className:(0,a.f)(ag,"stg:text-left stg:font-mono stg:font-medium"),children:s(e.agentVersionHash)}),(0,t.jsx)("td",{className:(0,a.f)(ag,"stg:tabular-nums stg:text-muted-foreground"),children:e.firstDate===e.lastDate?e.firstDate:`${e.firstDate} to ${e.lastDate}`}),(0,t.jsx)("td",{className:(0,a.f)(ag,"stg:tabular-nums"),children:c?.runs??0}),(0,t.jsx)("td",{className:(0,a.f)(ag,"stg:tabular-nums"),children:null===r?"—":nG(n1(c,nJ.b,r))}),i.map(e=>(0,t.jsx)("td",{className:(0,a.f)(ag,"stg:tabular-nums"),children:null===l?"—":nG(n2(c,nJ.T,l,e))},e)),(0,t.jsx)("td",{className:(0,a.f)(ag,"stg:tabular-nums"),children:null===u?"—":`${u.passed} up \xb7 ${u.failed} down`}),(0,t.jsx)("td",{className:(0,a.f)(ag,"stg:tabular-nums"),children:void 0===m?(0,t.jsx)("span",{className:"stg:text-muted-foreground",children:"no eval"}):void 0!==o&&""!==h?(0,t.jsx)("button",{type:"button",onClick:()=>o(h),className:"stg:text-primary stg:underline-offset-2 stg:hover:underline stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring",children:al(x)}):al(x)})]},e.agentVersionHash)})})]})})}function al(e){return null===e?"no case graded":`${nQ(e.rate)} of ${e.count} ${1===e.count?"case":"cases"}`}function ai({agentId:e,days:n,labelOf:r,onNavigateToRun:l}){let i,{items:o,isLoading:g,error:d,hasMore:c,loadMore:m,isLoadingMore:x,loadMoreError:h,refetch:p}=function(e,t){let n=(0,b.f)(),a=(0,nV.x)(),r=(0,s.useCallback)(s=>n.score.listFlaggedByAgent((0,f.f)(n6.L,{org:a,agentId:e,days:t,pageSize:20,pageToken:s})),[n,a,e,t]),l=""!==e&&""!==a,{data:i,isLoading:o,error:g,refetch:d}=(0,y.f)(l?()=>r(""):null,[a,e,t,n],null),c=o||l&&null===i&&null===g,[u,m]=(0,s.useState)(null),[x,h]=(0,s.useState)(!1),[p,v]=(0,s.useState)(null),j=null!==i&&u?.after===i?u:null,N=null!==i&&p?.after===i?p.error:null,k=null!==j?j.nextPageToken:i?.nextPageToken??"",C=(0,s.useCallback)(()=>{null===i||""===k||x||(h(!0),v(null),r(k).then(e=>{m(t=>({after:i,items:[...t?.after===i?t.items:n8,...e.entries],nextPageToken:e.nextPageToken})),h(!1)},e=>{v({after:i,error:(0,eg.f)(e)}),h(!1)}))},[i,k,x,r]),w=(0,s.useMemo)(()=>null===j?i?.entries??n8:[...i?.entries??n8,...j.items],[i,j]);return(0,s.useMemo)(()=>({items:w,isLoading:c,error:g,hasMore:""!==k,loadMore:C,isLoadingMore:x,loadMoreError:N,refetch:d}),[w,c,g,k,C,x,N,d])}(e,n);return i=g?(0,t.jsx)(nA.f,{label:"Loading flagged runs",className:"stg:flex stg:flex-col stg:gap-2",children:[0,1,2].map(e=>(0,t.jsx)("div",{className:"stg:h-6 stg:animate-pulse stg:rounded stg:bg-muted"},e))}):null!==d?(0,t.jsx)(u.f,{error:d,retry:p}):(0,t.jsxs)("div",{className:"stg:flex stg:flex-col stg:gap-2",children:[0===o.length?(0,t.jsx)("p",{className:"stg:text-sm stg:text-muted-foreground",children:c?"No flagged runs among the most recent grades.":`No flagged runs in the last ${n} days.`}):(0,t.jsx)("ul",{"aria-label":"Flagged runs",className:(0,a.f)(Q.J,"stg:flex stg:flex-col stg:divide-y stg:divide-border"),children:o.map(e=>(0,t.jsx)(ao,{score:e,labelOf:r,onNavigateToRun:l},e.metadata?.id??""))}),null!==h&&(0,t.jsxs)("p",{role:"alert",className:"stg:text-xs stg:text-destructive",children:["Could not read more flagged runs: ",h.message]}),c&&(0,t.jsx)("div",{children:(0,t.jsx)("button",{type:"button",onClick:m,disabled:x,className:nH.m,children:x?"Loading…":0===o.length?"Look further back":"Load more"})})]}),(0,t.jsx)(sA.f,{title:"Flagged runs",children:i})}function ao({score:e,labelOf:s,onNavigateToRun:n}){let a=e.status?.audit?.specAudit?.createdAt,l=void 0===a?null:(0,r.S)(a),i=e.spec?.runId??"",o=e.spec?.metric??"",g=function(e){let t=e.spec?.metric??"";if(t===nJ.C)return"thumbs down";let s=(e.spec?.criteria??[]).filter(e=>e.result===nq.a.failed).map(e=>e.name);return s.length>0?s.join(", "):n3(t)}(e),d=n3(o),c=o===nJ.C||g===d?g:`${d}: ${g}`;return(0,t.jsxs)("li",{className:"stg:flex stg:flex-wrap stg:items-baseline stg:gap-x-3 stg:gap-y-0.5 stg:py-1.5 stg:text-xs",children:[null===l?(0,t.jsx)("span",{className:"stg:text-muted-foreground",children:"—"}):(0,t.jsx)("time",{dateTime:l.toISOString(),className:"stg:tabular-nums stg:text-muted-foreground",children:l.toLocaleString()}),(0,t.jsx)("span",{className:"stg:font-mono stg:text-muted-foreground",children:s(e.status?.agentVersionHash??"")}),(0,t.jsx)("span",{className:"stg:text-foreground",children:c}),void 0!==n&&""!==i&&(0,t.jsx)("button",{type:"button","aria-label":`Open run: ${c}${null===l?"":`, ${l.toLocaleString()}`}`,onClick:()=>n(i),className:"stg:ml-auto stg:text-primary stg:underline-offset-2 stg:hover:underline stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-ring",children:"Open run"})]})}let ag="stg:px-2 stg:py-1.5 stg:whitespace-nowrap";function ad({agent:e,editable:s=!1,onNavigateToRun:n,onOpenEval:r,className:l}){return(0,t.jsxs)("div",{className:(0,a.f)("stg:flex stg:flex-col stg:gap-6",l),children:[(0,t.jsx)(ae,{agent:e,onNavigateToRun:n,onOpenEval:r}),(0,t.jsx)(ac,{agent:e,editable:s})]})}function ac({agent:e,editable:s}){let n=e.metadata?.id??"",{scoringRule:a,isLoading:r,error:l,refetch:i}=function(e){let t=(0,b.f)(),{data:s,isLoading:n,error:a,refetch:r}=(0,y.f)(e?async()=>{try{return await t.scoringrule.getByAgent((0,f.f)(n$.b,{agentId:e}))}catch(e){if((0,G.c)(e))return null;throw e}}:null,[e,t],null);return{scoringRule:s,isLoading:n,error:a,refetch:r}}(n);if(r)return(0,t.jsx)("p",{className:"stg:text-xs stg:text-muted-foreground",children:"Loading AI grading…"});if(null!==l)return(0,t.jsx)(u.f,{error:l,retry:i});let o=`${a?.metadata?.id??"none"}:${a?.status?.audit?.specAudit?.updatedAt?.seconds?.toString()??""}`;return(0,t.jsx)(au,{agentId:n,agentOrg:e.metadata?.org??"",scoringRule:a,editable:s,onSaved:i},o)}function au({agentId:e,agentOrg:n,scoringRule:r,editable:l,onSaved:i,className:o}){let g=(0,s.useId)(),{save:d,isSaving:c,error:u}=function(){let e=(0,b.f)(),[t,n]=(0,s.useState)(!1),[a,r]=(0,s.useState)(null),l=(0,s.useCallback)(()=>r(null),[]);return{save:(0,s.useCallback)(async(t,s,a)=>{n(!0),r(null);try{var l,i;let n,r={...a?.metadata?.id?{id:a.metadata.id}:{},name:a?.metadata?.name??"",org:a?.metadata?.org??t.org,agentId:t.id,enabled:s.enabled,sampleRate:(l=s,i=a,n=nI(l.oneIn),null!==i&&nM(i).oneIn===n&&(i.spec?.sampleRate??0)>0?i.spec?.sampleRate??0:1/n),monthlyLimitUsd:s.monthlyLimitUsd,modelName:s.modelName};if(null===a)return await e.scoringrule.create(r);let o=(0,nT.T)(r);return void 0!==o.metadata&&(o.metadata.etag=a.metadata?.etag??""),await e.scoringrule.update(o,[...nz])}catch(t){let e=(0,eg.f)(t);throw r(e),e}finally{n(!1)}},[e]),isSaving:t,error:a,clearError:l}}(),m=null===r?{...nL,enabled:!1}:nM(r),[x,h]=(0,s.useState)(m),[f,p]=(0,s.useState)(String(m.monthlyLimitUsd)),v=Number(f),j=nR(v),y=x.enabled!==m.enabled||x.oneIn!==m.oneIn||x.modelName!==m.modelName||v!==m.monthlyLimitUsd,N=async()=>{try{await d({id:e,org:n},{...x,monthlyLimitUsd:v},r),i()}catch{}},k=r?.status;return(0,t.jsxs)("div",{className:(0,a.f)("stg:flex stg:flex-col stg:gap-6",o),children:[(0,t.jsx)(sA.f,{title:"AI grading",children:(0,t.jsxs)("div",{className:"stg:flex stg:flex-col stg:gap-4",children:[(0,t.jsx)("p",{className:"stg:text-xs stg:text-muted-foreground",children:"An AI judge grades a sample of this agent's finished runs with four standard questions: did it do the task, did it make anything up, did it do only what was asked, and did it ask when the request was unclear. Everyone who can see a run sees its grade. The judge's cost is charged to the run's organization, never to the run."}),(0,t.jsxs)("div",{className:"stg:flex stg:items-center stg:gap-2",children:[(0,t.jsx)(ee.f,{id:`${g}-enabled`,checked:x.enabled,onCheckedChange:e=>h({...x,enabled:e}),disabled:!l||c}),(0,t.jsx)("label",{htmlFor:`${g}-enabled`,className:"stg:text-xs stg:font-medium stg:text-foreground",children:"Grade this agent's runs with an AI judge"})]}),(0,t.jsxs)("div",{className:"stg:flex stg:flex-col stg:gap-1",children:[(0,t.jsx)("label",{htmlFor:`${g}-one-in`,className:am,children:"Grade one in N runs"}),(0,t.jsx)("input",{id:`${g}-one-in`,type:"number",min:1,max:100,step:1,value:x.oneIn,onChange:e=>h({...x,oneIn:Number(e.target.value)}),disabled:!l||c,className:(0,a.f)(nH.c,"stg:sm:max-w-32")}),(0,t.jsx)("p",{className:ax,children:"1 grades every run; 10 grades about one run in ten."})]}),(0,t.jsxs)("div",{className:"stg:flex stg:flex-col stg:gap-1",children:[(0,t.jsx)("label",{htmlFor:`${g}-limit`,className:am,children:"Monthly limit (USD, estimated model spend)"}),(0,t.jsx)("input",{id:`${g}-limit`,type:"number",min:0,step:"any",value:f,onChange:e=>p(e.target.value),disabled:!l||c,"aria-invalid":!j,className:(0,a.f)(nH.c,"stg:sm:max-w-32")}),(0,t.jsx)("p",{className:ax,children:"When a grade would pass it, runs are marked “not graded: spending limit reached” until next month. The estimate is the model's cost before any platform pricing."}),nR(v)&&v<.25&&(0,t.jsx)("p",{className:"stg:text-xs stg:text-destructive",children:"Each grade sets aside up to $0.25 before it starts, so a limit below $0.25 grades no run."})]}),(0,t.jsxs)("div",{className:"stg:flex stg:flex-col stg:gap-1",children:[(0,t.jsx)("span",{className:am,children:"Judge model"}),(0,t.jsx)(tg.f,{value:""===x.modelName?void 0:x.modelName,onValueChange:e=>h({...x,modelName:e}),harness:"stigmer",compact:!0,disabled:!l||c,placeholderLabel:"Platform default"})]}),l&&(0,t.jsx)("div",{children:(0,t.jsx)("button",{type:"button",disabled:!y||!j||c,onClick:()=>void N(),className:nH.h,children:c?"Saving…":"Save"})}),null!==u&&(0,t.jsx)("p",{role:"alert",className:"stg:text-xs stg:text-destructive",children:u.message})]})}),void 0!==k&&""!==k.period&&(0,t.jsxs)(sA.f,{title:`This month (${k.period})`,children:[(0,t.jsxs)("dl",{className:"stg:grid stg:grid-cols-2 stg:gap-x-6 stg:gap-y-1 stg:text-xs stg:sm:max-w-md",children:[(0,t.jsx)("dt",{className:"stg:text-muted-foreground",children:"Spent"}),(0,t.jsx)("dd",{className:"stg:text-foreground",children:ah(k.spentUsd)}),(0,t.jsx)("dt",{className:"stg:text-muted-foreground",children:"Set aside for grades running"}),(0,t.jsx)("dd",{className:"stg:text-foreground",children:ah(k.reservedUsd)}),(0,t.jsx)("dt",{className:"stg:text-muted-foreground",children:"Graded"}),(0,t.jsx)("dd",{className:"stg:text-foreground",children:k.graded}),(0,t.jsx)("dt",{className:"stg:text-muted-foreground",children:"Not graded"}),(0,t.jsx)("dd",{className:"stg:text-foreground",children:k.notGraded})]}),""!==k.lastNotGradedReason&&(0,t.jsxs)("p",{className:"stg:mt-2 stg:text-xs stg:text-muted-foreground",children:["Last not graded: ",k.lastNotGradedReason]})]})]})}let am="stg:block stg:text-xs stg:font-medium stg:text-foreground",ax="stg:text-2xs stg:text-muted-foreground";function ah(e){return`$${e.toFixed(2)}`}var af=e.i(563479),ap=e.i(784400),ab=e.i(598529),av=e.i(19395);function aj({agent:e,className:n}){let[r,l]=(0,s.useState)(null),i=(0,nE.R)(e.metadata?.org??"",e.metadata?.slug??""),{versions:o,isLoading:g,getSpec:d}=i,c=o.find(e=>e.isCurrent)?.id??"",u=null!==r&&""!==c&&r!==c,m=(0,s.useMemo)(()=>u?(0,av.f)(ay(d(r)?.instructions??""),ay(d(c)?.instructions??"")):[],[u,r,c,d]);return(0,t.jsxs)("div",{className:(0,a.f)("stg:flex stg:min-h-[24rem] stg:gap-4",n),children:[(0,t.jsxs)("div",{className:(0,a.f)("stg:flex stg:shrink-0 stg:flex-col stg:overflow-y-auto",u?"stg:w-[280px]":"stg:w-full stg:max-w-md"),children:[(0,t.jsx)(ap.f,{entries:o,isLoading:g,selectedId:r??void 0,onEntrySelect:l,emptyMessage:"No versions yet. The agent's next change records its first version."}),(0,t.jsx)(e4.f,{hasMore:i.hasMore,loadMore:i.loadMore,isLoadingMore:i.isLoadingMore,loadMoreError:i.loadMoreError})]}),u&&(0,t.jsxs)("div",{className:"stg:flex stg:min-w-0 stg:flex-1 stg:flex-col",children:[(0,t.jsx)("div",{className:"stg:mb-2 stg:flex stg:items-center stg:gap-2 stg:text-xs stg:text-muted-foreground",children:(0,t.jsxs)("span",{children:["Comparing"," ",(0,t.jsx)("code",{className:"stg:rounded stg:bg-muted stg:px-1 stg:py-0.5 stg:font-mono stg:text-2xs",children:r.slice(0,8)})," ","with current"]})}),(0,t.jsx)(ab.f,{hunks:m,filePath:"instructions",className:"stg:flex-1"})]})]})}function ay(e){return""===e||e.endsWith("\n")?e:`${e}
20
+ `}var aN=e.i(252771),ak=e.i(352371);let aC={id:"overview",label:"Overview"},aw={id:"channels",label:"Channels"},aS={id:"quality",label:"Quality"},aA={id:"evals",label:"Evals"},a$={id:"dependencies",label:"Dependencies"},aT={id:"versions",label:"Versions"};function aL({org:e,slug:n,onSkillClick:a,onResourceLoad:f,primaryAction:p,actions:b,yamlActions:v=!1,additionalTabs:j,activeTab:y,onTabChange:k,defaultTab:C,editable:w=!1,onResourceUpdated:S,onRenamed:A,buildChatLinkUrl:$,channelAppsHref:T,sessionHref:L,onConnectExternal:M,onPluginClick:I,onAgentClick:E,onNavigateToRun:O,className:D}){let W,{agent:P,isLoading:U,error:B,refetch:F}=(0,i.f)(e,n),V=(0,R.w)(),H=(0,nS.l)(P?.metadata?.labels),_=P?.metadata?.id??"",q=(0,s.useMemo)(()=>""!==_?{kind:"agent",id:_}:null,[_]),J=(0,h.f)(w?q:null,"can_edit",{fail:"closed"}),K=w&&J.allowed,X=K&&null===H.plugin,{update:Q,isUpdating:G}=(0,o.f)(),[Z,ee]=(0,s.useState)(null),et=(0,s.useCallback)(async(e,t)=>{if(!P)return!1;ee(null);try{let{resource:e,paths:s}=(0,c.N)(P,g.h,t),n=await Q(e,s);return S?.(n),F(),!0}catch(t){return ee({field:e,message:(0,c.q)(t,"agent")}),!1}},[P,Q,S,F]),es=(0,s.useCallback)(async(e,t)=>{let s={};return s[e]=t,et(e,s)},[et]),en=(0,s.useCallback)(({harness:e,runConfig:t})=>et("runConfig",{harness:e,runConfig:t}),[et]),ea=(0,s.useCallback)(()=>ee(null),[]),er=(0,s.useCallback)(e=>{A?.(e),F()},[A,F]),[el,ei]=(0,s.useState)(null),{tree:eo,isEmpty:eg}=function({agentName:e,agentOrg:t,spec:n}){let a=(0,R.b)();return(0,s.useMemo)(()=>{if(!n)return{tree:null,isEmpty:!0};let{plugins:s,skillRefs:r,subagents:i}=n,o=n.mcpServers??[];if(!(s.length>0||o.length>0||r.length>0||i.length>0))return{tree:null,isEmpty:!0};let g=1,c=(e,s,n,r)=>(g++,(0,d.Q)(n))?{id:`${e}:deleted:${r}`,kind:e,label:(0,d.$)(s),children:[]}:{id:`${e}:${n.slug}`,kind:e,label:n.slug,qualifiedLabel:n.org&&n.org!==t?`${a(n.org)}/${n.slug}`:void 0,..."subagent"===e&&n.version?{metadata:{version:n.version.slice(0,8)}}:{},children:[],ref:{org:n.org||t,slug:n.slug}};return{tree:{root:{id:`agent:${e}`,kind:"agent",label:e,children:[...s.map((e,t)=>c("plugin",l.X.plugin,e,t)),...o.map(e=>{g++;let t=URL.canParse(e.url)?new URL(e.url).host:"";return{id:`mcp-server:${e.name}`,kind:"mcp-server",label:e.name,...""!==t?{metadata:{host:t}}:{},children:[]}}),...r.map((e,t)=>c("skill",l.X.skill,e,t)),...i.map((e,t)=>c("subagent",l.X.agent,e,t))]},nodeCount:g},isEmpty:!1}},[e,t,n,a])}({agentName:P?.metadata?.name||P?.metadata?.slug||n,agentOrg:P?.metadata?.org||V(e),spec:P?.spec}),ed=(0,nE.j)(P?.metadata?.org??null,P?.metadata?.slug??null),ec=N(P?.metadata?.id??"",P?.metadata?.org??""),eu=(0,s.useMemo)(()=>[aC,aw,aS,aA,...eg?[]:[a$],{...aT,...ed.count>0&&{badge:ed.count,badgeIsLowerBound:ed.isLowerBound}}],[eg,ed]),{effectiveTabs:em,effectiveActiveTab:ex,effectiveOnTabChange:eh,activeAdditionalTab:ef}=(0,s$.f)({builtInTabs:eu,additionalTabs:j,activeTab:y,onTabChange:k,defaultTab:C}),ep=(0,s.useCallback)(e=>{e.ref&&("plugin"===e.kind?I?.(e.ref):"skill"===e.kind?a?.(e.ref):"subagent"===e.kind&&E?.(e.ref))},[I,a,E]),eb=(0,s.useRef)(f);eb.current=f,(0,s.useEffect)(()=>{P?.metadata?.name&&eb.current?.({name:P.metadata.name,id:P.metadata.id,slug:P.metadata.slug})},[P]);let ev=(0,x.f)({resource:P?.metadata?{kind:l.X.agent,kindString:"agent",id:P.metadata.id,org:P.metadata.org,name:P.metadata.name}:null,visibility:P?.metadata?{kind:"agent",current:P.metadata.visibility,org:P.metadata.org,onChanged:F}:void 0}),[ej,ey]=(0,s.useState)(!1),{copyYaml:eN,copyJson:ek,downloadYaml:eC}=(0,ak.f)({resource:v?P:null}),ew=(0,s.useMemo)(()=>v?[...X?[{id:"edit-yaml",label:"Edit YAML",group:"export",requires:"can_edit",onAction:()=>ey(!0)}]:[],{id:"export-yaml",label:"Export YAML",group:"export",onAction:()=>void eN()},{id:"export-json",label:"Export JSON",group:"export",onAction:()=>void ek()},{id:"download-yaml",label:"Download YAML",group:"export",onAction:eC}]:[],[v,X,eN,ek,eC]);if(U)return(0,t.jsx)(aD,{className:D});if(B)return(0,t.jsx)(u.f,{error:B,retry:F,className:D});if(!P)return(0,t.jsx)(aW,{className:D});let eS=P.metadata,eA=P.spec,e$=P.status?.audit?.specAudit,eT=eS?.org||V(e),eL={name:eS?.name||eS?.slug||"Untitled",id:eS?.id||"",org:eS?.org,slug:eS?.slug,description:void 0,iconUrl:X?void 0:eA?.iconUrl,icon:X?(0,t.jsx)(nc,{value:eA?.iconUrl??"",onSave:e=>es("iconUrl",e||void 0),isSaving:G,fallback:(0,t.jsx)(aP,{className:"stg:size-6 stg:text-muted-foreground"}),disabled:!X}):eA?.iconUrl?void 0:(0,t.jsx)(aP,{className:"stg:size-6 stg:text-muted-foreground"}),createdAt:e$?.createdAt?(0,r.S)(e$.createdAt):null,updatedAt:e$?.updatedAt?(0,r.S)(e$.updatedAt):null},eM=eS?(0,t.jsx)(m.n,{visibility:eS.visibility,onClick:ev.action?ev.open:void 0}):void 0,eR=[ev.action].filter(e=>null!=e),eI=b??[],ez=eI.findIndex(e=>"destructive"===e.variant),eE=-1===ez?eI.length:ez,eO=[...eI.slice(0,eE),...ew,...eI.slice(eE),...eR];return W=ef?ef.content:ex===aw.id?(0,t.jsx)(sN,{agent:P,buildChatLinkUrl:$,channelAppsHref:T,sessionHref:L,onConnectExternal:M,channelList:ec}):"quality"===ex?(0,t.jsx)(ad,{agent:P,editable:K,onNavigateToRun:O,onOpenEval:e=>{ei(e),eh(aA.id)}}):"evals"===ex?(0,t.jsx)(af.f,{agent:P,onNavigateToRun:O,initialEvalRunId:el??void 0,onOpenPlugins:()=>eh(aC.id)}):"dependencies"===ex&&eo?(0,t.jsx)(sD,{tree:eo,onNodeClick:ep}):"versions"===ex?(0,t.jsx)(aj,{agent:P}):(0,t.jsxs)("div",{className:"stg:flex stg:flex-col stg:gap-6",children:[X&&(0,t.jsx)(aN.e,{kind:"agent",resourceId:eS?.id??null,currentSlug:eS?.slug??"",onRenamed:er,className:"stg:max-w-md"}),(0,t.jsx)(aM,{spec:eA,agentOrg:eT,agentSlug:eS?.slug??n,description:eA?.description,onSkillClick:a,editable:X,isSaving:G,saveField:es,saveRunDefaults:en,onPluginClick:I,onAgentClick:E,saveError:Z,clearSaveError:ea})]}),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(sS.f,{header:eL,identity:(0,t.jsx)(z,{agent:P,icon:eL.icon??(eL.iconUrl?(0,t.jsx)("img",{src:eL.iconUrl,alt:"",className:"stg:size-full stg:object-cover"}):null),visibilityControl:eM,versionCount:ed.count>0?ed.count:void 0,channelCount:ec.isLoading?void 0:ec.channels.length}),visibilityControl:eM,headerBanner:(0,t.jsx)(nw.f,{plugin:H.plugin,onPluginClick:I}),primaryAction:p,actions:eO,resource:q,tabs:em,activeTab:em?ex:void 0,onTabChange:em?eh:void 0,tabsAriaLabel:"Agent detail sections",className:D,children:W}),ev.dialog,ej&&(0,t.jsx)(Y.f,{open:!0,onOpenChange:ey,resource:P,onApplied:()=>F()})]})}function aM({spec:e,agentOrg:n,agentSlug:a,description:r,onSkillClick:i,editable:o,isSaving:g,saveField:c,saveRunDefaults:u,onPluginClick:m,onAgentClick:x,saveError:h,clearSaveError:f}){let p=e=>h?.field===e?h.message:void 0,b=(0,R.b)(),v=(0,s.useCallback)(async e=>c?.("instructions",e||void 0)??!1,[c]),j=(0,s.useCallback)(async e=>c?.("plugins",e.map(ta.f))??!1,[c]),y=(0,s.useCallback)(async e=>c?.("skillRefs",e.map(ta.f))??!1,[c]),N=(0,s.useCallback)(async e=>{let t={};for(let s of e)s.key.trim()&&(t[s.key.trim()]={isSecret:s.isSecret||void 0,description:s.description||void 0,optional:s.optional||void 0});return c?.("env",Object.keys(t).length>0?t:void 0)??!1},[c]),k=(0,s.useMemo)(()=>(e?.plugins??[]).map(e=>({org:e.org||n,slug:e.slug,...e.id?{id:e.id}:{},label:aI(l.X.plugin,e,n,b)})),[e?.plugins,n,b]),C=(0,s.useMemo)(()=>(e?.skillRefs??[]).map(e=>({org:e.org||n,slug:e.slug,...e.id?{id:e.id}:{},label:aI(l.X.skill,e,n,b)})),[e?.skillRefs,n,b]),w=(0,s.useMemo)(()=>Object.entries(e?.env??{}).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({key:e,value:"",isSecret:t.isSecret,description:t.description,optional:t.optional})),[e?.env]),S=o||!!r,A=o||!!e?.instructions,$=o||e&&e.plugins.length>0,T=o||e&&e.mcpServers.length>0,L=o||e&&e.skillRefs.length>0,M=o||e&&e.subagents.length>0,I=!!e&&sP(e),z=o||e?.env&&Object.keys(e.env).length>0,[E,O]=(0,s.useState)(!1),[D,W]=(0,s.useState)(!1),[P,U]=(0,s.useState)(!1),B=(0,s.useCallback)(e=>{e&&f?.(),O(e)},[f]),F=(0,s.useCallback)(e=>{e&&f?.(),W(e)},[f]),V=(0,s.useCallback)(e=>{e&&f?.(),U(e)},[f]);return(0,t.jsxs)("div",{className:"stg:flex stg:flex-col stg:gap-6",children:[S&&(0,t.jsx)(sA.f,{title:"Description",children:o?(0,t.jsx)("div",{className:"stg:max-h-20 stg:overflow-y-auto stg:p-3",children:(0,t.jsx)(ng.f,{value:e?.description||"",onSave:e=>c?.("description",e||void 0)??Promise.resolve(!1),isSaving:g,error:p("description"),placeholder:"Add a description",minRows:2})}):(0,t.jsx)("div",{className:"stg:p-3",children:(0,t.jsx)("pre",{className:"stg:whitespace-pre-wrap stg:break-words stg:text-sm stg:text-foreground stg:font-sans",children:r})})}),A&&(0,t.jsx)(sA.f,{title:"Instructions",children:o?(0,t.jsx)("div",{className:"stg:max-h-72 stg:overflow-y-auto stg:p-3",children:(0,t.jsx)(ng.f,{value:e?.instructions??"",onSave:v,isSaving:g,error:p("instructions"),placeholder:"Add instructions for the agent",minRows:4})}):(0,t.jsx)(aR,{text:e?.instructions??""})}),(0,t.jsx)(s6,{spec:e,editable:!!o&&void 0!==u,isSaving:!!g,error:p("runConfig"),onSave:e=>u?.(e)??Promise.resolve(!1),onEditStart:f}),(0,t.jsx)(no,{spec:e,agentOrg:n,editable:!!o&&void 0!==c,isSaving:!!g,error:p("environmentRef"),onSave:e=>c?.("environmentRef",e)??Promise.resolve(!1),onEditStart:f}),$&&(0,t.jsx)(sA.f,{title:"Plugins",count:e?.plugins.length,onEdit:o?()=>B(!E):void 0,children:o?(0,t.jsx)(ny,{value:k,onSave:j,isSaving:g,error:p("plugins"),editing:E,onEditingChange:B,onItemClick:m?e=>{(0,d.Q)(e)||m({org:e.org,slug:e.slug})}:void 0,itemIcon:(0,t.jsx)(sT.f,{className:"stg:size-4"}),resourceLabel:"plugin",defaultOrg:n}):(0,t.jsx)(az,{refs:e?.plugins??[],defaultOrg:n,onPluginClick:m})}),T&&(0,t.jsx)(s1,{servers:e?.mcpServers??[],org:n,editable:o,isSaving:g,error:p("mcpServers"),onSave:e=>c?.("mcpServers",e)??Promise.resolve(!1),onEditStart:f}),I&&e&&(0,t.jsx)(sA.f,{title:"Tools",children:(0,t.jsx)(sU,{tools:e.tools,disallowedTools:e.disallowedTools})}),(0,t.jsx)(sV,{hooks:e?.hooks??[]}),L&&(0,t.jsx)(sA.f,{title:"Skills",count:e?.skillRefs.length,onEdit:o?()=>F(!D):void 0,children:o?(0,t.jsx)(ny,{value:C,onSave:y,isSaving:g,error:p("skillRefs"),editing:D,onEditingChange:F,onItemClick:i?e=>{(0,d.Q)(e)||i({org:e.org,slug:e.slug})}:void 0,itemIcon:(0,t.jsx)(aU,{className:"stg:size-4"}),resourceLabel:"skill",defaultOrg:n}):(0,t.jsx)(aE,{refs:e?.skillRefs??[],defaultOrg:n,onSkillClick:i})}),M&&(0,t.jsx)(sq,{refs:e?.subagents??[],agentOrg:n,self:{org:n,slug:a},editable:o,isSaving:g,error:p("subagents"),onSave:e=>c?.("subagents",e)??Promise.resolve(!1),onEditStart:f,onAgentClick:x}),z&&(0,t.jsx)(sA.f,{title:"Environment Variables",count:Object.keys(e?.env??{}).length,onEdit:o?()=>V(!P):void 0,children:o?(0,t.jsx)(np,{value:w,onSave:N,isSaving:g,error:p("env"),editing:P,onEditingChange:V,showSecretToggle:!0,showOptionalToggle:!0,showDescription:!0,keyLabel:"Variable name"}):(0,t.jsx)(aO,{data:e?.env??{}})})]})}function aR({text:e}){let[n,r]=(0,s.useState)(!1),l=(0,s.useRef)(null),[i,o]=(0,s.useState)(!1);return(0,s.useEffect)(()=>{let e=l.current;e&&o(e.scrollHeight>e.clientHeight)},[e]),(0,t.jsxs)("div",{className:"stg:relative stg:p-3",children:[(0,t.jsx)("pre",{ref:l,className:(0,a.f)("stg:whitespace-pre-wrap stg:break-words stg:font-mono stg:text-sm stg:text-foreground stg:overflow-y-auto stg:transition-[max-height] stg:duration-200",!n&&"stg:overflow-hidden"),style:{maxHeight:n?"none":"12rem"},children:e}),!n&&i&&(0,t.jsx)("div",{className:"stg:pointer-events-none stg:absolute stg:inset-x-3 stg:bottom-10 stg:h-8 stg:bg-gradient-to-t stg:from-background stg:to-transparent"}),i&&(0,t.jsx)("button",{type:"button",onClick:()=>r(e=>!e),className:"stg:mt-2 stg:text-xs stg:font-medium stg:text-primary stg:transition-colors stg:hover:text-primary-muted",children:n?"Show less":"Show more"})]})}function aI(e,t,s,n){return(0,d.Q)(t)?(0,d.$)(e):t.org&&t.org!==s?`${n(t.org)}/${t.slug}`:t.slug}function az({refs:e,defaultOrg:s,onPluginClick:n}){let r=(0,R.b)();return(0,t.jsx)("div",{className:"stg:flex stg:flex-col",children:e.map((e,i)=>{let o=e.org||s,g=aI(l.X.plugin,e,s,r),c=(0,t.jsxs)("div",{className:"stg:flex stg:items-center stg:gap-3",children:[(0,t.jsx)(sT.f,{className:"stg:size-4 stg:shrink-0 stg:text-muted-foreground"}),(0,t.jsx)("span",{className:"stg:text-sm stg:font-medium stg:text-foreground",children:g})]});return n&&!(0,d.Q)(e)?(0,t.jsx)("button",{type:"button",onClick:()=>n({org:o,slug:e.slug}),className:(0,a.f)("stg:w-full stg:rounded-md stg:px-3 stg:py-2 stg:text-left stg:transition-colors","stg:hover:bg-accent-hover","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-inset stg:focus-visible:ring-ring"),children:c},`${o}/${e.slug||i}`):(0,t.jsx)("div",{className:"stg:px-3 stg:py-2",children:c},`${o}/${e.slug||i}`)})})}function aE({refs:e,defaultOrg:s,onSkillClick:n}){let r=(0,R.b)();return(0,t.jsx)("div",{className:"stg:flex stg:flex-col",children:e.map((e,i)=>{let o=e.org||s,g=aI(l.X.skill,e,s,r),c=(0,t.jsxs)("div",{className:"stg:flex stg:items-center stg:gap-3",children:[(0,t.jsx)(aU,{className:"stg:size-4 stg:shrink-0 stg:text-muted-foreground"}),(0,t.jsx)("span",{className:"stg:text-sm stg:font-medium stg:text-foreground",children:g})]});return n&&!(0,d.Q)(e)?(0,t.jsx)("button",{type:"button",onClick:()=>n({org:o,slug:e.slug}),className:(0,a.f)("stg:w-full stg:rounded-md stg:px-3 stg:py-2 stg:text-left stg:transition-colors","stg:hover:bg-accent-hover","stg:focus-visible:outline-none stg:focus-visible:ring-2 stg:focus-visible:ring-inset stg:focus-visible:ring-ring"),children:c},e.slug||i):(0,t.jsx)("div",{className:"stg:px-3 stg:py-2",children:c},e.slug||i)})})}function aO({data:e}){let s=Object.entries(e).sort(([e],[t])=>e.localeCompare(t));return(0,t.jsx)("div",{className:"stg:flex stg:flex-col stg:divide-y stg:divide-border",children:s.map(([e,s])=>(0,t.jsxs)("div",{className:"stg:flex stg:items-start stg:gap-3 stg:px-3 stg:py-2",children:[(0,t.jsx)("code",{className:"stg:shrink-0 stg:font-mono stg:text-sm stg:font-medium stg:text-foreground",children:e}),(0,t.jsx)("span",{className:"stg:shrink-0 stg:rounded stg:bg-muted stg:px-1.5 stg:py-0.5 stg:text-2xs stg:font-medium stg:text-muted-foreground",children:s.isSecret?"secret":"config"}),s.description&&(0,t.jsx)("span",{className:"stg:text-xs stg:text-muted-foreground",children:s.description})]},e))})}function aD({className:e}){return(0,t.jsxs)(nA.f,{className:(0,a.f)("stg:flex stg:flex-col stg:gap-6",e),label:"Loading agent details",children:[(0,t.jsxs)("div",{className:"stg:flex stg:items-start stg:gap-3",children:[(0,t.jsx)("div",{className:"stg:mt-1 stg:size-6 stg:shrink-0 stg:animate-pulse stg:rounded stg:bg-muted"}),(0,t.jsxs)("div",{className:"stg:flex-1 stg:space-y-2",children:[(0,t.jsx)("div",{className:"stg:h-5 stg:w-48 stg:animate-pulse stg:rounded stg:bg-muted"}),(0,t.jsx)("div",{className:"stg:h-3 stg:w-64 stg:animate-pulse stg:rounded stg:bg-muted"}),(0,t.jsx)("div",{className:"stg:h-4 stg:w-full stg:max-w-md stg:animate-pulse stg:rounded stg:bg-muted"})]})]}),[40,24,16].map(e=>(0,t.jsxs)("div",{className:"stg:space-y-2",children:[(0,t.jsx)("div",{className:"stg:h-3 stg:w-24 stg:animate-pulse stg:rounded stg:bg-muted"}),(0,t.jsx)("div",{className:"stg:animate-pulse stg:rounded-lg stg:border stg:border-border stg:bg-muted-faint",style:{height:`${4*e}px`}})]},e))]})}function aW({className:e}){return(0,t.jsxs)("div",{role:"status",className:(0,a.f)("stg:flex stg:flex-col stg:items-center stg:gap-2 stg:py-12 stg:text-center",e),children:[(0,t.jsx)(aP,{className:"stg:size-10 stg:text-muted-foreground-faint"}),(0,t.jsx)("p",{className:"stg:text-sm stg:font-medium stg:text-muted-foreground",children:"Agent not found"}),(0,t.jsx)("p",{className:"stg:text-xs stg:text-muted-foreground-subtle",children:"This agent doesn't exist or you don't have access to it."})]})}function aP({className:e}){return(0,t.jsxs)("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,t.jsx)("rect",{x:"3",y:"5",width:"10",height:"8",rx:"1.5"}),(0,t.jsx)("path",{d:"M6 9h.01M10 9h.01",strokeWidth:"2"}),(0,t.jsx)("path",{d:"M8 2v3"})]})}function aU({className:e}){return(0,t.jsx)("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M9 1.5 4 9h4l-1 5.5L12 7H8l1-5.5Z"})})}var aB=e.i(582321),aF=e.i(310057),aV=e.i(451241),aH=e.i(107141),a_=e.i(683738),aq=e.i(336095),aY=e.i(472402);function aJ(e){return(0,D.f)((0,aY.X)(),e)}var aK=e.i(774043);function aX({org:e,slug:a}){let r=(0,n.useRouter)(),{setLabel:l}=(0,aF.Q)(),{navigateToDetail:i,canonicalSlug:o}=(0,aV.b)(),{navigateToRun:g}=(0,a_.f)(),[d,c]=(0,s.useState)(null),[u,m]=(0,s.useState)("Agent"),{copyId:x,copyQualifiedSlug:h}=(0,ea.f)(),{confirmState:f,confirm:p,handleConfirm:b,handleCancel:v}=(0,q.f)(),{deleteResource:j,isDeleting:y}=(0,aB.f)("agent",d,u),[N,k]=(0,s.useState)(()=>new URLSearchParams(window.location.search).get("tab")??void 0??"overview");(0,s.useEffect)(()=>()=>l(null),[l]);let C=(0,s.useCallback)(({name:e,id:t,slug:s})=>{l(e),c(t),m(e),""!==s&&s!==a&&o(s)},[l,a,o]),w=(0,s.useCallback)(async()=>{if(await p({title:`Delete ${u}?`,description:aK.f,confirmLabel:"Delete",variant:"destructive"}))try{await j(),r.push("/library/agents")}catch{}},[p,j,r,u]),S=(0,s.useMemo)(()=>({id:"start-session",label:"Start session",onAction:()=>r.push((0,aq.p)(e,a))}),[r,e,a]),A=(0,s.useMemo)(()=>[{id:"copy-id",label:"Copy ID",group:"clipboard",onAction:()=>{d&&x(d)},disabled:!d},{id:"copy-slug",label:"Copy slug",group:"clipboard",onAction:()=>h(e,a)},{id:"delete",requires:"can_delete",label:"Delete",variant:"destructive",group:"danger",onAction:w,disabled:y}],[d,x,h,e,a,w,y]);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(aL,{org:e,slug:a,onResourceLoad:C,onSkillClick:({org:e,slug:t})=>i("skills",e,t),onPluginClick:({org:e,slug:t})=>i("plugins",e,t),onAgentClick:({org:e,slug:t})=>i("agents",e,t),onNavigateToRun:g,onRenamed:e=>{e.metadata?.slug&&o(e.metadata.slug)},editable:!0,primaryAction:S,actions:A,yamlActions:!0,buildChatLinkUrl:aJ,channelAppsHref:"/settings/channel-apps",sessionHref:e=>`/sessions/${e}`,activeTab:N,onTabChange:k}),(0,t.jsx)(_.f,{state:f,onConfirm:b,onCancel:v})]})}e.s(["AgentDetailPage",0,function(){let e=(0,aV.R)(),s=(0,aH.f)("org",2),n=(0,aH.f)("slug");return!e&&s&&n?(0,t.jsx)(aX,{org:s,slug:n}):null},"AgentDetailPageInner",0,aX],63353)}]);