@capagents/forgeqe 3.0.8 → 3.0.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 +19 -18
- package/dist/forgeqe.js +1848 -1822
- package/dist/web/assets/Agent-MlW7cfAm.js +7 -0
- package/dist/web/assets/AgentWork-BhepbEeU.js +2 -0
- package/dist/web/assets/ApiTests-mxUkUZvv.js +10 -0
- package/dist/web/assets/Browse-DENLuv4C.js +2 -0
- package/dist/web/assets/Chat-jxak1jci.js +3 -0
- package/dist/web/assets/{CommandPalette-Cm8lLnfi.js → CommandPalette-DMAmXPq1.js} +1 -1
- package/dist/web/assets/{Compare-D10RIrFU.js → Compare-DJNSrM2v.js} +1 -1
- package/dist/web/assets/Cost-CEOZgbPs.js +1 -0
- package/dist/web/assets/Data-COFRpcJn.js +6 -0
- package/dist/web/assets/Desktop-DGNdy7iS.js +1 -0
- package/dist/web/assets/DesktopReview-SdAwvi9y.js +1 -0
- package/dist/web/assets/Evidence-DTrdEz3M.js +1 -0
- package/dist/web/assets/{Explore-DOQ8KddV.js → Explore-DDXgQj5Q.js} +2 -2
- package/dist/web/assets/Features-BM5iXhOR.js +1 -0
- package/dist/web/assets/Flags-CkKp4bbv.js +2 -0
- package/dist/web/assets/Flaky-BqUHVLao.js +1 -0
- package/dist/web/assets/Impact-CA6s3POt.js +3 -0
- package/dist/web/assets/Jobs-B59p1qvn.js +5 -0
- package/dist/web/assets/KindPage-DPADNnwH.js +6 -0
- package/dist/web/assets/Migration-DtynahwR.js +2 -0
- package/dist/web/assets/PageAgent-CB8HtdGd.js +1 -0
- package/dist/web/assets/Product-wWMz2Nnk.js +7 -0
- package/dist/web/assets/Production-Nst6__N7.js +1 -0
- package/dist/web/assets/Quality-DgNo4H0u.js +1 -0
- package/dist/web/assets/Readiness--GiTxFZo.js +1 -0
- package/dist/web/assets/Record-a4whC1jV.js +1 -0
- package/dist/web/assets/Regression-hesOlN4G.js +5 -0
- package/dist/web/assets/{RelationGraph-ybf6gf-K.js → RelationGraph-C3Re0M1N.js} +1 -1
- package/dist/web/assets/Reports-C-NSlVAn.js +2 -0
- package/dist/web/assets/Response-CzX2rQEZ.js +9 -0
- package/dist/web/assets/RunDiff-CIdQD95y.js +1 -0
- package/dist/web/assets/Runs-DIDCOhbK.js +2 -0
- package/dist/web/assets/{Steps-BoSfaEHJ.js → Steps-BOWDBzu4.js} +2 -2
- package/dist/web/assets/TestCases-D-ZRb2N7.js +1 -0
- package/dist/web/assets/TestData-kXWCn7uZ.js +2 -0
- package/dist/web/assets/TestDebt-BvP3w7ye.js +1 -0
- package/dist/web/assets/TestManagement-CphGo9DZ.js +1 -0
- package/dist/web/assets/Tosca-dhFuqYxV.js +3 -0
- package/dist/web/assets/WhatsNew-DpJWNec7.js +1 -0
- package/dist/web/assets/agentTabs-BO5l3zw2.js +1 -0
- package/dist/web/assets/{dataParts-Bw4pl6JD.js → dataParts-DeUdfjjv.js} +2 -2
- package/dist/web/assets/{diff-CRxu9ARd.js → diff-D1_Qo2h1.js} +1 -1
- package/dist/web/assets/{families-D78NUxTI.js → families-DWilSDct.js} +1 -1
- package/dist/web/assets/filters-CVzIOjPG.js +1 -0
- package/dist/web/assets/{fold-DFcP0iIo.js → fold-BRxvbN9r.js} +1 -1
- package/dist/web/assets/frame-VTMu7MoC.js +13 -0
- package/dist/web/assets/index-CKRa-K2y.css +2 -0
- package/dist/web/assets/index-nuLrB-Rb.js +69 -0
- package/dist/web/assets/line-icons-C_amZ5-o.js +1 -0
- package/dist/web/assets/{logos-d0fFqQS2.js → logos-J6txZkKc.js} +1 -1
- package/dist/web/assets/{markdown-DIB_8ewG.js → markdown-CWisJbSJ.js} +7 -7
- package/dist/web/assets/paletteCommands-BmYmp6YY.js +1 -0
- package/dist/web/assets/parts-CDBCk_Xz.js +1 -0
- package/dist/web/assets/{productParts-BYAQJWF9.js → productParts-BxdHuSBa.js} +1 -1
- package/dist/web/assets/qualityParts-CGKSK9Dq.js +1 -0
- package/dist/web/assets/{recordTest-GM1nj_SM.js → recordTest-CcplpTS6.js} +1 -1
- package/dist/web/assets/{rows-CpFeqs4P.js → rows-yPc39hV7.js} +1 -1
- package/dist/web/index.html +6 -6
- package/docs/TEST_MANAGEMENT_PLAN.md +186 -15
- package/package.json +2 -1
- package/prompts/README.md +1 -0
- package/prompts/test-linker.md +43 -0
- package/py/forgeqe_testmgmt/__init__.py +1 -0
- package/py/forgeqe_testmgmt/pytest_collect.py +56 -0
- package/dist/web/assets/Agent-BgpsSPrr.js +0 -7
- package/dist/web/assets/AgentWork-VRJbVshA.js +0 -2
- package/dist/web/assets/ApiTests-DHwAbLqi.js +0 -10
- package/dist/web/assets/Browse-BMF56Efz.js +0 -2
- package/dist/web/assets/Chat-CaUU-WY7.js +0 -3
- package/dist/web/assets/Cost-B_UPdLMv.js +0 -1
- package/dist/web/assets/Data-C4H5sYEC.js +0 -6
- package/dist/web/assets/Desktop-bLj_WL8M.js +0 -1
- package/dist/web/assets/DesktopReview-Bl9TCBkR.js +0 -1
- package/dist/web/assets/Evidence-Cp1HUzpL.js +0 -1
- package/dist/web/assets/Features-RCBkPcEQ.js +0 -1
- package/dist/web/assets/Flags-n0IwBw02.js +0 -2
- package/dist/web/assets/Flaky-BfwzLt5Z.js +0 -1
- package/dist/web/assets/Impact-DLpuEZSR.js +0 -3
- package/dist/web/assets/Jobs-BdXmyaEl.js +0 -5
- package/dist/web/assets/KindPage-B3aoqE1U.js +0 -6
- package/dist/web/assets/Migration-CZyx2ubc.js +0 -2
- package/dist/web/assets/PageAgent-D5ZEQOQe.js +0 -1
- package/dist/web/assets/Product-BZe62mCa.js +0 -7
- package/dist/web/assets/Production-D0PyJr7i.js +0 -1
- package/dist/web/assets/Quality-k-6G5B1k.js +0 -1
- package/dist/web/assets/Readiness-InUynp50.js +0 -1
- package/dist/web/assets/Record-DIprTx7M.js +0 -1
- package/dist/web/assets/Regression-CWk9uEE7.js +0 -5
- package/dist/web/assets/Reports-BYOTLZah.js +0 -2
- package/dist/web/assets/Response-BC4GgybP.js +0 -9
- package/dist/web/assets/RunDiff-B0sRO9OI.js +0 -1
- package/dist/web/assets/Runs-Dy_fBhhR.js +0 -2
- package/dist/web/assets/TestCases-D4xZlPgR.js +0 -1
- package/dist/web/assets/TestData-CXDU1gv4.js +0 -2
- package/dist/web/assets/TestDebt-Cc5ODjR-.js +0 -1
- package/dist/web/assets/TestManagement-Cdj_o5D6.js +0 -1
- package/dist/web/assets/Tosca-CfgkdgcT.js +0 -3
- package/dist/web/assets/WhatsNew-DVzuub1d.js +0 -1
- package/dist/web/assets/agentTabs-CmOYLCIU.js +0 -1
- package/dist/web/assets/filters-D2j1h_NS.js +0 -1
- package/dist/web/assets/frame-Cr9XkzMf.js +0 -13
- package/dist/web/assets/index-C5JQ2Q4O.js +0 -69
- package/dist/web/assets/index-CpHco9gF.css +0 -2
- package/dist/web/assets/line-icons-Cb4JZG1G.js +0 -1
- package/dist/web/assets/paletteCommands-COA2_LAh.js +0 -1
- package/dist/web/assets/parts-Dsb4bByj.js +0 -1
- package/dist/web/assets/qualityParts-DyfqNmRK.js +0 -1
- package/dist/web/assets/segmented-BbcK9lLg.js +0 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{An as e,B as t,Dr as n,E as r,En as i,Fn as a,Ir as o,Jn as s,L as c,Ln as l,M as u,N as d,Nn as f,Nr as p,O as m,On as h,Rn as g,Wn as _,Xn as v,Y as y,_t as b,a as x,ar as S,er as C,gr as w,j as T,m as E,nt as D,o as O,sr as k,tn as ee,vt as te,w as A,wr as ne,xr as re,yr as ie,zr as ae}from"./line-icons-C_amZ5-o.js";import{$ as oe,$t as se,B as j,G as ce,H as M,J as le,K as ue,Mt as N,Q as de,V as P,a as F,at as fe,c as I,d as pe,f as me,g as L,h as he,i as ge,it as R,l as z,nt as _e,o as ve,p as B,q as ye,r as be,s as V,st as xe,t as Se,ut as H,v as Ce,z as U}from"./filters-CVzIOjPG.js";import{$ as we,An as Te,Bn as W,Bt as Ee,Cn as De,En as Oe,Fn as ke,Gn as Ae,H as G,Hn as je,Ht as Me,In as Ne,It as Pe,Mn as Fe,Nn as Ie,Pn as Le,Q as Re,Rn as ze,Rt as Be,Sn as Ve,Tn as He,Un as Ue,Ut as We,V as K,Vn as Ge,Vt as q,Wn as Ke,X as qe,Yt as Je,Z as Ye,_n as Xe,a as Ze,at as Qe,bn as $e,bt as et,et as tt,ft as nt,jn as rt,nt as it,o as at,pt as ot,st,t as ct,xn as lt,zn as ut}from"./frame-VTMu7MoC.js";import{E as dt,F as ft,I as pt,L as mt,N as ht,P as gt,S as _t,T as vt,U as yt,_ as bt,c as xt,g as St,l as Ct,r as wt,s as Tt,u as Et,v as Dt,w as Ot,x as kt,z as At}from"./index-nuLrB-Rb.js";import{i as jt,t as Mt}from"./rows-yPc39hV7.js";import{t as Nt}from"./diff-D1_Qo2h1.js";import{c as J}from"./dataParts-DeUdfjjv.js";import{n as Pt,t as Ft}from"./agentTabs-BO5l3zw2.js";import{a as It,i as Lt,n as Rt}from"./RelationGraph-C3Re0M1N.js";var Y=ae(o(),1),X=se(),zt=`forgeqe-agent-favourites`,Bt=`forgeqe-agent-favourites`;function Vt(){let e=()=>{try{return ze(localStorage.getItem(zt))}catch{return[]}},[t,n]=(0,Y.useState)(e);return(0,Y.useEffect)(()=>{let t=()=>n(e());return window.addEventListener(Bt,t),window.addEventListener(`storage`,t),()=>{window.removeEventListener(Bt,t),window.removeEventListener(`storage`,t)}},[]),{favs:t,toggle:e=>{let r=t.includes(e)?t.filter(t=>t!==e):[...t,e];n(r);try{localStorage.setItem(zt,JSON.stringify(r)),window.dispatchEvent(new Event(Bt))}catch{}Be(`favourites`)}}}var Ht={attention:{label:`Needs attention`,tone:`fail`},partial:{label:`Partly set up`,tone:`warn`},ready:{label:`Ready`,tone:`pass`},unavailable:{label:`Unavailable`,tone:`neutral`}},Ut={pass:`bg-pass`,warn:`bg-warn`,fail:`bg-fail`,neutral:`bg-line-strong`,running:`bg-accent`},Wt=(e,t)=>{let n=Fe(e),r=t?.[n.agent];return{fav:n.id,href:pe(n),name:Le(n.agent).name,about:n.about,short:n.short,icon:(0,X.jsx)(We,{agent:n.agent,px:44,iconPx:24,frame:Yt}),tags:r?.tags??[],...r?{status:r.status}:{},note:r?.note??``}},Gt={active:{label:`Active`,tone:`pass`},changed:{label:`Change waiting`,tone:`warn`},draft:{label:`Draft`,tone:`neutral`},invalid:{label:`Needs fixing`,tone:`fail`},broken:{label:`Cannot run`,tone:`fail`},disabled:{label:`Disabled`,tone:`neutral`}},Kt={active:`ready`,changed:`partial`,draft:`partial`,invalid:`attention`,broken:`attention`,disabled:`unavailable`},qt=e=>({fav:Ie(e.id),href:B(`agents`,`custom`,e.id),name:e.name,about:e.description||`No description yet.`,short:e.description||Gt[e.state].label,icon:(0,X.jsx)(We,{agent:e.id,icon:e.icon,px:44,iconPx:24,frame:Yt}),status:Kt[e.state],note:Gt[e.state].label,tags:[...e.state===`active`?[]:[Gt[e.state].label],...e.approvedVersion?[`v${e.approvedVersion}`]:[],...e.problems?[`${e.problems} problem${e.problems===1?``:`s`}`]:[]]});function Jt({cards:e}){let t=Object.values(e||{});if(!t.length||t.some(e=>e.status!==`unavailable`))return null;let n=[...new Set(t.map(e=>(e.note||``).replace(/:\s*Set up\.?$/,``).trim()).filter(Boolean))],r=n.length>0&&n.every(e=>/^No model/i.test(e));return(0,X.jsxs)(`div`,{role:`status`,className:`flex w-full flex-wrap items-center gap-x-4 gap-y-4 border-y border-line py-4`,children:[(0,X.jsx)(L,{icon:l,size:20,className:`flex-none text-accent-fg`}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-[1_1_280px] flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`No agent can run yet`}),(0,X.jsx)(`span`,{className:`text-sm text-muted [overflow-wrap:anywhere]`,children:n.length?n.join(` · `):`ForgeQE is not set up on this computer.`})]}),(0,X.jsxs)(`a`,{className:j({variant:`primary`}),href:r?B(`settings`,`models`):B(`settings`,`setup`),"data-tip":r?`Add a model key`:`Install what's missing`,children:[(0,X.jsx)(s,{"aria-hidden":`true`}),`Set up`]})]})}var Yt=`flex size-10 flex-none items-center justify-center rounded-[10px] @min-[260px]/col:size-11 bg-surface-strong`;function Xt({item:e,favs:t}){let n=t.favs.includes(e.fav),r=e.status?Ht[e.status]:void 0,i=[e.about,r&&`${r.label}${e.note?`: ${e.note}`:``}`,e.tags.length?e.tags.join(`, `):``].filter(Boolean).join(`
|
|
2
|
+
`);return(0,X.jsxs)(`li`,{className:`relative`,children:[(0,X.jsxs)(`a`,{href:e.href,"data-tip":i,className:`flex min-h-[68px] items-center gap-2 rounded-[12px] py-2 pr-8 pl-2 @min-[260px]/col:gap-4 @min-[260px]/col:pl-2 @min-[260px]/col:pr-10 text-ink no-underline hover:bg-surface-strong hover:text-ink`,children:[e.icon,(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:[(0,X.jsx)(`span`,{className:`line-clamp-2 text-[13px] leading-tight font-semibold @min-[260px]/col:text-[16px]`,children:e.name}),r&&(0,X.jsx)(`span`,{className:P(`size-[7px] flex-none rounded-full`,Ut[r.tone]),"aria-hidden":`true`})]}),(0,X.jsx)(`span`,{className:`truncate text-[13px] text-muted`,children:e.short}),(0,X.jsxs)(`span`,{className:`sr-only`,children:[r?`${r.label}${e.note?`: ${e.note}`:``}. `:``,e.about,e.tags.length?` ${e.tags.join(`, `)}.`:``]})]})]}),(0,X.jsx)(U,{variant:`icon`,size:`icon`,"aria-pressed":n,"aria-label":n?`Remove ${W(e.name)} from favourites`:`Add ${W(e.name)} to favourites`,"data-tip":n?`Remove from favourites`:`Add to favourites`,onClick:()=>t.toggle(e.fav),className:P(`absolute top-1/2 right-0 size-8 -translate-y-1/2`,n?`text-ink`:`text-muted`),children:(0,X.jsx)(k,{size:14,strokeWidth:1.8,fill:n?`currentColor`:`none`,"aria-hidden":`true`})})]})}function Zt({level:e}){return(0,X.jsx)(`span`,{role:`img`,"aria-label":`Autonomy ${e} of 3`,"data-tip":[``,`Helps you decide`,`Makes the work itself`,`Acts on its own`][e],className:`ml-auto flex items-end gap-1`,children:[1,2,3].map(t=>(0,X.jsx)(`span`,{className:P(`w-[4px] rounded-[1px]`,t<=e?`bg-accent`:`bg-line`),style:{height:4+t*4}},t))})}var Qt={assisted:1,native:2,agentic:3};function $t({id:e,title:t,short:n,about:r,items:i,empty:a,favs:o,footer:s}){return(0,X.jsxs)(`section`,{"aria-labelledby":`agents-${e}`,className:`@container/col flex min-w-0 flex-col`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-line px-2 pt-1 pb-4 mb-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(`h2`,{id:`agents-${e}`,"data-tip":r,className:`m-0 text-[16px] font-semibold`,children:[t,(0,X.jsx)(`span`,{className:`ml-2 text-[13px] font-normal text-muted tabular-nums`,children:i.length})]}),Qt[e]&&(0,X.jsx)(Zt,{level:Qt[e]})]}),(0,X.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:n}),r&&(0,X.jsx)(`p`,{className:`sr-only`,children:r})]}),i.length?(0,X.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0`,children:i.map(e=>(0,X.jsx)(Xt,{item:e,favs:o},e.fav))}):(0,X.jsx)(z,{center:!0,className:`py-10`,action:s,children:a}),s&&i.length>0&&(0,X.jsx)(`div`,{className:`pt-2`,children:s})]})}function en({items:e,value:t,onChange:n}){return(0,X.jsx)(`div`,{role:`group`,"aria-label":`Show`,className:`flex flex-wrap gap-2`,children:e.map(e=>{let r=t===e.id;return(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>n(e.id),className:P(`inline-flex h-9 cursor-pointer items-center gap-2 rounded-[8px] border px-4 text-[13px] font-medium`,r?`border-accent bg-accent-soft text-ink`:`border-transparent bg-surface-strong text-ink hover:bg-line`),children:[e.tone&&(0,X.jsx)(`span`,{className:P(`size-2 rounded-[2px]`,Ut[e.tone]),"aria-hidden":`true`}),e.label,e.n!==void 0&&(0,X.jsx)(`span`,{className:P(`tabular-nums`,r?`opacity-70`:`text-muted`),children:e.n})]},e.id)})})}var tn=`favourites`;function nn(){return(0,X.jsxs)(`a`,{href:B(`agents`,`custom`,`new`),className:P(j({variant:`primary`}),`no-underline`),"data-tip":`New agent`,children:[(0,X.jsx)(f,{"aria-hidden":`true`}),`New`]})}function rn({onDone:e}){let[t,n]=(0,Y.useState)(!1),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(!1),[g,_]=(0,Y.useState)(``),v=(0,Y.useRef)(null),y=()=>{i(null),o(``),c(``),u(null),f(!1),_(``)},b=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let e=String(r.result||``),n=e.indexOf(`,`);t(n>=0?e.slice(n+1):e)},r.onerror=()=>n(r.error||Error(`Could not read the package.`)),r.readAsDataURL(e)}),x=async e=>{if(_(``),u(null),e.size>4194304)_(`The package is larger than 4 MB.`);else try{let t=await b(e);i(t),o(e.name);let n=await H.importPreview(t);u(n),c(n.id||``)}catch(e){i(null),_(e.message||`That file is not a valid package.`)}},S=async e=>{if(r){h(!0),_(``);try{let t=await H.importPreview(r,e.trim()||void 0);u(t)}catch(e){_(e.message)}finally{h(!1)}}},C=async()=>{if(r&&l){h(!0),_(``);try{let t=await H.importPack(r,{id:s.trim()||void 0,overwriteKnowledge:d});n(!1),y(),e(t.id)}catch(e){_(e.message)}finally{h(!1)}}},w=l?[...l.missing.environments.map(e=>`environment ${e}`),...l.missing.systems.map(e=>`system ${e}`),...l.missing.capabilities.map(e=>`capability ${e}`),...l.missing.skills.map(e=>`skill ${e}`),...l.missing.knowledge.map(e=>`knowledge ${e}`)]:[],T=!(!l||l.problems.length||l.idTaken);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(U,{size:`sm`,variant:`ghost`,onClick:()=>(n(!0),y()),"data-tip":`Import agent`,children:[(0,X.jsx)(re,{"aria-hidden":`true`}),`Import`]}),(0,X.jsx)(q,{open:t,onClose:()=>(n(!1),y()),title:`Import a custom agent`,description:`A .forgeqe-agent.zip from Export to share (agent.json plus knowledge and skill files). It becomes a draft here: you edit, try and approve it. Environments and systems of this project must already exist.`,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(U,{variant:`ghost`,onClick:()=>(n(!1),y()),children:[(0,X.jsx)(p,{"aria-hidden":`true`}),`Cancel`]}),(0,X.jsxs)(U,{variant:`primary`,disabled:m||!T||l?.warnings.some(e=>e.includes(`already exists here`)&&e.startsWith(`knowledge`))&&!d,onClick:()=>void C(),"data-tip":`Import as draft`,children:[(0,X.jsx)(re,{"aria-hidden":`true`}),`Import`]})]}),children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-4 text-sm`,children:[(0,X.jsx)(`input`,{ref:v,type:`file`,accept:`.zip,application/zip`,className:`sr-only`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&x(t)}}),(0,X.jsxs)(U,{size:`sm`,className:`self-start`,onClick:()=>v.current?.click(),"data-tip":a?`Choose another file`:`Choose .zip package`,children:[(0,X.jsx)(te,{"aria-hidden":`true`}),`Choose`]}),a&&(0,X.jsx)(`span`,{className:`text-muted`,children:a}),l&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Id`}),(0,X.jsx)(F,{value:s,maxLength:40,spellCheck:!1,onChange:e=>c(e.target.value.toLowerCase()),onBlur:()=>void S(s)}),l.idTaken&&(0,X.jsx)(`span`,{className:`text-[13px] text-warn`,children:`That id is taken here. Choose another before importing.`})]}),l.knowledge.length>0&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Knowledge it brings`}),(0,X.jsx)(`ul`,{className:`m-0 list-disc pl-6 text-ink-2`,children:l.knowledge.map(e=>(0,X.jsx)(`li`,{children:e.path},e.path))})]}),l.skills.length>0&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Skills it brings`}),(0,X.jsx)(`ul`,{className:`m-0 list-disc pl-6 text-ink-2`,children:l.skills.map(e=>(0,X.jsx)(`li`,{children:e.name},e.name))})]}),w.length>0&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-[12px] bg-warn-soft px-4 py-2 text-warn`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`This project still needs`}),(0,X.jsx)(`ul`,{className:`m-0 list-disc pl-6`,children:w.map(e=>(0,X.jsx)(`li`,{children:e},e))})]}),l.warnings.some(e=>e.startsWith(`knowledge file `)&&e.endsWith(` already exists here`))&&(0,X.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Tt,{checked:d,onCheckedChange:f}),`Replace existing knowledge files of the same path`]}),l.problems.length>0&&(0,X.jsx)(`ul`,{className:`m-0 list-disc pl-6 text-fail`,children:l.problems.map((e,t)=>(0,X.jsx)(`li`,{children:e},t))})]}),g&&(0,X.jsx)(`p`,{className:`m-0 text-fail`,children:g})]})})]})}function an(){let[e,t]=(0,Y.useState)(null),[n,r]=(0,Y.useState)(``),[i,a]=(0,Y.useState)(``);return(0,Y.useEffect)(()=>{let e=!1;return H.list().then(n=>{e||(ut(n.agents,`replace`),t(n.agents),a(n.off||``))},n=>{e||(t([]),r(n.message))}),()=>{e=!0}},[]),{rows:e,error:n,off:i,setRows:t}}function on(){return(0,X.jsxs)(`p`,{role:`status`,className:`m-0 flex flex-wrap items-center gap-x-2 rounded-[12px] bg-surface-muted px-4 py-4 text-sm text-ink-2`,children:[`Custom agents are turned off for this project: none runs, from here, the terminal, Atlas or a schedule.`,(0,X.jsx)(`a`,{href:B(`settings`),children:`Turn them on in Settings, Custom agents`})]})}function sn({rows:e,onDone:t}){let[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)([]),[o,s]=(0,Y.useState)(null),[l,d]=(0,Y.useState)(``),[f,m]=(0,Y.useState)(!1),[h,g]=(0,Y.useState)(``),_=e.filter(e=>e.approvedVersion);if(!_.length)return null;let v=_.filter(e=>i.includes(e.id)),y=async()=>{if(o){m(!0);try{let e=await H.bulk(o,i,l);t(e.agents),g(`${o===`disable`?`Disabled`:`Enabled`} ${e.done.length}${e.skipped.length?`; skipped ${e.skipped.map(e=>e.id).join(`, `)} (already ${o}d)`:``}.`),s(null),a([]),r(!1)}catch(e){g(e.message)}finally{m(!1),d(``)}}};return(0,X.jsxs)(`section`,{"aria-labelledby":`custom-bulk`,className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`h2`,{id:`custom-bulk`,className:`m-0 flex-1 text-[13px] font-semibold text-muted`,children:`Disable or enable several`}),(0,X.jsxs)(U,{size:`sm`,variant:`ghost`,onClick:()=>(r(!n),a([]),g(``)),"data-tip":n?void 0:`Select agents`,children:[n?(0,X.jsx)(p,{"aria-hidden":`true`}):(0,X.jsx)(ee,{"aria-hidden":`true`}),n?`Cancel`:`Select`]})]}),n&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-[12px] card border p-4`,children:[(0,X.jsxs)(`label`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,X.jsx)(Tt,{checked:i.length===_.length,onCheckedChange:e=>a(e?_.map(e=>e.id):[])}),`All `,_.length,` approved agents`]}),(0,X.jsx)(`ul`,{className:`m-0 grid list-none grid-cols-1 gap-2 p-0 sm:grid-cols-2`,children:_.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,X.jsx)(Tt,{checked:i.includes(e.id),onCheckedChange:t=>a(t?[...i,e.id]:i.filter(t=>t!==e.id))}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name}),(0,X.jsx)(I,{tone:Gt[e.state].tone,icon:!1,children:Gt[e.state].label})]})},e.id))}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsxs)(U,{size:`sm`,disabled:!i.length,onClick:()=>s(`disable`),children:[(0,X.jsx)(c,{"aria-hidden":`true`}),i.length?`Disable (${i.length})`:`Disable`]}),(0,X.jsxs)(U,{size:`sm`,variant:`ghost`,disabled:!i.length,onClick:()=>s(`enable`),children:[(0,X.jsx)(u,{"aria-hidden":`true`}),i.length?`Enable (${i.length})`:`Enable`]})]})]}),h&&(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-[13px] text-muted`,children:h}),o&&(0,X.jsx)(q,{open:!0,onClose:()=>(s(null),d(``)),title:`${o===`disable`?`Disable`:`Enable`} ${v.length} agent${v.length===1?``:`s`}`,description:o===`disable`?`None of them runs (not you, your team, Atlas or their schedules) until a person enables it again. Their versions and history are kept.`:`Their approved versions run again, and their schedules come back.`,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(U,{variant:`ghost`,onClick:()=>(s(null),d(``)),children:[(0,X.jsx)(p,{"aria-hidden":`true`}),`Cancel`]}),(0,X.jsxs)(U,{variant:`primary`,disabled:f||l!==String(v.length),onClick:()=>void y(),children:[o===`disable`?(0,X.jsx)(c,{"aria-hidden":`true`}):(0,X.jsx)(u,{"aria-hidden":`true`}),o===`disable`?`Disable`:`Enable`]})]}),children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-4 text-sm`,children:[(0,X.jsx)(`span`,{className:`text-ink-2`,children:v.map(e=>e.name).join(`, `)}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`span`,{children:[`Type `,v.length,` to confirm`]}),(0,X.jsx)(F,{value:l,onChange:e=>d(e.target.value),autoComplete:`off`,inputMode:`numeric`})]})]})})]})}function cn({only:e}){let t=Vt(),n=an(),[r,i]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{oe.directory().then(e=>i(e.agents),()=>i({}))},[]);let[a,o]=(0,Y.useState)([]);(0,Y.useEffect)(()=>{_e.list().then(e=>o(e.approvals.filter(e=>e.state===`waiting`)),()=>{})},[]);let[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(`all`),d=e?Oe.find(t=>t.id===e):void 0,p=(0,Y.useMemo)(()=>ke(s,d?.id),[s,d]),m=(0,Y.useMemo)(()=>!d||d.id===`custom`?Ne(n.rows||[],s):[],[n.rows,s,d]),h=e=>e===`custom`?m.map(qt):p.filter(t=>t.category===e).map(e=>Wt(e.id,r)),g=e=>[...e.filter(e=>t.favs.includes(e.fav)),...e.filter(e=>!t.favs.includes(e.fav))],_=(d?[d]:Oe).map(e=>({c:e,all:g(h(e.id))})),v=_.flatMap(e=>e.all),y=e=>l===`all`||(l===tn?t.favs.includes(e.fav):e.status===l),b=e=>v.filter(t=>t.status===e).length,x=[{id:`all`,label:`All`,n:v.length},...[`attention`,`partial`,`ready`,`unavailable`].filter(e=>b(e)>0||e!==`unavailable`).map(e=>({id:e,label:Ht[e].label,n:b(e),tone:Ht[e].tone})),{id:tn,label:`Favourites`,n:v.filter(e=>t.favs.includes(e.fav)).length}],S=l!==`all`||!!s.trim(),C=(e,t)=>S?`None here.`:e===`custom`?n.rows===null?`Reading your custom agents…`:n.error?`Your custom agents cannot be read: ${n.error}`:(0,X.jsxs)(`span`,{className:`flex flex-col items-center gap-2`,children:[(0,X.jsx)(Ce,{name:$e.agents,px:22}),(0,X.jsx)(`span`,{className:`text-[16px] font-medium text-ink`,children:`No custom agents yet`}),(0,X.jsx)(`span`,{children:`Make one for a job your team repeats.`})]}):`No ${t.toLowerCase()} yet.`;return(0,X.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,X.jsx)(at,{}),(0,X.jsxs)(`main`,{className:P(ct,`max-w-[1400px] flex-auto gap-4`),children:[d?(0,X.jsx)(St,{href:B(`agents`),label:`All agents`}):(0,X.jsx)(bt,{}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-6 gap-y-4`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-[1_1_480px] flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,X.jsx)(et,{pixel:$e.agents,size:`lg`}),(0,X.jsx)(`h1`,{className:`m-0 text-[25px] font-semibold tracking-[-0.01em]`,children:d?d.label:`Agents`})]}),(0,X.jsx)(`p`,{className:`m-0 text-[13px] leading-relaxed text-ink-2`,children:d?d.about:`Open an agent to work with it and see what it can do.`})]}),(!d||d.id===`custom`)&&!n.off&&(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 self-center`,children:[(0,X.jsx)(rn,{onDone:e=>{H.list().then(e=>{ut(e.agents,`replace`),n.setRows(e.agents)}),location.hash=B(`agents`,`custom`,e)}}),(0,X.jsx)(nn,{})]})]}),(0,X.jsx)(Jt,{cards:r}),a.length>0&&(0,X.jsx)(`a`,{href:B(`agents`,`custom`,a[0].agent),role:`status`,className:`flex items-center gap-2 self-start rounded-[12px] bg-warn-soft px-4 py-2 text-sm font-medium text-warn no-underline hover:text-warn`,children:a.length===1?`${a[0].agent} is waiting for your approval`:`${a.length} requests from your agents are waiting for your approval`}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(ge,{id:`agents-search`,label:d?`Find an agent in ${d.label}`:`Find an agent`,value:s,onChange:c}),(0,X.jsx)(`span`,{className:`mx-2 hidden h-6 w-px bg-line sm:block`,"aria-hidden":`true`}),(0,X.jsx)(en,{items:x,value:l,onChange:u})]}),n.off&&(!d||d.id===`custom`)&&(0,X.jsx)(on,{}),d?.id===`custom`&&n.rows&&(0,X.jsx)(sn,{rows:n.rows,onDone:n.setRows}),(0,X.jsx)(`div`,{className:`@container`,children:(0,X.jsx)(`div`,{className:P(`grid items-start gap-x-6 gap-y-8`,d?`max-w-[720px] grid-cols-1`:`grid-cols-1 @2xl:grid-cols-2 @5xl:grid-cols-4`),children:_.map(({c:e,all:r})=>(0,X.jsx)($t,{id:e.id,title:e.label,short:e.short,about:e.id===`custom`?`Agents your team makes for its own work, held to the environments and actions you choose.`:e.about,items:r.filter(y),empty:C(e.id,e.label),favs:t,footer:e.id===`custom`&&!n.off&&!S?(0,X.jsxs)(`a`,{href:B(`agents`,`custom`,`new`),className:P(j({variant:`outline`,size:`sm`}),`justify-center gap-2 no-underline`,(n.rows?.length??0)>0&&`w-full`),"data-tip":`Make a custom agent`,children:[(0,X.jsx)(f,{"aria-hidden":`true`}),`New`]}):void 0},e.id))})})]})]})}function ln({value:e,onChange:t,id:n}){let i=Ke(e),a=typeof e==`string`?e.trim().replace(/\s+/g,` `):``,o=!i&&a?a.slice(0,60):``,s=Ke(e)?e:o?null:``,{theme:c}=Je(),l=Xe(c)===`icons`?`No icon: the Helper's face`:`No icon: its mascot`,[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(10),[m,h]=(0,Y.useState)(()=>!!(lt(`ph:robot`)||lt(`lucide:bot`)));(0,Y.useEffect)(()=>{Ve().then(()=>h(!0))},[]),(0,Y.useEffect)(()=>{p(10)},[u]);let g=!!u.trim(),{hits:v,total:y}=(0,Y.useMemo)(()=>g?De(u,f,0):De(``,f,Ge.length),[u,f,g]),b=He.length,x=g?y>f:f<b,S=g?Math.max(0,y-f):Math.max(0,b-f);return(0,X.jsxs)(`div`,{id:n,className:`flex flex-col gap-4`,children:[(0,X.jsxs)(`label`,{className:`relative block`,children:[(0,X.jsx)(_,{"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted`}),(0,X.jsx)(F,{value:u,onChange:e=>d(e.target.value),placeholder:`Search Phosphor and Lucide icons…`,"aria-label":`Search icons`,className:`pl-10`,spellCheck:!1})]}),o&&(0,X.jsxs)(`p`,{className:`text-[13px] text-warn`,children:[`This agent names an icon ForgeQE does not have: `,(0,X.jsx)(`span`,{className:`font-mono`,children:o}),`. Pick one below, or No icon.`]}),!g&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`mb-2 text-[13px] text-muted`,children:`No icon`}),(0,X.jsx)(`div`,{role:`listbox`,"aria-label":`No icon`,className:`flex flex-wrap gap-2`,children:(0,X.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":s===``,"aria-label":`No icon`,"data-tip":l,className:un(s===``),onClick:()=>t(``),children:(0,X.jsx)(Me,{agent:`custom`,px:28,decorative:!0})})})]}),!g&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`mb-2 text-[13px] text-muted`,children:`ForgeQE faces`}),(0,X.jsx)(`div`,{role:`listbox`,"aria-label":`ForgeQE faces`,className:`flex flex-wrap gap-2`,children:Ge.map(e=>(0,X.jsx)(dn,{icon:e,label:je(e),selected:e===s,ready:!0,onPick:t},e))})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`mb-2 text-[13px] text-muted`,children:g?`Top matches (${y})`:`Library icons (Phosphor and Lucide)`}),(0,X.jsxs)(`div`,{role:`listbox`,"aria-label":g?`Icon search results`:`Library icons`,className:`flex flex-wrap gap-2`,children:[v.map(e=>(0,X.jsx)(dn,{icon:e.id,label:e.label,selected:e.id===s,ready:m||e.kind===`face`,onPick:t},e.id)),v.length===0&&(0,X.jsx)(`p`,{className:`text-[13px] text-muted`,children:`No icons match that search.`})]}),x&&(0,X.jsxs)(`button`,{type:`button`,className:`mt-4 inline-flex items-center gap-1 text-[13px] font-medium text-accent underline-offset-4 hover:underline`,"data-tip":`Show ${Math.min(10,S)} of ${S} more`,onClick:()=>p(e=>e+10),children:[(0,X.jsx)(r,{size:14,"aria-hidden":`true`}),`More (`,S,`)`]})]}),s&&Ae(s)&&(0,X.jsxs)(`p`,{className:`text-[13px] text-muted`,children:[`Selected `,(0,X.jsx)(`span`,{className:`font-mono text-fg`,children:s})]})]})}var un=e=>P(`inline-flex size-11 cursor-pointer items-center justify-center rounded-[10px] border bg-bg text-fg transition-colors disabled:cursor-wait disabled:opacity-50`,e?`border-accent ring-2 ring-accent/30`:`border-line-soft hover:border-line`);function dn({icon:e,label:t,selected:n,ready:r,onPick:i}){return(0,X.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":n,"aria-label":t,"data-tip":t,disabled:!r&&!!Ae(e),className:un(n),onClick:()=>i(e),children:Ue(e)?(0,X.jsx)(Ce,{name:e,px:28}):(0,X.jsx)(Me,{agent:`custom`,icon:e,px:28,decorative:!0})})}var fn=[{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 pn(){let[e,t]=(0,Y.useState)(``),[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(``),[o,c]=(0,Y.useState)([]),[l,u]=(0,Y.useState)([]),d=Dt(n);(0,Y.useEffect)(()=>{fe.list().then(e=>c(e.sessions.filter(e=>!e.saved)),()=>{}),H.templates().then(e=>u(e.templates),()=>{})},[]);let f=async()=>{if(e.trim()){r(!0),a(``);try{let t=await fe.start(e.trim());location.hash=B(`agents`,`custom`,`build`,t.sid)}catch(e){a(e.message),r(!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)(Ze,{}),(0,X.jsxs)(`a`,{href:B(`agents`,`category`,`custom`),className:`inline-flex min-h-9 items-center gap-2 text-sm`,children:[(0,X.jsx)(x,{size:16,"aria-hidden":`true`}),`Custom agents`]})]}),(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)(he,{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-[31px] leading-tight font-semibold tracking-[-0.015em] text-ink`,children:`What should your agent do?`}),(0,X.jsx)(`p`,{className:`m-0 text-[16px] 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)(mt,{id:`build-goal`,label:`What your agent should do`,value:e,onChange:e=>{t(e),a(``)},onSend:()=>void f(),busy:n,disabled:n,placeholder:`An agent that checks the checkout on QA and tells me what broke…`}),i&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 -mt-6 text-sm text-fail`,children:i}),(0,X.jsxs)(`section`,{"aria-labelledby":`build-starters`,className:`flex w-full flex-col gap-2`,children:[(0,X.jsx)(`h2`,{id:`build-starters`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Or start from one of these, and change it to fit`}),(0,X.jsx)(`ul`,{className:`m-0 grid list-none grid-cols-1 gap-2 p-0 sm:grid-cols-2`,children:fn.map(n=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":e===n.text,onClick:()=>{t(n.text),a(``),document.getElementById(`build-goal`)?.focus()},className:P(`flex h-full w-full cursor-pointer flex-col items-start gap-1 rounded-[12px] border px-4 py-2 text-left hover:bg-surface-muted`,e===n.text?`border-accent bg-accent-soft`:`border-line-soft bg-transparent`),children:[(0,X.jsx)(`span`,{className:`text-[13px] font-medium text-ink`,children:n.label}),(0,X.jsx)(`span`,{className:`text-[13px] text-muted`,children:n.about})]})},n.label))})]}),o.length>0&&(0,X.jsxs)(`section`,{"aria-labelledby":`build-resume`,className:`flex w-full flex-col gap-2`,children:[(0,X.jsx)(`h2`,{id:`build-resume`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Pick up where you left off`}),(0,X.jsx)(`ul`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-2`,children:o.slice(0,5).map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`a`,{href:B(`agents`,`custom`,`build`,e.sid),className:`flex min-h-11 items-center gap-4 rounded-[8px] px-4 py-2 text-ink no-underline hover:bg-surface-muted hover:text-ink`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:e.goal}),(0,X.jsxs)(`span`,{className:`flex-none text-[13px] text-muted`,children:[mn[e.step].label,` · `,wt(e.updatedAt)]})]})},e.sid))})]}),l.length>0&&(0,X.jsxs)(`section`,{"aria-labelledby":`build-templates`,className:`flex w-full flex-col gap-2`,children:[(0,X.jsx)(`h2`,{id:`build-templates`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Or start from a template, and review it before you save`}),(0,X.jsx)(`ul`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-2`,children:l.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`a`,{href:B(`agents`,`custom`,`new`,`template`,e.id),className:`flex min-h-11 items-center gap-4 rounded-[8px] px-4 py-2 text-ink no-underline hover:bg-surface-muted hover:text-ink`,children:[(0,X.jsx)(`span`,{className:`flex-none text-[13px]`,children:e.title}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px] text-muted`,children:e.why||e.about})]})},e.id))})]}),(0,X.jsxs)(`a`,{href:B(`agents`,`custom`,`new`,`form`),className:`inline-flex items-center gap-2 text-[13px]`,children:[(0,X.jsx)(s,{size:14,"aria-hidden":`true`}),`Or set every option yourself`]})]})})]})}var mn={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 hn({sid:e}){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(!1);if((0,Y.useEffect)(()=>{fe.view(e).then(e=>{n(e),o(Math.min(e.reached,e.steps.length-1))},e=>i(e.message))},[e]),(0,Y.useEffect)(()=>{if(!t?.working)return;let r=setTimeout(()=>{fe.view(e).then(n,()=>{})},1500);return()=>clearTimeout(r)},[t,e]),r&&!t)return(0,X.jsx)(gn,{children:(0,X.jsxs)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-4 py-2 text-sm text-fail`,children:[r,` `,(0,X.jsx)(`a`,{href:B(`agents`,`custom`,`new`),children:`Start again`})]})});if(!t||a===null)return(0,X.jsx)(gn,{children:(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`})});let l=t.steps[a].id,u=mn[l],d=s||t.working===l,f=async t=>{if(l!==`try`){c(!0),i(``);try{let r=await fe.answer(e,l,t);n(r),o(Math.min(a+1,r.steps.length-1)),window.scrollTo({top:0})}catch(e){i(e.message)}finally{c(!1)}}};return(0,X.jsxs)(gn,{children:[(0,X.jsxs)(`a`,{href:B(`agents`,`category`,`custom`),className:`inline-flex items-center gap-2 self-start text-sm`,children:[(0,X.jsx)(x,{size:16,"aria-hidden":`true`}),`Custom agents`]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-[13px] text-muted`,children:`New agent`}),(0,X.jsxs)(`p`,{className:`m-0 text-[16px] text-ink-2 [overflow-wrap:anywhere]`,children:[`“`,t.goal,`”`]})]}),(0,X.jsx)(_n,{v:t,at:a,onGo:e=>!s&&o(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)(he,{state:d?`working`:`idle`,px:36,label:d?u.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-[20px] font-semibold tracking-[-0.01em]`,children:u.title}),(0,X.jsx)(`p`,{className:`m-0 text-[16px] leading-relaxed text-ink-2`,children:d?t.working===l?mn[l].thinking:u.working:t.says[l]}),!d&&t.source?.[l]&&(0,X.jsx)(`span`,{className:`text-[13px] text-muted`,children:t.source[l]===`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.`})]})]}),r&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-4 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:r}),t.working===l?null:l===`understand`&&(0,X.jsx)(bn,{v:t,busy:s,onNext:f,next:u.next},`u-${t.updatedAt}`),t.working!==l&&l===`plan`&&(0,X.jsx)(Sn,{v:t,busy:s,onNext:f,onBack:()=>o(a-1),next:u.next},`p-${t.updatedAt}`),l===`boundaries`&&(0,X.jsx)(Cn,{v:t,busy:s,onNext:f,onBack:()=>o(a-1),next:u.next},`b-${t.updatedAt}`),l===`knowledge`&&(0,X.jsx)(wn,{v:t,busy:s,onNext:f,onBack:()=>o(a-1),next:u.next},`k-${t.updatedAt}`),t.working!==l&&l===`review`&&(0,X.jsx)(Tn,{v:t,busy:s,onNext:f,onBack:()=>o(a-1),next:u.next},`r-${t.updatedAt}`),l===`try`&&(0,X.jsx)(En,{v:t})]})]})}function gn({children:e}){return(0,X.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,X.jsx)(at,{}),(0,X.jsx)(`main`,{className:P(ct,`max-w-[920px] flex-auto gap-6`),children:e})]})}function _n({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)(`button`,{type:`button`,disabled:!a,"aria-current":o?`step`:void 0,onClick:()=>n(i),className:P(`inline-flex min-h-9 items-center gap-2 rounded-[8px] border-0 px-2 text-[13px] font-medium`,o?`bg-accent-soft text-ink`:a?`cursor-pointer bg-transparent text-ink-2 hover:bg-surface-strong`:`bg-transparent text-muted`),children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:P(`inline-flex size-5 items-center justify-center rounded-full text-[13px] 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)(A,{size:12,strokeWidth:3}):i+1}),mn[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 vn({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-bg py-4`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px]`,children:a}),t&&(0,X.jsxs)(U,{variant:`ghost`,disabled:e,onClick:t,children:[(0,X.jsx)(x,{"aria-hidden":`true`}),`Back`]}),(0,X.jsxs)(U,{variant:`primary`,disabled:e||i,onClick:r,"data-tip":n,children:[o?(0,X.jsx)(A,{"aria-hidden":`true`}):(0,X.jsx)(O,{"aria-hidden":`true`}),o?`Save`:`Next`]})]})}function yn({on:e,label:t,why:n,recommended:r,onToggle:i}){return(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":e,onClick:i,className:P(`flex min-h-11 w-full cursor-pointer items-start gap-4 rounded-[12px] border px-4 py-2 text-left`,e?`border-accent bg-accent-soft`:`border-line-soft bg-bg hover:bg-surface-muted`),children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:P(`mt-1 inline-flex size-4 flex-none items-center justify-center rounded-[4px] border`,e?`border-accent bg-accent text-accent-ink`:`border-muted`),children:e&&(0,X.jsx)(A,{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-[13px] font-medium text-ink`,children:[t,r&&(0,X.jsx)(I,{tone:`running`,icon:!1,children:`Recommended`})]}),n&&(0,X.jsx)(`span`,{className:`text-[13px] text-muted`,children:n})]})]})}function bn({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:`m-0 flex flex-col gap-2 rounded-[14px] card border p-4`,children:[(0,X.jsx)(`legend`,{className:`sr-only`,children:e.text}),(0,X.jsx)(`span`,{className:`text-[16px] font-semibold`,children:e.text}),t?(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm text-ink-2`,children:[(0,X.jsx)(L,{icon:u,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)(U,{size:`sm`,variant:`ghost`,onClick:()=>s([...o,e.id]),"aria-label":`Change the answer`,"data-tip":`Change the answer`,children:(0,X.jsx)(h,{"aria-hidden":`true`})})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`text-[13px] 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)(yn,{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)(vn,{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 xn={ready:{icon:u,label:`Ready`,tone:`text-pass`},partial:{icon:d,label:`Partly set up`,tone:`text-warn`},needs_setup:{icon:c,label:`Not set up here yet`,tone:`text-muted`}};function Sn({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:`m-0 flex list-none flex-col gap-0 rounded-[14px] card border p-0`,children:e.planSteps.map((t,n)=>(0,X.jsxs)(`li`,{className:P(`flex items-start gap-4 px-4 py-4`,n>0&&`border-t border-line-soft`),children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex size-7 flex-none items-center justify-center rounded-full bg-accent-soft text-[13px] font-semibold text-accent-fg tabular-nums`,children:n+1}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-[16px] font-semibold`,children:t.title}),(0,X.jsx)(`span`,{className:`text-[13px] text-ink-2`,children:t.why}),t.without&&(0,X.jsxs)(`span`,{className:`text-[13px] 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)(`span`,{className:`rounded-[6px] bg-surface-strong px-2 py-1 text-[13px] text-ink-2`,children:n?.title||t},t)})})]})]},n))}),e.planSteps&&e.planSteps.length>0&&(0,X.jsx)(`h2`,{className:`m-0 mt-2 text-[13px] font-semibold text-muted`,children:`What it uses`}),(0,X.jsx)(`ol`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:l.map((e,t)=>{let n=xn[e.state];return(0,X.jsxs)(`li`,{className:`flex items-start gap-4 rounded-[14px] card border p-4`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex size-7 flex-none items-center justify-center rounded-full bg-accent-soft text-[13px] font-semibold text-accent-fg tabular-nums`,children:t+1}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-[16px] font-semibold`,children:e.title}),e.why&&(0,X.jsx)(`span`,{className:`text-[13px] text-ink-2`,children:e.why}),(0,X.jsx)(`span`,{className:`line-clamp-2 text-[13px] text-muted`,children:e.summary}),(0,X.jsxs)(`span`,{className:P(`flex items-center gap-2 text-[13px]`,n.tone),children:[(0,X.jsx)(L,{icon:n.icon,size:14}),n.label,e.state!==`ready`&&e.gaps.length?`: ${e.gaps.join(`; `)}`:``]})]}),(0,X.jsx)(U,{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)(w,{"aria-hidden":`true`})})]},e.capability)})}),s?(0,X.jsxs)(`section`,{"aria-labelledby":`build-add`,className:`flex flex-col gap-2 rounded-[14px] card border p-4`,children:[(0,X.jsx)(`h2`,{id:`build-add`,className:`m-0 text-[13px] font-semibold`,children:`What else should it do?`}),(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:`flex h-full w-full cursor-pointer items-start gap-2 rounded-[10px] border border-line-soft bg-bg px-4 py-2 text-left hover:bg-surface-muted`,children:[(0,X.jsx)(f,{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-[13px] font-medium`,children:e.title}),(0,X.jsx)(`span`,{className:`line-clamp-2 text-[13px] text-muted`,children:e.summary})]})]})},e.capability))})]}):(0,X.jsxs)(U,{size:`sm`,className:`self-start`,onClick:()=>c(!0),"data-tip":`Add something it should also do`,children:[(0,X.jsx)(f,{"aria-hidden":`true`}),`Add`]}),(0,X.jsx)(vn,{busy:t,onBack:r,next:i,onNext:()=>n({capabilities:a}),disabled:!a.length})]})}function Z({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-[13px] text-ink`,children:e}),(t||i)&&(0,X.jsx)(`span`,{className:`text-[13px] text-muted`,children:i||t})]}),i?(0,X.jsx)(v,{size:18,"aria-label":`Always`,className:`mt-1 flex-none text-muted`}):(0,X.jsx)(ot,{checked:n,onChange:e=>r?.(e),label:e})]})}function Cn({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,d]=(0,Y.useState)(a.approve),[f,p]=(0,Y.useState)(a.shell),[m,h]=(0,Y.useState)(a.repository),[g,_]=(0,Y.useState)(a.unattended),[v,y]=(0,Y.useState)(a.trust||[]),[b,x]=(0,Y.useState)((a.production||[]).includes(`run`)),S=o.some(t=>e.production.includes(t)),C=(e,t)=>y(t?[...new Set([...v,e])]:v.filter(t=>t!==e)),w=e.plan.filter(e=>e.on&&e.capability.startsWith(`system:`)),T=(e,t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],E=e=>c.includes(e),D=(e,t)=>l(t?[...new Set([...c,e])]:c.filter(t=>t!==e)),O=(e,t)=>d(t?[...new Set([...u,e])]:u.filter(t=>t!==e)),k=o.join(` and `)||`its environments`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 rounded-[14px] card border p-4`,children:[(0,X.jsx)(`legend`,{className:`sr-only`,children:`Where it works`}),(0,X.jsx)(`span`,{className:`text-[16px] font-semibold`,children:`Where it works`}),(0,X.jsx)(`span`,{className:`text-[13px] 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)(be,{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})}),S&&(0,X.jsx)(`span`,{className:`text-[13px] 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:`flex flex-col rounded-[14px] card border px-4 py-1`,children:[(0,X.jsx)(`h2`,{id:`build-may`,className:`sr-only`,children:`What it may do`}),(0,X.jsx)(Z,{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)(Z,{text:`Run tests and apps in ${k}`,help:`Browser runs, tests, API calls and database queries.`,on:E(`run`),onChange:e=>D(`run`,e)}),e.needs?.run&&E(`run`)&&(0,X.jsx)(Z,{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=>O(`run`,e)}),e.needs?.run&&E(`run`)&&S&&(0,X.jsx)(Z,{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:!b,onChange:e=>x(!e)}),(0,X.jsx)(Z,{text:`Change test assets on this computer`,help:`Regression packs, API contracts, page memory, recordings. Off unless its job is to make them.`,on:E(`change`),onChange:e=>D(`change`,e)}),E(`change`)&&(0,X.jsx)(Z,{text:`Ask me before each change`,on:u.includes(`change`),onChange:e=>O(`change`,e)}),e.needs?.external&&(0,X.jsx)(Z,{text:`Change other systems as you asked`,help:`Work items or the team's channel, as you chose.`,on:E(`external`),onChange:e=>D(`external`,e)}),E(`external`)&&(0,X.jsx)(Z,{text:`Ask me before each change to another system`,help:`Recommended. Off: it comments, updates and attaches as its job says, without asking.`,on:!v.includes(`external`),onChange:e=>C(`external`,!e)}),e.needs?.repository&&(0,X.jsx)(Z,{text:`Change your repository to write or heal tests`,help:`A coding agent does it on this computer.`,on:m===`write`,onChange:e=>(h(e?`write`:`read`),e&&D(`change`,!0))}),e.needs?.repository&&m===`write`&&(0,X.jsx)(Z,{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:!v.includes(`coding`),onChange:e=>C(`coding`,!e)}),(0,X.jsx)(Z,{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:f,onChange:p})]}),e.schedule&&(0,X.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 rounded-[14px] card border p-4`,children:[(0,X.jsx)(`legend`,{className:`sr-only`,children:`What it may do alone`}),(0,X.jsxs)(`span`,{className:`text-[16px] font-semibold`,children:[`When it runs `,e.schedule.toLowerCase(),`, with nobody watching`]}),(0,X.jsx)(`span`,{className:`text-[13px] 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:[E(`run`)&&(0,X.jsx)(yn,{on:g.includes(`run`),label:`Run tests and apps`,why:`Recommended: what it is there to do.`,recommended:!0,onToggle:()=>_(T(g,`run`))}),E(`change`)&&(0,X.jsx)(yn,{on:g.includes(`change`),label:`Change test assets`,onToggle:()=>_(T(g,`change`))}),m===`write`&&v.includes(`coding`)&&(0,X.jsx)(yn,{on:g.includes(`coding`),label:`Write or heal tests`,why:`The coding agent, when its test project names no address outside its environments.`,onToggle:()=>_(T(g,`coding`))}),w.map(e=>(0,X.jsx)(yn,{on:g.includes(`${e.capability.slice(7)}_*`),label:`Change ${e.title.replace(/^Work with /,``)}`,why:`Comment, update states, attach evidence, without a person approving each.`,onToggle:()=>_(T(g,`${e.capability.slice(7)}_*`))},e.capability))]})]}),(0,X.jsx)(vn,{busy:t,onBack:r,next:i,onNext:()=>n({environments:o,actions:c,approve:u,repository:m,shell:f,unattended:g,trust:v,production:b?[`run`]:[]}),disabled:!o.length})]})}function wn({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)),[c,l]=(0,Y.useState)(a.skills.filter(e=>e.on).map(e=>e.name)),[u,d]=(0,Y.useState)(a.notes),f=(e,t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],p=e=>[...e].sort((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:[p(a.files).map(e=>(0,X.jsx)(yn,{on:o.includes(e.file),label:e.title,why:e.why||e.file,recommended:e.on,onToggle:()=>s(f(o,e.file))},e.file)),p(a.skills).map(e=>(0,X.jsx)(yn,{on:c.includes(e.name),label:`Skill: ${e.name}`,why:e.why||e.about,recommended:e.on,onToggle:()=>l(f(c,e.name))},e.name))]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`span`,{className:`text-[16px] font-semibold`,children:`Anything else it should know?`}),(0,X.jsx)(`span`,{className:`text-[13px] 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)(V,{rows:5,value:u,maxLength:2e4,onChange:e=>d(e.target.value),placeholder:`A declined card shows “Payment failed” and keeps the basket.`})]}),(0,X.jsx)(vn,{busy:t,onBack:r,next:i,onNext:()=>n({files:o,skills:c,notes:u})})]})}function Tn({v:e,busy:t,onNext:n,onBack:r,next:i}){let a=e.review,[o,c]=(0,Y.useState)(a.name),[l,u]=(0,Y.useState)(a.id),[d,f]=(0,Y.useState)(a.description),[p,m]=(0,Y.useState)(a.icon||``),[h,g]=(0,Y.useState)(a.starters[0]?.text||e.goal),_=e.plan.filter(e=>e.on),v=e.boundaries,y=e.knowledge,b=[[`It works in`,v.environments.join(`, `)],[`It does`,_.map(e=>e.title).join(`; `)],[`It may`,[v.actions.includes(`run`)?`run tests and apps${v.approve.includes(`run`)?` (asking you first)`:``}`:``,v.actions.includes(`change`)?`change test assets`:``,v.actions.includes(`external`)?`change other systems${(v.trust||[]).includes(`external`)?` (without asking)`:` (asking you first)`}`:``,v.repository===`write`?`write or heal tests${(v.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${v.unattended.length?`; alone it may ${v.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`],...v.shell?[[`Shell`,`yes, a person approves each command`]]:[],[`It knows`,[...y.files.filter(e=>e.on).map(e=>e.title),...y.skills.filter(e=>e.on).map(e=>e.name),...y.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-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Name`}),(0,X.jsx)(F,{value:o,maxLength:60,onChange:e=>c(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Id`}),(0,X.jsx)(F,{value:l,maxLength:40,spellCheck:!1,disabled:!!e.saved,onChange:e=>u(e.target.value.toLowerCase())})]})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`What it is for`}),(0,X.jsx)(`span`,{className:`text-[13px] text-muted`,children:`One line. Atlas reads it to know when to hand it work.`}),(0,X.jsx)(F,{value:d,maxLength:300,onChange:e=>f(e.target.value)})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Icon`}),(0,X.jsx)(`span`,{className:`text-[13px] text-muted`,children:`What it wears on the Agents page: its mascot, or one of ForgeQE's agent icons.`}),(0,X.jsx)(ln,{value:p,onChange:m})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Its first request`}),(0,X.jsx)(F,{value:h,maxLength:500,onChange:e=>g(e.target.value)})]}),(0,X.jsx)(`dl`,{className:`m-0 grid grid-cols-1 gap-x-6 gap-y-2 rounded-[14px] bg-surface-muted px-4 py-4 text-sm sm:grid-cols-[140px_1fr]`,children:b.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:`flex flex-col gap-1 rounded-[12px] bg-warn-soft px-4 py-4 text-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium text-warn`,children:e.about}),(0,X.jsx)(`span`,{className:`text-[13px] text-ink-2`,children:e.fix})]},t))}),(0,X.jsx)(vn,{busy:t,onBack:r,next:e.saved?`Save the changes`:i,onNext:()=>n({name:o,id:l,description:d,icon:p,starters:[{label:`Run it now`,text:h}]}),disabled:!o.trim()||!l.trim(),aside:(0,X.jsxs)(`a`,{href:e.saved?B(`agents`,`custom`,e.saved,`edit`):B(`agents`,`custom`,`new`,`form`),className:`inline-flex items-center gap-2`,children:[(0,X.jsx)(s,{size:14,"aria-hidden":`true`}),`Advanced settings`]})})]})}function En({v:t}){let n=t.saved,[r,i]=(0,Y.useState)(t.review?.starters[0]?.text||t.goal),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(!1),[l,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(!1),m=async()=>{c(!0);try{let{id:e}=await xe.start(r.trim(),{agent:n,try:!0});location.hash=B(`chats`,e)}catch(e){d(e.message),c(!1)}},h=async()=>{c(!0),d(``);try{await H.act(n,`approve`,{confirm:a,note:`Made with the agent builder`}),p(!0)}catch(e){d(e.message)}finally{c(!1)}};return f?(0,X.jsxs)(`div`,{className:`flex flex-col items-start gap-4 rounded-[14px] bg-pass-soft px-4 py-4`,children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-2 text-[16px] font-semibold text-pass`,children:[(0,X.jsx)(u,{size:18,"aria-hidden":`true`}),W(t.review?.name||`agent`,!0),` is ready.`]}),(0,X.jsx)(`span`,{className:`text-sm text-ink-2`,children:`You, your team and Atlas can hand it work now.`}),(0,X.jsxs)(`a`,{href:B(`agents`,`custom`,n),className:P(j({variant:`primary`,size:`sm`}),`no-underline`),"data-tip":`Open the agent`,children:[(0,X.jsx)(O,{"aria-hidden":`true`}),`Open`]})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`section`,{"aria-labelledby":`build-try`,className:`flex flex-col gap-2 rounded-[14px] card border p-4`,children:[(0,X.jsx)(`h2`,{id:`build-try`,className:`m-0 text-[16px] font-semibold`,children:`1. Try it on a real request`}),(0,X.jsx)(V,{rows:2,"aria-label":`What to try`,value:r,onChange:e=>i(e.target.value)}),(0,X.jsxs)(U,{variant:`primary`,size:`sm`,className:`self-start`,disabled:s||!r.trim(),onClick:()=>void m(),"data-tip":`Try it in a chat`,children:[(0,X.jsx)(e,{"aria-hidden":`true`}),`Try`]}),(0,X.jsx)(`span`,{className:`text-[13px] text-muted`,children:`It opens as a chat. Come back here to approve it: Agents, Custom agents, then this agent.`})]}),(0,X.jsxs)(`section`,{"aria-labelledby":`build-approve`,className:`flex flex-col gap-2 rounded-[14px] card border p-4`,children:[(0,X.jsx)(`h2`,{id:`build-approve`,className:`m-0 text-[16px] font-semibold`,children:`2. Approve it`}),(0,X.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[`Only an approved version runs. Type its id to confirm: `,n]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(F,{"aria-label":`Type ${n} to confirm`,className:`w-[260px]`,value:a,spellCheck:!1,autoComplete:`off`,onChange:e=>o(e.target.value),placeholder:n}),(0,X.jsxs)(U,{size:`sm`,disabled:s||a!==n,onClick:()=>void h(),children:[(0,X.jsx)(u,{"aria-hidden":`true`}),`Approve`]})]})]}),l&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 text-sm text-fail [overflow-wrap:anywhere]`,children:l}),(0,X.jsx)(`a`,{href:B(`agents`,`custom`,n),className:`self-start text-[13px]`,children:`Open its page`})]})}function Dn({id:e}){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(!1),s=(0,Y.useCallback)(()=>{H.view(e).then(e=>{ut([{id:e.id,icon:e.icon}]),n(e),i(``)},e=>i(e.message))},[e]);(0,Y.useEffect)(()=>s(),[s]);let[c,l]=(0,Y.useState)(null);return Te.test(e)?(0,X.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[t?(0,X.jsx)(An,{view:t,detailsOpen:a,onDetails:o}):(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)(Ze,{}),(0,X.jsxs)(`a`,{href:B(`agents`,`category`,`custom`),className:`inline-flex min-h-9 items-center gap-2 text-sm`,children:[(0,X.jsx)(x,{size:16,"aria-hidden":`true`}),`Custom agents`]})]}),(0,X.jsx)(`main`,{className:`flex flex-auto flex-col items-center justify-center px-6 py-10`,children:r?(0,X.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-4 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:r}):(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`})})]}),t&&c&&(0,X.jsx)(Wn,{view:t,action:c.action,to:c.to,onClose:()=>l(null),onDone:e=>{`deleted`in e?(l(null),location.hash=B(`agents`,`category`,`custom`)):(n(e),l(null))}}),t&&(0,X.jsx)(In,{view:t,open:a,onClose:()=>o(!1),onAct:l})]}):(0,X.jsx)(On,{})}function On(){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)(Ze,{})}),(0,X.jsxs)(`p`,{className:`m-0 px-6 py-10 text-sm text-muted`,children:[`There is no such agent. `,(0,X.jsx)(`a`,{href:B(`agents`),children:`See every agent`}),`.`]})]})}var kn=e=>e.length?e.join(`, `):`none`;function An({view:t,detailsOpen:n,onDetails:r}){let a=yt(),o=[...t.problems.working,...t.problems.active,...t.problems.other],s=t.state===`active`||t.state===`changed`,c=!!t.working,l=Gt[t.state],[u,d]=(0,Y.useState)(t.starters[0]?.text||``),[f,p]=(0,Y.useState)(``),[m,g]=(0,Y.useState)(``),[_,v]=(0,Y.useState)(!1),y=dt(),{setup:b}=y,S=`custom-agent-${t.id}`,C=At(u,e=>{d(e),p(``)},S,{code:y.tools.code}),w=pt(`custom-${t.id}`,e=>{d(e),ft(S)}),T=async()=>{g(``);try{let e=await H.pack(t.id),n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=`${t.id}.forgeqe-agent.zip`,r.click(),setTimeout(()=>URL.revokeObjectURL(n),1e3),g(`Zip downloaded. A teammate imports it as a draft, then edits and approves it.`)}catch(e){g(e.message)}},E=async(e,n=u)=>{if(!(_||!n.trim()&&!C.hasFiles)&&(e||s)&&(!e||c)){v(!0),p(``);try{let r=await C.wrap(n.trim());if(!r.trim()){v(!1);return}let{id:i}=await xe.start(r,{...y.choice,agent:t.id,...e||!s?{try:!0}:{}});C.reset({keep:!0}),location.hash=B(`chats`,i)}catch(e){p(e.message),v(!1)}}},O=!s&&!c;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)(Ze,{}),(0,X.jsxs)(`a`,{href:B(`agents`,`category`,`custom`),className:`inline-flex min-h-9 items-center gap-2 text-sm`,children:[(0,X.jsx)(x,{size:16,"aria-hidden":`true`}),`Custom agents`]}),(0,X.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,children:[(0,X.jsx)(I,{tone:l.tone,children:l.label}),(0,X.jsx)(U,{variant:`icon`,size:`icon`,onClick:()=>void T(),"aria-label":`Export to share`,"data-tip":`Export to share`,children:(0,X.jsx)(D,{size:18,"aria-hidden":`true`})}),(0,X.jsx)(U,{variant:`icon`,size:`icon`,onClick:()=>r(!n),"aria-label":`Details`,"aria-pressed":n,"data-tip":`Details`,children:(0,X.jsx)(i,{size:18,"aria-hidden":`true`})}),(0,X.jsx)(`a`,{href:B(`agents`,`custom`,t.id,`edit`),className:P(j({variant:`icon`,size:`icon`}),`no-underline`),"aria-label":`Edit`,"data-tip":`Edit`,children:(0,X.jsx)(h,{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)(Me,{agent:t.id,icon:t.icon,px:a?64:96,decorative:!0,working:_,className:`mb-1`}),(0,X.jsx)(`h1`,{className:`m-0 text-[31px] leading-tight font-semibold tracking-[-0.015em] text-ink short:text-[25px] [overflow-wrap:anywhere]`,children:t.name}),(0,X.jsx)(`p`,{className:`m-0 text-[16px] leading-relaxed text-ink-2`,children:t.description||(s?`Ask ${W(t.name)}. It runs version ${t.approvedVersion}, within its limits.`:c?`Try ${W(t.name)}. It has no approved version yet: a try runs its manifest as it is.`:`Fix ${W(t.name)}'s manifest before it can be tried or approved.`)})]}),m&&(0,X.jsx)(`p`,{role:`status`,className:P(`m-0 -mt-4 text-center text-[13px]`,/downloaded|Zip/.test(m)?`text-muted`:`text-fail`),children:m}),o.length>0&&(0,X.jsxs)(`div`,{role:`alert`,className:`flex w-full flex-col gap-1 rounded-[12px] bg-fail-soft px-4 py-4 text-left text-sm text-fail`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:t.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:o.map((e,t)=>(0,X.jsx)(`li`,{children:e},t))})]}),(0,X.jsx)(Mn,{agent:t.id}),t.state===`changed`&&t.changes.length>0&&(0,X.jsxs)(`section`,{"aria-labelledby":`ca-changes`,className:`flex w-full flex-col gap-2 text-left`,children:[(0,X.jsxs)(`h2`,{id:`ca-changes`,className:`m-0 text-[13px] font-semibold text-muted`,children:[`Changed since `,t.approvedVersion,` was approved`]}),(0,X.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`The approved version keeps running until this change is approved.`}),(0,X.jsx)(Nt,{diff:t.changes})]}),O?(0,X.jsx)(`p`,{className:`m-0 text-center text-sm text-muted`,children:`Open Details for what is wrong, or Edit the agent.`}):(0,X.jsxs)(X.Fragment,{children:[b&&!b.ready&&(0,X.jsx)(vt,{project:b.project}),b?.ready&&(0,X.jsx)(Ot,{c:y}),(0,X.jsx)(mt,{id:S,label:`Message ${W(t.name)}`,value:u,onChange:e=>{d(e),p(``)},onSend:()=>void E(!s),disabled:_||!!b&&!b.ready||w.running,canSend:!!u.trim()||C.hasFiles,onEdit:C.onEdit,onKey:C.onKeyDown,onFiles:C.onFiles,dropping:C.dropping,drop:C.drop,mentions:C.mentions,combo:C.combo,placeholder:`Ask ${W(t.name)} to…`,top:(0,X.jsxs)(X.Fragment,{children:[C.chips,w.state&&(0,X.jsx)(gt,{state:w.state,onStop:()=>void w.stop(),onUndo:w.undo,onClose:w.close})]}),left:(0,X.jsxs)(X.Fragment,{children:[C.fileInput,(0,X.jsx)(kt,{attach:{pick:C.pick},choice:y}),(0,X.jsx)(ht,{running:w.running,disabled:!u.trim()||_||!!b&&!b.ready,onClick:()=>void w.start(u)})]}),right:(0,X.jsx)(_t,{c:y})}),(0,X.jsx)(`p`,{role:`status`,"aria-live":`polite`,className:P(`-mt-6 m-0 text-center text-sm text-ink-2 short:-mt-4`,!(f||C.error)&&`sr-only`),children:(0,X.jsx)(`span`,{className:C.error&&!f?`text-fail`:``,children:f||C.error||``})}),(0,X.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-4`,children:[t.starters.map(e=>(0,X.jsx)(U,{onClick:()=>{d(e.text),p(``),document.getElementById(S)?.focus()},children:e.label},e.label)),s&&c&&(0,X.jsxs)(U,{disabled:_||!u.trim(),onClick:()=>void E(!0),"data-tip":`Try the manifest`,children:[(0,X.jsx)(e,{"aria-hidden":`true`}),`Try`]})]})]}),(0,X.jsx)(jn,{view:t})]})})]})}function jn({view:e}){let t=e.capabilities;if(!t.length)return null;let 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)(`section`,{"aria-labelledby":`ca-needs`,className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`h2`,{id:`ca-needs`,className:`m-0 text-[13px] font-semibold text-muted`,children:`What it needs`}),(0,X.jsx)(I,{tone:r,children:i})]}),(0,X.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:n===`needs_setup`?`${W(e.name,!0)} cannot work until these are set up.`:`${W(e.name,!0)} works, without the parts below.`}),(0,X.jsx)(`ul`,{"aria-label":`What ${W(e.name)} needs`,className:`m-0 flex list-none flex-col rounded-[12px] card border p-0`,children:a.map((e,t)=>(0,X.jsxs)(`li`,{className:P(`flex items-center gap-4 px-4 py-2`,t>0&&`border-t border-line-soft`),children:[(0,X.jsx)(L,{icon:Fn[e.state].icon,size:16,className:P(`flex-none`,Fn[e.state].cls)}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,X.jsx)(`span`,{className:`text-[13px] font-medium`,children:e.title}),(0,X.jsx)(`span`,{className:`text-[13px] text-muted [overflow-wrap:anywhere]`,children:e.gaps.join(`; `)||Fn[e.state].label})]})]},e.id))})]}),(0,X.jsxs)(`section`,{"aria-labelledby":`ca-caps`,className:`flex flex-col gap-2`,children:[(0,X.jsx)(`h2`,{id:`ca-caps`,className:`m-0 text-[13px] font-semibold text-muted`,children:`What it can use`}),(0,X.jsx)(`ul`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-0`,children:t.map((e,t)=>{let n=Fn[e.state];return(0,X.jsxs)(`li`,{className:P(`flex items-start gap-4 px-4 py-2`,t>0&&`border-t border-line-soft`),children:[(0,X.jsx)(L,{icon:n.icon,size:16,className:P(`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-[13px] font-medium`,children:e.title}),(0,X.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[n.label,e.gaps.length?`: ${e.gaps.join(`; `)}`:``]})]})]},e.id)})})]})]})}function Mn({agent:e}){let[t,n]=(0,Y.useState)([]),[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(``),s=(0,Y.useCallback)(()=>{_e.list().then(t=>n(t.approvals.filter(t=>t.agent===e&&t.state===`waiting`)),()=>{})},[e]);if((0,Y.useEffect)(()=>{s();let e=setInterval(s,15e3);return()=>clearInterval(e)},[s]),!t.length)return null;let l=async(t,n)=>{i(t.id),o(``);try{await _e.answer(e,t.id,n),s()}catch(e){o(e.message)}finally{i(``)}};return(0,X.jsxs)(`section`,{"aria-labelledby":`ca-waiting`,className:`flex w-full flex-col gap-2 rounded-[14px] border border-warn bg-warn-soft p-4 text-left`,children:[(0,X.jsx)(`h2`,{id:`ca-waiting`,className:`m-0 text-base font-semibold text-warn`,children:`Waiting for you`}),(0,X.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-4 p-0`,children:t.map(e=>(0,X.jsxs)(`li`,{className:`flex flex-wrap items-start gap-4 rounded-[12px] bg-bg px-4 py-4`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-[1_1_320px] flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-[13px] font-medium [overflow-wrap:anywhere]`,children:e.title}),e.detail&&(0,X.jsx)(`span`,{className:`text-[13px] text-ink-2 [overflow-wrap:anywhere]`,children:e.detail}),(e.lines||[]).map((e,t)=>(0,X.jsx)(`span`,{className:`text-[13px] text-muted [overflow-wrap:anywhere]`,children:e},t)),(0,X.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[`Asked `,wt(e.createdAt),`; no answer by `,e.until.slice(0,16).replace(`T`,` `),` UTC is a no.`]})]}),(0,X.jsxs)(`span`,{className:`flex gap-2`,children:[(0,X.jsxs)(U,{size:`sm`,variant:`primary`,disabled:!!r,onClick:()=>void l(e,`allow`),children:[(0,X.jsx)(A,{"aria-hidden":`true`}),`Allow`]}),e.forRun&&(0,X.jsxs)(U,{size:`sm`,variant:`outline`,disabled:!!r,onClick:()=>void l(e,`allow_run`),"data-tip":`Allow for the rest of this run`,children:[(0,X.jsx)(A,{"aria-hidden":`true`}),`Allow run`]}),(0,X.jsxs)(U,{size:`sm`,variant:`ghost`,disabled:!!r,onClick:()=>void l(e,`deny`),children:[(0,X.jsx)(c,{"aria-hidden":`true`}),`Deny`]})]})]},e.id))}),a&&(0,X.jsx)(`p`,{className:`m-0 text-[13px] text-fail`,children:a})]})}var Nn={approved:`Approved`,disabled:`Disabled`,enabled:`Enabled`,"rolled-back":`Rolled back to`};function Pn(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 Fn={ready:{icon:u,label:`Ready`,cls:`text-pass`},partial:{icon:d,label:`Partly set up`,cls:`text-warn`},needs_setup:{icon:c,label:`Needs setup`,cls:`text-muted`}};function In({view:e,open:t,onClose:n,onAct:r}){let i=e.active||e.working,a=!!e.working&&(e.state===`draft`||e.state===`changed`||e.state===`broken`&&e.working!==void 0);return(0,X.jsx)(q,{open:t,onClose:n,wide:!0,title:`Details`,description:`${e.name} · ${e.id}`,footer:(0,X.jsxs)(U,{variant:`ghost`,onClick:n,children:[(0,X.jsx)(p,{"aria-hidden":`true`}),`Close`]}),children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[i&&(0,X.jsx)(Rn,{spec:i,view:e}),(0,X.jsx)(zn,{view:e,approvable:a,onAct:r}),(0,X.jsx)(Hn,{view:e})]})})}function Ln({id:e,title:t,children:n,aside:r}){return(0,X.jsxs)(`section`,{"aria-labelledby":e,className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,X.jsx)(`h2`,{id:e,className:`m-0 flex-1 text-[13px] font-semibold text-muted`,children:t}),r]}),n]})}function Rn({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`?kn(e.agents.map(e=>t.agentNames[e]||e)):n.text]):[[`Environments`,kn(e.environments)],[`Agents it may start`,kn(e.agents.map(e=>t.agentNames[e]||e))],[`It may`,kn(e.actions.map(e=>Bn[e]||e))],[`A person approves first`,kn(e.approve.map(e=>Bn[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`,kn(e.skills)],[`Knowledge`,kn(e.knowledge)]];return(0,X.jsxs)(Ln,{id:`ca-reach`,title:t.active?`What version ${t.approvedVersion} may reach`:`What its manifest may reach`,children:[(0,X.jsx)(`dl`,{className:`m-0 grid grid-cols-1 gap-x-6 gap-y-2 rounded-[12px] card border px-4 py-4 text-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-[13px] text-muted`,children:[`Guidance it is given (not a limit): `,e.policies.join(`; `)]})]})}function zn({view:e,approvable:t,onAct:n}){return(0,X.jsxs)(Ln,{id:`ca-versions`,title:`Versions`,aside:(0,X.jsxs)(`span`,{className:`flex flex-wrap gap-2`,children:[t&&(0,X.jsxs)(U,{size:`sm`,onClick:()=>n({action:`approve`}),"data-tip":`Approve ${e.manifestVersion}`,children:[(0,X.jsx)(u,{"aria-hidden":`true`}),`Approve`]}),e.approvedVersion&&(0,X.jsxs)(U,{size:`sm`,variant:`ghost`,onClick:()=>n({action:e.disabled?`enable`:`disable`}),children:[e.disabled?(0,X.jsx)(u,{"aria-hidden":`true`}):(0,X.jsx)(c,{"aria-hidden":`true`}),e.disabled?`Enable`:`Disable`]}),(0,X.jsxs)(U,{size:`sm`,variant:`danger`,onClick:()=>n({action:`delete`}),children:[(0,X.jsx)(w,{"aria-hidden":`true`}),`Delete`]})]}),children:[e.tried&&e.manifestVersion&&(0,X.jsxs)(`p`,{className:`m-0 text-[13px] text-muted`,children:[`Last try of manifest `,e.manifestVersion,`: `,e.tried.outcome,`.`]}),e.events.length===0?(0,X.jsx)(z,{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:`m-0 flex list-none flex-col rounded-[12px] card border p-2`,children:[...e.events].reverse().map((t,r)=>{let i=t.event===`approved`||t.event===`rolled-back`?t.version===e.approvedVersion:!1,a=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-[8px] 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-[13px] font-medium`,children:[(0,X.jsxs)(`span`,{children:[Nn[t.event],` `,t.version]}),i&&r===0?(0,X.jsx)(I,{tone:`pass`,children:`Running`}):null]}),(0,X.jsxs)(`span`,{className:`text-[13px] text-muted [overflow-wrap:anywhere]`,children:[Pn(t.by),` · `,wt(t.at),t.note?` · ${t.note}`:``,t.tried?` · tried: ${t.tried.outcome}`:``]})]}),a&&(0,X.jsx)(U,{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)(g,{"aria-hidden":`true`})})]},`${t.at}-${r}`)})})]})}var Bn={read:`read`,run:`run tests and apps`,change:`change files`,external:`change other systems`,schedule:`schedule work`},Vn={run:`Asked`,try:`Tried`,orchestrator:`From Atlas`};function Hn({view:e}){let[t,n]=(0,Y.useState)(``),r=async()=>{n(``);try{let t=await H.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)(Ln,{id:`ca-runs`,title:`Recent runs`,aside:(0,X.jsxs)(U,{size:`sm`,variant:`ghost`,onClick:()=>void r(),"data-tip":`Download its whole record, for audit`,children:[(0,X.jsx)(D,{"aria-hidden":`true`}),`Download`]}),children:[t&&(0,X.jsx)(`p`,{className:`m-0 text-[13px] text-fail`,children:t}),e.runs.length===0?(0,X.jsxs)(z,{className:`py-4`,children:[W(e.name,!0),` has not run yet.`]}):(0,X.jsx)(`ul`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-0`,children:e.runs.map((e,t)=>(0,X.jsx)(`li`,{className:P(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)(I,{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-[13px] font-medium`,"data-tip":e.request,children:e.request}),(0,X.jsxs)(`span`,{className:`text-[13px] text-muted tabular-nums`,children:[Vn[e.trigger],` · `,e.version,` · `,e.calls,` `,e.calls===1?`call`:`calls`,e.refused?`, ${e.refused} refused`:``,` · `,wt(e.startedAt)]})]}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2 pl-1 text-[13px]`,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:B(`runs`,encodeURIComponent(e.session)),className:`inline-flex items-center gap-1`,children:[`Open the run`,(0,X.jsx)(O,{size:14,"aria-hidden":`true`})]})]}),e.error&&(0,X.jsx)(`span`,{className:`text-fail [overflow-wrap:anywhere]`,children:e.error}),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)(u,{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-[13px]`,children:e.tool}),e.allowed?(0,X.jsxs)(`span`,{className:`text-muted`,children:[` · `,Bn[e.action||``]||e.action,e.approved?`, approved by a person`:``]}):(0,X.jsxs)(`span`,{className:`text-fail`,children:[` · `,e.reason]})]})]},t))})]})]})},e.run))})]})}var Un={approve:{title:`Approve this version`,button:`Approve`,icon:u},disable:{title:`Disable this agent`,button:`Disable`,icon:c},enable:{title:`Enable this agent`,button:`Enable`,icon:u},rollback:{title:`Run an earlier version`,button:`Roll back`,icon:g},delete:{title:`Delete this agent`,button:`Delete`,icon:w}};function Wn({view:e,action:t,to:n,onClose:r,onDone:i}){let[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(``),m=Un[t],h=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.`:t===`enable`?`Version ${e.approvedVersion} runs again.`: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.`:`Version ${n} runs from now on, in place of ${e.approvedVersion}.`,g=async()=>{u(!0),f(``);try{i(await H.act(e.id,t,{confirm:a,...s.trim()?{note:s.trim()}:{},...n?{to:n}:{}}))}catch(e){f(e.message),u(!1)}};return(0,X.jsx)(q,{open:!0,onClose:r,title:m.title,description:h,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(U,{variant:`ghost`,onClick:r,children:[(0,X.jsx)(p,{"aria-hidden":`true`}),`Cancel`]}),(0,X.jsxs)(U,{variant:t===`delete`?`destructive`:`primary`,disabled:l||a!==e.id,onClick:()=>void g(),children:[(0,X.jsx)(m.icon,{"aria-hidden":`true`}),m.button]})]}),children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,X.jsxs)(`span`,{children:[`Type `,(0,X.jsx)(`span`,{className:`font-mono`,children:e.id}),` to confirm`]}),(0,X.jsx)(F,{value:a,onChange:e=>o(e.target.value),autoComplete:`off`,spellCheck:!1})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,X.jsx)(`span`,{children:`Note (optional)`}),(0,X.jsx)(F,{value:s,maxLength:200,onChange:e=>c(e.target.value),placeholder:t===`rollback`?`Why it goes back`:`What changed, or why`})]}),d&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 text-sm text-fail [overflow-wrap:anywhere]`,children:d})]})})}var Gn=(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 Kn=`https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files-v1.0`,qn=Object.freeze([{file:`kokoro-onnx/kokoro-v1.0.onnx`,url:`${Kn}/kokoro-v1.0.onnx`,bytes:325532387,sha256:`7d5df8ecf7d4b1878015a32686053fd0eebe2bc377234608764cc0ef3636a6c5`},{file:`kokoro-onnx/voices-v1.0.bin`,url:`${Kn}/voices-v1.0.bin`,bytes:28214398,sha256:`bca610b8308e8d99f32e6fe4197e7ec01679264efed0cac9140fe9c29f1fbf7d`}]),Jn=`https://huggingface.co/Systran/faster-whisper-base.en/resolve/3d3d5dee26484f91867d81cb899cfcf72b96be6c`,Yn=Object.freeze([{file:`whisper-base.en/config.json`,url:`${Jn}/config.json`,bytes:2227,sha256:`f3bc3821e9fc76a27bae538e11ae5b677dcdd352b4600429ce7951d398569aeb`},{file:`whisper-base.en/tokenizer.json`,url:`${Jn}/tokenizer.json`,bytes:2128466,sha256:`929c5252409436dce1b38a75d1abbcb5e132d170d8e324e4e04ed915fa2d22df`},{file:`whisper-base.en/vocabulary.txt`,url:`${Jn}/vocabulary.txt`,bytes:422309,sha256:`ff77588746d3a2595d32ab5b69ffd7b95ce2441ac57533cb66fc3eb575a115cf`},{file:`whisper-base.en/model.bin`,url:`${Jn}/model.bin`,bytes:145216508,sha256:`2a166925539a16005f14ff328359f9b9adb9dc4fb631bb3b227526862e93e2ef`}]),Xn=Object.freeze(Gn(`onnx-community/silero-vad`,`e71cae966052b992a7eca6b17738916ce0eca4ec`,`silero-vad`,[[`onnx/model.onnx`,2243022,`a4a068cd6cf1ea8355b84327595838ca748ec29a25bc91fc82e6c299ccdc5808`]])),Zn=Object.freeze(Gn(`pipecat-ai/smart-turn-v3`,`f766f81d3cfdf7737ac64aad813d91bbfd56bf93`,`smart-turn-v3`,[[`smart-turn-v3.2-cpu.onnx`,8679182,`2bb026316b14a660486a75b1733cd3fbab8c2fd0314dc9af7be49f8cca967e4f`]])),Qn=Object.freeze([...Xn,...Zn]);Object.freeze([...qn,...Yn,...Qn]),Object.freeze({en:Object.freeze([`af_heart`,`am_michael`])}),Object.freeze({en:`af_heart`});var $n=Object.freeze([`light`,`deep`]);Object.freeze({en:{light:`af_heart`,deep:`am_michael`}});var er={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:[]};function tr(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^[^a-z]+/,``).replace(/-+$/,``).slice(0,40).replace(/-+$/,``)}var nr={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.`}},rr={ready:{icon:u,label:`Ready`,cls:`text-pass`},partial:{icon:d,label:`Partly set up`,cls:`text-warn`},needs_setup:{icon:c,label:`Needs setup`,cls:`text-muted`}},ir=(e,t,n)=>n?[...new Set([...e,t])]:e.filter(e=>e!==t);function Q({checked:e,onChange:t,disabled:n,children:r,help:i}){return(0,X.jsxs)(`label`,{className:P(`flex items-start gap-2 text-sm`,n?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,X.jsx)(Tt,{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-[13px] text-muted`,children:i})]})]})}function ar({id:e,template:t}){let n=!e,[r,i]=(0,Y.useState)(n&&!t?er:null),[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(``),[d,p]=(0,Y.useState)([]),[h,g]=(0,Y.useState)([]),[_,v]=(0,Y.useState)(!1),[y,b]=(0,Y.useState)(!1),[S,C]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{H.choices().then(c,e=>u(e.message)),t&&H.template(t).then(e=>{o(e),i({...er,...e.fields,scope:{...er.scope,...e.fields.scope},permissions:{...er.permissions,...e.fields.permissions}}),C(!0)},e=>u(e.message)),e&&H.view(e).then(t=>t.form?i({...er,...t.form,runtime:{maxDelegationDepth:t.form.runtime.maxDelegationDepth,...t.form.runtime.maxTokens?{maxTokens:t.form.runtime.maxTokens}:{}}}):u(`${e}'s manifest is not one the editor can read. Fix it in .forgeqe/agents/${e}.yaml.`),e=>u(e.message))},[e,t]);let T=(0,Y.useRef)(0);(0,Y.useEffect)(()=>{if(!r)return;let e=++T.current;v(!0);let t=setTimeout(()=>{H.validate(r).then(t=>e===T.current&&(p(t.problems||[]),g(t.advice||[]),v(!1)),t=>e===T.current&&(p([t.message]),v(!1)))},350);return()=>clearTimeout(t)},[r]);let E=e=>i(t=>t&&{...t,...e}),D=e=>i(t=>t&&{...t,scope:{...t.scope,...e}}),O=e=>i(t=>t&&{...t,voice:e?{sound:e}:void 0}),k=e=>i(t=>t&&{...t,permissions:{...t.permissions,...e}}),ee=(0,Y.useMemo)(()=>{let e=new Map;for(let t of s?.capabilities||[])e.set(t.area,[...e.get(t.area)||[],t]);return[...e]},[s]),te=async()=>{if(r){b(!0),u(``);try{let t=await H.save(r,n?{create:!0}:{id:e});location.hash=B(`agents`,`custom`,t.id)}catch(e){u(e.message),b(!1)}}},ne=e?B(`agents`,`custom`,e):B(`agents`,`custom`,`new`);return(0,X.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,X.jsx)(at,{}),(0,X.jsxs)(`main`,{className:P(ct,`settings-fields flex-auto gap-2`),children:[(0,X.jsxs)(`a`,{href:ne,className:`mb-2 inline-flex items-center gap-2 self-start text-sm`,children:[(0,X.jsx)(x,{size:16,"aria-hidden":`true`}),e?`Back to the agent`:`Back to the builder`]}),(0,X.jsx)(`h1`,{className:`m-0 text-[25px] font-semibold tracking-[-0.01em]`,children:n?`New custom agent`:`Edit ${r?.name||e}`}),(0,X.jsx)(`p`,{className:`m-0 mb-2 text-sm leading-relaxed text-ink-2`,children:n?a?`ForgeQE's ${a.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.`}),l&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-4 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:l}),a&&s&&(0,X.jsxs)(`section`,{"aria-labelledby":`ca-template`,className:`mb-2 flex flex-col gap-2`,children:[(0,X.jsxs)(`h2`,{id:`ca-template`,className:`m-0 text-base font-semibold`,children:[`From the `,a.title,` template`]}),(0,X.jsxs)(`ul`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:[a.systems.length>0&&(0,X.jsxs)(`li`,{className:`flex flex-col gap-1 rounded-[12px] bg-surface-muted px-4 py-4 text-sm`,children:[(0,X.jsxs)(`span`,{className:`font-medium text-ink`,children:[`It uses the tools of `,a.systems.map(e=>s?.systems.find(t=>t.name===e)?.label||e).join(`, `)]}),(0,X.jsx)(`span`,{className:`text-[13px] text-ink-2`,children:`Through ForgeQE, which checks every call against what this agent may do. The editor has no field for them yet: they are kept as the template set them.`})]}),a.notes.map(e=>(0,X.jsx)(`li`,{className:`flex flex-col gap-1 rounded-[12px] bg-surface-muted px-4 py-4 text-sm`,children:(0,X.jsx)(`span`,{className:`font-medium text-ink`,children:e})},e))]})]}),n&&!t&&(0,X.jsx)(`p`,{className:`m-0 mb-2 text-sm`,children:(0,X.jsx)(`a`,{href:B(`agents`,`custom`,`new`),children:`Or say what it should do, and let ForgeQE build it with you`})}),!r||!s?!l&&(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(K,{first:!0,children:`What it is`}),(0,X.jsx)(G,{label:`Name`,help:`What it does, then “agent”: Checkout guard agent.`,htmlFor:`ca-name`,children:(0,X.jsx)(F,{id:`ca-name`,value:r.name,maxLength:60,onChange:e=>E({name:e.target.value,...n&&!S?{id:tr(e.target.value)}:{}})})}),(0,X.jsx)(G,{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)(F,{id:`ca-id`,value:r.id,maxLength:40,disabled:!n,spellCheck:!1,onChange:e=>(C(!0),E({id:e.target.value.toLowerCase()}))})}),(0,X.jsx)(G,{label:`Version`,help:`Raise it for each change you approve: 1.0.0, then 1.1.0.`,htmlFor:`ca-version`,children:(0,X.jsx)(F,{id:`ca-version`,value:r.version,maxLength:14,onChange:e=>E({version:e.target.value})})}),(0,X.jsx)(G,{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)(F,{id:`ca-desc`,value:r.description,maxLength:300,onChange:e=>E({description:e.target.value})})}),(0,X.jsx)(G,{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)(ln,{id:`ca-icon`,value:r.icon,onChange:e=>E({icon:e})})}),(0,X.jsx)(G,{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)(st,{label:`Voice`,value:r.voice?.sound??``,onChange:e=>O(e),options:[{id:``,label:`Default`},...$n.map(e=>({id:e,label:e[0].toUpperCase()+e.slice(1)}))]})}),(0,X.jsx)(G,{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)(V,{id:`ca-instr`,rows:5,value:r.instructions,maxLength:8e3,onChange:e=>E({instructions:e.target.value})})}),(0,X.jsx)(K,{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.`,children:`Where it works`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 py-4`,children:[s.environments.length===0&&(0,X.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`No environments in env.yaml yet. Add them in Settings, Environments.`}),s.environments.map(e=>(0,X.jsx)(Q,{checked:r.scope.environments.includes(e.name),onChange:t=>D({environments:ir(r.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)(K,{help:`ForgeQE's capabilities it may use: their tools, and only theirs. Each says whether it is set up here.`,children:`What it can do`}),(0,X.jsx)(`div`,{className:`flex flex-col gap-4 py-4`,children:ee.map(([e,t])=>{let n=t.filter(e=>r.scope.capabilities.includes(e.id)).length;return(0,X.jsxs)(`details`,{open:n>0||void 0,className:`group rounded-[12px] card border px-4 py-2`,children:[(0,X.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 py-1 text-[13px] font-medium`,children:[(0,X.jsx)(m,{size:14,"aria-hidden":`true`,className:`flex-none text-muted transition-transform duration-200 group-open:rotate-90`}),(0,X.jsx)(`span`,{className:`flex-1`,children:e}),(0,X.jsx)(`span`,{className:`text-[13px] font-normal text-muted tabular-nums`,children:n?`${n} of ${t.length} picked`:`${t.length}`})]}),(0,X.jsx)(`div`,{className:`flex flex-col gap-2 pt-2 pb-1 pl-6`,children:t.map(e=>{let t=rr[e.state];return(0,X.jsx)(Q,{checked:r.scope.capabilities.includes(e.id),onChange:t=>D({capabilities:ir(r.scope.capabilities,e.id,t)}),help:(0,X.jsxs)(`span`,{className:`flex items-start gap-2`,children:[(0,X.jsx)(L,{icon:t.icon,size:13,className:P(`mt-1 flex-none`,t.cls)}),(0,X.jsxs)(`span`,{children:[t.label,e.gaps.length?`: ${e.gaps.join(`; `)}`:``]})]}),children:(0,X.jsx)(`span`,{"data-tip":e.summary,children:e.title})},e.id)})})]},e)})}),(0,X.jsx)(K,{help:`ForgeQE's agents it may start: a capability that needs one (a browser run needs WebPilot) is refused without it.`,children:`Agents it may use`}),(0,X.jsx)(`div`,{className:`flex flex-col gap-2 py-4`,children:s.agents.map(e=>(0,X.jsx)(Q,{checked:r.scope.agents.includes(e.name),onChange:t=>D({agents:ir(r.scope.agents,e.name,t)}),help:(0,X.jsx)(`span`,{className:`font-mono text-[13px]`,children:e.name}),children:e.title},e.name))}),(0,X.jsx)(K,{help:`Only these are loaded for 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-[13px] font-semibold text-muted`,children:`Skills`}),s.skills.length===0&&(0,X.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`None in this project yet.`}),s.skills.map(e=>(0,X.jsx)(Q,{checked:r.scope.skills.includes(e.name),onChange:t=>D({skills:ir(r.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-[13px] font-semibold text-muted`,children:`Knowledge files`}),s.knowledge.length===0&&(0,X.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`None in .forgeqe/knowledge yet.`}),s.knowledge.map(e=>(0,X.jsx)(Q,{checked:r.scope.knowledge.includes(e.file),onChange:t=>D({knowledge:ir(r.scope.knowledge,e.file,t)}),help:e.title===e.file?void 0:e.title,children:e.file},e.file))]})]}),(0,X.jsx)(K,{help:`Enforced on every call. Ask first: a person approves each such call in the chat. In production, every call is asked.`,children:`What it may do`}),(0,X.jsx)(`div`,{className:`flex flex-col gap-2 py-4`,children:s.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)(Q,{checked:r.permissions.actions.includes(e),onChange:t=>k({actions:ir(r.permissions.actions,e,t)}),help:nr[e]?.help,children:nr[e]?.label||e})}),(0,X.jsx)(Q,{checked:e===`external`?!(r.permissions.trust||[]).includes(`external`):r.permissions.approve.includes(e),disabled:!r.permissions.actions.includes(e),onChange:t=>k(e===`external`?{trust:ir(r.permissions.trust||[],`external`,!t)}:{approve:ir(r.permissions.approve,e,t)}),children:`Ask first`})]},e))}),(0,X.jsx)(G,{label:`Repository`,help:`Whether it may change files in the repository (with Change files).`,children:(0,X.jsx)(st,{label:`Repository`,value:r.permissions.repository,onChange:e=>k({repository:e}),options:[{id:`read`,label:`Read only`},{id:`write`,label:`May change files`}]})}),r.scope.environments.some(e=>s.environments.some(t=>t.name===e&&t.production))&&r.permissions.actions.includes(`run`)&&(0,X.jsx)(G,{label:`Production`,help:`Reads there go ahead without asking; every change there is approved by a person.`,children:(0,X.jsx)(Q,{checked:!(r.permissions.production||[]).includes(`run`),onChange:e=>k({production:e?[]:[`run`]}),children:`Ask before each run`})}),r.permissions.repository===`write`&&(()=>{let e=(s.coding||[]).filter(e=>s.capabilities.some(t=>r.scope.capabilities.includes(t.id)&&t.tools.includes(e)));if(!e.length)return null;let t=e.every(e=>(r.permissions.trust||[]).includes(e));return(0,X.jsx)(G,{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)(Q,{checked:!t,onChange:t=>k({trust:t?(r.permissions.trust||[]).filter(t=>!e.includes(t)):[...new Set([...r.permissions.trust||[],...e])]}),children:`Ask first`})})})(),(0,X.jsx)(G,{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)(ve,{id:`ca-depth`,value:String(r.runtime.maxDelegationDepth),onChange:e=>E({runtime:{...r.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)(G,{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)(F,{id:`ca-budget`,type:`number`,min:1e3,step:1e3,className:`w-[200px]`,value:r.runtime.maxTokens??``,placeholder:`No limit`,onChange:e=>E({runtime:{maxDelegationDepth:r.runtime.maxDelegationDepth,...e.target.value?{maxTokens:Math.max(0,Math.round(Number(e.target.value)))}:{}}})})}),(0,X.jsx)(K,{help:`One per line: what it should keep in mind. Guidance for the model, never a limit.`,children:`Guidance`}),(0,X.jsx)(V,{"aria-label":`Guidance, one per line`,rows:3,value:r.policies.join(`
|
|
3
|
+
`),onChange:e=>E({policies:e.target.value.split(`
|
|
4
|
+
`).map(e=>e.slice(0,300))})}),(0,X.jsx)(K,{help:`Requests its page offers to start from (at most 6).`,children:`Starters`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[r.starters.map((e,t)=>(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(F,{"aria-label":`Starter ${t+1} label`,className:`w-[200px]`,maxLength:40,value:e.label,placeholder:`Label`,onChange:e=>E({starters:r.starters.map((n,r)=>r===t?{...n,label:e.target.value}:n)})}),(0,X.jsx)(F,{"aria-label":`Starter ${t+1} request`,className:`min-w-0 flex-[1_1_280px]`,maxLength:500,value:e.text,placeholder:`The request`,onChange:e=>E({starters:r.starters.map((n,r)=>r===t?{...n,text:e.target.value}:n)})}),(0,X.jsx)(U,{variant:`icon`,size:`icon`,"aria-label":`Remove starter ${t+1}`,"data-tip":`Remove starter ${t+1}`,onClick:()=>E({starters:r.starters.filter((e,n)=>n!==t)}),children:(0,X.jsx)(w,{"aria-hidden":`true`})})]},t)),r.starters.length<6&&(0,X.jsxs)(U,{size:`sm`,className:`self-start`,onClick:()=>E({starters:[...r.starters,{label:``,text:``}]}),"data-tip":`Add a starter`,children:[(0,X.jsx)(f,{"aria-hidden":`true`}),`Add`]})]}),h.length>0&&(0,X.jsxs)(`section`,{"aria-labelledby":`ca-advice`,className:`mt-6 flex flex-col gap-2`,children:[(0,X.jsx)(`h2`,{id:`ca-advice`,className:`m-0 text-base font-semibold`,children:`What it still needs`}),(0,X.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:h.map((e,t)=>(0,X.jsxs)(`li`,{className:P(`flex flex-col gap-1 rounded-[12px] px-4 py-4 text-sm`,e.blocking?`bg-warn-soft`:`bg-surface-muted`),children:[(0,X.jsx)(`span`,{className:P(`font-medium`,e.blocking?`text-warn`:`text-ink`),children:e.about}),(0,X.jsx)(`span`,{className:`text-[13px] text-ink-2`,children:e.why}),(0,X.jsx)(`span`,{className:`text-[13px] text-muted`,children:e.fix})]},t))})]}),(0,X.jsxs)(`div`,{className:`sticky bottom-0 mt-4 flex flex-wrap items-center gap-4 border-t border-line-soft bg-bg py-4`,children:[(0,X.jsx)(`div`,{role:`status`,className:`min-w-0 flex-[1_1_320px] text-[13px]`,children:_?(0,X.jsx)(`span`,{className:`text-muted`,children:`Checking…`}):d.length?(0,X.jsxs)(`ul`,{className:`m-0 list-disc pl-6 text-fail [overflow-wrap:anywhere]`,children:[d.slice(0,4).map((e,t)=>(0,X.jsx)(`li`,{children:e},t)),d.length>4&&(0,X.jsxs)(`li`,{children:[`and `,d.length-4,` more`]})]}):(0,X.jsx)(`span`,{className:`text-pass`,children:`Ready to save. It can be tried once saved.`})}),(0,X.jsx)(`a`,{href:ne,className:`text-sm`,children:`Cancel`}),(0,X.jsxs)(U,{variant:`primary`,disabled:y||!r.id||!r.name,onClick:()=>void te(),"data-tip":n?`Save the agent`:`Save changes`,children:[(0,X.jsx)(A,{"aria-hidden":`true`}),`Save`]})]})]})]})]})}var or={legitimate:`Legitimate`,opportunistic:`Opportunistic`,adversarial:`Adversarial`},sr={sme:`Subject matter expert`,end_user:`End user`,specialist:`Specialist`,business_user:`Business user`},cr=[`personas`,`about`],lr={personas:`Personas`,about:`Tools and conversations`};function ur({current:e,count:t}){let[n,r]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{t===void 0&&N.list().then(e=>r(e.personas.length),()=>r(null))},[t===void 0]);let i=t??n;return(0,X.jsx)(Qe,{label:`Mask's pages`,current:e,links:[{id:`agent`,label:`Agent`,href:B(`agents`,`persona`)},{id:`personas`,label:i===null?`Personas`:`Personas (${i})`,href:B(`agents`,`persona`,`personas`)},{id:`about`,label:`Tools and conversations`,href:B(`agents`,`persona`,`about`)}]})}var dr=/^[a-z0-9][a-z0-9-]{0,39}$/,fr=/^[a-z][a-z0-9-]{1,39}$/,pr=e=>B(`agents`,`persona`,`personas`,encodeURIComponent(e));function mr({page:e,tab:t,sub:n}){let[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)([]),[s,c]=(0,Y.useState)(``),l=t===`new`,u=cr.includes(t)?t:`personas`,d=()=>N.list().then(e=>{i(e.personas),o(e.notLoaded),c(``)},e=>c(`The personas did not load: ${e.message}`));(0,Y.useEffect)(()=>{d()},[]);let f=u===`personas`&&n?me(n):``;return(0,X.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,X.jsx)(at,{}),(0,X.jsxs)(`main`,{className:P(ct,`@container flex-auto gap-4`),children:[(0,X.jsx)(Ct,{agent:e,tabs:(0,X.jsx)(ur,{current:u,...r?{count:r.length}:{}})}),(0,X.jsx)(`h2`,{className:`m-0 text-[20px] font-semibold`,children:lr[u]}),s&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-4 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:s}),!r&&!s&&(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}),r&&(0,X.jsx)(X.Fragment,{children:(0,X.jsxs)(`div`,{children:[u===`personas`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(hr,{personas:r,notLoaded:a,onChanged:e=>(i(e.personas),o(e.notLoaded))}),(0,X.jsx)(yr,{personas:r,opened:f,onChanged:e=>(i(e.personas),o(e.notLoaded))}),(0,X.jsx)(kr,{open:l,onClose:()=>location.hash=gr,personas:r,onSaved:e=>{d().then(()=>(Sr=e,location.hash=pr(e)))}})]}),u===`about`&&(0,X.jsx)(xi,{page:e})]})})]})]})}function hr({personas:e,notLoaded:t,onChanged:n}){let[r,i]=(0,Y.useState)(`all`),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(``),[d,p]=(0,Y.useState)(!1),m=(0,Y.useRef)(null),h=e.filter(e=>!e.builtIn).length,g=async()=>{c(``),u(``);try{let e=await N.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),c(`Exported ${M(h,`persona`)} of your own. Another project imports the file here.`)}catch(e){u(e.message)}},_=async e=>{let t=e?.[0];if(t){if(c(``),u(``),t.size>262144)return u(`${t.name} is over 256 KB.`);p(!0);try{let e=await N.importFile(await t.text());n(e),c(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&&u(`Not imported: ${e.skipped.map(e=>`${e.id} (${e.why})`).join(`; `)}`)}catch(e){u(e.message)}finally{p(!1)}}},v=a.toLowerCase().split(/\s+/).filter(Boolean),y=e.filter(e=>(r===`all`||e.kind===r)&&v.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-sm text-ink-2 tabular-nums`,children:[(0,X.jsx)(L,{icon:ne,size:14,className:`text-muted`}),M(e.length,`persona`),` · `,h,` 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:[h>0&&(0,X.jsxs)(U,{size:`sm`,onClick:()=>void g(),"data-tip":`A file of your own personas, for another project to import`,children:[(0,X.jsx)(D,{"aria-hidden":`true`}),`Export`]}),(0,X.jsxs)(U,{size:`sm`,disabled:d,onClick:()=>m.current?.click(),"data-tip":`Personas another project exported`,children:[(0,X.jsx)(re,{"aria-hidden":`true`}),d?`Importing…`:`Import`]}),(0,X.jsxs)(U,{size:`sm`,variant:`primary`,onClick:()=>location.hash=B(`agents`,`persona`,`new`),"data-tip":`Describe a person and Mask drafts the persona, or write it yourself`,children:[(0,X.jsx)(f,{"aria-hidden":`true`}),`New persona`]})]}),(0,X.jsx)(`input`,{ref:m,type:`file`,accept:`.json,application/json`,hidden:!0,onChange:e=>(_(e.target.files),e.target.value=``)})]}),s&&(0,X.jsx)(`p`,{role:`status`,className:`m-0 rounded-[12px] bg-surface-muted px-4 py-2 text-sm text-ink-2 [overflow-wrap:anywhere]`,children:s}),l&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-4 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:l}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(ge,{id:`persona-find`,label:`Find a persona`,value:a,onChange:o}),(0,X.jsx)(Se,{items:[{id:`all`,label:`All`,n:e.length},...ye.map(t=>({id:t,label:sr[t],n:e.filter(e=>e.kind===t).length}))],value:r,onChange:i})]}),y.length===0?(0,X.jsx)(z,{className:`py-4`,children:e.length?`No persona matches.`:`There are no personas yet.`}):(0,X.jsx)(`ul`,{"aria-label":`Personas`,className:`m-0 flex list-none flex-col rounded-[12px] card border p-2`,children:y.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`a`,{href:pr(e.id),className:`flex min-h-11 items-center gap-4 rounded-[8px] px-4 py-2 text-ink no-underline hover:bg-surface-muted hover:text-ink`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,X.jsxs)(`span`,{className:`truncate text-[13px] 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-[13px] text-muted`,children:[(0,X.jsxs)(`span`,{className:`font-mono`,children:[`/`,e.handle]}),` · `,sr[e.kind],e.intent===`legitimate`?``:` · ${or[e.intent].toLowerCase()}`,` · `,e.role,e.domain?` · ${e.domain}`:``]})]}),(0,X.jsx)(`span`,{className:`flex-none text-[13px] text-muted tabular-nums`,children:M(e.validates.length,`check`)})]})},e.id))}),t.length>0&&(0,X.jsxs)(`section`,{"aria-labelledby":`persona-not-loaded`,className:`flex flex-col gap-2`,children:[(0,X.jsx)(`h2`,{id:`persona-not-loaded`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Not loaded`}),(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-[13px] text-fail [overflow-wrap:anywhere]`,children:e},e))})]}),(0,X.jsx)(`p`,{className:`m-0 text-[13px] 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 gr=B(`agents`,`persona`,`personas`),_r=e=>{let{builtIn:t,...n}=e;return n},vr=(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 yr({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=gr,f=(t,n)=>{let r=new Set(e.flatMap(e=>[e.id,e.handle])),a=n===`copy`?{..._r(t),id:vr(t.id,r),handle:``}:_r(t);c(``),i({mode:n,from:t,fields:a,listText:Object.fromEntries(Dr.map(({key:e})=>[e,t[e].join(`
|
|
5
|
+
`)]))})},m=(0,Y.useMemo)(()=>new Set(e.filter(e=>r?.mode!==`edit`||e.id!==r.from.id).flatMap(e=>[e.id,e.handle])),[e,r]),g=r?Ar(r.fields,r.listText,m,r.mode===`edit`):null,_=br(!!t||!!r),v=async(e,t,r)=>{e[t].includes(r)||n(await N.update(e.id,{..._r(e),[t]:[...e[t],r]}))},b=async()=>{if(r&&g?.canSave){o(!0),c(``);try{let e={...r.fields,...Object.fromEntries(Dr.map(({key:e})=>[e,Or(r.listText[e]||``)]))},t=r.mode===`edit`?await N.update(r.from.id,e):await N.save(e);n(t),i(null),r.mode===`copy`&&(Sr=t.saved),location.hash=pr(t.saved)}catch(e){c(e.message)}finally{o(!1)}}};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(q,{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)(U,{onClick:d,children:[(0,X.jsx)(p,{"aria-hidden":`true`}),`Close`]}),l&&!l.builtIn&&(0,X.jsxs)(U,{variant:`primary`,onClick:()=>f(l,`edit`),children:[(0,X.jsx)(h,{"aria-hidden":`true`}),`Edit`]}),l?.builtIn&&(0,X.jsxs)(U,{variant:`primary`,"data-tip":`Make your own persona from this one, under another id and command`,onClick:()=>f(l,`copy`),children:[(0,X.jsx)(y,{"aria-hidden":`true`}),`Copy to edit`]})]}),children:l?(0,X.jsx)(Tr,{persona:l,resources:_,onAdd:l.builtIn?void 0:(e,t)=>v(l,e,t)}):(0,X.jsxs)(z,{className:`py-6`,children:[`There is no persona "`,t,`" in this project.`]})}),(0,X.jsx)(q,{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-[13px]`,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-sm text-fail [overflow-wrap:anywhere]`,children:s}):r&&!g?.canSave&&(0,X.jsxs)(`span`,{className:`mr-auto self-center text-[13px] text-muted`,children:[`It needs a name, `,r.mode===`copy`?`an id, `:``,`a role, and what they check or want.`]}),(0,X.jsxs)(U,{onClick:()=>i(null),children:[(0,X.jsx)(p,{"aria-hidden":`true`}),`Cancel`]}),(0,X.jsxs)(U,{variant:`primary`,disabled:a||!g?.canSave,onClick:()=>void b(),children:[(0,X.jsx)(A,{"aria-hidden":`true`}),a?`Saving…`:r?.mode===`copy`?`Save copy`:`Save`]})]}),children:r&&g&&(0,X.jsx)(`div`,{className:`pt-4`,children:(0,X.jsx)(jr,{fields:r.fields,listText:r.listText,onFields:e=>i({...r,fields:e}),onListText:e=>i({...r,listText:e}),check:g,idLocked:r.mode===`edit`,resources:_})})})]})}function br(e){let[t,n]=(0,Y.useState)(null);return(0,Y.useEffect)(()=>{e&&!t&&N.resources().then(n,e=>n({skills:[],documents:[],error:`The skills and documents did not load: ${e.message}`}))},[e,t]),t}function xr({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),N.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),p=e=>a?.documents.find(t=>t.ref===e),m=(0,X.jsx)(`span`,{className:`text-warn`,children:` · not in this project`}),h=async(e,t)=>{if(n){s(`${e}:${t}`),l(``);try{await n(e,t)}catch(e){l(e.message)}finally{s(``)}}},g=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)(`section`,{"aria-labelledby":`persona-uses`,className:`flex flex-col gap-2`,children:[(0,X.jsx)(`h3`,{id:`persona-uses`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Shared skills and documents`}),e.skills.length+e.knowledge.length===0?(0,X.jsx)(`p`,{className:`m-0 text-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)(L,{icon:C,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-[13px] [overflow-wrap:anywhere]`,children:e}),(0,X.jsxs)(`span`,{className:`text-[13px] text-muted [overflow-wrap:anywhere]`,children:[`Skill`,a&&!d(e)?m: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)(L,{icon:E,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-[13px] font-medium [overflow-wrap:anywhere]`,children:p(e)?.title||e}),(0,X.jsxs)(`span`,{className:`font-mono text-[13px] text-muted [overflow-wrap:anywhere]`,children:[e,a&&!p(e)?m:null]})]})]},`k:${e}`))]}),t?.error&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-4 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:t.error})]}),(0,X.jsxs)(`section`,{"aria-labelledby":`persona-suggested`,className:`flex flex-col gap-2`,children:[(0,X.jsx)(`h3`,{id:`persona-suggested`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Suggested for them`}),r?r.error?(0,X.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-4 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:r.error}):g.length===0?(0,X.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Nothing else matches their domain and checks. Add documents in Settings › Evidence, 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:g.map(t=>(0,X.jsxs)(`li`,{className:`flex items-center gap-4 border-t border-line-soft py-2`,children:[(0,X.jsx)(L,{icon:t.key===`skills`?C:E,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:P(`text-[13px] [overflow-wrap:anywhere]`,t.key===`skills`?`font-mono`:`font-medium`),children:t.key===`knowledge`&&p(t.name)?.title||t.name}),(0,X.jsxs)(`span`,{className:`text-[13px] text-muted [overflow-wrap:anywhere]`,children:[t.key===`skills`?`Skill`:t.name,` · matched `,t.why]})]}),n&&(0,X.jsxs)(U,{size:`sm`,disabled:!!o,onClick:()=>void h(t.key,t.name),"data-tip":`Add to what ${e.name} uses`,children:[(0,X.jsx)(f,{"aria-hidden":`true`}),o===`${t.key}:${t.name}`?`Adding…`:`Add`]})]},`${t.key}:${t.name}`))}):(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Looking for skills and documents that match…`}),c&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-4 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:c})]})]})}var Sr=``,Cr=e=>e.name.split(`,`)[0].trim()||e.name;function wr({persona:e}){let[t,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(``),f=Cr(e),m=()=>N.own(e.id).then(r,e=>r({skills:[],knowledge:[],problems:[],error:`${f}'s own skills and notes did not load: ${e.message}`})),g=async()=>{s(`draft`),l(``);try{let[t,n]=await Promise.all([N.draftOwn(e.id),N.own(e.id)]),r=(e,t)=>n[e].some(e=>e.name===t);d(``),a({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)(()=>{r(null),m(),Sr===e.id&&(Sr=``,g())},[e.id]);let _=async()=>{if(i){s(`save`),d(``);try{let t=i.items.filter(e=>e.was&&e.was!==e.name),n=await N.saveOwn(e.id,i.items.map(({was:e,...n})=>({...n,replace:n.replace&&!t.some(e=>e.kind===n.kind&&e.name===n.name)})));a({...i,items:i.items.map(e=>({...e,replace:!0}))});for(let n of t)await N.removeOwn(e.id,n.kind,n.was);r(t.length?await N.own(e.id):n),a(null)}catch(e){d(e.message),m()}finally{s(``)}}},v=async t=>{s(`remove:${t.kind}/${t.name}`),d(``);try{r(await N.removeOwn(e.id,t.kind,t.name)),a(null)}catch(e){d(e.message)}finally{s(``)}},y=t?[...t.skills,...t.knowledge]:[],b=(e,t)=>i&&a({...i,items:i.items.map((n,r)=>r===e?{...n,...t}:n)}),x=!!i&&i.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)(`section`,{"aria-labelledby":`persona-own`,className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(`h3`,{id:`persona-own`,className:`m-0 text-[13px] font-semibold text-muted`,children:[f,`'s own skills and knowledge`]}),(0,X.jsxs)(U,{size:`sm`,disabled:!!o||!t,onClick:()=>void g(),"data-tip":`Mask drafts a skill and a knowledge note for ${f}; you review them before anything is saved`,children:[(0,X.jsx)(n,{"aria-hidden":`true`}),o===`draft`?`Generating…`:y.length?`Generate again`:`Generate skill and knowledge`]})]}),(0,X.jsxs)(`p`,{className:`m-0 text-[13px] text-muted`,children:[`Used only when someone works as `,f,`, never by other agents.`]}),o===`draft`&&(0,X.jsxs)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:[`Mask is writing `,f,`'s skill and knowledge note…`]}),t?y.length===0?!t.error&&o!==`draft`&&(0,X.jsxs)(`p`,{className:`m-0 text-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:y.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center gap-4 border-t border-line-soft py-2`,children:[(0,X.jsx)(L,{icon:e.kind===`skills`?C:E,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-[13px] [overflow-wrap:anywhere]`,children:e.name}),(0,X.jsx)(`span`,{className:`line-clamp-2 text-[13px] text-muted [overflow-wrap:anywhere]`,children:e.kind===`skills`?`Skill · ${e.description}`:`Knowledge note`})]}),(0,X.jsxs)(U,{size:`sm`,disabled:!!o,onClick:()=>(d(``),a({drafted:!1,items:[{...e,replace:!0,was:e.name}]})),children:[(0,X.jsx)(h,{"aria-hidden":`true`}),`Edit`]})]},`${e.kind}:${e.name}`))}):(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}),t?.problems.length?(0,X.jsxs)(`p`,{className:`m-0 text-[13px] text-warn [overflow-wrap:anywhere]`,children:[`Not read: `,t.problems.join(`; `)]}):null,(c||t?.error)&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-4 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:c||t?.error}),(0,X.jsx)(q,{wide:!0,open:!!i,onClose:()=>a(null),title:i?.drafted?`Review ${f}'s skill and knowledge`:`Edit ${i?.items[0]?.was||``}`,description:(0,X.jsxs)(X.Fragment,{children:[i?.drafted&&(0,X.jsx)(X.Fragment,{children:`Mask's draft: change anything, then save. `}),`Kept in `,(0,X.jsxs)(`span`,{className:`font-mono text-[13px]`,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-sm text-fail [overflow-wrap:anywhere]`,children:u}):i&&!x&&(0,X.jsx)(`span`,{className:`mr-auto self-center text-[13px] text-muted`,children:`Each needs a name of lower-case words joined by dashes and its text; a skill also its "use when" line.`}),i&&!i.drafted&&i.items[0]?.was&&(0,X.jsxs)(U,{disabled:!!o,onClick:()=>void v({...i.items[0],name:i.items[0].was}),className:P(!u&&x&&`mr-auto`,`text-fail`),children:[(0,X.jsx)(w,{"aria-hidden":`true`}),o.startsWith(`remove:`)?`Deleting…`:`Delete`]}),(0,X.jsxs)(U,{onClick:()=>a(null),children:[(0,X.jsx)(p,{"aria-hidden":`true`}),`Cancel`]}),(0,X.jsxs)(U,{variant:`primary`,disabled:o===`save`||!x,onClick:()=>void _(),children:[(0,X.jsx)(A,{"aria-hidden":`true`}),o===`save`?`Saving…`:i?.drafted?`Save both`:`Save`]})]}),children:i&&(0,X.jsx)(`div`,{className:`flex flex-col gap-6 pt-4`,children:i.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-[13px] font-semibold text-muted`,children:[(0,X.jsx)(L,{icon:e.kind===`skills`?C:E,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-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Name`}),(0,X.jsx)(F,{value:e.name,maxLength:64,spellCheck:!1,autoComplete:`off`,className:`font-mono`,onChange:e=>b(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-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Use when`}),(0,X.jsx)(F,{value:e.description,maxLength:400,onChange:e=>b(t,{description:e.target.value})})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm`,children:[(0,X.jsx)(`label`,{htmlFor:`own-body-${t}`,className:`font-medium`,children:e.kind===`skills`?`Instructions`:`What it says`}),(0,X.jsx)(xt,{id:`own-body-${t}`,value:e.body,lang:`markdown`,onChange:e=>b(t,{body:e})})]})]},t))})})]})}function Tr({persona:e,resources:t,onAdd:n}){let r=[[`persona-validates`,`What they check before accepting the software`,e.validates],[`persona-goals`,`What they want to do`,e.goals],[`persona-knows`,`What they know`,e.knows],[`persona-frustrations`,`What puts them off`,e.frustrations],[`persona-scenarios`,`What they would try`,e.scenarios],[`persona-motivations`,`What drives them`,e.motivations],[`persona-permissions`,`What their role lets them do`,e.permissions],[`persona-constraints`,`What limits them`,e.constraints],[`persona-mistakes`,`Mistakes they make`,e.mistakes],[`persona-relationships`,`Who they deal with`,e.relationships]];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-[13px] text-muted`,children:[(0,X.jsxs)(`span`,{className:`font-mono`,children:[`/`,e.handle]}),` · `,sr[e.kind],` · `,e.role,e.domain?` · ${e.domain}`:``,` · `,e.expertise.charAt(0).toUpperCase()+e.expertise.slice(1),e.intent===`legitimate`?``:` · ${or[e.intent].toLowerCase()}, risk appetite ${e.risk_appetite}`,e.builtIn?``:` · version ${e.version}`]}),e.description&&(0,X.jsx)(`p`,{className:`m-0 text-sm leading-relaxed text-ink-2`,children:e.description})]}),(0,X.jsx)(wr,{persona:e}),(0,X.jsx)(xr,{persona:e,resources:t,...n?{onAdd:n}:{}}),r.filter(([,,e])=>e.length).map(([e,t,n])=>(0,X.jsxs)(`section`,{"aria-labelledby":e,className:`flex flex-col gap-2`,children:[(0,X.jsx)(`h3`,{id:e,className:`m-0 text-[13px] font-semibold text-muted`,children:t}),(0,X.jsx)(`ul`,{className:`m-0 flex list-disc flex-col gap-1 pl-6 text-sm text-ink-2`,children:n.map(e=>(0,X.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:e},e))})]},e))]})}var Er={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:[]},Dr=[{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.`}],Or=e=>e.split(`
|
|
6
|
+
`).map(e=>e.trim()).filter(Boolean);function kr({open:e,onClose:t,personas:r,onSaved:i}){let[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(null),[m,h]=(0,Y.useState)({}),[g,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)(``),[b,x]=(0,Y.useState)(``),C=(0,Y.useMemo)(()=>new Set(r.flatMap(e=>[e.id,e.handle])),[r]),w=br(!!d),T=(0,Y.useRef)(0);(0,Y.useEffect)(()=>{T.current+=1,e&&(o(``),c(``),u(``),f(null),h({}),_(!1),y(``),x(``))},[e]);let E=e=>{f(e),h(Object.fromEntries(Dr.map(({key:t})=>[t,e[t].join(`
|
|
7
|
+
`)])))},D=async()=>{let e=T.current;y(`draft`),x(``);try{let{persona:t}=await N.draft({request:a.trim(),...s?{kind:s}:{},...l.trim()?{domain:l.trim()}:{}});if(e!==T.current)return;let{builtIn:n,...r}=t;E(r),_(!0)}catch(t){e===T.current&&x(t.message)}finally{e===T.current&&y(``)}},O=async()=>{if(d){y(`save`),x(``);try{let e={...d,...Object.fromEntries(Dr.map(({key:e})=>[e,Or(m[e]||``)]))};i((await N.save(e)).saved)}catch(e){x(e.message),y(``)}}},k=d?Ar(d,m,C,!1):null,ee=!!k?.canSave;return(0,X.jsx)(q,{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-[13px]`,children:[`.forgeqe/business-personas/`,d?.id||`<id>`,`.yaml`]}),`, shared with the project.`]}),footer:(0,X.jsxs)(X.Fragment,{children:[b?(0,X.jsx)(`span`,{role:`alert`,className:`mr-auto self-center text-sm text-fail [overflow-wrap:anywhere]`,children:b}):d&&!ee&&(0,X.jsx)(`span`,{className:`mr-auto self-center text-[13px] text-muted`,children:`It needs a name, an id, a role, and what they check or want.`}),(0,X.jsxs)(U,{onClick:t,children:[(0,X.jsx)(p,{"aria-hidden":`true`}),`Cancel`]}),(0,X.jsxs)(U,{variant:`primary`,disabled:!!v||!ee,onClick:()=>void O(),children:[(0,X.jsx)(A,{"aria-hidden":`true`}),v===`save`?`Saving…`:`Save`]})]}),children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-6 pt-4`,children:[(0,X.jsxs)(`section`,{"aria-labelledby":`persona-ask`,className:`flex flex-col gap-4`,children:[(0,X.jsx)(`h3`,{id:`persona-ask`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Who is the persona?`}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Describe them`}),(0,X.jsx)(`span`,{className:`text-[13px] text-muted`,children:`Their job, what they know and what they check. Mask drafts the rest.`}),(0,X.jsx)(V,{rows:3,value:a,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-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Kind`}),(0,X.jsxs)(ve,{value:s,onChange:e=>c(e.target.value),children:[(0,X.jsx)(`option`,{value:``,children:`Let the agent choose`}),ye.map(e=>(0,X.jsx)(`option`,{value:e,children:sr[e]},e))]})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Domain`}),(0,X.jsx)(F,{value:l,maxLength:80,onChange:e=>u(e.target.value),placeholder:`payments`})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(U,{disabled:!!v||!a.trim(),onClick:()=>void D(),"data-tip":g?`Ask Mask for another draft`:`Ask Mask for a draft`,children:[(0,X.jsx)(n,{"aria-hidden":`true`}),g?`Draft again`:`Draft`]}),!d&&(0,X.jsxs)(U,{disabled:!!v,onClick:()=>E(Er),"data-tip":`Write every field yourself`,children:[(0,X.jsx)(S,{"aria-hidden":`true`}),`Write`]}),v===`draft`&&(0,X.jsx)(`span`,{role:`status`,className:`text-sm text-muted`,children:`Mask is drafting…`})]})]}),d&&k&&(0,X.jsxs)(`section`,{"aria-labelledby":`persona-fields`,className:`flex flex-col gap-4`,children:[(0,X.jsx)(`h3`,{id:`persona-fields`,className:`m-0 text-[13px] font-semibold text-muted`,children:`The persona`}),(0,X.jsx)(jr,{fields:d,listText:m,onFields:f,onListText:h,check:k,idLocked:!1,resources:w})]})]})})}function Ar(e,t,n,r){let i=r||e.id===``?``:dr.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===``?``:fr.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()&&(Or(t.validates||``).length>0||Or(t.goals||``).length>0)}}function jr({fields:e,listText:t,onFields:n,onListText:r,check:i,idLocked:a,resources:o}){let s=(t,r)=>n({...e,[t]:r}),{idProblem:c,handleProblem:l}=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-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Name`}),(0,X.jsx)(F,{value:e.name,maxLength:80,onChange:e=>s(`name`,e.target.value),placeholder:`Priya, payments SME`})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Id`}),(0,X.jsx)(F,{value:e.id,disabled:a,maxLength:40,spellCheck:!1,autoComplete:`off`,"aria-invalid":!!c,"aria-describedby":c?`persona-id-error`:void 0,onChange:e=>s(`id`,e.target.value.toLowerCase()),className:`font-mono`}),c&&(0,X.jsx)(`p`,{id:`persona-id-error`,role:`alert`,className:`m-0 text-[13px] text-fail`,children:c})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Command`}),(0,X.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[`Type it in any agent's chat: /`,e.handle||e.id||`priya`,` Validate the payment change.`]}),(0,X.jsx)(F,{value:e.handle,maxLength:40,spellCheck:!1,autoComplete:`off`,"aria-invalid":!!l,"aria-describedby":l?`persona-handle-error`:void 0,onChange:e=>s(`handle`,e.target.value.toLowerCase().replace(/^\//,``)),className:`font-mono`,placeholder:e.id||`priya`}),l&&(0,X.jsx)(`p`,{id:`persona-handle-error`,role:`alert`,className:`m-0 text-[13px] text-fail`,children:l})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Kind`}),(0,X.jsx)(ve,{value:e.kind,onChange:e=>s(`kind`,e.target.value),children:ye.map(e=>(0,X.jsx)(`option`,{value:e,children:sr[e]},e))})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Expertise in the domain`}),(0,X.jsx)(ve,{value:e.expertise,onChange:e=>s(`expertise`,e.target.value),children:ce.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-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Intent`}),(0,X.jsx)(`span`,{className:`text-[13px] text-muted`,children:`Opportunistic takes any advantage the app gives; adversarial sets out to misuse it. Watchdog tests as them.`}),(0,X.jsx)(ve,{value:e.intent,onChange:e=>s(`intent`,e.target.value),children:ue.map(e=>(0,X.jsx)(`option`,{value:e,children:or[e]},e))})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Risk appetite`}),(0,X.jsx)(ve,{value:e.risk_appetite,onChange:e=>s(`risk_appetite`,e.target.value),children:le.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-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Role`}),(0,X.jsx)(F,{value:e.role,maxLength:120,onChange:e=>s(`role`,e.target.value),placeholder:`Payments operations lead`})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Domain`}),(0,X.jsx)(F,{value:e.domain,maxLength:80,onChange:e=>s(`domain`,e.target.value)})]})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Who they are`}),(0,X.jsx)(V,{rows:3,value:e.description,maxLength:1200,onChange:e=>s(`description`,e.target.value)})]}),Dr.map(({key:e,label:n,hint:i})=>(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:n}),(0,X.jsx)(`span`,{className:`text-[13px] text-muted`,children:i}),(0,X.jsx)(V,{rows:e===`validates`?5:3,value:t[e]||``,onChange:n=>r({...t,[e]:n.target.value})})]},e)),(0,X.jsx)(Nr,{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:o?.skills.map(e=>({id:e.name,title:e.name,note:e.description,mono:!0}))??null,...o?.error?{error:o.error}:{},value:e.skills,onChange:e=>s(`skills`,e)}),(0,X.jsx)(Nr,{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:o?.documents.map(e=>({id:e.ref,title:e.title,note:e.ref}))??null,...o?.error?{error:o.error}:{},value:e.knowledge,onChange:e=>s(`knowledge`,e)})]})}var Mr=12;function Nr({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]:[],d=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))),f=a.length>=Mr;return(0,X.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 border-0 p-0 text-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-[13px] text-muted`,children:n}),i?(0,X.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-4 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:i}):r?u.length===0?(0,X.jsx)(`p`,{className:`m-0 text-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)(ge,{id:`${e}-find`,label:`Find in ${t.toLowerCase()}`,value:s,onChange:c})}),(0,X.jsxs)(`ul`,{"aria-label":t,className:`m-0 max-h-72 list-none overflow-y-auto rounded-[12px] card border px-4 py-0`,children:[d.length===0&&(0,X.jsx)(`li`,{className:`py-4 text-sm text-muted`,children:`Nothing matches.`}),d.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:P(`flex min-h-12 items-center gap-4 py-2`,!t&&f?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,X.jsx)(Tt,{checked:t,disabled:!t&&f,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:P(`text-[13px] [overflow-wrap:anywhere]`,e.mono?`font-mono`:`font-medium`),children:e.title}),(0,X.jsx)(`span`,{className:`line-clamp-2 text-[13px] text-muted [overflow-wrap:anywhere]`,"data-tip":e.note.length>120?e.note:void 0,children:e.note})]})]})},e.id)})]}),f&&(0,X.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[`At most `,Mr,`: take one off to pick another.`]})]}):(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`})]})}var Pr=[`agent`,`tests`,`personas`,`findings`],Fr={agent:`Agent`,tests:`Tests`,personas:`Personas`,findings:`Findings`},Ir={agent:`BASAL`,tests:`Business tests`,personas:`Personas`,findings:`Findings`},Lr={agent:`Business testing that acts. Ask a business question; BASAL works it through the steps below, beside the product's knowledge graph, and ForgeQE's agents play each step 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.`},$=(e,t)=>e===`agent`?B(`agents`,`basal`):t?B(`agents`,`basal`,e,t):B(`agents`,`basal`,e),Rr=[`ask`,`understand`,`strategy`,`cast`,`rehearse`,`approve`,`act`,`judge`],zr={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.`}},Br={asked:1,understood:2,planned:3,cast:4,rehearsed:5,approved:6,acted:8},Vr={understand:1,strategy:2,cast:3,rehearse:4,act:6},Hr=e=>String(e).padStart(2,`0`),Ur=[{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`}],Wr={confirmed_failure:`fail`,policy_ambiguity:`warn`,potential_risk:`warn`,missing_evidence:`neutral`,expected_behaviour:`pass`},Gr=[`confirmed_failure`,`policy_ambiguity`,`potential_risk`,`missing_evidence`,`expected_behaviour`];function Kr({page:e,tab:t,sub:n}){let r=Pr.includes(t)?t:`agent`,[i,a]=r===`tests`&&n?n.split(`/`):[],o=i?me(i):``,s=(e,t)=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`h2`,{className:`m-0 text-[20px] font-semibold`,children:Ir[e]}),(0,X.jsx)(`p`,{className:`m-0 text-[13px] leading-relaxed text-ink-2`,children:Lr[e]}),t]});return(0,X.jsx)(Pt,{page:e,title:Pe(`basal`),label:`BASAL`,current:r,onPick:e=>location.hash=$(e),tabs:Pr.filter(e=>e!==Ft).map(e=>({id:e,label:Fr[e]})),agentBody:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`m-0 text-[13px] leading-relaxed text-ink-2`,children:Lr.agent}),(0,X.jsx)(Zr,{})]}),children:o?(0,X.jsx)($r,{id:o,step:Rr.includes(a)?a:void 0},o):r===`tests`?s(`tests`,(0,X.jsx)(Qr,{})):r===`personas`?s(`personas`,(0,X.jsx)(hi,{})):r===`findings`?s(`findings`,(0,X.jsx)(gi,{})):null})}function qr(){let[e,t]=(0,Y.useState)(null),[n,r]=(0,Y.useState)(``),i=(0,Y.useCallback)(()=>R.home().then(t,e=>r(e.message)),[]);return(0,Y.useEffect)(()=>void i(),[i]),{home:e,error:n,load:i}}function Jr({g:e}){return(0,X.jsx)(`p`,{className:`m-0 text-[13px] text-muted tabular-nums`,children:e.connected?(0,X.jsxs)(X.Fragment,{children:[`Graph store: Neo4j · `,M(e.product||0,`product node`),` · `,M(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: the product graph's file`,e.reason?` (${e.reason})`:``,`. forgeqe graph setup starts Neo4j.`]})})}function Yr({home:t}){let[n,r]=(0,Y.useState)(``),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(``),c=async()=>{a(!0),s(``);try{let{id:e}=await R.ask(n.trim());await R.stage(e,`understand`),location.hash=$(`tests`,`${e}/understand`)}catch(e){s(e.message)}finally{a(!1)}};return(0,X.jsxs)(`section`,{"aria-labelledby":`basal-new`,className:`flex flex-col gap-2 rounded-[14px] card border p-4`,children:[(0,X.jsx)(`h2`,{id:`basal-new`,className:`m-0 text-[13px] font-semibold text-muted`,children:`New business test`}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Your business question`}),(0,X.jsx)(V,{id:`basal-request`,rows:3,value:n,onChange:e=>r(e.target.value),placeholder:`Should we launch saved cards with a fee? Test how merchants, shoppers and support would really be affected.`})]}),(0,X.jsx)(`span`,{className:`text-[13px] text-muted`,children:`Briefs and data files are added with forgeqe basal new --file; the product's knowledge graph and documents are read for every test.`}),o&&(0,X.jsx)(J,{text:o}),(0,X.jsx)(`div`,{children:(0,X.jsxs)(U,{variant:`primary`,disabled:i||n.trim().length<10||!t.model,onClick:()=>void c(),"data-tip":t.model?`Keeps the question and starts step 02, Understand`:`Set up a model in Settings › Models first`,children:[(0,X.jsx)(e,{"aria-hidden":`true`}),i?`Starting…`:`Start`]})})]})}function Xr({tests:e,search:t=!0,tools:n}){return(0,X.jsx)(qe,{label:`Business tests`,placeholder:`Find a business test`,empty:`No business test yet. Ask a business question on the Agent tab.`,search:t,...n?{tools:n}:{},head:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`th`,{className:P(we,`w-[55%]`),children:`Business question`}),(0,X.jsx)(`th`,{className:P(we,`hidden @xl:table-cell`),children:`Asked`}),(0,X.jsx)(`th`,{className:P(tt,`hidden @2xl:table-cell`),children:`Steps done`}),(0,X.jsx)(`th`,{className:we,children:`Stage`})]}),children:e.map(e=>{let t=Br[e.stage];return(0,X.jsxs)(`tr`,{onClick:()=>location.hash=$(`tests`,e.id),className:it,children:[(0,X.jsxs)(`td`,{className:P(Ye,`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:P(Ye,`hidden whitespace-nowrap text-muted @xl:table-cell`),children:e.created.slice(0,10)}),(0,X.jsx)(`td`,{className:P(Re,`hidden text-muted @2xl:table-cell`),children:t===void 0?`–`:`${t} of ${Rr.length}`}),(0,X.jsx)(`td`,{className:P(Ye,`whitespace-nowrap`),children:e.running?(0,X.jsx)(I,{tone:`running`,children:e.running}):(0,X.jsx)(I,{tone:`neutral`,children:e.stage})})]},e.id)})})}function Zr(){let{home:e,error:t}=qr();return t?(0,X.jsx)(J,{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:Rr.map((e,t)=>(0,X.jsxs)(`li`,{className:`flex flex-col gap-1 rounded-[12px] bg-surface-muted p-4`,children:[(0,X.jsxs)(`span`,{className:`font-mono text-[13px] text-muted`,children:[`STEP `,Hr(t+1)]}),(0,X.jsx)(`span`,{className:`text-[13px] font-semibold`,children:zr[e].name})]},e))}),(0,X.jsx)(Jr,{g:e.graph}),(0,X.jsx)(Yr,{home:e}),e.tests.length>0&&(0,X.jsxs)(`section`,{"aria-labelledby":`basal-recent`,className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`h2`,{id:`basal-recent`,className:`m-0 flex items-center justify-between text-[13px] font-semibold text-muted`,children:[`Recent tests`,(0,X.jsx)(`a`,{href:$(`tests`),className:`text-[13px] font-normal`,children:`Every test`})]}),(0,X.jsx)(Xr,{tests:e.tests.slice(0,5),search:!1})]})]}):(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`})}function Qr(){let{home:e,error:t,load:n}=qr();return t?(0,X.jsx)(J,{text:t}):e?(0,X.jsx)(Xr,{tests:e.tests,tools:(0,X.jsxs)(U,{size:`sm`,variant:`ghost`,onClick:()=>void n(),className:`ml-auto`,"data-tip":`Read the tests again`,children:[(0,X.jsx)(a,{"aria-hidden":`true`}),`Refresh`]})}):(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`})}function $r({id:e,step:t}){let[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(``),c=(0,Y.useCallback)(()=>R.test(e).then(r,e=>s(e.message)),[e]),l=(0,Y.useCallback)(()=>R.graph(e).then(a,e=>s(`The graph could not be read: ${e.message}`)),[e]);(0,Y.useEffect)(()=>{c(),l()},[c,l]);let u=!(!n?.job||n.job.endedAt);if((0,Y.useEffect)(()=>{if(!u)return;let e=setInterval(()=>{c(),l()},2500);return()=>{clearInterval(e),l()}},[u,c,l]),!n)return o?(0,X.jsx)(J,{text:o}):(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`});let d=Br[n.stage],f=n.job&&!n.job.endedAt?Vr[n.job.stage]:-1,p=t||Rr[f>=0?f:Math.min(d,Rr.length-1)],m=Rr.indexOf(p),h=async(e,t)=>{s(``);try{await e(),await c(),t&&(location.hash=$(`tests`,`${n.id}/${t}`))}catch(e){s(e.message)}},g=e=>e===f?{tone:`running`,word:`Working`}:e<d?{tone:`pass`,word:`Completed`}:e===d?{tone:`warn`,word:`Next`}:{tone:`neutral`,word:`Waiting`},_=g(m);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.jsxs)(`a`,{href:$(`tests`),className:`inline-flex items-center gap-2 self-start text-sm`,children:[(0,X.jsx)(x,{size:16,"aria-hidden":`true`}),`Every test`]}),(0,X.jsx)(`h2`,{className:`m-0 line-clamp-2 text-[20px] font-semibold text-balance`,"data-tip":n.scenario?.decision||n.request.request,children:n.scenario?.decision||n.request.request}),(0,X.jsxs)(`p`,{className:`m-0 text-[13px] text-muted`,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 rounded-[12px] bg-surface-muted p-1`,children:Rr.map((e,t)=>{let r=g(t),i=t<=d||t===f,a=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,X.jsx)(`span`,{className:`font-mono text-[13px] text-muted`,children:Hr(t+1)}),(0,X.jsx)(`span`,{className:`text-[13px] font-medium`,children:zr[e].name})]}),(0,X.jsx)(I,{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===p?`step`:void 0,className:P(`flex h-full flex-col gap-1 rounded-[8px] px-2 py-2 text-ink no-underline hover:text-ink`,e===p?`bg-bg`:`hover:bg-bg`),children:a}):(0,X.jsx)(`span`,{className:`flex h-full flex-col gap-1 rounded-[8px] px-2 py-2 opacity-60`,children:a})},e)})})}),o&&(0,X.jsx)(J,{text:o}),(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-[13px] text-muted tabular-nums`,children:i?.connected?`${M(i.nodes.length,`node`)} · ${M(i.edges.length,`edge`)} · scenario over the product graph`:`Graph store not connected`}),(0,X.jsx)(oi,{graph:i,onRefresh:()=>void R.regraph(e).then(l,e=>s(e.message))})]}),(0,X.jsxs)(`section`,{"aria-labelledby":`basal-step`,className:`flex min-w-0 flex-col gap-4 rounded-[14px] card border p-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`rounded-[8px] bg-accent-soft px-2 py-1 font-mono text-[13px] font-medium text-accent-fg`,children:[`STEP `,Hr(m+1)]}),(0,X.jsx)(`h3`,{id:`basal-step`,className:`m-0 text-[16px] font-semibold`,children:zr[p].name}),(0,X.jsx)(`span`,{className:`ml-auto`,children:(0,X.jsx)(I,{tone:_.tone,children:_.word})})]}),(0,X.jsx)(`p`,{className:`m-0 text-[13px] text-ink-2`,children:zr[p].about}),n.job&&Vr[n.job.stage]===m&&(0,X.jsx)(ai,{t:n}),(0,X.jsx)(ei,{step:p,t:n,onRun:h})]})]})]})}function ei({step:e,t,onRun:n}){let r=!(!t.job||t.job.endedAt),i=(e,t,i,a)=>(0,X.jsx)(`div`,{className:`border-t border-line pt-4`,children:(0,X.jsxs)(U,{variant:`primary`,disabled:r,onClick:()=>void n(i,a),"data-tip":t,children:[(0,X.jsx)(O,{"aria-hidden":`true`}),e]})}),a=(e,n)=>(0,X.jsx)(`div`,{className:`border-t border-line pt-4`,children:(0,X.jsxs)(`a`,{href:$(`tests`,`${t.id}/${n}`),className:j({variant:`primary`}),children:[(0,X.jsx)(O,{"aria-hidden":`true`}),e]})});return e===`ask`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`m-0 rounded-[8px] bg-surface-strong px-4 py-2 text-[13px] text-ink [overflow-wrap:anywhere]`,children:t.request.request}),(0,X.jsx)(Rt,{label:`Files`,children:t.request.files.length?t.request.files.join(`, `):`none`}),(0,X.jsx)(Rt,{label:`Work items`,children:t.request.stories.length?t.request.stories.join(`, `):`none`}),(0,X.jsx)(Rt,{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`,()=>R.stage(t.id,`understand`),`understand`):a(`Next: Understand`,`understand`)]}):e===`understand`?t.scenario?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(mi,{t}),t.stage===`understood`?i(`Plan the test strategy`,`Scenarios, the agent for each step, and the business expectations`,()=>R.stage(t.id,`strategy`),`strategy`):a(`Next: Strategy`,`strategy`)]}):(0,X.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`BASAL is reading the sources.`}):e===`strategy`?t.strategy?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(fi,{t}),t.stage===`planned`?i(`Cast the personas`,`One persona for each stakeholder who acts in the strategy`,()=>R.stage(t.id,`cast`),`cast`):a(`Next: Cast`,`cast`)]}):(0,X.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`Not planned yet.`}):e===`cast`?t.cast.length?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(pi,{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`,()=>R.stage(t.id,`rehearse`),`rehearse`):a(`Next: Rehearse`,`rehearse`)]}):(0,X.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`Not cast yet.`}):e===`rehearse`?(0,X.jsx)(ni,{t,onRun:n}):e===`approve`?(0,X.jsx)(ri,{t,onRun:n}):e===`act`?(0,X.jsx)(ii,{t,onRun:n}):t.verdicts.length?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ci,{t,onObserve:(e,r,i)=>void n(()=>R.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`,()=>R.stage(t.id,`rehearse`),`rehearse`)]}):(0,X.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`No verdict yet: the strategy has not been played.`})}var ti={support:`pass`,oppose:`fail`,undecided:`neutral`};function ni({t,onRun:n}){let r=!(!t.job||t.job.endedAt),i=new Map(t.cast.map(e=>[e.id,e.name])),a=t.rounds.at(-1),o=t.rounds.flatMap(e=>e.posts),s=new Map(o.map(e=>[e.id,e]));if(!a)return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`No round yet.`}),(0,X.jsx)(`div`,{className:`border-t border-line pt-4`,children:(0,X.jsxs)(U,{variant:`primary`,disabled:r||!t.cast.length,onClick:()=>void n(()=>R.stage(t.id,`rehearse`)),children:[(0,X.jsx)(e,{"aria-hidden":`true`}),`Play round 1`]})})]});let c={support:0,oppose:0,undecided:0};for(let e of a.turns)c[e.stance]=(c[e.stance]||0)+1;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`m-0 text-[13px] text-muted tabular-nums`,children:[`Round `,a.n,` · `,M(o.length,`post`),` on the feed · `,c.support,` support · `,c.oppose,` oppose · `,c.undecided,` undecided`,a.events.length?` · reacted to ${M(a.events.length,`outcome`)} on the product`:``]}),(0,X.jsxs)(`section`,{"aria-label":`Feed`,className:`flex flex-col gap-2`,children:[(0,X.jsx)(`h3`,{className:`m-0 text-[13px] font-semibold text-muted`,children:`Feed`}),(0,X.jsx)(`ol`,{className:`m-0 flex max-h-[420px] list-none flex-col gap-2 overflow-y-auto p-0`,children:[...o].reverse().map(e=>(0,X.jsxs)(`li`,{className:`flex flex-col gap-1 rounded-[8px] border border-line bg-bg p-2 text-[13px]`,children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:i.get(e.author)||e.author}),(0,X.jsxs)(`span`,{className:`text-muted`,children:[e.kind,e.target?` on ${i.get(s.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.jsxs)(`section`,{"aria-label":`Stances`,className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`h3`,{className:`m-0 text-[13px] font-semibold text-muted`,children:[`Where the cast stand after round `,a.n]}),(0,X.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0 text-[13px]`,children:a.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:i.get(e.id)||e.id}),` `,(0,X.jsxs)(`span`,{className:`text-ink-2`,children:[`— `,e.feeling]})]}),(0,X.jsx)(I,{tone:ti[e.stance]||`neutral`,icon:!1,children:e.stance})]},e.id))})]}),t.wanted.length>0&&(0,X.jsxs)(`section`,{"aria-label":`Wanted next`,className:`flex flex-col gap-1 text-[13px]`,children:[(0,X.jsx)(`h3`,{className:`m-0 text-[13px] font-semibold text-muted`,children:`What the cast want tried`}),t.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=>i.get(e)||e).join(`, `)]})]},e.scenario))]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2 border-t border-line pt-4`,children:[(0,X.jsxs)(`a`,{href:$(`tests`,`${t.id}/${t.strategy?.approved?`act`:`approve`}`),className:j({variant:`primary`}),children:[(0,X.jsx)(O,{"aria-hidden":`true`}),t.strategy?.approved?`Next: Act`:`Next: Approve`]}),(0,X.jsxs)(U,{variant:`outline`,disabled:r,onClick:()=>void n(()=>R.stage(t.id,`rehearse`)),children:[(0,X.jsx)(e,{"aria-hidden":`true`}),`Play round `,a.n+1]})]})]})}function ri({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-[13px] 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:`border-t border-line pt-4`,children:(0,X.jsxs)(`a`,{href:$(`tests`,`${e.id}/act`),className:j({variant:`primary`}),children:[(0,X.jsx)(O,{"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-[13px] text-ink-2`,children:[(0,X.jsxs)(`li`,{children:[M(i.scenarios.length,`scenario`),` on `,i.environment||`no test environment`,`, `,M(i.scenarios.reduce((e,t)=>e+t.steps.length,0),`step`)]}),(0,X.jsx)(`li`,{children:e.writes.length?`${M(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} (${di[e.channel]})`:di[e.channel])))].join(`, `)]}),i.needs.length>0&&(0,X.jsxs)(`li`,{className:`text-warn`,children:[M(i.needs.length,`thing`),` still needed: see Strategy`]})]}):null,(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Type the test's id to approve`}),(0,X.jsx)(F,{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-[13px] text-muted`,children:e.id}),(0,X.jsx)(`div`,{className:`border-t border-line pt-4`,children:(0,X.jsxs)(U,{variant:`primary`,disabled:n.trim()!==e.id||!i,onClick:()=>void t(()=>R.approve(e.id,n.trim()),`act`),children:[(0,X.jsx)(A,{"aria-hidden":`true`}),`Approve`]})})]})}function ii({t,onRun:n}){let[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(!0),s=!(!t.job||t.job.endedAt);if(!t.strategy?.approved)return(0,X.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`Approve the strategy first.`});let c=a&&t.wanted.length?t.wanted.map(e=>e.scenario):[];return(0,X.jsxs)(X.Fragment,{children:[t.handovers.length>0&&(0,X.jsx)(si,{handovers:t.handovers}),!s&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-line pt-4`,children:[t.wanted.length>0&&(0,X.jsxs)(`label`,{className:`flex min-h-9 cursor-pointer items-center gap-2 text-[13px]`,children:[(0,X.jsx)(Tt,{id:`basal-wanted`,checked:a,onCheckedChange:o}),`Only what the cast wants tried after round `,t.rounds.length,`: `,t.wanted.map(e=>e.scenario).join(`, `)]}),t.writes.length>0?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`m-0 text-[13px] text-ink-2`,children:[`These steps change data on `,t.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-[13px] text-warn`,children:t.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-[13px]`,children:[(0,X.jsx)(Tt,{id:`basal-writes`,checked:r,onCheckedChange:i}),`Let these steps change data`]})]}):(0,X.jsx)(`p`,{className:`m-0 text-[13px] text-ink-2`,children:`No step changes data.`}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsxs)(U,{variant:`primary`,onClick:()=>void n(()=>R.act(t.id,r?t.writes:[],c)),"data-tip":`Hands each step to ForgeQE's agents as its persona`,children:[(0,X.jsx)(e,{"aria-hidden":`true`}),t.verdicts.length?`Play it again`:`Act`]}),t.verdicts.length>0&&(0,X.jsxs)(`a`,{href:$(`tests`,`${t.id}/judge`),className:j({variant:`outline`}),children:[(0,X.jsx)(O,{"aria-hidden":`true`}),`Next: Judge`]})]})]})]})}function ai({t:e}){let t=e.job;return(0,X.jsxs)(`section`,{"aria-labelledby":`basal-feed`,className:`flex flex-col gap-2 rounded-[14px] card border p-4`,children:[(0,X.jsxs)(`h3`,{id:`basal-feed`,className:`m-0 flex items-center justify-between gap-2 text-[13px] font-semibold text-muted`,children:[(0,X.jsxs)(`span`,{children:[`Live · `,t.stage]}),t.endedAt?(0,X.jsx)(I,{tone:t.error?`fail`:`pass`,children:t.error?`stopped`:`finished`}):(0,X.jsx)(I,{tone:`running`,children:`working`})]}),(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-[13px] 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)(J,{text:t.error})]})}function oi({graph:e,onRefresh:n}){let[r,i]=(0,Y.useState)(null),{nodes:a,edges:o,types:s}=(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]),c=e=>It[Math.max(0,s.indexOf(e))%It.length],l=null;if(r?.kind===`node`){let t=e?.nodes.find(e=>e.id===r.id);t&&(l={title:t.name,pill:{text:t.layer===`product`?`product ${t.type}`:t.type,colour:c(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)(Rt,{label:`Layer`,children:t.layer}),t.state&&(0,X.jsx)(Rt,{label:`Evidence`,children:t.state})]})})}return e?.connected?a.length?(0,X.jsx)(Lt,{title:`Live knowledge graph`,nodes:a,edges:o,colourOfType:c,types:s,typesTitle:`Node types`,picked:r,onPick:i,detail:l,onRefresh:n}):(0,X.jsx)(z,{icon:t,title:`No scenario in the graph yet`,children:`It appears once BASAL has understood the question.`}):(0,X.jsx)(z,{icon:t,title:`The graph store is not connected`,children:e?.reason||`Start Neo4j with forgeqe graph setup to see the scenario grow over the product graph.`})}function si({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.jsxs)(`section`,{"aria-labelledby":`basal-board`,className:`flex flex-col gap-2`,children:[(0,X.jsx)(`h3`,{id:`basal-board`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Operations board`}),(0,X.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`Each card is a handover from BASAL to one of ForgeQE's agents, as one persona.`}),(0,X.jsx)(`div`,{className:`grid gap-2 @[1200px]:grid-cols-2`,children:Ur.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:`flex min-w-0 flex-col gap-2 rounded-[12px] bg-surface-muted p-2`,children:[(0,X.jsxs)(`h4`,{className:`m-0 px-2 pt-1 text-[13px] font-semibold`,children:[e.title,` `,(0,X.jsxs)(`span`,{className:`font-normal text-muted`,children:[`· `,t.length]})]}),t.map(e=>(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-[8px] border border-line bg-bg p-2 text-[13px]`,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)(I,{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 ci({t:e,onObserve:t}){let n=[...e.verdicts].sort((e,t)=>Gr.indexOf(e.outcome)-Gr.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)(li,{v:e,onObserve:(n,r)=>t(e.scenario,n,r)},e.scenario))})})}function li({v:e,onObserve:t}){return(0,X.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-[12px] card border p-4`,children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(I,{tone:Wr[e.outcome],children:e.label}),(0,X.jsx)(`span`,{className:`text-[13px] font-medium`,children:e.title}),(0,X.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[`· confidence `,e.confidence]})]}),(0,X.jsx)(`p`,{className:`m-0 text-[13px] 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-[13px]`,children:e.results.map(e=>(0,X.jsxs)(`li`,{className:P(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-[13px] text-warn`,children:[`Step `,e,` waits for a person:`,(0,X.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>t(e,!0),children:`The app let them do it`}),(0,X.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>t(e,!1),children:`The app refused it`})]},e))]})}var ui=e=>e.map(e=>e.trim().replace(/[.;]+$/,``)).join(`; `),di={browser:`browser`,api:`API`,mobile:`mobile`,desktop:`desktop`,person:`a person`,opinion:`opinion`};function fi({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-[13px] text-muted`,children:[M(t.scenarios.length,`scenario`),` on `,t.environment||`no test environment`,` · `,M(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-[13px] 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:`flex flex-col gap-2 rounded-[12px] card border p-4`,children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(I,{tone:e.priority===1?`warn`:`neutral`,icon:!1,children:[`P`,e.priority,` · `,e.risk]}),(0,X.jsx)(`span`,{className:`text-[13px] font-medium`,children:e.title})]}),(0,X.jsx)(`p`,{className:`m-0 text-[13px] text-ink-2`,children:e.question}),(0,X.jsx)(`ol`,{className:`m-0 flex flex-col gap-1 pl-6 text-[13px]`,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:[`· `,di[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-[13px] 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 pi({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:`flex flex-col gap-1 rounded-[12px] card border p-4 text-[13px]`,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)(I,{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: `,ui(e.validates)]}),e.frustrations.length>0&&(0,X.jsxs)(`span`,{className:`text-ink-2`,children:[`Objects to: `,ui(e.frustrations)]}),e.mistakes.length>0&&(0,X.jsxs)(`span`,{className:`text-ink-2`,children:[`Brings: `,ui(e.mistakes)]})]},e.id))})})}function mi({t:e}){let t=e.scenario,n=e=>(0,X.jsx)(I,{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:`flex flex-col gap-1 rounded-[12px] card border p-4 text-[13px]`,children:[(0,X.jsx)(`h3`,{className:`m-0 text-[13px] font-semibold text-muted`,children:`Success criteria`}),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:`flex flex-col gap-1 rounded-[12px] card border p-4 text-[13px]`,children:[(0,X.jsx)(`h3`,{className:`m-0 text-[13px] font-semibold text-muted`,children:`Stakeholders`}),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:`flex flex-col gap-1 rounded-[12px] card border p-4 text-[13px]`,children:[(0,X.jsxs)(`h3`,{className:`m-0 text-[13px] font-semibold text-muted`,children:[`Facts (`,t.facts.length,`)`]}),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 hi(){let{home:e,error:n}=qr(),[r,i]=(0,Y.useState)(null);return(0,Y.useEffect)(()=>{e&&Promise.all(e.tests.slice(0,8).map(e=>R.test(e.id).catch(()=>null))).then(e=>i(e.filter(e=>!!(e&&e.cast.length))))},[e]),n?(0,X.jsx)(J,{text:n}):r?r.length?(0,X.jsx)(`div`,{className:`flex flex-col gap-6`,children:r.map(e=>(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`a`,{href:$(`tests`,e.id),className:`text-[13px] font-medium`,children:e.scenario?.decision||e.request.request}),(0,X.jsx)(pi,{t:e})]},e.id))}):(0,X.jsx)(z,{icon:t,title:`No cast yet`,children:`A test is cast after its strategy is planned.`}):(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`})}function gi(){let{home:e,error:n}=qr(),[r,i]=(0,Y.useState)(null);return(0,Y.useEffect)(()=>{e&&Promise.all(e.tests.slice(0,12).map(e=>R.test(e.id).catch(()=>null))).then(e=>i(e.filter(e=>!!e).flatMap(e=>e.verdicts.map(t=>({t:e,v:t}))).sort((e,t)=>Gr.indexOf(e.v.outcome)-Gr.indexOf(t.v.outcome))))},[e]),n?(0,X.jsx)(J,{text:n}):r?r.length?(0,X.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:r.map(({t:e,v:t})=>(0,X.jsx)(li,{v:{...t,title:`${t.title} — ${e.scenario?.decision.slice(0,80)||e.id}`}},`${e.id}#${t.scenario}`))}):(0,X.jsx)(z,{icon:t,title:`No verdict yet`,children:`A verdict appears when a test's strategy has been played.`}):(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`})}var _i=5;function vi({to:e}){return(0,Y.useEffect)(()=>location.replace(`#${e.replace(/^#/,``)}`),[e]),null}function yi({id:e}){if(!e)return(0,X.jsx)(cn,{});let[t,n,r,...i]=e.split(`/`);if(t===`custom`&&n===`new`&&r===`template`&&i.length===1&&/^[a-z][a-z0-9-]{0,39}$/.test(i[0]))return(0,X.jsx)(ar,{template:i[0]},i[0]);if(t===`custom`&&!i.length){if(n===`new`&&r===void 0)return(0,X.jsx)(pn,{});if(n===`new`&&r===`form`)return(0,X.jsx)(ar,{});if(n===`build`&&r&&/^[a-f0-9]{16}$/.test(r))return(0,X.jsx)(hn,{sid:r},r);if(n&&Te.test(n)&&r===void 0)return(0,X.jsx)(Dn,{id:n},n);if(n&&Te.test(n)&&r===`edit`)return(0,X.jsx)(ar,{id:n},n)}let[a,o,...s]=(e||``).split(`/`);if(a===`business`)return(0,X.jsx)(vi,{to:B(`agents`,`basal`)});let c=Fe(a),l=o===`tools`||o===`conversations`;if(c?.id===`persona`&&o===void 0)return(0,X.jsx)(Et,{agent:c,tabs:(0,X.jsx)(ur,{current:`agent`})},c.id);if(c?.id===`persona`&&!l)return(0,X.jsx)(mr,{page:c,tab:o,sub:s.join(`/`)},`${c.id}/${o}`);if(c?.opens&&!l)return(0,X.jsx)(bi,{to:B(...c.opens,...[o,...s].filter(e=>!!e))});if(c?.id===`basal`&&!l)return(0,X.jsx)(Kr,{page:c,tab:o,sub:s.join(`/`)},c.id);let u=a===`category`&&!s.length?rt(o):void 0;return u?(0,X.jsx)(cn,{only:u.id},u.id):c&&o===`tools`&&!s.length?(0,X.jsx)(Ei,{page:c},c.id):c&&o===`conversations`&&!s.length?(0,X.jsx)(ki,{page:c},c.id):!c||o!==void 0?(0,X.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,X.jsx)(at,{}),(0,X.jsxs)(`p`,{className:`m-0 px-6 py-10 text-sm text-muted`,children:[`There is no such agent. `,(0,X.jsx)(`a`,{href:B(`agents`),children:`See every agent`}),`, or `,(0,X.jsx)(`a`,{href:B(),children:`start a chat`}),` instead.`]})]}):(0,X.jsx)(Et,{agent:c,below:(0,X.jsx)(xi,{page:c})},c.id)}function bi({to:e}){return(0,Y.useEffect)(()=>{location.replace(e)},[e]),null}function xi({page:e}){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)([]),[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{let t=!1;return oe.directory().then(n=>!t&&u(n.agents[e.agent]??null),()=>{}),oe.tools(e.agent).then(e=>!t&&o(e),e=>!t&&c(e.message)),xe.list().then(r=>!t&&n(jt(nt(e,r.chats))),()=>!t&&n([])),de.prompts().then(n=>!t&&i(n.agents.filter(t=>e.runs.includes(t.name))),()=>{}),()=>{t=!0}},[e]);let d=Le(e.agent).name,f=[...new Set(r.map(e=>e.prompt))];return(0,X.jsxs)(`div`,{className:`flex w-full flex-col gap-6 pt-2`,children:[l&&l.status!==`ready`&&(0,X.jsx)(Ci,{card:l,name:d}),(0,X.jsxs)(`section`,{"aria-labelledby":`agent-tools`,className:`flex flex-col gap-2`,children:[(0,X.jsx)(`h2`,{id:`agent-tools`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Tools it can use`}),s?(0,X.jsx)(`p`,{className:`m-0 text-sm text-fail`,children:s}):a?(0,X.jsx)(Di,{view:a,limit:_i,more:B(`agents`,e.id,`tools`)}):(0,X.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Reading its tools…`})]}),a&&a.connections.length>0&&(0,X.jsxs)(`section`,{"aria-labelledby":`agent-connected`,className:`flex flex-col gap-2`,children:[(0,X.jsx)(`h2`,{id:`agent-connected`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Connected to`}),(0,X.jsx)(Ti,{list:a.connections,limit:4,more:B(`agents`,e.id,`tools`)})]}),e.prompt!==!1&&(0,X.jsxs)(`section`,{"aria-labelledby":`agent-prompt`,className:`flex flex-col gap-2`,children:[(0,X.jsx)(`h2`,{id:`agent-prompt`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Its instructions`}),(0,X.jsxs)(`a`,{href:B(`prompts`),className:`flex items-center gap-4 rounded-[12px] card border px-4 py-4 text-ink no-underline hover:bg-surface-muted hover:text-ink`,children:[(0,X.jsx)(L,{icon:b,size:18,className:`flex-none text-muted`}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,X.jsx)(`span`,{className:`text-[13px] font-medium`,children:f.length?f.map(e=>`${e}.md`).join(`, `):`The prompt it starts from`}),(0,X.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[`What `,W(d),` starts with, and your team's additions: change them in Prompts.`]})]}),(0,X.jsx)(O,{size:16,"aria-hidden":`true`,className:`flex-none text-muted`})]})]}),(0,X.jsxs)(`section`,{"aria-labelledby":`agent-conversations`,className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,X.jsx)(`h2`,{id:`agent-conversations`,className:`m-0 flex-1 text-[13px] font-semibold text-muted`,children:`Conversations`}),t&&t.length>_i&&(0,X.jsxs)(`a`,{href:B(`agents`,e.id,`conversations`),className:`text-[13px]`,children:[`All `,t.length,` conversations`]})]}),t===null?(0,X.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Reading the conversations…`}):t.length===0?(0,X.jsxs)(z,{className:`py-4`,children:[`No conversations with `,W(d),` yet. Ask it above to start one.`]}):(0,X.jsx)(Oi,{name:d,chats:t.slice(0,_i)})]})]})}var Si={setup:{to:B(`settings`,`setup`),label:`Settings, Set up`},models:{to:B(`settings`,`models`),label:`Settings, Models`},tests:{to:B(`settings`,`tests`),label:`Settings, Code`},databases:{to:B(`settings`,`databases`),label:`Settings, Databases`},integrations:{to:B(`settings`,`integrations`),label:`Settings, Integrations`},features:{to:B(`settings`,`features`),label:`What's ready`}};function Ci({card:e,name:t}){let n=Ht[e.status],r=e.needs??[];return(0,X.jsxs)(`section`,{"aria-labelledby":`agent-needs`,className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`h2`,{id:`agent-needs`,className:`m-0 text-[13px] font-semibold text-muted`,children:`What it needs`}),(0,X.jsx)(I,{tone:n.tone,children:n.label})]}),r.length===0?(0,X.jsx)(`p`,{className:`m-0 rounded-[12px] bg-surface-muted px-4 py-4 text-sm text-ink-2`,children:e.note}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:r.some(e=>e.blocks)?`${W(t,!0)} cannot work until the first ${r.filter(e=>e.blocks).length===1?`one is`:`ones are`} set up.`:`${W(t,!0)} works, without the parts below.`}),(0,X.jsx)(`ul`,{"aria-label":`What ${W(t)} needs`,className:`m-0 flex list-none flex-col rounded-[12px] card border p-0`,children:r.map((e,t)=>(0,X.jsxs)(`li`,{className:P(`flex items-center gap-4 px-4 py-2`,t>0&&`border-t border-line-soft`),children:[(0,X.jsx)(T,{size:16,"aria-label":e.blocks?`Needed`:`Optional`,className:P(`flex-none`,e.blocks?`text-fail`:`text-warn`)}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,X.jsx)(`span`,{className:`text-[13px] font-medium`,children:e.what}),(0,X.jsx)(`span`,{className:`text-[13px] text-muted [overflow-wrap:anywhere]`,children:e.why})]}),e.fix&&(0,X.jsxs)(`a`,{href:Si[e.fix].to,className:`flex flex-none items-center gap-1 text-[13px]`,children:[Si[e.fix].label,(0,X.jsx)(O,{size:14,"aria-hidden":`true`})]})]},`${e.what}:${t}`))})]})]})}var wi={repository:`branch`,database:`container`,environment:`web`,system:`plug`};function Ti({list:e,limit:t,more:n}){let r=t?e.slice(0,t):e;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`ul`,{className:`m-0 grid list-none grid-cols-1 gap-2 p-0 sm:grid-cols-2`,children:r.map((e,t)=>(0,X.jsxs)(`li`,{className:P(`flex items-center gap-4 rounded-[12px] card border px-4 py-2`,!e.on&&`bg-surface-muted`),children:[(0,X.jsx)(Ce,{name:wi[e.kind],px:22,className:P(!e.on&&`opacity-50 grayscale`)}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,X.jsx)(`span`,{className:`truncate text-[13px] font-medium`,"data-tip":e.name,children:e.name}),(0,X.jsx)(`span`,{className:`truncate text-[13px] text-muted`,children:e.on?e.detail:`Not connected: ${e.why||`not set up`}`})]})]},`${e.kind}:${e.name}:${t}`))}),n&&r.length<e.length&&(0,X.jsxs)(`a`,{href:n,className:`self-start text-[13px]`,children:[`Show all `,e.length,` connections`]})]})}function Ei({page:e}){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(``);(0,Y.useEffect)(()=>{let t=!1;return oe.tools(e.agent).then(e=>!t&&n(e),e=>!t&&i(e.message)),()=>{t=!0}},[e]);let a=Le(e.agent).name;return(0,X.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,X.jsx)(at,{}),(0,X.jsxs)(`main`,{className:ct,children:[(0,X.jsxs)(`a`,{href:B(`agents`,e.id),className:`mb-4 inline-flex items-center gap-2 text-sm`,children:[(0,X.jsx)(x,{size:16,"aria-hidden":`true`}),a]}),(0,X.jsxs)(`div`,{className:`mb-1 flex items-center gap-4`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`theme-side inline-flex size-10 border border-line-soft flex-none items-center justify-center rounded-[10px]`,children:(0,X.jsx)(Me,{agent:e.agent,px:24,decorative:!0})}),(0,X.jsxs)(`h1`,{className:`m-0 text-[25px] font-semibold tracking-[-0.01em]`,children:[`What `,W(a),` can use`]})]}),(0,X.jsxs)(`p`,{className:`mt-1 mb-6 text-sm leading-relaxed text-ink-2`,children:[t?`${t.title.replace(/\.$/,``)}.`:e.about,` Every tool it has, in the groups its session is given, and what it reaches from this project.`]}),r?(0,X.jsx)(`p`,{className:`m-0 text-sm text-fail`,children:r}):t?(0,X.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,X.jsxs)(`section`,{"aria-labelledby":`all-tools`,className:`flex flex-col gap-2`,children:[(0,X.jsx)(`h2`,{id:`all-tools`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Tools it can use`}),(0,X.jsx)(Di,{view:t,openAll:!0})]}),t.connections.length>0&&(0,X.jsxs)(`section`,{"aria-labelledby":`all-connected`,className:`flex flex-col gap-2`,children:[(0,X.jsx)(`h2`,{id:`all-connected`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Connected to`}),(0,X.jsx)(Ti,{list:t.connections})]})]}):(0,X.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Reading its tools…`})]})]})}function Di({view:e,limit:t,more:n,openAll:r}){let[i,a]=(0,Y.useState)(()=>r?e.groups.map(e=>e.id):[]),o=t?e.groups.slice(0,t):e.groups,s=e.groups.reduce((e,t)=>e+t.tools.length,0),l=e.groups.filter(e=>e.on).length;return(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`p`,{className:`m-0 text-[13px] text-muted`,children:[l,` of `,e.groups.length,` `,e.groups.length===1?`group`:`groups`,` usable here.`]}),(0,X.jsx)(`ul`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-0`,children:o.map((e,n)=>{let r=i.includes(e.id);return(0,X.jsxs)(`li`,{className:P(n>0&&`border-t border-line-soft`),children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":r,"aria-controls":`tools-${n}`,disabled:!e.tools.length,onClick:()=>a(r?i.filter(t=>t!==e.id):[...i,e.id]),className:`flex w-full cursor-pointer items-center gap-4 border-0 bg-transparent px-4 py-2 text-left text-ink disabled:cursor-default`,children:[e.on?(0,X.jsx)(u,{size:16,"aria-label":`Usable`,className:`flex-none text-pass`}):(0,X.jsx)(c,{size:16,"aria-label":`Not usable here`,className:`flex-none text-muted`}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,X.jsxs)(`span`,{className:`text-[13px] font-medium`,children:[e.label,e.tools.length>0&&(0,X.jsxs)(`span`,{className:`font-normal text-muted`,children:[` · `,e.tools.length]})]}),(0,X.jsx)(`span`,{className:P(`text-[13px] text-muted`,t&&`truncate`),children:e.on?[e.about,e.limited].filter(Boolean).join(` · `):`Not here: ${e.why||`not set up`}`})]}),e.tools.length>0&&(0,X.jsx)(m,{size:16,"aria-hidden":`true`,className:P(`flex-none text-muted transition-transform duration-200`,r&&`rotate-90`)})]}),(0,X.jsx)(Ee,{open:r,id:`tools-${n}`,children:(0,X.jsx)(`ul`,{className:`m-0 flex list-none flex-wrap gap-2 px-4 pb-4 pl-10`,children:e.tools.map(e=>(0,X.jsxs)(`li`,{"data-tip":e.what||void 0,className:`rounded-[6px] bg-surface-strong px-2 py-1 font-mono text-[13px] text-ink-2`,children:[e.name,e.what&&(0,X.jsx)(`span`,{className:`ml-2 font-sans text-muted`,children:e.what})]},e.name))})})]},e.id)})}),n&&(o.length<e.groups.length||s>0)&&(0,X.jsx)(`a`,{href:n,className:`self-start text-[13px]`,children:o.length<e.groups.length?`Show all ${e.groups.length} groups and ${s} tools`:`Show every tool (${s})`})]})}function Oi({name:e,chats:t}){return(0,X.jsx)(`div`,{className:`@container rounded-[12px] card border`,children:(0,X.jsx)(`ul`,{"aria-label":`Conversations with ${W(e)}`,className:`m-0 flex list-none flex-col p-2`,children:t.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsx)(Mt,{c:e})},e.id))})})}function ki({page:e}){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(``);(0,Y.useEffect)(()=>{let t=!1;return xe.list().then(r=>!t&&n(jt(nt(e,r.chats))),e=>!t&&i(e.message)),()=>{t=!0}},[e]);let a=Le(e.agent).name;return(0,X.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,X.jsx)(at,{}),(0,X.jsxs)(`main`,{className:ct,children:[(0,X.jsxs)(`a`,{href:B(`agents`,e.id),className:`mb-4 inline-flex items-center gap-2 text-sm`,children:[(0,X.jsx)(x,{size:16,"aria-hidden":`true`}),a]}),(0,X.jsxs)(`div`,{className:`mb-1 flex items-center gap-4`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`theme-side inline-flex size-10 border border-line-soft flex-none items-center justify-center rounded-[10px]`,children:(0,X.jsx)(Me,{agent:e.agent,px:24,decorative:!0})}),(0,X.jsxs)(`h1`,{className:`m-0 text-[25px] font-semibold tracking-[-0.01em]`,children:[`Conversations with `,W(a)]})]}),(0,X.jsxs)(`p`,{className:`mt-1 mb-6 text-sm leading-relaxed text-ink-2`,children:[`Every chat started from `,W(a),`'s page, newest first. Open one to read it or carry it on.`]}),r?(0,X.jsx)(`p`,{className:`m-0 text-sm text-fail`,children:r}):t?t.length===0?(0,X.jsxs)(z,{className:`py-4`,children:[`No conversations with `,W(a),` yet. `,(0,X.jsx)(`a`,{href:B(`agents`,e.id),children:`Ask it`}),` to start one.`]}):(0,X.jsx)(Oi,{name:a,chats:t}):(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`})]})]})}export{yi as Agent,xi as AgentDetails};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Ir as e,Nr as t,w as n,zr as r}from"./line-icons-C_amZ5-o.js";import{$t as i,V as a,h as o,p as s,st as c}from"./filters-CVzIOjPG.js";import{m as l,p as u}from"./frame-VTMu7MoC.js";import{r as d}from"./markdown-CWisJbSJ.js";var f=r(e(),1),p=i(),m=e=>new Promise(t=>setTimeout(t,e));function h({id:e,onEnd:r,label:i=`The agent at work`,done:h=`Done.`,failed:g=`It could not finish.`}){let[_,v]=(0,f.useState)([]),[y,b]=(0,f.useState)(`starting`);(0,f.useEffect)(()=>{let t=!1,n=0,r=[];return(async()=>{for(;!t;)try{let i=await c.events(e,n,!0);if(t||(i.events.length&&(r.push(...i.events),n=i.events.at(-1).n,v([...r])),b(i.state),i.state===`closed`||i.state===`failed`))return}catch{await m(2e3)}})(),()=>{t=!0}},[e]);let x=l(_),S=x.turns.at(-1),C=!!S?.outcome||y===`failed`||y===`closed`,w=S&&!C?u(S):null,T=S?.outcome===`done`,E=C&&!T&&(S?.error||x.fatal||x.ended?.message)||``;return(0,f.useEffect)(()=>{C&&r?.()},[C]),(0,p.jsxs)(`section`,{"aria-label":i,className:`flex flex-col gap-2 border-t border-line-soft pt-4 text-sm`,children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[w||!C?(0,p.jsx)(o,{state:w?.orb??`thinking`,px:16}):T?(0,p.jsx)(n,{size:16,"aria-hidden":`true`,className:`text-pass`}):(0,p.jsx)(t,{size:16,"aria-hidden":`true`,className:`text-fail`}),(0,p.jsx)(`span`,{className:a(`min-w-0 flex-1 font-medium [overflow-wrap:anywhere]`,C&&!T&&`text-fail`),children:w?w.text:C?T?h:S?.outcome===`stopped`?`It was stopped.`:g:`Starting…`}),(0,p.jsx)(`a`,{href:s(`chats`,e),className:`text-[13px]`,children:`Open the chat`})]}),E&&(0,p.jsx)(`p`,{className:`m-0 text-[13px] text-fail [overflow-wrap:anywhere]`,children:E.split(`
|
|
2
|
+
`).slice(0,3).join(` `)}),S&&S.steps.length>0&&(0,p.jsx)(`ol`,{className:`m-0 flex list-none flex-col gap-1 p-0 text-[13px] text-muted`,children:S.steps.slice(-6).map(e=>(0,p.jsxs)(`li`,{className:a(`[overflow-wrap:anywhere]`,e.status===`fail`&&`text-fail`),children:[e.status===`running`?`… `:e.status===`fail`?`✗ `:`✓ `,e.label,e.arg?`: ${e.arg}`:``]},e.key))}),S&&S.changes.length>0&&(0,p.jsxs)(`p`,{className:`m-0 text-[13px] [overflow-wrap:anywhere]`,children:[`Changed: `,S.changes.map(e=>`${e.path} (+${e.added} −${e.removed})`).join(`, `)]}),S&&S.asks.some(e=>e.answer===void 0)&&(0,p.jsxs)(`p`,{className:`m-0 text-[13px] text-warn`,children:[`It is asking something: `,(0,p.jsx)(`a`,{href:s(`chats`,e),children:`answer it in the chat`}),`.`]}),S?.reply&&C&&(0,p.jsx)(d,{text:S.reply,className:`text-[13px]`})]})}export{h as t};
|