bazilion 0.58.0 → 0.58.2
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.
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/web/client/assets/{AddProviderDialog-Dx6Jy1MK.js → AddProviderDialog-BsUXLr-m.js} +1 -1
- package/dist/web/client/assets/{AgentTemplateParts-C0MksxsC.js → AgentTemplateParts-BaeuW_3n.js} +1 -1
- package/dist/web/client/assets/{ConfirmDialog-CD3lCuKs.js → ConfirmDialog-D8f2wI5x.js} +1 -1
- package/dist/web/client/assets/{ConnectionsView-DhMB84zy.js → ConnectionsView-BUZcfBHw.js} +1 -1
- package/dist/web/client/assets/{SkillsParts-DGPuOsLJ.js → SkillsParts-jMYdOiWh.js} +1 -1
- package/dist/web/client/assets/{SpawnTeamModal-64EFK4SI.js → SpawnTeamModal-Dq7D3Zlc.js} +1 -1
- package/dist/web/client/assets/{TeamForm-CwuN03mI.js → TeamForm-Crz3mvXu.js} +1 -1
- package/dist/web/client/assets/{TeamThread-DI7nByFL.js → TeamThread-qTkvxv27.js} +1 -1
- package/dist/web/client/assets/{UnsavedChangesGuard-a9NU27Fr.js → UnsavedChangesGuard-DGzP-x1t.js} +1 -1
- package/dist/web/client/assets/{_id-nb4d0WIQ.js → _id-CiqTBi2Q.js} +1 -1
- package/dist/web/client/assets/{_id-CvinniKw.js → _id-DsZBpW5G.js} +1 -1
- package/dist/web/client/assets/{access-C5_dVCE4.js → access-ssWsYTEU.js} +1 -1
- package/dist/web/client/assets/{agents-CsUBgEUq.js → agents-BmkaQvWh.js} +1 -1
- package/dist/web/client/assets/{agents-BRPw1ovf.js → agents-D3tZ58Dh.js} +1 -1
- package/dist/web/client/assets/{attention-wFUp_DS8.js → attention-ChHdu7E8.js} +1 -1
- package/dist/web/client/assets/{config-BWxlunbT.js → config-DPsq6Zy9.js} +1 -1
- package/dist/web/client/assets/{index-rLAiEnYi.js → index-CVVVmIFC.js} +2 -2
- package/dist/web/client/assets/{login-qzsVjf5D.js → login-B-Kpyw9o.js} +1 -1
- package/dist/web/client/assets/{manage-BXNoJYsp.js → manage-Dwe9yQl9.js} +1 -1
- package/dist/web/client/assets/{mcp-BKgf9fVi.js → mcp-73AMOCv3.js} +1 -1
- package/dist/web/client/assets/{routes-CYR3U892.js → routes-Lj8n-RF7.js} +3 -3
- package/dist/web/client/assets/{skills-eysL1kpW.js → skills-DmYDuDbl.js} +1 -1
- package/dist/web/client/assets/{style-CKIbA0FQ.js → style-B9Vy-99n.js} +1 -1
- package/dist/web/client/assets/{system-CWXwWRUO.js → system-t9hcqYBg.js} +1 -1
- package/dist/web/client/assets/{teams-DGhCD7wi.js → teams-5B2cyDin.js} +1 -1
- package/dist/web/client/assets/{teams-_vdczNlj.js → teams-Nk_bHpr0.js} +1 -1
- package/dist/web/client/assets/{telegram-DxWYGYIC.js → telegram-BWfL_OIt.js} +1 -1
- package/dist/web/client/assets/{tools-BfXQwJtf.js → tools-mdAuMsYJ.js} +1 -1
- package/dist/web/client/assets/{usage-Dh7uG1E_.js → usage-CWu7R8ZD.js} +1 -1
- package/dist/web/client/assets/{welcome-BTz-u179.js → welcome-BuRNFxpc.js} +1 -1
- package/dist/web/server/assets/{_tanstack-start-manifest_v-DoTfzNSt.js → _tanstack-start-manifest_v-gHDkHqeS.js} +57 -57
- package/dist/web/server/assets/{router-B4f4FMsA.js → router-yEsciAts.js} +1 -1
- package/dist/web/server/server.js +2 -2
- package/package.json +1 -1
package/dist/web/client/assets/{AddProviderDialog-Dx6Jy1MK.js → AddProviderDialog-BsUXLr-m.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
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-DZDOQ3kj.js";import{d as l,v as u,x as d,z as f}from"./parts-C104qEuC.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-rLAiEnYi.js";import{r as re}from"./use-resource-qjIkNQDY.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
|
+
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-DZDOQ3kj.js";import{d as l,v as u,x as d,z as f}from"./parts-C104qEuC.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-CVVVmIFC.js";import{r as re}from"./use-resource-qjIkNQDY.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};
|
package/dist/web/client/assets/{AgentTemplateParts-C0MksxsC.js → AgentTemplateParts-BaeuW_3n.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
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-C104qEuC.js";import{C as c,F as l,K as u,M as d,S as f,q as p}from"./index-
|
|
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-C104qEuC.js";import{C as c,F as l,K as u,M as d,S as f,q as p}from"./index-CVVVmIFC.js";import{S as m,x as h}from"./manage-Dwe9yQl9.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 +1 @@
|
|
|
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-
|
|
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-CVVVmIFC.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 +1 @@
|
|
|
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-a9NU27Fr.js";import{t as l}from"./Button-CoKQRO-s.js";import{t as u}from"./arrow-right-BqqfPqVi.js";import{c as d,d as f,i as p,n as m,o as h,t as g}from"./TeamThread-DI7nByFL.js";import{c as _,d as v,f as y,i as b,l as x,n as ee,o as S,r as C,s as te,t as w,u as T}from"./style-CKIbA0FQ.js";import{t as E}from"./message-square-B_pULba_.js";import{X as D,ot as ne}from"./index-rLAiEnYi.js";import{A as O,B as re,D as ie,F as k,I as A,L as ae,O as oe,P as j,R as se,j as ce,k as M,z as le}from"./manage-BXNoJYsp.js";import{r as N}from"./use-resource-qjIkNQDY.js";import{t as P}from"./ConfirmDialog-CD3lCuKs.js";import{t as ue}from"./Segmented-iylzLwE6.js";var de=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`}]]),F=e(t(),1),I=a(),L=`!size-2.5 !border-2 !border-snow !bg-sapphire`,R=[{id:`t`,position:T.Top},{id:`r`,position:T.Right},{id:`b`,position:T.Bottom},{id:`l`,position:T.Left}];function z(){return(0,I.jsx)(I.Fragment,{children:R.map(e=>(0,I.jsx)(b,{id:e.id,type:`source`,position:e.position,className:L},e.id))})}function B({data:e,selected:t}){let{member:n}=e;return(0,I.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,I.jsx)(z,{}),(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,I.jsx)(D,{identity:n.identity,size:34}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`span`,{className:`block truncate text-sm font-semibold text-chocolate`,children:n.name}),(0,I.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,I.jsx)(`span`,{className:`size-[7px] shrink-0 rounded-full ${h[n.state.kind]}`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`min-w-0 truncate`,children:n.isolated?`No connections`:n.state.text})]})]})]})]})}function V({selected:e}){return(0,I.jsxs)(`div`,{className:`w-[160px] rounded-2xl border border-dashed bg-ivory px-3 py-2.5 ${e?`border-sapphire`:`border-fawn`}`,children:[(0,I.jsx)(z,{}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(y,{className:`size-4 shrink-0 text-rose-baziu`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`block text-sm font-semibold text-chocolate`,children:`Other teams`})]})]})}var H={member:B,outside:V},U=(e,t)=>`pair:${p(e,t)}`;function fe(e){if(!e?.startsWith(`pair:`))return null;let[t,n]=e.slice(5).split(`|`);return t&&n?[t,n]:null}var W={member:{w:210,h:62},outside:{w:160,h:46}};function G(e,t){let n=e=>W[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 pe({document:e,members:t,traffic:n,selectedId:r,onSelect:i,onConnect:a,onMove:o,onOpenMember:s}){let c=(0,F.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:M,type:`outside`,position:{x:e,y:n},data:{},ariaLabel:`Agents in other teams`,selected:r===M,draggable:!1,deletable:!1}]},[t,r]),[l,u,d]=te(c);(0,F.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,F.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=k(e,c,l),d=k(e,l,c),f=U(c,l),p=n.get(f)??0;if(!u&&!d&&p===0)continue;let m=G(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:x.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,I.jsx)(`div`,{className:`h-full min-h-[420px] w-full bg-ivory`,children:(0,I.jsxs)(S,{nodes:l,edges:f,nodeTypes:H,connectionMode:_.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,I.jsx)(w,{variant:ee.Dots,gap:20,size:1.2,color:`var(--color-fawn)`}),(0,I.jsx)(C,{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 me={open:`Every member can message every other member, with no connections needed. Connections here only matter for other Teams, or if you switch the Team to Connections only.`,restricted:`A member can message a teammate only along a connection.`};function he(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 K=(e,t)=>e.has(t)?t:M,ge=e=>`bz_map_${e}`;function _e(e){try{let t=JSON.parse(window.localStorage.getItem(ge(e))??`{}`);return t&&typeof t==`object`?t:{}}catch{return{}}}function ve({team:e}){let t=N(t=>n(`/api/teams/${encodeURIComponent(e.id)}/policy`,{signal:t}),[e.id]);return t.error?(0,I.jsx)(d,{view:`connections`,children:(0,I.jsx)(`p`,{role:`alert`,className:`err m-4`,children:t.error})}):t.data?(0,I.jsx)(q,{team:e,policy:t.data},e.id):(0,I.jsx)(d,{view:`connections`,children:(0,I.jsx)(`p`,{role:`status`,className:`m-4 text-sm text-muted-foreground`,children:`Loading the connections…`})})}function q({team:e,policy:t}){let{agentById:r,search:a}=f(),s=ne(),u=i(),p=m(e.id,300),[h,_]=(0,F.useState)(()=>A(t)),[y,b]=(0,F.useState)(h),[x,ee]=(0,F.useState)(`map`),[S,C]=(0,F.useState)(null),[te,w]=(0,F.useState)({}),[T,E]=(0,F.useState)(!1),[D,k]=(0,F.useState)(null),[N,L]=(0,F.useState)(!1),R=!se(h,y);(0,F.useEffect)(()=>w(_e(e.id)),[e.id]);let z=(t,n)=>{w(r=>{let i={...r,[t]:n};try{window.localStorage.setItem(ge(e.id),JSON.stringify(i))}catch{}return i})},B=(0,F.useMemo)(()=>y.members.filter(e=>e.status!==`archived`),[y.members]),V=(0,F.useMemo)(()=>new Set(B.map(e=>e.key)),[B]),H=B.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:te[e.key]??he(t,B.length)})),W=e=>K(V,e),G=p.data,ve=(0,F.useMemo)(()=>{let e=new Map;for(let t of G??[]){let n=K(V,t.fromAgentId),r=K(V,t.toAgentId);if(n===r)continue;let i=U(n,r);e.set(i,(e.get(i)??0)+1)}return e},[G,V]),[q,J]=(0,F.useState)(null),Y=(e,t,n)=>{if(k(null),ce(y,e,t,n)){J({from:e,to:t});return}b(r=>le(r,e,t,n))};async function xe(){E(!0),k(null);try{let t=A(await n(`/api/teams/${encodeURIComponent(e.id)}/policy`,{method:`PATCH`,body:{mode:y.mode,edges:ae(y)}}));_(t),b(t),k({error:!1,text:`Saved. It applies to the next message an Agent sends.`}),await u.invalidate()}catch(e){k({error:!0,text:o(e)})}finally{E(!1)}}let X=fe(S),Z=S&&(V.has(S)||S===M)?S:null,Q=(e,t)=>W(e.fromAgentId)===t||W(e.toAgentId)===t,$=G??[],Se=X?$.filter(e=>Q(e,X[0])&&Q(e,X[1])):Z?$.filter(e=>Q(e,Z)):$;return(0,I.jsxs)(d,{view:`connections`,actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(ue,{label:`Who can message whom`,value:y.mode,options:[{id:`open`,label:ie.open},{id:`restricted`,label:ie.restricted}],onChange:e=>{k(null),b(t=>({...t,mode:e}))}}),(0,I.jsx)(ue,{label:`Show as`,value:x,options:[{id:`map`,label:`Map`},{id:`matrix`,label:`Table`}],onChange:ee}),(0,I.jsx)(l,{variant:`ghost`,className:`min-h-8 px-3 py-1 text-xs`,disabled:!R||T,onClick:()=>L(!0),children:`Discard`}),(0,I.jsxs)(l,{variant:`primary`,className:`min-h-8 px-3 py-1 text-xs`,disabled:!R||T,onClick:()=>void xe(),children:[(0,I.jsx)(de,{className:`size-3.5`,"aria-hidden":`true`}),T?`Saving…`:`Save`]})]}),children:[(0,I.jsx)(c,{when:R,subject:`connection changes`}),(0,I.jsxs)(`div`,{className:`grid h-full min-h-0 grid-cols-1 lg:grid-cols-[minmax(0,1fr)_23rem]`,children:[(0,I.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-col max-lg:h-[52vh]`,children:[(0,I.jsx)(`p`,{className:`m-0 border-b border-border px-3 py-1.5 text-xs ${D?.error?`text-danger`:R?`text-warning`:`text-mocha`}`,role:D?.error?`alert`:`status`,children:D?.text??(R?`Unsaved changes. `:``)+me[y.mode]+(x===`map`?` Drag from one Agent to another to connect them.`:``)}),(0,I.jsx)(`div`,{className:`min-h-0 flex-1`,children:B.length===0?(0,I.jsx)(`p`,{className:`m-0 p-6 text-center text-sm text-muted-foreground`,children:`This Team has no members to connect yet.`}):x===`map`?(0,I.jsx)(pe,{document:y,members:H,traffic:ve,selectedId:S,onSelect:C,onConnect:(e,t)=>{Y(e,t,!0),C(U(e,t))},onMove:z,onOpenMember:e=>void u.navigate({to:`/`,search:{agent:e,panel:`connections`}})}):(0,I.jsx)(v,{document:{...y,members:B},selectedId:S,onSelect:C,onToggle:Y})})]}),(0,I.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,I.jsx)(ye,{document:y,pair:X,onToggle:Y,onClear:()=>C(null)}):Z?(0,I.jsx)(be,{document:y,actor:Z,others:[...B.map(e=>e.key),M].filter(e=>e!==Z),panel:a.panel,onToggle:Y,onSelectPair:e=>C(U(Z,e))}):(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`h2`,{className:`m-0 font-body text-sm font-semibold text-foreground`,children:[B.length,` member`,B.length===1?``:`s`,` ·`,` `,oe[y.mode].toLowerCase()]}),(0,I.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,I.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 ${j(y,Z)}`:`Recent messages`}),p.error?(0,I.jsx)(`p`,{role:`alert`,className:`m-0 text-xs text-danger`,children:p.error}):(0,I.jsx)(g,{messages:Se,limit:30,empty:X||Z?`None among the Team’s recent messages.`:`No messages between Agents yet.`})]})]}),(0,I.jsx)(P,{open:q!==null,title:O.title,description:(0,I.jsx)(`p`,{children:O.description}),confirmLabel:O.confirm,onConfirm:()=>{q&&b(e=>re(e,q.from,q.to)),J(null)},onOpenChange:e=>{e||J(null)}}),(0,I.jsx)(P,{open:N,title:`Discard the connection changes?`,description:(0,I.jsx)(`p`,{children:`Every unsaved change is dropped. The saved connections stay as they are.`}),confirmLabel:`Discard changes`,onConfirm:()=>{b(h),C(null),k(null)},onOpenChange:L})]})}function J({document:e,from:t,to:n,onToggle:r}){let i=k(e,t,n),a=e.mode===`open`&&t!==M&&n!==M;return(0,I.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,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,I.jsx)(`span`,{className:`min-w-0 truncate font-semibold text-foreground`,children:j(e,t)}),(0,I.jsx)(u,{className:`size-3.5 shrink-0 text-mocha`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`min-w-0 truncate font-semibold text-foreground`,children:j(e,n)})]}),(0,I.jsx)(`span`,{className:`shrink-0 text-xs font-semibold ${i?`text-accent-foreground`:`text-muted-foreground`}`,children:i?`Connected`:a?`No connection needed`:`Not connected`})]})}function ye({document:e,pair:[t,n],onToggle:r,onClear:i}){let a=k(e,t,n)||k(e,n,t);return(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`h2`,{className:`m-0 font-body text-sm font-semibold text-foreground`,children:[j(e,t),` and `,j(e,n)]}),(0,I.jsxs)(`p`,{className:`m-0 mt-1 text-xs leading-relaxed text-mocha`,children:[`Each direction is its own connection.`,t===M||n===M?` Reaching another Team also needs that Team to connect its Agent to “Other teams”.`:``]}),(0,I.jsxs)(`div`,{className:`mt-3 space-y-1.5`,children:[(0,I.jsx)(J,{document:e,from:t,to:n,onToggle:r}),(0,I.jsx)(J,{document:e,from:n,to:t,onToggle:r})]}),a&&(0,I.jsx)(`div`,{className:`mt-2.5`,children:(0,I.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 be({document:e,actor:t,others:n,panel:i,onToggle:a,onSelectPair:o}){let{agentById:s}=f(),c=ne(),l=t===M?void 0:s(t),u=l?c.stateOf(l.id):null;return(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[t!==M&&(0,I.jsx)(D,{identity:l?.identity,size:34}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`h2`,{className:`m-0 truncate font-body text-sm font-semibold text-foreground`,children:j(e,t)}),u?(0,I.jsxs)(`p`,{className:`m-0 flex min-w-0 items-center gap-1.5 text-xs text-mocha`,children:[(0,I.jsx)(`span`,{className:`size-[7px] shrink-0 rounded-full ${h[u.kind]}`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`min-w-0 truncate`,children:u.text})]}):(0,I.jsx)(`p`,{className:`m-0 text-xs text-mocha`,children:`Every Agent that is not in this Team.`})]}),l&&(0,I.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,I.jsx)(E,{className:`size-3.5`,"aria-hidden":`true`}),`Open`]})]}),(0,I.jsx)(`div`,{className:`mt-3 space-y-3`,children:n.map(n=>(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`button`,{type:`button`,onClick:()=>o(n),className:`unstyled mb-1 text-xs font-semibold text-mocha hover:text-sapphire`,children:[`With `,j(e,n)]}),(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(J,{document:e,from:t,to:n,onToggle:a}),(0,I.jsx)(J,{document:e,from:n,to:t,onToggle:a})]})]},n))})]})}export{ve as ConnectionsView};
|
|
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-DGzP-x1t.js";import{t as l}from"./Button-CoKQRO-s.js";import{t as u}from"./arrow-right-BqqfPqVi.js";import{c as d,d as f,i as p,n as m,o as h,t as g}from"./TeamThread-qTkvxv27.js";import{c as _,d as v,f as y,i as b,l as x,n as ee,o as S,r as C,s as te,t as w,u as T}from"./style-B9Vy-99n.js";import{t as E}from"./message-square-B_pULba_.js";import{X as D,ot as ne}from"./index-CVVVmIFC.js";import{A as O,B as re,D as ie,F as k,I as A,L as ae,O as oe,P as j,R as se,j as ce,k as M,z as le}from"./manage-Dwe9yQl9.js";import{r as N}from"./use-resource-qjIkNQDY.js";import{t as P}from"./ConfirmDialog-D8f2wI5x.js";import{t as ue}from"./Segmented-iylzLwE6.js";var de=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`}]]),F=e(t(),1),I=a(),L=`!size-2.5 !border-2 !border-snow !bg-sapphire`,R=[{id:`t`,position:T.Top},{id:`r`,position:T.Right},{id:`b`,position:T.Bottom},{id:`l`,position:T.Left}];function z(){return(0,I.jsx)(I.Fragment,{children:R.map(e=>(0,I.jsx)(b,{id:e.id,type:`source`,position:e.position,className:L},e.id))})}function B({data:e,selected:t}){let{member:n}=e;return(0,I.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,I.jsx)(z,{}),(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,I.jsx)(D,{identity:n.identity,size:34}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`span`,{className:`block truncate text-sm font-semibold text-chocolate`,children:n.name}),(0,I.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,I.jsx)(`span`,{className:`size-[7px] shrink-0 rounded-full ${h[n.state.kind]}`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`min-w-0 truncate`,children:n.isolated?`No connections`:n.state.text})]})]})]})]})}function V({selected:e}){return(0,I.jsxs)(`div`,{className:`w-[160px] rounded-2xl border border-dashed bg-ivory px-3 py-2.5 ${e?`border-sapphire`:`border-fawn`}`,children:[(0,I.jsx)(z,{}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(y,{className:`size-4 shrink-0 text-rose-baziu`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`block text-sm font-semibold text-chocolate`,children:`Other teams`})]})]})}var H={member:B,outside:V},U=(e,t)=>`pair:${p(e,t)}`;function fe(e){if(!e?.startsWith(`pair:`))return null;let[t,n]=e.slice(5).split(`|`);return t&&n?[t,n]:null}var W={member:{w:210,h:62},outside:{w:160,h:46}};function G(e,t){let n=e=>W[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 pe({document:e,members:t,traffic:n,selectedId:r,onSelect:i,onConnect:a,onMove:o,onOpenMember:s}){let c=(0,F.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:M,type:`outside`,position:{x:e,y:n},data:{},ariaLabel:`Agents in other teams`,selected:r===M,draggable:!1,deletable:!1}]},[t,r]),[l,u,d]=te(c);(0,F.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,F.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=k(e,c,l),d=k(e,l,c),f=U(c,l),p=n.get(f)??0;if(!u&&!d&&p===0)continue;let m=G(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:x.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,I.jsx)(`div`,{className:`h-full min-h-[420px] w-full bg-ivory`,children:(0,I.jsxs)(S,{nodes:l,edges:f,nodeTypes:H,connectionMode:_.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,I.jsx)(w,{variant:ee.Dots,gap:20,size:1.2,color:`var(--color-fawn)`}),(0,I.jsx)(C,{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 me={open:`Every member can message every other member, with no connections needed. Connections here only matter for other Teams, or if you switch the Team to Connections only.`,restricted:`A member can message a teammate only along a connection.`};function he(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 K=(e,t)=>e.has(t)?t:M,ge=e=>`bz_map_${e}`;function _e(e){try{let t=JSON.parse(window.localStorage.getItem(ge(e))??`{}`);return t&&typeof t==`object`?t:{}}catch{return{}}}function ve({team:e}){let t=N(t=>n(`/api/teams/${encodeURIComponent(e.id)}/policy`,{signal:t}),[e.id]);return t.error?(0,I.jsx)(d,{view:`connections`,children:(0,I.jsx)(`p`,{role:`alert`,className:`err m-4`,children:t.error})}):t.data?(0,I.jsx)(q,{team:e,policy:t.data},e.id):(0,I.jsx)(d,{view:`connections`,children:(0,I.jsx)(`p`,{role:`status`,className:`m-4 text-sm text-muted-foreground`,children:`Loading the connections…`})})}function q({team:e,policy:t}){let{agentById:r,search:a}=f(),s=ne(),u=i(),p=m(e.id,300),[h,_]=(0,F.useState)(()=>A(t)),[y,b]=(0,F.useState)(h),[x,ee]=(0,F.useState)(`map`),[S,C]=(0,F.useState)(null),[te,w]=(0,F.useState)({}),[T,E]=(0,F.useState)(!1),[D,k]=(0,F.useState)(null),[N,L]=(0,F.useState)(!1),R=!se(h,y);(0,F.useEffect)(()=>w(_e(e.id)),[e.id]);let z=(t,n)=>{w(r=>{let i={...r,[t]:n};try{window.localStorage.setItem(ge(e.id),JSON.stringify(i))}catch{}return i})},B=(0,F.useMemo)(()=>y.members.filter(e=>e.status!==`archived`),[y.members]),V=(0,F.useMemo)(()=>new Set(B.map(e=>e.key)),[B]),H=B.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:te[e.key]??he(t,B.length)})),W=e=>K(V,e),G=p.data,ve=(0,F.useMemo)(()=>{let e=new Map;for(let t of G??[]){let n=K(V,t.fromAgentId),r=K(V,t.toAgentId);if(n===r)continue;let i=U(n,r);e.set(i,(e.get(i)??0)+1)}return e},[G,V]),[q,J]=(0,F.useState)(null),Y=(e,t,n)=>{if(k(null),ce(y,e,t,n)){J({from:e,to:t});return}b(r=>le(r,e,t,n))};async function xe(){E(!0),k(null);try{let t=A(await n(`/api/teams/${encodeURIComponent(e.id)}/policy`,{method:`PATCH`,body:{mode:y.mode,edges:ae(y)}}));_(t),b(t),k({error:!1,text:`Saved. It applies to the next message an Agent sends.`}),await u.invalidate()}catch(e){k({error:!0,text:o(e)})}finally{E(!1)}}let X=fe(S),Z=S&&(V.has(S)||S===M)?S:null,Q=(e,t)=>W(e.fromAgentId)===t||W(e.toAgentId)===t,$=G??[],Se=X?$.filter(e=>Q(e,X[0])&&Q(e,X[1])):Z?$.filter(e=>Q(e,Z)):$;return(0,I.jsxs)(d,{view:`connections`,actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(ue,{label:`Who can message whom`,value:y.mode,options:[{id:`open`,label:ie.open},{id:`restricted`,label:ie.restricted}],onChange:e=>{k(null),b(t=>({...t,mode:e}))}}),(0,I.jsx)(ue,{label:`Show as`,value:x,options:[{id:`map`,label:`Map`},{id:`matrix`,label:`Table`}],onChange:ee}),(0,I.jsx)(l,{variant:`ghost`,className:`min-h-8 px-3 py-1 text-xs`,disabled:!R||T,onClick:()=>L(!0),children:`Discard`}),(0,I.jsxs)(l,{variant:`primary`,className:`min-h-8 px-3 py-1 text-xs`,disabled:!R||T,onClick:()=>void xe(),children:[(0,I.jsx)(de,{className:`size-3.5`,"aria-hidden":`true`}),T?`Saving…`:`Save`]})]}),children:[(0,I.jsx)(c,{when:R,subject:`connection changes`}),(0,I.jsxs)(`div`,{className:`grid h-full min-h-0 grid-cols-1 lg:grid-cols-[minmax(0,1fr)_23rem]`,children:[(0,I.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-col max-lg:h-[52vh]`,children:[(0,I.jsx)(`p`,{className:`m-0 border-b border-border px-3 py-1.5 text-xs ${D?.error?`text-danger`:R?`text-warning`:`text-mocha`}`,role:D?.error?`alert`:`status`,children:D?.text??(R?`Unsaved changes. `:``)+me[y.mode]+(x===`map`?` Drag from one Agent to another to connect them.`:``)}),(0,I.jsx)(`div`,{className:`min-h-0 flex-1`,children:B.length===0?(0,I.jsx)(`p`,{className:`m-0 p-6 text-center text-sm text-muted-foreground`,children:`This Team has no members to connect yet.`}):x===`map`?(0,I.jsx)(pe,{document:y,members:H,traffic:ve,selectedId:S,onSelect:C,onConnect:(e,t)=>{Y(e,t,!0),C(U(e,t))},onMove:z,onOpenMember:e=>void u.navigate({to:`/`,search:{agent:e,panel:`connections`}})}):(0,I.jsx)(v,{document:{...y,members:B},selectedId:S,onSelect:C,onToggle:Y})})]}),(0,I.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,I.jsx)(ye,{document:y,pair:X,onToggle:Y,onClear:()=>C(null)}):Z?(0,I.jsx)(be,{document:y,actor:Z,others:[...B.map(e=>e.key),M].filter(e=>e!==Z),panel:a.panel,onToggle:Y,onSelectPair:e=>C(U(Z,e))}):(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`h2`,{className:`m-0 font-body text-sm font-semibold text-foreground`,children:[B.length,` member`,B.length===1?``:`s`,` ·`,` `,oe[y.mode].toLowerCase()]}),(0,I.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,I.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 ${j(y,Z)}`:`Recent messages`}),p.error?(0,I.jsx)(`p`,{role:`alert`,className:`m-0 text-xs text-danger`,children:p.error}):(0,I.jsx)(g,{messages:Se,limit:30,empty:X||Z?`None among the Team’s recent messages.`:`No messages between Agents yet.`})]})]}),(0,I.jsx)(P,{open:q!==null,title:O.title,description:(0,I.jsx)(`p`,{children:O.description}),confirmLabel:O.confirm,onConfirm:()=>{q&&b(e=>re(e,q.from,q.to)),J(null)},onOpenChange:e=>{e||J(null)}}),(0,I.jsx)(P,{open:N,title:`Discard the connection changes?`,description:(0,I.jsx)(`p`,{children:`Every unsaved change is dropped. The saved connections stay as they are.`}),confirmLabel:`Discard changes`,onConfirm:()=>{b(h),C(null),k(null)},onOpenChange:L})]})}function J({document:e,from:t,to:n,onToggle:r}){let i=k(e,t,n),a=e.mode===`open`&&t!==M&&n!==M;return(0,I.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,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,I.jsx)(`span`,{className:`min-w-0 truncate font-semibold text-foreground`,children:j(e,t)}),(0,I.jsx)(u,{className:`size-3.5 shrink-0 text-mocha`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`min-w-0 truncate font-semibold text-foreground`,children:j(e,n)})]}),(0,I.jsx)(`span`,{className:`shrink-0 text-xs font-semibold ${i?`text-accent-foreground`:`text-muted-foreground`}`,children:i?`Connected`:a?`No connection needed`:`Not connected`})]})}function ye({document:e,pair:[t,n],onToggle:r,onClear:i}){let a=k(e,t,n)||k(e,n,t);return(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`h2`,{className:`m-0 font-body text-sm font-semibold text-foreground`,children:[j(e,t),` and `,j(e,n)]}),(0,I.jsxs)(`p`,{className:`m-0 mt-1 text-xs leading-relaxed text-mocha`,children:[`Each direction is its own connection.`,t===M||n===M?` Reaching another Team also needs that Team to connect its Agent to “Other teams”.`:``]}),(0,I.jsxs)(`div`,{className:`mt-3 space-y-1.5`,children:[(0,I.jsx)(J,{document:e,from:t,to:n,onToggle:r}),(0,I.jsx)(J,{document:e,from:n,to:t,onToggle:r})]}),a&&(0,I.jsx)(`div`,{className:`mt-2.5`,children:(0,I.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 be({document:e,actor:t,others:n,panel:i,onToggle:a,onSelectPair:o}){let{agentById:s}=f(),c=ne(),l=t===M?void 0:s(t),u=l?c.stateOf(l.id):null;return(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[t!==M&&(0,I.jsx)(D,{identity:l?.identity,size:34}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`h2`,{className:`m-0 truncate font-body text-sm font-semibold text-foreground`,children:j(e,t)}),u?(0,I.jsxs)(`p`,{className:`m-0 flex min-w-0 items-center gap-1.5 text-xs text-mocha`,children:[(0,I.jsx)(`span`,{className:`size-[7px] shrink-0 rounded-full ${h[u.kind]}`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`min-w-0 truncate`,children:u.text})]}):(0,I.jsx)(`p`,{className:`m-0 text-xs text-mocha`,children:`Every Agent that is not in this Team.`})]}),l&&(0,I.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,I.jsx)(E,{className:`size-3.5`,"aria-hidden":`true`}),`Open`]})]}),(0,I.jsx)(`div`,{className:`mt-3 space-y-3`,children:n.map(n=>(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`button`,{type:`button`,onClick:()=>o(n),className:`unstyled mb-1 text-xs font-semibold text-mocha hover:text-sapphire`,children:[`With `,j(e,n)]}),(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(J,{document:e,from:t,to:n,onToggle:a}),(0,I.jsx)(J,{document:e,from:n,to:t,onToggle:a})]})]},n))})]})}export{ve as ConnectionsView};
|
|
@@ -1 +1 @@
|
|
|
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-DZDOQ3kj.js";import{g as l}from"./parts-C104qEuC.js";import{C as u,K as d,M as f,S as p,q as m}from"./index-
|
|
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-DZDOQ3kj.js";import{g as l}from"./parts-C104qEuC.js";import{C as u,K as d,M as f,S as p,q as m}from"./index-CVVVmIFC.js";import{s as h}from"./manage-Dwe9yQl9.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 +1 @@
|
|
|
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-C104qEuC.js";import{C as s,K as c,M as l,O as u,q as d}from"./index-
|
|
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-C104qEuC.js";import{C as s,K as c,M as l,O as u,q as d}from"./index-CVVVmIFC.js";import{O as f,S as p,s as m,x as h}from"./manage-Dwe9yQl9.js";var g=e(t(),1),_=r();function v({template:e,teams:t,initialTeamId:r=``,onClose:v,onSpawned:y}){let b=t.some(e=>e.id===r),[x,S]=(0,g.useState)(b?`existing`:`new`),[C,w]=(0,g.useState)(b?r:t[0]?.id??``),[T,E]=(0,g.useState)(b?``:r||p(e.name)),[D,O]=(0,g.useState)(e.userMd??``),[k,A]=(0,g.useState)(null),[j,M]=(0,g.useState)(!1),N=x===`existing`?C:T.trim(),P=x===`new`?h(N)??(t.some(e=>e.id===N)?`A Team with this ID exists: choose it under “A Team that exists”.`:void 0):void 0,F=N!==``&&!P&&e.slots.length>0;async function I(t){if(t.preventDefault(),!(!F||j)){M(!0),A(null);try{await n(`/api/team-templates/${encodeURIComponent(e.id)}/spawn`,{body:{teamId:N,...x===`new`&&D!==(e.userMd??``)?{userMd:D}:{}}}),y(N)}catch(e){A(i(e)),M(!1)}}}return(0,_.jsx)(c,{title:`Use ${e.name}`,description:`Creates ${m(e.slots.length,`Agent`)} and ${m(e.edges.length,`connection`)} between them.`,busy:j,onClose:v,className:`max-w-xl`,children:(0,_.jsxs)(`form`,{onSubmit:e=>void I(e),className:`grid gap-4`,children:[(0,_.jsx)(s,{legend:`Into`,name:`spawn-team-target`,value:x,disabled:j,options:[{value:`new`,label:`A new Team`,hint:`${f[e.policyMode]}, as in the template.`},{value:`existing`,label:`A Team that exists`,hint:`The Agents join it; it keeps its own messaging rules.`}],onChange:S}),x===`new`?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(l,{label:`ID of the new Team`,value:T,disabled:j,placeholder:`launch`,mono:!0,className:`max-w-none`,problem:P,onChange:E}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`label`,{htmlFor:`spawn-team-user-md`,className:`m-0 text-sm font-semibold text-foreground`,children:`USER.md`}),(0,_.jsx)(`textarea`,{id:`spawn-team-user-md`,rows:4,value:D,disabled:j,onChange:e=>O(e.target.value),className:`mt-1.5 font-mono text-sm leading-[1.55]`}),(0,_.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,_.jsx)(u,{label:`Team`,value:C,options:t.map(e=>({value:e.id,label:e.name})),disabled:j,className:`max-w-none`,onChange:w}),e.slots.length===0&&(0,_.jsx)(o,{tone:`warning`,children:`This template has no Agents yet: add some to it first.`}),k&&(0,_.jsx)(o,{tone:`warning`,role:`alert`,title:`The Agents were not added.`,children:k}),(0,_.jsxs)(d,{children:[(0,_.jsx)(a,{variant:`ghost`,disabled:j,onClick:v,children:`Cancel`}),(0,_.jsx)(a,{variant:`primary`,type:`submit`,disabled:j||!F,children:j?`Adding…`:`Add ${m(e.slots.length,`Agent`)}`})]})]})})}export{v as t};
|
|
@@ -1 +1 @@
|
|
|
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-C104qEuC.js";import{C as s,M as c,q as l}from"./index-
|
|
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-C104qEuC.js";import{C as s,M as c,q as l}from"./index-CVVVmIFC.js";import{S as u,x as d}from"./manage-Dwe9yQl9.js";var f=e(t(),1),p=r();function m(e,t=[]){let n=e.id.trim(),r=e.folder.trim(),i={},a=d(n);return a?i.id=a:t.includes(n)?i.id=`A Team already has this ID: choose another.`:!n&&e.name.trim()&&(i.id=`The name has no letters or digits to make an ID from: type one.`),e.place===`link`&&r&&!r.startsWith(`/`)&&(i.folder=`The full path of the folder, starting with /.`),!(n!==``&&(e.place===`new`||r!==``))||i.id||i.folder?{body:null,problems:i}:{body:{id:n,...e.name.trim()?{name:e.name.trim()}:{},...e.place===`link`?{link:r}:{}},problems:i}}function h({onCreated:e,onBusyChange:t,extraActions:r,taken:d=[]}){let[h,g]=(0,f.useState)(``),[_,v]=(0,f.useState)(``),[y,b]=(0,f.useState)(!1),[x,S]=(0,f.useState)(`new`),[C,w]=(0,f.useState)(``),[T,E]=(0,f.useState)(!1),[D,O]=(0,f.useState)(null),k=y?_:u(h),A=m({name:h,id:k,place:x,folder:C},d);function j(e){E(e),t?.(e)}async function M(t){if(t.preventDefault(),!(!A.body||T)){O(null),j(!0);try{await e(await n(`/api/teams`,{body:A.body}))}catch(e){O(i(e))}finally{j(!1)}}}return(0,p.jsxs)(`form`,{onSubmit:e=>void M(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:h,disabled:T,placeholder:`My project`,className:`max-w-none`,onChange:e=>{g(e),O(null)}}),(0,p.jsx)(c,{label:`ID`,value:k,disabled:T,placeholder:`my-project`,mono:!0,className:`max-w-none`,hint:`Used in commands and addresses; it cannot change later.`,problem:A.problems.id,onChange:e=>{b(!0),v(e),O(null)}})]}),(0,p.jsx)(s,{legend:`Where its files are`,name:`team-place`,value:x,disabled:T,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:S}),x===`link`&&(0,p.jsx)(c,{label:`Folder`,value:C,disabled:T,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:A.problems.folder,onChange:w}),D&&(0,p.jsx)(o,{tone:`warning`,role:`alert`,title:`The Team was not created.`,children:D}),(0,p.jsxs)(l,{children:[r?.(T),(0,p.jsx)(a,{variant:`primary`,type:`submit`,disabled:T||!A.body,children:T?`Creating…`:`Create Team`})]})]})}export{h as t};
|
|
@@ -1 +1 @@
|
|
|
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{X as u,Z as d,it as f,ot as p}from"./index-
|
|
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{X as u,Z as d,it as f,ot as p}from"./index-CVVVmIFC.js";import{r as m,t as h}from"./use-resource-qjIkNQDY.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)}function C(e){let{turnsEnded:t}=p();return m(async t=>{if(!e)return{changes:null,files:null,repository:null};let r=encodeURIComponent(e),[i,a]=await Promise.all([n(`/api/teams/${r}/review`,{signal:t}).catch(()=>null),n(`/api/results?teamId=${r}&limit=1`,{signal:t}).then(e=>e.total).catch(()=>null)]);return i?`unavailable`in i?{changes:null,files:a,repository:i.unavailable.code!==`not_repository`}:{changes:i.changes.changes.length,files:a,repository:!0}:{changes:null,files:a,repository:null}},[e],{refreshOn:t}).data??{changes:null,files:null,repository:null}}var w={connections:{label:`Connections`,icon:l},changes:{label:`Changes`,icon:g},files:{label:`Files`,icon:s}};function T({view:e,actions:t,children:n}){let{team:i,agent:a,to:s}=x(),c=C(i?.id);return(0,v.jsxs)(`section`,{"aria-label":`${w[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 min-w-0 max-w-[14rem] 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 shrink-0`,"aria-hidden":`true`}),(0,v.jsx)(`span`,{className:`min-w-0 truncate`,children: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:d.filter(t=>t!==`changes`||t===e||c.repository!==!1).map(t=>{let n=w[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:w[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 E={needs:`text-warning`,working:`text-success`,paused:`text-warning`,fresh:`text-accent-foreground`,idle:`text-muted-foreground`},D={needs:`bg-warning`,working:`bg-success animate-pulse`,paused:`bg-fawn`,fresh:`bg-primary`,idle:`bg-fawn`};function O(e){try{let t=JSON.parse(e);if(typeof t.text==`string`)return t.text}catch{}return e}var k=(e,t)=>e<t?`${e}|${t}`:`${t}|${e}`;function A(e){let t=new Map;for(let n of e){let e=k(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 j(e,t=100){let{turnsEnded:r}=p();return m(r=>n(`/api/teams/${encodeURIComponent(e)}/messages?limit=${t}`,{signal:r}).then(e=>e.messages),[e,t],{refreshOn:r})}function M({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=O(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)(u,{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)(u,{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:f(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{A as a,T as c,x as d,S as f,k as i,C as l,j as n,D as o,g as p,O as r,E as s,M as t,b as u};
|
package/dist/web/client/assets/{UnsavedChangesGuard-a9NU27Fr.js → UnsavedChangesGuard-DGzP-x1t.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,Z as t,d as n,h as r}from"./createLucideIcon-CZHSSDYA.js";import{t as i}from"./ConfirmDialog-
|
|
1
|
+
import{$ as e,Z as t,d as n,h as r}from"./createLucideIcon-CZHSSDYA.js";import{t as i}from"./ConfirmDialog-D8f2wI5x.js";var a=e(t(),1);function o(e,t){if(e===void 0)return{shouldBlockFn:()=>!0,withResolver:!1};if(`shouldBlockFn`in e)return e;if(typeof e==`function`){let n=!!(t??!0);return{shouldBlockFn:async()=>n?await e():!1,enableBeforeUnload:n,withResolver:!1}}let n=!!(e.condition??!0),r=e.blockerFn;return{shouldBlockFn:async()=>n&&r!==void 0?await r():n,enableBeforeUnload:n,withResolver:r===void 0}}function s(e,t){let{shouldBlockFn:r,enableBeforeUnload:i=!0,disabled:s=!1,withResolver:c=!1}=o(e,t),l=n(),{history:u}=l,[d,f]=a.useState({status:`idle`,current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return a.useEffect(()=>s?void 0:u.block({blockerFn:async e=>{function t(e){let t=l.parseLocation(e),n=l.getMatchedRoutes(t.pathname);return n.foundRoute===void 0?{routeId:`__notFound__`,fullPath:t.pathname,pathname:t.pathname,params:n.routeParams,search:l.options.parseSearch(e.search)}:{routeId:n.foundRoute.id,fullPath:n.foundRoute.fullPath,pathname:t.pathname,params:n.routeParams,search:l.options.parseSearch(e.search)}}let n=t(e.currentLocation),i=t(e.nextLocation);if(n.routeId===`__notFound__`&&i.routeId!==`__notFound__`)return!1;let a=await r({action:e.action,current:n,next:i});if(!c)return a;if(!a)return!1;let o=await new Promise(t=>{f({status:`blocked`,current:n,next:i,action:e.action,proceed:()=>t(!1),reset:()=>t(!0)})});return f({status:`idle`,current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),o},enableBeforeUnload:i}),[r,i,s,c,u,l]),d}var c=r();function l({when:e,subject:t=`changes`}){let n=(0,a.useRef)(!1),r=s({shouldBlockFn:(0,a.useCallback)(()=>e,[e]),enableBeforeUnload:e,disabled:!e,withResolver:!0}),o=r.status===`blocked`&&r.next.pathname!==r.current.pathname?r.next.pathname:``;return(0,c.jsx)(i,{open:r.status===`blocked`,title:`Discard unsaved ${t}?`,description:o?(0,c.jsxs)(`p`,{children:[`Leaving this page for `,(0,c.jsx)(`code`,{className:`font-mono`,children:o}),` will permanently discard the unsaved `,t,` on this page.`]}):(0,c.jsxs)(`p`,{children:[`Going on will permanently discard the unsaved `,t,`.`]}),confirmLabel:o?`Discard and leave`:`Discard`,onConfirm:()=>{n.current=!0,r.proceed?.()},onOpenChange:e=>{!e&&!n.current&&r.reset?.(),e||(n.current=!1)}})}export{l as t};
|
|
@@ -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{u as s}from"./preload-helper-CZOd_z6l.js";import{t as c}from"./UnsavedChangesGuard-
|
|
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{u as s}from"./preload-helper-CZOd_z6l.js";import{t as c}from"./UnsavedChangesGuard-DGzP-x1t.js";import{t as l}from"./Button-CoKQRO-s.js";import{S as u}from"./es2015-DZDOQ3kj.js";import{_ as d,a as f,c as p,t as m,y as h}from"./parts-C104qEuC.js";import{E as g,F as _,M as v,N as y,t as b,x}from"./index-CVVVmIFC.js";import{E as S,T as C,d as w,w as T}from"./manage-Dwe9yQl9.js";import{t as E}from"./ConfirmDialog-D8f2wI5x.js";import{t as D}from"./ManagePage-BzyMHGqs.js";import{n as O,r as k}from"./AgentTemplateParts-BaeuW_3n.js";var A=o(`file-code-corner`,[[`path`,{d:`M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35`,key:`1wthlu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m5 16-3 3 3 3`,key:`331omg`}],[`path`,{d:`m9 22 3-3-3-3`,key:`lsp7cz`}]]),j=o(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),M=e(t(),1),N=i(),P=e=>`/api/profiles/${encodeURIComponent(e)}`;function F(e,t){return e.size===t.size&&[...e].every(e=>t.has(e))}function I({loaded:e,chat:t,skills:r,onDirtyChange:i,onSaved:o}){let{profile:s}=e,[c,l]=(0,M.useState)(()=>({name:s.name,model:s.defaultModel,mode:s.skillsMode,picked:new Set(e.defaultSkills)})),[u,d]=(0,M.useState)(c.name),[p,m]=(0,M.useState)(c.model),[b,x]=(0,M.useState)(c.mode),[S,C]=(0,M.useState)(()=>new Set(c.picked)),[w,T]=(0,M.useState)(!1),[E,D]=(0,M.useState)(null),[k,A]=(0,M.useState)(!1),I=u.trim()!==c.name||p!==c.model||b!==c.mode||b===`selected`&&!F(S,c.picked);(0,M.useEffect)(()=>i(I),[I,i]);let L=()=>{A(!1),D(null)};async function R(e){if(e.preventDefault(),!(!I||w||!p||!u.trim())){T(!0),D(null);try{let e={name:u.trim(),model:p,mode:b,picked:b===`selected`?new Set(S):c.picked},t=e.mode!==c.mode||e.mode===`selected`&&!F(e.picked,c.picked);await n(P(s.id),{method:`PATCH`,body:{...e.name===c.name?{}:{name:e.name},...e.model===c.model?{}:{defaultModel:e.model},...t?{skillsMode:e.mode,...e.mode===`selected`?{defaultSkills:[...e.picked]}:{}}:{}}}),l(e),d(e.name),C(new Set(e.picked)),A(!0),await o()}catch(e){D(a(e))}finally{T(!1)}}}return(0,N.jsx)(h,{labelledBy:`template-settings`,icon:(0,N.jsx)(j,{className:`size-5`}),title:`Settings`,description:`What it is called, the model its Agents answer with, and the skills they start with.`,children:(0,N.jsxs)(f,{onSubmit:R,children:[(0,N.jsxs)(`div`,{className:`grid items-start gap-x-3 gap-y-4 sm:grid-cols-2`,children:[(0,N.jsx)(v,{label:`Name`,value:u,disabled:w,required:!0,placeholder:s.id,className:`max-w-none`,problem:u.trim()?void 0:`A template needs a name.`,onChange:e=>{L(),d(e)}}),(0,N.jsx)(_,{kit:!0,label:`Default model`,value:p,models:t,required:!0,onChange:e=>{L(),m(e)}})]}),(0,N.jsx)(O,{mode:b,picked:S,skills:r,disabled:w,onModeChange:e=>{L(),x(e)},onPickedChange:e=>{L(),C(e)}}),(0,N.jsx)(g,{busy:w,disabled:!I||!p||!u.trim(),status:y({error:E,dirty:I,saved:k,savedText:`Saved. Agents spawned from now on get these.`,footnote:`Agents already spawned keep their own model and skills.`})})]})})}function L(e){return{soul:e.soul,identity:e.identity,bootstrap:e.bootstrap,agents:e.agents,tools:e.tools}}function R({loaded:e,starter:t,onDirtyChange:r}){let i=e.profile.id,[o,s]=(0,M.useState)(()=>L(e.files)),[c,d]=(0,M.useState)(()=>L(e.files)),[m,_]=(0,M.useState)(`soul`),[v,b]=(0,M.useState)(!1),[x,S]=(0,M.useState)(null),[C,w]=(0,M.useState)(!1),T=k.filter(e=>c[e.key]!==o[e.key]),E=T.length>0;(0,M.useEffect)(()=>r(E),[E,r]);let D=k.find(e=>e.key===m)??k[0],O=D?c[D.key]:null;function j(e,t){w(!1),S(null),d(n=>({...n,[e]:t}))}let F=(0,M.useRef)({});function I(e){_(e),F.current[e]?.focus()}function R(e,t){let n=k.length-1,r=e.key===`ArrowRight`?t===n?0:t+1:e.key===`ArrowLeft`?t===0?n:t-1:e.key===`Home`?0:e.key===`End`?n:null,i=r===null?void 0:k[r];i&&(e.preventDefault(),I(i.key))}let[z,B]=(0,M.useState)(null);async function V(e){if(e.preventDefault(),!E||v)return;b(!0),S(null);let t={};try{for(let e of T){let r=c[e.key];r!==null&&(await n(`${P(i)}/files/${encodeURIComponent(e.name)}`,{method:`PUT`,body:{content:r}}),t[e.key]=r)}w(!0)}catch(e){S(a(e))}finally{s(e=>({...e,...t})),b(!1)}}return(0,N.jsxs)(h,{labelledBy:`template-files`,icon:(0,N.jsx)(A,{className:`size-5`}),title:`Files`,description:`Each Agent spawned from this template gets its own copy of these, and may change it.`,children:[(0,N.jsx)(p,{children:(0,N.jsx)(`div`,{role:`tablist`,"aria-label":`Template files`,className:`flex max-w-full gap-1 overflow-x-auto rounded-xl border border-border bg-muted/50 p-1`,children:k.map((e,t)=>{let n=e.key===m,r=c[e.key]===null,i=c[e.key]!==o[e.key];return(0,N.jsxs)(`button`,{type:`button`,role:`tab`,id:`template-file-${e.key}`,ref:t=>{F.current[e.key]=t},"aria-selected":n,"aria-controls":`template-file-panel`,tabIndex:n?0:-1,onClick:()=>_(e.key),onKeyDown:e=>R(e,t),className:u(`unstyled inline-flex items-center gap-1.5 whitespace-nowrap rounded-lg border px-2.5 py-1.5 font-mono text-xs font-semibold transition-colors sm:px-3`,n?`border-border bg-card text-foreground shadow-baziu-sm`:`border-transparent hover:bg-card/70 hover:text-foreground`,!n&&(r?`text-muted-foreground/70`:`text-muted-foreground`)),children:[e.name,i&&(0,N.jsx)(`span`,{className:`size-1.5 rounded-full bg-warning`,role:`img`,"aria-label":`not saved`})]},e.key)})})}),(0,N.jsx)(`div`,{id:`template-file-panel`,role:`tabpanel`,"aria-labelledby":`template-file-${m}`,children:(0,N.jsxs)(f,{onSubmit:V,children:[D&&O===null?(0,N.jsxs)(`div`,{className:`flex flex-col items-center gap-2 rounded-xl border border-dashed border-border bg-muted/30 px-4 py-8 text-center`,children:[(0,N.jsxs)(`p`,{className:`m-0 text-base font-semibold text-foreground`,children:[`This template has no `,D.name]}),(0,N.jsxs)(`p`,{className:`m-0 max-w-md text-sm text-muted-foreground`,children:[D.hint,` It starts from the built-in text and is saved with the other files.`]}),(0,N.jsxs)(l,{variant:`ghost`,className:`mt-2`,disabled:v,onClick:()=>{B(D.key),j(D.key,t[D.key])},children:[`Add `,D.name]})]}):D&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:D.hint}),(0,N.jsx)(`textarea`,{autoFocus:z===D.key,"aria-label":`${D.name} contents`,value:O??``,disabled:v,spellCheck:!1,rows:22,onChange:e=>j(D.key,e.target.value),className:`min-h-[18rem] resize-y font-mono text-sm leading-[1.6]`},D.key)]}),(0,N.jsx)(g,{busy:v,disabled:!E,label:T.length>1?`Save ${T.length} files`:`Save`,status:y({error:x,dirty:E,saved:C,savedText:`Saved. Agents spawned from now on get these files.`,footnote:`Saving keeps every file you changed, not only the one in view.`}),extra:E&&(0,N.jsx)(l,{variant:`ghost`,disabled:v,onClick:()=>{d(o),S(null),F.current[m]?.focus()},children:`Discard changes`})})]})})]})}function z(){let{loaded:e,chat:t,skills:i,starter:a,templates:o,teamTemplates:u,teams:f}=b.useLoaderData(),{profile:p}=e,h=r(),g=s(),[_,v]=(0,M.useState)(!1),[y,O]=(0,M.useState)(!1),[k,A]=(0,M.useState)(!1),[j,P]=(0,M.useState)(!1),F=(0,M.useCallback)(e=>v(e),[]),L=(0,M.useCallback)(e=>O(e),[]),z=o.find(e=>e.id===p.id),B=z?T(z,u):null,V=w(p.defaultModel,t),H=C(p);return(0,N.jsxs)(D,{title:H,description:(0,N.jsxs)(N.Fragment,{children:[`What every Agent spawned from this template starts with.`,` `,z?`${S(z,u)}.`:``,` Agents already spawned keep their own copies.`]}),actions:(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(l,{variant:`primary`,onClick:()=>A(!0),children:`Add an Agent`}),(0,N.jsx)(d,{label:`More for ${H}`,items:[{label:`Delete template…`,danger:!0,disabledReason:B,onSelect:()=>P(!0)}]})]}),children:[(0,N.jsx)(c,{when:_||y,subject:`template changes`}),V.missing&&(0,N.jsx)(m,{tone:`warning`,lead:`Its default model, ${V.name}, is not in Chat.`,action:(0,N.jsx)(`a`,{href:`/config`,className:`ghost-btn no-underline`,children:`Open Setup → Models`}),children:`Agents spawned from it are refused until it is. Choose another model below, or add it in Setup.`}),(0,N.jsx)(I,{loaded:e,chat:t,skills:i,onDirtyChange:F,onSaved:()=>h.invalidate({sync:!0})}),(0,N.jsx)(R,{loaded:e,starter:a,onDirtyChange:L}),k&&(0,N.jsx)(x,{profiles:o,teams:f,profileId:p.id,onClose:()=>A(!1)}),(0,N.jsx)(E,{open:j,onOpenChange:P,title:`Delete the ${H} template?`,description:(0,N.jsx)(`p`,{className:`m-0`,children:`This deletes the template and its files. No Agent and no Team template uses it.`}),confirmLabel:`Delete template`,onConfirm:async()=>{await n(`/api/profiles/${encodeURIComponent(p.id)}`,{method:`DELETE`}),await g({to:`/templates/agents`})}})]})}export{z as component};
|
|
@@ -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{u as s}from"./preload-helper-CZOd_z6l.js";import{t as c}from"./UnsavedChangesGuard-a9NU27Fr.js";import{t as l}from"./Button-CoKQRO-s.js";import{_ as u,g as d}from"./parts-C104qEuC.js";import{t as f}from"./bot-BHky7KAX.js";import{a as p,d as m,f as h,i as g,l as _,n as v,o as y,r as b,s as x,t as S,u as C}from"./style-CKIbA0FQ.js";import{t as w}from"./plus-CEKaHPBw.js";import{t as T}from"./shield-alert-CO7P-cbq.js";import{A as E,M as D,O,n as k}from"./index-rLAiEnYi.js";import{A,B as j,D as M,F as N,H as ee,M as P,N as F,P as I,R as L,V as R,j as z,k as B,s as V,z as H}from"./manage-BXNoJYsp.js";import{t as U}from"./ConfirmDialog-CD3lCuKs.js";import{t as W}from"./Segmented-iylzLwE6.js";import{t as G}from"./ManagePage-BzyMHGqs.js";import{t as K}from"./SpawnTeamModal-64EFK4SI.js";var q=o(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),J=e(t(),1),Y=i();function X({data:e,selected:t}){return(0,Y.jsxs)(`div`,{className:`relative w-[190px] rounded-md border bg-snow px-3 py-2.5 shadow-baziu-sm transition-shadow ${t?`border-sapphire shadow-baziu-md`:`border-frost`}`,children:[(0,Y.jsx)(g,{type:`target`,position:C.Left,className:`!h-3 !w-3 !border-2 !border-snow !bg-sapphire`}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,Y.jsx)(`span`,{className:`flex h-8 w-8 flex-none items-center justify-center rounded-md bg-sapphire-glow text-sapphire`,children:(0,Y.jsx)(f,{className:`h-4 w-4`,"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate text-sm font-semibold text-chocolate`,children:e.member.name}),(0,Y.jsx)(`span`,{className:`mt-0.5 flex items-center gap-1.5 truncate text-xs text-mocha-light`,children:e.subtitle})]}),e.isolated&&(0,Y.jsx)(T,{className:`h-4 w-4 flex-none text-[#a56568]`,"aria-label":`No connections`}),e.incomplete&&(0,Y.jsx)(q,{className:`h-4 w-4 flex-none text-warning`,"aria-label":`No template`})]}),(0,Y.jsx)(g,{type:`source`,position:C.Right,className:`!h-3 !w-3 !border-2 !border-snow !bg-sapphire`})]})}function Z({data:e,selected:t}){return(0,Y.jsxs)(`div`,{className:`w-[150px] rounded-md border bg-ivory px-3 py-2.5 shadow-baziu-sm ${t?`border-sapphire`:`border-fawn`}`,children:[(0,Y.jsx)(g,{type:`target`,position:C.Left,className:`!h-3 !w-3 !border-2 !border-ivory !bg-rose-baziu`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(h,{className:`h-4 w-4 flex-none text-rose-baziu`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`block text-sm font-semibold text-chocolate`,children:e.label})]}),(0,Y.jsx)(g,{type:`source`,position:C.Right,className:`!h-3 !w-3 !border-2 !border-ivory !bg-rose-baziu`})]})}var Q={agent:X,outside:Z},te={};function $({document:e,selectedId:t,incompleteKeys:n,templateNames:r=te,onSelect:i,onConnect:a,onRemoveEdge:o,onMoveMember:s,onOpenMember:c}){let l=(0,J.useMemo)(()=>[{id:B,type:`outside`,position:{x:Math.max(800,...e.members.map(e=>e.position.x+280)),y:110},data:{label:`Other teams`},ariaLabel:`Agents in other teams`,selected:t===B,draggable:!1,deletable:!1},...e.members.map(i=>{let a=e.mode===`restricted`&&!e.edges.some(e=>e.from===i.key||e.to===i.key),o=n.has(i.key);return{id:i.key,type:`agent`,position:i.position,data:{member:i,subtitle:r[i.profileId]??`No template`,isolated:a,incomplete:o},ariaLabel:`${i.name}${a?`, no connections`:``}${o?`, no template`:``}`,selected:t===i.key,deletable:!1}})],[e,n,t,r]),[u,d,f]=x(l);(0,J.useEffect)(()=>{d(e=>{let t=new Map(e.map(e=>[e.id,e]));return l.map(e=>({...t.get(e.id),...e}))})},[l,d]);let m=(0,J.useMemo)(()=>e.edges.map(e=>{let n=F(e.from,e.to);return{id:n,source:e.from,target:e.to,selected:t===n,markerEnd:{type:_.ArrowClosed,width:16,height:16},style:{stroke:`var(--color-sapphire)`,strokeWidth:1.7}}}),[e.edges,t]),h=e=>{e.source&&e.target&&a(e.source,e.target)},g=t=>e.members.find(e=>e.key===t);return(0,Y.jsx)(`div`,{className:`h-full min-h-[420px] w-full bg-ivory`,children:(0,Y.jsxs)(y,{nodes:u,edges:m,nodeTypes:Q,onConnect:h,onNodesChange:f,onNodeClick:(e,t)=>i(t.id),onNodeDoubleClick:(e,t)=>{let n=g(t.id);n&&c(n)},onEdgeClick:(e,t)=>i(t.id),onPaneClick:()=>i(null),onEdgesDelete:e=>{for(let t of e)o(t.source,t.target)},onNodeDragStop:(e,t)=>{g(t.id)&&s(t.id,t.position)},minZoom:.35,maxZoom:1.8,edgesReconnectable:!1,fitView:!0,fitViewOptions:{padding:.22,maxZoom:1},proOptions:{hideAttribution:!0},className:`policy-flow`,children:[(0,Y.jsx)(S,{variant:v.Dots,gap:20,size:1.2,color:`var(--color-fawn)`}),(0,Y.jsx)(b,{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`}),(0,Y.jsx)(p,{pannable:!0,zoomable:!0,position:`bottom-right`,className:`!hidden !rounded-md !border !border-frost !bg-snow sm:!block`,nodeColor:e=>e.type===`outside`?`var(--color-rose-baziu)`:`var(--color-sapphire)`,maskColor:`color-mix(in srgb, var(--color-cream) 70%, transparent)`})]})})}var ne={open:`Every member can message every other member, with no connections needed; connections only matter for messages to and from other Teams, or if the Team is set to Connections only.`,restricted:`Members message each other only along connections.`};function re({template:e,profiles:t,onSaved:r,onDirtyChange:i}){let[o,s]=(0,J.useState)(()=>R(e)),[u,d]=(0,J.useState)(o),[f,p]=(0,J.useState)(`flow`),[h,g]=(0,J.useState)(null),[_,v]=(0,J.useState)(!1),[y,b]=(0,J.useState)(null),[x,S]=(0,J.useState)(!1),C=!L(o,u);(0,J.useEffect)(()=>i?.(C),[C,i]);let w=(0,J.useMemo)(()=>new Set(u.members.filter(e=>!t.some(t=>t.id===e.profileId)).map(e=>e.key)),[u.members,t]),T=(0,J.useMemo)(()=>Object.fromEntries(t.map(e=>[e.id,`${e.name||e.id} template`])),[t]),[E,O]=(0,J.useState)(null),k=(e,t,n)=>{if(z(u,e,t,n)){O({from:e,to:t});return}d(r=>H(r,e,t,n))},N=async()=>{v(!0),b(null);try{let i=R(await n(`/api/team-templates/${encodeURIComponent(e.id)}`,{method:`PUT`,body:ee(u,t)}));s(i),d(i),g(null),b({text:`Saved.`,ok:!0}),await r?.()}catch(e){b({text:a(e),ok:!1})}finally{v(!1)}};return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(c,{when:C,subject:`Team template draft`}),(0,Y.jsxs)(`section`,{className:`min-w-0 overflow-hidden rounded-2xl border border-border bg-card shadow-baziu-sm`,"aria-label":`Roster and connections`,children:[(0,Y.jsxs)(`header`,{className:`flex flex-wrap items-end gap-x-3 gap-y-3 border-b border-border px-4 py-4 sm:px-5`,children:[(0,Y.jsx)(`div`,{className:`min-w-0 flex-1 basis-60`,children:(0,Y.jsx)(D,{label:`Name`,value:u.name,disabled:_,required:!0,className:`max-w-none`,problem:u.name.trim()?void 0:`A template needs a name.`,onChange:e=>d(t=>({...t,name:e}))})}),(0,Y.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-semibold text-foreground`,children:`Messaging`}),(0,Y.jsx)(W,{label:`Messaging`,value:u.mode,onChange:e=>d(t=>({...t,mode:e})),options:[{id:`open`,label:M.open},{id:`restricted`,label:M.restricted}]})]}),(0,Y.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-semibold text-foreground`,children:`View`}),(0,Y.jsx)(W,{label:`View`,value:f,onChange:p,options:[{id:`flow`,label:`Flow`},{id:`matrix`,label:`Matrix`}]})]}),(0,Y.jsx)(`p`,{className:`m-0 basis-full text-sm text-muted-foreground`,children:ne[u.mode]})]}),(0,Y.jsxs)(`div`,{className:`grid min-h-[620px] grid-cols-1 lg:grid-cols-[minmax(0,1fr)_280px]`,children:[(0,Y.jsx)(`div`,{className:`min-h-[480px] overflow-hidden`,children:f===`flow`?(0,Y.jsx)($,{document:u,templateNames:T,selectedId:h,incompleteKeys:w,onSelect:g,onConnect:(e,t)=>k(e,t,!0),onRemoveEdge:(e,t)=>k(e,t,!1),onMoveMember:(e,t)=>d(n=>({...n,members:n.members.map(n=>n.key===e?{...n,position:t}:n)})),onOpenMember:e=>g(e.key)}):(0,Y.jsx)(m,{document:u,selectedId:h,onSelect:g,onToggle:k})}),(0,Y.jsx)(`aside`,{className:`border-t border-border p-4 lg:border-l lg:border-t-0`,children:(0,Y.jsx)(ie,{document:u,selectedId:h,profiles:t,onDraft:d,onSelect:g,onToggle:k})})]}),(0,Y.jsxs)(`footer`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 border-t border-border px-4 py-4 sm:px-5`,children:[(0,Y.jsx)(l,{variant:`primary`,disabled:!C||_||!u.name.trim(),onClick:()=>void N(),children:_?`Saving…`:`Save`}),C&&(0,Y.jsx)(l,{variant:`ghost`,disabled:_,onClick:()=>S(!0),children:`Discard changes`}),(0,Y.jsx)(`p`,{role:`status`,className:`m-0 min-w-0 flex-1 basis-56 text-sm font-medium ${y&&!y.ok||C?`text-warning`:y?`text-success`:`text-muted-foreground`}`,children:y&&!y.ok?`Nothing was saved: ${y.text}`:C?`Not saved yet.`:y?`Saved. Teams spawned from now on get this roster.`:`Teams already spawned keep their own Agents and connections.`})]})]}),(0,Y.jsx)(U,{open:E!==null,title:A.title,description:(0,Y.jsx)(`p`,{children:A.description}),confirmLabel:A.confirm,onConfirm:()=>{E&&d(e=>j(e,E.from,E.to)),O(null)},onOpenChange:e=>{e||O(null)}}),(0,Y.jsx)(U,{open:x,title:`Discard your changes to this template?`,description:(0,Y.jsx)(`p`,{children:`The saved roster and connections stay as they are.`}),confirmLabel:`Discard changes`,onConfirm:()=>{d(o),g(null),b(null)},onOpenChange:S})]})}function ie({document:e,selectedId:t,profiles:n,onDraft:r,onSelect:i,onToggle:a}){let o=[...e.members.map(e=>e.key),B],s=e.edges.find(e=>F(e.from,e.to)===t),c=t&&o.includes(t)?t:null,u=e.members.find(e=>e.key===c),f=e=>r(t=>({...t,members:t.members.map(t=>t.key===u?.key?{...t,...e}:t)}));if(s)return(0,Y.jsxs)(`div`,{className:`grid gap-3`,children:[(0,Y.jsx)(`h3`,{className:`m-0 font-body text-sm font-semibold text-foreground`,children:`Connection`}),(0,Y.jsxs)(`p`,{className:`m-0 text-sm`,children:[I(e,s.from),` may message `,I(e,s.to),`.`]}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(l,{variant:`danger`,onClick:()=>{a(s.from,s.to,!1),i(null)},children:`Remove connection`})})]});if(!c)return(0,Y.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Y.jsxs)(`div`,{className:`grid gap-1`,children:[(0,Y.jsxs)(`h3`,{className:`m-0 font-body text-sm font-semibold text-foreground`,children:[e.members.length===1?`1 Agent`:`${e.members.length} Agents`,` ·`,` `,e.edges.length===1?`1 connection`:`${e.edges.length} connections`]}),(0,Y.jsx)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:`Select an Agent to choose who it may message, or drag from one Agent's dot to another. A message to another Team needs a connection to Other teams here, and one from Other teams in that Team.`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{htmlFor:`team-template-user-md`,className:`m-0 text-sm font-semibold text-foreground`,children:`USER.md`}),(0,Y.jsx)(`textarea`,{id:`team-template-user-md`,rows:6,value:e.userMd??``,onChange:e=>{let t=e.target.value;r(e=>({...e,userMd:t||null}))},className:`mt-1.5 font-mono text-[0.85em]`}),(0,Y.jsx)(`span`,{className:`mt-1 block text-xs text-muted-foreground`,children:`What every Agent of a Team spawned from it knows about you.`})]}),(0,Y.jsx)(`div`,{children:(0,Y.jsxs)(l,{variant:`ghost`,onClick:()=>r(e=>({...e,members:[...e.members,{key:`draft:${crypto.randomUUID()}`,profileId:n[0]?.id??``,name:`Agent ${e.members.length+1}`,position:P(e.members.length)}]})),children:[(0,Y.jsx)(w,{className:`size-4`,"aria-hidden":`true`}),` Add an Agent`]})})]});let p=u&&n.some(e=>e.id===u.profileId);return(0,Y.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Y.jsx)(`h3`,{className:`m-0 font-body text-sm font-semibold text-foreground`,children:u?u.name||`Agent`:`Other teams`}),u&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(D,{label:`Name`,value:u.name,className:`max-w-none`,onChange:e=>f({name:e})}),(0,Y.jsx)(O,{label:`Template`,value:u.profileId,className:`max-w-none`,options:[...p?[]:[{value:u.profileId,label:u.profileId||`Choose a template`}],...n.map(e=>({value:e.id,label:e.name||e.id}))],onChange:e=>f({profileId:e})}),!p&&(0,Y.jsx)(d,{tone:`warning`,children:`Choose a template: an Agent cannot be spawned without one.`})]}),(0,Y.jsxs)(`fieldset`,{className:`m-0 grid min-w-0 gap-3 border-0 p-0`,children:[(0,Y.jsx)(`legend`,{className:`mb-2 p-0 text-sm font-semibold text-foreground`,children:`May message`}),o.filter(e=>e!==c).map(t=>(0,Y.jsx)(E,{label:I(e,t),checked:N(e,c,t),onChange:e=>a(c,t,e)},t))]}),u&&(0,Y.jsx)(`div`,{children:(0,Y.jsx)(l,{variant:`danger`,onClick:()=>{r(e=>({...e,members:e.members.filter(e=>e.key!==u.key),edges:e.edges.filter(e=>e.from!==u.key&&e.to!==u.key)})),i(null)},children:`Remove this Agent`})})]})}function ae(){let{template:e,profiles:t,teams:i}=k.useLoaderData(),a=s(),o=r(),[c,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)(!1),[m,h]=(0,J.useState)(!1);return(0,Y.jsxs)(G,{title:e.name,description:`A roster of ${V(e.slots.length,`Agent`)} and ${V(e.edges.length,`connection`)}. Using it adds them to a new Team or one that exists; Teams made from it earlier keep their own.`,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(l,{variant:`primary`,disabled:e.slots.length===0||m,"aria-describedby":m?`spawn-needs-save`:void 0,onClick:()=>d(!0),children:`Use this template`}),(0,Y.jsx)(u,{label:`More for ${e.name}`,items:[{label:`Delete template…`,danger:!0,onSelect:()=>p(!0)}]})]}),children:[m&&(0,Y.jsx)(`p`,{id:`spawn-needs-save`,className:`m-0 text-sm font-medium text-warning`,children:`Save the roster to spawn it as it is on screen.`}),(0,Y.jsx)(re,{template:e,profiles:t,onSaved:()=>o.invalidate({sync:!0}),onDirtyChange:h}),c&&(0,Y.jsx)(K,{template:e,teams:i,onClose:()=>d(!1),onSpawned:e=>{d(!1),a({to:`/`,search:{team:e,panel:`team`}})}}),(0,Y.jsx)(U,{open:f,onOpenChange:p,title:`Delete the ${e.name} Team template?`,description:(0,Y.jsx)(`p`,{className:`m-0`,children:`Teams already spawned from it keep their Agents and connections.`}),confirmLabel:`Delete template`,onConfirm:async()=>{await n(`/api/team-templates/${encodeURIComponent(e.id)}`,{method:`DELETE`}),await a({to:`/templates/teams`})}})]})}export{ae 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{u as s}from"./preload-helper-CZOd_z6l.js";import{t as c}from"./UnsavedChangesGuard-DGzP-x1t.js";import{t as l}from"./Button-CoKQRO-s.js";import{_ as u,g as d}from"./parts-C104qEuC.js";import{t as f}from"./bot-BHky7KAX.js";import{a as p,d as m,f as h,i as g,l as _,n as v,o as y,r as b,s as x,t as S,u as C}from"./style-B9Vy-99n.js";import{t as w}from"./plus-CEKaHPBw.js";import{t as T}from"./shield-alert-CO7P-cbq.js";import{A as E,M as D,O,n as k}from"./index-CVVVmIFC.js";import{A,B as j,D as M,F as N,H as ee,M as P,N as F,P as I,R as L,V as R,j as z,k as B,s as V,z as H}from"./manage-Dwe9yQl9.js";import{t as U}from"./ConfirmDialog-D8f2wI5x.js";import{t as W}from"./Segmented-iylzLwE6.js";import{t as G}from"./ManagePage-BzyMHGqs.js";import{t as K}from"./SpawnTeamModal-Dq7D3Zlc.js";var q=o(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),J=e(t(),1),Y=i();function X({data:e,selected:t}){return(0,Y.jsxs)(`div`,{className:`relative w-[190px] rounded-md border bg-snow px-3 py-2.5 shadow-baziu-sm transition-shadow ${t?`border-sapphire shadow-baziu-md`:`border-frost`}`,children:[(0,Y.jsx)(g,{type:`target`,position:C.Left,className:`!h-3 !w-3 !border-2 !border-snow !bg-sapphire`}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,Y.jsx)(`span`,{className:`flex h-8 w-8 flex-none items-center justify-center rounded-md bg-sapphire-glow text-sapphire`,children:(0,Y.jsx)(f,{className:`h-4 w-4`,"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate text-sm font-semibold text-chocolate`,children:e.member.name}),(0,Y.jsx)(`span`,{className:`mt-0.5 flex items-center gap-1.5 truncate text-xs text-mocha-light`,children:e.subtitle})]}),e.isolated&&(0,Y.jsx)(T,{className:`h-4 w-4 flex-none text-[#a56568]`,"aria-label":`No connections`}),e.incomplete&&(0,Y.jsx)(q,{className:`h-4 w-4 flex-none text-warning`,"aria-label":`No template`})]}),(0,Y.jsx)(g,{type:`source`,position:C.Right,className:`!h-3 !w-3 !border-2 !border-snow !bg-sapphire`})]})}function Z({data:e,selected:t}){return(0,Y.jsxs)(`div`,{className:`w-[150px] rounded-md border bg-ivory px-3 py-2.5 shadow-baziu-sm ${t?`border-sapphire`:`border-fawn`}`,children:[(0,Y.jsx)(g,{type:`target`,position:C.Left,className:`!h-3 !w-3 !border-2 !border-ivory !bg-rose-baziu`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(h,{className:`h-4 w-4 flex-none text-rose-baziu`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`block text-sm font-semibold text-chocolate`,children:e.label})]}),(0,Y.jsx)(g,{type:`source`,position:C.Right,className:`!h-3 !w-3 !border-2 !border-ivory !bg-rose-baziu`})]})}var Q={agent:X,outside:Z},te={};function $({document:e,selectedId:t,incompleteKeys:n,templateNames:r=te,onSelect:i,onConnect:a,onRemoveEdge:o,onMoveMember:s,onOpenMember:c}){let l=(0,J.useMemo)(()=>[{id:B,type:`outside`,position:{x:Math.max(800,...e.members.map(e=>e.position.x+280)),y:110},data:{label:`Other teams`},ariaLabel:`Agents in other teams`,selected:t===B,draggable:!1,deletable:!1},...e.members.map(i=>{let a=e.mode===`restricted`&&!e.edges.some(e=>e.from===i.key||e.to===i.key),o=n.has(i.key);return{id:i.key,type:`agent`,position:i.position,data:{member:i,subtitle:r[i.profileId]??`No template`,isolated:a,incomplete:o},ariaLabel:`${i.name}${a?`, no connections`:``}${o?`, no template`:``}`,selected:t===i.key,deletable:!1}})],[e,n,t,r]),[u,d,f]=x(l);(0,J.useEffect)(()=>{d(e=>{let t=new Map(e.map(e=>[e.id,e]));return l.map(e=>({...t.get(e.id),...e}))})},[l,d]);let m=(0,J.useMemo)(()=>e.edges.map(e=>{let n=F(e.from,e.to);return{id:n,source:e.from,target:e.to,selected:t===n,markerEnd:{type:_.ArrowClosed,width:16,height:16},style:{stroke:`var(--color-sapphire)`,strokeWidth:1.7}}}),[e.edges,t]),h=e=>{e.source&&e.target&&a(e.source,e.target)},g=t=>e.members.find(e=>e.key===t);return(0,Y.jsx)(`div`,{className:`h-full min-h-[420px] w-full bg-ivory`,children:(0,Y.jsxs)(y,{nodes:u,edges:m,nodeTypes:Q,onConnect:h,onNodesChange:f,onNodeClick:(e,t)=>i(t.id),onNodeDoubleClick:(e,t)=>{let n=g(t.id);n&&c(n)},onEdgeClick:(e,t)=>i(t.id),onPaneClick:()=>i(null),onEdgesDelete:e=>{for(let t of e)o(t.source,t.target)},onNodeDragStop:(e,t)=>{g(t.id)&&s(t.id,t.position)},minZoom:.35,maxZoom:1.8,edgesReconnectable:!1,fitView:!0,fitViewOptions:{padding:.22,maxZoom:1},proOptions:{hideAttribution:!0},className:`policy-flow`,children:[(0,Y.jsx)(S,{variant:v.Dots,gap:20,size:1.2,color:`var(--color-fawn)`}),(0,Y.jsx)(b,{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`}),(0,Y.jsx)(p,{pannable:!0,zoomable:!0,position:`bottom-right`,className:`!hidden !rounded-md !border !border-frost !bg-snow sm:!block`,nodeColor:e=>e.type===`outside`?`var(--color-rose-baziu)`:`var(--color-sapphire)`,maskColor:`color-mix(in srgb, var(--color-cream) 70%, transparent)`})]})})}var ne={open:`Every member can message every other member, with no connections needed; connections only matter for messages to and from other Teams, or if the Team is set to Connections only.`,restricted:`Members message each other only along connections.`};function re({template:e,profiles:t,onSaved:r,onDirtyChange:i}){let[o,s]=(0,J.useState)(()=>R(e)),[u,d]=(0,J.useState)(o),[f,p]=(0,J.useState)(`flow`),[h,g]=(0,J.useState)(null),[_,v]=(0,J.useState)(!1),[y,b]=(0,J.useState)(null),[x,S]=(0,J.useState)(!1),C=!L(o,u);(0,J.useEffect)(()=>i?.(C),[C,i]);let w=(0,J.useMemo)(()=>new Set(u.members.filter(e=>!t.some(t=>t.id===e.profileId)).map(e=>e.key)),[u.members,t]),T=(0,J.useMemo)(()=>Object.fromEntries(t.map(e=>[e.id,`${e.name||e.id} template`])),[t]),[E,O]=(0,J.useState)(null),k=(e,t,n)=>{if(z(u,e,t,n)){O({from:e,to:t});return}d(r=>H(r,e,t,n))},N=async()=>{v(!0),b(null);try{let i=R(await n(`/api/team-templates/${encodeURIComponent(e.id)}`,{method:`PUT`,body:ee(u,t)}));s(i),d(i),g(null),b({text:`Saved.`,ok:!0}),await r?.()}catch(e){b({text:a(e),ok:!1})}finally{v(!1)}};return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(c,{when:C,subject:`Team template draft`}),(0,Y.jsxs)(`section`,{className:`min-w-0 overflow-hidden rounded-2xl border border-border bg-card shadow-baziu-sm`,"aria-label":`Roster and connections`,children:[(0,Y.jsxs)(`header`,{className:`flex flex-wrap items-end gap-x-3 gap-y-3 border-b border-border px-4 py-4 sm:px-5`,children:[(0,Y.jsx)(`div`,{className:`min-w-0 flex-1 basis-60`,children:(0,Y.jsx)(D,{label:`Name`,value:u.name,disabled:_,required:!0,className:`max-w-none`,problem:u.name.trim()?void 0:`A template needs a name.`,onChange:e=>d(t=>({...t,name:e}))})}),(0,Y.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-semibold text-foreground`,children:`Messaging`}),(0,Y.jsx)(W,{label:`Messaging`,value:u.mode,onChange:e=>d(t=>({...t,mode:e})),options:[{id:`open`,label:M.open},{id:`restricted`,label:M.restricted}]})]}),(0,Y.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-semibold text-foreground`,children:`View`}),(0,Y.jsx)(W,{label:`View`,value:f,onChange:p,options:[{id:`flow`,label:`Flow`},{id:`matrix`,label:`Matrix`}]})]}),(0,Y.jsx)(`p`,{className:`m-0 basis-full text-sm text-muted-foreground`,children:ne[u.mode]})]}),(0,Y.jsxs)(`div`,{className:`grid min-h-[620px] grid-cols-1 lg:grid-cols-[minmax(0,1fr)_280px]`,children:[(0,Y.jsx)(`div`,{className:`min-h-[480px] overflow-hidden`,children:f===`flow`?(0,Y.jsx)($,{document:u,templateNames:T,selectedId:h,incompleteKeys:w,onSelect:g,onConnect:(e,t)=>k(e,t,!0),onRemoveEdge:(e,t)=>k(e,t,!1),onMoveMember:(e,t)=>d(n=>({...n,members:n.members.map(n=>n.key===e?{...n,position:t}:n)})),onOpenMember:e=>g(e.key)}):(0,Y.jsx)(m,{document:u,selectedId:h,onSelect:g,onToggle:k})}),(0,Y.jsx)(`aside`,{className:`border-t border-border p-4 lg:border-l lg:border-t-0`,children:(0,Y.jsx)(ie,{document:u,selectedId:h,profiles:t,onDraft:d,onSelect:g,onToggle:k})})]}),(0,Y.jsxs)(`footer`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 border-t border-border px-4 py-4 sm:px-5`,children:[(0,Y.jsx)(l,{variant:`primary`,disabled:!C||_||!u.name.trim(),onClick:()=>void N(),children:_?`Saving…`:`Save`}),C&&(0,Y.jsx)(l,{variant:`ghost`,disabled:_,onClick:()=>S(!0),children:`Discard changes`}),(0,Y.jsx)(`p`,{role:`status`,className:`m-0 min-w-0 flex-1 basis-56 text-sm font-medium ${y&&!y.ok||C?`text-warning`:y?`text-success`:`text-muted-foreground`}`,children:y&&!y.ok?`Nothing was saved: ${y.text}`:C?`Not saved yet.`:y?`Saved. Teams spawned from now on get this roster.`:`Teams already spawned keep their own Agents and connections.`})]})]}),(0,Y.jsx)(U,{open:E!==null,title:A.title,description:(0,Y.jsx)(`p`,{children:A.description}),confirmLabel:A.confirm,onConfirm:()=>{E&&d(e=>j(e,E.from,E.to)),O(null)},onOpenChange:e=>{e||O(null)}}),(0,Y.jsx)(U,{open:x,title:`Discard your changes to this template?`,description:(0,Y.jsx)(`p`,{children:`The saved roster and connections stay as they are.`}),confirmLabel:`Discard changes`,onConfirm:()=>{d(o),g(null),b(null)},onOpenChange:S})]})}function ie({document:e,selectedId:t,profiles:n,onDraft:r,onSelect:i,onToggle:a}){let o=[...e.members.map(e=>e.key),B],s=e.edges.find(e=>F(e.from,e.to)===t),c=t&&o.includes(t)?t:null,u=e.members.find(e=>e.key===c),f=e=>r(t=>({...t,members:t.members.map(t=>t.key===u?.key?{...t,...e}:t)}));if(s)return(0,Y.jsxs)(`div`,{className:`grid gap-3`,children:[(0,Y.jsx)(`h3`,{className:`m-0 font-body text-sm font-semibold text-foreground`,children:`Connection`}),(0,Y.jsxs)(`p`,{className:`m-0 text-sm`,children:[I(e,s.from),` may message `,I(e,s.to),`.`]}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(l,{variant:`danger`,onClick:()=>{a(s.from,s.to,!1),i(null)},children:`Remove connection`})})]});if(!c)return(0,Y.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Y.jsxs)(`div`,{className:`grid gap-1`,children:[(0,Y.jsxs)(`h3`,{className:`m-0 font-body text-sm font-semibold text-foreground`,children:[e.members.length===1?`1 Agent`:`${e.members.length} Agents`,` ·`,` `,e.edges.length===1?`1 connection`:`${e.edges.length} connections`]}),(0,Y.jsx)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:`Select an Agent to choose who it may message, or drag from one Agent's dot to another. A message to another Team needs a connection to Other teams here, and one from Other teams in that Team.`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{htmlFor:`team-template-user-md`,className:`m-0 text-sm font-semibold text-foreground`,children:`USER.md`}),(0,Y.jsx)(`textarea`,{id:`team-template-user-md`,rows:6,value:e.userMd??``,onChange:e=>{let t=e.target.value;r(e=>({...e,userMd:t||null}))},className:`mt-1.5 font-mono text-[0.85em]`}),(0,Y.jsx)(`span`,{className:`mt-1 block text-xs text-muted-foreground`,children:`What every Agent of a Team spawned from it knows about you.`})]}),(0,Y.jsx)(`div`,{children:(0,Y.jsxs)(l,{variant:`ghost`,onClick:()=>r(e=>({...e,members:[...e.members,{key:`draft:${crypto.randomUUID()}`,profileId:n[0]?.id??``,name:`Agent ${e.members.length+1}`,position:P(e.members.length)}]})),children:[(0,Y.jsx)(w,{className:`size-4`,"aria-hidden":`true`}),` Add an Agent`]})})]});let p=u&&n.some(e=>e.id===u.profileId);return(0,Y.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Y.jsx)(`h3`,{className:`m-0 font-body text-sm font-semibold text-foreground`,children:u?u.name||`Agent`:`Other teams`}),u&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(D,{label:`Name`,value:u.name,className:`max-w-none`,onChange:e=>f({name:e})}),(0,Y.jsx)(O,{label:`Template`,value:u.profileId,className:`max-w-none`,options:[...p?[]:[{value:u.profileId,label:u.profileId||`Choose a template`}],...n.map(e=>({value:e.id,label:e.name||e.id}))],onChange:e=>f({profileId:e})}),!p&&(0,Y.jsx)(d,{tone:`warning`,children:`Choose a template: an Agent cannot be spawned without one.`})]}),(0,Y.jsxs)(`fieldset`,{className:`m-0 grid min-w-0 gap-3 border-0 p-0`,children:[(0,Y.jsx)(`legend`,{className:`mb-2 p-0 text-sm font-semibold text-foreground`,children:`May message`}),o.filter(e=>e!==c).map(t=>(0,Y.jsx)(E,{label:I(e,t),checked:N(e,c,t),onChange:e=>a(c,t,e)},t))]}),u&&(0,Y.jsx)(`div`,{children:(0,Y.jsx)(l,{variant:`danger`,onClick:()=>{r(e=>({...e,members:e.members.filter(e=>e.key!==u.key),edges:e.edges.filter(e=>e.from!==u.key&&e.to!==u.key)})),i(null)},children:`Remove this Agent`})})]})}function ae(){let{template:e,profiles:t,teams:i}=k.useLoaderData(),a=s(),o=r(),[c,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)(!1),[m,h]=(0,J.useState)(!1);return(0,Y.jsxs)(G,{title:e.name,description:`A roster of ${V(e.slots.length,`Agent`)} and ${V(e.edges.length,`connection`)}. Using it adds them to a new Team or one that exists; Teams made from it earlier keep their own.`,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(l,{variant:`primary`,disabled:e.slots.length===0||m,"aria-describedby":m?`spawn-needs-save`:void 0,onClick:()=>d(!0),children:`Use this template`}),(0,Y.jsx)(u,{label:`More for ${e.name}`,items:[{label:`Delete template…`,danger:!0,onSelect:()=>p(!0)}]})]}),children:[m&&(0,Y.jsx)(`p`,{id:`spawn-needs-save`,className:`m-0 text-sm font-medium text-warning`,children:`Save the roster to spawn it as it is on screen.`}),(0,Y.jsx)(re,{template:e,profiles:t,onSaved:()=>o.invalidate({sync:!0}),onDirtyChange:h}),c&&(0,Y.jsx)(K,{template:e,teams:i,onClose:()=>d(!1),onSpawned:e=>{d(!1),a({to:`/`,search:{team:e,panel:`team`}})}}),(0,Y.jsx)(U,{open:f,onOpenChange:p,title:`Delete the ${e.name} Team template?`,description:(0,Y.jsx)(`p`,{className:`m-0`,children:`Teams already spawned from it keep their Agents and connections.`}),confirmLabel:`Delete template`,onConfirm:async()=>{await n(`/api/team-templates/${encodeURIComponent(e.id)}`,{method:`DELETE`}),await a({to:`/templates/teams`})}})]})}export{ae as component};
|
|
@@ -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{a as c,d as l,g as u,h as d,o as f,s as p,y as m}from"./parts-C104qEuC.js";import{t as h}from"./key-round-DmSZN0Kq.js";import{t as g}from"./plus-CEKaHPBw.js";import{M as _,a as v}from"./index-
|
|
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{a as c,d as l,g as u,h as d,o as f,s as p,y as m}from"./parts-C104qEuC.js";import{t as h}from"./key-round-DmSZN0Kq.js";import{t as g}from"./plus-CEKaHPBw.js";import{M as _,a as v}from"./index-CVVVmIFC.js";import{t as y}from"./ConfirmDialog-D8f2wI5x.js";import{t as b}from"./ConfigPage-DFmHgEaL.js";var x=o(`monitor-smartphone`,[[`path`,{d:`M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8`,key:`10dyio`}],[`path`,{d:`M10 19v-3.96 3.15`,key:`1irgej`}],[`path`,{d:`M7 19h5`,key:`qswx4l`}],[`rect`,{width:`6`,height:`10`,x:`16`,y:`12`,rx:`2`,key:`1egngj`}]]),S=e(t(),1);function C(e){let t=e.label.trim(),n=e.days.trim(),r={};n!==``&&(!/^\d+$/.test(n)||Number(n)<1)&&(r.days=`A whole number of days, 1 or more. Empty means it never expires.`);let i=t===``&&n!==``?`A token needs a label to tell it from the others.`:null;return t===``||r.days?{problems:r,missing:i,body:null}:{problems:r,missing:i,body:{label:t,...n?{expiresInDays:Number(n)}:{}}}}function w(e,t){return e.revokedAt?{label:`Revoked`,tone:`neutral`}:e.expiresAt!==null&&e.expiresAt<=t?{label:`Expired`,tone:`neutral`}:{label:`Active`,tone:`success`}}function T(e){return new Date(e).toISOString().slice(0,16).replace(`T`,` `)}var E=i();function D({onMinted:e}){let[t,r]=(0,S.useState)({label:``,days:``}),[i,o]=(0,S.useState)(null),[l,d]=(0,S.useState)(!1),[f,p]=(0,S.useState)(null),h=C(t),v=e=>{p(null),r(t=>({...t,...e}))};async function y(t){if(t.preventDefault(),!(!h.body||l)){d(!0),p(null);try{let{token:t}=await n(`/api/tokens`,{body:h.body});o(t),r({label:``,days:``}),await e()}catch(e){p(a(e))}finally{d(!1)}}}return(0,E.jsx)(m,{labelledBy:`access-mint`,icon:(0,E.jsx)(g,{className:`size-5`}),title:`Mint a new token`,description:`One for each other device or script, so that each can be revoked on its own.`,children:(0,E.jsxs)(c,{onSubmit:y,children:[(0,E.jsxs)(`div`,{className:`grid items-start gap-x-3 gap-y-4 sm:grid-cols-[minmax(0,18rem)_minmax(0,11rem)]`,children:[(0,E.jsx)(_,{label:`Label`,value:t.label,disabled:l,placeholder:`e.g. laptop-tailscale`,onChange:e=>v({label:e})}),(0,E.jsx)(_,{label:`Expires in days`,value:t.days,disabled:l,placeholder:`never`,inputMode:`numeric`,problem:h.problems.days,onChange:e=>v({days:e})})]}),(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,E.jsx)(s,{variant:`primary`,type:`submit`,disabled:l||!h.body,children:l?`Creating…`:`Create`}),f?(0,E.jsxs)(`p`,{role:`alert`,className:`m-0 min-w-0 flex-1 basis-56 text-sm font-medium text-warning`,children:[`Nothing was created: `,f]}):h.missing&&(0,E.jsx)(`p`,{role:`status`,className:`m-0 min-w-0 flex-1 basis-56 text-sm font-medium text-warning`,children:h.missing})]}),i&&(0,E.jsx)(u,{tone:`warning`,title:`Copy this token now; it cannot be shown again.`,children:(0,E.jsx)(`code`,{className:`mt-1 block break-all bg-transparent p-0 text-[0.85em] text-foreground`,children:i})})]})})}function O({tokens:e,sessions:t,includeRevoked:r,now:i,onRevoked:a}){let[o,c]=(0,S.useState)(null),u=e=>t.some(t=>t.current&&t.tokenId===e?.id);return(0,E.jsxs)(m,{labelledBy:`access-tokens`,icon:(0,E.jsx)(h,{className:`size-5`}),title:`Tokens`,description:`Each signs in to the HTTP API, the CLI and the web UI, with full access.`,action:(0,E.jsx)(`a`,{className:`ghost-btn`,href:r?`/config/access`:`/config/access?all=1`,children:r?`Hide revoked`:`Show revoked`}),children:[e.length===0?(0,E.jsx)(p,{className:`py-4 text-sm text-muted-foreground`,children:`No tokens yet; mint one above.`}):(0,E.jsx)(f,{children:e.map(e=>{let t=e.kind===`bootstrap`,n=w(e,i);return(0,E.jsx)(d,{title:e.label,chip:(0,E.jsx)(l,{tone:n.tone,children:n.label}),meta:(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`span`,{children:t?`bootstrap (auth.json)`:e.kind}),(0,E.jsxs)(`span`,{children:[`created `,T(e.createdAt)]}),(0,E.jsxs)(`span`,{children:[`last used `,e.lastUsedAt?T(e.lastUsedAt):`never`]}),(0,E.jsxs)(`span`,{children:[`expires `,e.expiresAt?T(e.expiresAt):`never`]}),(0,E.jsx)(`code`,{children:e.id})]}),actions:!e.revokedAt&&!t&&(0,E.jsx)(s,{variant:`danger`,"aria-label":`Revoke ${e.label}`,onClick:()=>c(e),children:`Revoke`})},e.id)})}),(0,E.jsx)(y,{open:o!==null,onOpenChange:e=>{e||c(null)},title:`Revoke ${o?.label??``}?`,description:(0,E.jsxs)(`p`,{className:`m-0`,children:[`This permanently revokes token `,(0,E.jsx)(`code`,{children:o?.id}),` and ends every browser session opened with it.`,u(o)&&` This includes the session you are using now.`]}),confirmLabel:`Revoke token and sessions`,onConfirm:async()=>{o&&(await n(`/api/tokens/${encodeURIComponent(o.id)}`,{method:`DELETE`}),await a(u(o)))}})]})}function k({sessions:e,onRevoked:t}){let[r,i]=(0,S.useState)(null);return(0,E.jsxs)(m,{labelledBy:`access-sessions`,icon:(0,E.jsx)(x,{className:`size-5`}),title:`Browser sessions`,description:`A session ends after 30 days without use. Revoking a token also ends every session opened with it.`,children:[e.length===0?(0,E.jsx)(p,{className:`py-4 text-sm text-muted-foreground`,children:`No active browser sessions.`}):(0,E.jsx)(f,{children:e.map(e=>(0,E.jsx)(d,{title:e.tokenLabel,chip:e.current&&(0,E.jsx)(l,{tone:`success`,children:`This browser`}),meta:(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`span`,{children:[`last seen `,T(e.lastSeenAt)]}),(0,E.jsxs)(`span`,{children:[`expires `,T(e.expiresAt)]}),(0,E.jsx)(`code`,{children:e.id})]}),actions:(0,E.jsx)(s,{variant:`danger`,"aria-label":e.current?`Revoke the session of this browser`:`Revoke the ${e.tokenLabel} session last seen ${T(e.lastSeenAt)}`,onClick:()=>i(e),children:`Revoke`})},e.id))}),(0,E.jsx)(y,{open:r!==null,onOpenChange:e=>{e||i(null)},title:`Revoke the ${r?.tokenLabel??``} browser session?`,description:(0,E.jsxs)(`p`,{className:`m-0`,children:[`This ends browser session `,(0,E.jsx)(`code`,{children:r?.id}),r?.current?` and signs this browser out.`:`. The token stays active for later logins.`]}),confirmLabel:r?.current?`Sign out this browser`:`Revoke session`,onConfirm:async()=>{r&&(await n(`/api/sessions/${encodeURIComponent(r.id)}`,{method:`DELETE`}),await t(r.current))}})]})}function A(){let{tokens:e,sessions:t,now:n}=v.useLoaderData(),i=v.useSearch().all===1,a=r();async function o(e){e?window.location.assign(`/login`):await a.invalidate({sync:!0})}return(0,E.jsxs)(b,{title:`Access`,description:(0,E.jsxs)(E.Fragment,{children:[`Every token has full access to the HTTP API, the CLI and browser login. The`,` `,(0,E.jsx)(`code`,{children:`bootstrap`}),` token from `,(0,E.jsx)(`code`,{children:`~/.bazilion/auth.json`}),` cannot be revoked; mint a separate, revocable token for each other device.`]}),children:[(0,E.jsx)(D,{onMinted:()=>a.invalidate({sync:!0})}),(0,E.jsx)(O,{tokens:e,sessions:t,includeRevoked:i,now:n,onRevoked:o}),(0,E.jsx)(k,{sessions:t,onRevoked:o})]})}export{A as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,Z as t,a as n,d as r,h 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{_ as s,d as c,h as l,i as u,o as d,y as f}from"./parts-C104qEuC.js";import{t as p}from"./file-text-D6OTHixJ.js";import{r as m,x as h}from"./index-
|
|
1
|
+
import{$ as e,Z as t,a as n,d as r,h 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{_ as s,d as c,h as l,i as u,o as d,y as f}from"./parts-C104qEuC.js";import{t as p}from"./file-text-D6OTHixJ.js";import{r as m,x as h}from"./index-CVVVmIFC.js";import{E as g,T as _,d as v,s as y,w as b,y as x}from"./manage-Dwe9yQl9.js";import{t as S}from"./ConfirmDialog-D8f2wI5x.js";import{t as C}from"./ManagePage-BzyMHGqs.js";import{t as w}from"./AgentTemplateParts-BaeuW_3n.js";var T=e(t()),E=i();function D(){let{templates:e,teamTemplates:t,chat:i,skills:D,starter:O,teams:k}=m.useLoaderData(),A=m.useSearch(),j=a(),M=r(),[N,P]=(0,T.useState)(A.new===1),[F,I]=(0,T.useState)(null),[L,R]=(0,T.useState)(null);return(0,E.jsxs)(C,{title:`Agent templates`,description:`What a new Agent starts with: its files, its model and its skills. Agents already spawned keep their own copies.`,actions:(0,E.jsx)(o,{variant:`primary`,onClick:()=>P(!0),children:`New Agent template`}),children:[(0,E.jsx)(f,{labelledBy:`manage-agent-templates`,icon:(0,E.jsx)(p,{className:`size-5`}),title:`Agent templates`,description:`Open one to edit its files, model and skills.`,action:(0,E.jsx)(c,{tone:`neutral`,children:y(e.length,`template`)}),children:e.length===0?(0,E.jsx)(u,{icon:(0,E.jsx)(p,{className:`size-5`}),title:`No Agent templates yet`,action:(0,E.jsx)(o,{variant:`primary`,onClick:()=>P(!0),children:`New Agent template`}),children:`Every Agent is spawned from a template.`}):(0,E.jsx)(d,{children:e.map(e=>{let n=v(e.defaultModel,i),r=b(e,t),a=`/templates/agents/${encodeURIComponent(e.id)}`;return(0,E.jsx)(l,{inline:!0,title:(0,E.jsx)(`a`,{href:a,className:`text-foreground hover:text-primary`,children:_(e)}),chip:n.missing&&(0,E.jsx)(c,{tone:`warning`,children:`Model not in Chat`}),meta:(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`span`,{className:n.missing?`font-semibold text-warning`:``,children:n.name}),(0,E.jsx)(`span`,{children:x(e)}),(0,E.jsx)(`span`,{children:g(e,t)}),(0,E.jsx)(`code`,{children:e.id})]}),actions:(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(o,{variant:`ghost`,"aria-label":`Add an Agent from ${_(e)}`,onClick:()=>I(e.id),children:`Add an Agent`}),(0,E.jsx)(s,{label:`More for ${_(e)}`,items:[{label:`Edit files and settings`,onSelect:()=>{window.location.assign(a)}},{label:`Delete…`,danger:!0,disabledReason:r,onSelect:()=>R(e)}]})]})},e.id)})})}),N&&(0,E.jsx)(w,{chat:i,skills:D,starter:O,onClose:()=>{P(!1),A.new&&j({to:`/templates/agents`,search:{},replace:!0})}}),F&&(0,E.jsx)(h,{profiles:e,teams:k,profileId:F,onClose:()=>I(null)}),(0,E.jsx)(S,{open:L!==null,onOpenChange:e=>{e||R(null)},title:`Delete the ${L?_(L):``} template?`,description:(0,E.jsx)(`p`,{className:`m-0`,children:`This deletes the template and its files. No Agent and no Team template uses it.`}),confirmLabel:`Delete template`,onConfirm:async()=>{L&&(await n(`/api/profiles/${encodeURIComponent(L.id)}`,{method:`DELETE`}),await M.invalidate({sync:!0}))}})]})}export{D as component};
|
|
@@ -1 +1 @@
|
|
|
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-C104qEuC.js";import{t as v}from"./bot-BHky7KAX.js";import{K as y,O as b,St as x,X as S,q as C,u as w,x as T}from"./index-
|
|
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-C104qEuC.js";import{t as v}from"./bot-BHky7KAX.js";import{K as y,O as b,St as x,X as S,q as C,u as w,x as T}from"./index-CVVVmIFC.js";import{O as te,T as ne,c as re,n as E,r as D,s as O}from"./manage-Dwe9yQl9.js";import{t as k}from"./ConfirmDialog-D8f2wI5x.js";import{t as A}from"./Segmented-iylzLwE6.js";import{t as j}from"./ManagePage-BzyMHGqs.js";import{i as M,n as N,t as P}from"./agent-actions-B-9KIwn6.js";var F=e(t(),1),I=a();function L({agent:e,teams:t,onClose:r,onMoved:i}){let a=t.filter(t=>t.id!==e.teamId),[c,l]=(0,F.useState)(a[0]?.id??``),[u,f]=(0,F.useState)(!1),[p,m]=(0,F.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,I.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,I.jsxs)(`form`,{onSubmit:e=>void g(e),className:`grid gap-4`,children:[(0,I.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,I.jsx)(d,{tone:`warning`,role:`alert`,title:`It was not moved.`,children:p}),(0,I.jsxs)(C,{children:[(0,I.jsx)(s,{variant:`ghost`,disabled:u,onClick:r,children:`Cancel`}),(0,I.jsx)(s,{variant:`primary`,type:`submit`,disabled:u||!c,children:u?`Moving…`:`Move to ${t.find(e=>e.id===c)?.name??`Team`}`})]})]})})}function R({agents:e,teams:t,templates:n,chat:i,onSpawn:a,onChanged:y}){let[b,C]=(0,F.useState)(``),[w,T]=(0,F.useState)(`current`),[j,R]=(0,F.useState)(null),[z,B]=(0,F.useState)(null),[V,H]=(0,F.useState)(null),[U,W]=(0,F.useState)(null),[G,K]=(0,F.useState)(null),q=E(e),J=(0,F.useRef)(null),[Y,X]=(0,F.useState)(!1);(0,F.useEffect)(()=>{!Y||j!==null||(J.current?.focus(),X(!1))},[Y,j]);let Z=re(e,t,w,b);async function Q(e,t){R(e.id),B(null);try{await t(),await y()}catch(e){B(o(e))}finally{R(null)}}let ae=e=>Q(e,async()=>{await P(e.id),H(e),X(!0)}),$=e=>Q(e,async()=>{await M(e.id),H(null)});return(0,I.jsxs)(ee,{labelledBy:`manage-agents`,icon:(0,I.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,I.jsxs)(l,{children:[(0,I.jsx)(_,{label:`Find an Agent`,placeholder:`Find by name, creature or vibe`,value:b,onChange:C,className:`min-w-0 flex-1 basis-60`}),(0,I.jsx)(A,{label:`Which Agents`,value:w,onChange:T,options:[{id:`current`,label:`Current ${q.current}`},{id:`archived`,label:`Archived ${q.archived}`},{id:`all`,label:`All`}]})]}),V&&(0,I.jsx)(g,{className:`py-3`,children:(0,I.jsxs)(d,{tone:`neutral`,actions:(0,I.jsxs)(s,{ref:J,variant:`ghost`,disabled:j!==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,I.jsx)(g,{className:`py-3`,children:(0,I.jsx)(d,{tone:`warning`,role:`alert`,title:`That did not work.`,children:z})}),e.length===0?(0,I.jsx)(p,{icon:(0,I.jsx)(v,{className:`size-5`}),title:`No Agents yet`,action:(0,I.jsx)(s,{variant:`primary`,disabled:n.length===0||t.length===0,onClick:a,children:`Add 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,I.jsx)(p,{title:b.trim()?`No Agent matches “${b.trim()}”`:ie(w),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,I.jsxs)(`section`,{"aria-label":e.name,children:[(0,I.jsx)(m,{title:e.name,meta:`${O(a.length,`Agent`)} · ${te[e.policyMode].toLowerCase()}`,action:(0,I.jsx)(r,{to:`/`,search:{team:e.id,panel:`team`},children:`Go to the Team`})}),(0,I.jsx)(h,{children:a.map(e=>{let a=n.find(t=>t.id===e.profileId),o=D(e,n,i),l=e.status===`archived`,d=[e.identity?.creature,e.identity?.vibe].filter(Boolean).join(` · `);return(0,I.jsx)(f,{inline:!0,leading:(0,I.jsx)(S,{identity:e.identity,size:32}),title:(0,I.jsxs)(r,{to:`/`,search:{agent:e.id},className:`text-foreground hover:text-primary`,children:[e.name,x(e)&&(0,I.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[` `,`· calls itself `,x(e)]})]}),chip:l&&(0,I.jsx)(u,{tone:`neutral`,children:`Archived`}),meta:(0,I.jsxs)(I.Fragment,{children:[d&&(0,I.jsx)(`span`,{children:d}),(0,I.jsxs)(`span`,{children:[a?(0,I.jsx)(`a`,{href:`/templates/agents/${encodeURIComponent(a.id)}`,children:ne(a)}):e.profileId,` `,`template`]}),o&&(0,I.jsxs)(`span`,{className:o.missing?`font-semibold text-warning`:``,children:[o.name,o.missing?`, not in Chat`:o.inherited?``:`, its own`]})]}),actions:(0,I.jsxs)(I.Fragment,{children:[l&&(0,I.jsx)(s,{variant:`ghost`,disabled:j===e.id,onClick:()=>void $(e),children:`Restore`}),(0,I.jsx)(c,{label:`More for ${e.name}`,disabled:j===e.id,items:[t.length>1&&{label:`Move to another Team…`,onSelect:()=>W(e)},!l&&{label:`Archive`,onSelect:()=>void ae(e)},{label:`Delete permanently…`,danger:!0,onSelect:()=>K(e)}]})]})},e.id)})})]},e.id)),U&&(0,I.jsx)(L,{agent:U,teams:t,onClose:()=>W(null),onMoved:async()=>{W(null),await y()}}),(0,I.jsx)(k,{open:G!==null,onOpenChange:e=>{e||K(null)},title:`Delete ${G?.name??`this Agent`} permanently?`,description:(0,I.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 N(G.id),V?.id===G.id&&H(null),await y())}})]})}function ie(e){return e===`archived`?`No archived Agents`:`No current Agents`}function z(){let{agents:e,templates:t,teams:n,chat:r}=w.useLoaderData(),a=i(),[o,c]=(0,F.useState)(!1);return(0,I.jsxs)(j,{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,I.jsx)(s,{variant:`primary`,disabled:t.length===0||n.length===0,onClick:()=>c(!0),children:`Add an Agent`}),children:[(0,I.jsx)(R,{agents:e,teams:n,templates:t,chat:r,onSpawn:()=>c(!0),onChanged:()=>a.invalidate({sync:!0})}),o&&(0,I.jsx)(T,{profiles:t,teams:n,onClose:()=>c(!1)})]})}export{z as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,Z as t,a as n,c as r,h as i,r as ee,s as te}from"./createLucideIcon-CZHSSDYA.js";import{a}from"./preload-helper-CZOd_z6l.js";import{t as o}from"./Button-CoKQRO-s.js";import{H as s,U as c,c as l,d as u,g as d,h as f,i as p,o as ne,r as re,t as m,y as h}from"./parts-C104qEuC.js";import{Ft as g,I as _,d as v,w as y}from"./index-
|
|
1
|
+
import{$ as e,Z as t,a as n,c as r,h as i,r as ee,s as te}from"./createLucideIcon-CZHSSDYA.js";import{a}from"./preload-helper-CZOd_z6l.js";import{t as o}from"./Button-CoKQRO-s.js";import{H as s,U as c,c as l,d as u,g as d,h as f,i as p,o as ne,r as re,t as m,y as h}from"./parts-C104qEuC.js";import{Ft as g,I as _,d as v,w as y}from"./index-CVVVmIFC.js";import{a as b,m as x,o as S,t as C}from"./manage-Dwe9yQl9.js";import{t as ie}from"./use-resource-qjIkNQDY.js";import{t as ae}from"./Segmented-iylzLwE6.js";var w=e(t()),T=i(),E=`/api/attention?state=all&limit=200`,D=`/api/attention/summary`,O=5e3,k=3e4;function A(e){switch(e.kind){case`agent_question`:return`Answer`;case`command_approval`:return`Decide`;case`lesson_proposal`:return`Review lesson`;default:return`Open`}}var j=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});function M(){let e=v.useLoaderData(),[t,i]=(0,w.useState)(e.list),[M,N]=(0,w.useState)(e.summary),[P,F]=(0,w.useState)(e.now),[I,L]=(0,w.useState)(`open`),[R,z]=(0,w.useState)(`all`),[B,oe]=(0,w.useState)(`all`),[V,H]=(0,w.useState)(null),[U,W]=(0,w.useState)(null),G=a(),K=ee(),q=(0,w.useRef)(null),se=ie(),J=t.items.filter(e=>(I===`all`||(I===`open`?e.acknowledgedAt===null:e.acknowledgedAt!==null))&&(R===`all`||e.kind===R)&&(B===`all`||e.severity===B)),ce=t.items.filter(e=>e.acknowledgedAt===null).length,Y=t.items.filter(e=>e.acknowledgeable&&e.acknowledgedAt===null).length,X=[...new Set([...t.degraded,...M.degraded].map(e=>e.kind))],Z=S(M);async function Q(){let[e,t]=await Promise.all([n(E),n(D)]);i(e),N(t),F(Date.now())}(0,w.useEffect)(()=>K.subscribe(`attention`,e=>{let t=q.current!==e.revision;q.current=e.revision,t&&Q().catch(()=>{})}),[K.subscribe]),(0,w.useEffect)(()=>{let e=setInterval(()=>F(Date.now()),k);return()=>clearInterval(e)},[]),(0,w.useEffect)(()=>{if(V!==null||K.connected)return;let e=setInterval(()=>{document.visibilityState===`visible`&&Q().catch(()=>{})},O);return()=>clearInterval(e)},[V,K.connected]);async function $(e,t){H(e),W(null);try{let e=await t();e&&W({text:e,failed:!1})}catch(e){W({text:te(e),failed:!0})}finally{await Q().catch(()=>{}),G.refresh(),H(null)}}let le=(e,t)=>$(e.key,async()=>{let r=`/api/attention/${encodeURIComponent(e.key)}`;return await n(t?`${r}/acknowledge`:`${r}/acknowledgement`,{method:t?`POST`:`DELETE`}),null}),ue=()=>$(`all`,async()=>{let{acknowledged:e}=await n(`/api/attention/acknowledge-all`,{method:`POST`});return`Acknowledged ${e===1?`1 item`:`${e} items`}. Lesson proposals and paused queues stay open until they are dealt with.`});return(0,T.jsxs)(c,{children:[(0,T.jsx)(s,{title:`Attention`,description:`Decisions waiting for you and failures worth a look, from every Agent. Act on an item where it comes from; acknowledge the ones that only inform.`}),(0,T.jsx)(m,{tone:Z.tone,lead:Z.lead,children:Z.rest}),X.length>0&&(0,T.jsxs)(m,{tone:`warning`,role:`alert`,lead:`Some items could not be loaded.`,children:[X.map(e=>C[e]).join(`, `),` are missing from the list.`]}),(0,T.jsxs)(h,{labelledBy:`attention-items`,icon:(0,T.jsx)(g,{className:`size-5`}),title:`Items`,description:`Open items need you; history keeps the ones you acknowledged.`,action:Y>0&&(0,T.jsxs)(o,{variant:`ghost`,disabled:V!==null,onClick:()=>void ue(),children:[`Acknowledge `,Y===1?`the informational one`:`informational ones`]}),children:[(0,T.jsxs)(l,{children:[(0,T.jsx)(ae,{label:`Which items`,value:I,onChange:L,options:[{id:`open`,label:`Open ${ce}`},{id:`acknowledged`,label:`History`},{id:`all`,label:`All`}]}),(0,T.jsx)(y,{label:`Kind`,value:R,onChange:z,options:[{value:`all`,label:`All kinds`},...Object.entries(C).map(([e,t])=>({value:e,label:t}))]}),(0,T.jsx)(y,{label:`Severity`,value:B,onChange:oe,options:[{value:`all`,label:`Any severity`},{value:`action_required`,label:`Waiting for you`},{value:`error`,label:`Errors`},{value:`warning`,label:`Warnings`}]})]}),U&&(0,T.jsx)(re,{className:`py-3`,children:(0,T.jsx)(d,{tone:U.failed?`warning`:`success`,role:U.failed?`alert`:`status`,children:U.text})}),J.length===0?(0,T.jsx)(p,{icon:(0,T.jsx)(g,{className:`size-5`}),title:I===`open`&&R===`all`&&B===`all`?`Nothing needs you`:`No item matches`,children:`Items come from Agents' questions and commands to approve, learning reviews, schedules, follow-up queues and message loops.`}):(0,T.jsx)(ne,{children:J.map(e=>{let t=x(e.severity),n=e.acknowledgedAt!==null;return(0,T.jsx)(f,{title:e.title,chip:n?(0,T.jsx)(u,{tone:`neutral`,children:`Acknowledged`}):(0,T.jsx)(u,{tone:t.tone,children:t.label}),meta:(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`span`,{children:C[e.kind]}),(0,T.jsx)(`span`,{children:b(e)}),e.expiresAt!==void 0&&se&&(0,T.jsxs)(`span`,{className:`text-warning`,children:[`Waits until `,j(e.expiresAt)]}),(0,T.jsx)(`time`,{dateTime:new Date(e.occurredAt).toISOString(),title:new Date(e.occurredAt).toISOString().slice(0,16).replace(`T`,` `),children:_(e.occurredAt,P)})]}),actions:(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(r,{to:e.href,className:`ghost-btn no-underline`,children:A(e)}),e.acknowledgeable&&(0,T.jsx)(o,{variant:`ghost`,disabled:V!==null,onClick:()=>void le(e,!n),children:n?`Back to open`:`Acknowledge`})]}),children:(0,T.jsx)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:e.diagnostic})},e.key)})})]})]})}export{M as component};
|