bazilion 0.56.0 → 0.57.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/dist/cli.js +2 -1
  2. package/dist/cli.js.map +1 -1
  3. package/dist/daemon.js +599 -318
  4. package/dist/daemon.js.map +1 -1
  5. package/dist/web/client/assets/AddProviderDialog-D8VvDmbM.js +1 -0
  6. package/dist/web/client/assets/AgentTemplateParts-BWorU6-F.js +1 -0
  7. package/dist/web/client/assets/{ConfigPage-Ch-DSJUO.js → ConfigPage-DFmHgEaL.js} +1 -1
  8. package/dist/web/client/assets/ConfirmDialog-DrN26lN_.js +1 -0
  9. package/dist/web/client/assets/ConnectionsView-DcO7RJZ7.js +1 -0
  10. package/dist/web/client/assets/{ManagePage-kd7iWYEL.js → ManagePage-BzyMHGqs.js} +1 -1
  11. package/dist/web/client/assets/SectionTabs-C8H_LunZ.js +1 -0
  12. package/dist/web/client/assets/SkillsParts-BueR3HoP.js +1 -0
  13. package/dist/web/client/assets/SpawnTeamModal-B65eQyzu.js +1 -0
  14. package/dist/web/client/assets/TeamForm-BhI9FbjV.js +1 -0
  15. package/dist/web/client/assets/TeamThread-FPpHlVFc.js +1 -0
  16. package/dist/web/client/assets/{UnsavedChangesGuard-vQBdMl8h.js → UnsavedChangesGuard-CYz0AopL.js} +1 -1
  17. package/dist/web/client/assets/{_id-CC9r0qsr.js → _id-5mTcKU2j.js} +1 -1
  18. package/dist/web/client/assets/{_id-C6SADaiD.js → _id-DKgyyyeX.js} +1 -1
  19. package/dist/web/client/assets/{access-BbQFbTPh.js → access-BGtASxet.js} +1 -1
  20. package/dist/web/client/assets/{agents-BXwzmHu8.js → agents-BAODfMcm.js} +1 -1
  21. package/dist/web/client/assets/agents-Bfwz3dl5.js +1 -0
  22. package/dist/web/client/assets/{attention-BMrZJ9ui.js → attention-BIC0TL8d.js} +1 -1
  23. package/dist/web/client/assets/config-kMzM8kdp.js +1 -0
  24. package/dist/web/client/assets/{es2015-D1pnOGPG.js → es2015-DZDOQ3kj.js} +11 -11
  25. package/dist/web/client/assets/index-DuLpyCSP.js +14 -0
  26. package/dist/web/client/assets/{login-DM3q-V4R.js → login-q9O7dqRe.js} +1 -1
  27. package/dist/web/client/assets/{manage-R57MUzsY.js → manage-DdCiSgG9.js} +1 -1
  28. package/dist/web/client/assets/{mcp-CSHrVH1t.js → mcp-B3LzNtrr.js} +1 -1
  29. package/dist/web/client/assets/{parts-68zf8Fgw.js → parts-C104qEuC.js} +1 -1
  30. package/dist/web/client/assets/routes-BDdLZEGO.js +85 -0
  31. package/dist/web/client/assets/{skills-CPZftp9O.js → skills-VEtq-MQJ.js} +1 -1
  32. package/dist/web/client/assets/style-J8ypSsCb.js +7 -0
  33. package/dist/web/client/assets/styles-C7NsCHeU.css +2 -0
  34. package/dist/web/client/assets/{system-Dd2P9eqE.js → system-DtBBeAjO.js} +1 -1
  35. package/dist/web/client/assets/teams-D4X9oNx8.js +1 -0
  36. package/dist/web/client/assets/teams-QlaY2Sxd.js +1 -0
  37. package/dist/web/client/assets/telegram-B7vlTQbt.js +1 -0
  38. package/dist/web/client/assets/{tools-DqNXLMpc.js → tools-C0FIeAL1.js} +1 -1
  39. package/dist/web/client/assets/{usage-BC_TStVj.js → usage-3mYfS5C-.js} +1 -1
  40. package/dist/web/client/assets/use-resource-qjIkNQDY.js +1 -0
  41. package/dist/web/client/assets/{welcome-g8wtn_or.js → welcome-CkmanVa_.js} +1 -1
  42. package/dist/web/server/assets/{AddProviderDialog-DtkjBMv4.js → AddProviderDialog-CpLDHOcA.js} +4 -4
  43. package/dist/web/server/assets/{AgentTemplateParts-CxWyovvM.js → AgentTemplateParts-Dh9F_-T_.js} +5 -5
  44. package/dist/web/server/assets/{ConfigPage-usZi48Zr.js → ConfigPage-CrxctbtN.js} +2 -2
  45. package/dist/web/server/assets/{ConfirmDialog-DAcSBHkT.js → ConfirmDialog-C89B8qKM.js} +1 -1
  46. package/dist/web/server/assets/{ConnectionsView-Dy6uYSRI.js → ConnectionsView-DslcKQmA.js} +5 -5
  47. package/dist/web/server/assets/{Dialog-DTeF-nOZ.js → Dialog-_Gt_Nt86.js} +2 -2
  48. package/dist/web/server/assets/{ManagePage-Dy1EdovO.js → ManagePage-DGYNJ6XG.js} +2 -2
  49. package/dist/web/server/assets/{ModelMenu-D-hTgYOO.js → ModelMenu-DEJoYASj.js} +13 -1
  50. package/dist/web/server/assets/{SectionTabs-BVrMn76H.js → SectionTabs--vMBvaUz.js} +7 -1
  51. package/dist/web/server/assets/{SkillsParts-Cw05b3al.js → SkillsParts-CqS2B45v.js} +5 -5
  52. package/dist/web/server/assets/{SpawnDialog-BAE8W91z.js → SpawnDialog-BNKj2Lup.js} +10 -8
  53. package/dist/web/server/assets/{SpawnTeamModal-CgBY0HuN.js → SpawnTeamModal-zcLxtFOO.js} +4 -4
  54. package/dist/web/server/assets/{TeamForm-JyO5xJXX.js → TeamForm-XFP0l2TB.js} +9 -7
  55. package/dist/web/server/assets/{TeamThread-5o48EbXL.js → TeamThread-gYV_ToRM.js} +8 -9
  56. package/dist/web/server/assets/{UnsavedChangesGuard-CJQGu45L.js → UnsavedChangesGuard-CB_TugFF.js} +1 -1
  57. package/dist/web/server/assets/{_id-BNvm89oJ.js → _id-517adSuB.js} +1 -1
  58. package/dist/web/server/assets/{_id-BpumuCYL.js → _id-BTyd2i5U.js} +1 -1
  59. package/dist/web/server/assets/{_id-BE_RSvuN.js → _id-BsQnL9LV.js} +9 -9
  60. package/dist/web/server/assets/{_id-BfjTS4JO.js → _id-CyinHJam.js} +11 -11
  61. package/dist/web/server/assets/{_id-BW6sVrvw.js → _id-D4RFNqaJ.js} +2 -2
  62. package/dist/web/server/assets/{_id-C54t_nX6.js → _id-josYXBx3.js} +1 -1
  63. package/dist/web/server/assets/{_tanstack-start-manifest_v-BPwQX_5b.js → _tanstack-start-manifest_v-DIMayzEa.js} +78 -78
  64. package/dist/web/server/assets/{access-BhAMfi7U.js → access-B97-94Wt.js} +1 -1
  65. package/dist/web/server/assets/{access-DEyq3uP_.js → access-BdQmjMJV.js} +1 -1
  66. package/dist/web/server/assets/{access-6FWih7nC.js → access-Cc7fMMod.js} +5 -5
  67. package/dist/web/server/assets/{agents-ncyhVx-T.js → agents-BL918wVc.js} +1 -1
  68. package/dist/web/server/assets/{agents-BXuglv4G.js → agents-BlUZqqJn.js} +10 -10
  69. package/dist/web/server/assets/{agents-3hBjrd8B.js → agents-BzJFjA2i.js} +2 -2
  70. package/dist/web/server/assets/{agents-KJcDMj0Y.js → agents-CjrkaEz8.js} +9 -9
  71. package/dist/web/server/assets/{agents-rTDlRZa5.js → agents-Tg3zkmQv.js} +2 -2
  72. package/dist/web/server/assets/{agents-DhenbitX.js → agents-uw32jPWx.js} +1 -1
  73. package/dist/web/server/assets/{attention-X0U6ZmiA.js → attention-2unmuO-q.js} +1 -1
  74. package/dist/web/server/assets/{attention-CDdOCOio.js → attention-C94WWwQe.js} +1 -1
  75. package/dist/web/server/assets/{attention-DM__BzWY.js → attention-a_OmC6L3.js} +6 -6
  76. package/dist/web/server/assets/{auth-BexhV8Yq.js → auth-DuIqEAed.js} +1 -1
  77. package/dist/web/server/assets/{config-Cld8Q8N7.js → config-BG1KOtwA.js} +1 -1
  78. package/dist/web/server/assets/{config-DpgYAXQ3.js → config-Bhem9XER.js} +8 -8
  79. package/dist/web/server/assets/{config-Cx5ri2DL2.js → config-D1Li_7Yt2.js} +1 -1
  80. package/dist/web/server/assets/{daemon-client-RxAllljf.js → daemon-client-D-NWKQto.js} +1 -1
  81. package/dist/web/server/assets/{form-BEjeiSy3.js → form-Bwsyt9OY.js} +2 -2
  82. package/dist/web/server/assets/{manage-C6ucNYZW.js → manage-C7ReF2ZZ.js} +1 -1
  83. package/dist/web/server/assets/{mcp-DwCzj7eO.js → mcp-BFixpBQk.js} +1 -1
  84. package/dist/web/server/assets/{mcp-BXnWQOwM.js → mcp-BTZkDvdc.js} +5 -5
  85. package/dist/web/server/assets/{mcp-C8VLspco.js → mcp-Ceg9gzKE.js} +1 -1
  86. package/dist/web/server/assets/{open-groups-BMGYUTtY.js → open-groups-C89TEK85.js} +1 -1
  87. package/dist/web/server/assets/{parts-k9M-atPa.js → parts-B0wbj_yK.js} +1 -1
  88. package/dist/web/server/assets/{router-BttfLktO.js → router-DizFxqh-.js} +141 -51
  89. package/dist/web/server/assets/{routes-A7UcreVX.js → routes-CVrH9qgo.js} +1 -1
  90. package/dist/web/server/assets/{routes-B9jw-MJ8.js → routes-D9Mw1_VV.js} +297 -101
  91. package/dist/web/server/assets/{routes-BX2FV8rS.js → routes-DsuaDPTO.js} +2 -2
  92. package/dist/web/server/assets/{skills-Cd5Cfdaz.js → skills-BNbZ75am.js} +1 -1
  93. package/dist/web/server/assets/{skills-y3GsyKce.js → skills-BWwEFc4a.js} +1 -1
  94. package/dist/web/server/assets/{skills-BVAH93cd.js → skills-D5rnOmKJ.js} +7 -7
  95. package/dist/web/server/assets/{src-vrZVrV9u.js → src-BeMh8Fze.js} +11 -1
  96. package/dist/web/server/assets/{start-Dl8gQ-95.js → start-2MvkBRdC.js} +1 -1
  97. package/dist/web/server/assets/{style-BQ3H9I7Y.js → style-B3l0Wtlf.js} +1 -1
  98. package/dist/web/server/assets/{system-BJPKqM6b.js → system-Cr4C-YRw.js} +1 -1
  99. package/dist/web/server/assets/{system-C7mejQSc.js → system-DT7AU0e6.js} +3 -3
  100. package/dist/web/server/assets/{system-LsLcuVzY.js → system-DsmXkgqn.js} +1 -1
  101. package/dist/web/server/assets/{teams-CiX8LUQo.js → teams-BeStcDvQ.js} +1 -1
  102. package/dist/web/server/assets/{teams-B6gbflsZ.js → teams-CsEBLW8-.js} +11 -9
  103. package/dist/web/server/assets/{teams-D-XdIkCr.js → teams-Dix5XVIx.js} +1 -1
  104. package/dist/web/server/assets/{teams-C7kXMNgc.js → teams-DjE0swAZ.js} +8 -8
  105. package/dist/web/server/assets/{teams-CeLLd2Mf.js → teams-Rk_RED7X.js} +1 -1
  106. package/dist/web/server/assets/{teams-CPXoTggb.js → teams-u6m6JzuU.js} +1 -1
  107. package/dist/web/server/assets/{telegram-D8_V7_sW.js → telegram-BjqABrl-.js} +7 -7
  108. package/dist/web/server/assets/{telegram-D7TW3LNZ.js → telegram-CQpF3EHA.js} +1 -1
  109. package/dist/web/server/assets/{telegram-DA2dwLID.js → telegram-DhzHgDfg.js} +1 -1
  110. package/dist/web/server/assets/{tools-D1BBVkRh.js → tools-DC69leH7.js} +1 -1
  111. package/dist/web/server/assets/{tools-CluiJywK.js → tools-Dn6RnOFu.js} +1 -1
  112. package/dist/web/server/assets/{tools-CckcG9Jl.js → tools-x_DQTQtE.js} +5 -5
  113. package/dist/web/server/assets/{usage-PNNb3pPj.js → usage-4zMG0sab.js} +4 -4
  114. package/dist/web/server/assets/{usage-CrYyvPgf.js → usage-mvQegG4l.js} +1 -1
  115. package/dist/web/server/assets/{use-resource-BUA9qGGY.js → use-resource-BjN1uJoL.js} +9 -1
  116. package/dist/web/server/assets/{welcome-CwzLt6Rp.js → welcome-BuE9FRf4.js} +1 -1
  117. package/dist/web/server/assets/{welcome-CUTYf8UG.js → welcome-DYw35wl5.js} +1 -1
  118. package/dist/web/server/assets/{welcome-CYhh3iUU.js → welcome-DrYbWGd_.js} +5 -5
  119. package/dist/web/server/server.js +20 -20
  120. package/dist/worker.js +116 -12
  121. package/dist/worker.js.map +1 -1
  122. package/package.json +1 -1
  123. package/dist/web/client/assets/AddProviderDialog-DZ9mXFdq.js +0 -1
  124. package/dist/web/client/assets/AgentTemplateParts-BfG3a-ri.js +0 -1
  125. package/dist/web/client/assets/ConfirmDialog-B_jXAPmh.js +0 -1
  126. package/dist/web/client/assets/ConnectionsView-D1Liebtf.js +0 -1
  127. package/dist/web/client/assets/SectionTabs-Dc0bNn-J.js +0 -1
  128. package/dist/web/client/assets/SkillsParts-C5T7sYDA.js +0 -1
  129. package/dist/web/client/assets/SpawnTeamModal-DatFF4f_.js +0 -1
  130. package/dist/web/client/assets/TeamForm-l-N_PYeE.js +0 -1
  131. package/dist/web/client/assets/TeamThread-BWmIQiAh.js +0 -1
  132. package/dist/web/client/assets/agents-BtETzVIY.js +0 -1
  133. package/dist/web/client/assets/config-B2ZDYo52.js +0 -1
  134. package/dist/web/client/assets/index-B-N6NIX4.js +0 -14
  135. package/dist/web/client/assets/routes-DOoeKVwr.js +0 -85
  136. package/dist/web/client/assets/style-Bm9QsFpy.js +0 -7
  137. package/dist/web/client/assets/styles-B-kTTvCo.css +0 -2
  138. package/dist/web/client/assets/teams-7FEpSZg1.js +0 -1
  139. package/dist/web/client/assets/teams-ClirFbDV.js +0 -1
  140. package/dist/web/client/assets/telegram-BJnT5THs.js +0 -1
  141. package/dist/web/client/assets/use-resource-Bn0Sx7r6.js +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bazilion",
3
- "version": "0.56.0",
3
+ "version": "0.57.1",
4
4
  "description": "Multi-agent runtime CLI — spawn LLM agents, manage profiles/teams/skills, and run the local daemon.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1 +0,0 @@
1
- import{$ as e,Z as t,a as n,h as r,s as i}from"./createLucideIcon-CZHSSDYA.js";import{t as a}from"./Button-CoKQRO-s.js";import{S as o,b as s,x as c}from"./es2015-D1pnOGPG.js";import{d as l,v as u,x as d,z as f}from"./parts-68zf8Fgw.js";import{n as p,t as m}from"./images-BULrW-FC.js";import{t as ee}from"./chevron-right-D1shxvdo.js";import{B as h,H as g,K as _,L as te,U as v,V as ne,W as y,q as b,z as x}from"./index-B-N6NIX4.js";import{r as re}from"./use-resource-Bn0Sx7r6.js";var S=e(t(),1),C=r();function w({name:e,tone:t=`neutral`,className:n}){return(0,C.jsx)(`span`,{"aria-hidden":`true`,className:o(`flex size-9 shrink-0 items-center justify-center rounded-xl text-base font-bold`,t===`success`&&`bg-success/10 text-success`,t===`warning`&&`bg-warning/10 text-warning`,t===`accent`&&`bg-accent text-accent-foreground`,t===`neutral`&&`bg-muted text-muted-foreground`,n),children:e.replace(/[^\p{L}\p{N}]/gu,``).slice(0,1)||`?`})}function T({provider:e,now:t}){let n=y(e,t);return(0,C.jsx)(l,{tone:n.tone,children:n.label})}function ie({failure:e,children:t}){return(0,C.jsxs)(`div`,{role:`alert`,className:`rounded-2xl border border-warning/35 bg-warning/10 p-4 text-sm`,children:[(0,C.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,C.jsx)(f,{className:`mt-0.5 size-5 shrink-0 text-warning`,"aria-hidden":`true`}),(0,C.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,C.jsx)(`div`,{className:`font-semibold text-foreground`,children:e.title}),(0,C.jsx)(`div`,{className:`mt-0.5 text-muted-foreground`,children:e.hint}),e.detail&&(0,C.jsxs)(`details`,{className:`mt-2 text-xs text-muted-foreground`,children:[(0,C.jsx)(`summary`,{className:`cursor-pointer font-semibold`,children:`Details`}),(0,C.jsx)(`div`,{className:`mt-1 break-words font-mono`,children:e.detail})]})]})]}),t&&(0,C.jsx)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:t})]})}function ae({model:e,connect:t,checked:n,disabled:r,onToggle:i,className:a}){return(0,C.jsxs)(`label`,{className:o(`m-0 grid cursor-pointer grid-cols-[auto_minmax(0,1fr)] items-center gap-x-3 gap-y-0.5 border-b border-border py-2.5 sm:grid-cols-[auto_minmax(0,1.5fr)_minmax(0,1.2fr)_9.5rem]`,a),children:[(0,C.jsx)(`input`,{type:`checkbox`,checked:n,disabled:r,onChange:i,className:`m-0 size-[18px]`}),(0,C.jsxs)(`span`,{className:`min-w-0`,children:[(0,C.jsx)(`span`,{className:`text-sm font-semibold text-foreground`,children:g(e)}),e.suggested&&(0,C.jsx)(`span`,{className:`ml-2 rounded-full bg-accent px-2 py-0.5 text-xs font-semibold text-accent-foreground`,children:`Suggested`}),e.name&&(0,C.jsx)(`span`,{className:`block break-all font-mono text-xs text-muted-foreground`,children:e.id})]}),(0,C.jsx)(`span`,{className:`col-start-2 text-xs text-muted-foreground sm:col-start-auto`,children:x(e,t)}),(0,C.jsx)(`span`,{className:`col-start-2 text-xs text-foreground sm:col-start-auto sm:text-right`,children:v(e,t)})]})}var oe=60;function E(e){let t={};for(let n of e.fields)t[n.envVar]=n.kind===`config`?n.value??``:``;let n=e.fields.find(e=>e.kind===`config`&&!e.advanced);return e.connect===`local`&&n&&!n.set&&(t[n.envVar]=e.address??``),t}function D(e,t){let n={};for(let r of e.fields){let i=(t[r.envVar]??``).trim();if(r.kind===`secret`)i&&(n[r.envVar]=i);else if(i!==(r.value??``)){if(!r.set&&e.connect===`local`&&i===e.address)continue;n[r.envVar]=i}}return n}function O({provider:e,imageRoutes:t=[],onConnected:r}){let[o,c]=(0,S.useState)(()=>E(e)),[l,f]=(0,S.useState)(()=>k(e,E(e))),[p,_]=(0,S.useState)(null),[v,y]=(0,S.useState)([]),[b,x]=(0,S.useState)(``),[w,T]=(0,S.useState)(null),[O,A]=(0,S.useState)(!1),[j,M]=(0,S.useState)(``),[N,P]=(0,S.useState)(`idle`),[F,ce]=(0,S.useState)(e.configured),[I,le]=(0,S.useState)(null),[L,ue]=(0,S.useState)(null),R=(0,S.useRef)(null);(0,S.useEffect)(()=>()=>R.current?.abort(),[]);let z=(0,S.useRef)(null);(0,S.useEffect)(()=>{(I||L)&&z.current?.scrollIntoView({block:`nearest`,behavior:`smooth`})},[I,L]);let B=re(t=>n(`/api/config/providers/${encodeURIComponent(e.id)}/catalog`,{body:{fields:l},signal:t}),[e.id,JSON.stringify(l)]),V=(0,S.useMemo)(()=>{let t=t=>{let n=e.suggested.indexOf(t.id);return n===-1?e.suggested.length:n},n=[...B.data?.models??[]].sort((e,n)=>t(e)-t(n)),r=new Set(n.map(e=>e.id));return[...n,...v.filter(e=>!r.has(e)).map(e=>({id:e,selected:!1,suggested:!1}))]},[B.data,v,e.suggested]);(0,S.useEffect)(()=>{let e=B.data?.models;e&&(_(t=>t&&[...t].some(t=>e.some(e=>e.id===t))?t:new Set(h(e))),T(t=>t??(e.length<=6||h(e).length===0)))},[B.data]);let H=p??new Set,U=V.filter(e=>H.has(e.id)),W=te(U),G=N!==`idle`,K=e.connect===`local`,q=e.connect===`signin`,J=e.fields.filter(e=>!e.advanced),Y=e.fields.filter(e=>e.advanced),de=q||e.configured||J.every(e=>e.set||(o[e.envVar]??``).trim().length>0),fe=V.filter(e=>e.suggested||e.selected||H.has(e.id)),X=w===!0,Z=X?V.filter(e=>j?ne(e,j):!e.dated||H.has(e.id)):fe,Q=Z.slice(0,oe);function pe(e){_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function me(){let e=b.trim();e&&(y(t=>t.includes(e)?t:[...t,e]),_(t=>new Set(t).add(e)),x(``))}async function he(t){R.current?.abort();let a=new AbortController;R.current=a,le(null),ue(null);try{q&&!F&&(P(`signin`),await n(`/api/auth/openai/login`,{method:`POST`,signal:a.signal}),ce(!0)),P(`connecting`);let i={fields:D(e,o),models:U.map(e=>e.id),...t&&U.length>0?{}:{test:!1}},s=await n(`/api/config/providers/${encodeURIComponent(e.id)}/connect`,{body:i,signal:a.signal});if(a.signal.aborted)return;s.connected?await r(s):le(s.failure)}catch(e){a.signal.aborted||ue(i(e))}finally{R.current===a&&P(`idle`)}}let $=`No chat model is ticked, so nothing is tested.`;if(U.length>0){let e=W?g(W):`a model`,t=W?.price?`cheapest`:`first`,n=U.length>1?`${e}, the ${t} one ticked`:e;$=q&&!F?`After the sign-in, one short message goes to ${n}.`:`The test sends one short message to ${n}.`,W?.price&&!q&&($+=` It costs a fraction of a cent.`)}return(0,C.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),he(!0)},className:`grid gap-4`,children:[e.hint&&(0,C.jsx)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:e.hint}),q&&(0,C.jsx)(`p`,{className:`m-0 rounded-xl border border-border bg-muted/40 p-3 text-sm text-muted-foreground`,children:F?`You are signed in with ChatGPT. Bazilion renews the sign-in by itself.`:`A browser tab opens on the machine Bazilion runs on, and you sign in with your ChatGPT account there. On another machine, run bazilion auth openai login --device-code on it instead.`}),J.map((t,n)=>(0,C.jsx)(se,{field:t,value:o[t.envVar]??``,disabled:G,autoFocus:n===0&&!K,onChange:e=>c(n=>({...n,[t.envVar]:e})),onCommit:K?()=>f(k(e,o)):void 0},t.envVar)),Y.length>0&&(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`button`,{type:`button`,"aria-expanded":O,onClick:()=>A(e=>!e),className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[(0,C.jsx)(ee,{className:`size-4 text-muted-foreground transition-transform ${O?`rotate-90`:``}`,"aria-hidden":`true`}),`More settings`]}),O&&(0,C.jsx)(`div`,{className:`mt-2 grid gap-3 rounded-xl border border-border bg-muted/40 p-3`,children:Y.map(e=>(0,C.jsx)(se,{field:e,value:o[e.envVar]??``,disabled:G,onChange:t=>c(n=>({...n,[e.envVar]:t}))},e.envVar))})]}),(0,C.jsxs)(`fieldset`,{className:`m-0 min-w-0 border-0 p-0`,children:[(0,C.jsxs)(`legend`,{className:`mb-2 flex w-full flex-wrap items-baseline gap-x-2 p-0`,children:[(0,C.jsx)(`span`,{className:`text-sm font-semibold text-foreground`,children:`Models your Agents can use`}),(0,C.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:K?`What the server reports. You can change this later.`:`${V.length} available. You can change this later.`})]}),K&&B.data?.listError&&(0,C.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-3 rounded-xl border border-warning/35 bg-warning/10 px-3 py-2 text-sm`,children:[(0,C.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[`Nothing answers at `,o[J[0]?.envVar??``]||`that address`,`. Start`,` `,e.displayName,` and switch its server on.`]}),(0,C.jsx)(a,{variant:`ghost`,disabled:B.loading,onClick:()=>{f(k(e,o)),B.reload()},children:B.loading?`Looking…`:`Look again`})]}),X&&V.length>8&&(0,C.jsx)(u,{label:`Search ${e.displayName} models`,placeholder:`Search by name`,value:j,onChange:M,className:`mb-2`}),X&&V.length>8&&U.length>0&&(0,C.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-1.5 text-xs`,children:[(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:`Ticked:`}),U.map(e=>(0,C.jsxs)(`button`,{type:`button`,disabled:G,onClick:()=>pe(e.id),"aria-label":`Untick ${g(e)}`,className:`inline-flex items-center gap-1 rounded-full bg-accent px-2.5 py-1 font-semibold text-accent-foreground`,children:[g(e),(0,C.jsx)(s,{className:`size-3`,"aria-hidden":`true`})]},e.id))]}),(0,C.jsxs)(`div`,{className:`max-h-72 overflow-y-auto rounded-xl border border-border`,children:[B.loading&&!B.data&&(0,C.jsx)(`div`,{className:`p-3 text-sm text-muted-foreground`,children:`Reading the model list…`}),B.error&&(0,C.jsx)(`div`,{className:`p-3 text-sm text-danger`,children:B.error}),B.data&&Q.length===0&&(0,C.jsx)(`div`,{className:`p-3 text-sm text-muted-foreground`,children:j?`No model matches.`:K?`The server lists no model yet.`:`No models are listed for this provider. Add one by its id below.`}),Q.map(t=>(0,C.jsx)(ae,{model:t,connect:e.connect,checked:H.has(t.id),disabled:G,onToggle:()=>pe(t.id),className:`px-3 last:border-b-0`},t.id)),Z.length>Q.length&&(0,C.jsxs)(`div`,{className:`p-3 text-xs text-muted-foreground`,children:[Z.length-Q.length,` more: search to narrow them down.`]})]}),(0,C.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-4 gap-y-2`,children:[!X&&V.length>fe.length&&(0,C.jsxs)(`button`,{type:`button`,onClick:()=>T(!0),className:`text-sm font-semibold text-primary`,children:[`See all `,V.length]}),X&&!K&&(0,C.jsxs)(`span`,{className:`flex min-w-0 flex-1 basis-64 items-center gap-2`,children:[(0,C.jsx)(`input`,{type:`text`,"aria-label":`A model id that is not listed`,placeholder:`A model id that is not listed`,value:b,disabled:G,onChange:e=>x(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),me())},className:`min-h-10 font-mono text-sm`}),(0,C.jsx)(a,{variant:`ghost`,disabled:G||!b.trim(),onClick:me,children:`Add`})]})]})]}),t.length>0&&(0,C.jsxs)(`p`,{className:`m-0 flex items-start gap-2 text-sm text-muted-foreground`,children:[(0,C.jsx)(m,{className:`mt-0.5 size-4 shrink-0 text-accent-foreground`,"aria-hidden":`true`}),(0,C.jsxs)(`span`,{children:[q?`The same sign-in`:`The same key`,` makes`,` `,[...new Set(t.map(e=>e.model))].join(` and `),` available under Images.`]})]}),(0,C.jsxs)(`div`,{ref:z,className:`grid gap-3 empty:hidden`,children:[I&&(0,C.jsx)(ie,{failure:I}),L&&(0,C.jsx)(`p`,{role:`alert`,className:`m-0 rounded-xl bg-danger/10 px-3 py-2 text-sm text-danger`,children:L})]}),G?(0,C.jsx)(d,{children:N===`signin`?`Waiting for the ChatGPT sign-in in the browser…`:W?`Asking ${g(W)} for a short reply…`:`Saving…`}):(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,C.jsx)(a,{variant:`primary`,type:`submit`,disabled:!de||K&&U.length===0,children:q&&!F?`Sign in with ChatGPT`:U.length===0?`Connect`:`Connect and test`}),U.length>0&&!(q&&!F)&&(0,C.jsx)(`button`,{type:`button`,disabled:!de,onClick:()=>void he(!1),className:`text-sm font-semibold text-primary disabled:opacity-50`,children:`Save without testing`})]}),(0,C.jsx)(`p`,{className:`m-0 mt-2 text-xs text-muted-foreground`,children:$})]})]})}function k(e,t){if(e.connect!==`local`)return{};let n=D(e,t);return Object.fromEntries(Object.entries(n).filter(([t])=>e.fields.some(e=>e.envVar===t&&e.kind===`config`)))}function se({field:e,value:t,disabled:n,autoFocus:r=!1,onChange:i,onCommit:a}){let o=e.kind===`secret`;return(0,C.jsxs)(`label`,{className:`m-0 text-sm font-semibold text-foreground`,children:[e.label,(0,C.jsx)(`input`,{type:o?`password`:`text`,value:t,disabled:n,autoFocus:r,autoComplete:`off`,spellCheck:!1,placeholder:o&&e.set?`Saved. Paste another to replace it.`:e.placeholder??``,onChange:e=>i(e.target.value),onBlur:a,onKeyDown:e=>{e.key===`Enter`&&a&&(e.preventDefault(),a())},className:`mt-1.5 font-mono font-normal`}),(e.description||o)&&(0,C.jsx)(`span`,{className:`mt-1 block text-xs font-normal text-muted-foreground`,children:e.description??`Stored encrypted on the machine Bazilion runs on. It is never shown again.`})]})}function A(e){try{return new URL(e).host}catch{return e}}function j(e,t){if(!e)return t?`Looking…`:`A model server on this computer`;if(!e.found)return`Nothing at ${A(e.address)}`;let n=e.models.length;return`Running at ${A(e.address)}, ${n===1?`1 model`:`${n} models`}`}function M(e,t){let n=t.trim().toLowerCase();return n?[e.displayName,e.id,e.hint??``].some(e=>e.toLowerCase().includes(n)):!0}function N({providers:e,expanded:t=!1,onPick:r}){let[i,a]=(0,S.useState)(``),[o,s]=(0,S.useState)(t),l=re(e=>n(`/api/config/providers/local`,{signal:e}),[]),d=(0,S.useMemo)(()=>Date.now(),[]),f=e.filter(e=>M(e,i)),p=e=>f.filter(t=>t.group===e),m=p(`more`),h=i.trim().length>0,g=e=>{let t=l.data?.servers.find(t=>t.id===e.id),n=e.group===`local`&&t?.found,i=e.listed?y(e,d).label:e.group===`local`?j(t,l.loading):e.hint??e.id;return(0,C.jsxs)(`button`,{type:`button`,onClick:()=>r(e),className:`flex min-h-16 min-w-0 items-center gap-3 rounded-2xl border border-border bg-card px-3.5 py-2.5 text-left transition-colors hover:border-primary/40 hover:bg-accent/40`,children:[(0,C.jsx)(w,{name:e.displayName,tone:e.listed||n?`success`:`neutral`}),(0,C.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,C.jsx)(`span`,{className:`block truncate text-sm font-semibold text-foreground`,children:e.displayName}),(0,C.jsx)(`span`,{className:`line-clamp-2 text-xs leading-snug ${e.listed||n?`text-success`:`text-muted-foreground`}`,children:i})]}),e.listed?(0,C.jsx)(c,{className:`size-4 shrink-0 text-success`,"aria-hidden":`true`}):(0,C.jsx)(ee,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`})]},e.id)},_=(e,t)=>t.length>0&&(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h3`,{className:`m-0 mb-2 font-body text-xs font-bold uppercase tracking-[0.08em] text-muted-foreground`,children:e}),(0,C.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:t.map(g)})]});return(0,C.jsxs)(`div`,{className:`grid gap-4`,children:[(0,C.jsx)(u,{label:`Search providers`,placeholder:`Search ${e.length} providers`,value:i,onChange:a}),_(`Most used`,p(`popular`)),_(`On this computer`,p(`local`)),(h||o)&&_(`More`,m),f.length===0&&(0,C.jsxs)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:[`No provider matches “`,i,`”.`]}),!h&&!o&&m.length>0&&(0,C.jsxs)(`button`,{type:`button`,onClick:()=>s(!0),className:`justify-self-start text-sm font-semibold text-primary`,children:[`Show `,m.length,` more:`,` `,m.slice(0,4).map(e=>e.displayName).join(`, `),`…`]})]})}function P({result:e,imageRoutes:t}){let{provider:n,check:r,dropped:i,movedTemplates:a}=e,o=n.models.length,s=[...new Set(t.map(e=>e.model))];return(0,C.jsxs)(`div`,{role:`status`,className:`flex items-start gap-4`,children:[(0,C.jsx)(`span`,{"aria-hidden":`true`,className:`flex size-11 shrink-0 items-center justify-center rounded-full ${r?`bg-success/10 text-success`:`bg-muted text-muted-foreground`}`,children:(0,C.jsx)(c,{className:`size-6`})}),(0,C.jsxs)(`div`,{className:`min-w-0 flex-1 text-sm`,children:[(0,C.jsx)(`div`,{className:`text-base font-semibold text-foreground`,children:r?`${n.displayName} is connected`:`${n.displayName} is saved, not tested`}),(0,C.jsxs)(`ul`,{className:`m-0 mt-1 list-none space-y-0.5 p-0 text-muted-foreground`,children:[r&&(0,C.jsxs)(`li`,{children:[r.modelName??r.model,` answered in `,((r.ms??0)/1e3).toFixed(1),` s.`]}),(0,C.jsxs)(`li`,{children:[o===0?`No chat model is in use from it.`:o===1?`1 model is in Chat.`:`${o} models are in Chat.`,!r&&o>0&&` Test it from its row before you rely on it.`]}),i.map(e=>(0,C.jsxs)(`li`,{className:`text-warning`,children:[e.model,` was left out: this account cannot use it.`]},e.model)),s.length>0&&(0,C.jsxs)(`li`,{children:[s.join(` and `),` can now be chosen under Images.`]}),a.map(e=>(0,C.jsxs)(`li`,{children:[`The `,e.name,` template now uses `,e.model,`.`]},e.id))]})]})]})}function F({providers:e,imageRoutes:t,start:n,onClose:r,onConnected:i,onOpenProvider:o}){let[s,c]=(0,S.useState)(n&&e.some(e=>e.id===n)?n:null),[l,u]=(0,S.useState)(null),d=e.find(e=>e.id===s)??null,f=e=>t.filter(t=>t.provider===e);return l?(0,C.jsxs)(_,{title:l.provider.displayName,onClose:r,className:`max-w-xl`,children:[(0,C.jsx)(P,{result:l,imageRoutes:f(l.provider.id)}),(0,C.jsx)(b,{children:(0,C.jsx)(a,{variant:`primary`,onClick:r,children:`Done`})})]}):d?(0,C.jsxs)(_,{title:`Connect ${d.displayName}`,onClose:r,className:`top-[6dvh] max-h-[88dvh] max-w-2xl translate-y-0 content-start`,children:[!n&&(0,C.jsxs)(`button`,{type:`button`,onClick:()=>c(null),className:`-mt-1 flex items-center gap-1 justify-self-start text-sm font-semibold text-primary`,children:[(0,C.jsx)(p,{className:`size-4`,"aria-hidden":`true`}),`All providers`]}),(0,C.jsx)(O,{provider:d,imageRoutes:f(d.id).filter(e=>!e.ready),onConnected:async e=>{await i(),u(e)}},d.id)]}):(0,C.jsx)(_,{title:`Add a provider`,onClose:r,className:`top-[6dvh] max-h-[88dvh] max-w-2xl translate-y-0 content-start`,children:(0,C.jsx)(N,{providers:e,onPick:e=>e.listed?o(e.id):c(e.id)})})}export{O as a,w as c,A as i,T as l,P as n,ie as o,N as r,ae as s,F as t};
@@ -1 +0,0 @@
1
- import{$ as e,Z as t,a as n,h as r,s as i}from"./createLucideIcon-CZHSSDYA.js";import{u as a}from"./preload-helper-CZOd_z6l.js";import{t as o}from"./Button-CoKQRO-s.js";import{g as s}from"./parts-68zf8Fgw.js";import{C as c,F as l,K as u,M as d,S as f,q as p}from"./index-B-N6NIX4.js";import{S as m,x as h}from"./manage-R57MUzsY.js";var g=e(t(),1),_=r(),v=[{key:`soul`,name:`SOUL.md`,hint:`Persona, values and operating principles. Part of every session.`,optional:!1},{key:`identity`,name:`IDENTITY.md`,hint:`Name, creature, vibe, emoji and avatar: filled in during the first conversation.`,optional:!1},{key:`bootstrap`,name:`BOOTSTRAP.md`,hint:`The first-run ritual in which the Agent introduces itself; it retires the file once done.`,optional:!0},{key:`agents`,name:`AGENTS.md`,hint:`How the Agent works in its workspace: memory, red lines, who it hands work to.`,optional:!0},{key:`tools`,name:`TOOLS.md`,hint:`Notes on its tools and environment beyond the tool descriptions.`,optional:!0}],y=[{value:`all`,label:`All skills`,hint:`Every installed skill, including ones imported later.`},{value:`selected`,label:`Chosen skills`,hint:`Only the ones ticked below.`}];function b({mode:e,picked:t,skills:n,disabled:r,onModeChange:i,onPickedChange:a}){return(0,_.jsxs)(`div`,{className:`grid gap-3`,children:[(0,_.jsx)(c,{legend:`Skills at spawn`,name:`template-skills`,value:e,options:y,disabled:r,onChange:i}),e===`selected`&&(n.length===0?(0,_.jsxs)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:[`No skills are installed yet. Import some under `,(0,_.jsx)(`a`,{href:`/skills`,children:`Skills`}),`.`]}):(0,_.jsxs)(`fieldset`,{className:`m-0 grid max-h-64 min-w-0 gap-2.5 overflow-y-auto rounded-xl border border-border bg-muted/30 p-3.5`,children:[(0,_.jsx)(`legend`,{className:`sr-only`,children:`Chosen skills`}),n.map(e=>(0,_.jsx)(f,{checked:t.has(e.name),disabled:r,label:(0,_.jsxs)(`span`,{className:`min-w-0`,children:[(0,_.jsx)(`span`,{className:`font-mono text-[0.9em] font-semibold`,children:e.name}),e.description&&(0,_.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,e.description]})]}),onChange:n=>{let r=new Set(t);n?r.add(e.name):r.delete(e.name),a(r)}},e.name))]})),(0,_.jsx)(`p`,{className:`m-0 text-xs text-muted-foreground`,children:`Each Agent can still attach or detach skills after it is spawned.`})]})}function x({chat:e,skills:t,starter:r,onClose:c}){let y=a(),[x,S]=(0,g.useState)(``),[C,w]=(0,g.useState)(``),[T,E]=(0,g.useState)(!1),[D,O]=(0,g.useState)(``),[k,A]=(0,g.useState)(`all`),[j,M]=(0,g.useState)(new Set),[N,P]=(0,g.useState)({soul:!0,identity:!0,bootstrap:!0,agents:!0,tools:!0}),[F,I]=(0,g.useState)(!1),[L,R]=(0,g.useState)(null),z=T?C:m(x),B=h(z),V=z!==``&&!B&&D!==``;async function H(e){if(e.preventDefault(),!(!V||F)){I(!0),R(null);try{await n(`/api/profiles`,{body:{id:z,name:x.trim()||void 0,defaultModel:D,skillsMode:k,defaultSkills:k===`selected`?[...j]:[],soul:r.soul,identity:r.identity,bootstrap:N.bootstrap?r.bootstrap:null,agents:N.agents?r.agents:null,tools:N.tools?r.tools:null}}),await y({to:`/templates/agents/$id`,params:{id:z}})}catch(e){R(i(e)),I(!1)}}}return(0,_.jsx)(u,{title:`New Agent template`,description:`It starts from the built-in files, which you can edit next. Agents spawned from it get their own copies.`,busy:F,onClose:c,className:`max-w-xl`,children:(0,_.jsxs)(`form`,{onSubmit:e=>void H(e),className:`grid gap-4`,children:[(0,_.jsxs)(`div`,{className:`grid items-start gap-x-3 gap-y-4 sm:grid-cols-2`,children:[(0,_.jsx)(d,{label:`Name`,value:x,disabled:F,placeholder:`Writer`,className:`max-w-none`,onChange:S}),(0,_.jsx)(d,{label:`ID`,value:z,disabled:F,placeholder:`writer`,mono:!0,className:`max-w-none`,problem:B,onChange:e=>{E(!0),w(e)}})]}),(0,_.jsx)(l,{kit:!0,label:`Default model`,value:D,onChange:O,models:e,required:!0}),e.length===0&&(0,_.jsxs)(s,{tone:`warning`,children:[`No chat model is in use yet. Add one under `,(0,_.jsx)(`a`,{href:`/config`,children:`Setup → Models`}),` first.`]}),(0,_.jsx)(b,{mode:k,picked:j,skills:t,disabled:F,onModeChange:A,onPickedChange:M}),(0,_.jsxs)(`fieldset`,{className:`m-0 grid min-w-0 gap-2.5 border-0 p-0`,children:[(0,_.jsx)(`legend`,{className:`mb-2 p-0 text-sm font-semibold text-foreground`,children:`Files`}),(0,_.jsx)(`p`,{className:`m-0 text-xs text-muted-foreground`,children:`SOUL.md and IDENTITY.md are always there. These three can be left out:`}),v.filter(e=>e.optional).map(e=>(0,_.jsx)(f,{checked:N[e.key],disabled:F,label:(0,_.jsxs)(`span`,{className:`min-w-0`,children:[(0,_.jsx)(`span`,{className:`font-mono text-[0.9em] font-semibold`,children:e.name}),(0,_.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,e.hint]})]}),onChange:t=>P(n=>({...n,[e.key]:t}))},e.key))]}),L&&(0,_.jsx)(s,{tone:`warning`,role:`alert`,title:`The template was not created.`,children:L}),(0,_.jsxs)(p,{children:[(0,_.jsx)(o,{variant:`ghost`,disabled:F,onClick:c,children:`Cancel`}),(0,_.jsx)(o,{variant:`primary`,type:`submit`,disabled:F||!V,children:F?`Creating…`:`Create and edit its files`})]})]})})}export{b as n,v as r,x as t};
@@ -1 +0,0 @@
1
- import{$ as e,Z as t,h as n,s as r}from"./createLucideIcon-CZHSSDYA.js";import{t as i}from"./Button-CoKQRO-s.js";import{K as a,q as o}from"./index-B-N6NIX4.js";var s=e(t(),1),c=n();function l({open:e,title:t,description:n,confirmLabel:l,confirmVariant:u=`danger`,onConfirm:d,onOpenChange:f}){let[p,m]=(0,s.useState)(!1),[h,g]=(0,s.useState)(null);(0,s.useEffect)(()=>{e||(m(!1),g(null))},[e]);async function _(){m(!0),g(null);try{await d(),f(!1)}catch(e){g(r(e)),m(!1)}}return(0,c.jsxs)(a,{open:e,busy:p,onClose:()=>f(!1),title:t,description:n,className:`max-w-md`,children:[h&&(0,c.jsx)(`p`,{role:`alert`,className:`rounded-md bg-danger/10 px-3 py-2 text-sm text-danger`,children:h}),(0,c.jsxs)(o,{children:[(0,c.jsx)(i,{variant:`ghost`,disabled:p,onClick:()=>f(!1),children:`Cancel`}),(0,c.jsx)(i,{variant:u,disabled:p,onClick:()=>void _(),children:p?`Working…`:l})]})]})}export{l as t};
@@ -1 +0,0 @@
1
- import{$ as e,Z as t,a as n,c as r,d as i,h as a,s as o,t as s}from"./createLucideIcon-CZHSSDYA.js";import{t as c}from"./UnsavedChangesGuard-vQBdMl8h.js";import{t as l}from"./Button-CoKQRO-s.js";import{t as u}from"./arrow-right-BqqfPqVi.js";import{c as d,i as f,n as p,o as m,t as h,u as g}from"./TeamThread-BWmIQiAh.js";import{C as _,_ as v,b as ee,c as y,d as te,f as b,g as x,h as S,i as C,l as ne,n as w,o as T,r as E,s as D,t as O,u as k,v as re,y as ie}from"./style-Bm9QsFpy.js";import{t as A}from"./message-square-B_pULba_.js";import{ft as j,nt as M}from"./index-B-N6NIX4.js";import{r as ae}from"./use-resource-Bn0Sx7r6.js";import{t as oe}from"./ConfirmDialog-B_jXAPmh.js";import{t as N}from"./Segmented-iylzLwE6.js";var se=s(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),P=e(t(),1),F=a(),I=`!size-2.5 !border-2 !border-snow !bg-sapphire`,L=[{id:`t`,position:k.Top},{id:`r`,position:k.Right},{id:`b`,position:k.Bottom},{id:`l`,position:k.Left}];function R(){return(0,F.jsx)(F.Fragment,{children:L.map(e=>(0,F.jsx)(C,{id:e.id,type:`source`,position:e.position,className:I},e.id))})}function z({data:e,selected:t}){let{member:n}=e;return(0,F.jsxs)(`div`,{className:`w-[210px] rounded-2xl border bg-snow px-3 py-2.5 shadow-baziu-sm transition-shadow ${t?`border-sapphire shadow-baziu-md`:`border-frost`}`,children:[(0,F.jsx)(R,{}),(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,F.jsx)(M,{identity:n.identity,size:34}),(0,F.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`span`,{className:`block truncate text-sm font-semibold text-chocolate`,children:n.name}),(0,F.jsxs)(`span`,{className:`mt-0.5 flex min-w-0 items-center gap-1.5 text-xs ${n.isolated?`font-semibold text-warning`:`text-mocha`}`,children:[(0,F.jsx)(`span`,{className:`size-[7px] shrink-0 rounded-full ${m[n.state.kind]}`,"aria-hidden":`true`}),(0,F.jsx)(`span`,{className:`min-w-0 truncate`,children:n.isolated?`No connections`:n.state.text})]})]})]})]})}function B({selected:e}){return(0,F.jsxs)(`div`,{className:`w-[160px] rounded-2xl border border-dashed bg-ivory px-3 py-2.5 ${e?`border-sapphire`:`border-fawn`}`,children:[(0,F.jsx)(R,{}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(_,{className:`size-4 shrink-0 text-rose-baziu`,"aria-hidden":`true`}),(0,F.jsx)(`span`,{className:`block text-sm font-semibold text-chocolate`,children:`Other teams`})]})]})}var V={member:z,outside:B},H=(e,t)=>`pair:${f(e,t)}`;function ce(e){if(!e?.startsWith(`pair:`))return null;let[t,n]=e.slice(5).split(`|`);return t&&n?[t,n]:null}var U={member:{w:210,h:62},outside:{w:160,h:46}};function W(e,t){let n=e=>U[e.type===`outside`?`outside`:`member`],r=t.position.x+n(t).w/2-(e.position.x+n(e).w/2),i=t.position.y+n(t).h/2-(e.position.y+n(e).h/2);return Math.abs(r)>=Math.abs(i)*1.4?r>0?{from:`r`,to:`l`}:{from:`l`,to:`r`}:i>0?{from:`b`,to:`t`}:{from:`t`,to:`b`}}function le({document:e,members:t,traffic:n,selectedId:r,onSelect:i,onConnect:a,onMove:o,onOpenMember:s}){let c=(0,P.useMemo)(()=>{let e=Math.max(520,...t.map(e=>e.position.x+270)),n=t.length===0?120:t.reduce((e,t)=>e+t.position.y,0)/t.length;return[...t.map(e=>({id:e.id,type:`member`,position:e.position,data:{member:e},ariaLabel:`${e.name}: ${e.isolated?`no connections`:e.state.text}`,selected:r===e.id,deletable:!1})),{id:b,type:`outside`,position:{x:e,y:n},data:{},ariaLabel:`Agents in other teams`,selected:r===b,draggable:!1,deletable:!1}]},[t,r]),[l,u,d]=D(c);(0,P.useEffect)(()=>{u(e=>{let t=new Map(e.map(e=>[e.id,e]));return c.map(e=>{let n=t.get(e.id);return n?.dragging?{...e,position:n.position}:e})})},[c,u]);let f=(0,P.useMemo)(()=>{let t=[],i=new Map(l.map(e=>[e.id,e])),a=[...i.keys()];for(let o=0;o<a.length;o++)for(let s=o+1;s<a.length;s++){let[c,l]=[a[o],a[s]].sort(),u=x(e,c,l),d=x(e,l,c),f=H(c,l),p=n.get(f)??0;if(!u&&!d&&p===0)continue;let m=W(i.get(c),i.get(l)),h=u||d,g=r===f,_=g?`var(--color-sapphire-deep)`:h?`var(--color-sapphire)`:`var(--color-fawn)`,v={type:ne.ArrowClosed,width:16,height:16,color:_};t.push({id:f,source:c,target:l,sourceHandle:m.from,targetHandle:m.to,selected:g,...u?{markerEnd:v}:{},...d?{markerStart:v}:{},style:{stroke:_,strokeWidth:g?2.6:1.8,...h?{}:{strokeDasharray:`5 5`}},...p>0?{label:`${p} message${p===1?``:`s`}`,labelStyle:{fontSize:11,fontWeight:600,fill:`var(--color-mocha)`},labelBgStyle:{fill:`var(--color-snow)`,stroke:`var(--color-frost)`},labelBgPadding:[6,3],labelBgBorderRadius:8}:{},interactionWidth:24})}return t},[l,e,n,r]);return(0,F.jsx)(`div`,{className:`h-full min-h-[420px] w-full bg-ivory`,children:(0,F.jsxs)(T,{nodes:l,edges:f,nodeTypes:V,connectionMode:y.Loose,onConnect:e=>{e.source&&e.target&&e.source!==e.target&&a(e.source,e.target)},onNodesChange:d,onNodeClick:(e,t)=>i(t.id),onNodeDoubleClick:(e,t)=>{t.type===`member`&&s(t.id)},onEdgeClick:(e,t)=>i(t.id),onPaneClick:()=>i(null),onNodeDragStop:(e,t)=>{t.type===`member`&&o(t.id,t.position)},deleteKeyCode:null,minZoom:.35,maxZoom:1.6,edgesReconnectable:!1,fitView:!0,fitViewOptions:{padding:.2,maxZoom:1},proOptions:{hideAttribution:!0},className:`policy-flow`,children:[(0,F.jsx)(O,{variant:w.Dots,gap:20,size:1.2,color:`var(--color-fawn)`}),(0,F.jsx)(E,{position:`bottom-left`,showInteractive:!1,className:`!overflow-hidden !rounded-md !border !border-frost !bg-snow !shadow-baziu-sm [&_button]:!border-frost [&_button]:!bg-snow [&_button]:!fill-chocolate`})]})})}var ue={open:`Members message each other freely. A connection only matters for reaching other Teams.`,restricted:`A member can message a teammate only along a connection.`};function de(e,t){if(t===1)return{x:220,y:140};let n=Math.max(135,t*38),r=e/t*2*Math.PI-Math.PI/2;return{x:Math.round(40+n*1.3*(1+Math.cos(r))),y:Math.round(40+n*(1+Math.sin(r)))}}var G=(e,t)=>e.has(t)?t:b,K=e=>`bz_map_${e}`;function fe(e){try{let t=JSON.parse(window.localStorage.getItem(K(e))??`{}`);return t&&typeof t==`object`?t:{}}catch{return{}}}function q({team:e}){let t=ae(t=>n(`/api/teams/${encodeURIComponent(e.id)}/policy`,{signal:t}),[e.id]);return t.error?(0,F.jsx)(d,{view:`connections`,children:(0,F.jsx)(`p`,{role:`alert`,className:`err m-4`,children:t.error})}):t.data?(0,F.jsx)(J,{team:e,policy:t.data},e.id):(0,F.jsx)(d,{view:`connections`,children:(0,F.jsx)(`p`,{role:`status`,className:`m-4 text-sm text-muted-foreground`,children:`Loading the connections…`})})}function J({team:e,policy:t}){let{agentById:r,search:a}=g(),s=j(),u=i(),f=p(e.id,300),[m,_]=(0,P.useState)(()=>v(t)),[y,x]=(0,P.useState)(m),[C,ne]=(0,P.useState)(`map`),[w,T]=(0,P.useState)(null),[E,D]=(0,P.useState)({}),[O,k]=(0,P.useState)(!1),[A,M]=(0,P.useState)(null),[ae,I]=(0,P.useState)(!1),L=!ie(m,y);(0,P.useEffect)(()=>D(fe(e.id)),[e.id]);let R=(t,n)=>{D(r=>{let i={...r,[t]:n};try{window.localStorage.setItem(K(e.id),JSON.stringify(i))}catch{}return i})},z=(0,P.useMemo)(()=>y.members.filter(e=>e.status!==`archived`),[y.members]),B=(0,P.useMemo)(()=>new Set(z.map(e=>e.key)),[z]),V=z.map((e,t)=>({id:e.key,name:e.name,identity:r(e.key)?.identity,state:s.stateOf(e.key),isolated:y.mode===`restricted`&&!y.edges.some(t=>t.from===e.key||t.to===e.key),position:E[e.key]??de(t,z.length)})),U=e=>G(B,e),W=f.data,q=(0,P.useMemo)(()=>{let e=new Map;for(let t of W??[]){let n=G(B,t.fromAgentId),r=G(B,t.toAgentId);if(n===r)continue;let i=H(n,r);e.set(i,(e.get(i)??0)+1)}return e},[W,B]),J=(e,t,n)=>{M(null),x(r=>ee(r,e,t,n))};async function Y(){k(!0),M(null);try{let t=v(await n(`/api/teams/${encodeURIComponent(e.id)}/policy`,{method:`PATCH`,body:{mode:y.mode,edges:re(y)}}));_(t),x(t),M({error:!1,text:`Saved. It applies to the next message an Agent sends.`}),await u.invalidate()}catch(e){M({error:!0,text:o(e)})}finally{k(!1)}}let X=ce(w),Z=w&&(B.has(w)||w===b)?w:null,Q=(e,t)=>U(e.fromAgentId)===t||U(e.toAgentId)===t,$=W??[],he=X?$.filter(e=>Q(e,X[0])&&Q(e,X[1])):Z?$.filter(e=>Q(e,Z)):$;return(0,F.jsxs)(d,{view:`connections`,actions:(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(N,{label:`How members reach each other`,value:y.mode,options:[{id:`open`,label:`Open`},{id:`restricted`,label:`Restricted`}],onChange:e=>{M(null),x(t=>({...t,mode:e}))}}),(0,F.jsx)(N,{label:`Show as`,value:C,options:[{id:`map`,label:`Map`},{id:`matrix`,label:`Table`}],onChange:ne}),(0,F.jsx)(l,{variant:`ghost`,className:`min-h-8 px-3 py-1 text-xs`,disabled:!L||O,onClick:()=>I(!0),children:`Discard`}),(0,F.jsxs)(l,{variant:`primary`,className:`min-h-8 px-3 py-1 text-xs`,disabled:!L||O,onClick:()=>void Y(),children:[(0,F.jsx)(se,{className:`size-3.5`,"aria-hidden":`true`}),O?`Saving…`:`Save`]})]}),children:[(0,F.jsx)(c,{when:L,subject:`connection changes`}),(0,F.jsxs)(`div`,{className:`grid h-full min-h-0 grid-cols-1 lg:grid-cols-[minmax(0,1fr)_23rem]`,children:[(0,F.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-col max-lg:h-[52vh]`,children:[(0,F.jsx)(`p`,{className:`m-0 border-b border-border px-3 py-1.5 text-xs ${A?.error?`text-danger`:L?`text-warning`:`text-mocha`}`,role:A?.error?`alert`:`status`,children:A?.text??(L?`Unsaved changes. `:``)+ue[y.mode]+(C===`map`?` Drag from one Agent to another to connect them.`:``)}),(0,F.jsx)(`div`,{className:`min-h-0 flex-1`,children:z.length===0?(0,F.jsx)(`p`,{className:`m-0 p-6 text-center text-sm text-muted-foreground`,children:`This Team has no members to connect yet.`}):C===`map`?(0,F.jsx)(le,{document:y,members:V,traffic:q,selectedId:w,onSelect:T,onConnect:(e,t)=>{J(e,t,!0),T(H(e,t))},onMove:R,onOpenMember:e=>void u.navigate({to:`/`,search:{agent:e,panel:`connections`}})}):(0,F.jsx)(te,{document:{...y,members:z},selectedId:w,onSelect:T,onToggle:J})})]}),(0,F.jsxs)(`aside`,{"aria-label":`About the selection`,className:`min-h-0 overflow-y-auto border-border p-3.5 max-lg:border-t lg:border-l`,children:[X?(0,F.jsx)(pe,{document:y,pair:X,onToggle:J,onClear:()=>T(null)}):Z?(0,F.jsx)(me,{document:y,actor:Z,others:[...z.map(e=>e.key),b].filter(e=>e!==Z),panel:a.panel,onToggle:J,onSelectPair:e=>T(H(Z,e))}):(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`h2`,{className:`m-0 font-body text-sm font-semibold text-foreground`,children:[z.length,` member`,z.length===1?``:`s`,` ·`,` `,y.mode===`open`?`open Team`:`restricted Team`]}),(0,F.jsx)(`p`,{className:`m-0 mt-1 text-xs leading-relaxed text-mocha`,children:`Select an Agent to choose who it can message, or a line to see what two Agents said to each other. You can always talk to every Agent, and every Agent can always reach you.`})]}),(0,F.jsx)(`h2`,{className:`m-0 mb-1.5 mt-5 font-body text-xs font-bold uppercase tracking-[0.08em] text-muted-foreground`,children:X?`Messages between them`:Z?`Messages of ${S(y,Z)}`:`Recent messages`}),f.error?(0,F.jsx)(`p`,{role:`alert`,className:`m-0 text-xs text-danger`,children:f.error}):(0,F.jsx)(h,{messages:he,limit:30,empty:X||Z?`None among the Team’s recent messages.`:`No messages between Agents yet.`})]})]}),(0,F.jsx)(oe,{open:ae,title:`Discard the connection changes?`,description:(0,F.jsx)(`p`,{children:`Every unsaved change is dropped. The saved connections stay as they are.`}),confirmLabel:`Discard changes`,onConfirm:()=>{x(m),T(null),M(null)},onOpenChange:I})]})}function Y({document:e,from:t,to:n,onToggle:r}){let i=x(e,t,n),a=e.mode===`open`&&t!==b&&n!==b;return(0,F.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":i,onClick:()=>r(t,n,!i),className:`unstyled flex min-h-10 w-full items-center gap-2 rounded-[10px] border px-2.5 py-1.5 text-left text-sm ${i?`border-primary/30 bg-accent/60`:`border-border bg-card hover:bg-muted`}`,children:[(0,F.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`min-w-0 truncate font-semibold text-foreground`,children:S(e,t)}),(0,F.jsx)(u,{className:`size-3.5 shrink-0 text-mocha`,"aria-hidden":`true`}),(0,F.jsx)(`span`,{className:`min-w-0 truncate font-semibold text-foreground`,children:S(e,n)})]}),(0,F.jsx)(`span`,{className:`shrink-0 text-xs font-semibold ${i?`text-accent-foreground`:`text-muted-foreground`}`,children:i?`Connected`:a?`Open anyway`:`Not connected`})]})}function pe({document:e,pair:[t,n],onToggle:r,onClear:i}){let a=x(e,t,n)||x(e,n,t);return(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`h2`,{className:`m-0 font-body text-sm font-semibold text-foreground`,children:[S(e,t),` and `,S(e,n)]}),(0,F.jsxs)(`p`,{className:`m-0 mt-1 text-xs leading-relaxed text-mocha`,children:[`Each direction is its own connection.`,t===b||n===b?` Reaching another Team also needs that Team to connect its Agent to “Other teams”.`:``]}),(0,F.jsxs)(`div`,{className:`mt-3 space-y-1.5`,children:[(0,F.jsx)(Y,{document:e,from:t,to:n,onToggle:r}),(0,F.jsx)(Y,{document:e,from:n,to:t,onToggle:r})]}),a&&(0,F.jsx)(`div`,{className:`mt-2.5`,children:(0,F.jsx)(l,{variant:`danger`,className:`min-h-8 px-3 py-1 text-xs`,onClick:()=>{r(t,n,!1),r(n,t,!1),i()},children:`Disconnect both ways`})})]})}function me({document:e,actor:t,others:n,panel:i,onToggle:a,onSelectPair:o}){let{agentById:s}=g(),c=j(),l=t===b?void 0:s(t),u=l?c.stateOf(l.id):null;return(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[t!==b&&(0,F.jsx)(M,{identity:l?.identity,size:34}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`h2`,{className:`m-0 truncate font-body text-sm font-semibold text-foreground`,children:S(e,t)}),u?(0,F.jsxs)(`p`,{className:`m-0 flex min-w-0 items-center gap-1.5 text-xs text-mocha`,children:[(0,F.jsx)(`span`,{className:`size-[7px] shrink-0 rounded-full ${m[u.kind]}`,"aria-hidden":`true`}),(0,F.jsx)(`span`,{className:`min-w-0 truncate`,children:u.text})]}):(0,F.jsx)(`p`,{className:`m-0 text-xs text-mocha`,children:`Every Agent that is not in this Team.`})]}),l&&(0,F.jsxs)(r,{to:`/`,search:{agent:l.id,...i?{panel:i}:{panel:`connections`}},className:`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-[10px] border border-border bg-card px-2.5 text-xs font-semibold text-foreground hover:border-sapphire-light hover:text-sapphire`,children:[(0,F.jsx)(A,{className:`size-3.5`,"aria-hidden":`true`}),`Open`]})]}),(0,F.jsx)(`div`,{className:`mt-3 space-y-3`,children:n.map(n=>(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>o(n),className:`unstyled mb-1 text-xs font-semibold text-mocha hover:text-sapphire`,children:[`With `,S(e,n)]}),(0,F.jsxs)(`div`,{className:`space-y-1`,children:[(0,F.jsx)(Y,{document:e,from:t,to:n,onToggle:a}),(0,F.jsx)(Y,{document:e,from:n,to:t,onToggle:a})]})]},n))})]})}export{q as ConnectionsView};
@@ -1 +0,0 @@
1
- import{c as e,h as t}from"./createLucideIcon-CZHSSDYA.js";var n=t();function r({label:t,base:r,tabs:i,children:a}){return(0,n.jsxs)(`nav`,{"aria-label":t,className:`mb-6 flex max-w-full gap-1 overflow-x-auto rounded-xl border border-border bg-muted/50 p-1`,children:[i.map(([t,i])=>{let a=`${r}${t}`;return(0,n.jsx)(e,{to:a,activeOptions:{exact:!t,includeSearch:!1},className:`inline-flex items-center whitespace-nowrap rounded-lg border px-2 py-1.5 text-xs font-semibold transition-colors sm:px-3 sm:text-sm`,activeProps:{className:`border-border bg-card text-foreground shadow-baziu-sm`},inactiveProps:{className:`border-transparent text-muted-foreground hover:bg-card/70 hover:text-foreground`},children:i},a)}),a]})}var i=[[`/agents`,`Agents`],[`/teams`,`Teams`],[`/templates/agents`,`Agent templates`],[`/templates/teams`,`Team templates`],[`/skills`,`Skills`],[`/usage`,`Usage`]],a=[[``,`Models`],[`/tools`,`Tools`],[`/mcp`,`MCP`],[`/telegram`,`Telegram`],[`/access`,`Access`],[`/system`,`System`]];export{i as n,r,a as t};
@@ -1 +0,0 @@
1
- import{$ as e,Z as t,a as n,h as r,i,s as a,t as o}from"./createLucideIcon-CZHSSDYA.js";import{t as s}from"./Button-CoKQRO-s.js";import{S as c}from"./es2015-D1pnOGPG.js";import{g as l}from"./parts-68zf8Fgw.js";import{C as u,K as d,M as f,S as p,q as m}from"./index-B-N6NIX4.js";import{s as h}from"./manage-R57MUzsY.js";var g=o(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),_=e(t(),1),v=r();function y({findings:e}){return(0,v.jsx)(`ul`,{className:`m-0 mt-1 grid list-none gap-1 p-0`,children:e.map((e,t)=>(0,v.jsxs)(`li`,{className:`min-w-0`,children:[(0,v.jsxs)(`span`,{className:e.severity===`danger`?`font-semibold`:``,children:[e.severity===`danger`?`Risky`:`Check`,`:`]}),` `,e.message,` `,(0,v.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.code,e.line?`, line ${e.line}`:``,`)`]})]},t))})}function b({findings:e,title:t}){let n=e.some(e=>e.severity===`danger`);return(0,v.jsx)(l,{tone:n?`warning`:`neutral`,title:t??(n?`Read it before an Agent uses it: its text goes into the system prompt.`:`Worth a look.`),children:(0,v.jsx)(y,{findings:e})})}var x=[{value:`openclaw`,label:`OpenClaw`,hint:`Every skill in ~/.openclaw/skills on the computer Bazilion runs on.`},{value:`path`,label:`A folder`,hint:`One skill folder with a SKILL.md, or a folder of them, on that computer.`},{value:`zip`,label:`A ZIP file`,hint:`Uploaded from here: one folder per skill at its top level.`}];function S({onClose:e,onImported:t}){let[r,o]=(0,_.useState)(`openclaw`),[g,y]=(0,_.useState)(``),[S,C]=(0,_.useState)(null),[w,T]=(0,_.useState)(!1),[E,D]=(0,_.useState)(!1),[O,k]=(0,_.useState)(!1),[A,j]=(0,_.useState)(null),[M,N]=(0,_.useState)([]),P=r===`path`&&g.trim()&&!g.trim().startsWith(`/`)?`The full path of the folder, starting with /.`:void 0,F=r===`openclaw`||r===`path`&&g.trim()!==``&&!P||r===`zip`&&S!==null;function I(e){if(e){if(j(null),!/\.zip$/i.test(e.name)){j(`Only ZIP archives can be imported.`);return}C(e)}}async function L(e){if(e.preventDefault(),!F||O)return;k(!0),j(null),N([]);let o;if(r===`zip`&&S){let e=new FormData;e.set(`file`,S),E&&e.set(`force`,`true`),o=e}else o={source:r===`openclaw`?`openclaw`:g.trim(),force:E};try{await t(await n(`/api/skills/import`,{body:o}))}catch(e){e instanceof i&&N(e.body?.findings??[]),j(a(e)),k(!1)}}return(0,v.jsx)(d,{title:`Import skills`,description:`A skill's SKILL.md is added to the system prompt of every Agent it is attached to. Each one is scanned before it is installed.`,busy:O,onClose:e,className:`max-w-2xl`,children:(0,v.jsxs)(`form`,{onSubmit:e=>void L(e),className:`grid gap-4`,children:[(0,v.jsx)(u,{legend:`From`,name:`skills-source`,value:r,options:x,columns:3,disabled:O,onChange:e=>{o(e),j(null),N([])}}),r===`path`&&(0,v.jsx)(f,{label:`Folder`,value:g,disabled:O,placeholder:`/home/you/my-skills`,mono:!0,className:`max-w-none`,problem:P,onChange:y}),r===`zip`&&(0,v.jsxs)(`label`,{onDragOver:e=>{e.preventDefault(),T(!0)},onDragLeave:()=>T(!1),onDrop:e=>{e.preventDefault(),T(!1),I(e.dataTransfer.files[0])},className:c(`relative m-0 block cursor-pointer rounded-xl border-2 border-dashed px-6 py-7 text-center text-sm transition-colors`,w?`border-primary bg-accent text-accent-foreground`:S?`border-solid border-primary/40 bg-card text-foreground`:`border-border bg-muted/30 text-muted-foreground hover:border-primary hover:bg-accent/60`),children:[(0,v.jsx)(`input`,{type:`file`,accept:`.zip,application/zip`,disabled:O,onChange:e=>I(e.target.files?.[0]),className:`absolute h-px w-px overflow-hidden opacity-0`}),S?(0,v.jsx)(`span`,{className:`block break-all font-mono text-foreground`,children:S.name}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`span`,{className:`block font-semibold text-foreground`,children:`Choose a ZIP file`}),(0,v.jsx)(`span`,{className:`text-xs`,children:`or drop it here`})]})]}),(0,v.jsx)(p,{checked:E,disabled:O,label:`Replace skills that are already installed, and import despite scan findings`,onChange:D}),M.length>0&&(0,v.jsx)(b,{findings:M,title:`The scan found ${h(M.length,`thing`)} to check. Read them; to import anyway, tick the box above.`}),A&&M.length===0&&(0,v.jsx)(l,{tone:`warning`,role:`alert`,title:`Nothing was imported.`,children:A}),(0,v.jsxs)(m,{children:[(0,v.jsx)(s,{variant:`ghost`,disabled:O,onClick:e,children:`Cancel`}),(0,v.jsx)(s,{variant:`primary`,type:`submit`,disabled:O||!F,children:O?`Importing…`:r===`openclaw`?`Import from OpenClaw`:r===`zip`?`Upload and import`:`Import`})]})]})})}export{g as i,b as n,S as r,y as t};
@@ -1 +0,0 @@
1
- import{$ as e,Z as t,a as n,h as r,s as i}from"./createLucideIcon-CZHSSDYA.js";import{t as a}from"./Button-CoKQRO-s.js";import{g as o}from"./parts-68zf8Fgw.js";import{C as s,K as c,M as l,O as u,q as d}from"./index-B-N6NIX4.js";import{S as f,s as p,x as m}from"./manage-R57MUzsY.js";var h=e(t(),1),g=r();function _({template:e,teams:t,initialTeamId:r=``,onClose:_,onSpawned:v}){let y=t.some(e=>e.id===r),[b,x]=(0,h.useState)(y?`existing`:`new`),[S,C]=(0,h.useState)(y?r:t[0]?.id??``),[w,T]=(0,h.useState)(y?``:r||f(e.name)),[E,D]=(0,h.useState)(e.userMd??``),[O,k]=(0,h.useState)(null),[A,j]=(0,h.useState)(!1),M=b===`existing`?S:w.trim(),N=b===`new`?m(M)??(t.some(e=>e.id===M)?`A Team with this ID exists: choose it under “A Team that exists”.`:void 0):void 0,P=M!==``&&!N&&e.slots.length>0;async function F(t){if(t.preventDefault(),!(!P||A)){j(!0),k(null);try{await n(`/api/team-templates/${encodeURIComponent(e.id)}/spawn`,{body:{teamId:M,...b===`new`&&E!==(e.userMd??``)?{userMd:E}:{}}}),v(M)}catch(e){k(i(e)),j(!1)}}}return(0,g.jsx)(c,{title:`Spawn ${e.name}`,description:`Creates ${p(e.slots.length,`Agent`)} and ${p(e.edges.length,`connection`)} between them.`,busy:A,onClose:_,className:`max-w-xl`,children:(0,g.jsxs)(`form`,{onSubmit:e=>void F(e),className:`grid gap-4`,children:[(0,g.jsx)(s,{legend:`Into`,name:`spawn-team-target`,value:b,disabled:A,options:[{value:`new`,label:`A new Team`,hint:`It is ${e.policyMode===`restricted`?`restricted: members message each other along connections`:`open: members message each other freely`}, as the template is.`},{value:`existing`,label:`A Team that exists`,hint:`The Agents join it; it keeps its own messaging rules.`}],onChange:x}),b===`new`?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(l,{label:`ID of the new Team`,value:w,disabled:A,placeholder:`launch`,mono:!0,className:`max-w-none`,problem:N,onChange:T}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`label`,{htmlFor:`spawn-team-user-md`,className:`m-0 text-sm font-semibold text-foreground`,children:`USER.md`}),(0,g.jsx)(`textarea`,{id:`spawn-team-user-md`,rows:4,value:E,disabled:A,onChange:e=>D(e.target.value),className:`mt-1.5 font-mono text-sm leading-[1.55]`}),(0,g.jsx)(`span`,{className:`mt-1 block text-xs text-muted-foreground`,children:`What every Agent of the new Team knows about you. It starts from the template’s.`})]})]}):(0,g.jsx)(u,{label:`Team`,value:S,options:t.map(e=>({value:e.id,label:e.name})),disabled:A,className:`max-w-none`,onChange:C}),e.slots.length===0&&(0,g.jsx)(o,{tone:`warning`,children:`This template has no Agents yet: add some to it first.`}),O&&(0,g.jsx)(o,{tone:`warning`,role:`alert`,title:`The Team was not spawned.`,children:O}),(0,g.jsxs)(d,{children:[(0,g.jsx)(a,{variant:`ghost`,disabled:A,onClick:_,children:`Cancel`}),(0,g.jsx)(a,{variant:`primary`,type:`submit`,disabled:A||!P,children:A?`Spawning…`:`Spawn ${p(e.slots.length,`Agent`)}`})]})]})})}export{_ as t};
@@ -1 +0,0 @@
1
- import{$ as e,Z as t,a as n,h as r,s as i}from"./createLucideIcon-CZHSSDYA.js";import{t as a}from"./Button-CoKQRO-s.js";import{g as o}from"./parts-68zf8Fgw.js";import{C as s,M as c,q as l}from"./index-B-N6NIX4.js";import{S as u,x as d}from"./manage-R57MUzsY.js";var f=e(t(),1),p=r();function m(e){let t=e.id.trim(),n=e.folder.trim(),r={},i=d(t);return i&&(r.id=i),e.place===`link`&&n&&!n.startsWith(`/`)&&(r.folder=`The full path of the folder, starting with /.`),!(t!==``&&(e.place===`new`||n!==``))||r.id||r.folder?{body:null,problems:r}:{body:{id:t,...e.name.trim()?{name:e.name.trim()}:{},...e.place===`link`?{link:n}:{}},problems:r}}function h({onCreated:e,onBusyChange:t,extraActions:r}){let[d,h]=(0,f.useState)(``),[g,_]=(0,f.useState)(``),[v,y]=(0,f.useState)(!1),[b,x]=(0,f.useState)(`new`),[S,C]=(0,f.useState)(``),[w,T]=(0,f.useState)(!1),[E,D]=(0,f.useState)(null),O=v?g:u(d),k=m({name:d,id:O,place:b,folder:S});function A(e){T(e),t?.(e)}async function j(t){if(t.preventDefault(),!(!k.body||w)){D(null),A(!0);try{await e(await n(`/api/teams`,{body:k.body}))}catch(e){D(i(e))}finally{A(!1)}}}return(0,p.jsxs)(`form`,{onSubmit:e=>void j(e),className:`grid gap-4`,children:[(0,p.jsxs)(`div`,{className:`grid items-start gap-x-3 gap-y-4 sm:grid-cols-2`,children:[(0,p.jsx)(c,{label:`Name`,value:d,disabled:w,placeholder:`My project`,className:`max-w-none`,onChange:e=>{h(e),D(null)}}),(0,p.jsx)(c,{label:`ID`,value:O,disabled:w,placeholder:`my-project`,mono:!0,className:`max-w-none`,hint:`Used in commands and addresses; it cannot change later.`,problem:k.problems.id,onChange:e=>{y(!0),_(e),D(null)}})]}),(0,p.jsx)(s,{legend:`Where its files are`,name:`team-place`,value:b,disabled:w,options:[{value:`new`,label:`A new folder`,hint:`Bazilion makes one for it in its home.`},{value:`link`,label:`A project folder`,hint:`Its Agents work in a folder that already exists, such as a code repository.`}],onChange:x}),b===`link`&&(0,p.jsx)(c,{label:`Folder`,value:S,disabled:w,placeholder:`/home/you/projects/my-project`,mono:!0,className:`max-w-none`,hint:`The Team links to it; removing the Team later removes only the link, never the folder.`,problem:k.problems.folder,onChange:C}),E&&(0,p.jsx)(o,{tone:`warning`,role:`alert`,title:`The Team was not created.`,children:E}),(0,p.jsxs)(l,{children:[r?.(w),(0,p.jsx)(a,{variant:`primary`,type:`submit`,disabled:w||!k.body,children:w?`Creating…`:`Create Team`})]})]})}export{h as t};
@@ -1 +0,0 @@
1
- import{$ as e,Z as t,a as n,c as r,h as i,t as a}from"./createLucideIcon-CZHSSDYA.js";import{n as o,t as s}from"./images-BULrW-FC.js";import{t as c}from"./arrow-right-BqqfPqVi.js";import{t as l}from"./network-BqmVqC4_.js";import{ft as u,nt as d,rt as f,ut as p}from"./index-B-N6NIX4.js";import{r as m,t as h}from"./use-resource-Bn0Sx7r6.js";var g=a(`code-xml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),_=e(t(),1),v=i(),y=(0,_.createContext)(null);function b({value:e,children:t}){let n=(0,_.useMemo)(()=>{let t=new Map(e.agents.map(e=>[e.id,e]));return{...e,agentById:e=>t.get(e),to:t=>({...e.search,...t})}},[e]);return(0,v.jsx)(y.Provider,{value:n,children:t})}function x(){let e=(0,_.useContext)(y);if(!e)throw Error(`useWorkspace needs a WorkspaceProvider`);return e}function S(){return(0,_.useContext)(y)}var C={connections:{label:`Connections`,icon:l},changes:{label:`Changes`,icon:g},files:{label:`Files`,icon:s}};function w({view:e,actions:t,children:n}){let{team:i,agent:a,to:s}=x();return(0,v.jsxs)(`section`,{"aria-label":`${C[e].label} of ${i?.name??`the Team`}`,className:`flex h-full min-w-0 flex-col overflow-hidden rounded-[16px] border border-border bg-card shadow-baziu-sm`,children:[(0,v.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-border bg-muted/60 px-3 py-2`,children:[(0,v.jsxs)(r,{to:`/`,search:s({view:void 0,result:void 0,panel:e}),className:`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-[10px] border border-border bg-card px-2.5 text-sm font-semibold text-foreground hover:border-sapphire-light hover:text-sapphire`,children:[(0,v.jsx)(o,{className:`size-3.5`,"aria-hidden":`true`}),a?a.agent.name:`Back`]}),(0,v.jsx)(`h1`,{className:`m-0 min-w-0 truncate font-display text-xl leading-tight text-charcoal`,children:i?.name}),(0,v.jsx)(`nav`,{"aria-label":`Team views`,className:`flex rounded-[12px] border border-border bg-card p-0.5`,children:f.map(t=>{let n=C[t].icon,i=t===e;return(0,v.jsxs)(r,{to:`/`,search:s({view:t}),"aria-current":i?`page`:void 0,className:`inline-flex h-7 items-center gap-1.5 rounded-[9px] px-2.5 text-sm font-semibold ${i?`bg-accent text-accent-foreground`:`text-mocha hover:bg-muted hover:text-foreground`}`,children:[(0,v.jsx)(n,{className:`size-3.5`,"aria-hidden":`true`}),(0,v.jsx)(`span`,{className:i?``:`hidden sm:inline`,children:C[t].label})]},t)})}),t&&(0,v.jsx)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:t})]}),(0,v.jsx)(`div`,{className:`min-h-0 flex-1`,children:n})]})}var T={needs:`text-warning`,working:`text-success`,paused:`text-warning`,fresh:`text-accent-foreground`,idle:`text-muted-foreground`},E={needs:`bg-warning`,working:`bg-success animate-pulse`,paused:`bg-fawn`,fresh:`bg-primary`,idle:`bg-fawn`};function D(e){try{let t=JSON.parse(e);if(typeof t.text==`string`)return t.text}catch{}return e}var O=(e,t)=>e<t?`${e}|${t}`:`${t}|${e}`;function k(e){let t=new Map;for(let n of e){let e=O(n.fromAgentId,n.toAgentId),r=t.get(e)??{forward:0,back:0,lastAt:0};n.fromAgentId<n.toAgentId?r.forward++:r.back++,r.lastAt=Math.max(r.lastAt,n.createdAt),t.set(e,r)}return t}function A(e,t=100){let{turnsEnded:r}=u();return m(r=>n(`/api/teams/${encodeURIComponent(e)}/messages?limit=${t}`,{signal:r}).then(e=>e.messages),[e,t,r])}function j({messages:e,limit:t=20,empty:n=`No messages between Agents yet.`}){let{agentById:r}=x(),i=h();if(e.length===0)return(0,v.jsx)(`p`,{className:`m-0 py-3 text-sm text-muted-foreground`,children:n});let a=e=>r(e)?.name??e.slice(0,8);return(0,v.jsxs)(`ol`,{className:`m-0 list-none space-y-1.5 p-0`,children:[e.slice(0,t).map(e=>{let t=D(e.payload);return(0,v.jsx)(`li`,{children:(0,v.jsxs)(`details`,{className:`group rounded-[10px] border border-border bg-card`,children:[(0,v.jsxs)(`summary`,{className:`flex cursor-pointer list-none flex-col gap-0.5 px-2.5 py-2 [&::-webkit-details-marker]:hidden`,children:[(0,v.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs`,children:[(0,v.jsx)(d,{identity:r(e.fromAgentId)?.identity,size:18}),(0,v.jsx)(`span`,{className:`min-w-0 truncate font-semibold text-foreground`,children:a(e.fromAgentId)}),(0,v.jsx)(c,{className:`size-3 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,v.jsx)(d,{identity:r(e.toAgentId)?.identity,size:18}),(0,v.jsx)(`span`,{className:`min-w-0 truncate font-semibold text-foreground`,children:a(e.toAgentId)}),e.readAt===null&&(0,v.jsx)(`span`,{className:`shrink-0 rounded-full bg-warning/15 px-1.5 text-xs font-semibold text-warning`,children:`unread`}),i&&(0,v.jsx)(`time`,{dateTime:new Date(e.createdAt).toISOString(),className:`ml-auto shrink-0 text-muted-foreground`,children:p(e.createdAt)})]}),(0,v.jsx)(`span`,{className:`line-clamp-2 break-words text-sm leading-snug text-mocha group-open:hidden`,children:t})]}),(0,v.jsx)(`p`,{className:`m-0 whitespace-pre-wrap break-words border-t border-frost/70 px-2.5 py-2 text-sm leading-snug text-chocolate`,children:t})]})},e.id)}),e.length>t&&(0,v.jsxs)(`li`,{className:`px-1 text-xs text-muted-foreground`,children:[`The newest `,t,` of `,e.length,` loaded.`]})]})}export{k as a,w as c,S as d,g as f,O as i,b as l,A as n,E as o,D as r,T as s,j as t,x as u};
@@ -1 +0,0 @@
1
- import{$ as e,Z as t,a as n,c as r,d as i,h as a,s as o}from"./createLucideIcon-CZHSSDYA.js";import{t as s}from"./Button-CoKQRO-s.js";import{_ as c,c as l,d as u,g as d,h as f,i as p,m,o as h,r as g,v as _,y as ee}from"./parts-68zf8Fgw.js";import{t as v}from"./bot-BHky7KAX.js";import{K as y,O as b,nt as x,q as S,u as C,x as w}from"./index-B-N6NIX4.js";import{t as te}from"./ConfirmDialog-B_jXAPmh.js";import{t as ne}from"./Segmented-iylzLwE6.js";import{t as T}from"./ManagePage-kd7iWYEL.js";import{i as E,n as D,t as O}from"./agent-actions-B-9KIwn6.js";import{T as k,c as A,n as j,r as M,s as N}from"./manage-R57MUzsY.js";var P=e(t(),1),F=a();function I({agent:e,teams:t,onClose:r,onMoved:i}){let a=t.filter(t=>t.id!==e.teamId),[c,l]=(0,P.useState)(a[0]?.id??``),[u,f]=(0,P.useState)(!1),[p,m]=(0,P.useState)(null),h=t.find(t=>t.id===e.teamId)?.name??e.teamId;async function g(t){if(t.preventDefault(),!(!c||u)){f(!0),m(null);try{await n(`/api/agents/${encodeURIComponent(e.id)}/team`,{method:`PATCH`,body:{teamId:c}}),await i()}catch(e){m(o(e)),f(!1)}}}return(0,F.jsx)(y,{title:`Move ${e.name}`,description:`From ${h} to another Team. Its conversations and files go with it; its connections stay behind, so it joins the other Team with none.`,busy:u,onClose:r,children:(0,F.jsxs)(`form`,{onSubmit:e=>void g(e),className:`grid gap-4`,children:[(0,F.jsx)(b,{label:`Team`,value:c,options:a.map(e=>({value:e.id,label:e.name})),disabled:u,className:`max-w-none`,onChange:l}),p&&(0,F.jsx)(d,{tone:`warning`,role:`alert`,title:`It was not moved.`,children:p}),(0,F.jsxs)(S,{children:[(0,F.jsx)(s,{variant:`ghost`,disabled:u,onClick:r,children:`Cancel`}),(0,F.jsx)(s,{variant:`primary`,type:`submit`,disabled:u||!c,children:u?`Moving…`:`Move to ${t.find(e=>e.id===c)?.name??`Team`}`})]})]})})}function L({agents:e,teams:t,templates:n,chat:i,onSpawn:a,onChanged:y}){let[b,S]=(0,P.useState)(``),[C,w]=(0,P.useState)(`current`),[T,L]=(0,P.useState)(null),[z,B]=(0,P.useState)(null),[V,H]=(0,P.useState)(null),[U,W]=(0,P.useState)(null),[G,K]=(0,P.useState)(null),q=j(e),J=(0,P.useRef)(null),[Y,X]=(0,P.useState)(!1);(0,P.useEffect)(()=>{!Y||T!==null||(J.current?.focus(),X(!1))},[Y,T]);let Z=A(e,t,C,b);async function Q(e,t){L(e.id),B(null);try{await t(),await y()}catch(e){B(o(e))}finally{L(null)}}let re=e=>Q(e,async()=>{await O(e.id),H(e),X(!0)}),$=e=>Q(e,async()=>{await E(e.id),H(null)});return(0,F.jsxs)(ee,{labelledBy:`manage-agents`,icon:(0,F.jsx)(v,{className:`size-5`}),title:`Agents`,description:`Grouped by Team. An archived Agent keeps its files and conversations, takes no work, and can be restored.`,children:[(0,F.jsxs)(l,{children:[(0,F.jsx)(_,{label:`Find an Agent`,placeholder:`Find by name, creature or vibe`,value:b,onChange:S,className:`min-w-0 flex-1 basis-60`}),(0,F.jsx)(ne,{label:`Which Agents`,value:C,onChange:w,options:[{id:`current`,label:`Current ${q.current}`},{id:`archived`,label:`Archived ${q.archived}`},{id:`all`,label:`All`}]})]}),V&&(0,F.jsx)(g,{className:`py-3`,children:(0,F.jsxs)(d,{tone:`neutral`,actions:(0,F.jsxs)(s,{ref:J,variant:`ghost`,disabled:T!==null,onClick:()=>void $(V),children:[`Restore `,V.name]}),children:[V.name,` is archived. It keeps its files and conversations and takes no work until it is restored.`]})}),z&&(0,F.jsx)(g,{className:`py-3`,children:(0,F.jsx)(d,{tone:`warning`,role:`alert`,title:`That did not work.`,children:z})}),e.length===0?(0,F.jsx)(p,{icon:(0,F.jsx)(v,{className:`size-5`}),title:`No Agents yet`,action:(0,F.jsx)(s,{variant:`primary`,disabled:n.length===0||t.length===0,onClick:a,children:`Spawn an agent`}),children:`An Agent is spawned from a template into a Team, and starts talking as soon as it is.`}):Z.length===0?(0,F.jsx)(p,{title:b.trim()?`No Agent matches “${b.trim()}”`:R(C),children:b.trim()?`Try another name, or look in all of them.`:`Archived Agents appear here when there are any.`}):Z.map(({team:e,agents:a})=>(0,F.jsxs)(`section`,{"aria-label":e.name,children:[(0,F.jsx)(m,{title:e.name,meta:`${N(a.length,`Agent`)} · ${e.policyMode===`restricted`?`Restricted`:`Open`}`,action:(0,F.jsx)(r,{to:`/`,search:{team:e.id,panel:`team`},children:`Open Team`})}),(0,F.jsx)(h,{children:a.map(e=>{let a=n.find(t=>t.id===e.profileId),o=M(e,n,i),l=e.status===`archived`,d=[e.identity?.creature,e.identity?.vibe].filter(Boolean).join(` · `);return(0,F.jsx)(f,{inline:!0,leading:(0,F.jsx)(x,{identity:e.identity,size:32}),title:(0,F.jsx)(r,{to:`/`,search:{agent:e.id},className:`text-foreground hover:text-primary`,children:e.name}),chip:l&&(0,F.jsx)(u,{tone:`neutral`,children:`Archived`}),meta:(0,F.jsxs)(F.Fragment,{children:[d&&(0,F.jsx)(`span`,{children:d}),(0,F.jsxs)(`span`,{children:[a?(0,F.jsx)(`a`,{href:`/templates/agents/${encodeURIComponent(a.id)}`,children:k(a)}):e.profileId,` `,`template`]}),o&&(0,F.jsxs)(`span`,{className:o.missing?`font-semibold text-warning`:``,children:[o.name,o.missing?`, not in Chat`:o.inherited?``:`, its own`]})]}),actions:(0,F.jsxs)(F.Fragment,{children:[l&&(0,F.jsx)(s,{variant:`ghost`,disabled:T===e.id,onClick:()=>void $(e),children:`Restore`}),(0,F.jsx)(c,{label:`More for ${e.name}`,disabled:T===e.id,items:[t.length>1&&{label:`Move to another Team…`,onSelect:()=>W(e)},!l&&{label:`Archive`,onSelect:()=>void re(e)},{label:`Delete permanently…`,danger:!0,onSelect:()=>K(e)}]})]})},e.id)})})]},e.id)),U&&(0,F.jsx)(I,{agent:U,teams:t,onClose:()=>W(null),onMoved:async()=>{W(null),await y()}}),(0,F.jsx)(te,{open:G!==null,onOpenChange:e=>{e||K(null)},title:`Delete ${G?.name??`this Agent`} permanently?`,description:(0,F.jsx)(`p`,{className:`m-0`,children:`This removes the Agent, its conversations, messages, schedules, skill attachments and its folder. It cannot be undone. To keep them, archive it instead.`}),confirmLabel:`Delete permanently`,onConfirm:async()=>{G&&(await D(G.id),V?.id===G.id&&H(null),await y())}})]})}function R(e){return e===`archived`?`No archived Agents`:`No current Agents`}function z(){let{agents:e,templates:t,teams:n,chat:r}=C.useLoaderData(),a=i(),[o,c]=(0,P.useState)(!1);return(0,F.jsxs)(T,{title:`Agents`,description:`Every Agent in every Team. Open one to talk to it; its model, skills and schedules are in its side panel.`,actions:(0,F.jsx)(s,{variant:`primary`,disabled:t.length===0||n.length===0,onClick:()=>c(!0),children:`Spawn an agent`}),children:[(0,F.jsx)(L,{agents:e,teams:n,templates:t,chat:r,onSpawn:()=>c(!0),onChanged:()=>a.invalidate({sync:!0})}),o&&(0,F.jsx)(w,{profiles:t,teams:n,onClose:()=>c(!1)})]})}export{z as component};
@@ -1 +0,0 @@
1
- import{$ as e,Z as t,a as n,d as r,h as i,s as a,t as o}from"./createLucideIcon-CZHSSDYA.js";import{t as s}from"./Button-CoKQRO-s.js";import{b as c,x as l}from"./es2015-D1pnOGPG.js";import{b as u,d,n as f,t as p,v as m,x as h,y as g}from"./parts-68zf8Fgw.js";import{t as _}from"./images-BULrW-FC.js";import{t as v}from"./chevron-right-D1shxvdo.js";import{t as y}from"./message-square-B_pULba_.js";import{t as b}from"./plus-CEKaHPBw.js";import{G as x,H as S,I as C,K as w,R as T,U as E,V as D,W as O,f as k,z as A}from"./index-B-N6NIX4.js";import{r as j}from"./use-resource-Bn0Sx7r6.js";import{t as M}from"./ConfirmDialog-B_jXAPmh.js";import{t as N}from"./Segmented-iylzLwE6.js";import{t as P}from"./ConfigPage-Ch-DSJUO.js";import{c as F,l as I,o as L,s as R,t as z}from"./AddProviderDialog-DZ9mXFdq.js";var B=o(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),V=e(t(),1),H=i(),U=[{id:`all`,label:`All`},{id:`images`,label:`Sees images`},{id:`reasoning`,label:`Reasoning`}],W=80;function G({providers:e,chat:t,onClose:r,onSaved:i,onAddProvider:o}){let[c,l]=(0,V.useState)(``),[u,d]=(0,V.useState)(`all`),[f,p]=(0,V.useState)(!1),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(!1),[y,b]=(0,V.useState)(null),x=j(async t=>{let r=await Promise.all(e.map(async e=>({provider:e,catalog:await n(`/api/config/providers/${encodeURIComponent(e.id)}/catalog`,{signal:t})})));return g(Object.fromEntries(r.map(({provider:e,catalog:t})=>[e.id,t.models.filter(e=>e.selected).map(e=>e.id)]))),r},[e.map(e=>e.id).join(`,`)]),C=h??{},T=(e,t)=>C[e]?.includes(t)??!1,E=(e,t)=>g(n=>{let r=n?.[e]??[];return{...n,[e]:r.includes(t)?r.filter(e=>e!==t):[...r,t]}}),O=(e,t)=>c?D(e,c):e.dated&&!f&&!T(t.id,e.id)?!1:u===`images`?e.images===!0:u===`reasoning`?e.reasoning===!0:!0,k=(0,V.useMemo)(()=>(x.data??[]).filter(({provider:e,catalog:t})=>{let n=t.models.filter(e=>e.selected).map(e=>e.id),r=C[e.id]??[];return n.length!==r.length||n.some(e=>!r.includes(e))}),[x.data,C]),A=t.filter(e=>e.usedBy.agents>0&&k.some(({provider:t})=>t.id===e.provider)&&!T(e.provider,e.id)),M=Object.values(C).reduce((e,t)=>e+t.length,0);async function P(){v(!0),b(null);try{for(let{provider:e}of k)await n(`/api/config/providers/${encodeURIComponent(e.id)}/models`,{method:`PUT`,body:{models:C[e.id]??[]}});await i(),r()}catch(e){b(a(e)),v(!1)}}return(0,H.jsxs)(w,{title:`Chat models`,description:`Tick the models your Agents may use. Each Agent and each template picks one of them.`,onClose:r,busy:_,className:`top-[4dvh] max-h-[92dvh] max-w-3xl translate-y-0 content-start`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(m,{label:`Search models`,placeholder:`Search by name, for example haiku`,value:c,onChange:l,className:`flex-1 basis-60`}),(0,H.jsx)(N,{label:`Show`,value:u,options:U,onChange:d})]}),(0,H.jsxs)(`div`,{className:`max-h-[min(58dvh,36rem)] min-h-40 overflow-y-auto rounded-xl border border-border`,children:[x.loading&&!x.data&&(0,H.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Reading the model lists…`}),x.error&&(0,H.jsx)(`div`,{role:`alert`,className:`p-4 text-sm text-danger`,children:x.error}),x.data?.length===0&&(0,H.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`No provider is connected yet. Add one to see its models here.`}),(x.data??[]).map(({provider:e,catalog:t})=>{let n=t.models.filter(t=>O(t,e)),r=n.slice(0,W),i=t.models.filter(t=>t.dated&&!T(e.id,t.id)).length;return c&&n.length===0?null:(0,H.jsxs)(`section`,{"aria-label":e.displayName,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 border-b border-border bg-muted/50 px-4 py-2`,children:[(0,H.jsx)(`h3`,{className:`m-0 font-body text-xs font-bold uppercase tracking-[0.08em] text-muted-foreground`,children:e.displayName}),(0,H.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[(C[e.id]??[]).length,` of `,t.models.length,` in use`]}),t.listError&&(0,H.jsxs)(`span`,{className:`text-xs text-warning`,children:[`Its own list could not be read: `,t.listError]})]}),r.length===0&&(0,H.jsx)(`div`,{className:`border-b border-border px-4 py-3 text-sm text-muted-foreground`,children:t.models.length===0?`It lists no model.`:`Nothing matches.`}),r.map(t=>(0,H.jsx)(R,{model:{...t,suggested:!1},connect:e.connect,checked:T(e.id,t.id),disabled:_,onToggle:()=>E(e.id,t.id),className:`px-4 hover:bg-accent/30`},t.id)),n.length>r.length&&(0,H.jsxs)(`div`,{className:`border-b border-border px-4 py-2 text-xs text-muted-foreground`,children:[n.length-r.length,` more: search to narrow them down.`]}),!c&&i>0&&(0,H.jsx)(`div`,{className:`border-b border-border px-4 py-1.5`,children:(0,H.jsx)(`button`,{type:`button`,onClick:()=>p(e=>!e),className:`text-xs font-semibold text-primary`,children:f?`Hide dated versions`:`Show ${i} dated ${i===1?`version`:`versions`} of the same models`})})]},e.id)})]}),A.length>0&&(0,H.jsxs)(`p`,{role:`status`,className:`m-0 rounded-xl bg-warning/10 px-3 py-2 text-sm text-warning`,children:[A.map(e=>S(e)).join(`, `),` `,A.length===1?`is`:`are`,` in use by Agents. They are refused until you give them another model in their Agent tab.`]}),y&&(0,H.jsx)(`p`,{role:`alert`,className:`m-0 rounded-xl bg-danger/10 px-3 py-2 text-sm text-danger`,children:y}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 border-t border-frost pt-4`,children:[(0,H.jsx)(`span`,{className:`min-w-0 flex-1 basis-40 text-sm text-muted-foreground`,children:M===1?`1 model in Chat`:`${M} models in Chat`}),(0,H.jsx)(`button`,{type:`button`,onClick:o,className:`text-sm font-semibold text-primary`,children:`A model from another provider?`}),(0,H.jsx)(s,{variant:`ghost`,disabled:_,onClick:r,children:`Cancel`}),(0,H.jsx)(s,{variant:`primary`,disabled:_||k.length===0,onClick:()=>void P(),children:_?`Saving…`:`Save`})]})]})}function K({providers:e,chat:t,now:n,onOpen:r,onTestAll:i,testing:a}){let o=e.filter(e=>e.enabled);if(o.length===0)return null;let c=o.filter(e=>e.state===`failing`||e.state===`incomplete`),l=o.filter(e=>e.state===`untested`&&e.models.length>0);if(c.length>0)return(0,H.jsx)(`div`,{className:`grid gap-2`,children:c.map(e=>{let i=t.filter(t=>t.provider===e.id),a=i.reduce((e,t)=>e+t.usedBy.agents,0);return(0,H.jsx)(p,{tone:`warning`,lead:(0,H.jsxs)(H.Fragment,{children:[e.check?.failure?.title??`${e.displayName}: ${O(e,n).label.toLowerCase()}`,`.`]}),action:(0,H.jsxs)(s,{variant:`ghost`,onClick:()=>r(e.id),children:[`Open `,e.displayName]}),children:i.length===0?`No chat model runs on it.`:`${i.length===1?`1 chat model runs`:`${i.length} chat models run`} on it${a===0?``:`, used by ${a===1?`1 Agent`:`${a} Agents`}`}.`},e.id)})});if(l.length>0)return(0,H.jsx)(p,{tone:`neutral`,lead:l.length===1?`${l[0]?.displayName} has not been tested.`:`${l.length} providers have not been tested.`,action:(0,H.jsx)(s,{variant:`ghost`,disabled:a,onClick:i,children:a?`Testing…`:l.length===1?`Test it`:`Test them`}),children:`A test sends one short message to the cheapest model of each.`});let u=o.filter(e=>e.state===`working`);return u.length===0?null:(0,H.jsxs)(p,{tone:`success`,lead:u.length===1?`Your provider answers.`:`Every provider answers.`,action:(0,H.jsx)(s,{variant:`ghost`,disabled:a,onClick:i,children:a?`Testing…`:`Test again`}),children:[t.length===1?`1 chat model`:`${t.length} chat models`,` for your Agents.`]})}function q({chat:e,hasProviders:t,onPick:r,onChanged:i}){let[o,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(null);async function p(t){let r=e.filter(e=>e.provider===t.provider&&e.id!==t.id).map(e=>e.id);await n(`/api/config/providers/${encodeURIComponent(t.provider)}/models`,{method:`PUT`,body:{models:r}}),await i()}function m(e){d(null),e.usedBy.agents>0||e.usedBy.templates.length>0?l(e):p(e).catch(e=>d(a(e)))}return(0,H.jsxs)(g,{labelledBy:`setup-chat`,icon:(0,H.jsx)(y,{className:`size-5`}),title:`Chat`,description:`The models Agents think with. Each Agent and each template uses one of them.`,action:(0,H.jsxs)(s,{variant:`primary`,disabled:!t,onClick:r,children:[(0,H.jsx)(b,{className:`size-4`,"aria-hidden":`true`}),`Add models`]}),children:[e.length>0&&(0,H.jsxs)(`div`,{"aria-hidden":`true`,className:`flex flex-wrap items-center gap-x-4 gap-y-1 border-t border-border px-4 sm:px-5 hidden bg-muted/50 py-2 text-xs font-bold uppercase tracking-[0.08em] text-muted-foreground lg:flex`,children:[(0,H.jsx)(`span`,{className:`min-w-0 flex-[2.2] basis-52`,children:`Model`}),(0,H.jsx)(`span`,{className:`w-28 shrink-0`,children:`Provider`}),(0,H.jsx)(`span`,{className:`min-w-0 flex-[2] basis-48`,children:`Can do`}),(0,H.jsx)(`span`,{className:`w-40 shrink-0`,children:`Price per 1M tokens`}),(0,H.jsx)(`span`,{className:`min-w-0 flex-[1.4] basis-36`,children:`Used by`}),(0,H.jsx)(`span`,{className:`w-8 shrink-0`})]}),e.map(e=>{let t=e.providerState===`failing`||e.providerState===`incomplete`;return(0,H.jsxs)(`div`,{className:`${f} min-h-16 py-2.5`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-[2.2] basis-52`,children:[(0,H.jsx)(`div`,{className:`text-base font-semibold text-foreground`,children:S(e)}),e.name&&(0,H.jsx)(`div`,{className:`break-all font-mono text-xs text-muted-foreground`,children:e.id})]}),(0,H.jsx)(`div`,{className:`w-28 shrink-0 text-sm`,children:e.providerName}),(0,H.jsx)(`div`,{className:`min-w-0 flex-[2] basis-48 text-sm ${t?`font-semibold text-warning`:`text-muted-foreground`}`,children:t?`${e.providerName} is not working`:A(e,e.providerConnect)}),(0,H.jsx)(`div`,{className:`w-40 shrink-0 text-sm`,children:E(e,e.providerConnect)}),(0,H.jsx)(`div`,{className:`min-w-0 flex-[1.4] basis-36 text-sm text-muted-foreground`,children:x(e.usedBy)}),(0,H.jsx)(`button`,{type:`button`,"aria-label":`Remove ${S(e)} from Chat`,onClick:()=>m(e),className:`flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-muted hover:text-danger`,children:(0,H.jsx)(c,{className:`size-4`,"aria-hidden":`true`})})]},e.value)}),e.length===0&&(0,H.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 border-t border-border px-4 sm:px-5 py-5 text-sm text-muted-foreground`,children:t?`No chat model yet. Agents cannot answer until one is added.`:`No chat model yet. Add a provider below, and its models appear here.`}),u&&(0,H.jsx)(`div`,{role:`alert`,className:`flex flex-wrap items-center gap-x-4 gap-y-1 border-t border-border px-4 sm:px-5 py-3 text-sm text-danger`,children:u}),(0,H.jsx)(M,{open:o!==null,onOpenChange:e=>{e||l(null)},title:`Remove ${o?S(o):``} from Chat?`,description:o&&(0,H.jsxs)(`p`,{className:`m-0`,children:[`It is used by `,x(o.usedBy),`.`,` `,o.usedBy.agents>0&&`Those Agents are refused until you give them another model in their Agent tab. `,o.usedBy.templates.length>0&&`An Agent template on it moves to another model by itself.`]}),confirmLabel:`Remove from Chat`,onConfirm:async()=>{o&&await p(o)}})]})}function J({images:e,onConnect:t,onChanged:r}){let[i,o]=(0,V.useState)(null),[c,l]=(0,V.useState)(null),u=e.routes.find(t=>t.id===e.selected),p=u?.ready===!0,m=i??e.selected;async function h(e){o(e),l(null);try{await n(`/api/config/fields/BAZILION_IMAGE_MODEL`,{method:`PUT`,body:{value:e}}),await r()}catch(e){l(a(e))}finally{o(null)}}let v=(e,t,n,r)=>(0,H.jsxs)(`label`,{className:`${f} m-0 min-h-[3.25rem] py-2 ${n?`cursor-pointer`:``} ${m===e?`bg-accent/40`:``}`,children:[(0,H.jsx)(`input`,{type:`radio`,name:`image-model`,checked:m===e,disabled:!n||i!==null,onChange:()=>void h(e),className:`m-0 size-[18px] shrink-0 accent-[var(--color-sapphire)]`}),t,(0,H.jsx)(`span`,{className:`ml-auto flex shrink-0 justify-end sm:w-44`,children:r})]},e);return(0,H.jsxs)(g,{labelledBy:`setup-images`,icon:(0,H.jsx)(_,{className:`size-5`}),title:`Images`,description:`What Agents draw with. One model for every Agent, up to four images a turn.`,action:(0,H.jsx)(d,{tone:p?`success`:u?`warning`:`neutral`,children:p?`On: ${u.model}`:u?`Needs ${u.needs}`:`Off`}),children:[e.routes.map(e=>v(e.id,(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{className:`min-w-0 flex-[1.6] basis-60 text-base`,children:[(0,H.jsx)(`span`,{className:`font-semibold ${e.ready?`text-foreground`:`text-muted-foreground`}`,children:e.model}),` `,(0,H.jsxs)(`span`,{className:`text-muted-foreground`,children:[`through `,e.providerName]})]}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 basis-44 text-sm text-muted-foreground`,children:e.billing})]}),e.ready,e.ready?(0,H.jsx)(`span`,{className:`text-sm font-semibold text-success`,children:`Ready`}):(0,H.jsx)(s,{variant:`ghost`,onClick:()=>t(e.provider),children:e.provider===`openai-codex`?`Sign in`:`Connect ${e.providerName}`}))),v(`off`,(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`min-w-0 flex-[1.6] basis-60 text-base font-semibold text-foreground`,children:`Off`}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 basis-44 text-sm text-muted-foreground`,children:`Agents have no image tool`})]}),!0,null),e.selected!==`off`&&!u&&(0,H.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center gap-x-4 gap-y-1 border-t border-border px-4 sm:px-5 py-3 text-sm text-warning`,children:[`BAZILION_IMAGE_MODEL is set to “`,e.selected,`”, which is not an image route. Choose one above.`]}),c&&(0,H.jsx)(`div`,{role:`alert`,className:`flex flex-wrap items-center gap-x-4 gap-y-1 border-t border-border px-4 sm:px-5 py-3 text-sm text-danger`,children:c})]})}function Y({providers:e,total:t,images:n,now:r,onOpen:i,onAdd:a}){let o=n.routes.find(e=>e.id===n.selected&&e.ready);return(0,H.jsxs)(g,{labelledBy:`setup-providers`,icon:(0,H.jsx)(B,{className:`size-5`}),title:`Providers`,description:`The accounts and local servers your models run on.`,action:(0,H.jsxs)(s,{variant:`primary`,onClick:a,children:[(0,H.jsx)(b,{className:`size-4`,"aria-hidden":`true`}),`Add a provider`]}),children:[e.map(e=>{let t=e.enabled?e.models.length:0,n=[t>0?`Chat: ${t===1?`1 model`:`${t} models`}`:null,o?.provider===e.id?`Images`:null].filter(Boolean),a=O(e,r);return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),className:`${f} min-h-[4.25rem] w-full py-3 text-left transition-colors hover:bg-accent/30`,children:[(0,H.jsx)(F,{name:e.displayName,tone:a.tone}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-[1.6] basis-56`,children:[(0,H.jsx)(`span`,{className:`block text-base font-semibold text-foreground`,children:e.displayName}),(0,H.jsx)(`span`,{className:`block truncate text-sm text-muted-foreground`,children:T(e)})]}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 basis-40 text-sm text-muted-foreground`,children:n.length>0?n.join(` · `):`Not used yet`}),(0,H.jsx)(I,{provider:e,now:r}),(0,H.jsx)(v,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`})]},e.id)}),e.length===0&&(0,H.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 border-t border-border px-4 sm:px-5 py-5 text-sm text-muted-foreground`,children:`No provider yet. Add one to give your Agents a model.`}),(0,H.jsxs)(`div`,{className:`${f} bg-muted/50 py-3 text-sm text-muted-foreground`,children:[t-e.length,` more can be added: a ChatGPT plan, API keys from OpenAI, Anthropic, Google and many others, or a model server on this computer.`]})]})}function X({field:e}){let t=r(),i=`/api/config/fields/${encodeURIComponent(e.envVar)}`,o=(0,V.useId)(),c=`${o}-description`,[l,u]=(0,V.useState)(e.kind===`config`?e.value??``:``),[d,f]=(0,V.useState)(!1),[p,m]=(0,V.useState)(null),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(!1),y=e.kind===`secret`&&l.trim().length===0;async function b(r){if(r.preventDefault(),y){m(e.set?`Paste a replacement value, or use remove credential to explicitly clear the stored secret.`:`A secret value is required.`);return}f(!0),m(null);try{await n(i,{method:`PUT`,body:{value:l}}),g(Date.now()),e.kind===`secret`&&u(``),await t.invalidate()}catch(e){m(a(e))}finally{f(!1)}}async function x(){await n(i,{method:`DELETE`}),u(``),m(null),g(Date.now()),await t.invalidate()}return(0,H.jsxs)(`form`,{onSubmit:b,className:`grid grid-cols-1 gap-2 border-b py-3 last:border-0 md:grid-cols-[12rem_minmax(0,1fr)_auto_auto] md:items-center`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`label`,{htmlFor:o,className:`text-sm font-medium text-foreground`,children:e.label}),e.description&&(0,H.jsx)(`div`,{id:c,className:`text-xs text-muted-foreground mt-0.5`,children:e.description}),(0,H.jsxs)(`details`,{className:`mt-1 text-xs text-muted-foreground`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer`,children:`Advanced identifier`}),(0,H.jsx)(`code`,{className:`mt-1 inline-block break-all font-mono`,children:e.envVar})]})]}),(0,H.jsx)(`div`,{className:`min-w-0`,children:e.kind===`config`?(0,H.jsx)(`input`,{id:o,type:`text`,"aria-describedby":e.description?c:void 0,value:l,onChange:e=>u(e.target.value),placeholder:e.placeholder??``,className:`w-full rounded-md border bg-background px-2 py-1.5 text-sm outline-none focus:ring-2 focus:ring-ring/30`}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`input`,{id:o,type:`password`,"aria-describedby":e.description?c:void 0,value:l,onChange:e=>u(e.target.value),placeholder:e.set?`(paste to replace stored value)`:e.placeholder??`paste key…`,autoComplete:`off`,className:`w-full rounded-md border bg-background px-2 py-1.5 text-sm outline-none focus:ring-2 focus:ring-ring/30`}),e.set&&(0,H.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Blank keeps the current credential. Removal is a separate explicit action.`})]})}),(0,H.jsxs)(`span`,{className:`text-xs`,children:[e.kind===`secret`&&e.set&&(0,H.jsx)(`span`,{className:`rounded-full bg-success/10 text-success px-1.5 py-0.5`,title:`preview: ${e.preview??``}`,children:`set`}),h&&Date.now()-h<2e3&&(0,H.jsx)(`span`,{role:`status`,className:`text-success ml-2`,children:`saved ✓`})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2 md:justify-self-end`,children:[(0,H.jsx)(s,{variant:`ghost`,type:`submit`,disabled:d||y,className:`text-xs`,children:`save`}),e.kind===`secret`&&e.set&&(0,H.jsx)(s,{variant:`danger`,className:`text-xs`,onClick:()=>v(!0),children:`remove`})]}),p&&(0,H.jsx)(`p`,{role:`alert`,className:`text-xs text-danger md:col-span-4`,children:p}),(0,H.jsx)(M,{open:_,title:`Remove ${e.label}?`,description:(0,H.jsxs)(`p`,{children:[`This permanently deletes the stored `,(0,H.jsx)(`code`,{className:`font-mono`,children:e.envVar}),` `,`credential. Features that use it will fail until you save a replacement.`]}),confirmLabel:`remove stored credential`,onConfirm:x,onOpenChange:v})]})}var Z=`m-0 font-body text-xs font-bold uppercase tracking-[0.08em] text-muted-foreground`;function Q({provider:e,chat:t,imageRoutes:r,imageSelected:i,onClose:o,onChanged:c,onPickModels:d,onReconnect:f}){let p=(0,V.useMemo)(()=>Date.now(),[]),[m,g]=(0,V.useState)(null),[_,y]=(0,V.useState)(null),[b,T]=(0,V.useState)(!1),[E,D]=(0,V.useState)(!1),O=`/api/config/providers/${encodeURIComponent(e.id)}`,{state:k,check:A}=e,j=e.connect===`signin`,N=e.fields.filter(e=>!e.advanced),P=e.fields.filter(e=>e.advanced),F=t.reduce((e,t)=>e+t.usedBy.agents,0),I=r.find(e=>e.id===i);async function R(e,t){g(e),y(null);try{await t(),await c()}catch(e){y(a(e))}finally{g(null)}}let z=()=>R(`test`,()=>n(`${O}/test`,{method:`POST`})),B=e=>R(`switch`,()=>n(`${O}/enabled`,{method:`PUT`,body:{enabled:e}})),U=()=>R(`signin`,()=>n(`/api/auth/openai/login`,{method:`POST`}));async function W(){await n(O,{method:`DELETE`}),await c(),o()}let G=e.models.length>0,K=(e,t=!1)=>(0,H.jsx)(s,{variant:t?`primary`:`ghost`,disabled:m!==null,onClick:()=>void z(),children:e});return(0,H.jsxs)(w,{title:e.displayName,description:e.hint,onClose:o,busy:m===`signin`,className:`top-[4dvh] max-h-[92dvh] max-w-2xl translate-y-0 content-start gap-5`,children:[m===`test`?(0,H.jsx)(`div`,{className:`rounded-2xl border border-border bg-muted/40 p-4`,children:(0,H.jsx)(h,{children:`Asking for a short reply…`})}):m===`signin`?(0,H.jsx)(`div`,{className:`rounded-2xl border border-border bg-muted/40 p-4`,children:(0,H.jsx)(h,{children:`Waiting for the ChatGPT sign-in in the browser…`})}):k===`working`&&A?(0,H.jsxs)(`div`,{role:`status`,className:`flex flex-wrap items-center gap-3 rounded-2xl border border-success/30 bg-success/10 p-4 text-sm`,children:[(0,H.jsx)(l,{className:`size-5 shrink-0 text-success`,"aria-hidden":`true`}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1 basis-48`,children:[(0,H.jsxs)(`div`,{className:`font-semibold text-foreground`,children:[A.modelName??A.model,` answered in `,((A.ms??0)/1e3).toFixed(1),` s`]}),(0,H.jsxs)(`div`,{className:`text-muted-foreground`,children:[`Tested `,C(A.at,p)]})]}),K(`Test again`)]}):k===`failing`&&A?.failure?(0,H.jsxs)(L,{failure:A.failure,children:[(0,H.jsxs)(`span`,{className:`mr-auto self-center text-xs text-muted-foreground`,children:[`Tried `,C(A.at,p)]}),A.failure.kind===`credentials`&&(0,H.jsx)(s,{variant:`ghost`,onClick:j?()=>void U():f,children:j?`Sign in again`:`Replace the key`}),K(`Try again`,!0)]}):k===`incomplete`?(0,H.jsxs)(`div`,{role:`status`,className:`flex flex-wrap items-center gap-3 rounded-2xl border border-warning/35 bg-warning/10 p-4 text-sm`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1 basis-48`,children:[(0,H.jsx)(`div`,{className:`font-semibold text-foreground`,children:j?`Not signed in`:`Switched on, but its credentials are missing`}),(0,H.jsx)(`div`,{className:`text-muted-foreground`,children:`Agents on its models are refused until it is connected again.`})]}),(0,H.jsx)(s,{variant:`primary`,onClick:j?()=>void U():f,children:j?`Sign in with ChatGPT`:`Connect`})]}):k===`off`?(0,H.jsxs)(`div`,{role:`status`,className:`flex flex-wrap items-center gap-3 rounded-2xl border border-border bg-muted/40 p-4 text-sm`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1 basis-48`,children:[(0,H.jsx)(`div`,{className:`font-semibold text-foreground`,children:e.models.length===0?`Saved, not in use`:`Turned off`}),(0,H.jsx)(`div`,{className:`text-muted-foreground`,children:e.models.length===0?`Connect it to choose its models and test it.`:`Its models are out of Chat until you turn it on again. What is saved stays saved.`})]}),e.models.length===0?(0,H.jsx)(s,{variant:`primary`,disabled:m!==null,onClick:f,children:`Connect`}):(0,H.jsx)(s,{variant:`primary`,disabled:m!==null||!e.configured,onClick:()=>void B(!0),children:`Turn on`})]}):(0,H.jsxs)(`div`,{role:`status`,className:`flex flex-wrap items-center gap-3 rounded-2xl border border-border bg-muted/40 p-4 text-sm`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1 basis-48`,children:[(0,H.jsx)(`div`,{className:`font-semibold text-foreground`,children:`Not tested yet`}),(0,H.jsx)(`div`,{className:`text-muted-foreground`,children:G?`A test sends one short message to its cheapest model in Chat.`:`It has no model in Chat, so there is nothing to ask.`})]}),G&&K(`Test now`,!0)]}),_&&(0,H.jsx)(`p`,{role:`alert`,className:`m-0 rounded-xl bg-danger/10 px-3 py-2 text-sm text-danger`,children:_}),(0,H.jsxs)(`section`,{"aria-label":`Credentials`,children:[(0,H.jsx)(`h3`,{className:Z,children:j?`Sign-in`:e.connect===`local`?`Address`:`Credentials`}),(0,H.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3`,children:[(0,H.jsx)(`div`,{className:`min-w-0 flex-1 basis-56 text-sm`,children:j?e.configured?(0,H.jsxs)(H.Fragment,{children:[`Signed in with your ChatGPT account`,e.account&&(0,H.jsxs)(`span`,{className:`text-muted-foreground`,children:[` (`,e.account,`)`]}),`. Bazilion renews the sign-in by itself.`]}):`Not signed in.`:N.length===0?(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:e.configured?`Read from the environment of the machine Bazilion runs on.`:`Not found in the environment of the machine Bazilion runs on.`}):(0,H.jsx)(`dl`,{className:`m-0 grid gap-1`,children:N.map(t=>(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-x-2`,children:[(0,H.jsx)(`dt`,{className:`text-muted-foreground`,children:t.label}),(0,H.jsx)(`dd`,{className:`m-0 min-w-0 break-all font-mono text-[0.85em]`,children:t.kind===`secret`?t.set?`${t.preview??`saved`}, stored encrypted`:`not saved`:t.value||(e.address??`not set`)})]},t.envVar))})}),j?(0,H.jsx)(s,{variant:`ghost`,disabled:m!==null,onClick:()=>void U(),children:e.configured?`Sign in again`:`Sign in with ChatGPT`}):N.length>0&&(0,H.jsx)(s,{variant:`ghost`,disabled:m!==null,onClick:f,children:e.connect===`local`?`Change the address`:N.some(e=>e.kind===`secret`&&!e.set)?`Add the key`:`Replace the key`})]})]}),(0,H.jsxs)(`section`,{"aria-label":`Its models in Chat`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(`h3`,{className:`${Z} flex-1`,children:`Its models in Chat`}),(0,H.jsx)(`button`,{type:`button`,onClick:d,className:`text-sm font-semibold text-primary`,children:`Choose models`})]}),(0,H.jsxs)(`ul`,{className:`m-0 mt-2 list-none divide-y divide-border overflow-hidden rounded-xl border border-border p-0`,children:[e.models.length===0&&(0,H.jsx)(`li`,{className:`px-3 py-2.5 text-sm text-muted-foreground`,children:`None of its models is in Chat.`}),e.models.map(e=>{let n=t.find(t=>t.id===e);return(0,H.jsxs)(`li`,{className:`flex flex-wrap items-center gap-x-3 px-3 py-2.5 text-sm`,children:[(0,H.jsx)(`span`,{className:`min-w-0 flex-1 basis-40 font-semibold text-foreground`,children:n?S(n):e}),(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:n?x(n.usedBy):`Out of Chat while this is turned off`})]},e)})]}),r.length>0&&(0,H.jsx)(`p`,{className:`m-0 mt-2 text-sm text-muted-foreground`,children:I?`Images are drawn by ${I.model} through this provider.`:`Can also draw images: ${[...new Set(r.map(e=>e.model))].join(`, `)}.`})]}),(0,H.jsxs)(`section`,{"aria-label":`More settings`,children:[(0,H.jsxs)(`button`,{type:`button`,"aria-expanded":b,onClick:()=>T(e=>!e),className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[(0,H.jsx)(v,{className:`size-4 text-muted-foreground transition-transform ${b?`rotate-90`:``}`,"aria-hidden":`true`}),`More settings`]}),b&&(0,H.jsxs)(`div`,{className:`mt-2 grid gap-3 rounded-xl border border-border bg-muted/40 p-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1 text-sm`,children:[(0,H.jsx)(`div`,{className:`font-semibold text-foreground`,children:`Agents may use this provider`}),(0,H.jsx)(`div`,{className:`text-muted-foreground`,children:`Turn off to pause it without removing what is saved.`})]}),(0,H.jsx)(u,{checked:e.enabled,label:`Agents may use this provider`,disabled:m!==null||!e.enabled&&!e.configured,onChange:e=>void B(e)})]}),P.map(e=>(0,H.jsx)(X,{field:e},e.envVar)),e.fields.length>0&&(0,H.jsxs)(`p`,{className:`m-0 text-xs text-muted-foreground`,children:[`Setting names, for `,(0,H.jsx)(`code`,{children:`bazilion config set`}),` and the daemon’s environment:`,` `,e.fields.map(e=>e.envVar).join(`, `),`. A value set in the environment wins over the one saved here.`]})]})]}),(0,H.jsxs)(`section`,{"aria-label":`Disconnect`,className:`border-t border-frost pt-4`,children:[(0,H.jsxs)(s,{variant:`danger`,disabled:m!==null,onClick:()=>D(!0),children:[`Disconnect `,e.displayName]}),(0,H.jsxs)(`p`,{className:`m-0 mt-2 text-sm text-muted-foreground`,children:[`Removes`,` `,j?`the sign-in`:e.connect===`local`?`the address`:`the key`,`, its models from Chat and its test.`]})]}),(0,H.jsx)(M,{open:E,onOpenChange:D,title:`Disconnect ${e.displayName}?`,description:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`p`,{className:`m-0`,children:[`This removes`,` `,j?`the saved ChatGPT sign-in`:e.connect===`local`?`the saved address`:`the saved credentials`,` `,`and takes its `,e.models.length===1?`model`:`models`,` out of Chat.`]}),F>0&&(0,H.jsxs)(`p`,{className:`m-0 mt-2`,children:[F===1?`1 Agent runs`:`${F} Agents run`,` on its models and will be refused until given another model. Agent templates move to another model by themselves.`]}),I&&(0,H.jsx)(`p`,{className:`m-0 mt-2`,children:`Image generation stops until another route is chosen.`})]}),confirmLabel:`Disconnect ${e.displayName}`,onConfirm:W})]})}function $(){let{providers:e,models:t,now:i}=k.useLoaderData(),a=k.useSearch(),o=k.useNavigate(),s=r(),[c,l]=(0,V.useState)(!1),u=e.filter(e=>e.listed),d=u.filter(e=>e.enabled),f=e=>void o({search:e}),p=()=>f({}),m=()=>s.invalidate({sync:!0}),h=e.find(e=>e.id===a.provider&&e.listed);async function g(){l(!0);try{await Promise.all(d.filter(e=>e.models.length>0).map(e=>n(`/api/config/providers/${encodeURIComponent(e.id)}/test`,{method:`POST`}).catch(()=>void 0))),await m()}finally{l(!1)}}return(0,H.jsxs)(P,{title:`Models`,description:`What your Agents think and draw with, and the accounts behind it.`,children:[(0,H.jsx)(K,{providers:u,chat:t.chat,now:i,testing:c,onOpen:e=>f({provider:e}),onTestAll:()=>void g()}),(0,H.jsx)(q,{chat:t.chat,hasProviders:d.length>0,onPick:()=>f({pick:!0}),onChanged:m}),(0,H.jsx)(J,{images:t.images,onConnect:e=>f({add:e}),onChanged:m}),(0,H.jsx)(Y,{providers:u,total:e.length,images:t.images,now:i,onOpen:e=>f({provider:e}),onAdd:()=>f({add:`new`})}),a.add&&(0,H.jsx)(z,{providers:e,imageRoutes:t.images.routes,start:a.add===`new`?void 0:a.add,onClose:p,onConnected:m,onOpenProvider:e=>f({provider:e})},a.add),a.pick&&(0,H.jsx)(G,{providers:d,chat:t.chat,onClose:p,onSaved:m,onAddProvider:()=>f({add:`new`})}),h&&(0,H.jsx)(Q,{provider:h,chat:t.chat.filter(e=>e.provider===h.id),imageRoutes:t.images.routes.filter(e=>e.provider===h.id),imageSelected:t.images.selected,onClose:p,onChanged:m,onPickModels:()=>f({pick:!0}),onReconnect:()=>f({add:h.id})},h.id)]})}export{$ as component};