@capagents/forgeqe 3.3.7 → 3.3.9
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/HOW_TO_USE.md +92 -0
- package/dist/a11y-runtime.mjs +3204 -0
- package/dist/docs-site/docs/area-quality/index.html +90 -2
- package/dist/docs-site/docs/overview/index.html +1 -1
- package/dist/docs-site/docs/search.js +1 -1
- package/dist/forgeqe.js +2215 -2094
- package/dist/template.html +69 -70
- package/dist/web/assets/{3d-force-graph-Bsispdm1.js → 3d-force-graph-BPsVSYjw.js} +1 -1
- package/dist/web/assets/Agent-DY6pRvcD.js +10 -0
- package/dist/web/assets/{AgentWork-BugEUl60.js → AgentWork-Brch_Mn3.js} +1 -1
- package/dist/web/assets/ApiTests-BtWKVPw5.js +17 -0
- package/dist/web/assets/{Browse-Dl2Lneca.js → Browse-DbIFxsy8.js} +1 -1
- package/dist/web/assets/Chat-BWiH0XGV.js +3 -0
- package/dist/web/assets/{CommandPalette-B7YPDCOk.js → CommandPalette-DfoEUEL6.js} +1 -1
- package/dist/web/assets/{Compare-D6XsFmmb.js → Compare-DTZ_BW1P.js} +1 -1
- package/dist/web/assets/Cost-DDghPWch.js +1 -0
- package/dist/web/assets/Data-DZlKsTwA.js +6 -0
- package/dist/web/assets/Desktop-DTIZ62Pi.js +1 -0
- package/dist/web/assets/DesktopReview-B8-dSGJH.js +2 -0
- package/dist/web/assets/Evidence-BYw_Q4Ul.js +1 -0
- package/dist/web/assets/Explore-BL_c5WK1.js +2 -0
- package/dist/web/assets/{Features-N3_77mz-.js → Features-DrFNrvbh.js} +1 -1
- package/dist/web/assets/Flags-CHrDwhqG.js +2 -0
- package/dist/web/assets/Flaky-DtcLf8h6.js +1 -0
- package/dist/web/assets/Impact-CMU_ijo2.js +3 -0
- package/dist/web/assets/Jobs-BjybdQb_.js +5 -0
- package/dist/web/assets/KindPage-VK-Vgkzv.js +6 -0
- package/dist/web/assets/{LiveDevice-j7NZXIJZ.js → LiveDevice-BqL1P33F.js} +1 -1
- package/dist/web/assets/Migration-7BI7iXIv.js +8 -0
- package/dist/web/assets/Mobile-AgAhvlVL.js +1 -0
- package/dist/web/assets/Observability-5r36Xf3d.js +1 -0
- package/dist/web/assets/{OwnItems-BdiPfdTw.js → OwnItems-CqCOuvba.js} +4 -4
- package/dist/web/assets/PageAgent-00NQxK49.js +1 -0
- package/dist/web/assets/Product-B75ztJFn.js +6 -0
- package/dist/web/assets/Production-lIUlcjf0.js +1 -0
- package/dist/web/assets/Quality-BlRpB6mx.js +1 -0
- package/dist/web/assets/Readiness-CesaSDtp.js +1 -0
- package/dist/web/assets/Record-CLy9jQ5N.js +1 -0
- package/dist/web/assets/Regression-BjpZrkfK.js +5 -0
- package/dist/web/assets/{RelationGraph-Blfs7PhK.js → RelationGraph-ClPBGuMw.js} +1 -1
- package/dist/web/assets/{Reports-HQkTX4Kr.js → Reports-Du8SNiHM.js} +2 -2
- package/dist/web/assets/Requirements-Dr1iLoMc.js +2 -0
- package/dist/web/assets/Responsive-DcD6MLzG.js +3 -0
- package/dist/web/assets/{RunDiff-75a-smeg.js → RunDiff-cLSFOsfC.js} +1 -1
- package/dist/web/assets/{Settings-BaodIliH.js → Settings-CUT5ggDd.js} +16 -16
- package/dist/web/assets/SiteScan-iUfWBeLV.js +5 -0
- package/dist/web/assets/{Steps-ZPH_rTJh.js → Steps-DJYwIiDu.js} +2 -2
- package/dist/web/assets/{TestData-DUlTo5qt.js → TestData-DqEcL5o4.js} +2 -2
- package/dist/web/assets/TestManagement-mBcfWTVH.js +4 -0
- package/dist/web/assets/{WhatsNew-BrVNacPl.js → WhatsNew-DrPf6l9-.js} +1 -1
- package/dist/web/assets/{agentSettingsSheet-UCqUtdjq.js → agentSettingsSheet-DyaVNewv.js} +1 -1
- package/dist/web/assets/api-Dr3U7W5w.js +1 -0
- package/dist/web/assets/{choice-C4-yW2x9.js → choice-W0qOx_1k.js} +1 -1
- package/dist/web/assets/{coverage-pqIlfEP0.js → coverage-DbHm8BUP.js} +3 -3
- package/dist/web/assets/{dataParts-C0C67bVQ.js → dataParts-Bdf97ZOD.js} +3 -3
- package/dist/web/assets/{desktopAppPath-B89LKvjx.js → desktopAppPath-kQmQOW6a.js} +1 -1
- package/dist/web/assets/{flowTheme-BNKwRxun.js → flowTheme-CVnIjV_m.js} +1 -1
- package/dist/web/assets/frame-CavkQick.js +13 -0
- package/dist/web/assets/index-BaEsXdFc.css +2 -0
- package/dist/web/assets/index-C1kXcI0E.js +57 -0
- package/dist/web/assets/line-icons-Cwj9OmCz.js +1 -0
- package/dist/web/assets/{logos-P2LOMyTK.js → logos-Cf-Wf5ex.js} +1 -1
- package/dist/web/assets/{markdown-CxsWgpYs.js → markdown-Bvv6oj4v.js} +3 -3
- package/dist/web/assets/{nav-DYgvAJu-.js → nav-DVPiPhOy.js} +1 -1
- package/dist/web/assets/pageBack-Blig1Uqs.js +3 -0
- package/dist/web/assets/{palette-BgJTq_Ot.js → palette-DwrGI2Fp.js} +1 -1
- package/dist/web/assets/{paletteCommands-Isq1rLs-.js → paletteCommands-DOF2o-rv.js} +1 -1
- package/dist/web/assets/parts-DgJ2y_ic.js +1 -0
- package/dist/web/assets/{productParts-ZEi0sPIk.js → productParts-B78jij3z.js} +1 -1
- package/dist/web/assets/qualityParts-t5t9kEKG.js +2 -0
- package/dist/web/assets/{recordTest-Bz5ryzpS.js → recordTest-BbXVOuGZ.js} +1 -1
- package/dist/web/assets/{route-oDy8sV6H.js → route-9BkoTWUE.js} +1 -1
- package/dist/web/assets/{sectionList-B651VPon.js → sectionList-DMyhAqst.js} +1 -1
- package/dist/web/assets/{step-mark-CaKf4dAR.js → step-mark-Bu6fNKW8.js} +1 -1
- package/dist/web/assets/stepper-CE4yOLqn.js +1 -0
- package/dist/web/assets/wizardParts-Bxb9UG5k.js +1 -0
- package/dist/web/index.html +11 -11
- package/docs/ForgeQE-Static-Analysis-Report-4008e9ee.html +207 -0
- package/docs/ForgeQE-Static-Analysis-Report-4008e9ee.pdf +0 -0
- package/docs/{ForgeQE-Static-Analysis-Report-5bbf0da7.html → ForgeQE-Static-Analysis-Report-ccbdac00.html} +33 -33
- package/docs/ForgeQE-Static-Analysis-Report-ccbdac00.pdf +0 -0
- package/docs/user-guide.html +89 -1
- package/forgeqe.example.yaml +1 -1
- package/package.json +2 -2
- package/prompts/brain.md +7 -0
- package/py/forgeqe_engine/cli.py +57 -0
- package/py/forgeqe_engine/diagnostics.py +32 -2
- package/py/forgeqe_engine/logins.py +11 -0
- package/py/forgeqe_engine/persona.py +90 -1
- package/py/forgeqe_engine/scan.py +202 -0
- package/py/forgeqe_engine/seo.py +95 -0
- package/py/forgeqe_engine/seo_analytics.mjs +59 -0
- package/py/forgeqe_engine/seo_facts.mjs +63 -0
- package/py/forgeqe_engine/seo_site.mjs +36 -0
- package/py/forgeqe_engine/service.py +3 -2
- package/dist/web/assets/Agent-39FbaH7G.js +0 -10
- package/dist/web/assets/ApiTests-B9rtwCbe.js +0 -17
- package/dist/web/assets/Chat-DocT7FlH.js +0 -3
- package/dist/web/assets/Cost-DvbuXS6u.js +0 -1
- package/dist/web/assets/Data-BmZHJkfj.js +0 -6
- package/dist/web/assets/Desktop-DD3F69ih.js +0 -1
- package/dist/web/assets/DesktopReview-BR0LtVFw.js +0 -2
- package/dist/web/assets/Evidence-OqAiYzrl.js +0 -1
- package/dist/web/assets/Explore-QNyusEFo.js +0 -2
- package/dist/web/assets/Flags-Yv4Ttmmh.js +0 -2
- package/dist/web/assets/Flaky-Bg2f2K1U.js +0 -1
- package/dist/web/assets/Impact-CpxvVnKj.js +0 -3
- package/dist/web/assets/Jobs-_gZTxoaG.js +0 -5
- package/dist/web/assets/KindPage-Amr6R7Ym.js +0 -6
- package/dist/web/assets/Migration-DfPYzTfk.js +0 -8
- package/dist/web/assets/Mobile-fIhhQPsp.js +0 -1
- package/dist/web/assets/Observability-13DkrRp2.js +0 -1
- package/dist/web/assets/PageAgent-CC8Ha6vu.js +0 -1
- package/dist/web/assets/Product-CnXkqwQm.js +0 -6
- package/dist/web/assets/Production-5mTIt4sr.js +0 -1
- package/dist/web/assets/Quality-DbLcbP1X.js +0 -1
- package/dist/web/assets/Readiness-BG1xmC09.js +0 -1
- package/dist/web/assets/Record-sFth-2I1.js +0 -1
- package/dist/web/assets/Regression-Dd4y8I1z.js +0 -5
- package/dist/web/assets/Requirements-DmhUNCIP.js +0 -2
- package/dist/web/assets/Responsive-D18eYdCh.js +0 -3
- package/dist/web/assets/TestManagement-DUMGdHDw.js +0 -4
- package/dist/web/assets/api-D8-lxyQi.js +0 -1
- package/dist/web/assets/frame-C8sL1yo-.js +0 -13
- package/dist/web/assets/index-BFG13fbg.js +0 -55
- package/dist/web/assets/index-DBnWgocz.css +0 -2
- package/dist/web/assets/line-icons-CwCZidXs.js +0 -1
- package/dist/web/assets/pageBack-BefA2rh7.js +0 -3
- package/dist/web/assets/parts-BNpm4gXC.js +0 -1
- package/dist/web/assets/qualityParts-DtsD70Qh.js +0 -1
- package/dist/web/assets/stepper-CONWT_tv.js +0 -1
- package/dist/web/assets/wizardParts-CulZqqjz.js +0 -1
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./react-BDur5s0O.js";import{n,r,t as i}from"./route-oDy8sV6H.js";import{F as a,H as o,L as s,R as c,a as l,c as u,l as d,n as f,r as p,s as m}from"./preload-helper-BupTYkQW.js";import{n as h,t as g}from"./utils-DJRAScIl.js";import{t as _}from"./jsx-runtime-LKYXHABd.js";import{K as v,U as y,a as b,i as x,r as S,u as C}from"./palette-BgJTq_Ot.js";import{b as w,c as T,d as E,i as D,l as O,u as k,x as A}from"./sectionList-B651VPon.js";import{K as j,S as M,_ as N,a as ee,g as P,i as te,o as F,ot as I,r as ne,y as re}from"./api-D8-lxyQi.js";import{C as L,S as R,_ as ie,b as z,f as ae,g as B,h as oe,m as V,n as se,r as ce,t as le,x as H,y as ue}from"./pageBack-BefA2rh7.js";import{$ as de,$t as fe,B as pe,Bt as me,Cr as he,Dr as U,E as ge,Fn as _e,Fr as ve,G as ye,Hn as be,K as xe,L as Se,Ln as W,Lr as Ce,Lt as we,M as Te,Mn as Ee,N as G,O as De,Or as Oe,P as ke,Pn as Ae,Pr as je,Qn as Me,Qt as Ne,R as Pe,Rr as Fe,Sr as Ie,Tr as Le,Un as Re,V as ze,Vn as Be,X as Ve,Xn as He,Z as Ue,Zn as We,_ as Ge,a as Ke,b as qe,bt as Je,cr as Ye,dt as Xe,er as Ze,f as Qe,gn as $e,gt as et,h as tt,hn as nt,in as rt,ir as it,jr as at,kn as ot,kt as st,lr as ct,m as lt,mt as ut,o as dt,on as ft,or as pt,pn as mt,qn as ht,qt as gt,rr as _t,rt as vt,st as yt,tn as bt,ut as xt,v as St,vn as Ct,vt as wt,w as Tt,wr as Et,yr as K,zn as Dt,zr as Ot}from"./line-icons-CwCZidXs.js";import{Ct as kt,Et as At,Jt as jt,K as Mt,L as Nt,Mt as Pt,R as Ft,St as It,Xt as Lt,Y as q,Yt as Rt,_t as zt,bt as Bt,ct as Vt,dt as Ht,lt as Ut,o as Wt,s as Gt,st as Kt,t as qt,vt as Jt,wt as Yt,zt as Xt}from"./frame-C8sL1yo-.js";import{t as Zt}from"./when-BuWCTaKm.js";import{u as Qt}from"./nav-DYgvAJu-.js";import{t as $t}from"./code-Jek8uWUO.js";import{s as en}from"./markdown-CxsWgpYs.js";import{$ as tn,B as nn,C as rn,I as an,J as on,U as sn,W as cn,X as ln,Y as J,at as un,c as dn,d as fn,dt as pn,et as mn,f as hn,ft as gn,g as _n,gt as vn,h as yn,it as bn,l as xn,m as Sn,mt as Cn,n as wn,nt as Tn,p as En,pt as Dn,r as On,rt as kn,t as An,u as jn,ut as Mn,vt as Nn,w as Pn}from"./index-BFG13fbg.js";import{i as Fn,r as In,t as Ln}from"./RelationGraph-Blfs7PhK.js";import{a as Rn,c as zn,d as Bn,f as Vn,l as Hn,n as Un,r as Wn,s as Gn,t as Kn}from"./flowTheme-BNKwRxun.js";import{r as qn,t as Jn}from"./choice-C4-yW2x9.js";import{t as Yn}from"./step-mark-CaKf4dAR.js";import{t as Xn}from"./stepper-CONWT_tv.js";import{r as Zn}from"./wizardParts-CulZqqjz.js";import{a as Qn,n as $n,o as er,r as tr,t as nr}from"./OwnItems-BdiPfdTw.js";import{l as rr}from"./dataParts-C0C67bVQ.js";var Y=e(t(),1),X=_(),ir=[{label:`Defect retest`,about:`Each morning, retests the defects resolved since yesterday and says which are really fixed.`,text:`Every morning, find the defects resolved in our tracker since yesterday, retest each one on QA by rerunning its test or following its steps in a real browser, and tell me which are really fixed and which still fail, with screenshots. Add the result as a comment on each defect.`},{label:`Nightly smoke`,about:`Each night, runs the critical flows on QA and tells the team what broke and why.`,text:`Every night, run our critical flows (sign-in, search, checkout) on QA in a real browser, and tell the team in our channel what broke, with screenshots and the likely cause.`},{label:`Pull request test check`,about:`Reviews a pull request's tests, runs the ones it touches, and says what is missing or risky.`,text:`When I give it a pull request, review its tests and changes, run the automated tests it touches, and tell me what is missing or risky before I merge.`},{label:`Release readiness`,about:`Runs a release's regression pack and says whether it is ready to ship and what blocks it.`,text:`For a release I name, run its regression pack on QA, look at its test cases' results and its open defects, and tell me if it is ready to ship and what blocks it.`},{label:`API contracts`,about:`Checks an API against its contracts after each deploy and explains any break.`,text:`Check our order API against its contracts after each deploy and explain any break`},{label:`Test case quality`,about:`Reviews a story's test cases and says what is missing or vague.`,text:`Review a story's test cases and tell me what is missing or vague`}];function ar(){let[e,t]=(0,Y.useState)(``),[n,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)([]),[l,u]=(0,Y.useState)([]),d=an(n);(0,Y.useEffect)(()=>{N.list().then(e=>c(e.sessions.filter(e=>!e.saved)),()=>{}),M.templates().then(e=>u(e.templates),()=>{})},[]);let f=async()=>{if(e.trim()){i(!0),o(``);try{let t=await N.start(e.trim());location.hash=r(`agents`,`custom`,`build`,t.sid)}catch(e){o(e.message),i(!1)}}};return(0,X.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,X.jsxs)(`header`,{className:`flex items-center gap-1 px-6 py-4`,children:[(0,X.jsx)(Wt,{}),(0,X.jsx)(se,{to:{href:r(`agents`,`category`,`custom`),label:`Custom agents`},className:`self-center`})]}),(0,X.jsx)(`main`,{className:`flex flex-auto flex-col items-center justify-center px-6 pt-6 pb-30`,children:(0,X.jsxs)(`div`,{className:`flex w-full max-w-[780px] flex-col items-center gap-10`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col items-center gap-4 text-center`,children:[(0,X.jsx)(ue,{state:n?`waiting`:d,px:112,label:n?`Starting the builder`:`ForgeQE is ready to build an agent`,className:`mb-1`}),(0,X.jsx)(`h1`,{className:`m-0 text-headline-lg text-ink`,children:`What should your agent do?`}),(0,X.jsx)(`p`,{className:`m-0 text-body-lg leading-relaxed text-ink-2`,children:`Say it in your own words. ForgeQE works out what it needs from what your project has, asks only what it cannot decide, and builds it with you step by step.`})]}),(0,X.jsx)(Cn,{id:`build-goal`,label:`What your agent should do`,value:e,onChange:e=>{t(e),o(``)},onSend:()=>void f(),busy:n,disabled:n,placeholder:`An agent that checks the checkout on QA and tells me what broke…`}),a&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 -mt-6 text-body-sm text-fail`,children:a}),(0,X.jsx)(J,{id:`build-starters`,icon:bt,title:`Or start from one of these, and change it to fit`,className:`w-full`,children:(0,X.jsx)(`ul`,{className:`m-0 grid list-none grid-cols-1 gap-2 p-0 sm:grid-cols-2`,children:ir.map(n=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":e===n.text,onClick:()=>{t(n.text),o(``),document.getElementById(`build-goal`)?.focus()},className:g(qn,`h-full w-full flex-col gap-1`),children:[(0,X.jsx)(`span`,{className:`text-body-sm font-medium text-ink`,children:n.label}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:n.about})]})},n.label))})}),s.length>0&&(0,X.jsx)(J,{id:`build-resume`,icon:me,title:`Pick up where you left off`,className:`w-full`,children:(0,X.jsx)(`ul`,{className:g(`surface rounded-lg bg-bg p-6 shadow-sm`,`m-0 flex list-none flex-col`),children:s.slice(0,5).map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`a`,{href:r(`agents`,`custom`,`build`,e.sid),className:`flex w-full min-h-11 cursor-pointer items-center gap-4 rounded-base border-0 bg-transparent px-4 py-2 text-left text-body-sm text-ink no-underline transition-colors duration-150 hover:bg-tint hover:text-ink aria-[current]:bg-tint-hover aria-selected:bg-tint-hover aria-pressed:bg-tint-hover aria-checked:bg-tint-hover has-[:checked]:bg-tint-hover disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-body-sm`,children:e.goal}),(0,X.jsxs)(`span`,{className:`flex-none text-body-sm text-muted`,children:[or[e.step].label,` · `,Zt(e.updatedAt)]})]})},e.sid))})}),l.length>0&&(0,X.jsx)(J,{id:`build-templates`,icon:Qe,title:`Or start from a template, and review it before you save`,className:`w-full`,children:(0,X.jsx)(`ul`,{className:g(`surface rounded-lg bg-bg p-6 shadow-sm`,`m-0 flex list-none flex-col`),children:l.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`a`,{href:r(`agents`,`custom`,`new`,`template`,e.id),className:`flex w-full min-h-11 cursor-pointer items-center gap-4 rounded-base border-0 bg-transparent px-4 py-2 text-left text-body-sm text-ink no-underline transition-colors duration-150 hover:bg-tint hover:text-ink aria-[current]:bg-tint-hover aria-selected:bg-tint-hover aria-pressed:bg-tint-hover aria-checked:bg-tint-hover has-[:checked]:bg-tint-hover disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,X.jsx)(`span`,{className:`flex-none text-body-sm`,children:e.title}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 text-body-sm text-muted`,children:e.why||e.about})]})},e.id))})}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2`,children:[(0,X.jsxs)(`a`,{href:r(`agents`,`custom`,`new`,`form`),className:`inline-flex items-center gap-2 text-body-sm`,children:[(0,X.jsx)(Me,{size:14,"aria-hidden":`true`}),`Or set every option yourself`]}),(0,X.jsxs)(`a`,{href:r(`agents`,`teams`,`new`),className:`inline-flex items-center gap-2 text-body-sm`,children:[(0,X.jsx)(U,{size:14,"aria-hidden":`true`}),`Need several agents working together? Build a team`]})]})]})})]})}var or={understand:{label:`Understand`,title:`Let's understand your requirements`,next:`Make the plan`,working:`Working out the plan…`,thinking:`Reading what you want, and what your project has…`},plan:{label:`Plan`,title:`Here's how your agent will work`,next:`Set its boundaries`,working:`Working out what it may do…`,thinking:`Planning how your agent will do it, step by step…`},boundaries:{label:`Boundaries`,title:`Where it works and what it may do`,next:`Choose what it knows`,working:`Looking for what it should know…`,thinking:``},knowledge:{label:`Knowledge`,title:`What it should know`,next:`Review it`,working:`Putting it together…`,thinking:``},review:{label:`Review`,title:`Your agent`,next:`Save it as a draft`,working:`Saving it…`,thinking:`Naming it, and writing its instructions…`},try:{label:`Try`,title:`Try it, then approve it`,next:``,working:``,thinking:``}};function sr({sid:e}){let[t,n]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(``),[o,s]=(0,Y.useState)(null),[c,l]=(0,Y.useState)(!1);if((0,Y.useEffect)(()=>{N.view(e).then(e=>{n(e),s(Math.min(e.reached,e.steps.length-1))},e=>a(e.message))},[e]),(0,Y.useEffect)(()=>{if(!t?.working)return;let r=setTimeout(()=>{N.view(e).then(n,()=>{})},1500);return()=>clearTimeout(r)},[t,e]),i&&!t)return(0,X.jsx)(cr,{children:(0,X.jsxs)(`p`,{role:`alert`,className:g(L.fail,`m-0`),children:[i,` `,(0,X.jsx)(`a`,{href:r(`agents`,`custom`,`new`),children:`Start again`})]})});if(!t||o===null)return(0,X.jsx)(cr,{children:(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Loading…`})});let u=t.steps[o].id,d=or[u],f=c||t.working===u,p=async(t,i=!1)=>{if(u!==`try`){l(!0),a(``);try{let a=await N.answer(e,u,t);if(i&&a.saved){location.hash=r(`agents`,`custom`,a.saved,`edit`);return}n(a),s(Math.min(o+1,a.steps.length-1)),window.scrollTo({top:0})}catch(e){a(e.message),window.scrollTo({top:0})}finally{l(!1)}}};return(0,X.jsxs)(cr,{children:[(0,X.jsx)(se,{to:{href:r(`agents`,`category`,`custom`),label:`Custom agents`}}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:`New agent`}),(0,X.jsxs)(`p`,{className:`m-0 text-body-lg text-ink-2 [overflow-wrap:anywhere]`,children:[`“`,t.goal,`”`]})]}),(0,X.jsx)(lr,{v:t,at:o,onGo:e=>!c&&s(e)}),(0,X.jsxs)(`section`,{"aria-labelledby":`build-step`,className:`flex flex-col gap-6`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,X.jsx)(ue,{state:f?`working`:`idle`,px:36,label:f?d.working:`ForgeQE`,className:`flex-none`}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,X.jsx)(`h1`,{id:`build-step`,className:`m-0 text-headline-sm`,children:d.title}),(0,X.jsx)(`p`,{className:`m-0 text-body-lg leading-relaxed text-ink-2`,children:f?t.working===u?or[u].thinking:d.working:t.says[u]}),!f&&t.source?.[u]&&(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:t.source[u]===`model`?`Worked out by ForgeQE's model from what you said and what your project has.`:t.note||`Worked out by ForgeQE's rules: no model is set up.`})]})]}),i&&(0,X.jsx)(`p`,{role:`alert`,className:g(L.fail,`m-0`),children:i}),t.working===u?null:u===`understand`&&(0,X.jsx)(fr,{v:t,busy:c,onNext:p,next:d.next},`u-${t.updatedAt}`),t.working!==u&&u===`plan`&&(0,X.jsx)(mr,{v:t,busy:c,onNext:p,onBack:()=>s(o-1),next:d.next},`p-${t.updatedAt}`),u===`boundaries`&&(0,X.jsx)(gr,{v:t,busy:c,onNext:p,onBack:()=>s(o-1),next:d.next},`b-${t.updatedAt}`),u===`knowledge`&&(0,X.jsx)(_r,{v:t,busy:c,onNext:p,onBack:()=>s(o-1),next:d.next},`k-${t.updatedAt}`),t.working!==u&&u===`review`&&(0,X.jsx)(vr,{v:t,busy:c,onNext:p,onBack:()=>s(o-1),next:d.next},`r-${t.updatedAt}`),u===`try`&&(0,X.jsx)(yr,{v:t})]})]})}function cr({children:e}){return(0,X.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,X.jsx)(Gt,{}),(0,X.jsx)(`main`,{className:g(qt,`max-w-[920px] flex-auto gap-6`),children:e})]})}function lr({v:e,at:t,onGo:n}){return(0,X.jsx)(`nav`,{"aria-label":`Steps`,children:(0,X.jsx)(`ol`,{className:`m-0 flex list-none flex-wrap gap-x-1 gap-y-2 p-0`,children:e.steps.map((r,i)=>{let a=i<=e.reached,o=i===t;return(0,X.jsxs)(`li`,{className:`flex items-center gap-1`,children:[(0,X.jsxs)(H,{variant:`ghost`,size:`sm`,disabled:!a,"aria-current":o?`step`:void 0,onClick:()=>n(i),children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:g(`inline-flex size-5 items-center justify-center rounded-full text-body-sm tabular-nums`,r.done&&!o?`bg-pass-soft text-pass`:o?`bg-accent text-accent-ink`:`bg-surface-strong text-muted`),children:r.done&&!o?(0,X.jsx)(Tt,{size:12,strokeWidth:3}):i+1}),or[r.id].label]}),i<e.steps.length-1&&(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`h-px w-4 bg-line`})]},r.id)})})})}function ur({busy:e,onBack:t,next:n,onNext:r,disabled:i,aside:a}){let o=n.startsWith(`Save`);return(0,X.jsxs)(`div`,{className:`sticky bottom-0 flex flex-wrap items-center gap-4 border-t border-line-soft bg-canvas py-4`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 text-body-sm`,children:a}),t&&(0,X.jsxs)(H,{variant:`ghost`,disabled:e,onClick:t,children:[(0,X.jsx)(Ke,{"aria-hidden":`true`}),`Back`]}),(0,X.jsxs)(H,{variant:`primary`,disabled:e||i,onClick:r,"data-tip":n,children:[o?(0,X.jsx)(Tt,{"aria-hidden":`true`}):(0,X.jsx)(dt,{"aria-hidden":`true`}),o?`Save`:`Next`]})]})}function dr({on:e,label:t,why:n,recommended:r,onToggle:i}){return(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":e,onClick:i,className:g(Jn,`w-full items-start`),children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:g(`mt-1 inline-flex size-4 flex-none items-center justify-center rounded-sm`,e?`bg-accent text-accent-ink`:m),children:e&&(0,X.jsx)(Tt,{size:12,strokeWidth:3})}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-body-sm font-medium text-ink`,children:[t,r&&(0,X.jsx)(B,{tone:`running`,icon:!1,children:`Recommended`})]}),n&&(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:n})]})]})}function fr({v:e,busy:t,onNext:n,next:r}){let[i,a]=(0,Y.useState)(()=>Object.fromEntries(e.questions.map(e=>[e.id,e.answer]))),[o,s]=(0,Y.useState)([]),c=(e,t,n)=>a(r=>{let i=r[e]||[];return{...r,[e]:t===`one`?[n]:i.includes(n)?i.filter(e=>e!==n):[...i,n]}});return(0,X.jsxs)(X.Fragment,{children:[e.questions.map(e=>{let t=e.assumed&&!o.includes(e.id);return(0,X.jsxs)(`fieldset`,{className:g(d,`m-0 flex flex-col gap-2`),children:[(0,X.jsx)(`legend`,{className:`sr-only`,children:e.text}),(0,X.jsx)(`span`,{className:`text-body-lg font-medium`,children:e.text}),t?(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-body-sm text-ink-2`,children:[(0,X.jsx)(z,{icon:G,size:16,className:`text-pass`}),e.assumed,!(i[e.id]||[]).every(t=>e.assumed?.includes(t))&&(0,X.jsxs)(`span`,{className:`text-muted`,children:[`(`,i[e.id]?.join(`, `),`)`]}),(0,X.jsx)(H,{size:`sm`,variant:`ghost`,onClick:()=>s([...o,e.id]),"aria-label":`Change the answer`,"data-tip":`Change the answer`,children:(0,X.jsx)(Ee,{"aria-hidden":`true`})})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:e.why}),(0,X.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:e.options.map(t=>(0,X.jsx)(dr,{on:(i[e.id]||[]).includes(t.id),label:t.label,why:t.why,recommended:t.recommended,onToggle:()=>c(e.id,e.kind,t.id)},t.id))})]})]},e.id)}),(0,X.jsx)(ur,{busy:t,next:r,onNext:()=>n({answers:i}),disabled:e.questions.some(e=>e.id===`environment`&&!(i[e.id]||[]).length),aside:e.environments.length===0?(0,X.jsx)(`span`,{className:`text-fail`,children:`Add a test environment in Settings first: an agent needs one to work in.`}):void 0})]})}var pr={ready:{icon:G,label:`Ready`,tone:`text-pass`},partial:{icon:ke,label:`Partly set up`,tone:`text-warn`},needs_setup:{icon:Pe,label:`Not set up here yet`,tone:`text-muted`}};function mr({v:e,busy:t,onNext:n,onBack:r,next:i}){let[a,o]=(0,Y.useState)(()=>e.plan.filter(e=>e.on).map(e=>e.capability)),[s,c]=(0,Y.useState)(!1),l=a.map(t=>e.plan.find(e=>e.capability===t)).filter(Boolean),u=e.plan.filter(e=>!a.includes(e.capability));return(0,X.jsxs)(X.Fragment,{children:[e.planSteps&&e.planSteps.length>0&&(0,X.jsx)(`ol`,{"aria-label":`How it will work`,className:g(`surface rounded-lg bg-bg p-6 shadow-sm`,`m-0 flex list-none flex-col gap-0 p-0`),children:e.planSteps.map((t,n)=>(0,X.jsxs)(`li`,{className:g(`flex items-start gap-4 px-4 py-4`,n>0&&`border-t border-line-soft`),children:[(0,X.jsx)(Yn,{state:`pending`,n:n+1}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-body-lg font-medium`,children:t.title}),(0,X.jsx)(`span`,{className:`text-body-sm text-ink-2`,children:t.why}),t.without&&(0,X.jsxs)(`span`,{className:`text-body-sm text-muted`,children:[`Without it: `,t.without]}),(0,X.jsx)(`span`,{className:`flex flex-wrap gap-2 pt-1`,children:t.uses.map(t=>{let n=e.plan.find(e=>e.capability===t);return(0,X.jsx)(B,{tone:`neutral`,icon:!1,children:n?.title||t},t)})})]})]},n))}),e.planSteps&&e.planSteps.length>0&&(0,X.jsx)(ln,{icon:Ce,title:`What it uses`,level:3,className:`mt-2`}),(0,X.jsx)(`ol`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:l.map((e,t)=>{let n=pr[e.state];return(0,X.jsxs)(`li`,{className:g(d,`flex items-start gap-4`),children:[(0,X.jsx)(Yn,{state:`pending`,n:t+1}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-body-lg font-medium`,children:e.title}),e.why&&(0,X.jsx)(`span`,{className:`text-body-sm text-ink-2`,children:e.why}),(0,X.jsx)(`span`,{className:`line-clamp-2 text-body-sm text-muted`,children:e.summary}),(0,X.jsxs)(`span`,{className:g(`flex items-center gap-2 text-body-sm`,n.tone),children:[(0,X.jsx)(z,{icon:n.icon,size:14}),n.label,e.state!==`ready`&&e.gaps.length?`: ${e.gaps.join(`; `)}`:``]})]}),(0,X.jsx)(H,{variant:`icon`,size:`icon`,"aria-label":`Leave out ${e.title}`,"data-tip":`Leave out ${e.title}`,onClick:()=>o(a.filter(t=>t!==e.capability)),children:(0,X.jsx)(K,{"aria-hidden":`true`})})]},e.capability)})}),s?(0,X.jsx)(J,{id:`build-add`,icon:W,title:`What else should it do?`,level:3,className:d,children:(0,X.jsx)(`ul`,{className:`m-0 grid list-none grid-cols-1 gap-2 p-0 sm:grid-cols-2`,children:u.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,onClick:()=>o([...a,e.capability]),className:g(Jn,`h-full w-full items-start gap-2`),children:[(0,X.jsx)(W,{size:16,"aria-hidden":`true`,className:`mt-1 flex-none text-muted`}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,X.jsx)(`span`,{className:`text-body-sm font-medium`,children:e.title}),(0,X.jsx)(`span`,{className:`line-clamp-2 text-body-sm text-muted`,children:e.summary})]})]})},e.capability))})}):(0,X.jsxs)(H,{size:`sm`,className:`self-start`,onClick:()=>c(!0),"data-tip":`Add something it should also do`,children:[(0,X.jsx)(W,{"aria-hidden":`true`}),`Add`]}),(0,X.jsx)(ur,{busy:t,onBack:r,next:i,onNext:()=>n({capabilities:a}),disabled:!a.length})]})}function hr({text:e,help:t,on:n,onChange:r,locked:i}){return(0,X.jsxs)(`div`,{className:`flex items-start gap-4 border-t border-line-soft py-4 first:border-t-0`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-body-sm text-ink`,children:e}),(t||i)&&(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:i||t})]}),i?(0,X.jsx)(Ze,{size:18,"aria-label":`Always`,className:`mt-1 flex-none text-muted`}):(0,X.jsx)(Pt,{checked:n,onChange:e=>r?.(e),label:e})]})}function gr({v:e,busy:t,onNext:n,onBack:r,next:i}){let a=e.boundaries,[o,s]=(0,Y.useState)(a.environments),[c,l]=(0,Y.useState)(a.actions),[u,f]=(0,Y.useState)(a.approve),[p,m]=(0,Y.useState)(a.shell),[h,_]=(0,Y.useState)(a.repository),[v,y]=(0,Y.useState)(a.unattended),[b,x]=(0,Y.useState)(a.trust||[]),[S,C]=(0,Y.useState)((a.production||[]).includes(`run`)),w=o.some(t=>e.production.includes(t)),T=(e,t)=>x(t?[...new Set([...b,e])]:b.filter(t=>t!==e)),E=e.plan.filter(e=>e.on&&e.capability.startsWith(`system:`)),D=(e,t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],O=e=>c.includes(e),k=(e,t)=>l(t?[...new Set([...c,e])]:c.filter(t=>t!==e)),A=(e,t)=>f(t?[...new Set([...u,e])]:u.filter(t=>t!==e)),j=o.join(` and `)||`its environments`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`fieldset`,{className:g(d,`m-0 flex flex-col gap-2`),children:[(0,X.jsx)(`legend`,{className:`sr-only`,children:`Where it works`}),(0,X.jsx)(`span`,{className:`text-body-lg font-medium`,children:`Where it works`}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:`Every run, test and call goes only here. In production it reads without asking, and a person approves every change.`}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,X.jsx)(V,{items:e.environments.map(t=>({id:t,label:t,...e.production.includes(t)&&!/prod/i.test(t)?{note:`production`,noteClass:`text-warn`}:{}})),value:o,onChange:s})}),w&&(0,X.jsx)(`span`,{className:`text-body-sm text-warn`,children:`In production, it reads without asking; a person approves every change there, on a schedule too (it waits, and the team is told). Before a step that could reach real customers, it asks you itself.`})]}),(0,X.jsxs)(`section`,{"aria-labelledby":`build-may`,className:g(d,`flex flex-col`),children:[(0,X.jsx)(`h2`,{id:`build-may`,className:`sr-only`,children:`What it may do`}),(0,X.jsx)(hr,{text:`Read test cases, runs, reports and your systems' data`,on:!0,locked:`Always: it cannot work without it, and it changes nothing.`}),e.needs?.run&&(0,X.jsx)(hr,{text:`Run tests and apps in ${j}`,help:`Browser runs, tests, API calls and database queries.`,on:O(`run`),onChange:e=>k(`run`,e)}),e.needs?.run&&O(`run`)&&(0,X.jsx)(hr,{text:`Ask me before each run`,help:`Recommended while it is new; turn it off once you trust it.`,on:u.includes(`run`),onChange:e=>A(`run`,e)}),e.needs?.run&&O(`run`)&&w&&(0,X.jsx)(hr,{text:`Ask me before each run in production`,help:`Off: browser runs, tests and API calls there go ahead without asking. Each question also offers to allow the rest of the run.`,on:!S,onChange:e=>C(!e)}),(0,X.jsx)(hr,{text:`Change test assets on this computer`,help:`Regression packs, API contracts, page memory, recordings. Off unless its job is to make them.`,on:O(`change`),onChange:e=>k(`change`,e)}),O(`change`)&&(0,X.jsx)(hr,{text:`Ask me before each change`,on:u.includes(`change`),onChange:e=>A(`change`,e)}),e.needs?.external&&(0,X.jsx)(hr,{text:`Change other systems as you asked`,help:`Work items or the team's channel, as you chose.`,on:O(`external`),onChange:e=>k(`external`,e)}),O(`external`)&&(0,X.jsx)(hr,{text:`Ask me before each change to another system`,help:`Recommended. Off: it comments, updates and attaches as its job says, without asking.`,on:!b.includes(`external`),onChange:e=>T(`external`,!e)}),e.needs?.repository&&(0,X.jsx)(hr,{text:`Change your repository to write or heal tests`,help:`A coding agent does it on this computer.`,on:h===`write`,onChange:e=>(_(e?`write`:`read`),e&&k(`change`,!0))}),e.needs?.repository&&h===`write`&&(0,X.jsx)(hr,{text:`Ask me before the coding agent works`,help:`Off: it writes and heals tests without asking. The tests it runs can reach any address, so ForgeQE first looks in your test project's config and env files, and asks you when they name an address outside its environments.`,on:!b.includes(`coding`),onChange:e=>T(`coding`,!e)}),(0,X.jsx)(hr,{text:`Use the shell`,help:`Commands on this computer, and fetching web pages. A person approves each one; ForgeQE's secrets stay out of reach.`,on:p,onChange:m})]}),e.schedule&&(0,X.jsxs)(`fieldset`,{className:g(`surface rounded-lg bg-bg p-6 shadow-sm`,`m-0 flex flex-col gap-2`),children:[(0,X.jsx)(`legend`,{className:`sr-only`,children:`What it may do alone`}),(0,X.jsxs)(`span`,{className:`text-body-lg font-medium`,children:[`When it runs `,e.schedule.toLowerCase(),`, with nobody watching`]}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:`What it may do without asking. Anything else waits for a person: the team is told, and no answer in four hours is a no. It may always ask a person itself.`}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:[O(`run`)&&(0,X.jsx)(dr,{on:v.includes(`run`),label:`Run tests and apps`,why:`Recommended: what it is there to do.`,recommended:!0,onToggle:()=>y(D(v,`run`))}),O(`change`)&&(0,X.jsx)(dr,{on:v.includes(`change`),label:`Change test assets`,onToggle:()=>y(D(v,`change`))}),h===`write`&&b.includes(`coding`)&&(0,X.jsx)(dr,{on:v.includes(`coding`),label:`Write or heal tests`,why:`The coding agent, when its test project names no address outside its environments.`,onToggle:()=>y(D(v,`coding`))}),E.map(e=>(0,X.jsx)(dr,{on:v.includes(`${e.capability.slice(7)}_*`),label:`Change ${e.title.replace(/^Work with /,``)}`,why:`Comment, update states, attach evidence, without a person approving each.`,onToggle:()=>y(D(v,`${e.capability.slice(7)}_*`))},e.capability))]})]}),(0,X.jsx)(ur,{busy:t,onBack:r,next:i,onNext:()=>n({environments:o,actions:c,approve:u,repository:h,shell:p,unattended:v,trust:b,production:S?[`run`]:[]}),disabled:!o.length})]})}function _r({v:e,busy:t,onNext:n,onBack:r,next:i}){let a=e.knowledge,[o,s]=(0,Y.useState)(a.files.filter(e=>e.on).map(e=>e.file)),[l,u]=(0,Y.useState)(a.skills.filter(e=>e.on).map(e=>e.name)),[d,f]=(0,Y.useState)(a.notes),p=(e,t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],m=e=>e.toSorted((e,t)=>Number(!!t.why)-Number(!!e.why));return(0,X.jsxs)(X.Fragment,{children:[(a.files.length>0||a.skills.length>0)&&(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:[m(a.files).map(e=>(0,X.jsx)(dr,{on:o.includes(e.file),label:e.title,why:e.why||e.file,recommended:e.on,onToggle:()=>s(p(o,e.file))},e.file)),m(a.skills).map(e=>(0,X.jsx)(dr,{on:l.includes(e.name),label:`Skill: ${e.name}`,why:e.why||e.about,recommended:e.on,onToggle:()=>u(p(l,e.name))},e.name))]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`span`,{className:`text-body-lg font-medium`,children:`Anything else it should know?`}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:`Business rules, what “done” looks like, which test accounts to use (never passwords). It is kept as this agent's own knowledge.`}),(0,X.jsx)(c,{rows:5,value:d,maxLength:2e4,onChange:e=>f(e.target.value),placeholder:`A declined card shows “Payment failed” and keeps the basket.`})]}),(0,X.jsx)(ur,{busy:t,onBack:r,next:i,onNext:()=>n({files:o,skills:l,notes:d})})]})}function vr({v:e,busy:t,onNext:n,onBack:i,next:o}){let c=e.review,[l,d]=(0,Y.useState)(c.name),[f,p]=(0,Y.useState)(c.id),[m,h]=(0,Y.useState)(c.description),[_,v]=(0,Y.useState)(c.icon||``),[y,b]=(0,Y.useState)(c.starters[0]?.text||e.goal),[x,S]=(0,Y.useState)(c.model||``),[C,w]=(0,Y.useState)(c.maxTokens?String(c.maxTokens):``),[T,E]=(0,Y.useState)(c.maxMinutes?String(c.maxMinutes):``),D=[C&&!(Number.isInteger(Number(C))&&Number(C)>=1e3&&Number(C)<=1e8)?`The budget per run is a whole number of tokens, from 1,000 to 100,000,000.`:``,T&&!(Number.isInteger(Number(T))&&Number(T)>=1&&Number(T)<=1440)?`The time limit per run is a whole number of minutes, from 1 to 1440.`:``,x&&!(e.models||[]).some(e=>e.name===x)?`${x} is no longer in llms.json: pick another model, or ForgeQE's choice.`:``].filter(Boolean).join(` `),O={...x?{model:x}:{},...C?{maxTokens:Math.round(Number(C))}:{},...T?{maxMinutes:Math.round(Number(T))}:{}},k=e.plan.filter(e=>e.on),A=e.boundaries,j=e.knowledge,M=[[`It works in`,A.environments.join(`, `)],[`It does`,k.map(e=>e.title).join(`; `)],[`It may`,[A.actions.includes(`run`)?`run tests and apps${A.approve.includes(`run`)?` (asking you first)`:``}`:``,A.actions.includes(`change`)?`change test assets`:``,A.actions.includes(`external`)?`change other systems${(A.trust||[]).includes(`external`)?` (without asking)`:` (asking you first)`}`:``,A.repository===`write`?`write or heal tests${(A.trust||[]).includes(`coding`)?` (without asking, unless its test project names an address outside its environments)`:` (asking you first)`}`:``].filter(Boolean).join(`; `)||`only read`],[`Runs by itself`,e.schedule?`${e.schedule.toLowerCase()}, with nobody watching${A.unattended.length?`; alone it may ${A.unattended.map(e=>e===`run`?`run tests and apps`:e===`change`?`change test assets`:e===`coding`?`write or heal tests`:`change ${e.replace(/_\*$/,``).replace(/_/g,` `)}`).join(`, `)}`:``}`:`no: you, your team or Atlas start it`],...A.shell?[[`Shell`,`yes, a person approves each command`]]:[],[`It knows`,[...j.files.filter(e=>e.on).map(e=>e.title),...j.skills.filter(e=>e.on).map(e=>e.name),...j.notes.trim()?[`your notes`]:[]].join(`, `)||`nothing extra`]];return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Name`}),(0,X.jsx)(a,{value:l,maxLength:60,onChange:e=>d(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Id`}),(0,X.jsx)(a,{value:f,maxLength:40,spellCheck:!1,disabled:!!e.saved,onChange:e=>p(e.target.value.toLowerCase())})]})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`What it is for`}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:`One line. Atlas reads it to know when to hand it work.`}),(0,X.jsx)(a,{value:m,maxLength:300,onChange:e=>h(e.target.value)})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Icon`}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:`What it wears on the Agents page: its mascot, or one of ForgeQE's agent icons.`}),(0,X.jsx)(yn,{value:_,onChange:v})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-3`,children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Budget per run`}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:`The most model tokens one run may use, 1,000 or more; it stops there. Empty: no limit.`}),(0,X.jsx)(a,{type:`number`,min:1e3,step:1e3,value:C,placeholder:`No limit`,onChange:e=>w(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Time limit per run`}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:`In minutes, 1 to 1440. Empty: no limit when someone is watching, 120 when nobody is (a schedule, a trigger, another agent).`}),(0,X.jsx)(a,{type:`number`,min:1,max:1440,value:T,placeholder:`Minutes`,onChange:e=>E(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Model`}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:`The model profile of llms.json its runs use.`}),(0,X.jsxs)(s,{value:x,onChange:e=>S(e.target.value),children:[(0,X.jsx)(`option`,{value:``,children:`ForgeQE's choice`}),(e.models||[]).map(e=>(0,X.jsxs)(`option`,{value:e.name,children:[e.name,` (`,e.model,`)`]},e.name)),x&&!(e.models||[]).some(e=>e.name===x)&&(0,X.jsxs)(`option`,{value:x,children:[x,` (not in llms.json)`]})]})]})]}),D&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 text-body-sm text-fail`,children:D}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Its first request`}),(0,X.jsx)(a,{value:y,maxLength:500,onChange:e=>b(e.target.value)})]}),(0,X.jsx)(`dl`,{className:g(u,`m-0 grid grid-cols-1 gap-x-6 gap-y-2 text-body-sm sm:grid-cols-[140px_1fr]`),children:M.map(([e,t])=>(0,X.jsxs)(`div`,{className:`contents`,children:[(0,X.jsx)(`dt`,{className:`text-muted`,children:e}),(0,X.jsx)(`dd`,{className:`m-0 text-ink [overflow-wrap:anywhere]`,children:t})]},e))}),e.advice.filter(e=>e.blocking).length>0&&(0,X.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:e.advice.filter(e=>e.blocking).map((e,t)=>(0,X.jsxs)(`li`,{className:g(L.warn,`flex flex-col gap-1`),children:[(0,X.jsx)(`span`,{className:`font-medium text-warn`,children:e.about}),(0,X.jsx)(`span`,{className:`text-body-sm text-ink-2`,children:e.fix})]},t))}),(0,X.jsx)(ur,{busy:t,onBack:i,next:e.saved?`Save the changes`:o,onNext:()=>n({name:l,id:f,description:m,icon:_,starters:[{label:`Run it now`,text:y}],...O}),disabled:!l.trim()||!f.trim()||!!D,aside:e.saved?(0,X.jsxs)(`a`,{href:r(`agents`,`custom`,e.saved,`edit`),className:`inline-flex items-center gap-2`,children:[(0,X.jsx)(Me,{size:14,"aria-hidden":`true`}),`Open every setting`]}):(0,X.jsxs)(H,{size:`sm`,variant:`ghost`,disabled:t||!l.trim()||!f.trim()||!!D,onClick:()=>n({name:l,id:f,description:m,icon:_,starters:[{label:`Run it now`,text:y}],...O},!0),"data-tip":`Save it as a draft, then open every setting`,children:[(0,X.jsx)(Me,{"aria-hidden":`true`}),`Save and open every setting`]})})]})}function yr({v:e}){let t=e.saved,[n,i]=(0,Y.useState)(e.review?.starters[0]?.text||e.goal),[o,s]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(``),[m,h]=(0,Y.useState)(!1),_=async()=>{u(!0);try{let{id:e}=await re.start(n.trim(),{agent:t,try:!0});location.hash=r(`chats`,e)}catch(e){p(e.message),u(!1)}},v=async()=>{u(!0),p(``);try{await M.act(t,`approve`,{confirm:o,note:`Made with the agent builder`}),h(!0)}catch(e){p(e.message)}finally{u(!1)}};return m?(0,X.jsxs)(`div`,{className:g(L.pass,`flex flex-col items-start gap-4`),children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-2 text-body-lg font-medium text-pass`,children:[(0,X.jsx)(G,{size:18,"aria-hidden":`true`}),A(e.review?.name||`agent`,!0),` is ready.`]}),(0,X.jsx)(`span`,{className:`text-body-sm text-ink-2`,children:`You, your team and Atlas can hand it work now.`}),(0,X.jsxs)(`a`,{href:r(`agents`,`custom`,t),className:g(R({variant:`primary`,size:`sm`}),`no-underline`),"data-tip":`Open the agent`,children:[(0,X.jsx)(dt,{"aria-hidden":`true`}),`Open`]})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(J,{id:`build-try`,icon:Ae,title:`1. Try it on a real request`,level:3,className:d,children:[(0,X.jsx)(c,{rows:2,"aria-label":`What to try`,value:n,onChange:e=>i(e.target.value)}),(0,X.jsxs)(H,{variant:`primary`,size:`sm`,className:`self-start`,disabled:l||!n.trim(),onClick:()=>void _(),"data-tip":`Try it in a chat`,children:[(0,X.jsx)(Ae,{"aria-hidden":`true`}),`Try`]}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:`It opens as a chat. Come back here to approve it: Agents, Custom agents, then this agent.`})]}),(0,X.jsxs)(J,{id:`build-approve`,icon:G,title:`2. Approve it`,level:3,className:d,children:[(0,X.jsxs)(`span`,{className:`text-body-sm text-muted`,children:[`Only an approved version runs. Type its id to confirm: `,t]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(a,{"aria-label":`Type ${t} to confirm`,className:`w-[260px]`,value:o,spellCheck:!1,autoComplete:`off`,onChange:e=>s(e.target.value),placeholder:t}),(0,X.jsxs)(H,{size:`sm`,disabled:l||o!==t,onClick:()=>void v(),children:[(0,X.jsx)(G,{"aria-hidden":`true`}),`Approve`]})]})]}),f&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 text-body-sm text-fail [overflow-wrap:anywhere]`,children:f}),(0,X.jsx)(`a`,{href:r(`agents`,`custom`,t),className:`self-start text-body-sm`,children:`Open its page`})]})}function br({text:e,file:t}){let n=e.replace(/\n$/,``).split(`
|
|
2
|
-
`);return(0,X.jsx)(J,{id:`ca-manifest`,icon:Xe,title:(0,X.jsxs)(X.Fragment,{children:[`Its manifest, as it is in `,(0,X.jsx)(`span`,{className:`font-mono`,children:t})]}),description:`Read only: fix it in that file, or start a new agent from the form and delete this one.`,className:`w-full text-left`,children:(0,X.jsx)(`pre`,{tabIndex:0,"aria-label":`The manifest in ${t}`,className:g(d,`m-0 max-h-[50vh] overflow-auto font-mono text-body-sm leading-relaxed`),children:n.map((e,t)=>(0,X.jsxs)(`span`,{className:`block pl-12 -indent-12 whitespace-pre-wrap [overflow-wrap:anywhere]`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`mr-4 inline-block w-8 text-right text-muted select-none`,children:t+1}),e]},t))})})}function xr(e,t){let n=e.endedAt?Date.parse(e.endedAt)-Date.parse(e.startedAt):NaN,r=Number.isFinite(n)&&n>=0?n>=6e4?`${Math.floor(n/6e4)} min`:`${Math.max(1,Math.floor(n/1e3))}s`:``;return[e.model||``,e.usage?t.usage(e.usage):``,r,e.cost?`about ${t.money(e.cost.amount,e.cost.currency)}`:``].filter(Boolean).join(` · `)}var Sr=[`text`,`environment`,`choice`],Cr=/[\u0000-\u001f\u007f\u2028\u2029]/,wr=/\{([a-z][a-z0-9_]{0,31})\}/g;function Tr(e){return[...new Set([...e.matchAll(wr)].map(e=>e[1]))]}function Er(e,t,n){return typeof t!=`string`||!t.trim()?`${e.label} needs a value.`:t.length>200?`${e.label} is longer than 200 characters.`:Cr.test(t)?`${e.label} must be one line of text.`:t.trim().startsWith(`-`)?`${e.label} cannot start with a dash.`:e.kind===`environment`&&!n.includes(t)?`${e.label}: "${t.slice(0,40)}" is not one of its environments.`:e.kind===`choice`&&!(e.options||[]).includes(t)?`${e.label}: "${t.slice(0,40)}" is not one of its options.`:``}function Dr(e,t,n,r){let i=[];for(let a of Tr(e)){let e=t.find(e=>e.name===a);if(!e)i.push(`{${a}} is not one of its inputs.`);else{let t=Er(e,Object.hasOwn(n,a)?n[a]:void 0,r);t&&i.push(t)}}if(i.length)throw Error(i.join(` `));let a=e.replace(wr,(e,t)=>n[t].trim());if(a.trim().startsWith(`-`))throw Error(`The request cannot start with a dash.`);return a}var Or=(e,t,n,r)=>r.map(([r,i,a])=>({file:`${n}/${r}`,url:`https://huggingface.co/${e}/resolve/${t}/${r}`,bytes:i,sha256:a}));Object.freeze(`anyio==4.15.1 ; sys_platform != 'emscripten',attrs==26.1.0,av==19.0.2,click==8.5.0,cloudpickle==3.1.2,colorama==0.4.6 ; sys_platform == 'win32',ctranslate2==4.8.4,dlinfo==2.0.0,espeakng-loader==0.2.4,faster-whisper==1.2.1,filelock==4.2.6,flatbuffers==25.12.19,fsspec==2026.9.0,h11==0.16.0 ; sys_platform != 'emscripten',hf-xet==1.8.0 ; platform_machine == 'AMD64' or platform_machine == 'ARM64' or platform_machine == 'aarch64' or platform_machine == 'amd64' or platform_machine == 'arm64' or platform_machine == 'x86_64',httpcore2==2.16.0 ; sys_platform != 'emscripten',httpx2==2.16.0,httpx2-jsfetch==1.0 ; sys_platform == 'emscripten',huggingface-hub==2.4.0,idna==3.20,joblib==1.6.0,kokoro-onnx==0.6.1,numpy==2.5.4,onnxruntime==1.31.1,packaging==26.3,phonemizer==3.4.0,protobuf==7.36.2,pyyaml==6.0.3,tokenizers==0.23.3,tqdm==4.70.1,truststore==0.10.5 ; sys_platform != 'emscripten',typing-extensions==4.16.0`.split(`,`));var kr=`https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files-v1.0`,Ar=Object.freeze([{file:`kokoro-onnx/kokoro-v1.0.onnx`,url:`${kr}/kokoro-v1.0.onnx`,bytes:325532387,sha256:`7d5df8ecf7d4b1878015a32686053fd0eebe2bc377234608764cc0ef3636a6c5`},{file:`kokoro-onnx/voices-v1.0.bin`,url:`${kr}/voices-v1.0.bin`,bytes:28214398,sha256:`bca610b8308e8d99f32e6fe4197e7ec01679264efed0cac9140fe9c29f1fbf7d`}]),jr=`https://huggingface.co/Systran/faster-whisper-base.en/resolve/3d3d5dee26484f91867d81cb899cfcf72b96be6c`,Mr=Object.freeze([{file:`whisper-base.en/config.json`,url:`${jr}/config.json`,bytes:2227,sha256:`f3bc3821e9fc76a27bae538e11ae5b677dcdd352b4600429ce7951d398569aeb`},{file:`whisper-base.en/tokenizer.json`,url:`${jr}/tokenizer.json`,bytes:2128466,sha256:`929c5252409436dce1b38a75d1abbcb5e132d170d8e324e4e04ed915fa2d22df`},{file:`whisper-base.en/vocabulary.txt`,url:`${jr}/vocabulary.txt`,bytes:422309,sha256:`ff77588746d3a2595d32ab5b69ffd7b95ce2441ac57533cb66fc3eb575a115cf`},{file:`whisper-base.en/model.bin`,url:`${jr}/model.bin`,bytes:145216508,sha256:`2a166925539a16005f14ff328359f9b9adb9dc4fb631bb3b227526862e93e2ef`}]),Nr=Object.freeze(Or(`onnx-community/silero-vad`,`e71cae966052b992a7eca6b17738916ce0eca4ec`,`silero-vad`,[[`onnx/model.onnx`,2243022,`a4a068cd6cf1ea8355b84327595838ca748ec29a25bc91fc82e6c299ccdc5808`]])),Pr=Object.freeze(Or(`pipecat-ai/smart-turn-v3`,`f766f81d3cfdf7737ac64aad813d91bbfd56bf93`,`smart-turn-v3`,[[`smart-turn-v3.2-cpu.onnx`,8679182,`2bb026316b14a660486a75b1733cd3fbab8c2fd0314dc9af7be49f8cca967e4f`]])),Fr=Object.freeze([...Nr,...Pr]);Object.freeze([...Ar,...Mr,...Fr]),Object.freeze({en:Object.freeze([`af_heart`,`am_michael`])}),Object.freeze({en:`af_heart`});var Ir=Object.freeze([`light`,`deep`]);Object.freeze({en:{light:`af_heart`,deep:`am_michael`}});var Lr=[`suite_failed`,`suite_passed`,`job_failed`,`job_recovered`,`eval_failed`,`pr_opened`,`pr_updated`,`push`],Rr=[`pr_opened`,`pr_updated`,`push`],zr=[`number`,`text`,`yes_no`],Br=e=>e.replace(/(?<!\s)\s+MCP\s*$/i,``),Vr={id:``,name:``,version:`1.0.0`,description:``,instructions:``,scope:{agents:[],capabilities:[],skills:[],knowledge:[],environments:[]},permissions:{repository:`read`,actions:[`read`],approve:[]},runtime:{maxDelegationDepth:1},policies:[],starters:[]},Hr=[{name:`About it`,title:`What it is`,icon:gt,tip:`Its name, description and instructions`},{name:`What it uses`,title:`What it works with`,icon:Ge,tip:`Environments, capabilities, agents, systems, skills and knowledge`},{name:`Permissions`,title:`What it may do`,icon:Ze,tip:`Actions, the repository, the shell and its limits per run`},{name:`Runs by itself`,title:`When it runs by itself`,icon:qe,tip:`A schedule, triggers and what it does alone`},{name:`Inputs and output`,title:`What it takes and reports`,icon:Oe,tip:`Inputs, starters, memory and output`},{name:`Review`,title:`Check and save`,icon:pe,tip:`Checks, approval and a last look before saving`}],Ur=Hr.length-1;function Wr(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^[^a-z]+/,``).replace(/(?<!-)-+$/,``).slice(0,40).replace(/(?<!-)-+$/,``)}var Gr={read:{label:`Read`,help:`Test cases, runs, reports, the repository, systems' data. Changes nothing.`},run:{label:`Run`,help:`Browser runs, tests, API calls and database queries, in its environments only.`},change:{label:`Change files`,help:`Test assets on this computer: packs, contracts, page memory, recordings.`},external:{label:`Change other systems`,help:`Work items, pull requests, pipelines, channels.`}},Kr=6,qr={number:`A number`,text:`One line of text`,yes_no:`Yes or no`},Jr=Rr,Yr={suite_failed:`A suite failed`,suite_passed:`A suite passed`,job_failed:`A schedule failed`,job_recovered:`A schedule recovered`,eval_failed:`An eval failed`,pr_opened:`A pull request opened`,pr_updated:`A pull request updated`,push:`A branch pushed to`},Xr={text:`Text`,environment:`One of its environments`,choice:`One of a list`},Zr={read:`Read`,run:`Run`,change:`Change files`,external:`Change other systems`,schedule:`Schedule work`};function Qr(e){let t=e.schedule?.with;if(!e.schedule||!t)return e;let n=new Set(Tr(e.schedule.request)),r=Object.fromEntries(Object.entries(t).filter(([t,r])=>{let i=(e.inputs||[]).find(e=>e.name===t);return!i||!n.has(t)?!1:i.kind===`choice`?(i.options||[]).map(e=>e.trim()).includes(r.trim()):i.kind!==`environment`||e.scope.environments.includes(r)}));if(Object.keys(r).length===Object.keys(t).length)return e;let{with:i,...a}=e.schedule;return{...e,schedule:{...a,...Object.keys(r).length?{with:r}:{}}}}function $r(e,t){let n=e.permissions.deny||[];if(!n.length)return e;let r=new Set(t.flatMap(e=>(e.usable||[]).map(e=>e.name))),i=new Set(t.filter(t=>e.scope.capabilities.includes(t.id)).flatMap(e=>(e.usable||[]).map(e=>e.name))),a=n.filter(e=>!r.has(e)||i.has(e));return a.length===n.length?e:{...e,permissions:{...e.permissions,deny:a}}}var ei={ready:{icon:G,label:`Ready`,cls:`text-pass`},partial:{icon:ke,label:`Partly set up`,cls:`text-warn`},needs_setup:{icon:Pe,label:`Needs setup`,cls:`text-muted`}},ti=e=>e?e.cron===void 0?`every`:`cron`:``;function ni(e,t,n=[]){let r=e.permissions,i=r.repository===`write`?n.filter(e=>(r.trust||[]).includes(e)):[],a=[...r.actions.includes(`run`)?[{key:`run`,ids:[`run`],label:`Run tests and apps`}]:[],...r.actions.includes(`change`)?[{key:`change`,ids:[`change`],label:`Change test assets`}]:[],...i.length?[{key:`coding`,ids:i,label:`Write or heal tests`}]:[],...(e.scope.systems||[]).map(e=>({key:`${e}_*`,ids:[`${e}_*`],label:`Change ${Br(t.find(t=>t.name===e)?.label||e)}`}))],o=new Set(a.flatMap(e=>e.ids)),s={external:`Change other systems`,schedule:`Schedule work`};return[...a,...(r.unattended||[]).filter(e=>!o.has(e)).map(e=>({key:e,ids:[e],label:s[e]||e.replace(/_\*$/,` (all its tools)`).replace(/_/g,` `)}))]}function ri(e,t=[],n=t){let r=e.permissions,i=new Set(e.scope.systems||[]),a=new Set([`run`,`change`,`external`,`schedule`]),o=(r.unattended||[]).filter(e=>a.has(e)?r.actions.includes(e):e.endsWith(`_*`)?i.has(e.slice(0,-2)):!t.includes(e)||n.includes(e)&&r.repository===`write`&&(r.trust||[]).includes(e));return o.length===(r.unattended||[]).length?e:{...e,permissions:{...r,unattended:o}}}var ii=(e,t,n)=>n?[...new Set([...e,t])]:e.filter(e=>e!==t);function Z({checked:e,onChange:t,disabled:n,children:r,help:i}){return(0,X.jsxs)(`label`,{className:g(`flex items-start gap-2 text-body-sm`,n?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,X.jsx)(on,{checked:e,disabled:n,onCheckedChange:t,className:`mt-1`}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,X.jsx)(`span`,{className:`text-ink`,children:r}),i&&(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:i})]})]})}function ai({id:e,label:t,options:n,onChange:r,placeholder:i=`checkout, search`,max:o=12,mono:s=!1}){let[c,l]=(0,Y.useState)(n.join(`, `)),u=e=>[...new Set(e.split(`,`).map(e=>e.trim()).filter(Boolean))].slice(0,o);return(0,Y.useEffect)(()=>{u(c).join(`\0`)!==n.join(`\0`)&&l(n.join(`, `))},[n.join(`\0`)]),(0,X.jsx)(a,{id:e,"aria-label":t,className:g(`min-w-0 flex-[1_1_200px]`,s&&`font-mono`),value:c,placeholder:i,maxLength:o*122,spellCheck:!s,onChange:e=>{let t=s?e.target.value.toLowerCase():e.target.value;l(t),r(u(t))}})}function oi({id:e,input:t,environments:n,value:r,onChange:i}){let o=t.kind===`environment`?n:t.kind===`choice`?t.options||[]:null;return o?(0,X.jsxs)(s,{id:e,value:r,className:`w-[200px]`,onChange:e=>i(e.target.value),children:[(0,X.jsx)(`option`,{value:``,children:`Pick one`}),o.map(e=>(0,X.jsx)(`option`,{value:e,children:e},e))]}):(0,X.jsx)(a,{id:e,value:r,maxLength:200,className:`w-[200px]`,onChange:e=>i(e.target.value)})}var si=[void 0,`Only what you pick here is loaded for it, and every call it makes is held to it.`,`Enforced on every call. Ask first: a person approves each such call in the chat. In production, every call is asked.`,`On a schedule or a trigger it runs the approved version with nobody watching: it does alone only what you tick under What it may do alone, and anything else waits for a person.`,`What people give it when they start it, what it keeps between runs, and what its reply reports.`,`Requests to try it on, who approves it, and everything it is about to be saved with.`],ci=(e,t=`None`)=>e.length?e.join(`, `):t;function li(e,t){let n=e.permissions,r=e=>t.capabilities.find(t=>t.id===e)?.title||e,i=e=>t.agents.find(t=>t.name===e)?.title||e,a=e=>Br(t.systems.find(t=>t.name===e)?.label||e),o=e.schedule,s=o?ti(o)===`cron`?`On the cron schedule ${o.cron||`(not given)`}`:`Every ${o.every||`(not given)`}`:`Only when asked`,c=[e.runtime.maxTokens?`${e.runtime.maxTokens} tokens`:``,e.runtime.maxMinutes?`${e.runtime.maxMinutes} minutes`:``,e.runtime.model?`model ${e.runtime.model}`:``].filter(Boolean);return[{step:0,label:`Name`,text:e.name.trim()?`${e.name} (${e.id||`no id`})`:`Not named yet`,aside:!0},{step:0,label:`Description`,text:e.description.trim()||`None`},{step:0,label:`Instructions`,text:e.instructions.trim()?`${e.instructions.trim().split(/\s+/).length} words`:`None`},{step:1,label:`Environments`,text:ci(e.scope.environments),aside:!0},{step:1,label:`Capabilities`,text:ci(e.scope.capabilities.map(r)),aside:!0},{step:1,label:`Agents it may use`,text:ci(e.scope.agents.map(i))},{step:1,label:`Hands work to`,text:ci((e.scope.customAgents||[]).map(e=>t.customAgents?.find(t=>t.id===e)?.name||e))},{step:1,label:`Systems`,text:ci((e.scope.systems||[]).map(a))},{step:1,label:`Skills and knowledge`,text:ci([...e.scope.skills,...e.scope.knowledge])},{step:2,label:`Actions`,text:ci(n.actions.map(e=>(Gr[e]?.label||e)+((e===`external`?!(n.trust||[]).includes(`external`):n.approve.includes(e))?` (asks first)`:``))),aside:!0},{step:2,label:`Repository`,text:n.repository===`write`?`May change files`:`Read only`},{step:2,label:`Shell`,text:n.shell?`Yes, each command approved`:`No`},{step:2,label:`Limits per run`,text:ci(c,`None`)},{step:3,label:`Runs by itself`,text:s,aside:!0},{step:3,label:`Starts when`,text:ci((e.triggers||[]).map(e=>Yr[e.on]))},{step:3,label:`Does alone`,text:e.schedule||(e.triggers||[]).length?ci(ni(e,t.systems).filter(e=>e.ids.every(e=>(n.unattended||[]).includes(e))).map(e=>e.label),`Only reading`):`Nothing: it runs only when someone is watching`},{step:4,label:`Inputs`,text:ci((e.inputs||[]).map(e=>e.label||e.name))},{step:4,label:`Starters`,text:ci(e.starters.map(e=>e.label||e.text).filter(Boolean)),aside:!0},{step:4,label:`Memory`,text:e.memory?.notes?`Up to ${e.memory.notes} notes`:`No memory`},{step:4,label:`Verdicts`,text:ci(e.output?.verdicts||[])},{step:Ur,label:`Checks`,text:ci((e.checks||[]).map(e=>e.name||e.request).filter(Boolean)),aside:!0},{step:Ur,label:`Approval`,text:`${(e.approval?.people||1)===1?`One person`:`${e.approval.people} different people`}${(e.approval?.owners||[]).length?`: ${e.approval.owners.join(`, `)}`:``}`}]}function ui({fields:e,choices:t}){let n=e.scope.capabilities.map(e=>t.capabilities.find(t=>t.id===e)?.title||e),r=li(e,t).filter(e=>e.aside&&e.label!==`Name`&&e.label!==`Capabilities`);return(0,X.jsxs)(`aside`,{"aria-label":`Preview`,className:g(d,`hidden flex-col gap-4 @5xl:sticky @5xl:top-6 @5xl:flex`),children:[(0,X.jsx)(`span`,{className:`text-body-sm font-medium text-muted`,children:`Preview`}),(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-4`,children:[(0,X.jsx)(b,{agent:e.id||`custom`,icon:e.icon,px:48,decorative:!0}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,X.jsx)(`span`,{className:g(`truncate text-body-lg font-medium`,e.name.trim()?`text-ink`:`text-muted`),children:e.name.trim()||`Not named yet`}),(0,X.jsx)(`span`,{className:`truncate font-mono text-body-sm text-muted`,children:e.id||`no-id`}),(0,X.jsxs)(`span`,{className:`text-body-sm text-muted`,children:[`Version `,e.version||`not given`]})]})]}),e.description.trim()&&(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-ink-2 [overflow-wrap:anywhere]`,children:e.description}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`span`,{className:`text-body-sm font-medium text-muted`,children:`Capabilities`}),n.length?(0,X.jsx)(`span`,{className:`flex flex-wrap gap-1`,children:n.map(e=>(0,X.jsx)(B,{tone:`neutral`,icon:!1,children:e},e))}):(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:`None yet`})]}),(0,X.jsx)(`dl`,{className:g(l,`m-0 flex flex-col gap-2`),children:r.map(e=>(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(`dt`,{className:`text-body-sm text-muted`,children:e.label}),(0,X.jsx)(`dd`,{className:g(`m-0 text-body-sm [overflow-wrap:anywhere]`,/^(None|Only when asked)$/.test(e.text)?`text-muted`:`text-ink`),children:e.text})]},e.label))})]})}function di(e,t,n,r=!1){let i=(e.checks||[]).length;return[{ok:!!e.name.trim()&&!!e.id,step:0,text:e.name.trim()?`Named ${e.name.trim()}`:`It has no name yet`},{ok:!!e.instructions.trim(),step:0,text:e.instructions.trim()?`Its instructions are written`:`No instructions yet: it knows only its description`},{ok:e.scope.environments.length>0,step:1,text:e.scope.environments.length?`Works in ${e.scope.environments.join(`, `)}`:`No environment picked: it can run nothing`},{ok:e.scope.capabilities.length>0,step:1,text:e.scope.capabilities.length?`Uses ${e.scope.capabilities.length} ${e.scope.capabilities.length===1?`capability`:`capabilities`}`:`No capability picked: it has no tools`},{ok:t.length===0,step:3,text:t.length?t[0]:e.schedule||(e.triggers||[]).length?`Its schedule and triggers say what they ask`:`It runs only when someone asks`},{ok:i>0,step:Ur,text:i?`${i} ${i===1?`check`:`checks`} to try it on`:`No checks: it is approved only when a person says so`},{ok:!r&&n.length===0,step:Ur,text:r?`Checking the manifest…`:n.length?`${n.length} ${n.length===1?`problem`:`problems`} in the manifest, listed below`:`The manifest checks out`}]}function fi({items:e,onGo:t}){let n=e.filter(e=>e.ok).length;return(0,X.jsx)(J,{icon:Ze,title:`Before you save`,n:`${n} of ${e.length}`,level:3,children:(0,X.jsx)(`ul`,{className:g(d,`m-0 flex list-none flex-col gap-0 py-2`),children:e.map((e,n)=>(0,X.jsxs)(`li`,{className:`flex items-center gap-2 border-b border-line-soft py-2 last:border-b-0`,children:[(0,X.jsx)(z,{icon:e.ok?G:Ie,size:16,className:g(`flex-none`,e.ok?`text-pass`:`text-warn`)}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 text-body-sm text-ink [overflow-wrap:anywhere]`,children:e.text}),!e.ok&&e.step<Ur&&(0,X.jsx)(H,{variant:`link`,size:`inline`,onClick:()=>t(e.step),"aria-label":`Change: ${Hr[e.step].name}`,children:`Change`})]},n))})})}function pi({facts:e,onGo:t}){return(0,X.jsx)(J,{icon:gt,title:`What it is saved with`,level:3,className:`mt-10`,children:(0,X.jsx)(`div`,{className:`flex flex-col gap-4`,children:Hr.slice(0,Ur).map((n,r)=>(0,X.jsxs)(`div`,{className:g(d,`flex flex-col gap-2`),children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(z,{icon:n.icon,size:16,className:`flex-none text-icon`}),(0,X.jsx)(`span`,{className:`flex-1 text-body-sm font-medium text-ink`,children:n.name}),(0,X.jsx)(H,{variant:`link`,size:`inline`,onClick:()=>t(r),"aria-label":`Change: ${n.name}`,children:`Change`})]}),(0,X.jsx)(`dl`,{className:`m-0 grid grid-cols-[minmax(0,1fr)] gap-x-4 gap-y-2 @xl:grid-cols-[160px_minmax(0,1fr)]`,children:e.filter(e=>e.step===r).map(e=>(0,X.jsxs)(Y.Fragment,{children:[(0,X.jsx)(`dt`,{className:`text-body-sm font-medium text-muted`,children:e.label}),(0,X.jsx)(`dd`,{className:`m-0 text-body-sm [overflow-wrap:anywhere]`,children:e.text})]},e.label))})]},n.name))})})}function mi({id:e,template:t}){let n=!e,[i,o]=(0,Y.useState)(n&&!t?Vr:null),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(``),[h,_]=(0,Y.useState)(``),[v,y]=(0,Y.useState)(null),[b,x]=(0,Y.useState)([]),[S,C]=(0,Y.useState)([]),[w,T]=(0,Y.useState)(!1),[E,D]=(0,Y.useState)(!1),[O,k]=(0,Y.useState)(!1),[A,j]=(0,Y.useState)(0),[N,ee]=(0,Y.useState)(n&&!t?0:Ur),P=e=>{m(``),j(e),ee(t=>Math.max(t,e)),window.scrollTo({top:0})};(0,Y.useEffect)(()=>{M.choices().then(f,e=>m(e.message)),t&&M.template(t).then(e=>{u(e),o({...Vr,...e.fields,scope:{...Vr.scope,...e.fields.scope},permissions:{...Vr.permissions,...e.fields.permissions}}),k(!0)},e=>m(e.message)),e&&M.view(e).then(t=>(_(t.approvedVersion||``),t.form?o({...Vr,...t.form,runtime:{...t.form.runtime}}):t.manifestText===void 0?m(`${e} has no manifest the editor can read (it may have been removed). Its page says what it has.`):(y({text:t.manifestText,file:t.manifestFile||`.forgeqe/agents/${e}.yaml`,problems:t.problems.working}),m(`${e}'s manifest is not one the editor can read. Fix it in ${t.manifestFile||`.forgeqe/agents/${e}.yaml`}; what is wrong, and the file as it is, are below.`))),e=>m(e.message))},[e,t]);let te=(0,Y.useRef)(0);(0,Y.useEffect)(()=>{if(!i)return;let e=++te.current;T(!0);let t=setTimeout(()=>{M.validate(Qr(i)).then(t=>e===te.current&&(x(t.problems||[]),C(t.advice||[]),T(!1)),t=>e===te.current&&(x([t.message]),T(!1)))},350);return()=>clearTimeout(t)},[i]);let F=e=>o(t=>t&&{...t,...e}),I=d?.coding||[],ne=e=>I.filter(t=>(d?.capabilities||[]).some(n=>e.scope.capabilities.includes(n.id)&&n.tools.includes(t))),re=e=>$r(ri(e,I,ne(e)),d?.capabilities||[]),R=e=>o(t=>t&&re({...t,scope:{...t.scope,...e}})),ie=i?[...d?.personas||[],...(i.personas||[]).filter(e=>!(d?.personas||[]).some(t=>t.id===e)).map(e=>({id:e,name:`${e} (not in this project)`}))].filter(e=>e.id!==i.persona):[],B=e=>o(t=>t&&{...t,voice:e?{sound:e}:void 0}),V=e=>o(t=>t&&re({...t,permissions:{...t.permissions,...e}})),se=e=>o(t=>{if(!t)return t;let n=t.schedule?.request??t.starters[0]?.text??``;if(!e)return{...t,schedule:void 0,...(t.triggers||[]).length?{}:{permissions:{...t.permissions,unattended:[]}}};let r=t.schedule?.with?{with:t.schedule.with}:{};return{...t,schedule:e===`every`?{every:t.schedule?.every??`1d`,request:n,...r}:{cron:t.schedule?.cron??`0 7 * * 1-5`,request:n,...r}}}),ce=e=>o(t=>t?.schedule?{...t,schedule:{...t.schedule,...e}}:t),ue=i?.schedule,de=[...ue&&ti(ue)===`every`&&!ue.every?.trim()?[`Say how often it runs: 15m, 1h, 1d.`]:[],...ue&&ti(ue)===`cron`&&!ue.cron?.trim()?[`Give its cron schedule: 0 7 * * 1-5.`]:[],...ue&&!ue.request.trim()?[`Say what it is asked each time it runs by itself.`]:[],...(i?.triggers||[]).flatMap((e,t)=>e.request.trim()?[]:[`Say what trigger ${t+1} asks it (${Yr[e.on].toLowerCase()}).`])],fe=[...de,...b],pe=!!i?.id&&!!i?.name&&de.length===0,me=e=>e===0?!!i?.name.trim()&&!!i?.id:e!==3||de.length===0,[he,U]=(0,Y.useState)(``),[ge,ve]=(0,Y.useState)(``),ye=(0,Y.useMemo)(()=>{let e=new Map;for(let t of d?.capabilities||[])e.set(t.area,[...e.get(t.area)||[],t]);return[...e]},[d]),be=(0,Y.useMemo)(()=>{let e=he.toLowerCase().split(/\s+/).filter(Boolean);return(d?.capabilities||[]).filter(t=>(!ge||t.area===ge)&&e.every(e=>`${t.title} ${t.area} ${t.summary}`.toLowerCase().includes(e)))},[d,he,ge]),xe=async()=>{if(i){D(!0),m(``);try{let t=await M.save(Qr(i),n?{create:!0}:{id:e});location.hash=r(`agents`,`custom`,t.id)}catch(e){m(e.message),D(!1)}}},Se=e?r(`agents`,`custom`,e):r(`agents`,`custom`,`new`);return(0,X.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,X.jsx)(Gt,{}),(0,X.jsxs)(`main`,{className:g(qt,`@container flex-auto gap-2`),children:[(0,X.jsx)(le,{href:Se,label:e?`Back to the agent`:`Back to the builder`,className:`mb-2`}),(0,X.jsx)(`h1`,{className:`m-0 text-headline-lg`,children:n?`New custom agent`:`Edit ${i?.name||e}`}),(0,X.jsx)(`p`,{className:`m-0 mb-2 text-body-sm leading-relaxed text-ink-2`,children:n?l?`ForgeQE's ${l.title} template, filled from this project. Read every setting and change what does not fit: it is saved as a draft, and runs once a person has tried and approved it.`:`An agent for one job your team repeats. It uses ForgeQE's own agents, tools, skills and knowledge, and is held to the environments and actions you pick here, on every call. It runs once a person has tried and approved it.`:`Saving changes its manifest only. The approved version keeps running until this change is approved on its page.`}),p&&(0,X.jsx)(`p`,{role:`alert`,className:g(L.fail,`m-0`),children:p}),A===0&&l&&d&&(0,X.jsx)(J,{id:`ca-template`,icon:Qe,title:(0,X.jsxs)(X.Fragment,{children:[`From the `,l.title,` template`]}),level:3,className:`mb-2`,children:(0,X.jsxs)(`ul`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:[l.systems.length>0&&(0,X.jsxs)(`li`,{className:g(`rounded-base bg-surface-muted p-4`,`flex flex-col gap-1 text-body-sm`),children:[(0,X.jsxs)(`span`,{className:`font-medium text-ink`,children:[`It uses the tools of `,l.systems.map(e=>Br(d?.systems.find(t=>t.name===e)?.label||e)).join(`, `)]}),(0,X.jsx)(`span`,{className:`text-body-sm text-ink-2`,children:`Through ForgeQE, which checks every call against what this agent may do. Change them under Systems it works with.`})]}),l.notes.map(e=>(0,X.jsx)(`li`,{className:g(`rounded-base bg-surface-muted p-4`,`flex flex-col gap-1 text-body-sm`),children:(0,X.jsx)(`span`,{className:`font-medium text-ink`,children:e})},e))]})}),A===0&&n&&!t&&(0,X.jsx)(`p`,{className:`m-0 mb-2 text-body-sm`,children:(0,X.jsx)(`a`,{href:r(`agents`,`custom`,`new`),children:`Or say what it should do, and let ForgeQE build it with you`})}),v&&(0,X.jsxs)(X.Fragment,{children:[v.problems.length>0&&(0,X.jsxs)(`div`,{className:g(L.fail,`flex flex-col gap-1`),children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Its manifest needs fixing before it can be edited here:`}),(0,X.jsx)(`ul`,{className:`m-0 list-disc pl-6 [overflow-wrap:anywhere]`,children:v.problems.map((e,t)=>(0,X.jsx)(`li`,{children:e},t))})]}),(0,X.jsx)(br,{text:v.text,file:v.file})]}),!i||!d?!p&&(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Loading…`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Xn,{steps:Hr,at:A,reached:N,onGo:e=>!E&&P(e),label:`Steps of the agent`,detailed:!0}),(0,X.jsxs)(`div`,{className:g(`mt-6 grid grid-cols-[minmax(0,1fr)] items-start gap-6 @5xl:grid-cols-[minmax(0,1fr)_300px]`),children:[(0,X.jsxs)(`section`,{"aria-labelledby":`ca-step`,className:`flex min-w-0 flex-col`,children:[(0,X.jsx)(ln,{id:`ca-step`,icon:Hr[A].icon,title:Hr[A].title,description:si[A],className:`mb-4`}),A===0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(q,{label:`Name`,help:`What it does, then “agent”: Checkout guard agent.`,htmlFor:`ca-name`,children:(0,X.jsx)(a,{id:`ca-name`,value:i.name,maxLength:60,onChange:e=>F({name:e.target.value,...n&&!O?{id:Wr(e.target.value)}:{}})})}),(0,X.jsx)(q,{label:`Id`,help:n?`Its file name and address: lower-case words and hyphens. It cannot change later.`:`It cannot change. Make a new agent for another id.`,htmlFor:`ca-id`,children:(0,X.jsx)(a,{id:`ca-id`,value:i.id,maxLength:40,disabled:!n,spellCheck:!1,onChange:e=>(k(!0),F({id:e.target.value.toLowerCase()}))})}),(0,X.jsx)(q,{label:`Version`,help:`${h?`${h} is approved and runs now. `:``}Raise it for each change you approve: 1.0.0, then 1.1.0. A change saved under a version already approved is raised to the next free one, so each version names one set of settings.`,htmlFor:`ca-version`,children:(0,X.jsx)(a,{id:`ca-version`,value:i.version,maxLength:14,onChange:e=>F({version:e.target.value})})}),(0,X.jsx)(q,{label:`Description`,help:`One line: what it is for. Atlas reads it to know when to hand it work.`,htmlFor:`ca-desc`,stacked:!0,children:(0,X.jsx)(a,{id:`ca-desc`,value:i.description,maxLength:300,onChange:e=>F({description:e.target.value})})}),(0,X.jsx)(q,{label:`Icon`,help:`What it wears on the Agents page and its own page: its mascot, or one of ForgeQE's agent icons.`,htmlFor:`ca-icon`,stacked:!0,children:(0,X.jsx)(yn,{id:`ca-icon`,value:i.icon,onChange:e=>F({icon:e})})}),(0,X.jsx)(q,{label:`Voice`,help:`How it sounds when you talk with it. Default is ForgeQE's own voice; ForgeQE picks each from the speech set up on that computer.`,children:(0,X.jsx)(Ht,{label:`Voice`,value:i.voice?.sound??``,onChange:e=>B(e),options:[{id:``,label:`Default`},...Ir.map(e=>({id:e,label:e[0].toUpperCase()+e.slice(1)}))]})}),(0,X.jsx)(q,{label:`Works as`,help:`A business persona it acts as: the steps they would take, the words they would use, what would stop them. Who it acts as, never what it may do.`,htmlFor:`ca-persona`,children:(0,X.jsxs)(s,{id:`ca-persona`,value:i.persona??``,className:`w-[200px]`,onChange:e=>F({persona:e.target.value||void 0}),children:[(0,X.jsx)(`option`,{value:``,children:`No persona`}),(d.personas||[]).map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.name},e.id)),i.persona&&!(d.personas||[]).some(e=>e.id===i.persona)&&(0,X.jsxs)(`option`,{value:i.persona,children:[i.persona,` (not in this project)`]})]})}),(0,X.jsx)(q,{label:`A run may pick`,help:`Other personas a person may pick when they ask it, for that run only. Its own persona is always one of them.`,stacked:!0,children:(0,X.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 border-0 p-0`,children:[(0,X.jsx)(`legend`,{className:`sr-only`,children:`Personas a run may pick`}),ie.length===0&&(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:(d.personas||[]).length?`No other persona in this project.`:`None in this project yet.`}),ie.map(e=>(0,X.jsx)(Z,{checked:(i.personas||[]).includes(e.id),onChange:t=>F({personas:ii(i.personas||[],e.id,t)}),children:e.name},e.id))]})}),(0,X.jsx)(q,{label:`Instructions`,help:`Its focus and how to work, in plain words. Guidance for the model: the limits below are what holds it.`,htmlFor:`ca-instr`,stacked:!0,children:(0,X.jsx)(c,{id:`ca-instr`,rows:5,value:i.instructions,maxLength:8e3,onChange:e=>F({instructions:e.target.value})})}),(0,X.jsx)(Mt,{help:`One per line: what it should keep in mind. Guidance for the model, never a limit.`,icon:bt,children:`Guidance`}),(0,X.jsx)(c,{"aria-label":`Guidance, one per line`,rows:3,value:i.policies.join(`
|
|
3
|
-
`),onChange:e=>F({policies:e.target.value.split(`
|
|
4
|
-
`).map(e=>e.slice(0,300))})})]}),A===1&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Mt,{first:!0,help:`Where its runs, tests and calls may go. In an environment named like production, reads go ahead, runs are asked unless you say otherwise, and every change is approved by a person.`,icon:We,children:`Where it works`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 py-4`,children:[d.environments.length===0&&(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`No environments in env.yaml yet. Add them in Settings, Environments.`}),d.environments.map(e=>(0,X.jsx)(Z,{checked:i.scope.environments.includes(e.name),onChange:t=>R({environments:ii(i.scope.environments,e.name,t)}),help:e.production?`Production: reads go ahead; a person approves every change there.`:void 0,children:e.name},e.name))]}),(0,X.jsx)(Mt,{help:`ForgeQE's capabilities it may use: their tools, and only theirs. Each says whether it is set up here.`,icon:Ce,children:`What it can do`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-4 py-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,X.jsx)(oe,{id:`ca-cap-find`,label:`Find a capability`,value:he,onChange:U,className:`max-w-none flex-[1_1_240px]`}),(0,X.jsxs)(`span`,{className:`text-body-sm text-muted tabular-nums`,children:[i.scope.capabilities.length,` of `,d.capabilities.length,` picked`]})]}),ye.length>1&&(0,X.jsx)(`div`,{role:`group`,"aria-label":`Capabilities by area`,className:`flex flex-wrap gap-2`,children:(0,X.jsx)(ae,{items:[{id:``,label:`All`,n:d.capabilities.length},...ye.map(([e,t])=>({id:e,label:e,n:t.length}))],value:ge,onChange:ve})}),be.length===0&&(0,X.jsxs)(`p`,{className:`m-0 text-body-sm text-muted`,children:[`No capability matches “`,he.trim(),`”`,ge?` in ${ge}`:``,`.`]}),(0,X.jsx)(`ul`,{className:`m-0 grid list-none grid-cols-[minmax(0,1fr)] gap-2 p-0 @3xl:grid-cols-2`,children:be.map(e=>{let t=ei[e.state],n=i.scope.capabilities.includes(e.id),r=i.permissions.deny||[],a=(e.usable||[]).filter(e=>!r.includes(e.name)).length;return(0,X.jsxs)(`li`,{className:g(`relative flex min-w-0 cursor-pointer items-center gap-4 overflow-hidden rounded-base border-0 bg-surface-strong px-4 py-4 text-left text-ink transition-[background-color,box-shadow] duration-150 hover:bg-tint-hover aria-checked:bg-bg aria-checked:shadow-[inset_0_0_0_2px_var(--color-accent)] aria-pressed:bg-bg aria-pressed:shadow-[inset_0_0_0_2px_var(--color-accent)] disabled:cursor-default disabled:opacity-50`,`cursor-default flex-col items-stretch gap-2`,n&&`shadow-[inset_0_0_0_2px_var(--color-accent)]`),children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsx)(`label`,{htmlFor:`ca-cap-${e.id}`,className:`cursor-pointer text-body-sm font-medium text-ink`,children:e.title}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:e.area})]}),(0,X.jsx)(Pt,{id:`ca-cap-${e.id}`,label:`Use ${e.title}`,checked:n,onChange:t=>R({capabilities:ii(i.scope.capabilities,e.id,t)})})]}),e.summary&&(0,X.jsx)(`span`,{className:`text-body-sm text-ink-2`,children:e.summary}),(0,X.jsxs)(`span`,{className:`flex items-start gap-2 text-body-sm text-muted`,children:[(0,X.jsx)(z,{icon:t.icon,size:13,className:g(`mt-1 flex-none`,t.cls)}),(0,X.jsxs)(`span`,{children:[t.label,e.gaps.length?`: ${e.gaps.join(`; `)}`:``]})]}),n&&((e.usable||[]).length>1||(e.usable||[]).some(e=>r.includes(e.name)))&&(0,X.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 border-0 border-t border-line-soft p-0 pt-2`,children:[(0,X.jsxs)(`legend`,{className:`sr-only`,children:[`Tools of `,e.title,` it uses`]}),(e.usable||[]).map(e=>{let t=!r.includes(e.name)&&a===1;return(0,X.jsx)(Z,{checked:!r.includes(e.name),disabled:t,onChange:t=>V({deny:ii(r,e.name,!t)}),help:(Zr[e.action]||e.action)+(t?`. Its last tool: turn the capability off instead.`:``),children:(0,X.jsx)(`span`,{className:`font-mono text-body-sm`,children:e.name})},e.name)})]})]},e.id)})})]}),(0,X.jsx)(Mt,{help:`ForgeQE's agents it may start: a capability that needs one (a browser run needs WebPilot) is refused without it.`,icon:tt,children:`Agents it may use`}),(0,X.jsx)(`div`,{className:`flex flex-col gap-2 py-4`,children:d.agents.map(e=>(0,X.jsx)(Z,{checked:i.scope.agents.includes(e.name),onChange:t=>R({agents:ii(i.scope.agents,e.name,t)}),help:(0,X.jsx)(`span`,{className:`font-mono text-body-sm`,children:e.name}),children:e.title},e.name))}),(0,X.jsx)(Mt,{help:`Your team's other custom agents it may hand a request to. Each runs its approved version within its own limits and this one's, never more; one already working on the request is not handed it again. It needs Hands work on of 1 level or more.`,icon:st,children:`Custom agents it may hand work to`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 py-4`,children:[(d.customAgents||[]).filter(e=>e.id!==i.id).length===0&&(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`No other custom agents in this project yet.`}),(d.customAgents||[]).filter(e=>e.id!==i.id).map(e=>(0,X.jsx)(Z,{checked:(i.scope.customAgents||[]).includes(e.id),onChange:t=>R({customAgents:ii(i.scope.customAgents||[],e.id,t)}),help:(0,X.jsxs)(`span`,{className:`font-mono text-body-sm`,children:[e.id,e.approved?``:` · not approved yet: it is handed nothing until it is`]}),children:e.name},e.id))]}),(0,X.jsx)(Mt,{help:`Other systems' MCP servers this project has set up. It uses their tools through ForgeQE, which checks every call; a change in them is asked unless you lift it under What it may do.`,icon:_e,children:`Systems it works with`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 py-4`,children:[d.systems.length===0&&(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`None set up yet. Add them in Settings, MCP servers.`}),d.systems.map(e=>(0,X.jsx)(Z,{checked:(i.scope.systems||[]).includes(e.name),onChange:t=>R({systems:ii(i.scope.systems||[],e.name,t)}),help:e.about.slice(0,160),children:Br(e.label)},e.name))]}),(0,X.jsx)(Mt,{help:`Only these are loaded for it.`,icon:it,children:`Skills and knowledge`}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 py-4 sm:grid-cols-2`,children:[(0,X.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 border-0 p-0`,children:[(0,X.jsx)(`legend`,{className:`mb-1 p-0 text-body-sm font-medium text-muted`,children:`Skills`}),d.skills.length===0&&(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`None in this project yet.`}),d.skills.map(e=>(0,X.jsx)(Z,{checked:i.scope.skills.includes(e.name),onChange:t=>R({skills:ii(i.scope.skills,e.name,t)}),help:e.about,children:e.name},e.name))]}),(0,X.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 border-0 p-0`,children:[(0,X.jsx)(`legend`,{className:`mb-1 p-0 text-body-sm font-medium text-muted`,children:`Knowledge files`}),d.knowledge.length===0&&(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`None in .forgeqe/knowledge yet.`}),d.knowledge.map(e=>(0,X.jsx)(Z,{checked:i.scope.knowledge.includes(e.file),onChange:t=>R({knowledge:ii(i.scope.knowledge,e.file,t)}),help:e.title===e.file?void 0:e.title,children:e.file},e.file))]})]})]}),A===2&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`flex flex-col gap-2 py-4`,children:d.actions.map(e=>(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-6 gap-y-1`,children:[(0,X.jsx)(`div`,{className:`min-w-0 flex-[1_1_320px]`,children:(0,X.jsx)(Z,{checked:i.permissions.actions.includes(e),onChange:t=>V({actions:ii(i.permissions.actions,e,t)}),help:Gr[e]?.help,children:Gr[e]?.label||e})}),(0,X.jsx)(Z,{checked:e===`external`?!(i.permissions.trust||[]).includes(`external`):i.permissions.approve.includes(e),disabled:!i.permissions.actions.includes(e),onChange:t=>V(e===`external`?{trust:ii(i.permissions.trust||[],`external`,!t)}:{approve:ii(i.permissions.approve,e,t)}),children:`Ask first`})]},e))}),(0,X.jsx)(q,{label:`Repository`,help:`Whether it may change files in the repository (with Change files).`,children:(0,X.jsx)(Ht,{label:`Repository`,value:i.permissions.repository,onChange:e=>V({repository:e}),options:[{id:`read`,label:`Read only`},{id:`write`,label:`May change files`}]})}),i.scope.environments.some(e=>d.environments.some(t=>t.name===e&&t.production))&&i.permissions.actions.includes(`run`)&&(0,X.jsx)(q,{label:`Production`,help:`Reads there go ahead without asking; every change there is approved by a person.`,children:(0,X.jsx)(Z,{checked:!(i.permissions.production||[]).includes(`run`),onChange:e=>V({production:e?[]:[`run`]}),children:`Ask before each run`})}),i.permissions.repository===`write`&&(()=>{let e=(d.coding||[]).filter(e=>d.capabilities.some(t=>i.scope.capabilities.includes(t.id)&&t.tools.includes(e)));if(!e.length)return null;let t=e.every(e=>(i.permissions.trust||[]).includes(e));return(0,X.jsx)(q,{label:`Quill`,help:`The tests it runs can reach any address. Without asking, ForgeQE first looks in the test project's config and env files, and asks when they name an address outside its environments.`,children:(0,X.jsx)(Z,{checked:!t,onChange:t=>V({trust:t?(i.permissions.trust||[]).filter(t=>!e.includes(t)):[...new Set([...i.permissions.trust||[],...e])]}),children:`Ask first`})})})(),(0,X.jsx)(q,{label:`Shell`,help:`Commands on this computer, and fetching web pages. A person approves each one; ForgeQE's secrets stay out of reach.`,children:(0,X.jsx)(Z,{checked:i.permissions.shell===!0,onChange:e=>V({shell:e}),children:`Use the shell`})}),(0,X.jsx)(q,{label:`Hands work on`,help:`How many levels deep it may give part of a task to a helper.`,htmlFor:`ca-depth`,children:(0,X.jsxs)(s,{id:`ca-depth`,value:String(i.runtime.maxDelegationDepth),onChange:e=>F({runtime:{...i.runtime,maxDelegationDepth:Number(e.target.value)}}),className:`w-[200px]`,children:[(0,X.jsx)(`option`,{value:`0`,children:`Never`}),(0,X.jsx)(`option`,{value:`1`,children:`1 level`}),(0,X.jsx)(`option`,{value:`2`,children:`2 levels`}),(0,X.jsx)(`option`,{value:`3`,children:`3 levels`})]})}),(0,X.jsx)(q,{label:`Budget per run`,help:`The most model tokens one run may use; it stops there. Empty: no limit.`,htmlFor:`ca-budget`,children:(0,X.jsx)(a,{id:`ca-budget`,type:`number`,min:1e3,step:1e3,className:`w-[200px]`,value:i.runtime.maxTokens??``,placeholder:`No limit`,onChange:e=>{let{maxTokens:t,...n}=i.runtime;F({runtime:{...n,...e.target.value?{maxTokens:Math.max(0,Math.round(Number(e.target.value)))}:{}}})}})}),(0,X.jsx)(q,{label:`Time limit per run`,help:`In minutes (1 to 1440): the longest one run may take; it stops there. Empty: no limit when someone is watching, 120 minutes when nobody is (a schedule, a trigger, another agent).`,htmlFor:`ca-minutes`,children:(0,X.jsx)(a,{id:`ca-minutes`,type:`number`,min:1,max:1440,className:`w-[200px]`,value:i.runtime.maxMinutes??``,placeholder:`Minutes`,onChange:e=>{let{maxMinutes:t,...n}=i.runtime;F({runtime:{...n,...e.target.value?{maxMinutes:Math.max(1,Math.round(Number(e.target.value)))}:{}}})}})}),(0,X.jsx)(q,{label:`Model`,help:`The model profile of llms.json its runs use. ForgeQE's choice: the model ForgeQE's agent would use.`,htmlFor:`ca-model`,children:(0,X.jsxs)(s,{id:`ca-model`,value:i.runtime.model??``,className:`w-[200px]`,onChange:e=>{let{model:t,...n}=i.runtime;F({runtime:{...n,...e.target.value?{model:e.target.value}:{}}})},children:[(0,X.jsx)(`option`,{value:``,children:`ForgeQE's choice`}),(d.models||[]).map(e=>(0,X.jsxs)(`option`,{value:e.name,children:[e.name,` (`,e.model,`)`]},e.name)),i.runtime.model&&!(d.models||[]).some(e=>e.name===i.runtime.model)&&(0,X.jsxs)(`option`,{value:i.runtime.model,children:[i.runtime.model,` (not in llms.json)`]})]})})]}),A===3&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(q,{label:`When`,children:(0,X.jsx)(Ht,{label:`When`,value:ti(i.schedule),onChange:se,options:[{id:``,label:`Only when asked`},{id:`every`,label:`Every`},{id:`cron`,label:`On a cron schedule`}]})}),(0,X.jsx)(q,{label:`Tell the team`,help:`How a run with nobody watching (on its schedule, a trigger, or started with --unattended) ended, on the notification channels that take custom agents' runs (Settings, Notifications).`,htmlFor:`ca-notify`,children:(0,X.jsxs)(s,{id:`ca-notify`,value:i.runtime.notify??`failed`,className:`w-[200px]`,onChange:e=>{let{notify:t,...n}=i.runtime;F({runtime:{...n,...e.target.value===`failed`?{}:{notify:e.target.value}}})},children:[(0,X.jsx)(`option`,{value:`failed`,children:`When it does not finish`}),(0,X.jsx)(`option`,{value:`always`,children:`Each time it ends`}),(0,X.jsx)(`option`,{value:`never`,children:`Never`})]})}),(d.channels||[]).length>0&&(0,X.jsx)(q,{label:`Its notices go to`,help:`The notification channels its notices go to, each still only for the events it takes (Settings, Notifications). None ticked: every channel that takes them.`,children:(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:d.channels.map(e=>(0,X.jsx)(Z,{checked:(i.runtime.channels||[]).includes(e.name),onChange:t=>F({runtime:{...i.runtime,channels:ii(i.runtime.channels||[],e.name,t)}}),help:e.on.some(e=>e.startsWith(`agent_`))?void 0:`It takes no custom agent's events: tick them for it in Settings, Notifications.`,children:e.name},e.name))})}),i.schedule&&(0,X.jsxs)(X.Fragment,{children:[ti(i.schedule)===`every`?(0,X.jsx)(q,{label:`Every`,help:`15m, 1h, 1d.`,htmlFor:`ca-every`,children:(0,X.jsx)(a,{id:`ca-every`,value:i.schedule.every??``,placeholder:`30m`,spellCheck:!1,className:`max-w-[120px] font-mono`,onChange:e=>ce({every:e.target.value})})}):(0,X.jsx)(q,{label:`Cron`,help:`Five fields, this machine's time: 0 7 * * 1-5 is weekdays at 07:00.`,htmlFor:`ca-cron`,children:(0,X.jsx)(a,{id:`ca-cron`,value:i.schedule.cron??``,spellCheck:!1,className:`max-w-[180px] font-mono`,onChange:e=>ce({cron:e.target.value})})}),(0,X.jsx)(q,{label:`Request`,help:`What it is asked each time it runs by itself. {name} uses one of its inputs, filled with the value below.`,htmlFor:`ca-request`,stacked:!0,children:(0,X.jsx)(a,{id:`ca-request`,value:i.schedule.request,maxLength:500,placeholder:`Run the checkout pack on qa`,onChange:e=>ce({request:e.target.value})})}),Tr(i.schedule.request).map(e=>(i.inputs||[]).find(t=>t.name===e)).filter(e=>!!e).map(e=>(0,X.jsx)(q,{label:e.label||`{${e.name}}`,help:`The value of {${e.name}} when it runs by itself.`,htmlFor:`ca-with-${e.name}`,children:(0,X.jsx)(oi,{id:`ca-with-${e.name}`,input:e,environments:i.scope.environments,value:i.schedule?.with?.[e.name]??``,onChange:t=>ce({with:{...i.schedule?.with||{},[e.name]:t}})})},e.name))]}),(0,X.jsx)(Mt,{help:`Something that happens in ForgeQE, or a pull request or push on GitHub or Azure DevOps, can start its approved version too, with nobody watching. A schedule's name narrows it to that schedule; a custom agent's own schedules never start anything. A pull request or push needs the repository's webhook to reach ForgeQE, signed with the webhook secret (Settings, Secrets, FORGEQE_WEBHOOK_SECRET); the agent is told only the pull request's number, repository and branches, never its title or description.`,icon:je,children:`Starts when something happens`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[(i.triggers||[]).map((e,t)=>{let n=e=>F({triggers:(i.triggers||[]).map((n,r)=>r===t?{...n,...e}:n)});return(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(s,{"aria-label":`Trigger ${t+1} event`,className:`w-[200px]`,value:e.on,onChange:t=>{let r=t.target.value,i=Jr.includes(r);n({on:r,...r.startsWith(`job_`)?{}:{job:void 0},...i?{source:e.source||`github`}:{source:void 0,repo:void 0,branch:void 0}})},children:Lr.map(e=>(0,X.jsx)(`option`,{value:e,children:Yr[e]},e))}),Jr.includes(e.on)&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(s,{"aria-label":`Trigger ${t+1} host`,className:`w-[200px]`,value:e.source||`github`,onChange:e=>n({source:e.target.value}),children:[(0,X.jsx)(`option`,{value:`github`,children:`GitHub`}),(0,X.jsx)(`option`,{value:`azure_devops`,children:`Azure DevOps`})]}),(0,X.jsx)(a,{"aria-label":`Trigger ${t+1} repository`,className:`w-[200px] font-mono`,maxLength:201,spellCheck:!1,value:e.repo??``,placeholder:e.source===`azure_devops`?`project/repository`:`owner/name`,onChange:e=>n({repo:e.target.value||void 0})}),(0,X.jsx)(a,{"aria-label":`Trigger ${t+1}: which branch, empty for any`,className:`w-[140px] font-mono`,maxLength:200,spellCheck:!1,value:e.branch??``,placeholder:e.on===`push`?`any branch`:`any target`,onChange:e=>n({branch:e.target.value||void 0})})]}),e.on.startsWith(`job_`)&&(0,X.jsx)(a,{"aria-label":`Trigger ${t+1}: which schedule, empty for any`,className:`w-[140px] font-mono`,maxLength:40,spellCheck:!1,value:e.job??``,placeholder:`any schedule`,onChange:e=>n({job:e.target.value||void 0})}),(0,X.jsx)(a,{"aria-label":`Trigger ${t+1} request`,className:`min-w-0 flex-[1_1_280px]`,maxLength:500,value:e.request,placeholder:`What it is asked then (no {name}: nobody gives a value)`,onChange:e=>n({request:e.target.value})}),(0,X.jsx)(H,{variant:`icon`,size:`icon`,"aria-label":`Remove trigger ${t+1}`,"data-tip":`Remove trigger ${t+1}`,onClick:()=>{let e=(i.triggers||[]).filter((e,n)=>n!==t);F({triggers:e,...!e.length&&!i.schedule?{permissions:{...i.permissions,unattended:[]}}:{}})},children:(0,X.jsx)(K,{"aria-hidden":`true`})})]},t)}),(i.triggers||[]).length<4&&(0,X.jsxs)(H,{size:`sm`,className:`self-start`,onClick:()=>F({triggers:[...i.triggers||[],{on:`suite_failed`,request:``}]}),"data-tip":`Add a trigger`,children:[(0,X.jsx)(W,{"aria-hidden":`true`}),`Add`]})]}),(i.schedule||(i.triggers||[]).length>0)&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Mt,{help:`With nobody watching, it does only these without asking. Anything else waits for a person: the team is told, and no answer in time is a no.`,icon:Ze,children:`What it may do alone`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 py-4`,children:[ni(i,d.systems,ne(i)).length===0&&(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`Only reading: allow more under What it may do, or pick Systems it works with, first.`}),ni(i,d.systems,ne(i)).map(e=>(0,X.jsx)(Z,{checked:e.ids.every(e=>(i.permissions.unattended||[]).includes(e)),onChange:t=>V({unattended:t?[...new Set([...i.permissions.unattended||[],...e.ids])]:(i.permissions.unattended||[]).filter(t=>!e.ids.includes(t))}),children:e.label},e.key))]})]})]}),A===4&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Mt,{first:!0,help:`What its starters and its schedule leave open, at most 6. Write {name} in a starter or the schedule's request (not a trigger's: nobody is there to give the value); its page asks for the value (one line of text, or a pick from its list) before the starter fills the message.`,icon:Oe,children:`Inputs`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[(i.inputs||[]).map((e,t)=>{let n=e=>F({inputs:(i.inputs||[]).map((n,r)=>r===t?{...n,...e}:n)});return(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(a,{"aria-label":`Input ${t+1} name`,className:`w-[140px] font-mono`,maxLength:32,spellCheck:!1,value:e.name,placeholder:`name`,onChange:e=>n({name:e.target.value.toLowerCase()})}),(0,X.jsx)(a,{"aria-label":`Input ${t+1} label`,className:`w-[200px]`,maxLength:40,value:e.label,placeholder:`Label`,onChange:e=>n({label:e.target.value})}),(0,X.jsx)(s,{"aria-label":`Input ${t+1} kind`,className:`w-[200px]`,value:e.kind,onChange:t=>{let r=t.target.value;n(r===`choice`?{kind:r,options:e.options||[]}:{kind:r,options:void 0})},children:Sr.map(e=>(0,X.jsx)(`option`,{value:e,children:Xr[e]},e))}),e.kind===`choice`&&(0,X.jsx)(ai,{label:`Input ${t+1} options, separated by commas`,options:e.options||[],onChange:e=>n({options:e})}),(0,X.jsx)(H,{variant:`icon`,size:`icon`,"aria-label":`Remove input ${t+1}`,"data-tip":`Remove input ${t+1}`,onClick:()=>F({inputs:(i.inputs||[]).filter((e,n)=>n!==t)}),children:(0,X.jsx)(K,{"aria-hidden":`true`})})]},t)}),(i.inputs||[]).length<6&&(0,X.jsxs)(H,{size:`sm`,className:`self-start`,onClick:()=>F({inputs:[...i.inputs||[],{name:``,label:``,kind:`text`}]}),"data-tip":`Add an input`,children:[(0,X.jsx)(W,{"aria-hidden":`true`}),`Add`]})]}),(0,X.jsx)(Mt,{help:`Requests its page offers to start from (at most ${Kr}). {name} uses one of its inputs.`,icon:nt,children:`Starters`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[i.starters.map((e,t)=>(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(a,{"aria-label":`Starter ${t+1} label`,className:`w-[200px]`,maxLength:40,value:e.label,placeholder:`Label`,onChange:e=>F({starters:i.starters.map((n,r)=>r===t?{...n,label:e.target.value}:n)})}),(0,X.jsx)(a,{"aria-label":`Starter ${t+1} request`,className:`min-w-0 flex-[1_1_280px]`,maxLength:500,value:e.text,placeholder:`The request`,onChange:e=>F({starters:i.starters.map((n,r)=>r===t?{...n,text:e.target.value}:n)})}),(0,X.jsx)(H,{variant:`icon`,size:`icon`,"aria-label":`Remove starter ${t+1}`,"data-tip":`Remove starter ${t+1}`,onClick:()=>F({starters:i.starters.filter((e,n)=>n!==t)}),children:(0,X.jsx)(K,{"aria-hidden":`true`})})]},t)),i.starters.length<Kr&&(0,X.jsxs)(H,{size:`sm`,className:`self-start`,onClick:()=>F({starters:[...i.starters,{label:``,text:``}]}),"data-tip":`Add a starter`,children:[(0,X.jsx)(W,{"aria-hidden":`true`}),`Add`]})]}),(0,X.jsx)(Mt,{help:`Short facts it keeps between runs with its remember tool and reads back with recall: what it found, never instructions. You can read and forget them on its page, under Details, Memory.`,icon:St,children:`Memory`}),(0,X.jsx)(q,{label:`Notes it keeps`,htmlFor:`ca-notes`,help:`At most 200; past that the oldest go. None: it starts every run knowing only its manifest.`,children:(0,X.jsxs)(s,{id:`ca-notes`,className:`w-[200px]`,value:String(i.memory?.notes||0),onChange:e=>F({memory:Number(e.target.value)?{notes:Number(e.target.value)}:void 0}),children:[(0,X.jsx)(`option`,{value:`0`,children:`No memory`}),[20,50,100,200].map(e=>(0,X.jsxs)(`option`,{value:e,children:[`Up to `,e,` notes`]},e)),i.memory&&![20,50,100,200].includes(i.memory.notes)&&(0,X.jsxs)(`option`,{value:i.memory.notes,children:[`Up to `,i.memory.notes,` notes`]})]})}),(0,X.jsx)(Mt,{help:`What its reply ends with, read by ForgeQE, not by a model: a verdict of your words (at most 8) and named values (at most 12). Each run keeps them, checks can expect a verdict, a verdict you count as a failure tells the team as a failure, and forgeqe agent run exits 1 on it.`,icon:xt,children:`Output`}),(0,X.jsx)(q,{label:`Verdicts`,htmlFor:`ca-verdicts`,help:`Words for how a run came out, such as passed, failed, blocked. Lower-case letters, digits and underscores.`,children:(0,X.jsx)(ai,{id:`ca-verdicts`,label:`Verdicts, separated by commas`,placeholder:`passed, failed, blocked`,max:8,mono:!0,options:i.output?.verdicts||[],onChange:e=>F({output:{verdicts:e,failOn:(i.output?.failOn||[]).filter(t=>e.includes(t)),fields:i.output?.fields||[]}})})}),(i.output?.verdicts.length||0)>0&&(0,X.jsx)(q,{label:`Counts as a failure`,help:`A run with one of these verdicts, or with none, tells the team as a failure. Its checks still grade what they expect.`,children:(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:i.output.verdicts.map(e=>(0,X.jsx)(Z,{checked:i.output.failOn.includes(e),onChange:t=>F({output:{...i.output,failOn:ii(i.output.failOn,e,t)}}),children:e},e))})}),(0,X.jsx)(q,{label:`Fields`,stacked:!0,help:`Named values its reply reports, each of a kind. Leave a field out of the reply when it could not be found out.`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(i.output?.fields||[]).map((e,t)=>{let n=i.output||{verdicts:[],failOn:[],fields:[]},r=e=>F({output:{...n,fields:n.fields.map((n,r)=>r===t?{...n,...e}:n)}});return(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(a,{"aria-label":`Field ${t+1} name`,className:`w-[200px] font-mono`,maxLength:40,spellCheck:!1,value:e.name,placeholder:`defects_found`,onChange:e=>r({name:e.target.value.toLowerCase()})}),(0,X.jsx)(s,{"aria-label":`Field ${t+1} kind`,className:`w-[200px]`,value:e.kind,onChange:e=>r({kind:e.target.value}),children:zr.map(e=>(0,X.jsx)(`option`,{value:e,children:qr[e]},e))}),(0,X.jsx)(H,{variant:`icon`,size:`icon`,"aria-label":`Remove field ${t+1}`,"data-tip":`Remove field ${t+1}`,onClick:()=>F({output:{...n,fields:n.fields.filter((e,n)=>n!==t)}}),children:(0,X.jsx)(K,{"aria-hidden":`true`})})]},t)}),(i.output?.fields.length||0)<12&&(0,X.jsxs)(H,{size:`sm`,className:`self-start`,onClick:()=>F({output:{verdicts:i.output?.verdicts||[],failOn:i.output?.failOn||[],fields:[...i.output?.fields||[],{name:``,kind:`text`}]}}),"data-tip":`Add a field`,children:[(0,X.jsx)(W,{"aria-hidden":`true`}),`Add`]})]})})]}),A===Ur&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(fi,{items:di(i,de,b,w),onGo:P}),(0,X.jsx)(Mt,{help:`Requests to try it on before it is approved, at most 8: forgeqe agent test runs them on the manifest as it is and grades each by code from the run (how it ended, words its reply holds or not, tools it used or never called). A version whose checks have not all passed is approved only when a person says so.`,icon:rt,children:`Checks`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-4 py-2`,children:[(i.checks||[]).map((e,t)=>{let n=e=>F({checks:(i.checks||[]).map((n,r)=>r===t?{...n,...e}:n)}),r=t=>n({expect:{...e.expect,...t}});return(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(a,{"aria-label":`Check ${t+1} name`,className:`w-[200px] font-mono`,maxLength:40,spellCheck:!1,value:e.name,placeholder:`basket-total`,onChange:e=>n({name:e.target.value.toLowerCase()})}),(0,X.jsx)(a,{"aria-label":`Check ${t+1} request`,className:`min-w-0 flex-[1_1_280px]`,maxLength:500,value:e.request,placeholder:`The request it is tried on`,onChange:e=>n({request:e.target.value})}),(0,X.jsx)(H,{variant:`icon`,size:`icon`,"aria-label":`Remove check ${t+1}`,"data-tip":`Remove check ${t+1}`,onClick:()=>F({checks:(i.checks||[]).filter((e,n)=>n!==t)}),children:(0,X.jsx)(K,{"aria-hidden":`true`})})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pl-6`,children:[(0,X.jsxs)(s,{"aria-label":`Check ${t+1} ends`,className:`w-[200px]`,value:e.expect.outcome,onChange:e=>r({outcome:e.target.value}),children:[(0,X.jsx)(`option`,{value:`done`,children:`Ends done`}),(0,X.jsx)(`option`,{value:`needs_input`,children:`Ends needing a person`}),(0,X.jsx)(`option`,{value:`failed`,children:`Ends failed`})]}),(0,X.jsx)(ai,{label:`Check ${t+1}: words its reply says, separated by commas`,placeholder:`Its reply says…`,max:16,options:e.expect.says,onChange:e=>r({says:e})}),(0,X.jsx)(ai,{label:`Check ${t+1}: words its reply never says, separated by commas`,placeholder:`…and never says`,max:16,options:e.expect.neverSays,onChange:e=>r({neverSays:e})}),(0,X.jsx)(ai,{label:`Check ${t+1}: tools it uses, separated by commas`,placeholder:`Tools it uses`,max:16,mono:!0,options:e.expect.uses,onChange:e=>r({uses:e})}),(0,X.jsx)(ai,{label:`Check ${t+1}: tools it never calls, separated by commas`,placeholder:`Tools it never calls`,max:16,mono:!0,options:e.expect.neverUses,onChange:e=>r({neverUses:e})}),(i.output?.verdicts.length||0)>0&&(0,X.jsxs)(s,{"aria-label":`Check ${t+1} verdict`,className:`w-[200px]`,value:e.expect.verdict||``,onChange:e=>r({verdict:e.target.value||void 0}),children:[(0,X.jsx)(`option`,{value:``,children:`Any verdict`}),i.output.verdicts.map(e=>(0,X.jsxs)(`option`,{value:e,children:[`Verdict `,e]},e))]})]})]},t)}),(i.checks||[]).length<8&&(0,X.jsxs)(H,{size:`sm`,className:`self-start`,onClick:()=>F({checks:[...i.checks||[],{name:``,request:``,expect:{outcome:`done`,says:[],neverSays:[],uses:[],neverUses:[]}}]}),"data-tip":`Add a check`,children:[(0,X.jsx)(W,{"aria-hidden":`true`}),`Add`]})]}),(0,X.jsx)(Mt,{help:`Who approves a version before it runs. ForgeQE knows a person by git's user name on their computer, so this is an agreement the history keeps, not a sign-in. A change is approved under the stricter of this and the version that runs.`,icon:G,children:`Approval`}),(0,X.jsx)(q,{label:`People who approve`,htmlFor:`ca-people`,help:`How many different people approve a version. Each but the last signs it; it runs once the last approves.`,children:(0,X.jsx)(s,{id:`ca-people`,className:`w-[200px]`,value:String(i.approval?.people||1),onChange:e=>F({approval:{people:Number(e.target.value),owners:i.approval?.owners||[]}}),children:[1,2,3].map(e=>(0,X.jsx)(`option`,{value:e,children:e===1?`One person`:`${e} different people`},e))})}),(0,X.jsx)(q,{label:`Who may approve`,htmlFor:`ca-owners`,help:`People's names as git knows them (user.name, or user.email). None: anyone who can approve agents in this project.`,children:(0,X.jsx)(ai,{id:`ca-owners`,label:`Who may approve, separated by commas`,placeholder:`Ann Lee, Bo Chen`,max:20,options:i.approval?.owners||[],onChange:e=>F({approval:{people:i.approval?.people||1,owners:e}})})}),(0,X.jsx)(pi,{facts:li(i,d),onGo:P}),fe.length>0&&!w&&(0,X.jsxs)(`div`,{className:g(L.fail,`mt-6 flex flex-col gap-1`),children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`To fix before it can be saved:`}),(0,X.jsx)(`ul`,{className:`m-0 list-disc pl-6 [overflow-wrap:anywhere]`,children:fe.map((e,t)=>(0,X.jsx)(`li`,{children:e},t))})]}),S.length>0&&(0,X.jsx)(J,{id:`ca-advice`,icon:Ie,title:`What it still needs`,level:3,className:`mt-6`,children:(0,X.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:S.map((e,t)=>(0,X.jsxs)(`li`,{className:g(`flex flex-col gap-1 rounded-base px-4 py-4 text-body-sm`,e.blocking?`bg-warn-soft`:`bg-surface-muted`),children:[(0,X.jsx)(`span`,{className:g(`font-medium`,e.blocking?`text-warn`:`text-ink`),children:e.about}),(0,X.jsx)(`span`,{className:`text-body-sm text-ink-2`,children:e.why}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:e.fix})]},t))})})]}),(0,X.jsx)(Zn,{busy:E,onBack:A>0?()=>P(A-1):void 0,next:A<Ur?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(dt,{"aria-hidden":`true`}),`Next: `,Hr[A+1].name]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Tt,{"aria-hidden":`true`}),E?`Saving…`:`Save`]}),onNext:()=>A<Ur?P(A+1):void xe(),disabled:A<Ur?!me(A):!pe,aside:(0,X.jsxs)(`span`,{role:`status`,className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[w?(0,X.jsx)(`span`,{className:`text-muted`,children:`Checking…`}):fe.length?(0,X.jsx)(`span`,{className:`text-fail [overflow-wrap:anywhere]`,children:A===Ur?`${fe.length} to fix, listed above.`:`${fe[0]}${fe.length>1?` (and ${fe.length-1} more, listed under Review)`:``}`}):(0,X.jsx)(`span`,{className:`text-pass`,children:A===Ur?`Ready to save. It can be tried once saved.`:`Nothing to fix so far.`}),A<Ur&&N===Ur&&(0,X.jsx)(H,{variant:`link`,size:`inline`,disabled:E||!pe,onClick:()=>void xe(),"data-tip":n?`Save it as a draft now: nothing runs until it is approved`:`Save changes`,children:n?`Save draft`:`Save`})]})})]}),(0,X.jsx)(ui,{fields:i,choices:d})]})]})]})]})}function hi({id:e}){let[t,n]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(``),[o,s]=(0,Y.useState)(!1),c=(0,Y.useCallback)(()=>{M.view(e).then(e=>{w([{id:e.id,icon:e.icon}]),n(e),a(``)},e=>a(e.message))},[e]);(0,Y.useEffect)(()=>c(),[c]);let[l,u]=(0,Y.useState)(null);return T.test(e)?(0,X.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[t?(0,X.jsx)(vi,{view:t,detailsOpen:o,onDetails:s}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`header`,{className:`flex items-center gap-1 px-6 py-4 short:py-2`,children:[(0,X.jsx)(Wt,{}),(0,X.jsx)(se,{to:{href:r(`agents`,`category`,`custom`),label:`Custom agents`},className:`self-center`})]}),(0,X.jsx)(`main`,{className:`flex flex-auto flex-col items-center justify-center px-6 py-10`,children:i?(0,X.jsx)(`p`,{role:`alert`,className:g(L.fail,`m-0`),children:i}):(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Loading…`})})]}),t&&l&&(0,X.jsx)(Bi,{view:t,action:l.action,to:l.to,onClose:()=>u(null),onDone:e=>{`deleted`in e?(u(null),location.hash=r(`agents`,`category`,`custom`)):(n(e),u(null))}}),t&&(0,X.jsx)(Ei,{view:t,open:o,onClose:()=>s(!1),onAct:u,onReload:c})]}):(0,X.jsx)(gi,{})}function gi(){return(0,X.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,X.jsx)(`header`,{className:`flex items-center gap-1 px-6 py-4`,children:(0,X.jsx)(Wt,{})}),(0,X.jsxs)(`p`,{className:`m-0 px-6 py-10 text-body-sm text-muted`,children:[`There is no such agent. `,(0,X.jsx)(`a`,{href:r(`agents`),children:`See every agent`}),`.`]})]})}var _i=e=>e.length?e.join(`, `):`none`;function vi({view:e,detailsOpen:t,onDetails:n}){let i=Nn(),a=[...e.problems.working,...e.problems.active,...e.problems.other],o=e.state===`active`||e.state===`changed`,s=!!e.working,c=hn[e.state],[l,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(e.starters[0]&&!Tr(e.starters[0].text).length?e.starters[0].text:``),[p,m]=(0,Y.useState)(null),[h,_]=(0,Y.useState)({}),v=(e.active||e.working)?.environments||[];(0,Y.useEffect)(()=>m(null),[e.active?.digest,e.working?.digest]);let[y,x]=(0,Y.useState)(``),[S,C]=(0,Y.useState)(``),[w,T]=(0,Y.useState)(!0),[E,D]=(0,Y.useState)(!1),[O,k]=(0,Y.useState)(!1),j=bn(),{setup:N}=j,ee=`custom-agent-${e.id}`,P=vn(d,e=>{f(e),x(``)},ee,{code:j.tools.code}),te=Dn(`custom-${e.id}`,e=>{f(e),gn(ee)}),F=async()=>{C(``);try{let t=await M.pack(e.id),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${e.id}.forgeqe-agent.zip`,r.click(),setTimeout(()=>URL.revokeObjectURL(n),1e3),T(!0),C(`Zip downloaded. A teammate imports it as a draft, then edits and approves it.`)}catch(e){T(!1),C(e.message)}},I=async()=>{if(!E){D(!0),C(``);try{let t=await M.duplicate(e.id);location.hash=r(`agents`,`custom`,t.id,`edit`)}catch(e){T(!1),C(e.message),D(!1)}}},ne=async(t,n=d)=>{if(!(O||!n.trim()&&!P.hasFiles)&&(t||o)&&(!t||s)){k(!0),x(``);try{let i=await P.wrap(n.trim());if(!i.trim()){k(!1);return}let{id:a}=await re.start(i,{...j.choice,agent:e.id,...t||!o?{try:!0}:{},...ae?{persona:ae}:{}});P.reset({keep:!0}),location.hash=r(`chats`,a)}catch(e){x(e.message),k(!1)}}},ie=!o&&!s,z=o?e.active:e.working,ae=l&&z?.personas?.some(e=>e.id===l)?l:``,oe=(z?.personas||[]).filter(e=>e.id!==z?.persona?.id),V=z?.model;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`header`,{className:`flex items-center gap-1 px-6 py-4 short:py-2`,children:[(0,X.jsx)(Wt,{}),(0,X.jsx)(se,{to:{href:r(`agents`,`category`,`custom`),label:`Custom agents`},className:`self-center`}),(0,X.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,children:[(0,X.jsx)(B,{tone:c.tone,children:c.label}),(0,X.jsx)(H,{variant:`icon`,size:`icon`,onClick:()=>void I(),disabled:E||e.state===`invalid`,"aria-label":e.state===`invalid`?`Duplicate (fix its manifest first)`:`Duplicate`,"data-tip":e.state===`invalid`?`Duplicate (fix its manifest first)`:`Duplicate`,children:(0,X.jsx)(Ve,{size:18,"aria-hidden":`true`})}),(0,X.jsx)(H,{variant:`icon`,size:`icon`,onClick:()=>void F(),"aria-label":`Export to share`,"data-tip":`Export to share`,children:(0,X.jsx)(vt,{size:18,"aria-hidden":`true`})}),(0,X.jsx)(H,{variant:`icon`,size:`icon`,onClick:()=>n(!t),"aria-label":`Details`,"aria-pressed":t,"data-tip":`Details`,children:(0,X.jsx)(ot,{size:18,"aria-hidden":`true`})}),(0,X.jsx)(`a`,{href:r(`agents`,`custom`,e.id,`edit`),className:g(R({variant:`icon`,size:`icon`}),`no-underline`),"aria-label":`Edit`,"data-tip":`Edit`,children:(0,X.jsx)(Ee,{size:18,"aria-hidden":`true`})})]})]}),(0,X.jsx)(`main`,{className:`flex flex-auto flex-col items-center justify-center px-6 pt-6 pb-30 short:pt-0 short:pb-8`,children:(0,X.jsxs)(`div`,{className:`flex w-full max-w-[780px] flex-col items-center gap-10 short:gap-6`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col items-center gap-4 text-center short:gap-2`,children:[(0,X.jsx)(b,{agent:e.id,icon:e.icon,px:i?64:96,decorative:!0,working:O,className:`mb-1`}),(0,X.jsx)(`h1`,{className:`m-0 text-headline-lg text-ink [overflow-wrap:anywhere]`,children:e.name}),(0,X.jsx)(`p`,{className:`m-0 text-body-lg leading-relaxed text-ink-2`,children:e.description||(o?`Ask ${A(e.name)}. It runs version ${e.approvedVersion}, within its limits.`:e.state===`drifted`?`${e.name} ${e.approvedVersion} does not run until a person approves it again: what it knows changed. A try runs its manifest as it is.`:s?`Try ${A(e.name)}. It has no approved version yet: a try runs its manifest as it is.`:`Fix ${A(e.name)}'s manifest before it can be tried or approved.`)})]}),S&&(0,X.jsx)(`p`,{role:`status`,className:g(`m-0 -mt-4 text-center text-body-sm`,w?`text-muted`:`text-fail`),children:S}),a.length>0&&(0,X.jsxs)(`div`,{role:`alert`,className:g(L.fail,`flex w-full flex-col gap-1 text-left`),children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.state===`invalid`?`Its manifest needs fixing before it can be tried or approved:`:`It cannot run as it is:`}),(0,X.jsx)(`ul`,{className:`m-0 list-disc pl-6 [overflow-wrap:anywhere]`,children:a.map((e,t)=>(0,X.jsx)(`li`,{children:e},t))})]}),e.manifestText!==void 0&&(0,X.jsx)(br,{text:e.manifestText,file:e.manifestFile||``}),e.state===`drifted`&&e.drift&&(0,X.jsxs)(`section`,{"aria-labelledby":`ca-drift`,role:`alert`,className:g(L.warn,`flex w-full flex-col gap-2 text-left`),children:[(0,X.jsx)(ln,{id:`ca-drift`,icon:Ie,title:(0,X.jsxs)(X.Fragment,{children:[`What `,e.approvedVersion,` knows changed since it was approved`]}),level:3}),(0,X.jsx)(`ul`,{className:`m-0 list-disc pl-6 text-ink-2`,children:e.drift.map(e=>(0,X.jsx)(`li`,{children:e},e))}),(0,X.jsxs)(`p`,{className:`m-0 text-body-sm text-ink-2`,children:[`It does not run (for you, your team, Atlas, its schedule or another agent) until a person reads the change and approves it again`,e.working?` under Details, Versions`:`: its manifest was removed, so put it back first`,`.`,e.changes.length>0?` Its manifest was also changed since: that change is below, and approving takes it too.`:``]})]}),e.changes.length>0&&(0,X.jsx)(J,{id:`ca-changes`,icon:ut,title:(0,X.jsxs)(X.Fragment,{children:[`Changed since `,e.approvedVersion,` was approved`]}),description:(0,X.jsxs)(X.Fragment,{children:[e.state===`changed`?`The approved version keeps running until this change is approved.`:`Approving takes this change too.`,` Approve or discard it under Details, Versions.`]}),className:`w-full text-left`,children:(0,X.jsx)(en,{diff:e.changes})}),ie?(0,X.jsx)(`p`,{className:`m-0 text-center text-body-sm text-muted`,children:e.manifestText===void 0?`See what is wrong above, or Edit the agent.`:`Fix what is listed above in its file, then come back.`}):(0,X.jsxs)(X.Fragment,{children:[N&&!N.ready&&(0,X.jsx)(kn,{project:N.project}),N?.ready&&(0,X.jsx)(Tn,{c:j}),(0,X.jsx)(Cn,{id:ee,label:`Message ${A(e.name)}`,value:d,onChange:e=>{f(e),x(``)},onSend:()=>void ne(!o),disabled:O||!!N&&!N.ready||te.running,canSend:!!d.trim()||P.hasFiles,onEdit:P.onEdit,onKey:P.onKeyDown,onFiles:P.onFiles,dropping:P.dropping,drop:P.drop,mentions:P.mentions,combo:P.combo,placeholder:`Ask ${A(e.name)} to…`,top:(0,X.jsxs)(X.Fragment,{children:[P.chips,te.state&&(0,X.jsx)(pn,{state:te.state,onStop:()=>void te.stop(),onUndo:te.undo,onClose:te.close})]}),left:(0,X.jsxs)(X.Fragment,{children:[P.fileInput,(0,X.jsx)(tn,{attach:{pick:P.pick},choice:j}),oe.length?(0,X.jsx)(yi,{own:z?.persona,personas:oe,value:ae,onPick:u}):null,(0,X.jsx)(Mn,{running:te.running,disabled:!d.trim()||O||!!N&&!N.ready,onClick:()=>void te.start(d)})]}),right:V?(0,X.jsxs)(H,{variant:`ghost`,className:`max-w-[46vw] min-w-0 px-2 text-body-lg sm:px-2`,disabled:!0,"aria-label":`Model: ${V}, as its manifest says`,"data-tip":`It runs on ${V}, as its manifest says${o&&s&&e.working?.model!==V?`; a try runs on ${e.working?.model||`ForgeQE's choice`}`:``}`,children:[(0,X.jsx)(_t,{"aria-hidden":`true`,className:`size-4`}),(0,X.jsx)(`span`,{className:`hidden truncate sm:inline`,children:V})]}):(0,X.jsx)(mn,{c:j})}),(0,X.jsx)(`p`,{role:`status`,"aria-live":`polite`,className:g(`-mt-6 m-0 text-center text-body-sm text-ink-2 short:-mt-4`,!(y||P.error)&&`sr-only`),children:(0,X.jsx)(`span`,{className:P.error&&!y?`text-fail`:``,children:y||P.error||``})}),p&&(0,X.jsx)(bi,{starter:p,inputs:e.inputs||[],environments:v,values:h,onChange:_,onUse:e=>{f(e),m(null),document.getElementById(ee)?.focus()},onCancel:()=>{let t=e.starters.findIndex(e=>e.label===p.label);m(null),t>=0&&requestAnimationFrame(()=>document.getElementById(`${ee}-starter-${t}`)?.focus())}},p.label),(0,X.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-4`,children:[e.starters.map((e,t)=>(0,X.jsx)(H,{id:`${ee}-starter-${t}`,"aria-expanded":Tr(e.text).length?p?.label===e.label:void 0,onClick:()=>{x(``),Tr(e.text).length?(m(p?.label===e.label?null:e),_({})):(m(null),f(e.text),document.getElementById(ee)?.focus())},children:e.label},e.label)),o&&s&&(0,X.jsxs)(H,{disabled:O||!d.trim(),onClick:()=>void ne(!0),"data-tip":`Try the manifest`,children:[(0,X.jsx)(Ae,{"aria-hidden":`true`}),`Try`]})]})]}),(0,X.jsx)(Si,{view:e})]})})]})}function yi({own:e,personas:t,value:n,onPick:r}){let[i,a]=(0,Y.useState)(!1),s=t.find(e=>e.id===n)?.name||e?.name||`No persona`,c=[{id:``,name:e?`${e.name} (its own)`:`No persona`},...t];return(0,X.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,X.jsxs)(H,{variant:`ghost`,className:`max-w-[46vw] min-w-0 px-2 text-body-lg sm:px-2`,"aria-expanded":i,"aria-haspopup":`menu`,"aria-label":`Works as: ${s}`,onClick:()=>a(!i),children:[(0,X.jsx)(Le,{"aria-hidden":`true`,className:`size-4`}),(0,X.jsx)(`span`,{className:`hidden truncate sm:inline`,children:s}),(0,X.jsx)(ge,{size:16,"aria-hidden":`true`,className:`hidden sm:block`})]}),(0,X.jsx)(y,{open:i,onClose:()=>a(!1),label:`Works as`,className:`w-[min(320px,calc(100vw-48px))]`,children:(0,X.jsxs)(`div`,{className:`flex flex-col`,children:[(0,X.jsx)(un,{children:`Works as, in this chat`}),c.map(e=>{let t=e.id===n;return(0,X.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":t,onClick:()=>{r(e.id),a(!1)},className:o,children:[(0,X.jsx)(Xt,{icon:Le}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-body-sm font-medium text-ink`,children:e.name}),(0,X.jsx)(Tt,{size:16,"aria-hidden":`true`,className:g(`flex-none text-accent-fg`,!t&&`invisible`)})]},e.id||`own`)})]})})]})}function bi({starter:e,inputs:t,environments:n,values:r,onChange:i,onUse:a,onCancel:o}){let s=Tr(e.text),c=s.map(e=>t.find(t=>t.name===e)).filter(e=>!!e),l=s.filter(e=>!t.some(t=>t.name===e)),[u,f]=(0,Y.useState)(``),p=(0,Y.useId)();(0,Y.useEffect)(()=>{c[0]?document.getElementById(`starter-${c[0].name}`)?.focus():document.getElementById(p)?.focus()},[e.label]);let m=()=>{try{a(Dr(e.text,t,r,n))}catch(e){f(e.message)}};return(0,X.jsxs)(`form`,{"aria-label":`Values for ${e.label}`,className:g(d,`flex w-full flex-col gap-4 text-left`),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),o())},onSubmit:e=>{e.preventDefault(),m()},children:[(0,X.jsx)(`span`,{className:`text-body-sm font-medium`,children:e.label}),c.map(e=>(0,X.jsxs)(`label`,{htmlFor:`starter-${e.name}`,className:`flex flex-wrap items-center gap-x-4 gap-y-1 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`min-w-[140px] text-ink-2`,children:e.label}),(0,X.jsx)(oi,{id:`starter-${e.name}`,input:e,environments:n,value:r[e.name]??``,onChange:t=>(i({...r,[e.name]:t}),f(``))})]},e.name)),l.length>0&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 text-body-sm text-fail [overflow-wrap:anywhere]`,children:l.map(e=>`{${e}} is not one of its inputs, so this starter cannot be filled. Edit the agent.`).join(` `)}),u&&!l.length&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 text-body-sm text-fail [overflow-wrap:anywhere]`,children:u}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,X.jsx)(H,{type:`submit`,variant:`primary`,size:`sm`,children:`Use`}),(0,X.jsx)(H,{id:p,type:`button`,variant:`ghost`,size:`sm`,onClick:o,children:`Cancel`})]})]})}function xi({view:e,onDone:t}){let n=e.memory?.kept||[],[r,i]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(!1),[u,f]=(0,Y.useState)(``),p=(0,Y.useId)(),m=()=>{i(!1),s(``),setTimeout(()=>document.getElementById(p)?.focus(),0)},h=async n=>{l(!0),f(``);try{await M.forget(e.id,n),i(!1),s(``),t()}catch(e){f(e.message)}finally{l(!1)}};return(0,X.jsxs)(Di,{id:`ca-memory`,icon:St,title:`Memory · ${n.length} of ${e.memory?.notes||n.length} notes`,aside:n.length>0&&!r?(0,X.jsxs)(H,{id:p,size:`sm`,variant:`danger`,onClick:()=>i(!0),children:[(0,X.jsx)(K,{"aria-hidden":`true`}),`Forget all`]}):void 0,children:[r&&(0,X.jsxs)(`div`,{className:g(L.warn,`flex flex-wrap items-end gap-2`),children:[(0,X.jsxs)(`label`,{className:`flex min-w-0 flex-[1_1_240px] flex-col gap-2`,children:[(0,X.jsxs)(`span`,{children:[`Type `,(0,X.jsx)(`span`,{className:`font-mono`,children:e.id}),` to forget all `,n.length,` notes`]}),(0,X.jsx)(a,{autoFocus:!0,value:o,onChange:e=>s(e.target.value),autoComplete:`off`,spellCheck:!1})]}),(0,X.jsx)(H,{variant:`ghost`,onClick:m,children:`Cancel`}),(0,X.jsx)(H,{variant:`destructive`,disabled:c||o!==e.id,onClick:()=>void h({all:!0,confirm:o}),children:`Forget all`})]}),u&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 text-body-sm text-fail [overflow-wrap:anywhere]`,children:u}),n.length===0?(0,X.jsxs)(ie,{className:`py-4`,children:[A(e.name,!0),` has noted nothing yet. It keeps short facts it finds, to recall in later runs.`]}):(0,X.jsx)(`ul`,{className:g(d,`m-0 flex list-none flex-col p-0`),children:n.map((e,t)=>(0,X.jsxs)(`li`,{className:g(`flex items-start gap-2 px-4 py-2 text-body-sm`,t>0&&`border-t border-line-soft`),children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 [overflow-wrap:anywhere]`,children:e.text}),(0,X.jsx)(`span`,{className:`flex-none text-muted tabular-nums`,children:Zt(e.at)}),(0,X.jsx)(H,{variant:`icon`,size:`icon`,disabled:c,"aria-label":`Forget note ${t+1}`,"data-tip":`Forget this note (cannot be undone)`,onClick:()=>void h({at:e.at,text:e.text}),children:(0,X.jsx)(K,{"aria-hidden":`true`})})]},`${e.at}-${t}`))})]})}function Si({view:e}){let t=e.capabilities,n=t.some(e=>e.state===`needs_setup`)?`needs_setup`:t.some(e=>e.state===`partial`)?`partial`:`ready`,r=n===`ready`?`pass`:n===`partial`?`warn`:`neutral`,i=n===`ready`?`Ready`:n===`partial`?`Partly set up`:`Needs setup`,a=t.filter(e=>e.state!==`ready`);return(0,X.jsxs)(`div`,{className:`flex w-full flex-col gap-6 pt-2 text-left`,children:[a.length>0&&(0,X.jsxs)(J,{id:`ca-needs`,icon:Ie,title:`What it needs`,actions:(0,X.jsx)(B,{tone:r,children:i}),children:[(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:n===`needs_setup`?`${A(e.name,!0)} cannot work until these are set up.`:`${A(e.name,!0)} works, without the parts below.`}),(0,X.jsx)(`ul`,{"aria-label":`What ${A(e.name)} needs`,className:g(`surface rounded-lg bg-bg p-6 shadow-sm`,`m-0 flex list-none flex-col p-0`),children:a.map((e,t)=>(0,X.jsxs)(`li`,{className:g(`flex items-center gap-4 px-4 py-2`,t>0&&`border-t border-line-soft`),children:[(0,X.jsx)(z,{icon:Ti[e.state].icon,size:16,className:g(`flex-none`,Ti[e.state].cls)}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,X.jsx)(`span`,{className:`text-body-sm font-medium`,children:e.title}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted [overflow-wrap:anywhere]`,children:e.gaps.join(`; `)||Ti[e.state].label})]})]},e.id))})]}),(0,X.jsx)(cn,{scope:{kind:`custom`,id:e.id,name:e.name}}),t.length>0&&(0,X.jsx)(nn,{title:`What ${A(e.name)} can use`,children:(0,X.jsx)(`section`,{"aria-label":`What ${A(e.name)} can use`,className:`flex flex-col gap-2 pt-2`,children:(0,X.jsx)(`ul`,{className:g(`surface rounded-lg bg-bg p-6 shadow-sm`,`m-0 flex list-none flex-col p-0`),children:t.map((e,t)=>{let n=Ti[e.state];return(0,X.jsxs)(`li`,{className:g(`flex items-start gap-4 px-4 py-2`,t>0&&`border-t border-line-soft`),children:[(0,X.jsx)(z,{icon:n.icon,size:16,className:g(`mt-1 flex-none`,n.cls)}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,X.jsx)(`span`,{className:`text-body-sm font-medium`,children:e.title}),(0,X.jsxs)(`span`,{className:`text-body-sm text-muted`,children:[n.label,e.gaps.length?`: ${e.gaps.join(`; `)}`:``]})]})]},e.id)})})})})]})}var Ci={approved:`Approved`,signed:`Signed`,disabled:`Disabled`,enabled:`Enabled`,"rolled-back":`Rolled back to`};function wi(e){let t=/\s*\(web\)$/i.test(e),n=e.replace(/\s*\(web\)$/i,``).trim(),r=/^(?:\d+\+)?([^@\s]+)@users\.noreply\.github\.com$/i.exec(n);return r?n=r[1]:n.includes(`@`)&&n.length>24&&(n=n.slice(0,n.indexOf(`@`))),t?`${n} · web`:n}var Ti={ready:{icon:G,label:`Ready`,cls:`text-pass`},partial:{icon:ke,label:`Partly set up`,cls:`text-warn`},needs_setup:{icon:Pe,label:`Needs setup`,cls:`text-muted`}};function Ei({view:e,open:t,onClose:n,onAct:r,onReload:i}){let a=e.active||e.working,o=!!e.working&&(e.state===`draft`||e.state===`changed`||e.state===`drifted`||e.state===`broken`&&e.working!==void 0);return(0,X.jsx)(Lt,{open:t,onClose:n,wide:!0,title:`Details`,description:`${e.name} · ${e.id}`,footer:(0,X.jsxs)(H,{variant:`ghost`,onClick:n,children:[(0,X.jsx)(Fe,{"aria-hidden":`true`}),`Close`]}),children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[a&&(0,X.jsx)(Oi,{spec:a,view:e}),(e.checkResults||[]).length>0&&(0,X.jsx)(Mi,{view:e,onDone:i}),((e.memory?.notes||0)>0||(e.memory?.kept.length||0)>0)&&(0,X.jsx)(xi,{view:e,onDone:i}),(0,X.jsx)(ki,{view:e,approvable:o,onAct:r}),(0,X.jsx)(Ri,{view:e})]})})}function Di({id:e,icon:t,title:n,children:r,aside:i}){return(0,X.jsx)(J,{id:e,icon:t,title:n,level:3,actions:i,children:r})}function Oi({spec:e,view:t}){let n=(t.active?t.describe?.active:t.describe?.working)||[],r=[...n.length?n.map(n=>[n.label,n.label===`Agents it may start`?_i(e.agents.map(e=>t.agentNames[e]||e)):n.text]):[[`Environments`,_i(e.environments)],[`Agents it may start`,_i(e.agents.map(e=>t.agentNames[e]||e))],[`It may`,_i(e.actions.map(e=>Ai[e]||e))],[`A person approves first`,_i(e.approve.map(e=>Ai[e]||e))],[`Repository`,e.repository===`write`?`may change files`:`read only`]],...n.some(e=>e.label===`Runs by itself`)?[]:[[`Runs by itself`,e.schedule?`${e.schedule.every?`every ${e.schedule.every}`:`at ${e.schedule.cron}`}: “${e.schedule.request}”`:`no: you, your team or Atlas start it`]],[`Skills`,_i(e.skills)],[`Knowledge`,_i(e.knowledge)]];return(0,X.jsxs)(Di,{id:`ca-reach`,icon:Ze,title:t.active?`What version ${t.approvedVersion} may reach`:`What its manifest may reach`,children:[(0,X.jsx)(`dl`,{className:g(d,`m-0 grid grid-cols-1 gap-x-6 gap-y-2 text-body-sm sm:grid-cols-[160px_1fr]`),children:r.map(([e,t])=>(0,X.jsxs)(`div`,{className:`contents`,children:[(0,X.jsx)(`dt`,{className:`text-muted`,children:e}),(0,X.jsx)(`dd`,{className:`m-0 text-ink [overflow-wrap:anywhere]`,children:t})]},e))}),e.policies.length>0&&(0,X.jsxs)(`p`,{className:`m-0 text-body-sm text-muted`,children:[`Guidance it is given (not a limit): `,e.policies.join(`; `)]})]})}function ki({view:e,approvable:t,onAct:n}){let[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(!1),l=async()=>{c(!0),o(null);try{let t=await M.library.publish(e.id);o({ok:!0,text:`Published ${e.approvedVersion} to your library: another project on this computer installs it from Import.${t.warnings.length?` ${t.warnings.join(`; `)}.`:``}`})}catch(e){o({ok:!1,text:e.message})}finally{c(!1)}};return(0,X.jsxs)(X.Fragment,{children:[r&&(0,X.jsx)(Pi,{view:e,at:r.ref,canGoBack:r.canGoBack,onClose:()=>i(null),onAct:n}),(0,X.jsxs)(Di,{id:`ca-versions`,icon:me,title:`Versions`,aside:(0,X.jsxs)(`span`,{className:`flex flex-wrap gap-2`,children:[t&&(e.approval?.signed.length||0)>0&&(0,X.jsxs)(`span`,{className:`self-center text-body-sm text-muted`,children:[`Signed by `,e.approval.signed.map(e=>e.by).join(`, `),`; needs `,e.approval.people-e.approval.signed.length,` more`]}),t&&(0,X.jsxs)(H,{size:`sm`,onClick:()=>n({action:`approve`}),"data-tip":`Approve ${e.manifestVersion}`,children:[(0,X.jsx)(G,{"aria-hidden":`true`}),`Approve`]}),e.changes.length>0&&(0,X.jsxs)(H,{size:`sm`,variant:`danger`,onClick:()=>n({action:`discard`}),"data-tip":`Back to ${e.approvedVersion}`,children:[(0,X.jsx)(he,{"aria-hidden":`true`}),`Discard the change`]}),e.approvedVersion&&(0,X.jsxs)(H,{size:`sm`,variant:`ghost`,onClick:()=>n({action:e.disabled?`enable`:`disable`}),children:[e.disabled?(0,X.jsx)(G,{"aria-hidden":`true`}):(0,X.jsx)(Pe,{"aria-hidden":`true`}),e.disabled?`Enable`:`Disable`]}),e.approvedVersion&&(0,X.jsxs)(H,{size:`sm`,variant:`ghost`,disabled:s,onClick:()=>void l(),"data-tip":`Publish ${e.approvedVersion} to your library`,children:[(0,X.jsx)(Et,{"aria-hidden":`true`}),`Publish`]}),(0,X.jsxs)(H,{size:`sm`,variant:`danger`,onClick:()=>n({action:`delete`}),children:[(0,X.jsx)(K,{"aria-hidden":`true`}),`Delete`]})]}),children:[a&&(0,X.jsx)(`p`,{role:a.ok?`status`:`alert`,className:g(`m-0 rounded-base px-4 py-2 text-body-sm [overflow-wrap:anywhere]`,a.ok?`bg-pass-soft text-pass`:`bg-fail-soft text-fail`),children:a.text}),e.tried&&e.manifestVersion&&(0,X.jsxs)(`p`,{className:`m-0 text-body-sm text-muted`,children:[`Last try of manifest `,e.manifestVersion,`: `,e.tried.outcome,`.`]}),e.events.length===0?(0,X.jsx)(ie,{className:`py-4`,children:`No version has been approved yet. Try it, then approve it: only an approved version runs, for you, your team and Atlas.`}):(0,X.jsx)(`ul`,{className:g(d,`m-0 flex list-none flex-col`),children:e.events.toReversed().map((t,r)=>{let a=t.event===`approved`||t.event===`rolled-back`?t.version===e.approvedVersion:!1,o=t.event===`approved`&&t.version!==e.approvedVersion&&!e.events.slice(e.events.indexOf(t)+1).some(e=>e.event===`approved`&&e.version===t.version);return(0,X.jsxs)(`li`,{className:`flex min-h-11 flex-wrap items-center gap-4 rounded-sm px-4 py-2`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-body-sm font-medium`,children:[(0,X.jsxs)(`span`,{children:[Ci[t.event],` `,t.version]}),a&&r===0?(0,X.jsx)(B,{tone:`pass`,children:`Running`}):null]}),(0,X.jsxs)(`span`,{className:`text-body-sm text-muted [overflow-wrap:anywhere]`,children:[wi(t.by),` · `,Zt(t.at),t.note?` · ${t.note}`:``,t.tried?` · tried: ${t.tried.outcome}`:``]})]}),t.event===`approved`&&(0,X.jsx)(H,{size:`sm`,variant:`ghost`,onClick:()=>i({ref:t.digest.slice(0,16),canGoBack:o}),"aria-label":`Read version ${t.version}`,"data-tip":`Read version ${t.version}`,children:(0,X.jsx)(yt,{"aria-hidden":`true`})}),o&&(0,X.jsx)(H,{size:`sm`,variant:`ghost`,onClick:()=>n({action:`rollback`,to:t.version}),"aria-label":`Roll back to ${t.version}`,"data-tip":`Roll back to ${t.version}`,children:(0,X.jsx)(be,{"aria-hidden":`true`})})]},`${t.at}-${r}`)})})]})]})}var Ai={read:`read`,run:`run tests and apps`,change:`change files`,external:`change other systems`,schedule:`schedule work`},ji={passed:{label:`Passed`,tone:`pass`},failed:{label:`Failed`,tone:`fail`},not_run:{label:`Not run on this version`,tone:`neutral`}};function Mi({view:e,onDone:t}){let[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(``),o=n&&n.target===e.id?n:null,s=!!n?.running,c=(0,Y.useRef)(null),l=(0,Y.useRef)(``),u=n=>{n&&n.target===e.id&&!n.running&&l.current!==n.startedAt&&(l.current=n.startedAt,t())},f=e=>{r(e),u(e)};(0,Y.useEffect)(()=>{M.checks.job().then(e=>f(e.job),e=>a(e.message))},[e.id]),(0,Y.useEffect)(()=>{if(!s)return;let e=Rt(()=>{M.checks.job().then(e=>(a(``),f(e.job)),e=>a(e.message))},2e3);return()=>jt(e)},[s]),(0,Y.useEffect)(()=>{c.current&&(c.current.scrollTop=c.current.scrollHeight)},[o?.lines.length]);let p=e=>{a(``),e.then(e=>f(e.job),e=>a(e.message))};return(0,X.jsxs)(Di,{id:`ca-checks`,icon:rt,title:`Checks`,aside:o?.running?(0,X.jsxs)(H,{size:`sm`,variant:`danger`,onClick:()=>p(M.checks.stop()),children:[(0,X.jsx)(pt,{"aria-hidden":`true`}),`Stop`]}):(0,X.jsxs)(H,{size:`sm`,onClick:()=>p(M.checks.start(e.id)),disabled:s,"data-tip":`Try each check on ${e.manifestVersion}`,children:[(0,X.jsx)(Ae,{"aria-hidden":`true`}),`Run checks`]}),children:[s&&!o&&(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`Another agent's checks are running: Run checks waits for them to end.`}),(0,X.jsx)(`ul`,{className:g(d,`m-0 flex list-none flex-col p-0`),children:e.checkResults.map((e,t)=>(0,X.jsxs)(`li`,{className:g(`flex flex-col gap-1 px-4 py-2 text-body-sm`,t>0&&`border-t border-line-soft`),children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`font-mono text-body-sm`,children:e.name}),(0,X.jsx)(B,{tone:ji[e.state].tone,children:ji[e.state].label}),e.at&&(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:Zt(e.at)})]}),(0,X.jsx)(`span`,{className:`text-body-sm text-ink-2 [overflow-wrap:anywhere]`,children:e.request}),e.state===`failed`&&(e.reasons||[]).length>0&&(0,X.jsx)(`ul`,{className:`m-0 list-disc pl-6 text-body-sm text-fail [overflow-wrap:anywhere]`,children:e.reasons.map(e=>(0,X.jsx)(`li`,{children:e},e))})]},e.name))}),i&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 text-body-sm text-fail [overflow-wrap:anywhere]`,children:i}),o&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`details`,{open:o.running,children:[(0,X.jsxs)(`summary`,{className:`cursor-pointer text-body-sm text-muted`,children:[`Output (`,o.lines.length,` lines)`]}),(0,X.jsx)(`pre`,{ref:c,className:g(`overflow-auto rounded-base bg-surface-muted p-4 font-mono text-body-sm leading-relaxed whitespace-pre-wrap text-ink-2 [overflow-wrap:anywhere]`,`mt-2 max-h-[300px]`),children:(0,X.jsx)(ce,{text:o.lines.join(`
|
|
5
|
-
`)||`Starting…`})})]}),o.running&&o.question&&(0,X.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 border-0 p-0`,children:[(0,X.jsx)(`legend`,{className:`mb-1 text-body-sm font-medium`,children:o.question.title}),o.question.detail&&(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:o.question.detail}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:o.question.options.map(e=>(0,X.jsx)(H,{size:`sm`,variant:e.id===`deny`||e.id===`stop`?`outline`:`primary`,onClick:()=>p(M.checks.answer(o.question.id,e.id)),children:e.label},e.id))})]})]})]})}function Ni({lines:e}){return(0,X.jsx)(`dl`,{className:g(d,`m-0 grid grid-cols-1 gap-x-6 gap-y-2 text-body-sm sm:grid-cols-[160px_1fr]`),children:e.map(e=>(0,X.jsxs)(`div`,{className:`contents`,children:[(0,X.jsxs)(`dt`,{className:g(e.mark===`same`?`text-muted`:`font-medium text-warn`),children:[e.label,e.mark!==`same`&&(0,X.jsxs)(`span`,{className:`sr-only`,children:[` (`,Fi[e.mark],`)`]})]}),(0,X.jsxs)(`dd`,{className:g(`m-0 [overflow-wrap:anywhere]`,e.mark===`removed`?`text-muted line-through`:`text-ink`),children:[e.mark!==`same`&&(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`mr-2 text-body-sm font-medium text-warn`,children:Fi[e.mark]}),e.text,e.before&&(0,X.jsxs)(`span`,{className:`block text-body-sm text-muted`,children:[`Was: `,e.before]})]})]},`${e.mark}-${e.label}`))})}function Pi({view:e,at:t,canGoBack:n,onClose:r,onAct:i}){let[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(``);return(0,Y.useEffect)(()=>{M.version(e.id,t).then(o,e=>c(e.message))},[e.id,t]),(0,X.jsx)(Lt,{open:!0,wide:!0,onClose:r,title:a?`Version ${a.version}`:`Version`,description:a?`Approved by ${wi(a.by)} ${Zt(a.at)}${a.note?`: ${a.note}`:``}.${a.running?` It is the version that runs.`:``}`:void 0,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(H,{variant:`ghost`,onClick:r,children:[(0,X.jsx)(Fe,{"aria-hidden":`true`}),`Close`]}),n&&a&&!a.running&&(0,X.jsxs)(H,{variant:`primary`,onClick:()=>(r(),i({action:`rollback`,to:a.version})),children:[(0,X.jsx)(be,{"aria-hidden":`true`}),`Roll back to `,a.version]})]}),children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[s&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 text-body-sm text-fail [overflow-wrap:anywhere]`,children:s}),!a&&!s&&(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Loading…`}),a&&(0,X.jsxs)(X.Fragment,{children:[!a.running&&a.permissions.length>0&&(0,X.jsx)(J,{id:`ca-version-may`,icon:Ze,title:(0,X.jsxs)(X.Fragment,{children:[`What it may do, against `,e.approvedVersion]}),level:3,children:(0,X.jsx)(Ni,{lines:a.permissions})}),a.diff&&(0,X.jsx)(J,{id:`ca-version-diff`,icon:ut,title:(0,X.jsxs)(X.Fragment,{children:[`Its manifest against `,e.approvedVersion]}),level:3,children:(0,X.jsx)(en,{diff:a.diff})}),(0,X.jsx)(J,{id:`ca-version-source`,icon:ye,title:`Its manifest as approved`,level:3,children:(0,X.jsx)(`pre`,{className:g(`surface rounded-lg bg-bg p-6 shadow-sm`,`m-0 max-h-[50vh] overflow-auto font-mono text-body-sm whitespace-pre-wrap [overflow-wrap:anywhere]`),children:a.source})})]})]})})}var Fi={new:`New`,changed:`Changed`,removed:`No longer`},Ii={run:`Asked`,try:`Tried`,orchestrator:`From Atlas`,schedule:`Nobody watching`,agent:`Handed on by another agent`,check:`A saved check`},Li={usage:Ft,money:Nt};function Ri({view:e}){let[t,n]=(0,Y.useState)(``),i=async()=>{n(``);try{let t=await M.audit(e.id),n=URL.createObjectURL(new Blob([t],{type:`application/x-ndjson;charset=utf-8`})),r=document.createElement(`a`);r.href=n,r.download=`${e.id}-audit.jsonl`,r.click(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}catch(e){n(e.message)}};return(0,X.jsxs)(Di,{id:`ca-runs`,icon:Ae,title:`Recent runs`,aside:(0,X.jsxs)(H,{size:`sm`,variant:`ghost`,onClick:()=>void i(),"data-tip":`Download its whole record, for audit`,children:[(0,X.jsx)(vt,{"aria-hidden":`true`}),`Download`]}),children:[t&&(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-fail`,children:t}),e.runs.length===0?(0,X.jsxs)(ie,{className:`py-4`,children:[A(e.name,!0),` has not run yet.`]}):(0,X.jsx)(`ul`,{className:g(d,`m-0 flex list-none flex-col p-0`),children:e.runs.map((e,t)=>(0,X.jsx)(`li`,{className:g(t>0&&`border-t border-line-soft`),children:(0,X.jsxs)(`details`,{className:`group px-4 py-2`,children:[(0,X.jsxs)(`summary`,{className:`flex cursor-pointer list-none flex-wrap items-center gap-x-4 gap-y-1`,children:[(0,X.jsx)(B,{tone:e.outcome===`done`?`pass`:e.outcome===`running`?`running`:e.outcome===`stopped`||e.outcome===`needs_input`?`neutral`:`fail`,children:e.outcome.replace(`_`,` `)}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-body-sm font-medium`,"data-tip":e.request,children:e.request}),(0,X.jsxs)(`span`,{className:`text-body-sm text-muted tabular-nums`,children:[Ii[e.trigger]||`Started another way`,` · `,e.version,` · `,e.calls,` `,e.calls===1?`call`:`calls`,e.refused?`, ${e.refused} refused`:``,e.result?.verdict?` · verdict ${e.result.verdict}`:``,` · `,Zt(e.startedAt)]})]}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2 pl-1 text-body-sm`,children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-4 gap-y-1`,children:[(0,X.jsxs)(`span`,{className:`text-muted`,children:[`By `,e.by]}),e.session&&(0,X.jsxs)(`a`,{href:r(`runs`,encodeURIComponent(e.session)),className:`inline-flex items-center gap-1`,children:[`Open the run`,(0,X.jsx)(dt,{size:14,"aria-hidden":`true`})]})]}),xr(e,Li)&&(0,X.jsx)(`span`,{className:`text-muted tabular-nums [overflow-wrap:anywhere]`,children:xr(e,Li)}),e.error&&(0,X.jsx)(`span`,{className:`text-fail [overflow-wrap:anywhere]`,children:e.error}),e.result&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-muted`,children:`Its result`}),(0,X.jsxs)(`dl`,{className:`m-0 grid grid-cols-[max-content_1fr] gap-x-4 gap-y-1`,children:[(0,X.jsx)(`dt`,{className:`text-muted`,children:`Verdict`}),(0,X.jsx)(`dd`,{className:`m-0`,children:e.result.verdict||`None given`}),Object.entries(e.result.fields).map(([e,t])=>(0,X.jsxs)(Y.Fragment,{children:[(0,X.jsx)(`dt`,{className:`font-mono text-body-sm text-muted`,children:e}),(0,X.jsx)(`dd`,{className:`m-0 [overflow-wrap:anywhere]`,children:typeof t==`boolean`?t?`Yes`:`No`:String(t)})]},e))]}),e.result.problems.length>0&&(0,X.jsxs)(`span`,{className:`text-warn [overflow-wrap:anywhere]`,children:[`Not read: `,e.result.problems.join(`; `),`.`]})]}),e.reply&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-muted`,children:`Its reply`}),(0,X.jsx)(`p`,{tabIndex:0,"aria-label":`Its reply`,className:g(`rounded-base bg-surface-muted p-4`,`m-0 max-h-[240px] overflow-auto whitespace-pre-wrap text-ink-2 [overflow-wrap:anywhere]`),children:e.reply})]}),e.decisions.length>0&&(0,X.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0`,children:e.decisions.map((e,t)=>(0,X.jsxs)(`li`,{className:`flex items-start gap-2`,children:[e.allowed?(0,X.jsx)(G,{size:14,"aria-label":`Allowed`,className:`mt-1 flex-none text-pass`}):(0,X.jsx)(Ie,{size:14,"aria-label":`Refused`,className:`mt-1 flex-none text-fail`}),(0,X.jsxs)(`span`,{className:`min-w-0 [overflow-wrap:anywhere]`,children:[(0,X.jsx)(`span`,{className:`font-mono text-body-sm`,children:e.tool}),e.allowed?(0,X.jsxs)(`span`,{className:`text-muted`,children:[` · `,Ai[e.action||``]||e.action,e.approved?`, approved by a person`:``]}):(0,X.jsxs)(`span`,{className:`text-fail`,children:[` · `,e.reason]})]})]},t))})]})]})},e.run))})]})}var zi={approve:{title:`Approve this version`,button:`Approve`,icon:G},disable:{title:`Disable this agent`,button:`Disable`,icon:Pe},enable:{title:`Enable this agent`,button:`Enable`,icon:G},rollback:{title:`Run an earlier version`,button:`Roll back`,icon:be},delete:{title:`Delete this agent`,button:`Delete`,icon:K},discard:{title:`Discard the change`,button:`Discard the change`,icon:he}};function Bi({view:e,action:t,to:n,onClose:r,onDone:i}){let[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(``),m=t===`approve`?e.checks:null,h=!!m&&(m.failed.length>0||m.missing.length>0),[_,v]=(0,Y.useState)(!1),y=t===`approve`?e.approval:void 0,b=y?y.people-y.signed.length:1,x=(e,t)=>e.toLowerCase()===t.toLowerCase(),S=!!y&&y.owners.length>0&&!y.owners.some(e=>x(e,y.you)),C=!!y&&y.signed.some(e=>x(e.by,y.you)),w=zi[t],T=t===`approve`&&e.state===`drifted`&&e.changes.length===0?`Version ${e.approvedVersion} is approved again with what it knows now, and runs again for you, your team and Atlas. Commit .forgeqe/agents/.releases/${e.id} so your team has it.`:t===`approve`&&b>1?`Your approval of version ${e.manifestVersion} is kept; it runs once ${b-1} more ${b-1==1?`person approves`:`people approve`} it. Commit .forgeqe/agents/.releases/${e.id} so the next person sees your approval.`:t===`approve`?`Version ${e.manifestVersion} becomes what runs, for you, your team and Atlas${e.approvedVersion?`, in place of ${e.approvedVersion}`:``}.${e.tried?` Its last try: ${e.tried.outcome}.`:` It was never tried.`} Commit .forgeqe/agents/.releases/${e.id} so your team has it.`:t===`disable`?`Nothing of it runs (not you, your team, Atlas or its schedule) until a person enables it again, here or with forgeqe agent enable.${e.handedBy?.length?` ${e.handedBy.join(`, `)} ${e.handedBy.length===1?`hands`:`hand`} work to it: those hand-offs will be refused meanwhile.`:``}`:t===`enable`?`Version ${e.approvedVersion} runs again.`:t===`discard`?`Its manifest goes back to version ${e.approvedVersion}, the one that runs; the change waiting for approval is thrown away (the audit log keeps that it was).`:t===`delete`?`${e.name} will be removed for good: its manifest, approved versions, runs and waiting approvals. Knowledge files and skills it named stay in the project.${e.handedBy?.length?` ${e.handedBy.join(`, `)} ${e.handedBy.length===1?`hands`:`hand`} work to it: those hand-offs will be refused.`:``}`:`Version ${n} runs from now on, in place of ${e.approvedVersion}.`,E=async()=>{d(!0),p(``);try{i(await M.act(e.id,t,{confirm:o,...c.trim()?{note:c.trim()}:{},...n?{to:n}:{},...h&&_?{skipChecks:!0}:{}}))}catch(e){p(e.message),d(!1)}};return(0,X.jsx)(Lt,{open:!0,onClose:r,title:w.title,description:T,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(H,{variant:`ghost`,onClick:r,children:[(0,X.jsx)(Fe,{"aria-hidden":`true`}),`Cancel`]}),(0,X.jsxs)(H,{variant:t===`delete`||t===`discard`?`destructive`:`primary`,disabled:u||o!==e.id||h&&!_||S||C,onClick:()=>void E(),children:[(0,X.jsx)(w.icon,{"aria-hidden":`true`}),w.button]})]}),children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[t===`approve`&&e.state===`drifted`&&e.drift&&(0,X.jsx)(J,{id:`ca-approve-drift`,icon:ut,title:(0,X.jsxs)(X.Fragment,{children:[`What it knows that changed since `,e.approvedVersion,` was approved`]}),level:3,children:(0,X.jsx)(`ul`,{className:g(`surface rounded-lg bg-bg p-6 shadow-sm`,`m-0 list-disc text-body-sm text-ink`),children:e.drift.map(e=>(0,X.jsx)(`li`,{children:e},e))})}),t===`approve`&&(e.permissions||[]).length>0&&(0,X.jsx)(J,{id:`ca-approve-may`,icon:Ze,title:(0,X.jsx)(X.Fragment,{children:e.approvedVersion?`What it may do, against ${e.approvedVersion}`:`What it may do`}),level:3,children:(0,X.jsx)(Ni,{lines:e.permissions})}),m&&(0,X.jsxs)(`div`,{role:h?`alert`:void 0,className:g(`flex flex-col gap-2 rounded-base px-4 py-4 text-body-sm`,h?`bg-warn-soft`:`bg-surface-muted`),children:[(0,X.jsx)(`span`,{className:g(`font-medium`,h?`text-warn`:`text-ink`),children:h?`Its checks have not all passed on version ${e.manifestVersion}`:`Its ${m.total} ${m.total===1?`check`:`checks`} passed on version ${e.manifestVersion}`}),m.failed.length>0&&(0,X.jsxs)(`span`,{className:`text-body-sm text-ink-2`,children:[`Failed: `,m.failed.join(`, `)]}),m.missing.length>0&&(0,X.jsxs)(`span`,{className:`text-body-sm text-ink-2`,children:[`Not run on this version: `,m.missing.join(`, `),`. Run them under Details, Checks, or with `,(0,X.jsxs)(`span`,{className:`font-mono`,children:[`forgeqe agent test `,e.id]}),`.`]}),h&&(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2`,children:[(0,X.jsx)(on,{checked:_,onCheckedChange:e=>v(e===!0),className:`mt-1`}),(0,X.jsx)(`span`,{children:`Approve it without them (kept in its history)`})]})]}),y&&(y.people>1||y.owners.length>0)&&(0,X.jsxs)(`div`,{role:S||C?`alert`:void 0,className:g(`flex flex-col gap-2 rounded-base px-4 py-4 text-body-sm`,S||C?`bg-warn-soft`:`bg-surface-muted`),children:[(0,X.jsx)(`span`,{className:g(`font-medium`,S||C?`text-warn`:`text-ink`),children:S?`Only ${y.owners.join(`, `)} may approve it`:C?`You already approved this version: another person approves it next`:y.people>1?`It needs ${y.people} different people to approve it`:`Only ${y.owners.join(`, `)} may approve it`}),y.people>1&&(0,X.jsxs)(`span`,{className:`text-body-sm text-ink-2`,children:[`Approved so far by `,y.signed.map(e=>e.by).join(`, `)||`nobody`,`.`]}),(0,X.jsxs)(`span`,{className:`text-body-sm text-muted`,children:[`ForgeQE knows you as `,y.you||`nobody`,`, git's user name on this computer: an agreement the history keeps, not a sign-in.`]})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsxs)(`span`,{children:[`Type `,(0,X.jsx)(`span`,{className:`font-mono`,children:e.id}),` to confirm`]}),(0,X.jsx)(a,{value:o,onChange:e=>s(e.target.value),autoComplete:`off`,spellCheck:!1})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{children:`Note (optional)`}),(0,X.jsx)(a,{value:c,maxLength:200,onChange:e=>l(e.target.value),placeholder:t===`rollback`?`Why it goes back`:`What changed, or why`})]}),f&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 text-body-sm text-fail [overflow-wrap:anywhere]`,children:f})]})})}var Vi=/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/,Hi={queued:`neutral`,done:`pass`,running:`running`,working:`running`,failed:`fail`,refused:`fail`,stopped:`neutral`,needs_input:`warn`},Ui={queued:`waiting its turn`,done:`done`,running:`running`,working:`working`,failed:`failed`,refused:`refused`,stopped:`stopped`,needs_input:`needed a person`},Wi={pass:`bg-pass`,fail:`bg-fail`,warn:`bg-warn`,running:`bg-accent`,neutral:`bg-muted`},Gi={run:`From a terminal`,orchestrator:`From Atlas`,web:`From this app`,try:`A preview`};function Ki({problems:e,invalid:t}){return(0,X.jsxs)(`div`,{role:`alert`,className:g(L.fail,`flex flex-col gap-1`),children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-2 font-medium`,children:[(0,X.jsx)(Ie,{size:16,"aria-hidden":`true`,className:`flex-none`}),t?`Its file needs fixing before it can be approved`:e.length===1?`One thing stops it, or one of its members`:`${e.length} things stop it, or some of its members`]}),(0,X.jsx)(`ul`,{className:`m-0 list-disc pl-10 [overflow-wrap:anywhere]`,children:e.slice(0,3).map((e,t)=>(0,X.jsx)(`li`,{children:e},t))})]})}var qi=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}k`:String(e);function Ji({t:e,icon:t,name:n}){let r=Hi[e.state],i=n||e.member;return(0,X.jsxs)(`li`,{className:`relative inline-flex`,"data-tip":`${e.n}. ${i}: ${Ui[e.state]}`,children:[(0,X.jsx)(b,{agent:e.member,icon:t,px:24,decorative:!0}),(0,X.jsx)(`span`,{className:g(`absolute -right-1 -bottom-1 size-3 rounded-full border-2 border-bg`,Wi[r])}),(0,X.jsxs)(`span`,{className:`sr-only`,children:[`Task `,e.n,`, `,i,`: `,Ui[e.state]]})]})}function Yi({board:e,view:t,onClose:n}){let r=[...t.lead?[t.lead]:[],...t.members||[]],i=e=>r.find(t=>t.agent===e)?.icon,a=e=>r.find(t=>t.agent===e)?.name||e,o=e?[...new Set(e.tasks.map(e=>e.member))]:[],[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)({}),d=t=>`${e?.run||``}:${t}`,f=t=>{if(!e)return;let n=d(t);if(l[n])return u({...l,[n]:void 0});u({...l,[n]:{}});let r=e=>u(t=>t[n]&&t[n].text===void 0&&t[n].error===void 0?{...t,[n]:e}:t);I.sharedFile(e.team,e.run,t).then(e=>r({text:e.text})).catch(e=>r({error:e.message}))};return(0,X.jsx)(Lt,{open:!!e,onClose:()=>(c(!1),u({}),n()),wide:!0,title:`Run`,description:e?`${Gi[e.trigger]}${e.unattended?`, nobody watching`:``} · ${Zt(e.startedAt)} · by ${e.by}`:void 0,footer:(0,X.jsxs)(H,{variant:`ghost`,onClick:()=>(c(!1),u({}),n()),children:[(0,X.jsx)(Fe,{"aria-hidden":`true`}),`Close`]}),children:e&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(B,{tone:Hi[e.outcome],className:`self-start`,children:Ui[e.outcome]}),(0,X.jsx)(`p`,{className:`m-0 text-body-lg font-medium whitespace-pre-wrap text-ink [overflow-wrap:anywhere]`,children:e.request}),e.error&&(0,X.jsx)(`p`,{className:`m-0 text-body-md text-fail [overflow-wrap:anywhere]`,children:e.error})]}),(0,X.jsxs)(Vt,{label:`This run`,children:[(0,X.jsx)(Kt,{compact:!0,icon:rt,label:`Tasks`,value:e.tasks.length,note:`${e.tasks.filter(e=>e.state===`done`).length} done`}),(0,X.jsx)(Kt,{compact:!0,icon:mt,label:`Questions`,value:(e.questions||[]).length}),(0,X.jsx)(Kt,{compact:!0,icon:wt,label:`Files`,value:(e.files||[]).length}),(0,X.jsx)(Kt,{compact:!0,icon:xe,label:`Tokens`,value:e.tokens?qi(e.tokens):`—`})]}),o.length>0&&(0,X.jsx)(J,{id:`run-lanes`,icon:U,title:`Who did what`,level:3,children:(0,X.jsx)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-[repeat(auto-fit,minmax(220px,1fr))]`,children:o.map(t=>(0,X.jsxs)(`section`,{"aria-label":a(t),className:g(`rounded-base bg-surface-muted p-4`,`flex flex-col gap-2`),children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-2 text-body-md font-medium text-ink`,children:[(0,X.jsx)(b,{agent:t,icon:i(t),px:24,decorative:!0}),(0,X.jsx)(`span`,{className:`truncate`,children:a(t)})]}),(0,X.jsx)(`ol`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:e.tasks.filter(e=>e.member===t).map(e=>(0,X.jsxs)(`li`,{className:g(`bg-nest text-ink-2 shadow-(--nest-shadow)`,`flex flex-col gap-1 rounded-base px-4 py-2 text-body-sm`),children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`text-muted tabular-nums`,children:[`#`,e.n]}),(0,X.jsx)(B,{tone:Hi[e.state],children:Ui[e.state]}),e.copy?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-muted`,children:[(0,X.jsx)(Ve,{size:12,"aria-hidden":`true`}),`copy `,e.copy]}):null,e.for?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-muted`,children:[(0,X.jsx)(Ue,{size:12,"aria-hidden":`true`}),`helping `,a(e.for),e.forTask?` (#${e.forTask})`:``]}):null,e.verdict&&(0,X.jsx)(`span`,{className:`text-muted`,children:e.verdict})]}),(0,X.jsx)(`span`,{className:`whitespace-pre-wrap text-ink-2 [overflow-wrap:anywhere]`,children:e.task}),e.error&&(0,X.jsx)(`span`,{className:`text-fail [overflow-wrap:anywhere]`,children:e.error})]},e.n))})]},t))})}),((e.questions||[]).length>0||e.notes.length>0)&&(0,X.jsx)(J,{id:`run-talk`,icon:mt,title:`What they said to each other`,level:3,children:(0,X.jsxs)(`ol`,{className:`m-0 flex list-none flex-col gap-4 p-0`,children:[(e.questions||[]).map(e=>(0,X.jsxs)(`li`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(Zi,{face:(0,X.jsx)(b,{agent:e.from,icon:i(e.from),px:24,decorative:!0}),who:`${a(e.from)} asked the lead${e.task?` (task ${e.task})`:``}`,text:e.text}),e.answer?(0,X.jsx)(Zi,{right:!0,face:t.lead?(0,X.jsx)(b,{agent:t.lead.agent,icon:t.lead.icon,px:24,decorative:!0}):null,who:`The lead answered`,text:e.answer}):(0,X.jsx)(`span`,{className:`pl-10 text-body-sm text-muted`,children:e.state===`open`?`Waiting for the lead`:`Not answered in time: it carried on`})]},`q${e.n}`)),e.notes.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsx)(Zi,{face:(0,X.jsx)(b,{agent:e.from,icon:i(e.from),px:24,decorative:!0}),who:`${a(e.from)} → ${e.to===`all`?`everyone`:e.to===`lead`?`the lead`:a(e.to)} · ${e.kind}`,text:e.text})},`n${e.n}`))]})}),(e.files||[]).length>0&&(0,X.jsx)(J,{id:`run-files`,icon:wt,title:`What they shared`,level:3,children:(0,X.jsx)(`ol`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:(e.files||[]).map(e=>(0,X.jsxs)(`li`,{className:g(`bg-nest text-ink-2 shadow-(--nest-shadow)`,`flex flex-col gap-1 rounded-base px-4 py-2 text-body-sm`),children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(b,{agent:e.from,icon:i(e.from),px:24,decorative:!0}),(0,X.jsx)(`span`,{className:`font-medium text-ink [overflow-wrap:anywhere]`,children:e.name}),(0,X.jsxs)(`span`,{className:`text-muted`,children:[`by `,a(e.from),` · `,Xi(e.bytes)]})]}),e.about&&(0,X.jsx)(`span`,{className:`text-ink-2 [overflow-wrap:anywhere]`,children:e.about}),(0,X.jsxs)(H,{variant:`ghost`,className:`self-start`,"aria-expanded":!!l[d(e.name)],"aria-label":`${l[d(e.name)]?`Hide the file`:`Show the file`} ${e.name}`,onClick:()=>f(e.name),children:[(0,X.jsx)(De,{"aria-hidden":`true`,className:g(`transition-transform`,l[d(e.name)]&&`rotate-90`)}),l[d(e.name)]?`Hide the file`:`Show the file`]}),l[d(e.name)]&&(l[d(e.name)].error?(0,X.jsx)(`p`,{className:`m-0 text-body-md text-fail [overflow-wrap:anywhere]`,children:l[d(e.name)].error}):l[d(e.name)].text===void 0?(0,X.jsx)(`p`,{className:`m-0 text-body-md text-muted`,children:`Reading the file…`}):(0,X.jsx)(`p`,{"aria-label":e.name,className:g(`rounded-base bg-surface-muted p-4`,`m-0 text-body-md whitespace-pre-wrap text-ink-2 [overflow-wrap:anywhere]`),children:l[d(e.name)].text}))]},e.name))})}),e.reply&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(H,{variant:`ghost`,className:`self-start`,"aria-expanded":s,onClick:()=>c(!s),children:[(0,X.jsx)(De,{"aria-hidden":`true`,className:g(`transition-transform`,s&&`rotate-90`)}),`The lead's report`]}),s&&(0,X.jsx)(`p`,{"aria-label":`The lead's report`,className:g(`rounded-base bg-surface-muted p-4`,`m-0 text-body-md whitespace-pre-wrap text-ink-2 [overflow-wrap:anywhere]`),children:e.reply})]})]})})}var Xi=e=>e<1024?`${e} bytes`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`;function Zi({face:e,who:t,text:n,right:r}){return(0,X.jsxs)(`div`,{className:g(`flex items-start gap-2`,r&&`flex-row-reverse`),children:[(0,X.jsx)(`span`,{className:`flex-none pt-1`,children:e}),(0,X.jsxs)(`div`,{className:g(r?f:p,`flex max-w-[85%] flex-col gap-1 text-body-md`),children:[(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:t}),(0,X.jsx)(`span`,{className:`text-ink [overflow-wrap:anywhere]`,children:n})]})]})}var Qi={approve:{title:`Approve this version`,button:`Approve`,icon:G},disable:{title:`Disable this team`,button:`Disable`,icon:Pe},enable:{title:`Enable this team`,button:`Enable`,icon:G}};function $i({view:e,action:t,onClose:n,onDone:r}){let[i,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(``),p=Qi[t],m=t===`approve`?`Version ${e.fileVersion} becomes what runs, for you, your team and Atlas${e.approvedVersion?`, in place of ${e.approvedVersion}`:``}. Commit .forgeqe/agents/teams/.releases/${e.id} so your team has it.`:t===`disable`?`Nothing of it runs (not you, your team or Atlas) until a person enables it again, here or with forgeqe team enable. Its members keep running on their own.`:`Version ${e.approvedVersion} runs again.`,h=async()=>{u(!0),f(``);try{r(await I.act(e.id,t,{confirm:i,...s.trim()?{note:s.trim()}:{}}))}catch(e){f(e.message),u(!1)}};return(0,X.jsx)(Lt,{open:!0,onClose:n,title:p.title,description:m,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(H,{variant:`ghost`,onClick:n,children:[(0,X.jsx)(Fe,{"aria-hidden":`true`}),`Cancel`]}),(0,X.jsxs)(H,{variant:`primary`,disabled:l||i!==e.id,onClick:()=>void h(),children:[(0,X.jsx)(p.icon,{"aria-hidden":`true`}),p.button]})]}),children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[t===`approve`&&e.working&&(0,X.jsx)(J,{id:`team-approve-may`,icon:Ze,title:`What it lets its members do`,level:3,children:(0,X.jsx)(`dl`,{className:g(`rounded-base bg-surface-muted p-4`,`m-0 grid grid-cols-1 gap-x-6 gap-y-2 text-body-md sm:grid-cols-[160px_1fr]`),children:e.working.describe.map(e=>(0,X.jsxs)(`div`,{className:`contents`,children:[(0,X.jsx)(`dt`,{className:`text-muted`,children:e.label}),(0,X.jsx)(`dd`,{className:`m-0 text-ink [overflow-wrap:anywhere]`,children:e.text})]},e.label))})}),t===`approve`&&e.problems.other.length>0&&(0,X.jsxs)(`p`,{role:`alert`,className:g(L.warn,`m-0 flex items-start gap-2`),children:[(0,X.jsx)(Ie,{size:16,"aria-hidden":`true`,className:`mt-1 flex-none`}),(0,X.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:e.problems.other.join(` `)})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-md`,children:[(0,X.jsxs)(`span`,{children:[`Type `,(0,X.jsx)(`span`,{className:`font-mono`,children:e.id}),` to confirm`]}),(0,X.jsx)(a,{value:i,onChange:e=>o(e.target.value),autoComplete:`off`,spellCheck:!1})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-md`,children:[(0,X.jsx)(`span`,{children:`Note (optional)`}),(0,X.jsx)(a,{value:s,maxLength:200,onChange:e=>c(e.target.value),placeholder:`What changed, or why`})]}),d&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 text-body-md text-fail [overflow-wrap:anywhere]`,children:d})]})})}function ea({id:e,name:t,members:n,onClose:r,onDone:i}){let[o,s]=(0,Y.useState)(``),[c,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(``),p=async()=>{u(!0),f(``);try{await I.remove(e,o),i()}catch(e){f(e.message),u(!1)}};return(0,X.jsx)(Lt,{open:!0,onClose:r,title:`Delete ${t||e}`,description:`The team is gone for you, your team and Atlas. Its agents stay: each keeps working on its own and in other teams.`,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(H,{variant:`ghost`,onClick:r,children:[(0,X.jsx)(Fe,{"aria-hidden":`true`}),`Cancel`]}),(0,X.jsxs)(H,{variant:`danger`,disabled:c||o!==e,onClick:()=>void p(),children:[(0,X.jsx)(K,{"aria-hidden":`true`}),`Delete team`]})]}),children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsxs)(`ul`,{className:g(l,`m-0 flex list-none flex-col gap-2 p-4 text-body-md`),children:[[`Its file and every approved version`,`Its own notes, skills, prompts and guardrails`,`Its icon, pictures and the names given to its agents`,`Its runs' boards and its schedule`].map(e=>(0,X.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,X.jsx)(K,{size:16,"aria-hidden":`true`,className:`mt-1 flex-none text-fail`}),e]},e)),(0,X.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,X.jsx)(G,{size:16,"aria-hidden":`true`,className:`mt-1 flex-none text-pass`}),n===1?`Its agent stays`:`Its ${n} agents stay`]})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-md`,children:[(0,X.jsxs)(`span`,{children:[`Type `,(0,X.jsx)(`span`,{className:`font-mono`,children:e}),` to confirm`]}),(0,X.jsx)(a,{value:o,onChange:e=>s(e.target.value),autoComplete:`off`,spellCheck:!1})]}),d&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 text-body-md text-fail [overflow-wrap:anywhere]`,children:d})]})})}var ta=312,na=132,ra={suite_failed:`A suite fails`,suite_passed:`A suite passes`,job_failed:`A schedule fails`,job_recovered:`A schedule recovers`,eval_failed:`An eval fails`,pr_opened:`A PR is opened`,pr_updated:`A PR is updated`,push:`A branch is pushed`},ia=e=>ra[e]||e.replace(/_/g,` `),aa=e=>e.every?e.every===`1d`?`Every day`:e.every===`1h`?`Every hour`:`Every ${e.every}`:e.cron===`0 7 * * 1-5`?`Weekdays at 07:00`:e.cron?`On cron ${e.cron}`:`On a schedule`,oa=(e,t)=>!e||e.kind!==t.kind?!1:e.kind===`member`&&t.kind===`member`?e.agent===t.agent:e.kind===`gap`&&t.kind===`gap`?e.area===t.area:e.kind===`start`&&t.kind===`start`?JSON.stringify(e.which)===JSON.stringify(t.which):!0;function sa(e,t,n){if(t===n)return!0;let r=new Set,i=t=>t===n||!r.has(t)&&(r.add(t),(e.members.find(e=>e.agent===t)?.after||[]).some(i));return i(t)}function ca(e){let t=new Map;if(!e)return t;let n=e=>e.state===`done`?`done`:e.state===`failed`||e.state===`refused`?`failed`:e.state===`working`?`working`:e.state===`queued`?`queued`:e.state===`needs_input`?`waiting`:`stopped`;for(let r of e.tasks)t.set(r.member,n(r));return t.set(e.lead.agent,e.outcome===`running`?`working`:e.outcome===`done`?`done`:e.outcome===`failed`?`failed`:e.outcome===`needs_input`?`waiting`:`stopped`),t}function la(e,t,n,r,i,a={}){let o=e=>t?.agents.find(t=>t.id===e),s=e=>{let t=o(e),n=a.look?.members[e];return n?{...t||{},id:e,name:n.name||t?.name||e,icon:n.icon||t?.icon,image:n.image,own:n.name?t?.name||e:void 0}:t},c=e=>s(e)?.name||e,l=[],u=[],d=(e,t)=>Array.from({length:e},(n,r)=>{let i=Math.floor(r/4),a=Math.min(4,e-i*4);return{x:(r%4-(a-1)/2)*ta,y:t+i*108}}),f=[{id:`start-asked`,pick:{kind:`start`,which:`asked`},title:`When asked`,sub:`From this page, Atlas or the terminal`},...e.schedule?.request?[{id:`start-schedule`,pick:{kind:`start`,which:`schedule`},title:aa(e.schedule),sub:e.schedule.request}]:[],...e.triggers.map((e,t)=>({id:`start-trigger-${t}`,pick:{kind:`start`,which:{trigger:t}},title:ia(e.on),sub:e.request}))],p=d(f.length,0);f.forEach((e,t)=>l.push({id:e.id,x:p[t].x,y:p[t].y,data:{kind:`start`,pick:e.pick,title:e.title,sub:e.sub,chips:[],selected:oa(r,e.pick)}}));let m=e.limits,h=m.environments?.length?m.environments.join(` · `):`each member's own`,g=m.actions?.length?m.actions.join(` · `):`each member's own`,_=e=>Math.ceil(e/4)*108+24,v=_(f.length);l.push({id:`rules`,x:0,y:v,data:{kind:`rules`,pick:{kind:`rules`},title:`Team rules`,sub:`${h} — ${g}`,chips:[{text:`${m.max_tasks??12} tasks`},...m.parallel&&m.parallel>1?[{text:`${m.parallel} at once`}]:[],...m.max_tokens?[{text:`${Math.round(m.max_tokens/1e3)}k tokens`}]:[]],selected:oa(r,{kind:`rules`})}});for(let e of f)u.push({id:`${e.id}-rules`,source:e.id,target:`rules`});let y=e.knowledge||{},b=a.own||{notes:0,skills:0},x=(e,t)=>`${e} ${t}${e===1?``:`s`}`,S=[y.product?`Product`:``,y.files?.length?x(y.files.length,`file`):``,e.skills?.length?x(e.skills.length,`skill`):``].filter(Boolean),C=[b.skills?x(b.skills,`team skill`):``,b.prompts?x(b.prompts,`prompt`):``,b.rules?x(b.rules,`guardrail set`):``,b.notes?x(b.notes,`note`):``].filter(Boolean);l.push({id:`knowledge`,x:ta,y:v,data:{kind:`knowledge`,pick:{kind:`knowledge`},title:`Knowledge`,sub:S.length||C.length?[...S,...C].join(` · `):`Add what the team should know`,chips:[...S.length?[{text:`Shared`}]:[],...C.length?[{text:`This team only`,tone:`accent`}]:[]],selected:oa(r,{kind:`knowledge`})}});let w=s(e.lead);l.push({id:`lead`,x:0,y:v+na,data:{kind:`lead`,pick:{kind:`lead`},title:w?.name||e.lead||`Pick a lead`,sub:w&&`own`in w&&w.own?`Lead · ${w.own}`:`Lead · plans and hands out tasks`,agent:e.lead||void 0,icon:w?.icon,...w&&`image`in w&&w.image?{image:!0,team:e.id}:{},chips:w?.builtin?[{text:`ForgeQE`}]:w&&!w.approved?[{text:w.state===`draft`?`Draft`:`Not approved`,tone:`warn`}]:[],live:i.get(e.lead),selected:oa(r,{kind:`lead`})}}),u.push({id:`rules-lead`,source:`rules`,target:`lead`,live:i.get(e.lead)===`working`}),u.push({id:`knowledge-lead`,source:`knowledge`,target:`lead`,dashed:!0});let T=[...e.members.map(t=>{let n=s(t.agent),a={kind:`member`,agent:t.agent};return{id:`member-${t.agent}`,data:{kind:`member`,pick:a,title:n?.name||t.agent,sub:n&&`own`in n&&n.own?`${t.role} · ${n.own}`:t.role,agent:t.agent,icon:n?.icon,...n&&`image`in n&&n.image?{image:!0,team:e.id}:{},chips:[...t.after?.length?[{text:`after ${t.after.map(c).join(`, `)}`,tone:`accent`}]:[],...t.asks?.length?[{text:t.asks.includes(`all`)?`can ask any member`:`can ask ${t.asks.map(c).join(`, `)}`}]:[],...t.persona?[{text:`as ${t.persona}`}]:[],...t.instances&&t.instances>1?[{text:`×${t.instances}`,tone:`accent`}]:[],...n?.builtin?[{text:`ForgeQE`}]:[],...n&&!n.approved?[{text:n.state===`draft`?`New · draft`:`Not approved`,tone:`warn`}]:[],...n?[]:[{text:`Missing`,tone:`fail`}]],live:i.get(t.agent),selected:oa(r,a)}}}),...n.map(e=>({id:`gap-${e.area}`,data:{kind:`gap`,pick:{kind:`gap`,area:e.area,role:e.role},title:`Nobody does ${e.role.toLowerCase()}`,sub:`Choose an agent or build one`,chips:[],selected:oa(r,{kind:`gap`,area:e.area,role:e.role})}})),{id:`add`,data:{kind:`add`,pick:{kind:`add`},title:`Add member`,sub:`Choose an agent or build one`,chips:[],selected:oa(r,{kind:`add`})}}],E=v+264,D=d(T.length,E);T.forEach((e,t)=>{l.push({id:e.id,x:D[t].x,y:D[t].y,data:e.data}),u.push({id:`lead-${e.id}`,source:`lead`,target:e.id,live:e.data.live===`working`,dashed:e.data.kind!==`member`})});for(let t of e.members)for(let n of t.after||[])e.members.some(e=>e.agent===n)&&u.push({id:`after-${n}-${t.agent}`,source:`member-${n}`,target:`member-${t.agent}`,handoff:{from:n,to:t.agent},live:i.get(t.agent)===`working`});for(let t of e.members)for(let n of new Set(t.asks||[]))n!==`all`&&n!==t.agent&&e.members.some(e=>e.agent===n)&&u.push({id:`asks-${t.agent}-${n}`,source:`member-${t.agent}`,target:`member-${n}`,dashed:!0,asks:!0});let O=E+_(T.length)+40;l.push({id:`gate`,x:0,y:O,data:{kind:`gate`,pick:{kind:`gate`},title:`A person approves`,sub:m.approve?.length?`${m.approve.join(` · `)}, and every change`:`Every change, and production`,chips:[],selected:oa(r,{kind:`gate`})}});for(let t of e.members)u.push({id:`member-${t.agent}-gate`,source:`member-${t.agent}`,target:`gate`,live:i.get(t.agent)===`working`});e.members.length||u.push({id:`lead-gate`,source:`lead`,target:`gate`}),l.push({id:`end`,x:0,y:O+na,data:{kind:`end`,pick:{kind:`end`},title:`Report`,sub:`One verdict, back to who asked`,chips:e.starters.length?[{text:`${e.starters.length} ${e.starters.length===1?`starter`:`starters`}`}]:[],selected:oa(r,{kind:`end`})}}),u.push({id:`gate-end`,source:`gate`,target:`end`});let k=a.positions||{};for(let e of l){let t=k[e.id];t&&(e.x=t[0],e.y=t[1])}return{nodes:l,edges:u}}var ua=e=>e.builtin?D.find(t=>t.agent===e.id||e.id===`forgeqe`&&t.id===`orchestrator`):void 0,da=[`skills`,`prompts`,`guardrails`,`knowledge`],fa=`text-body-sm font-medium text-ink-2`,pa=(e,t)=>{let n={};for(let[t,r]of Object.entries(e.look?.members||{}))n[t]={...r.name?{name:r.name}:{},...r.icon?{icon:r.icon}:{}};let r=t.member;r&&(n[r.agent]={...n[r.agent],...`name`in r?{name:r.name}:{},...`icon`in r?{icon:r.icon}:{}});let i=`icon`in t?t.icon:e.look?.icon;return{...i?{icon:i}:{},members:n}},ma=e=>[e.lead?.agent,...(e.members||[]).map(e=>e.agent)].filter(Boolean);function ha({title:e,sub:t,onClose:n,children:r,footer:i}){return(0,X.jsxs)(`aside`,{"aria-label":typeof e==`string`?e:`Details`,className:`flex h-full w-full flex-col bg-bg`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-2 border-b border-line px-6 py-4`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsx)(`h2`,{className:`m-0 truncate text-body-lg font-medium text-ink`,children:e}),t&&(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:t})]}),(0,X.jsx)(H,{size:`icon-sm`,variant:`icon`,"aria-label":`Close`,"data-tip":`Close`,onClick:n,children:(0,X.jsx)(Fe,{"aria-hidden":`true`})})]}),(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-6 overflow-y-auto px-6 py-6`,children:r}),i&&(0,X.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 border-t border-line px-6 py-4`,children:i})]})}function Q({id:e,title:t,hint:n,children:r}){return(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`label`,{htmlFor:e,className:fa,children:t}),r,n&&(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:n})]})}function ga({f:e,set:t,view:n,onView:i,onClose:o}){let[s,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(``),f=async e=>{d(``);try{i(await I.look(n.id,pa(n,{icon:e})))}catch(e){d(e.message)}};return(0,X.jsxs)(ha,{title:`The team`,sub:`${e.id} · version ${e.version}`,onClose:o,footer:(0,X.jsxs)(H,{variant:`ghost`,className:`mr-auto text-fail`,onClick:()=>l(!0),children:[(0,X.jsx)(K,{"aria-hidden":`true`}),`Delete team`]}),children:[(0,X.jsxs)(`section`,{"aria-labelledby":`tp-look`,className:`flex flex-col gap-2`,children:[(0,X.jsx)(`h3`,{id:`tp-look`,className:g(fa,`m-0`),children:`Icon or picture`}),(0,X.jsx)(En,{team:n.id,slot:`team`,icon:n.look?.icon,image:n.look?.image,label:`The team`,onIcon:e=>void f(e),onView:i}),u&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 text-body-sm text-fail`,children:u}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:`Shown on its card, page and canvas. Saved at once; nothing to approve.`})]}),(0,X.jsx)(Q,{id:`tp-name`,title:`Name`,children:(0,X.jsx)(a,{id:`tp-name`,value:e.name,maxLength:80,onChange:n=>t({...e,name:n.target.value})})}),(0,X.jsx)(Q,{id:`tp-desc`,title:`What it is for`,hint:`One line, on its card and page.`,children:(0,X.jsx)(a,{id:`tp-desc`,value:e.description,maxLength:300,onChange:n=>t({...e,description:n.target.value})})}),(0,X.jsx)(Q,{id:`tp-purpose`,title:`What the lead is told`,hint:`Guidance for the lead, never a way past the team's rules.`,children:(0,X.jsx)(c,{id:`tp-purpose`,rows:6,maxLength:4e3,value:e.purpose,onChange:n=>t({...e,purpose:n.target.value})})}),s&&(0,X.jsx)(ea,{id:n.id,name:e.name,members:1+e.members.length,onClose:()=>l(!1),onDone:()=>{location.hash=r(`agents`,`category`,`custom`)}})]})}var _a=[{id:`hour`,label:`Every hour`,every:`1h`},{id:`day`,label:`Every day`,every:`1d`},{id:`weekdays`,label:`Weekdays 07:00`,cron:`0 7 * * 1-5`}];function va({f:e,set:t,choices:n,onClose:r}){let i=e.schedule,o=_a.find(e=>e.every&&e.every===i?.every||e.cron&&e.cron===i?.cron)?.id||`day`,[c,u]=(0,Y.useState)(n?.events.find(e=>e===`suite_failed`)||n?.events[0]||`suite_failed`);return(0,X.jsxs)(ha,{title:`How it starts`,sub:`With nobody watching, only what its rules allow goes ahead; anything else waits for a person.`,onClose:r,children:[(0,X.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-2 text-body-md font-medium`,children:[(0,X.jsx)(Ae,{size:16,"aria-hidden":`true`,className:`text-pass`}),`When asked`]}),(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`Always: from its page, a chat with Atlas, or forgeqe team run.`})]}),(0,X.jsxs)(`section`,{className:`flex flex-col gap-4 pt-2`,children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-2 text-body-md font-medium`,children:[(0,X.jsx)(qe,{size:16,"aria-hidden":`true`,className:`text-pass`}),`On a schedule`]}),i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ht,{label:`How often`,options:_a.map(e=>({id:e.id,label:e.label})),value:o,onChange:n=>{let r=_a.find(e=>e.id===n);t({...e,schedule:{...r.every?{every:r.every}:{},...r.cron?{cron:r.cron}:{},request:i.request}})}}),(0,X.jsx)(Q,{id:`sp-request`,title:`What it is asked each time`,children:(0,X.jsx)(a,{id:`sp-request`,value:i.request,maxLength:500,onChange:n=>t({...e,schedule:{...i,request:n.target.value.replace(/[\r\n]+/g,` `)}})})}),(0,X.jsxs)(H,{variant:`ghost`,className:`self-start`,onClick:()=>t({...e,schedule:void 0}),children:[(0,X.jsx)(K,{"aria-hidden":`true`}),`No schedule`]})]}):(0,X.jsxs)(H,{variant:`outline`,className:`self-start`,onClick:()=>t({...e,schedule:{every:`1d`,request:e.starters[0]?.text?.split(`
|
|
6
|
-
`)[0]||`Run the ${e.name} checks`}}),children:[(0,X.jsx)(W,{"aria-hidden":`true`}),`Add a schedule`]})]}),(0,X.jsxs)(`section`,{className:`flex flex-col gap-4 pt-2`,children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-2 text-body-md font-medium`,children:[(0,X.jsx)(ve,{size:16,"aria-hidden":`true`,className:`text-pass`}),`When something happens`]}),e.triggers.map((n,r)=>(0,X.jsxs)(`div`,{className:g(l,`flex flex-col gap-2`),children:[(0,X.jsxs)(`span`,{className:`flex items-center justify-between gap-2 text-body-md font-medium`,children:[ia(n.on),(0,X.jsx)(H,{size:`icon-sm`,variant:`icon`,"aria-label":`Remove: ${ia(n.on)}`,"data-tip":`Remove`,onClick:()=>t({...e,triggers:e.triggers.filter((e,t)=>t!==r)}),children:(0,X.jsx)(K,{"aria-hidden":`true`})})]}),(0,X.jsx)(a,{"aria-label":`What it is asked when ${ia(n.on).toLowerCase()}`,value:n.request,maxLength:500,onChange:n=>t({...e,triggers:e.triggers.map((e,t)=>t===r?{...e,request:n.target.value.replace(/[\r\n]+/g,` `)}:e)})}),(n.on===`pr_opened`||n.on===`pr_updated`||n.on===`push`)&&(0,X.jsx)(a,{"aria-label":`Repository (owner/name)`,placeholder:`owner/name`,value:n.repo||``,onChange:n=>t({...e,triggers:e.triggers.map((e,t)=>t===r?{...e,source:e.source||`github`,repo:n.target.value.trim()}:e)})})]},r)),e.triggers.length<4&&(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(s,{"aria-label":`Event`,size:`sm`,value:c,onChange:e=>u(e.target.value),className:`w-auto`,children:(n?.events||[]).map(e=>(0,X.jsx)(`option`,{value:e,children:ia(e)},e))}),(0,X.jsxs)(H,{size:`sm`,variant:`outline`,onClick:()=>t({...e,triggers:[...e.triggers,{on:c,request:`Find out why: ${ia(c).toLowerCase()}`}]}),children:[(0,X.jsx)(W,{"aria-hidden":`true`}),`Add`]})]})]})]})}var ya={careful:{actions:[`read`],approve:[`run`],repository:`read`,words:`Reads only; asks before every run.`},standard:{actions:[`read`,`run`],approve:[`change`],repository:`read`,words:`Runs tests and apps; asks before any change.`},trusted:{actions:[`read`,`run`,`change`],approve:[`external`],repository:`write`,words:`Also changes test files; asks before other systems.`}},ba=e=>e.limits.actions?.includes(`change`)?`trusted`:e.limits.actions?.includes(`run`)?`standard`:`careful`;function xa({f:e,set:t,choices:n,onClose:r}){let i=e.limits,o=ba(e),s=i.environments||[],c=(e,t,n)=>{let r=Math.round(Number(e));return Number.isFinite(r)&&e.trim()?Math.min(n,Math.max(t,r)):void 0},l=n=>t({...e,limits:{...i,...n}});return(0,X.jsxs)(ha,{title:`Team rules`,sub:`Each member runs its own approved version; these only ever take away from what it may do.`,onClose:r,children:[(0,X.jsxs)(Q,{title:`How much it may do`,children:[(0,X.jsx)(Ht,{label:`How much it may do`,options:[{id:`careful`,label:`Careful`},{id:`standard`,label:`Standard`},{id:`trusted`,label:`Trusted`}],value:o,onChange:e=>l({actions:ya[e].actions,approve:ya[e].approve,repository:ya[e].repository})}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:ya[o].words})]}),(0,X.jsx)(Q,{title:`Environments`,children:(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(n?.environments||[]).map(e=>{let t=s.includes(e.name);return(0,X.jsx)(H,{size:`sm`,variant:`outline`,disabled:e.production,"aria-pressed":t,"data-tip":e.production?`Production is never a team's: its members' own rules decide there.`:void 0,onClick:()=>l({environments:t?s.filter(t=>t!==e.name):[...s,e.name]}),children:e.name},e.name)})})}),(n?.systems||[]).length>0&&(0,X.jsx)(Q,{title:`Other systems`,hint:`Members use their tools; asks before any change there.`,children:(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(n?.systems||[]).map(({name:n,label:r})=>{let i=e.systems||[],a=i.includes(n);return(0,X.jsx)(H,{size:`sm`,variant:`outline`,"aria-pressed":a,onClick:()=>{let r=a?i.filter(e=>e!==n):[...i,n];t({...e,systems:r.length?r:void 0})},children:Br(r||n)},n)})})}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,X.jsx)(Q,{id:`rp-tasks`,title:`Tasks in a run`,children:(0,X.jsx)(a,{id:`rp-tasks`,type:`number`,min:1,max:50,value:i.max_tasks??12,onChange:e=>l({max_tasks:c(e.target.value,1,50)})})}),(0,X.jsx)(Q,{id:`rp-parallel`,title:`Members at once`,children:(0,X.jsx)(a,{id:`rp-parallel`,type:`number`,min:1,max:n?.limits.maxParallel||4,value:i.parallel??1,onChange:e=>l({parallel:c(e.target.value,1,n?.limits.maxParallel||4)})})}),(0,X.jsx)(Q,{id:`rp-tokens`,title:`Token budget`,hint:`For the whole team in one run`,children:(0,X.jsx)(a,{id:`rp-tokens`,type:`number`,min:1e3,step:1e4,placeholder:`No limit`,value:i.max_tokens??``,onChange:e=>l({max_tokens:c(e.target.value,1e3,5e7)})})}),(0,X.jsx)(Q,{id:`rp-minutes`,title:`Minutes`,children:(0,X.jsx)(a,{id:`rp-minutes`,type:`number`,min:1,max:1440,placeholder:`No limit`,value:i.max_minutes??``,onChange:e=>l({max_minutes:c(e.target.value,1,1440)})})})]})]})}function Sa({pick:e,f:t,set:n,choices:o,view:c,onView:l,onClose:u,onPick:d}){let f=e.kind===`lead`?t.lead:e.agent,p=c.look?.members[f],m=ma(c).includes(f),h=o?.agents.find(e=>e.id===f),g=e.kind===`member`?t.members.find(t=>t.agent===e.agent):void 0,_=new Set([t.lead,...t.members.map(e=>e.agent)]),v=r=>{e.kind===`lead`?n({...t,lead:r,members:Ta(t.members,r)}):(n({...t,members:t.members.map(t=>({...t.agent===e.agent?{...t,agent:r}:t,...t.after?.includes(e.agent)?{after:t.after.map(t=>t===e.agent?r:t)}:{},...t.asks?.includes(e.agent)?{asks:t.asks.map(t=>t===e.agent?r:t)}:{}}))}),d({kind:`member`,agent:r}))},y=e=>n({...t,members:t.members.map(t=>t.agent===f?{...t,...e}:t)});return(0,X.jsxs)(ha,{title:p?.name||h?.name||f,sub:p?.name&&e.kind===`lead`?`${h?.name||f} · lead`:p?.name?`${h?.name||f} · ${g?.role||``}`:e.kind===`lead`?`Lead: plans the work and hands each task to a member`:g?.role,onClose:u,footer:(0,X.jsxs)(X.Fragment,{children:[h&&(0,X.jsx)(`a`,{href:ua(h)?i(ua(h)):r(`agents`,`custom`,h.id),className:`mr-auto text-body-md font-medium`,children:`Open the agent`}),e.kind===`member`&&(0,X.jsxs)(H,{variant:`ghost`,onClick:()=>{n({...t,members:Ta(t.members,f)}),d(null)},children:[(0,X.jsx)(K,{"aria-hidden":`true`}),`Remove`]})]}),children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,X.jsx)(Sn,{team:c.id,slot:f,agent:f,icon:p?.icon||h?.icon,image:p?.image,px:64}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[h?.builtin?(0,X.jsx)(B,{tone:`neutral`,icon:!1,children:`ForgeQE's agent`}):h?(0,X.jsx)(B,{tone:hn[h.state].tone,children:hn[h.state].label}):(0,X.jsx)(B,{tone:`fail`,children:`Not in this project`}),h?.description&&(0,X.jsx)(`p`,{className:`m-0 text-body-md text-ink-2 [overflow-wrap:anywhere]`,children:h.description}),h?.builtin&&(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:`It works here within this team's rules: the environments and actions you set in Rules, every change asked of a person.`}),h&&!h.builtin&&h.teams.filter(e=>e!==t.id).length>0&&(0,X.jsxs)(`span`,{className:`text-body-sm text-muted`,children:[`Also in `,h.teams.filter(e=>e!==t.id).join(`, `),`: changing the agent changes those teams too.`]})]})]}),(0,X.jsx)(Ca,{view:c,agent:f,own:h?.name||f,saved:m,onView:l},f),g&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{id:`ap-role`,title:`Its role in this team`,hint:`One line: what the lead hands it.`,children:(0,X.jsx)(a,{id:`ap-role`,value:g.role,maxLength:60,onChange:e=>y({role:e.target.value.replace(/[\r\n]+/g,` `)})})}),(0,X.jsx)(Q,{title:`Works as persona`,children:(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[{id:``,name:`None`,role:``},...o?.personas||[]].map(e=>(0,X.jsxs)(H,{size:`sm`,variant:`outline`,"aria-pressed":(g.persona||``)===e.id,"data-tip":e.role||void 0,onClick:()=>y({persona:e.id||void 0}),className:`gap-1`,children:[e.id&&(0,X.jsx)(U,{size:12,"aria-hidden":`true`}),e.name]},e.id||`none`))})}),t.members.length>1&&(0,X.jsx)(Q,{title:`Works after`,hint:`It waits for each one picked to finish a task, and the lead passes on what they found. Draw a line between two members on the canvas to do the same.`,children:(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,X.jsx)(V,{items:t.members.filter(e=>e.agent!==f).map(e=>{let n=!g.after?.includes(e.agent)&&sa(t,e.agent,f);return{id:e.agent,label:o?.agents.find(t=>t.id===e.agent)?.name||e.agent,...n?{note:`waits for it`,noteClass:`text-muted`,title:`${e.agent} already waits for this member, so this would be a circle.`}:{}}}),value:g.after||[],onChange:e=>{let n=e.filter(e=>g.after?.includes(e)||!sa(t,e,f));y({after:n.length?n:void 0})}})})}),t.members.length>1&&(0,X.jsx)(Q,{title:`Can ask`,hint:`While it works, it may ask each one picked for help, such as test data or a load test. Each request is that member's own task, within the team's rules.`,children:(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,X.jsx)(V,{items:[{id:`all`,label:`Any member`,title:`Every other member, including ones added later.`},...t.members.filter(e=>e.agent!==f).map(e=>({id:e.agent,label:o?.agents.find(t=>t.id===e.agent)?.name||e.agent}))],value:g.asks||[],onChange:e=>y({asks:wa(g.asks||[],e)})})})}),(0,X.jsx)(Q,{title:`Copies at once`,hint:`Each copy works on its own task, as its own run.`,children:(0,X.jsx)(Ht,{label:`Copies at once`,options:Array.from({length:o?.limits.maxInstances||3},(e,t)=>({id:String(t+1),label:`×${t+1}`})),value:String(g.instances||1),onChange:e=>y({instances:Number(e)>1?Number(e):void 0})})}),(0,X.jsx)(Q,{id:`ap-focus`,title:`Focus (optional)`,children:(0,X.jsx)(a,{id:`ap-focus`,value:g.focus||``,maxLength:200,placeholder:`The payments endpoints`,onChange:e=>y({focus:e.target.value.replace(/[\r\n]+/g,` `)||void 0})})})]}),(0,X.jsx)(Q,{id:`ap-swap`,title:e.kind===`lead`?`Another agent as lead`:`Another agent in its place`,children:(0,X.jsxs)(s,{id:`ap-swap`,value:``,onChange:e=>e.target.value&&v(e.target.value),children:[(0,X.jsx)(`option`,{value:``,children:`Choose an agent…`}),(o?.agents||[]).filter(e=>!_.has(e.id)&&e.state!==`invalid`).map(e=>(0,X.jsxs)(`option`,{value:e.id,children:[e.name,e.approved?``:` (not approved yet)`]},e.id))]})})]})}function Ca({view:e,agent:t,own:n,saved:r,onView:i}){let o=e.look?.members[t],[s,c]=(0,Y.useState)(o?.name||``),[l,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(!1),p=async n=>{u(``),f(!1);try{i(await I.look(e.id,pa(e,{member:{agent:t,...n}}))),f(!0)}catch(e){u(e.message)}};return r?(0,X.jsxs)(`section`,{"aria-labelledby":`look-${t}`,className:`flex flex-col gap-4`,children:[(0,X.jsx)(`h3`,{id:`look-${t}`,className:Ea,children:`In this team`}),(0,X.jsx)(Q,{id:`name-${t}`,title:`Name`,hint:d?`Saved.`:`Its own name, ${n}, stays everywhere else.`,children:(0,X.jsx)(a,{id:`name-${t}`,value:s,maxLength:40,placeholder:n,onChange:e=>c(e.target.value),onBlur:()=>{s.trim()!==(o?.name||``)&&p({name:s.trim()})},onKeyDown:e=>{x(e)&&e.target.blur()}})}),(0,X.jsx)(En,{team:e.id,slot:t,agent:t,icon:o?.icon,image:o?.image,label:o?.name||n,face:!1,onIcon:e=>void p({icon:e}),onView:i}),l&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 text-body-sm text-fail`,children:l})]}):(0,X.jsxs)(`p`,{className:g(L.info,`m-0 text-body-sm`),children:[`Save the team, then give `,n,` a name, icon or picture in this team.`]})}function wa(e,t){let n=t.find(t=>!e.includes(t)),r=n===`all`?[`all`]:n?t.filter(e=>e!==`all`):t;return r.length?r:void 0}function Ta(e,t){return e.filter(e=>e.agent!==t).map(e=>{let n=e.after?.filter(e=>e!==t),r=e.asks?.filter(e=>e!==t);return{...e,after:n?.length?n:void 0,asks:r?.length?r:void 0}})}var Ea=`m-0 flex items-center gap-2 text-body-md font-medium text-ink`;function Da({f:e,set:t,choices:n,view:r,onView:i,onClose:a}){let[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(`team`),m=e.knowledge||{},h=m.files||[],_=n=>{let r={...m,...n};t({...e,knowledge:r.files?.length||r.product?{...r.files?.length?{files:r.files}:{},...r.product?{product:!0}:{}}:void 0})},v=(n?.knowledge||[]).filter(e=>!o.trim()||`${e.file} ${e.title}`.toLowerCase().includes(o.trim().toLowerCase())),y=r.own,b=da.reduce((e,t)=>e+(y[t]?.length||0),0);return(0,X.jsxs)(ha,{title:`Knowledge`,sub:`What every agent of this team knows while it works in it.`,onClose:a,children:[r.drift&&r.drift.length>0&&(0,X.jsxs)(`p`,{role:`status`,className:g(L.warn,`m-0 flex gap-2`),children:[(0,X.jsx)(Ie,{size:16,"aria-hidden":`true`,className:`mt-1 flex-none`}),`It changed since the team was approved (`,r.drift.join(`; `),`). The team does not run until a person approves it again in Publish.`]}),(0,X.jsx)(Ht,{label:`Whose knowledge`,value:f,onChange:p,options:[{id:`team`,label:`This team only`,n:b},{id:`shared`,label:`Shared from ForgeQE`,n:+!!m.product+h.length+(e.skills?.length||0)}]}),f===`team`&&(0,X.jsxs)(`section`,{"aria-labelledby":`kp-own`,className:`flex flex-col gap-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsxs)(`h3`,{id:`kp-own`,className:Ea,children:[(0,X.jsx)(U,{size:16,"aria-hidden":`true`}),`This team only`]}),(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`Skills, prompts, guardrails and notes written for this team. Only its agents get them; no other agent sees them. They also show under Teams in Settings › Skills, Prompts and Guardrails.`})]}),u&&(0,X.jsx)(`p`,{role:`status`,className:g(L.info,`m-0`),children:u}),b>0&&(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:da.filter(e=>y[e]?.length).map(t=>(0,X.jsxs)(`div`,{className:`flex flex-col`,children:[(0,X.jsx)(`span`,{className:`px-4 text-body-sm font-medium text-muted`,children:nr[t].many.charAt(0).toUpperCase()+nr[t].many.slice(1)}),y[t].map(n=>(0,X.jsx)(tr,{kind:t,item:n,compact:!0,onOpen:()=>l(er(t,e.id,n))},n.name))]},t))}),y.problems.length>0&&(0,X.jsxs)(`p`,{className:`m-0 text-body-sm text-warn [overflow-wrap:anywhere]`,children:[`Not used: `,y.problems.join(`; `)]}),(0,X.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:da.map(t=>{let n=nr[t];return(0,X.jsxs)(H,{size:`sm`,variant:`outline`,className:`justify-start`,onClick:()=>(d(``),l(Qn(t,e.id))),children:[(0,X.jsx)(n.icon,{"aria-hidden":`true`}),`Add a `,t===`guardrails`?`guardrail`:n.one]},t)})}),(0,X.jsx)($n,{draft:c,teams:[{id:e.id,name:e.name}],taken:(n?.skills||[]).map(e=>e.name),onClose:()=>l(null),onSaved:(e,t)=>{l(null),d(t),i(e)}})]}),f===`shared`&&(0,X.jsxs)(`section`,{"aria-labelledby":`kp-shared`,className:`flex flex-col gap-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsxs)(`h3`,{id:`kp-shared`,className:Ea,children:[(0,X.jsx)(lt,{size:16,"aria-hidden":`true`}),`Shared from ForgeQE`]}),(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`The project's own knowledge, which any agent can be given. Picked here, every agent of this team gets it.`})]}),(0,X.jsxs)(`div`,{className:g(`rounded-base bg-surface-muted p-4`,`flex items-start gap-4`),children:[(0,X.jsx)(Xt,{icon:St}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,X.jsx)(`label`,{htmlFor:`kp-product`,className:`text-body-md font-medium text-ink`,children:`Product knowledge`}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:n?.product?`How the product works, from its repositories and documents. Read only.`:`Set up product repositories first, in Settings › Product knowledge.`})]}),(0,X.jsx)(Pt,{id:`kp-product`,label:`Product knowledge`,checked:!!m.product,disabled:!n?.product&&!m.product,onChange:e=>_({product:e})})]}),(0,X.jsxs)(Q,{id:`kp-files`,title:`Knowledge files${h.length?` · ${h.length} picked`:``}`,children:[(n?.knowledge.length||0)>6&&(0,X.jsx)(oe,{id:`kp-files`,value:o,onChange:s,placeholder:`Find a file`,label:`Find a knowledge file`,className:`flex-none`}),n&&n.knowledge.length===0?(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:`The project has no knowledge files yet (.forgeqe/knowledge).`}):(0,X.jsx)(`ul`,{className:`m-0 flex max-h-56 list-none flex-col overflow-y-auto p-0`,children:v.slice(0,60).map(e=>{let t=h.includes(e.file);return(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>_({files:t?h.filter(t=>t!==e.file):[...h,e.file]}),className:g(`flex w-full min-h-11 cursor-pointer items-center gap-4 rounded-base border-0 bg-transparent px-4 py-2 text-left text-body-sm text-ink no-underline transition-colors duration-150 hover:bg-tint hover:text-ink aria-[current]:bg-tint-hover aria-selected:bg-tint-hover aria-pressed:bg-tint-hover aria-checked:bg-tint-hover has-[:checked]:bg-tint-hover disabled:cursor-not-allowed disabled:opacity-50`,`gap-2 text-body-md`),children:[(0,X.jsx)(wt,{size:16,"aria-hidden":`true`,className:t?`text-accent-fg`:`text-muted`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-ink`,children:e.title}),(0,X.jsx)(`span`,{className:`truncate text-body-sm text-muted`,children:e.file}),t&&(0,X.jsx)(G,{size:16,"aria-hidden":`true`,className:`flex-none text-accent-fg`})]})},e.file)})})]}),(n?.skills.length||0)>0&&(0,X.jsx)(Q,{title:`Skills${e.skills?.length?` · ${e.skills.length} picked`:``}`,children:(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,X.jsx)(V,{items:(n?.skills||[]).map(e=>({id:e.name,label:e.name,title:e.description||void 0})),value:e.skills||[],onChange:n=>t({...e,skills:n.length?n:void 0})})})})]})]})}function Oa({f:e,onClose:t,onRules:n}){return(0,X.jsxs)(ha,{title:`A person approves`,sub:`Kept in code on every call, whatever any agent says.`,onClose:t,children:[(0,X.jsxs)(`ul`,{className:`m-0 flex list-none flex-col gap-4 p-0 text-body-md`,children:[(0,X.jsxs)(`li`,{className:`flex gap-2`,children:[(0,X.jsx)(Ze,{size:16,"aria-hidden":`true`,className:`mt-1 flex-none text-accent-fg`}),`Every change to files or other systems, unless a member's own approved version lets it go ahead.`]}),(e.limits.approve||[]).length>0&&(0,X.jsxs)(`li`,{className:`flex gap-2`,children:[(0,X.jsx)(Ze,{size:16,"aria-hidden":`true`,className:`mt-1 flex-none text-accent-fg`}),`On top of each member's own: `,(e.limits.approve||[]).join(`, `),`.`]}),(0,X.jsxs)(`li`,{className:`flex gap-2`,children:[(0,X.jsx)(Ze,{size:16,"aria-hidden":`true`,className:`mt-1 flex-none text-accent-fg`}),`Anything in production, always.`]}),(0,X.jsxs)(`li`,{className:`flex gap-2`,children:[(0,X.jsx)(mt,{size:16,"aria-hidden":`true`,className:`mt-1 flex-none text-accent-fg`}),`With nobody watching, a question waits for a person; no answer in time is a no.`]})]}),(0,X.jsx)(H,{variant:`outline`,className:`self-start`,onClick:n,children:`Change the team's rules`})]})}function ka({f:e,set:t,onClose:n}){return(0,X.jsx)(ha,{title:`Report`,sub:`The lead ends each run with one report: each task, who did it, how it went, and the verdict. It goes back to whoever asked, and stays on the run's board.`,onClose:n,children:(0,X.jsx)(Q,{title:`Starters`,hint:`Requests people pick when they ask the team.`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.starters.map((n,r)=>(0,X.jsxs)(`div`,{className:g(l,`flex flex-col gap-2`),children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(a,{"aria-label":`Starter's label`,size:`sm`,value:n.label,maxLength:60,onChange:n=>t({...e,starters:e.starters.map((e,t)=>t===r?{...e,label:n.target.value}:e)})}),(0,X.jsx)(H,{size:`icon-sm`,variant:`icon`,"aria-label":`Remove the starter ${n.label}`,"data-tip":`Remove`,onClick:()=>t({...e,starters:e.starters.filter((e,t)=>t!==r)}),children:(0,X.jsx)(K,{"aria-hidden":`true`})})]}),(0,X.jsx)(c,{"aria-label":`What the starter asks`,rows:2,maxLength:500,value:n.text,onChange:n=>t({...e,starters:e.starters.map((e,t)=>t===r?{...e,text:n.target.value}:e)})})]},r)),e.starters.length<8&&(0,X.jsxs)(H,{variant:`outline`,className:`self-start`,onClick:()=>t({...e,starters:[...e.starters,{label:`New starter`,text:``}]}),children:[(0,X.jsx)(W,{"aria-hidden":`true`}),`Add a starter`]})]})})})}var Aa=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|(?<!-)-+$/g,``).replace(/^[^a-z]+/,``).slice(0,40).replace(/(?<!-)-+$/,``);function ja({gap:e,f:t,set:n,choices:r,onClose:i,onAdded:a,reloadChoices:o}){let[s,c]=(0,Y.useState)(`choose`),[l,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(`all`),p=r?.agents||[],m=new Set([t.lead,...t.members.map(e=>e.agent)]),h=t=>e?`${t.name} ${t.description} ${t.capabilities.join(` `)}`.toLowerCase().includes(e.area):!1,_=p.filter(e=>d===`all`||d===`forgeqe`===e.builtin).filter(e=>!l.trim()||`${e.name} ${e.description}`.toLowerCase().includes(l.trim().toLowerCase())).sort((e,t)=>Number(h(t))-Number(h(e))||Number(t.approved)-Number(e.approved)||e.name.localeCompare(t.name)),v=(e,r)=>{n({...t,members:[...t.members,{agent:e,role:r.slice(0,60)}]}),a(e)};return(0,X.jsxs)(ha,{title:`Add a member`,sub:e?`To fill: nobody does ${e.role.toLowerCase()}`:`One of ForgeQE's agents, one of your own, or a new one built for this team`,onClose:i,children:[(0,X.jsx)(Ht,{label:`How to add`,options:[{id:`choose`,label:`Choose an agent`},{id:`build`,label:`Build a new one`}],value:s,onChange:c}),s===`choose`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(oe,{id:`team-add-search`,label:`Find an agent`,value:l,onChange:u,className:`max-w-none flex-none`}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,X.jsx)(ae,{items:[{id:`all`,label:`All`,n:p.length},{id:`forgeqe`,label:`ForgeQE's agents`,n:p.filter(e=>e.builtin).length},{id:`custom`,label:`Your custom agents`,n:p.filter(e=>!e.builtin).length}],value:d,onChange:f})}),_.length===0?(0,X.jsx)(ie,{className:`py-4`,children:`No agent matches. Build a new one instead.`}):(0,X.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:_.map((n,r)=>{let i=m.has(n.id),a=n.state===`invalid`||n.state===`disabled`;return(0,X.jsxs)(`li`,{className:g(`flex items-center gap-4 py-2`,r>0&&`border-t border-line-soft`,(i||a)&&`opacity-60`),children:[(0,X.jsx)(b,{agent:n.id,icon:n.icon,px:40,decorative:!0}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,X.jsx)(`span`,{className:`truncate text-body-md font-medium text-ink`,children:n.name}),(0,X.jsx)(`span`,{className:`truncate text-body-sm text-muted`,children:n.description||n.id}),(0,X.jsxs)(`span`,{className:`flex flex-wrap gap-x-2 text-body-sm`,children:[h(n)&&(0,X.jsx)(`span`,{className:`font-medium text-accent-fg`,children:`Good fit`}),(0,X.jsx)(`span`,{className:`text-muted`,children:n.builtin?`ForgeQE's agent`:`Your custom agent`}),n.teams.filter(e=>e!==t.id).length>0&&(0,X.jsxs)(`span`,{className:`text-muted`,children:[`in `,n.teams.filter(e=>e!==t.id).length,` other`,` `,n.teams.filter(e=>e!==t.id).length===1?`team`:`teams`]})]})]}),i?(0,X.jsx)(B,{tone:`neutral`,icon:!1,children:`In the team`}):a?(0,X.jsx)(B,{tone:`fail`,icon:!1,children:hn[n.state].label}):(0,X.jsxs)(H,{size:`sm`,variant:`outline`,onClick:()=>v(n.id,e?.role||n.description||n.name),children:[(0,X.jsx)(W,{"aria-hidden":`true`}),`Add`]})]},n.id)})})]}):(0,X.jsx)(Ma,{gap:e,f:t,onBuilt:async(e,t)=>(await o(),v(e,t))})]})}function Ma({gap:e,f:t,onBuilt:n}){let[r,i]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(e?`${e.role.replace(/ (checks|testing)$/i,``)} agent`:``),[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)([]),[m,h]=(0,Y.useState)(e?.area||``),[_,v]=(0,Y.useState)(!1),[y,b]=(0,Y.useState)(``);(0,Y.useEffect)(()=>{M.choices().then(i,e=>b(e.message))},[]);let x=(0,Y.useMemo)(()=>(r?.capabilities||[]).filter(e=>!m.trim()||`${e.title} ${e.summary} ${e.area}`.toLowerCase().includes(m.trim().toLowerCase())).slice(0,12),[r,m]),S=async()=>{if(!r)return;v(!0),b(``);let i=r.capabilities.filter(e=>f.includes(e.id)),a=[...new Set([`read`,...i.flatMap(e=>e.actions)])].filter(e=>t.limits.actions?.length?t.limits.actions.includes(e):e===`read`||e===`run`),s={id:Aa(o)||`team-member`,name:o.trim(),version:`1.0.0`,description:u.trim().split(`
|
|
7
|
-
`)[0].slice(0,300),instructions:u.trim(),scope:{agents:[...new Set(i.flatMap(e=>e.starts))],capabilities:f,skills:[],knowledge:[],environments:t.limits.environments?.length?t.limits.environments:r.environments.filter(e=>!e.production).map(e=>e.name)},permissions:{repository:`read`,actions:a,approve:a.includes(`change`)?[`change`]:[]},runtime:{maxDelegationDepth:1},policies:[],starters:[]};try{await n((await M.save(s,{create:!0})).id,e?.role||o.trim())}catch(e){b(e.message),v(!1)}};return(0,X.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,X.jsxs)(`div`,{className:g(l,`flex items-start gap-4 text-body-sm text-ink-2`),children:[(0,X.jsx)(_t,{size:16,"aria-hidden":`true`,className:`mt-1 flex-none text-accent-fg`}),(0,X.jsxs)(`span`,{children:[`Kept to the team's rules from the start:`,` `,t.limits.environments?.join(`, `)||`the project's test environments`,`; it may `,(t.limits.actions||[`read`,`run`]).join(`, `),`. It is saved as a draft custom agent, and approved in Publish.`]})]}),(0,X.jsx)(Q,{id:`bm-name`,title:`Name`,children:(0,X.jsx)(a,{id:`bm-name`,value:o,maxLength:80,placeholder:`Accessibility checker agent`,onChange:e=>s(e.target.value)})}),(0,X.jsx)(Q,{id:`bm-what`,title:`What should it do?`,children:(0,X.jsx)(c,{id:`bm-what`,rows:4,maxLength:2e3,value:u,placeholder:`Check the basket and checkout pages against WCAG 2.2 AA, keyboard only.`,onChange:e=>d(e.target.value)})}),(0,X.jsxs)(Q,{title:`What it can use`,hint:f.length?`${f.length} picked`:`Pick at least one`,children:[(0,X.jsx)(oe,{id:`bm-caps`,label:`Find a capability`,value:m,onChange:h,className:`max-w-none flex-none`}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:x.map(e=>{let t=f.includes(e.id);return(0,X.jsx)(H,{size:`sm`,variant:`outline`,"aria-pressed":t,"data-tip":e.summary,onClick:()=>p(t?f.filter(t=>t!==e.id):[...f,e.id]),children:e.title},e.id)})})]}),y&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 text-body-md text-fail [overflow-wrap:anywhere]`,children:y}),(0,X.jsxs)(H,{variant:`primary`,className:`self-end`,disabled:_||!r||!o.trim()||!u.trim()||!f.length,onClick:()=>void S(),children:[(0,X.jsx)(we,{"aria-hidden":`true`}),`Save and add`]})]})}function Na({view:e,f:t,dirty:n,onClose:i}){let[a,o]=(0,Y.useState)(t.starters[0]?.text||``),[s,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(``),m=async()=>{l(!0),p(``);try{let{request:t}=await I.try(e.id,a.trim()),{id:n}=await re.start(t,{});d(n)}catch(e){p(e.message)}finally{l(!1)}};return(0,X.jsxs)(ha,{title:`Preview`,sub:`Try the team as its file is now. Every agent only reads and runs, and you approve each run in the chat.`,onClose:i,children:[n&&(0,X.jsxs)(`p`,{role:`status`,className:g(L.warn,`m-0 flex items-start gap-2`),children:[(0,X.jsx)(Ie,{size:16,"aria-hidden":`true`,className:`mt-1 flex-none`}),`Save first: a preview runs the saved file.`]}),t.starters.length>0&&(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.starters.map((e,t)=>(0,X.jsx)(H,{size:`sm`,variant:`outline`,onClick:()=>o(e.text),children:e.label},t))}),(0,X.jsx)(Q,{id:`pv-words`,title:`What should the team try?`,children:(0,X.jsx)(c,{id:`pv-words`,rows:4,maxLength:4e3,value:a,onChange:e=>o(e.target.value)})}),f&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 text-body-md text-fail [overflow-wrap:anywhere]`,children:f}),u?(0,X.jsxs)(`div`,{role:`status`,className:g(L.info,`flex flex-col gap-2`),children:[(0,X.jsx)(`span`,{className:`font-medium text-ink`,children:`The preview is running.`}),(0,X.jsx)(`span`,{className:`text-ink-2`,children:`The canvas lights up as each agent works. Approve its runs in the chat.`}),(0,X.jsx)(`a`,{href:r(`chats`,u),className:`self-start font-medium`,children:`Open the chat`})]}):(0,X.jsxs)(H,{variant:`primary`,className:`self-end`,disabled:s||n||!a.trim(),onClick:()=>void m(),children:[(0,X.jsx)(He,{"aria-hidden":`true`}),`Run the preview`]})]})}function Pa({view:e,f:t,choices:n,dirty:i,onClose:o,onApproveTeam:s,reloadChoices:c}){let u=[t.lead,...t.members.map(e=>e.agent)].map(e=>({id:e,a:n?.agents.find(t=>t.id===e)})).filter(e=>!e.a?.approved),[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(``),[h,_]=(0,Y.useState)(``),[v,y]=(0,Y.useState)(!1),x=e.working&&(e.state===`draft`||e.state===`changed`||e.state===`broken`||e.state===`drifted`),S=async e=>{y(!0),_(``);try{await M.act(e,`approve`,{confirm:p}),f(null),m(``),await c()}catch(e){_(e.message)}finally{y(!1)}};return(0,X.jsxs)(ha,{title:`Publish`,sub:`What runs is only what a person approves, each with its id typed. Commit .forgeqe/agents so your team has it.`,onClose:o,children:[i&&(0,X.jsxs)(`p`,{role:`status`,className:g(L.warn,`m-0 flex items-start gap-2`),children:[(0,X.jsx)(Ie,{size:16,"aria-hidden":`true`,className:`mt-1 flex-none`}),`Save first: what is approved is the saved file.`]}),(0,X.jsxs)(`ol`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:[u.map((e,t)=>(0,X.jsxs)(`li`,{className:g(l,`flex flex-col gap-2`),children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-4`,children:[(0,X.jsx)(`span`,{className:`text-body-sm text-muted tabular-nums`,children:t+1}),(0,X.jsx)(b,{agent:e.id,icon:e.a?.icon,px:32,decorative:!0}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,X.jsx)(`span`,{className:`truncate text-body-md font-medium`,children:e.a?.name||e.id}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:e.a?hn[e.a.state].label:`Not in this project`})]}),e.a&&d!==e.id&&(0,X.jsx)(H,{size:`sm`,variant:`outline`,onClick:()=>(f(e.id),m(``),_(``)),children:`Approve`})]}),d===e.id&&(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(a,{"aria-label":`Type ${e.id} to confirm`,size:`sm`,placeholder:`Type ${e.id}`,value:p,autoComplete:`off`,spellCheck:!1,onChange:e=>m(e.target.value),className:`w-auto flex-1`}),(0,X.jsxs)(H,{size:`sm`,variant:`primary`,disabled:v||p!==e.id,onClick:()=>void S(e.id),children:[(0,X.jsx)(G,{"aria-hidden":`true`}),`Approve`]}),(0,X.jsx)(`a`,{href:r(`agents`,`custom`,e.id),className:`text-body-sm font-medium`,children:`See what it may do`})]})]},e.id)),(0,X.jsxs)(`li`,{className:g(l,`flex items-center gap-4`),children:[(0,X.jsx)(`span`,{className:`text-body-sm text-muted tabular-nums`,children:u.length+1}),(0,X.jsx)(U,{size:24,"aria-hidden":`true`,className:`text-accent-fg`}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,X.jsx)(`span`,{className:`truncate text-body-md font-medium`,children:t.name}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:u.length?`Waits for ${u.length} ${u.length===1?`agent`:`agents`}`:x?`Version ${e.fileVersion||t.version} is ready to approve`:e.approvedVersion?`Version ${e.approvedVersion} runs`:`Fix its file first`})]}),(0,X.jsxs)(H,{size:`sm`,variant:`primary`,disabled:i||!x||u.length>0,onClick:s,children:[(0,X.jsx)(G,{"aria-hidden":`true`}),`Approve`]})]})]}),h&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 text-body-md text-fail [overflow-wrap:anywhere]`,children:h})]})}var Fa=[{label:`Release check`,goal:`Check each release candidate end to end on qa: the API, the main pages as a customer, and give one verdict.`},{label:`PR gate`,goal:`Review a pull request's tests and run the impacted ones on qa, then say whether it can merge.`},{label:`Regression triage`,goal:`Sort the last suite's failures into flaky tests, product bugs and test bugs, with evidence for each.`},{label:`Accessibility sweep`,goal:`Check the main pages for accessibility against WCAG 2.2 AA, keyboard only, and list what to fix first.`},{label:`New feature tests`,goal:`Turn a new story into test cases, then check the feature on qa against them.`}],Ia=`forgeqe.team.proposal.`;function La(e){try{let t=sessionStorage.getItem(Ia+e);if(!t)return null;sessionStorage.removeItem(Ia+e);let n=JSON.parse(t);return{gaps:Array.isArray(n.gaps)?n.gaps.filter(e=>!!e&&typeof e.area==`string`&&typeof e.role==`string`&&/^[a-z]{1,20}$/.test(e.area)).map(e=>({area:e.area,role:e.role.slice(0,60)})):[],...n.by===`model`||n.by===`words`?{by:n.by}:{}}}catch{return null}}function Ra(){let[e,t]=(0,Y.useState)(``),[n,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{I.list().then(e=>c(e.teams),()=>c([]))},[]);let l=async()=>{if(e.trim()&&!n){i(!0),o(``);try{let t=await I.propose(e.trim());if(!t.fields.lead){o(t.empty||`No agent can lead this team yet: build one, or check that custom agents are on.`),i(!1);return}let n=await I.create(t.fields);try{sessionStorage.setItem(Ia+n.id,JSON.stringify({gaps:t.gaps,by:t.by}))}catch{}location.hash=r(`agents`,`teams`,n.id)}catch(e){o(e.message),i(!1)}}};return(0,X.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,X.jsx)(Gt,{}),(0,X.jsxs)(`main`,{className:`mx-auto box-border flex w-full max-w-[880px] flex-auto flex-col gap-10 px-6 pt-8 pb-16`,children:[(0,X.jsx)(se,{to:{href:r(`agents`,`category`,`custom`),label:`Custom agents`}}),(0,X.jsxs)(`section`,{"aria-labelledby":`ts-title`,className:`flex flex-col items-center gap-6 text-center`,children:[(0,X.jsx)(Xt,{icon:U,size:`xl`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`h1`,{id:`ts-title`,className:`m-0 text-headline-lg`,children:`Build a team`}),(0,X.jsx)(`p`,{className:`m-0 text-body-lg text-ink-2`,children:`Say what the team should do. ForgeQE picks a lead and members from its own agents and yours, in any mix; you shape it on the canvas.`})]}),(0,X.jsxs)(`form`,{className:g(d,`flex w-full flex-col gap-2 text-left focus-within:shadow-focus`),onSubmit:e=>{e.preventDefault(),l()},children:[(0,X.jsx)(`label`,{htmlFor:`ts-goal`,className:`sr-only`,children:`What should this team do?`}),(0,X.jsx)(`textarea`,{id:`ts-goal`,rows:3,maxLength:1e3,value:e,placeholder:`What should this team do?`,onChange:e=>t(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!S(e)&&(e.preventDefault(),l())},className:`min-h-20 w-full resize-none border-0 bg-transparent text-body-lg text-ink outline-none placeholder:text-muted`}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:n?`Captain is drafting a team from ForgeQE's agents and yours…`:`Enter to build it`}),(0,X.jsx)(H,{size:`icon`,variant:`primary`,type:`submit`,disabled:n||!e.trim(),"aria-label":`Build the team`,"data-tip":`Build the team`,children:(0,X.jsx)(He,{"aria-hidden":`true`})})]})]}),(0,X.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:Fa.map(e=>(0,X.jsx)(H,{size:`sm`,variant:`outline`,onClick:()=>t(e.goal),children:e.label},e.label))}),a&&(0,X.jsxs)(`p`,{role:`alert`,className:`m-0 flex flex-wrap items-center justify-center gap-2 text-body-md text-fail [overflow-wrap:anywhere]`,children:[a,(0,X.jsx)(`a`,{href:r(`agents`,`custom`,`new`),className:`font-medium`,children:`Build an agent`})]})]}),s&&s.length>0&&(0,X.jsxs)(`section`,{"aria-labelledby":`ts-teams`,className:`flex flex-col gap-4`,children:[(0,X.jsx)(ln,{id:`ts-teams`,icon:U,title:`Your teams`}),(0,X.jsx)(`ul`,{className:`m-0 grid list-none grid-cols-1 gap-4 p-0 sm:grid-cols-2`,children:s.map(e=>(0,X.jsx)(`li`,{className:`flex`,children:(0,X.jsxs)(`a`,{href:r(`agents`,`teams`,e.id),className:g(`surface rounded-lg bg-bg p-6 shadow-sm`,`group flex w-full flex-col gap-4 text-ink no-underline focus-visible:outline-2 focus-visible:outline-accent`),children:[(0,X.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`flex items-center`,children:(e.agents||[]).slice(0,5).map((t,n)=>(0,X.jsx)(`span`,{className:g(`inline-flex rounded-full ring-2 ring-bg`,n>0&&`-ml-2`),children:(0,X.jsx)(Sn,{team:e.id,slot:t.agent,agent:t.agent,icon:t.icon,image:t.image,px:32})},t.agent))}),(0,X.jsx)(B,{tone:hn[e.state].tone,icon:!1,children:hn[e.state].label})]}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(e.look?.icon||e.look?.image)&&(0,X.jsx)(Sn,{team:e.id,slot:`team`,icon:e.look.icon,image:e.look.image,px:28}),(0,X.jsx)(`span`,{className:`truncate text-body-lg font-medium group-hover:underline`,children:e.name})]}),(0,X.jsx)(`span`,{className:`line-clamp-2 text-body-sm text-muted`,children:e.description})]})]})},e.id))})]})]})]})}var za={working:`bg-accent`,done:`bg-pass`,failed:`bg-fail`,queued:`bg-muted`,stopped:`bg-muted`,waiting:`bg-warn`},Ba={working:`Working`,done:`Done`,failed:`Failed`,queued:`Waiting its turn`,stopped:`Stopped`,waiting:`Needs a person`},Va={asked:{icon:Ae,tone:`pass`},schedule:{icon:qe,tone:`pass`},trigger:{icon:je,tone:`pass`},rules:{icon:Ze,tone:`warn`},knowledge:{icon:fe,tone:`info`},gate:{icon:Ze,tone:`info`},end:{icon:Je}},Ha=e=>e.kind===`start`?e.pick.kind===`start`&&e.pick.which===`asked`?Va.asked:e.pick.kind===`start`&&e.pick.which===`schedule`?Va.schedule:Va.trigger:Va[e.kind],Ua={start:`Start`,rules:`Guardrail`,knowledge:`Every agent`,lead:`Lead agent`,member:`Agent`,gate:`Approval`,end:`End`};function Wa({data:e}){let t=e.kind===`member`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Rn,{type:`target`,position:Vn.Top,isConnectable:!1,className:`!pointer-events-none !opacity-0`}),t&&(0,X.jsx)(Rn,{id:`in`,type:`target`,position:Vn.Left,className:`!size-3 !border-2 !border-bg !bg-accent`}),(0,X.jsx)(Ga,{d:e}),t&&(0,X.jsx)(Rn,{id:`out`,type:`source`,position:Vn.Right,title:`Drag to another member: it works after this one`,className:`!size-3 !border-2 !border-bg !bg-accent`}),(0,X.jsx)(Rn,{type:`source`,position:Vn.Bottom,isConnectable:!1,className:`!pointer-events-none !opacity-0`})]})}function Ga({d:e,wide:t=!1}){let n=Ha(e),r=e.kind===`gap`||e.kind===`add`;return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>e.onPick(e.pick),className:g(r?`rounded-lg border-2 border-dashed border-line-strong bg-transparent hover:bg-surface-muted`:g(d,`border-0 hover:shadow-md`),`flex w-full cursor-pointer items-center gap-4 px-4 py-2 text-left transition-shadow focus-visible:outline-2 focus-visible:outline-accent`,e.selected&&`ring-2 ring-accent`,e.kind===`gap`&&`border-warn`),style:t?void 0:{width:248},children:[e.agent?(0,X.jsxs)(`span`,{className:`relative flex-none`,children:[e.image?(0,X.jsx)(Sn,{team:e.team,slot:e.agent,agent:e.agent,icon:e.icon,image:!0,px:40}):(0,X.jsx)(b,{agent:e.agent,icon:e.icon,px:40,decorative:!0,working:e.live===`working`}),e.live&&(0,X.jsx)(`span`,{"aria-hidden":`true`,className:g(`absolute -right-1 -bottom-1 size-3 rounded-full border-2 border-bg`,za[e.live],e.live===`working`&&`animate-pulse`)})]}):r?(0,X.jsx)(Xt,{icon:W,size:`lg`}):(0,X.jsx)(Xt,{icon:n?.icon,tone:n?.tone,size:`lg`}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,X.jsx)(`span`,{className:`truncate text-body-md font-medium text-ink`,children:e.title}),(0,X.jsx)(`span`,{className:`truncate text-body-sm text-muted`,children:e.live?Ba[e.live]:r||e.kind===`member`||e.kind===`lead`?e.sub:`${Ua[e.kind]} · ${e.sub}`}),e.chips.length>0&&(0,X.jsx)(`span`,{className:`mt-1 flex flex-wrap gap-1`,children:e.chips.map(e=>(0,X.jsx)(B,{tone:Ka[e.tone||``]||`neutral`,icon:!1,children:e.text},e.text))})]})]})}var Ka={warn:`warn`,fail:`fail`,accent:`running`},qa={team:Wa};function Ja({onAdd:e,onTidy:t,onUndo:n,onRedo:r,canUndo:i,canRedo:a}){let o=Hn(),s=(e,t,n,r=!1)=>(0,X.jsx)(H,{size:`icon-sm`,variant:`icon`,"aria-label":t,"data-tip":t,disabled:r,onClick:n,children:(0,X.jsx)(z,{icon:e,size:16})});return(0,X.jsxs)(`div`,{role:`toolbar`,"aria-label":`Canvas`,className:g(v,`absolute bottom-6 left-1/2 z-10 flex -translate-x-1/2 items-center gap-1`),children:[(0,X.jsxs)(H,{size:`sm`,variant:`ghost`,onClick:e,children:[(0,X.jsx)(W,{"aria-hidden":`true`}),`Add member`]}),(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`mx-1 h-5 w-px bg-line`}),s(Ot,`Zoom in`,()=>void o.zoomIn({duration:150})),s(Ct,`Zoom out`,()=>void o.zoomOut({duration:150})),s(de,`Fit the team`,()=>void o.fitView({duration:200,padding:.2})),t&&s(Ne,`Tidy up`,t),(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`mx-1 h-5 w-px bg-line`}),s(he,`Undo`,n,!i),s(Re,`Redo`,r,!a)]})}function Ya({shape:e}){let t=Hn();return(0,Y.useEffect)(()=>{let e=setTimeout(()=>void t.fitView({duration:200,padding:.12,maxZoom:1}),30);return()=>clearTimeout(e)},[t,e]),null}function Xa({id:e}){let[t,n]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)([]),[p,m]=(0,Y.useState)([]),[h,_]=(0,Y.useState)(``),[v,y]=(0,Y.useState)(!1),[b,x]=(0,Y.useState)(``),[S]=(0,Y.useState)(()=>La(e)),w=S?.gaps||[];(0,Y.useEffect)(()=>{S&&x(S.by===`model`?`Captain drafted this team from your agents. Shape it, then Save.`:`Drafted from what your agents say they do. Shape it, then Save.`)},[S]);let[T,E]=(0,Y.useState)(null),[D,O]=(0,Y.useState)(`build`),[k,A]=(0,Y.useState)(null),[j,M]=(0,Y.useState)(null),[N,ee]=(0,Y.useState)(!1),[P,te]=(0,Y.useState)(null),[F,ne]=(0,Y.useState)({}),re=(0,Y.useRef)(null),[R,ie]=(0,Y.useState)([]),[z,ae]=(0,Y.useState)(()=>typeof window<`u`&&window.innerWidth<768),{mode:oe}=C(),V=(0,Y.useCallback)((t=!1)=>I.view(e).then(e=>{n(e),a(``),t||ne(e.positions||{}),!t&&e.fields&&(u(e.fields),_(JSON.stringify(e.fields)))},e=>a(e.message)),[e]),ce=(0,Y.useCallback)(()=>I.choices().then(c,()=>{}),[]);(0,Y.useEffect)(()=>void V(),[V]),(0,Y.useEffect)(()=>void ce(),[ce]),(0,Y.useEffect)(()=>{let e=()=>ae(window.innerWidth<768);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let le=t?.runs.some(e=>e.outcome===`running`);(0,Y.useEffect)(()=>{if(!le&&T?.kind!==`preview`)return;let e=Rt(()=>void V(!0),3e3);return()=>jt(e)},[le,T,V]);let ue=l!==null&&JSON.stringify(l)!==h,de=e=>{l&&f([...d.slice(-49),l]),m([]),u(e)},fe=()=>{let e=d.at(-1);e&&l&&(m([l,...p]),f(d.slice(0,-1)),u(e))},pe=()=>{let e=p[0];e&&l&&(f([...d,l]),m(p.slice(1)),u(e))},me=async()=>{if(l){y(!0),x(``);try{let t=await I.save(e,l);x(t.bumped?`Saved as version ${t.bumped.to}: ${t.bumped.from} is approved with other settings.`:t.problems.length?`Saved. Still to fix: ${t.problems[0]}`:`Saved.`),await V(),f([]),m([])}catch(e){x(e.message)}finally{y(!1)}}},he=D===`runs`&&k?t?.runs.find(e=>e.run===k):t?.runs.find(e=>e.outcome===`running`),U=(0,Y.useMemo)(()=>ca(he),[he]),ge=T?.kind===`pick`?T.pick:null,_e=w.filter(e=>!R.includes(e.area)),ve=(0,Y.useMemo)(()=>l?la(l,s,_e,ge,U,{own:t?{notes:t.own.knowledge.length,skills:t.own.skills.length,prompts:t.own.prompts?.length||0,rules:t.own.guardrails?.length||0}:void 0,positions:F,look:t?.look}):null,[l,s,_e,ge,U,t,F]),be=(0,Y.useCallback)(e=>E(e?{kind:`pick`,pick:e}:null),[]),xe=(0,Y.useMemo)(()=>ve?ve.nodes.map(e=>({id:e.id,type:`team`,position:{x:e.x-124,y:e.y},data:{...e.data,onPick:be},draggable:!0,selectable:!1,style:{pointerEvents:`all`}})):[],[ve,be]),Se=(0,Y.useMemo)(()=>ve?ve.edges.map(e=>e.handoff?{id:e.id,source:e.source,target:e.target,sourceHandle:`out`,targetHandle:`in`,animated:e.live,selectable:!0,deletable:!0,markerEnd:{type:Bn.ArrowClosed,color:`var(--color-accent)`},style:{stroke:`var(--color-accent)`,strokeWidth:2},data:e.handoff}:{id:e.id,source:e.source,target:e.target,...e.asks?{sourceHandle:`out`,targetHandle:`in`}:{},animated:e.live,selectable:!1,deletable:!1,style:{stroke:e.live?`var(--color-accent)`:`var(--color-line-strong)`,strokeWidth:e.live?2:1.25,...e.dashed?{strokeDasharray:`5 5`}:{}}}):[],[ve]),W=(0,Y.useCallback)(t=>{let n=!1,r=!1;ne(i=>{let a={...i};for(let e of t)e.type===`position`&&e.position?(a[e.id]=[Math.round(e.position.x+124),Math.round(e.position.y)],n=!0,e.dragging===!1&&(r=!0)):e.type===`position`&&e.dragging===!1&&(r=!0);return r&&(re.current&&clearTimeout(re.current),re.current=setTimeout(()=>void I.canvas(e,a).catch(()=>{}),300)),n?a:i})},[e]),Ce=()=>{ne({}),I.canvas(e,{}).catch(()=>{})},we=e=>{let t=e.source?.replace(/^member-/,``),n=e.target?.replace(/^member-/,``);return!l||!t||!n||!e.source?.startsWith(`member-`)||!e.target?.startsWith(`member-`)||!l.members.some(e=>e.agent===t)||!l.members.some(e=>e.agent===n)?null:{from:t,to:n}},Te=e=>{let t=we(e);t&&l&&(sa(l,t.from,t.to)?x(`${t.from} already waits for ${t.to}, so that line would be a circle.`):de({...l,members:l.members.map(e=>e.agent===t.to&&!e.after?.includes(t.from)?{...e,after:[...e.after||[],t.from]}:e)}))},Ee=e=>{if(!l)return;let t=e.map(e=>e.data).filter(e=>!!(e?.from&&e?.to));t.length&&de({...l,members:l.members.map(e=>{let n=t.filter(t=>t.to===e.agent).map(e=>e.from);if(!n.length||!e.after)return e;let r=e.after.filter(e=>!n.includes(e));return{...e,after:r.length?r:void 0}})})},G=l?`${l.members.length}-${l.triggers.length}-${+!!l.schedule}-${_e.length}-${T||D===`runs`?1:0}`:``;if(!Vi.test(e))return(0,X.jsx)(`p`,{className:`m-0 px-6 py-10 text-body-md text-muted`,children:`There is no such team.`});if(!t||!l)return(0,X.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,X.jsx)(Gt,{}),(0,X.jsxs)(`main`,{className:`flex flex-col gap-4 px-6 py-10`,children:[(0,X.jsx)(se,{to:{href:r(`agents`,`category`,`custom`),label:`Custom agents`}}),i?(0,X.jsx)(`p`,{role:`alert`,className:g(L.fail,`m-0`),children:i}):t&&!t.fields?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ki,{problems:[...t.problems.working,...t.problems.active,...t.problems.other],invalid:!0}),t.fileText!==void 0&&(0,X.jsx)(`pre`,{className:g(`overflow-auto rounded-base bg-surface-muted p-4 font-mono text-body-sm leading-relaxed whitespace-pre-wrap text-ink-2 [overflow-wrap:anywhere]`,`m-0 max-h-[60vh]`),children:t.fileText})]}):(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-body-md text-muted`,children:`Reading the team…`})]})]});let De=hn[t.state],Oe=[...t.problems.working,...t.problems.active,...t.problems.other],ke=()=>E(null),je=(()=>{if(!T)return null;if(T.kind===`preview`)return(0,X.jsx)(Na,{view:t,f:l,dirty:ue,onClose:ke});if(T.kind===`publish`)return(0,X.jsx)(Pa,{view:t,f:l,choices:s,dirty:ue,onClose:ke,onApproveTeam:()=>te(`approve`),reloadChoices:ce});if(T.kind===`runs`)return null;let e=T.pick;if(e.kind===`team`)return(0,X.jsx)(ga,{f:l,set:de,view:t,onView:e=>n(e),onClose:ke});if(e.kind===`start`)return(0,X.jsx)(va,{f:l,set:de,choices:s,onClose:ke});if(e.kind===`rules`)return(0,X.jsx)(xa,{f:l,set:de,choices:s,onClose:ke});if(e.kind===`knowledge`)return(0,X.jsx)(Da,{f:l,set:de,choices:s,view:t,onView:e=>n(e),onClose:ke});if(e.kind===`lead`||e.kind===`member`)return(0,X.jsx)(Sa,{pick:e,f:l,set:de,choices:s,view:t,onView:e=>n(e),onClose:ke,onPick:be});if(e.kind===`gate`)return(0,X.jsx)(Oa,{f:l,onClose:ke,onRules:()=>be({kind:`rules`})});if(e.kind===`end`)return(0,X.jsx)(ka,{f:l,set:de,onClose:ke});let r=e.kind===`gap`?{area:e.area,role:e.role}:void 0;return(0,X.jsx)(ja,{gap:r,f:l,set:de,choices:s,onClose:ke,reloadChoices:ce,onAdded:e=>{r&&ie([...R,r.area]),be({kind:`member`,agent:e})}})})(),Ne=(0,X.jsx)(ha,{title:`Runs`,sub:`Pick a run to see how each agent did on the canvas.`,onClose:()=>(O(`build`),A(null)),children:t.runs.length===0?(0,X.jsx)(`p`,{className:`m-0 text-body-md text-muted`,children:`The team has not run yet. Try it with Preview.`}):(0,X.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:t.runs.map((e,n)=>(0,X.jsxs)(`li`,{className:g(n>0&&`border-t border-line-soft`),children:[(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":k===e.run,onClick:()=>A(e.run),className:g(o,`flex-col items-start gap-2`),children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(B,{tone:Hi[e.outcome],children:Ui[e.outcome]}),(0,X.jsxs)(`span`,{className:`text-body-sm text-muted`,children:[Gi[e.trigger],` · `,Zt(e.startedAt)]})]}),(0,X.jsx)(`span`,{className:`line-clamp-2 text-body-md text-ink`,children:e.request}),e.tasks.length>0&&(0,X.jsx)(`ul`,{"aria-label":`Tasks`,className:`m-0 flex list-none items-center gap-2 p-0`,children:e.tasks.slice(0,8).map(e=>(0,X.jsx)(Ji,{t:e,icon:s?.agents.find(t=>t.id===e.member)?.icon,name:[t?.lead,...t?.members||[]].find(t=>t?.agent===e.member)?.name||s?.agents.find(t=>t.id===e.member)?.name},e.n))})]}),k===e.run&&(0,X.jsx)(H,{size:`sm`,variant:`ghost`,className:`mb-2 ml-2`,onClick:()=>M(e.run),children:`Open its board`})]},e.run))})}),Pe=D===`runs`?Ne:je;return(0,X.jsxs)(`div`,{className:`flex h-(--screen) min-h-0 flex-col`,children:[(0,X.jsx)(Gt,{}),(0,X.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 border-b border-line-soft px-4 py-2`,children:[(0,X.jsx)(se,{to:{href:r(`agents`,`category`,`custom`),label:`Agents`},className:`min-h-8 self-center`}),(0,X.jsxs)(H,{variant:`ghost`,onClick:()=>be({kind:`team`}),className:`min-w-0 justify-start truncate px-2 text-body-lg`,"data-tip":`Name, look and purpose`,children:[(0,X.jsx)(Sn,{team:t.id,slot:`team`,icon:t.look?.icon,image:t.look?.image,px:28}),(0,X.jsx)(`span`,{className:`truncate`,children:l.name})]}),(0,X.jsx)(B,{tone:ue?`warn`:De.tone,children:ue?`Unsaved changes`:`${De.label} · ${t.fileVersion||t.approvedVersion||l.version}`}),(0,X.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(Ht,{label:`Build or runs`,options:[{id:`build`,label:`Build`},{id:`runs`,label:`Runs${t.runs.length?` ${t.runs.length}`:``}`}],value:D,onChange:e=>{O(e),e===`runs`&&A(t.runs[0]?.run||null)}}),(0,X.jsx)(H,{size:`icon-sm`,variant:`icon`,"aria-label":`Team rules`,"data-tip":`Team rules`,onClick:()=>(O(`build`),be({kind:`rules`})),children:(0,X.jsx)(Me,{"aria-hidden":`true`})}),(0,X.jsx)(H,{size:`icon-sm`,variant:`icon`,"aria-label":`Code`,"data-tip":`Its file`,onClick:()=>ee(!0),children:(0,X.jsx)(ye,{"aria-hidden":`true`})}),ue&&(0,X.jsxs)(H,{size:`sm`,variant:`outline`,disabled:v,onClick:()=>void me(),children:[(0,X.jsx)(Tt,{"aria-hidden":`true`}),v?`Saving…`:`Save`]}),(0,X.jsxs)(H,{size:`sm`,variant:`ghost`,onClick:()=>(O(`build`),E({kind:`preview`})),children:[(0,X.jsx)(Ae,{"aria-hidden":`true`}),`Preview`]}),(0,X.jsxs)(H,{size:`sm`,variant:`primary`,onClick:()=>(O(`build`),E({kind:`publish`})),children:[(0,X.jsx)(Be,{"aria-hidden":`true`}),`Publish`]})]})]}),(b||Oe.length>0||t.off)&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 border-b border-line-soft px-4 py-2`,children:[t.off&&(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-warn`,children:t.off}),b&&(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-ink-2 [overflow-wrap:anywhere]`,children:b}),Oe.length>0&&(0,X.jsxs)(`p`,{className:`m-0 text-body-sm text-fail [overflow-wrap:anywhere]`,children:[Oe[0],Oe.length>1?` (and ${Oe.length-1} more)`:``]})]}),(0,X.jsxs)(`div`,{className:`relative flex min-h-0 flex-1`,children:[z?(0,X.jsx)(`ol`,{"aria-label":`The team`,className:`m-0 flex flex-1 list-none flex-col gap-2 overflow-y-auto bg-canvas p-4`,children:ve?.nodes.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsx)(Ga,{d:{...e.data,onPick:be},wide:!0})},e.id))}):(0,X.jsx)(`div`,{className:`relative min-w-0 flex-1 bg-canvas`,children:(0,X.jsx)(Gn,{children:(0,X.jsxs)(zn,{"aria-label":`${l.name}: how it starts, its rules and knowledge, its lead and members, who approves, and its report, top to bottom`,nodes:xe,edges:Se,onNodesChange:W,onConnect:Te,onEdgesDelete:Ee,isValidConnection:e=>{let t=we(e);return!!(t&&l&&!sa(l,t.from,t.to))},connectionLineStyle:{stroke:`var(--color-accent)`,strokeWidth:2},deleteKeyCode:[`Backspace`,`Delete`],defaultEdgeOptions:{type:`smoothstep`},nodeTypes:qa,colorMode:oe,minZoom:.3,maxZoom:1.5,nodesDraggable:!0,nodesConnectable:!0,elementsSelectable:!0,zoomOnDoubleClick:!1,proOptions:{hideAttribution:!0},style:Kn,children:[(0,X.jsx)(Un,{variant:Wn.Dots,gap:20,size:1.2,color:`var(--color-line-strong)`}),(0,X.jsx)(Ya,{shape:G}),(0,X.jsx)(Ja,{onAdd:()=>(O(`build`),be({kind:`add`})),onTidy:Object.keys(F).length?Ce:void 0,onUndo:fe,onRedo:pe,canUndo:d.length>0,canRedo:p.length>0})]})})}),Pe&&!z&&(0,X.jsx)(`div`,{className:`w-[400px] flex-none border-l border-line`,children:Pe})]}),z&&Pe&&(0,X.jsx)(Lt,{open:!0,onClose:D===`runs`?()=>O(`build`):ke,title:`Details`,footer:null,bare:!0,children:Pe}),(0,X.jsx)(Lt,{open:N,onClose:()=>ee(!1),wide:!0,title:`Its file`,description:`.forgeqe/agents/teams/${e}.yaml, as saved. Edit the team on the canvas; a change runs once a person approves it.`,footer:(0,X.jsx)(H,{variant:`ghost`,onClick:()=>ee(!1),children:`Close`}),children:(0,X.jsx)(`pre`,{tabIndex:0,"aria-label":`The team's file`,className:g($t,`m-0 text-ink`),children:t.fileText??``})}),(0,X.jsx)(Yi,{board:t.runs.find(e=>e.run===j),view:t,onClose:()=>M(null)}),P&&(0,X.jsx)($i,{view:t,action:P,onClose:()=>te(null),onDone:e=>{n(e),te(null),x(P===`approve`?`Approved: this version runs from now on.`:``)}})]})}var Za={legitimate:`Legitimate`,opportunistic:`Opportunistic`,adversarial:`Adversarial`},Qa={sme:`Subject matter expert`,end_user:`End user`,specialist:`Specialist`,business_user:`Business user`},$a=[`personas`,`about`],eo={personas:`Personas`,about:`Tools and conversations`},to={personas:U,about:gt};function no({current:e,count:t}){let[n,i]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{t===void 0&&j.list().then(e=>i(e.personas.length),()=>i(null))},[t===void 0]);let a=t??n;return(0,X.jsx)(Ut,{label:`Mask's pages`,current:e,links:[{id:`agent`,label:`Agent`,href:r(`agents`,`persona`),icon:On(`persona`)},{id:`personas`,label:a===null?`Personas`:`Personas (${a})`,href:r(`agents`,`persona`,`personas`),icon:to.personas},{id:`about`,label:`Tools and conversations`,href:r(`agents`,`persona`,`about`),icon:to.about}]})}var ro=/^[a-z0-9][a-z0-9-]{0,39}$/,io=/^[a-z][a-z0-9-]{1,39}$/,ao=e=>r(`agents`,`persona`,`personas`,encodeURIComponent(e));function oo({page:e,tab:t,sub:r}){let[i,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)([]),[c,l]=(0,Y.useState)(``),u=t===`new`,d=$a.includes(t)?t:`personas`,f=()=>j.list().then(e=>{a(e.personas),s(e.notLoaded),l(``)},e=>l(`The personas did not load: ${e.message}`));(0,Y.useEffect)(()=>{f()},[]);let p=d===`personas`&&r?n(r):``;return(0,X.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,X.jsx)(Gt,{}),(0,X.jsxs)(`main`,{className:g(qt,`@container flex-auto gap-4`),children:[(0,X.jsx)(rn,{agent:e,tabs:(0,X.jsx)(no,{current:d,...i?{count:i.length}:{}})}),(0,X.jsx)(ln,{icon:to[d],title:eo[d]}),c&&(0,X.jsx)(`p`,{role:`alert`,className:g(L.fail,`m-0`),children:c}),!i&&!c&&(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Loading…`}),i&&(0,X.jsx)(X.Fragment,{children:(0,X.jsxs)(`div`,{children:[d===`personas`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(so,{personas:i,notLoaded:o,onChanged:e=>(a(e.personas),s(e.notLoaded))}),(0,X.jsx)(fo,{personas:i,opened:p,onChanged:e=>(a(e.personas),s(e.notLoaded))}),(0,X.jsx)(So,{open:u,onClose:()=>location.hash=co,personas:i,onSaved:e=>{f().then(()=>(ho=e,location.hash=ao(e)))}})]}),d===`about`&&(0,X.jsx)(xn,{page:e,onTab:!0})]})})]})]})}function so({personas:e,notLoaded:t,onChanged:n}){let[i,a]=(0,Y.useState)(`all`),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(``),[m,_]=(0,Y.useState)(!1),v=(0,Y.useRef)(null),y=e.filter(e=>!e.builtIn).length,b=async()=>{u(``),p(``);try{let e=await j.exportFile(),t=URL.createObjectURL(new Blob([`${JSON.stringify(e,null,2)}\n`],{type:`application/json;charset=utf-8`})),n=document.createElement(`a`);n.href=t,n.download=`forgeqe-personas.json`,n.click(),setTimeout(()=>URL.revokeObjectURL(t),1e3),u(`Exported ${h(y,`persona`)} of your own. Another project imports the file here.`)}catch(e){p(e.message)}},x=async e=>{let t=e?.[0];if(t){if(u(``),p(``),t.size>262144)return p(`${t.name} is over 256 KB.`);_(!0);try{let e=await j.importFile(await t.text());n(e),u(e.added.length?`Imported ${e.added.length===1?`the persona`:`${e.added.length} personas:`} ${e.added.join(`, `)}.`:`No new persona in the file.`),e.skipped.length&&p(`Not imported: ${e.skipped.map(e=>`${e.id} (${e.why})`).join(`; `)}`)}catch(e){p(e.message)}finally{_(!1)}}},S=s.toLowerCase().split(/\s+/).filter(Boolean),C=e.filter(e=>(i===`all`||e.kind===i)&&S.every(t=>`${e.name} ${e.role} ${e.domain} ${e.id} /${e.handle}`.toLowerCase().includes(t)));return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`p`,{className:`m-0 mr-auto flex flex-wrap items-center gap-x-1 text-body-sm text-ink-2 tabular-nums`,children:[(0,X.jsx)(z,{icon:U,size:14,className:`text-muted`}),h(e.length,`persona`),` · `,y,` of your own`,t.length?(0,X.jsxs)(X.Fragment,{children:[` · `,(0,X.jsxs)(`span`,{className:`text-fail`,children:[t.length,` not loaded`]})]}):null]}),(0,X.jsxs)(`span`,{className:`flex items-center gap-2`,children:[y>0&&(0,X.jsxs)(H,{size:`sm`,onClick:()=>void b(),"data-tip":`A file of your own personas, for another project to import`,children:[(0,X.jsx)(vt,{"aria-hidden":`true`}),`Export`]}),(0,X.jsxs)(H,{busy:m,size:`sm`,disabled:m,onClick:()=>v.current?.click(),"data-tip":`Personas another project exported`,children:[(0,X.jsx)(Et,{"aria-hidden":`true`}),m?`Importing…`:`Import`]}),(0,X.jsxs)(H,{size:`sm`,variant:`accent`,onClick:()=>location.hash=r(`agents`,`persona`,`new`),"data-tip":`Describe a person and Mask drafts the persona, or write it yourself`,children:[(0,X.jsx)(W,{"aria-hidden":`true`}),`New persona`]})]}),(0,X.jsx)(`input`,{ref:v,type:`file`,accept:`.json,application/json`,hidden:!0,onChange:e=>(x(e.target.files),e.target.value=``)})]}),l&&(0,X.jsx)(`p`,{role:`status`,className:g(L.info,`m-0`),children:l}),f&&(0,X.jsx)(`p`,{role:`alert`,className:g(L.fail,`m-0`),children:f}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(oe,{id:`persona-find`,label:`Find a persona`,value:s,onChange:c}),(0,X.jsx)(ae,{items:[{id:`all`,label:`All`,n:e.length},...ee.map(t=>({id:t,label:Qa[t],n:e.filter(e=>e.kind===t).length}))],value:i,onChange:a})]}),C.length===0?(0,X.jsx)(ie,{className:`py-4`,children:e.length?`No persona matches.`:`There are no personas yet.`}):(0,X.jsx)(`ul`,{"aria-label":`Personas`,className:g(d,`m-0 flex list-none flex-col`),children:C.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`a`,{href:ao(e.id),className:o,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,X.jsxs)(`span`,{className:`truncate text-body-sm font-medium`,"data-tip":e.name,children:[e.name,!e.builtIn&&(0,X.jsx)(`span`,{className:`font-normal text-muted`,children:` · yours`})]}),(0,X.jsxs)(`span`,{className:`truncate text-body-sm text-muted`,children:[(0,X.jsxs)(`span`,{className:`font-mono`,children:[`/`,e.handle]}),` · `,Qa[e.kind],e.intent===`legitimate`?``:` · ${Za[e.intent].toLowerCase()}`,` · `,e.role,e.domain?` · ${e.domain}`:``]})]}),(0,X.jsx)(`span`,{className:`flex-none text-body-sm text-muted tabular-nums`,children:h(e.validates.length,`check`)})]})},e.id))}),t.length>0&&(0,X.jsx)(J,{id:`persona-not-loaded`,icon:Ie,title:`Not loaded`,level:3,children:(0,X.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0`,children:t.map(e=>(0,X.jsx)(`li`,{className:`text-body-sm text-fail [overflow-wrap:anywhere]`,children:e},e))})}),(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`Your own personas are in .forgeqe/business-personas (each with its profile as a .md file), shared with everyone who uses the repository. Type a persona's command in any agent's chat, such as /priya and the task.`})]})}var co=r(`agents`,`persona`,`personas`),lo=e=>{let{builtIn:t,...n}=e;return n},uo=(e,t)=>{for(let n=1;n<100;n++){let r=n===1?`-copy`:`-copy-${n}`,i=`${e.slice(0,40-r.length)}${r}`;if(!t.has(i))return i}return``};function fo({personas:e,opened:t,onChanged:n}){let[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(``),l=r?void 0:e.find(e=>e.id===t),u=!!t&&!r&&!l,d=()=>location.hash=co,f=(t,n)=>{let r=new Set(e.flatMap(e=>[e.id,e.handle])),a=n===`copy`?{...lo(t),id:uo(t.id,r),handle:``}:lo(t);c(``),i({mode:n,from:t,fields:a,listText:Object.fromEntries(bo.map(({key:e})=>[e,t[e].join(`
|
|
8
|
-
`)]))})},p=(0,Y.useMemo)(()=>new Set(e.filter(e=>r?.mode!==`edit`||e.id!==r.from.id).flatMap(e=>[e.id,e.handle])),[e,r]),m=r?Co(r.fields,r.listText,p,r.mode===`edit`):null,h=po(!!t||!!r),g=async(e,t,r)=>{e[t].includes(r)||n(await j.update(e.id,{...lo(e),[t]:[...e[t],r]}))},_=async()=>{if(r&&m?.canSave){o(!0),c(``);try{let e={...r.fields,...Object.fromEntries(bo.map(({key:e})=>[e,xo(r.listText[e]||``)]))},t=r.mode===`edit`?await j.update(r.from.id,e):await j.save(e);n(t),i(null),r.mode===`copy`&&(ho=t.saved),location.hash=ao(t.saved)}catch(e){c(e.message)}finally{o(!1)}}};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Lt,{wide:!0,open:!!l||u,onClose:d,title:l?.name||`No such persona`,description:l?l.builtIn?`ForgeQE's persona: read only. Copy it to edit your own version for this project.`:`This project's own persona: you can edit it.`:void 0,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(H,{onClick:d,children:[(0,X.jsx)(Fe,{"aria-hidden":`true`}),`Close`]}),l&&!l.builtIn&&(0,X.jsxs)(H,{variant:`primary`,onClick:()=>f(l,`edit`),children:[(0,X.jsx)(Ee,{"aria-hidden":`true`}),`Edit`]}),l?.builtIn&&(0,X.jsxs)(H,{variant:`primary`,"data-tip":`Make your own persona from this one, under another id and command`,onClick:()=>f(l,`copy`),children:[(0,X.jsx)(Ve,{"aria-hidden":`true`}),`Copy to edit`]})]}),children:l?(0,X.jsx)(vo,{persona:l,resources:h,onAdd:l.builtIn?void 0:(e,t)=>g(l,e,t)}):(0,X.jsxs)(ie,{className:`py-6`,children:[`There is no persona "`,t,`" in this project.`]})}),(0,X.jsx)(Lt,{wide:!0,open:!!r,onClose:()=>i(null),title:r?.mode===`edit`?`Edit ${r.from.name}`:`Copy ${r?.from.name||``}`,description:(0,X.jsxs)(X.Fragment,{children:[r?.mode===`copy`&&(0,X.jsx)(X.Fragment,{children:`A persona of your own, made from the built-in one, which stays as it is. `}),`Saved in `,(0,X.jsxs)(`span`,{className:`font-mono text-body-sm`,children:[`.forgeqe/business-personas/`,r?.fields.id||`<id>`,`.yaml`]}),`, shared with everyone who uses the repository.`]}),footer:(0,X.jsxs)(X.Fragment,{children:[s?(0,X.jsx)(`span`,{role:`alert`,className:`mr-auto self-center text-body-sm text-fail [overflow-wrap:anywhere]`,children:s}):r&&!m?.canSave&&(0,X.jsxs)(`span`,{className:`mr-auto self-center text-body-sm text-muted`,children:[`It needs a name, `,r.mode===`copy`?`an id, `:``,`a role, and what they check or want.`]}),(0,X.jsxs)(H,{onClick:()=>i(null),children:[(0,X.jsx)(Fe,{"aria-hidden":`true`}),`Cancel`]}),(0,X.jsxs)(H,{busy:a,variant:`primary`,disabled:a||!m?.canSave,onClick:()=>void _(),children:[(0,X.jsx)(Tt,{"aria-hidden":`true`}),a?`Saving…`:r?.mode===`copy`?`Save copy`:`Save`]})]}),children:r&&m&&(0,X.jsx)(`div`,{className:`pt-4`,children:(0,X.jsx)(wo,{fields:r.fields,listText:r.listText,onFields:e=>i({...r,fields:e}),onListText:e=>i({...r,listText:e}),check:m,idLocked:r.mode===`edit`,resources:h})})})]})}function po(e){let[t,n]=(0,Y.useState)(null);return(0,Y.useEffect)(()=>{e&&!t&&j.resources().then(n,e=>n({skills:[],documents:[],error:`The skills and documents did not load: ${e.message}`}))},[e,t]),t}function mo({persona:e,resources:t,onAdd:n}){let[r,i]=(0,Y.useState)(null),a=t?.error?null:t,[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(``),u=`${e.skills.join(`,`)}|${e.knowledge.join(`,`)}`;(0,Y.useEffect)(()=>{i(null),j.suggest(e.id).then(i,e=>i({skills:[],documents:[],error:`The suggestions did not load: ${e.message}`}))},[e.id,u]);let d=e=>a?.skills.find(t=>t.name===e),f=e=>a?.documents.find(t=>t.ref===e),p=(0,X.jsx)(`span`,{className:`text-warn`,children:` · not in this project`}),m=async(e,t)=>{if(n){s(`${e}:${t}`),l(``);try{await n(e,t)}catch(e){l(e.message)}finally{s(``)}}},h=r?[...r.skills.map(e=>({key:`skills`,...e})),...r.documents.map(e=>({key:`knowledge`,...e}))]:[];return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(J,{id:`persona-uses`,icon:it,title:`Shared skills and documents`,level:3,children:[e.skills.length+e.knowledge.length===0?(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:n?`No skills or documents yet. Add a suggestion below, or pick them in Edit.`:`No skills or documents. Copy it to edit, then pick them.`}):(0,X.jsxs)(`ul`,{"aria-label":`Skills and documents`,className:`m-0 flex list-none flex-col p-0`,children:[e.skills.map(e=>(0,X.jsxs)(`li`,{className:`flex items-start gap-4 border-t border-line-soft py-2`,children:[(0,X.jsx)(z,{icon:it,size:16,className:`mt-1 text-muted`}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`font-mono text-body-sm [overflow-wrap:anywhere]`,children:e}),(0,X.jsxs)(`span`,{className:`text-body-sm text-muted [overflow-wrap:anywhere]`,children:[`Skill`,a&&!d(e)?p:d(e)?` · ${d(e).description}`:``]})]})]},`s:${e}`)),e.knowledge.map(e=>(0,X.jsxs)(`li`,{className:`flex items-start gap-4 border-t border-line-soft py-2`,children:[(0,X.jsx)(z,{icon:lt,size:16,className:`mt-1 text-muted`}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-body-sm font-medium [overflow-wrap:anywhere]`,children:f(e)?.title||e}),(0,X.jsxs)(`span`,{className:`font-mono text-body-sm text-muted [overflow-wrap:anywhere]`,children:[e,a&&!f(e)?p:null]})]})]},`k:${e}`))]}),t?.error&&(0,X.jsx)(`p`,{role:`alert`,className:g(L.fail,`m-0`),children:t.error})]}),(0,X.jsxs)(J,{id:`persona-suggested`,icon:bt,title:`Suggested for them`,level:3,children:[r?r.error?(0,X.jsx)(`p`,{role:`alert`,className:g(L.fail,`m-0`),children:r.error}):h.length===0?(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`Nothing else matches their domain and checks. Add documents in Settings › Product knowledge, or knowledge notes, to see more.`}):(0,X.jsx)(`ul`,{"aria-label":`Suggested skills and documents`,className:`m-0 flex list-none flex-col p-0`,children:h.map(t=>(0,X.jsxs)(`li`,{className:`flex items-center gap-4 border-t border-line-soft py-2`,children:[(0,X.jsx)(z,{icon:t.key===`skills`?it:lt,size:16,className:`text-muted`}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:g(`text-body-sm [overflow-wrap:anywhere]`,t.key===`skills`?`font-mono`:`font-medium`),children:t.key===`knowledge`&&f(t.name)?.title||t.name}),(0,X.jsxs)(`span`,{className:`text-body-sm text-muted [overflow-wrap:anywhere]`,children:[t.key===`skills`?`Skill`:t.name,` · matched `,t.why]})]}),n&&(0,X.jsxs)(H,{size:`sm`,disabled:!!o,onClick:()=>void m(t.key,t.name),"data-tip":`Add to what ${e.name} uses`,children:[(0,X.jsx)(W,{"aria-hidden":`true`}),o===`${t.key}:${t.name}`?`Adding…`:`Add`]})]},`${t.key}:${t.name}`))}):(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Looking for skills and documents that match…`}),c&&(0,X.jsx)(`p`,{role:`alert`,className:g(L.fail,`m-0`),children:c})]})]})}var ho=``,go=e=>e.name.split(`,`)[0].trim()||e.name;function _o({persona:e}){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(``),f=go(e),p=()=>j.own(e.id).then(n,e=>n({skills:[],knowledge:[],problems:[],error:`${f}'s own skills and notes did not load: ${e.message}`})),m=async()=>{s(`draft`),l(``);try{let[t,n]=await Promise.all([j.draftOwn(e.id),j.own(e.id)]),r=(e,t)=>n[e].some(e=>e.name===t);d(``),i({drafted:!0,items:[t.skill,t.knowledge].map(e=>({...e,replace:r(e.kind,e.name)}))})}catch(e){l(e.message)}finally{s(``)}};(0,Y.useEffect)(()=>{n(null),p(),ho===e.id&&(ho=``,m())},[e.id]);let h=async()=>{if(r){s(`save`),d(``);try{let t=r.items.filter(e=>e.was&&e.was!==e.name),a=await j.saveOwn(e.id,r.items.map(({was:e,...n})=>({...n,replace:n.replace&&!t.some(e=>e.kind===n.kind&&e.name===n.name)})));i({...r,items:r.items.map(e=>({...e,replace:!0}))});for(let n of t)await j.removeOwn(e.id,n.kind,n.was);n(t.length?await j.own(e.id):a),i(null)}catch(e){d(e.message),p()}finally{s(``)}}},_=async t=>{s(`remove:${t.kind}/${t.name}`),d(``);try{n(await j.removeOwn(e.id,t.kind,t.name)),i(null)}catch(e){d(e.message)}finally{s(``)}},v=t?[...t.skills,...t.knowledge]:[],y=(e,t)=>r&&i({...r,items:r.items.map((n,r)=>r===e?{...n,...t}:n)}),b=!!r&&r.items.every(e=>/^[a-z0-9]+(-[a-z0-9]+)*$/.test(e.name)&&e.body.trim()&&(e.kind===`knowledge`||e.description.trim()));return(0,X.jsxs)(J,{id:`persona-own`,icon:St,level:3,title:(0,X.jsxs)(X.Fragment,{children:[f,`'s own skills and knowledge`]}),description:(0,X.jsxs)(X.Fragment,{children:[`Used only when someone works as `,f,`, never by other agents.`]}),actions:(0,X.jsxs)(H,{busy:o===`draft`,size:`sm`,disabled:!!o||!t,onClick:()=>void m(),"data-tip":`Mask drafts a skill and a knowledge note for ${f}; you review them before anything is saved`,children:[(0,X.jsx)(at,{"aria-hidden":`true`}),o===`draft`?`Generating…`:v.length?`Generate again`:`Generate skill and knowledge`]}),children:[o===`draft`&&(0,X.jsxs)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:[`Mask is writing `,f,`'s skill and knowledge note…`]}),t?v.length===0?!t.error&&o!==`draft`&&(0,X.jsxs)(`p`,{className:`m-0 text-body-sm text-muted`,children:[`None yet. Generate a skill and a knowledge note from `,f,`'s checks, then change them as you need.`]}):(0,X.jsx)(`ul`,{"aria-label":`${f}'s own skills and knowledge`,className:`m-0 flex list-none flex-col p-0`,children:v.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center gap-4 border-t border-line-soft py-2`,children:[(0,X.jsx)(z,{icon:e.kind===`skills`?it:lt,size:16,className:`text-muted`}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`font-mono text-body-sm [overflow-wrap:anywhere]`,children:e.name}),(0,X.jsx)(`span`,{className:`line-clamp-2 text-body-sm text-muted [overflow-wrap:anywhere]`,children:e.kind===`skills`?`Skill · ${e.description}`:`Knowledge note`})]}),(0,X.jsxs)(H,{size:`sm`,disabled:!!o,onClick:()=>(d(``),i({drafted:!1,items:[{...e,replace:!0,was:e.name}]})),children:[(0,X.jsx)(Ee,{"aria-hidden":`true`}),`Edit`]})]},`${e.kind}:${e.name}`))}):(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Loading…`}),t?.problems.length?(0,X.jsxs)(`p`,{className:`m-0 text-body-sm text-warn [overflow-wrap:anywhere]`,children:[`Not read: `,t.problems.join(`; `)]}):null,(c||t?.error)&&(0,X.jsx)(`p`,{role:`alert`,className:g(L.fail,`m-0`),children:c||t?.error}),(0,X.jsx)(Lt,{wide:!0,open:!!r,onClose:()=>i(null),title:r?.drafted?`Review ${f}'s skill and knowledge`:`Edit ${r?.items[0]?.was||``}`,description:(0,X.jsxs)(X.Fragment,{children:[r?.drafted&&(0,X.jsx)(X.Fragment,{children:`Mask's draft: change anything, then save. `}),`Kept in `,(0,X.jsxs)(`span`,{className:`font-mono text-body-sm`,children:[`.forgeqe/business-personas/`,e.id,`/`]}),` and used only when someone works as `,f,`.`]}),footer:(0,X.jsxs)(X.Fragment,{children:[u?(0,X.jsx)(`span`,{role:`alert`,className:`mr-auto self-center text-body-sm text-fail [overflow-wrap:anywhere]`,children:u}):r&&!b&&(0,X.jsx)(`span`,{className:`mr-auto self-center text-body-sm text-muted`,children:`Each needs a name of lower-case words joined by dashes and its text; a skill also its "use when" line.`}),r&&!r.drafted&&r.items[0]?.was&&(0,X.jsxs)(H,{disabled:!!o,onClick:()=>void _({...r.items[0],name:r.items[0].was}),className:g(!u&&b&&`mr-auto`,`text-fail`),children:[(0,X.jsx)(K,{"aria-hidden":`true`}),o.startsWith(`remove:`)?`Deleting…`:`Delete`]}),(0,X.jsxs)(H,{onClick:()=>i(null),children:[(0,X.jsx)(Fe,{"aria-hidden":`true`}),`Cancel`]}),(0,X.jsxs)(H,{busy:o===`save`,variant:`primary`,disabled:o===`save`||!b,onClick:()=>void h(),children:[(0,X.jsx)(Tt,{"aria-hidden":`true`}),o===`save`?`Saving…`:r?.drafted?`Save both`:`Save`]})]}),children:r&&(0,X.jsx)(`div`,{className:`flex flex-col gap-6 pt-4`,children:r.items.map((e,t)=>(0,X.jsxs)(`section`,{"aria-labelledby":`own-item-${t}`,className:`flex flex-col gap-4`,children:[(0,X.jsxs)(`h3`,{id:`own-item-${t}`,className:`m-0 flex items-center gap-2 text-body-sm font-medium text-muted`,children:[(0,X.jsx)(z,{icon:e.kind===`skills`?it:lt,size:14}),e.kind===`skills`?`Skill`:`Knowledge note`,e.replace&&!e.was&&(0,X.jsx)(`span`,{className:`font-normal text-warn`,children:` · replaces the one of this name`})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Name`}),(0,X.jsx)(a,{value:e.name,maxLength:64,spellCheck:!1,autoComplete:`off`,className:`font-mono`,onChange:e=>y(t,{name:e.target.value.toLowerCase().replace(/[^a-z0-9-]+/g,`-`)})})]}),e.kind===`skills`&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Use when`}),(0,X.jsx)(a,{value:e.description,maxLength:400,onChange:e=>y(t,{description:e.target.value})})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`label`,{htmlFor:`own-body-${t}`,className:`font-medium`,children:e.kind===`skills`?`Instructions`:`What it says`}),(0,X.jsx)(_n,{id:`own-body-${t}`,value:e.body,lang:`markdown`,onChange:e=>y(t,{body:e})})]})]},t))})})]})}function vo({persona:e,resources:t,onAdd:n}){let r=[[`persona-validates`,`What they check before accepting the software`,e.validates,rt],[`persona-goals`,`What they want to do`,e.goals,de],[`persona-knows`,`What they know`,e.knows,St],[`persona-frustrations`,`What puts them off`,e.frustrations,Ie],[`persona-scenarios`,`What they would try`,e.scenarios,ft],[`persona-motivations`,`What drives them`,e.motivations,bt],[`persona-permissions`,`What their role lets them do`,e.permissions,Ze],[`persona-constraints`,`What limits them`,e.constraints,Pe],[`persona-mistakes`,`Mistakes they make`,e.mistakes,Te],[`persona-relationships`,`Who they deal with`,e.relationships,U]];return(0,X.jsxs)(`div`,{className:`flex flex-col gap-6 pt-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`p`,{className:`m-0 text-body-sm text-muted`,children:[(0,X.jsxs)(`span`,{className:`font-mono`,children:[`/`,e.handle]}),` · `,Qa[e.kind],` · `,e.role,e.domain?` · ${e.domain}`:``,` · `,e.expertise.charAt(0).toUpperCase()+e.expertise.slice(1),e.intent===`legitimate`?``:` · ${Za[e.intent].toLowerCase()}, risk appetite ${e.risk_appetite}`,e.builtIn?``:` · version ${e.version}`]}),e.description&&(0,X.jsx)(`p`,{className:`m-0 text-body-sm leading-relaxed text-ink-2`,children:e.description})]}),(0,X.jsx)(_o,{persona:e}),(0,X.jsx)(mo,{persona:e,resources:t,...n?{onAdd:n}:{}}),r.filter(([,,e])=>e.length).map(([e,t,n,r])=>(0,X.jsx)(J,{id:e,icon:r,title:t,level:3,children:(0,X.jsx)(`ul`,{className:`m-0 flex list-disc flex-col gap-1 pl-6 text-body-sm text-ink-2`,children:n.map(e=>(0,X.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:e},e))})},e))]})}var yo={id:``,handle:``,name:``,kind:`business_user`,role:``,domain:``,expertise:`intermediate`,description:``,goals:[],knows:[],validates:[],frustrations:[],scenarios:[],intent:`legitimate`,risk_appetite:`low`,motivations:[],permissions:[],constraints:[],mistakes:[],relationships:[],version:1,skills:[],knowledge:[]},bo=[{key:`validates`,label:`What they check`,hint:`One rule a test can check per line, such as: a refund never exceeds the captured amount.`},{key:`goals`,label:`What they want to do`,hint:`One per line.`},{key:`knows`,label:`What they know`,hint:`Terms and rules of the domain, one per line.`},{key:`frustrations`,label:`What puts them off`,hint:`One per line.`},{key:`scenarios`,label:`What they would try`,hint:`Tasks in their words, one per line.`},{key:`motivations`,label:`What drives them`,hint:`One per line, such as: save money, hit the monthly target.`},{key:`permissions`,label:`What their role lets them do`,hint:`In the app, one per line, such as: issue refunds up to 500.`},{key:`constraints`,label:`What limits them`,hint:`Money, time or rules they work within, one per line.`},{key:`mistakes`,label:`Mistakes they make`,hint:`One per line, such as: double-clicks Pay when the page is slow.`},{key:`relationships`,label:`Who they deal with`,hint:`Other personas by id and how, one per line, such as: approves for insider-agent.`}],xo=e=>e.split(`
|
|
9
|
-
`).map(e=>e.trim()).filter(Boolean);function So({open:e,onClose:t,personas:n,onSaved:r}){let[i,o]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(``),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)({}),[_,v]=(0,Y.useState)(!1),[y,b]=(0,Y.useState)(``),[x,S]=(0,Y.useState)(``),C=(0,Y.useMemo)(()=>new Set(n.flatMap(e=>[e.id,e.handle])),[n]),w=po(!!p),T=(0,Y.useRef)(0);(0,Y.useEffect)(()=>{T.current+=1,e&&(o(``),u(``),f(``),m(null),g({}),v(!1),b(``),S(``))},[e]);let E=e=>{m(e),g(Object.fromEntries(bo.map(({key:t})=>[t,e[t].join(`
|
|
10
|
-
`)])))},D=async()=>{let e=T.current;b(`draft`),S(``);try{let{persona:t}=await j.draft({request:i.trim(),...l?{kind:l}:{},...d.trim()?{domain:d.trim()}:{}});if(e!==T.current)return;let{builtIn:n,...r}=t;E(r),v(!0)}catch(t){e===T.current&&S(t.message)}finally{e===T.current&&b(``)}},O=async()=>{if(p){b(`save`),S(``);try{let e={...p,...Object.fromEntries(bo.map(({key:e})=>[e,xo(h[e]||``)]))};r((await j.save(e)).saved)}catch(e){S(e.message),b(``)}}},k=p?Co(p,h,C,!1):null,A=!!k?.canSave;return(0,X.jsx)(Lt,{wide:!0,open:e,onClose:t,title:`New persona`,description:(0,X.jsxs)(X.Fragment,{children:[`Saved in `,(0,X.jsxs)(`span`,{className:`font-mono text-body-sm`,children:[`.forgeqe/business-personas/`,p?.id||`<id>`,`.yaml`]}),`, shared with the project.`]}),footer:(0,X.jsxs)(X.Fragment,{children:[x?(0,X.jsx)(`span`,{role:`alert`,className:`mr-auto self-center text-body-sm text-fail [overflow-wrap:anywhere]`,children:x}):p&&!A&&(0,X.jsx)(`span`,{className:`mr-auto self-center text-body-sm text-muted`,children:`It needs a name, an id, a role, and what they check or want.`}),(0,X.jsxs)(H,{onClick:t,children:[(0,X.jsx)(Fe,{"aria-hidden":`true`}),`Cancel`]}),(0,X.jsxs)(H,{busy:y===`save`,variant:`primary`,disabled:!!y||!A,onClick:()=>void O(),children:[(0,X.jsx)(Tt,{"aria-hidden":`true`}),y===`save`?`Saving…`:`Save`]})]}),children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-6 pt-4`,children:[(0,X.jsxs)(J,{id:`persona-ask`,icon:U,title:`Who is the persona?`,level:3,children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Describe them`}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:`Their job, what they know and what they check. Mask drafts the rest.`}),(0,X.jsx)(c,{rows:3,value:i,maxLength:2e3,onChange:e=>o(e.target.value),placeholder:`An SME in card payments who reconciles settlements every morning and signs off refunds`})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Kind`}),(0,X.jsxs)(s,{value:l,onChange:e=>u(e.target.value),children:[(0,X.jsx)(`option`,{value:``,children:`Let the agent choose`}),ee.map(e=>(0,X.jsx)(`option`,{value:e,children:Qa[e]},e))]})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Domain`}),(0,X.jsx)(a,{value:d,maxLength:80,onChange:e=>f(e.target.value),placeholder:`payments`})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(H,{disabled:!!y||!i.trim(),onClick:()=>void D(),"data-tip":_?`Ask Mask for another draft`:`Ask Mask for a draft`,children:[(0,X.jsx)(at,{"aria-hidden":`true`}),_?`Draft again`:`Draft`]}),!p&&(0,X.jsxs)(H,{disabled:!!y,onClick:()=>E(yo),"data-tip":`Write every field yourself`,children:[(0,X.jsx)(ct,{"aria-hidden":`true`}),`Write`]}),y===`draft`&&(0,X.jsx)(`span`,{role:`status`,className:`text-body-sm text-muted`,children:`Mask is drafting…`})]})]}),p&&k&&(0,X.jsx)(J,{id:`persona-fields`,icon:Le,title:`The persona`,level:3,children:(0,X.jsx)(wo,{fields:p,listText:h,onFields:m,onListText:g,check:k,idLocked:!1,resources:w})})]})})}function Co(e,t,n,r){let i=r||e.id===``?``:ro.test(e.id)?n.has(e.id)?`A persona has this id: pick another.`:``:`Lower-case letters, digits and dashes, at most 40.`,a=e.handle||e.id,o=a===``?``:io.test(a)?e.handle&&e.handle!==e.id&&n.has(e.handle)?`A persona has this command: pick another.`:``:`A word of lower-case letters, digits and dashes that starts with a letter.`;return{idProblem:i,handleProblem:o,canSave:!!e.id&&!i&&!o&&!!e.name.trim()&&!!e.role.trim()&&(xo(t.validates||``).length>0||xo(t.goals||``).length>0)}}function wo({fields:e,listText:t,onFields:n,onListText:r,check:i,idLocked:o,resources:l}){let u=(t,r)=>n({...e,[t]:r}),{idProblem:d,handleProblem:f}=i;return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Name`}),(0,X.jsx)(a,{value:e.name,maxLength:80,onChange:e=>u(`name`,e.target.value),placeholder:`Priya, payments SME`})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Id`}),(0,X.jsx)(a,{value:e.id,disabled:o,maxLength:40,spellCheck:!1,autoComplete:`off`,"aria-invalid":!!d,"aria-describedby":d?`persona-id-error`:void 0,onChange:e=>u(`id`,e.target.value.toLowerCase()),className:`font-mono`}),d&&(0,X.jsx)(`p`,{id:`persona-id-error`,role:`alert`,className:`m-0 text-body-sm text-fail`,children:d})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Command`}),(0,X.jsxs)(`span`,{className:`text-body-sm text-muted`,children:[`Type it in any agent's chat: /`,e.handle||e.id||`priya`,` Validate the payment change.`]}),(0,X.jsx)(a,{value:e.handle,maxLength:40,spellCheck:!1,autoComplete:`off`,"aria-invalid":!!f,"aria-describedby":f?`persona-handle-error`:void 0,onChange:e=>u(`handle`,e.target.value.toLowerCase().replace(/^\//,``)),className:`font-mono`,placeholder:e.id||`priya`}),f&&(0,X.jsx)(`p`,{id:`persona-handle-error`,role:`alert`,className:`m-0 text-body-sm text-fail`,children:f})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Kind`}),(0,X.jsx)(s,{value:e.kind,onChange:e=>u(`kind`,e.target.value),children:ee.map(e=>(0,X.jsx)(`option`,{value:e,children:Qa[e]},e))})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Expertise in the domain`}),(0,X.jsx)(s,{value:e.expertise,onChange:e=>u(`expertise`,e.target.value),children:ne.map(e=>(0,X.jsx)(`option`,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Intent`}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:`Opportunistic takes any advantage the app gives; adversarial sets out to misuse it. Watchdog tests as them.`}),(0,X.jsx)(s,{value:e.intent,onChange:e=>u(`intent`,e.target.value),children:te.map(e=>(0,X.jsx)(`option`,{value:e,children:Za[e]},e))})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Risk appetite`}),(0,X.jsx)(s,{value:e.risk_appetite,onChange:e=>u(`risk_appetite`,e.target.value),children:F.map(e=>(0,X.jsx)(`option`,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Role`}),(0,X.jsx)(a,{value:e.role,maxLength:120,onChange:e=>u(`role`,e.target.value),placeholder:`Payments operations lead`})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Domain`}),(0,X.jsx)(a,{value:e.domain,maxLength:80,onChange:e=>u(`domain`,e.target.value)})]})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Who they are`}),(0,X.jsx)(c,{rows:3,value:e.description,maxLength:1200,onChange:e=>u(`description`,e.target.value)})]}),bo.map(({key:e,label:n,hint:i})=>(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:n}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:i}),(0,X.jsx)(c,{rows:e===`validates`?5:3,value:t[e]||``,onChange:n=>r({...t,[e]:n.target.value})})]},e)),(0,X.jsx)(Eo,{id:`persona-skills`,label:`Skills an agent loads as them`,hint:`The agent loads these with its skill tool whenever someone works as this persona.`,items:l?.skills.map(e=>({id:e.name,title:e.name,note:e.description,mono:!0}))??null,...l?.error?{error:l.error}:{},value:e.skills,onChange:e=>u(`skills`,e)}),(0,X.jsx)(Eo,{id:`persona-knowledge`,label:`Documents they rely on`,hint:`Knowledge notes and the project's documents. The agent searches them for what the request needs.`,items:l?.documents.map(e=>({id:e.ref,title:e.title,note:e.ref}))??null,...l?.error?{error:l.error}:{},value:e.knowledge,onChange:e=>u(`knowledge`,e)})]})}var To=12;function Eo({id:e,label:t,hint:n,items:r,error:i,value:a,onChange:o}){let[s,c]=(0,Y.useState)(``),l=s.toLowerCase().split(/\s+/).filter(Boolean),u=r?[...a.filter(e=>!r.some(t=>t.id===e)).map(e=>({id:e,title:e,note:`Not in this project`,mono:!0})),...r]:[],f=u.filter(e=>l.every(t=>`${e.title} ${e.note} ${e.id}`.toLowerCase().includes(t))).sort((e,t)=>Number(a.includes(t.id))-Number(a.includes(e.id))),p=a.length>=To;return(0,X.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 border-0 p-0 text-body-sm`,children:[(0,X.jsxs)(`legend`,{className:`mb-2 p-0 font-medium`,children:[t,` `,(0,X.jsxs)(`span`,{className:`font-normal text-muted tabular-nums`,children:[`· `,a.length,` picked`]})]}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:n}),i?(0,X.jsx)(`p`,{role:`alert`,className:g(L.fail,`m-0`),children:i}):r?u.length===0?(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`There are none in this project yet.`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,X.jsx)(oe,{id:`${e}-find`,label:`Find in ${t.toLowerCase()}`,value:s,onChange:c})}),(0,X.jsxs)(`ul`,{"aria-label":t,className:g(d,`m-0 max-h-72 list-none overflow-y-auto`),children:[f.length===0&&(0,X.jsx)(`li`,{className:`py-4 text-body-sm text-muted`,children:`Nothing matches.`}),f.map(e=>{let t=a.includes(e.id);return(0,X.jsx)(`li`,{className:`border-t border-line-soft first:border-t-0`,children:(0,X.jsxs)(`label`,{className:g(`flex min-h-12 items-center gap-4 py-2`,!t&&p?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,X.jsx)(on,{checked:t,disabled:!t&&p,onCheckedChange:t=>o(t?[...a,e.id]:a.filter(t=>t!==e.id))}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:g(`text-body-sm [overflow-wrap:anywhere]`,e.mono?`font-mono`:`font-medium`),children:e.title}),(0,X.jsx)(`span`,{className:`line-clamp-2 text-body-sm text-muted [overflow-wrap:anywhere]`,"data-tip":e.note.length>120?e.note:void 0,children:e.note})]})]})},e.id)})]}),p&&(0,X.jsxs)(`span`,{className:`text-body-sm text-muted`,children:[`At most `,To,`: take one off to pick another.`]})]}):(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Loading…`})]})}var Do=[`agent`,`tests`,`personas`,`findings`],Oo={agent:`Agent`,tests:`Tests`,personas:`Personas`,findings:`Findings`},ko={agent:`BASAL`,tests:`Business tests`,personas:`Personas`,findings:`Findings`},Ao={agent:`Ask a business question, and ForgeQE's agents act it out as the people it affects.`,tests:`Every business test BASAL has worked: its question, how far through the eight steps it is, and its stage. Open one for its strategy, cast, handovers and verdicts. A new test starts from a business question on the Agent tab.`,personas:`The people each test was cast with: what they check before they accept the outcome, what they object to, and the mistakes they bring.`,findings:`Every scenario's latest verdict, the ones that need attention first. Each rests on what ForgeQE's agents observed, never on a model's opinion.`},jo={tests:pe,personas:U,findings:et},$=(e,t)=>e===`agent`?r(`agents`,`basal`,`agent`):t?r(`agents`,`basal`,e,t):r(`agents`,`basal`,e),Mo=[`ask`,`understand`,`strategy`,`cast`,`rehearse`,`approve`,`act`,`judge`],No={ask:{name:`Ask`,about:`The business question, and what came with it.`},understand:{name:`Understand`,about:`The decision, its stakeholders, how success is measured, and the facts, read from the sources and the product graph. Observed: quoted as written. Inferred: worked out, to be confirmed.`},strategy:{name:`Strategy`,about:`Scenarios that decide the question, each step on the channel an agent can play, and the business expectations that judge it.`},cast:{name:`Cast`,about:`One persona for each stakeholder who acts: what they check, what they object to, and the mistakes they bring.`},rehearse:{name:`Rehearse`,about:`The cast react on a social feed: to the decision, to each other, and to what the agents really saw on the product. What they want to try next picks the scenarios to play. Opinions, never evidence.`},approve:{name:`Approve`,about:`Nothing runs until a person approves the strategy.`},act:{name:`Act`,about:`Each step handed to ForgeQE's agents as its persona, on the test environment. Steps that change data run only when you agree.`},judge:{name:`Judge`,about:`Code judges each scenario from what the agents observed. A step only a person can see waits for you.`}},Po={asked:1,understood:2,planned:3,cast:4,rehearsed:5,approved:6,acted:8},Fo={understand:1,strategy:2,cast:3,rehearse:4,act:6},Io=[{channel:`browser`,title:`WebPilot · browser`},{channel:`api`,title:`API workbench`},{channel:`mobile`,title:`Mobile agent`},{channel:`desktop`,title:`Desktop agent`},{channel:`person`,title:`A person`}],Lo={confirmed_failure:`fail`,policy_ambiguity:`warn`,potential_risk:`warn`,missing_evidence:`neutral`,expected_behaviour:`pass`},Ro=[`confirmed_failure`,`policy_ambiguity`,`potential_risk`,`missing_evidence`,`expected_behaviour`];function zo({page:e,tab:t,sub:r}){let i=Do.includes(t)?t:`agent`,[a,o]=i===`tests`&&r?r.split(`/`):[],s=a?n(a):``,c=(e,t)=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ln,{icon:jo[e],title:ko[e],description:Ao[e]}),t]});return(0,X.jsx)(wn,{page:e,title:Qt(`basal`),label:`BASAL`,current:i,tabHref:e=>$(e),onPick:e=>location.hash=$(e),tabs:Do.filter(e=>e!==An).map(e=>({id:e,label:Oo[e],icon:jo[e]})),agentBody:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(sn,{more:(0,X.jsxs)(X.Fragment,{children:[`Business testing that acts: BASAL works your question through the steps below, beside the product's knowledge graph, and ForgeQE's agents play each step as the people it affects. The product's knowledge graph and documents are read for every test; briefs and data files are added at a terminal with `,(0,X.jsx)(`code`,{className:`font-mono text-body-sm`,children:`forgeqe basal new --file`}),`. The graph store starts with `,(0,X.jsx)(`code`,{className:`font-mono text-body-sm`,children:`forgeqe graph setup`}),`.`]}),children:Ao.agent}),(0,X.jsx)(Wo,{}),(0,X.jsx)(cn,{scope:{kind:`page`,page:e}})]}),children:s?(0,X.jsx)(Ko,{id:s,step:Mo.includes(o)?o:void 0},s):i===`tests`?c(`tests`,(0,X.jsx)(Go,{})):i===`personas`?c(`personas`,(0,X.jsx)(cs,{})):i===`findings`?c(`findings`,(0,X.jsx)(ls,{})):null})}function Bo(){let[e,t]=(0,Y.useState)(null),[n,r]=(0,Y.useState)(``),i=(0,Y.useCallback)(()=>P.home().then(t,e=>r(e.message)),[]);return(0,Y.useEffect)(()=>void i(),[i]),{home:e,error:n,load:i}}function Vo({g:e}){return(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted tabular-nums`,children:e.connected?(0,X.jsxs)(X.Fragment,{children:[`Graph store: running · `,h(e.product||0,`product node`),` · `,h(e.scenario||0,`scenario node`),e.embedding?` · found by meaning with ${e.embedding}`:` · by words only (no embedding model)`]}):(0,X.jsxs)(X.Fragment,{children:[`Graph store: not running, so the product graph's file is read`,e.reason?` (${e.reason})`:``,`.`]})})}function Ho({home:e}){let[t,n]=(0,Y.useState)(``),[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(``),s=async()=>{i(!0),o(``);try{let{id:e}=await P.ask(t.trim());await P.stage(e,`understand`),location.hash=$(`tests`,`${e}/understand`)}catch(e){o(e.message)}finally{i(!1)}};return(0,X.jsxs)(J,{id:`basal-new`,icon:Se,title:`New business test`,divider:!1,className:d,children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Your business question`}),(0,X.jsx)(c,{id:`basal-request`,rows:3,value:t,onChange:e=>n(e.target.value),placeholder:`Should we launch saved cards with a fee? Test how merchants, shoppers and support would really be affected.`})]}),a&&(0,X.jsx)(rr,{text:a}),(0,X.jsx)(`div`,{children:(0,X.jsxs)(H,{busy:r,variant:`primary`,disabled:r||t.trim().length<10||!e.model,onClick:()=>void s(),"data-tip":e.model?`Keeps the question and starts step 02, Understand`:`Set up a model in Settings › Models first`,children:[(0,X.jsx)(Ae,{"aria-hidden":`true`}),r?`Starting…`:`Start`]})})]})}function Uo({tests:e,search:t=!0,tools:n}){return(0,X.jsx)(zt,{label:`Business tests`,placeholder:`Find a business test`,empty:`No business test yet. Ask a business question on the Agent tab.`,search:t,...t?{height:Jt}:{},...n?{tools:n}:{},head:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`th`,{scope:`col`,className:g(kt,`w-[55%]`),children:`Business question`}),(0,X.jsx)(`th`,{scope:`col`,className:g(kt,`hidden @xl:table-cell`),children:`Asked`}),(0,X.jsx)(`th`,{scope:`col`,className:g(Yt,`hidden @2xl:table-cell`),children:`Steps done`}),(0,X.jsx)(`th`,{scope:`col`,className:kt,children:`Stage`})]}),children:e.map(e=>{let t=Po[e.stage];return(0,X.jsxs)(`tr`,{onClick:()=>location.hash=$(`tests`,e.id),className:At,children:[(0,X.jsxs)(`td`,{className:g(Bt,`max-w-0`),children:[(0,X.jsx)(`a`,{href:$(`tests`,e.id),onClick:e=>e.stopPropagation(),"data-tip":e.request,className:`block truncate font-medium text-ink no-underline hover:underline`,children:e.request}),(0,X.jsx)(`span`,{className:`block truncate font-mono text-muted`,children:e.id})]}),(0,X.jsx)(`td`,{className:g(Bt,`hidden whitespace-nowrap text-muted @xl:table-cell`),children:e.created.slice(0,10)}),(0,X.jsx)(`td`,{className:g(It,`hidden text-muted @2xl:table-cell`),"data-sort":t??-1,children:t===void 0?`–`:`${t} of ${Mo.length}`}),(0,X.jsx)(`td`,{className:g(Bt,`whitespace-nowrap`),children:e.running?(0,X.jsx)(B,{tone:`running`,children:e.running}):(0,X.jsx)(B,{tone:`neutral`,children:e.stage})})]},e.id)})})}function Wo(){let{home:e,error:t}=Bo();return t?(0,X.jsx)(rr,{text:t}):e?(0,X.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,X.jsx)(`ol`,{"aria-label":`BASAL's steps`,className:`m-0 grid list-none gap-2 p-0 @[640px]:grid-cols-4 @[1040px]:grid-cols-8`,children:Mo.map((e,t)=>(0,X.jsxs)(`li`,{className:g(u,`flex items-center gap-2`),children:[(0,X.jsx)(Yn,{state:`pending`,n:t+1}),(0,X.jsx)(`span`,{className:`text-body-sm font-medium`,children:No[e].name})]},e))}),(0,X.jsx)(Vo,{g:e.graph}),(0,X.jsx)(Ho,{home:e}),e.tests.length>0&&(0,X.jsx)(J,{id:`basal-recent`,icon:me,title:`Recent tests`,actions:(0,X.jsx)(`a`,{href:$(`tests`),className:`text-body-sm font-normal`,children:`Every test`}),children:(0,X.jsx)(Uo,{tests:e.tests.slice(0,5),search:!1})})]}):(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Loading…`})}function Go(){let{home:e,error:t,load:n}=Bo();return t?(0,X.jsx)(rr,{text:t}):e?(0,X.jsx)(Uo,{tests:e.tests,tools:(0,X.jsxs)(H,{size:`sm`,variant:`ghost`,onClick:()=>void n(),className:`ml-auto`,"data-tip":`Read the tests again`,children:[(0,X.jsx)(Dt,{"aria-hidden":`true`}),`Refresh`]})}):(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Loading…`})}function Ko({id:e,step:t}){let[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(``),l=(0,Y.useCallback)(()=>P.test(e).then(r,e=>c(e.message)),[e]),u=(0,Y.useCallback)(()=>P.graph(e).then(a,e=>c(`The graph could not be read: ${e.message}`)),[e]);(0,Y.useEffect)(()=>{l(),u()},[l,u]);let f=!(!n?.job||n.job.endedAt);if((0,Y.useEffect)(()=>{if(!f)return;let e=Rt(()=>{l(),u()},2500);return()=>{jt(e),u()}},[f,l,u]),!n)return s?(0,X.jsx)(rr,{text:s}):(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Loading…`});let p=Po[n.stage],m=n.job&&!n.job.endedAt?Fo[n.job.stage]:-1,_=t||Mo[m>=0?m:Math.min(p,Mo.length-1)],v=Mo.indexOf(_),y=async(e,t)=>{c(``);try{await e(),await l(),t&&(location.hash=$(`tests`,`${n.id}/${t}`))}catch(e){c(e.message)}},b=e=>e===m?{tone:`running`,word:`Working`}:e<p?{tone:`pass`,word:`Completed`}:e===p?{tone:`warn`,word:`Next`}:{tone:`neutral`,word:`Waiting`},x=b(v);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(se,{to:{href:$(`tests`),label:`Every test`}}),(0,X.jsx)(`div`,{"data-tip":n.scenario?.decision||n.request.request,children:(0,X.jsx)(ln,{icon:pe,title:n.scenario?.decision||n.request.request,description:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`font-mono`,children:n.id}),` · asked `,n.request.created.slice(0,10),n.strategy?.environment?` · on ${n.strategy.environment}`:``,n.strategy?.approved?` · approved by ${n.strategy.approved.by}`:``]})})})]}),(0,X.jsx)(`nav`,{"aria-label":`BASAL's steps`,className:`overflow-x-auto`,children:(0,X.jsx)(`ol`,{className:`m-0 grid min-w-[800px] list-none grid-cols-8 gap-1 p-0`,children:Mo.map((e,t)=>{let r=b(t),i=t<=p||t===m,a=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Yn,{state:r.tone===`pass`?`done`:r.tone===`fail`?`failed`:r.tone===`running`?`running`:e===_?`current`:`pending`,n:t+1,className:`self-center`}),(0,X.jsx)(`span`,{className:`text-body-sm font-medium`,children:No[e].name})]}),(0,X.jsx)(B,{tone:r.tone,icon:r.tone===`running`,className:`self-start`,children:r.word})]});return(0,X.jsx)(`li`,{className:`min-w-0`,children:i?(0,X.jsx)(`a`,{href:$(`tests`,`${n.id}/${e}`),"aria-current":e===_?`step`:void 0,className:g(o,`h-full flex-col items-start gap-1`),children:a}):(0,X.jsx)(`span`,{className:`flex h-full flex-col gap-1 px-4 py-2 opacity-60`,children:a})},e)})})}),s&&(0,X.jsx)(rr,{text:s}),(0,X.jsxs)(`div`,{className:`grid items-start gap-4 @[960px]:grid-cols-[minmax(0,1fr)_minmax(0,1.15fr)]`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 @[960px]:sticky @[960px]:top-4`,children:[(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted tabular-nums`,children:i?.connected?`${h(i.nodes.length,`node`)} · ${h(i.edges.length,`edge`)} · scenario over the product graph`:`Graph store not connected`}),(0,X.jsx)($o,{graph:i,onRefresh:()=>void P.regraph(e).then(u,e=>c(e.message))})]}),(0,X.jsxs)(`section`,{"aria-labelledby":`basal-step`,className:g(d,`flex min-w-0 flex-col gap-4`),children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(B,{tone:`running`,icon:!1,className:`tabular-nums`,children:[`Step `,v+1,` of `,Mo.length]}),(0,X.jsx)(`h3`,{id:`basal-step`,className:`m-0 text-body-lg font-medium`,children:No[_].name}),(0,X.jsx)(`span`,{className:`ml-auto`,children:(0,X.jsx)(B,{tone:x.tone,children:x.word})})]}),(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-ink-2`,children:No[_].about}),n.job&&Fo[n.job.stage]===v&&(0,X.jsx)(Qo,{t:n}),(0,X.jsx)(qo,{step:_,t:n,onRun:y})]})]})]})}function qo({step:e,t,onRun:n}){let r=!(!t.job||t.job.endedAt),i=(e,t,i,a)=>(0,X.jsx)(`div`,{className:`pt-4`,children:(0,X.jsxs)(H,{variant:`primary`,disabled:r,onClick:()=>void n(i,a),"data-tip":t,children:[(0,X.jsx)(dt,{"aria-hidden":`true`}),e]})}),a=(e,n)=>(0,X.jsx)(`div`,{className:`pt-4`,children:(0,X.jsxs)(`a`,{href:$(`tests`,`${t.id}/${n}`),className:R({variant:`primary`}),children:[(0,X.jsx)(dt,{"aria-hidden":`true`}),e]})});return e===`ask`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:g(u,`m-0 text-body-sm text-ink [overflow-wrap:anywhere]`),children:t.request.request}),(0,X.jsx)(Ln,{label:`Files`,children:t.request.files.length?t.request.files.join(`, `):`none`}),(0,X.jsx)(Ln,{label:`Work items`,children:t.request.stories.length?t.request.stories.join(`, `):`none`}),(0,X.jsx)(Ln,{label:`Environment`,children:t.request.environment||`the active test environment`}),t.stage===`asked`?i(`Understand the question`,`Reads the request, its files and the product graph into the scenario`,()=>P.stage(t.id,`understand`),`understand`):a(`Next: Understand`,`understand`)]}):e===`understand`?t.scenario?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ss,{t}),t.stage===`understood`?i(`Plan the test strategy`,`Scenarios, the agent for each step, and the business expectations`,()=>P.stage(t.id,`strategy`),`strategy`):a(`Next: Strategy`,`strategy`)]}):(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`BASAL is reading the sources.`}):e===`strategy`?t.strategy?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(as,{t}),t.stage===`planned`?i(`Cast the personas`,`One persona for each stakeholder who acts in the strategy`,()=>P.stage(t.id,`cast`),`cast`):a(`Next: Cast`,`cast`)]}):(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`Not planned yet.`}):e===`cast`?t.cast.length?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(os,{t}),t.stage===`cast`?i(`Play round 1`,`The cast react to the decision on a feed; what they want to try picks the scenarios`,()=>P.stage(t.id,`rehearse`),`rehearse`):a(`Next: Rehearse`,`rehearse`)]}):(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`Not cast yet.`}):e===`rehearse`?(0,X.jsx)(Yo,{t,onRun:n}):e===`approve`?(0,X.jsx)(Xo,{t,onRun:n}):e===`act`?(0,X.jsx)(Zo,{t,onRun:n}):t.verdicts.length?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ts,{t,onObserve:(e,r,i)=>void n(()=>P.observe(t.id,{scenario:e,step:r,...i?{accepted:!0}:{refused:!0}}))}),t.cast.length>0&&i(`Next round: the cast react to these outcomes`,`Round `+(t.rounds.length+1)+`: what the agents saw goes back to the personas`,()=>P.stage(t.id,`rehearse`),`rehearse`)]}):(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`No verdict yet: the strategy has not been played.`})}var Jo={support:`pass`,oppose:`fail`,undecided:`neutral`};function Yo({t:e,onRun:t}){let n=!(!e.job||e.job.endedAt),r=new Map(e.cast.map(e=>[e.id,e.name])),i=e.rounds.at(-1),a=e.rounds.flatMap(e=>e.posts),o=new Map(a.map(e=>[e.id,e]));if(!i)return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`No round yet.`}),(0,X.jsx)(`div`,{className:`pt-4`,children:(0,X.jsxs)(H,{variant:`primary`,disabled:n||!e.cast.length,onClick:()=>void t(()=>P.stage(e.id,`rehearse`)),children:[(0,X.jsx)(Ae,{"aria-hidden":`true`}),`Play round 1`]})})]});let s={support:0,oppose:0,undecided:0};for(let e of i.turns)s[e.stance]=(s[e.stance]||0)+1;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`m-0 text-body-sm text-muted tabular-nums`,children:[`Round `,i.n,` · `,h(a.length,`post`),` on the feed · `,s.support,` support · `,s.oppose,` oppose · `,s.undecided,` undecided`,i.events.length?` · reacted to ${h(i.events.length,`outcome`)} on the product`:``]}),(0,X.jsx)(J,{icon:$e,title:`Feed`,level:3,children:(0,X.jsx)(`ol`,{className:`m-0 flex max-h-[420px] list-none flex-col gap-2 overflow-y-auto p-0`,children:a.toReversed().map(e=>(0,X.jsxs)(`li`,{className:g(d,`flex flex-col gap-1 text-body-sm`),children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:r.get(e.author)||e.author}),(0,X.jsxs)(`span`,{className:`text-muted`,children:[e.kind,e.target?` on ${r.get(o.get(e.target)?.author||``)||e.target}`:``,` · round `,e.round]})]}),(0,X.jsx)(`span`,{className:`text-ink-2 [overflow-wrap:anywhere]`,children:e.text})]},e.id))})}),(0,X.jsx)(J,{icon:U,title:(0,X.jsxs)(X.Fragment,{children:[`Where the cast stand after round `,i.n]}),level:3,children:(0,X.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0 text-body-sm`,children:i.turns.map(e=>(0,X.jsxs)(`li`,{className:`flex items-start justify-between gap-2`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`font-medium`,children:r.get(e.id)||e.id}),` `,(0,X.jsxs)(`span`,{className:`text-ink-2`,children:[`— `,e.feeling]})]}),(0,X.jsx)(B,{tone:Jo[e.stance]||`neutral`,icon:!1,children:e.stance})]},e.id))})}),e.wanted.length>0&&(0,X.jsx)(J,{icon:bt,title:`What the cast want tried`,level:3,className:`text-body-sm`,children:e.wanted.map(e=>(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`font-mono`,children:e.scenario}),` `,(0,X.jsxs)(`span`,{className:`text-muted`,children:[`· `,e.by.map(e=>r.get(e)||e).join(`, `)]})]},e.scenario))}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2 pt-4`,children:[(0,X.jsxs)(`a`,{href:$(`tests`,`${e.id}/${e.strategy?.approved?`act`:`approve`}`),className:R({variant:`primary`}),children:[(0,X.jsx)(dt,{"aria-hidden":`true`}),e.strategy?.approved?`Next: Act`:`Next: Approve`]}),(0,X.jsxs)(H,{variant:`outline`,disabled:n,onClick:()=>void t(()=>P.stage(e.id,`rehearse`)),children:[(0,X.jsx)(Ae,{"aria-hidden":`true`}),`Play round `,i.n+1]})]})]})}function Xo({t:e,onRun:t}){let[n,r]=(0,Y.useState)(``);if(e.strategy?.approved)return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`m-0 text-body-sm text-ink-2`,children:[`Approved by `,e.strategy.approved.by,` on `,e.strategy.approved.at.slice(0,16).replace(`T`,` `),`.`]}),(0,X.jsx)(`div`,{className:`pt-4`,children:(0,X.jsxs)(`a`,{href:$(`tests`,`${e.id}/act`),className:R({variant:`primary`}),children:[(0,X.jsx)(dt,{"aria-hidden":`true`}),`Next: Act`]})})]});let i=e.strategy;return(0,X.jsxs)(X.Fragment,{children:[i?(0,X.jsxs)(`ul`,{className:`m-0 flex flex-col gap-1 pl-6 text-body-sm text-ink-2`,children:[(0,X.jsxs)(`li`,{children:[h(i.scenarios.length,`scenario`),` on `,i.environment||`no test environment`,`, `,h(i.scenarios.reduce((e,t)=>e+t.steps.length,0),`step`)]}),(0,X.jsx)(`li`,{children:e.writes.length?`${h(e.writes.length,`step`)} change data: Act lists them for your agreement before anything runs`:`No step changes data`}),(0,X.jsxs)(`li`,{children:[`Plays on:`,` `,[...new Set(i.scenarios.flatMap(e=>e.steps.map(e=>e.app?`${e.app} (${is[e.channel]})`:is[e.channel])))].join(`, `)]}),i.needs.length>0&&(0,X.jsxs)(`li`,{className:`text-warn`,children:[h(i.needs.length,`thing`),` still needed: see Strategy`]})]}):null,(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Type the test's id to approve`}),(0,X.jsx)(a,{id:`basal-typed`,value:n,onChange:e=>r(e.target.value),placeholder:`Type the test's id`})]}),(0,X.jsx)(`span`,{className:`font-mono text-body-sm text-muted`,children:e.id}),(0,X.jsx)(`div`,{className:`pt-4`,children:(0,X.jsxs)(H,{variant:`primary`,disabled:n.trim()!==e.id||!i,onClick:()=>void t(()=>P.approve(e.id,n.trim()),`act`),children:[(0,X.jsx)(Tt,{"aria-hidden":`true`}),`Approve`]})})]})}function Zo({t:e,onRun:t}){let[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(!0),o=!(!e.job||e.job.endedAt);if(!e.strategy?.approved)return(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`Approve the strategy first.`});let s=i&&e.wanted.length?e.wanted.map(e=>e.scenario):[];return(0,X.jsxs)(X.Fragment,{children:[e.handovers.length>0&&(0,X.jsx)(es,{handovers:e.handovers}),!o&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 pt-4`,children:[e.wanted.length>0&&(0,X.jsxs)(`label`,{className:`flex min-h-9 cursor-pointer items-center gap-2 text-body-sm`,children:[(0,X.jsx)(on,{id:`basal-wanted`,checked:i,onCheckedChange:a}),`Only what the cast wants tried after round `,e.rounds.length,`: `,e.wanted.map(e=>e.scenario).join(`, `)]}),e.writes.length>0?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`m-0 text-body-sm text-ink-2`,children:[`These steps change data on `,e.strategy.environment,`. Without your agreement they are skipped and the agents change nothing.`]}),(0,X.jsx)(`ul`,{className:`m-0 flex flex-col gap-1 pl-4 text-body-sm text-warn`,children:e.writes.map(e=>(0,X.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:e},e))}),(0,X.jsxs)(`label`,{className:`flex min-h-9 cursor-pointer items-center gap-2 text-body-sm`,children:[(0,X.jsx)(on,{id:`basal-writes`,checked:n,onCheckedChange:r}),`Let these steps change data`]})]}):(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-ink-2`,children:`No step changes data.`}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsxs)(H,{variant:`primary`,onClick:()=>void t(()=>P.act(e.id,n?e.writes:[],s)),"data-tip":`Hands each step to ForgeQE's agents as its persona`,children:[(0,X.jsx)(Ae,{"aria-hidden":`true`}),e.verdicts.length?`Play it again`:`Act`]}),e.verdicts.length>0&&(0,X.jsxs)(`a`,{href:$(`tests`,`${e.id}/judge`),className:R({variant:`outline`}),children:[(0,X.jsx)(dt,{"aria-hidden":`true`}),`Next: Judge`]})]})]})]})}function Qo({t:e}){let t=e.job;return(0,X.jsxs)(J,{id:`basal-feed`,icon:ht,title:(0,X.jsxs)(X.Fragment,{children:[`Live · `,t.stage]}),level:3,className:d,actions:t.endedAt?(0,X.jsx)(B,{tone:t.error?`fail`:`pass`,children:t.error?`stopped`:`finished`}):(0,X.jsx)(B,{tone:`running`,children:`working`}),children:[(0,X.jsx)(`ol`,{"aria-live":`polite`,className:`m-0 flex max-h-64 list-none flex-col gap-1 overflow-y-auto p-0 text-body-sm text-ink-2`,children:t.lines.slice(-40).map((e,t)=>(0,X.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:e},t))}),t.error&&(0,X.jsx)(rr,{text:t.error})]})}function $o({graph:e,onRefresh:t}){let[n,r]=(0,Y.useState)(null),{nodes:i,edges:a,types:o}=(0,Y.useMemo)(()=>{let t=(e?.nodes||[]).map(e=>({id:e.id,name:e.type===`fact`?``:e.name.length>34?`${e.name.slice(0,32).trimEnd()}…`:e.name,type:e.layer===`product`?`product ${e.type}`:e.type}));return{nodes:t,edges:(e?.edges||[]).map((e,t)=>({id:`e${t}`,from:e.from,to:e.to,label:e.type})),types:[...new Set(t.map(e=>e.type))]}},[e]),s=e=>Fn[Math.max(0,o.indexOf(e))%Fn.length],c=null;if(n?.kind===`node`){let t=e?.nodes.find(e=>e.id===n.id);t&&(c={title:t.name,pill:{text:t.layer===`product`?`product ${t.type}`:t.type,colour:s(t.layer===`product`?`product ${t.type}`:t.type)},body:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`m-0 text-ink [overflow-wrap:anywhere]`,children:t.summary}),(0,X.jsx)(Ln,{label:`Layer`,children:t.layer}),t.state&&(0,X.jsx)(Ln,{label:`Evidence`,children:t.state})]})})}return e?.connected?i.length?(0,X.jsx)(In,{title:`Live knowledge graph`,nodes:i,edges:a,colourOfType:s,types:o,typesTitle:`Node types`,picked:n,onPick:r,detail:c,onRefresh:t}):(0,X.jsx)(ie,{icon:ze,title:`No scenario in the graph yet`,children:`It appears once BASAL has understood the question.`}):(0,X.jsx)(ie,{icon:ze,title:`The graph store is not connected`,children:e?.reason||`Start the graph store to see the scenario grow over the product graph. At a terminal: forgeqe graph setup.`})}function es({handovers:e}){let t=new Map;for(let n of e)t.set(`${n.scenario}#${n.step}`,n);let n=[...t.values()],r=e=>e.state===`started`?`running`:e.state===`waiting`?`warn`:e.state===`skipped`?`neutral`:e.outcome===`accepted`?`pass`:e.outcome===`refused`?`fail`:`neutral`,i=e=>e.state===`started`?`in progress`:e.state===`waiting`?`waiting for you`:e.state===`skipped`?`skipped`:e.outcome||`done`;return(0,X.jsx)(J,{id:`basal-board`,icon:Ye,title:`Operations board`,level:3,description:`Each card is a handover from BASAL to one of ForgeQE's agents, as one persona.`,children:(0,X.jsx)(`div`,{className:`grid gap-2 @[1200px]:grid-cols-2`,children:Io.filter(e=>n.some(t=>t.channel===e.channel)).map(e=>{let t=n.filter(t=>t.channel===e.channel);return(0,X.jsxs)(`div`,{className:g(u,`flex min-w-0 flex-col gap-2`),children:[(0,X.jsxs)(`h4`,{className:`m-0 px-2 pt-1 text-body-sm font-medium`,children:[e.title,` `,(0,X.jsxs)(`span`,{className:`font-normal text-muted`,children:[`· `,t.length]})]}),t.map(e=>(0,X.jsxs)(`div`,{className:g(d,`flex flex-col gap-1 text-body-sm`),children:[(0,X.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`truncate font-medium`,children:e.actor}),(0,X.jsx)(B,{tone:r(e),children:i(e)})]}),(0,X.jsxs)(`span`,{className:`text-muted`,children:[(0,X.jsx)(`span`,{className:`font-mono`,children:e.scenario}),` · step `,e.step]}),e.note&&(0,X.jsx)(`span`,{className:`text-ink-2 [overflow-wrap:anywhere]`,children:e.note}),e.run&&(0,X.jsx)(`span`,{className:`font-mono text-muted`,children:e.run})]},`${e.scenario}#${e.step}`))]},e.channel)})})})}function ts({t:e,onObserve:t}){let n=e.verdicts.toSorted((e,t)=>Ro.indexOf(e.outcome)-Ro.indexOf(t.outcome));return(0,X.jsx)(`section`,{"aria-label":`Verdicts`,className:`flex flex-col gap-2`,children:(0,X.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:n.map(e=>(0,X.jsx)(ns,{v:e,onObserve:(n,r)=>t(e.scenario,n,r)},e.scenario))})})}function ns({v:e,onObserve:t}){return(0,X.jsxs)(`li`,{className:g(d,`flex flex-col gap-2`),children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(B,{tone:Lo[e.outcome],children:e.label}),(0,X.jsx)(`span`,{className:`text-body-sm font-medium`,children:e.title}),(0,X.jsxs)(`span`,{className:`text-body-sm text-muted`,children:[`· confidence `,e.confidence]})]}),(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-ink-2 [overflow-wrap:anywhere]`,children:e.why}),e.results.length>0&&(0,X.jsx)(`ul`,{className:`m-0 flex flex-col gap-1 pl-4 text-body-sm`,children:e.results.map(e=>(0,X.jsxs)(`li`,{className:g(e.status===`violated`?`text-fail`:e.status===`held`?`text-ink`:`text-muted`),children:[e.status===`held`?`Held`:e.status===`violated`?`Broken`:`Not known`,`: `,e.says,e.detail?` — ${e.detail}`:``]},e.id))}),t&&e.pending.map(e=>(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-body-sm text-warn`,children:[`Step `,e,` waits for a person:`,(0,X.jsx)(H,{size:`sm`,variant:`outline`,onClick:()=>t(e,!0),children:`The app let them do it`}),(0,X.jsx)(H,{size:`sm`,variant:`outline`,onClick:()=>t(e,!1),children:`The app refused it`})]},e))]})}var rs=e=>e.map(e=>e.trim().replace(/(?<![.;])[.;]+$/,``)).join(`; `),is={browser:`browser`,api:`API`,mobile:`mobile`,desktop:`desktop`,person:`a person`,opinion:`opinion`};function as({t:e}){let t=e.strategy;return(0,X.jsxs)(`section`,{"aria-label":`Strategy`,className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`p`,{className:`m-0 text-body-sm text-muted`,children:[h(t.scenarios.length,`scenario`),` on `,t.environment||`no test environment`,` · `,h(t.rounds,`round`)]}),t.needs.length>0&&(0,X.jsx)(`ul`,{"aria-label":`What the strategy still needs`,className:`m-0 flex flex-col gap-1 pl-6 text-body-sm text-warn`,children:t.needs.map(e=>(0,X.jsx)(`li`,{children:e},e))}),(0,X.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:t.scenarios.map(e=>(0,X.jsxs)(`li`,{className:g(d,`flex flex-col gap-2`),children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(B,{tone:e.priority===1?`warn`:`neutral`,icon:!1,children:[`P`,e.priority,` · `,e.risk]}),(0,X.jsx)(`span`,{className:`text-body-sm font-medium`,children:e.title})]}),(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-ink-2`,children:e.question}),(0,X.jsx)(`ol`,{className:`m-0 flex flex-col gap-1 pl-6 text-body-sm`,children:e.steps.map(e=>(0,X.jsxs)(`li`,{className:`[overflow-wrap:anywhere]`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.actor}),` `,(0,X.jsxs)(`span`,{className:`text-muted`,children:[`· `,is[e.channel],e.app?` ${e.app}`:``,e.changes_data?` · changes data`:``]}),` — `,e.does]},e.n))}),e.oracles.length>0&&(0,X.jsx)(`ul`,{"aria-label":`Business expectations`,className:`m-0 flex flex-col gap-1 pl-4 text-body-sm text-ink-2`,children:e.oracles.map(e=>(0,X.jsxs)(`li`,{children:[e.says,` `,(0,X.jsxs)(`span`,{className:`text-muted`,children:[`(`,e.basis,`)`]})]},e.id))})]},e.id))})]})}function os({t:e}){return(0,X.jsx)(`section`,{"aria-label":`Cast`,className:`flex flex-col gap-2`,children:(0,X.jsx)(`ul`,{className:`m-0 grid list-none gap-2 p-0 @[1100px]:grid-cols-2`,children:e.cast.map(e=>(0,X.jsxs)(`li`,{className:g(d,`flex flex-col gap-1 text-body-sm`),children:[(0,X.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,X.jsx)(B,{tone:e.intent===`legitimate`?`neutral`:`warn`,icon:!1,children:e.intent})]}),(0,X.jsx)(`span`,{className:`text-muted`,children:e.role}),e.validates.length>0&&(0,X.jsxs)(`span`,{className:`text-ink-2`,children:[`Checks: `,rs(e.validates)]}),e.frustrations.length>0&&(0,X.jsxs)(`span`,{className:`text-ink-2`,children:[`Objects to: `,rs(e.frustrations)]}),e.mistakes.length>0&&(0,X.jsxs)(`span`,{className:`text-ink-2`,children:[`Brings: `,rs(e.mistakes)]})]},e.id))})})}function ss({t:e}){let t=e.scenario,n=e=>(0,X.jsx)(B,{tone:e===`observed`?`pass`:`neutral`,icon:!1,children:e});return(0,X.jsxs)(`section`,{"aria-label":`What BASAL understood`,className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[(0,X.jsxs)(`div`,{className:g(d,`flex flex-col gap-1 text-body-sm`),children:[(0,X.jsx)(ln,{icon:rt,title:`Success criteria`,level:3}),t.criteria.map(e=>(0,X.jsxs)(`span`,{className:`flex items-start justify-between gap-2`,children:[(0,X.jsxs)(`span`,{children:[e.text,e.measure?(0,X.jsxs)(`span`,{className:`text-muted`,children:[` (`,e.measure,`)`]}):null]}),n(e.evidence)]},e.id))]}),(0,X.jsxs)(`div`,{className:g(d,`flex flex-col gap-1 text-body-sm`),children:[(0,X.jsx)(ln,{icon:U,title:`Stakeholders`,level:3}),t.stakeholders.map(e=>(0,X.jsxs)(`span`,{className:`flex items-start justify-between gap-2`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.name}),` `,(0,X.jsxs)(`span`,{className:`text-muted`,children:[`· `,e.kind]}),` — `,e.cares]}),n(e.evidence)]},e.id))]})]}),(0,X.jsxs)(`div`,{className:g(d,`flex flex-col gap-1 text-body-sm`),children:[(0,X.jsx)(ln,{icon:et,title:`Facts (${t.facts.length})`,level:3}),t.facts.map(e=>(0,X.jsxs)(`span`,{className:`flex items-start justify-between gap-2`,children:[(0,X.jsxs)(`span`,{className:`[overflow-wrap:anywhere]`,children:[e.text,e.about.length?(0,X.jsxs)(`span`,{className:`text-muted`,children:[` → `,e.about.join(`, `)]}):null]}),n(e.evidence)]},e.id))]})]})}function cs(){let{home:e,error:t}=Bo(),[n,r]=(0,Y.useState)(null);return(0,Y.useEffect)(()=>{e&&Promise.all(e.tests.slice(0,8).map(e=>P.test(e.id).catch(()=>null))).then(e=>r(e.filter(e=>!!(e&&e.cast.length))))},[e]),t?(0,X.jsx)(rr,{text:t}):n?n.length?(0,X.jsx)(`div`,{className:`flex flex-col gap-6`,children:n.map(e=>(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`a`,{href:$(`tests`,e.id),className:`text-body-sm font-medium`,children:e.scenario?.decision||e.request.request}),(0,X.jsx)(os,{t:e})]},e.id))}):(0,X.jsx)(ie,{page:!0,icon:ze,title:`No cast yet`,action:(0,X.jsxs)(`a`,{className:R({size:`sm`}),href:$(`tests`),children:[(0,X.jsx)(dt,{"aria-hidden":`true`}),`Business tests`]}),children:`A test is cast after its strategy is planned.`}):(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Loading…`})}function ls(){let{home:e,error:t}=Bo(),[n,r]=(0,Y.useState)(null);return(0,Y.useEffect)(()=>{e&&Promise.all(e.tests.slice(0,12).map(e=>P.test(e.id).catch(()=>null))).then(e=>r(e.filter(e=>!!e).flatMap(e=>e.verdicts.map(t=>({t:e,v:t}))).sort((e,t)=>Ro.indexOf(e.v.outcome)-Ro.indexOf(t.v.outcome))))},[e]),t?(0,X.jsx)(rr,{text:t}):n?n.length?(0,X.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:n.map(({t:e,v:t})=>(0,X.jsx)(ns,{v:{...t,title:`${t.title} — ${e.scenario?.decision.slice(0,80)||e.id}`}},`${e.id}#${t.scenario}`))}):(0,X.jsx)(ie,{page:!0,icon:ze,title:`No verdict yet`,action:(0,X.jsxs)(`a`,{className:R({size:`sm`}),href:$(`tests`),children:[(0,X.jsx)(dt,{"aria-hidden":`true`}),`Business tests`]}),children:`A verdict appears when a test's strategy has been played.`}):(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Loading…`})}function us({to:e}){return(0,Y.useEffect)(()=>location.replace(`#${e.replace(/^#/,``)}`),[e]),null}function ds({id:e}){if(!e)return(0,X.jsx)(fn,{});let[t,n,a,...o]=e.split(`/`);if(t===`teams`&&n===`new`&&a===void 0)return(0,X.jsx)(Ra,{});if(t===`teams`&&n&&Vi.test(n)&&a===void 0)return(0,X.jsx)(Xa,{id:n},n);if(t===`custom`&&n===`new`&&a===`template`&&o.length===1&&/^[a-z][a-z0-9-]{0,39}$/.test(o[0]))return(0,X.jsx)(mi,{template:o[0]},o[0]);if(t===`custom`&&!o.length){if(n===`new`&&a===void 0)return(0,X.jsx)(ar,{});if(n===`new`&&a===`form`)return(0,X.jsx)(mi,{});if(n===`build`&&a&&/^[a-f0-9]{16}$/.test(a))return(0,X.jsx)(sr,{sid:a},a);if(n&&T.test(n)&&a===void 0)return(0,X.jsx)(hi,{id:n},n);if(n&&T.test(n)&&a===`edit`)return(0,X.jsx)(mi,{id:n},n)}let[s,c,...l]=(e||``).split(`/`);if(s===`business`)return(0,X.jsx)(us,{to:r(`agents`,`basal`)});if(s&&Object.hasOwn(O,s))return(0,X.jsx)(us,{to:r(`agents`,O[s])});let u=E(s),d=c===`tools`||c===`conversations`;return u?.id===`persona`&&c===void 0?(0,X.jsx)(Pn,{agent:u,tabs:(0,X.jsx)(no,{current:`agent`})},u.id):u?.id===`persona`&&!d?(0,X.jsx)(oo,{page:u,tab:c,sub:l.join(`/`)},`${u.id}/${c}`):u?.opens&&!d?(0,X.jsx)(fs,{to:c?r(...u.opens,...[c,...l].filter(e=>!!e)):i(u)}):u?.id===`basal`&&!d?(0,X.jsx)(zo,{page:u,tab:c,sub:l.join(`/`)},u.id):s===`category`&&!l.length&&k(c)?c===`custom`?(0,X.jsx)(fn,{only:`custom`},`custom`):(0,X.jsx)(fs,{to:r(`agents`)}):u&&c===`tools`&&!l.length?(0,X.jsx)(jn,{page:u},u.id):u&&c===`conversations`&&!l.length?(0,X.jsx)(dn,{page:u},u.id):!u||c!==void 0?(0,X.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,X.jsx)(Gt,{}),(0,X.jsxs)(`p`,{className:`m-0 px-6 py-10 text-body-sm text-muted`,children:[`There is no such agent. `,(0,X.jsx)(`a`,{href:r(`agents`),children:`See every agent`}),`, or `,(0,X.jsx)(`a`,{href:r(),children:`start a chat`}),` instead.`]})]}):(0,X.jsx)(Pn,{agent:u,below:(0,X.jsx)(xn,{page:u})},u.id)}function fs({to:e}){return(0,Y.useEffect)(()=>{location.replace(e)},[e]),null}export{ds as Agent};
|