bazilion 0.12.2 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/README.md +2 -2
  2. package/dist/cli.js +795 -240
  3. package/dist/cli.js.map +1 -1
  4. package/dist/daemon.js +4532 -1277
  5. package/dist/daemon.js.map +1 -1
  6. package/dist/migrations/0001_init.sql +21 -0
  7. package/dist/web/client/assets/{ProductionTeamPolicyEditor-CsWpTsy6.js → ProductionTeamPolicyEditor-DdpYInwV.js} +1 -1
  8. package/dist/web/client/assets/{ProfileCommunicationEditor-C43HvUe-.js → ProfileCommunicationEditor-BcSf2Hao.js} +1 -1
  9. package/dist/web/client/assets/{TeamTabs-DvqWieCq.js → TeamTabs-Bk89JfN7.js} +1 -1
  10. package/dist/web/client/assets/{TemplatesTabs-6Jd_xQj7.js → TemplatesTabs-CyDVzrOl.js} +1 -1
  11. package/dist/web/client/assets/{_id-BrA4Crh_.js → _id-CAJTTnee.js} +1 -1
  12. package/dist/web/client/assets/{_id-BUuz7Drv.js → _id-CN6jPaBu.js} +1 -1
  13. package/dist/web/client/assets/{_id-BegmVRmT.js → _id-DGwJqqDc.js} +1 -1
  14. package/dist/web/client/assets/{_id-AOAT0H_5.js → _id-DWTMH7Eb.js} +1 -1
  15. package/dist/web/client/assets/{activity-n0Fw9_w3.js → activity-DK_M0-bn.js} +1 -1
  16. package/dist/web/client/assets/{agents-C50pdxp7.js → agents-B-i5pASm.js} +1 -1
  17. package/dist/web/client/assets/{agents-B33VQtbl.js → agents-n8U7qNxw.js} +1 -1
  18. package/dist/web/client/assets/{approvals-DVW0hX8h.js → approvals-CmVxCy0Z.js} +1 -1
  19. package/dist/web/client/assets/{attention-B2490jcN.js → attention-F0lUQCWE.js} +1 -1
  20. package/dist/web/client/assets/chevron-down-OndG7r1U.js +1 -0
  21. package/dist/web/client/assets/config-DuApZ9xS.js +3 -0
  22. package/dist/web/client/assets/{context-DcFzsfZ3.js → context-C1sMnW6K.js} +1 -1
  23. package/dist/web/client/assets/dm-sans-latin-400-normal-BwCSEQnW.woff +0 -0
  24. package/dist/web/client/assets/dm-sans-latin-400-normal-CW0RaeGs.woff2 +0 -0
  25. package/dist/web/client/assets/dm-sans-latin-500-normal-B9HHJjqV.woff2 +0 -0
  26. package/dist/web/client/assets/dm-sans-latin-500-normal-Dr3UlScf.woff +0 -0
  27. package/dist/web/client/assets/dm-sans-latin-600-normal-Aqo67rzb.woff2 +0 -0
  28. package/dist/web/client/assets/dm-sans-latin-600-normal-BmdmIIQ2.woff +0 -0
  29. package/dist/web/client/assets/dm-sans-latin-700-normal-CUSSCpQX.woff +0 -0
  30. package/dist/web/client/assets/dm-sans-latin-700-normal-DvUfVpUG.woff2 +0 -0
  31. package/dist/web/client/assets/dm-serif-display-latin-400-normal-C5_t9oOD.woff2 +0 -0
  32. package/dist/web/client/assets/dm-serif-display-latin-400-normal-_kVFYEpx.woff +0 -0
  33. package/dist/web/client/assets/{inbox-Bn1GbUsJ.js → inbox-D2NypLee.js} +1 -1
  34. package/dist/web/client/assets/{index-3nrK5iFr.js → index-B3vdrEEg.js} +4 -4
  35. package/dist/web/client/assets/index-Cofc7zhl.css +1 -0
  36. package/dist/web/client/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
  37. package/dist/web/client/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
  38. package/dist/web/client/assets/jetbrains-mono-latin-500-normal-BWZEU5yA.woff2 +0 -0
  39. package/dist/web/client/assets/jetbrains-mono-latin-500-normal-CJOVTJB7.woff +0 -0
  40. package/dist/web/client/assets/{learning-BUX1MFu2.js → learning-zYDCfVxT.js} +1 -1
  41. package/dist/web/client/assets/{login-CMWpGDKv.js → login-B1Un51Zx.js} +1 -1
  42. package/dist/web/client/assets/{mcp-lZV08dqc.js → mcp-DSVmJBdv.js} +1 -1
  43. package/dist/web/client/assets/{members-DAeaY2Cy.js → members-Pl7hXJcN.js} +1 -1
  44. package/dist/web/client/assets/{memory-HmMWxxdF.js → memory-Co3BEaAq.js} +1 -1
  45. package/dist/web/client/assets/plus-Dor-_wmL.js +1 -0
  46. package/dist/web/client/assets/{policy-DaijITy7.js → policy-CHM95pMU.js} +1 -1
  47. package/dist/web/client/assets/{routes-BNk270AM.js → routes-D29qjwG0.js} +1 -1
  48. package/dist/web/client/assets/{services-DtrpJrdo.js → services-CCQ_6YWQ.js} +1 -1
  49. package/dist/web/client/assets/{skills-Cv93A3P3.js → skills-3xAIvzvP.js} +1 -1
  50. package/dist/web/client/assets/styles-D6RPN7RK.css +2 -0
  51. package/dist/web/client/assets/{teams-D92R9Pb7.js → teams-Dm_huGxn.js} +1 -1
  52. package/dist/web/client/assets/{teams-CCFnSNKi.js → teams-UGLyjHYj.js} +1 -1
  53. package/dist/web/client/assets/telegram-3KvrJVO6.js +1 -0
  54. package/dist/web/client/assets/tokens-DUSFmV5_.js +1 -0
  55. package/dist/web/client/assets/{triggers-NT24i4hZ.js → triggers-DlQ2KF1h.js} +1 -1
  56. package/dist/web/client/assets/{welcome-D0cy68eZ.js → welcome-DkP8qzK1.js} +1 -1
  57. package/dist/web/server/assets/{_id-CwyGjJeP.js → _id-BENqNBfK.js} +4 -4
  58. package/dist/web/server/assets/{_id-D3Ap7zZA.js → _id-BFELaMIN.js} +1 -1
  59. package/dist/web/server/assets/{_id-LrvXU4Nr.js → _id-BQ2zoMiR.js} +1 -1
  60. package/dist/web/server/assets/{_id-D27T85mU.js → _id-BZWunvy7.js} +4 -4
  61. package/dist/web/server/assets/{_id-BHYLL8M-.js → _id-BreRHYV2.js} +1 -1
  62. package/dist/web/server/assets/{_id-C3HY4lWg.js → _id-CPIXIqyO.js} +1 -1
  63. package/dist/web/server/assets/{_id-FcHdSocl.js → _id-CvYqVJPU.js} +4 -4
  64. package/dist/web/server/assets/{_id-DinTp_7X.js → _id-DkrNqqTw.js} +3 -3
  65. package/dist/web/server/assets/{_id-IzadFZV9.js → _id-DvlDkk04.js} +4 -4
  66. package/dist/web/server/assets/{_id-BhOB8Umi.js → _id-DxCnEFpm.js} +4 -4
  67. package/dist/web/server/assets/{_id-tB47Vsfp.js → _id-HMy7jM3P.js} +3 -3
  68. package/dist/web/server/assets/{_id-Dj1yZ3zJ.js → _id-xTD_6ApX.js} +4 -4
  69. package/dist/web/server/assets/{_tanstack-start-manifest_v-BGDBdnUs.js → _tanstack-start-manifest_v-COkJjXt_.js} +57 -56
  70. package/dist/web/server/assets/{activity-DohitgwW.js → activity-9VP6QDTH.js} +3 -3
  71. package/dist/web/server/assets/{activity-BCI4mfNS.js → activity-B6N1T_5N.js} +1 -1
  72. package/dist/web/server/assets/{activity-D9SMqBhy.js → activity-BazZNfvf.js} +3 -3
  73. package/dist/web/server/assets/{agents-BY74v7fM.js → agents-BJAv919x.js} +3 -3
  74. package/dist/web/server/assets/{agents-C9xlWK0Z.js → agents-BpSeOA30.js} +4 -4
  75. package/dist/web/server/assets/{agents-BvttypqB.js → agents-DY630p6x.js} +3 -3
  76. package/dist/web/server/assets/{agents-DZuFEj0D.js → agents-DfoLnTyD.js} +1 -1
  77. package/dist/web/server/assets/{agents-BPKOshR5.js → agents-DjyQk94u.js} +4 -4
  78. package/dist/web/server/assets/{agents-CgZMHj80.js → agents-wSYNPuyK.js} +1 -1
  79. package/dist/web/server/assets/{approvals-DCaVw1Mz.js → approvals-BYajNOdE.js} +1 -1
  80. package/dist/web/server/assets/{approvals-BGU-XGIO.js → approvals-BYi84gwl.js} +3 -3
  81. package/dist/web/server/assets/{approvals-CWcFHlor.js → approvals-BkUGmYU9.js} +3 -3
  82. package/dist/web/server/assets/{attention-BxkTf337.js → attention-Bw_wiiqI.js} +3 -3
  83. package/dist/web/server/assets/{attention-CM-Ks1N9.js → attention-UhqPK_Ro.js} +3 -3
  84. package/dist/web/server/assets/{attention-w21GQIGH.js → attention-Z3bGuxOD.js} +1 -1
  85. package/dist/web/server/assets/{auth-byfSx6Ja.js → auth-7BHTH-KS.js} +5 -5
  86. package/dist/web/server/assets/{config-BDCJdtj2.js → config-BMiajTZP.js} +10 -5
  87. package/dist/web/server/assets/{config-BmixCpz-.js → config-DGzM28F_.js} +197 -15
  88. package/dist/web/server/assets/{config-1w2GiJUn.js → config-wYtIhkRm.js} +3 -3
  89. package/dist/web/server/assets/context-BkDDwbby.js +12 -0
  90. package/dist/web/server/assets/context-DMc0KyHh.js +12 -0
  91. package/dist/web/server/assets/{context-DrkrIWun.js → context-poimKI7w.js} +1 -1
  92. package/dist/web/server/assets/{createServerRpc-pU-IQV2Y.js → createServerRpc-B7Yr1K8i.js} +1 -1
  93. package/dist/web/server/assets/{createSsrRpc-DFsIAfFd.js → createSsrRpc-6LHNEsSK.js} +1 -1
  94. package/dist/web/server/assets/{daemon-client-2NRMzlTr.js → daemon-client-CI5NHwNC.js} +16 -4
  95. package/dist/web/server/assets/{inbox-ZvDNAjaM.js → inbox-0iiSg-Y1.js} +4 -4
  96. package/dist/web/server/assets/{inbox-BLUzA5sQ.js → inbox-DTTfSuGU.js} +1 -1
  97. package/dist/web/server/assets/{inbox-CzlKT9Wg.js → inbox-Dv55rGYq.js} +4 -4
  98. package/dist/web/server/assets/{learning-8zav4pIT.js → learning-C2upa1CE.js} +4 -4
  99. package/dist/web/server/assets/{learning-B7PBkvER.js → learning-DpyLNVe8.js} +4 -4
  100. package/dist/web/server/assets/{learning-Cq7K2heb.js → learning-fG8316uc.js} +1 -1
  101. package/dist/web/server/assets/{login-Bx5LEyGP.js → login-CrFVVUaE.js} +1 -1
  102. package/dist/web/server/assets/{login-CmWvxfTK.js → login-D_GDeTrB.js} +7 -7
  103. package/dist/web/server/assets/{mcp-DIWTogHM.js → mcp-BQtp2T87.js} +3 -3
  104. package/dist/web/server/assets/{mcp-2pwT9HU8.js → mcp-BvnvlVFd.js} +3 -3
  105. package/dist/web/server/assets/{mcp-BJjLIdP0.js → mcp-DlgXUcAS.js} +1 -1
  106. package/dist/web/server/assets/members-BP3UTqu1.js +12 -0
  107. package/dist/web/server/assets/{members-CCv17cjQ.js → members-CteHKPSF.js} +1 -1
  108. package/dist/web/server/assets/members-DXu2oAS_.js +12 -0
  109. package/dist/web/server/assets/{memory-Dngc13Nw.js → memory-BqV-Afy1.js} +4 -4
  110. package/dist/web/server/assets/{memory-a8Kz57Kh.js → memory-C6fX_FKI.js} +1 -1
  111. package/dist/web/server/assets/{memory-pZ4pZT7p.js → memory-Iq2M0-Yc.js} +4 -4
  112. package/dist/web/server/assets/{policy-Bb-vEgqg.js → policy-18fdTFO4.js} +3 -3
  113. package/dist/web/server/assets/{policy-BcGELcc9.js → policy-Bg6u-rTq.js} +1 -1
  114. package/dist/web/server/assets/{policy-C30AeFIb.js → policy-D7kj3Cy7.js} +3 -3
  115. package/dist/web/server/assets/public-origin-xV0lm0Ty.js +25 -0
  116. package/dist/web/server/assets/{router-CIVjTgNp.js → router-D-6TzLRZ.js} +167 -64
  117. package/dist/web/server/assets/{routes-BrA-U_Hm.js → routes-CNRzy79H.js} +4 -4
  118. package/dist/web/server/assets/{routes-B6cMLIPk.js → routes-CiPfEldd.js} +1 -1
  119. package/dist/web/server/assets/{routes-C19CMLZt.js → routes-D933ngZS.js} +4 -4
  120. package/dist/web/server/assets/{services-B9yBWDX0.js → services-DJRA1A0-.js} +1 -1
  121. package/dist/web/server/assets/{services-wG8I06oS.js → services-DozuJtzX.js} +3 -3
  122. package/dist/web/server/assets/{services-C4szdhPx.js → services-OB4LAr2A.js} +3 -3
  123. package/dist/web/server/assets/{skills-BZdqiDig.js → skills-Babb9jsQ.js} +1 -1
  124. package/dist/web/server/assets/{skills-C-UgkuCW.js → skills-D5DQL8bM.js} +3 -3
  125. package/dist/web/server/assets/{skills-a9VSWHWq.js → skills-DfGSJTCB.js} +3 -3
  126. package/dist/web/server/assets/start-uKQNK6if.js +70 -0
  127. package/dist/web/server/assets/{teams-CpQ0YgWf.js → teams-Bk6ZT0MD.js} +1 -1
  128. package/dist/web/server/assets/{teams-jBtvnk59.js → teams-Cc2Czynq.js} +1 -1
  129. package/dist/web/server/assets/{teams-DqfrEoH6.js → teams-DPnAX4wD.js} +4 -4
  130. package/dist/web/server/assets/{teams-DEpQR2QA.js → teams-DqC4wZxu.js} +3 -3
  131. package/dist/web/server/assets/{teams-OIkHuxy1.js → teams-Dz6ZEMRo.js} +3 -3
  132. package/dist/web/server/assets/{teams-MjqgsmC3.js → teams-be05ci17.js} +3 -3
  133. package/dist/web/server/assets/{telegram-DNgCWebD.js → telegram-1AWL6lFw.js} +3 -3
  134. package/dist/web/server/assets/{telegram-CBF8SJzB.js → telegram-DUbDIVGX.js} +122 -3
  135. package/dist/web/server/assets/{telegram-XwyKSEtj.js → telegram-J4T0XhwQ.js} +3 -3
  136. package/dist/web/server/assets/{tokens-yyTSfBSN.js → tokens-CJM_0NDa.js} +126 -22
  137. package/dist/web/server/assets/{tokens-BnwFbV7T.js → tokens-DO5BzNOn.js} +4 -4
  138. package/dist/web/server/assets/tokens-DjM8GsgS.js +19 -0
  139. package/dist/web/server/assets/{triggers-CSNNzRIi.js → triggers-B87fycBl.js} +1 -1
  140. package/dist/web/server/assets/{triggers-BZPl5CHs.js → triggers-BdBx-HwR.js} +4 -4
  141. package/dist/web/server/assets/{triggers-D79NoSXk.js → triggers-Nezfw-Bd.js} +4 -4
  142. package/dist/web/server/server.js +30 -30
  143. package/dist/web-server.js +4 -0
  144. package/dist/web-server.js.map +1 -1
  145. package/dist/worker.js +1744 -362
  146. package/dist/worker.js.map +1 -1
  147. package/package.json +7 -6
  148. package/dist/web/client/assets/chevron-down-B0aNNOyn.js +0 -1
  149. package/dist/web/client/assets/config-CMMxxeX2.js +0 -3
  150. package/dist/web/client/assets/plus-CPzRJg1V.js +0 -1
  151. package/dist/web/client/assets/styles-DMltY3su.css +0 -2
  152. package/dist/web/client/assets/telegram-BF1vdgDB.js +0 -1
  153. package/dist/web/client/assets/tokens-BXj6hWW-.js +0 -1
  154. package/dist/web/server/assets/context-B-XDf6Ym.js +0 -12
  155. package/dist/web/server/assets/context-BXGo5Vfi.js +0 -12
  156. package/dist/web/server/assets/members-CW5aBe81.js +0 -12
  157. package/dist/web/server/assets/members-VdPwD6CE.js +0 -12
  158. package/dist/web/server/assets/start-WH8WzTL_.js +0 -4
  159. package/dist/web/server/assets/tokens-DPDMSN5O.js +0 -12
@@ -0,0 +1 @@
1
+ @font-face{font-family:DM Sans;font-style:normal;font-display:swap;font-weight:400;src:url(/assets/dm-sans-latin-400-normal-CW0RaeGs.woff2)format("woff2"),url(/assets/dm-sans-latin-400-normal-BwCSEQnW.woff)format("woff")}@font-face{font-family:DM Sans;font-style:normal;font-display:swap;font-weight:500;src:url(/assets/dm-sans-latin-500-normal-B9HHJjqV.woff2)format("woff2"),url(/assets/dm-sans-latin-500-normal-Dr3UlScf.woff)format("woff")}@font-face{font-family:DM Sans;font-style:normal;font-display:swap;font-weight:600;src:url(/assets/dm-sans-latin-600-normal-Aqo67rzb.woff2)format("woff2"),url(/assets/dm-sans-latin-600-normal-BmdmIIQ2.woff)format("woff")}@font-face{font-family:DM Sans;font-style:normal;font-display:swap;font-weight:700;src:url(/assets/dm-sans-latin-700-normal-DvUfVpUG.woff2)format("woff2"),url(/assets/dm-sans-latin-700-normal-CUSSCpQX.woff)format("woff")}@font-face{font-family:DM Serif Display;font-style:normal;font-display:swap;font-weight:400;src:url(/assets/dm-serif-display-latin-400-normal-C5_t9oOD.woff2)format("woff2"),url(/assets/dm-serif-display-latin-400-normal-_kVFYEpx.woff)format("woff")}@font-face{font-family:JetBrains Mono;font-style:normal;font-display:swap;font-weight:400;src:url(/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2)format("woff2"),url(/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff)format("woff")}@font-face{font-family:JetBrains Mono;font-style:normal;font-display:swap;font-weight:500;src:url(/assets/jetbrains-mono-latin-500-normal-BWZEU5yA.woff2)format("woff2"),url(/assets/jetbrains-mono-latin-500-normal-CJOVTJB7.woff)format("woff")}
@@ -1 +1 @@
1
- import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{d as r}from"./preload-helper-mNuBjNXU.js";import{i}from"./index-3nrK5iFr.js";import{r as a}from"./Page-CwNuDhWz.js";import{t as o}from"./AgentTabs-R6gSjIj3.js";import{t as s}from"./Button-ByiV6fpd.js";var c=e(n()),l=t();function u(){let{resolved:e,config:t,reviews:n,proposals:u}=i.useLoaderData(),p=r(),[m,h]=(0,c.useState)(null),[g,_]=(0,c.useState)(!1);async function v(e,t,n){h(null),_(!0);try{let r=await fetch(e,{method:t,headers:n===void 0?void 0:{"content-type":`application/json`},body:n===void 0?void 0:JSON.stringify(n)});if(!r.ok){let e=await r.json().catch(()=>null);throw Error(e?.error??`request failed (${r.status})`)}await p.invalidate()}catch(e){h(e instanceof Error?e.message:String(e))}finally{_(!1)}}let y=encodeURIComponent(e.agent.id);return(0,l.jsxs)(a,{children:[(0,l.jsx)(`header`,{className:`mb-6`,children:(0,l.jsx)(`h1`,{children:e.agent.name})}),(0,l.jsx)(o,{agentId:e.agent.id,active:`learning`,archived:e.agent.status===`archived`}),m&&(0,l.jsxs)(`p`,{className:`mb-4 rounded border border-red-300 bg-red-50 p-3 text-sm text-red-800`,children:[m,`. Refresh before retrying if another operator changed this proposal.`]}),(0,l.jsxs)(`section`,{className:`mb-8 rounded-lg border bg-card p-5`,children:[(0,l.jsx)(`h2`,{className:`mb-2 text-xl`,children:`Reviewed learning`}),(0,l.jsxs)(`p`,{className:`mb-4 text-sm text-muted-foreground`,children:[`Reviews inspect at most 8 successful user turns and 40,000 characters. They use `,t.model??`the Agent model`,` at `,t.reasoningLevel,` reasoning, propose at most five lessons, and never apply anything without your approval.`]}),(0,l.jsx)(d,{agentId:e.agent.id,config:t,disabled:g,onError:h,onSaved:()=>p.invalidate()}),(0,l.jsxs)(`div`,{className:`mt-4 flex items-center gap-3`,children:[(0,l.jsx)(s,{variant:`primary`,disabled:g||e.agent.status===`archived`,onClick:()=>v(`/api/agents/${y}/reviews`,`POST`),children:`Review now`}),!t.enabled&&(0,l.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Periodic review is disabled; manual review remains available.`})]})]}),(0,l.jsx)(`h2`,{className:`mb-3 text-xl`,children:`Lesson proposals`}),u.length===0?(0,l.jsx)(`p`,{className:`mb-8 text-muted-foreground`,children:`No proposals yet. A successful review may also produce zero proposals.`}):(0,l.jsx)(`div`,{className:`mb-8 grid gap-3`,children:u.map(t=>(0,l.jsx)(f,{proposal:t,agentId:e.agent.id,busy:g,act:v},t.id))}),(0,l.jsx)(`h2`,{className:`mb-3 text-xl`,children:`Review history`}),n.length===0?(0,l.jsx)(`p`,{className:`text-muted-foreground`,children:`No reviews have been queued.`}):(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{children:`created`}),(0,l.jsx)(`th`,{children:`trigger`}),(0,l.jsx)(`th`,{children:`status`}),(0,l.jsx)(`th`,{children:`turns`}),(0,l.jsx)(`th`,{children:`proposals`}),(0,l.jsx)(`th`,{children:`diagnostic`})]})}),(0,l.jsx)(`tbody`,{children:n.map(e=>(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{children:new Date(e.createdAt).toLocaleString()}),(0,l.jsx)(`td`,{children:e.trigger}),(0,l.jsx)(`td`,{children:(0,l.jsx)(`code`,{children:e.status})}),(0,l.jsx)(`td`,{children:e.turnsReviewed}),(0,l.jsx)(`td`,{children:e.proposalCount}),(0,l.jsx)(`td`,{children:e.lastError??`—`})]},e.id))})]})})]})}function d({agentId:e,config:t,disabled:n,onError:r,onSaved:i}){let[a,o]=(0,c.useState)(t.enabled),[u,d]=(0,c.useState)(t.everyNTurns),[f,p]=(0,c.useState)(t.model??``),[m,h]=(0,c.useState)(t.reasoningLevel);async function g(t){t.preventDefault(),r(null);let n=await fetch(`/api/agents/${encodeURIComponent(e)}/review-config`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({enabled:a,everyNTurns:u,model:f.trim()||null,reasoningLevel:m})});if(!n.ok){r((await n.json().catch(()=>null))?.error??`request failed (${n.status})`);return}i()}return(0,l.jsxs)(`form`,{onSubmit:g,className:`grid gap-3 md:grid-cols-4`,children:[(0,l.jsxs)(`label`,{className:`text-sm`,children:[(0,l.jsx)(`span`,{className:`block mb-1`,children:`Periodic review`}),(0,l.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked)}),` enabled`]}),(0,l.jsxs)(`label`,{className:`text-sm`,children:[(0,l.jsx)(`span`,{className:`block mb-1`,children:`Every turns`}),(0,l.jsx)(`input`,{type:`number`,min:1,max:100,value:u,onChange:e=>d(Number(e.target.value))})]}),(0,l.jsxs)(`label`,{className:`text-sm`,children:[(0,l.jsx)(`span`,{className:`block mb-1`,children:`Model override`}),(0,l.jsx)(`input`,{value:f,placeholder:`agent model`,onChange:e=>p(e.target.value)})]}),(0,l.jsxs)(`label`,{className:`text-sm`,children:[(0,l.jsx)(`span`,{className:`block mb-1`,children:`Reasoning`}),(0,l.jsxs)(`select`,{value:m,onChange:e=>h(e.target.value),children:[(0,l.jsx)(`option`,{children:`off`}),(0,l.jsx)(`option`,{children:`minimal`}),(0,l.jsx)(`option`,{children:`low`}),(0,l.jsx)(`option`,{children:`medium`}),(0,l.jsx)(`option`,{children:`high`}),(0,l.jsx)(`option`,{children:`xhigh`})]})]}),(0,l.jsx)(`div`,{children:(0,l.jsx)(s,{variant:`primary`,type:`submit`,disabled:n,children:`Save learning settings`})})]})}function f({proposal:e,agentId:t,busy:n,act:r}){let[i,a]=(0,c.useState)(e.text),[o,u]=(0,c.useState)(e.scope),d=`/api/agents/${encodeURIComponent(t)}/lesson-proposals/${encodeURIComponent(e.id)}`;return(0,l.jsxs)(`article`,{className:`rounded-lg border bg-card p-4`,children:[(0,l.jsxs)(`div`,{className:`mb-2 flex justify-between gap-2`,children:[(0,l.jsx)(`code`,{children:e.status}),(0,l.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`v`,e.version]})]}),e.status===`pending`?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`textarea`,{className:`w-full`,rows:3,value:i,onChange:e=>a(e.target.value)}),(0,l.jsxs)(`select`,{className:`mt-2`,value:o,onChange:e=>u(e.target.value),children:[(0,l.jsx)(`option`,{value:`private`,children:`private Agent behavior`}),(0,l.jsx)(`option`,{value:`shared`,children:`shared Team knowledge`})]}),(0,l.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,l.jsx)(s,{variant:`ghost`,disabled:n,onClick:()=>r(d,`PATCH`,{version:e.version,text:i,scope:o}),children:`Save edit`}),(0,l.jsx)(s,{variant:`primary`,disabled:n,onClick:()=>r(`${d}/approve`,`POST`,{version:e.version}),children:`Approve`}),(0,l.jsx)(s,{variant:`danger`,disabled:n,onClick:()=>r(`${d}/reject`,`POST`,{version:e.version}),children:`Reject`})]})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`p`,{children:e.text}),e.status===`approved`&&(0,l.jsx)(`div`,{className:`mt-3`,children:(0,l.jsx)(s,{variant:`danger`,disabled:n,onClick:()=>r(`${d}/revoke`,`POST`,{version:e.version}),children:`Revoke`})})]}),(0,l.jsxs)(`div`,{className:`mt-3 text-xs text-muted-foreground`,children:[`Evidence: `,e.evidence.length===0?`none`:(0,l.jsx)(`ul`,{className:`mt-1 list-disc pl-5`,children:e.evidence.map(e=>(0,l.jsxs)(`li`,{children:[(0,l.jsxs)(`code`,{children:[e.sessionId,`:`,e.entryOrdinal]}),e.excerpt?` — ${e.excerpt}`:` — excerpt unavailable`]},`${e.sessionId}:${e.entryOrdinal}`))})]}),o===`shared`&&(0,l.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Shared lessons become searchable Team memory. Stable facts about the human belong in Team USER.md instead.`})]})}export{u as component};
1
+ import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{d as r}from"./preload-helper-mNuBjNXU.js";import{i}from"./index-B3vdrEEg.js";import{r as a}from"./Page-CwNuDhWz.js";import{t as o}from"./AgentTabs-R6gSjIj3.js";import{t as s}from"./Button-ByiV6fpd.js";var c=e(n()),l=t();function u(){let{resolved:e,config:t,reviews:n,proposals:u}=i.useLoaderData(),p=r(),[m,h]=(0,c.useState)(null),[g,_]=(0,c.useState)(!1);async function v(e,t,n){h(null),_(!0);try{let r=await fetch(e,{method:t,headers:n===void 0?void 0:{"content-type":`application/json`},body:n===void 0?void 0:JSON.stringify(n)});if(!r.ok){let e=await r.json().catch(()=>null);throw Error(e?.error??`request failed (${r.status})`)}await p.invalidate()}catch(e){h(e instanceof Error?e.message:String(e))}finally{_(!1)}}let y=encodeURIComponent(e.agent.id);return(0,l.jsxs)(a,{children:[(0,l.jsx)(`header`,{className:`mb-6`,children:(0,l.jsx)(`h1`,{children:e.agent.name})}),(0,l.jsx)(o,{agentId:e.agent.id,active:`learning`,archived:e.agent.status===`archived`}),m&&(0,l.jsxs)(`p`,{className:`mb-4 rounded border border-red-300 bg-red-50 p-3 text-sm text-red-800`,children:[m,`. Refresh before retrying if another operator changed this proposal.`]}),(0,l.jsxs)(`section`,{className:`mb-8 rounded-lg border bg-card p-5`,children:[(0,l.jsx)(`h2`,{className:`mb-2 text-xl`,children:`Reviewed learning`}),(0,l.jsxs)(`p`,{className:`mb-4 text-sm text-muted-foreground`,children:[`Reviews inspect at most 8 successful user turns and 40,000 characters. They use `,t.model??`the Agent model`,` at `,t.reasoningLevel,` reasoning, propose at most five lessons, and never apply anything without your approval.`]}),(0,l.jsx)(d,{agentId:e.agent.id,config:t,disabled:g,onError:h,onSaved:()=>p.invalidate()}),(0,l.jsxs)(`div`,{className:`mt-4 flex items-center gap-3`,children:[(0,l.jsx)(s,{variant:`primary`,disabled:g||e.agent.status===`archived`,onClick:()=>v(`/api/agents/${y}/reviews`,`POST`),children:`Review now`}),!t.enabled&&(0,l.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Periodic review is disabled; manual review remains available.`})]})]}),(0,l.jsx)(`h2`,{className:`mb-3 text-xl`,children:`Lesson proposals`}),u.length===0?(0,l.jsx)(`p`,{className:`mb-8 text-muted-foreground`,children:`No proposals yet. A successful review may also produce zero proposals.`}):(0,l.jsx)(`div`,{className:`mb-8 grid gap-3`,children:u.map(t=>(0,l.jsx)(f,{proposal:t,agentId:e.agent.id,busy:g,act:v},t.id))}),(0,l.jsx)(`h2`,{className:`mb-3 text-xl`,children:`Review history`}),n.length===0?(0,l.jsx)(`p`,{className:`text-muted-foreground`,children:`No reviews have been queued.`}):(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{children:`created`}),(0,l.jsx)(`th`,{children:`trigger`}),(0,l.jsx)(`th`,{children:`status`}),(0,l.jsx)(`th`,{children:`turns`}),(0,l.jsx)(`th`,{children:`proposals`}),(0,l.jsx)(`th`,{children:`diagnostic`})]})}),(0,l.jsx)(`tbody`,{children:n.map(e=>(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{children:new Date(e.createdAt).toLocaleString()}),(0,l.jsx)(`td`,{children:e.trigger}),(0,l.jsx)(`td`,{children:(0,l.jsx)(`code`,{children:e.status})}),(0,l.jsx)(`td`,{children:e.turnsReviewed}),(0,l.jsx)(`td`,{children:e.proposalCount}),(0,l.jsx)(`td`,{children:e.lastError??`—`})]},e.id))})]})})]})}function d({agentId:e,config:t,disabled:n,onError:r,onSaved:i}){let[a,o]=(0,c.useState)(t.enabled),[u,d]=(0,c.useState)(t.everyNTurns),[f,p]=(0,c.useState)(t.model??``),[m,h]=(0,c.useState)(t.reasoningLevel);async function g(t){t.preventDefault(),r(null);let n=await fetch(`/api/agents/${encodeURIComponent(e)}/review-config`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({enabled:a,everyNTurns:u,model:f.trim()||null,reasoningLevel:m})});if(!n.ok){r((await n.json().catch(()=>null))?.error??`request failed (${n.status})`);return}i()}return(0,l.jsxs)(`form`,{onSubmit:g,className:`grid gap-3 md:grid-cols-4`,children:[(0,l.jsxs)(`label`,{className:`text-sm`,children:[(0,l.jsx)(`span`,{className:`block mb-1`,children:`Periodic review`}),(0,l.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked)}),` enabled`]}),(0,l.jsxs)(`label`,{className:`text-sm`,children:[(0,l.jsx)(`span`,{className:`block mb-1`,children:`Every turns`}),(0,l.jsx)(`input`,{type:`number`,min:1,max:100,value:u,onChange:e=>d(Number(e.target.value))})]}),(0,l.jsxs)(`label`,{className:`text-sm`,children:[(0,l.jsx)(`span`,{className:`block mb-1`,children:`Model override`}),(0,l.jsx)(`input`,{value:f,placeholder:`agent model`,onChange:e=>p(e.target.value)})]}),(0,l.jsxs)(`label`,{className:`text-sm`,children:[(0,l.jsx)(`span`,{className:`block mb-1`,children:`Reasoning`}),(0,l.jsxs)(`select`,{value:m,onChange:e=>h(e.target.value),children:[(0,l.jsx)(`option`,{children:`off`}),(0,l.jsx)(`option`,{children:`minimal`}),(0,l.jsx)(`option`,{children:`low`}),(0,l.jsx)(`option`,{children:`medium`}),(0,l.jsx)(`option`,{children:`high`}),(0,l.jsx)(`option`,{children:`xhigh`})]})]}),(0,l.jsx)(`div`,{children:(0,l.jsx)(s,{variant:`primary`,type:`submit`,disabled:n,children:`Save learning settings`})})]})}function f({proposal:e,agentId:t,busy:n,act:r}){let[i,a]=(0,c.useState)(e.text),[o,u]=(0,c.useState)(e.scope),d=`/api/agents/${encodeURIComponent(t)}/lesson-proposals/${encodeURIComponent(e.id)}`;return(0,l.jsxs)(`article`,{className:`rounded-lg border bg-card p-4`,children:[(0,l.jsxs)(`div`,{className:`mb-2 flex justify-between gap-2`,children:[(0,l.jsx)(`code`,{children:e.status}),(0,l.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`v`,e.version]})]}),e.status===`pending`?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`textarea`,{className:`w-full`,rows:3,value:i,onChange:e=>a(e.target.value)}),(0,l.jsxs)(`select`,{className:`mt-2`,value:o,onChange:e=>u(e.target.value),children:[(0,l.jsx)(`option`,{value:`private`,children:`private Agent behavior`}),(0,l.jsx)(`option`,{value:`shared`,children:`shared Team knowledge`})]}),(0,l.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,l.jsx)(s,{variant:`ghost`,disabled:n,onClick:()=>r(d,`PATCH`,{version:e.version,text:i,scope:o}),children:`Save edit`}),(0,l.jsx)(s,{variant:`primary`,disabled:n,onClick:()=>r(`${d}/approve`,`POST`,{version:e.version}),children:`Approve`}),(0,l.jsx)(s,{variant:`danger`,disabled:n,onClick:()=>r(`${d}/reject`,`POST`,{version:e.version}),children:`Reject`})]})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`p`,{children:e.text}),e.status===`approved`&&(0,l.jsx)(`div`,{className:`mt-3`,children:(0,l.jsx)(s,{variant:`danger`,disabled:n,onClick:()=>r(`${d}/revoke`,`POST`,{version:e.version}),children:`Revoke`})})]}),(0,l.jsxs)(`div`,{className:`mt-3 text-xs text-muted-foreground`,children:[`Evidence: `,e.evidence.length===0?`none`:(0,l.jsx)(`ul`,{className:`mt-1 list-disc pl-5`,children:e.evidence.map(e=>(0,l.jsxs)(`li`,{children:[(0,l.jsxs)(`code`,{children:[e.sessionId,`:`,e.entryOrdinal]}),e.excerpt?` — ${e.excerpt}`:` — excerpt unavailable`]},`${e.sessionId}:${e.entryOrdinal}`))})]}),o===`shared`&&(0,l.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Shared lessons become searchable Team memory. Stable facts about the human belong in Team USER.md instead.`})]})}export{u as component};
@@ -1 +1 @@
1
- import{t as e}from"./jsx-runtime-DGeXAQPT.js";import{A as t,D as n,E as r,M as i,O as a,j as o}from"./index-3nrK5iFr.js";var s=t(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),c=t(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),l=e();function u(){let{error:e}=r.useSearch();return(0,l.jsxs)(`main`,{className:`relative flex min-h-dvh items-center overflow-hidden bg-cream px-5 py-16 sm:px-8`,children:[(0,l.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0`,style:{background:`radial-gradient(circle at 16% 12%, rgba(61,120,153,0.18), transparent 36rem), radial-gradient(circle at 88% 84%, rgba(196,135,138,0.13), transparent 32rem)`}}),(0,l.jsx)(`div`,{className:`absolute right-4 top-4 z-10 sm:right-6 sm:top-6`,children:(0,l.jsx)(n,{})}),(0,l.jsxs)(`div`,{className:`relative mx-auto grid w-full max-w-5xl items-center gap-10 lg:grid-cols-[minmax(0,1fr)_25rem] lg:gap-20`,children:[(0,l.jsxs)(`section`,{className:`hidden lg:block`,children:[(0,l.jsxs)(`div`,{className:`mb-8 flex items-center gap-3`,children:[(0,l.jsx)(i,{className:`h-12 w-12`}),(0,l.jsx)(`span`,{className:`font-display text-3xl tracking-[-0.03em] text-charcoal`,children:`bazilion`})]}),(0,l.jsx)(`h1`,{className:`max-w-xl text-[3.4rem] leading-[0.98] tracking-[-0.035em]`,children:`Your agents, working as one thoughtful team.`}),(0,l.jsx)(`p`,{className:`mt-6 max-w-lg text-base leading-7 text-mocha`,children:`A private workspace for long-lived agents, shared context, and communication policies you can actually see and control.`}),(0,l.jsxs)(`div`,{className:`mt-8 grid max-w-lg gap-3 sm:grid-cols-2`,children:[(0,l.jsx)(d,{icon:(0,l.jsx)(c,{className:`h-4 w-4`}),label:`Persistent conversations`}),(0,l.jsx)(d,{icon:(0,l.jsx)(a,{className:`h-4 w-4`}),label:`Team-owned context`})]})]}),(0,l.jsxs)(`section`,{className:`w-full rounded-[24px] border border-frost bg-snow/95 p-7 shadow-baziu-lg backdrop-blur sm:p-9`,children:[(0,l.jsxs)(`div`,{className:`mb-6 flex items-center gap-3 lg:hidden`,children:[(0,l.jsx)(i,{className:`h-10 w-10`}),(0,l.jsx)(`span`,{className:`font-display text-2xl text-charcoal`,children:`bazilion`})]}),(0,l.jsx)(`div`,{className:`mb-6 flex h-10 w-10 items-center justify-center rounded-xl bg-sapphire-glow text-sapphire`,children:(0,l.jsx)(s,{className:`h-5 w-5`,"aria-hidden":`true`})}),(0,l.jsx)(`h2`,{className:`font-display text-3xl text-charcoal`,children:`Welcome back`}),(0,l.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-mocha-light`,children:`Use the local access token created by your Bazilion daemon.`}),e&&(0,l.jsx)(`div`,{className:`err mt-5`,children:`That token was not accepted.`}),(0,l.jsxs)(`form`,{method:`POST`,action:`/api/login`,className:`mt-6 text-left`,children:[(0,l.jsx)(`label`,{htmlFor:`token`,className:`block text-[0.85em] font-semibold text-mocha`,children:`Access token`}),(0,l.jsx)(`input`,{type:`password`,id:`token`,name:`token`,autoFocus:!0,required:!0,placeholder:`Paste your token`,className:`mb-4`}),(0,l.jsx)(`button`,{type:`submit`,className:`w-full`,children:`Open Bazilion`})]}),(0,l.jsxs)(`p`,{className:`mt-5 rounded-xl bg-ivory px-3 py-2.5 text-[0.78em] leading-relaxed text-mocha-light`,children:[`Find it in `,(0,l.jsx)(`code`,{children:`~/.bazilion/auth.json`}),`, created the first time you run`,` `,(0,l.jsx)(`code`,{children:`bazilion serve`}),`.`]})]})]}),(0,l.jsxs)(`footer`,{className:`absolute bottom-4 left-0 right-0 text-center text-[0.75em] text-fawn`,children:[`dedicated to Baziu`,(0,l.jsx)(o,{className:`ml-1 inline-block h-3 w-3 align-[-1px] opacity-40`})]})]})}function d({icon:e,label:t}){return(0,l.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl border border-frost bg-snow/70 px-3 py-2.5 text-sm font-semibold text-mocha shadow-baziu-sm`,children:[(0,l.jsx)(`span`,{className:`text-sapphire`,children:e}),t]})}export{u as component};
1
+ import{t as e}from"./jsx-runtime-DGeXAQPT.js";import{A as t,D as n,E as r,M as i,O as a,j as o}from"./index-B3vdrEEg.js";var s=t(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),c=t(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),l=e();function u(){let{error:e}=r.useSearch();return(0,l.jsxs)(`main`,{className:`relative flex min-h-dvh items-center overflow-hidden bg-cream px-5 py-16 sm:px-8`,children:[(0,l.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0`,style:{background:`radial-gradient(circle at 16% 12%, rgba(61,120,153,0.18), transparent 36rem), radial-gradient(circle at 88% 84%, rgba(196,135,138,0.13), transparent 32rem)`}}),(0,l.jsx)(`div`,{className:`absolute right-4 top-4 z-10 sm:right-6 sm:top-6`,children:(0,l.jsx)(n,{})}),(0,l.jsxs)(`div`,{className:`relative mx-auto grid w-full max-w-5xl items-center gap-10 lg:grid-cols-[minmax(0,1fr)_25rem] lg:gap-20`,children:[(0,l.jsxs)(`section`,{className:`hidden lg:block`,children:[(0,l.jsxs)(`div`,{className:`mb-8 flex items-center gap-3`,children:[(0,l.jsx)(i,{className:`h-12 w-12`}),(0,l.jsx)(`span`,{className:`font-display text-3xl tracking-[-0.03em] text-charcoal`,children:`bazilion`})]}),(0,l.jsx)(`h1`,{className:`max-w-xl text-[3.4rem] leading-[0.98] tracking-[-0.035em]`,children:`Your agents, working as one thoughtful team.`}),(0,l.jsx)(`p`,{className:`mt-6 max-w-lg text-base leading-7 text-mocha`,children:`A private workspace for long-lived agents, shared context, and communication policies you can actually see and control.`}),(0,l.jsxs)(`div`,{className:`mt-8 grid max-w-lg gap-3 sm:grid-cols-2`,children:[(0,l.jsx)(d,{icon:(0,l.jsx)(c,{className:`h-4 w-4`}),label:`Persistent conversations`}),(0,l.jsx)(d,{icon:(0,l.jsx)(a,{className:`h-4 w-4`}),label:`Team-owned context`})]})]}),(0,l.jsxs)(`section`,{className:`w-full rounded-[24px] border border-frost bg-snow/95 p-7 shadow-baziu-lg backdrop-blur sm:p-9`,children:[(0,l.jsxs)(`div`,{className:`mb-6 flex items-center gap-3 lg:hidden`,children:[(0,l.jsx)(i,{className:`h-10 w-10`}),(0,l.jsx)(`span`,{className:`font-display text-2xl text-charcoal`,children:`bazilion`})]}),(0,l.jsx)(`div`,{className:`mb-6 flex h-10 w-10 items-center justify-center rounded-xl bg-sapphire-glow text-sapphire`,children:(0,l.jsx)(s,{className:`h-5 w-5`,"aria-hidden":`true`})}),(0,l.jsx)(`h2`,{className:`font-display text-3xl text-charcoal`,children:`Welcome back`}),(0,l.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-mocha-light`,children:`Use a named device token minted locally by your Bazilion CLI.`}),e&&(0,l.jsx)(`div`,{className:`err mt-5`,children:`That token was not accepted.`}),(0,l.jsxs)(`form`,{method:`POST`,action:`/api/login`,className:`mt-6 text-left`,children:[(0,l.jsx)(`label`,{htmlFor:`token`,className:`block text-[0.85em] font-semibold text-mocha`,children:`Access token`}),(0,l.jsx)(`input`,{type:`password`,id:`token`,name:`token`,autoFocus:!0,required:!0,placeholder:`Paste your token`,className:`mb-4`}),(0,l.jsx)(`button`,{type:`submit`,className:`w-full`,children:`Open Bazilion`})]}),(0,l.jsxs)(`p`,{className:`mt-5 rounded-xl bg-ivory px-3 py-2.5 text-[0.78em] leading-relaxed text-mocha-light`,children:[`On the server, run `,(0,l.jsx)(`code`,{children:`bazilion token create browser`}),`. The bootstrap token in`,` `,(0,l.jsx)(`code`,{children:`auth.json`}),` is intentionally rejected here.`]})]})]}),(0,l.jsxs)(`footer`,{className:`absolute bottom-4 left-0 right-0 text-center text-[0.75em] text-fawn`,children:[`dedicated to Baziu`,(0,l.jsx)(o,{className:`ml-1 inline-block h-3 w-3 align-[-1px] opacity-40`})]})]})}function d({icon:e,label:t}){return(0,l.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl border border-frost bg-snow/70 px-3 py-2.5 text-sm font-semibold text-mocha shadow-baziu-sm`,children:[(0,l.jsx)(`span`,{className:`text-sapphire`,children:e}),t]})}export{u as component};
@@ -1 +1 @@
1
- import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{d as r}from"./preload-helper-mNuBjNXU.js";import{g as i}from"./index-3nrK5iFr.js";import{t as a}from"./ConfigPage-BCwfgyjD.js";var o=e(n()),s=t(),c=[`stdio`,`http`,`sse`];function l(){let{servers:e}=i.useLoaderData(),t=r(),[n,l]=(0,o.useState)(``),[u,d]=(0,o.useState)(`stdio`),[f,p]=(0,o.useState)(``),[m,h]=(0,o.useState)(``),[g,_]=(0,o.useState)(``),[v,y]=(0,o.useState)(``),[b,x]=(0,o.useState)(null),[S,C]=(0,o.useState)(!1),[w,T]=(0,o.useState)({});async function E(e){e.preventDefault(),x(null),C(!0);try{let e={name:n,transport:u,command:u===`stdio`?f:null,args:u===`stdio`?m.split(` `).filter(Boolean):[],url:u===`stdio`?null:g,authToken:v||void 0},r=await fetch(`/api/mcp-servers`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.error??`${r.status} ${r.statusText}`)}l(``),p(``),h(``),_(``),y(``),await t.invalidate()}catch(e){x(e.message)}finally{C(!1)}}async function D(e){await fetch(`/api/mcp-servers/${e.id}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({enabled:!e.enabled})}),await t.invalidate()}async function O(e){await fetch(`/api/mcp-servers/${e}`,{method:`DELETE`}),await t.invalidate()}async function k(e){T(t=>({...t,[e]:`connecting…`}));let t=await(await fetch(`/api/mcp-servers/${e}/test`,{method:`POST`})).json().catch(()=>({}));T(n=>({...n,[e]:t.ok?`✓ ${t.tools?.length??0} tools: ${(t.tools??[]).map(e=>e.name).join(`, `)}`:`✗ ${t.error??`failed`}`}))}return(0,s.jsxs)(a,{active:`mcp`,title:`MCP servers`,description:(0,s.jsxs)(s.Fragment,{children:[`Expose tools from local or remote Model Context Protocol servers to every agent under the `,(0,s.jsx)(`code`,{className:`font-mono`,children:`mcp__<server>__<tool>`}),` namespace. Local stdio servers inherit configured secrets; HTTP and SSE servers can use a bearer token.`]}),children:[(0,s.jsxs)(`section`,{className:`rounded-lg border bg-card p-5`,children:[(0,s.jsx)(`h3`,{className:`font-serif text-xl mb-3`,children:`Add a server`}),(0,s.jsxs)(`form`,{onSubmit:E,className:`space-y-3`,children:[(0,s.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-end`,children:[(0,s.jsxs)(`label`,{className:`w-full text-sm sm:w-auto`,children:[`Name`,(0,s.jsx)(`input`,{type:`text`,value:n,onChange:e=>l(e.target.value),required:!0,placeholder:`playwright`,pattern:`[a-zA-Z0-9_]+`,className:`mt-1 block w-full rounded-md border bg-background px-3 py-2 text-sm sm:w-48`})]}),(0,s.jsxs)(`label`,{className:`w-full text-sm sm:w-auto`,children:[`Transport`,(0,s.jsx)(`select`,{value:u,onChange:e=>d(e.target.value),className:`mt-1 block w-full rounded-md border bg-background px-3 py-2 text-sm`,children:c.map(e=>(0,s.jsx)(`option`,{value:e,children:e},e))})]})]}),u===`stdio`?(0,s.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-end`,children:[(0,s.jsxs)(`label`,{className:`w-full text-sm sm:w-auto`,children:[`Command`,(0,s.jsx)(`input`,{type:`text`,value:f,onChange:e=>p(e.target.value),placeholder:`npx`,className:`mt-1 block w-full rounded-md border bg-background px-3 py-2 text-sm sm:w-48`})]}),(0,s.jsxs)(`label`,{className:`w-full min-w-0 text-sm sm:flex-1`,children:[`Args (space-separated)`,(0,s.jsx)(`input`,{type:`text`,value:m,onChange:e=>h(e.target.value),placeholder:`-y @modelcontextprotocol/server-filesystem /tmp`,className:`block mt-1 rounded-md border bg-background px-3 py-2 text-sm w-full`})]})]}):(0,s.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-end`,children:[(0,s.jsxs)(`label`,{className:`w-full min-w-0 text-sm sm:flex-1`,children:[`URL`,(0,s.jsx)(`input`,{type:`url`,value:g,onChange:e=>_(e.target.value),placeholder:`https://mcp.example.com/sse`,className:`block mt-1 rounded-md border bg-background px-3 py-2 text-sm w-full`})]}),(0,s.jsxs)(`label`,{className:`w-full text-sm sm:w-auto`,children:[`Bearer token (optional)`,(0,s.jsx)(`input`,{type:`password`,value:v,onChange:e=>y(e.target.value),autoComplete:`off`,className:`mt-1 block w-full rounded-md border bg-background px-3 py-2 text-sm sm:w-56`})]})]}),(0,s.jsx)(`button`,{type:`submit`,disabled:S,className:`w-full rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground disabled:opacity-50 sm:w-auto`,children:S?`adding…`:`add server`}),b&&(0,s.jsx)(`p`,{className:`text-sm text-danger`,children:b})]})]}),(0,s.jsx)(`div`,{className:`overflow-x-auto`,children:(0,s.jsxs)(`table`,{className:`w-full min-w-[720px] text-sm`,children:[(0,s.jsx)(`thead`,{className:`text-left text-muted-foreground border-b`,children:(0,s.jsxs)(`tr`,{children:[(0,s.jsx)(`th`,{className:`py-2`,children:`name`}),(0,s.jsx)(`th`,{children:`transport`}),(0,s.jsx)(`th`,{children:`target`}),(0,s.jsx)(`th`,{children:`state`}),(0,s.jsx)(`th`,{})]})}),(0,s.jsxs)(`tbody`,{children:[e.length===0&&(0,s.jsx)(`tr`,{children:(0,s.jsx)(`td`,{colSpan:5,className:`py-6 text-center text-muted-foreground italic`,children:`no MCP servers yet — add one above`})}),e.map(e=>(0,s.jsxs)(`tr`,{className:`border-b last:border-0 align-top`,children:[(0,s.jsxs)(`td`,{className:`py-2`,children:[e.name,e.hasAuthToken&&(0,s.jsx)(`span`,{className:`ml-2 text-[0.7em] uppercase tracking-wide text-muted-foreground`,children:`auth`}),w[e.id]&&(0,s.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1 break-all`,children:w[e.id]})]}),(0,s.jsx)(`td`,{children:e.transport}),(0,s.jsx)(`td`,{className:`font-mono text-xs break-all`,children:e.transport===`stdio`?`${e.command??``} ${e.args.join(` `)}`.trim():e.url}),(0,s.jsx)(`td`,{children:e.enabled?(0,s.jsx)(`span`,{className:`text-success`,children:`enabled`}):(0,s.jsx)(`span`,{className:`text-muted-foreground`,children:`disabled`})}),(0,s.jsxs)(`td`,{className:`space-x-2 whitespace-nowrap`,children:[(0,s.jsx)(`button`,{type:`button`,onClick:()=>k(e.id),className:`rounded-md border px-2 py-1 text-xs hover:bg-accent`,children:`test`}),(0,s.jsx)(`button`,{type:`button`,onClick:()=>D(e),className:`rounded-md border px-2 py-1 text-xs hover:bg-accent`,children:e.enabled?`disable`:`enable`}),(0,s.jsx)(`button`,{type:`button`,onClick:()=>O(e.id),className:`rounded-md border px-2 py-1 text-xs text-danger hover:bg-danger/10`,children:`delete`})]})]},e.id))]})]})})]})}export{l as component};
1
+ import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{d as r}from"./preload-helper-mNuBjNXU.js";import{g as i}from"./index-B3vdrEEg.js";import{t as a}from"./ConfigPage-BCwfgyjD.js";var o=e(n()),s=t(),c=[`stdio`,`http`,`sse`];function l(){let{servers:e}=i.useLoaderData(),t=r(),[n,l]=(0,o.useState)(``),[u,d]=(0,o.useState)(`stdio`),[f,p]=(0,o.useState)(``),[m,h]=(0,o.useState)(``),[g,_]=(0,o.useState)(``),[v,y]=(0,o.useState)(``),[b,x]=(0,o.useState)(null),[S,C]=(0,o.useState)(!1),[w,T]=(0,o.useState)({});async function E(e){e.preventDefault(),x(null),C(!0);try{let e={name:n,transport:u,command:u===`stdio`?f:null,args:u===`stdio`?m.split(` `).filter(Boolean):[],url:u===`stdio`?null:g,authToken:v||void 0},r=await fetch(`/api/mcp-servers`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.error??`${r.status} ${r.statusText}`)}l(``),p(``),h(``),_(``),y(``),await t.invalidate()}catch(e){x(e.message)}finally{C(!1)}}async function D(e){await fetch(`/api/mcp-servers/${e.id}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({enabled:!e.enabled})}),await t.invalidate()}async function O(e){await fetch(`/api/mcp-servers/${e}`,{method:`DELETE`}),await t.invalidate()}async function k(e){T(t=>({...t,[e]:`connecting…`}));let t=await(await fetch(`/api/mcp-servers/${e}/test`,{method:`POST`})).json().catch(()=>({}));T(n=>({...n,[e]:t.ok?`✓ ${t.tools?.length??0} tools: ${(t.tools??[]).map(e=>e.name).join(`, `)}`:`✗ ${t.error??`failed`}`}))}return(0,s.jsxs)(a,{active:`mcp`,title:`MCP servers`,description:(0,s.jsxs)(s.Fragment,{children:[`Expose tools from local or remote Model Context Protocol servers to every agent under the `,(0,s.jsx)(`code`,{className:`font-mono`,children:`mcp__<server>__<tool>`}),` namespace. Local stdio servers inherit configured secrets; HTTP and SSE servers can use a bearer token.`]}),children:[(0,s.jsxs)(`section`,{className:`rounded-lg border bg-card p-5`,children:[(0,s.jsx)(`h3`,{className:`font-serif text-xl mb-3`,children:`Add a server`}),(0,s.jsxs)(`form`,{onSubmit:E,className:`space-y-3`,children:[(0,s.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-end`,children:[(0,s.jsxs)(`label`,{className:`w-full text-sm sm:w-auto`,children:[`Name`,(0,s.jsx)(`input`,{type:`text`,value:n,onChange:e=>l(e.target.value),required:!0,placeholder:`playwright`,pattern:`[a-zA-Z0-9_]+`,className:`mt-1 block w-full rounded-md border bg-background px-3 py-2 text-sm sm:w-48`})]}),(0,s.jsxs)(`label`,{className:`w-full text-sm sm:w-auto`,children:[`Transport`,(0,s.jsx)(`select`,{value:u,onChange:e=>d(e.target.value),className:`mt-1 block w-full rounded-md border bg-background px-3 py-2 text-sm`,children:c.map(e=>(0,s.jsx)(`option`,{value:e,children:e},e))})]})]}),u===`stdio`?(0,s.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-end`,children:[(0,s.jsxs)(`label`,{className:`w-full text-sm sm:w-auto`,children:[`Command`,(0,s.jsx)(`input`,{type:`text`,value:f,onChange:e=>p(e.target.value),placeholder:`npx`,className:`mt-1 block w-full rounded-md border bg-background px-3 py-2 text-sm sm:w-48`})]}),(0,s.jsxs)(`label`,{className:`w-full min-w-0 text-sm sm:flex-1`,children:[`Args (space-separated)`,(0,s.jsx)(`input`,{type:`text`,value:m,onChange:e=>h(e.target.value),placeholder:`-y @modelcontextprotocol/server-filesystem /tmp`,className:`block mt-1 rounded-md border bg-background px-3 py-2 text-sm w-full`})]})]}):(0,s.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-end`,children:[(0,s.jsxs)(`label`,{className:`w-full min-w-0 text-sm sm:flex-1`,children:[`URL`,(0,s.jsx)(`input`,{type:`url`,value:g,onChange:e=>_(e.target.value),placeholder:`https://mcp.example.com/sse`,className:`block mt-1 rounded-md border bg-background px-3 py-2 text-sm w-full`})]}),(0,s.jsxs)(`label`,{className:`w-full text-sm sm:w-auto`,children:[`Bearer token (optional)`,(0,s.jsx)(`input`,{type:`password`,value:v,onChange:e=>y(e.target.value),autoComplete:`off`,className:`mt-1 block w-full rounded-md border bg-background px-3 py-2 text-sm sm:w-56`})]})]}),(0,s.jsx)(`button`,{type:`submit`,disabled:S,className:`w-full rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground disabled:opacity-50 sm:w-auto`,children:S?`adding…`:`add server`}),b&&(0,s.jsx)(`p`,{className:`text-sm text-danger`,children:b})]})]}),(0,s.jsx)(`div`,{className:`overflow-x-auto`,children:(0,s.jsxs)(`table`,{className:`w-full min-w-[720px] text-sm`,children:[(0,s.jsx)(`thead`,{className:`text-left text-muted-foreground border-b`,children:(0,s.jsxs)(`tr`,{children:[(0,s.jsx)(`th`,{className:`py-2`,children:`name`}),(0,s.jsx)(`th`,{children:`transport`}),(0,s.jsx)(`th`,{children:`target`}),(0,s.jsx)(`th`,{children:`state`}),(0,s.jsx)(`th`,{})]})}),(0,s.jsxs)(`tbody`,{children:[e.length===0&&(0,s.jsx)(`tr`,{children:(0,s.jsx)(`td`,{colSpan:5,className:`py-6 text-center text-muted-foreground italic`,children:`no MCP servers yet — add one above`})}),e.map(e=>(0,s.jsxs)(`tr`,{className:`border-b last:border-0 align-top`,children:[(0,s.jsxs)(`td`,{className:`py-2`,children:[e.name,e.hasAuthToken&&(0,s.jsx)(`span`,{className:`ml-2 text-[0.7em] uppercase tracking-wide text-muted-foreground`,children:`auth`}),w[e.id]&&(0,s.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1 break-all`,children:w[e.id]})]}),(0,s.jsx)(`td`,{children:e.transport}),(0,s.jsx)(`td`,{className:`font-mono text-xs break-all`,children:e.transport===`stdio`?`${e.command??``} ${e.args.join(` `)}`.trim():e.url}),(0,s.jsx)(`td`,{children:e.enabled?(0,s.jsx)(`span`,{className:`text-success`,children:`enabled`}):(0,s.jsx)(`span`,{className:`text-muted-foreground`,children:`disabled`})}),(0,s.jsxs)(`td`,{className:`space-x-2 whitespace-nowrap`,children:[(0,s.jsx)(`button`,{type:`button`,onClick:()=>k(e.id),className:`rounded-md border px-2 py-1 text-xs hover:bg-accent`,children:`test`}),(0,s.jsx)(`button`,{type:`button`,onClick:()=>D(e),className:`rounded-md border px-2 py-1 text-xs hover:bg-accent`,children:e.enabled?`disable`:`enable`}),(0,s.jsx)(`button`,{type:`button`,onClick:()=>O(e.id),className:`rounded-md border px-2 py-1 text-xs text-danger hover:bg-danger/10`,children:`delete`})]})]},e.id))]})]})})]})}export{l as component};
@@ -1 +1 @@
1
- import{t as e}from"./jsx-runtime-DGeXAQPT.js";import{l as t}from"./index-3nrK5iFr.js";import{r as n}from"./Page-CwNuDhWz.js";import{t as r}from"./TeamTabs-DvqWieCq.js";var i=e();function a(){let e=t.useLoaderData(),{id:a}=t.useParams();return(0,i.jsxs)(n,{children:[(0,i.jsx)(`h1`,{children:`Team members`}),(0,i.jsxs)(`p`,{className:`muted`,children:[(0,i.jsx)(`code`,{children:`agents.team_id`}),` is the only live-membership authority.`]}),(0,i.jsx)(r,{teamId:a}),(0,i.jsx)(`div`,{className:`overflow-x-auto rounded-md border border-frost`,children:(0,i.jsxs)(`table`,{className:`w-full`,children:[(0,i.jsx)(`thead`,{children:(0,i.jsxs)(`tr`,{children:[(0,i.jsx)(`th`,{children:`agent`}),(0,i.jsx)(`th`,{children:`status`}),(0,i.jsx)(`th`,{children:`agent template`}),(0,i.jsx)(`th`,{children:`source slot`})]})}),(0,i.jsxs)(`tbody`,{children:[e.members.map(t=>{let n=e.bindings.find(e=>e.agentId===t.id);return(0,i.jsxs)(`tr`,{children:[(0,i.jsx)(`td`,{children:(0,i.jsx)(`a`,{href:`/agents/${t.id}`,children:t.name})}),(0,i.jsx)(`td`,{children:t.status}),(0,i.jsx)(`td`,{children:t.profileId}),(0,i.jsx)(`td`,{children:(0,i.jsx)(`code`,{children:n?.sourceSlotId??`live-only`})})]},t.id)}),e.members.length===0&&(0,i.jsx)(`tr`,{children:(0,i.jsx)(`td`,{colSpan:4,className:`muted`,children:`No agents belong to this team.`})})]})]})})]})}export{a as component};
1
+ import{t as e}from"./jsx-runtime-DGeXAQPT.js";import{l as t}from"./index-B3vdrEEg.js";import{r as n}from"./Page-CwNuDhWz.js";import{t as r}from"./TeamTabs-Bk89JfN7.js";var i=e();function a(){let e=t.useLoaderData(),{id:a}=t.useParams();return(0,i.jsxs)(n,{children:[(0,i.jsx)(`h1`,{children:`Team members`}),(0,i.jsxs)(`p`,{className:`muted`,children:[(0,i.jsx)(`code`,{children:`agents.team_id`}),` is the only live-membership authority.`]}),(0,i.jsx)(r,{teamId:a}),(0,i.jsx)(`div`,{className:`overflow-x-auto rounded-md border border-frost`,children:(0,i.jsxs)(`table`,{className:`w-full`,children:[(0,i.jsx)(`thead`,{children:(0,i.jsxs)(`tr`,{children:[(0,i.jsx)(`th`,{children:`agent`}),(0,i.jsx)(`th`,{children:`status`}),(0,i.jsx)(`th`,{children:`agent template`}),(0,i.jsx)(`th`,{children:`source slot`})]})}),(0,i.jsxs)(`tbody`,{children:[e.members.map(t=>{let n=e.bindings.find(e=>e.agentId===t.id);return(0,i.jsxs)(`tr`,{children:[(0,i.jsx)(`td`,{children:(0,i.jsx)(`a`,{href:`/agents/${t.id}`,children:t.name})}),(0,i.jsx)(`td`,{children:t.status}),(0,i.jsx)(`td`,{children:t.profileId}),(0,i.jsx)(`td`,{children:(0,i.jsx)(`code`,{children:n?.sourceSlotId??`live-only`})})]},t.id)}),e.members.length===0&&(0,i.jsx)(`tr`,{children:(0,i.jsx)(`td`,{colSpan:4,className:`muted`,children:`No agents belong to this team.`})})]})]})})]})}export{a as component};
@@ -1 +1 @@
1
- import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{u as r}from"./index-3nrK5iFr.js";import{r as i}from"./Page-CwNuDhWz.js";import{t as a}from"./TeamTabs-DvqWieCq.js";var o=e(n()),s=t();function c(e){return e.split(`/`).map(encodeURIComponent).join(`/`)}function l(){let{team:e,memberCount:t,entries:n}=r.useLoaderData(),l=e.id,[u,d]=(0,o.useState)(()=>n.map(e=>({key:e.key,preview:e.content.slice(0,80)}))),[f,p]=(0,o.useState)(!1),[m,h]=(0,o.useState)(``),[g,_]=(0,o.useState)(null),[v,y]=(0,o.useState)(`none`),[b,x]=(0,o.useState)(``),[S,C]=(0,o.useState)(``),[w,T]=(0,o.useState)(null),E=(0,o.useRef)(null);async function D(e){try{let t=e.trim().length>0?`/api/teams/${encodeURIComponent(l)}/memory/search?q=${encodeURIComponent(e)}&limit=50`:`/api/teams/${encodeURIComponent(l)}/memory`,n=await fetch(t);if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error??n.statusText)}let r=await n.json();e.trim().length>0?(d(r.map(e=>({key:e.key,preview:e.snippet,score:e.score}))),p(!0)):(d(r.map(e=>({key:e.key,preview:e.content.slice(0,80)}))),p(!1))}catch(e){T({msg:`error: ${e.message}`,kind:`error`})}}(0,o.useEffect)(()=>(E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{D(m)},200),()=>{E.current&&clearTimeout(E.current)}),[m]);async function O(e){_(e),y(`edit`),T({msg:`loading…`,kind:`info`});try{let t=await fetch(`/api/teams/${encodeURIComponent(l)}/memory/${c(e)}`);if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error??t.statusText)}let n=await t.json();x(n.key),C(n.content??``),T({msg:`loaded ${n.key}`,kind:`info`})}catch(e){T({msg:`error: ${e.message}`,kind:`error`})}}function k(){_(null),y(`new`),x(``),C(``),T({msg:`new entry — type a key and content, then save`,kind:`info`})}async function A(){let e=b.trim();if(!e){T({msg:`key is required`,kind:`error`});return}try{let t=await fetch(`/api/teams/${encodeURIComponent(l)}/memory/${c(e)}`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({content:S})});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error??t.statusText)}_(e),y(`edit`),T({msg:`saved`,kind:`info`}),await D(m)}catch(e){T({msg:`error: ${e.message}`,kind:`error`})}}async function j(){if(g&&confirm(`delete ${g}?`))try{let e=await fetch(`/api/teams/${encodeURIComponent(l)}/memory/${c(g)}`,{method:`DELETE`});if(!e.ok&&e.status!==204){let t=await e.json().catch(()=>null);throw Error(t?.error??e.statusText)}_(null),y(`none`),x(``),C(``),T({msg:`deleted`,kind:`info`}),await D(m)}catch(e){T({msg:`error: ${e.message}`,kind:`error`})}}let M=v!==`none`&&b.trim().length>0,N=v===`edit`&&g!==null;return(0,s.jsxs)(i,{children:[(0,s.jsxs)(`header`,{className:`mb-6`,children:[(0,s.jsxs)(`h1`,{className:`font-serif text-3xl text-foreground`,children:[e.name,` `,(0,s.jsx)(`span`,{className:`text-muted-foreground text-base`,children:`/ Shared memory`})]}),(0,s.jsxs)(`p`,{className:`text-muted-foreground text-sm mt-1`,children:[`BM25-indexed markdown notes shared by every agent in`,` `,(0,s.jsx)(`a`,{href:`/teams/${encodeURIComponent(e.id)}`,className:`font-mono underline`,children:e.id}),` `,`(`,t,` member`,t===1?``:`s`,`). Anything written here is visible to every member; per-agent notes belong in the agent's own`,` `,(0,s.jsx)(`code`,{className:`font-mono`,children:`IDENTITY.md`}),` via `,(0,s.jsx)(`code`,{children:`home_write`}),`.`]})]}),(0,s.jsx)(a,{teamId:e.id}),(0,s.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-[320px_1fr]`,children:[(0,s.jsxs)(`div`,{children:[(0,s.jsxs)(`div`,{className:`overflow-hidden rounded-[16px] border border-frost bg-snow`,children:[(0,s.jsx)(`div`,{className:`border-b border-frost p-2`,children:(0,s.jsx)(`input`,{type:`text`,placeholder:`search (BM25)...`,autoComplete:`off`,value:m,onChange:e=>h(e.target.value)})}),(0,s.jsx)(`div`,{className:`max-h-[520px] overflow-y-auto`,children:u.length===0?(0,s.jsx)(`div`,{className:`p-8 text-center text-mocha-light`,children:`no entries`}):u.map(e=>(0,s.jsxs)(`button`,{type:`button`,onClick:()=>O(e.key),className:`unstyled block w-full cursor-pointer border-b border-frost/50 px-3.5 py-2 text-left font-mono text-[0.84em] transition-colors last:border-b-0 hover:bg-sapphire-glow ${e.key===g?`bg-sapphire-glow font-medium text-sapphire-deep`:``}`,children:[f&&e.score!==void 0&&(0,s.jsx)(`span`,{className:`float-right text-[0.75em] text-sapphire`,children:e.score.toFixed(2)}),e.key,e.preview&&(0,s.jsx)(`span`,{className:`mt-1 block text-[0.9em] font-normal text-mocha-light`,children:e.preview})]},e.key))})]}),(0,s.jsx)(`button`,{type:`button`,className:`ghost-btn mt-3 w-full`,onClick:k,children:`+ new entry`})]}),(0,s.jsxs)(`div`,{children:[(0,s.jsx)(`div`,{className:`mb-3 flex items-center gap-2`,children:(0,s.jsx)(`input`,{type:`text`,placeholder:`key (e.g. prefs/hiking.md)`,value:b,onChange:e=>x(e.target.value),disabled:v!==`new`,className:`flex-1 font-mono`})}),(0,s.jsx)(`textarea`,{placeholder:`select an entry on the left, or create a new one.`,value:S,onChange:e=>C(e.target.value),className:`min-h-[360px] w-full font-mono text-[0.9em] leading-[1.55]`}),(0,s.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,s.jsx)(`button`,{type:`button`,className:`btn-primary`,onClick:A,disabled:!M,children:`save`}),(0,s.jsx)(`button`,{type:`button`,className:`ghost-btn`,onClick:j,disabled:!N,children:`delete`})]}),w&&(0,s.jsx)(`p`,{className:`mt-2 text-[0.9em] ${w.kind===`error`?`text-danger`:`text-mocha-light`}`,children:w.msg})]})]})]})}export{l as component};
1
+ import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{u as r}from"./index-B3vdrEEg.js";import{r as i}from"./Page-CwNuDhWz.js";import{t as a}from"./TeamTabs-Bk89JfN7.js";var o=e(n()),s=t();function c(e){return e.split(`/`).map(encodeURIComponent).join(`/`)}function l(){let{team:e,memberCount:t,entries:n}=r.useLoaderData(),l=e.id,[u,d]=(0,o.useState)(()=>n.map(e=>({key:e.key,preview:e.content.slice(0,80)}))),[f,p]=(0,o.useState)(!1),[m,h]=(0,o.useState)(``),[g,_]=(0,o.useState)(null),[v,y]=(0,o.useState)(`none`),[b,x]=(0,o.useState)(``),[S,C]=(0,o.useState)(``),[w,T]=(0,o.useState)(null),E=(0,o.useRef)(null);async function D(e){try{let t=e.trim().length>0?`/api/teams/${encodeURIComponent(l)}/memory/search?q=${encodeURIComponent(e)}&limit=50`:`/api/teams/${encodeURIComponent(l)}/memory`,n=await fetch(t);if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error??n.statusText)}let r=await n.json();e.trim().length>0?(d(r.map(e=>({key:e.key,preview:e.snippet,score:e.score}))),p(!0)):(d(r.map(e=>({key:e.key,preview:e.content.slice(0,80)}))),p(!1))}catch(e){T({msg:`error: ${e.message}`,kind:`error`})}}(0,o.useEffect)(()=>(E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{D(m)},200),()=>{E.current&&clearTimeout(E.current)}),[m]);async function O(e){_(e),y(`edit`),T({msg:`loading…`,kind:`info`});try{let t=await fetch(`/api/teams/${encodeURIComponent(l)}/memory/${c(e)}`);if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error??t.statusText)}let n=await t.json();x(n.key),C(n.content??``),T({msg:`loaded ${n.key}`,kind:`info`})}catch(e){T({msg:`error: ${e.message}`,kind:`error`})}}function k(){_(null),y(`new`),x(``),C(``),T({msg:`new entry — type a key and content, then save`,kind:`info`})}async function A(){let e=b.trim();if(!e){T({msg:`key is required`,kind:`error`});return}try{let t=await fetch(`/api/teams/${encodeURIComponent(l)}/memory/${c(e)}`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({content:S})});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error??t.statusText)}_(e),y(`edit`),T({msg:`saved`,kind:`info`}),await D(m)}catch(e){T({msg:`error: ${e.message}`,kind:`error`})}}async function j(){if(g&&confirm(`delete ${g}?`))try{let e=await fetch(`/api/teams/${encodeURIComponent(l)}/memory/${c(g)}`,{method:`DELETE`});if(!e.ok&&e.status!==204){let t=await e.json().catch(()=>null);throw Error(t?.error??e.statusText)}_(null),y(`none`),x(``),C(``),T({msg:`deleted`,kind:`info`}),await D(m)}catch(e){T({msg:`error: ${e.message}`,kind:`error`})}}let M=v!==`none`&&b.trim().length>0,N=v===`edit`&&g!==null;return(0,s.jsxs)(i,{children:[(0,s.jsxs)(`header`,{className:`mb-6`,children:[(0,s.jsxs)(`h1`,{className:`font-serif text-3xl text-foreground`,children:[e.name,` `,(0,s.jsx)(`span`,{className:`text-muted-foreground text-base`,children:`/ Shared memory`})]}),(0,s.jsxs)(`p`,{className:`text-muted-foreground text-sm mt-1`,children:[`BM25-indexed markdown notes shared by every agent in`,` `,(0,s.jsx)(`a`,{href:`/teams/${encodeURIComponent(e.id)}`,className:`font-mono underline`,children:e.id}),` `,`(`,t,` member`,t===1?``:`s`,`). Anything written here is visible to every member; per-agent notes belong in the agent's own`,` `,(0,s.jsx)(`code`,{className:`font-mono`,children:`IDENTITY.md`}),` via `,(0,s.jsx)(`code`,{children:`home_write`}),`.`]})]}),(0,s.jsx)(a,{teamId:e.id}),(0,s.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-[320px_1fr]`,children:[(0,s.jsxs)(`div`,{children:[(0,s.jsxs)(`div`,{className:`overflow-hidden rounded-[16px] border border-frost bg-snow`,children:[(0,s.jsx)(`div`,{className:`border-b border-frost p-2`,children:(0,s.jsx)(`input`,{type:`text`,placeholder:`search (BM25)...`,autoComplete:`off`,value:m,onChange:e=>h(e.target.value)})}),(0,s.jsx)(`div`,{className:`max-h-[520px] overflow-y-auto`,children:u.length===0?(0,s.jsx)(`div`,{className:`p-8 text-center text-mocha-light`,children:`no entries`}):u.map(e=>(0,s.jsxs)(`button`,{type:`button`,onClick:()=>O(e.key),className:`unstyled block w-full cursor-pointer border-b border-frost/50 px-3.5 py-2 text-left font-mono text-[0.84em] transition-colors last:border-b-0 hover:bg-sapphire-glow ${e.key===g?`bg-sapphire-glow font-medium text-sapphire-deep`:``}`,children:[f&&e.score!==void 0&&(0,s.jsx)(`span`,{className:`float-right text-[0.75em] text-sapphire`,children:e.score.toFixed(2)}),e.key,e.preview&&(0,s.jsx)(`span`,{className:`mt-1 block text-[0.9em] font-normal text-mocha-light`,children:e.preview})]},e.key))})]}),(0,s.jsx)(`button`,{type:`button`,className:`ghost-btn mt-3 w-full`,onClick:k,children:`+ new entry`})]}),(0,s.jsxs)(`div`,{children:[(0,s.jsx)(`div`,{className:`mb-3 flex items-center gap-2`,children:(0,s.jsx)(`input`,{type:`text`,placeholder:`key (e.g. prefs/hiking.md)`,value:b,onChange:e=>x(e.target.value),disabled:v!==`new`,className:`flex-1 font-mono`})}),(0,s.jsx)(`textarea`,{placeholder:`select an entry on the left, or create a new one.`,value:S,onChange:e=>C(e.target.value),className:`min-h-[360px] w-full font-mono text-[0.9em] leading-[1.55]`}),(0,s.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,s.jsx)(`button`,{type:`button`,className:`btn-primary`,onClick:A,disabled:!M,children:`save`}),(0,s.jsx)(`button`,{type:`button`,className:`ghost-btn`,onClick:j,disabled:!N,children:`delete`})]}),w&&(0,s.jsx)(`p`,{className:`mt-2 text-[0.9em] ${w.kind===`error`?`text-danger`:`text-mocha-light`}`,children:w.msg})]})]})]})}export{l as component};
@@ -0,0 +1 @@
1
+ import{A as e}from"./index-B3vdrEEg.js";var t=e(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]);export{t};
@@ -1 +1 @@
1
- import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{n as r,t as i}from"./ProductionTeamPolicyEditor-CsWpTsy6.js";import{A as a,d as o}from"./index-3nrK5iFr.js";import{r as s}from"./Page-CwNuDhWz.js";import{t as c}from"./Button-ByiV6fpd.js";import{t as l}from"./RecoveryState-QfMSuwy3.js";import{t as u}from"./TeamTabs-DvqWieCq.js";var d=a(`git-compare-arrows`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`M12 18H7a2 2 0 0 1-2-2V9`,key:`16sdep`}],[`path`,{d:`m9 15 3 3-3 3`,key:`1m3kbl`}]]),f=a(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),p=e(n(),1),m=t();function h({teamId:e,detail:t,templates:n}){let[i,a]=(0,p.useState)(null),[o,s]=(0,p.useState)(null),[l,u]=(0,p.useState)(!1),[h,v]=(0,p.useState)(`${e}-snapshot`),[y,b]=(0,p.useState)(`${e} snapshot`),x=(0,p.useMemo)(()=>new Set(t.bindings.map(e=>e.agentId)),[t.bindings]),S=t.members.filter(e=>!x.has(e.id)),C=async()=>{let t=await fetch(`/api/teams/${encodeURIComponent(e)}/policy/diff`);if(!t.ok)throw Error((await t.json().catch(()=>null))?.error??`Could not load source comparison`);a(await t.json())};return(0,p.useEffect)(()=>{C().catch(e=>s(e instanceof Error?e.message:String(e)))},[e]),(0,m.jsxs)(`section`,{className:`card space-y-4`,"aria-labelledby":`source-workflows`,children:[(0,m.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,m.jsx)(d,{className:`mt-1 h-5 w-5 text-sapphire`}),(0,m.jsxs)(`div`,{className:`mr-auto`,children:[(0,m.jsx)(`h2`,{id:`source-workflows`,className:`m-0 text-lg`,children:`Baseline and source`}),(0,m.jsx)(`p`,{className:`muted mt-1 text-sm`,children:`Lineage is retained for comparison; source edits never auto-propagate.`})]}),(0,m.jsxs)(c,{variant:`ghost`,onClick:()=>void C(),children:[(0,m.jsx)(f,{className:`h-4 w-4`}),`Refresh comparison`]})]}),i?(0,m.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,m.jsx)(g,{label:`Baseline`,value:i.baseline?`${i.baseline.templateId} r${i.baseline.templateRevision}`:`None`}),(0,m.jsx)(g,{label:`Live changes`,value:`+${i.comparison.addedSinceBaseline.length} / −${i.comparison.removedSinceBaseline.length} edges`}),(0,m.jsx)(g,{label:`Source slots`,value:`+${i.comparison.currentSourceAddedSlotIds.length} / −${i.comparison.currentSourceRemovedSlotIds.length}`}),(0,m.jsx)(g,{label:`Source state`,value:i.currentSource?i.sourceDiverged?`Diverged — rebaseline required`:`Aligned`:`Missing/tombstoned`,warning:i.sourceDiverged||!i.currentSource})]}):(0,m.jsx)(`p`,{className:`muted`,children:`Loading comparison…`}),i?.sourceDiverged&&(0,m.jsx)(`div`,{role:`alert`,className:`rounded-md border border-warning/25 bg-warning/10 p-3 text-sm text-warning`,children:`The source has changed since this Team retained its baseline. Both versions remain intact. Update-source is disabled; compare and explicitly rebaseline instead.`}),i?.currentSource&&!i.sourceDiverged&&(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,m.jsxs)(`p`,{className:`mr-auto text-sm`,children:[`Promote the current live policy to `,(0,m.jsx)(`strong`,{children:i.currentSource.template.name}),`, including `,S.length,` live-only Agent`,S.length===1?``:`s`,`.`]}),(0,m.jsx)(c,{variant:`ghost`,disabled:l,onClick:async()=>{if(!(!i?.currentSource||i.sourceDiverged)){u(!0),s(null);try{let n=await fetch(`/api/teams/${encodeURIComponent(e)}/policy/update-source`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({teamExpectedRevision:t.teamPolicy.revision,templateExpectedRevision:i.currentSource.template.currentRevision,includeAgentIds:S.map(e=>e.id)})});if(!n.ok)throw Error((await n.json().catch(()=>null))?.error??`Update failed (${n.status})`);window.location.reload()}catch(e){s(e instanceof Error?e.message:String(e))}finally{u(!1)}}},children:`Update source after review`})]}),(0,m.jsxs)(`div`,{className:`grid gap-3 border-t border-frost pt-4 sm:grid-cols-[1fr_1fr_auto]`,children:[(0,m.jsxs)(`label`,{className:`text-xs`,children:[`New template ID`,(0,m.jsx)(`input`,{value:h,onChange:e=>v(e.target.value)})]}),(0,m.jsxs)(`label`,{className:`text-xs`,children:[`New template name`,(0,m.jsx)(`input`,{value:y,onChange:e=>b(e.target.value)})]}),(0,m.jsxs)(c,{variant:`primary`,disabled:l||!h.trim()||!y.trim(),onClick:async()=>{u(!0),s(null);try{let n=await fetch(`/api/teams/${encodeURIComponent(e)}/policy/save-as-template`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({expectedRevision:t.teamPolicy.revision,id:h,name:y})});if(!n.ok)throw Error((await n.json().catch(()=>null))?.error??`Save failed (${n.status})`);let r=await n.json();window.location.assign(`/templates/teams/${encodeURIComponent(r.template.id)}`)}catch(e){s(e instanceof Error?e.message:String(e))}finally{u(!1)}},children:[(0,m.jsx)(r,{className:`h-4 w-4`}),`Save independent Team template`]})]}),o&&(0,m.jsx)(`p`,{role:`alert`,className:`err`,children:o}),(0,m.jsx)(_,{teamId:e,detail:t,templates:n})]})}function g({label:e,value:t,warning:n=!1}){return(0,m.jsxs)(`div`,{className:`rounded-md border p-3 ${n?`border-warning/25 bg-warning/10 dark:bg-amber-950/30`:`border-frost bg-ivory`}`,children:[(0,m.jsx)(`dt`,{className:`text-xs font-semibold uppercase text-mocha-light`,children:e}),(0,m.jsx)(`dd`,{className:`mt-1 break-words text-sm font-semibold`,children:t})]})}function _({teamId:e,detail:t,templates:n}){let[r,i]=(0,p.useState)(n.find(e=>!e.deletedAt)?.id??``),[a,o]=(0,p.useState)(null),[s,l]=(0,p.useState)({}),[u,d]=(0,p.useState)({}),[f,h]=(0,p.useState)(null),[g,_]=(0,p.useState)(null),v=async()=>{_(null),h(null);let e=await fetch(`/api/team-templates/${encodeURIComponent(r)}`);if(!e.ok){_(`Could not load Team (${e.status})`);return}let n=await e.json();o(n);let i={};n.slots.forEach((e,n)=>{let r=t.members[n];r&&(i[e.slotId]=r.id)}),l(i);let a=new Set(Object.values(i));d(Object.fromEntries(t.members.filter(e=>!a.has(e.id)).map(e=>[e.id,`isolated`])))},y=()=>({teamExpectedRevision:t.teamPolicy.revision,templateId:a?.template.id,templateExpectedRevision:a?.template.currentRevision,slotMappings:a?.slots.map(e=>({slotId:e.slotId,agentId:s[e.slotId]}))??[],remainingPlacements:t.members.filter(e=>!Object.values(s).includes(e.id)).map(e=>({agentId:e.id,placement:u[e.id]??`isolated`}))});return(0,m.jsxs)(`div`,{className:`space-y-4 border-t border-frost pt-5`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`h3`,{className:`m-0 text-base`,children:`Adopt or rebaseline from Team Template`}),(0,m.jsx)(`p`,{className:`muted mt-1 text-sm`,children:`Map every stable source slot to one current Agent, choose placement for remaining Agents, then review the daemon-resolved edge set.`})]}),(0,m.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,m.jsxs)(`label`,{className:`min-w-52 flex-1 text-xs`,children:[`Team Template`,(0,m.jsx)(`select`,{value:r,onChange:e=>{i(e.target.value),o(null),h(null)},children:n.filter(e=>!e.deletedAt).map(e=>(0,m.jsxs)(`option`,{value:e.id,children:[e.name,` · r`,e.currentRevision]},e.id))})]}),(0,m.jsx)(c,{variant:`ghost`,onClick:v,children:`Configure mapping`})]}),a&&(0,m.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,m.jsxs)(`div`,{className:`space-y-2`,children:[(0,m.jsx)(`p`,{className:`text-xs font-semibold uppercase text-mocha-light`,children:`Stable slots`}),a.slots.map(e=>(0,m.jsxs)(`label`,{className:`block text-xs`,children:[(0,m.jsxs)(`span`,{className:`block truncate`,title:e.slotId,children:[e.agentName,` · slot `,(0,m.jsx)(`code`,{children:e.slotId.slice(0,8)})]}),(0,m.jsxs)(`select`,{value:s[e.slotId]??``,onChange:t=>{l(n=>({...n,[e.slotId]:t.target.value})),h(null)},children:[(0,m.jsx)(`option`,{value:``,children:`Select Agent…`}),t.members.map(t=>(0,m.jsxs)(`option`,{value:t.id,disabled:Object.entries(s).some(([n,r])=>n!==e.slotId&&r===t.id),children:[t.name,t.status===`archived`?` (archived)`:``]},t.id))]})]},e.slotId))]}),(0,m.jsxs)(`div`,{className:`space-y-2`,children:[(0,m.jsx)(`p`,{className:`text-xs font-semibold uppercase text-mocha-light`,children:`Remaining live Agents`}),t.members.filter(e=>!Object.values(s).includes(e.id)).map(e=>(0,m.jsxs)(`label`,{className:`block text-xs`,children:[e.name,(0,m.jsxs)(`select`,{value:u[e.id]??`isolated`,onChange:t=>{d(n=>({...n,[e.id]:t.target.value})),h(null)},children:[(0,m.jsx)(`option`,{value:`isolated`,children:`Isolated`}),(0,m.jsx)(`option`,{value:`profile_defaults`,children:`Agent-template defaults`})]})]},e.id))]})]}),a&&(0,m.jsx)(c,{variant:`ghost`,onClick:async()=>{if(!a||a.slots.some(e=>!s[e.slotId])||new Set(Object.values(s)).size!==a.slots.length){_(`Map every stable slot to a distinct current Agent.`);return}let t=await fetch(`/api/teams/${encodeURIComponent(e)}/policy/adopt-template/preview`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(y())}),n=await t.json().catch(()=>null);if(!t.ok){_(n?.error??`Preview failed (${t.status})`);return}h(n.edges)},children:`Review exact resulting policy`}),f&&(0,m.jsxs)(`div`,{className:`rounded-md border border-sapphire-light bg-sapphire-glow p-3 text-sm`,children:[(0,m.jsxs)(`p`,{children:[`The daemon resolved `,(0,m.jsx)(`strong`,{children:f.length}),` directed allow edges. This preview is submitted unchanged and recomputed transactionally at commit.`]}),(0,m.jsx)(`div`,{className:`mt-2 max-h-40 overflow-auto`,children:(0,m.jsx)(`ul`,{children:f.map((e,t)=>(0,m.jsx)(`li`,{children:(0,m.jsxs)(`code`,{children:[e.sourceKind,e.sourceId?`:${e.sourceId}`:``,` → `,e.targetKind,e.targetId?`:${e.targetId}`:``]})},`${e.sourceKind}:${e.sourceId??``}>${e.targetKind}:${e.targetId??``}:${t}`))})}),(0,m.jsx)(c,{variant:`primary`,className:`mt-3`,onClick:async()=>{if(!f)return;let t=await fetch(`/api/teams/${encodeURIComponent(e)}/policy/adopt-template`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({...y(),previewEdges:f})}),n=await t.json().catch(()=>null);if(!t.ok){_(n?.error??`Rebaseline failed (${t.status})`);return}window.location.reload()},children:`Commit reviewed rebaseline`})]}),g&&(0,m.jsx)(`p`,{role:`alert`,className:`err`,children:g})]})}function v(){let e=o.useLoaderData();if(!e.ok)return(0,m.jsx)(l,{title:`Team policy unavailable`,error:Error(e.error),reset:()=>window.location.reload(),fallbackHref:`/teams`});let{detail:t,profiles:n,templates:r}=e.value,{id:a}=o.useParams(),c=o.useSearch(),d=t.baseline;return(0,m.jsxs)(s,{size:`wide`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`h1`,{children:`Team policy`}),(0,m.jsxs)(`p`,{className:`muted`,children:[`The sole effective live communication policy for `,(0,m.jsx)(`code`,{children:a}),`.`]})]}),(0,m.jsx)(u,{teamId:a}),(0,m.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,"aria-label":`Policy status`,children:[(0,m.jsx)(y,{label:`Revision`,value:t.teamPolicy.revision}),(0,m.jsx)(y,{label:`Allow edges`,value:t.edges.length}),(0,m.jsx)(y,{label:`Baseline`,value:d?`${d.templateId} r${d.templateRevision}`:`Not initialized`})]}),(0,m.jsx)(i,{source:{kind:`live`,teamId:a,detail:t},profiles:n,initialUi:{view:c.view,selectedId:c.selected,viewport:{x:c.vx,y:c.vy,zoom:c.vz}}}),(0,m.jsx)(h,{teamId:a,detail:t,templates:r})]})}function y({label:e,value:t}){return(0,m.jsxs)(`div`,{className:`card`,children:[(0,m.jsx)(`dt`,{className:`muted text-xs`,children:e}),(0,m.jsx)(`dd`,{className:`break-words font-semibold`,children:t})]})}export{v as component};
1
+ import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{n as r,t as i}from"./ProductionTeamPolicyEditor-DdpYInwV.js";import{A as a,d as o}from"./index-B3vdrEEg.js";import{r as s}from"./Page-CwNuDhWz.js";import{t as c}from"./Button-ByiV6fpd.js";import{t as l}from"./RecoveryState-QfMSuwy3.js";import{t as u}from"./TeamTabs-Bk89JfN7.js";var d=a(`git-compare-arrows`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`M12 18H7a2 2 0 0 1-2-2V9`,key:`16sdep`}],[`path`,{d:`m9 15 3 3-3 3`,key:`1m3kbl`}]]),f=a(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),p=e(n(),1),m=t();function h({teamId:e,detail:t,templates:n}){let[i,a]=(0,p.useState)(null),[o,s]=(0,p.useState)(null),[l,u]=(0,p.useState)(!1),[h,v]=(0,p.useState)(`${e}-snapshot`),[y,b]=(0,p.useState)(`${e} snapshot`),x=(0,p.useMemo)(()=>new Set(t.bindings.map(e=>e.agentId)),[t.bindings]),S=t.members.filter(e=>!x.has(e.id)),C=async()=>{let t=await fetch(`/api/teams/${encodeURIComponent(e)}/policy/diff`);if(!t.ok)throw Error((await t.json().catch(()=>null))?.error??`Could not load source comparison`);a(await t.json())};return(0,p.useEffect)(()=>{C().catch(e=>s(e instanceof Error?e.message:String(e)))},[e]),(0,m.jsxs)(`section`,{className:`card space-y-4`,"aria-labelledby":`source-workflows`,children:[(0,m.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,m.jsx)(d,{className:`mt-1 h-5 w-5 text-sapphire`}),(0,m.jsxs)(`div`,{className:`mr-auto`,children:[(0,m.jsx)(`h2`,{id:`source-workflows`,className:`m-0 text-lg`,children:`Baseline and source`}),(0,m.jsx)(`p`,{className:`muted mt-1 text-sm`,children:`Lineage is retained for comparison; source edits never auto-propagate.`})]}),(0,m.jsxs)(c,{variant:`ghost`,onClick:()=>void C(),children:[(0,m.jsx)(f,{className:`h-4 w-4`}),`Refresh comparison`]})]}),i?(0,m.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,m.jsx)(g,{label:`Baseline`,value:i.baseline?`${i.baseline.templateId} r${i.baseline.templateRevision}`:`None`}),(0,m.jsx)(g,{label:`Live changes`,value:`+${i.comparison.addedSinceBaseline.length} / −${i.comparison.removedSinceBaseline.length} edges`}),(0,m.jsx)(g,{label:`Source slots`,value:`+${i.comparison.currentSourceAddedSlotIds.length} / −${i.comparison.currentSourceRemovedSlotIds.length}`}),(0,m.jsx)(g,{label:`Source state`,value:i.currentSource?i.sourceDiverged?`Diverged — rebaseline required`:`Aligned`:`Missing/tombstoned`,warning:i.sourceDiverged||!i.currentSource})]}):(0,m.jsx)(`p`,{className:`muted`,children:`Loading comparison…`}),i?.sourceDiverged&&(0,m.jsx)(`div`,{role:`alert`,className:`rounded-md border border-warning/25 bg-warning/10 p-3 text-sm text-warning`,children:`The source has changed since this Team retained its baseline. Both versions remain intact. Update-source is disabled; compare and explicitly rebaseline instead.`}),i?.currentSource&&!i.sourceDiverged&&(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,m.jsxs)(`p`,{className:`mr-auto text-sm`,children:[`Promote the current live policy to `,(0,m.jsx)(`strong`,{children:i.currentSource.template.name}),`, including `,S.length,` live-only Agent`,S.length===1?``:`s`,`.`]}),(0,m.jsx)(c,{variant:`ghost`,disabled:l,onClick:async()=>{if(!(!i?.currentSource||i.sourceDiverged)){u(!0),s(null);try{let n=await fetch(`/api/teams/${encodeURIComponent(e)}/policy/update-source`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({teamExpectedRevision:t.teamPolicy.revision,templateExpectedRevision:i.currentSource.template.currentRevision,includeAgentIds:S.map(e=>e.id)})});if(!n.ok)throw Error((await n.json().catch(()=>null))?.error??`Update failed (${n.status})`);window.location.reload()}catch(e){s(e instanceof Error?e.message:String(e))}finally{u(!1)}}},children:`Update source after review`})]}),(0,m.jsxs)(`div`,{className:`grid gap-3 border-t border-frost pt-4 sm:grid-cols-[1fr_1fr_auto]`,children:[(0,m.jsxs)(`label`,{className:`text-xs`,children:[`New template ID`,(0,m.jsx)(`input`,{value:h,onChange:e=>v(e.target.value)})]}),(0,m.jsxs)(`label`,{className:`text-xs`,children:[`New template name`,(0,m.jsx)(`input`,{value:y,onChange:e=>b(e.target.value)})]}),(0,m.jsxs)(c,{variant:`primary`,disabled:l||!h.trim()||!y.trim(),onClick:async()=>{u(!0),s(null);try{let n=await fetch(`/api/teams/${encodeURIComponent(e)}/policy/save-as-template`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({expectedRevision:t.teamPolicy.revision,id:h,name:y})});if(!n.ok)throw Error((await n.json().catch(()=>null))?.error??`Save failed (${n.status})`);let r=await n.json();window.location.assign(`/templates/teams/${encodeURIComponent(r.template.id)}`)}catch(e){s(e instanceof Error?e.message:String(e))}finally{u(!1)}},children:[(0,m.jsx)(r,{className:`h-4 w-4`}),`Save independent Team template`]})]}),o&&(0,m.jsx)(`p`,{role:`alert`,className:`err`,children:o}),(0,m.jsx)(_,{teamId:e,detail:t,templates:n})]})}function g({label:e,value:t,warning:n=!1}){return(0,m.jsxs)(`div`,{className:`rounded-md border p-3 ${n?`border-warning/25 bg-warning/10 dark:bg-amber-950/30`:`border-frost bg-ivory`}`,children:[(0,m.jsx)(`dt`,{className:`text-xs font-semibold uppercase text-mocha-light`,children:e}),(0,m.jsx)(`dd`,{className:`mt-1 break-words text-sm font-semibold`,children:t})]})}function _({teamId:e,detail:t,templates:n}){let[r,i]=(0,p.useState)(n.find(e=>!e.deletedAt)?.id??``),[a,o]=(0,p.useState)(null),[s,l]=(0,p.useState)({}),[u,d]=(0,p.useState)({}),[f,h]=(0,p.useState)(null),[g,_]=(0,p.useState)(null),v=async()=>{_(null),h(null);let e=await fetch(`/api/team-templates/${encodeURIComponent(r)}`);if(!e.ok){_(`Could not load Team (${e.status})`);return}let n=await e.json();o(n);let i={};n.slots.forEach((e,n)=>{let r=t.members[n];r&&(i[e.slotId]=r.id)}),l(i);let a=new Set(Object.values(i));d(Object.fromEntries(t.members.filter(e=>!a.has(e.id)).map(e=>[e.id,`isolated`])))},y=()=>({teamExpectedRevision:t.teamPolicy.revision,templateId:a?.template.id,templateExpectedRevision:a?.template.currentRevision,slotMappings:a?.slots.map(e=>({slotId:e.slotId,agentId:s[e.slotId]}))??[],remainingPlacements:t.members.filter(e=>!Object.values(s).includes(e.id)).map(e=>({agentId:e.id,placement:u[e.id]??`isolated`}))});return(0,m.jsxs)(`div`,{className:`space-y-4 border-t border-frost pt-5`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`h3`,{className:`m-0 text-base`,children:`Adopt or rebaseline from Team Template`}),(0,m.jsx)(`p`,{className:`muted mt-1 text-sm`,children:`Map every stable source slot to one current Agent, choose placement for remaining Agents, then review the daemon-resolved edge set.`})]}),(0,m.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,m.jsxs)(`label`,{className:`min-w-52 flex-1 text-xs`,children:[`Team Template`,(0,m.jsx)(`select`,{value:r,onChange:e=>{i(e.target.value),o(null),h(null)},children:n.filter(e=>!e.deletedAt).map(e=>(0,m.jsxs)(`option`,{value:e.id,children:[e.name,` · r`,e.currentRevision]},e.id))})]}),(0,m.jsx)(c,{variant:`ghost`,onClick:v,children:`Configure mapping`})]}),a&&(0,m.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,m.jsxs)(`div`,{className:`space-y-2`,children:[(0,m.jsx)(`p`,{className:`text-xs font-semibold uppercase text-mocha-light`,children:`Stable slots`}),a.slots.map(e=>(0,m.jsxs)(`label`,{className:`block text-xs`,children:[(0,m.jsxs)(`span`,{className:`block truncate`,title:e.slotId,children:[e.agentName,` · slot `,(0,m.jsx)(`code`,{children:e.slotId.slice(0,8)})]}),(0,m.jsxs)(`select`,{value:s[e.slotId]??``,onChange:t=>{l(n=>({...n,[e.slotId]:t.target.value})),h(null)},children:[(0,m.jsx)(`option`,{value:``,children:`Select Agent…`}),t.members.map(t=>(0,m.jsxs)(`option`,{value:t.id,disabled:Object.entries(s).some(([n,r])=>n!==e.slotId&&r===t.id),children:[t.name,t.status===`archived`?` (archived)`:``]},t.id))]})]},e.slotId))]}),(0,m.jsxs)(`div`,{className:`space-y-2`,children:[(0,m.jsx)(`p`,{className:`text-xs font-semibold uppercase text-mocha-light`,children:`Remaining live Agents`}),t.members.filter(e=>!Object.values(s).includes(e.id)).map(e=>(0,m.jsxs)(`label`,{className:`block text-xs`,children:[e.name,(0,m.jsxs)(`select`,{value:u[e.id]??`isolated`,onChange:t=>{d(n=>({...n,[e.id]:t.target.value})),h(null)},children:[(0,m.jsx)(`option`,{value:`isolated`,children:`Isolated`}),(0,m.jsx)(`option`,{value:`profile_defaults`,children:`Agent-template defaults`})]})]},e.id))]})]}),a&&(0,m.jsx)(c,{variant:`ghost`,onClick:async()=>{if(!a||a.slots.some(e=>!s[e.slotId])||new Set(Object.values(s)).size!==a.slots.length){_(`Map every stable slot to a distinct current Agent.`);return}let t=await fetch(`/api/teams/${encodeURIComponent(e)}/policy/adopt-template/preview`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(y())}),n=await t.json().catch(()=>null);if(!t.ok){_(n?.error??`Preview failed (${t.status})`);return}h(n.edges)},children:`Review exact resulting policy`}),f&&(0,m.jsxs)(`div`,{className:`rounded-md border border-sapphire-light bg-sapphire-glow p-3 text-sm`,children:[(0,m.jsxs)(`p`,{children:[`The daemon resolved `,(0,m.jsx)(`strong`,{children:f.length}),` directed allow edges. This preview is submitted unchanged and recomputed transactionally at commit.`]}),(0,m.jsx)(`div`,{className:`mt-2 max-h-40 overflow-auto`,children:(0,m.jsx)(`ul`,{children:f.map((e,t)=>(0,m.jsx)(`li`,{children:(0,m.jsxs)(`code`,{children:[e.sourceKind,e.sourceId?`:${e.sourceId}`:``,` → `,e.targetKind,e.targetId?`:${e.targetId}`:``]})},`${e.sourceKind}:${e.sourceId??``}>${e.targetKind}:${e.targetId??``}:${t}`))})}),(0,m.jsx)(c,{variant:`primary`,className:`mt-3`,onClick:async()=>{if(!f)return;let t=await fetch(`/api/teams/${encodeURIComponent(e)}/policy/adopt-template`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({...y(),previewEdges:f})}),n=await t.json().catch(()=>null);if(!t.ok){_(n?.error??`Rebaseline failed (${t.status})`);return}window.location.reload()},children:`Commit reviewed rebaseline`})]}),g&&(0,m.jsx)(`p`,{role:`alert`,className:`err`,children:g})]})}function v(){let e=o.useLoaderData();if(!e.ok)return(0,m.jsx)(l,{title:`Team policy unavailable`,error:Error(e.error),reset:()=>window.location.reload(),fallbackHref:`/teams`});let{detail:t,profiles:n,templates:r}=e.value,{id:a}=o.useParams(),c=o.useSearch(),d=t.baseline;return(0,m.jsxs)(s,{size:`wide`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`h1`,{children:`Team policy`}),(0,m.jsxs)(`p`,{className:`muted`,children:[`The sole effective live communication policy for `,(0,m.jsx)(`code`,{children:a}),`.`]})]}),(0,m.jsx)(u,{teamId:a}),(0,m.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,"aria-label":`Policy status`,children:[(0,m.jsx)(y,{label:`Revision`,value:t.teamPolicy.revision}),(0,m.jsx)(y,{label:`Allow edges`,value:t.edges.length}),(0,m.jsx)(y,{label:`Baseline`,value:d?`${d.templateId} r${d.templateRevision}`:`Not initialized`})]}),(0,m.jsx)(i,{source:{kind:`live`,teamId:a,detail:t},profiles:n,initialUi:{view:c.view,selectedId:c.selected,viewport:{x:c.vx,y:c.vy,zoom:c.vz}}}),(0,m.jsx)(h,{teamId:a,detail:t,templates:r})]})}function y({label:e,value:t}){return(0,m.jsxs)(`div`,{className:`card`,children:[(0,m.jsx)(`dt`,{className:`muted text-xs`,children:e}),(0,m.jsx)(`dd`,{className:`break-words font-semibold`,children:t})]})}export{v as component};
@@ -1 +1 @@
1
- import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{a as r,d as i,o as a}from"./preload-helper-mNuBjNXU.js";import{t as o}from"./chevron-down-B0aNNOyn.js";import{t as s}from"./plus-CPzRJg1V.js";import{A as c,O as l,T as u,k as d}from"./index-3nrK5iFr.js";import{i as f}from"./wire-constants-BhVKOCQa.js";import{t as p}from"./Button-ByiV6fpd.js";var m=c(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),h=c(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),g=c(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),_=c(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),v=e(n(),1),y=t();function b({onClose:e}){let t=i(),[n,r]=(0,v.useState)(``),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(null);async function m(r){if(r.preventDefault(),f(null),!n.trim()){f(`id is required`);return}u(!0);try{let r={id:n.trim()};a.trim()&&(r.name=a.trim()),s.trim()&&(r.link=s.trim());let i=await fetch(`/api/teams`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(r)});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.error??`${i.status} ${i.statusText}`)}e(),await t.invalidate()}catch(e){f(e.message),u(!1)}}return(0,y.jsx)(`div`,{onClick:e,onKeyDown:t=>{t.key===`Escape`&&e()},className:`fixed inset-0 z-50 flex items-center justify-center bg-charcoal/45 p-4 backdrop-blur-sm`,children:(0,y.jsxs)(`form`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`create-team-title`,onSubmit:m,onClick:e=>e.stopPropagation(),className:`max-h-[calc(100dvh-2rem)] w-full max-w-lg overflow-y-auto rounded-3xl border border-frost bg-card p-6 shadow-baziu-lg sm:p-7`,children:[(0,y.jsx)(`h2`,{id:`create-team-title`,className:`font-serif text-2xl text-foreground`,children:`Create a team`}),(0,y.jsxs)(`p`,{className:`text-sm text-muted-foreground mb-4`,children:[`A team is a collaboration context — one filesystem root, one USER.md, one roster. The slot lives at `,(0,y.jsx)(`code`,{className:`font-mono`,children:`~/.bazilion/teams/<slug>/`}),`.`]}),(0,y.jsxs)(`div`,{className:`mb-3 grid gap-3 sm:grid-cols-2`,children:[(0,y.jsxs)(`label`,{className:`block text-sm`,children:[`ID (slug)`,(0,y.jsx)(`input`,{type:`text`,value:n,onChange:e=>r(e.target.value),required:!0,pattern:`[a-z0-9][a-z0-9_-]*`,placeholder:`myproject`,autoFocus:!0,className:`mt-1 block w-full rounded-md border bg-background px-3 py-2 outline-none focus:ring-2 focus:ring-ring/30`})]}),(0,y.jsxs)(`label`,{className:`block text-sm`,children:[`Name `,(0,y.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`}),(0,y.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),className:`mt-1 block w-full rounded-md border bg-background px-3 py-2 outline-none focus:ring-2 focus:ring-ring/30`})]})]}),(0,y.jsxs)(`label`,{className:`block text-sm mb-3`,children:[`Link target`,` `,(0,y.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional, absolute path)`}),(0,y.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:`/home/you/projects/myrepo`,className:`mt-1 block w-full rounded-md border bg-background px-3 py-2 outline-none focus:ring-2 focus:ring-ring/30`}),(0,y.jsx)(`span`,{className:`mt-1 block text-xs text-muted-foreground`,children:`Leave blank to create a fresh directory. Supply an absolute path to materialize the slot as a symlink to your existing project tree.`})]}),d&&(0,y.jsx)(`p`,{className:`err mt-2`,children:d}),(0,y.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,y.jsx)(p,{variant:`ghost`,onClick:e,children:`Cancel`}),(0,y.jsx)(p,{variant:`primary`,type:`submit`,disabled:l,children:l?`Creating…`:`Create`})]})]})})}function x({profileId:e,teamHint:t,teams:n,onClose:r}){let i=a(),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(t??n.find(e=>e.id==="default")?.id??n[0]?.id??``),[u,d]=(0,v.useState)(`profile_defaults`),[f,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(null),[_,b]=(0,v.useState)(null);async function x(){let t=await fetch(`/api/teams/${encodeURIComponent(c)}/policy`);if(!t.ok)throw Error(`The selected Team policy is unavailable. Reload and try again.`);let n=await t.json();return{current:n,body:{profileId:e,teamId:c,teamExpectedRevision:n.teamPolicy.revision,placement:u}}}async function C(){g(null),m(!0);try{let{body:e}=await x(),t=await fetch(`/api/agents/placement-preview`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error??`Preview failed (${t.status})`)}b(await t.json())}catch(e){g(e.message)}finally{m(!1)}}async function w(t){t.preventDefault(),g(null),m(!0);try{if(!_){await C();return}let t={profile:e,teamExpectedRevision:_.currentRevision,placement:u};o.trim()&&(t.name=o.trim()),c&&(t.teamId=c);let n=await fetch(`/api/agents`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`${n.status} ${n.statusText}`)}let a=(await n.json()).agent;r(),await i({to:`/`,search:{agent:a.id}})}catch(e){g(e.message),m(!1)}}return(0,y.jsx)(S,{onClose:r,children:(0,y.jsxs)(`form`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`spawn-agent-title`,onSubmit:w,className:`max-h-[calc(100dvh-2rem)] w-full max-w-lg overflow-y-auto rounded-3xl border border-frost bg-card p-6 shadow-baziu-lg sm:p-7`,onClick:e=>e.stopPropagation(),children:[(0,y.jsx)(`h3`,{id:`spawn-agent-title`,className:`font-serif text-xl text-foreground mb-1`,children:`Spawn a new agent`}),(0,y.jsxs)(`p`,{className:`text-sm text-muted-foreground mb-4`,children:[`Profile: `,(0,y.jsx)(`code`,{className:`font-mono`,children:e})]}),(0,y.jsxs)(`label`,{className:`block text-sm text-foreground mb-3`,children:[`Agent name`,` `,(0,y.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional — defaults to the profile's name)`}),(0,y.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),autoFocus:!0,autoComplete:`off`,className:`mt-1 block w-full rounded-md border bg-background px-3 py-2 outline-none focus:ring-2 focus:ring-ring/30`})]}),(0,y.jsxs)(`label`,{className:`block text-sm text-foreground mb-3`,children:[`Initial policy placement`,(0,y.jsxs)(`select`,{value:u,onChange:e=>{d(e.target.value),b(null)},className:`mt-1 block w-full rounded-md border bg-background px-3 py-2`,children:[(0,y.jsx)(`option`,{value:`profile_defaults`,children:`Agent-template defaults`}),(0,y.jsx)(`option`,{value:`isolated`,children:`isolated`})]}),(0,y.jsx)(`span`,{className:`mt-1 block text-xs text-muted-foreground`,children:`The current Team revision is checked again when you submit.`})]}),(0,y.jsxs)(`label`,{className:`block text-sm text-foreground mb-3`,children:[`Team`,(0,y.jsx)(`select`,{value:c,onChange:e=>{l(e.target.value),b(null)},className:`mt-1 block w-full rounded-md border bg-background px-3 py-2 outline-none focus:ring-2 focus:ring-ring/30`,children:n.map(e=>(0,y.jsxs)(`option`,{value:e.id,children:[e.name,e.id==="default"?` (default)`:``]},e.id))})]}),h&&(0,y.jsx)(`p`,{className:`err mt-2`,children:h}),_&&(0,y.jsxs)(`div`,{className:`mt-3 rounded-md border border-sapphire-light bg-sapphire-glow p-3 text-sm`,children:[(0,y.jsxs)(`p`,{children:[`Creating this Agent advances Team revision `,_.currentRevision,` → `,(0,y.jsx)(`strong`,{children:_.resultingRevision}),` and adds `,(0,y.jsx)(`strong`,{children:_.addedEdges.length}),` directed edges to the existing `,_.existingEdges.length,`.`]}),(0,y.jsx)(`ul`,{className:`mt-2 max-h-36 overflow-auto`,children:_.addedEdges.map((e,t)=>(0,y.jsx)(`li`,{children:(0,y.jsxs)(`code`,{children:[e.sourceKind,e.sourceId?`:${e.sourceId}`:``,` → `,e.targetKind,e.targetId?`:${e.targetId}`:``]})},`${e.sourceKind}:${e.sourceId??``}>${e.targetKind}:${e.targetId??``}:${t}`))}),_.addedEdges.length===0&&(0,y.jsx)(`p`,{className:`mt-2`,children:`The new Agent starts isolated.`})]}),(0,y.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,y.jsx)(p,{variant:`ghost`,onClick:r,children:`Cancel`}),(0,y.jsx)(p,{variant:`primary`,type:`submit`,disabled:f,children:f?`Working…`:_?`Commit reviewed creation`:`Review exact policy`})]})]})})}function S({children:e,onClose:t}){return(0,y.jsx)(`div`,{onClick:t,onKeyDown:e=>{e.key===`Escape`&&t()},className:`fixed inset-0 z-50 flex items-center justify-center bg-charcoal/45 p-4 backdrop-blur-sm`,children:e})}function C({profileGroup:e,teams:t,onClose:n,onSpawned:r}){let[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(!1),[f,m]=(0,v.useState)(null),h=(0,v.useRef)(null);(0,v.useEffect)(()=>{h.current?.focus()},[]);async function g(){let n=i.trim();if(!n)throw Error(`target Team slug is required`);let r=t.find(e=>e.id===n),a;if(r){let e=await fetch(`/api/teams/${encodeURIComponent(n)}/policy`);if(!e.ok)throw Error(`The target Team policy is unavailable.`);a=(await e.json()).teamPolicy.revision}return{target:n,body:{templateExpectedRevision:e.currentRevision,teamId:n,...a?{teamExpectedRevision:a}:{},mode:r?`append`:`initialize`,...o?{userMd:o}:{}}}}async function _(){d(!0),l(null),m(null);try{let{body:t}=await g(),n=await fetch(`/api/team-templates/${encodeURIComponent(e.id)}/spawn/preview`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(!n.ok)throw Error((await n.json().catch(()=>null))?.error??n.statusText);m(await n.json())}catch(e){l(e.message)}finally{d(!1)}}async function b(){let t=i.trim();if(!t){l(`target Team slug is required`);return}d(!0),l(null);try{let{body:n}=await g(),i=await fetch(`/api/team-templates/${encodeURIComponent(e.id)}/spawn`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n)});if(!i.ok)throw Error((await i.json().catch(()=>null))?.error??i.statusText);r(t)}catch(e){l(e.message)}finally{d(!1)}}return(0,y.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`spawn-team-title`,className:`fixed inset-0 z-50 flex items-center justify-center bg-charcoal/45 p-4 backdrop-blur-sm`,onClick:n,onKeyDown:e=>{e.key===`Escape`&&n()},children:(0,y.jsxs)(`div`,{ref:h,tabIndex:-1,className:`max-h-[calc(100dvh-2rem)] w-full max-w-lg overflow-y-auto rounded-3xl border border-frost bg-card p-6 shadow-baziu-lg sm:p-7`,role:`document`,onClick:e=>e.stopPropagation(),onKeyDown:e=>{e.key!==`Escape`&&e.stopPropagation()},children:[(0,y.jsxs)(`h2`,{id:`spawn-team-title`,children:[`Spawn team — `,e.name]}),c&&(0,y.jsx)(`div`,{className:`err`,children:c}),(0,y.jsxs)(`p`,{className:`muted`,children:[`Uses immutable Team revision `,e.currentRevision,`. Existing Teams append at their current reviewed revision; a new Team initializes at revision 1. Conflicts never overwrite newer state.`]}),(0,y.jsxs)(`label`,{children:[`target Team slug`,(0,y.jsx)(`input`,{value:i,onChange:e=>{a(e.target.value),m(null)},list:`canonical-teams`,required:!0}),(0,y.jsx)(`datalist`,{id:`canonical-teams`,children:t.map(e=>(0,y.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,y.jsxs)(`label`,{children:[`starter USER.md (new Team only)`,(0,y.jsx)(`textarea`,{rows:3,value:o,onChange:e=>{s(e.target.value),m(null)},className:`font-mono text-[0.88em] leading-[1.55]`})]}),f&&(0,y.jsxs)(`div`,{className:`mt-4 rounded-md border border-sapphire-light bg-sapphire-glow p-3 text-sm`,children:[(0,y.jsxs)(`p`,{children:[(0,y.jsx)(`strong`,{children:f.mode===`initialize`?`Initialize`:`Append`}),` produces Team revision `,f.resultingRevision,`, adds `,f.newMembers.length,` Agents, and results in `,f.edges.length,` directed allow edges.`]}),(0,y.jsx)(`ul`,{className:`mt-2 max-h-40 overflow-auto`,children:f.newMembers.map(e=>(0,y.jsxs)(`li`,{children:[e.agentName,` · stable source slot `,(0,y.jsx)(`code`,{children:e.slotId})]},e.slotId))}),(0,y.jsxs)(`details`,{className:`mt-2`,children:[(0,y.jsx)(`summary`,{className:`cursor-pointer`,children:`Review exact edge topology`}),(0,y.jsx)(`ul`,{className:`mt-2 max-h-40 overflow-auto`,children:f.edges.map((e,t)=>(0,y.jsx)(`li`,{children:(0,y.jsxs)(`code`,{children:[e.sourceKind,e.sourceId?`:${e.sourceId}`:``,` → `,e.targetKind,e.targetId?`:${e.targetId}`:``]})},`${e.sourceKind}:${e.sourceId??``}>${e.targetKind}:${e.targetId??``}:${t}`))})]})]}),(0,y.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,y.jsx)(p,{variant:`ghost`,onClick:n,children:`cancel`}),f?(0,y.jsx)(p,{variant:`primary`,onClick:b,disabled:u,children:u?`spawning…`:`commit ${f.mode}`}):(0,y.jsx)(p,{variant:`primary`,onClick:_,disabled:u||e.slotCount===0,children:u?`reviewing…`:`review exact result`})]})]})})}var w=`bz_sidebar_open_groups`;function T(e){if(typeof document>`u`)return;let t=encodeURIComponent(JSON.stringify(e));document.cookie=`${w}=${t}; Path=/; Max-Age=31536000; SameSite=Lax`}function E({agents:e,teams:t,profiles:n,profileGroups:a,selectedAgentId:c,initialOpenGroups:u}){let f=i(),[p,S]=(0,v.useState)(null),[w,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(!1),[k,A]=(0,v.useState)(!1),j=(0,v.useRef)(null),M=()=>window.requestAnimationFrame(()=>j.current?.focus()),[N,P]=(0,v.useState)(()=>u??{});async function F(e){let t=window.prompt(`rename "${e.name}" to:`,e.name)?.trim();if(!t||t===e.name)return;let n=await fetch(`/api/agents/${e.id}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({name:t})});if(!n.ok){let e=await n.json().catch(()=>null);alert(e?.error??n.statusText);return}await f.invalidate()}async function I(e){if(!confirm(`archive "${e.name}"? (reversible — find under "show archived")`))return;let t=await fetch(`/api/agents/${e.id}/archive`,{method:`POST`});if(!t.ok&&t.status!==204){alert(t.statusText);return}await f.invalidate()}let L=[...n].sort((e,t)=>e.id==="default"?-1:+(t.id==="default")),R=[...t].sort((e,t)=>e.id==="default"?-1:+(t.id==="default")),z=new Map;for(let t of e){let e=z.get(t.teamId)??[];e.push(t),z.set(t.teamId,e)}let B=e.find(e=>e.id===c)?.teamId??null;return(0,y.jsxs)(`aside`,{className:`flex h-full flex-col overflow-hidden rounded-2xl border border-border bg-card shadow-baziu-sm`,children:[(0,y.jsxs)(`header`,{className:`flex items-center justify-between gap-3 border-b border-border bg-muted/30 px-3 py-2.5`,children:[(0,y.jsxs)(`div`,{className:`min-w-0`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-foreground`,children:[(0,y.jsx)(`span`,{className:`flex size-7 items-center justify-center rounded-lg bg-accent text-accent-foreground`,children:(0,y.jsx)(d,{className:`size-4`,"aria-hidden":`true`})}),(0,y.jsx)(`span`,{children:`Agents`})]}),(0,y.jsxs)(`p`,{className:`mt-0.5 truncate pl-9 text-[0.7rem] text-muted-foreground`,children:[e.length,` agent`,e.length===1?``:`s`,` across `,t.length,` team`,t.length===1?``:`s`]})]}),(0,y.jsxs)(`div`,{className:`relative`,children:[(0,y.jsxs)(`button`,{ref:j,type:`button`,onClick:()=>A(e=>!e),"aria-expanded":k,"aria-haspopup":`menu`,className:`unstyled inline-flex h-8 items-center gap-1 rounded-lg border border-border bg-card px-2.5 text-xs font-semibold text-foreground shadow-baziu-sm transition-colors hover:border-primary/30 hover:bg-accent hover:text-accent-foreground`,children:[(0,y.jsx)(s,{className:`size-3.5`,"aria-hidden":`true`}),`New`,(0,y.jsx)(o,{className:`size-3.5 text-muted-foreground transition-transform ${k?`rotate-180`:``}`,"aria-hidden":`true`})]}),k&&(0,y.jsxs)(`div`,{role:`menu`,className:`absolute right-0 top-[calc(100%+0.4rem)] z-20 w-60 overflow-hidden rounded-xl border border-border bg-popover p-1.5 text-popover-foreground shadow-baziu-lg`,onMouseLeave:()=>A(!1),children:[n.length===0?(0,y.jsxs)(`div`,{className:`rounded-lg bg-muted/40 px-3 py-2.5 text-xs leading-5 text-muted-foreground`,children:[`No Agent templates yet.`,` `,(0,y.jsx)(`a`,{href:`/templates/agents`,className:`text-primary underline`,children:`Create one to spawn agents.`})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-[0.68rem] font-semibold uppercase tracking-[0.1em] text-muted-foreground`,children:[(0,y.jsx)(d,{className:`size-3`,"aria-hidden":`true`}),`Agent templates`]}),L.map(e=>(0,y.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{A(!1),S({profileId:e.id})},className:`unstyled flex min-h-8 w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-sm text-foreground transition-colors hover:bg-accent hover:text-accent-foreground`,children:[(0,y.jsx)(`span`,{className:`flex size-6 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground`,children:(0,y.jsx)(d,{className:`size-3.5`,"aria-hidden":`true`})}),(0,y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name||e.id}),e.id==="default"&&(0,y.jsx)(`span`,{className:`rounded-full border border-border bg-muted px-1.5 py-0.5 text-[0.65rem] font-semibold text-muted-foreground`,children:`Default`})]},e.id))]}),(0,y.jsx)(`div`,{className:`my-1.5 h-px bg-border`}),(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-[0.68rem] font-semibold uppercase tracking-[0.1em] text-muted-foreground`,children:[(0,y.jsx)(l,{className:`size-3`,"aria-hidden":`true`}),`Team templates`]}),a.length===0?(0,y.jsxs)(`div`,{className:`rounded-lg bg-muted/40 px-3 py-2 text-xs leading-5 text-muted-foreground`,children:[`No team templates yet.`,` `,(0,y.jsx)(`a`,{href:`/templates/teams`,className:`text-primary underline`,children:`Create one`}),`.`]}):a.map(e=>(0,y.jsxs)(`button`,{type:`button`,role:`menuitem`,disabled:e.slotCount===0,title:e.slotCount===0?`Add at least one member before spawning`:void 0,onClick:()=>{A(!1),E(e)},className:`unstyled flex min-h-8 w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-sm text-foreground transition-colors hover:bg-accent hover:text-accent-foreground disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent`,children:[(0,y.jsx)(`span`,{className:`flex size-6 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground`,children:(0,y.jsx)(l,{className:`size-3.5`,"aria-hidden":`true`})}),(0,y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name||e.id}),(0,y.jsx)(`span`,{className:`inline-flex min-w-6 items-center justify-center rounded-full bg-muted px-1.5 font-mono text-[0.68rem] text-muted-foreground`,children:e.slotCount})]},e.id)),(0,y.jsx)(`div`,{className:`my-1.5 h-px bg-border`}),(0,y.jsxs)(`button`,{type:`button`,onClick:()=>{A(!1),O(!0)},className:`unstyled flex min-h-8 w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground`,children:[(0,y.jsx)(s,{className:`size-3.5`,"aria-hidden":`true`}),`Create a team`]})]})]})]}),(0,y.jsx)(`nav`,{className:`flex-1 overflow-y-auto p-1.5`,"aria-label":`Teams and agents`,children:e.length===0&&t.length===0?(0,y.jsxs)(`div`,{className:`m-1 flex flex-col items-center rounded-xl border border-dashed border-border bg-muted/30 px-4 py-6 text-center`,children:[(0,y.jsx)(`span`,{className:`mb-2 flex size-9 items-center justify-center rounded-full bg-accent text-accent-foreground`,children:(0,y.jsx)(d,{className:`size-4`,"aria-hidden":`true`})}),(0,y.jsx)(`p`,{className:`text-sm font-semibold text-foreground`,children:`No agents yet`}),(0,y.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:`Spawn your first agent to start a conversation.`}),(0,y.jsxs)(`a`,{href:`/agents`,className:`mt-3 inline-flex items-center gap-1 text-xs font-semibold text-primary hover:text-primary/80`,children:[`Open agent setup`,(0,y.jsx)(h,{className:`size-3.5`,"aria-hidden":`true`})]})]}):R.map(e=>{let t=z.get(e.id)??[],n=B===e.id,i=N[e.id];return(0,y.jsxs)(`details`,{open:i===void 0?n||e.id==="default":i,onToggle:t=>{let n=t.currentTarget.open;if(N[e.id]===n)return;let r={...N,[e.id]:n};T(r),P(r),f.invalidate()},className:`team/details mb-1 last:mb-0`,children:[(0,y.jsxs)(`summary`,{className:`flex min-h-8 cursor-pointer list-none items-center gap-1.5 rounded-lg px-2 py-1.5 text-sm transition-colors hover:bg-accent hover:text-accent-foreground ${n?`bg-muted/60 text-foreground`:`text-muted-foreground`}`,children:[(0,y.jsx)(h,{className:`size-3.5 shrink-0 transition-transform team-open/details:rotate-90`,"aria-hidden":`true`}),(0,y.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground`,children:(0,y.jsx)(l,{className:`size-3`,"aria-hidden":`true`})}),(0,y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:e.name}),e.id==="default"&&(0,y.jsx)(`span`,{className:`text-[0.62rem] font-semibold uppercase tracking-wide text-muted-foreground`,children:`Default`}),(0,y.jsx)(`span`,{className:`inline-flex min-w-6 items-center justify-center rounded-full border border-border bg-card px-1.5 font-mono text-[0.68rem] text-muted-foreground`,children:t.length})]}),t.length===0?(0,y.jsx)(`div`,{className:`py-2 pl-12 pr-2 text-xs text-muted-foreground`,children:`No agents in this team`}):(0,y.jsx)(`div`,{className:`space-y-0.5 py-0.5 pl-2`,children:t.map(e=>(0,y.jsxs)(`div`,{className:`team/row relative rounded-lg`,children:[(0,y.jsxs)(r,{to:`/`,search:{agent:e.id},"aria-current":e.id===c?`page`:void 0,className:`block min-h-11 rounded-lg border border-transparent py-1.5 pl-2.5 pr-[4.6rem] transition-colors hover:bg-accent/70 ${e.id===c?`border-primary/20 bg-accent text-accent-foreground shadow-baziu-sm`:`text-foreground`}`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium`,children:[(0,y.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full ${e.id===c?`bg-primary`:`bg-border`}`,"aria-hidden":`true`}),(0,y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),e.telegramTopicId!==null&&(0,y.jsx)(`span`,{className:`shrink-0 text-primary`,title:`Telegram topic #${e.telegramTopicId}`,"aria-label":`Bound to Telegram topic ${e.telegramTopicId}`,children:(0,y.jsx)(_,{className:`size-3`,"aria-hidden":`true`})})]}),(0,y.jsxs)(`div`,{className:`mt-0.5 flex gap-2 pl-3 font-mono text-[0.65rem] text-muted-foreground`,children:[(0,y.jsx)(`span`,{className:`uppercase tracking-wide`,children:e.status}),(0,y.jsx)(`span`,{children:e.id.slice(0,8)})]})]}),(0,y.jsxs)(`div`,{className:`absolute right-1 top-1/2 z-10 flex -translate-y-1/2 gap-0.5`,children:[(0,y.jsx)(`button`,{type:`button`,onClick:()=>F(e),title:`Rename`,"aria-label":`Rename ${e.name}`,className:`unstyled flex size-8 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-card hover:text-primary focus-visible:bg-card`,children:(0,y.jsx)(g,{className:`size-3.5`,"aria-hidden":`true`})}),(0,y.jsx)(`button`,{type:`button`,onClick:()=>I(e),title:`Archive`,"aria-label":`Archive ${e.name}`,className:`unstyled flex size-8 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:bg-destructive/10 focus-visible:text-destructive`,children:(0,y.jsx)(m,{className:`size-3.5`,"aria-hidden":`true`})})]})]},e.id))})]},e.id)})}),p&&(0,y.jsx)(x,{profileId:p.profileId,teamHint:p.teamHint,teams:R,onClose:()=>{S(null),M()}}),w&&(0,y.jsx)(C,{profileGroup:w,teams:R,onClose:()=>{E(null),M()},onSpawned:e=>{E(null),f.navigate({to:`/teams/$id`,params:{id:e}})}}),D&&(0,y.jsx)(b,{onClose:()=>{O(!1),M()}})]})}function D(){let e=u.useLoaderData(),t=e.selected?.resolved.agent.id??null;return(0,y.jsxs)(`div`,{className:`grid h-full min-h-0 grid-cols-1 gap-3 py-3 lg:grid-cols-[18rem_minmax(0,1fr)]`,children:[(0,y.jsx)(`div`,{className:`min-h-0 ${e.selected?`hidden lg:block`:``}`,children:(0,y.jsx)(E,{agents:e.agents,teams:e.teams,profiles:e.profiles,profileGroups:e.profileGroups,selectedAgentId:t,initialOpenGroups:e.initialOpenGroups})}),(0,y.jsx)(`section`,{className:`min-h-0 overflow-hidden ${e.selected?``:`hidden lg:block`}`,children:e.selected?(0,y.jsx)(f,{agentId:e.selected.resolved.agent.id,agentName:e.selected.resolved.agent.name,initialMessages:e.selected.initialMessages,initialSessionHead:e.selected.sessionHead}):(0,y.jsx)(`div`,{className:`flex h-full items-center justify-center rounded-lg border border-dashed bg-card text-muted-foreground`,children:e.agents.length===0?`No agents yet.`:`Pick an agent on the left to start chatting.`})})]})}export{D as component};
1
+ import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{a as r,d as i,o as a}from"./preload-helper-mNuBjNXU.js";import{t as o}from"./chevron-down-OndG7r1U.js";import{t as s}from"./plus-Dor-_wmL.js";import{A as c,O as l,T as u,k as d}from"./index-B3vdrEEg.js";import{i as f}from"./wire-constants-BhVKOCQa.js";import{t as p}from"./Button-ByiV6fpd.js";var m=c(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),h=c(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),g=c(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),_=c(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),v=e(n(),1),y=t();function b({onClose:e}){let t=i(),[n,r]=(0,v.useState)(``),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(null);async function m(r){if(r.preventDefault(),f(null),!n.trim()){f(`id is required`);return}u(!0);try{let r={id:n.trim()};a.trim()&&(r.name=a.trim()),s.trim()&&(r.link=s.trim());let i=await fetch(`/api/teams`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(r)});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.error??`${i.status} ${i.statusText}`)}e(),await t.invalidate()}catch(e){f(e.message),u(!1)}}return(0,y.jsx)(`div`,{onClick:e,onKeyDown:t=>{t.key===`Escape`&&e()},className:`fixed inset-0 z-50 flex items-center justify-center bg-charcoal/45 p-4 backdrop-blur-sm`,children:(0,y.jsxs)(`form`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`create-team-title`,onSubmit:m,onClick:e=>e.stopPropagation(),className:`max-h-[calc(100dvh-2rem)] w-full max-w-lg overflow-y-auto rounded-3xl border border-frost bg-card p-6 shadow-baziu-lg sm:p-7`,children:[(0,y.jsx)(`h2`,{id:`create-team-title`,className:`font-serif text-2xl text-foreground`,children:`Create a team`}),(0,y.jsxs)(`p`,{className:`text-sm text-muted-foreground mb-4`,children:[`A team is a collaboration context — one filesystem root, one USER.md, one roster. The slot lives at `,(0,y.jsx)(`code`,{className:`font-mono`,children:`~/.bazilion/teams/<slug>/`}),`.`]}),(0,y.jsxs)(`div`,{className:`mb-3 grid gap-3 sm:grid-cols-2`,children:[(0,y.jsxs)(`label`,{className:`block text-sm`,children:[`ID (slug)`,(0,y.jsx)(`input`,{type:`text`,value:n,onChange:e=>r(e.target.value),required:!0,pattern:`[a-z0-9][a-z0-9_-]*`,placeholder:`myproject`,autoFocus:!0,className:`mt-1 block w-full rounded-md border bg-background px-3 py-2 outline-none focus:ring-2 focus:ring-ring/30`})]}),(0,y.jsxs)(`label`,{className:`block text-sm`,children:[`Name `,(0,y.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`}),(0,y.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),className:`mt-1 block w-full rounded-md border bg-background px-3 py-2 outline-none focus:ring-2 focus:ring-ring/30`})]})]}),(0,y.jsxs)(`label`,{className:`block text-sm mb-3`,children:[`Link target`,` `,(0,y.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional, absolute path)`}),(0,y.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:`/home/you/projects/myrepo`,className:`mt-1 block w-full rounded-md border bg-background px-3 py-2 outline-none focus:ring-2 focus:ring-ring/30`}),(0,y.jsx)(`span`,{className:`mt-1 block text-xs text-muted-foreground`,children:`Leave blank to create a fresh directory. Supply an absolute path to materialize the slot as a symlink to your existing project tree.`})]}),d&&(0,y.jsx)(`p`,{className:`err mt-2`,children:d}),(0,y.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,y.jsx)(p,{variant:`ghost`,onClick:e,children:`Cancel`}),(0,y.jsx)(p,{variant:`primary`,type:`submit`,disabled:l,children:l?`Creating…`:`Create`})]})]})})}function x({profileId:e,teamHint:t,teams:n,onClose:r}){let i=a(),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(t??n.find(e=>e.id==="default")?.id??n[0]?.id??``),[u,d]=(0,v.useState)(`profile_defaults`),[f,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(null),[_,b]=(0,v.useState)(null);async function x(){let t=await fetch(`/api/teams/${encodeURIComponent(c)}/policy`);if(!t.ok)throw Error(`The selected Team policy is unavailable. Reload and try again.`);let n=await t.json();return{current:n,body:{profileId:e,teamId:c,teamExpectedRevision:n.teamPolicy.revision,placement:u}}}async function C(){g(null),m(!0);try{let{body:e}=await x(),t=await fetch(`/api/agents/placement-preview`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error??`Preview failed (${t.status})`)}b(await t.json())}catch(e){g(e.message)}finally{m(!1)}}async function w(t){t.preventDefault(),g(null),m(!0);try{if(!_){await C();return}let t={profile:e,teamExpectedRevision:_.currentRevision,placement:u};o.trim()&&(t.name=o.trim()),c&&(t.teamId=c);let n=await fetch(`/api/agents`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`${n.status} ${n.statusText}`)}let a=(await n.json()).agent;r(),await i({to:`/`,search:{agent:a.id}})}catch(e){g(e.message),m(!1)}}return(0,y.jsx)(S,{onClose:r,children:(0,y.jsxs)(`form`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`spawn-agent-title`,onSubmit:w,className:`max-h-[calc(100dvh-2rem)] w-full max-w-lg overflow-y-auto rounded-3xl border border-frost bg-card p-6 shadow-baziu-lg sm:p-7`,onClick:e=>e.stopPropagation(),children:[(0,y.jsx)(`h3`,{id:`spawn-agent-title`,className:`font-serif text-xl text-foreground mb-1`,children:`Spawn a new agent`}),(0,y.jsxs)(`p`,{className:`text-sm text-muted-foreground mb-4`,children:[`Profile: `,(0,y.jsx)(`code`,{className:`font-mono`,children:e})]}),(0,y.jsxs)(`label`,{className:`block text-sm text-foreground mb-3`,children:[`Agent name`,` `,(0,y.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional — defaults to the profile's name)`}),(0,y.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),autoFocus:!0,autoComplete:`off`,className:`mt-1 block w-full rounded-md border bg-background px-3 py-2 outline-none focus:ring-2 focus:ring-ring/30`})]}),(0,y.jsxs)(`label`,{className:`block text-sm text-foreground mb-3`,children:[`Initial policy placement`,(0,y.jsxs)(`select`,{value:u,onChange:e=>{d(e.target.value),b(null)},className:`mt-1 block w-full rounded-md border bg-background px-3 py-2`,children:[(0,y.jsx)(`option`,{value:`profile_defaults`,children:`Agent-template defaults`}),(0,y.jsx)(`option`,{value:`isolated`,children:`isolated`})]}),(0,y.jsx)(`span`,{className:`mt-1 block text-xs text-muted-foreground`,children:`The current Team revision is checked again when you submit.`})]}),(0,y.jsxs)(`label`,{className:`block text-sm text-foreground mb-3`,children:[`Team`,(0,y.jsx)(`select`,{value:c,onChange:e=>{l(e.target.value),b(null)},className:`mt-1 block w-full rounded-md border bg-background px-3 py-2 outline-none focus:ring-2 focus:ring-ring/30`,children:n.map(e=>(0,y.jsxs)(`option`,{value:e.id,children:[e.name,e.id==="default"?` (default)`:``]},e.id))})]}),h&&(0,y.jsx)(`p`,{className:`err mt-2`,children:h}),_&&(0,y.jsxs)(`div`,{className:`mt-3 rounded-md border border-sapphire-light bg-sapphire-glow p-3 text-sm`,children:[(0,y.jsxs)(`p`,{children:[`Creating this Agent advances Team revision `,_.currentRevision,` → `,(0,y.jsx)(`strong`,{children:_.resultingRevision}),` and adds `,(0,y.jsx)(`strong`,{children:_.addedEdges.length}),` directed edges to the existing `,_.existingEdges.length,`.`]}),(0,y.jsx)(`ul`,{className:`mt-2 max-h-36 overflow-auto`,children:_.addedEdges.map((e,t)=>(0,y.jsx)(`li`,{children:(0,y.jsxs)(`code`,{children:[e.sourceKind,e.sourceId?`:${e.sourceId}`:``,` → `,e.targetKind,e.targetId?`:${e.targetId}`:``]})},`${e.sourceKind}:${e.sourceId??``}>${e.targetKind}:${e.targetId??``}:${t}`))}),_.addedEdges.length===0&&(0,y.jsx)(`p`,{className:`mt-2`,children:`The new Agent starts isolated.`})]}),(0,y.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,y.jsx)(p,{variant:`ghost`,onClick:r,children:`Cancel`}),(0,y.jsx)(p,{variant:`primary`,type:`submit`,disabled:f,children:f?`Working…`:_?`Commit reviewed creation`:`Review exact policy`})]})]})})}function S({children:e,onClose:t}){return(0,y.jsx)(`div`,{onClick:t,onKeyDown:e=>{e.key===`Escape`&&t()},className:`fixed inset-0 z-50 flex items-center justify-center bg-charcoal/45 p-4 backdrop-blur-sm`,children:e})}function C({profileGroup:e,teams:t,onClose:n,onSpawned:r}){let[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(!1),[f,m]=(0,v.useState)(null),h=(0,v.useRef)(null);(0,v.useEffect)(()=>{h.current?.focus()},[]);async function g(){let n=i.trim();if(!n)throw Error(`target Team slug is required`);let r=t.find(e=>e.id===n),a;if(r){let e=await fetch(`/api/teams/${encodeURIComponent(n)}/policy`);if(!e.ok)throw Error(`The target Team policy is unavailable.`);a=(await e.json()).teamPolicy.revision}return{target:n,body:{templateExpectedRevision:e.currentRevision,teamId:n,...a?{teamExpectedRevision:a}:{},mode:r?`append`:`initialize`,...o?{userMd:o}:{}}}}async function _(){d(!0),l(null),m(null);try{let{body:t}=await g(),n=await fetch(`/api/team-templates/${encodeURIComponent(e.id)}/spawn/preview`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(!n.ok)throw Error((await n.json().catch(()=>null))?.error??n.statusText);m(await n.json())}catch(e){l(e.message)}finally{d(!1)}}async function b(){let t=i.trim();if(!t){l(`target Team slug is required`);return}d(!0),l(null);try{let{body:n}=await g(),i=await fetch(`/api/team-templates/${encodeURIComponent(e.id)}/spawn`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n)});if(!i.ok)throw Error((await i.json().catch(()=>null))?.error??i.statusText);r(t)}catch(e){l(e.message)}finally{d(!1)}}return(0,y.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`spawn-team-title`,className:`fixed inset-0 z-50 flex items-center justify-center bg-charcoal/45 p-4 backdrop-blur-sm`,onClick:n,onKeyDown:e=>{e.key===`Escape`&&n()},children:(0,y.jsxs)(`div`,{ref:h,tabIndex:-1,className:`max-h-[calc(100dvh-2rem)] w-full max-w-lg overflow-y-auto rounded-3xl border border-frost bg-card p-6 shadow-baziu-lg sm:p-7`,role:`document`,onClick:e=>e.stopPropagation(),onKeyDown:e=>{e.key!==`Escape`&&e.stopPropagation()},children:[(0,y.jsxs)(`h2`,{id:`spawn-team-title`,children:[`Spawn team — `,e.name]}),c&&(0,y.jsx)(`div`,{className:`err`,children:c}),(0,y.jsxs)(`p`,{className:`muted`,children:[`Uses immutable Team revision `,e.currentRevision,`. Existing Teams append at their current reviewed revision; a new Team initializes at revision 1. Conflicts never overwrite newer state.`]}),(0,y.jsxs)(`label`,{children:[`target Team slug`,(0,y.jsx)(`input`,{value:i,onChange:e=>{a(e.target.value),m(null)},list:`canonical-teams`,required:!0}),(0,y.jsx)(`datalist`,{id:`canonical-teams`,children:t.map(e=>(0,y.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,y.jsxs)(`label`,{children:[`starter USER.md (new Team only)`,(0,y.jsx)(`textarea`,{rows:3,value:o,onChange:e=>{s(e.target.value),m(null)},className:`font-mono text-[0.88em] leading-[1.55]`})]}),f&&(0,y.jsxs)(`div`,{className:`mt-4 rounded-md border border-sapphire-light bg-sapphire-glow p-3 text-sm`,children:[(0,y.jsxs)(`p`,{children:[(0,y.jsx)(`strong`,{children:f.mode===`initialize`?`Initialize`:`Append`}),` produces Team revision `,f.resultingRevision,`, adds `,f.newMembers.length,` Agents, and results in `,f.edges.length,` directed allow edges.`]}),(0,y.jsx)(`ul`,{className:`mt-2 max-h-40 overflow-auto`,children:f.newMembers.map(e=>(0,y.jsxs)(`li`,{children:[e.agentName,` · stable source slot `,(0,y.jsx)(`code`,{children:e.slotId})]},e.slotId))}),(0,y.jsxs)(`details`,{className:`mt-2`,children:[(0,y.jsx)(`summary`,{className:`cursor-pointer`,children:`Review exact edge topology`}),(0,y.jsx)(`ul`,{className:`mt-2 max-h-40 overflow-auto`,children:f.edges.map((e,t)=>(0,y.jsx)(`li`,{children:(0,y.jsxs)(`code`,{children:[e.sourceKind,e.sourceId?`:${e.sourceId}`:``,` → `,e.targetKind,e.targetId?`:${e.targetId}`:``]})},`${e.sourceKind}:${e.sourceId??``}>${e.targetKind}:${e.targetId??``}:${t}`))})]})]}),(0,y.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,y.jsx)(p,{variant:`ghost`,onClick:n,children:`cancel`}),f?(0,y.jsx)(p,{variant:`primary`,onClick:b,disabled:u,children:u?`spawning…`:`commit ${f.mode}`}):(0,y.jsx)(p,{variant:`primary`,onClick:_,disabled:u||e.slotCount===0,children:u?`reviewing…`:`review exact result`})]})]})})}var w=`bz_sidebar_open_groups`;function T(e){if(typeof document>`u`)return;let t=encodeURIComponent(JSON.stringify(e));document.cookie=`${w}=${t}; Path=/; Max-Age=31536000; SameSite=Lax`}function E({agents:e,teams:t,profiles:n,profileGroups:a,selectedAgentId:c,initialOpenGroups:u}){let f=i(),[p,S]=(0,v.useState)(null),[w,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(!1),[k,A]=(0,v.useState)(!1),j=(0,v.useRef)(null),M=()=>window.requestAnimationFrame(()=>j.current?.focus()),[N,P]=(0,v.useState)(()=>u??{});async function F(e){let t=window.prompt(`rename "${e.name}" to:`,e.name)?.trim();if(!t||t===e.name)return;let n=await fetch(`/api/agents/${e.id}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({name:t})});if(!n.ok){let e=await n.json().catch(()=>null);alert(e?.error??n.statusText);return}await f.invalidate()}async function I(e){if(!confirm(`archive "${e.name}"? (reversible — find under "show archived")`))return;let t=await fetch(`/api/agents/${e.id}/archive`,{method:`POST`});if(!t.ok&&t.status!==204){alert(t.statusText);return}await f.invalidate()}let L=[...n].sort((e,t)=>e.id==="default"?-1:+(t.id==="default")),R=[...t].sort((e,t)=>e.id==="default"?-1:+(t.id==="default")),z=new Map;for(let t of e){let e=z.get(t.teamId)??[];e.push(t),z.set(t.teamId,e)}let B=e.find(e=>e.id===c)?.teamId??null;return(0,y.jsxs)(`aside`,{className:`flex h-full flex-col overflow-hidden rounded-2xl border border-border bg-card shadow-baziu-sm`,children:[(0,y.jsxs)(`header`,{className:`flex items-center justify-between gap-3 border-b border-border bg-muted/30 px-3 py-2.5`,children:[(0,y.jsxs)(`div`,{className:`min-w-0`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-foreground`,children:[(0,y.jsx)(`span`,{className:`flex size-7 items-center justify-center rounded-lg bg-accent text-accent-foreground`,children:(0,y.jsx)(d,{className:`size-4`,"aria-hidden":`true`})}),(0,y.jsx)(`span`,{children:`Agents`})]}),(0,y.jsxs)(`p`,{className:`mt-0.5 truncate pl-9 text-[0.7rem] text-muted-foreground`,children:[e.length,` agent`,e.length===1?``:`s`,` across `,t.length,` team`,t.length===1?``:`s`]})]}),(0,y.jsxs)(`div`,{className:`relative`,children:[(0,y.jsxs)(`button`,{ref:j,type:`button`,onClick:()=>A(e=>!e),"aria-expanded":k,"aria-haspopup":`menu`,className:`unstyled inline-flex h-8 items-center gap-1 rounded-lg border border-border bg-card px-2.5 text-xs font-semibold text-foreground shadow-baziu-sm transition-colors hover:border-primary/30 hover:bg-accent hover:text-accent-foreground`,children:[(0,y.jsx)(s,{className:`size-3.5`,"aria-hidden":`true`}),`New`,(0,y.jsx)(o,{className:`size-3.5 text-muted-foreground transition-transform ${k?`rotate-180`:``}`,"aria-hidden":`true`})]}),k&&(0,y.jsxs)(`div`,{role:`menu`,className:`absolute right-0 top-[calc(100%+0.4rem)] z-20 w-60 overflow-hidden rounded-xl border border-border bg-popover p-1.5 text-popover-foreground shadow-baziu-lg`,onMouseLeave:()=>A(!1),children:[n.length===0?(0,y.jsxs)(`div`,{className:`rounded-lg bg-muted/40 px-3 py-2.5 text-xs leading-5 text-muted-foreground`,children:[`No Agent templates yet.`,` `,(0,y.jsx)(`a`,{href:`/templates/agents`,className:`text-primary underline`,children:`Create one to spawn agents.`})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-[0.68rem] font-semibold uppercase tracking-[0.1em] text-muted-foreground`,children:[(0,y.jsx)(d,{className:`size-3`,"aria-hidden":`true`}),`Agent templates`]}),L.map(e=>(0,y.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{A(!1),S({profileId:e.id})},className:`unstyled flex min-h-8 w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-sm text-foreground transition-colors hover:bg-accent hover:text-accent-foreground`,children:[(0,y.jsx)(`span`,{className:`flex size-6 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground`,children:(0,y.jsx)(d,{className:`size-3.5`,"aria-hidden":`true`})}),(0,y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name||e.id}),e.id==="default"&&(0,y.jsx)(`span`,{className:`rounded-full border border-border bg-muted px-1.5 py-0.5 text-[0.65rem] font-semibold text-muted-foreground`,children:`Default`})]},e.id))]}),(0,y.jsx)(`div`,{className:`my-1.5 h-px bg-border`}),(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-[0.68rem] font-semibold uppercase tracking-[0.1em] text-muted-foreground`,children:[(0,y.jsx)(l,{className:`size-3`,"aria-hidden":`true`}),`Team templates`]}),a.length===0?(0,y.jsxs)(`div`,{className:`rounded-lg bg-muted/40 px-3 py-2 text-xs leading-5 text-muted-foreground`,children:[`No team templates yet.`,` `,(0,y.jsx)(`a`,{href:`/templates/teams`,className:`text-primary underline`,children:`Create one`}),`.`]}):a.map(e=>(0,y.jsxs)(`button`,{type:`button`,role:`menuitem`,disabled:e.slotCount===0,title:e.slotCount===0?`Add at least one member before spawning`:void 0,onClick:()=>{A(!1),E(e)},className:`unstyled flex min-h-8 w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-sm text-foreground transition-colors hover:bg-accent hover:text-accent-foreground disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent`,children:[(0,y.jsx)(`span`,{className:`flex size-6 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground`,children:(0,y.jsx)(l,{className:`size-3.5`,"aria-hidden":`true`})}),(0,y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name||e.id}),(0,y.jsx)(`span`,{className:`inline-flex min-w-6 items-center justify-center rounded-full bg-muted px-1.5 font-mono text-[0.68rem] text-muted-foreground`,children:e.slotCount})]},e.id)),(0,y.jsx)(`div`,{className:`my-1.5 h-px bg-border`}),(0,y.jsxs)(`button`,{type:`button`,onClick:()=>{A(!1),O(!0)},className:`unstyled flex min-h-8 w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground`,children:[(0,y.jsx)(s,{className:`size-3.5`,"aria-hidden":`true`}),`Create a team`]})]})]})]}),(0,y.jsx)(`nav`,{className:`flex-1 overflow-y-auto p-1.5`,"aria-label":`Teams and agents`,children:e.length===0&&t.length===0?(0,y.jsxs)(`div`,{className:`m-1 flex flex-col items-center rounded-xl border border-dashed border-border bg-muted/30 px-4 py-6 text-center`,children:[(0,y.jsx)(`span`,{className:`mb-2 flex size-9 items-center justify-center rounded-full bg-accent text-accent-foreground`,children:(0,y.jsx)(d,{className:`size-4`,"aria-hidden":`true`})}),(0,y.jsx)(`p`,{className:`text-sm font-semibold text-foreground`,children:`No agents yet`}),(0,y.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:`Spawn your first agent to start a conversation.`}),(0,y.jsxs)(`a`,{href:`/agents`,className:`mt-3 inline-flex items-center gap-1 text-xs font-semibold text-primary hover:text-primary/80`,children:[`Open agent setup`,(0,y.jsx)(h,{className:`size-3.5`,"aria-hidden":`true`})]})]}):R.map(e=>{let t=z.get(e.id)??[],n=B===e.id,i=N[e.id];return(0,y.jsxs)(`details`,{open:i===void 0?n||e.id==="default":i,onToggle:t=>{let n=t.currentTarget.open;if(N[e.id]===n)return;let r={...N,[e.id]:n};T(r),P(r),f.invalidate()},className:`team/details mb-1 last:mb-0`,children:[(0,y.jsxs)(`summary`,{className:`flex min-h-8 cursor-pointer list-none items-center gap-1.5 rounded-lg px-2 py-1.5 text-sm transition-colors hover:bg-accent hover:text-accent-foreground ${n?`bg-muted/60 text-foreground`:`text-muted-foreground`}`,children:[(0,y.jsx)(h,{className:`size-3.5 shrink-0 transition-transform team-open/details:rotate-90`,"aria-hidden":`true`}),(0,y.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground`,children:(0,y.jsx)(l,{className:`size-3`,"aria-hidden":`true`})}),(0,y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:e.name}),e.id==="default"&&(0,y.jsx)(`span`,{className:`text-[0.62rem] font-semibold uppercase tracking-wide text-muted-foreground`,children:`Default`}),(0,y.jsx)(`span`,{className:`inline-flex min-w-6 items-center justify-center rounded-full border border-border bg-card px-1.5 font-mono text-[0.68rem] text-muted-foreground`,children:t.length})]}),t.length===0?(0,y.jsx)(`div`,{className:`py-2 pl-12 pr-2 text-xs text-muted-foreground`,children:`No agents in this team`}):(0,y.jsx)(`div`,{className:`space-y-0.5 py-0.5 pl-2`,children:t.map(e=>(0,y.jsxs)(`div`,{className:`team/row relative rounded-lg`,children:[(0,y.jsxs)(r,{to:`/`,search:{agent:e.id},"aria-current":e.id===c?`page`:void 0,className:`block min-h-11 rounded-lg border border-transparent py-1.5 pl-2.5 pr-[4.6rem] transition-colors hover:bg-accent/70 ${e.id===c?`border-primary/20 bg-accent text-accent-foreground shadow-baziu-sm`:`text-foreground`}`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium`,children:[(0,y.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full ${e.id===c?`bg-primary`:`bg-border`}`,"aria-hidden":`true`}),(0,y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),e.telegramTopicId!==null&&(0,y.jsx)(`span`,{className:`shrink-0 text-primary`,title:`Telegram topic #${e.telegramTopicId}`,"aria-label":`Bound to Telegram topic ${e.telegramTopicId}`,children:(0,y.jsx)(_,{className:`size-3`,"aria-hidden":`true`})})]}),(0,y.jsxs)(`div`,{className:`mt-0.5 flex gap-2 pl-3 font-mono text-[0.65rem] text-muted-foreground`,children:[(0,y.jsx)(`span`,{className:`uppercase tracking-wide`,children:e.status}),(0,y.jsx)(`span`,{children:e.id.slice(0,8)})]})]}),(0,y.jsxs)(`div`,{className:`absolute right-1 top-1/2 z-10 flex -translate-y-1/2 gap-0.5`,children:[(0,y.jsx)(`button`,{type:`button`,onClick:()=>F(e),title:`Rename`,"aria-label":`Rename ${e.name}`,className:`unstyled flex size-8 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-card hover:text-primary focus-visible:bg-card`,children:(0,y.jsx)(g,{className:`size-3.5`,"aria-hidden":`true`})}),(0,y.jsx)(`button`,{type:`button`,onClick:()=>I(e),title:`Archive`,"aria-label":`Archive ${e.name}`,className:`unstyled flex size-8 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:bg-destructive/10 focus-visible:text-destructive`,children:(0,y.jsx)(m,{className:`size-3.5`,"aria-hidden":`true`})})]})]},e.id))})]},e.id)})}),p&&(0,y.jsx)(x,{profileId:p.profileId,teamHint:p.teamHint,teams:R,onClose:()=>{S(null),M()}}),w&&(0,y.jsx)(C,{profileGroup:w,teams:R,onClose:()=>{E(null),M()},onSpawned:e=>{E(null),f.navigate({to:`/teams/$id`,params:{id:e}})}}),D&&(0,y.jsx)(b,{onClose:()=>{O(!1),M()}})]})}function D(){let e=u.useLoaderData(),t=e.selected?.resolved.agent.id??null;return(0,y.jsxs)(`div`,{className:`grid h-full min-h-0 grid-cols-1 gap-3 py-3 lg:grid-cols-[18rem_minmax(0,1fr)]`,children:[(0,y.jsx)(`div`,{className:`min-h-0 ${e.selected?`hidden lg:block`:``}`,children:(0,y.jsx)(E,{agents:e.agents,teams:e.teams,profiles:e.profiles,profileGroups:e.profileGroups,selectedAgentId:t,initialOpenGroups:e.initialOpenGroups})}),(0,y.jsx)(`section`,{className:`min-h-0 overflow-hidden ${e.selected?``:`hidden lg:block`}`,children:e.selected?(0,y.jsx)(f,{agentId:e.selected.resolved.agent.id,agentName:e.selected.resolved.agent.name,initialMessages:e.selected.initialMessages,initialSessionHead:e.selected.sessionHead}):(0,y.jsx)(`div`,{className:`flex h-full items-center justify-center rounded-lg border border-dashed bg-card text-muted-foreground`,children:e.agents.length===0?`No agents yet.`:`Pick an agent on the left to start chatting.`})})]})}export{D as component};
@@ -1 +1 @@
1
- import{t as e}from"./jsx-runtime-DGeXAQPT.js";import{_ as t}from"./index-3nrK5iFr.js";import{t as n}from"./ConfigPage-BCwfgyjD.js";import{t as r}from"./FieldRow-avAFLgYW.js";var i=e(),a=`Other`;function o(e){let t=new Map;for(let n of e){let e=n.team??a,r=t.get(e)??[];r.push(n),t.set(e,r)}let n=Array.from(t,([e,t])=>({team:e,items:t}));return n.length>1&&n.sort((e,t)=>e.team===a?1:t.team===a?-1:0),n}function s(){let{services:e}=t.useLoaderData(),a=o(e);return(0,i.jsxs)(n,{active:`services`,title:`Services`,description:(0,i.jsxs)(i.Fragment,{children:[`Configure non-LLM integrations such as web search and crawlers. Secret fields are encrypted in the `,(0,i.jsx)(`code`,{className:`font-mono`,children:`secrets`}),` table; URLs and IDs live in the `,(0,i.jsx)(`code`,{className:`font-mono`,children:`config`}),` table.`]}),children:[e.length===0&&(0,i.jsx)(`p`,{className:`text-muted-foreground italic`,children:`(no services registered)`}),a.map(({team:e,items:t})=>(0,i.jsxs)(`section`,{children:[(0,i.jsx)(`h2`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:e}),t.map(e=>(0,i.jsxs)(`section`,{className:`rounded-lg border bg-card p-5 mb-3`,children:[(0,i.jsxs)(`header`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[(0,i.jsx)(`span`,{className:`font-mono font-semibold`,children:e.id}),(0,i.jsxs)(`span`,{className:`text-muted-foreground text-sm`,children:[`· `,e.displayName]})]}),e.hint&&(0,i.jsx)(`p`,{className:`text-xs text-muted-foreground mb-2`,children:e.hint}),e.fields.map(e=>(0,i.jsx)(r,{field:e},e.envVar))]},e.id))]},e))]})}export{s as component};
1
+ import{t as e}from"./jsx-runtime-DGeXAQPT.js";import{_ as t}from"./index-B3vdrEEg.js";import{t as n}from"./ConfigPage-BCwfgyjD.js";import{t as r}from"./FieldRow-avAFLgYW.js";var i=e(),a=`Other`;function o(e){let t=new Map;for(let n of e){let e=n.team??a,r=t.get(e)??[];r.push(n),t.set(e,r)}let n=Array.from(t,([e,t])=>({team:e,items:t}));return n.length>1&&n.sort((e,t)=>e.team===a?1:t.team===a?-1:0),n}function s(){let{services:e}=t.useLoaderData(),a=o(e);return(0,i.jsxs)(n,{active:`services`,title:`Services`,description:(0,i.jsxs)(i.Fragment,{children:[`Configure non-LLM integrations such as web search and crawlers. Secret fields are encrypted in the `,(0,i.jsx)(`code`,{className:`font-mono`,children:`secrets`}),` table; URLs and IDs live in the `,(0,i.jsx)(`code`,{className:`font-mono`,children:`config`}),` table.`]}),children:[e.length===0&&(0,i.jsx)(`p`,{className:`text-muted-foreground italic`,children:`(no services registered)`}),a.map(({team:e,items:t})=>(0,i.jsxs)(`section`,{children:[(0,i.jsx)(`h2`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:e}),t.map(e=>(0,i.jsxs)(`section`,{className:`rounded-lg border bg-card p-5 mb-3`,children:[(0,i.jsxs)(`header`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[(0,i.jsx)(`span`,{className:`font-mono font-semibold`,children:e.id}),(0,i.jsxs)(`span`,{className:`text-muted-foreground text-sm`,children:[`· `,e.displayName]})]}),e.hint&&(0,i.jsx)(`p`,{className:`text-xs text-muted-foreground mb-2`,children:e.hint}),e.fields.map(e=>(0,i.jsx)(r,{field:e},e.envVar))]},e.id))]},e))]})}export{s as component};
@@ -1 +1 @@
1
- import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{d as r}from"./preload-helper-mNuBjNXU.js";import{C as i}from"./index-3nrK5iFr.js";import{a,i as o,n as s,r as c,t as l}from"./Page-CwNuDhWz.js";import{t as u}from"./Button-ByiV6fpd.js";var d=e(n()),f=t();function p(){let e=i.useLoaderData(),t=r();async function n(e){if(!confirm(`Remove skill "${e}"? This deletes the directory on disk.`))return;let n=await fetch(`/api/skills/${encodeURIComponent(e)}`,{method:`DELETE`});if(!n.ok&&n.status!==204){alert(n.statusText);return}await t.invalidate()}return(0,f.jsxs)(c,{size:`wide`,children:[(0,f.jsx)(s,{title:`Skills`,description:`Install and review the prompt-only skills available to your agents.`}),(0,f.jsx)(m,{onImported:()=>t.invalidate()}),(0,f.jsx)(o,{title:`Installed skills`,description:`${e.length} skill${e.length===1?``:`s`} available`,children:e.length===0?(0,f.jsx)(l,{title:`No skills installed`,description:`Import from OpenClaw, a server directory, or a ZIP archive to get started.`}):(0,f.jsx)(`div`,{className:`overflow-x-auto`,children:(0,f.jsxs)(`table`,{className:`m-0 min-w-[760px]`,children:[(0,f.jsx)(`thead`,{children:(0,f.jsxs)(`tr`,{children:[(0,f.jsx)(`th`,{children:`Name`}),(0,f.jsx)(`th`,{children:`Description`}),(0,f.jsx)(`th`,{children:`Scan`}),(0,f.jsx)(`th`,{children:`Source`}),(0,f.jsx)(`th`,{})]})}),(0,f.jsx)(`tbody`,{children:e.map(e=>(0,f.jsxs)(`tr`,{children:[(0,f.jsx)(`td`,{children:(0,f.jsx)(`code`,{children:e.name})}),(0,f.jsx)(`td`,{className:`max-w-xl`,children:e.parseError?(0,f.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[(0,f.jsx)(a,{variant:`danger`,children:`Parse error`}),(0,f.jsx)(`span`,{className:`text-destructive`,children:e.parseError})]}):e.description}),(0,f.jsx)(`td`,{children:(0,f.jsx)(h,{findings:e.scanFindings??[]})}),(0,f.jsxs)(`td`,{className:`text-xs text-muted-foreground`,children:[(0,f.jsx)(`span`,{className:`font-mono`,children:e.source??`Unknown`}),e.importedAt&&(0,f.jsx)(`div`,{className:`mt-1 font-mono`,children:new Date(e.importedAt).toLocaleDateString()})]}),(0,f.jsx)(`td`,{className:`text-right`,children:(0,f.jsx)(u,{variant:`danger`,className:`whitespace-nowrap`,onClick:()=>n(e.name),children:`Remove`})})]},e.name))})]})})})]})}function m({onImported:e}){let[t,n]=(0,d.useState)(`openclaw`),[r,i]=(0,d.useState)(``),[s,c]=(0,d.useState)(!1),[l,p]=(0,d.useState)(null),[m,h]=(0,d.useState)(!1),[v,y]=(0,d.useState)(null),[b,x]=(0,d.useState)([]),[S,C]=(0,d.useState)(!1),w=(0,d.useRef)(null);async function T(n){n.preventDefault(),y(null),x([]),C(!0);try{let n;if(t===`zip`){if(!l){y(`Choose a ZIP file first.`),C(!1);return}let e=new FormData;e.set(`file`,l),s&&e.set(`force`,`true`),n=await fetch(`/api/skills/import`,{method:`POST`,body:e})}else{let e;if(t===`openclaw`)e=`openclaw`;else if(e=r.trim(),!e){y(`Enter the server path.`),C(!1);return}n=await fetch(`/api/skills/import`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({source:e,force:s})})}if(!n.ok){let e=await n.json().catch(()=>null);throw x(e?.findings??[]),Error(e?.error??`${n.status} ${n.statusText}`)}x(_((await n.json().catch(()=>null))?.findings)),i(``),p(null),e()}catch(e){y(e.message)}finally{C(!1)}}function E(e){p(e.target.files?.[0]??null)}function D(e){e.preventDefault(),h(!1);let t=e.dataTransfer?.files;if(!t||t.length===0)return;let n=t[0];if(n){if(!/\.zip$/i.test(n.name)){y(`Only ZIP archives are supported.`);return}if(p(n),w.current){let e=new DataTransfer;e.items.add(n),w.current.files=e.files}}}let O=b.some(e=>e.severity===`danger`)?`danger`:`warning`;return(0,f.jsxs)(o,{title:`Import skills`,description:(0,f.jsxs)(f.Fragment,{children:[`Choose a source. Each skill's `,(0,f.jsx)(`code`,{children:`SKILL.md`}),` body is injected into the system prompt of any agent it is attached to.`]}),children:[(0,f.jsx)(`div`,{role:`tablist`,className:`mb-5 inline-flex max-w-full gap-0 overflow-x-auto rounded-lg border border-border bg-muted p-1`,children:[{id:`openclaw`,label:`OpenClaw`},{id:`path`,label:`Server directory`},{id:`zip`,label:`Upload ZIP`}].map(e=>(0,f.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.id,onClick:()=>{n(e.id),y(null)},className:`unstyled cursor-pointer whitespace-nowrap rounded-md border-none bg-transparent px-3 py-1.5 text-sm font-medium transition-colors ${t===e.id?`bg-card text-accent-foreground shadow-baziu-sm`:`text-muted-foreground hover:bg-accent/50 hover:text-foreground`}`,children:e.label},e.id))}),v&&(0,f.jsx)(`div`,{role:`alert`,className:`mb-4 rounded-lg border border-destructive/20 bg-destructive/10 px-4 py-3 text-sm text-destructive`,children:v}),b.length>0&&(0,f.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-muted/30 p-4 text-sm`,children:[(0,f.jsx)(a,{variant:O,className:`mb-2`,children:`Scan findings`}),(0,f.jsx)(g,{findings:b})]}),(0,f.jsxs)(`form`,{className:`space-y-4`,onSubmit:T,children:[t===`openclaw`&&(0,f.jsxs)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:[`One-click import of every skill found in `,(0,f.jsx)(`code`,{children:`~/.openclaw/skills`}),` on the server.`]}),t===`path`&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:[`Import from an absolute path on the server — either a single skill folder (contains `,(0,f.jsx)(`code`,{children:`SKILL.md`}),`) or a parent folder holding many skill subfolders.`]}),(0,f.jsxs)(`label`,{className:`max-w-2xl`,children:[`Server path`,(0,f.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`/home/you/my-skills`,required:!0})]})]}),t===`zip`&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:[`Upload a `,(0,f.jsx)(`code`,{children:`.zip`}),` archive whose top level contains one folder per skill — the folder name becomes the skill name.`]}),(0,f.jsxs)(`label`,{onDragOver:e=>{e.preventDefault(),h(!0)},onDragLeave:()=>h(!1),onDrop:D,className:`block cursor-pointer rounded-xl border-2 border-dashed p-8 text-center transition-colors ${m?`border-primary bg-accent text-accent-foreground`:l?`border-solid border-primary/40 bg-card text-foreground`:`border-border bg-muted/30 text-muted-foreground hover:border-primary hover:bg-accent hover:text-accent-foreground`}`,children:[(0,f.jsx)(`input`,{ref:w,type:`file`,accept:`.zip,application/zip`,onChange:E,className:`absolute h-px w-px overflow-hidden opacity-0`}),l?(0,f.jsx)(`span`,{className:`block break-all font-mono text-sm text-accent-foreground`,children:l.name}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`span`,{className:`block text-sm font-medium text-foreground`,children:`Click to choose a ZIP file`}),(0,f.jsx)(`span`,{className:`text-xs`,children:`or drag and drop it here`})]})]})]}),(0,f.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,f.jsx)(u,{variant:`primary`,type:`submit`,disabled:S,children:S?`Importing…`:t===`zip`?`Upload and import`:t===`openclaw`?`Import from OpenClaw`:`Import`}),(0,f.jsxs)(`label`,{className:`m-0 inline-flex cursor-pointer items-center gap-1 text-sm text-foreground`,children:[(0,f.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked)}),(0,f.jsx)(`span`,{children:`Overwrite existing`}),(0,f.jsx)(`span`,{className:`text-muted-foreground`,children:`and confirm scan findings`})]})]})]})]})}function h({findings:e}){return e.length===0?(0,f.jsx)(a,{variant:`success`,children:`Clean`}):(0,f.jsxs)(`details`,{className:`text-xs`,children:[(0,f.jsx)(`summary`,{className:`cursor-pointer list-none`,children:(0,f.jsxs)(a,{variant:e.some(e=>e.severity===`danger`)?`danger`:`warning`,children:[e.length,` finding`,e.length===1?``:`s`]})}),(0,f.jsx)(`div`,{className:`mt-2 min-w-64`,children:(0,f.jsx)(g,{findings:e})})]})}function g({findings:e}){return(0,f.jsx)(`ul`,{className:`m-0 space-y-1.5 pl-0`,children:e.map((e,t)=>(0,f.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,f.jsx)(a,{variant:e.severity===`danger`?`danger`:`warning`,children:e.severity===`danger`?`Danger`:`Warning`}),(0,f.jsxs)(`span`,{children:[(0,f.jsx)(`code`,{children:e.code}),e.line?`, line ${e.line}`:``,` — `,e.message]})]},`${e.code}-${e.line??0}-${t}`))})}function _(e){return e?Object.entries(e).flatMap(([e,t])=>t.map(t=>({...t,message:`${e}: ${t.message}`}))):[]}export{p as component};
1
+ import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{d as r}from"./preload-helper-mNuBjNXU.js";import{C as i}from"./index-B3vdrEEg.js";import{a,i as o,n as s,r as c,t as l}from"./Page-CwNuDhWz.js";import{t as u}from"./Button-ByiV6fpd.js";var d=e(n()),f=t();function p(){let e=i.useLoaderData(),t=r();async function n(e){if(!confirm(`Remove skill "${e}"? This deletes the directory on disk.`))return;let n=await fetch(`/api/skills/${encodeURIComponent(e)}`,{method:`DELETE`});if(!n.ok&&n.status!==204){alert(n.statusText);return}await t.invalidate()}return(0,f.jsxs)(c,{size:`wide`,children:[(0,f.jsx)(s,{title:`Skills`,description:`Install and review the prompt-only skills available to your agents.`}),(0,f.jsx)(m,{onImported:()=>t.invalidate()}),(0,f.jsx)(o,{title:`Installed skills`,description:`${e.length} skill${e.length===1?``:`s`} available`,children:e.length===0?(0,f.jsx)(l,{title:`No skills installed`,description:`Import from OpenClaw, a server directory, or a ZIP archive to get started.`}):(0,f.jsx)(`div`,{className:`overflow-x-auto`,children:(0,f.jsxs)(`table`,{className:`m-0 min-w-[760px]`,children:[(0,f.jsx)(`thead`,{children:(0,f.jsxs)(`tr`,{children:[(0,f.jsx)(`th`,{children:`Name`}),(0,f.jsx)(`th`,{children:`Description`}),(0,f.jsx)(`th`,{children:`Scan`}),(0,f.jsx)(`th`,{children:`Source`}),(0,f.jsx)(`th`,{})]})}),(0,f.jsx)(`tbody`,{children:e.map(e=>(0,f.jsxs)(`tr`,{children:[(0,f.jsx)(`td`,{children:(0,f.jsx)(`code`,{children:e.name})}),(0,f.jsx)(`td`,{className:`max-w-xl`,children:e.parseError?(0,f.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[(0,f.jsx)(a,{variant:`danger`,children:`Parse error`}),(0,f.jsx)(`span`,{className:`text-destructive`,children:e.parseError})]}):e.description}),(0,f.jsx)(`td`,{children:(0,f.jsx)(h,{findings:e.scanFindings??[]})}),(0,f.jsxs)(`td`,{className:`text-xs text-muted-foreground`,children:[(0,f.jsx)(`span`,{className:`font-mono`,children:e.source??`Unknown`}),e.importedAt&&(0,f.jsx)(`div`,{className:`mt-1 font-mono`,children:new Date(e.importedAt).toLocaleDateString()})]}),(0,f.jsx)(`td`,{className:`text-right`,children:(0,f.jsx)(u,{variant:`danger`,className:`whitespace-nowrap`,onClick:()=>n(e.name),children:`Remove`})})]},e.name))})]})})})]})}function m({onImported:e}){let[t,n]=(0,d.useState)(`openclaw`),[r,i]=(0,d.useState)(``),[s,c]=(0,d.useState)(!1),[l,p]=(0,d.useState)(null),[m,h]=(0,d.useState)(!1),[v,y]=(0,d.useState)(null),[b,x]=(0,d.useState)([]),[S,C]=(0,d.useState)(!1),w=(0,d.useRef)(null);async function T(n){n.preventDefault(),y(null),x([]),C(!0);try{let n;if(t===`zip`){if(!l){y(`Choose a ZIP file first.`),C(!1);return}let e=new FormData;e.set(`file`,l),s&&e.set(`force`,`true`),n=await fetch(`/api/skills/import`,{method:`POST`,body:e})}else{let e;if(t===`openclaw`)e=`openclaw`;else if(e=r.trim(),!e){y(`Enter the server path.`),C(!1);return}n=await fetch(`/api/skills/import`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({source:e,force:s})})}if(!n.ok){let e=await n.json().catch(()=>null);throw x(e?.findings??[]),Error(e?.error??`${n.status} ${n.statusText}`)}x(_((await n.json().catch(()=>null))?.findings)),i(``),p(null),e()}catch(e){y(e.message)}finally{C(!1)}}function E(e){p(e.target.files?.[0]??null)}function D(e){e.preventDefault(),h(!1);let t=e.dataTransfer?.files;if(!t||t.length===0)return;let n=t[0];if(n){if(!/\.zip$/i.test(n.name)){y(`Only ZIP archives are supported.`);return}if(p(n),w.current){let e=new DataTransfer;e.items.add(n),w.current.files=e.files}}}let O=b.some(e=>e.severity===`danger`)?`danger`:`warning`;return(0,f.jsxs)(o,{title:`Import skills`,description:(0,f.jsxs)(f.Fragment,{children:[`Choose a source. Each skill's `,(0,f.jsx)(`code`,{children:`SKILL.md`}),` body is injected into the system prompt of any agent it is attached to.`]}),children:[(0,f.jsx)(`div`,{role:`tablist`,className:`mb-5 inline-flex max-w-full gap-0 overflow-x-auto rounded-lg border border-border bg-muted p-1`,children:[{id:`openclaw`,label:`OpenClaw`},{id:`path`,label:`Server directory`},{id:`zip`,label:`Upload ZIP`}].map(e=>(0,f.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.id,onClick:()=>{n(e.id),y(null)},className:`unstyled cursor-pointer whitespace-nowrap rounded-md border-none bg-transparent px-3 py-1.5 text-sm font-medium transition-colors ${t===e.id?`bg-card text-accent-foreground shadow-baziu-sm`:`text-muted-foreground hover:bg-accent/50 hover:text-foreground`}`,children:e.label},e.id))}),v&&(0,f.jsx)(`div`,{role:`alert`,className:`mb-4 rounded-lg border border-destructive/20 bg-destructive/10 px-4 py-3 text-sm text-destructive`,children:v}),b.length>0&&(0,f.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-muted/30 p-4 text-sm`,children:[(0,f.jsx)(a,{variant:O,className:`mb-2`,children:`Scan findings`}),(0,f.jsx)(g,{findings:b})]}),(0,f.jsxs)(`form`,{className:`space-y-4`,onSubmit:T,children:[t===`openclaw`&&(0,f.jsxs)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:[`One-click import of every skill found in `,(0,f.jsx)(`code`,{children:`~/.openclaw/skills`}),` on the server.`]}),t===`path`&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:[`Import from an absolute path on the server — either a single skill folder (contains `,(0,f.jsx)(`code`,{children:`SKILL.md`}),`) or a parent folder holding many skill subfolders.`]}),(0,f.jsxs)(`label`,{className:`max-w-2xl`,children:[`Server path`,(0,f.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`/home/you/my-skills`,required:!0})]})]}),t===`zip`&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:[`Upload a `,(0,f.jsx)(`code`,{children:`.zip`}),` archive whose top level contains one folder per skill — the folder name becomes the skill name.`]}),(0,f.jsxs)(`label`,{onDragOver:e=>{e.preventDefault(),h(!0)},onDragLeave:()=>h(!1),onDrop:D,className:`block cursor-pointer rounded-xl border-2 border-dashed p-8 text-center transition-colors ${m?`border-primary bg-accent text-accent-foreground`:l?`border-solid border-primary/40 bg-card text-foreground`:`border-border bg-muted/30 text-muted-foreground hover:border-primary hover:bg-accent hover:text-accent-foreground`}`,children:[(0,f.jsx)(`input`,{ref:w,type:`file`,accept:`.zip,application/zip`,onChange:E,className:`absolute h-px w-px overflow-hidden opacity-0`}),l?(0,f.jsx)(`span`,{className:`block break-all font-mono text-sm text-accent-foreground`,children:l.name}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`span`,{className:`block text-sm font-medium text-foreground`,children:`Click to choose a ZIP file`}),(0,f.jsx)(`span`,{className:`text-xs`,children:`or drag and drop it here`})]})]})]}),(0,f.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,f.jsx)(u,{variant:`primary`,type:`submit`,disabled:S,children:S?`Importing…`:t===`zip`?`Upload and import`:t===`openclaw`?`Import from OpenClaw`:`Import`}),(0,f.jsxs)(`label`,{className:`m-0 inline-flex cursor-pointer items-center gap-1 text-sm text-foreground`,children:[(0,f.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked)}),(0,f.jsx)(`span`,{children:`Overwrite existing`}),(0,f.jsx)(`span`,{className:`text-muted-foreground`,children:`and confirm scan findings`})]})]})]})]})}function h({findings:e}){return e.length===0?(0,f.jsx)(a,{variant:`success`,children:`Clean`}):(0,f.jsxs)(`details`,{className:`text-xs`,children:[(0,f.jsx)(`summary`,{className:`cursor-pointer list-none`,children:(0,f.jsxs)(a,{variant:e.some(e=>e.severity===`danger`)?`danger`:`warning`,children:[e.length,` finding`,e.length===1?``:`s`]})}),(0,f.jsx)(`div`,{className:`mt-2 min-w-64`,children:(0,f.jsx)(g,{findings:e})})]})}function g({findings:e}){return(0,f.jsx)(`ul`,{className:`m-0 space-y-1.5 pl-0`,children:e.map((e,t)=>(0,f.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,f.jsx)(a,{variant:e.severity===`danger`?`danger`:`warning`,children:e.severity===`danger`?`Danger`:`Warning`}),(0,f.jsxs)(`span`,{children:[(0,f.jsx)(`code`,{children:e.code}),e.line?`, line ${e.line}`:``,` — `,e.message]})]},`${e.code}-${e.line??0}-${t}`))})}function _(e){return e?Object.entries(e).flatMap(([e,t])=>t.map(t=>({...t,message:`${e}: ${t.message}`}))):[]}export{p as component};