bazilion 0.59.0 → 0.60.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/cli.js +1 -1
  2. package/dist/cli.js.map +1 -1
  3. package/dist/daemon.js +180 -37
  4. package/dist/daemon.js.map +1 -1
  5. package/dist/web/client/assets/{AddProviderDialog-CbBtkgU7.js → AddProviderDialog-PK8ZRkVP.js} +1 -1
  6. package/dist/web/client/assets/{AgentTemplateParts-Tx0RJoDa.js → AgentTemplateParts-DXqswWc_.js} +1 -1
  7. package/dist/web/client/assets/{ConfirmDialog-Du8-95Zj.js → ConfirmDialog-C7Id43en.js} +1 -1
  8. package/dist/web/client/assets/{ConnectionsView-Dg9kLuab.js → ConnectionsView-sCcb1DqZ.js} +1 -1
  9. package/dist/web/client/assets/{SkillsParts-TYzEfrVu.js → SkillsParts-ClIFyTi8.js} +1 -1
  10. package/dist/web/client/assets/{SpawnTeamModal-Dr98zpUf.js → SpawnTeamModal-BxRg6e3v.js} +1 -1
  11. package/dist/web/client/assets/{TeamForm-DaH5H-LF.js → TeamForm-e_yDks2o.js} +1 -1
  12. package/dist/web/client/assets/{TeamThread-DmtbrFq1.js → TeamThread-BFz7jkrt.js} +1 -1
  13. package/dist/web/client/assets/{UnsavedChangesGuard-fvP4Xr0R.js → UnsavedChangesGuard-Cgc9WraN.js} +1 -1
  14. package/dist/web/client/assets/{_id--1i1fY0o.js → _id-C24VHwwo.js} +1 -1
  15. package/dist/web/client/assets/{_id-C_s4pMAk.js → _id-DeCenuG4.js} +1 -1
  16. package/dist/web/client/assets/{access-99X0FS-H.js → access-Dh3w6dHo.js} +1 -1
  17. package/dist/web/client/assets/{agents-CDJMwJL1.js → agents-CUQ-DKWA.js} +1 -1
  18. package/dist/web/client/assets/{agents-DVAJFWJI.js → agents-DHTN7twQ.js} +1 -1
  19. package/dist/web/client/assets/{attention-CDzRuQGN.js → attention-pzVO90iq.js} +1 -1
  20. package/dist/web/client/assets/{config-9GESe8FI.js → config-B29EfkVV.js} +1 -1
  21. package/dist/web/client/assets/{index-DkK2xZ2o.js → index-B8Bft71n.js} +3 -3
  22. package/dist/web/client/assets/{login-DUmrDZjN.js → login-CUACsY1J.js} +1 -1
  23. package/dist/web/client/assets/{manage-D6zhY8hA.js → manage-DrwsI5ur.js} +1 -1
  24. package/dist/web/client/assets/{mcp-ByioWHXZ.js → mcp-DFBkafUW.js} +1 -1
  25. package/dist/web/client/assets/{routes-DEMmBJiz.js → routes-DPz6Wrxz.js} +3 -3
  26. package/dist/web/client/assets/{skills-a52e5W9Z.js → skills-B0khtQXg.js} +1 -1
  27. package/dist/web/client/assets/{style-CiyV21dp.js → style-BEcLEdJR.js} +1 -1
  28. package/dist/web/client/assets/{system-wJXOiU47.js → system-DexaXrV1.js} +1 -1
  29. package/dist/web/client/assets/{teams-vRmMRnY_.js → teams-CUgnrqA5.js} +1 -1
  30. package/dist/web/client/assets/{teams-wLJHtFW_.js → teams-DC-abyJ_.js} +1 -1
  31. package/dist/web/client/assets/{telegram-CUsT8ZzL.js → telegram-DlnKiJP1.js} +1 -1
  32. package/dist/web/client/assets/{tools-NMtdwKi0.js → tools-BefW81ig.js} +1 -1
  33. package/dist/web/client/assets/{usage-DiIpfPPk.js → usage-oJ-ACG85.js} +1 -1
  34. package/dist/web/client/assets/{welcome-BWN0jtZP.js → welcome-BzesXAyM.js} +1 -1
  35. package/dist/web/server/assets/{ConnectionsView-CplWLHII.js → ConnectionsView-HoyHjzrZ.js} +2 -2
  36. package/dist/web/server/assets/{TeamThread-BGl5z8_I.js → TeamThread-Be_seq83.js} +1 -1
  37. package/dist/web/server/assets/{_tanstack-start-manifest_v-Be9mOSxg.js → _tanstack-start-manifest_v-CEGe-Ovy.js} +57 -57
  38. package/dist/web/server/assets/{activity-Czfq-5_F.js → activity-Dy1HUqjo.js} +13 -0
  39. package/dist/web/server/assets/{router-BER0FKkT.js → router-CE6lnn8Z.js} +2 -2
  40. package/dist/web/server/assets/{routes-qtTyGHXK.js → routes-B0oBIDOC.js} +1 -1
  41. package/dist/web/server/assets/{routes-DSIwTrHI.js → routes-Ci6C5w_N.js} +4 -4
  42. package/dist/web/server/server.js +2 -2
  43. package/dist/worker.js +153 -10
  44. package/dist/worker.js.map +1 -1
  45. package/package.json +1 -1
@@ -1 +1 @@
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-DZDOQ3kj.js";import{b as u,d,n as f,t as p,v as m,x as h,y as g}from"./parts-C104qEuC.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,W as D,f as O,q as k,z as A}from"./index-DkK2xZ2o.js";import{r as j}from"./use-resource-qjIkNQDY.js";import{t as M}from"./ConfirmDialog-Du8-95Zj.js";import{t as N}from"./Segmented-iylzLwE6.js";import{t as P}from"./ConfigPage-DFmHgEaL.js";import{c as F,l as I,o as L,s as R,t as z}from"./AddProviderDialog-CbBtkgU7.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??{},w=(e,t)=>C[e]?.includes(t)??!1,T=(e,t)=>g(n=>{let r=n?.[e]??[];return{...n,[e]:r.includes(t)?r.filter(e=>e!==t):[...r,t]}}),D=(e,t)=>c?S(e,c):e.dated&&!f&&!w(t.id,e.id)?!1:u===`images`?e.images===!0:u===`reasoning`?e.reasoning===!0:!0,O=(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&&O.some(({provider:t})=>t.id===e.provider)&&!w(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 O)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)(k,{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=>D(t,e)),r=n.slice(0,W),i=t.models.filter(t=>t.dated&&!w(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:w(e.id,t.id),disabled:_,onToggle:()=>T(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=>E(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:_||O.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}: ${x(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:E(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:D(e,e.providerConnect)}),(0,H.jsx)(`div`,{className:`min-w-0 flex-[1.4] basis-36 text-sm text-muted-foreground`,children:w(e.usedBy)}),(0,H.jsx)(`button`,{type:`button`,"aria-label":`Remove ${E(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?E(o):``} from Chat?`,description:o&&(0,H.jsxs)(`p`,{className:`m-0`,children:[`It is used by `,w(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=x(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,x]=(0,V.useState)(!1),[S,T]=(0,V.useState)(!1),D=`/api/config/providers/${encodeURIComponent(e.id)}`,{state:O,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(`${D}/test`,{method:`POST`})),B=e=>R(`switch`,()=>n(`${D}/enabled`,{method:`PUT`,body:{enabled:e}})),U=()=>R(`signin`,()=>n(`/api/auth/openai/login`,{method:`POST`}));async function W(){await n(D,{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)(k,{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…`})}):O===`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`)]}):O===`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)]}):O===`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`})]}):O===`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?E(n):e}),(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:n?w(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:()=>x(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:()=>T(!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:S,onOpenChange:T,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}=O.useLoaderData(),a=O.useSearch(),o=O.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};
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-DZDOQ3kj.js";import{b as u,d,n as f,t as p,v as m,x as h,y as g}from"./parts-C104qEuC.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,W as D,f as O,q as k,z as A}from"./index-B8Bft71n.js";import{r as j}from"./use-resource-qjIkNQDY.js";import{t as M}from"./ConfirmDialog-C7Id43en.js";import{t as N}from"./Segmented-iylzLwE6.js";import{t as P}from"./ConfigPage-DFmHgEaL.js";import{c as F,l as I,o as L,s as R,t as z}from"./AddProviderDialog-PK8ZRkVP.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??{},w=(e,t)=>C[e]?.includes(t)??!1,T=(e,t)=>g(n=>{let r=n?.[e]??[];return{...n,[e]:r.includes(t)?r.filter(e=>e!==t):[...r,t]}}),D=(e,t)=>c?S(e,c):e.dated&&!f&&!w(t.id,e.id)?!1:u===`images`?e.images===!0:u===`reasoning`?e.reasoning===!0:!0,O=(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&&O.some(({provider:t})=>t.id===e.provider)&&!w(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 O)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)(k,{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=>D(t,e)),r=n.slice(0,W),i=t.models.filter(t=>t.dated&&!w(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:w(e.id,t.id),disabled:_,onToggle:()=>T(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=>E(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:_||O.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}: ${x(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:E(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:D(e,e.providerConnect)}),(0,H.jsx)(`div`,{className:`min-w-0 flex-[1.4] basis-36 text-sm text-muted-foreground`,children:w(e.usedBy)}),(0,H.jsx)(`button`,{type:`button`,"aria-label":`Remove ${E(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?E(o):``} from Chat?`,description:o&&(0,H.jsxs)(`p`,{className:`m-0`,children:[`It is used by `,w(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=x(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,x]=(0,V.useState)(!1),[S,T]=(0,V.useState)(!1),D=`/api/config/providers/${encodeURIComponent(e.id)}`,{state:O,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(`${D}/test`,{method:`POST`})),B=e=>R(`switch`,()=>n(`${D}/enabled`,{method:`PUT`,body:{enabled:e}})),U=()=>R(`signin`,()=>n(`/api/auth/openai/login`,{method:`POST`}));async function W(){await n(D,{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)(k,{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…`})}):O===`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`)]}):O===`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)]}):O===`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`})]}):O===`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?E(n):e}),(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:n?w(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:()=>x(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:()=>T(!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:S,onOpenChange:T,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}=O.useLoaderData(),a=O.useSearch(),o=O.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};