bazilion 0.19.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +272 -129
- package/dist/cli.js.map +1 -1
- package/dist/daemon.js +1689 -709
- package/dist/daemon.js.map +1 -1
- package/dist/migrations/0001_init.sql +46 -0
- package/dist/web/client/assets/{ChatPane-DCyGcqdh.js → ChatPane-CGCtAuD3.js} +1 -1
- package/dist/web/client/assets/{ConfirmDialog-C908TxS5.js → ConfirmDialog-Br19uXWH.js} +1 -1
- package/dist/web/client/assets/{FieldRow-CELqI-1V.js → FieldRow-Csy3_cH5.js} +1 -1
- package/dist/web/client/assets/{ProductionTeamPolicyEditor-DnTcWhG8.js → ProductionTeamPolicyEditor-DG1x4Cqz.js} +1 -1
- package/dist/web/client/assets/{ProfileCommunicationEditor-BVIEaW3s.js → ProfileCommunicationEditor-C3odNVkK.js} +1 -1
- package/dist/web/client/assets/{ResultSourceConversation-4gbZCh_s.js → ResultSourceConversation-5PFWqXTY.js} +1 -1
- package/dist/web/client/assets/{TeamTabs-V17b45X5.js → TeamTabs-BHB_COm0.js} +1 -1
- package/dist/web/client/assets/{TemplatesTabs-BMK3Qok_.js → TemplatesTabs-YyytjW7k.js} +1 -1
- package/dist/web/client/assets/{UnsavedChangesGuard-BaE-UzyS.js → UnsavedChangesGuard-CredyC3E.js} +1 -1
- package/dist/web/client/assets/{_id-CArZR-IO.js → _id-BLm9LVlZ.js} +1 -1
- package/dist/web/client/assets/{_id-BU1l9gP7.js → _id-BZ_-4M4s.js} +1 -1
- package/dist/web/client/assets/{_id-Bvh5LyUv.js → _id-CIkPtQY0.js} +1 -1
- package/dist/web/client/assets/{_id-BVANQm00.js → _id-KXX6nuKc.js} +1 -1
- package/dist/web/client/assets/{_id-tUkSe5li.js → _id-nDbQY7f_.js} +1 -1
- package/dist/web/client/assets/{activity-CWCnqjqj.js → activity-BE7jG1Mz.js} +1 -1
- package/dist/web/client/assets/{agents-CdCnhH06.js → agents-S9lzXrrs.js} +1 -1
- package/dist/web/client/assets/{agents-CX4STmGK.js → agents-vOPd-upn.js} +1 -1
- package/dist/web/client/assets/{approvals-CnNpwG78.js → approvals-BUfhlUAX.js} +1 -1
- package/dist/web/client/assets/{attention-CEE-wWrx.js → attention-C3r-2GSp.js} +1 -1
- package/dist/web/client/assets/chevron-right-C7P3Z105.js +1 -0
- package/dist/web/client/assets/{config-CSEtI-dq.js → config-AL_EM57n.js} +1 -1
- package/dist/web/client/assets/{inbox-MYnBtPdF.js → inbox-LlCpJrMH.js} +1 -1
- package/dist/web/client/assets/{index-Ct31TjS-.js → index-CwMw0pnV.js} +2 -2
- package/dist/web/client/assets/{learning-BIR5FTgQ.js → learning-zvTJ_9vM.js} +1 -1
- package/dist/web/client/assets/{login-DIeceuOs.js → login-BpQ54z8Y.js} +1 -1
- package/dist/web/client/assets/{mcp-CX3kJpGu.js → mcp-BD6VzXg_.js} +1 -1
- package/dist/web/client/assets/{members-DlhSjye1.js → members-SEDi8SFo.js} +1 -1
- package/dist/web/client/assets/{memory-CsDd6b2l.js → memory-zi_dPlMA.js} +1 -1
- package/dist/web/client/assets/{policy-DkWDhG0x.js → policy-URjQAAdN.js} +1 -1
- package/dist/web/client/assets/{results-BHdhNHJJ.js → results-Bcuy4Flp.js} +1 -1
- package/dist/web/client/assets/review-CVH7X9-d.js +1 -0
- package/dist/web/client/assets/{routes-DtYD4WJL.js → routes-BJEX6yAE.js} +1 -1
- package/dist/web/client/assets/{services-WUlW7oEo.js → services-BTG4F5FL.js} +1 -1
- package/dist/web/client/assets/{skills-jNoUfUSZ.js → skills-DwiHS7eD.js} +1 -1
- package/dist/web/client/assets/{teams-C1kYRrtP.js → teams-DcROmSGB.js} +1 -1
- package/dist/web/client/assets/{teams-D3FaSKE7.js → teams-DfpwQu1i.js} +1 -1
- package/dist/web/client/assets/{telegram-D86AO6V9.js → telegram-BLyaaUXE.js} +1 -1
- package/dist/web/client/assets/{tokens-B42KDisP.js → tokens-Dp9Vwvfx.js} +1 -1
- package/dist/web/client/assets/{triggers-yEfWnQ_K.js → triggers-CtVhrAGA.js} +1 -1
- package/dist/web/client/assets/verifications-TC0ccGLY.js +2 -0
- package/dist/web/client/assets/{welcome-D8IbF_P0.js → welcome-DML3X1ha.js} +1 -1
- package/dist/web/client/assets/{x-CXKABZ7C.js → x-D8yuCam7.js} +1 -1
- package/dist/web/server/assets/{_id-bVispdh-.js → _id-Bazctexc.js} +1 -1
- package/dist/web/server/assets/{_id-Dab2CVtO2.js → _id-BjvOb4CK2.js} +1 -1
- package/dist/web/server/assets/{_id-DL-SnSnK.js → _id-Bn0w00AG.js} +1 -1
- package/dist/web/server/assets/{_id-D2bDA1iV.js → _id-DFf_uQiI.js} +1 -1
- package/dist/web/server/assets/{_tanstack-start-manifest_v-BcTOb0oj.js → _tanstack-start-manifest_v-BGSoO6CK.js} +79 -79
- package/dist/web/server/assets/{activity-CLDAy6rk.js → activity-j_Enmf3L.js} +1 -1
- package/dist/web/server/assets/{agents-CdB2kuNN.js → agents-BAi0dE66.js} +1 -1
- package/dist/web/server/assets/{agents-DfHcb2H2.js → agents-BHUbTrm7.js} +1 -1
- package/dist/web/server/assets/{approvals-Bq846WaP.js → approvals-BcUm6IOo.js} +1 -1
- package/dist/web/server/assets/{attention-Sm-U7s_0.js → attention-BQBa0Bu5.js} +1 -1
- package/dist/web/server/assets/{auth-PB5dVyvX.js → auth-PDNSxrT-.js} +1 -1
- package/dist/web/server/assets/{config-BNGTBu80.js → config-Cf7hhsUR.js} +1 -1
- package/dist/web/server/assets/{daemon-client-CWQvck6B.js → daemon-client-DY4jE6KU.js} +15 -0
- package/dist/web/server/assets/{git-review-C_h_tezf.js → git-review-RvzReZyD.js} +1 -1
- package/dist/web/server/assets/{inbox-DJoU-bla.js → inbox-Du1guYth.js} +1 -1
- package/dist/web/server/assets/{learning-DVb0I_3Z.js → learning-CjcixPRH.js} +1 -1
- package/dist/web/server/assets/{mcp-CeZqOiDG.js → mcp-BCalFLvt.js} +1 -1
- package/dist/web/server/assets/{members-CcYjuqxB.js → members-C4TpK50B.js} +1 -1
- package/dist/web/server/assets/{memory-CH2yNT89.js → memory-CLZs-XRY.js} +1 -1
- package/dist/web/server/assets/{policy-DrRKinMr.js → policy-BrIXpwxZ.js} +1 -1
- package/dist/web/server/assets/publications-BrX3-WJf.js +57 -0
- package/dist/web/server/assets/{results-fT2zyiJx.js → results-CJR6dNzB.js} +1 -1
- package/dist/web/server/assets/{review-CvUPk4HA.js → review-CRHiZfC8.js} +1 -1
- package/dist/web/server/assets/{review-DYcYdUTv.js → review-Dqdts12v.js} +205 -3
- package/dist/web/server/assets/{review-packets-e36PsTSX.js → review-packets-D3bZ7QYU.js} +1 -1
- package/dist/web/server/assets/{router-NYhuYQCd.js → router-BVhdWkwP.js} +3 -3
- package/dist/web/server/assets/{routes-RdppWPiW.js → routes-DizvfkfZ.js} +1 -1
- package/dist/web/server/assets/{services-Dgu7dcTC.js → services-DDRj180j.js} +1 -1
- package/dist/web/server/assets/{skills-DL7UIWa8.js → skills-Bck9L5oo.js} +1 -1
- package/dist/web/server/assets/{teams-DiC-MBg4.js → teams-CSqR5mWl.js} +1 -1
- package/dist/web/server/assets/{teams-Cmn7mdx9.js → teams-C_PicOsj.js} +1 -1
- package/dist/web/server/assets/{telegram-CLOFnLjF.js → telegram-D0odXx1E.js} +1 -1
- package/dist/web/server/assets/{tokens-BVva7GHu.js → tokens-B2O0Di4p.js} +1 -1
- package/dist/web/server/assets/{triggers-D4orksJq.js → triggers-DtKMYL2r.js} +1 -1
- package/dist/web/server/assets/{verification-C1SHMTX8.js → verification-no5BrOeR.js} +1 -1
- package/dist/web/server/assets/{verifications-Ci49n2Km.js → verifications-CM-Bbgjt.js} +114 -91
- package/dist/web/server/assets/{verifications-C_ycXrPK.js → verifications-DhGe86E1.js} +1 -1
- package/dist/web/server/server.js +56 -48
- package/dist/worker.js +52 -1
- package/dist/worker.js.map +1 -1
- package/package.json +3 -3
- package/dist/web/client/assets/chevron-right-CvCEwfSl.js +0 -1
- package/dist/web/client/assets/review-Dyw47eM1.js +0 -1
- package/dist/web/client/assets/verifications-DrHQEQFx.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./jsx-runtime-DGeXAQPT.js";import{c as t}from"./index-
|
|
1
|
+
import{t as e}from"./jsx-runtime-DGeXAQPT.js";import{c as t}from"./index-CwMw0pnV.js";import{a as n,i as r,r as i,t as a}from"./Page-NV96O47A.js";import{t as o}from"./TeamTabs-BHB_COm0.js";var s=e();function c(){let e=t.useLoaderData(),{id:c}=t.useParams();return(0,s.jsxs)(i,{children:[(0,s.jsx)(`h1`,{children:`Team members`}),(0,s.jsxs)(`p`,{className:`muted`,children:[(0,s.jsx)(`code`,{children:`agents.team_id`}),` is the only live-membership authority.`]}),(0,s.jsx)(o,{teamId:c}),e.members.length===0?(0,s.jsx)(a,{title:`No Team members`,description:`Spawn an Agent into this Team from the Agents page or apply a Team template.`,actions:(0,s.jsx)(`a`,{href:`/agents`,className:`btn-primary no-underline`,children:`Spawn an Agent`})}):(0,s.jsxs)(r,{title:`Live roster`,description:`Every Agent belongs to exactly one Team; source slots show reusable-template lineage only.`,children:[(0,s.jsx)(`div`,{className:`hidden overflow-x-auto rounded-md border border-frost md:block`,children:(0,s.jsxs)(`table`,{className:`w-full`,children:[(0,s.jsx)(`thead`,{children:(0,s.jsxs)(`tr`,{children:[(0,s.jsx)(`th`,{children:`agent`}),(0,s.jsx)(`th`,{children:`status`}),(0,s.jsx)(`th`,{children:`agent template`}),(0,s.jsx)(`th`,{children:`source slot`})]})}),(0,s.jsx)(`tbody`,{children:e.members.map(t=>{let n=e.bindings.find(e=>e.agentId===t.id);return(0,s.jsxs)(`tr`,{children:[(0,s.jsx)(`td`,{children:(0,s.jsx)(`a`,{href:`/agents/${t.id}`,children:t.name})}),(0,s.jsx)(`td`,{children:t.status}),(0,s.jsx)(`td`,{children:t.profileId}),(0,s.jsx)(`td`,{children:(0,s.jsx)(`code`,{children:n?.sourceSlotId??`live-only`})})]},t.id)})})]})}),(0,s.jsx)(`div`,{className:`grid gap-3 md:hidden`,children:e.members.map(t=>{let r=e.bindings.find(e=>e.agentId===t.id);return(0,s.jsxs)(`article`,{className:`min-w-0 rounded-xl border border-border bg-muted/20 p-4`,children:[(0,s.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[(0,s.jsxs)(`div`,{className:`min-w-0`,children:[(0,s.jsx)(`a`,{href:`/agents/${t.id}`,className:`block truncate font-semibold text-foreground`,children:t.name}),(0,s.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-xs text-muted-foreground`,children:t.id})]}),(0,s.jsx)(n,{variant:t.status===`archived`?`warning`:`success`,children:t.status})]}),(0,s.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-xs`,children:[(0,s.jsxs)(`div`,{className:`rounded-lg bg-muted p-2`,children:[(0,s.jsx)(`dt`,{className:`font-semibold text-muted-foreground`,children:`Agent template`}),(0,s.jsx)(`dd`,{className:`mt-0.5 break-all font-mono`,children:t.profileId})]}),(0,s.jsxs)(`div`,{className:`rounded-lg bg-muted p-2`,children:[(0,s.jsx)(`dt`,{className:`font-semibold text-muted-foreground`,children:`Source slot`}),(0,s.jsx)(`dd`,{className:`mt-0.5 break-all font-mono`,children:r?.sourceSlotId??`live-only`})]})]})]},t.id)})})]})]})}export{c as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{t as r}from"./UnsavedChangesGuard-
|
|
1
|
+
import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{t as r}from"./UnsavedChangesGuard-CredyC3E.js";import{t as i}from"./ConfirmDialog-Br19uXWH.js";import{l as a}from"./index-CwMw0pnV.js";import{r as o}from"./Page-NV96O47A.js";import{t as s}from"./Button-ByiV6fpd.js";import{t as c}from"./TeamTabs-BHB_COm0.js";var l=e(n()),u=t();function d(e){return e.split(`/`).map(encodeURIComponent).join(`/`)}function f(){let{team:e,memberCount:t,entries:n}=a.useLoaderData(),f=e.id,[p,m]=(0,l.useState)(()=>n.map(e=>({key:e.key,preview:e.content.slice(0,80)}))),[h,g]=(0,l.useState)(!1),[_,v]=(0,l.useState)(``),[y,b]=(0,l.useState)(null),[x,S]=(0,l.useState)(`none`),[C,w]=(0,l.useState)(``),[T,E]=(0,l.useState)(``),[D,O]=(0,l.useState)(``),[k,A]=(0,l.useState)(``),[j,M]=(0,l.useState)(null),[N,P]=(0,l.useState)(null),F=(0,l.useRef)(null),I=x!==`none`&&(C!==D||T!==k);async function L(e){try{let t=e.trim().length>0?`/api/teams/${encodeURIComponent(f)}/memory/search?q=${encodeURIComponent(e)}&limit=50`:`/api/teams/${encodeURIComponent(f)}/memory`,n=await fetch(t);if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error??n.statusText)}let r=await n.json();e.trim().length>0?(m(r.map(e=>({key:e.key,preview:e.snippet,score:e.score}))),g(!0)):(m(r.map(e=>({key:e.key,preview:e.content.slice(0,80)}))),g(!1))}catch(e){M({msg:`error: ${e.message}`,kind:`error`})}}(0,l.useEffect)(()=>(F.current&&clearTimeout(F.current),F.current=setTimeout(()=>{L(_)},200),()=>{F.current&&clearTimeout(F.current)}),[_]);async function R(e){M({msg:`loading…`,kind:`info`});try{let t=await fetch(`/api/teams/${encodeURIComponent(f)}/memory/${d(e)}`);if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error??t.statusText)}let n=await t.json();b(n.key),S(`edit`),w(n.key),E(n.content??``),O(n.key),A(n.content??``),M({msg:`loaded ${n.key}`,kind:`info`})}catch(e){M({msg:`error: ${e.message}`,kind:`error`})}}function z(e){if(!(x===`edit`&&e===y)){if(!I){R(e);return}P({title:`Discard unsaved memory changes?`,description:(0,u.jsxs)(`p`,{children:[`Opening `,(0,u.jsx)(`code`,{className:`font-mono`,children:e}),` will permanently discard your changes to`,` `,(0,u.jsx)(`code`,{className:`font-mono`,children:y??(C||`this new entry`)}),`.`]}),confirmLabel:`discard and open entry`,onConfirm:()=>R(e)})}}function B(){b(null),S(`new`),w(``),E(``),O(``),A(``),M({msg:`new entry — type a key and content, then save`,kind:`info`})}function V(){if(!I){B();return}P({title:`Discard unsaved memory changes?`,description:(0,u.jsxs)(`p`,{children:[`Starting a new entry will permanently discard your changes to`,` `,(0,u.jsx)(`code`,{className:`font-mono`,children:y??(C||`this new entry`)}),`.`]}),confirmLabel:`discard and create new`,onConfirm:B})}async function H(){let e=C.trim();if(!e){M({msg:`key is required`,kind:`error`});return}try{let t=await fetch(`/api/teams/${encodeURIComponent(f)}/memory/${d(e)}`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({content:T})});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error??t.statusText)}b(e),S(`edit`),w(e),O(e),A(T),M({msg:`saved`,kind:`info`}),await L(_)}catch(e){M({msg:`error: ${e.message}`,kind:`error`})}}async function U(){if(!y)return;let e=y,t=await fetch(`/api/teams/${encodeURIComponent(f)}/memory/${d(e)}`,{method:`DELETE`});if(!t.ok&&t.status!==204){let e=await t.json().catch(()=>null);throw Error(e?.error??t.statusText)}b(null),S(`none`),w(``),E(``),O(``),A(``),M({msg:`${e} deleted`,kind:`info`}),await L(_)}function W(){if(!y)return;let e=y;P({title:`Delete ${e}?`,description:(0,u.jsxs)(`p`,{children:[`This permanently deletes `,(0,u.jsx)(`code`,{className:`font-mono`,children:e}),` from shared Team memory and removes it from search results for every Team member. This cannot be undone.`]}),confirmLabel:`delete memory entry`,onConfirm:U})}let G=x!==`none`&&C.trim().length>0,K=x===`edit`&&y!==null;return(0,u.jsxs)(o,{children:[(0,u.jsx)(r,{when:I,subject:`Team memory draft`}),(0,u.jsxs)(`header`,{className:`mb-6`,children:[(0,u.jsxs)(`h1`,{className:`font-serif text-3xl text-foreground`,children:[e.name,` `,(0,u.jsx)(`span`,{className:`text-muted-foreground text-base`,children:`/ Shared memory`})]}),(0,u.jsxs)(`p`,{className:`text-muted-foreground text-sm mt-1`,children:[`BM25-indexed markdown notes shared by every agent in`,` `,(0,u.jsx)(`a`,{href:`/teams/${encodeURIComponent(e.id)}`,className:`font-mono underline`,children:e.id}),` `,`(`,t,` member`,t===1?``:`s`,`). Anything written here is visible to every member; per-agent notes belong in the agent's own`,` `,(0,u.jsx)(`code`,{className:`font-mono`,children:`IDENTITY.md`}),` via `,(0,u.jsx)(`code`,{children:`home_write`}),`.`]})]}),(0,u.jsx)(c,{teamId:e.id}),(0,u.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-[320px_1fr]`,children:[(0,u.jsxs)(`div`,{children:[(0,u.jsxs)(`div`,{className:`overflow-hidden rounded-[16px] border border-frost bg-snow`,children:[(0,u.jsxs)(`div`,{className:`border-b border-frost p-2`,children:[(0,u.jsx)(`label`,{htmlFor:`team-memory-search`,className:`sr-only`,children:`Search Team memory`}),(0,u.jsx)(`input`,{id:`team-memory-search`,type:`text`,placeholder:`search (BM25)...`,autoComplete:`off`,value:_,onChange:e=>v(e.target.value)})]}),(0,u.jsx)(`div`,{className:`max-h-[520px] overflow-y-auto`,children:p.length===0?(0,u.jsx)(`div`,{className:`p-8 text-center text-mocha-light`,children:`no entries`}):p.map(e=>(0,u.jsxs)(`button`,{type:`button`,onClick:()=>z(e.key),className:`unstyled block w-full cursor-pointer border-b border-frost/50 px-3.5 py-2 text-left font-mono text-[0.84em] transition-colors last:border-b-0 hover:bg-sapphire-glow ${e.key===y?`bg-sapphire-glow font-medium text-sapphire-deep`:``}`,children:[h&&e.score!==void 0&&(0,u.jsx)(`span`,{className:`float-right text-[0.75em] text-sapphire`,children:e.score.toFixed(2)}),e.key,e.preview&&(0,u.jsx)(`span`,{className:`mt-1 block text-[0.9em] font-normal text-mocha-light`,children:e.preview})]},e.key))})]}),(0,u.jsx)(s,{variant:`ghost`,className:`mt-3 w-full`,onClick:V,children:`+ new entry`})]}),(0,u.jsxs)(`div`,{children:[(0,u.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,u.jsx)(`label`,{htmlFor:`team-memory-key`,className:`sr-only`,children:`Memory entry key`}),(0,u.jsx)(`input`,{id:`team-memory-key`,type:`text`,placeholder:`key (e.g. prefs/hiking.md)`,value:C,onChange:e=>w(e.target.value),disabled:x!==`new`,className:`flex-1 font-mono`})]}),(0,u.jsx)(`label`,{htmlFor:`team-memory-content`,className:`sr-only`,children:`Memory entry content`}),(0,u.jsx)(`textarea`,{id:`team-memory-content`,placeholder:`select an entry on the left, or create a new one.`,value:T,onChange:e=>E(e.target.value),disabled:x===`none`,className:`min-h-[360px] w-full font-mono text-[0.9em] leading-[1.55]`}),(0,u.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,u.jsx)(s,{variant:`primary`,onClick:H,disabled:!G||!I,children:`save`}),(0,u.jsx)(s,{variant:`danger`,onClick:W,disabled:!K,children:`delete`})]}),j&&(0,u.jsx)(`p`,{role:j.kind===`error`?`alert`:`status`,className:`mt-2 text-[0.9em] ${j.kind===`error`?`text-danger`:`text-mocha-light`}`,children:j.msg})]})]}),(0,u.jsx)(i,{open:N!==null,title:N?.title??``,description:N?.description??null,confirmLabel:N?.confirmLabel??`continue`,onConfirm:()=>N?.onConfirm(),onOpenChange:e=>{e||P(null)}})]})}export{f as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{n as r,t as i}from"./ProductionTeamPolicyEditor-DnTcWhG8.js";import{gt as a,u as o}from"./index-Ct31TjS-.js";import{r as s}from"./Page-NV96O47A.js";import{t as c}from"./Button-ByiV6fpd.js";import{t as l}from"./RecoveryState-QfMSuwy3.js";import{t as u}from"./TeamTabs-V17b45X5.js";var d=a(`git-compare-arrows`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`M12 18H7a2 2 0 0 1-2-2V9`,key:`16sdep`}],[`path`,{d:`m9 15 3 3-3 3`,key:`1m3kbl`}]]),f=a(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),p=e(n(),1),m=t();function h({teamId:e,detail:t,templates:n}){let[i,a]=(0,p.useState)(null),[o,s]=(0,p.useState)(null),[l,u]=(0,p.useState)(!1),[h,v]=(0,p.useState)(`${e}-snapshot`),[y,b]=(0,p.useState)(`${e} snapshot`),x=(0,p.useMemo)(()=>new Set(t.bindings.map(e=>e.agentId)),[t.bindings]),S=t.members.filter(e=>!x.has(e.id)),C=async()=>{let t=await fetch(`/api/teams/${encodeURIComponent(e)}/policy/diff`);if(!t.ok)throw Error((await t.json().catch(()=>null))?.error??`Could not load source comparison`);a(await t.json())};return(0,p.useEffect)(()=>{C().catch(e=>s(e instanceof Error?e.message:String(e)))},[e]),(0,m.jsxs)(`section`,{className:`card space-y-4`,"aria-labelledby":`source-workflows`,children:[(0,m.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,m.jsx)(d,{className:`mt-1 h-5 w-5 text-sapphire`}),(0,m.jsxs)(`div`,{className:`mr-auto`,children:[(0,m.jsx)(`h2`,{id:`source-workflows`,className:`m-0 text-lg`,children:`Baseline and source`}),(0,m.jsx)(`p`,{className:`muted mt-1 text-sm`,children:`Lineage is retained for comparison; source edits never auto-propagate.`})]}),(0,m.jsxs)(c,{variant:`ghost`,onClick:()=>void C(),children:[(0,m.jsx)(f,{className:`h-4 w-4`}),`Refresh comparison`]})]}),i?(0,m.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,m.jsx)(g,{label:`Baseline`,value:i.baseline?`${i.baseline.templateId} r${i.baseline.templateRevision}`:`None`}),(0,m.jsx)(g,{label:`Live changes`,value:`+${i.comparison.addedSinceBaseline.length} / −${i.comparison.removedSinceBaseline.length} edges`}),(0,m.jsx)(g,{label:`Source slots`,value:`+${i.comparison.currentSourceAddedSlotIds.length} / −${i.comparison.currentSourceRemovedSlotIds.length}`}),(0,m.jsx)(g,{label:`Source state`,value:i.currentSource?i.sourceDiverged?`Diverged — rebaseline required`:`Aligned`:`Missing/tombstoned`,warning:i.sourceDiverged||!i.currentSource})]}):(0,m.jsx)(`p`,{className:`muted`,children:`Loading comparison…`}),i?.sourceDiverged&&(0,m.jsx)(`div`,{role:`alert`,className:`rounded-md border border-warning/25 bg-warning/10 p-3 text-sm text-warning`,children:`The source has changed since this Team retained its baseline. Both versions remain intact. Update-source is disabled; compare and explicitly rebaseline instead.`}),i?.currentSource&&!i.sourceDiverged&&(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,m.jsxs)(`p`,{className:`mr-auto text-sm`,children:[`Promote the current live policy to `,(0,m.jsx)(`strong`,{children:i.currentSource.template.name}),`, including `,S.length,` live-only Agent`,S.length===1?``:`s`,`.`]}),(0,m.jsx)(c,{variant:`ghost`,disabled:l,onClick:async()=>{if(!(!i?.currentSource||i.sourceDiverged)){u(!0),s(null);try{let n=await fetch(`/api/teams/${encodeURIComponent(e)}/policy/update-source`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({teamExpectedRevision:t.teamPolicy.revision,templateExpectedRevision:i.currentSource.template.currentRevision,includeAgentIds:S.map(e=>e.id)})});if(!n.ok)throw Error((await n.json().catch(()=>null))?.error??`Update failed (${n.status})`);window.location.reload()}catch(e){s(e instanceof Error?e.message:String(e))}finally{u(!1)}}},children:`Update source after review`})]}),(0,m.jsxs)(`div`,{className:`grid gap-3 border-t border-frost pt-4 sm:grid-cols-[1fr_1fr_auto]`,children:[(0,m.jsxs)(`label`,{className:`text-xs`,children:[`New template ID`,(0,m.jsx)(`input`,{value:h,onChange:e=>v(e.target.value)})]}),(0,m.jsxs)(`label`,{className:`text-xs`,children:[`New template name`,(0,m.jsx)(`input`,{value:y,onChange:e=>b(e.target.value)})]}),(0,m.jsxs)(c,{variant:`primary`,disabled:l||!h.trim()||!y.trim(),onClick:async()=>{u(!0),s(null);try{let n=await fetch(`/api/teams/${encodeURIComponent(e)}/policy/save-as-template`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({expectedRevision:t.teamPolicy.revision,id:h,name:y})});if(!n.ok)throw Error((await n.json().catch(()=>null))?.error??`Save failed (${n.status})`);let r=await n.json();window.location.assign(`/templates/teams/${encodeURIComponent(r.template.id)}`)}catch(e){s(e instanceof Error?e.message:String(e))}finally{u(!1)}},children:[(0,m.jsx)(r,{className:`h-4 w-4`}),`Save independent Team template`]})]}),o&&(0,m.jsx)(`p`,{role:`alert`,className:`err`,children:o}),(0,m.jsx)(_,{teamId:e,detail:t,templates:n})]})}function g({label:e,value:t,warning:n=!1}){return(0,m.jsxs)(`div`,{className:`rounded-md border p-3 ${n?`border-warning/25 bg-warning/10 dark:bg-amber-950/30`:`border-frost bg-ivory`}`,children:[(0,m.jsx)(`dt`,{className:`text-xs font-semibold uppercase text-mocha-light`,children:e}),(0,m.jsx)(`dd`,{className:`mt-1 break-words text-sm font-semibold`,children:t})]})}function _({teamId:e,detail:t,templates:n}){let[r,i]=(0,p.useState)(n.find(e=>!e.deletedAt)?.id??``),[a,o]=(0,p.useState)(null),[s,l]=(0,p.useState)({}),[u,d]=(0,p.useState)({}),[f,h]=(0,p.useState)(null),[g,_]=(0,p.useState)(null),v=async()=>{_(null),h(null);let e=await fetch(`/api/team-templates/${encodeURIComponent(r)}`);if(!e.ok){_(`Could not load Team (${e.status})`);return}let n=await e.json();o(n);let i={};n.slots.forEach((e,n)=>{let r=t.members[n];r&&(i[e.slotId]=r.id)}),l(i);let a=new Set(Object.values(i));d(Object.fromEntries(t.members.filter(e=>!a.has(e.id)).map(e=>[e.id,`isolated`])))},y=()=>({teamExpectedRevision:t.teamPolicy.revision,templateId:a?.template.id,templateExpectedRevision:a?.template.currentRevision,slotMappings:a?.slots.map(e=>({slotId:e.slotId,agentId:s[e.slotId]}))??[],remainingPlacements:t.members.filter(e=>!Object.values(s).includes(e.id)).map(e=>({agentId:e.id,placement:u[e.id]??`isolated`}))});return(0,m.jsxs)(`div`,{className:`space-y-4 border-t border-frost pt-5`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`h3`,{className:`m-0 text-base`,children:`Adopt or rebaseline from Team Template`}),(0,m.jsx)(`p`,{className:`muted mt-1 text-sm`,children:`Map every stable source slot to one current Agent, choose placement for remaining Agents, then review the daemon-resolved edge set.`})]}),(0,m.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,m.jsxs)(`label`,{className:`min-w-52 flex-1 text-xs`,children:[`Team Template`,(0,m.jsx)(`select`,{value:r,onChange:e=>{i(e.target.value),o(null),h(null)},children:n.filter(e=>!e.deletedAt).map(e=>(0,m.jsxs)(`option`,{value:e.id,children:[e.name,` · r`,e.currentRevision]},e.id))})]}),(0,m.jsx)(c,{variant:`ghost`,onClick:v,children:`Configure mapping`})]}),a&&(0,m.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,m.jsxs)(`div`,{className:`space-y-2`,children:[(0,m.jsx)(`p`,{className:`text-xs font-semibold uppercase text-mocha-light`,children:`Stable slots`}),a.slots.map(e=>(0,m.jsxs)(`label`,{className:`block text-xs`,children:[(0,m.jsxs)(`span`,{className:`block truncate`,title:e.slotId,children:[e.agentName,` · slot `,(0,m.jsx)(`code`,{children:e.slotId.slice(0,8)})]}),(0,m.jsxs)(`select`,{value:s[e.slotId]??``,onChange:t=>{l(n=>({...n,[e.slotId]:t.target.value})),h(null)},children:[(0,m.jsx)(`option`,{value:``,children:`Select Agent…`}),t.members.map(t=>(0,m.jsxs)(`option`,{value:t.id,disabled:Object.entries(s).some(([n,r])=>n!==e.slotId&&r===t.id),children:[t.name,t.status===`archived`?` (archived)`:``]},t.id))]})]},e.slotId))]}),(0,m.jsxs)(`div`,{className:`space-y-2`,children:[(0,m.jsx)(`p`,{className:`text-xs font-semibold uppercase text-mocha-light`,children:`Remaining live Agents`}),t.members.filter(e=>!Object.values(s).includes(e.id)).map(e=>(0,m.jsxs)(`label`,{className:`block text-xs`,children:[e.name,(0,m.jsxs)(`select`,{value:u[e.id]??`isolated`,onChange:t=>{d(n=>({...n,[e.id]:t.target.value})),h(null)},children:[(0,m.jsx)(`option`,{value:`isolated`,children:`Isolated`}),(0,m.jsx)(`option`,{value:`profile_defaults`,children:`Agent-template defaults`})]})]},e.id))]})]}),a&&(0,m.jsx)(c,{variant:`ghost`,onClick:async()=>{if(!a||a.slots.some(e=>!s[e.slotId])||new Set(Object.values(s)).size!==a.slots.length){_(`Map every stable slot to a distinct current Agent.`);return}let t=await fetch(`/api/teams/${encodeURIComponent(e)}/policy/adopt-template/preview`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(y())}),n=await t.json().catch(()=>null);if(!t.ok){_(n?.error??`Preview failed (${t.status})`);return}h(n.edges)},children:`Review exact resulting policy`}),f&&(0,m.jsxs)(`div`,{className:`rounded-md border border-sapphire-light bg-sapphire-glow p-3 text-sm`,children:[(0,m.jsxs)(`p`,{children:[`The daemon resolved `,(0,m.jsx)(`strong`,{children:f.length}),` directed allow edges. This preview is submitted unchanged and recomputed transactionally at commit.`]}),(0,m.jsx)(`div`,{className:`mt-2 max-h-40 overflow-auto`,children:(0,m.jsx)(`ul`,{children:f.map((e,t)=>(0,m.jsx)(`li`,{children:(0,m.jsxs)(`code`,{children:[e.sourceKind,e.sourceId?`:${e.sourceId}`:``,` → `,e.targetKind,e.targetId?`:${e.targetId}`:``]})},`${e.sourceKind}:${e.sourceId??``}>${e.targetKind}:${e.targetId??``}:${t}`))})}),(0,m.jsx)(c,{variant:`primary`,className:`mt-3`,onClick:async()=>{if(!f)return;let t=await fetch(`/api/teams/${encodeURIComponent(e)}/policy/adopt-template`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({...y(),previewEdges:f})}),n=await t.json().catch(()=>null);if(!t.ok){_(n?.error??`Rebaseline failed (${t.status})`);return}window.location.reload()},children:`Commit reviewed rebaseline`})]}),g&&(0,m.jsx)(`p`,{role:`alert`,className:`err`,children:g})]})}function v(){let e=o.useLoaderData();if(!e.ok)return(0,m.jsx)(l,{title:`Team policy unavailable`,error:Error(e.error),reset:()=>window.location.reload(),fallbackHref:`/teams`});let{detail:t,profiles:n,templates:r}=e.value,{id:a}=o.useParams(),c=o.useSearch(),d=t.baseline;return(0,m.jsxs)(s,{size:`wide`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`h1`,{children:`Team policy`}),(0,m.jsxs)(`p`,{className:`muted`,children:[`The sole effective live communication policy for `,(0,m.jsx)(`code`,{children:a}),`.`]})]}),(0,m.jsx)(u,{teamId:a}),(0,m.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,"aria-label":`Policy status`,children:[(0,m.jsx)(y,{label:`Revision`,value:t.teamPolicy.revision}),(0,m.jsx)(y,{label:`Allow edges`,value:t.edges.length}),(0,m.jsx)(y,{label:`Baseline`,value:d?`${d.templateId} r${d.templateRevision}`:`Not initialized`})]}),(0,m.jsx)(i,{source:{kind:`live`,teamId:a,detail:t},profiles:n,initialUi:{view:c.view,selectedId:c.selected,viewport:{x:c.vx,y:c.vy,zoom:c.vz}}}),(0,m.jsx)(h,{teamId:a,detail:t,templates:r})]})}function y({label:e,value:t}){return(0,m.jsxs)(`div`,{className:`card`,children:[(0,m.jsx)(`dt`,{className:`muted text-xs`,children:e}),(0,m.jsx)(`dd`,{className:`break-words font-semibold`,children:t})]})}export{v as component};
|
|
1
|
+
import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{n as r,t as i}from"./ProductionTeamPolicyEditor-DG1x4Cqz.js";import{gt as a,u as o}from"./index-CwMw0pnV.js";import{r as s}from"./Page-NV96O47A.js";import{t as c}from"./Button-ByiV6fpd.js";import{t as l}from"./RecoveryState-QfMSuwy3.js";import{t as u}from"./TeamTabs-BHB_COm0.js";var d=a(`git-compare-arrows`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`M12 18H7a2 2 0 0 1-2-2V9`,key:`16sdep`}],[`path`,{d:`m9 15 3 3-3 3`,key:`1m3kbl`}]]),f=a(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),p=e(n(),1),m=t();function h({teamId:e,detail:t,templates:n}){let[i,a]=(0,p.useState)(null),[o,s]=(0,p.useState)(null),[l,u]=(0,p.useState)(!1),[h,v]=(0,p.useState)(`${e}-snapshot`),[y,b]=(0,p.useState)(`${e} snapshot`),x=(0,p.useMemo)(()=>new Set(t.bindings.map(e=>e.agentId)),[t.bindings]),S=t.members.filter(e=>!x.has(e.id)),C=async()=>{let t=await fetch(`/api/teams/${encodeURIComponent(e)}/policy/diff`);if(!t.ok)throw Error((await t.json().catch(()=>null))?.error??`Could not load source comparison`);a(await t.json())};return(0,p.useEffect)(()=>{C().catch(e=>s(e instanceof Error?e.message:String(e)))},[e]),(0,m.jsxs)(`section`,{className:`card space-y-4`,"aria-labelledby":`source-workflows`,children:[(0,m.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,m.jsx)(d,{className:`mt-1 h-5 w-5 text-sapphire`}),(0,m.jsxs)(`div`,{className:`mr-auto`,children:[(0,m.jsx)(`h2`,{id:`source-workflows`,className:`m-0 text-lg`,children:`Baseline and source`}),(0,m.jsx)(`p`,{className:`muted mt-1 text-sm`,children:`Lineage is retained for comparison; source edits never auto-propagate.`})]}),(0,m.jsxs)(c,{variant:`ghost`,onClick:()=>void C(),children:[(0,m.jsx)(f,{className:`h-4 w-4`}),`Refresh comparison`]})]}),i?(0,m.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,m.jsx)(g,{label:`Baseline`,value:i.baseline?`${i.baseline.templateId} r${i.baseline.templateRevision}`:`None`}),(0,m.jsx)(g,{label:`Live changes`,value:`+${i.comparison.addedSinceBaseline.length} / −${i.comparison.removedSinceBaseline.length} edges`}),(0,m.jsx)(g,{label:`Source slots`,value:`+${i.comparison.currentSourceAddedSlotIds.length} / −${i.comparison.currentSourceRemovedSlotIds.length}`}),(0,m.jsx)(g,{label:`Source state`,value:i.currentSource?i.sourceDiverged?`Diverged — rebaseline required`:`Aligned`:`Missing/tombstoned`,warning:i.sourceDiverged||!i.currentSource})]}):(0,m.jsx)(`p`,{className:`muted`,children:`Loading comparison…`}),i?.sourceDiverged&&(0,m.jsx)(`div`,{role:`alert`,className:`rounded-md border border-warning/25 bg-warning/10 p-3 text-sm text-warning`,children:`The source has changed since this Team retained its baseline. Both versions remain intact. Update-source is disabled; compare and explicitly rebaseline instead.`}),i?.currentSource&&!i.sourceDiverged&&(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,m.jsxs)(`p`,{className:`mr-auto text-sm`,children:[`Promote the current live policy to `,(0,m.jsx)(`strong`,{children:i.currentSource.template.name}),`, including `,S.length,` live-only Agent`,S.length===1?``:`s`,`.`]}),(0,m.jsx)(c,{variant:`ghost`,disabled:l,onClick:async()=>{if(!(!i?.currentSource||i.sourceDiverged)){u(!0),s(null);try{let n=await fetch(`/api/teams/${encodeURIComponent(e)}/policy/update-source`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({teamExpectedRevision:t.teamPolicy.revision,templateExpectedRevision:i.currentSource.template.currentRevision,includeAgentIds:S.map(e=>e.id)})});if(!n.ok)throw Error((await n.json().catch(()=>null))?.error??`Update failed (${n.status})`);window.location.reload()}catch(e){s(e instanceof Error?e.message:String(e))}finally{u(!1)}}},children:`Update source after review`})]}),(0,m.jsxs)(`div`,{className:`grid gap-3 border-t border-frost pt-4 sm:grid-cols-[1fr_1fr_auto]`,children:[(0,m.jsxs)(`label`,{className:`text-xs`,children:[`New template ID`,(0,m.jsx)(`input`,{value:h,onChange:e=>v(e.target.value)})]}),(0,m.jsxs)(`label`,{className:`text-xs`,children:[`New template name`,(0,m.jsx)(`input`,{value:y,onChange:e=>b(e.target.value)})]}),(0,m.jsxs)(c,{variant:`primary`,disabled:l||!h.trim()||!y.trim(),onClick:async()=>{u(!0),s(null);try{let n=await fetch(`/api/teams/${encodeURIComponent(e)}/policy/save-as-template`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({expectedRevision:t.teamPolicy.revision,id:h,name:y})});if(!n.ok)throw Error((await n.json().catch(()=>null))?.error??`Save failed (${n.status})`);let r=await n.json();window.location.assign(`/templates/teams/${encodeURIComponent(r.template.id)}`)}catch(e){s(e instanceof Error?e.message:String(e))}finally{u(!1)}},children:[(0,m.jsx)(r,{className:`h-4 w-4`}),`Save independent Team template`]})]}),o&&(0,m.jsx)(`p`,{role:`alert`,className:`err`,children:o}),(0,m.jsx)(_,{teamId:e,detail:t,templates:n})]})}function g({label:e,value:t,warning:n=!1}){return(0,m.jsxs)(`div`,{className:`rounded-md border p-3 ${n?`border-warning/25 bg-warning/10 dark:bg-amber-950/30`:`border-frost bg-ivory`}`,children:[(0,m.jsx)(`dt`,{className:`text-xs font-semibold uppercase text-mocha-light`,children:e}),(0,m.jsx)(`dd`,{className:`mt-1 break-words text-sm font-semibold`,children:t})]})}function _({teamId:e,detail:t,templates:n}){let[r,i]=(0,p.useState)(n.find(e=>!e.deletedAt)?.id??``),[a,o]=(0,p.useState)(null),[s,l]=(0,p.useState)({}),[u,d]=(0,p.useState)({}),[f,h]=(0,p.useState)(null),[g,_]=(0,p.useState)(null),v=async()=>{_(null),h(null);let e=await fetch(`/api/team-templates/${encodeURIComponent(r)}`);if(!e.ok){_(`Could not load Team (${e.status})`);return}let n=await e.json();o(n);let i={};n.slots.forEach((e,n)=>{let r=t.members[n];r&&(i[e.slotId]=r.id)}),l(i);let a=new Set(Object.values(i));d(Object.fromEntries(t.members.filter(e=>!a.has(e.id)).map(e=>[e.id,`isolated`])))},y=()=>({teamExpectedRevision:t.teamPolicy.revision,templateId:a?.template.id,templateExpectedRevision:a?.template.currentRevision,slotMappings:a?.slots.map(e=>({slotId:e.slotId,agentId:s[e.slotId]}))??[],remainingPlacements:t.members.filter(e=>!Object.values(s).includes(e.id)).map(e=>({agentId:e.id,placement:u[e.id]??`isolated`}))});return(0,m.jsxs)(`div`,{className:`space-y-4 border-t border-frost pt-5`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`h3`,{className:`m-0 text-base`,children:`Adopt or rebaseline from Team Template`}),(0,m.jsx)(`p`,{className:`muted mt-1 text-sm`,children:`Map every stable source slot to one current Agent, choose placement for remaining Agents, then review the daemon-resolved edge set.`})]}),(0,m.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,m.jsxs)(`label`,{className:`min-w-52 flex-1 text-xs`,children:[`Team Template`,(0,m.jsx)(`select`,{value:r,onChange:e=>{i(e.target.value),o(null),h(null)},children:n.filter(e=>!e.deletedAt).map(e=>(0,m.jsxs)(`option`,{value:e.id,children:[e.name,` · r`,e.currentRevision]},e.id))})]}),(0,m.jsx)(c,{variant:`ghost`,onClick:v,children:`Configure mapping`})]}),a&&(0,m.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,m.jsxs)(`div`,{className:`space-y-2`,children:[(0,m.jsx)(`p`,{className:`text-xs font-semibold uppercase text-mocha-light`,children:`Stable slots`}),a.slots.map(e=>(0,m.jsxs)(`label`,{className:`block text-xs`,children:[(0,m.jsxs)(`span`,{className:`block truncate`,title:e.slotId,children:[e.agentName,` · slot `,(0,m.jsx)(`code`,{children:e.slotId.slice(0,8)})]}),(0,m.jsxs)(`select`,{value:s[e.slotId]??``,onChange:t=>{l(n=>({...n,[e.slotId]:t.target.value})),h(null)},children:[(0,m.jsx)(`option`,{value:``,children:`Select Agent…`}),t.members.map(t=>(0,m.jsxs)(`option`,{value:t.id,disabled:Object.entries(s).some(([n,r])=>n!==e.slotId&&r===t.id),children:[t.name,t.status===`archived`?` (archived)`:``]},t.id))]})]},e.slotId))]}),(0,m.jsxs)(`div`,{className:`space-y-2`,children:[(0,m.jsx)(`p`,{className:`text-xs font-semibold uppercase text-mocha-light`,children:`Remaining live Agents`}),t.members.filter(e=>!Object.values(s).includes(e.id)).map(e=>(0,m.jsxs)(`label`,{className:`block text-xs`,children:[e.name,(0,m.jsxs)(`select`,{value:u[e.id]??`isolated`,onChange:t=>{d(n=>({...n,[e.id]:t.target.value})),h(null)},children:[(0,m.jsx)(`option`,{value:`isolated`,children:`Isolated`}),(0,m.jsx)(`option`,{value:`profile_defaults`,children:`Agent-template defaults`})]})]},e.id))]})]}),a&&(0,m.jsx)(c,{variant:`ghost`,onClick:async()=>{if(!a||a.slots.some(e=>!s[e.slotId])||new Set(Object.values(s)).size!==a.slots.length){_(`Map every stable slot to a distinct current Agent.`);return}let t=await fetch(`/api/teams/${encodeURIComponent(e)}/policy/adopt-template/preview`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(y())}),n=await t.json().catch(()=>null);if(!t.ok){_(n?.error??`Preview failed (${t.status})`);return}h(n.edges)},children:`Review exact resulting policy`}),f&&(0,m.jsxs)(`div`,{className:`rounded-md border border-sapphire-light bg-sapphire-glow p-3 text-sm`,children:[(0,m.jsxs)(`p`,{children:[`The daemon resolved `,(0,m.jsx)(`strong`,{children:f.length}),` directed allow edges. This preview is submitted unchanged and recomputed transactionally at commit.`]}),(0,m.jsx)(`div`,{className:`mt-2 max-h-40 overflow-auto`,children:(0,m.jsx)(`ul`,{children:f.map((e,t)=>(0,m.jsx)(`li`,{children:(0,m.jsxs)(`code`,{children:[e.sourceKind,e.sourceId?`:${e.sourceId}`:``,` → `,e.targetKind,e.targetId?`:${e.targetId}`:``]})},`${e.sourceKind}:${e.sourceId??``}>${e.targetKind}:${e.targetId??``}:${t}`))})}),(0,m.jsx)(c,{variant:`primary`,className:`mt-3`,onClick:async()=>{if(!f)return;let t=await fetch(`/api/teams/${encodeURIComponent(e)}/policy/adopt-template`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({...y(),previewEdges:f})}),n=await t.json().catch(()=>null);if(!t.ok){_(n?.error??`Rebaseline failed (${t.status})`);return}window.location.reload()},children:`Commit reviewed rebaseline`})]}),g&&(0,m.jsx)(`p`,{role:`alert`,className:`err`,children:g})]})}function v(){let e=o.useLoaderData();if(!e.ok)return(0,m.jsx)(l,{title:`Team policy unavailable`,error:Error(e.error),reset:()=>window.location.reload(),fallbackHref:`/teams`});let{detail:t,profiles:n,templates:r}=e.value,{id:a}=o.useParams(),c=o.useSearch(),d=t.baseline;return(0,m.jsxs)(s,{size:`wide`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`h1`,{children:`Team policy`}),(0,m.jsxs)(`p`,{className:`muted`,children:[`The sole effective live communication policy for `,(0,m.jsx)(`code`,{children:a}),`.`]})]}),(0,m.jsx)(u,{teamId:a}),(0,m.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,"aria-label":`Policy status`,children:[(0,m.jsx)(y,{label:`Revision`,value:t.teamPolicy.revision}),(0,m.jsx)(y,{label:`Allow edges`,value:t.edges.length}),(0,m.jsx)(y,{label:`Baseline`,value:d?`${d.templateId} r${d.templateRevision}`:`Not initialized`})]}),(0,m.jsx)(i,{source:{kind:`live`,teamId:a,detail:t},profiles:n,initialUi:{view:c.view,selectedId:c.selected,viewport:{x:c.vx,y:c.vy,zoom:c.vz}}}),(0,m.jsx)(h,{teamId:a,detail:t,templates:r})]})}function y({label:e,value:t}){return(0,m.jsxs)(`div`,{className:`card`,children:[(0,m.jsx)(`dt`,{className:`muted text-xs`,children:e}),(0,m.jsx)(`dd`,{className:`break-words font-semibold`,children:t})]})}export{v as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{t as r}from"./ConfirmDialog-
|
|
1
|
+
import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{t as r}from"./ConfirmDialog-Br19uXWH.js";import{d as i}from"./index-CwMw0pnV.js";import{r as a}from"./Page-NV96O47A.js";import{t as o}from"./Button-ByiV6fpd.js";import{t as s}from"./ResultCard-Cps_lXVN.js";import{n as c}from"./ResultSourceConversation-5PFWqXTY.js";import{t as l}from"./TeamTabs-BHB_COm0.js";var u=e(n()),d=t();function f(){let e=i.useLoaderData(),[t,n]=(0,u.useState)(null),[f,p]=(0,u.useState)(``),[m,h]=(0,u.useState)(``),[g,_]=(0,u.useState)(0),[v,y]=(0,u.useState)(0),[b,x]=(0,u.useState)(``),[S,C]=(0,u.useState)(null);return(0,u.useEffect)(()=>{let t=new AbortController,r=new URLSearchParams({teamId:e.id,limit:`20`,offset:String(g)});return m&&r.set(`agentId`,m),n(null),x(``),fetch(`/api/results?${r}`,{signal:t.signal}).then(async e=>{if(!e.ok)throw Error(`Could not load saved results.`);let r=await e.json();if(!t.signal.aborted){if(g>0&&g>=r.total){_(Math.max(0,Math.floor((r.total-1)/20)*20));return}n(r)}}).catch(e=>{t.signal.aborted||x(e.message)}),()=>t.abort()},[e.id,m,g,v]),(0,d.jsxs)(a,{children:[(0,d.jsxs)(`header`,{children:[(0,d.jsxs)(`h1`,{children:[e.name||e.id,` results`]}),(0,d.jsx)(`p`,{children:`Files delivered by this Team, saved with their original contents.`})]}),(0,d.jsx)(l,{teamId:e.id}),(0,d.jsxs)(`form`,{className:`flex flex-wrap items-end gap-3`,onSubmit:e=>{e.preventDefault(),_(0),h(f.trim())},children:[(0,d.jsxs)(`label`,{className:`min-w-0`,children:[`Producing Agent ID`,(0,d.jsx)(`input`,{value:f,onChange:e=>p(e.target.value),placeholder:`All Agents`,className:`block max-w-full`})]}),(0,d.jsx)(o,{variant:`ghost`,type:`submit`,children:`Filter`}),(0,d.jsx)(o,{variant:`ghost`,onClick:()=>y(e=>e+1),children:`Refresh`})]}),b&&(0,d.jsx)(`p`,{role:`alert`,className:`text-danger`,children:b}),!t&&!b&&(0,d.jsx)(`p`,{role:`status`,children:`Loading results…`}),t&&(0,d.jsxs)(d.Fragment,{children:[!t.results.length&&(0,d.jsxs)(`p`,{children:[`No saved results`,m?` for this Agent`:` yet`,`.`]}),(0,d.jsx)(`div`,{className:`grid min-w-0 gap-4 md:grid-cols-2`,children:t.results.map(e=>(0,d.jsxs)(`article`,{className:`min-w-0 rounded-lg border border-fawn p-4`,children:[(0,d.jsx)(s,{resultId:e.id,showPreview:!0}),(0,d.jsxs)(`p`,{className:`break-all text-sm`,children:[`Agent: `,e.agentId]}),(0,d.jsxs)(`p`,{className:`text-sm`,children:[`Saved: `,new Date(e.createdAt).toLocaleString()]}),(0,d.jsxs)(`p`,{className:`break-all text-sm`,children:[`Conversation: `,e.sessionId]}),(0,d.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,d.jsx)(c,{resultId:e.id,agentId:e.agentId}),(0,d.jsx)(o,{variant:`danger`,onClick:()=>C({id:e.id,name:e.name}),children:`Delete saved file`})]})]},e.id))}),(0,d.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,"aria-label":`Results pagination`,children:[(0,d.jsx)(o,{variant:`ghost`,disabled:g===0,onClick:()=>_(e=>Math.max(0,e-20)),children:`Previous`}),(0,d.jsx)(`span`,{children:t.total?`${g+1}–${g+t.results.length} of ${t.total}`:`0 results`}),(0,d.jsx)(o,{variant:`ghost`,disabled:g+20>=t.total,onClick:()=>_(e=>e+20),children:`Next`})]})]}),(0,d.jsx)(r,{open:S!==null,title:`Delete saved file?`,description:`Permanently delete the saved bytes of “${S?.name??``}”. History will show a deletion receipt. The workspace source file is unchanged.`,confirmLabel:`Delete saved file`,onOpenChange:e=>{e||C(null)},onConfirm:async()=>{if(S){if(!(await fetch(`/api/results/${encodeURIComponent(S.id)}`,{method:`DELETE`})).ok)throw Error(`Could not delete the saved file.`);C(null),_(0),y(e=>e+1)}}})]})}export{f as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{C as r,D as i,E as a,S as o,T as s,_ as c,b as l,f as u,g as d,m as f,p,v as m,w as h,x as g,xt as _,y as v,yt as y}from"./index-CwMw0pnV.js";import{r as b}from"./Page-NV96O47A.js";import{t as x}from"./Button-ByiV6fpd.js";import{a as S,i as C,o as w,r as T,s as E}from"./git-review-presentation-CzHQulDk.js";import{t as D}from"./TeamTabs-BHB_COm0.js";var O=e(n(),1),k=y({method:`POST`}).handler(_(`8cb9f33e191419922cf300f6a376425d82c51eefacc87c7ac673a4dc6d5404d6`)),A=y({method:`POST`}).handler(_(`f514a362fcd27ca13859cf38b528929dac740cb400fe6cd920fedfb5b4860198`)),j=t();function M({teamId:e}){let[t,n]=(0,O.useState)(null),[r,i]=(0,O.useState)(``),[a,o]=(0,O.useState)(``),[s,c]=(0,O.useState)(!1),[l,u]=(0,O.useState)(null),[d,f]=(0,O.useState)(null),p=async()=>{c(!0);let t=await k({data:{id:e}});c(!1),n(t)};return t===null?(0,j.jsxs)(`section`,{className:`card space-y-3`,"aria-label":`Publications`,children:[(0,j.jsx)(`h3`,{children:`Publications`}),(0,j.jsx)(`p`,{className:`muted`,children:`Publishing commits a reviewed revision to a new branch and opens a pull request. It never merges and never deploys, and the commit is unsigned.`}),(0,j.jsx)(x,{variant:`ghost`,disabled:s,onClick:()=>void p(),children:`Load publications`})]}):(0,j.jsxs)(`section`,{className:`card space-y-3`,"aria-label":`Publications`,children:[(0,j.jsx)(`h3`,{children:`Publications`}),(0,j.jsx)(`p`,{className:`muted`,children:`Publishing commits a reviewed revision to a new branch and opens a pull request. It never merges and never deploys, and the commit is unsigned.`}),(0,j.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,j.jsxs)(`label`,{className:`flex flex-col grow text-sm`,children:[(0,j.jsx)(`span`,{className:`muted`,children:`Reviewed packet id`}),(0,j.jsx)(`input`,{value:r,onChange:e=>i(e.target.value)})]}),(0,j.jsxs)(`label`,{className:`flex flex-col grow text-sm`,children:[(0,j.jsx)(`span`,{className:`muted`,children:`Branch (optional)`}),(0,j.jsx)(`input`,{value:a,placeholder:`bazilion/review-…`,onChange:e=>o(e.target.value)})]}),(0,j.jsx)(x,{variant:`primary`,disabled:s||r.trim().length===0,onClick:()=>{(async()=>{c(!0),u(null),f(null);let t=await A({data:{id:e,packetId:r.trim(),...a.trim()?{headBranch:a.trim()}:{}}});if(c(!1),`blocked`in t&&t.blocked){f(t.blocked);return}if(`unavailable`in t&&t.unavailable){u(t.unavailable.message);return}await p()})()},children:`Publish`}),(0,j.jsx)(x,{variant:`ghost`,disabled:s,onClick:()=>void p(),children:`Refresh`})]}),d?(0,j.jsxs)(`p`,{role:`alert`,className:`rounded-sm border border-fawn p-2 text-sm`,children:[`Refused (`,d.reason,`): `,d.detail,` — nothing was sent.`]}):null,l?(0,j.jsx)(`p`,{role:`alert`,className:`rounded-sm border border-fawn p-2 text-sm`,children:l}):null,t.unavailable?(0,j.jsx)(`p`,{role:`alert`,children:t.unavailable.message}):null,t.publications.length===0?(0,j.jsx)(`p`,{className:`muted`,children:`No publications yet. Nothing has been sent anywhere for this Team.`}):(0,j.jsx)(`ul`,{className:`list`,children:t.publications.map(e=>(0,j.jsxs)(`li`,{className:`card space-y-1`,children:[(0,j.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-2`,children:[(0,j.jsx)(`strong`,{children:e.state}),(0,j.jsxs)(`span`,{className:`muted`,children:[e.host,` `,e.repository]})]}),(0,j.jsxs)(`p`,{className:`muted`,children:[e.headBranch,` (base `,e.baseBranch,`) · packet `,e.packetId]}),e.commitOid?(0,j.jsxs)(`p`,{className:`muted`,children:[`commit `,e.commitOid.slice(0,12),` · unsigned`]}):null,e.pullRequestUrl?(0,j.jsxs)(`p`,{className:`muted`,children:[`pull request`,` `,(0,j.jsxs)(`a`,{href:e.pullRequestUrl,rel:`noreferrer`,target:`_blank`,children:[`#`,e.pullRequestNumber??``]})]}):e.state===`published`?(0,j.jsx)(`p`,{className:`muted`,children:`no pull request was opened`}):null,e.refusalReason?(0,j.jsxs)(`p`,{className:`muted`,children:[`refused: `,e.refusalReason,` — `,e.refusalDetail]}):null,e.error?(0,j.jsxs)(`p`,{className:`muted`,children:[`note: `,e.error]}):null,(0,j.jsx)(`p`,{className:`muted`,children:e.state===`refused`?`Nothing was sent: no commit, no push, no pull request.`:e.state===`uncertain`?`Whether the branch reached the host is unknown. Check the host before publishing again.`:`Nothing was merged and nothing was deployed.`})]},e.id))})]})}var N=[`blocker`,`major`,`minor`,`info`],P=[`changes_requested`,`commented`,`recommended`],F=[`committed`,`pushed`,`pullRequest`,`merged`,`deployed`,`productionAccepted`];function I(e){return e===`identical`?`unchanged since capture`:e===`changed`?`changed since capture (never a pass)`:`not checked`}function L({teamId:e,view:t}){let[n,c]=(0,O.useState)({}),[u,d]=(0,O.useState)(!1),[f,p]=(0,O.useState)(null),[m,_]=(0,O.useState)(t.snapshots[0]?.id??``),[v,y]=(0,O.useState)(t.members[0]?.id??``),[b,S]=(0,O.useState)({path:``,severity:`major`,note:``}),[C,w]=(0,O.useState)(null),[T,E]=(0,O.useState)(null),[D,k]=(0,O.useState)(``),[A,M]=(0,O.useState)(`committed`),[L,R]=(0,O.useState)(``),z=async e=>{d(!0),p(null);try{let t=await e();`report`in t&&t.report?c(e=>({...e,[t.report.packet.id]:t.report})):`message`in t&&p(t)}finally{d(!1)}},B=()=>z(()=>g({data:{id:e,snapshotId:m,reviewerAgentId:v||null}})),V=t=>z(()=>h({data:{id:e,packetId:t}})),H=e=>n[e];return(0,j.jsxs)(`section`,{className:`space-y-3`,"aria-label":`Review packets`,children:[(0,j.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,j.jsx)(`h3`,{children:`Review packets`}),(0,j.jsx)(`span`,{className:`muted`,children:`A packet binds one captured revision. Findings are recorded against it; resolving one needs an explicit decision or a named later revision.`})]}),(0,j.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,j.jsxs)(`label`,{className:`flex flex-col text-sm`,children:[(0,j.jsx)(`span`,{className:`muted`,children:`Revision`}),(0,j.jsxs)(`select`,{value:m,onChange:e=>_(e.target.value),className:`unstyled`,children:[t.snapshots.length===0?(0,j.jsx)(`option`,{value:``,children:`(none captured)`}):null,t.snapshots.map(e=>(0,j.jsxs)(`option`,{value:e.id,children:[e.id.slice(0,12),e.complete?``:` — INCOMPLETE`]},e.id))]})]}),(0,j.jsxs)(`label`,{className:`flex flex-col text-sm`,children:[(0,j.jsx)(`span`,{className:`muted`,children:`Reviewer (optional)`}),(0,j.jsxs)(`select`,{value:v,onChange:e=>y(e.target.value),className:`unstyled`,children:[(0,j.jsx)(`option`,{value:``,children:`none — nothing delegated`}),t.members.map(e=>(0,j.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,j.jsx)(x,{variant:`primary`,disabled:u||!m,onClick:B,children:`Open packet`})]}),f?(0,j.jsx)(`p`,{role:`alert`,className:`rounded-sm border border-fawn p-2 text-sm`,children:f.message}):null,t.packets.length===0?(0,j.jsx)(`p`,{className:`muted`,children:`No review packets yet.`}):(0,j.jsx)(`ul`,{className:`list`,children:t.packets.map(t=>{let n=H(t.packet.id);return(0,j.jsxs)(`li`,{className:`card space-y-2`,children:[(0,j.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-2`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`strong`,{children:t.packet.state}),` `,(0,j.jsxs)(`span`,{className:`muted`,children:[t.packet.reviewerAgentId??`no reviewer`,` ·`,` `,t.packet.snapshot.id.slice(0,12)]})]}),(0,j.jsxs)(`div`,{className:`flex gap-2`,children:[(0,j.jsx)(x,{variant:`ghost`,disabled:u,onClick:()=>V(t.packet.id),children:`Details`}),(0,j.jsx)(x,{variant:`ghost`,disabled:u,onClick:async()=>{d(!0);let n=await o({data:{id:e,packetId:t.packet.id}});d(!1),`handoff`in n?w({packetId:t.packet.id,patch:n.patch,text:n.handoff}):`message`in n&&p(n)},children:`Handoff`})]})]}),(0,j.jsxs)(`p`,{className:`muted`,children:[t.counts.findings,` finding(s), `,t.counts.unresolved,` unresolved`,t.counts.blockers>0?`, ${t.counts.blockers} blocker(s)`:``,` ·`,` `,t.conclusion??`no conclusion yet`]}),C?.packetId===t.packet.id?(0,j.jsxs)(`div`,{className:`space-y-1`,children:[(0,j.jsx)(`h4`,{children:`Handoff`}),(0,j.jsx)(`pre`,{className:`overflow-x-auto rounded-sm border border-fawn p-2 text-xs`,children:C.text}),C.patch?(0,j.jsx)(`pre`,{className:`overflow-x-auto rounded-sm border border-fawn p-2 text-xs`,children:C.patch}):null,(0,j.jsx)(x,{variant:`ghost`,onClick:()=>{navigator.clipboard?.writeText(C.patch||C.text)},children:`Copy`})]}):null,n?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`p`,{className:`muted`,children:[`applicability: `,I(n.applicability.comparison)]}),(0,j.jsx)(`ul`,{children:n.findings.map(n=>(0,j.jsxs)(`li`,{children:[(0,j.jsxs)(`span`,{className:`muted`,children:[`[`,n.severity,`]`]}),` `,(0,j.jsxs)(`code`,{children:[n.path,n.lineStart===null?``:`:${n.lineStart}${n.lineEnd&&n.lineEnd!==n.lineStart?`-${n.lineEnd}`:``}`]}),` `,`— `,n.note,n.resolution?(0,j.jsxs)(`span`,{className:`muted`,children:[` `,`· resolved (`,n.resolution.kind,`) by `,n.resolution.by.kind]}):n.state===`unverified`?(0,j.jsx)(`span`,{className:`muted`,children:` · UNVERIFIED — not correlated to this revision`}):(0,j.jsx)(x,{variant:`ghost`,disabled:u,onClick:()=>z(()=>i({data:{id:e,packetId:t.packet.id,findingId:n.id,resolutionKind:`explicit`,resolutionNote:`resolved by the operator`}})),children:`Resolve explicitly`})]},n.id))}),(0,j.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,j.jsxs)(`label`,{className:`flex flex-col text-sm`,children:[(0,j.jsx)(`span`,{className:`muted`,children:`Finding path`}),(0,j.jsx)(`input`,{value:b.path,onChange:e=>S({...b,path:e.target.value})})]}),(0,j.jsxs)(`label`,{className:`flex flex-col text-sm`,children:[(0,j.jsx)(`span`,{className:`muted`,children:`Severity`}),(0,j.jsx)(`select`,{value:b.severity,onChange:e=>S({...b,severity:e.target.value}),children:N.map(e=>(0,j.jsx)(`option`,{value:e,children:e},e))})]}),(0,j.jsxs)(`label`,{className:`flex flex-col grow text-sm`,children:[(0,j.jsx)(`span`,{className:`muted`,children:`Note`}),(0,j.jsx)(`input`,{value:b.note,onChange:e=>S({...b,note:e.target.value})})]}),(0,j.jsx)(x,{variant:`ghost`,disabled:u||!b.path||!b.note,onClick:()=>z(()=>l({data:{id:e,packetId:t.packet.id,path:b.path,severity:b.severity,note:b.note}})),children:`Add finding`})]}),(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,j.jsx)(`span`,{className:`muted`,children:`Conclusion:`}),P.map(n=>(0,j.jsx)(x,{variant:`ghost`,disabled:u,onClick:()=>z(()=>a({data:{id:e,packetId:t.packet.id,conclusion:n}})),children:n},n))]}),(0,j.jsxs)(`div`,{className:`space-y-1`,children:[(0,j.jsx)(`span`,{className:`muted`,children:`Where a file link points. The workspace belongs to the machine running the daemon, so this says which host it names and whether it is the reviewed revision.`}),(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,j.jsx)(`input`,{placeholder:`changed path`,value:L,onChange:e=>R(e.target.value)}),(0,j.jsx)(x,{variant:`ghost`,disabled:u||!L,onClick:async()=>{let n=await r({data:{id:e,packetId:t.packet.id,path:L}});`link`in n?E({packetId:t.packet.id,link:n.link}):`message`in n&&p(n)},children:`Resolve location`}),T?.packetId===t.packet.id?(0,j.jsx)(x,{variant:`ghost`,onClick:()=>void navigator.clipboard?.writeText(T.link.copyTarget),children:`Copy location`}):null]}),T?.packetId===t.packet.id?(0,j.jsxs)(`p`,{className:`muted`,children:[(0,j.jsx)(`code`,{children:T.link.copyTarget}),` · on`,` `,T.link.host.daemon??`the daemon host`,` ·`,` `,T.link.mode===`live`?`the reviewed revision`:T.link.mode===`stale`?`the CURRENT file, not the reviewed revision`:`unknown`,` `,`·`,` `,T.link.canOpen?`an editor is configured on the daemon host (${T.link.command})`:`no editor configured, so nothing can be opened here`]}):null]}),(0,j.jsxs)(`p`,{className:`muted`,children:[`completed: change prepared=`,String(n.facts.changePrepared),` checks current=`,String(n.facts.checksCurrent),` reviewed=`,String(n.facts.reviewed),` — a conclusion is not acceptance, and nothing here commits, pushes, merges or deploys.`]}),(0,j.jsxs)(`div`,{className:`space-y-1`,children:[(0,j.jsx)(`span`,{className:`muted`,children:`Beyond this point nothing is verified: Bazilion has no code-host integration, so these are whatever you report.`}),(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,j.jsx)(`select`,{className:`unstyled`,value:A,onChange:e=>M(e.target.value),children:F.map(e=>(0,j.jsx)(`option`,{value:e,children:e},e))}),(0,j.jsx)(`input`,{placeholder:`commit id, URL, release name…`,value:D,onChange:e=>k(e.target.value)}),(0,j.jsx)(x,{variant:`ghost`,disabled:u,onClick:()=>z(()=>s({data:{id:e,packetId:t.packet.id,state:A,reference:D||null}})),children:`Report`})]}),(0,j.jsxs)(`p`,{className:`muted`,children:[`reported (reported, not verified):`,` `,Object.entries(n.packet.reported).filter(([,e])=>e!==null).map(([e,t])=>`${e}=${t}`).join(` `)||`nothing yet`]})]})]}):null]},t.packet.id)})})]})}function R(){let e=u.useLoaderData(),t=e.team.id,[n,r]=(0,O.useState)(``),[i,a]=(0,O.useState)(``),[o,s]=(0,O.useState)(e.review),[l,h]=(0,O.useState)(e.unavailable),[g,_]=(0,O.useState)(e.snapshots),[y,k]=(0,O.useState)(null),[A,N]=(0,O.useState)(null),[P,F]=(0,O.useState)(null),[I,R]=(0,O.useState)(()=>e.snapshots[0]?.snapshotId??null),[z,B]=(0,O.useState)(``),[V,H]=(0,O.useState)(()=>e.members[0]?.id??``),[U,W]=(0,O.useState)(null),[G,K]=(0,O.useState)(null),[q,J]=(0,O.useState)(!1);async function Y(e=i){J(!0),K({kind:`info`,message:`Loading changes…`});try{let n=await d({data:{id:t,...e?{base:e}:{}}});if(!n)return;s(n.review),h(n.unavailable),_(n.snapshots),a(e),k(null),N(null),K(null)}finally{J(!1)}}async function X(e){k(e),N(null),K({kind:`info`,message:`Loading diff…`}),N(await f({data:{id:t,path:e,...i?{base:i}:{}}})),K(null)}async function Z(){J(!0),K({kind:`info`,message:`Capturing a source snapshot…`});let e=await p({data:{id:t}});`reference`in e?(K({kind:`info`,message:`Captured ${S(e.reference)}`}),await Y()):K({kind:`error`,message:E(e.code,e.message)}),J(!1)}async function Q(){if(!y)return;J(!0),K({kind:`info`,message:`Preparing feedback…`});let e=await m({data:{id:t,path:y,...I?{snapshotId:I}:{},...z.trim()?{note:z}:{}}});`message`in e&&`reference`in e?(W(e),K(null)):K({kind:`error`,message:E(e.code,e.message)}),J(!1)}async function ee(){if(!U||!V)return;J(!0);let e=await v({data:{agentId:V,message:U.message}});K(`queued`in e?{kind:`info`,message:`Feedback queued for the Agent. It runs as the next turn.`}:{kind:`error`,message:E(e.code,e.message)}),`queued`in e&&W(null),J(!1)}async function te(e){K({kind:`info`,message:`Loading snapshot…`});let n=await c({data:{id:t,snapshotId:e}});F(n),K(n?null:{kind:`error`,message:`That snapshot is no longer retained.`})}let $=o?.changes;return(0,j.jsxs)(b,{children:[(0,j.jsxs)(`header`,{children:[(0,j.jsxs)(`h1`,{children:[e.team.name||e.team.id,` review`]}),(0,j.jsx)(`p`,{children:`Changes since a pinned baseline, and the source snapshots taken for them. Inspection is read-only — nothing here stages, commits or reverts anything.`})]}),(0,j.jsx)(D,{teamId:t}),(0,j.jsxs)(`section`,{className:`space-y-2`,"aria-label":`Comparison base`,children:[(0,j.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-end`,children:[(0,j.jsxs)(`label`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,j.jsx)(`span`,{children:`Comparison base`}),(0,j.jsx)(`input`,{className:`input`,value:n,placeholder:`HEAD`,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Y(n)}})]}),(0,j.jsxs)(`div`,{className:`flex gap-2`,children:[(0,j.jsx)(x,{variant:`ghost`,disabled:q,onClick:()=>void Y(n),children:`Apply base`}),(0,j.jsx)(x,{variant:`primary`,disabled:q,onClick:()=>void Y(),children:`Refresh`})]})]}),$&&(0,j.jsx)(`p`,{className:`text-sm opacity-80`,children:T($.identity,$)}),(0,j.jsx)(`p`,{className:`text-xs opacity-70`,children:`A branch name is resolved to a concrete commit when the review loads, so a moving tip cannot rewrite what you are looking at.`})]}),G&&(0,j.jsx)(`p`,{role:G.kind===`error`?`alert`:`status`,className:`text-sm`,children:G.message}),l&&(0,j.jsxs)(`section`,{className:`rounded-sm border border-fawn bg-ivory p-3`,"aria-label":`Review unavailable`,children:[(0,j.jsx)(`p`,{role:`alert`,children:E(l.code,l.message)}),l.code&&(0,j.jsxs)(`p`,{className:`text-xs opacity-70`,children:[`code: `,l.code]})]}),$&&(0,j.jsxs)(`section`,{className:`space-y-2`,"aria-label":`Changes since baseline`,children:[(0,j.jsx)(`h2`,{children:`Changes since baseline`}),$.changes.length===0&&(0,j.jsx)(`p`,{children:`No changes since this baseline.`}),$.changes.length>0&&(0,j.jsx)(`ul`,{className:`divide-y divide-fawn rounded-sm border border-fawn`,children:$.changes.map(e=>(0,j.jsx)(`li`,{children:(0,j.jsxs)(`button`,{type:`button`,"aria-current":y===e.path?`true`:void 0,onClick:()=>void X(e.path),className:`flex w-full flex-col gap-1 px-3 py-2 text-left hover:bg-sapphire-glow focus:bg-sapphire-glow`,children:[(0,j.jsx)(`span`,{className:`break-all font-mono text-sm`,children:e.previousPath?`${e.previousPath} → ${e.path}`:e.path}),(0,j.jsxs)(`span`,{className:`text-xs opacity-80`,children:[C(e),e.patchTruncated?` · diff truncated`:``]})]})},`${e.status}:${e.path}`))}),$.truncated&&(0,j.jsx)(`p`,{className:`text-sm`,children:`This list is incomplete: more files changed than the review limit allows.`}),($.withheld.excluded>0||$.withheld.untracked>0)&&(0,j.jsxs)(`p`,{className:`text-xs opacity-80`,children:[$.withheld.excluded,` excluded and `,$.withheld.untracked,` untracked path(s) withheld by scope policy.`]}),$.issues.map(e=>(0,j.jsxs)(`p`,{className:`text-xs opacity-80`,children:[`note: `,e.code,`: `,e.message]},`${e.code}:${e.message}`))]}),y&&(0,j.jsxs)(`section`,{className:`space-y-2`,"aria-label":`Selected file diff`,children:[(0,j.jsx)(`h2`,{className:`break-all font-mono text-base`,children:y}),A===null?(0,j.jsx)(`p`,{className:`text-sm`,children:`Loading…`}):A.patch===null?(0,j.jsxs)(`p`,{className:`text-sm`,children:[`No diff text for this file`,A.omitted?` (${A.omitted.replaceAll(`_`,` `)})`:``,`.`]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`pre`,{className:`max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-sm bg-[rgba(42,31,22,0.04)] p-3 font-mono text-xs`,children:A.patch}),A.truncated&&(0,j.jsx)(`p`,{className:`text-xs`,children:`This diff was truncated at the patch limit.`})]}),(0,j.jsxs)(`div`,{className:`space-y-2 rounded-sm border border-fawn p-3`,children:[(0,j.jsx)(`h3`,{children:`Send feedback about this file`}),(0,j.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,j.jsx)(`span`,{children:`Note (optional)`}),(0,j.jsx)(`textarea`,{className:`input`,rows:2,value:z,onChange:e=>B(e.target.value)})]}),(0,j.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,j.jsx)(`span`,{children:`Agent`}),(0,j.jsx)(`select`,{className:`input`,value:V,onChange:e=>H(e.target.value),children:e.members.map(e=>(0,j.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,j.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,j.jsx)(x,{variant:`ghost`,disabled:q,onClick:()=>void Q(),children:`Preview message`}),(0,j.jsx)(x,{variant:`primary`,disabled:q||!U||!V,onClick:()=>void ee(),children:`Queue for Agent`})]}),I?(0,j.jsxs)(`p`,{className:`text-xs opacity-70`,children:[`Referenced snapshot: `,I.slice(0,12),`. It is rechecked now, and the verdict is stated in the message.`]}):(0,j.jsx)(`p`,{className:`text-xs opacity-70`,children:`No snapshot captured for this Team yet, so the feedback will say its source identity is unknown rather than implying the lines still match.`}),U&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`p`,{className:`text-sm`,children:U.applicability===`current`?`This file is unchanged since the snapshot.`:U.applicability===`stale`?`This file changed since the snapshot — the selected lines may have moved.`:`Source identity unknown (${U.applicabilityReason}).`}),(0,j.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words rounded-sm bg-[rgba(42,31,22,0.04)] p-3 font-mono text-xs`,children:U.message})]})]})]}),(0,j.jsxs)(`section`,{className:`space-y-2`,"aria-label":`Source snapshots`,children:[(0,j.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,j.jsx)(`h2`,{children:`Source snapshots`}),(0,j.jsx)(x,{variant:`ghost`,disabled:q,onClick:()=>void Z(),children:`Capture snapshot`})]}),(0,j.jsx)(`p`,{className:`text-xs opacity-70`,children:`A snapshot records HEAD, the index and digests of changed files — never file content. Untracked content is only included when a path is named explicitly.`}),g.length===0&&(0,j.jsx)(`p`,{children:`No retained snapshots for this Team.`}),g.length>0&&(0,j.jsx)(`ul`,{className:`divide-y divide-fawn rounded-sm border border-fawn`,children:g.map(e=>(0,j.jsx)(`li`,{children:(0,j.jsx)(`button`,{type:`button`,onClick:()=>void te(e.snapshotId),className:`w-full px-3 py-2 text-left font-mono text-xs hover:bg-sapphire-glow focus:bg-sapphire-glow`,children:w(e)})},e.snapshotId))}),P&&(0,j.jsxs)(`div`,{className:`space-y-1`,children:[(0,j.jsxs)(`p`,{className:`text-sm`,children:[P.id.slice(0,12),` · `,P.complete?`complete`:`incomplete — applicability unknown`,` · head `,P.head?.slice(0,12)??`(unborn)`]}),P.entries.length>0&&(0,j.jsx)(`ul`,{className:`space-y-1 font-mono text-xs`,children:P.entries.map(e=>(0,j.jsxs)(`li`,{children:[e.layer,` · `,e.kind,` · `,e.path,e.bytes===null?``:` · ${e.bytes}B`]},`${e.layer}:${e.path}`))}),P.exclusions.length>0&&(0,j.jsxs)(`p`,{className:`text-xs opacity-80`,children:[`withheld: `,P.exclusions.map(e=>`${e.path} (${e.reason})`).join(`, `)]})]})]}),e.packets?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(L,{teamId:t,view:e.packets}),(0,j.jsx)(M,{teamId:t})]}):null]})}export{R as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{a as r,d as i,o as a}from"./preload-helper-bztXdkDj.js";import{t as o}from"./chevron-right-CvCEwfSl.js";import{n as s,t as c}from"./x-CXKABZ7C.js";import{a as l,c as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./ConfirmDialog-C908TxS5.js";import{ft as _,gt as v,ht as y,lt as b,mt as x,q as S}from"./index-Ct31TjS-.js";import{n as C,t as w}from"./utils-B6KiDbIe.js";import{t as T}from"./Button-ByiV6fpd.js";import{t as E}from"./ChatPane-DCyGcqdh.js";import"./wire-constants-CBD-lTaa.js";var D=v(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),O=v(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),k=v(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),A=e(n(),1),j=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,M=C,N=(e,t)=>n=>{if(t?.variants==null)return M(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=j(t)||j(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return M(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)},P=t(),F=N(`team/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,outline:`border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground`,ghost:`hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50`,destructive:`bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,xs:`h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-team]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-team]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,icon:`size-8`,"icon-xs":`size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-team]:rounded-lg [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-team]:rounded-lg`,"icon-lg":`size-9`}},defaultVariants:{variant:`default`,size:`default`}});function I({className:e,variant:t=`default`,size:n=`default`,asChild:r=!1,...i}){return(0,P.jsx)(r?b:`button`,{"data-slot":`button`,"data-variant":t,"data-size":n,className:w(F({variant:t,size:n,className:e})),...i})}function L({...e}){return(0,P.jsx)(f,{"data-slot":`dialog`,...e})}function R({...e}){return(0,P.jsx)(h,{"data-slot":`dialog-portal`,...e})}function z({className:e,...t}){return(0,P.jsx)(p,{"data-slot":`dialog-overlay`,className:w(`fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function B({className:e,children:t,showCloseButton:n=!0,...r}){return(0,P.jsxs)(R,{children:[(0,P.jsx)(z,{}),(0,P.jsxs)(d,{"data-slot":`dialog-content`,className:w(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r,children:[t,n&&(0,P.jsx)(m,{"data-slot":`dialog-close`,asChild:!0,children:(0,P.jsxs)(I,{variant:`ghost`,className:`absolute top-2 right-2`,size:`icon-sm`,children:[(0,P.jsx)(c,{}),(0,P.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function V({className:e,...t}){return(0,P.jsx)(`div`,{"data-slot":`dialog-header`,className:w(`flex flex-col gap-2`,e),...t})}function H({className:e,showCloseButton:t=!1,children:n,...r}){return(0,P.jsxs)(`div`,{"data-slot":`dialog-footer`,className:w(`-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end`,e),...r,children:[n,t&&(0,P.jsx)(m,{asChild:!0,children:(0,P.jsx)(I,{variant:`outline`,children:`Close`})})]})}function U({className:e,...t}){return(0,P.jsx)(u,{"data-slot":`dialog-title`,className:w(`font-heading text-base leading-none font-medium`,e),...t})}function W({className:e,...t}){return(0,P.jsx)(l,{"data-slot":`dialog-description`,className:w(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function G({onClose:e}){let t=i(),[n,r]=(0,A.useState)(``),[a,o]=(0,A.useState)(``),[s,c]=(0,A.useState)(``),[l,u]=(0,A.useState)(!1),[d,f]=(0,A.useState)(null);async function p(r){if(r.preventDefault(),f(null),!n.trim()){f(`id is required`);return}u(!0);try{let r={id:n.trim()};a.trim()&&(r.name=a.trim()),s.trim()&&(r.link=s.trim());let i=await fetch(`/api/teams`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(r)});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.error??`${i.status} ${i.statusText}`)}e(),await t.invalidate()}catch(e){f(e.message),u(!1)}}return(0,P.jsx)(L,{open:!0,onOpenChange:t=>{!t&&!l&&e()},children:(0,P.jsx)(B,{showCloseButton:!l,className:`max-h-[calc(100dvh-2rem)] w-full max-w-lg overflow-y-auto rounded-3xl border border-frost bg-card p-6 shadow-baziu-lg sm:p-7`,onEscapeKeyDown:e=>{l&&e.preventDefault()},onPointerDownOutside:e=>{l&&e.preventDefault()},children:(0,P.jsxs)(`form`,{onSubmit:p,children:[(0,P.jsxs)(V,{children:[(0,P.jsx)(U,{className:`font-serif text-2xl text-foreground`,children:`Create a team`}),(0,P.jsxs)(W,{children:[`A team is a collaboration context — one filesystem root, one USER.md, one roster. The slot lives at `,(0,P.jsx)(`code`,{className:`font-mono`,children:`~/.bazilion/teams/<slug>/`}),`.`]})]}),(0,P.jsxs)(`div`,{className:`mb-3 mt-4 grid gap-3 sm:grid-cols-2`,children:[(0,P.jsxs)(`label`,{className:`block text-sm`,children:[`ID (slug)`,(0,P.jsx)(`input`,{type:`text`,value:n,onChange:e=>r(e.target.value),required:!0,pattern:`[a-z0-9][a-z0-9_-]*`,placeholder:`myproject`,className:`mt-1 block w-full rounded-md border bg-background px-3 py-2 outline-none focus:ring-2 focus:ring-ring/30`})]}),(0,P.jsxs)(`label`,{className:`block text-sm`,children:[`Name `,(0,P.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`}),(0,P.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),className:`mt-1 block w-full rounded-md border bg-background px-3 py-2 outline-none focus:ring-2 focus:ring-ring/30`})]})]}),(0,P.jsxs)(`label`,{className:`mb-3 block text-sm`,children:[`Link target`,` `,(0,P.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional, absolute path)`}),(0,P.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:`/home/you/projects/myrepo`,className:`mt-1 block w-full rounded-md border bg-background px-3 py-2 outline-none focus:ring-2 focus:ring-ring/30`}),(0,P.jsx)(`span`,{className:`mt-1 block text-xs text-muted-foreground`,children:`Leave blank to create a fresh directory. Supply an absolute path to materialize the slot as a symlink to your existing project tree.`})]}),d&&(0,P.jsx)(`p`,{role:`alert`,className:`err mt-2`,children:d}),(0,P.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,P.jsx)(T,{variant:`ghost`,disabled:l,onClick:e,children:`Cancel`}),(0,P.jsx)(T,{variant:`primary`,type:`submit`,disabled:l,children:l?`Creating…`:`Create team`})]})]})})})}function K({profileId:e,teamHint:t,teams:n,onClose:r}){let i=a(),[o,s]=(0,A.useState)(``),[c,l]=(0,A.useState)(t??n.find(e=>e.id==="default")?.id??n[0]?.id??``),[u,d]=(0,A.useState)(`profile_defaults`),[f,p]=(0,A.useState)(!1),[m,h]=(0,A.useState)(null),[g,_]=(0,A.useState)(null);async function v(){let t=await fetch(`/api/teams/${encodeURIComponent(c)}/policy`);if(!t.ok)throw Error(`The selected Team policy is unavailable. Reload and try again.`);let n=await t.json();return{current:n,body:{profileId:e,teamId:c,teamExpectedRevision:n.teamPolicy.revision,placement:u}}}async function y(){h(null),p(!0);try{let{body:e}=await v(),t=await fetch(`/api/agents/placement-preview`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error??`Preview failed (${t.status})`)}_(await t.json())}catch(e){h(e.message)}finally{p(!1)}}async function b(t){t.preventDefault(),h(null),p(!0);try{if(!g){await y();return}let t={profile:e,teamExpectedRevision:g.currentRevision,placement:u};o.trim()&&(t.name=o.trim()),c&&(t.teamId=c);let n=await fetch(`/api/agents`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`${n.status} ${n.statusText}`)}let a=(await n.json()).agent;r(),await i({to:`/`,search:{agent:a.id}})}catch(e){h(e.message),p(!1)}}return(0,P.jsx)(L,{open:!0,onOpenChange:e=>{!e&&!f&&r()},children:(0,P.jsx)(B,{showCloseButton:!f,className:`max-h-[calc(100dvh-2rem)] w-full max-w-lg overflow-y-auto rounded-3xl border border-frost bg-card p-6 shadow-baziu-lg sm:p-7`,onEscapeKeyDown:e=>{f&&e.preventDefault()},onPointerDownOutside:e=>{f&&e.preventDefault()},children:(0,P.jsxs)(`form`,{onSubmit:b,children:[(0,P.jsxs)(V,{children:[(0,P.jsx)(U,{className:`font-serif text-xl text-foreground`,children:`Spawn a new agent`}),(0,P.jsxs)(W,{children:[`Create an agent from profile `,(0,P.jsx)(`code`,{className:`font-mono`,children:e}),`, then review its exact Team policy placement before committing.`]})]}),(0,P.jsxs)(`label`,{className:`mb-3 mt-4 block text-sm text-foreground`,children:[`Agent name`,` `,(0,P.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional — defaults to the profile's name)`}),(0,P.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),autoComplete:`off`,className:`mt-1 block w-full rounded-md border bg-background px-3 py-2 outline-none focus:ring-2 focus:ring-ring/30`})]}),(0,P.jsxs)(`label`,{className:`mb-3 block text-sm text-foreground`,children:[`Initial policy placement`,(0,P.jsxs)(`select`,{value:u,onChange:e=>{d(e.target.value),_(null)},className:`mt-1 block w-full rounded-md border bg-background px-3 py-2`,children:[(0,P.jsx)(`option`,{value:`profile_defaults`,children:`Agent-template defaults`}),(0,P.jsx)(`option`,{value:`isolated`,children:`Isolated`})]}),(0,P.jsx)(`span`,{className:`mt-1 block text-xs text-muted-foreground`,children:`The current Team revision is checked again when you submit.`})]}),(0,P.jsxs)(`label`,{className:`mb-3 block text-sm text-foreground`,children:[`Team`,(0,P.jsx)(`select`,{value:c,onChange:e=>{l(e.target.value),_(null)},className:`mt-1 block w-full rounded-md border bg-background px-3 py-2 outline-none focus:ring-2 focus:ring-ring/30`,children:n.map(e=>(0,P.jsxs)(`option`,{value:e.id,children:[e.name,e.id==="default"?` (default)`:``]},e.id))})]}),m&&(0,P.jsx)(`p`,{role:`alert`,className:`err mt-2`,children:m}),g&&(0,P.jsxs)(`div`,{role:`status`,className:`mt-3 rounded-md border border-sapphire-light bg-sapphire-glow p-3 text-sm`,children:[(0,P.jsxs)(`p`,{children:[`Creating this Agent advances Team revision `,g.currentRevision,` →`,` `,(0,P.jsx)(`strong`,{children:g.resultingRevision}),` and adds`,` `,(0,P.jsx)(`strong`,{children:g.addedEdges.length}),` directed edges to the existing`,` `,g.existingEdges.length,`.`]}),(0,P.jsx)(`ul`,{className:`mt-2 max-h-36 overflow-auto`,children:g.addedEdges.map((e,t)=>(0,P.jsx)(`li`,{children:(0,P.jsxs)(`code`,{children:[e.sourceKind,e.sourceId?`:${e.sourceId}`:``,` → `,e.targetKind,e.targetId?`:${e.targetId}`:``]})},`${e.sourceKind}:${e.sourceId??``}>${e.targetKind}:${e.targetId??``}:${t}`))}),g.addedEdges.length===0&&(0,P.jsx)(`p`,{className:`mt-2`,children:`The new Agent starts isolated.`})]}),(0,P.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,P.jsx)(T,{variant:`ghost`,disabled:f,onClick:r,children:`Cancel`}),(0,P.jsx)(T,{variant:`primary`,type:`submit`,disabled:f,children:f?`Working…`:g?`Commit reviewed creation`:`Review exact policy`})]})]})})})}function q({profileGroup:e,teams:t,onClose:n,onSpawned:r}){let[i,a]=(0,A.useState)(``),[o,s]=(0,A.useState)(``),[c,l]=(0,A.useState)(null),[u,d]=(0,A.useState)(!1),[f,p]=(0,A.useState)(null);async function m(){let n=i.trim();if(!n)throw Error(`Target Team slug is required`);let r=t.find(e=>e.id===n),a;if(r){let e=await fetch(`/api/teams/${encodeURIComponent(n)}/policy`);if(!e.ok)throw Error(`The target Team policy is unavailable.`);a=(await e.json()).teamPolicy.revision}return{target:n,body:{templateExpectedRevision:e.currentRevision,teamId:n,...a?{teamExpectedRevision:a}:{},mode:r?`append`:`initialize`,...o?{userMd:o}:{}}}}async function h(){d(!0),l(null),p(null);try{let{body:t}=await m(),n=await fetch(`/api/team-templates/${encodeURIComponent(e.id)}/spawn/preview`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(!n.ok)throw Error((await n.json().catch(()=>null))?.error??n.statusText);p(await n.json())}catch(e){l(e.message)}finally{d(!1)}}async function g(){let t=i.trim();if(!t){l(`Target Team slug is required`);return}d(!0),l(null);try{let{body:n}=await m(),i=await fetch(`/api/team-templates/${encodeURIComponent(e.id)}/spawn`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n)});if(!i.ok)throw Error((await i.json().catch(()=>null))?.error??i.statusText);r(t)}catch(e){l(e.message)}finally{d(!1)}}return(0,P.jsx)(L,{open:!0,onOpenChange:e=>{!e&&!u&&n()},children:(0,P.jsxs)(B,{showCloseButton:!u,className:`max-h-[calc(100dvh-2rem)] w-full max-w-lg overflow-y-auto rounded-3xl border border-frost bg-card p-6 shadow-baziu-lg sm:p-7`,onEscapeKeyDown:e=>{u&&e.preventDefault()},onPointerDownOutside:e=>{u&&e.preventDefault()},children:[(0,P.jsxs)(V,{children:[(0,P.jsxs)(U,{className:`font-serif text-xl text-foreground`,children:[`Spawn team — `,e.name]}),(0,P.jsxs)(W,{children:[`Uses immutable Team revision `,e.currentRevision,`. Existing Teams append at their current reviewed revision; a new Team initializes at revision 1. Conflicts never overwrite newer state.`]})]}),c&&(0,P.jsx)(`div`,{role:`alert`,className:`err`,children:c}),(0,P.jsxs)(`label`,{children:[`Target Team slug`,(0,P.jsx)(`input`,{value:i,onChange:e=>{a(e.target.value),p(null)},list:`canonical-teams`,required:!0}),(0,P.jsx)(`datalist`,{id:`canonical-teams`,children:t.map(e=>(0,P.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,P.jsxs)(`label`,{children:[`Starter USER.md (new Team only)`,(0,P.jsx)(`textarea`,{rows:3,value:o,onChange:e=>{s(e.target.value),p(null)},className:`font-mono text-[0.88em] leading-[1.55]`})]}),f&&(0,P.jsxs)(`div`,{role:`status`,className:`mt-4 rounded-md border border-sapphire-light bg-sapphire-glow p-3 text-sm`,children:[(0,P.jsxs)(`p`,{children:[(0,P.jsx)(`strong`,{children:f.mode===`initialize`?`Initialize`:`Append`}),` produces Team revision `,f.resultingRevision,`, adds `,f.newMembers.length,` Agents, and results in `,f.edges.length,` directed allow edges.`]}),(0,P.jsx)(`ul`,{className:`mt-2 max-h-40 overflow-auto`,children:f.newMembers.map(e=>(0,P.jsxs)(`li`,{children:[e.agentName,` · stable source slot `,(0,P.jsx)(`code`,{children:e.slotId})]},e.slotId))}),(0,P.jsxs)(`details`,{className:`mt-2`,children:[(0,P.jsx)(`summary`,{className:`cursor-pointer`,children:`Review exact edge topology`}),(0,P.jsx)(`ul`,{className:`mt-2 max-h-40 overflow-auto`,children:f.edges.map((e,t)=>(0,P.jsx)(`li`,{children:(0,P.jsxs)(`code`,{children:[e.sourceKind,e.sourceId?`:${e.sourceId}`:``,` → `,e.targetKind,e.targetId?`:${e.targetId}`:``]})},`${e.sourceKind}:${e.sourceId??``}>${e.targetKind}:${e.targetId??``}:${t}`))})]})]}),(0,P.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,P.jsx)(T,{variant:`ghost`,disabled:u,onClick:n,children:`Cancel`}),f?(0,P.jsx)(T,{variant:`primary`,onClick:g,disabled:u,children:u?`Spawning…`:`Commit ${f.mode}`}):(0,P.jsx)(T,{variant:`primary`,onClick:h,disabled:u||e.slotCount===0,children:u?`Reviewing…`:`Review exact result`})]})]})})}var J=`bz_sidebar_open_groups`;function Y(e){if(typeof document>`u`)return;let t=encodeURIComponent(JSON.stringify(e));document.cookie=`${J}=${t}; Path=/; Max-Age=31536000; SameSite=Lax`}function X({agents:e,teams:t,profiles:n,profileGroups:a,selectedAgentId:c,initialOpenGroups:l}){let u=i(),[d,f]=(0,A.useState)(null),[p,m]=(0,A.useState)(null),[h,v]=(0,A.useState)(!1),[b,S]=(0,A.useState)(!1),[C,w]=(0,A.useState)(null),[T,E]=(0,A.useState)(null),[j,M]=(0,A.useState)(null),N=(0,A.useRef)(null),F=(0,A.useRef)(null),I=()=>window.requestAnimationFrame(()=>N.current?.focus()),[L,R]=(0,A.useState)(()=>l??{});(0,A.useEffect)(()=>{if(!b)return;let e=F.current;window.requestAnimationFrame(()=>{e?.querySelector(`[role="menuitem"]:not([disabled])`)?.focus()});let t=t=>{e?.contains(t.target)||N.current?.contains(t.target)||(S(!1),I())},n=e=>{e.key===`Escape`&&(e.preventDefault(),S(!1),I())};return document.addEventListener(`pointerdown`,t),document.addEventListener(`keydown`,n),()=>{document.removeEventListener(`pointerdown`,t),document.removeEventListener(`keydown`,n)}},[b]);function z(e){if(![`ArrowDown`,`ArrowUp`,`Home`,`End`].includes(e.key))return;let t=Array.from(e.currentTarget.querySelectorAll(`[role="menuitem"]:not([disabled])`));if(t.length===0)return;e.preventDefault();let n=t.indexOf(document.activeElement);t[e.key===`Home`?0:e.key===`End`?t.length-1:e.key===`ArrowDown`?(n+1+t.length)%t.length:(n-1+t.length)%t.length]?.focus()}async function B(e,t){let n=t.trim();if(!n||n===e.name)return;let r=await fetch(`/api/agents/${e.id}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({name:n})});if(!r.ok){let e=await r.json().catch(()=>null);throw Error(e?.error??`Could not rename agent (${r.status})`)}await u.invalidate()}async function V(e){let t=await fetch(`/api/agents/${e.id}/archive`,{method:`POST`});if(!t.ok&&t.status!==204){let e=await t.json().catch(()=>null);throw Error(e?.error??`Could not archive agent (${t.status})`)}await u.invalidate()}let H=[...n].sort((e,t)=>e.id==="default"?-1:+(t.id==="default")),U=[...t].sort((e,t)=>e.id==="default"?-1:+(t.id==="default")),W=new Map;for(let t of e){let e=W.get(t.teamId)??[];e.push(t),W.set(t.teamId,e)}let J=e.find(e=>e.id===c)?.teamId??null;return(0,P.jsxs)(`aside`,{className:`flex h-full flex-col overflow-hidden rounded-2xl border border-border bg-card shadow-baziu-sm`,children:[(0,P.jsxs)(`header`,{className:`flex items-center justify-between gap-3 border-b border-border bg-muted/30 px-3 py-2.5`,children:[(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-foreground`,children:[(0,P.jsx)(`span`,{className:`flex size-7 items-center justify-center rounded-lg bg-accent text-accent-foreground`,children:(0,P.jsx)(y,{className:`size-4`,"aria-hidden":`true`})}),(0,P.jsx)(`span`,{children:`Agents`})]}),(0,P.jsxs)(`p`,{className:`mt-0.5 truncate pl-9 text-xs text-muted-foreground`,children:[e.length,` agent`,e.length===1?``:`s`,` across `,t.length,` team`,t.length===1?``:`s`]})]}),(0,P.jsxs)(`div`,{className:`relative`,children:[(0,P.jsxs)(`button`,{ref:N,id:`sidebar-new-menu-button`,type:`button`,onClick:()=>S(e=>!e),"aria-label":`Create a new Agent or Team`,"aria-controls":b?`sidebar-new-menu`:void 0,"aria-expanded":b,"aria-haspopup":`menu`,className:`unstyled inline-flex h-8 items-center gap-1 rounded-lg border border-border bg-card px-2.5 text-xs font-semibold text-foreground shadow-baziu-sm transition-colors hover:border-primary/30 hover:bg-accent hover:text-accent-foreground`,children:[(0,P.jsx)(s,{className:`size-3.5`,"aria-hidden":`true`}),`New`,(0,P.jsx)(x,{className:`size-3.5 text-muted-foreground transition-transform ${b?`rotate-180`:``}`,"aria-hidden":`true`})]}),b&&(0,P.jsxs)(`div`,{ref:F,id:`sidebar-new-menu`,role:`menu`,"aria-labelledby":`sidebar-new-menu-button`,className:`absolute right-0 top-[calc(100%+0.4rem)] z-20 w-60 overflow-hidden rounded-xl border border-border bg-popover p-1.5 text-popover-foreground shadow-baziu-lg`,onKeyDown:z,children:[n.length===0?(0,P.jsxs)(`div`,{className:`rounded-lg bg-muted/40 px-3 py-2.5 text-xs leading-5 text-muted-foreground`,children:[`No Agent templates yet.`,` `,(0,P.jsx)(`a`,{href:`/templates/agents`,role:`menuitem`,className:`text-primary underline`,children:`Create one to spawn agents.`})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-xs font-semibold uppercase tracking-[0.08em] text-muted-foreground`,children:[(0,P.jsx)(y,{className:`size-3`,"aria-hidden":`true`}),`Agent templates`]}),H.map(e=>(0,P.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{S(!1),f({profileId:e.id})},className:`unstyled flex min-h-8 w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-sm text-foreground transition-colors hover:bg-accent hover:text-accent-foreground`,children:[(0,P.jsx)(`span`,{className:`flex size-6 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground`,children:(0,P.jsx)(y,{className:`size-3.5`,"aria-hidden":`true`})}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name||e.id}),e.id==="default"&&(0,P.jsx)(`span`,{className:`rounded-full border border-border bg-muted px-1.5 py-0.5 text-xs font-semibold text-muted-foreground`,children:`Default`})]},e.id))]}),(0,P.jsx)(`div`,{className:`my-1.5 h-px bg-border`}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-xs font-semibold uppercase tracking-[0.08em] text-muted-foreground`,children:[(0,P.jsx)(_,{className:`size-3`,"aria-hidden":`true`}),`Team templates`]}),a.length===0?(0,P.jsxs)(`div`,{className:`rounded-lg bg-muted/40 px-3 py-2 text-xs leading-5 text-muted-foreground`,children:[`No team templates yet.`,` `,(0,P.jsx)(`a`,{href:`/templates/teams`,role:`menuitem`,className:`text-primary underline`,children:`Create one`}),`.`]}):a.map(e=>(0,P.jsxs)(`button`,{type:`button`,role:`menuitem`,disabled:e.slotCount===0,title:e.slotCount===0?`Add at least one member before spawning`:void 0,onClick:()=>{S(!1),m(e)},className:`unstyled flex min-h-8 w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-sm text-foreground transition-colors hover:bg-accent hover:text-accent-foreground disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent`,children:[(0,P.jsx)(`span`,{className:`flex size-6 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground`,children:(0,P.jsx)(_,{className:`size-3.5`,"aria-hidden":`true`})}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name||e.id}),(0,P.jsx)(`span`,{className:`inline-flex min-w-6 items-center justify-center rounded-full bg-muted px-1.5 font-mono text-xs text-muted-foreground`,children:e.slotCount})]},e.id)),(0,P.jsx)(`div`,{className:`my-1.5 h-px bg-border`}),(0,P.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{S(!1),v(!0)},className:`unstyled flex min-h-8 w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground`,children:[(0,P.jsx)(s,{className:`size-3.5`,"aria-hidden":`true`}),`Create a team`]})]})]})]}),j&&(0,P.jsx)(`p`,{role:`alert`,className:`m-2 rounded-lg bg-danger/10 px-3 py-2 text-xs text-danger`,children:j}),(0,P.jsx)(`nav`,{className:`flex-1 overflow-y-auto p-1.5`,"aria-label":`Teams and agents`,children:e.length===0?(0,P.jsxs)(`div`,{className:`m-1 flex flex-col items-center rounded-xl border border-dashed border-border bg-muted/30 px-4 py-6 text-center`,children:[(0,P.jsx)(`span`,{className:`mb-2 flex size-9 items-center justify-center rounded-full bg-accent text-accent-foreground`,children:(0,P.jsx)(y,{className:`size-4`,"aria-hidden":`true`})}),(0,P.jsx)(`p`,{className:`text-sm font-semibold text-foreground`,children:`No agents yet`}),(0,P.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:`Your default Team is ready. Spawn the first agent to start a conversation.`}),H[0]?(0,P.jsxs)(`button`,{type:`button`,onClick:()=>f({profileId:H[0]?.id??`default`}),className:`unstyled mt-3 inline-flex min-h-9 items-center gap-1 rounded-lg bg-primary px-3 text-xs font-semibold text-primary-foreground hover:bg-primary/90`,children:[`Spawn first agent`,(0,P.jsx)(o,{className:`size-3.5`,"aria-hidden":`true`})]}):(0,P.jsxs)(`a`,{href:`/templates/agents`,className:`mt-3 inline-flex items-center gap-1 text-xs font-semibold text-primary hover:text-primary/80`,children:[`Create an Agent template`,(0,P.jsx)(o,{className:`size-3.5`,"aria-hidden":`true`})]})]}):U.map(e=>{let t=W.get(e.id)??[],n=J===e.id,i=L[e.id];return(0,P.jsxs)(`details`,{open:i===void 0?n||e.id==="default":i,onToggle:t=>{let n=t.currentTarget.open;if(L[e.id]===n)return;let r={...L,[e.id]:n};Y(r),R(r),u.invalidate()},className:`team/details mb-1 last:mb-0`,children:[(0,P.jsxs)(`summary`,{className:`flex min-h-8 cursor-pointer list-none items-center gap-1.5 rounded-lg px-2 py-1.5 text-sm transition-colors hover:bg-accent hover:text-accent-foreground ${n?`bg-muted/60 text-foreground`:`text-muted-foreground`}`,children:[(0,P.jsx)(o,{className:`size-3.5 shrink-0 transition-transform team-open/details:rotate-90`,"aria-hidden":`true`}),(0,P.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground`,children:(0,P.jsx)(_,{className:`size-3`,"aria-hidden":`true`})}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:e.name}),e.id==="default"&&(0,P.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Default`}),(0,P.jsx)(`span`,{className:`inline-flex min-w-6 items-center justify-center rounded-full border border-border bg-card px-1.5 font-mono text-xs text-muted-foreground`,children:t.length})]}),t.length===0?(0,P.jsx)(`div`,{className:`py-2 pl-12 pr-2 text-xs text-muted-foreground`,children:`No agents in this team`}):(0,P.jsx)(`div`,{className:`space-y-0.5 py-0.5 pl-2`,children:t.map(e=>(0,P.jsxs)(`div`,{className:`team/row relative rounded-lg`,children:[(0,P.jsxs)(r,{to:`/`,search:{agent:e.id},"aria-current":e.id===c?`page`:void 0,className:`block min-h-11 rounded-lg border border-transparent py-1.5 pl-2.5 pr-[4.6rem] transition-colors hover:bg-accent/70 ${e.id===c?`border-primary/20 bg-accent text-accent-foreground shadow-baziu-sm`:`text-foreground`}`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium`,children:[(0,P.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full ${e.id===c?`bg-primary`:`bg-border`}`,"aria-hidden":`true`}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),e.telegramTopicId!==null&&(0,P.jsx)(`span`,{className:`shrink-0 text-primary`,title:`Telegram topic #${e.telegramTopicId}`,"aria-label":`Bound to Telegram topic ${e.telegramTopicId}`,children:(0,P.jsx)(k,{className:`size-3`,"aria-hidden":`true`})})]}),(0,P.jsxs)(`div`,{className:`mt-0.5 flex gap-2 pl-3 font-mono text-xs text-muted-foreground`,children:[(0,P.jsx)(`span`,{className:`uppercase tracking-wide`,children:e.status}),(0,P.jsx)(`span`,{children:e.id.slice(0,8)})]})]}),(0,P.jsxs)(`div`,{className:`absolute right-1 top-1/2 z-10 flex -translate-y-1/2 gap-0.5`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>w(e),title:`Rename`,"aria-label":`Rename ${e.name}`,className:`unstyled flex size-8 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-card hover:text-primary focus-visible:bg-card`,children:(0,P.jsx)(O,{className:`size-3.5`,"aria-hidden":`true`})}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>E(e),title:`Archive`,"aria-label":`Archive ${e.name}`,className:`unstyled flex size-8 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:bg-destructive/10 focus-visible:text-destructive`,children:(0,P.jsx)(D,{className:`size-3.5`,"aria-hidden":`true`})})]})]},e.id))})]},e.id)})}),d&&(0,P.jsx)(K,{profileId:d.profileId,teamHint:d.teamHint,teams:U,onClose:()=>{f(null),I()}}),p&&(0,P.jsx)(q,{profileGroup:p,teams:U,onClose:()=>{m(null),I()},onSpawned:e=>{m(null),u.navigate({to:`/teams/$id`,params:{id:e}})}}),h&&(0,P.jsx)(G,{onClose:()=>{v(!1),I()}}),(0,P.jsx)(Z,{agent:C,onOpenChange:e=>{e||w(null)},onRename:async(e,t)=>{M(null);try{await B(e,t)}catch(e){throw M(e instanceof Error?e.message:String(e)),e}}}),(0,P.jsx)(g,{open:T!==null,onOpenChange:e=>{e||E(null)},title:`Archive ${T?.name??`agent`}?`,description:(0,P.jsx)(`p`,{children:`The Agent will stop appearing in this sidebar and cannot receive normal work. You can restore it later from the Agents page with “Show archived”.`}),confirmLabel:`Archive agent`,confirmVariant:`primary`,onConfirm:async()=>{if(T){M(null);try{await V(T)}catch(e){throw M(e instanceof Error?e.message:String(e)),e}}}})]})}function Z({agent:e,onOpenChange:t,onRename:n}){let[r,i]=(0,A.useState)(``),[a,o]=(0,A.useState)(!1),[s,c]=(0,A.useState)(null);function l(n){!n&&a||(n&&e&&i(e.name),n||(i(``),c(null),o(!1)),t(n))}async function u(t){if(t.preventDefault(),!(!e||!r.trim()||r.trim()===e.name)){o(!0),c(null);try{await n(e,r),l(!1)}catch(e){c(e instanceof Error?e.message:String(e)),o(!1)}}}return(0,P.jsx)(L,{open:e!==null,onOpenChange:l,children:(0,P.jsx)(B,{showCloseButton:!a,children:(0,P.jsxs)(`form`,{onSubmit:e=>void u(e),children:[(0,P.jsxs)(V,{children:[(0,P.jsxs)(U,{children:[`Rename `,e?.name??`agent`]}),(0,P.jsx)(W,{children:`This changes the display name only; the Agent ID and history stay the same.`})]}),(0,P.jsxs)(`label`,{className:`mt-4 block text-sm font-semibold text-foreground`,children:[`Agent name`,(0,P.jsx)(`input`,{autoFocus:!0,className:`mt-1`,value:r||e?.name||``,onChange:e=>i(e.target.value),maxLength:120})]}),s&&(0,P.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:s}),(0,P.jsxs)(H,{className:`mt-4`,children:[(0,P.jsx)(T,{variant:`ghost`,disabled:a,onClick:()=>l(!1),children:`Cancel`}),(0,P.jsx)(T,{variant:`primary`,type:`submit`,disabled:a||!r.trim()||r.trim()===e?.name,children:a?`Renaming…`:`Rename agent`})]})]})})})}function Q(){let e=S.useLoaderData(),t=e.selected?.resolved.agent.id??null;return(0,P.jsxs)(`div`,{className:`grid h-full min-h-0 grid-cols-1 gap-3 py-3 lg:grid-cols-[18rem_minmax(0,1fr)]`,children:[(0,P.jsx)(`div`,{className:`min-h-0 ${e.selected?`hidden lg:block`:``}`,children:(0,P.jsx)(X,{agents:e.agents,teams:e.teams,profiles:e.profiles,profileGroups:e.profileGroups,selectedAgentId:t,initialOpenGroups:e.initialOpenGroups})}),(0,P.jsx)(`section`,{className:`min-h-0 overflow-hidden ${e.selected?``:`hidden lg:block`}`,children:e.selected?(0,P.jsx)(E,{agentId:e.selected.resolved.agent.id,agentName:e.selected.resolved.agent.name,initialMessages:e.selected.initialMessages,initialSessionHead:e.selected.sessionHead}):(0,P.jsx)(`div`,{className:`flex h-full items-center justify-center rounded-2xl border border-dashed bg-card px-6 text-center text-muted-foreground`,children:(0,P.jsxs)(`div`,{className:`max-w-sm`,children:[(0,P.jsx)(`h1`,{className:`m-0 font-body text-lg font-semibold text-foreground`,children:e.agents.length===0?`Start your first conversation`:`Choose an agent`}),(0,P.jsx)(`p`,{className:`mt-2 text-sm leading-6`,children:e.agents.length===0?`Your default Team and Agent template are ready. Use “Spawn first agent” on the left to create a working member.`:`Pick an agent in the Team list to open its persistent conversation.`}),e.agents.length===0&&(0,P.jsx)(`a`,{href:`/agents`,className:`btn-primary mt-4 no-underline`,children:`Open agent setup`})]})})})]})}export{Q as component};
|
|
1
|
+
import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{a as r,d as i,o as a}from"./preload-helper-bztXdkDj.js";import{t as o}from"./chevron-right-C7P3Z105.js";import{n as s,t as c}from"./x-D8yuCam7.js";import{a as l,c as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./ConfirmDialog-Br19uXWH.js";import{ft as _,gt as v,ht as y,lt as b,mt as x,q as S}from"./index-CwMw0pnV.js";import{n as C,t as w}from"./utils-B6KiDbIe.js";import{t as T}from"./Button-ByiV6fpd.js";import{t as E}from"./ChatPane-CGCtAuD3.js";import"./wire-constants-CBD-lTaa.js";var D=v(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),O=v(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),k=v(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),A=e(n(),1),j=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,M=C,N=(e,t)=>n=>{if(t?.variants==null)return M(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=j(t)||j(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return M(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)},P=t(),F=N(`team/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,outline:`border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground`,ghost:`hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50`,destructive:`bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,xs:`h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-team]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-team]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,icon:`size-8`,"icon-xs":`size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-team]:rounded-lg [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-team]:rounded-lg`,"icon-lg":`size-9`}},defaultVariants:{variant:`default`,size:`default`}});function I({className:e,variant:t=`default`,size:n=`default`,asChild:r=!1,...i}){return(0,P.jsx)(r?b:`button`,{"data-slot":`button`,"data-variant":t,"data-size":n,className:w(F({variant:t,size:n,className:e})),...i})}function L({...e}){return(0,P.jsx)(f,{"data-slot":`dialog`,...e})}function R({...e}){return(0,P.jsx)(h,{"data-slot":`dialog-portal`,...e})}function z({className:e,...t}){return(0,P.jsx)(p,{"data-slot":`dialog-overlay`,className:w(`fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function B({className:e,children:t,showCloseButton:n=!0,...r}){return(0,P.jsxs)(R,{children:[(0,P.jsx)(z,{}),(0,P.jsxs)(d,{"data-slot":`dialog-content`,className:w(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r,children:[t,n&&(0,P.jsx)(m,{"data-slot":`dialog-close`,asChild:!0,children:(0,P.jsxs)(I,{variant:`ghost`,className:`absolute top-2 right-2`,size:`icon-sm`,children:[(0,P.jsx)(c,{}),(0,P.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function V({className:e,...t}){return(0,P.jsx)(`div`,{"data-slot":`dialog-header`,className:w(`flex flex-col gap-2`,e),...t})}function H({className:e,showCloseButton:t=!1,children:n,...r}){return(0,P.jsxs)(`div`,{"data-slot":`dialog-footer`,className:w(`-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end`,e),...r,children:[n,t&&(0,P.jsx)(m,{asChild:!0,children:(0,P.jsx)(I,{variant:`outline`,children:`Close`})})]})}function U({className:e,...t}){return(0,P.jsx)(u,{"data-slot":`dialog-title`,className:w(`font-heading text-base leading-none font-medium`,e),...t})}function W({className:e,...t}){return(0,P.jsx)(l,{"data-slot":`dialog-description`,className:w(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function G({onClose:e}){let t=i(),[n,r]=(0,A.useState)(``),[a,o]=(0,A.useState)(``),[s,c]=(0,A.useState)(``),[l,u]=(0,A.useState)(!1),[d,f]=(0,A.useState)(null);async function p(r){if(r.preventDefault(),f(null),!n.trim()){f(`id is required`);return}u(!0);try{let r={id:n.trim()};a.trim()&&(r.name=a.trim()),s.trim()&&(r.link=s.trim());let i=await fetch(`/api/teams`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(r)});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.error??`${i.status} ${i.statusText}`)}e(),await t.invalidate()}catch(e){f(e.message),u(!1)}}return(0,P.jsx)(L,{open:!0,onOpenChange:t=>{!t&&!l&&e()},children:(0,P.jsx)(B,{showCloseButton:!l,className:`max-h-[calc(100dvh-2rem)] w-full max-w-lg overflow-y-auto rounded-3xl border border-frost bg-card p-6 shadow-baziu-lg sm:p-7`,onEscapeKeyDown:e=>{l&&e.preventDefault()},onPointerDownOutside:e=>{l&&e.preventDefault()},children:(0,P.jsxs)(`form`,{onSubmit:p,children:[(0,P.jsxs)(V,{children:[(0,P.jsx)(U,{className:`font-serif text-2xl text-foreground`,children:`Create a team`}),(0,P.jsxs)(W,{children:[`A team is a collaboration context — one filesystem root, one USER.md, one roster. The slot lives at `,(0,P.jsx)(`code`,{className:`font-mono`,children:`~/.bazilion/teams/<slug>/`}),`.`]})]}),(0,P.jsxs)(`div`,{className:`mb-3 mt-4 grid gap-3 sm:grid-cols-2`,children:[(0,P.jsxs)(`label`,{className:`block text-sm`,children:[`ID (slug)`,(0,P.jsx)(`input`,{type:`text`,value:n,onChange:e=>r(e.target.value),required:!0,pattern:`[a-z0-9][a-z0-9_-]*`,placeholder:`myproject`,className:`mt-1 block w-full rounded-md border bg-background px-3 py-2 outline-none focus:ring-2 focus:ring-ring/30`})]}),(0,P.jsxs)(`label`,{className:`block text-sm`,children:[`Name `,(0,P.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`}),(0,P.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),className:`mt-1 block w-full rounded-md border bg-background px-3 py-2 outline-none focus:ring-2 focus:ring-ring/30`})]})]}),(0,P.jsxs)(`label`,{className:`mb-3 block text-sm`,children:[`Link target`,` `,(0,P.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional, absolute path)`}),(0,P.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:`/home/you/projects/myrepo`,className:`mt-1 block w-full rounded-md border bg-background px-3 py-2 outline-none focus:ring-2 focus:ring-ring/30`}),(0,P.jsx)(`span`,{className:`mt-1 block text-xs text-muted-foreground`,children:`Leave blank to create a fresh directory. Supply an absolute path to materialize the slot as a symlink to your existing project tree.`})]}),d&&(0,P.jsx)(`p`,{role:`alert`,className:`err mt-2`,children:d}),(0,P.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,P.jsx)(T,{variant:`ghost`,disabled:l,onClick:e,children:`Cancel`}),(0,P.jsx)(T,{variant:`primary`,type:`submit`,disabled:l,children:l?`Creating…`:`Create team`})]})]})})})}function K({profileId:e,teamHint:t,teams:n,onClose:r}){let i=a(),[o,s]=(0,A.useState)(``),[c,l]=(0,A.useState)(t??n.find(e=>e.id==="default")?.id??n[0]?.id??``),[u,d]=(0,A.useState)(`profile_defaults`),[f,p]=(0,A.useState)(!1),[m,h]=(0,A.useState)(null),[g,_]=(0,A.useState)(null);async function v(){let t=await fetch(`/api/teams/${encodeURIComponent(c)}/policy`);if(!t.ok)throw Error(`The selected Team policy is unavailable. Reload and try again.`);let n=await t.json();return{current:n,body:{profileId:e,teamId:c,teamExpectedRevision:n.teamPolicy.revision,placement:u}}}async function y(){h(null),p(!0);try{let{body:e}=await v(),t=await fetch(`/api/agents/placement-preview`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error??`Preview failed (${t.status})`)}_(await t.json())}catch(e){h(e.message)}finally{p(!1)}}async function b(t){t.preventDefault(),h(null),p(!0);try{if(!g){await y();return}let t={profile:e,teamExpectedRevision:g.currentRevision,placement:u};o.trim()&&(t.name=o.trim()),c&&(t.teamId=c);let n=await fetch(`/api/agents`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`${n.status} ${n.statusText}`)}let a=(await n.json()).agent;r(),await i({to:`/`,search:{agent:a.id}})}catch(e){h(e.message),p(!1)}}return(0,P.jsx)(L,{open:!0,onOpenChange:e=>{!e&&!f&&r()},children:(0,P.jsx)(B,{showCloseButton:!f,className:`max-h-[calc(100dvh-2rem)] w-full max-w-lg overflow-y-auto rounded-3xl border border-frost bg-card p-6 shadow-baziu-lg sm:p-7`,onEscapeKeyDown:e=>{f&&e.preventDefault()},onPointerDownOutside:e=>{f&&e.preventDefault()},children:(0,P.jsxs)(`form`,{onSubmit:b,children:[(0,P.jsxs)(V,{children:[(0,P.jsx)(U,{className:`font-serif text-xl text-foreground`,children:`Spawn a new agent`}),(0,P.jsxs)(W,{children:[`Create an agent from profile `,(0,P.jsx)(`code`,{className:`font-mono`,children:e}),`, then review its exact Team policy placement before committing.`]})]}),(0,P.jsxs)(`label`,{className:`mb-3 mt-4 block text-sm text-foreground`,children:[`Agent name`,` `,(0,P.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional — defaults to the profile's name)`}),(0,P.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),autoComplete:`off`,className:`mt-1 block w-full rounded-md border bg-background px-3 py-2 outline-none focus:ring-2 focus:ring-ring/30`})]}),(0,P.jsxs)(`label`,{className:`mb-3 block text-sm text-foreground`,children:[`Initial policy placement`,(0,P.jsxs)(`select`,{value:u,onChange:e=>{d(e.target.value),_(null)},className:`mt-1 block w-full rounded-md border bg-background px-3 py-2`,children:[(0,P.jsx)(`option`,{value:`profile_defaults`,children:`Agent-template defaults`}),(0,P.jsx)(`option`,{value:`isolated`,children:`Isolated`})]}),(0,P.jsx)(`span`,{className:`mt-1 block text-xs text-muted-foreground`,children:`The current Team revision is checked again when you submit.`})]}),(0,P.jsxs)(`label`,{className:`mb-3 block text-sm text-foreground`,children:[`Team`,(0,P.jsx)(`select`,{value:c,onChange:e=>{l(e.target.value),_(null)},className:`mt-1 block w-full rounded-md border bg-background px-3 py-2 outline-none focus:ring-2 focus:ring-ring/30`,children:n.map(e=>(0,P.jsxs)(`option`,{value:e.id,children:[e.name,e.id==="default"?` (default)`:``]},e.id))})]}),m&&(0,P.jsx)(`p`,{role:`alert`,className:`err mt-2`,children:m}),g&&(0,P.jsxs)(`div`,{role:`status`,className:`mt-3 rounded-md border border-sapphire-light bg-sapphire-glow p-3 text-sm`,children:[(0,P.jsxs)(`p`,{children:[`Creating this Agent advances Team revision `,g.currentRevision,` →`,` `,(0,P.jsx)(`strong`,{children:g.resultingRevision}),` and adds`,` `,(0,P.jsx)(`strong`,{children:g.addedEdges.length}),` directed edges to the existing`,` `,g.existingEdges.length,`.`]}),(0,P.jsx)(`ul`,{className:`mt-2 max-h-36 overflow-auto`,children:g.addedEdges.map((e,t)=>(0,P.jsx)(`li`,{children:(0,P.jsxs)(`code`,{children:[e.sourceKind,e.sourceId?`:${e.sourceId}`:``,` → `,e.targetKind,e.targetId?`:${e.targetId}`:``]})},`${e.sourceKind}:${e.sourceId??``}>${e.targetKind}:${e.targetId??``}:${t}`))}),g.addedEdges.length===0&&(0,P.jsx)(`p`,{className:`mt-2`,children:`The new Agent starts isolated.`})]}),(0,P.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,P.jsx)(T,{variant:`ghost`,disabled:f,onClick:r,children:`Cancel`}),(0,P.jsx)(T,{variant:`primary`,type:`submit`,disabled:f,children:f?`Working…`:g?`Commit reviewed creation`:`Review exact policy`})]})]})})})}function q({profileGroup:e,teams:t,onClose:n,onSpawned:r}){let[i,a]=(0,A.useState)(``),[o,s]=(0,A.useState)(``),[c,l]=(0,A.useState)(null),[u,d]=(0,A.useState)(!1),[f,p]=(0,A.useState)(null);async function m(){let n=i.trim();if(!n)throw Error(`Target Team slug is required`);let r=t.find(e=>e.id===n),a;if(r){let e=await fetch(`/api/teams/${encodeURIComponent(n)}/policy`);if(!e.ok)throw Error(`The target Team policy is unavailable.`);a=(await e.json()).teamPolicy.revision}return{target:n,body:{templateExpectedRevision:e.currentRevision,teamId:n,...a?{teamExpectedRevision:a}:{},mode:r?`append`:`initialize`,...o?{userMd:o}:{}}}}async function h(){d(!0),l(null),p(null);try{let{body:t}=await m(),n=await fetch(`/api/team-templates/${encodeURIComponent(e.id)}/spawn/preview`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(!n.ok)throw Error((await n.json().catch(()=>null))?.error??n.statusText);p(await n.json())}catch(e){l(e.message)}finally{d(!1)}}async function g(){let t=i.trim();if(!t){l(`Target Team slug is required`);return}d(!0),l(null);try{let{body:n}=await m(),i=await fetch(`/api/team-templates/${encodeURIComponent(e.id)}/spawn`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n)});if(!i.ok)throw Error((await i.json().catch(()=>null))?.error??i.statusText);r(t)}catch(e){l(e.message)}finally{d(!1)}}return(0,P.jsx)(L,{open:!0,onOpenChange:e=>{!e&&!u&&n()},children:(0,P.jsxs)(B,{showCloseButton:!u,className:`max-h-[calc(100dvh-2rem)] w-full max-w-lg overflow-y-auto rounded-3xl border border-frost bg-card p-6 shadow-baziu-lg sm:p-7`,onEscapeKeyDown:e=>{u&&e.preventDefault()},onPointerDownOutside:e=>{u&&e.preventDefault()},children:[(0,P.jsxs)(V,{children:[(0,P.jsxs)(U,{className:`font-serif text-xl text-foreground`,children:[`Spawn team — `,e.name]}),(0,P.jsxs)(W,{children:[`Uses immutable Team revision `,e.currentRevision,`. Existing Teams append at their current reviewed revision; a new Team initializes at revision 1. Conflicts never overwrite newer state.`]})]}),c&&(0,P.jsx)(`div`,{role:`alert`,className:`err`,children:c}),(0,P.jsxs)(`label`,{children:[`Target Team slug`,(0,P.jsx)(`input`,{value:i,onChange:e=>{a(e.target.value),p(null)},list:`canonical-teams`,required:!0}),(0,P.jsx)(`datalist`,{id:`canonical-teams`,children:t.map(e=>(0,P.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,P.jsxs)(`label`,{children:[`Starter USER.md (new Team only)`,(0,P.jsx)(`textarea`,{rows:3,value:o,onChange:e=>{s(e.target.value),p(null)},className:`font-mono text-[0.88em] leading-[1.55]`})]}),f&&(0,P.jsxs)(`div`,{role:`status`,className:`mt-4 rounded-md border border-sapphire-light bg-sapphire-glow p-3 text-sm`,children:[(0,P.jsxs)(`p`,{children:[(0,P.jsx)(`strong`,{children:f.mode===`initialize`?`Initialize`:`Append`}),` produces Team revision `,f.resultingRevision,`, adds `,f.newMembers.length,` Agents, and results in `,f.edges.length,` directed allow edges.`]}),(0,P.jsx)(`ul`,{className:`mt-2 max-h-40 overflow-auto`,children:f.newMembers.map(e=>(0,P.jsxs)(`li`,{children:[e.agentName,` · stable source slot `,(0,P.jsx)(`code`,{children:e.slotId})]},e.slotId))}),(0,P.jsxs)(`details`,{className:`mt-2`,children:[(0,P.jsx)(`summary`,{className:`cursor-pointer`,children:`Review exact edge topology`}),(0,P.jsx)(`ul`,{className:`mt-2 max-h-40 overflow-auto`,children:f.edges.map((e,t)=>(0,P.jsx)(`li`,{children:(0,P.jsxs)(`code`,{children:[e.sourceKind,e.sourceId?`:${e.sourceId}`:``,` → `,e.targetKind,e.targetId?`:${e.targetId}`:``]})},`${e.sourceKind}:${e.sourceId??``}>${e.targetKind}:${e.targetId??``}:${t}`))})]})]}),(0,P.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,P.jsx)(T,{variant:`ghost`,disabled:u,onClick:n,children:`Cancel`}),f?(0,P.jsx)(T,{variant:`primary`,onClick:g,disabled:u,children:u?`Spawning…`:`Commit ${f.mode}`}):(0,P.jsx)(T,{variant:`primary`,onClick:h,disabled:u||e.slotCount===0,children:u?`Reviewing…`:`Review exact result`})]})]})})}var J=`bz_sidebar_open_groups`;function Y(e){if(typeof document>`u`)return;let t=encodeURIComponent(JSON.stringify(e));document.cookie=`${J}=${t}; Path=/; Max-Age=31536000; SameSite=Lax`}function X({agents:e,teams:t,profiles:n,profileGroups:a,selectedAgentId:c,initialOpenGroups:l}){let u=i(),[d,f]=(0,A.useState)(null),[p,m]=(0,A.useState)(null),[h,v]=(0,A.useState)(!1),[b,S]=(0,A.useState)(!1),[C,w]=(0,A.useState)(null),[T,E]=(0,A.useState)(null),[j,M]=(0,A.useState)(null),N=(0,A.useRef)(null),F=(0,A.useRef)(null),I=()=>window.requestAnimationFrame(()=>N.current?.focus()),[L,R]=(0,A.useState)(()=>l??{});(0,A.useEffect)(()=>{if(!b)return;let e=F.current;window.requestAnimationFrame(()=>{e?.querySelector(`[role="menuitem"]:not([disabled])`)?.focus()});let t=t=>{e?.contains(t.target)||N.current?.contains(t.target)||(S(!1),I())},n=e=>{e.key===`Escape`&&(e.preventDefault(),S(!1),I())};return document.addEventListener(`pointerdown`,t),document.addEventListener(`keydown`,n),()=>{document.removeEventListener(`pointerdown`,t),document.removeEventListener(`keydown`,n)}},[b]);function z(e){if(![`ArrowDown`,`ArrowUp`,`Home`,`End`].includes(e.key))return;let t=Array.from(e.currentTarget.querySelectorAll(`[role="menuitem"]:not([disabled])`));if(t.length===0)return;e.preventDefault();let n=t.indexOf(document.activeElement);t[e.key===`Home`?0:e.key===`End`?t.length-1:e.key===`ArrowDown`?(n+1+t.length)%t.length:(n-1+t.length)%t.length]?.focus()}async function B(e,t){let n=t.trim();if(!n||n===e.name)return;let r=await fetch(`/api/agents/${e.id}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({name:n})});if(!r.ok){let e=await r.json().catch(()=>null);throw Error(e?.error??`Could not rename agent (${r.status})`)}await u.invalidate()}async function V(e){let t=await fetch(`/api/agents/${e.id}/archive`,{method:`POST`});if(!t.ok&&t.status!==204){let e=await t.json().catch(()=>null);throw Error(e?.error??`Could not archive agent (${t.status})`)}await u.invalidate()}let H=[...n].sort((e,t)=>e.id==="default"?-1:+(t.id==="default")),U=[...t].sort((e,t)=>e.id==="default"?-1:+(t.id==="default")),W=new Map;for(let t of e){let e=W.get(t.teamId)??[];e.push(t),W.set(t.teamId,e)}let J=e.find(e=>e.id===c)?.teamId??null;return(0,P.jsxs)(`aside`,{className:`flex h-full flex-col overflow-hidden rounded-2xl border border-border bg-card shadow-baziu-sm`,children:[(0,P.jsxs)(`header`,{className:`flex items-center justify-between gap-3 border-b border-border bg-muted/30 px-3 py-2.5`,children:[(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-foreground`,children:[(0,P.jsx)(`span`,{className:`flex size-7 items-center justify-center rounded-lg bg-accent text-accent-foreground`,children:(0,P.jsx)(y,{className:`size-4`,"aria-hidden":`true`})}),(0,P.jsx)(`span`,{children:`Agents`})]}),(0,P.jsxs)(`p`,{className:`mt-0.5 truncate pl-9 text-xs text-muted-foreground`,children:[e.length,` agent`,e.length===1?``:`s`,` across `,t.length,` team`,t.length===1?``:`s`]})]}),(0,P.jsxs)(`div`,{className:`relative`,children:[(0,P.jsxs)(`button`,{ref:N,id:`sidebar-new-menu-button`,type:`button`,onClick:()=>S(e=>!e),"aria-label":`Create a new Agent or Team`,"aria-controls":b?`sidebar-new-menu`:void 0,"aria-expanded":b,"aria-haspopup":`menu`,className:`unstyled inline-flex h-8 items-center gap-1 rounded-lg border border-border bg-card px-2.5 text-xs font-semibold text-foreground shadow-baziu-sm transition-colors hover:border-primary/30 hover:bg-accent hover:text-accent-foreground`,children:[(0,P.jsx)(s,{className:`size-3.5`,"aria-hidden":`true`}),`New`,(0,P.jsx)(x,{className:`size-3.5 text-muted-foreground transition-transform ${b?`rotate-180`:``}`,"aria-hidden":`true`})]}),b&&(0,P.jsxs)(`div`,{ref:F,id:`sidebar-new-menu`,role:`menu`,"aria-labelledby":`sidebar-new-menu-button`,className:`absolute right-0 top-[calc(100%+0.4rem)] z-20 w-60 overflow-hidden rounded-xl border border-border bg-popover p-1.5 text-popover-foreground shadow-baziu-lg`,onKeyDown:z,children:[n.length===0?(0,P.jsxs)(`div`,{className:`rounded-lg bg-muted/40 px-3 py-2.5 text-xs leading-5 text-muted-foreground`,children:[`No Agent templates yet.`,` `,(0,P.jsx)(`a`,{href:`/templates/agents`,role:`menuitem`,className:`text-primary underline`,children:`Create one to spawn agents.`})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-xs font-semibold uppercase tracking-[0.08em] text-muted-foreground`,children:[(0,P.jsx)(y,{className:`size-3`,"aria-hidden":`true`}),`Agent templates`]}),H.map(e=>(0,P.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{S(!1),f({profileId:e.id})},className:`unstyled flex min-h-8 w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-sm text-foreground transition-colors hover:bg-accent hover:text-accent-foreground`,children:[(0,P.jsx)(`span`,{className:`flex size-6 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground`,children:(0,P.jsx)(y,{className:`size-3.5`,"aria-hidden":`true`})}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name||e.id}),e.id==="default"&&(0,P.jsx)(`span`,{className:`rounded-full border border-border bg-muted px-1.5 py-0.5 text-xs font-semibold text-muted-foreground`,children:`Default`})]},e.id))]}),(0,P.jsx)(`div`,{className:`my-1.5 h-px bg-border`}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-xs font-semibold uppercase tracking-[0.08em] text-muted-foreground`,children:[(0,P.jsx)(_,{className:`size-3`,"aria-hidden":`true`}),`Team templates`]}),a.length===0?(0,P.jsxs)(`div`,{className:`rounded-lg bg-muted/40 px-3 py-2 text-xs leading-5 text-muted-foreground`,children:[`No team templates yet.`,` `,(0,P.jsx)(`a`,{href:`/templates/teams`,role:`menuitem`,className:`text-primary underline`,children:`Create one`}),`.`]}):a.map(e=>(0,P.jsxs)(`button`,{type:`button`,role:`menuitem`,disabled:e.slotCount===0,title:e.slotCount===0?`Add at least one member before spawning`:void 0,onClick:()=>{S(!1),m(e)},className:`unstyled flex min-h-8 w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-sm text-foreground transition-colors hover:bg-accent hover:text-accent-foreground disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent`,children:[(0,P.jsx)(`span`,{className:`flex size-6 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground`,children:(0,P.jsx)(_,{className:`size-3.5`,"aria-hidden":`true`})}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name||e.id}),(0,P.jsx)(`span`,{className:`inline-flex min-w-6 items-center justify-center rounded-full bg-muted px-1.5 font-mono text-xs text-muted-foreground`,children:e.slotCount})]},e.id)),(0,P.jsx)(`div`,{className:`my-1.5 h-px bg-border`}),(0,P.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{S(!1),v(!0)},className:`unstyled flex min-h-8 w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground`,children:[(0,P.jsx)(s,{className:`size-3.5`,"aria-hidden":`true`}),`Create a team`]})]})]})]}),j&&(0,P.jsx)(`p`,{role:`alert`,className:`m-2 rounded-lg bg-danger/10 px-3 py-2 text-xs text-danger`,children:j}),(0,P.jsx)(`nav`,{className:`flex-1 overflow-y-auto p-1.5`,"aria-label":`Teams and agents`,children:e.length===0?(0,P.jsxs)(`div`,{className:`m-1 flex flex-col items-center rounded-xl border border-dashed border-border bg-muted/30 px-4 py-6 text-center`,children:[(0,P.jsx)(`span`,{className:`mb-2 flex size-9 items-center justify-center rounded-full bg-accent text-accent-foreground`,children:(0,P.jsx)(y,{className:`size-4`,"aria-hidden":`true`})}),(0,P.jsx)(`p`,{className:`text-sm font-semibold text-foreground`,children:`No agents yet`}),(0,P.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:`Your default Team is ready. Spawn the first agent to start a conversation.`}),H[0]?(0,P.jsxs)(`button`,{type:`button`,onClick:()=>f({profileId:H[0]?.id??`default`}),className:`unstyled mt-3 inline-flex min-h-9 items-center gap-1 rounded-lg bg-primary px-3 text-xs font-semibold text-primary-foreground hover:bg-primary/90`,children:[`Spawn first agent`,(0,P.jsx)(o,{className:`size-3.5`,"aria-hidden":`true`})]}):(0,P.jsxs)(`a`,{href:`/templates/agents`,className:`mt-3 inline-flex items-center gap-1 text-xs font-semibold text-primary hover:text-primary/80`,children:[`Create an Agent template`,(0,P.jsx)(o,{className:`size-3.5`,"aria-hidden":`true`})]})]}):U.map(e=>{let t=W.get(e.id)??[],n=J===e.id,i=L[e.id];return(0,P.jsxs)(`details`,{open:i===void 0?n||e.id==="default":i,onToggle:t=>{let n=t.currentTarget.open;if(L[e.id]===n)return;let r={...L,[e.id]:n};Y(r),R(r),u.invalidate()},className:`team/details mb-1 last:mb-0`,children:[(0,P.jsxs)(`summary`,{className:`flex min-h-8 cursor-pointer list-none items-center gap-1.5 rounded-lg px-2 py-1.5 text-sm transition-colors hover:bg-accent hover:text-accent-foreground ${n?`bg-muted/60 text-foreground`:`text-muted-foreground`}`,children:[(0,P.jsx)(o,{className:`size-3.5 shrink-0 transition-transform team-open/details:rotate-90`,"aria-hidden":`true`}),(0,P.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground`,children:(0,P.jsx)(_,{className:`size-3`,"aria-hidden":`true`})}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:e.name}),e.id==="default"&&(0,P.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Default`}),(0,P.jsx)(`span`,{className:`inline-flex min-w-6 items-center justify-center rounded-full border border-border bg-card px-1.5 font-mono text-xs text-muted-foreground`,children:t.length})]}),t.length===0?(0,P.jsx)(`div`,{className:`py-2 pl-12 pr-2 text-xs text-muted-foreground`,children:`No agents in this team`}):(0,P.jsx)(`div`,{className:`space-y-0.5 py-0.5 pl-2`,children:t.map(e=>(0,P.jsxs)(`div`,{className:`team/row relative rounded-lg`,children:[(0,P.jsxs)(r,{to:`/`,search:{agent:e.id},"aria-current":e.id===c?`page`:void 0,className:`block min-h-11 rounded-lg border border-transparent py-1.5 pl-2.5 pr-[4.6rem] transition-colors hover:bg-accent/70 ${e.id===c?`border-primary/20 bg-accent text-accent-foreground shadow-baziu-sm`:`text-foreground`}`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium`,children:[(0,P.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full ${e.id===c?`bg-primary`:`bg-border`}`,"aria-hidden":`true`}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),e.telegramTopicId!==null&&(0,P.jsx)(`span`,{className:`shrink-0 text-primary`,title:`Telegram topic #${e.telegramTopicId}`,"aria-label":`Bound to Telegram topic ${e.telegramTopicId}`,children:(0,P.jsx)(k,{className:`size-3`,"aria-hidden":`true`})})]}),(0,P.jsxs)(`div`,{className:`mt-0.5 flex gap-2 pl-3 font-mono text-xs text-muted-foreground`,children:[(0,P.jsx)(`span`,{className:`uppercase tracking-wide`,children:e.status}),(0,P.jsx)(`span`,{children:e.id.slice(0,8)})]})]}),(0,P.jsxs)(`div`,{className:`absolute right-1 top-1/2 z-10 flex -translate-y-1/2 gap-0.5`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>w(e),title:`Rename`,"aria-label":`Rename ${e.name}`,className:`unstyled flex size-8 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-card hover:text-primary focus-visible:bg-card`,children:(0,P.jsx)(O,{className:`size-3.5`,"aria-hidden":`true`})}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>E(e),title:`Archive`,"aria-label":`Archive ${e.name}`,className:`unstyled flex size-8 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:bg-destructive/10 focus-visible:text-destructive`,children:(0,P.jsx)(D,{className:`size-3.5`,"aria-hidden":`true`})})]})]},e.id))})]},e.id)})}),d&&(0,P.jsx)(K,{profileId:d.profileId,teamHint:d.teamHint,teams:U,onClose:()=>{f(null),I()}}),p&&(0,P.jsx)(q,{profileGroup:p,teams:U,onClose:()=>{m(null),I()},onSpawned:e=>{m(null),u.navigate({to:`/teams/$id`,params:{id:e}})}}),h&&(0,P.jsx)(G,{onClose:()=>{v(!1),I()}}),(0,P.jsx)(Z,{agent:C,onOpenChange:e=>{e||w(null)},onRename:async(e,t)=>{M(null);try{await B(e,t)}catch(e){throw M(e instanceof Error?e.message:String(e)),e}}}),(0,P.jsx)(g,{open:T!==null,onOpenChange:e=>{e||E(null)},title:`Archive ${T?.name??`agent`}?`,description:(0,P.jsx)(`p`,{children:`The Agent will stop appearing in this sidebar and cannot receive normal work. You can restore it later from the Agents page with “Show archived”.`}),confirmLabel:`Archive agent`,confirmVariant:`primary`,onConfirm:async()=>{if(T){M(null);try{await V(T)}catch(e){throw M(e instanceof Error?e.message:String(e)),e}}}})]})}function Z({agent:e,onOpenChange:t,onRename:n}){let[r,i]=(0,A.useState)(``),[a,o]=(0,A.useState)(!1),[s,c]=(0,A.useState)(null);function l(n){!n&&a||(n&&e&&i(e.name),n||(i(``),c(null),o(!1)),t(n))}async function u(t){if(t.preventDefault(),!(!e||!r.trim()||r.trim()===e.name)){o(!0),c(null);try{await n(e,r),l(!1)}catch(e){c(e instanceof Error?e.message:String(e)),o(!1)}}}return(0,P.jsx)(L,{open:e!==null,onOpenChange:l,children:(0,P.jsx)(B,{showCloseButton:!a,children:(0,P.jsxs)(`form`,{onSubmit:e=>void u(e),children:[(0,P.jsxs)(V,{children:[(0,P.jsxs)(U,{children:[`Rename `,e?.name??`agent`]}),(0,P.jsx)(W,{children:`This changes the display name only; the Agent ID and history stay the same.`})]}),(0,P.jsxs)(`label`,{className:`mt-4 block text-sm font-semibold text-foreground`,children:[`Agent name`,(0,P.jsx)(`input`,{autoFocus:!0,className:`mt-1`,value:r||e?.name||``,onChange:e=>i(e.target.value),maxLength:120})]}),s&&(0,P.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:s}),(0,P.jsxs)(H,{className:`mt-4`,children:[(0,P.jsx)(T,{variant:`ghost`,disabled:a,onClick:()=>l(!1),children:`Cancel`}),(0,P.jsx)(T,{variant:`primary`,type:`submit`,disabled:a||!r.trim()||r.trim()===e?.name,children:a?`Renaming…`:`Rename agent`})]})]})})})}function Q(){let e=S.useLoaderData(),t=e.selected?.resolved.agent.id??null;return(0,P.jsxs)(`div`,{className:`grid h-full min-h-0 grid-cols-1 gap-3 py-3 lg:grid-cols-[18rem_minmax(0,1fr)]`,children:[(0,P.jsx)(`div`,{className:`min-h-0 ${e.selected?`hidden lg:block`:``}`,children:(0,P.jsx)(X,{agents:e.agents,teams:e.teams,profiles:e.profiles,profileGroups:e.profileGroups,selectedAgentId:t,initialOpenGroups:e.initialOpenGroups})}),(0,P.jsx)(`section`,{className:`min-h-0 overflow-hidden ${e.selected?``:`hidden lg:block`}`,children:e.selected?(0,P.jsx)(E,{agentId:e.selected.resolved.agent.id,agentName:e.selected.resolved.agent.name,initialMessages:e.selected.initialMessages,initialSessionHead:e.selected.sessionHead}):(0,P.jsx)(`div`,{className:`flex h-full items-center justify-center rounded-2xl border border-dashed bg-card px-6 text-center text-muted-foreground`,children:(0,P.jsxs)(`div`,{className:`max-w-sm`,children:[(0,P.jsx)(`h1`,{className:`m-0 font-body text-lg font-semibold text-foreground`,children:e.agents.length===0?`Start your first conversation`:`Choose an agent`}),(0,P.jsx)(`p`,{className:`mt-2 text-sm leading-6`,children:e.agents.length===0?`Your default Team and Agent template are ready. Use “Spawn first agent” on the left to create a working member.`:`Pick an agent in the Team list to open its persistent conversation.`}),e.agents.length===0&&(0,P.jsx)(`a`,{href:`/agents`,className:`btn-primary mt-4 no-underline`,children:`Open agent setup`})]})})})]})}export{Q as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./jsx-runtime-DGeXAQPT.js";import{R as t}from"./index-
|
|
1
|
+
import{t as e}from"./jsx-runtime-DGeXAQPT.js";import{R as t}from"./index-CwMw0pnV.js";import{a as n,t as r}from"./Page-NV96O47A.js";import{t as i}from"./ConfigPage-BCLp-FUC.js";import{t as a}from"./FieldRow-Csy3_cH5.js";var o=e(),s=`Other`;function c(e){let t=new Map;for(let n of e){let e=n.team??s,r=t.get(e)??[];r.push(n),t.set(e,r)}let n=Array.from(t,([e,t])=>({team:e,items:t}));return n.length>1&&n.sort((e,t)=>e.team===s?1:t.team===s?-1:0),n}function l(){let{services:e}=t.useLoaderData(),s=c(e);return(0,o.jsxs)(i,{active:`services`,title:`Services`,description:(0,o.jsx)(o.Fragment,{children:`Connect optional tools such as web search and crawlers. Secret values are encrypted; endpoint details remain inspectable and editable on this device.`}),children:[e.length===0&&(0,o.jsx)(r,{title:`No optional services`,description:`This Bazilion build has no additional service connectors registered.`}),s.map(({team:e,items:t})=>(0,o.jsxs)(`section`,{className:`space-y-3`,children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`h2`,{className:`m-0 font-body text-base font-semibold text-foreground`,children:e}),(0,o.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Open only the service you want to configure.`})]}),t.map(e=>{let t=e.fields.filter(e=>e.set).length;return(0,o.jsxs)(`details`,{open:t>0,className:`overflow-hidden rounded-2xl border border-border bg-card shadow-baziu-sm`,children:[(0,o.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-3 px-4 py-4 marker:hidden sm:px-5`,children:[(0,o.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,o.jsx)(`span`,{className:`block font-semibold text-foreground`,children:e.displayName}),(0,o.jsx)(`span`,{className:`mt-0.5 block font-mono text-xs text-muted-foreground`,children:e.id})]}),(0,o.jsx)(n,{variant:t>0?`success`:`neutral`,children:t>0?`${t} field${t===1?``:`s`} configured`:`Not configured`})]}),(0,o.jsxs)(`div`,{className:`border-t border-border px-4 py-4 sm:px-5`,children:[e.hint&&(0,o.jsx)(`p`,{className:`mb-2 text-sm text-muted-foreground`,children:e.hint}),e.fields.map(e=>(0,o.jsx)(a,{field:e},e.envVar))]})]},e.id)})]},e))]})}export{l as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{d as r}from"./preload-helper-bztXdkDj.js";import{t as i}from"./ConfirmDialog-
|
|
1
|
+
import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{d as r}from"./preload-helper-bztXdkDj.js";import{t as i}from"./ConfirmDialog-Br19uXWH.js";import{G as a}from"./index-CwMw0pnV.js";import{a as o,i as s,n as c,r as l,t as u}from"./Page-NV96O47A.js";import{t as d}from"./Button-ByiV6fpd.js";var f=e(n()),p=t();function m(){let e=a.useLoaderData(),t=r(),[n,m]=(0,f.useState)(null),[_,v]=(0,f.useState)(null);async function y(e){let n=await fetch(`/api/skills/${encodeURIComponent(e)}`,{method:`DELETE`});if(!n.ok&&n.status!==204){let e=await n.json().catch(()=>null);throw Error(e?.error??`Could not remove skill (${n.status})`)}await t.invalidate()}return(0,p.jsxs)(l,{size:`wide`,children:[(0,p.jsx)(c,{title:`Skills`,description:`Install and review the prompt-only skills available to your agents.`}),_&&(0,p.jsx)(`p`,{role:`alert`,className:`err`,children:_}),(0,p.jsx)(h,{onImported:()=>t.invalidate()}),(0,p.jsx)(s,{title:`Installed skills`,description:`${e.length} skill${e.length===1?``:`s`} available`,children:e.length===0?(0,p.jsx)(u,{title:`No skills installed`,description:`Import from OpenClaw, a server directory, or a ZIP archive to get started.`}):(0,p.jsx)(`div`,{className:`overflow-x-auto`,children:(0,p.jsxs)(`table`,{className:`m-0 min-w-[760px]`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`Name`}),(0,p.jsx)(`th`,{children:`Description`}),(0,p.jsx)(`th`,{children:`Scan`}),(0,p.jsx)(`th`,{children:`Source`}),(0,p.jsx)(`th`,{})]})}),(0,p.jsx)(`tbody`,{children:e.map(e=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(`code`,{children:e.name})}),(0,p.jsx)(`td`,{className:`max-w-xl`,children:e.parseError?(0,p.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[(0,p.jsx)(o,{variant:`danger`,children:`Parse error`}),(0,p.jsx)(`span`,{className:`text-destructive`,children:e.parseError})]}):e.description}),(0,p.jsx)(`td`,{children:(0,p.jsx)(g,{findings:e.scanFindings??[]})}),(0,p.jsxs)(`td`,{className:`text-xs text-muted-foreground`,children:[(0,p.jsx)(`span`,{className:`font-mono`,children:e.source??`Unknown`}),e.importedAt&&(0,p.jsx)(`div`,{className:`mt-1 font-mono`,children:new Date(e.importedAt).toLocaleDateString()})]}),(0,p.jsx)(`td`,{className:`text-right`,children:(0,p.jsx)(d,{variant:`danger`,className:`whitespace-nowrap`,onClick:()=>{v(null),m(e)},children:`Remove`})})]},e.name))})]})})}),(0,p.jsx)(i,{open:n!==null,title:`Remove skill ${n?.name??``}?`,description:(0,p.jsxs)(`p`,{children:[`This permanently deletes the installed `,(0,p.jsx)(`code`,{className:`font-mono`,children:`SKILL.md`}),` and every helper script or asset in the `,(0,p.jsx)(`code`,{className:`font-mono`,children:n?.name}),` `,`directory. The skill becomes unavailable to every Agent and Agent template until it is imported again.`]}),confirmLabel:`delete installed skill`,onConfirm:async()=>{if(n)try{await y(n.name)}catch(e){throw v(e instanceof Error?e.message:String(e)),e}},onOpenChange:e=>{e||m(null)}})]})}function h({onImported:e}){let[t,n]=(0,f.useState)(`openclaw`),[r,i]=(0,f.useState)(``),[a,c]=(0,f.useState)(!1),[l,u]=(0,f.useState)(null),[m,h]=(0,f.useState)(!1),[g,y]=(0,f.useState)(null),[b,x]=(0,f.useState)([]),[S,C]=(0,f.useState)(!1),w=(0,f.useRef)(null);async function T(n){n.preventDefault(),y(null),x([]),C(!0);try{let n;if(t===`zip`){if(!l){y(`Choose a ZIP file first.`),C(!1);return}let e=new FormData;e.set(`file`,l),a&&e.set(`force`,`true`),n=await fetch(`/api/skills/import`,{method:`POST`,body:e})}else{let e;if(t===`openclaw`)e=`openclaw`;else if(e=r.trim(),!e){y(`Enter the server path.`),C(!1);return}n=await fetch(`/api/skills/import`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({source:e,force:a})})}if(!n.ok){let e=await n.json().catch(()=>null);throw x(e?.findings??[]),Error(e?.error??`${n.status} ${n.statusText}`)}x(v((await n.json().catch(()=>null))?.findings)),i(``),u(null),e()}catch(e){y(e.message)}finally{C(!1)}}function E(e){u(e.target.files?.[0]??null)}function D(e){e.preventDefault(),h(!1);let t=e.dataTransfer?.files;if(!t||t.length===0)return;let n=t[0];if(n){if(!/\.zip$/i.test(n.name)){y(`Only ZIP archives are supported.`);return}if(u(n),w.current){let e=new DataTransfer;e.items.add(n),w.current.files=e.files}}}let O=b.some(e=>e.severity===`danger`)?`danger`:`warning`;return(0,p.jsxs)(s,{title:`Import skills`,description:(0,p.jsxs)(p.Fragment,{children:[`Choose a source. Each skill's `,(0,p.jsx)(`code`,{children:`SKILL.md`}),` body is injected into the system prompt of any agent it is attached to.`]}),children:[(0,p.jsx)(`div`,{role:`tablist`,className:`mb-5 inline-flex max-w-full gap-0 overflow-x-auto rounded-lg border border-border bg-muted p-1`,children:[{id:`openclaw`,label:`OpenClaw`},{id:`path`,label:`Server directory`},{id:`zip`,label:`Upload ZIP`}].map(e=>(0,p.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.id,onClick:()=>{n(e.id),y(null)},className:`unstyled cursor-pointer whitespace-nowrap rounded-md border-none bg-transparent px-3 py-1.5 text-sm font-medium transition-colors ${t===e.id?`bg-card text-accent-foreground shadow-baziu-sm`:`text-muted-foreground hover:bg-accent/50 hover:text-foreground`}`,children:e.label},e.id))}),g&&(0,p.jsx)(`div`,{role:`alert`,className:`mb-4 rounded-lg border border-destructive/20 bg-destructive/10 px-4 py-3 text-sm text-destructive`,children:g}),b.length>0&&(0,p.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-muted/30 p-4 text-sm`,children:[(0,p.jsx)(o,{variant:O,className:`mb-2`,children:`Scan findings`}),(0,p.jsx)(_,{findings:b})]}),(0,p.jsxs)(`form`,{className:`space-y-4`,onSubmit:T,children:[t===`openclaw`&&(0,p.jsxs)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:[`One-click import of every skill found in `,(0,p.jsx)(`code`,{children:`~/.openclaw/skills`}),` on the server.`]}),t===`path`&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:[`Import from an absolute path on the server — either a single skill folder (contains `,(0,p.jsx)(`code`,{children:`SKILL.md`}),`) or a parent folder holding many skill subfolders.`]}),(0,p.jsxs)(`label`,{className:`max-w-2xl`,children:[`Server path`,(0,p.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`/home/you/my-skills`,required:!0})]})]}),t===`zip`&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:[`Upload a `,(0,p.jsx)(`code`,{children:`.zip`}),` archive whose top level contains one folder per skill — the folder name becomes the skill name.`]}),(0,p.jsxs)(`label`,{onDragOver:e=>{e.preventDefault(),h(!0)},onDragLeave:()=>h(!1),onDrop:D,className:`block cursor-pointer rounded-xl border-2 border-dashed p-8 text-center transition-colors ${m?`border-primary bg-accent text-accent-foreground`:l?`border-solid border-primary/40 bg-card text-foreground`:`border-border bg-muted/30 text-muted-foreground hover:border-primary hover:bg-accent hover:text-accent-foreground`}`,children:[(0,p.jsx)(`input`,{ref:w,type:`file`,accept:`.zip,application/zip`,onChange:E,className:`absolute h-px w-px overflow-hidden opacity-0`}),l?(0,p.jsx)(`span`,{className:`block break-all font-mono text-sm text-accent-foreground`,children:l.name}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`span`,{className:`block text-sm font-medium text-foreground`,children:`Click to choose a ZIP file`}),(0,p.jsx)(`span`,{className:`text-xs`,children:`or drag and drop it here`})]})]})]}),(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,p.jsx)(d,{variant:`primary`,type:`submit`,disabled:S,children:S?`Importing…`:t===`zip`?`Upload and import`:t===`openclaw`?`Import from OpenClaw`:`Import`}),(0,p.jsxs)(`label`,{className:`m-0 inline-flex cursor-pointer items-center gap-1 text-sm text-foreground`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>c(e.target.checked)}),(0,p.jsx)(`span`,{children:`Overwrite existing`}),(0,p.jsx)(`span`,{className:`text-muted-foreground`,children:`and confirm scan findings`})]})]})]})]})}function g({findings:e}){return e.length===0?(0,p.jsx)(o,{variant:`success`,children:`Clean`}):(0,p.jsxs)(`details`,{className:`text-xs`,children:[(0,p.jsx)(`summary`,{className:`cursor-pointer list-none`,children:(0,p.jsxs)(o,{variant:e.some(e=>e.severity===`danger`)?`danger`:`warning`,children:[e.length,` finding`,e.length===1?``:`s`]})}),(0,p.jsx)(`div`,{className:`mt-2 min-w-64`,children:(0,p.jsx)(_,{findings:e})})]})}function _({findings:e}){return(0,p.jsx)(`ul`,{className:`m-0 space-y-1.5 pl-0`,children:e.map((e,t)=>(0,p.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,p.jsx)(o,{variant:e.severity===`danger`?`danger`:`warning`,children:e.severity===`danger`?`Danger`:`Warning`}),(0,p.jsxs)(`span`,{children:[(0,p.jsx)(`code`,{children:e.code}),e.line?`, line ${e.line}`:``,` — `,e.message]})]},`${e.code}-${e.line??0}-${t}`))})}function v(e){return e?Object.entries(e).flatMap(([e,t])=>t.map(t=>({...t,message:`${e}: ${t.message}`}))):[]}export{m as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{d as r}from"./preload-helper-bztXdkDj.js";import{I as i}from"./index-
|
|
1
|
+
import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{d as r}from"./preload-helper-bztXdkDj.js";import{I as i}from"./index-CwMw0pnV.js";import{n as a,r as o}from"./Page-NV96O47A.js";import{t as s}from"./Button-ByiV6fpd.js";import{t as c}from"./TemplatesTabs-YyytjW7k.js";var l=e(n()),u=t();function d(){let e=i.useLoaderData(),t=r();return(0,u.jsxs)(o,{size:`wide`,children:[(0,u.jsx)(a,{eyebrow:`Templates`,title:`Team templates`,description:`Create revisioned rosters with stable slots and a reusable communication policy.`}),(0,u.jsx)(c,{}),(0,u.jsx)(f,{onCreated:()=>t.invalidate()}),(0,u.jsx)(`div`,{className:`overflow-x-auto`,children:(0,u.jsxs)(`table`,{children:[(0,u.jsx)(`thead`,{children:(0,u.jsxs)(`tr`,{children:[(0,u.jsx)(`th`,{children:`id`}),(0,u.jsx)(`th`,{children:`name`}),(0,u.jsx)(`th`,{children:`slots`}),(0,u.jsx)(`th`,{children:`revision`}),(0,u.jsx)(`th`,{children:`source state`})]})}),(0,u.jsxs)(`tbody`,{children:[e.map(e=>(0,u.jsxs)(`tr`,{children:[(0,u.jsx)(`td`,{children:(0,u.jsx)(`a`,{href:`/templates/teams/${encodeURIComponent(e.id)}`,children:(0,u.jsx)(`code`,{children:e.id})})}),(0,u.jsx)(`td`,{children:e.name}),(0,u.jsx)(`td`,{children:e.slotCount}),(0,u.jsx)(`td`,{children:e.currentRevision}),(0,u.jsx)(`td`,{children:e.deletedAt?`deleted source`:`canonical`})]},e.id)),e.length===0&&(0,u.jsx)(`tr`,{children:(0,u.jsx)(`td`,{colSpan:5,className:`muted`,children:`No team templates yet.`})})]})]})})]})}function f({onCreated:e}){let[t,n]=(0,l.useState)(``),[r,i]=(0,l.useState)(``),[a,o]=(0,l.useState)(null),[c,d]=(0,l.useState)(!1);async function f(a){a.preventDefault(),d(!0),o(null);try{let a=await fetch(`/api/team-templates`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:t.trim(),name:r.trim()})});if(!a.ok)throw Error((await a.json().catch(()=>null))?.error??a.statusText);n(``),i(``),await e()}catch(e){o(e.message)}finally{d(!1)}}return(0,u.jsxs)(`form`,{className:`card`,onSubmit:f,children:[(0,u.jsx)(`h2`,{className:`text-xl`,children:`new team template`}),a&&(0,u.jsx)(`p`,{className:`err`,children:a}),(0,u.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,u.jsxs)(`label`,{children:[`id`,(0,u.jsx)(`input`,{required:!0,value:t,onChange:e=>n(e.target.value),placeholder:`review-team`})]}),(0,u.jsxs)(`label`,{children:[`name`,(0,u.jsx)(`input`,{required:!0,value:r,onChange:e=>i(e.target.value),placeholder:`Review team`})]})]}),(0,u.jsx)(s,{variant:`primary`,type:`submit`,disabled:c,children:c?`creating…`:`create team template`})]})}export{d as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{d as r}from"./preload-helper-bztXdkDj.js";import{t as i}from"./ConfirmDialog-
|
|
1
|
+
import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{d as r}from"./preload-helper-bztXdkDj.js";import{t as i}from"./ConfirmDialog-Br19uXWH.js";import{K as a}from"./index-CwMw0pnV.js";import{a as o,i as s,n as c,r as l,t as u}from"./Page-NV96O47A.js";import{t as d}from"./Button-ByiV6fpd.js";var f=e(n()),p=t();function m(){let{teams:e,memberCounts:t,policies:n,readiness:m}=a.useLoaderData(),g=r(),[_,v]=(0,f.useState)(null),[y,b]=(0,f.useState)(null);async function x(e){let t=n[e]?.revision;if(!t)throw Error(`The Team policy revision is unavailable. Nothing was removed.`);let r=await fetch(`/api/teams/${encodeURIComponent(e)}?expectedTeamPolicyRevision=${t}`,{method:`DELETE`});if(!r.ok&&r.status!==204){let e=await r.json().catch(()=>null);throw Error(e?.error??`Could not remove Team (${r.status})`)}await g.invalidate()}return(0,p.jsxs)(l,{size:`wide`,children:[(0,p.jsx)(c,{eyebrow:`Workspace`,title:`Teams`,description:`Each Team owns one workspace, one live membership roster, and one effective communication policy. Every agent belongs to exactly one Team.`}),(0,p.jsx)(s,{title:`Policy enforcement`,description:`Management contract v${m.contractVersion} is ready for this daemon.`,actions:(0,p.jsx)(o,{variant:m.enforcementActive?`success`:`warning`,children:m.enforcementActive?`Enforcement on`:`Enforcement off`}),"aria-label":`Team Policy enforcement readiness`,children:(0,p.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:m.enforcementActive?`Communication boundaries are currently enforcing each Team policy.`:(0,p.jsxs)(p.Fragment,{children:[`Set `,(0,p.jsx)(`code`,{children:`BAZILION_TEAM_POLICY_ENFORCEMENT=on`}),` and restart the daemon to enforce Team policies.`]})})}),(0,p.jsx)(h,{onRegistered:()=>g.invalidate()}),y&&(0,p.jsx)(`p`,{role:`alert`,className:`err`,children:y}),(0,p.jsx)(s,{title:`Registered teams`,description:`Open a Team to manage its context, members, shared memory, and policy.`,children:e.length===0?(0,p.jsx)(u,{title:`No teams registered`,description:`Register a Team above to create a workspace for your agents.`}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`hidden overflow-x-auto md:block`,children:(0,p.jsxs)(`table`,{className:`min-w-[820px]`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`ID`}),(0,p.jsx)(`th`,{children:`Name`}),(0,p.jsx)(`th`,{children:`Members`}),(0,p.jsx)(`th`,{children:`Policy`}),(0,p.jsx)(`th`,{children:`Baseline`}),(0,p.jsx)(`th`,{children:(0,p.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]})}),(0,p.jsx)(`tbody`,{children:e.map(e=>{let r=t[e.id]??0,i=n[e.id];return(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(`code`,{children:e.id})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(`a`,{href:`/teams/${e.id}`,children:e.name})}),(0,p.jsx)(`td`,{children:r}),(0,p.jsx)(`td`,{children:(0,p.jsx)(`a`,{href:`/teams/${e.id}/policy`,children:i?`r${i.revision} · ${i.edges} edges`:`Unavailable`})}),(0,p.jsx)(`td`,{children:i?.baseline??`None`}),(0,p.jsx)(`td`,{children:(0,p.jsx)(`div`,{className:`flex justify-end`,children:r===0?(0,p.jsx)(d,{variant:`danger`,onClick:()=>v(e),children:`Remove`}):(0,p.jsx)(o,{variant:`neutral`,title:`${r} agent(s) belong to this Team`,children:`In use`})})})]},e.id)})})]})}),(0,p.jsx)(`div`,{className:`grid gap-3 md:hidden`,children:e.map(e=>{let r=t[e.id]??0,i=n[e.id];return(0,p.jsxs)(`article`,{className:`min-w-0 rounded-xl border border-border bg-muted/20 p-4`,children:[(0,p.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[(0,p.jsxs)(`div`,{className:`min-w-0`,children:[(0,p.jsx)(`a`,{href:`/teams/${encodeURIComponent(e.id)}`,className:`block truncate font-semibold text-foreground`,children:e.name}),(0,p.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-xs text-muted-foreground`,children:e.id})]}),(0,p.jsxs)(o,{variant:r>0?`success`:`neutral`,children:[r,` member`,r===1?``:`s`]})]}),(0,p.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-xs sm:grid-cols-2`,children:[(0,p.jsxs)(`div`,{className:`rounded-lg bg-muted p-2`,children:[(0,p.jsx)(`dt`,{className:`font-semibold text-muted-foreground`,children:`Policy`}),(0,p.jsx)(`dd`,{className:`mt-0.5`,children:(0,p.jsx)(`a`,{href:`/teams/${encodeURIComponent(e.id)}/policy`,children:i?`Revision ${i.revision} · ${i.edges} edges`:`Unavailable`})})]}),(0,p.jsxs)(`div`,{className:`rounded-lg bg-muted p-2`,children:[(0,p.jsx)(`dt`,{className:`font-semibold text-muted-foreground`,children:`Baseline`}),(0,p.jsx)(`dd`,{className:`mt-0.5 break-words`,children:i?.baseline??`None`})]})]}),r===0&&(0,p.jsx)(`div`,{className:`mt-3`,children:(0,p.jsx)(d,{variant:`danger`,onClick:()=>v(e),children:`Remove Team`})})]},e.id)})})]})}),(0,p.jsx)(i,{open:_!==null,onOpenChange:e=>{e||v(null)},title:`Remove ${_?.name??`Team`}?`,description:(0,p.jsx)(`p`,{children:`This removes the empty Team registration and its Bazilion-managed workspace slot. If the slot is a symlink, its external target is not deleted. This action cannot be undone from the web UI.`}),confirmLabel:`Remove Team`,onConfirm:async()=>{if(_)try{await x(_.id)}catch(e){throw b(e instanceof Error?e.message:String(e)),e}}})]})}function h({onRegistered:e}){let[t,n]=(0,f.useState)(``),[r,i]=(0,f.useState)(``),[a,o]=(0,f.useState)(``),[c,l]=(0,f.useState)(null),[u,m]=(0,f.useState)(!1);async function h(s){if(s.preventDefault(),l(null),!t.trim()){l(`id is required`);return}m(!0);try{let s=await fetch(`/api/teams`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:t.trim(),name:r.trim()||void 0,link:a.trim()||void 0})});if(!s.ok){let e=await s.json().catch(()=>null);throw Error(e?.error??s.statusText)}n(``),i(``),o(``),e()}catch(e){l(e.message)}finally{m(!1)}}return(0,p.jsx)(s,{title:`Register a team`,description:(0,p.jsxs)(p.Fragment,{children:[`Teams live under `,(0,p.jsx)(`code`,{children:`~/.bazilion/teams/<slug>/`}),`. Link an existing project directory or leave the target blank to create a fresh workspace.`]}),children:(0,p.jsxs)(`form`,{onSubmit:h,children:[c&&(0,p.jsx)(`div`,{role:`alert`,className:`err`,children:c}),(0,p.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,p.jsxs)(`label`,{children:[`ID (slug)`,(0,p.jsx)(`input`,{value:t,onChange:e=>n(e.target.value),required:!0,placeholder:`my-project`})]}),(0,p.jsxs)(`label`,{children:[`Name`,(0,p.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`My project`})]}),(0,p.jsxs)(`label`,{className:`sm:col-span-2`,children:[`Link target (optional, absolute path)`,(0,p.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),placeholder:`/home/user/projects/my-project`})]})]}),(0,p.jsx)(`div`,{className:`mt-4`,children:(0,p.jsx)(d,{variant:`primary`,type:`submit`,disabled:u,children:u?`Registering…`:`Register team`})})]})})}export{m as component};
|