botmancers 0.9.3 → 0.10.1

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 (204) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +5 -5
  3. package/app/.next/BUILD_ID +1 -1
  4. package/app/.next/app-path-routes-manifest.json +1 -0
  5. package/app/.next/build-manifest.json +3 -3
  6. package/app/.next/prerender-manifest.json +3 -3
  7. package/app/.next/required-server-files.json +2 -2
  8. package/app/.next/routes-manifest.json +6 -0
  9. package/app/.next/server/app/_global-error.html +1 -1
  10. package/app/.next/server/app/_global-error.rsc +1 -1
  11. package/app/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  12. package/app/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  13. package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  14. package/app/.next/server/app/_not-found/page.js.nft.json +1 -1
  15. package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  16. package/app/.next/server/app/_not-found.html +1 -1
  17. package/app/.next/server/app/_not-found.rsc +2 -2
  18. package/app/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  19. package/app/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  20. package/app/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  21. package/app/.next/server/app/agents/[id]/activity/page.js.nft.json +1 -1
  22. package/app/.next/server/app/agents/[id]/activity/page_client-reference-manifest.js +1 -1
  23. package/app/.next/server/app/agents/[id]/config/page.js.nft.json +1 -1
  24. package/app/.next/server/app/agents/[id]/config/page_client-reference-manifest.js +1 -1
  25. package/app/.next/server/app/agents/[id]/conversations/[conversationId]/page.js.nft.json +1 -1
  26. package/app/.next/server/app/agents/[id]/conversations/[conversationId]/page_client-reference-manifest.js +1 -1
  27. package/app/.next/server/app/agents/[id]/conversations/page.js.nft.json +1 -1
  28. package/app/.next/server/app/agents/[id]/conversations/page_client-reference-manifest.js +1 -1
  29. package/app/.next/server/app/agents/[id]/page.js.nft.json +1 -1
  30. package/app/.next/server/app/agents/[id]/page_client-reference-manifest.js +1 -1
  31. package/app/.next/server/app/agents/[id]/sessions/page.js.nft.json +1 -1
  32. package/app/.next/server/app/agents/[id]/sessions/page_client-reference-manifest.js +1 -1
  33. package/app/.next/server/app/agents/[id]/slack/page.js.nft.json +1 -1
  34. package/app/.next/server/app/agents/[id]/slack/page_client-reference-manifest.js +1 -1
  35. package/app/.next/server/app/api/bots/[id]/activity/route.js.nft.json +1 -1
  36. package/app/.next/server/app/api/bots/[id]/config/route.js.nft.json +1 -1
  37. package/app/.next/server/app/api/bots/[id]/conversations/[conversationId]/route.js.nft.json +1 -1
  38. package/app/.next/server/app/api/bots/[id]/conversations/route.js.nft.json +1 -1
  39. package/app/.next/server/app/api/bots/[id]/overview/route.js.nft.json +1 -1
  40. package/app/.next/server/app/api/bots/[id]/sessions/[ref]/pins/route.js.nft.json +1 -1
  41. package/app/.next/server/app/api/bots/[id]/sessions/[ref]/route.js.nft.json +1 -1
  42. package/app/.next/server/app/api/bots/[id]/sessions/[ref]/shares/route.js.nft.json +1 -1
  43. package/app/.next/server/app/api/bots/[id]/sessions/route.js.nft.json +1 -1
  44. package/app/.next/server/app/api/bots/[id]/sessions/sync/route.js.nft.json +1 -1
  45. package/app/.next/server/app/api/bots/[id]/share-policy/route.js.nft.json +1 -1
  46. package/app/.next/server/app/api/bots/[id]/skill/route.js.nft.json +1 -1
  47. package/app/.next/server/app/api/bots/availability/route.js.nft.json +1 -1
  48. package/app/.next/server/app/api/bots/delete-preview/route.js.nft.json +1 -1
  49. package/app/.next/server/app/api/bots/import/route.js.nft.json +1 -1
  50. package/app/.next/server/app/api/bots/manage/route.js.nft.json +1 -1
  51. package/app/.next/server/app/api/bots/name-migrations/route.js.nft.json +1 -1
  52. package/app/.next/server/app/api/bots/route.js.nft.json +1 -1
  53. package/app/.next/server/app/api/conversations/[id]/approve/route.js.nft.json +1 -1
  54. package/app/.next/server/app/api/conversations/[id]/deny/route.js.nft.json +1 -1
  55. package/app/.next/server/app/api/conversations/[id]/draft/route.js.nft.json +1 -1
  56. package/app/.next/server/app/api/conversations/[id]/messages/[messageId]/stop/route.js.nft.json +1 -1
  57. package/app/.next/server/app/api/conversations/[id]/messages/route.js.nft.json +1 -1
  58. package/app/.next/server/app/api/conversations/[id]/route.js.nft.json +1 -1
  59. package/app/.next/server/app/api/conversations/[id]/stop/route.js.nft.json +1 -1
  60. package/app/.next/server/app/api/conversations/route.js.nft.json +1 -1
  61. package/app/.next/server/app/api/exchanges/[id]/cancel/route.js.nft.json +1 -1
  62. package/app/.next/server/app/api/exchanges/[id]/route.js.nft.json +1 -1
  63. package/app/.next/server/app/api/exchanges/route.js.nft.json +1 -1
  64. package/app/.next/server/app/api/files/[name]/route.js.nft.json +1 -1
  65. package/app/.next/server/app/api/groups/route.js.nft.json +1 -1
  66. package/app/.next/server/app/api/health/route.js.nft.json +1 -1
  67. package/app/.next/server/app/api/mcp/route.js.nft.json +1 -1
  68. package/app/.next/server/app/api/messages/[id]/between/route.js.nft.json +1 -1
  69. package/app/.next/server/app/api/runtime-capacity/route/app-paths-manifest.json +3 -0
  70. package/app/.next/server/app/api/runtime-capacity/route/build-manifest.json +12 -0
  71. package/app/.next/server/app/api/runtime-capacity/route/server-reference-manifest.json +4 -0
  72. package/app/.next/server/app/api/runtime-capacity/route.js +10 -0
  73. package/app/.next/server/app/api/runtime-capacity/route.js.nft.json +1 -0
  74. package/app/.next/server/app/api/runtime-capacity/route_client-reference-manifest.js +3 -0
  75. package/app/.next/server/app/api/runtime-connections/route.js.nft.json +1 -1
  76. package/app/.next/server/app/api/service-grants/route.js.nft.json +1 -1
  77. package/app/.next/server/app/api/shares/[shareRef]/revoke/route.js.nft.json +1 -1
  78. package/app/.next/server/app/api/shares/route.js.nft.json +1 -1
  79. package/app/.next/server/app/api/v0/agents/[agentId]/conversations/[conversationId]/route.js.nft.json +1 -1
  80. package/app/.next/server/app/api/v0/agents/[agentId]/conversations/route.js.nft.json +1 -1
  81. package/app/.next/server/app/api/v0/agents/[agentId]/messages/route.js.nft.json +1 -1
  82. package/app/.next/server/app/api/v0/agents/[agentId]/pins/route.js.nft.json +1 -1
  83. package/app/.next/server/app/api/v0/agents/[agentId]/route.js.nft.json +1 -1
  84. package/app/.next/server/app/api/v0/agents/[agentId]/sessions/[ref]/route.js.nft.json +1 -1
  85. package/app/.next/server/app/api/v0/agents/[agentId]/sessions/route.js.nft.json +1 -1
  86. package/app/.next/server/app/api/v0/agents/route.js.nft.json +1 -1
  87. package/app/.next/server/app/api/v0/capabilities/route.js.nft.json +1 -1
  88. package/app/.next/server/app/api/v0/conversations/[id]/route.js.nft.json +1 -1
  89. package/app/.next/server/app/api/v0/exchanges/[id]/cancel/route.js.nft.json +1 -1
  90. package/app/.next/server/app/api/v0/exchanges/[id]/route.js.nft.json +1 -1
  91. package/app/.next/server/app/api/v0/exchanges/route.js.nft.json +1 -1
  92. package/app/.next/server/app/api/v0/mcp/route.js.nft.json +1 -1
  93. package/app/.next/server/app/api/v0/pins/[pinRef]/detach/route.js.nft.json +1 -1
  94. package/app/.next/server/app/api/v0/pins/[pinRef]/messages/route.js.nft.json +1 -1
  95. package/app/.next/server/app/api/v0/pins/[pinRef]/route.js.nft.json +1 -1
  96. package/app/.next/server/app/api/v0/requests/[id]/route.js.nft.json +1 -1
  97. package/app/.next/server/app/api/v0/sessions/[ref]/messages/route.js.nft.json +1 -1
  98. package/app/.next/server/app/api/v0/sessions/[ref]/pins/route.js.nft.json +1 -1
  99. package/app/.next/server/app/api/v0/sessions/[ref]/shares/route.js.nft.json +1 -1
  100. package/app/.next/server/app/api/v0/shares/[shareRef]/revoke/route.js.nft.json +1 -1
  101. package/app/.next/server/app/api/v0/shares/[shareRef]/route.js.nft.json +1 -1
  102. package/app/.next/server/app/api/v0/shares/current/route.js.nft.json +1 -1
  103. package/app/.next/server/app/api/v0/shares/route.js.nft.json +1 -1
  104. package/app/.next/server/app/api/wake-grants/[id]/revoke/route.js.nft.json +1 -1
  105. package/app/.next/server/app/api/wakes/[id]/decision/route.js.nft.json +1 -1
  106. package/app/.next/server/app/api/wakes/[id]/retry/route.js.nft.json +1 -1
  107. package/app/.next/server/app/bots/[id]/config/page.js.nft.json +1 -1
  108. package/app/.next/server/app/bots/[id]/config/page_client-reference-manifest.js +1 -1
  109. package/app/.next/server/app/exchanges/page.js.nft.json +1 -1
  110. package/app/.next/server/app/exchanges/page_client-reference-manifest.js +1 -1
  111. package/app/.next/server/app/exchanges.html +1 -1
  112. package/app/.next/server/app/exchanges.rsc +3 -3
  113. package/app/.next/server/app/exchanges.segments/_full.segment.rsc +3 -3
  114. package/app/.next/server/app/exchanges.segments/_tree.segment.rsc +2 -2
  115. package/app/.next/server/app/exchanges.segments/exchanges/__PAGE__.segment.rsc +3 -3
  116. package/app/.next/server/app/index.html +1 -1
  117. package/app/.next/server/app/index.rsc +3 -3
  118. package/app/.next/server/app/index.segments/__PAGE__.segment.rsc +3 -3
  119. package/app/.next/server/app/index.segments/_full.segment.rsc +3 -3
  120. package/app/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  121. package/app/.next/server/app/page.js.nft.json +1 -1
  122. package/app/.next/server/app/page_client-reference-manifest.js +1 -1
  123. package/app/.next/server/app/settings/page.js.nft.json +1 -1
  124. package/app/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  125. package/app/.next/server/app/settings.html +1 -1
  126. package/app/.next/server/app/settings.rsc +3 -3
  127. package/app/.next/server/app/settings.segments/_full.segment.rsc +3 -3
  128. package/app/.next/server/app/settings.segments/_tree.segment.rsc +2 -2
  129. package/app/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +3 -3
  130. package/app/.next/server/app/threads/[id]/route.js.nft.json +1 -1
  131. package/app/.next/server/app-paths-manifest.json +1 -0
  132. package/app/.next/server/chunks/[externals]__06_ygwr._.js +3 -0
  133. package/app/.next/server/chunks/{[externals]__1eaoma8._.js → [externals]__0z3qnkl._.js} +2 -2
  134. package/app/.next/server/chunks/[root-of-the-server]__0aincj4._.js +1 -1
  135. package/app/.next/server/chunks/[root-of-the-server]__0anfwiu._.js +1 -1
  136. package/app/.next/server/chunks/[root-of-the-server]__0fku-bw._.js +1 -1
  137. package/app/.next/server/chunks/[root-of-the-server]__1280ke1._.js +1 -1
  138. package/app/.next/server/chunks/[root-of-the-server]__13wghn3._.js +4 -4
  139. package/app/.next/server/chunks/[root-of-the-server]__1jxwu9_._.js +2 -2
  140. package/app/.next/server/chunks/{[root-of-the-server]__00ntari._.js → [root-of-the-server]__1nf6z4s._.js} +10 -10
  141. package/app/.next/server/chunks/[root-of-the-server]__1qbadul._.js +5 -0
  142. package/app/.next/server/chunks/_0061c2q._.js +1 -1
  143. package/app/.next/server/chunks/_1-5mthb._.js +1 -1
  144. package/app/.next/server/chunks/_1a0er16._.js +3 -3
  145. package/app/.next/server/chunks/_1uxmsh3._.js +3 -3
  146. package/app/.next/server/chunks/_next-internal_server_app_api_runtime-capacity_route_actions_1dzvg7f.js +3 -0
  147. package/app/.next/server/chunks/lib_service-api_ts_18eok4w._.js +3 -3
  148. package/app/.next/server/chunks/ssr/_00qrupp._.js +3 -0
  149. package/app/.next/server/chunks/ssr/_01ngpwj._.js +1 -1
  150. package/app/.next/server/chunks/ssr/_0d7gv3q._.js +3 -0
  151. package/app/.next/server/chunks/ssr/_0iywd5g._.js +1 -1
  152. package/app/.next/server/chunks/ssr/_0mxifu3._.js +1 -1
  153. package/app/.next/server/chunks/ssr/_0u7urta._.js +1 -1
  154. package/app/.next/server/chunks/ssr/app_agents_[id]_0sr4fdg._.js +1 -1
  155. package/app/.next/server/chunks/ssr/app_agents_[id]_activity_AgentActivityPage_tsx_042-590._.js +1 -1
  156. package/app/.next/server/chunks/ssr/app_agents_[id]_config_page_tsx_1f_gu1l._.js +1 -1
  157. package/app/.next/server/chunks/ssr/app_agents_[id]_sessions_page_tsx_0tfup-2._.js +3 -3
  158. package/app/.next/server/chunks/ssr/app_agents_[id]_slack_AgentSlackPage_tsx_20njhs1._.js +1 -1
  159. package/app/.next/server/chunks/ssr/app_page_tsx_0pxmutw._.js +1 -1
  160. package/app/.next/server/chunks/ssr/lib_0pfn9gs._.js +1 -1
  161. package/app/.next/server/chunks/ssr/lib_agent-registration-ui_ts_1z582mm._.js +1 -1
  162. package/app/.next/server/chunks/ssr/lib_exchange-view_ts_1a4q9ju._.js +1 -1
  163. package/app/.next/server/chunks/ssr/lib_share-view_ts_08psw5o._.js +1 -1
  164. package/app/.next/server/middleware-build-manifest.js +3 -3
  165. package/app/.next/server/middleware.js +2 -2
  166. package/app/.next/server/pages/404.html +1 -1
  167. package/app/.next/server/pages/500.html +1 -1
  168. package/app/.next/server/server-reference-manifest.js +1 -1
  169. package/app/.next/server/server-reference-manifest.json +1 -1
  170. package/app/.next/static/chunks/{2dtkykrnob8wk.js → 00pca1oa16xc5.js} +1 -1
  171. package/app/.next/static/chunks/{3x56k5qa012au.js → 0apccyvpyjlo7.js} +1 -1
  172. package/app/.next/static/chunks/{04nfr73lkk7pz.js → 0l9r-x310007w.js} +1 -1
  173. package/app/.next/static/chunks/{0eqgs3167zj2j.js → 0xo3nwo_nscvf.js} +1 -1
  174. package/app/.next/static/chunks/{326jto9l-m8vj.js → 0z_bq7h1mwcf3.js} +4 -4
  175. package/app/.next/static/chunks/18btj4qlun8o7.js +1 -0
  176. package/app/.next/static/chunks/{2cc4uzbhs_v23.js → 1k8e6j67zksws.js} +1 -1
  177. package/app/.next/static/chunks/1y9hc8qm0hqds.js +1 -0
  178. package/app/.next/static/chunks/{2ebpfmg4vni8e.js → 2wbcr5n_vcynr.js} +1 -1
  179. package/app/.next/static/chunks/3_lwv2zgy_-bw.css +3 -0
  180. package/app/.next/static/chunks/3a_ffnuma49te.js +1 -0
  181. package/app/.next/static/chunks/{3whw2-l4a2sli.js → 3fm68xa8a4-es.js} +1 -1
  182. package/app/.next/static/chunks/{0cjh4u-f7mlwd.js → 3gw1ytgjq4pxu.js} +1 -1
  183. package/app/.next/static/chunks/3wlqn3gd_jv_r.js +1 -0
  184. package/app/.next/static/chunks/3xjoca0z2onuc.js +1 -0
  185. package/app/BUILD_INFO.json +2 -2
  186. package/app/package.json +1 -1
  187. package/app/public/brand/harness/claude.svg +3 -0
  188. package/app/public/brand/harness/codex.png +0 -0
  189. package/app/public/brand/harness/cursor.svg +3 -0
  190. package/app/public/brand/harness/muse.svg +33 -0
  191. package/app/server.js +1 -1
  192. package/package.json +1 -1
  193. package/schemas/botmancers.mcp.v2.tools.json +46 -46
  194. package/app/.next/server/chunks/ssr/_0g3y1u9._.js +0 -3
  195. package/app/.next/server/chunks/ssr/app_agents_[id]_conversations_page_tsx_15zl_c8._.js +0 -3
  196. package/app/.next/static/chunks/10i-rrea371m2.js +0 -1
  197. package/app/.next/static/chunks/1ob-de9xo9m2e.css +0 -3
  198. package/app/.next/static/chunks/1ypwptc0fsn4w.js +0 -1
  199. package/app/.next/static/chunks/1zryovio86f1z.js +0 -1
  200. package/app/.next/static/chunks/34v8aumua0x5n.js +0 -1
  201. package/app/.next/static/chunks/3m-2-98qud-hf.js +0 -1
  202. /package/app/.next/static/{0BJMiZPkEfFOd56nhl62e → eBmHBBldHWytVvYPu0zHc}/_buildManifest.js +0 -0
  203. /package/app/.next/static/{0BJMiZPkEfFOd56nhl62e → eBmHBBldHWytVvYPu0zHc}/_clientMiddlewareManifest.js +0 -0
  204. /package/app/.next/static/{0BJMiZPkEfFOd56nhl62e → eBmHBBldHWytVvYPu0zHc}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,31713,e=>{"use strict";var t=e.i(43476),n=e.i(71645),a=e.i(22016),s=e.i(57688),r=e.i(18566),l=e.i(64711),i=e.i(87303),o=e.i(89873),c=e.i(68684),d=e.i(74904),u=e.i(33851),m=e.i(44079),h=e.i(52900),p=e.i(68541),f=e.i(15983),g=e.i(10718);function x(e){return String(e).padStart(2,"0")}function y(e){let t=new Date(e);return`${t.getFullYear()}-${x(t.getMonth()+1)}-${x(t.getDate())} ${x(t.getHours())}:${x(t.getMinutes())}`}function v({onClose:e,onDeleted:a}){let s=(0,n.useId)(),[r,l]=(0,n.useState)(null),[i,o]=(0,n.useState)(""),[c,u]=(0,n.useState)(""),[m,h]=(0,n.useState)([]),[p,x]=(0,n.useState)(!1),j=(0,n.useRef)(null),b=(0,n.useRef)(null),w=(0,n.useRef)(null);(0,n.useEffect)(()=>{let e=!1;return fetch("/api/bots/manage",{cache:"no-store"}).then(async t=>{let n=await t.json().catch(()=>null);if(!e){if(!t.ok||!Array.isArray(n))return void o("string"==typeof n?.error?n.error:"Could not load agents.");l(n)}}).catch(()=>{e||o("Could not load agents.")}),j.current?.focus(),()=>{e=!0}},[]);let N=c.trim().toLowerCase(),C=(r??[]).filter(e=>e.name.toLowerCase().includes(N)),S=C.filter(e=>!e.blocked);return(0,n.useEffect)(()=>{if(p)return;let t=t=>{"Escape"===t.key&&e()};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[p,e]),(0,t.jsxs)("div",{className:"modal-scrim manage-scrim",children:[(0,t.jsxs)("div",{ref:w,className:"manage-card",role:"dialog","aria-modal":"true","aria-labelledby":s,onKeyDown:e=>{if("Tab"!==e.key||!w.current)return;let t=Array.from(w.current.querySelectorAll("button:not(:disabled), input:not(:disabled)"));if(0===t.length)return;let n=t[0],a=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),a.focus()):e.shiftKey||document.activeElement!==a||(e.preventDefault(),n.focus())},children:[(0,t.jsxs)("div",{className:"manage-head",children:[(0,t.jsx)("h2",{id:s,className:"delete-title",children:"Manage agents"}),(0,t.jsx)("button",{type:"button",className:"cancel-btn",onClick:e,children:"Close"})]}),(0,t.jsx)("label",{className:"manage-search-label",htmlFor:`${s}-search`,children:"Filter by name"}),(0,t.jsx)("input",{id:`${s}-search`,ref:j,className:"manage-search",type:"search",value:c,onChange:e=>u(e.target.value),placeholder:"Name contains…"}),(0,t.jsxs)("div",{className:"manage-tools",children:[(0,t.jsx)("button",{type:"button",className:"pin-word",onClick:()=>{h(e=>Array.from(new Set([...e,...S.map(e=>e.id)])))},disabled:0===S.length,children:"Select all shown"}),(0,t.jsx)("button",{type:"button",className:"pin-word",onClick:()=>{h([]),j.current?.focus()},disabled:0===m.length,children:"Clear selection"}),(0,t.jsxs)("span",{className:"manage-count","aria-live":"polite",children:[m.length," selected · ",C.length," shown of ",r?.length??0]})]}),i?(0,t.jsx)("p",{className:"delete-error",role:"alert",children:i}):null,r||i?null:(0,t.jsx)("p",{className:"delete-copy",children:"Loading agents…"}),r?(0,t.jsxs)("ul",{className:"manage-list","aria-label":"Agents",children:[0===C.length?(0,t.jsx)("li",{className:"delete-copy",children:"No agents match."}):null,C.map(e=>{let n=`${s}-row-${e.id}`,a=(0,d.botConnectionLabel)(e)??"Not set";return(0,t.jsxs)("li",{className:e.blocked?"manage-row is-blocked":"manage-row","data-agent-id":e.id,children:[(0,t.jsx)("input",{id:n,type:"checkbox",checked:m.includes(e.id),disabled:!!e.blocked,onChange:()=>{var t;return t=e.id,void h(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},"aria-describedby":e.blocked?`${n}-reason`:void 0}),(0,t.jsxs)("div",{className:"manage-copy",children:[(0,t.jsxs)("label",{htmlFor:n,className:"manage-name",children:[e.name,e.hidden?(0,t.jsx)("span",{className:"manage-tag",children:"Hidden"}):null]}),(0,t.jsxs)("dl",{className:"manage-meta",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{children:"Agent"}),(0,t.jsx)("dd",{children:(0,d.botAgentLabel)(e)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{children:"Connection"}),(0,t.jsx)("dd",{children:a})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{children:"Source"}),(0,t.jsx)("dd",{children:e.source_provider||"Created here"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{children:"Created"}),(0,t.jsx)("dd",{children:y(e.created_at)})]}),e.last_activity?(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{children:"Last activity"}),(0,t.jsx)("dd",{children:y(e.last_activity)})]}):null]}),e.blocked?(0,t.jsx)("p",{id:`${n}-reason`,className:"manage-reason",children:(0,g.blockedReasonCopy)(e.blocked)}):null]})]},e.id)})]}):null,(0,t.jsxs)("div",{className:"form-actions manage-actions",children:[(0,t.jsx)("button",{type:"button",className:"cancel-btn",onClick:e,children:"Cancel"}),(0,t.jsxs)("button",{ref:b,type:"button",className:"delete-btn",disabled:0===m.length,onClick:()=>x(!0),children:["Delete selected",m.length>0?` (${m.length})`:""]})]})]}),p?(0,t.jsx)(f.default,{ids:m,onCancel:()=>{x(!1),requestAnimationFrame(()=>b.current?.focus())},onDeleted:a}):null]})}var j=e.i(71836);function b({view:e,agentName:n}){if("loading"===e)return(0,t.jsx)("p",{className:"thread-note",role:"status",children:"Loading messages…"});if("error"===e)return(0,t.jsx)("p",{className:"thread-note thread-note-error",role:"alert",children:"Couldn’t load messages. Trying again…"});if("empty"===e){let e={title:`No messages with ${n} yet.`,hint:"Say something below to start the conversation."};return(0,t.jsxs)("div",{className:"thread-empty","data-thread-empty":"",children:[(0,t.jsx)("p",{className:"thread-empty-title",children:e.title}),(0,t.jsx)("p",{className:"thread-empty-hint",children:e.hint})]})}return null}var w=e.i(46986),N=e.i(96594),C=e.i(15366),S=e.i(54423),k=e.i(13255),R=e.i(63352),A=e.i(3136);function D(e,t,n){let a=t?`/agents/${encodeURIComponent(e)}/conversations/${encodeURIComponent(t)}`:`/agents/${encodeURIComponent(e)}/conversations`;return n?`${a}?exchange=${encodeURIComponent(n)}`:a}function I(e){return!!e&&"chief-of-staff"===e.name.toLowerCase()}function E(e){return I(e)?0:e.pinned?1:2}function $(e){let t=e;for(let e=0;e<2;e++){let e=t.replace(/^\s*\[Message from [^\]]+\]\s*(?:\r?\n)?/,"");if(e===t)break;t=e}return t.replace(/^\s+/,"")}function T(e){let t=e;for(let e=0;e<4;e++){let e=t.replace(/^\s*\[(?:Message from|From) [^\]]+\]\s*(?:\r?\n)?/,"");if(e===t)break;t=e}return t}function L({message:e,conversationId:a,status:s,onDone:r}){let l=(0,c.parseDraft)(T(e.content)),[i,o]=(0,n.useState)(l?.recipient??""),[d,u]=(0,n.useState)(l?.body??""),[m,h]=(0,n.useState)(!1),[p,f]=(0,n.useState)("open"!==s),g=(0,n.useRef)("open"!==s);if(!l)return null;let x="open"!==s||p,y=x?l.recipient:i,v=x?l.body:d,j=async t=>{if(!x&&!g.current&&!m&&("send"!==t||""!==i.trim())){g.current=!0,f(!0),h(!0);try{(await fetch(`/api/conversations/${a}/draft`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messageId:e.id,action:t,recipient:i,body:d})})).ok||(g.current=!1,f(!1))}finally{h(!1),r()}}};return(0,t.jsxs)("div",{className:"draft-card",children:[(0,t.jsx)("div",{className:"draft-title",children:(0,c.draftTitle)(l.channel)}),(0,t.jsx)("input",{type:"text","aria-label":"Recipient",value:y,readOnly:x,disabled:m,onChange:e=>{x||o(e.target.value)}}),(0,t.jsx)("textarea",{rows:3,"aria-label":"Draft body",value:v,readOnly:x,disabled:m,onChange:e=>{x||u(e.target.value)}}),"sent"===s?(0,t.jsx)("span",{className:"draft-mark",children:"Sent"}):null,"discarded"===s?(0,t.jsx)("span",{className:"draft-mark",children:"Discarded"}):null,"discarded"!==s?(0,t.jsx)("button",{type:"button",className:"approve-control",disabled:m,onClick:()=>{j("send")},children:"Send"}):null,"open"===s?(0,t.jsx)("button",{type:"button",className:"approve-control",style:{marginLeft:8},disabled:m,onClick:()=>{j("discard")},children:"Discard"}):null]})}function F({message:e,conversationId:a,status:s,onDone:r}){let l=(0,c.parseApprovalCode)(e.content),[i,o]=(0,n.useState)(!1),d=(0,n.useRef)("pending"!==s);if(!l)return null;let u=async t=>{if(!d.current&&!i){d.current=!0,o(!0);try{(await fetch(`/api/conversations/${a}/${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:l,messageId:e.id})})).ok||(d.current=!1)}finally{o(!1),r()}}};return"pending"!==s?(0,t.jsx)("span",{className:"draft-mark",children:"approved"===s?"Approved":"Denied"}):(0,t.jsxs)("span",{className:"draft-mark",children:[(0,t.jsx)("button",{type:"button",className:"approve-control",disabled:i,onClick:()=>{u("approve")},children:"Approve"}),(0,t.jsx)("button",{type:"button",className:"approve-control",style:{marginLeft:8},disabled:i,onClick:()=>{u("deny")},children:"Deny"})]})}function _({names:e}){return 0===e.length?null:(0,t.jsx)(t.Fragment,{children:e.map(e=>(0,t.jsxs)("span",{children:[(0,t.jsx)("br",{}),(0,t.jsxs)("a",{className:"file-control",href:`/api/files/${encodeURIComponent(e)}`,download:e,children:["Download ",e]})]},e))})}function P({anchorRef:e,onClose:a,onCreated:s}){let[r,l]=(0,n.useState)(""),[i,o]=(0,n.useState)(u.DEFAULT_REGISTRATION_FORM),[c,p]=(0,n.useState)(""),[f,g]=(0,n.useState)(!1),[x,y]=(0,n.useState)(!1),[v,b]=(0,n.useState)(null),w=(0,h.useRuntimeConnections)(),[N,C]=(0,n.useState)(null),S=(0,n.useRef)(null),k=(0,n.useRef)(null),D=(0,n.useRef)(null);(0,n.useLayoutEffect)(()=>{let t=()=>{let t=e.current?.getBoundingClientRect();C((0,j.newAgentDialogPlacement)(t?{left:t.left,bottom:t.bottom}:null,{width:window.innerWidth,height:window.innerHeight}))};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[e]),(0,n.useEffect)(()=>{k.current?.focus()},[]),(0,n.useEffect)(()=>{v&&D.current?.focus()},[v]),(0,n.useEffect)(()=>{let e=e=>{"Escape"===e.key&&(e.stopPropagation(),a())};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[a]);let I=(0,u.registrationFormView)(i,w.state),E=async e=>{let t;if(e.preventDefault(),I.submitDisabled||x)return;if((0,u.hasRegistrationErrors)(I)){g(!0),p("Fix the highlighted fields.");return}p(""),y(!0);try{t=await fetch("/api/bots",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify((0,u.registrationCreateBody)(r,i))})}finally{y(!1)}let n=await t.json().catch(()=>null);if(!t.ok)return void p("string"==typeof n?.error&&n.error?n.error:"Failed to create agent");let a=n?.session_sync;if(!a||"string"!=typeof a.outcome)return void s();let l="string"==typeof n?.agent?(0,A.agentLabel)(n.agent):"Sessions";b({line:(0,R.registrationSessionSyncCopy)(a,l),agentName:"string"==typeof n?.name?n.name:r})};return(0,t.jsx)("div",{className:"modal-scrim new-agent-scrim",onKeyDown:e=>{if("Tab"!==e.key||!S.current)return;let t=Array.from(S.current.querySelectorAll(j.DIALOG_FOCUSABLE)),n=(0,j.wrapFocusTarget)(t,document.activeElement,e.shiftKey);n&&(e.preventDefault(),n.focus())},children:(0,t.jsxs)("div",{ref:S,className:"form-card new-agent-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"new-agent-title",style:N??void 0,children:[(0,t.jsx)("div",{className:"kind-row",children:(0,t.jsx)("h2",{id:"new-agent-title",className:"kind-word new-agent-title",children:"New Agent"})}),v?(0,t.jsxs)("div",{className:"bot-form",children:[(0,t.jsx)("div",{className:"new-agent-body",children:(0,t.jsxs)("p",{role:"status",children:[v.agentName," created. ",v.line]})}),(0,t.jsx)("div",{className:"form-actions",children:(0,t.jsx)("button",{ref:D,type:"button",className:"create-btn",onClick:s,children:"Done"})})]}):(0,t.jsxs)("form",{onSubmit:E,className:"bot-form",children:[(0,t.jsxs)("div",{className:"new-agent-body",children:[(0,t.jsx)("label",{htmlFor:"bot-name",children:"Name"}),(0,t.jsx)("input",{ref:k,id:"bot-name",type:"text",value:r,onChange:e=>l(e.target.value),required:!0}),(0,t.jsx)(m.RegistrationFields,{idPrefix:"bot",variant:"modal",form:i,onChange:e=>{p(""),o(t=>({...t,...e}))},view:I,showErrors:f,connections:w.state,onRetryConnections:w.retry,onAddConnection:w.add,workspacePlaceholder:d.WORKSPACE_TEMPLATE,workspaceHint:d.NEW_AGENT_WORKSPACE_HINT}),c?(0,t.jsx)("p",{className:"form-error",role:"alert",children:c}):null]}),(0,t.jsxs)("div",{className:"form-actions",children:[(0,t.jsx)("button",{type:"button",className:"cancel-btn",onClick:a,children:"Cancel"}),(0,t.jsx)("button",{type:"submit",className:"create-btn",disabled:I.submitDisabled||x,children:x?"Creating…":"Create"})]})]})]})})}e.s(["default",0,function(){var e,u,m,h;let f=(0,r.useRouter)(),[x,y]=(0,n.useState)([]),[j,R]=(0,n.useState)(!1),[A,O]=(0,n.useState)(null),U=(0,n.useRef)(!1),B=(0,n.useRef)(0),[M,H]=(0,n.useState)([]),[K,q]=(0,n.useState)([]),[W,J]=(0,n.useState)([]),z=(0,n.useRef)(null),[G,V]=(0,n.useState)(null),Z=(0,n.useRef)(null),[Y,Q]=(0,n.useState)(""),[X,ee]=(0,n.useState)(""),[et,en]=(0,n.useState)(!1),[ea,es]=(0,n.useState)([]),[er,el]=(0,n.useState)(""),ei=(0,n.useRef)(null),eo=(0,n.useRef)(null),[ec,ed]=(0,n.useState)(!1),eu=(0,n.useRef)(null),[em,eh]=(0,n.useState)(!1),[ep,ef]=(0,n.useState)(!1),[eg,ex]=(0,n.useState)({}),ey=(0,n.useRef)({}),[ev,ej]=(0,n.useState)(!1),eb=(0,n.useRef)(null),[ew,eN]=(0,n.useState)(""),eC=(0,n.useRef)(null),eS=(0,n.useRef)(null),ek=(0,n.useRef)(null),eR=(0,n.useRef)(null),eA=(0,n.useRef)(null),eD=(0,n.useRef)(null),eI=(0,n.useRef)(null),[eE,e$]=(0,n.useState)([]),[eT,eL]=(0,n.useState)({serverNow:0,fetchedAt:0}),[eF,e_]=(0,n.useState)(()=>Date.now()),eP=(0,n.useRef)({}),eO=(0,n.useRef)(!1),[eU,eB]=(0,n.useState)(!1);(0,n.useEffect)(()=>{eO.current||0===x.length||(eO.current=!0,eB(!0))},[x.length]),(0,n.useEffect)(()=>{let e=(0,p.importedBotId)(window.location.search);if(e)return void window.location.replace((0,p.importedConfigPath)(e));let t=new URLSearchParams(window.location.search);"1"===t.get("new")?(U.current=!0,window.setTimeout(()=>ed(!0),0),window.history.replaceState(null,"","/")):"1"===t.get("manage")&&(U.current=!0,window.setTimeout(()=>ej(!0),0),window.history.replaceState(null,"","/"));let n=Number(t.get("deleted"));n>0&&(B.current=n,window.history.replaceState(null,"","/"));let a=t.get("agent");if(a){if(U.current=!0,"1"===t.get("sessions")){let e=t.get("session"),n=e?`/agents/${encodeURIComponent(a)}/sessions?session=${encodeURIComponent(e)}`:`/agents/${encodeURIComponent(a)}/sessions`;window.location.replace(n);return}let e=t.get("exchange");fetch(`/api/conversations?botId=${encodeURIComponent(a)}`,{cache:"no-store"}).then(async e=>e.ok?e.json():null).then(t=>{window.location.replace(D(a,t?.id??null,e))}).catch(()=>window.location.replace(D(a,null,e)))}eq().then(()=>{n>0&&eN((0,g.deletedStatusLine)(n))});let s=setInterval(eq,2e3),r=setInterval(()=>e_(Date.now()),1e3);return()=>{clearInterval(s),clearInterval(r)}},[]),(0,n.useEffect)(()=>{if(U.current||0===x.length||A)return;let e=[...x].filter(e=>!e.hidden).sort((e,t)=>E(e)-E(t))[0]||x[0];U.current=!0;let t=B.current;f.replace(`/agents/${encodeURIComponent(e.id)}${t>0?`?deleted=${t}`:""}`)},[x,A]),(0,n.useEffect)(()=>{if(Z.current=A?.id??null,A)return eW(),eI.current&&clearInterval(eI.current),eI.current=setInterval(eW,2e3),()=>{eI.current&&clearInterval(eI.current)}},[A]);let eM=A?x.find(e=>e.id===A.details.id)??A.details:void 0,eH=!!A&&I(eM),eK=eH?function(e){for(let t=e.length-1;t>=0;t--){let n=(0,l.parseRun)(e[t].content);if(n){if("stopped"===n.state)return null;return n.page||n.html||null}}return null}(M):null;async function eq(){let e=await fetch("/api/bots",{cache:"no-store"}),t=await e.json(),n=Date.parse(e.headers.get("date")||"");eL({serverNow:Number.isNaN(n)?Date.now():n,fetchedAt:Date.now()}),Array.isArray(t)&&(y(t),R(!0))}async function eW(){if(!A)return;let e=A.id,t=null,n=!1,a=fetch(`/api/conversations/${e}`).then(async e=>{let t=await e.json();return e.ok&&Array.isArray(t?.events)?t.events:null}).catch(()=>null),s=fetch(`/api/exchanges?conversation=${encodeURIComponent(e)}`,{cache:"no-store"}).then(async e=>{let t=await e.json();return e.ok&&Array.isArray(t?.exchanges)?t.exchanges:null}).catch(()=>null);try{let a=await fetch(`/api/conversations/${e}/messages`);t=await a.json(),n=a.ok&&Array.isArray(t)}catch{n=!1}let r=await a,l=await s;Z.current===e&&(n&&H(t),r&&q((0,S.wakeNotices)(r)),l&&J(l),V({conversationId:e,status:n?"ready":"error"}))}(0,n.useLayoutEffect)(()=>{let e=ek.current?.parentElement;if(!e)return;let t=eR.current,n=eA.current,a=eD.current;if(eH&&t&&n&&a){let s=s=>{let r=Math.ceil(t.getBoundingClientRect().height);n.style.height=r+16+s+"px";let l=n.getBoundingClientRect().top-e.getBoundingClientRect().top;a.style.height=Math.max(0,e.clientHeight-l)+"px";let i=t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;e.scrollTop=Math.max(0,i-l)};s(0);let r=n.nextElementSibling,l=t.getBoundingClientRect().bottom,i=r?r.getBoundingClientRect().top:n.getBoundingClientRect().bottom;l>=i&&s(Math.max(16,Math.ceil(l-i)));return}a&&(a.style.height="0px"),n&&(n.style.height=""),e.scrollTop=e.scrollHeight},[M,eH]),(0,n.useEffect)(()=>{let e=z.current;if(!e)return;let t=document.getElementById(`exchange-${e}`);t&&(z.current=null,t.scrollIntoView({block:"center"}),t.focus({preventScroll:!0}))},[W]),(0,n.useLayoutEffect)(()=>{e$(e=>{if(0===e.length)return e;let t=e.filter(e=>{let t=eP.current[e]??0;return M.some(n=>"bot"===n.sender_type&&n.sender_id===e&&n.created_at>t&&!/^\[(mcp|tool call|tool result)\]/i.test(n.content.trim()))});if(0===t.length)return e;for(let e of t)delete eP.current[e];return e.filter(e=>!t.includes(e))})},[M]);let eJ=async e=>{A&&(await fetch(`/api/conversations/${A.id}/messages/${e}/stop`,{method:"POST"}),await eW())},ez=async()=>{A&&(await fetch(`/api/conversations/${A.id}/stop`,{method:"POST"}),await eW())},eG=async(e,t)=>{if(eg[e.id])return void ex(t=>{let n={...t};return delete n[e.id],n});if(ey.current[e.id])return;let n=M.findIndex(t=>t.id===e.id),a=x.find(e=>e.name===t),s=M.slice(n+1).find(e=>"bot"===e.sender_type&&(a?e.sender_id===a.id:e.sender_name===t));if(s){ey.current[e.id]=!0;try{let t=await fetch(`/api/messages/${e.id}/between?other=${encodeURIComponent(s.id)}`),n=await t.json().catch(()=>null);t.ok&&Array.isArray(n)&&n.length>0&&ex(t=>({...t,[e.id]:n}))}finally{delete ey.current[e.id]}}},eV=async()=>{if(!A)return;let e=eC.current?.files?.[0];if(!e)return;let t=await new Promise((t,n)=>{let a=new FileReader;a.onload=()=>t(String(a.result||"")),a.onerror=()=>n(a.error),a.readAsDataURL(e)});if(!t.startsWith("data:image/"))return;let n=await fetch("/api/bots",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:A.details.id,avatar:t})});if(!n.ok)return;let a=await n.json();y(e=>e.map(e=>e.id===a.id?{...e,avatar:a.avatar}:e)),O({...A,details:{...A.details,avatar:a.avatar}})},eZ=async e=>{if(!e||!A)return;let t=await new Promise((t,n)=>{let a=new FileReader;a.onload=()=>t(String(a.result||"")),a.onerror=()=>n(a.error),a.readAsDataURL(e)});if(!t.startsWith("data:image/"))return;let n=await fetch("/api/bots",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:A.details.id,avatar:t})});if(!n.ok)return;let a=await n.json();y(e=>e.map(e=>e.id===a.id?{...e,avatar:a.avatar}:e)),O({...A,details:{...A.details,avatar:a.avatar}})},eY=async()=>{if(!A)return;let e=await fetch("/api/bots",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:A.details.id,avatar:null})});if(!e.ok)return;let t=await e.json();y(e=>e.map(e=>e.id===t.id?{...e,avatar:t.avatar||""}:e)),O({...A,details:{...A.details,avatar:t.avatar||""}})},eQ=j&&0===x.length,eX=async e=>{let t=e.map(e=>e.id);ej(!1),eN((0,g.deletedStatusLine)(t.length)),requestAnimationFrame(()=>eb.current?.focus()),y(e=>e.filter(e=>!t.includes(e.id))),A&&t.includes(A.details.id)&&(O(null),H([]),q([])),await eq()},e0=et?x.filter(e=>e.name.toLowerCase().includes(X.toLowerCase())):[],e1=e=>{let t=ei.current,n=t?t.selectionStart:Y.length,a=Y.slice(0,n).lastIndexOf("@");if(a<0)return;Q(Y.slice(0,a)+"@"+e+" "+Y.slice(n)),en(!1);let s=a+e.length+2;requestAnimationFrame(()=>{t?.focus(),t?.setSelectionRange(s,s)})},e6=e=>{if(0===e.length)return;let t=6-ea.length;e.length>t?el("Up to six attachments."):el("");let n=e.slice(0,Math.max(t,0));0!==n.length&&es(e=>[...e,...n.map((t,n)=>({id:t.name+"-"+e.length+"-"+n+"-"+t.size,name:t.name}))])},e4=async()=>{let e=ea.map(e=>e.name),t=Y.trim();if(!t&&0===e.length||!A)return;let n=[t,...e].filter(e=>e.length>0).join("\n"),a=[A.details.id],s=M.reduce((e,t)=>Math.max(e,t.created_at||0),0);for(let e of a)eP.current[e]=s;e$(e=>Array.from(new Set([...e,...a])));let r=[...x].sort((e,t)=>t.name.length-e.name.length).find(e=>(function(e,t){let n="@"+t,a=0;for(;a<e.length;){let t=e.indexOf(n,a);if(t<0)break;let s=e[t+n.length];if(!s||/[\s.,!?:;]/.test(s))return!0;a=t+n.length}return!1})(n,e.name));if(!(await fetch(`/api/conversations/${A.id}/messages`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n,mentionedBotId:r?.id,idempotencyKey:crypto.randomUUID()})})).ok){for(let e of a)delete eP.current[e];e$(e=>e.filter(e=>!a.includes(e)))}Q(""),es([]),el(""),en(!1),eW()},e3=A?(e=A.id,M.length>0?"messages":G&&G.conversationId===e&&"loading"!==G.status?"error"===G.status?"error":"empty":"loading"):"loading",e2=A?(0,t.jsx)(b,{view:e3,agentName:A.details.name}):null,e8=(A?.details.title||"").trim(),e9=A?.details.color,e5=new Set,e7=e=>(0,t.jsx)("div",{className:"msg-status",children:(0,t.jsx)(C.default,{notice:e,onDone:()=>{eW()}})},e.eventId),te=new Set,tt=e=>(0,t.jsx)("div",{className:"msg-status",children:(0,t.jsx)(k.default,{summary:e,onChanged:()=>{eW()}})},`exchange-${e.id}`),tn=e=>{let t=W.filter(t=>!te.has(t.id)&&t.created_at<e).sort((e,t)=>e.created_at-t.created_at||(e.id<t.id?-1:1));return t.forEach(e=>te.add(e.id)),t.map(tt)},ta=()=>{ed(!1),requestAnimationFrame(()=>eu.current?.focus())};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"field",inert:ec,children:[(0,t.jsx)(o.default,{agents:x,activeAgentId:A?.details.id,workingIds:eE,beatClock:eT,now:eF,status:ew,logoDrop:eU,onAgentsChange:e=>y(e),onNew:()=>ed(!0),onManage:()=>{eN(""),ej(!0)},onDeleted:e=>{eX(e)},newButtonRef:eu,manageButtonRef:eb}),(0,t.jsx)("section",{className:"pane",children:A?(0,t.jsxs)("div",{className:"thread",children:[(0,t.jsxs)("div",{className:"thread-bar",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("button",{type:"button",className:"thread-name",style:e9?{color:e9}:void 0,onClick:()=>{eh(!0),ef(!1)},children:A.details.name}),e8?(0,t.jsx)("div",{className:"thread-role",children:e8}):null,(0,t.jsx)("div",{className:"thread-role",children:eE.includes(A.details.id)?"Working":"Not working"}),(0,t.jsx)("div",{className:"thread-role",children:(u=(eM??A.details).last_seen,m=eT.serverNow,h=eT.fetchedAt,u&&m?eF-h+(m-u)>15e3?"Stopped":"Heartbeat "+new Intl.DateTimeFormat("en-US",{timeZone:"America/Los_Angeles",hour:"numeric",minute:"2-digit",second:"2-digit"}).format(new Date(u)):"Stopped")}),em?(0,t.jsx)("button",{type:"button",className:"avatar-pic",onClick:()=>ef(!0),"aria-label":"Picture",children:A.details.avatar?(0,t.jsx)("img",{src:A.details.avatar,alt:""}):(0,t.jsx)(i.default,{bot:A.details,size:46})}):null]}),(0,t.jsxs)("div",{style:{marginLeft:"auto",display:"flex",gap:16,alignItems:"flex-start"},children:[(0,t.jsx)(a.default,{href:`/agents/${A.details.id}/config`,className:"attach-word",style:{textDecoration:"none"},children:"Config"}),(0,t.jsx)(a.default,{href:`/agents/${encodeURIComponent(A.details.id)}/sessions`,className:"attach-word",style:{textDecoration:"none"},children:"Sessions"}),(0,t.jsx)("button",{type:"button",className:"attach-word",title:"Stop delegated turns in this thread",onClick:()=>{ez()},children:"Stop"})]})]}),ep?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"avatar-step avatar-desk",children:[(0,t.jsx)("span",{className:"kind-word",children:"Agent"}),(0,t.jsx)("button",{type:"button",className:"kind-word",children:"Generate"}),(0,t.jsxs)("label",{className:"kind-word",children:["Upload",(0,t.jsx)("input",{ref:eC,type:"file",accept:"image/*,.svg"})]}),(0,t.jsx)("button",{type:"button",className:"create-btn",onClick:eV,children:"Set avatar"})]}),(0,t.jsxs)("div",{className:"avatar-step avatar-phone",children:[(0,t.jsx)("button",{type:"button",className:"kind-word",onClick:()=>eS.current?.click(),children:"Gallery"}),(0,t.jsx)("button",{type:"button",className:"kind-word",children:"Generate"}),(0,t.jsx)("button",{type:"button",className:"kind-word",onClick:eY,children:"Remove Photo"}),(0,t.jsx)("input",{ref:eS,type:"file",accept:"image/*,.svg",onChange:e=>{let t=e.target.files?.[0];e.target.value="",eZ(t)}})]})]}):null,(0,t.jsxs)("div",{className:"messages-wrap",children:[(0,t.jsxs)("div",{className:"messages",children:[eH?null:e2,M.map(e=>{var a;let s,r=K.filter(t=>!e5.has(t.eventId)&&t.createdAt<e.created_at);r.forEach(e=>e5.add(e.eventId));let i=tn(e.created_at),o="user"===e.sender_type,u=o?null:(0,N.classifyRuntimeFailure)(T(e.content));if(u)return(0,t.jsxs)(n.Fragment,{children:[r.map(e7),i,(0,t.jsx)("div",{className:"msg-status",children:(0,t.jsx)(w.default,{failure:u})})]},e.id);let m=(a=T(e.content),s=[],{text:$(a.replace(/data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=\s]+/g,e=>(s.push(e.replace(/\s/g,"")),""))),images:s}),h=m.images.map(e=>(0,t.jsx)("img",{src:e,alt:"",style:{display:"block",width:64,height:64}},e.slice(0,48))),p=o?void 0:A.details.color,f=o?null:(0,l.parseRun)(e.content),g=o||f?null:(0,c.parseDraft)(T(e.content)),x=o||f?null:(0,c.parseApprovalCode)(e.content),y=o||f?[]:(0,c.parseFileNames)(e.content),v=o||f?null:(0,c.parseHandoff)(m.text),j=e.draftStatus??(g?"open":null),b=e.approvalStatus??(x?"pending":null);return(0,t.jsxs)(n.Fragment,{children:[r.map(e7),i,(0,t.jsxs)("div",{className:o?"msg-you":"msg-bot",ref:f&&"running"===f.state?eR:void 0,children:[(0,t.jsx)("div",{className:o?"msg-name msg-name-you":"msg-name",style:p?{color:p}:void 0,children:o?"You":e.sender_name||A.details.name}),f?(0,t.jsxs)("div",{className:"msg-body",children:[(0,l.runLine)(f),"running"===f.state?(0,t.jsxs)(t.Fragment,{children:[" ",(0,t.jsx)("button",{type:"button",className:"attach-word",style:{font:"inherit"},onClick:t=>{t.preventDefault(),t.stopPropagation(),eJ(e.id)},children:"Stop"})]}):null]}):g&&j?(0,t.jsx)("div",{className:"msg-body",children:(0,t.jsx)(L,{message:e,conversationId:A.id,status:j,onDone:()=>{eW()}},e.id+j)}):(0,t.jsxs)("div",{className:"msg-body",onClick:v?()=>{eG(e,v)}:void 0,title:v?"Show the replies between this handoff and the reply":void 0,style:v?{cursor:"pointer"}:void 0,children:[function(e,n){let a=String(e??"").split("\n");if(!a.some(e=>null!==(0,d.agentEventDisplay)(e)))return e;let s=[];return a.forEach((e,a)=>{a>0&&s.push((0,t.jsx)("br",{},n+"-br-"+a));let r=(0,d.agentEventDisplay)(e);r?s.push((0,t.jsxs)("span",{className:"agent-event",children:[(0,t.jsx)("span",{className:"agent-event-label",children:r.label}),r.detail?" "+r.detail:""]},n+"-"+a)):s.push((0,t.jsx)("span",{children:e},n+"-"+a))}),s}(m.text,e.id),h,x&&b?(0,t.jsx)(F,{message:e,conversationId:A.id,status:b,onDone:()=>{eW()}},e.id+b):null,(0,t.jsx)(_,{names:y})]}),eg[e.id]?(0,t.jsx)("div",{className:"msg-body",children:eg[e.id].map(e=>(0,t.jsx)("div",{children:(e.sender_name||"Agent")+": "+$(e.content)},e.id))}):null]})]},e.id)}),K.filter(e=>!e5.has(e.eventId)).map(e7),tn(1/0),(0,t.jsx)("div",{ref:eD}),(0,t.jsx)("div",{ref:ek})]}),eH?(0,t.jsxs)("div",{className:"computer-float",children:[(0,t.jsxs)("div",{className:"computer-top",children:[(0,t.jsxs)("span",{className:"computer-lights","aria-hidden":"true",children:[(0,t.jsx)("span",{className:"computer-light computer-light-red"}),(0,t.jsx)("span",{className:"computer-light computer-light-yellow"}),(0,t.jsx)("span",{className:"computer-light computer-light-green"})]}),(0,t.jsxs)("span",{className:"computer-teach",children:[(0,t.jsxs)("span",{className:"computer-teach-pill",children:[(0,t.jsx)("span",{className:"computer-teach-mark","aria-hidden":"true"}),"Teach a task"]}),(0,t.jsx)("span",{className:"computer-expand","aria-hidden":"true",children:(0,t.jsx)("svg",{viewBox:"0 0 16 16",width:"14",height:"14",children:(0,t.jsx)("path",{d:"M9.2 2.6H13.4V6.8M6.8 13.4H2.6V9.2M13.1 2.9L9.4 6.6M2.9 13.1L6.6 9.4",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]}),(0,t.jsx)("div",{className:"messages"===e3?"computer-band":"computer-band computer-band-note",ref:eA,children:e2}),(0,t.jsxs)("div",{className:"computer-desk",children:[eK?(0,t.jsx)("iframe",{className:"computer-page",sandbox:"",srcDoc:eK,tabIndex:-1}):null,(0,t.jsxs)("div",{className:"computer-dock",children:[(0,t.jsx)("img",{src:"/computer/dock-chrome.png",alt:""}),(0,t.jsx)("img",{src:"/computer/dock-gray.png",alt:""}),(0,t.jsx)("img",{src:"/computer/dock-terminal.png",alt:""})]})]})]}):null]}),(0,t.jsxs)("div",{className:"composer",onPaste:e=>{let t=[],n=e.clipboardData.files;if(n&&n.length>0)t.push(...Array.from(n));else for(let n of Array.from(e.clipboardData.items)){if("file"!==n.kind)continue;let e=n.getAsFile();e&&t.push(e)}0!==t.length&&(e.preventDefault(),e6(t))},children:[et&&e0.length>0?(0,t.jsx)("div",{className:"mention-list",children:e0.map(e=>(0,t.jsxs)("button",{type:"button",onMouseDown:t=>{t.preventDefault(),e1(e.name)},children:["@",e.name]},e.id))}):null,(0,t.jsxs)("div",{className:"composer-box",children:[er?(0,t.jsx)("p",{className:"attach-error",children:er}):null,ea.length>0?(0,t.jsx)("div",{className:"attach-names",children:ea.map(e=>(0,t.jsx)("span",{children:e.name},e.id))}):null,(0,t.jsx)("textarea",{ref:ei,rows:2,value:Y,onChange:e=>{var t,n;let a,s;Q(e.target.value),t=e.target.value,n=e.target.selectionStart,(s=(a=t.slice(0,n)).lastIndexOf("@"))<0||/\s/.test(a.slice(s+1))?en(!1):(ee(a.slice(s+1)),en(!0))},onKeyDown:e=>{if("Enter"===e.key&&!e.shiftKey){if(e.preventDefault(),et&&e0.length>0)return void e1(e0[0].name);e4()}},placeholder:"Say something"})]}),(0,t.jsx)("input",{ref:eo,className:"attach-input",type:"file",multiple:!0,onChange:e=>{e6(Array.from(e.target.files||[])),e.target.value=""}}),(0,t.jsx)("button",{type:"button",className:"attach-word",onClick:()=>eo.current?.click(),children:"Attach"}),(0,t.jsx)("button",{type:"button",className:"send-btn",onClick:e4,children:"Send"})]})]}):eQ?(0,t.jsxs)("div",{className:"welcome",children:[(0,t.jsx)(s.default,{className:"welcome-mark",src:"/brand/botmancers-logo-outline-256.png",alt:"Botmancers",width:144,height:144,priority:!0}),(0,t.jsx)("p",{className:"empty-line",children:"Pick someone to talk to."})]}):(0,t.jsx)("p",{className:"empty-line",children:"Pick someone to talk to."})}),ev?(0,t.jsx)(v,{onClose:()=>{ej(!1),requestAnimationFrame(()=>eb.current?.focus())},onDeleted:e=>{eX(e)}}):null]}),ec&&(0,t.jsx)(P,{anchorRef:eu,onClose:ta,onCreated:()=>{eq(),ta()}})]})}],31713)}]);
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,31713,e=>{"use strict";var t=e.i(43476),n=e.i(71645),a=e.i(22016),s=e.i(57688),r=e.i(18566),l=e.i(64711),i=e.i(87303),o=e.i(89873),c=e.i(68684),d=e.i(74904),u=e.i(33851),m=e.i(44079),h=e.i(52900),p=e.i(68541),f=e.i(15983),g=e.i(10718);function x(e){return String(e).padStart(2,"0")}function y(e){let t=new Date(e);return`${t.getFullYear()}-${x(t.getMonth()+1)}-${x(t.getDate())} ${x(t.getHours())}:${x(t.getMinutes())}`}function v({onClose:e,onDeleted:a}){let s=(0,n.useId)(),[r,l]=(0,n.useState)(null),[i,o]=(0,n.useState)(""),[c,u]=(0,n.useState)(""),[m,h]=(0,n.useState)([]),[p,x]=(0,n.useState)(!1),j=(0,n.useRef)(null),b=(0,n.useRef)(null),w=(0,n.useRef)(null);(0,n.useEffect)(()=>{let e=!1;return fetch("/api/bots/manage",{cache:"no-store"}).then(async t=>{let n=await t.json().catch(()=>null);if(!e){if(!t.ok||!Array.isArray(n))return void o("string"==typeof n?.error?n.error:"Could not load agents.");l(n)}}).catch(()=>{e||o("Could not load agents.")}),j.current?.focus(),()=>{e=!0}},[]);let N=c.trim().toLowerCase(),C=(r??[]).filter(e=>e.name.toLowerCase().includes(N)),S=C.filter(e=>!e.blocked);return(0,n.useEffect)(()=>{if(p)return;let t=t=>{"Escape"===t.key&&e()};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[p,e]),(0,t.jsxs)("div",{className:"modal-scrim manage-scrim",children:[(0,t.jsxs)("div",{ref:w,className:"manage-card",role:"dialog","aria-modal":"true","aria-labelledby":s,onKeyDown:e=>{if("Tab"!==e.key||!w.current)return;let t=Array.from(w.current.querySelectorAll("button:not(:disabled), input:not(:disabled)"));if(0===t.length)return;let n=t[0],a=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),a.focus()):e.shiftKey||document.activeElement!==a||(e.preventDefault(),n.focus())},children:[(0,t.jsxs)("div",{className:"manage-head",children:[(0,t.jsx)("h2",{id:s,className:"delete-title",children:"Manage agents"}),(0,t.jsx)("button",{type:"button",className:"cancel-btn",onClick:e,children:"Close"})]}),(0,t.jsx)("label",{className:"manage-search-label",htmlFor:`${s}-search`,children:"Filter by name"}),(0,t.jsx)("input",{id:`${s}-search`,ref:j,className:"manage-search",type:"search",value:c,onChange:e=>u(e.target.value),placeholder:"Name contains…"}),(0,t.jsxs)("div",{className:"manage-tools",children:[(0,t.jsx)("button",{type:"button",className:"pin-word",onClick:()=>{h(e=>Array.from(new Set([...e,...S.map(e=>e.id)])))},disabled:0===S.length,children:"Select all shown"}),(0,t.jsx)("button",{type:"button",className:"pin-word",onClick:()=>{h([]),j.current?.focus()},disabled:0===m.length,children:"Clear selection"}),(0,t.jsxs)("span",{className:"manage-count","aria-live":"polite",children:[m.length," selected · ",C.length," shown of ",r?.length??0]})]}),i?(0,t.jsx)("p",{className:"delete-error",role:"alert",children:i}):null,r||i?null:(0,t.jsx)("p",{className:"delete-copy",children:"Loading agents…"}),r?(0,t.jsxs)("ul",{className:"manage-list","aria-label":"Agents",children:[0===C.length?(0,t.jsx)("li",{className:"delete-copy",children:"No agents match."}):null,C.map(e=>{let n=`${s}-row-${e.id}`,a=(0,d.botConnectionLabel)(e)??"Not set";return(0,t.jsxs)("li",{className:e.blocked?"manage-row is-blocked":"manage-row","data-agent-id":e.id,children:[(0,t.jsx)("input",{id:n,type:"checkbox",checked:m.includes(e.id),disabled:!!e.blocked,onChange:()=>{var t;return t=e.id,void h(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},"aria-describedby":e.blocked?`${n}-reason`:void 0}),(0,t.jsxs)("div",{className:"manage-copy",children:[(0,t.jsxs)("label",{htmlFor:n,className:"manage-name",children:[e.name,e.hidden?(0,t.jsx)("span",{className:"manage-tag",children:"Hidden"}):null]}),(0,t.jsxs)("dl",{className:"manage-meta",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{children:"Agent"}),(0,t.jsx)("dd",{children:(0,d.botAgentLabel)(e)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{children:"Connection"}),(0,t.jsx)("dd",{children:a})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{children:"Source"}),(0,t.jsx)("dd",{children:e.source_provider||"Created here"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{children:"Created"}),(0,t.jsx)("dd",{children:y(e.created_at)})]}),e.last_activity?(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{children:"Last activity"}),(0,t.jsx)("dd",{children:y(e.last_activity)})]}):null]}),e.blocked?(0,t.jsx)("p",{id:`${n}-reason`,className:"manage-reason",children:(0,g.blockedReasonCopy)(e.blocked)}):null]})]},e.id)})]}):null,(0,t.jsxs)("div",{className:"form-actions manage-actions",children:[(0,t.jsx)("button",{type:"button",className:"cancel-btn",onClick:e,children:"Cancel"}),(0,t.jsxs)("button",{ref:b,type:"button",className:"delete-btn",disabled:0===m.length,onClick:()=>x(!0),children:["Delete selected",m.length>0?` (${m.length})`:""]})]})]}),p?(0,t.jsx)(f.default,{ids:m,onCancel:()=>{x(!1),requestAnimationFrame(()=>b.current?.focus())},onDeleted:a}):null]})}var j=e.i(71836);function b({view:e,agentName:n}){if("loading"===e)return(0,t.jsx)("p",{className:"thread-note",role:"status",children:"Loading messages…"});if("error"===e)return(0,t.jsx)("p",{className:"thread-note thread-note-error",role:"alert",children:"Couldn’t load messages. Trying again…"});if("empty"===e){let e={title:`No messages with ${n} yet.`,hint:"Say something below to start the conversation."};return(0,t.jsxs)("div",{className:"thread-empty","data-thread-empty":"",children:[(0,t.jsx)("p",{className:"thread-empty-title",children:e.title}),(0,t.jsx)("p",{className:"thread-empty-hint",children:e.hint})]})}return null}var w=e.i(46986),N=e.i(96594),C=e.i(15366),S=e.i(54423),k=e.i(13255),R=e.i(63352),A=e.i(3136);function D(e,t,n){let a=t?`/agents/${encodeURIComponent(e)}/conversations/${encodeURIComponent(t)}`:`/agents/${encodeURIComponent(e)}/conversations`;return n?`${a}?exchange=${encodeURIComponent(n)}`:a}function I(e){return!!e&&"chief-of-staff"===e.name.toLowerCase()}function E(e){return I(e)?0:e.pinned?1:2}function $(e){let t=e;for(let e=0;e<2;e++){let e=t.replace(/^\s*\[Message from [^\]]+\]\s*(?:\r?\n)?/,"");if(e===t)break;t=e}return t.replace(/^\s+/,"")}function T(e){let t=e;for(let e=0;e<4;e++){let e=t.replace(/^\s*\[(?:Message from|From) [^\]]+\]\s*(?:\r?\n)?/,"");if(e===t)break;t=e}return t}function L({message:e,conversationId:a,status:s,onDone:r}){let l=(0,c.parseDraft)(T(e.content)),[i,o]=(0,n.useState)(l?.recipient??""),[d,u]=(0,n.useState)(l?.body??""),[m,h]=(0,n.useState)(!1),[p,f]=(0,n.useState)("open"!==s),g=(0,n.useRef)("open"!==s);if(!l)return null;let x="open"!==s||p,y=x?l.recipient:i,v=x?l.body:d,j=async t=>{if(!x&&!g.current&&!m&&("send"!==t||""!==i.trim())){g.current=!0,f(!0),h(!0);try{(await fetch(`/api/conversations/${a}/draft`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messageId:e.id,action:t,recipient:i,body:d})})).ok||(g.current=!1,f(!1))}finally{h(!1),r()}}};return(0,t.jsxs)("div",{className:"draft-card",children:[(0,t.jsx)("div",{className:"draft-title",children:(0,c.draftTitle)(l.channel)}),(0,t.jsx)("input",{type:"text","aria-label":"Recipient",value:y,readOnly:x,disabled:m,onChange:e=>{x||o(e.target.value)}}),(0,t.jsx)("textarea",{rows:3,"aria-label":"Draft body",value:v,readOnly:x,disabled:m,onChange:e=>{x||u(e.target.value)}}),"sent"===s?(0,t.jsx)("span",{className:"draft-mark",children:"Sent"}):null,"discarded"===s?(0,t.jsx)("span",{className:"draft-mark",children:"Discarded"}):null,"discarded"!==s?(0,t.jsx)("button",{type:"button",className:"approve-control",disabled:m,onClick:()=>{j("send")},children:"Send"}):null,"open"===s?(0,t.jsx)("button",{type:"button",className:"approve-control",style:{marginLeft:8},disabled:m,onClick:()=>{j("discard")},children:"Discard"}):null]})}function F({message:e,conversationId:a,status:s,onDone:r}){let l=(0,c.parseApprovalCode)(e.content),[i,o]=(0,n.useState)(!1),d=(0,n.useRef)("pending"!==s);if(!l)return null;let u=async t=>{if(!d.current&&!i){d.current=!0,o(!0);try{(await fetch(`/api/conversations/${a}/${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:l,messageId:e.id})})).ok||(d.current=!1)}finally{o(!1),r()}}};return"pending"!==s?(0,t.jsx)("span",{className:"draft-mark",children:"approved"===s?"Approved":"Denied"}):(0,t.jsxs)("span",{className:"draft-mark",children:[(0,t.jsx)("button",{type:"button",className:"approve-control",disabled:i,onClick:()=>{u("approve")},children:"Approve"}),(0,t.jsx)("button",{type:"button",className:"approve-control",style:{marginLeft:8},disabled:i,onClick:()=>{u("deny")},children:"Deny"})]})}function _({names:e}){return 0===e.length?null:(0,t.jsx)(t.Fragment,{children:e.map(e=>(0,t.jsxs)("span",{children:[(0,t.jsx)("br",{}),(0,t.jsxs)("a",{className:"file-control",href:`/api/files/${encodeURIComponent(e)}`,download:e,children:["Download ",e]})]},e))})}function P({anchorRef:e,onClose:a,onCreated:s}){let[r,l]=(0,n.useState)(""),[i,o]=(0,n.useState)(u.DEFAULT_REGISTRATION_FORM),[c,p]=(0,n.useState)(""),[f,g]=(0,n.useState)(!1),[x,y]=(0,n.useState)(!1),[v,b]=(0,n.useState)(null),w=(0,h.useRuntimeConnections)(),[N,C]=(0,n.useState)(null),S=(0,n.useRef)(null),k=(0,n.useRef)(null),D=(0,n.useRef)(null);(0,n.useLayoutEffect)(()=>{let t=()=>{let t=e.current?.getBoundingClientRect();C((0,j.newAgentDialogPlacement)(t?{left:t.left,bottom:t.bottom}:null,{width:window.innerWidth,height:window.innerHeight}))};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[e]),(0,n.useEffect)(()=>{k.current?.focus()},[]),(0,n.useEffect)(()=>{v&&D.current?.focus()},[v]),(0,n.useEffect)(()=>{let e=e=>{"Escape"===e.key&&(e.stopPropagation(),a())};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[a]);let I=(0,u.registrationFormView)(i,w.state),E=async e=>{let t;if(e.preventDefault(),I.submitDisabled||x)return;if((0,u.hasRegistrationErrors)(I)){g(!0),p("Fix the highlighted fields.");return}p(""),y(!0);try{t=await fetch("/api/bots",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify((0,u.registrationCreateBody)(r,i))})}finally{y(!1)}let n=await t.json().catch(()=>null);if(!t.ok)return void p("string"==typeof n?.error&&n.error?n.error:"Failed to create agent");let a=n?.session_sync;if(!a||"string"!=typeof a.outcome)return void s();let l="string"==typeof n?.agent?(0,A.agentLabel)(n.agent):"Sessions";b({line:(0,R.registrationSessionSyncCopy)(a,l),agentName:"string"==typeof n?.name?n.name:r})};return(0,t.jsx)("div",{className:"modal-scrim new-agent-scrim",onKeyDown:e=>{if("Tab"!==e.key||!S.current)return;let t=Array.from(S.current.querySelectorAll(j.DIALOG_FOCUSABLE)),n=(0,j.wrapFocusTarget)(t,document.activeElement,e.shiftKey);n&&(e.preventDefault(),n.focus())},children:(0,t.jsxs)("div",{ref:S,className:"form-card new-agent-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"new-agent-title",style:N??void 0,children:[(0,t.jsx)("div",{className:"kind-row",children:(0,t.jsx)("h2",{id:"new-agent-title",className:"kind-word new-agent-title",children:"New agent"})}),v?(0,t.jsxs)("div",{className:"bot-form",children:[(0,t.jsx)("div",{className:"new-agent-body",children:(0,t.jsxs)("p",{role:"status",children:[v.agentName," created. ",v.line]})}),(0,t.jsx)("div",{className:"form-actions",children:(0,t.jsx)("button",{ref:D,type:"button",className:"create-btn",onClick:s,children:"Done"})})]}):(0,t.jsxs)("form",{onSubmit:E,className:"bot-form",children:[(0,t.jsxs)("div",{className:"new-agent-body",children:[(0,t.jsx)("label",{htmlFor:"bot-name",children:"Name"}),(0,t.jsx)("input",{ref:k,id:"bot-name",type:"text",value:r,onChange:e=>l(e.target.value),required:!0}),(0,t.jsx)(m.RegistrationFields,{idPrefix:"bot",variant:"modal",form:i,onChange:e=>{p(""),o(t=>({...t,...e}))},view:I,showErrors:f,connections:w.state,onRetryConnections:w.retry,onAddConnection:w.add,workspacePlaceholder:d.WORKSPACE_TEMPLATE,workspaceHint:d.NEW_AGENT_WORKSPACE_HINT}),c?(0,t.jsx)("p",{className:"form-error",role:"alert",children:c}):null]}),(0,t.jsxs)("div",{className:"form-actions",children:[(0,t.jsx)("button",{type:"button",className:"cancel-btn",onClick:a,children:"Cancel"}),(0,t.jsx)("button",{type:"submit",className:"create-btn",disabled:I.submitDisabled||x,children:x?"Creating…":"Create"})]})]})]})})}e.s(["default",0,function(){var e,u,m,h;let f=(0,r.useRouter)(),[x,y]=(0,n.useState)([]),[j,R]=(0,n.useState)(!1),[A,O]=(0,n.useState)(null),U=(0,n.useRef)(!1),B=(0,n.useRef)(0),[M,H]=(0,n.useState)([]),[K,q]=(0,n.useState)([]),[W,J]=(0,n.useState)([]),z=(0,n.useRef)(null),[G,V]=(0,n.useState)(null),Z=(0,n.useRef)(null),[Y,Q]=(0,n.useState)(""),[X,ee]=(0,n.useState)(""),[et,en]=(0,n.useState)(!1),[ea,es]=(0,n.useState)([]),[er,el]=(0,n.useState)(""),ei=(0,n.useRef)(null),eo=(0,n.useRef)(null),[ec,ed]=(0,n.useState)(!1),eu=(0,n.useRef)(null),[em,eh]=(0,n.useState)(!1),[ep,ef]=(0,n.useState)(!1),[eg,ex]=(0,n.useState)({}),ey=(0,n.useRef)({}),[ev,ej]=(0,n.useState)(!1),eb=(0,n.useRef)(null),[ew,eN]=(0,n.useState)(""),eC=(0,n.useRef)(null),eS=(0,n.useRef)(null),ek=(0,n.useRef)(null),eR=(0,n.useRef)(null),eA=(0,n.useRef)(null),eD=(0,n.useRef)(null),eI=(0,n.useRef)(null),[eE,e$]=(0,n.useState)([]),[eT,eL]=(0,n.useState)({serverNow:0,fetchedAt:0}),[eF,e_]=(0,n.useState)(()=>Date.now()),eP=(0,n.useRef)({}),eO=(0,n.useRef)(!1),[eU,eB]=(0,n.useState)(!1);(0,n.useEffect)(()=>{eO.current||0===x.length||(eO.current=!0,eB(!0))},[x.length]),(0,n.useEffect)(()=>{let e=(0,p.importedBotId)(window.location.search);if(e)return void window.location.replace((0,p.importedConfigPath)(e));let t=new URLSearchParams(window.location.search);"1"===t.get("new")?(U.current=!0,window.setTimeout(()=>ed(!0),0),window.history.replaceState(null,"","/")):"1"===t.get("manage")&&(U.current=!0,window.setTimeout(()=>ej(!0),0),window.history.replaceState(null,"","/"));let n=Number(t.get("deleted"));n>0&&(B.current=n,window.history.replaceState(null,"","/"));let a=t.get("agent");if(a){if(U.current=!0,"1"===t.get("sessions")){let e=t.get("session"),n=e?`/agents/${encodeURIComponent(a)}/sessions?session=${encodeURIComponent(e)}`:`/agents/${encodeURIComponent(a)}/sessions`;window.location.replace(n);return}let e=t.get("exchange");fetch(`/api/conversations?botId=${encodeURIComponent(a)}`,{cache:"no-store"}).then(async e=>e.ok?e.json():null).then(t=>{window.location.replace(D(a,t?.id??null,e))}).catch(()=>window.location.replace(D(a,null,e)))}eq().then(()=>{n>0&&eN((0,g.deletedStatusLine)(n))});let s=setInterval(eq,2e3),r=setInterval(()=>e_(Date.now()),1e3);return()=>{clearInterval(s),clearInterval(r)}},[]),(0,n.useEffect)(()=>{if(U.current||0===x.length||A)return;let e=[...x].filter(e=>!e.hidden).sort((e,t)=>E(e)-E(t))[0]||x[0];U.current=!0;let t=B.current;f.replace(`/agents/${encodeURIComponent(e.id)}${t>0?`?deleted=${t}`:""}`)},[x,A]),(0,n.useEffect)(()=>{if(Z.current=A?.id??null,A)return eW(),eI.current&&clearInterval(eI.current),eI.current=setInterval(eW,2e3),()=>{eI.current&&clearInterval(eI.current)}},[A]);let eM=A?x.find(e=>e.id===A.details.id)??A.details:void 0,eH=!!A&&I(eM),eK=eH?function(e){for(let t=e.length-1;t>=0;t--){let n=(0,l.parseRun)(e[t].content);if(n){if("stopped"===n.state)return null;return n.page||n.html||null}}return null}(M):null;async function eq(){let e=await fetch("/api/bots",{cache:"no-store"}),t=await e.json(),n=Date.parse(e.headers.get("date")||"");eL({serverNow:Number.isNaN(n)?Date.now():n,fetchedAt:Date.now()}),Array.isArray(t)&&(y(t),R(!0))}async function eW(){if(!A)return;let e=A.id,t=null,n=!1,a=fetch(`/api/conversations/${e}`).then(async e=>{let t=await e.json();return e.ok&&Array.isArray(t?.events)?t.events:null}).catch(()=>null),s=fetch(`/api/exchanges?conversation=${encodeURIComponent(e)}`,{cache:"no-store"}).then(async e=>{let t=await e.json();return e.ok&&Array.isArray(t?.exchanges)?t.exchanges:null}).catch(()=>null);try{let a=await fetch(`/api/conversations/${e}/messages`);t=await a.json(),n=a.ok&&Array.isArray(t)}catch{n=!1}let r=await a,l=await s;Z.current===e&&(n&&H(t),r&&q((0,S.wakeNotices)(r)),l&&J(l),V({conversationId:e,status:n?"ready":"error"}))}(0,n.useLayoutEffect)(()=>{let e=ek.current?.parentElement;if(!e)return;let t=eR.current,n=eA.current,a=eD.current;if(eH&&t&&n&&a){let s=s=>{let r=Math.ceil(t.getBoundingClientRect().height);n.style.height=r+16+s+"px";let l=n.getBoundingClientRect().top-e.getBoundingClientRect().top;a.style.height=Math.max(0,e.clientHeight-l)+"px";let i=t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;e.scrollTop=Math.max(0,i-l)};s(0);let r=n.nextElementSibling,l=t.getBoundingClientRect().bottom,i=r?r.getBoundingClientRect().top:n.getBoundingClientRect().bottom;l>=i&&s(Math.max(16,Math.ceil(l-i)));return}a&&(a.style.height="0px"),n&&(n.style.height=""),e.scrollTop=e.scrollHeight},[M,eH]),(0,n.useEffect)(()=>{let e=z.current;if(!e)return;let t=document.getElementById(`exchange-${e}`);t&&(z.current=null,t.scrollIntoView({block:"center"}),t.focus({preventScroll:!0}))},[W]),(0,n.useLayoutEffect)(()=>{e$(e=>{if(0===e.length)return e;let t=e.filter(e=>{let t=eP.current[e]??0;return M.some(n=>"bot"===n.sender_type&&n.sender_id===e&&n.created_at>t&&!/^\[(mcp|tool call|tool result)\]/i.test(n.content.trim()))});if(0===t.length)return e;for(let e of t)delete eP.current[e];return e.filter(e=>!t.includes(e))})},[M]);let eJ=async e=>{A&&(await fetch(`/api/conversations/${A.id}/messages/${e}/stop`,{method:"POST"}),await eW())},ez=async()=>{A&&(await fetch(`/api/conversations/${A.id}/stop`,{method:"POST"}),await eW())},eG=async(e,t)=>{if(eg[e.id])return void ex(t=>{let n={...t};return delete n[e.id],n});if(ey.current[e.id])return;let n=M.findIndex(t=>t.id===e.id),a=x.find(e=>e.name===t),s=M.slice(n+1).find(e=>"bot"===e.sender_type&&(a?e.sender_id===a.id:e.sender_name===t));if(s){ey.current[e.id]=!0;try{let t=await fetch(`/api/messages/${e.id}/between?other=${encodeURIComponent(s.id)}`),n=await t.json().catch(()=>null);t.ok&&Array.isArray(n)&&n.length>0&&ex(t=>({...t,[e.id]:n}))}finally{delete ey.current[e.id]}}},eV=async()=>{if(!A)return;let e=eC.current?.files?.[0];if(!e)return;let t=await new Promise((t,n)=>{let a=new FileReader;a.onload=()=>t(String(a.result||"")),a.onerror=()=>n(a.error),a.readAsDataURL(e)});if(!t.startsWith("data:image/"))return;let n=await fetch("/api/bots",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:A.details.id,avatar:t})});if(!n.ok)return;let a=await n.json();y(e=>e.map(e=>e.id===a.id?{...e,avatar:a.avatar}:e)),O({...A,details:{...A.details,avatar:a.avatar}})},eZ=async e=>{if(!e||!A)return;let t=await new Promise((t,n)=>{let a=new FileReader;a.onload=()=>t(String(a.result||"")),a.onerror=()=>n(a.error),a.readAsDataURL(e)});if(!t.startsWith("data:image/"))return;let n=await fetch("/api/bots",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:A.details.id,avatar:t})});if(!n.ok)return;let a=await n.json();y(e=>e.map(e=>e.id===a.id?{...e,avatar:a.avatar}:e)),O({...A,details:{...A.details,avatar:a.avatar}})},eY=async()=>{if(!A)return;let e=await fetch("/api/bots",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:A.details.id,avatar:null})});if(!e.ok)return;let t=await e.json();y(e=>e.map(e=>e.id===t.id?{...e,avatar:t.avatar||""}:e)),O({...A,details:{...A.details,avatar:t.avatar||""}})},eQ=j&&0===x.length,eX=async e=>{let t=e.map(e=>e.id);ej(!1),eN((0,g.deletedStatusLine)(t.length)),requestAnimationFrame(()=>eb.current?.focus()),y(e=>e.filter(e=>!t.includes(e.id))),A&&t.includes(A.details.id)&&(O(null),H([]),q([])),await eq()},e0=et?x.filter(e=>e.name.toLowerCase().includes(X.toLowerCase())):[],e1=e=>{let t=ei.current,n=t?t.selectionStart:Y.length,a=Y.slice(0,n).lastIndexOf("@");if(a<0)return;Q(Y.slice(0,a)+"@"+e+" "+Y.slice(n)),en(!1);let s=a+e.length+2;requestAnimationFrame(()=>{t?.focus(),t?.setSelectionRange(s,s)})},e6=e=>{if(0===e.length)return;let t=6-ea.length;e.length>t?el("Up to six attachments."):el("");let n=e.slice(0,Math.max(t,0));0!==n.length&&es(e=>[...e,...n.map((t,n)=>({id:t.name+"-"+e.length+"-"+n+"-"+t.size,name:t.name}))])},e4=async()=>{let e=ea.map(e=>e.name),t=Y.trim();if(!t&&0===e.length||!A)return;let n=[t,...e].filter(e=>e.length>0).join("\n"),a=[A.details.id],s=M.reduce((e,t)=>Math.max(e,t.created_at||0),0);for(let e of a)eP.current[e]=s;e$(e=>Array.from(new Set([...e,...a])));let r=[...x].sort((e,t)=>t.name.length-e.name.length).find(e=>(function(e,t){let n="@"+t,a=0;for(;a<e.length;){let t=e.indexOf(n,a);if(t<0)break;let s=e[t+n.length];if(!s||/[\s.,!?:;]/.test(s))return!0;a=t+n.length}return!1})(n,e.name));if(!(await fetch(`/api/conversations/${A.id}/messages`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n,mentionedBotId:r?.id,idempotencyKey:crypto.randomUUID()})})).ok){for(let e of a)delete eP.current[e];e$(e=>e.filter(e=>!a.includes(e)))}Q(""),es([]),el(""),en(!1),eW()},e3=A?(e=A.id,M.length>0?"messages":G&&G.conversationId===e&&"loading"!==G.status?"error"===G.status?"error":"empty":"loading"):"loading",e2=A?(0,t.jsx)(b,{view:e3,agentName:A.details.name}):null,e8=(A?.details.title||"").trim(),e9=A?.details.color,e5=new Set,e7=e=>(0,t.jsx)("div",{className:"msg-status",children:(0,t.jsx)(C.default,{notice:e,onDone:()=>{eW()}})},e.eventId),te=new Set,tt=e=>(0,t.jsx)("div",{className:"msg-status",children:(0,t.jsx)(k.default,{summary:e,onChanged:()=>{eW()}})},`exchange-${e.id}`),tn=e=>{let t=W.filter(t=>!te.has(t.id)&&t.created_at<e).sort((e,t)=>e.created_at-t.created_at||(e.id<t.id?-1:1));return t.forEach(e=>te.add(e.id)),t.map(tt)},ta=()=>{ed(!1),requestAnimationFrame(()=>eu.current?.focus())};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"field",inert:ec,children:[(0,t.jsx)(o.default,{agents:x,activeAgentId:A?.details.id,workingIds:eE,beatClock:eT,now:eF,status:ew,logoDrop:eU,onAgentsChange:e=>y(e),onNew:()=>ed(!0),onManage:()=>{eN(""),ej(!0)},onDeleted:e=>{eX(e)},newButtonRef:eu,manageButtonRef:eb}),(0,t.jsx)("section",{className:"pane",children:A?(0,t.jsxs)("div",{className:"thread",children:[(0,t.jsxs)("div",{className:"thread-bar",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("button",{type:"button",className:"thread-name",style:e9?{color:e9}:void 0,onClick:()=>{eh(!0),ef(!1)},children:A.details.name}),e8?(0,t.jsx)("div",{className:"thread-role",children:e8}):null,(0,t.jsx)("div",{className:"thread-role",children:eE.includes(A.details.id)?"Working":"Not working"}),(0,t.jsx)("div",{className:"thread-role",children:(u=(eM??A.details).last_seen,m=eT.serverNow,h=eT.fetchedAt,u&&m?eF-h+(m-u)>15e3?"Stopped":"Heartbeat "+new Intl.DateTimeFormat("en-US",{timeZone:"America/Los_Angeles",hour:"numeric",minute:"2-digit",second:"2-digit"}).format(new Date(u)):"Stopped")}),em?(0,t.jsx)("button",{type:"button",className:"avatar-pic",onClick:()=>ef(!0),"aria-label":"Picture",children:A.details.avatar?(0,t.jsx)("img",{src:A.details.avatar,alt:""}):(0,t.jsx)(i.default,{bot:A.details,size:46})}):null]}),(0,t.jsxs)("div",{style:{marginLeft:"auto",display:"flex",gap:16,alignItems:"flex-start"},children:[(0,t.jsx)(a.default,{href:`/agents/${A.details.id}/config`,className:"attach-word",style:{textDecoration:"none"},children:"Config"}),(0,t.jsx)(a.default,{href:`/agents/${encodeURIComponent(A.details.id)}/sessions`,className:"attach-word",style:{textDecoration:"none"},children:"Sessions"}),(0,t.jsx)("button",{type:"button",className:"attach-word",title:"Stop delegated turns in this thread",onClick:()=>{ez()},children:"Stop"})]})]}),ep?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"avatar-step avatar-desk",children:[(0,t.jsx)("span",{className:"kind-word",children:"Agent"}),(0,t.jsx)("button",{type:"button",className:"kind-word",children:"Generate"}),(0,t.jsxs)("label",{className:"kind-word",children:["Upload",(0,t.jsx)("input",{ref:eC,type:"file",accept:"image/*,.svg"})]}),(0,t.jsx)("button",{type:"button",className:"create-btn",onClick:eV,children:"Set avatar"})]}),(0,t.jsxs)("div",{className:"avatar-step avatar-phone",children:[(0,t.jsx)("button",{type:"button",className:"kind-word",onClick:()=>eS.current?.click(),children:"Gallery"}),(0,t.jsx)("button",{type:"button",className:"kind-word",children:"Generate"}),(0,t.jsx)("button",{type:"button",className:"kind-word",onClick:eY,children:"Remove Photo"}),(0,t.jsx)("input",{ref:eS,type:"file",accept:"image/*,.svg",onChange:e=>{let t=e.target.files?.[0];e.target.value="",eZ(t)}})]})]}):null,(0,t.jsxs)("div",{className:"messages-wrap",children:[(0,t.jsxs)("div",{className:"messages",children:[eH?null:e2,M.map(e=>{var a;let s,r=K.filter(t=>!e5.has(t.eventId)&&t.createdAt<e.created_at);r.forEach(e=>e5.add(e.eventId));let i=tn(e.created_at),o="user"===e.sender_type,u=o?null:(0,N.classifyRuntimeFailure)(T(e.content));if(u)return(0,t.jsxs)(n.Fragment,{children:[r.map(e7),i,(0,t.jsx)("div",{className:"msg-status",children:(0,t.jsx)(w.default,{failure:u})})]},e.id);let m=(a=T(e.content),s=[],{text:$(a.replace(/data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=\s]+/g,e=>(s.push(e.replace(/\s/g,"")),""))),images:s}),h=m.images.map(e=>(0,t.jsx)("img",{src:e,alt:"",style:{display:"block",width:64,height:64}},e.slice(0,48))),p=o?void 0:A.details.color,f=o?null:(0,l.parseRun)(e.content),g=o||f?null:(0,c.parseDraft)(T(e.content)),x=o||f?null:(0,c.parseApprovalCode)(e.content),y=o||f?[]:(0,c.parseFileNames)(e.content),v=o||f?null:(0,c.parseHandoff)(m.text),j=e.draftStatus??(g?"open":null),b=e.approvalStatus??(x?"pending":null);return(0,t.jsxs)(n.Fragment,{children:[r.map(e7),i,(0,t.jsxs)("div",{className:o?"msg-you":"msg-bot",ref:f&&"running"===f.state?eR:void 0,children:[(0,t.jsx)("div",{className:o?"msg-name msg-name-you":"msg-name",style:p?{color:p}:void 0,children:o?"You":e.sender_name||A.details.name}),f?(0,t.jsxs)("div",{className:"msg-body",children:[(0,l.runLine)(f),"running"===f.state?(0,t.jsxs)(t.Fragment,{children:[" ",(0,t.jsx)("button",{type:"button",className:"attach-word",style:{font:"inherit"},onClick:t=>{t.preventDefault(),t.stopPropagation(),eJ(e.id)},children:"Stop"})]}):null]}):g&&j?(0,t.jsx)("div",{className:"msg-body",children:(0,t.jsx)(L,{message:e,conversationId:A.id,status:j,onDone:()=>{eW()}},e.id+j)}):(0,t.jsxs)("div",{className:"msg-body",onClick:v?()=>{eG(e,v)}:void 0,title:v?"Show the replies between this handoff and the reply":void 0,style:v?{cursor:"pointer"}:void 0,children:[function(e,n){let a=String(e??"").split("\n");if(!a.some(e=>null!==(0,d.agentEventDisplay)(e)))return e;let s=[];return a.forEach((e,a)=>{a>0&&s.push((0,t.jsx)("br",{},n+"-br-"+a));let r=(0,d.agentEventDisplay)(e);r?s.push((0,t.jsxs)("span",{className:"agent-event",children:[(0,t.jsx)("span",{className:"agent-event-label",children:r.label}),r.detail?" "+r.detail:""]},n+"-"+a)):s.push((0,t.jsx)("span",{children:e},n+"-"+a))}),s}(m.text,e.id),h,x&&b?(0,t.jsx)(F,{message:e,conversationId:A.id,status:b,onDone:()=>{eW()}},e.id+b):null,(0,t.jsx)(_,{names:y})]}),eg[e.id]?(0,t.jsx)("div",{className:"msg-body",children:eg[e.id].map(e=>(0,t.jsx)("div",{children:(e.sender_name||"Agent")+": "+$(e.content)},e.id))}):null]})]},e.id)}),K.filter(e=>!e5.has(e.eventId)).map(e7),tn(1/0),(0,t.jsx)("div",{ref:eD}),(0,t.jsx)("div",{ref:ek})]}),eH?(0,t.jsxs)("div",{className:"computer-float",children:[(0,t.jsxs)("div",{className:"computer-top",children:[(0,t.jsxs)("span",{className:"computer-lights","aria-hidden":"true",children:[(0,t.jsx)("span",{className:"computer-light computer-light-red"}),(0,t.jsx)("span",{className:"computer-light computer-light-yellow"}),(0,t.jsx)("span",{className:"computer-light computer-light-green"})]}),(0,t.jsxs)("span",{className:"computer-teach",children:[(0,t.jsxs)("span",{className:"computer-teach-pill",children:[(0,t.jsx)("span",{className:"computer-teach-mark","aria-hidden":"true"}),"Teach a task"]}),(0,t.jsx)("span",{className:"computer-expand","aria-hidden":"true",children:(0,t.jsx)("svg",{viewBox:"0 0 16 16",width:"14",height:"14",children:(0,t.jsx)("path",{d:"M9.2 2.6H13.4V6.8M6.8 13.4H2.6V9.2M13.1 2.9L9.4 6.6M2.9 13.1L6.6 9.4",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]}),(0,t.jsx)("div",{className:"messages"===e3?"computer-band":"computer-band computer-band-note",ref:eA,children:e2}),(0,t.jsxs)("div",{className:"computer-desk",children:[eK?(0,t.jsx)("iframe",{className:"computer-page",sandbox:"",srcDoc:eK,tabIndex:-1}):null,(0,t.jsxs)("div",{className:"computer-dock",children:[(0,t.jsx)("img",{src:"/computer/dock-chrome.png",alt:""}),(0,t.jsx)("img",{src:"/computer/dock-gray.png",alt:""}),(0,t.jsx)("img",{src:"/computer/dock-terminal.png",alt:""})]})]})]}):null]}),(0,t.jsxs)("div",{className:"composer",onPaste:e=>{let t=[],n=e.clipboardData.files;if(n&&n.length>0)t.push(...Array.from(n));else for(let n of Array.from(e.clipboardData.items)){if("file"!==n.kind)continue;let e=n.getAsFile();e&&t.push(e)}0!==t.length&&(e.preventDefault(),e6(t))},children:[et&&e0.length>0?(0,t.jsx)("div",{className:"mention-list",children:e0.map(e=>(0,t.jsxs)("button",{type:"button",onMouseDown:t=>{t.preventDefault(),e1(e.name)},children:["@",e.name]},e.id))}):null,(0,t.jsxs)("div",{className:"composer-box",children:[er?(0,t.jsx)("p",{className:"attach-error",children:er}):null,ea.length>0?(0,t.jsx)("div",{className:"attach-names",children:ea.map(e=>(0,t.jsx)("span",{children:e.name},e.id))}):null,(0,t.jsx)("textarea",{ref:ei,rows:2,value:Y,onChange:e=>{var t,n;let a,s;Q(e.target.value),t=e.target.value,n=e.target.selectionStart,(s=(a=t.slice(0,n)).lastIndexOf("@"))<0||/\s/.test(a.slice(s+1))?en(!1):(ee(a.slice(s+1)),en(!0))},onKeyDown:e=>{if("Enter"===e.key&&!e.shiftKey){if(e.preventDefault(),et&&e0.length>0)return void e1(e0[0].name);e4()}},placeholder:"Say something"})]}),(0,t.jsx)("input",{ref:eo,className:"attach-input",type:"file",multiple:!0,onChange:e=>{e6(Array.from(e.target.files||[])),e.target.value=""}}),(0,t.jsx)("button",{type:"button",className:"attach-word",onClick:()=>eo.current?.click(),children:"Attach"}),(0,t.jsx)("button",{type:"button",className:"send-btn",onClick:e4,children:"Send"})]})]}):eQ?(0,t.jsxs)("div",{className:"welcome",children:[(0,t.jsx)(s.default,{className:"welcome-mark",src:"/brand/botmancers-logo-outline-256.png",alt:"Botmancers",width:144,height:144,priority:!0}),(0,t.jsx)("p",{className:"empty-line",children:"Pick someone to talk to."})]}):(0,t.jsx)("p",{className:"empty-line",children:"Pick someone to talk to."})}),ev?(0,t.jsx)(v,{onClose:()=>{ej(!1),requestAnimationFrame(()=>eb.current?.focus())},onDeleted:e=>{eX(e)}}):null]}),ec&&(0,t.jsx)(P,{anchorRef:eu,onClose:ta,onCreated:()=>{eq(),ta()}})]})}],31713)}]);
@@ -1 +1 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,13255,e=>{"use strict";var t=e.i(43476),n=e.i(71645),s=e.i(22016),a=e.i(50814);e.s(["default",0,function({summary:e,onChanged:i}){let[o,r]=(0,n.useState)(!1),[l,c]=(0,n.useState)(""),d=(0,a.stateTone)(e.state),u=(0,a.outcomeLine)(e),p=(0,a.failureAdvice)(e),h=`exchange-${e.id}-title`,m=async()=>{if(!o){r(!0),c("");try{let t=await fetch(`/api/exchanges/${encodeURIComponent(e.id)}/cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"});if(!t.ok){let e=await t.json().catch(()=>null);c("string"==typeof e?.error?.message?e.error.message:"Could not cancel. Try again.")}}catch{c("Could not cancel. Try again.")}finally{r(!1),i?.()}}};return(0,t.jsxs)("article",{id:`exchange-${e.id}`,className:`exchange-card is-${d} is-${e.state}`,"data-exchange-id":e.id,"data-exchange-state":e.state,"aria-labelledby":h,tabIndex:-1,children:[(0,t.jsxs)("p",{className:"exchange-card-line",children:[(0,t.jsx)("span",{className:"exchange-card-mode",children:(0,a.modeLabel)(e.mode)}),(0,t.jsx)("span",{id:h,className:"exchange-card-title",children:(0,a.participantsLabel)(e)}),(0,t.jsx)("span",{className:"exchange-card-state",role:"status",children:(0,a.liveStateLabel)(e)})]}),(0,t.jsx)("p",{className:"exchange-card-session",children:(0,a.sessionLabel)(e)}),(0,t.jsxs)("p",{className:"exchange-card-instruction",children:[(0,t.jsx)("span",{className:"exchange-card-key",children:(0,a.instructionHeading)(e.mode)})," ",(0,a.excerpt)(e.instruction,220)]}),u?(0,t.jsx)("p",{className:"failed"===e.state?"exchange-card-outcome is-failure":"exchange-card-outcome",children:u}):null,p?(0,t.jsx)("p",{className:"exchange-card-advice",children:p}):null,l?(0,t.jsx)("p",{className:"exchange-card-error",role:"alert",children:l}):null,(0,t.jsxs)("p",{className:"exchange-card-foot",children:[(0,t.jsxs)("span",{className:"exchange-card-time",children:["Updated ",(0,a.formatExchangeTime)(e.updated_at)]}),(0,t.jsx)(s.default,{className:"exchange-card-link",href:(0,a.detailsHref)(e.id),"aria-label":`Details: ${(0,a.modeLabel)(e.mode)} ${(0,a.participantsLabel)(e)}`,children:"Details"}),e.can_cancel?(0,t.jsx)("button",{type:"button",className:"exchange-card-cancel",disabled:o,onClick:()=>{m()},children:o?"Cancelling…":"Cancel"}):null]})]})}])},46986,15366,e=>{"use strict";var t=e.i(43476),n=e.i(71645),s=e.i(96594);e.s(["default",0,function({failure:e}){let[a,i]=(0,n.useState)("idle"),o=(0,s.severityLabel)(e.severity),r=(0,n.useId)();async function l(){try{await navigator.clipboard.writeText(e.detail),i("copied")}catch{i("failed")}}return(0,t.jsxs)("div",{className:`runtime-failure runtime-failure-${e.severity}`,role:"status","aria-labelledby":r,"data-runtime-failure":e.kind,children:[(0,t.jsxs)("p",{className:"runtime-failure-title",id:r,children:[(0,t.jsx)("span",{className:"runtime-failure-severity",children:o}),e.title]}),(0,t.jsx)("p",{className:"runtime-failure-recovery",children:e.recovery}),(0,t.jsxs)("details",{className:"runtime-failure-details",children:[(0,t.jsx)("summary",{children:"Details"}),(0,t.jsx)("code",{className:"runtime-failure-detail",children:e.detail}),(0,t.jsx)("button",{type:"button",className:"runtime-failure-copy",onClick:()=>{l()},children:"copied"===a?"Copied":"failed"===a?"Copy failed":"Copy details"})]})]})}],46986);let a={blocked:"Needs approval",rejected:"Not started",allowed:"Allowed",denied:"Denied",waiting:"Queued",stopped:"Stopped"};e.s(["default",0,function({notice:e,onDone:s}){let[i,o]=(0,n.useState)(!1),[r,l]=(0,n.useState)(""),c="blocked"!==e.tone||e.actionable?a[e.tone]:"Blocked",d=async t=>{if(!i&&e.wakeId){o(!0),l("");try{let n=await fetch(`/api/wakes/${e.wakeId}/decision`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({decision:t})});if(!n.ok){let e=await n.json().catch(()=>null);l("string"==typeof e?.error?.message?e.error.message:"The decision could not be recorded.")}}catch{l("The decision could not be recorded.")}finally{o(!1),s()}}};return(0,t.jsxs)("div",{className:`wake-notice wake-notice-${e.tone}`,role:"status","data-wake-notice":e.tone,"data-wake-id":e.wakeId??void 0,children:[(0,t.jsxs)("p",{className:"wake-notice-line",children:[(0,t.jsx)("span",{className:"wake-notice-label",children:c}),e.text]}),e.actionable?(0,t.jsxs)("div",{className:"wake-notice-actions",children:[(0,t.jsx)("button",{type:"button",className:"approve-control",disabled:i,onClick:()=>{d("allow")},children:"Allow"}),(0,t.jsx)("button",{type:"button",className:"approve-control",style:{marginLeft:8},disabled:i,onClick:()=>{d("deny")},children:"Deny"})]}):null,r?(0,t.jsx)("p",{className:"wake-notice-error",role:"alert",children:r}):null]})}],15366)},33851,44079,52900,68541,e=>{"use strict";var t=e.i(3136);let n="This computer",s={read_only:"Read only",workspace_write:"Workspace write"},a={workspaces:"Selected workspaces",sessions:"Selected imported sessions",all_provider_sessions:"All sessions this runtime can see"};function i(e){return e.startsWith("/")||"~"===e||e.startsWith("~/")}function o(e){return e.length>1?e.replace(/\/+$/,""):e}t.AGENTS.join("|");let r="/api/runtime-connections",l={connection:"Runtime connection",scope:"Session scope",defaultWorkspace:"Default workspace (optional)",policy:"Policy",homeSession:"Home session (optional)"},c={connection:"The runtime installation or account this Agent uses. Several Agents can share one.",workspaces:"One absolute path per line. An empty scope never means unrestricted.",sessions:"Only this Agent’s own Botmancers sessions can be selected.",noSessions:"This Agent has no sessions yet. Choose workspaces or all sessions for now.",allSessions:"Every session this runtime can see. Choose this only on purpose.",defaultWorkspace:"Where new sessions start. Convenience only — not a permission.",resumeEdits:"Needs Workspace write.",homeSession:"A stable session to return to. Must be one of this Agent’s sessions.",addConnection:"Stores a name and host only. Credentials stay with the runtime."},d="Loading runtime connections…",u="Couldn't load runtime connections — retry.";function p(){return{status:"loading",connections:[],error:""}}function h(e){return`${e.label} \xb7 ${t.AGENT_LABELS[e.provider]??e.provider}`}function m(e){if("object"!=typeof e||null===e)return null;let t=e.connections;if(!Array.isArray(t))return null;let n=[];for(let e of t){if("object"!=typeof e||null===e||"string"!=typeof e.id||"string"!=typeof e.provider||"string"!=typeof e.label)return null;n.push({id:e.id,provider:e.provider,label:e.label,host:"string"==typeof e.host?e.host:"",agent_count:"number"==typeof e.agent_count?e.agent_count:void 0})}return n}function f(e){let t=[];for(let n of e.split("\n")){let e=n.trim();e&&!t.includes(e)&&t.push(e)}return t}function g(e){return"workspaces"===e.scopeKind?{kind:"workspaces",workspaces:f(e.workspaces)}:"sessions"===e.scopeKind?{kind:"sessions",sessions:e.sessions}:{kind:e.scopeKind}}function k(e){return{mode:e.policyMode,allow_new_sessions:e.allowNewSessions,allow_resume_with_edits:e.allowResumeWithEdits}}e.s(["CONNECTIONS_ENDPOINT",0,r,"CONNECTIONS_ERROR_COPY",0,u,"CONNECTIONS_LOADING_COPY",0,d,"DEFAULT_REGISTRATION_FORM",0,{connectionId:"",scopeKind:"",workspaces:"",sessions:[],defaultWorkspace:"",policyMode:"read_only",allowNewSessions:!0,allowResumeWithEdits:!1,homeSessionId:""},"HINTS",0,c,"LABELS",0,l,"connectionOptionLabel",0,h,"hasRegistrationErrors",0,function(e){return Object.keys(e.errors).length>0},"initialConnectionListState",0,p,"parseConnectionList",0,m,"registrationCreateBody",0,function(e,t){let n={name:String(e??"").trim(),runtime_connection_id:t.connectionId,session_scope:g(t),policy:k(t)},s=t.defaultWorkspace.trim();return s&&(n.default_workspace=s),n},"registrationFormFromBot",0,function(e){let t=e.session_scope??null;return{connectionId:e.runtime_connection_id??"",scopeKind:t?.kind??"",workspaces:t?.kind==="workspaces"?t.workspaces.join("\n"):"",sessions:t?.kind==="sessions"?[...t.sessions]:[],defaultWorkspace:e.default_workspace??"",policyMode:e.policy?.mode??"read_only",allowNewSessions:!e.policy||e.policy.allow_new_sessions,allowResumeWithEdits:!!e.policy&&e.policy.allow_resume_with_edits,homeSessionId:e.home_session_id??""}},"registrationFormView",0,function(e,t){let n={};e.connectionId||(n.connection="Pick a runtime connection.");let s=f(e.workspaces);e.scopeKind?"workspaces"===e.scopeKind?0===s.length?n.workspaces="Add at least one workspace.":s.every(i)||(n.workspaces="Workspaces must be absolute paths (or start with ~/)."):"sessions"===e.scopeKind&&0===e.sessions.length&&(n.sessions="Select at least one session."):n.scope="Choose a session scope.";let a=e.defaultWorkspace.trim();a&&(i(a)?"workspaces"!==e.scopeKind||n.workspaces||s.some(e=>{let t,n;return t=o(e),t===(n=o(a))||n.startsWith("/"===t?"/":`${t}/`)})||(n.defaultWorkspace="The default workspace must be inside one of the selected workspaces."):n.defaultWorkspace="The default workspace must be an absolute path (or start with ~/)."),e.allowResumeWithEdits&&"workspace_write"!==e.policyMode&&(n.policy="Resume with edits needs the Workspace write policy.");let r="",l=!1;return"ready"!==t.status&&(l=!0,r="error"===t.status?u:""),{errors:n,submitDisabled:l,blocker:r}},"registrationPatchBody",0,function(e,t){return{id:e,runtime_connection_id:t.connectionId,session_scope:g(t),default_workspace:t.defaultWorkspace.trim(),policy:k(t),home_session_id:t.homeSessionId}},"registrationReadView",0,function(e,n){var i;let o,r=[{key:"connection",label:l.connection,value:(o=e.runtime_connection)?`${o.label} (${(0,t.agentLabel)(o.provider)} \xb7 ${o.host})`:"Not set"},{key:"scope",label:l.scope,value:function(e,t){if(!e)return"Not set — this Agent cannot launch until a scope is chosen.";if("all_provider_sessions"===e.kind)return a.all_provider_sessions;if("workspaces"===e.kind)return`${a.workspaces}: ${e.workspaces.join(", ")}`;let n=e.sessions.map(e=>t?.find(t=>t.ref===e)?.title??e);return`${a.sessions}: ${n.join(", ")}`}(e.session_scope,n)},{key:"defaultWorkspace",label:"Default workspace",value:e.default_workspace||"None"},{key:"policy",label:l.policy,value:(i=e.policy)?[s[i.mode],i.allow_new_sessions?"new sessions allowed":"no new sessions",i.allow_resume_with_edits?"resume with edits allowed":"no resume with edits"].join(" · "):"Not set"}],c=[];return r.push({key:"homeSession",label:"Home session",value:e.home_session_id?n?.find(t=>t.ref===e.home_session_id)?.title??e.home_session_id:"None"}),"connection"===e.launch_blocker?c.push("Choose a runtime connection before this Agent can run."):"session_scope"===e.launch_blocker?c.push("Choose a session scope before this Agent can run."):"agent"===e.launch_blocker&&c.push("This Agent has an unsupported Agent type."),{rows:r,notices:c}}],33851);var b=e.i(43476),y=e.i(71645),w=e.i(74904);let _={modal:{fieldset:"agent-fieldset reg-fieldset",legend:"field-legend",label:"",picks:"runtime-picks",pick:"runtime-pick",stack:"reg-stack",control:"reg-control",input:"",hint:"runtime-hint",error:"form-error reg-error",button:"runtime-retry",note:"runtime-note"},config:{fieldset:"agent-fieldset reg-fieldset",legend:"block text-sm cfg-muted mt-3 mb-1 p-0",label:"block text-sm cfg-muted mt-3 mb-1",picks:"flex flex-wrap gap-x-4 gap-y-1 text-sm cfg-muted",pick:"text-sm cfg-muted",stack:"flex flex-col gap-1 text-sm cfg-muted",control:"cfg-input text-sm",input:"cfg-input text-sm",hint:"mt-1 text-xs cfg-faint",error:"mt-1 text-sm cfg-error",button:"cfg-link text-sm",note:"text-sm cfg-muted mt-1"}};function x({id:e,message:t,variant:n}){return t?(0,b.jsx)("p",{id:e,className:_[n].error,role:"alert",children:t}):null}function v({idPrefix:e,variant:t,onAdd:s}){let a=_[t],[i,o]=(0,y.useState)(!1),[r,l]=(0,y.useState)(w.AGENT_OPTIONS[0].value),[d,u]=(0,y.useState)(""),[p,h]=(0,y.useState)(""),[m,f]=(0,y.useState)(""),[g,k]=(0,y.useState)(!1),x=async()=>{if(g)return;k(!0),f("");let e=await s({provider:r,label:d,host:p.trim()||n});(k(!1),"string"==typeof e)?f(e):(o(!1),u(""),h(""))};return i?(0,b.jsxs)("div",{id:`${e}-add-connection`,className:"reg-add-connection",role:"group","aria-label":"Add connection",children:[(0,b.jsx)("label",{className:a.label,htmlFor:`${e}-add-provider`,children:"Provider"}),(0,b.jsx)("select",{id:`${e}-add-provider`,className:a.control,value:r,onChange:e=>l(e.target.value),children:w.AGENT_OPTIONS.map(e=>(0,b.jsx)("option",{value:e.value,children:e.label},e.value))}),(0,b.jsx)("label",{className:a.label,htmlFor:`${e}-add-label`,children:"Connection name"}),(0,b.jsx)("input",{id:`${e}-add-label`,type:"text",className:a.input||void 0,value:d,placeholder:"Codex on my laptop",onChange:e=>u(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),x())}}),(0,b.jsx)("label",{className:a.label,htmlFor:`${e}-add-host`,children:"Host"}),(0,b.jsx)("input",{id:`${e}-add-host`,type:"text",className:a.input||void 0,value:p,placeholder:n,"aria-describedby":`${e}-add-hint`,onChange:e=>h(e.target.value)}),(0,b.jsx)("p",{id:`${e}-add-hint`,className:a.hint,children:c.addConnection}),m?(0,b.jsx)("p",{className:a.error,role:"alert",children:m}):null,(0,b.jsxs)("div",{className:"reg-actions",children:[(0,b.jsx)("button",{type:"button",className:a.button,onClick:()=>void x(),disabled:g,children:g?"Adding…":"Add"}),(0,b.jsx)("button",{type:"button",className:a.button,"aria-expanded":"true",onClick:()=>o(!1),children:"Cancel"})]})]}):(0,b.jsx)("button",{type:"button",className:a.button,"aria-expanded":"false","aria-controls":`${e}-add-connection`,onClick:()=>o(!0),children:"Add connection…"})}e.s(["RegistrationFields",0,function({idPrefix:e,variant:t,form:n,onChange:i,view:o,showErrors:r,connections:p,onRetryConnections:m,onAddConnection:f,workspacePlaceholder:g,workspaceHint:k,sessions:y,includeHomeSession:w}){let $=_[t],N=e=>r?o.errors[e]:void 0,j=t=>`${e}-${t}-error`,C=(e,...t)=>[...t,N(e)?j(e):""].filter(Boolean).join(" ")||void 0,S=!!(y&&y.length>0);return(0,b.jsxs)("div",{className:"registration-fields","data-registration":t,children:[(0,b.jsxs)("fieldset",{className:$.fieldset,"data-field":"connection","aria-describedby":C("connection",`${e}-connection-hint`),children:[(0,b.jsx)("legend",{className:$.legend,id:`${e}-connection-legend`,children:l.connection}),"loading"===p.status?(0,b.jsx)("p",{className:$.note,role:"status",children:d}):"error"===p.status?(0,b.jsxs)("p",{className:$.note,role:"status",children:[u," ",(0,b.jsx)("button",{type:"button",className:$.button,onClick:m,children:"Retry"})]}):(0,b.jsxs)("select",{id:`${e}-connection`,className:$.control,"aria-labelledby":`${e}-connection-legend`,"aria-required":"true","aria-invalid":!!N("connection")||void 0,value:n.connectionId,onChange:e=>i({connectionId:e.target.value}),children:[(0,b.jsx)("option",{value:"",disabled:!0,children:"Select a connection…"}),p.connections.map(e=>(0,b.jsx)("option",{value:e.id,children:h(e)},e.id))]}),(0,b.jsx)("p",{id:`${e}-connection-hint`,className:$.hint,children:c.connection}),(0,b.jsx)(x,{id:j("connection"),message:N("connection"),variant:t}),"ready"===p.status?(0,b.jsx)(v,{idPrefix:e,variant:t,onAdd:async e=>{let t=await f(e);return"string"!=typeof t&&i({connectionId:t.id}),t}}):null]}),(0,b.jsxs)("fieldset",{className:$.fieldset,"data-field":"scope",children:[(0,b.jsx)("legend",{className:$.legend,id:`${e}-scope-legend`,children:l.scope}),(0,b.jsx)("div",{className:$.stack,role:"radiogroup","aria-labelledby":`${e}-scope-legend`,"aria-required":"true","aria-describedby":C("scope"),children:["workspaces","sessions","all_provider_sessions"].map(t=>(0,b.jsxs)("label",{className:$.pick,children:[(0,b.jsx)("input",{type:"radio",name:`${e}-scope`,value:t,checked:n.scopeKind===t,disabled:"sessions"===t&&!S,onChange:()=>i({scopeKind:t})})," "+a[t]]},t))}),S?null:(0,b.jsx)("p",{className:$.hint,children:c.noSessions}),(0,b.jsx)(x,{id:j("scope"),message:N("scope"),variant:t}),"workspaces"===n.scopeKind?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("label",{className:$.label,htmlFor:`${e}-workspaces`,children:"Workspaces"}),(0,b.jsx)("textarea",{id:`${e}-workspaces`,className:$.input||void 0,rows:2,value:n.workspaces,placeholder:"/Users/you/work/project","aria-required":"true","aria-invalid":!!N("workspaces")||void 0,"aria-describedby":C("workspaces",`${e}-workspaces-hint`),onChange:e=>i({workspaces:e.target.value})}),(0,b.jsx)("p",{id:`${e}-workspaces-hint`,className:$.hint,children:c.workspaces}),(0,b.jsx)(x,{id:j("workspaces"),message:N("workspaces"),variant:t})]}):null,"sessions"===n.scopeKind&&y?(0,b.jsxs)("div",{className:$.stack,role:"group","aria-label":"Sessions in scope","aria-describedby":C("sessions",`${e}-sessions-hint`),children:[y.map(e=>(0,b.jsxs)("label",{className:$.pick,children:[(0,b.jsx)("input",{type:"checkbox",checked:n.sessions.includes(e.ref),onChange:t=>i({sessions:t.target.checked?[...n.sessions,e.ref]:n.sessions.filter(t=>t!==e.ref)})}),` ${e.title} (${e.status})`]},e.ref)),(0,b.jsx)("p",{id:`${e}-sessions-hint`,className:$.hint,children:c.sessions}),(0,b.jsx)(x,{id:j("sessions"),message:N("sessions"),variant:t})]}):null,"all_provider_sessions"===n.scopeKind?(0,b.jsx)("p",{className:$.hint,children:c.allSessions}):null]}),(0,b.jsxs)("div",{"data-field":"default-workspace",children:[(0,b.jsx)("label",{className:$.label,htmlFor:`${e}-default-workspace`,children:l.defaultWorkspace}),(0,b.jsx)("input",{id:`${e}-default-workspace`,type:"text",className:$.input||void 0,value:n.defaultWorkspace,placeholder:g,"aria-invalid":!!N("defaultWorkspace")||void 0,"aria-describedby":C("defaultWorkspace",`${e}-default-workspace-hint`,`${e}-default-workspace-note`),onChange:e=>i({defaultWorkspace:e.target.value})}),(0,b.jsx)("p",{id:`${e}-default-workspace-hint`,className:$.hint,children:k}),(0,b.jsx)("p",{id:`${e}-default-workspace-note`,className:$.hint,children:c.defaultWorkspace}),(0,b.jsx)(x,{id:j("defaultWorkspace"),message:N("defaultWorkspace"),variant:t})]}),(0,b.jsxs)("fieldset",{className:$.fieldset,"data-field":"policy",children:[(0,b.jsx)("legend",{className:$.legend,id:`${e}-policy-legend`,children:l.policy}),(0,b.jsx)("div",{className:$.picks,role:"radiogroup","aria-labelledby":`${e}-policy-legend`,children:["read_only","workspace_write"].map(t=>(0,b.jsxs)("label",{className:$.pick,children:[(0,b.jsx)("input",{type:"radio",name:`${e}-policy`,value:t,checked:n.policyMode===t,onChange:()=>i("read_only"===t?{policyMode:t,allowResumeWithEdits:!1}:{policyMode:t})})," "+s[t]]},t))}),(0,b.jsxs)("div",{className:$.stack,children:[(0,b.jsxs)("label",{className:$.pick,children:[(0,b.jsx)("input",{type:"checkbox",checked:n.allowNewSessions,onChange:e=>i({allowNewSessions:e.target.checked})})," Allow new sessions"]}),(0,b.jsxs)("label",{className:$.pick,children:[(0,b.jsx)("input",{type:"checkbox",checked:n.allowResumeWithEdits,disabled:"workspace_write"!==n.policyMode,"aria-describedby":`${e}-resume-hint`,onChange:e=>i({allowResumeWithEdits:e.target.checked})})," Allow resume with edits"]}),(0,b.jsx)("p",{id:`${e}-resume-hint`,className:$.hint,children:c.resumeEdits})]}),(0,b.jsx)(x,{id:j("policy"),message:N("policy"),variant:t})]}),w?(0,b.jsxs)("div",{"data-field":"home-session",children:[(0,b.jsx)("label",{className:$.label,htmlFor:`${e}-home-session`,children:l.homeSession}),(0,b.jsxs)("select",{id:`${e}-home-session`,className:$.control,value:n.homeSessionId,"aria-describedby":`${e}-home-session-hint`,onChange:e=>i({homeSessionId:e.target.value}),children:[(0,b.jsx)("option",{value:"",children:"None"}),(y??[]).map(e=>(0,b.jsx)("option",{value:e.ref,children:`${e.title} (${e.status})`},e.ref))]}),(0,b.jsx)("p",{id:`${e}-home-session-hint`,className:$.hint,children:c.homeSession})]}):null]})}],44079),e.s(["useRuntimeConnections",0,function(){let[e,t]=(0,y.useState)(()=>p()),[n,s]=(0,y.useState)(0);return(0,y.useEffect)(()=>{let e=!1;return fetch(r,{cache:"no-store"}).then(async n=>{let s=n.ok?m(await n.json().catch(()=>null)):null;e||t(s?{status:"ready",connections:s,error:""}:{status:"error",connections:[],error:`HTTP ${n.status}`})}).catch(n=>{e||t({status:"error",connections:[],error:n instanceof Error?n.message:String(n)})}),()=>{e=!0}},[n]),{state:e,retry:(0,y.useCallback)(()=>{t(p()),s(e=>e+1)},[]),add:(0,y.useCallback)(async e=>{let n=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await n.json().catch(()=>null);if(!n.ok)return"string"==typeof s?.error?s.error:"Failed to add the connection";let a=m({connections:[s]})?.[0];return a?(t(e=>({status:"ready",connections:[...e.connections,a],error:""})),a):"Failed to add the connection"},[])}}],52900);let $="imported",N=/^[A-Za-z0-9_-]{1,128}$/;function j(e){let t=new URLSearchParams(e).get($);if(null===t)return null;let n=t.trim();return N.test(n)?n:""}function C(e){return`/agents/${encodeURIComponent(e)}/config`}async function S(e,t,n){let s=j(e);if(null===s)return{kind:"none"};if(!s)return{kind:"missing"};if(s===t)return{kind:"stay"};try{return await n(s)?{kind:"open",path:C(s)}:{kind:"missing"}}catch{return{kind:"missing"}}}e.s(["HANDOFF_STATUS_PATH",0,"/api/marketplace-handoff/status","IMPORT_RETURN_QUERY",0,$,"handoffStartPath",0,function(e,t){return`/api/marketplace-handoff?return=${encodeURIComponent(e+t)}`},"importedBotId",0,j,"importedConfigPath",0,C,"marketImportView",0,function(e){switch(e){case"checking":return{busy:!0,tone:"muted",message:"Checking Grok Marketplace…"};case"redirecting":return{busy:!0,tone:"muted",message:"Opening Grok Marketplace…"};case"unavailable":return{busy:!1,tone:"error",message:"Grok Marketplace isn't configured. Set CLONE_MARKET_URL on the Botmancers server."};case"failed":return{busy:!1,tone:"error",message:"Couldn't reach Botmancers to start the import. Try again."};case"missing":return{busy:!1,tone:"error",message:"Imported agent not found. The import may not have completed."};default:return{busy:!1,tone:"muted",message:"Imports a new agent and opens its Config. This agent is not changed."}}},"resolveImportReturn",0,S],68541)},68684,e=>{"use strict";e.s(["draftTitle",0,function(e){return"email"===e?"New Email":"New Slack Message"},"parseApprovalCode",0,function(e){let t=e.match(/approve using the code ([A-Za-z0-9][A-Za-z0-9_-]*)/i);return t?t[1]:null},"parseDraft",0,function(e){let t,n=e.match(/^\s*\[draft\]\s*([\s\S]*)$/);if(!n)return null;try{t=JSON.parse(n[1])}catch{return null}if(!t||"object"!=typeof t)return null;let s=t;return"email"!==s.channel&&"slack"!==s.channel||"open"!==s.state&&"sent"!==s.state&&"discarded"!==s.state||"string"!=typeof s.recipient||"string"!=typeof s.body?null:{channel:s.channel,recipient:s.recipient,body:s.body,state:s.state}},"parseFileNames",0,function(e){let t=[];for(let n of e.split("\n")){let e=n.match(/^\s*\[file\]\s*(\S+)\s*$/i);e&&!t.includes(e[1])&&t.push(e[1])}return t},"parseHandoff",0,function(e){let t=e.match(/^\s*\[Handing off to ([^\]]+)\]/);return t&&t[1].trim()||null}])},50814,63352,e=>{"use strict";function t(e){return`${new Date(e).toISOString().slice(0,16).replace("T"," ")} UTC`}function n(e){return e?e.split("/").filter(e=>e.length>0).pop()??null:null}function s(e,t){let n=function(e){if(!e)return null;let t=e.toLowerCase();return"muse code"===t?"muse":(["codex","claude","cursor","hermes","muse"].includes(t),t)}(t);switch(e){case"provider_unavailable":return n?{reason:`${n} is not installed or did not start`,fix:`Install ${n} and Retry.`}:{reason:"the runtime is not installed or did not start",fix:"Install the runtime and Retry."};case"auth_required":return{reason:"not signed in",fix:"Sign in and Retry."};case"permission_denied":return{reason:"permission denied",fix:"Check permissions and Retry."};case"incompatible_version":return{reason:"incompatible version",fix:"Update the runtime and Retry."};case"usage_limit":return{reason:"usage limit reached",fix:"Wait or upgrade and Retry."};case"scope_missing":return{reason:"no session scope is set",fix:"Choose a scope in Config."};case"provider_failed":return{reason:"the listing failed",fix:"Retry."};default:return{reason:e,fix:"Retry."}}}let a="Not reported";function i(e){return e.toFixed(1).replace(/\.0$/,"")}function o(e){return e.toLocaleString("en-US")}function r(e){return 0===e?"$0.00":e>=.01?`$${e.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`:e<1e-4?"<$0.0001":`$${e.toFixed(4)}`}let l={input_tokens:"Input tokens",output_tokens:"Output tokens",cost_usd:"Cost"};function c(e,t,n){return"cost_usd"===e?r(t):n?o(t):t<1e3?String(t):t<999950?`${i(t/1e3)}k`:t<99995e4?`${i(t/1e6)}M`:`${i(t/1e9)}B`}function d(e){return`${e} ${1===e?"run":"runs"}`}function u(e,t,n=!1){let s=l[e];if(!t||"unavailable"===t.quality||null===t.sum)return{name:s,text:a,quality:"unavailable",coverage:t&&t.total>0?`0 of ${d(t.total)} reported`:"No runs recorded",label:`${s}: not reported`};let i=c(e,t.sum,n),o=c(e,t.sum,!0);return"partial"===t.quality?{name:s,text:i,quality:"partial",coverage:`Partial: ${t.known} of ${d(t.total)} reported`,label:`${s}: at least ${o}, partial, reported by ${t.known} of ${d(t.total)}`}:{name:s,text:i,quality:"complete",coverage:`All ${d(t.total)} reported`,label:`${s}: ${o}, reported by all ${d(t.total)}`}}e.s(["SESSION_FILTER_OPTIONS",0,[{value:"all",label:"All"},{value:"active",label:"Active"},{value:"ended",label:"Ended"}],"attemptLabel",0,function(e){let t="source"===e.role?"Started the session":"Resumed the session";return`${t} \xb7 ${e.outcome??"running"}`},"emptySessionsCopy",0,function(e,t,n,a){if("active"===e)return`${t} has no active sessions.`;if("ended"===e)return`${t} has no ended sessions.`;if(n?.last_error_code){let{reason:e,fix:t}=s(n.last_error_code,a),i=a?`${a} sessions`:"sessions";return`Could not read ${i}: ${e}. ${t}`}if(n&&null===n.synced_at)return`${t} has not synced sessions yet. Refresh to load past sessions.`;let i=n?.out_of_scope_count??0;return i>0?`${i} ${1===i?"session exists":"sessions exist"} outside ${t}'s scope. Widen the scope to see them.`:`${t} has no sessions yet. One appears after a coding run keeps its runtime context.`},"formatSessionDate",0,t,"formatSyncRelativeTime",0,function(e,t=Date.now()){if(null===e)return"never";let n=Math.max(0,t-e);if(n<6e4)return"just now";let s=Math.floor(n/6e4);if(s<60)return`${s} minute${1===s?"":"s"} ago`;let a=Math.floor(s/60);if(a<24)return`${a} hour${1===a?"":"s"} ago`;let i=Math.floor(a/24);return`${i} day${1===i?"":"s"} ago`},"noMatchingSessionsCopy",0,function(e,t){let s=e.trim();if(s)return`No sessions match “${s}”.`;let a=n(t);return a?`No sessions in ${a}.`:"No sessions match the current filters."},"registrationSessionSyncCopy",0,function(e,t){if("failed"===e.outcome){let{reason:n,fix:a}=s(e.error_code??"provider_failed",t);return`Could not read ${t} sessions: ${n}. ${a}`}if("unsupported"===e.outcome)return`Past sessions are not available for ${t}.`;let n=1===e.imported?"session":"sessions",a=`Loaded ${e.imported} ${n}`;return e.rejected_out_of_scope>0&&(a+=`, ${e.rejected_out_of_scope} outside the scope`),e.complete||(a+=", more remain"),`${a}.`},"runtimeLabel",0,function(e){return e.agent.transport?`${e.agent.adapter} \xb7 ${e.agent.transport}`:e.agent.adapter},"sessionOriginChips",0,function(e){let t=[],n=e.origin.work_request?.requester;return n?.kind==="person"?t.push("Human origin"):n?.kind==="bot"?t.push(n.name?`${n.name} Agent`:"Agent origin"):n?.kind==="service"&&t.push("Service origin"),e.origin.conversation&&t.push(e.origin.conversation.label),[...new Set(t)]},"sessionStateTags",0,function(e){let t=[];return(e.home&&t.push("Home"),e.state?.availability==="missing")?[...t,"Missing"]:(e.state?.lifecycle==="archived"&&t.push("Archived"),e.state?.busy&&t.push("Busy"),(e.resumable||e.state?.resumable===!0)&&t.push("Resumable"),t)},"sessionUsageLine",0,function(e){let t=u("input_tokens",e?.input_tokens),n=u("output_tokens",e?.output_tokens),s=u("cost_usd",e?.cost_usd),i=[t,n,s];if(i.every(e=>"unavailable"===e.quality))return{text:a,label:"Usage: not reported",quality:"unavailable",partial:!1};let o=["unavailable"===t.quality?"input not reported":`${t.text} in`,"unavailable"===n.quality?"output not reported":`${n.text} out`,"unavailable"===s.quality?"cost not reported":s.text].join(" · "),r=i.some(e=>"partial"===e.quality),l=r||i.some(e=>"unavailable"===e.quality)?"partial":"complete";return{text:o,label:`Reported usage: ${i.map(e=>e.label).join("; ")}`,quality:l,partial:r}},"statusLabel",0,function(e){return"active"===e.status?"Active":"Ended"},"usageMetricView",0,u,"usageSampleLabel",0,function(e,t){let n="turn"===e.kind?"start"===e.turn_kind?"provider turn, started":"provider turn":"resume"===e.turn_kind?"resumed":"started";return`Run ${t+1} \xb7 ${n}`},"usageSampleValues",0,function(e){return{input:null===e.input_tokens?a:o(e.input_tokens),output:null===e.output_tokens?a:o(e.output_tokens),cost:null===e.cost_usd?a:r(e.cost_usd)}},"workRequestLabel",0,function(e){var t;let n=e.origin.work_request;return n?`${(t=n.execution_kind)?t[0].toUpperCase()+t.slice(1):t} \xb7 ${n.state}`:null},"workspaceFolderName",0,n,"workspaceOptions",0,function(e){let t=[...new Set(e.filter(e=>"string"==typeof e&&e.length>0))],s=t.map(e=>n(e)??e);return t.map((e,t)=>({value:e,label:s.filter(e=>e===s[t]).length>1?e:s[t]})).sort((e,t)=>e.label<t.label?-1:+(e.label>t.label))}],63352);let p={ask:"Ask from this context",resume:"Resume work here",handoff:"Hand off to…"},h=["queued","extracting","delivering","completed","failed","cancelled"],m=["completed","failed","cancelled"];function f(e,t){switch(t){case"queued":return"Queued";case"extracting":return"ask"===e?"Asking the session":"Extracting handoff";case"delivering":return"Delivering handoff";case"completed":return"ask"===e?"Answered":"Handed off";case"failed":return"Failed";case"cancelled":return"Cancelled"}}function g(e,t=140){let n=String(e??"").split("\n").map(e=>e.trim()).filter(e=>e.length>0).join(" ");return n.length>t?`${n.slice(0,t-1).trimEnd()}…`:n}function k(e,t){return t.updated_at-e.updated_at||t.created_at-e.created_at||(e.id<t.id?-1:+(e.id>t.id))}e.s(["DEFAULT_LEDGER_FILTER",0,{mode:"all",state:"all",agentId:""},"INSTRUCTION_LIMIT",0,4e3,"MODE_FILTER_OPTIONS",0,[{value:"all",label:"All"},{value:"ask",label:"Ask"},{value:"continue",label:"Continue"}],"STATE_FILTER_OPTIONS",0,[{value:"all",label:"Any status"},{value:"active",label:"In progress"},{value:"queued",label:"Queued"},{value:"extracting",label:"Asking / extracting"},{value:"delivering",label:"Delivering"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"},{value:"cancelled",label:"Cancelled"}],"detailsHref",0,function(e){return`/exchanges?id=${encodeURIComponent(e)}`},"eventLabel",0,function(e,t){let n=e.data??{},s=t.source.agent_name,a=t.destination?.agent_name??"the destination Agent",i="string"==typeof n.hop?n.hop:null;switch(e.type){case"created":return"ask"===t.mode?`You asked ${s}'s session a question`:`You handed ${s}'s session to ${a}`;case"hop_queued":if("deliver"===i)return`Handoff queued for ${a}'s new session`;return"extract"===i?`Handoff extraction queued in ${s}'s session`:`Question queued for ${s}'s session`;case"hop_started":if("deliver"===i)return`${a} started a new session`;return"extract"===i?`${s}'s session started extracting the handoff`:`${s}'s session started answering`;case"state_changed":{let e="string"==typeof n.to&&h.includes(n.to)?n.to:null;return e?`Now ${f(t.mode,e).toLowerCase()}`:"State changed"}case"answer_returned":return`Answer returned to ${t.origin?.label??"the origin thread"}${n.truncated?" (shortened)":""}`;case"packet_extracted":return"Handoff packet extracted";case"packet_rejected":return`Handoff packet refused${"string"==typeof n.reason?`: ${n.reason}`:""}`;case"destination_replied":return`${a} replied in ${t.destination?.conversation?.label??"its thread"}`;case"destination_session_rejected":return`${a}'s session was not new; the handoff stopped`;case"cancel_requested":return"You asked to cancel";case"hop_result_discarded":return"A late result was discarded";default:return e.type.replace(/_/g," ")}},"excerpt",0,g,"exchangeRequestBody",0,function(e,t,n){let s={mode:e.mode,idempotency_key:n,origin_conversation_id:e.originConversationId,source:{agent_id:t.agentId,session_ref:t.sessionRef},instruction:e.instruction.trim()};return"continue"===e.mode&&(s.destination={agent_id:e.destinationAgentId}),s},"failureAdvice",0,function(e){if("failed"!==e.state)return null;switch(e.failure?.code){case"packet_invalid":case"packet_missing":return"The source session did not return a usable handoff. Start a new Continue with a clearer objective.";case"destination_session_invalid":return"The destination did not start a fresh session. Check its runtime, then start a new Continue.";case"destination_turn_failed":return"Check the destination Agent’s runtime, then start a new Continue from the source session.";case"source_turn_failed":return"Check the source Agent’s runtime, then start a new exchange from its Sessions.";default:return"Start a new exchange from the session to try again."}},"formatExchangeTime",0,function(e){return t(e)},"instructionHeading",0,function(e){return"ask"===e?"Question":"Objective"},"ledgerAgents",0,function(e){let t=new Map;for(let n of e)t.set(n.source.agent_id,n.source.agent_name),n.destination&&t.set(n.destination.agent_id,n.destination.agent_name);return[...t.entries()].map(([e,t])=>({id:e,name:t})).sort((e,t)=>e.name.localeCompare(t.name)||e.id.localeCompare(t.id))},"ledgerRows",0,function(e,t){return e.filter(e=>("all"===t.mode||e.mode===t.mode)&&("active"!==t.state||!e.terminal)&&("all"===t.state||"active"===t.state||e.state===t.state)&&(!t.agentId||e.source.agent_id===t.agentId||e.destination?.agent_id===t.agentId)).sort(k)},"ledgerView",0,function(e,t,n){return null===e?t?"error":"loading":0===e.length?"empty":0===n.length?"filtered-out":"rows"},"linkRoleLabel",0,function(e){let t={origin:"Started here",source:"Source session",destination:"Destination"};return e.map(e=>t[e]).join(" · ")},"liveStateLabel",0,function(e){var t;return e.cancel_requested&&(t=e.state,!m.includes(t))?"Cancelling…":f(e.mode,e.state)},"modeLabel",0,function(e){return"ask"===e?"Ask":"Continue"},"outcomeLine",0,function(e){if("completed"===e.state){if("ask"===e.mode){let t=e.origin?.label??"the origin thread";return e.outcome.answer?`Answer in ${t}: ${g(e.outcome.answer,200)}`:`Answered in ${t}.`}let t=e.destination?.agent_name??"The destination Agent";return e.outcome.reply?`${t} picked it up in a new session: ${g(e.outcome.reply,200)}`:`${t} picked it up in a new session.`}return"failed"===e.state?e.failure?.message||"The exchange failed.":"cancelled"===e.state?"Cancelled before it finished. Nothing more will run.":null},"participantsLabel",0,function(e){return"ask"===e.mode?`You → ${e.source.agent_name}`:`${e.source.agent_name} → ${e.destination?.agent_name??"another Agent"}`},"pinRequestBody",0,function(e,t,n,s,a){return{action:e,content:t.trim(),conversation_id:n,idempotency_key:a,..."resume"===e?{approve_write:s}:{}}},"sessionDialogMode",0,function(e){return"handoff"===e?"continue":e},"sessionDialogTitle",0,function(e){return p["continue"===e?"handoff":e]},"sessionDialogUsesPin",0,function(e,t){return"resume"===e||"ask"===e&&"provider"===t},"sessionLabel",0,function(e){return`${e.source.agent_name}'s session “${e.source.session_title}”`},"sessionRowActions",0,function(e){let t;if(e.actions)t=e.actions;else{let n="ended"===e.status?{available:!1,reason:"Ask from this context and Hand off to… are unavailable: this session has ended. Its history stays here."}:e.resumable?{available:!0}:{available:!1,reason:`Ask from this context and Hand off to… are unavailable: Botmancers can’t resume this session under ${e.agent.name}’s current runtime.`},s=n.available?{available:!0}:{available:!1,code:"ended"===e.status?"session_ended":"session_not_resumable",reason:n.reason,recovery:"choose_session"};t={ask:s,resume:{available:!1,code:"action_unavailable",reason:`${p.resume} is unavailable: this runtime can’t resume a session with edits.`,recovery:"choose_action"},handoff:s}}return["ask","resume","handoff"].map(e=>({action:e,label:p[e],availability:t[e]}))},"stateTone",0,function(e){return"completed"===e?"done":"failed"===e||"cancelled"===e?"stopped":"active"},"submitErrorMessage",0,function(e,t){switch(e){case"session_ended":return"This session has ended and can’t be resumed.";case"session_not_resumable":return"Botmancers can’t resume this session under the Agent’s current runtime.";case"source_session_busy":return"This session already has an exchange in progress. Wait for it or cancel it from its card.";case"agent_unavailable":return t||"That Agent can’t launch yet. Choose its runtime connection and session scope in Config.";case"idempotency_conflict":return"This request changed while it was being sent. Send again.";case"session_missing":return"The runtime no longer has this session. Its history stays here; choose another session.";case"approval_required":return"Resume work here needs your approval of edits. Tick the approval, then send again.";case"authority_not_allowed":return t||"This Agent’s policy doesn’t allow edits in a resumed session. Change it in Config.";case"action_unavailable":return t||"This runtime can’t do that in this session. Choose another action.";case"provider_failed":return"The runtime failed this turn. Nothing moved to another session; try again later.";default:return t||"The exchange could not be started. Your draft is kept; try again."}},"threadHref",0,function(e,t){let n=new URLSearchParams;if(e.thread_agent_id){t&&n.set("exchange",t);let s=n.toString();return`/agents/${encodeURIComponent(e.thread_agent_id)}/conversations/${encodeURIComponent(e.id)}${s?`?${s}`:""}`}if("group"!==e.kind)return null;t&&n.set("exchange",t);let s=n.toString();return`/threads/${encodeURIComponent(e.id)}${s?`?${s}`:""}`},"validateDraft",0,function(e){let t={},n=e.instruction.trim(),s="ask"===e.mode?"a question":"an objective";return n?e.instruction.length>4e3&&(t.instruction="Keep it under 4000 characters."):t.instruction=`Enter ${s}.`,e.originConversationId||(t.origin="Choose the thread that follows this exchange."),"continue"!==e.mode||e.destinationAgentId||(t.destination="Choose the Agent who continues the work."),t},"validateResumeDraft",0,function(e,t){let n={};return e.trim()?e.length>4e3&&(n.instruction="Keep it under 4000 characters."):n.instruction="Enter what to work on.",t||(n.approval="Approve edits in this session to resume work here."),n}],50814)},71836,e=>{"use strict";e.s(["DIALOG_FOCUSABLE",0,'a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])',"newAgentDialogPlacement",0,function(e,t){let n=Math.min(358,t.width-32),s=Math.max(16,t.width-16-n),a=16,i=16;if(e){i=Math.min(Math.max(e.left,16),s);let n=e.bottom+8;t.height-n-16>=360&&(a=n)}return{top:a,left:i,maxHeight:Math.max(0,t.height-a-16)}},"wrapFocusTarget",0,function(e,t,n){if(0===e.length)return null;let s=e[0],a=e[e.length-1],i=null!==t&&e.includes(t);return n?i&&t!==s?null:a:i&&t!==a?null:s}])},54423,e=>{"use strict";e.s(["wakeNotices",0,function(e){let t=[],n=new Map;return e.forEach((s,a)=>{let i="string"==typeof s.data.target_name?s.data.target_name:null;s.requestId&&i&&n.set(s.requestId,i);let o=function(e){switch(e.kind){case"wake_blocked":return"blocked";case"wake_rejected":return"rejected";case"lineage_stopped":return"stopped";case"wake_accepted":return"string"==typeof e.data.reason?"allowed":null;case"request_cancelled":return"grant_denied"===e.data.reason?"denied":null;case"request_queued":return"capacity"===e.data.waiting_for?"waiting":null;default:return null}}(s);if(!o)return;let r=Array.isArray(s.data.actions)?s.data.actions:[],l=null!==s.requestId&&e.slice(a+1).some(e=>e.requestId===s.requestId);if("waiting"===o&&l)return;let c=s.requestId?n.get(s.requestId):void 0,d="denied"===o&&c?`Wake denied: ${c} — no work ran`:"waiting"===o&&c?`Queued: ${c} — waiting for capacity`:s.text;t.push({eventId:s.eventId,wakeId:s.wakeId,tone:o,text:d,actionable:"blocked"===o&&!!s.wakeId&&r.includes("allow")&&r.includes("deny")&&!l,createdAt:s.createdAt})}),t}])}]);
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,13255,e=>{"use strict";var t=e.i(43476),n=e.i(71645),s=e.i(22016),a=e.i(50814);e.s(["default",0,function({summary:e,onChanged:i}){let[o,r]=(0,n.useState)(!1),[l,c]=(0,n.useState)(""),d=(0,a.stateTone)(e.state),u=(0,a.outcomeLine)(e),p=(0,a.failureAdvice)(e),h=`exchange-${e.id}-title`,m=async()=>{if(!o){r(!0),c("");try{let t=await fetch(`/api/exchanges/${encodeURIComponent(e.id)}/cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"});if(!t.ok){let e=await t.json().catch(()=>null);c("string"==typeof e?.error?.message?e.error.message:"Could not cancel. Try again.")}}catch{c("Could not cancel. Try again.")}finally{r(!1),i?.()}}};return(0,t.jsxs)("article",{id:`exchange-${e.id}`,className:`exchange-card is-${d} is-${e.state}`,"data-exchange-id":e.id,"data-exchange-state":e.state,"aria-labelledby":h,tabIndex:-1,children:[(0,t.jsxs)("p",{className:"exchange-card-line",children:[(0,t.jsx)("span",{className:"exchange-card-mode",children:(0,a.modeLabel)(e.mode)}),(0,t.jsx)("span",{id:h,className:"exchange-card-title",children:(0,a.participantsLabel)(e)}),(0,t.jsx)("span",{className:"exchange-card-state",role:"status",children:(0,a.liveStateLabel)(e)})]}),(0,t.jsx)("p",{className:"exchange-card-session",children:(0,a.sessionLabel)(e)}),(0,t.jsxs)("p",{className:"exchange-card-instruction",children:[(0,t.jsx)("span",{className:"exchange-card-key",children:(0,a.instructionHeading)(e.mode)})," ",(0,a.excerpt)(e.instruction,220)]}),u?(0,t.jsx)("p",{className:"failed"===e.state?"exchange-card-outcome is-failure":"exchange-card-outcome",children:u}):null,p?(0,t.jsx)("p",{className:"exchange-card-advice",children:p}):null,l?(0,t.jsx)("p",{className:"exchange-card-error",role:"alert",children:l}):null,(0,t.jsxs)("p",{className:"exchange-card-foot",children:[(0,t.jsxs)("span",{className:"exchange-card-time",children:["Updated ",(0,a.formatExchangeTime)(e.updated_at)]}),(0,t.jsx)(s.default,{className:"exchange-card-link",href:(0,a.detailsHref)(e.id),"aria-label":`Details: ${(0,a.modeLabel)(e.mode)} ${(0,a.participantsLabel)(e)}`,children:"Details"}),e.can_cancel?(0,t.jsx)("button",{type:"button",className:"exchange-card-cancel",disabled:o,onClick:()=>{m()},children:o?"Cancelling…":"Cancel"}):null]})]})}])},46986,15366,e=>{"use strict";var t=e.i(43476),n=e.i(71645),s=e.i(96594);e.s(["default",0,function({failure:e}){let[a,i]=(0,n.useState)("idle"),o=(0,s.severityLabel)(e.severity),r=(0,n.useId)();async function l(){try{await navigator.clipboard.writeText(e.detail),i("copied")}catch{i("failed")}}return(0,t.jsxs)("div",{className:`runtime-failure runtime-failure-${e.severity}`,role:"status","aria-labelledby":r,"data-runtime-failure":e.kind,children:[(0,t.jsxs)("p",{className:"runtime-failure-title",id:r,children:[(0,t.jsx)("span",{className:"runtime-failure-severity",children:o}),e.title]}),(0,t.jsx)("p",{className:"runtime-failure-recovery",children:e.recovery}),(0,t.jsxs)("details",{className:"runtime-failure-details",children:[(0,t.jsx)("summary",{children:"Details"}),(0,t.jsx)("code",{className:"runtime-failure-detail",children:e.detail}),(0,t.jsx)("button",{type:"button",className:"runtime-failure-copy",onClick:()=>{l()},children:"copied"===a?"Copied":"failed"===a?"Copy failed":"Copy details"})]})]})}],46986);let a={blocked:"Needs approval",rejected:"Not started",allowed:"Allowed",denied:"Denied",waiting:"Queued",stopped:"Stopped"};e.s(["default",0,function({notice:e,onDone:s}){let[i,o]=(0,n.useState)(!1),[r,l]=(0,n.useState)(""),c="blocked"!==e.tone||e.actionable?a[e.tone]:"Blocked",d=async t=>{if(!i&&e.wakeId){o(!0),l("");try{let n=await fetch(`/api/wakes/${e.wakeId}/decision`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({decision:t})});if(!n.ok){let e=await n.json().catch(()=>null);l("string"==typeof e?.error?.message?e.error.message:"The decision could not be recorded.")}}catch{l("The decision could not be recorded.")}finally{o(!1),s()}}};return(0,t.jsxs)("div",{className:`wake-notice wake-notice-${e.tone}`,role:"status","data-wake-notice":e.tone,"data-wake-id":e.wakeId??void 0,children:[(0,t.jsxs)("p",{className:"wake-notice-line",children:[(0,t.jsx)("span",{className:"wake-notice-label",children:c}),e.text]}),e.actionable?(0,t.jsxs)("div",{className:"wake-notice-actions",children:[(0,t.jsx)("button",{type:"button",className:"approve-control",disabled:i,onClick:()=>{d("allow")},children:"Allow"}),(0,t.jsx)("button",{type:"button",className:"approve-control",style:{marginLeft:8},disabled:i,onClick:()=>{d("deny")},children:"Deny"})]}):null,r?(0,t.jsx)("p",{className:"wake-notice-error",role:"alert",children:r}):null]})}],15366)},33851,44079,52900,68541,e=>{"use strict";var t=e.i(3136);let n="This computer",s={read_only:"Read only",workspace_write:"Workspace write"},a={workspaces:"Selected workspaces",sessions:"Selected imported sessions",all_provider_sessions:"All sessions this runtime can see"};function i(e){return e.startsWith("/")||"~"===e||e.startsWith("~/")}function o(e){return e.length>1?e.replace(/\/+$/,""):e}t.AGENTS.join("|");let r="/api/runtime-connections",l={connection:"Runtime connection",scope:"Session scope",defaultWorkspace:"Default workspace (optional)",policy:"Policy",homeSession:"Home session (optional)"},c={connection:"The runtime installation or account this agent uses. Several agents can share one.",workspaces:"One absolute path per line. An empty scope never means unrestricted.",sessions:"Only this agent’s own Botmancers sessions can be selected.",noSessions:"This Agent has no sessions yet. Choose workspaces or all sessions for now.",allSessions:"Every session this runtime can see. Choose this only on purpose.",defaultWorkspace:"Where new sessions start. Convenience only — not a permission.",resumeEdits:"Needs Workspace write.",homeSession:"A stable session to return to. Must be one of this agent’s sessions.",addConnection:"Stores a name and host only. Credentials stay with the runtime."},d="Loading runtime connections…",u="Couldn't load runtime connections — retry.";function p(){return{status:"loading",connections:[],error:""}}function h(e){return`${e.label} \xb7 ${t.AGENT_LABELS[e.provider]??e.provider}`}function m(e){if("object"!=typeof e||null===e)return null;let t=e.connections;if(!Array.isArray(t))return null;let n=[];for(let e of t){if("object"!=typeof e||null===e||"string"!=typeof e.id||"string"!=typeof e.provider||"string"!=typeof e.label)return null;n.push({id:e.id,provider:e.provider,label:e.label,host:"string"==typeof e.host?e.host:"",agent_count:"number"==typeof e.agent_count?e.agent_count:void 0})}return n}function f(e){let t=[];for(let n of e.split("\n")){let e=n.trim();e&&!t.includes(e)&&t.push(e)}return t}function g(e){return"workspaces"===e.scopeKind?{kind:"workspaces",workspaces:f(e.workspaces)}:"sessions"===e.scopeKind?{kind:"sessions",sessions:e.sessions}:{kind:e.scopeKind}}function k(e){return{mode:e.policyMode,allow_new_sessions:e.allowNewSessions,allow_resume_with_edits:e.allowResumeWithEdits}}e.s(["CONNECTIONS_ENDPOINT",0,r,"CONNECTIONS_ERROR_COPY",0,u,"CONNECTIONS_LOADING_COPY",0,d,"DEFAULT_REGISTRATION_FORM",0,{connectionId:"",scopeKind:"",workspaces:"",sessions:[],defaultWorkspace:"",policyMode:"read_only",allowNewSessions:!0,allowResumeWithEdits:!1,homeSessionId:""},"HINTS",0,c,"LABELS",0,l,"connectionOptionLabel",0,h,"hasRegistrationErrors",0,function(e){return Object.keys(e.errors).length>0},"initialConnectionListState",0,p,"parseConnectionList",0,m,"registrationCreateBody",0,function(e,t){let n={name:String(e??"").trim(),runtime_connection_id:t.connectionId,session_scope:g(t),policy:k(t)},s=t.defaultWorkspace.trim();return s&&(n.default_workspace=s),n},"registrationFormFromBot",0,function(e){let t=e.session_scope??null;return{connectionId:e.runtime_connection_id??"",scopeKind:t?.kind??"",workspaces:t?.kind==="workspaces"?t.workspaces.join("\n"):"",sessions:t?.kind==="sessions"?[...t.sessions]:[],defaultWorkspace:e.default_workspace??"",policyMode:e.policy?.mode??"read_only",allowNewSessions:!e.policy||e.policy.allow_new_sessions,allowResumeWithEdits:!!e.policy&&e.policy.allow_resume_with_edits,homeSessionId:e.home_session_id??""}},"registrationFormView",0,function(e,t){let n={};e.connectionId||(n.connection="Pick a runtime connection.");let s=f(e.workspaces);e.scopeKind?"workspaces"===e.scopeKind?0===s.length?n.workspaces="Add at least one workspace.":s.every(i)||(n.workspaces="Workspaces must be absolute paths (or start with ~/)."):"sessions"===e.scopeKind&&0===e.sessions.length&&(n.sessions="Select at least one session."):n.scope="Choose a session scope.";let a=e.defaultWorkspace.trim();a&&(i(a)?"workspaces"!==e.scopeKind||n.workspaces||s.some(e=>{let t,n;return t=o(e),t===(n=o(a))||n.startsWith("/"===t?"/":`${t}/`)})||(n.defaultWorkspace="The default workspace must be inside one of the selected workspaces."):n.defaultWorkspace="The default workspace must be an absolute path (or start with ~/)."),e.allowResumeWithEdits&&"workspace_write"!==e.policyMode&&(n.policy="Resume with edits needs the Workspace write policy.");let r="",l=!1;return"ready"!==t.status&&(l=!0,r="error"===t.status?u:""),{errors:n,submitDisabled:l,blocker:r}},"registrationPatchBody",0,function(e,t){return{id:e,runtime_connection_id:t.connectionId,session_scope:g(t),default_workspace:t.defaultWorkspace.trim(),policy:k(t),home_session_id:t.homeSessionId}},"registrationReadView",0,function(e,n){var i;let o,r=[{key:"connection",label:l.connection,value:(o=e.runtime_connection)?`${o.label} (${(0,t.agentLabel)(o.provider)} \xb7 ${o.host})`:"Not set"},{key:"scope",label:l.scope,value:function(e,t){if(!e)return"Not set — this agent cannot launch until a scope is chosen.";if("all_provider_sessions"===e.kind)return a.all_provider_sessions;if("workspaces"===e.kind)return`${a.workspaces}: ${e.workspaces.join(", ")}`;let n=e.sessions.map(e=>t?.find(t=>t.ref===e)?.title??e);return`${a.sessions}: ${n.join(", ")}`}(e.session_scope,n)},{key:"defaultWorkspace",label:"Default workspace",value:e.default_workspace||"None"},{key:"policy",label:l.policy,value:(i=e.policy)?[s[i.mode],i.allow_new_sessions?"new sessions allowed":"no new sessions",i.allow_resume_with_edits?"resume with edits allowed":"no resume with edits"].join(" · "):"Not set"}],c=[];return r.push({key:"homeSession",label:"Home session",value:e.home_session_id?n?.find(t=>t.ref===e.home_session_id)?.title??e.home_session_id:"None"}),"connection"===e.launch_blocker?c.push("Choose a runtime connection before this agent can run."):"session_scope"===e.launch_blocker?c.push("Choose a session scope before this agent can run."):"agent"===e.launch_blocker&&c.push("This Agent has an unsupported Agent type."),{rows:r,notices:c}}],33851);var b=e.i(43476),y=e.i(71645),w=e.i(74904);let _={modal:{fieldset:"agent-fieldset reg-fieldset",legend:"field-legend",label:"",picks:"runtime-picks",pick:"runtime-pick",stack:"reg-stack",control:"reg-control",input:"",hint:"runtime-hint",error:"form-error reg-error",button:"runtime-retry",note:"runtime-note"},config:{fieldset:"agent-fieldset reg-fieldset",legend:"block text-sm cfg-muted mt-3 mb-1 p-0",label:"block text-sm cfg-muted mt-3 mb-1",picks:"flex flex-wrap gap-x-4 gap-y-1 text-sm cfg-muted",pick:"text-sm cfg-muted",stack:"flex flex-col gap-1 text-sm cfg-muted",control:"cfg-input text-sm",input:"cfg-input text-sm",hint:"mt-1 text-xs cfg-faint",error:"mt-1 text-sm cfg-error",button:"cfg-link text-sm",note:"text-sm cfg-muted mt-1"}};function x({id:e,message:t,variant:n}){return t?(0,b.jsx)("p",{id:e,className:_[n].error,role:"alert",children:t}):null}function v({idPrefix:e,variant:t,onAdd:s}){let a=_[t],[i,o]=(0,y.useState)(!1),[r,l]=(0,y.useState)(w.AGENT_OPTIONS[0].value),[d,u]=(0,y.useState)(""),[p,h]=(0,y.useState)(""),[m,f]=(0,y.useState)(""),[g,k]=(0,y.useState)(!1),x=async()=>{if(g)return;k(!0),f("");let e=await s({provider:r,label:d,host:p.trim()||n});(k(!1),"string"==typeof e)?f(e):(o(!1),u(""),h(""))};return i?(0,b.jsxs)("div",{id:`${e}-add-connection`,className:"reg-add-connection",role:"group","aria-label":"Add connection",children:[(0,b.jsx)("label",{className:a.label,htmlFor:`${e}-add-provider`,children:"Provider"}),(0,b.jsx)("select",{id:`${e}-add-provider`,className:a.control,value:r,onChange:e=>l(e.target.value),children:w.AGENT_OPTIONS.map(e=>(0,b.jsx)("option",{value:e.value,children:e.label},e.value))}),(0,b.jsx)("label",{className:a.label,htmlFor:`${e}-add-label`,children:"Connection name"}),(0,b.jsx)("input",{id:`${e}-add-label`,type:"text",className:a.input||void 0,value:d,placeholder:"Codex on my laptop",onChange:e=>u(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),x())}}),(0,b.jsx)("label",{className:a.label,htmlFor:`${e}-add-host`,children:"Host"}),(0,b.jsx)("input",{id:`${e}-add-host`,type:"text",className:a.input||void 0,value:p,placeholder:n,"aria-describedby":`${e}-add-hint`,onChange:e=>h(e.target.value)}),(0,b.jsx)("p",{id:`${e}-add-hint`,className:a.hint,children:c.addConnection}),m?(0,b.jsx)("p",{className:a.error,role:"alert",children:m}):null,(0,b.jsxs)("div",{className:"reg-actions",children:[(0,b.jsx)("button",{type:"button",className:a.button,onClick:()=>void x(),disabled:g,children:g?"Adding…":"Add"}),(0,b.jsx)("button",{type:"button",className:a.button,"aria-expanded":"true",onClick:()=>o(!1),children:"Cancel"})]})]}):(0,b.jsx)("button",{type:"button",className:a.button,"aria-expanded":"false","aria-controls":`${e}-add-connection`,onClick:()=>o(!0),children:"Add connection…"})}e.s(["RegistrationFields",0,function({idPrefix:e,variant:t,form:n,onChange:i,view:o,showErrors:r,connections:p,onRetryConnections:m,onAddConnection:f,workspacePlaceholder:g,workspaceHint:k,sessions:y,includeHomeSession:w}){let $=_[t],N=e=>r?o.errors[e]:void 0,j=t=>`${e}-${t}-error`,C=(e,...t)=>[...t,N(e)?j(e):""].filter(Boolean).join(" ")||void 0,S=!!(y&&y.length>0);return(0,b.jsxs)("div",{className:"registration-fields","data-registration":t,children:[(0,b.jsxs)("fieldset",{className:$.fieldset,"data-field":"connection","aria-describedby":C("connection",`${e}-connection-hint`),children:[(0,b.jsx)("legend",{className:$.legend,id:`${e}-connection-legend`,children:l.connection}),"loading"===p.status?(0,b.jsx)("p",{className:$.note,role:"status",children:d}):"error"===p.status?(0,b.jsxs)("p",{className:$.note,role:"status",children:[u," ",(0,b.jsx)("button",{type:"button",className:$.button,onClick:m,children:"Retry"})]}):(0,b.jsxs)("select",{id:`${e}-connection`,className:$.control,"aria-labelledby":`${e}-connection-legend`,"aria-required":"true","aria-invalid":!!N("connection")||void 0,value:n.connectionId,onChange:e=>i({connectionId:e.target.value}),children:[(0,b.jsx)("option",{value:"",disabled:!0,children:"Select a connection…"}),p.connections.map(e=>(0,b.jsx)("option",{value:e.id,children:h(e)},e.id))]}),(0,b.jsx)("p",{id:`${e}-connection-hint`,className:$.hint,children:c.connection}),(0,b.jsx)(x,{id:j("connection"),message:N("connection"),variant:t}),"ready"===p.status?(0,b.jsx)(v,{idPrefix:e,variant:t,onAdd:async e=>{let t=await f(e);return"string"!=typeof t&&i({connectionId:t.id}),t}}):null]}),(0,b.jsxs)("fieldset",{className:$.fieldset,"data-field":"scope",children:[(0,b.jsx)("legend",{className:$.legend,id:`${e}-scope-legend`,children:l.scope}),(0,b.jsx)("div",{className:$.stack,role:"radiogroup","aria-labelledby":`${e}-scope-legend`,"aria-required":"true","aria-describedby":C("scope"),children:["workspaces","sessions","all_provider_sessions"].map(t=>(0,b.jsxs)("label",{className:$.pick,children:[(0,b.jsx)("input",{type:"radio",name:`${e}-scope`,value:t,checked:n.scopeKind===t,disabled:"sessions"===t&&!S,onChange:()=>i({scopeKind:t})})," "+a[t]]},t))}),S?null:(0,b.jsx)("p",{className:$.hint,children:c.noSessions}),(0,b.jsx)(x,{id:j("scope"),message:N("scope"),variant:t}),"workspaces"===n.scopeKind?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("label",{className:$.label,htmlFor:`${e}-workspaces`,children:"Workspaces"}),(0,b.jsx)("textarea",{id:`${e}-workspaces`,className:$.input||void 0,rows:2,value:n.workspaces,placeholder:"/Users/you/work/project","aria-required":"true","aria-invalid":!!N("workspaces")||void 0,"aria-describedby":C("workspaces",`${e}-workspaces-hint`),onChange:e=>i({workspaces:e.target.value})}),(0,b.jsx)("p",{id:`${e}-workspaces-hint`,className:$.hint,children:c.workspaces}),(0,b.jsx)(x,{id:j("workspaces"),message:N("workspaces"),variant:t})]}):null,"sessions"===n.scopeKind&&y?(0,b.jsxs)("div",{className:$.stack,role:"group","aria-label":"Sessions in scope","aria-describedby":C("sessions",`${e}-sessions-hint`),children:[y.map(e=>(0,b.jsxs)("label",{className:$.pick,children:[(0,b.jsx)("input",{type:"checkbox",checked:n.sessions.includes(e.ref),onChange:t=>i({sessions:t.target.checked?[...n.sessions,e.ref]:n.sessions.filter(t=>t!==e.ref)})}),` ${e.title} (${e.status})`]},e.ref)),(0,b.jsx)("p",{id:`${e}-sessions-hint`,className:$.hint,children:c.sessions}),(0,b.jsx)(x,{id:j("sessions"),message:N("sessions"),variant:t})]}):null,"all_provider_sessions"===n.scopeKind?(0,b.jsx)("p",{className:$.hint,children:c.allSessions}):null]}),(0,b.jsxs)("div",{"data-field":"default-workspace",children:[(0,b.jsx)("label",{className:$.label,htmlFor:`${e}-default-workspace`,children:l.defaultWorkspace}),(0,b.jsx)("input",{id:`${e}-default-workspace`,type:"text",className:$.input||void 0,value:n.defaultWorkspace,placeholder:g,"aria-invalid":!!N("defaultWorkspace")||void 0,"aria-describedby":C("defaultWorkspace",`${e}-default-workspace-hint`,`${e}-default-workspace-note`),onChange:e=>i({defaultWorkspace:e.target.value})}),(0,b.jsx)("p",{id:`${e}-default-workspace-hint`,className:$.hint,children:k}),(0,b.jsx)("p",{id:`${e}-default-workspace-note`,className:$.hint,children:c.defaultWorkspace}),(0,b.jsx)(x,{id:j("defaultWorkspace"),message:N("defaultWorkspace"),variant:t})]}),(0,b.jsxs)("fieldset",{className:$.fieldset,"data-field":"policy",children:[(0,b.jsx)("legend",{className:$.legend,id:`${e}-policy-legend`,children:l.policy}),(0,b.jsx)("div",{className:$.picks,role:"radiogroup","aria-labelledby":`${e}-policy-legend`,children:["read_only","workspace_write"].map(t=>(0,b.jsxs)("label",{className:$.pick,children:[(0,b.jsx)("input",{type:"radio",name:`${e}-policy`,value:t,checked:n.policyMode===t,onChange:()=>i("read_only"===t?{policyMode:t,allowResumeWithEdits:!1}:{policyMode:t})})," "+s[t]]},t))}),(0,b.jsxs)("div",{className:$.stack,children:[(0,b.jsxs)("label",{className:$.pick,children:[(0,b.jsx)("input",{type:"checkbox",checked:n.allowNewSessions,onChange:e=>i({allowNewSessions:e.target.checked})})," Allow new sessions"]}),(0,b.jsxs)("label",{className:$.pick,children:[(0,b.jsx)("input",{type:"checkbox",checked:n.allowResumeWithEdits,disabled:"workspace_write"!==n.policyMode,"aria-describedby":`${e}-resume-hint`,onChange:e=>i({allowResumeWithEdits:e.target.checked})})," Allow resume with edits"]}),(0,b.jsx)("p",{id:`${e}-resume-hint`,className:$.hint,children:c.resumeEdits})]}),(0,b.jsx)(x,{id:j("policy"),message:N("policy"),variant:t})]}),w?(0,b.jsxs)("div",{"data-field":"home-session",children:[(0,b.jsx)("label",{className:$.label,htmlFor:`${e}-home-session`,children:l.homeSession}),(0,b.jsxs)("select",{id:`${e}-home-session`,className:$.control,value:n.homeSessionId,"aria-describedby":`${e}-home-session-hint`,onChange:e=>i({homeSessionId:e.target.value}),children:[(0,b.jsx)("option",{value:"",children:"None"}),(y??[]).map(e=>(0,b.jsx)("option",{value:e.ref,children:`${e.title} (${e.status})`},e.ref))]}),(0,b.jsx)("p",{id:`${e}-home-session-hint`,className:$.hint,children:c.homeSession})]}):null]})}],44079),e.s(["useRuntimeConnections",0,function(){let[e,t]=(0,y.useState)(()=>p()),[n,s]=(0,y.useState)(0);return(0,y.useEffect)(()=>{let e=!1;return fetch(r,{cache:"no-store"}).then(async n=>{let s=n.ok?m(await n.json().catch(()=>null)):null;e||t(s?{status:"ready",connections:s,error:""}:{status:"error",connections:[],error:`HTTP ${n.status}`})}).catch(n=>{e||t({status:"error",connections:[],error:n instanceof Error?n.message:String(n)})}),()=>{e=!0}},[n]),{state:e,retry:(0,y.useCallback)(()=>{t(p()),s(e=>e+1)},[]),add:(0,y.useCallback)(async e=>{let n=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await n.json().catch(()=>null);if(!n.ok)return"string"==typeof s?.error?s.error:"Failed to add the connection";let a=m({connections:[s]})?.[0];return a?(t(e=>({status:"ready",connections:[...e.connections,a],error:""})),a):"Failed to add the connection"},[])}}],52900);let $="imported",N=/^[A-Za-z0-9_-]{1,128}$/;function j(e){let t=new URLSearchParams(e).get($);if(null===t)return null;let n=t.trim();return N.test(n)?n:""}function C(e){return`/agents/${encodeURIComponent(e)}/config`}async function S(e,t,n){let s=j(e);if(null===s)return{kind:"none"};if(!s)return{kind:"missing"};if(s===t)return{kind:"stay"};try{return await n(s)?{kind:"open",path:C(s)}:{kind:"missing"}}catch{return{kind:"missing"}}}e.s(["HANDOFF_STATUS_PATH",0,"/api/marketplace-handoff/status","IMPORT_RETURN_QUERY",0,$,"handoffStartPath",0,function(e,t){return`/api/marketplace-handoff?return=${encodeURIComponent(e+t)}`},"importedBotId",0,j,"importedConfigPath",0,C,"marketImportView",0,function(e){switch(e){case"checking":return{busy:!0,tone:"muted",message:"Checking Grok Marketplace…"};case"redirecting":return{busy:!0,tone:"muted",message:"Opening Grok Marketplace…"};case"unavailable":return{busy:!1,tone:"error",message:"Grok Marketplace isn't configured. Set CLONE_MARKET_URL on the Botmancers server."};case"failed":return{busy:!1,tone:"error",message:"Couldn't reach Botmancers to start the import. Try again."};case"missing":return{busy:!1,tone:"error",message:"Imported agent not found. The import may not have completed."};default:return{busy:!1,tone:"muted",message:"Imports a new agent and opens its Config. This agent is not changed."}}},"resolveImportReturn",0,S],68541)},68684,e=>{"use strict";e.s(["draftTitle",0,function(e){return"email"===e?"New Email":"New Slack Message"},"parseApprovalCode",0,function(e){let t=e.match(/approve using the code ([A-Za-z0-9][A-Za-z0-9_-]*)/i);return t?t[1]:null},"parseDraft",0,function(e){let t,n=e.match(/^\s*\[draft\]\s*([\s\S]*)$/);if(!n)return null;try{t=JSON.parse(n[1])}catch{return null}if(!t||"object"!=typeof t)return null;let s=t;return"email"!==s.channel&&"slack"!==s.channel||"open"!==s.state&&"sent"!==s.state&&"discarded"!==s.state||"string"!=typeof s.recipient||"string"!=typeof s.body?null:{channel:s.channel,recipient:s.recipient,body:s.body,state:s.state}},"parseFileNames",0,function(e){let t=[];for(let n of e.split("\n")){let e=n.match(/^\s*\[file\]\s*(\S+)\s*$/i);e&&!t.includes(e[1])&&t.push(e[1])}return t},"parseHandoff",0,function(e){let t=e.match(/^\s*\[Handing off to ([^\]]+)\]/);return t&&t[1].trim()||null}])},50814,63352,e=>{"use strict";function t(e){return`${new Date(e).toISOString().slice(0,16).replace("T"," ")} UTC`}function n(e){return e?e.split("/").filter(e=>e.length>0).pop()??null:null}function s(e,t){let n=function(e){if(!e)return null;let t=e.toLowerCase();return"muse code"===t?"muse":(["codex","claude","cursor","hermes","muse"].includes(t),t)}(t);switch(e){case"provider_unavailable":return n?{reason:`${n} is not installed or did not start`,fix:`Install ${n} and Retry.`}:{reason:"the runtime is not installed or did not start",fix:"Install the runtime and Retry."};case"auth_required":return{reason:"not signed in",fix:"Sign in and Retry."};case"permission_denied":return{reason:"permission denied",fix:"Check permissions and Retry."};case"incompatible_version":return{reason:"incompatible version",fix:"Update the runtime and Retry."};case"usage_limit":return{reason:"usage limit reached",fix:"Wait or upgrade and Retry."};case"scope_missing":return{reason:"no session scope is set",fix:"Choose a scope in Config."};case"provider_failed":return{reason:"the listing failed",fix:"Retry."};default:return{reason:e,fix:"Retry."}}}let a="Not reported";function i(e){return e.toFixed(1).replace(/\.0$/,"")}function o(e){return e.toLocaleString("en-US")}function r(e){return 0===e?"$0.00":e>=.01?`$${e.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`:e<1e-4?"<$0.0001":`$${e.toFixed(4)}`}let l={input_tokens:"Input tokens",output_tokens:"Output tokens",cost_usd:"Cost"};function c(e,t,n){return"cost_usd"===e?r(t):n?o(t):t<1e3?String(t):t<999950?`${i(t/1e3)}k`:t<99995e4?`${i(t/1e6)}M`:`${i(t/1e9)}B`}function d(e){return`${e} ${1===e?"run":"runs"}`}function u(e,t,n=!1){let s=l[e];if(!t||"unavailable"===t.quality||null===t.sum)return{name:s,text:a,quality:"unavailable",coverage:t&&t.total>0?`0 of ${d(t.total)} reported`:"No runs recorded",label:`${s}: not reported`};let i=c(e,t.sum,n),o=c(e,t.sum,!0);return"partial"===t.quality?{name:s,text:i,quality:"partial",coverage:`Partial: ${t.known} of ${d(t.total)} reported`,label:`${s}: at least ${o}, partial, reported by ${t.known} of ${d(t.total)}`}:{name:s,text:i,quality:"complete",coverage:`All ${d(t.total)} reported`,label:`${s}: ${o}, reported by all ${d(t.total)}`}}e.s(["SESSION_FILTER_OPTIONS",0,[{value:"all",label:"All"},{value:"active",label:"Active"},{value:"ended",label:"Ended"}],"attemptLabel",0,function(e){let t="source"===e.role?"Started the session":"Resumed the session";return`${t} \xb7 ${e.outcome??"running"}`},"emptySessionsCopy",0,function(e,t,n,a){if("active"===e)return`${t} has no active sessions.`;if("ended"===e)return`${t} has no ended sessions.`;if(n?.last_error_code){let{reason:e,fix:t}=s(n.last_error_code,a),i=a?`${a} sessions`:"sessions";return`Could not read ${i}: ${e}. ${t}`}if(n&&null===n.synced_at)return`${t} has not synced sessions yet. Refresh to load past sessions.`;let i=n?.out_of_scope_count??0;return i>0?`${i} ${1===i?"session exists":"sessions exist"} outside ${t}'s scope. Widen the scope to see them.`:`${t} has no sessions yet. One appears after a coding run keeps its runtime context.`},"formatSessionDate",0,t,"formatSyncRelativeTime",0,function(e,t=Date.now()){if(null===e)return"never";let n=Math.max(0,t-e);if(n<6e4)return"just now";let s=Math.floor(n/6e4);if(s<60)return`${s} minute${1===s?"":"s"} ago`;let a=Math.floor(s/60);if(a<24)return`${a} hour${1===a?"":"s"} ago`;let i=Math.floor(a/24);return`${i} day${1===i?"":"s"} ago`},"noMatchingSessionsCopy",0,function(e,t){let s=e.trim();if(s)return`No sessions match “${s}”.`;let a=n(t);return a?`No sessions in ${a}.`:"No sessions match the current filters."},"registrationSessionSyncCopy",0,function(e,t){if("failed"===e.outcome){let{reason:n,fix:a}=s(e.error_code??"provider_failed",t);return`Could not read ${t} sessions: ${n}. ${a}`}if("unsupported"===e.outcome)return`Past sessions are not available for ${t}.`;let n=1===e.imported?"session":"sessions",a=`Loaded ${e.imported} ${n}`;return e.rejected_out_of_scope>0&&(a+=`, ${e.rejected_out_of_scope} outside the scope`),e.complete||(a+=", more remain"),`${a}.`},"runtimeLabel",0,function(e){return e.agent.transport?`${e.agent.adapter} \xb7 ${e.agent.transport}`:e.agent.adapter},"sessionConversationHref",0,function(e){return e.thread_agent_id?`/agents/${encodeURIComponent(e.thread_agent_id)}/conversations`:"group"===e.kind?`/threads/${encodeURIComponent(e.id)}`:null},"sessionOriginChips",0,function(e){let t=[],n=e.origin.work_request?.requester;return n?.kind==="person"?t.push("Human origin"):n?.kind==="bot"?t.push(n.name?`${n.name} Agent`:"Agent origin"):n?.kind==="service"&&t.push("Service origin"),e.origin.conversation&&t.push(e.origin.conversation.label),[...new Set(t)]},"sessionStateTags",0,function(e){let t=[];return(e.home&&t.push("Home"),e.state?.availability==="missing")?[...t,"Missing"]:(e.state?.lifecycle==="archived"&&t.push("Archived"),e.state?.busy&&t.push("Busy"),(e.resumable||e.state?.resumable===!0)&&t.push("Resumable"),t)},"sessionUsageLine",0,function(e){let t=u("input_tokens",e?.input_tokens),n=u("output_tokens",e?.output_tokens),s=u("cost_usd",e?.cost_usd),i=[t,n,s];if(i.every(e=>"unavailable"===e.quality))return{text:a,label:"Usage: not reported",quality:"unavailable",partial:!1};let o=["unavailable"===t.quality?"input not reported":`${t.text} in`,"unavailable"===n.quality?"output not reported":`${n.text} out`,"unavailable"===s.quality?"cost not reported":s.text].join(" · "),r=i.some(e=>"partial"===e.quality),l=r||i.some(e=>"unavailable"===e.quality)?"partial":"complete";return{text:o,label:`Reported usage: ${i.map(e=>e.label).join("; ")}`,quality:l,partial:r}},"statusLabel",0,function(e){return"active"===e.status?"Active":"Ended"},"usageMetricView",0,u,"usageSampleLabel",0,function(e,t){let n="turn"===e.kind?"start"===e.turn_kind?"provider turn, started":"provider turn":"resume"===e.turn_kind?"resumed":"started";return`Run ${t+1} \xb7 ${n}`},"usageSampleValues",0,function(e){return{input:null===e.input_tokens?a:o(e.input_tokens),output:null===e.output_tokens?a:o(e.output_tokens),cost:null===e.cost_usd?a:r(e.cost_usd)}},"workRequestLabel",0,function(e){var t;let n=e.origin.work_request;return n?`${(t=n.execution_kind)?t[0].toUpperCase()+t.slice(1):t} \xb7 ${n.state}`:null},"workspaceFolderName",0,n,"workspaceOptions",0,function(e){let t=[...new Set(e.filter(e=>"string"==typeof e&&e.length>0))],s=t.map(e=>n(e)??e);return t.map((e,t)=>({value:e,label:s.filter(e=>e===s[t]).length>1?e:s[t]})).sort((e,t)=>e.label<t.label?-1:+(e.label>t.label))}],63352);let p={ask:"Ask from this context",resume:"Resume work here",handoff:"Hand off to…"},h=["queued","extracting","delivering","completed","failed","cancelled"],m=["completed","failed","cancelled"];function f(e,t){switch(t){case"queued":return"Queued";case"extracting":return"ask"===e?"Asking the session":"Extracting handoff";case"delivering":return"Delivering handoff";case"completed":return"ask"===e?"Answered":"Handed off";case"failed":return"Failed";case"cancelled":return"Cancelled"}}function g(e,t=140){let n=String(e??"").split("\n").map(e=>e.trim()).filter(e=>e.length>0).join(" ");return n.length>t?`${n.slice(0,t-1).trimEnd()}…`:n}function k(e,t){return t.updated_at-e.updated_at||t.created_at-e.created_at||(e.id<t.id?-1:+(e.id>t.id))}e.s(["DEFAULT_LEDGER_FILTER",0,{mode:"all",state:"all",agentId:""},"INSTRUCTION_LIMIT",0,4e3,"MODE_FILTER_OPTIONS",0,[{value:"all",label:"All"},{value:"ask",label:"Ask"},{value:"continue",label:"Continue"}],"STATE_FILTER_OPTIONS",0,[{value:"all",label:"Any status"},{value:"active",label:"In progress"},{value:"queued",label:"Queued"},{value:"extracting",label:"Asking / extracting"},{value:"delivering",label:"Delivering"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"},{value:"cancelled",label:"Cancelled"}],"detailsHref",0,function(e){return`/exchanges?id=${encodeURIComponent(e)}`},"eventLabel",0,function(e,t){let n=e.data??{},s=t.source.agent_name,a=t.destination?.agent_name??"the destination Agent",i="string"==typeof n.hop?n.hop:null;switch(e.type){case"created":return"ask"===t.mode?`You asked ${s}'s session a question`:`You handed ${s}'s session to ${a}`;case"hop_queued":if("deliver"===i)return`Handoff queued for ${a}'s new session`;return"extract"===i?`Handoff extraction queued in ${s}'s session`:`Question queued for ${s}'s session`;case"hop_started":if("deliver"===i)return`${a} started a new session`;return"extract"===i?`${s}'s session started extracting the handoff`:`${s}'s session started answering`;case"state_changed":{let e="string"==typeof n.to&&h.includes(n.to)?n.to:null;return e?`Now ${f(t.mode,e).toLowerCase()}`:"State changed"}case"answer_returned":return`Answer returned to ${t.origin?.label??"the origin thread"}${n.truncated?" (shortened)":""}`;case"packet_extracted":return"Handoff packet extracted";case"packet_rejected":return`Handoff packet refused${"string"==typeof n.reason?`: ${n.reason}`:""}`;case"destination_replied":return`${a} replied in ${t.destination?.conversation?.label??"its thread"}`;case"destination_session_rejected":return`${a}'s session was not new; the handoff stopped`;case"cancel_requested":return"You asked to cancel";case"hop_result_discarded":return"A late result was discarded";default:return e.type.replace(/_/g," ")}},"excerpt",0,g,"exchangeRequestBody",0,function(e,t,n){let s={mode:e.mode,idempotency_key:n,origin_conversation_id:e.originConversationId,source:{agent_id:t.agentId,session_ref:t.sessionRef},instruction:e.instruction.trim()};return"continue"===e.mode&&(s.destination={agent_id:e.destinationAgentId}),s},"failureAdvice",0,function(e){if("failed"!==e.state)return null;switch(e.failure?.code){case"packet_invalid":case"packet_missing":return"The source session did not return a usable handoff. Start a new Continue with a clearer objective.";case"destination_session_invalid":return"The destination did not start a fresh session. Check its runtime, then start a new Continue.";case"destination_turn_failed":return"Check the destination Agent’s runtime, then start a new Continue from the source session.";case"source_turn_failed":return"Check the source Agent’s runtime, then start a new exchange from its Sessions.";default:return"Start a new exchange from the session to try again."}},"formatExchangeTime",0,function(e){return t(e)},"instructionHeading",0,function(e){return"ask"===e?"Question":"Objective"},"ledgerAgents",0,function(e){let t=new Map;for(let n of e)t.set(n.source.agent_id,n.source.agent_name),n.destination&&t.set(n.destination.agent_id,n.destination.agent_name);return[...t.entries()].map(([e,t])=>({id:e,name:t})).sort((e,t)=>e.name.localeCompare(t.name)||e.id.localeCompare(t.id))},"ledgerRows",0,function(e,t){return e.filter(e=>("all"===t.mode||e.mode===t.mode)&&("active"!==t.state||!e.terminal)&&("all"===t.state||"active"===t.state||e.state===t.state)&&(!t.agentId||e.source.agent_id===t.agentId||e.destination?.agent_id===t.agentId)).sort(k)},"ledgerView",0,function(e,t,n){return null===e?t?"error":"loading":0===e.length?"empty":0===n.length?"filtered-out":"rows"},"linkRoleLabel",0,function(e){let t={origin:"Started here",source:"Source session",destination:"Destination"};return e.map(e=>t[e]).join(" · ")},"liveStateLabel",0,function(e){var t;return e.cancel_requested&&(t=e.state,!m.includes(t))?"Cancelling…":f(e.mode,e.state)},"modeLabel",0,function(e){return"ask"===e?"Ask":"Continue"},"outcomeLine",0,function(e){if("completed"===e.state){if("ask"===e.mode){let t=e.origin?.label??"the origin thread";return e.outcome.answer?`Answer in ${t}: ${g(e.outcome.answer,200)}`:`Answered in ${t}.`}let t=e.destination?.agent_name??"The destination Agent";return e.outcome.reply?`${t} picked it up in a new session: ${g(e.outcome.reply,200)}`:`${t} picked it up in a new session.`}return"failed"===e.state?e.failure?.message||"The exchange failed.":"cancelled"===e.state?"Cancelled before it finished. Nothing more will run.":null},"participantsLabel",0,function(e){return"ask"===e.mode?`You → ${e.source.agent_name}`:`${e.source.agent_name} → ${e.destination?.agent_name??"another Agent"}`},"pinRequestBody",0,function(e,t,n,s,a){return{action:e,content:t.trim(),conversation_id:n,idempotency_key:a,..."resume"===e?{approve_write:s}:{}}},"sessionDialogMode",0,function(e){return"handoff"===e?"continue":e},"sessionDialogTitle",0,function(e){return p["continue"===e?"handoff":e]},"sessionDialogUsesPin",0,function(e,t){return"resume"===e||"ask"===e&&"provider"===t},"sessionLabel",0,function(e){return`${e.source.agent_name}'s session “${e.source.session_title}”`},"sessionRowActions",0,function(e){let t;if(e.actions)t=e.actions;else{let n="ended"===e.status?{available:!1,reason:"Ask from this context and Hand off to… are unavailable: this session has ended. Its history stays here."}:e.resumable?{available:!0}:{available:!1,reason:`Ask from this context and Hand off to… are unavailable: Botmancers can’t resume this session under ${e.agent.name}’s current runtime.`},s=n.available?{available:!0}:{available:!1,code:"ended"===e.status?"session_ended":"session_not_resumable",reason:n.reason,recovery:"choose_session"};t={ask:s,resume:{available:!1,code:"action_unavailable",reason:`${p.resume} is unavailable: this runtime can’t resume a session with edits.`,recovery:"choose_action"},handoff:s}}return["ask","resume","handoff"].map(e=>({action:e,label:p[e],availability:t[e]}))},"stateTone",0,function(e){return"completed"===e?"done":"failed"===e||"cancelled"===e?"stopped":"active"},"submitErrorMessage",0,function(e,t){switch(e){case"session_ended":return"This session has ended and can’t be resumed.";case"session_not_resumable":return"Botmancers can’t resume this session under the agent’s current runtime.";case"source_session_busy":return"This session already has an exchange in progress. Wait for it or cancel it from its card.";case"agent_unavailable":return t||"That Agent can’t launch yet. Choose its runtime connection and session scope in Config.";case"idempotency_conflict":return"This request changed while it was being sent. Send again.";case"session_missing":return"The runtime no longer has this session. Its history stays here; choose another session.";case"approval_required":return"Resume work here needs your approval of edits. Tick the approval, then send again.";case"authority_not_allowed":return t||"This agent’s policy doesn’t allow edits in a resumed session. Change it in Config.";case"action_unavailable":return t||"This runtime can’t do that in this session. Choose another action.";case"provider_failed":return"The runtime failed this turn. Nothing moved to another session; try again later.";default:return t||"The exchange could not be started. Your draft is kept; try again."}},"threadHref",0,function(e,t){let n=new URLSearchParams;if(e.thread_agent_id){t&&n.set("exchange",t);let s=n.toString();return`/agents/${encodeURIComponent(e.thread_agent_id)}/conversations/${encodeURIComponent(e.id)}${s?`?${s}`:""}`}if("group"!==e.kind)return null;t&&n.set("exchange",t);let s=n.toString();return`/threads/${encodeURIComponent(e.id)}${s?`?${s}`:""}`},"validateDraft",0,function(e){let t={},n=e.instruction.trim(),s="ask"===e.mode?"a question":"an objective";return n?e.instruction.length>4e3&&(t.instruction="Keep it under 4000 characters."):t.instruction=`Enter ${s}.`,e.originConversationId||(t.origin="Choose the thread that follows this exchange."),"continue"!==e.mode||e.destinationAgentId||(t.destination="Choose the agent who continues the work."),t},"validateResumeDraft",0,function(e,t){let n={};return e.trim()?e.length>4e3&&(n.instruction="Keep it under 4000 characters."):n.instruction="Enter what to work on.",t||(n.approval="Approve edits in this session to resume work here."),n}],50814)},71836,e=>{"use strict";e.s(["DIALOG_FOCUSABLE",0,'a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])',"newAgentDialogPlacement",0,function(e,t){let n=Math.min(358,t.width-32),s=Math.max(16,t.width-16-n),a=16,i=16;if(e){i=Math.min(Math.max(e.left,16),s);let n=e.bottom+8;t.height-n-16>=360&&(a=n)}return{top:a,left:i,maxHeight:Math.max(0,t.height-a-16)}},"wrapFocusTarget",0,function(e,t,n){if(0===e.length)return null;let s=e[0],a=e[e.length-1],i=null!==t&&e.includes(t);return n?i&&t!==s?null:a:i&&t!==a?null:s}])},54423,e=>{"use strict";e.s(["wakeNotices",0,function(e){let t=[],n=new Map;return e.forEach((s,a)=>{let i="string"==typeof s.data.target_name?s.data.target_name:null;s.requestId&&i&&n.set(s.requestId,i);let o=function(e){switch(e.kind){case"wake_blocked":return"blocked";case"wake_rejected":return"rejected";case"lineage_stopped":return"stopped";case"wake_accepted":return"string"==typeof e.data.reason?"allowed":null;case"request_cancelled":return"grant_denied"===e.data.reason?"denied":null;case"request_queued":return"capacity"===e.data.waiting_for?"waiting":null;default:return null}}(s);if(!o)return;let r=Array.isArray(s.data.actions)?s.data.actions:[],l=null!==s.requestId&&e.slice(a+1).some(e=>e.requestId===s.requestId);if("waiting"===o&&l)return;let c=s.requestId?n.get(s.requestId):void 0,d="denied"===o&&c?`Wake denied: ${c} — no work ran`:"waiting"===o&&c?`Queued: ${c} — waiting for capacity`:s.text;t.push({eventId:s.eventId,wakeId:s.wakeId,tone:o,text:d,actionable:"blocked"===o&&!!s.wakeId&&r.includes("allow")&&r.includes("deny")&&!l,createdAt:s.createdAt})}),t}])}]);