@capagents/forgeqe 3.2.1 → 3.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/HOW_TO_USE.md +9 -8
  2. package/dist/docs-site/docs/area-api/index.html +1 -1
  3. package/dist/docs-site/docs/get-started/index.html +8 -7
  4. package/dist/docs-site/docs/search.js +1 -1
  5. package/dist/forgeqe.js +1842 -1838
  6. package/dist/web/assets/{3d-force-graph-ByL874l5.js → 3d-force-graph-Bt0kE6fK.js} +1 -1
  7. package/dist/web/assets/{Agent-Drs4mcil.js → Agent-CsZ7vFCx.js} +6 -6
  8. package/dist/web/assets/{AgentWork-DLcCZTgu.js → AgentWork-Bjy58QJs.js} +1 -1
  9. package/dist/web/assets/ApiTests-_8-mU4o4.js +10 -0
  10. package/dist/web/assets/{Browse-D9eaDrZT.js → Browse-DXN091Tl.js} +1 -1
  11. package/dist/web/assets/Chat--mi_QDYP.js +3 -0
  12. package/dist/web/assets/{CommandPalette-Bcf1Muan.js → CommandPalette-DpYwTkxH.js} +1 -1
  13. package/dist/web/assets/{Compare-V5xKnwGO.js → Compare-CBatuMuQ.js} +1 -1
  14. package/dist/web/assets/Cost-Biq5Isox.js +1 -0
  15. package/dist/web/assets/{Data-DzrP-MdL.js → Data-0_y_XKGw.js} +3 -3
  16. package/dist/web/assets/Desktop-DPKPECCb.js +1 -0
  17. package/dist/web/assets/DesktopReview-COQqvQ7S.js +2 -0
  18. package/dist/web/assets/{DeviceScreen-CoArZGyY.js → DeviceScreen-D8u68b5B.js} +1 -1
  19. package/dist/web/assets/{Evidence-D6VvlFNK.js → Evidence-_PkdHSff.js} +1 -1
  20. package/dist/web/assets/{Explore-YkonRPmA.js → Explore-Bum9glmY.js} +2 -2
  21. package/dist/web/assets/{Features-BKB4iSRj.js → Features-OENuS23e.js} +1 -1
  22. package/dist/web/assets/Flags-BqepPJcc.js +2 -0
  23. package/dist/web/assets/{Flaky-BRcLjYrP.js → Flaky-CCLSqsfC.js} +1 -1
  24. package/dist/web/assets/Impact-9PxyQO57.js +3 -0
  25. package/dist/web/assets/Jobs-BGuNihAj.js +5 -0
  26. package/dist/web/assets/{KindPage-Ige-qO2t.js → KindPage-T4AUKlMQ.js} +3 -3
  27. package/dist/web/assets/{LiveDevice-DI7Bq6ag.js → LiveDevice-CP5RZ30S.js} +1 -1
  28. package/dist/web/assets/{Migration-CEwXGs4c.js → Migration-CrkuTtB7.js} +5 -5
  29. package/dist/web/assets/{Mobile-BqyFTBeG.js → Mobile-BlHPt6gb.js} +1 -1
  30. package/dist/web/assets/{Observability-B2Y1pHpD.js → Observability-nbCRQf-p.js} +1 -1
  31. package/dist/web/assets/PageAgent-B17N29Vg.js +1 -0
  32. package/dist/web/assets/{Product-CXIbmmMF.js → Product-y5qWviku.js} +4 -4
  33. package/dist/web/assets/Production-3yYw4c-9.js +1 -0
  34. package/dist/web/assets/Quality-DZjyRpSa.js +1 -0
  35. package/dist/web/assets/{Readiness-B53Drc7i.js → Readiness-DR-KExeM.js} +1 -1
  36. package/dist/web/assets/Record-DNByPZFL.js +1 -0
  37. package/dist/web/assets/{Regression-BpPXCQIv.js → Regression-Dewx-pZm.js} +3 -3
  38. package/dist/web/assets/{RelationGraph-UXFyQOKO.js → RelationGraph-BlR8ewL9.js} +1 -1
  39. package/dist/web/assets/{Reports-CWCa9uof.js → Reports-Ca7Kewsb.js} +2 -2
  40. package/dist/web/assets/Response-CQMw9bTX.js +9 -0
  41. package/dist/web/assets/{Responsive-Bl6i7kB3.js → Responsive-CEuJK8lj.js} +2 -2
  42. package/dist/web/assets/{RunDiff-CWf9Bkmu.js → RunDiff-CYVCUyER.js} +1 -1
  43. package/dist/web/assets/Runs-DPqjZhbv.js +2 -0
  44. package/dist/web/assets/{Settings-tgCcBEwu.js → Settings-DmFBERmV.js} +15 -15
  45. package/dist/web/assets/{Steps-xASPoq1N.js → Steps-AUxLKS75.js} +3 -3
  46. package/dist/web/assets/{TestCases-Cm4KwWIP.js → TestCases-ZZx3n1uf.js} +1 -1
  47. package/dist/web/assets/TestData-aY6U1NQz.js +2 -0
  48. package/dist/web/assets/TestDebt-C6y5j1or.js +1 -0
  49. package/dist/web/assets/TestManagement-8O_G3MDS.js +4 -0
  50. package/dist/web/assets/{WhatsNew-Dp-zP-jw.js → WhatsNew-CABuR9OZ.js} +1 -1
  51. package/dist/web/assets/{dataParts-BPff7ClX.js → dataParts-DqE6xkYJ.js} +2 -2
  52. package/dist/web/assets/{desktopAppPath-BVJxel_D.js → desktopAppPath-CqwJou-7.js} +1 -1
  53. package/dist/web/assets/{diff-BXu8cULX.js → diff-CdVbBfvE.js} +1 -1
  54. package/dist/web/assets/{highlight-DCCKhwHj.js → highlight-BbSbwn5i.js} +1 -1
  55. package/dist/web/assets/{index-BsAaOk_G.js → index-CeVry7Jo.js} +12 -12
  56. package/dist/web/assets/index-FhirFP-O.css +2 -0
  57. package/dist/web/assets/input-CK9KiscI.js +1 -0
  58. package/dist/web/assets/{pageBack-BNLSF2VR.js → pageBack-CGpBg0rz.js} +1 -1
  59. package/dist/web/assets/{palette-BS9ixqiJ.js → palette-sQXAx0hh.js} +1 -1
  60. package/dist/web/assets/{paletteCommands-C3knXWbA.js → paletteCommands-BUbZcBfs.js} +1 -1
  61. package/dist/web/assets/{parts-69Ei7EPi.js → parts-CY9Brfn9.js} +1 -1
  62. package/dist/web/assets/{productParts-CrAb3-j0.js → productParts-DLa8Xzv7.js} +1 -1
  63. package/dist/web/assets/{qualityParts-BQTnBwPs.js → qualityParts-Dfn1l_k_.js} +1 -1
  64. package/dist/web/assets/{recordTest-DVJCNI0y.js → recordTest-CPRlUK1r.js} +1 -1
  65. package/dist/web/assets/{stepper-t0O_8eQo.js → stepper-D9tX3bS5.js} +1 -1
  66. package/dist/web/index.html +5 -5
  67. package/docs/user-guide.html +29 -16
  68. package/package.json +1 -1
  69. package/prompts/brain.md +1 -1
  70. package/py/forgeqe_engine/copilot_gateway.py +8 -9
  71. package/py/forgeqe_engine/recordsession.py +2 -2
  72. package/py/forgeqe_engine/webrecord.py +9 -3
  73. package/py/forgeqe_engine/webrecord_page.py +87 -10
  74. package/dist/web/assets/ApiTests-BcrTspwJ.js +0 -10
  75. package/dist/web/assets/Chat-CMNf9-ys.js +0 -3
  76. package/dist/web/assets/Cost-DC3DYthD.js +0 -1
  77. package/dist/web/assets/Desktop-DjTq9eAr.js +0 -1
  78. package/dist/web/assets/DesktopReview-Buecn3n5.js +0 -2
  79. package/dist/web/assets/Flags-4GGW38Xu.js +0 -2
  80. package/dist/web/assets/Impact-CvuahLDQ.js +0 -3
  81. package/dist/web/assets/Jobs-DBCw8Z8I.js +0 -5
  82. package/dist/web/assets/PageAgent-BRhWi7LL.js +0 -1
  83. package/dist/web/assets/Production-BOy7ew7l.js +0 -1
  84. package/dist/web/assets/Quality-Dtcq2AWE.js +0 -1
  85. package/dist/web/assets/Record-BuCIDb1d.js +0 -1
  86. package/dist/web/assets/Response-C6EmnnQz.js +0 -9
  87. package/dist/web/assets/Runs-C0tfrB_j.js +0 -2
  88. package/dist/web/assets/TestData-DMV5S00V.js +0 -2
  89. package/dist/web/assets/TestDebt-D54mt0ZT.js +0 -1
  90. package/dist/web/assets/TestManagement-DBFlK8Xe.js +0 -4
  91. package/dist/web/assets/index-CgpH1pj9.css +0 -2
  92. package/dist/web/assets/input-BmJ7dt1C.js +0 -1
@@ -1,8 +1,8 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{$ as t,A as n,B as r,Bn as i,Cr as a,Dr as o,Er as s,F as c,Fn as l,Fr as u,Gn as d,Hn as f,Hr as p,I as m,J as h,Kr as g,L as _,Ln as v,M as y,Mn as b,Mr as x,Mt as S,O as C,Or as ee,Rn as w,Rr as T,S as E,U as D,Ut as te,V as O,Vr as ne,W as k,Xn as A,Xt as re,Zn as ie,_t as ae,dr as oe,er as se,fr as ce,g as le,in as ue,jr as j,kr as de,l as fe,ln as pe,lr as me,mt as he,n as ge,nt as _e,or as ve,ot as ye,pt as be,r as M,rr as xe,sn as Se,sr as Ce,tr as we,u as N,ut as Te,v as Ee,vn as De,w as Oe,y as ke,yn as Ae,yt as je}from"./route-D8G-pTdk.js";import{C as Me,S as Ne,T as Pe,b as Fe,c as Ie,l as Le,o as Re,s as ze,v as Be,w as Ve,y as P}from"./agents-DPabR9dS.js";import{t as He}from"./jsx-runtime-LKYXHABd.js";import{A as F,Ct as I,F as Ue,I as We,J as L,L as Ge,R as Ke,Y as qe,Z as Je,et as R,j as z,l as Ye,n as B,r as Xe,t as V}from"./input-BmJ7dt1C.js";import{C as Ze,D as Qe,E as H,c as U,i as $e,l as et,o as tt,r as nt,s as rt,t as it,v as at,w as W}from"./pageBack-BNLSF2VR.js";import{B as ot,H as st,N as ct,V as lt,a as ut,u as dt,z as ft}from"./palette-BS9ixqiJ.js";import{$t as pt,At as mt,Bn as ht,Bt as gt,Dt as _t,F as vt,Hn as yt,In as bt,It as xt,Ln as St,Mn as Ct,Nn as wt,Nt as Tt,O as Et,Ot as Dt,Pn as Ot,Qt as G,R as kt,Rn as At,Rt as jt,Un as Mt,Vt as Nt,Yt as Pt,a as Ft,c as It,cn as Lt,d as Rt,dt as zt,f as Bt,i as Vt,in as Ht,jn as Ut,jt as Wt,k as Gt,kt as Kt,l as qt,ln as Jt,o as Yt,on as Xt,p as Zt,r as Qt,rn as $t,s as en,sn as tn,u as nn,ut as rn,vt as K,yt as q,z as an}from"./index-BsAaOk_G.js";import{i as on,r as sn,t as cn}from"./RelationGraph-UXFyQOKO.js";import{t as ln}from"./diff-BXu8cULX.js";import{l as un}from"./dataParts-BPff7ClX.js";var J=e(g(),1),Y=He();function dn({value:e,onChange:t,id:r}){let i=Ve(e),a=typeof e==`string`?e.trim().replace(/\s+/g,` `):``,o=!i&&a?a.slice(0,60):``,s=Ve(e)?e:o?null:``,{theme:c}=dt(),l=ct(c)===`icons`?`No icon: the Helper's face`:`No icon: its mascot`,[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(10),[m,h]=(0,J.useState)(()=>!!(ft(`ph:robot`)||ft(`lucide:bot`)));(0,J.useEffect)(()=>{ot().then(()=>h(!0))},[]),(0,J.useEffect)(()=>{p(10)},[u]);let g=!!u.trim(),{hits:_,total:v}=(0,J.useMemo)(()=>g?lt(u,f,0):lt(``,f,Fe.length),[u,f,g]),y=st.length,b=g?v>f:f<y,x=g?Math.max(0,v-f):Math.max(0,y-f);return(0,Y.jsxs)(`div`,{id:r,className:`flex flex-col gap-4`,children:[(0,Y.jsxs)(`label`,{className:`relative block`,children:[(0,Y.jsx)(ie,{"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted`}),(0,Y.jsx)(V,{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,Y.jsxs)(`p`,{className:`text-[13px] text-warn`,children:[`This agent names an icon ForgeQE does not have: `,(0,Y.jsx)(`span`,{className:`font-mono`,children:o}),`. Pick one below, or No icon.`]}),!g&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:`mb-2 text-[13px] text-muted`,children:`No icon`}),(0,Y.jsx)(`div`,{role:`listbox`,"aria-label":`No icon`,className:`flex flex-wrap gap-2`,children:(0,Y.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":s===``,"aria-label":`No icon`,"data-tip":l,className:fn(s===``),onClick:()=>t(``),children:(0,Y.jsx)(ut,{agent:`custom`,px:28,decorative:!0})})})]}),!g&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:`mb-2 text-[13px] text-muted`,children:`ForgeQE faces`}),(0,Y.jsx)(`div`,{role:`listbox`,"aria-label":`ForgeQE faces`,className:`flex flex-wrap gap-2`,children:Fe.map(e=>(0,Y.jsx)(pn,{icon:e,label:Ne(e),selected:e===s,ready:!0,onPick:t},e))})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:`mb-2 text-[13px] text-muted`,children:g?`Top matches (${v})`:`Library icons (Phosphor and Lucide)`}),(0,Y.jsxs)(`div`,{role:`listbox`,"aria-label":g?`Icon search results`:`Library icons`,className:`flex flex-wrap gap-2`,children:[_.map(e=>(0,Y.jsx)(pn,{icon:e.id,label:e.label,selected:e.id===s,ready:m||e.kind===`face`,onPick:t},e.id)),_.length===0&&(0,Y.jsx)(`p`,{className:`text-[13px] text-muted`,children:`No icons match that search.`})]}),b&&(0,Y.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,x)} of ${x} more`,onClick:()=>p(e=>e+10),children:[(0,Y.jsx)(n,{size:14,"aria-hidden":`true`}),`More (`,x,`)`]})]}),s&&Pe(s)&&(0,Y.jsxs)(`p`,{className:`text-[13px] text-muted`,children:[`Selected `,(0,Y.jsx)(`span`,{className:`font-mono text-fg`,children:s})]})]})}var fn=e=>F(`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 pn({icon:e,label:t,selected:n,ready:r,onPick:i}){return(0,Y.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":n,"aria-label":t,"data-tip":t,disabled:!r&&!!Pe(e),className:fn(n),onClick:()=>i(e),children:Me(e)?(0,Y.jsx)(Ye,{name:e,px:28}):(0,Y.jsx)(ut,{agent:`custom`,icon:e,px:28,decorative:!0})})}var mn=[{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 hn(){let[e,t]=(0,J.useState)(``),[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(``),[o,s]=(0,J.useState)([]),[c,l]=(0,J.useState)([]),u=gt(n);(0,J.useEffect)(()=>{qe.list().then(e=>s(e.sessions.filter(e=>!e.saved)),()=>{}),R.templates().then(e=>l(e.templates),()=>{})},[]);let d=async()=>{if(e.trim()){r(!0),a(``);try{let t=await qe.start(e.trim());location.hash=M(`agents`,`custom`,`build`,t.sid)}catch(e){a(e.message),r(!1)}}};return(0,Y.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,Y.jsxs)(`header`,{className:`flex items-center gap-1 px-6 py-4`,children:[(0,Y.jsx)(kt,{}),(0,Y.jsx)(it,{href:M(`agents`,`category`,`custom`),label:`Custom agents`,className:`self-center`})]}),(0,Y.jsx)(`main`,{className:`flex flex-auto flex-col items-center justify-center px-6 pt-6 pb-30`,children:(0,Y.jsxs)(`div`,{className:`flex w-full max-w-[780px] flex-col items-center gap-10`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-4 text-center`,children:[(0,Y.jsx)(Ze,{state:n?`waiting`:u,px:112,label:n?`Starting the builder`:`ForgeQE is ready to build an agent`,className:`mb-1`}),(0,Y.jsx)(`h1`,{className:`m-0 text-[31px] leading-tight font-semibold tracking-[-0.015em] text-ink`,children:`What should your agent do?`}),(0,Y.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,Y.jsx)(At,{id:`build-goal`,label:`What your agent should do`,value:e,onChange:e=>{t(e),a(``)},onSend:()=>void d(),busy:n,disabled:n,placeholder:`An agent that checks the checkout on QA and tells me what broke…`}),i&&(0,Y.jsx)(`p`,{role:`alert`,className:`m-0 -mt-6 text-sm text-fail`,children:i}),(0,Y.jsx)(G,{id:`build-starters`,icon:ue,title:`Or start from one of these, and change it to fit`,className:`w-full`,children:(0,Y.jsx)(`ul`,{className:`m-0 grid list-none grid-cols-1 gap-2 p-0 sm:grid-cols-2`,children:mn.map(n=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":e===n.text,onClick:()=>{t(n.text),a(``),document.getElementById(`build-goal`)?.focus()},className:F(`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,Y.jsx)(`span`,{className:`text-[13px] font-medium text-ink`,children:n.label}),(0,Y.jsx)(`span`,{className:`text-[13px] text-muted`,children:n.about})]})},n.label))})}),o.length>0&&(0,Y.jsx)(G,{id:`build-resume`,icon:te,title:`Pick up where you left off`,className:`w-full`,children:(0,Y.jsx)(`ul`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-2`,children:o.slice(0,5).map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`a`,{href:M(`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,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:e.goal}),(0,Y.jsxs)(`span`,{className:`flex-none text-[13px] text-muted`,children:[gn[e.step].label,` · `,Pt(e.updatedAt)]})]})},e.sid))})}),c.length>0&&(0,Y.jsx)(G,{id:`build-templates`,icon:le,title:`Or start from a template, and review it before you save`,className:`w-full`,children:(0,Y.jsx)(`ul`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-2`,children:c.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`a`,{href:M(`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,Y.jsx)(`span`,{className:`flex-none text-[13px]`,children:e.title}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px] text-muted`,children:e.why||e.about})]})},e.id))})}),(0,Y.jsxs)(`a`,{href:M(`agents`,`custom`,`new`,`form`),className:`inline-flex items-center gap-2 text-[13px]`,children:[(0,Y.jsx)(we,{size:14,"aria-hidden":`true`}),`Or set every option yourself`]})]})})]})}var gn={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 _n({sid:e}){let[t,n]=(0,J.useState)(null),[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(!1);if((0,J.useEffect)(()=>{qe.view(e).then(e=>{n(e),o(Math.min(e.reached,e.steps.length-1))},e=>i(e.message))},[e]),(0,J.useEffect)(()=>{if(!t?.working)return;let r=setTimeout(()=>{qe.view(e).then(n,()=>{})},1500);return()=>clearTimeout(r)},[t,e]),r&&!t)return(0,Y.jsx)(vn,{children:(0,Y.jsxs)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-4 py-2 text-sm text-fail`,children:[r,` `,(0,Y.jsx)(`a`,{href:M(`agents`,`custom`,`new`),children:`Start again`})]})});if(!t||a===null)return(0,Y.jsx)(vn,{children:(0,Y.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`})});let l=t.steps[a].id,u=gn[l],d=s||t.working===l,f=async(t,r=!1)=>{if(l!==`try`){c(!0),i(``);try{let i=await qe.answer(e,l,t);if(r&&i.saved){location.hash=M(`agents`,`custom`,i.saved,`edit`);return}n(i),o(Math.min(a+1,i.steps.length-1)),window.scrollTo({top:0})}catch(e){i(e.message),window.scrollTo({top:0})}finally{c(!1)}}};return(0,Y.jsxs)(vn,{children:[(0,Y.jsx)(it,{href:M(`agents`,`category`,`custom`),label:`Custom agents`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-[13px] text-muted`,children:`New agent`}),(0,Y.jsxs)(`p`,{className:`m-0 text-[16px] text-ink-2 [overflow-wrap:anywhere]`,children:[`“`,t.goal,`”`]})]}),(0,Y.jsx)(yn,{v:t,at:a,onGo:e=>!s&&o(e)}),(0,Y.jsxs)(`section`,{"aria-labelledby":`build-step`,className:`flex flex-col gap-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,Y.jsx)(Ze,{state:d?`working`:`idle`,px:36,label:d?u.working:`ForgeQE`,className:`flex-none`}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Y.jsx)(`h1`,{id:`build-step`,className:`m-0 text-[20px] font-semibold tracking-[-0.01em]`,children:u.title}),(0,Y.jsx)(`p`,{className:`m-0 text-[16px] leading-relaxed text-ink-2`,children:d?t.working===l?gn[l].thinking:u.working:t.says[l]}),!d&&t.source?.[l]&&(0,Y.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,Y.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,Y.jsx)(Sn,{v:t,busy:s,onNext:f,next:u.next},`u-${t.updatedAt}`),t.working!==l&&l===`plan`&&(0,Y.jsx)(wn,{v:t,busy:s,onNext:f,onBack:()=>o(a-1),next:u.next},`p-${t.updatedAt}`),l===`boundaries`&&(0,Y.jsx)(Tn,{v:t,busy:s,onNext:f,onBack:()=>o(a-1),next:u.next},`b-${t.updatedAt}`),l===`knowledge`&&(0,Y.jsx)(En,{v:t,busy:s,onNext:f,onBack:()=>o(a-1),next:u.next},`k-${t.updatedAt}`),t.working!==l&&l===`review`&&(0,Y.jsx)(Dn,{v:t,busy:s,onNext:f,onBack:()=>o(a-1),next:u.next},`r-${t.updatedAt}`),l===`try`&&(0,Y.jsx)(On,{v:t})]})]})}function vn({children:e}){return(0,Y.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,Y.jsx)(an,{}),(0,Y.jsx)(`main`,{className:F(vt,`max-w-[920px] flex-auto gap-6`),children:e})]})}function yn({v:e,at:t,onGo:n}){return(0,Y.jsx)(`nav`,{"aria-label":`Steps`,children:(0,Y.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,Y.jsxs)(`li`,{className:`flex items-center gap-1`,children:[(0,Y.jsxs)(`button`,{type:`button`,disabled:!a,"aria-current":o?`step`:void 0,onClick:()=>n(i),className:F(`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,Y.jsx)(`span`,{"aria-hidden":`true`,className:F(`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,Y.jsx)(C,{size:12,strokeWidth:3}):i+1}),gn[r.id].label]}),i<e.steps.length-1&&(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`h-px w-4 bg-line`})]},r.id)})})})}function bn({busy:e,onBack:t,next:n,onNext:r,disabled:i,aside:a}){let o=n.startsWith(`Save`);return(0,Y.jsxs)(`div`,{className:`sticky bottom-0 flex flex-wrap items-center gap-4 border-t border-line-soft bg-bg py-4`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px]`,children:a}),t&&(0,Y.jsxs)(H,{variant:`ghost`,disabled:e,onClick:t,children:[(0,Y.jsx)(fe,{"aria-hidden":`true`}),`Back`]}),(0,Y.jsxs)(H,{variant:`primary`,disabled:e||i,onClick:r,"data-tip":n,children:[o?(0,Y.jsx)(C,{"aria-hidden":`true`}):(0,Y.jsx)(N,{"aria-hidden":`true`}),o?`Save`:`Next`]})]})}function xn({on:e,label:t,why:n,recommended:r,onToggle:i}){return(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":e,onClick:i,className:F(`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,Y.jsx)(`span`,{"aria-hidden":`true`,className:F(`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,Y.jsx)(C,{size:12,strokeWidth:3})}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-[13px] font-medium text-ink`,children:[t,r&&(0,Y.jsx)(U,{tone:`running`,icon:!1,children:`Recommended`})]}),n&&(0,Y.jsx)(`span`,{className:`text-[13px] text-muted`,children:n})]})]})}function Sn({v:e,busy:t,onNext:n,next:r}){let[i,a]=(0,J.useState)(()=>Object.fromEntries(e.questions.map(e=>[e.id,e.answer]))),[o,s]=(0,J.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,Y.jsxs)(Y.Fragment,{children:[e.questions.map(e=>{let t=e.assumed&&!o.includes(e.id);return(0,Y.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 rounded-[14px] card border p-4`,children:[(0,Y.jsx)(`legend`,{className:`sr-only`,children:e.text}),(0,Y.jsx)(`span`,{className:`text-[16px] font-semibold`,children:e.text}),t?(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm text-ink-2`,children:[(0,Y.jsx)(W,{icon:m,size:16,className:`text-pass`}),e.assumed,!(i[e.id]||[]).every(t=>e.assumed?.includes(t))&&(0,Y.jsxs)(`span`,{className:`text-muted`,children:[`(`,i[e.id]?.join(`, `),`)`]}),(0,Y.jsx)(H,{size:`sm`,variant:`ghost`,onClick:()=>s([...o,e.id]),"aria-label":`Change the answer`,"data-tip":`Change the answer`,children:(0,Y.jsx)(l,{"aria-hidden":`true`})})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`text-[13px] text-muted`,children:e.why}),(0,Y.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:e.options.map(t=>(0,Y.jsx)(xn,{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,Y.jsx)(bn,{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,Y.jsx)(`span`,{className:`text-fail`,children:`Add a test environment in Settings first: an agent needs one to work in.`}):void 0})]})}var Cn={ready:{icon:m,label:`Ready`,tone:`text-pass`},partial:{icon:_,label:`Partly set up`,tone:`text-warn`},needs_setup:{icon:O,label:`Not set up here yet`,tone:`text-muted`}};function wn({v:e,busy:t,onNext:n,onBack:r,next:o}){let[s,c]=(0,J.useState)(()=>e.plan.filter(e=>e.on).map(e=>e.capability)),[l,u]=(0,J.useState)(!1),d=s.map(t=>e.plan.find(e=>e.capability===t)).filter(Boolean),f=e.plan.filter(e=>!s.includes(e.capability));return(0,Y.jsxs)(Y.Fragment,{children:[e.planSteps&&e.planSteps.length>0&&(0,Y.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,Y.jsxs)(`li`,{className:F(`flex items-start gap-4 px-4 py-4`,n>0&&`border-t border-line-soft`),children:[(0,Y.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,Y.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-[16px] font-semibold`,children:t.title}),(0,Y.jsx)(`span`,{className:`text-[13px] text-ink-2`,children:t.why}),t.without&&(0,Y.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[`Without it: `,t.without]}),(0,Y.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,Y.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,Y.jsx)(pt,{icon:ne,title:`What it uses`,level:3,className:`mt-2`}),(0,Y.jsx)(`ol`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:d.map((e,t)=>{let n=Cn[e.state];return(0,Y.jsxs)(`li`,{className:`flex items-start gap-4 rounded-[14px] card border p-4`,children:[(0,Y.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,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-[16px] font-semibold`,children:e.title}),e.why&&(0,Y.jsx)(`span`,{className:`text-[13px] text-ink-2`,children:e.why}),(0,Y.jsx)(`span`,{className:`line-clamp-2 text-[13px] text-muted`,children:e.summary}),(0,Y.jsxs)(`span`,{className:F(`flex items-center gap-2 text-[13px]`,n.tone),children:[(0,Y.jsx)(W,{icon:n.icon,size:14}),n.label,e.state!==`ready`&&e.gaps.length?`: ${e.gaps.join(`; `)}`:``]})]}),(0,Y.jsx)(H,{variant:`icon`,size:`icon`,"aria-label":`Leave out ${e.title}`,"data-tip":`Leave out ${e.title}`,onClick:()=>c(s.filter(t=>t!==e.capability)),children:(0,Y.jsx)(a,{"aria-hidden":`true`})})]},e.capability)})}),l?(0,Y.jsx)(G,{id:`build-add`,icon:i,title:`What else should it do?`,level:3,className:`rounded-[14px] card border p-4`,children:(0,Y.jsx)(`ul`,{className:`m-0 grid list-none grid-cols-1 gap-2 p-0 sm:grid-cols-2`,children:f.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>c([...s,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,Y.jsx)(i,{size:16,"aria-hidden":`true`,className:`mt-1 flex-none text-muted`}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Y.jsx)(`span`,{className:`text-[13px] font-medium`,children:e.title}),(0,Y.jsx)(`span`,{className:`line-clamp-2 text-[13px] text-muted`,children:e.summary})]})]})},e.capability))})}):(0,Y.jsxs)(H,{size:`sm`,className:`self-start`,onClick:()=>u(!0),"data-tip":`Add something it should also do`,children:[(0,Y.jsx)(i,{"aria-hidden":`true`}),`Add`]}),(0,Y.jsx)(bn,{busy:t,onBack:r,next:o,onNext:()=>n({capabilities:s}),disabled:!s.length})]})}function X({text:e,help:t,on:n,onChange:r,locked:i}){return(0,Y.jsxs)(`div`,{className:`flex items-start gap-4 border-t border-line-soft py-4 first:border-t-0`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-[13px] text-ink`,children:e}),(t||i)&&(0,Y.jsx)(`span`,{className:`text-[13px] text-muted`,children:i||t})]}),i?(0,Y.jsx)(xe,{size:18,"aria-label":`Always`,className:`mt-1 flex-none text-muted`}):(0,Y.jsx)(Jt,{checked:n,onChange:e=>r?.(e),label:e})]})}function Tn({v:e,busy:t,onNext:n,onBack:r,next:i}){let a=e.boundaries,[o,s]=(0,J.useState)(a.environments),[c,l]=(0,J.useState)(a.actions),[u,d]=(0,J.useState)(a.approve),[f,p]=(0,J.useState)(a.shell),[m,h]=(0,J.useState)(a.repository),[g,_]=(0,J.useState)(a.unattended),[v,y]=(0,J.useState)(a.trust||[]),[b,x]=(0,J.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)),ee=e.plan.filter(e=>e.on&&e.capability.startsWith(`system:`)),w=(e,t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],T=e=>c.includes(e),E=(e,t)=>l(t?[...new Set([...c,e])]:c.filter(t=>t!==e)),D=(e,t)=>d(t?[...new Set([...u,e])]:u.filter(t=>t!==e)),te=o.join(` and `)||`its environments`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 rounded-[14px] card border p-4`,children:[(0,Y.jsx)(`legend`,{className:`sr-only`,children:`Where it works`}),(0,Y.jsx)(`span`,{className:`text-[16px] font-semibold`,children:`Where it works`}),(0,Y.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,Y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,Y.jsx)(tt,{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,Y.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,Y.jsxs)(`section`,{"aria-labelledby":`build-may`,className:`flex flex-col rounded-[14px] card border px-4 py-1`,children:[(0,Y.jsx)(`h2`,{id:`build-may`,className:`sr-only`,children:`What it may do`}),(0,Y.jsx)(X,{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,Y.jsx)(X,{text:`Run tests and apps in ${te}`,help:`Browser runs, tests, API calls and database queries.`,on:T(`run`),onChange:e=>E(`run`,e)}),e.needs?.run&&T(`run`)&&(0,Y.jsx)(X,{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=>D(`run`,e)}),e.needs?.run&&T(`run`)&&S&&(0,Y.jsx)(X,{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,Y.jsx)(X,{text:`Change test assets on this computer`,help:`Regression packs, API contracts, page memory, recordings. Off unless its job is to make them.`,on:T(`change`),onChange:e=>E(`change`,e)}),T(`change`)&&(0,Y.jsx)(X,{text:`Ask me before each change`,on:u.includes(`change`),onChange:e=>D(`change`,e)}),e.needs?.external&&(0,Y.jsx)(X,{text:`Change other systems as you asked`,help:`Work items or the team's channel, as you chose.`,on:T(`external`),onChange:e=>E(`external`,e)}),T(`external`)&&(0,Y.jsx)(X,{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,Y.jsx)(X,{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&&E(`change`,!0))}),e.needs?.repository&&m===`write`&&(0,Y.jsx)(X,{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,Y.jsx)(X,{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,Y.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 rounded-[14px] card border p-4`,children:[(0,Y.jsx)(`legend`,{className:`sr-only`,children:`What it may do alone`}),(0,Y.jsxs)(`span`,{className:`text-[16px] font-semibold`,children:[`When it runs `,e.schedule.toLowerCase(),`, with nobody watching`]}),(0,Y.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,Y.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:[T(`run`)&&(0,Y.jsx)(xn,{on:g.includes(`run`),label:`Run tests and apps`,why:`Recommended: what it is there to do.`,recommended:!0,onToggle:()=>_(w(g,`run`))}),T(`change`)&&(0,Y.jsx)(xn,{on:g.includes(`change`),label:`Change test assets`,onToggle:()=>_(w(g,`change`))}),m===`write`&&v.includes(`coding`)&&(0,Y.jsx)(xn,{on:g.includes(`coding`),label:`Write or heal tests`,why:`The coding agent, when its test project names no address outside its environments.`,onToggle:()=>_(w(g,`coding`))}),ee.map(e=>(0,Y.jsx)(xn,{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:()=>_(w(g,`${e.capability.slice(7)}_*`))},e.capability))]})]}),(0,Y.jsx)(bn,{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 En({v:e,busy:t,onNext:n,onBack:r,next:i}){let a=e.knowledge,[o,s]=(0,J.useState)(a.files.filter(e=>e.on).map(e=>e.file)),[c,l]=(0,J.useState)(a.skills.filter(e=>e.on).map(e=>e.name)),[u,d]=(0,J.useState)(a.notes),f=(e,t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],p=e=>e.toSorted((e,t)=>Number(!!t.why)-Number(!!e.why));return(0,Y.jsxs)(Y.Fragment,{children:[(a.files.length>0||a.skills.length>0)&&(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:[p(a.files).map(e=>(0,Y.jsx)(xn,{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,Y.jsx)(xn,{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,Y.jsxs)(`label`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[16px] font-semibold`,children:`Anything else it should know?`}),(0,Y.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,Y.jsx)(Xe,{rows:5,value:u,maxLength:2e4,onChange:e=>d(e.target.value),placeholder:`A declined card shows “Payment failed” and keeps the basket.`})]}),(0,Y.jsx)(bn,{busy:t,onBack:r,next:i,onNext:()=>n({files:o,skills:c,notes:u})})]})}function Dn({v:e,busy:t,onNext:n,onBack:r,next:i}){let a=e.review,[o,s]=(0,J.useState)(a.name),[c,l]=(0,J.useState)(a.id),[u,d]=(0,J.useState)(a.description),[f,p]=(0,J.useState)(a.icon||``),[m,h]=(0,J.useState)(a.starters[0]?.text||e.goal),[g,_]=(0,J.useState)(a.model||``),[v,y]=(0,J.useState)(a.maxTokens?String(a.maxTokens):``),[b,x]=(0,J.useState)(a.maxMinutes?String(a.maxMinutes):``),S=[v&&!(Number.isInteger(Number(v))&&Number(v)>=1e3&&Number(v)<=1e8)?`The budget per run is a whole number of tokens, from 1,000 to 100,000,000.`:``,b&&!(Number.isInteger(Number(b))&&Number(b)>=1&&Number(b)<=1440)?`The time limit per run is a whole number of minutes, from 1 to 1440.`:``,g&&!(e.models||[]).some(e=>e.name===g)?`${g} is no longer in llms.json: pick another model, or ForgeQE's choice.`:``].filter(Boolean).join(` `),C={...g?{model:g}:{},...v?{maxTokens:Math.round(Number(v))}:{},...b?{maxMinutes:Math.round(Number(b))}:{}},ee=e.plan.filter(e=>e.on),w=e.boundaries,T=e.knowledge,E=[[`It works in`,w.environments.join(`, `)],[`It does`,ee.map(e=>e.title).join(`; `)],[`It may`,[w.actions.includes(`run`)?`run tests and apps${w.approve.includes(`run`)?` (asking you first)`:``}`:``,w.actions.includes(`change`)?`change test assets`:``,w.actions.includes(`external`)?`change other systems${(w.trust||[]).includes(`external`)?` (without asking)`:` (asking you first)`}`:``,w.repository===`write`?`write or heal tests${(w.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${w.unattended.length?`; alone it may ${w.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`],...w.shell?[[`Shell`,`yes, a person approves each command`]]:[],[`It knows`,[...T.files.filter(e=>e.on).map(e=>e.title),...T.skills.filter(e=>e.on).map(e=>e.name),...T.notes.trim()?[`your notes`]:[]].join(`, `)||`nothing extra`]];return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Name`}),(0,Y.jsx)(V,{value:o,maxLength:60,onChange:e=>s(e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Id`}),(0,Y.jsx)(V,{value:c,maxLength:40,spellCheck:!1,disabled:!!e.saved,onChange:e=>l(e.target.value.toLowerCase())})]})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`What it is for`}),(0,Y.jsx)(`span`,{className:`text-[13px] text-muted`,children:`One line. Atlas reads it to know when to hand it work.`}),(0,Y.jsx)(V,{value:u,maxLength:300,onChange:e=>d(e.target.value)})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Icon`}),(0,Y.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,Y.jsx)(dn,{value:f,onChange:p})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-3`,children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Budget per run`}),(0,Y.jsx)(`span`,{className:`text-[13px] text-muted`,children:`The most model tokens one run may use, 1,000 or more; it stops there. Empty: no limit.`}),(0,Y.jsx)(V,{type:`number`,min:1e3,step:1e3,value:v,placeholder:`No limit`,onChange:e=>y(e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Time limit per run`}),(0,Y.jsx)(`span`,{className:`text-[13px] text-muted`,children:`In minutes, 1 to 1440. Empty: no limit when someone is watching, 120 when nobody is (a schedule, a trigger, another agent).`}),(0,Y.jsx)(V,{type:`number`,min:1,max:1440,value:b,placeholder:`Minutes`,onChange:e=>x(e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Model`}),(0,Y.jsx)(`span`,{className:`text-[13px] text-muted`,children:`The model profile of llms.json its runs use.`}),(0,Y.jsxs)(B,{value:g,onChange:e=>_(e.target.value),children:[(0,Y.jsx)(`option`,{value:``,children:`ForgeQE's choice`}),(e.models||[]).map(e=>(0,Y.jsxs)(`option`,{value:e.name,children:[e.name,` (`,e.model,`)`]},e.name)),g&&!(e.models||[]).some(e=>e.name===g)&&(0,Y.jsxs)(`option`,{value:g,children:[g,` (not in llms.json)`]})]})]})]}),S&&(0,Y.jsx)(`p`,{role:`alert`,className:`m-0 text-sm text-fail`,children:S}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Its first request`}),(0,Y.jsx)(V,{value:m,maxLength:500,onChange:e=>h(e.target.value)})]}),(0,Y.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:E.map(([e,t])=>(0,Y.jsxs)(`div`,{className:`contents`,children:[(0,Y.jsx)(`dt`,{className:`text-muted`,children:e}),(0,Y.jsx)(`dd`,{className:`m-0 text-ink [overflow-wrap:anywhere]`,children:t})]},e))}),e.advice.filter(e=>e.blocking).length>0&&(0,Y.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,Y.jsxs)(`li`,{className:`flex flex-col gap-1 rounded-[12px] bg-warn-soft px-4 py-4 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-warn`,children:e.about}),(0,Y.jsx)(`span`,{className:`text-[13px] text-ink-2`,children:e.fix})]},t))}),(0,Y.jsx)(bn,{busy:t,onBack:r,next:e.saved?`Save the changes`:i,onNext:()=>n({name:o,id:c,description:u,icon:f,starters:[{label:`Run it now`,text:m}],...C}),disabled:!o.trim()||!c.trim()||!!S,aside:e.saved?(0,Y.jsxs)(`a`,{href:M(`agents`,`custom`,e.saved,`edit`),className:`inline-flex items-center gap-2`,children:[(0,Y.jsx)(we,{size:14,"aria-hidden":`true`}),`Open every setting`]}):(0,Y.jsxs)(H,{size:`sm`,variant:`ghost`,disabled:t||!o.trim()||!c.trim()||!!S,onClick:()=>n({name:o,id:c,description:u,icon:f,starters:[{label:`Run it now`,text:m}],...C},!0),"data-tip":`Save it as a draft, then open every setting`,children:[(0,Y.jsx)(we,{"aria-hidden":`true`}),`Save and open every setting`]})})]})}function On({v:e}){let t=e.saved,[n,r]=(0,J.useState)(e.review?.starters[0]?.text||e.goal),[i,a]=(0,J.useState)(``),[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(``),[u,d]=(0,J.useState)(!1),f=async()=>{s(!0);try{let{id:e}=await Je.start(n.trim(),{agent:t,try:!0});location.hash=M(`chats`,e)}catch(e){l(e.message),s(!1)}},p=async()=>{s(!0),l(``);try{await R.act(t,`approve`,{confirm:i,note:`Made with the agent builder`}),d(!0)}catch(e){l(e.message)}finally{s(!1)}};return u?(0,Y.jsxs)(`div`,{className:`flex flex-col items-start gap-4 rounded-[14px] bg-pass-soft px-4 py-4`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-2 text-[16px] font-semibold text-pass`,children:[(0,Y.jsx)(m,{size:18,"aria-hidden":`true`}),P(e.review?.name||`agent`,!0),` is ready.`]}),(0,Y.jsx)(`span`,{className:`text-sm text-ink-2`,children:`You, your team and Atlas can hand it work now.`}),(0,Y.jsxs)(`a`,{href:M(`agents`,`custom`,t),className:F(Qe({variant:`primary`,size:`sm`}),`no-underline`),"data-tip":`Open the agent`,children:[(0,Y.jsx)(N,{"aria-hidden":`true`}),`Open`]})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(G,{id:`build-try`,icon:v,title:`1. Try it on a real request`,level:3,className:`rounded-[14px] card border p-4`,children:[(0,Y.jsx)(Xe,{rows:2,"aria-label":`What to try`,value:n,onChange:e=>r(e.target.value)}),(0,Y.jsxs)(H,{variant:`primary`,size:`sm`,className:`self-start`,disabled:o||!n.trim(),onClick:()=>void f(),"data-tip":`Try it in a chat`,children:[(0,Y.jsx)(v,{"aria-hidden":`true`}),`Try`]}),(0,Y.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,Y.jsxs)(G,{id:`build-approve`,icon:m,title:`2. Approve it`,level:3,className:`rounded-[14px] card border p-4`,children:[(0,Y.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[`Only an approved version runs. Type its id to confirm: `,t]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(V,{"aria-label":`Type ${t} to confirm`,className:`w-[260px]`,value:i,spellCheck:!1,autoComplete:`off`,onChange:e=>a(e.target.value),placeholder:t}),(0,Y.jsxs)(H,{size:`sm`,disabled:o||i!==t,onClick:()=>void p(),children:[(0,Y.jsx)(m,{"aria-hidden":`true`}),`Approve`]})]})]}),c&&(0,Y.jsx)(`p`,{role:`alert`,className:`m-0 text-sm text-fail [overflow-wrap:anywhere]`,children:c}),(0,Y.jsx)(`a`,{href:M(`agents`,`custom`,t),className:`self-start text-[13px]`,children:`Open its page`})]})}function kn({text:e,file:t}){let n=e.replace(/\n$/,``).split(`
2
- `);return(0,Y.jsx)(G,{id:`ca-manifest`,icon:he,title:(0,Y.jsxs)(Y.Fragment,{children:[`Its manifest, as it is in `,(0,Y.jsx)(`span`,{className:`font-mono`,children:t})]}),description:`Read only: fix it in that file, or start a new agent from the form and delete this one.`,className:`w-full text-left`,children:(0,Y.jsx)(`pre`,{tabIndex:0,"aria-label":`The manifest in ${t}`,className:`m-0 max-h-[50vh] overflow-auto rounded-[12px] card border px-4 py-4 font-mono text-[13px] leading-relaxed`,children:n.map((e,t)=>(0,Y.jsxs)(`span`,{className:`block pl-12 -indent-12 whitespace-pre-wrap [overflow-wrap:anywhere]`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`mr-4 inline-block w-8 text-right text-muted select-none`,children:t+1}),e]},t))})})}function An(e,t){let n=e.endedAt?Date.parse(e.endedAt)-Date.parse(e.startedAt):NaN,r=Number.isFinite(n)&&n>=0?n>=6e4?`${Math.floor(n/6e4)} min`:`${Math.max(1,Math.floor(n/1e3))}s`:``;return[e.model||``,e.usage?t.usage(e.usage):``,r,e.cost?`about ${t.money(e.cost.amount,e.cost.currency)}`:``].filter(Boolean).join(` · `)}var jn=[`text`,`environment`,`choice`],Mn=/[\u0000-\u001f\u007f\u2028\u2029]/,Nn=/\{([a-z][a-z0-9_]{0,31})\}/g;function Pn(e){return[...new Set([...e.matchAll(Nn)].map(e=>e[1]))]}function Fn(e,t,n){return typeof t!=`string`||!t.trim()?`${e.label} needs a value.`:t.length>200?`${e.label} is longer than 200 characters.`:Mn.test(t)?`${e.label} must be one line of text.`:t.trim().startsWith(`-`)?`${e.label} cannot start with a dash.`:e.kind===`environment`&&!n.includes(t)?`${e.label}: "${t.slice(0,40)}" is not one of its environments.`:e.kind===`choice`&&!(e.options||[]).includes(t)?`${e.label}: "${t.slice(0,40)}" is not one of its options.`:``}function In(e,t,n,r){let i=[];for(let a of Pn(e)){let e=t.find(e=>e.name===a);if(!e)i.push(`{${a}} is not one of its inputs.`);else{let t=Fn(e,Object.hasOwn(n,a)?n[a]:void 0,r);t&&i.push(t)}}if(i.length)throw Error(i.join(` `));let a=e.replace(Nn,(e,t)=>n[t].trim());if(a.trim().startsWith(`-`))throw Error(`The request cannot start with a dash.`);return a}var Ln=(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 Rn=`https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files-v1.0`,zn=Object.freeze([{file:`kokoro-onnx/kokoro-v1.0.onnx`,url:`${Rn}/kokoro-v1.0.onnx`,bytes:325532387,sha256:`7d5df8ecf7d4b1878015a32686053fd0eebe2bc377234608764cc0ef3636a6c5`},{file:`kokoro-onnx/voices-v1.0.bin`,url:`${Rn}/voices-v1.0.bin`,bytes:28214398,sha256:`bca610b8308e8d99f32e6fe4197e7ec01679264efed0cac9140fe9c29f1fbf7d`}]),Bn=`https://huggingface.co/Systran/faster-whisper-base.en/resolve/3d3d5dee26484f91867d81cb899cfcf72b96be6c`,Vn=Object.freeze([{file:`whisper-base.en/config.json`,url:`${Bn}/config.json`,bytes:2227,sha256:`f3bc3821e9fc76a27bae538e11ae5b677dcdd352b4600429ce7951d398569aeb`},{file:`whisper-base.en/tokenizer.json`,url:`${Bn}/tokenizer.json`,bytes:2128466,sha256:`929c5252409436dce1b38a75d1abbcb5e132d170d8e324e4e04ed915fa2d22df`},{file:`whisper-base.en/vocabulary.txt`,url:`${Bn}/vocabulary.txt`,bytes:422309,sha256:`ff77588746d3a2595d32ab5b69ffd7b95ce2441ac57533cb66fc3eb575a115cf`},{file:`whisper-base.en/model.bin`,url:`${Bn}/model.bin`,bytes:145216508,sha256:`2a166925539a16005f14ff328359f9b9adb9dc4fb631bb3b227526862e93e2ef`}]),Hn=Object.freeze(Ln(`onnx-community/silero-vad`,`e71cae966052b992a7eca6b17738916ce0eca4ec`,`silero-vad`,[[`onnx/model.onnx`,2243022,`a4a068cd6cf1ea8355b84327595838ca748ec29a25bc91fc82e6c299ccdc5808`]])),Un=Object.freeze(Ln(`pipecat-ai/smart-turn-v3`,`f766f81d3cfdf7737ac64aad813d91bbfd56bf93`,`smart-turn-v3`,[[`smart-turn-v3.2-cpu.onnx`,8679182,`2bb026316b14a660486a75b1733cd3fbab8c2fd0314dc9af7be49f8cca967e4f`]])),Wn=Object.freeze([...Hn,...Un]);Object.freeze([...zn,...Vn,...Wn]),Object.freeze({en:Object.freeze([`af_heart`,`am_michael`])}),Object.freeze({en:`af_heart`});var Gn=Object.freeze([`light`,`deep`]);Object.freeze({en:{light:`af_heart`,deep:`am_michael`}});var Kn=[`suite_failed`,`suite_passed`,`job_failed`,`job_recovered`,`eval_failed`,`pr_opened`,`pr_updated`,`push`],qn=[`pr_opened`,`pr_updated`,`push`],Jn=[`number`,`text`,`yes_no`],Yn={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 Xn(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^[^a-z]+/,``).replace(/(?<!-)-+$/,``).slice(0,40).replace(/(?<!-)-+$/,``)}var Zn={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.`}},Qn=6,$n={number:`A number`,text:`One line of text`,yes_no:`Yes or no`},er=qn,tr={suite_failed:`A suite failed`,suite_passed:`A suite passed`,job_failed:`A schedule failed`,job_recovered:`A schedule recovered`,eval_failed:`An eval failed`,pr_opened:`A pull request opened`,pr_updated:`A pull request updated`,push:`A branch pushed to`},nr={text:`Text`,environment:`One of its environments`,choice:`One of a list`},rr={read:`Read`,run:`Run`,change:`Change files`,external:`Change other systems`,schedule:`Schedule work`};function ir(e){let t=e.schedule?.with;if(!e.schedule||!t)return e;let n=new Set(Pn(e.schedule.request)),r=Object.fromEntries(Object.entries(t).filter(([t,r])=>{let i=(e.inputs||[]).find(e=>e.name===t);return!i||!n.has(t)?!1:i.kind===`choice`?(i.options||[]).map(e=>e.trim()).includes(r.trim()):i.kind!==`environment`||e.scope.environments.includes(r)}));if(Object.keys(r).length===Object.keys(t).length)return e;let{with:i,...a}=e.schedule;return{...e,schedule:{...a,...Object.keys(r).length?{with:r}:{}}}}function ar(e,t){let n=e.permissions.deny||[];if(!n.length)return e;let r=new Set(t.flatMap(e=>(e.usable||[]).map(e=>e.name))),i=new Set(t.filter(t=>e.scope.capabilities.includes(t.id)).flatMap(e=>(e.usable||[]).map(e=>e.name))),a=n.filter(e=>!r.has(e)||i.has(e));return a.length===n.length?e:{...e,permissions:{...e.permissions,deny:a}}}var or={ready:{icon:m,label:`Ready`,cls:`text-pass`},partial:{icon:_,label:`Partly set up`,cls:`text-warn`},needs_setup:{icon:O,label:`Needs setup`,cls:`text-muted`}},sr=e=>e?e.cron===void 0?`every`:`cron`:``,cr=e=>e.replace(/\s+MCP\s*$/i,``);function lr(e,t,n=[]){let r=e.permissions,i=r.repository===`write`?n.filter(e=>(r.trust||[]).includes(e)):[],a=[...r.actions.includes(`run`)?[{key:`run`,ids:[`run`],label:`Run tests and apps`}]:[],...r.actions.includes(`change`)?[{key:`change`,ids:[`change`],label:`Change test assets`}]:[],...i.length?[{key:`coding`,ids:i,label:`Write or heal tests`}]:[],...(e.scope.systems||[]).map(e=>({key:`${e}_*`,ids:[`${e}_*`],label:`Change ${cr(t.find(t=>t.name===e)?.label||e)}`}))],o=new Set(a.flatMap(e=>e.ids)),s={external:`Change other systems`,schedule:`Schedule work`};return[...a,...(r.unattended||[]).filter(e=>!o.has(e)).map(e=>({key:e,ids:[e],label:s[e]||e.replace(/_\*$/,` (all its tools)`).replace(/_/g,` `)}))]}function ur(e,t=[],n=t){let r=e.permissions,i=new Set(e.scope.systems||[]),a=new Set([`run`,`change`,`external`,`schedule`]),o=(r.unattended||[]).filter(e=>a.has(e)?r.actions.includes(e):e.endsWith(`_*`)?i.has(e.slice(0,-2)):!t.includes(e)||n.includes(e)&&r.repository===`write`&&(r.trust||[]).includes(e));return o.length===(r.unattended||[]).length?e:{...e,permissions:{...r,unattended:o}}}var Z=(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,Y.jsxs)(`label`,{className:F(`flex items-start gap-2 text-sm`,n?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,Y.jsx)(Rt,{checked:e,disabled:n,onCheckedChange:t,className:`mt-1`}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Y.jsx)(`span`,{className:`text-ink`,children:r}),i&&(0,Y.jsx)(`span`,{className:`text-[13px] text-muted`,children:i})]})]})}function dr({id:e,label:t,options:n,onChange:r,placeholder:i=`checkout, search`,max:a=12,mono:o=!1}){let[s,c]=(0,J.useState)(n.join(`, `)),l=e=>[...new Set(e.split(`,`).map(e=>e.trim()).filter(Boolean))].slice(0,a);return(0,J.useEffect)(()=>{l(s).join(`\0`)!==n.join(`\0`)&&c(n.join(`, `))},[n.join(`\0`)]),(0,Y.jsx)(V,{id:e,"aria-label":t,className:F(`min-w-0 flex-[1_1_200px]`,o&&`font-mono`),value:s,placeholder:i,maxLength:a*122,spellCheck:!o,onChange:e=>{let t=o?e.target.value.toLowerCase():e.target.value;c(t),r(l(t))}})}function fr({id:e,input:t,environments:n,value:r,onChange:i}){let a=t.kind===`environment`?n:t.kind===`choice`?t.options||[]:null;return a?(0,Y.jsxs)(B,{id:e,value:r,className:`w-[200px]`,onChange:e=>i(e.target.value),children:[(0,Y.jsx)(`option`,{value:``,children:`Pick one`}),a.map(e=>(0,Y.jsx)(`option`,{value:e,children:e},e))]}):(0,Y.jsx)(V,{id:e,value:r,maxLength:200,className:`w-[200px]`,onChange:e=>i(e.target.value)})}function pr({id:e,template:t}){let n=!e,[r,o]=(0,J.useState)(n&&!t?Yn:null),[c,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(null),[f,p]=(0,J.useState)(``),[h,g]=(0,J.useState)(``),[_,v]=(0,J.useState)(null),[b,ee]=(0,J.useState)([]),[D,te]=(0,J.useState)([]),[O,k]=(0,J.useState)(!1),[A,ie]=(0,J.useState)(!1),[ae,oe]=(0,J.useState)(!1);(0,J.useEffect)(()=>{R.choices().then(d,e=>p(e.message)),t&&R.template(t).then(e=>{l(e),o({...Yn,...e.fields,scope:{...Yn.scope,...e.fields.scope},permissions:{...Yn.permissions,...e.fields.permissions}}),oe(!0)},e=>p(e.message)),e&&R.view(e).then(t=>(g(t.approvedVersion||``),t.form?o({...Yn,...t.form,runtime:{...t.form.runtime}}):t.manifestText===void 0?p(`${e} has no manifest the editor can read (it may have been removed). Its page says what it has.`):(v({text:t.manifestText,file:t.manifestFile||`.forgeqe/agents/${e}.yaml`,problems:t.problems.working}),p(`${e}'s manifest is not one the editor can read. Fix it in ${t.manifestFile||`.forgeqe/agents/${e}.yaml`}; what is wrong, and the file as it is, are below.`))),e=>p(e.message))},[e,t]);let ce=(0,J.useRef)(0);(0,J.useEffect)(()=>{if(!r)return;let e=++ce.current;k(!0);let t=setTimeout(()=>{R.validate(ir(r)).then(t=>e===ce.current&&(ee(t.problems||[]),te(t.advice||[]),k(!1)),t=>e===ce.current&&(ee([t.message]),k(!1)))},350);return()=>clearTimeout(t)},[r]);let j=e=>o(t=>t&&{...t,...e}),de=u?.coding||[],fe=e=>de.filter(t=>(u?.capabilities||[]).some(n=>e.scope.capabilities.includes(n.id)&&n.tools.includes(t))),pe=e=>ar(ur(e,de,fe(e)),u?.capabilities||[]),me=e=>o(t=>t&&pe({...t,scope:{...t.scope,...e}})),he=e=>o(t=>t&&{...t,voice:e?{sound:e}:void 0}),ge=e=>o(t=>t&&pe({...t,permissions:{...t.permissions,...e}})),_e=e=>o(t=>{if(!t)return t;let n=t.schedule?.request??t.starters[0]?.text??``;if(!e)return{...t,schedule:void 0,...(t.triggers||[]).length?{}:{permissions:{...t.permissions,unattended:[]}}};let r=t.schedule?.with?{with:t.schedule.with}:{};return{...t,schedule:e===`every`?{every:t.schedule?.every??`1d`,request:n,...r}:{cron:t.schedule?.cron??`0 7 * * 1-5`,request:n,...r}}}),ve=e=>o(t=>t?.schedule?{...t,schedule:{...t.schedule,...e}}:t),ye=r?.schedule,we=[...ye&&sr(ye)===`every`&&!ye.every?.trim()?[`Say how often it runs: 15m, 1h, 1d.`]:[],...ye&&sr(ye)===`cron`&&!ye.cron?.trim()?[`Give its cron schedule: 0 7 * * 1-5.`]:[],...ye&&!ye.request.trim()?[`Say what it is asked each time it runs by itself.`]:[],...(r?.triggers||[]).flatMap((e,t)=>e.request.trim()?[]:[`Say what trigger ${t+1} asks it (${tr[e.on].toLowerCase()}).`])],N=[...we,...b],Te=(0,J.useMemo)(()=>{let e=new Map;for(let t of u?.capabilities||[])e.set(t.area,[...e.get(t.area)||[],t]);return[...e]},[u]),Ee=async()=>{if(r){ie(!0),p(``);try{let t=await R.save(ir(r),n?{create:!0}:{id:e});location.hash=M(`agents`,`custom`,t.id)}catch(e){p(e.message),ie(!1)}}},Ae=e?M(`agents`,`custom`,e):M(`agents`,`custom`,`new`);return(0,Y.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,Y.jsx)(an,{}),(0,Y.jsxs)(`main`,{className:F(vt,`settings-fields flex-auto gap-2`),children:[(0,Y.jsx)(it,{href:Ae,label:e?`Back to the agent`:`Back to the builder`,className:`mb-2`}),(0,Y.jsx)(`h1`,{className:`m-0 text-[25px] font-semibold tracking-[-0.01em]`,children:n?`New custom agent`:`Edit ${r?.name||e}`}),(0,Y.jsx)(`p`,{className:`m-0 mb-2 text-sm leading-relaxed text-ink-2`,children:n?c?`ForgeQE's ${c.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.`}),f&&(0,Y.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-4 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:f}),c&&u&&(0,Y.jsx)(G,{id:`ca-template`,icon:le,title:(0,Y.jsxs)(Y.Fragment,{children:[`From the `,c.title,` template`]}),level:3,className:`mb-2`,children:(0,Y.jsxs)(`ul`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:[c.systems.length>0&&(0,Y.jsxs)(`li`,{className:`flex flex-col gap-1 rounded-[12px] bg-surface-muted px-4 py-4 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`font-medium text-ink`,children:[`It uses the tools of `,c.systems.map(e=>cr(u?.systems.find(t=>t.name===e)?.label||e)).join(`, `)]}),(0,Y.jsx)(`span`,{className:`text-[13px] text-ink-2`,children:`Through ForgeQE, which checks every call against what this agent may do. Change them under Systems it works with.`})]}),c.notes.map(e=>(0,Y.jsx)(`li`,{className:`flex flex-col gap-1 rounded-[12px] bg-surface-muted px-4 py-4 text-sm`,children:(0,Y.jsx)(`span`,{className:`font-medium text-ink`,children:e})},e))]})}),n&&!t&&(0,Y.jsx)(`p`,{className:`m-0 mb-2 text-sm`,children:(0,Y.jsx)(`a`,{href:M(`agents`,`custom`,`new`),children:`Or say what it should do, and let ForgeQE build it with you`})}),_&&(0,Y.jsxs)(Y.Fragment,{children:[_.problems.length>0&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-[12px] bg-fail-soft px-4 py-4 text-sm text-fail`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Its manifest needs fixing before it can be edited here:`}),(0,Y.jsx)(`ul`,{className:`m-0 list-disc pl-6 [overflow-wrap:anywhere]`,children:_.problems.map((e,t)=>(0,Y.jsx)(`li`,{children:e},t))})]}),(0,Y.jsx)(kn,{text:_.text,file:_.file})]}),!r||!u?!f&&(0,Y.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(K,{first:!0,icon:re,children:`What it is`}),(0,Y.jsx)(q,{label:`Name`,help:`What it does, then “agent”: Checkout guard agent.`,htmlFor:`ca-name`,children:(0,Y.jsx)(V,{id:`ca-name`,value:r.name,maxLength:60,onChange:e=>j({name:e.target.value,...n&&!ae?{id:Xn(e.target.value)}:{}})})}),(0,Y.jsx)(q,{label:`Id`,help:n?`Its file name and address: lower-case words and hyphens. It cannot change later.`:`It cannot change. Make a new agent for another id.`,htmlFor:`ca-id`,children:(0,Y.jsx)(V,{id:`ca-id`,value:r.id,maxLength:40,disabled:!n,spellCheck:!1,onChange:e=>(oe(!0),j({id:e.target.value.toLowerCase()}))})}),(0,Y.jsx)(q,{label:`Version`,help:`${h?`${h} is approved and runs now. `:``}Raise it for each change you approve: 1.0.0, then 1.1.0. A change saved under a version already approved is raised to the next free one, so each version names one set of settings.`,htmlFor:`ca-version`,children:(0,Y.jsx)(V,{id:`ca-version`,value:r.version,maxLength:14,onChange:e=>j({version:e.target.value})})}),(0,Y.jsx)(q,{label:`Description`,help:`One line: what it is for. Atlas reads it to know when to hand it work.`,htmlFor:`ca-desc`,stacked:!0,children:(0,Y.jsx)(V,{id:`ca-desc`,value:r.description,maxLength:300,onChange:e=>j({description:e.target.value})})}),(0,Y.jsx)(q,{label:`Icon`,help:`What it wears on the Agents page and its own page: its mascot, or one of ForgeQE's agent icons.`,htmlFor:`ca-icon`,stacked:!0,children:(0,Y.jsx)(dn,{id:`ca-icon`,value:r.icon,onChange:e=>j({icon:e})})}),(0,Y.jsx)(q,{label:`Voice`,help:`How it sounds when you talk with it. Default is ForgeQE's own voice; ForgeQE picks each from the speech set up on that computer.`,children:(0,Y.jsx)(jt,{label:`Voice`,value:r.voice?.sound??``,onChange:e=>he(e),options:[{id:``,label:`Default`},...Gn.map(e=>({id:e,label:e[0].toUpperCase()+e.slice(1)}))]})}),(0,Y.jsx)(q,{label:`Instructions`,help:`Its focus and how to work, in plain words. Guidance for the model: the limits below are what holds it.`,htmlFor:`ca-instr`,stacked:!0,children:(0,Y.jsx)(Xe,{id:`ca-instr`,rows:5,value:r.instructions,maxLength:8e3,onChange:e=>j({instructions:e.target.value})})}),(0,Y.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.`,icon:se,children:`Where it works`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 py-4`,children:[u.environments.length===0&&(0,Y.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`No environments in env.yaml yet. Add them in Settings, Environments.`}),u.environments.map(e=>(0,Y.jsx)(Q,{checked:r.scope.environments.includes(e.name),onChange:t=>me({environments:Z(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,Y.jsx)(K,{help:`ForgeQE's capabilities it may use: their tools, and only theirs. Each says whether it is set up here.`,icon:ne,children:`What it can do`}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-4 py-4`,children:Te.map(([e,t])=>{let n=t.filter(e=>r.scope.capabilities.includes(e.id)).length;return(0,Y.jsxs)(`details`,{open:n>0||void 0,className:`group rounded-[12px] card border px-4 py-2`,children:[(0,Y.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 py-1 text-[13px] font-medium`,children:[(0,Y.jsx)(y,{size:14,"aria-hidden":`true`,className:`flex-none text-muted transition-transform duration-200 group-open:rotate-90`}),(0,Y.jsx)(`span`,{className:`flex-1`,children:e}),(0,Y.jsx)(`span`,{className:`text-[13px] font-normal text-muted tabular-nums`,children:n?`${n} of ${t.length} picked`:`${t.length}`})]}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-2 pt-2 pb-1 pl-6`,children:t.map(e=>{let t=or[e.state];return(0,Y.jsxs)(J.Fragment,{children:[(0,Y.jsx)(Q,{checked:r.scope.capabilities.includes(e.id),onChange:t=>me({capabilities:Z(r.scope.capabilities,e.id,t)}),help:(0,Y.jsxs)(`span`,{className:`flex items-start gap-2`,children:[(0,Y.jsx)(W,{icon:t.icon,size:13,className:F(`mt-1 flex-none`,t.cls)}),(0,Y.jsxs)(`span`,{children:[t.label,e.gaps.length?`: ${e.gaps.join(`; `)}`:``]})]}),children:(0,Y.jsx)(`span`,{"data-tip":e.summary,children:e.title})}),r.scope.capabilities.includes(e.id)&&((e.usable||[]).length>1||(e.usable||[]).some(e=>(r.permissions.deny||[]).includes(e.name)))&&(0,Y.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 border-0 p-0 pl-6`,children:[(0,Y.jsxs)(`legend`,{className:`sr-only`,children:[`Tools of `,e.title,` it uses`]}),(e.usable||[]).map(t=>(0,Y.jsx)(Q,{checked:!(r.permissions.deny||[]).includes(t.name),disabled:!(r.permissions.deny||[]).includes(t.name)&&(e.usable||[]).filter(e=>!(r.permissions.deny||[]).includes(e.name)).length===1,onChange:e=>ge({deny:Z(r.permissions.deny||[],t.name,!e)}),help:(rr[t.action]||t.action)+(!(r.permissions.deny||[]).includes(t.name)&&(e.usable||[]).filter(e=>!(r.permissions.deny||[]).includes(e.name)).length===1?`. Its last tool: untick the capability instead.`:``),children:(0,Y.jsx)(`span`,{className:`font-mono text-[13px]`,children:t.name})},t.name))]})]},e.id)})})]},e)})}),(0,Y.jsx)(K,{help:`ForgeQE's agents it may start: a capability that needs one (a browser run needs WebPilot) is refused without it.`,icon:ke,children:`Agents it may use`}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-2 py-4`,children:u.agents.map(e=>(0,Y.jsx)(Q,{checked:r.scope.agents.includes(e.name),onChange:t=>me({agents:Z(r.scope.agents,e.name,t)}),help:(0,Y.jsx)(`span`,{className:`font-mono text-[13px]`,children:e.name}),children:e.title},e.name))}),(0,Y.jsx)(K,{help:`Your team's other custom agents it may hand a request to. Each runs its approved version within its own limits and this one's, never more; one already working on the request is not handed it again. It needs Hands work on of 1 level or more.`,icon:S,children:`Custom agents it may hand work to`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 py-4`,children:[(u.customAgents||[]).filter(e=>e.id!==r.id).length===0&&(0,Y.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`No other custom agents in this project yet.`}),(u.customAgents||[]).filter(e=>e.id!==r.id).map(e=>(0,Y.jsx)(Q,{checked:(r.scope.customAgents||[]).includes(e.id),onChange:t=>me({customAgents:Z(r.scope.customAgents||[],e.id,t)}),help:(0,Y.jsxs)(`span`,{className:`font-mono text-[13px]`,children:[e.id,e.approved?``:` · not approved yet: it is handed nothing until it is`]}),children:e.name},e.id))]}),(0,Y.jsx)(K,{help:`Other systems' MCP servers this project has set up. It uses their tools through ForgeQE, which checks every call; a change in them is asked unless you lift it under What it may do.`,icon:w,children:`Systems it works with`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 py-4`,children:[u.systems.length===0&&(0,Y.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`None set up yet. Add them in Settings, MCP servers.`}),u.systems.map(e=>(0,Y.jsx)(Q,{checked:(r.scope.systems||[]).includes(e.name),onChange:t=>me({systems:Z(r.scope.systems||[],e.name,t)}),help:e.about.slice(0,160),children:cr(e.label)},e.name))]}),(0,Y.jsx)(K,{help:`Only these are loaded for it.`,icon:Ce,children:`Skills and knowledge`}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 py-4 sm:grid-cols-2`,children:[(0,Y.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 border-0 p-0`,children:[(0,Y.jsx)(`legend`,{className:`mb-1 p-0 text-[13px] font-semibold text-muted`,children:`Skills`}),u.skills.length===0&&(0,Y.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`None in this project yet.`}),u.skills.map(e=>(0,Y.jsx)(Q,{checked:r.scope.skills.includes(e.name),onChange:t=>me({skills:Z(r.scope.skills,e.name,t)}),help:e.about,children:e.name},e.name))]}),(0,Y.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 border-0 p-0`,children:[(0,Y.jsx)(`legend`,{className:`mb-1 p-0 text-[13px] font-semibold text-muted`,children:`Knowledge files`}),u.knowledge.length===0&&(0,Y.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`None in .forgeqe/knowledge yet.`}),u.knowledge.map(e=>(0,Y.jsx)(Q,{checked:r.scope.knowledge.includes(e.file),onChange:t=>me({knowledge:Z(r.scope.knowledge,e.file,t)}),help:e.title===e.file?void 0:e.title,children:e.file},e.file))]})]}),(0,Y.jsx)(K,{help:`Enforced on every call. Ask first: a person approves each such call in the chat. In production, every call is asked.`,icon:xe,children:`What it may do`}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-2 py-4`,children:u.actions.map(e=>(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-6 gap-y-1`,children:[(0,Y.jsx)(`div`,{className:`min-w-0 flex-[1_1_320px]`,children:(0,Y.jsx)(Q,{checked:r.permissions.actions.includes(e),onChange:t=>ge({actions:Z(r.permissions.actions,e,t)}),help:Zn[e]?.help,children:Zn[e]?.label||e})}),(0,Y.jsx)(Q,{checked:e===`external`?!(r.permissions.trust||[]).includes(`external`):r.permissions.approve.includes(e),disabled:!r.permissions.actions.includes(e),onChange:t=>ge(e===`external`?{trust:Z(r.permissions.trust||[],`external`,!t)}:{approve:Z(r.permissions.approve,e,t)}),children:`Ask first`})]},e))}),(0,Y.jsx)(q,{label:`Repository`,help:`Whether it may change files in the repository (with Change files).`,children:(0,Y.jsx)(jt,{label:`Repository`,value:r.permissions.repository,onChange:e=>ge({repository:e}),options:[{id:`read`,label:`Read only`},{id:`write`,label:`May change files`}]})}),r.scope.environments.some(e=>u.environments.some(t=>t.name===e&&t.production))&&r.permissions.actions.includes(`run`)&&(0,Y.jsx)(q,{label:`Production`,help:`Reads there go ahead without asking; every change there is approved by a person.`,children:(0,Y.jsx)(Q,{checked:!(r.permissions.production||[]).includes(`run`),onChange:e=>ge({production:e?[]:[`run`]}),children:`Ask before each run`})}),r.permissions.repository===`write`&&(()=>{let e=(u.coding||[]).filter(e=>u.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,Y.jsx)(q,{label:`Quill`,help:`The tests it runs can reach any address. Without asking, ForgeQE first looks in the test project's config and env files, and asks when they name an address outside its environments.`,children:(0,Y.jsx)(Q,{checked:!t,onChange:t=>ge({trust:t?(r.permissions.trust||[]).filter(t=>!e.includes(t)):[...new Set([...r.permissions.trust||[],...e])]}),children:`Ask first`})})})(),(0,Y.jsx)(q,{label:`Shell`,help:`Commands on this computer, and fetching web pages. A person approves each one; ForgeQE's secrets stay out of reach.`,children:(0,Y.jsx)(Q,{checked:r.permissions.shell===!0,onChange:e=>ge({shell:e}),children:`Use the shell`})}),(0,Y.jsx)(q,{label:`Hands work on`,help:`How many levels deep it may give part of a task to a helper.`,htmlFor:`ca-depth`,children:(0,Y.jsxs)(B,{id:`ca-depth`,value:String(r.runtime.maxDelegationDepth),onChange:e=>j({runtime:{...r.runtime,maxDelegationDepth:Number(e.target.value)}}),className:`w-[200px]`,children:[(0,Y.jsx)(`option`,{value:`0`,children:`Never`}),(0,Y.jsx)(`option`,{value:`1`,children:`1 level`}),(0,Y.jsx)(`option`,{value:`2`,children:`2 levels`}),(0,Y.jsx)(`option`,{value:`3`,children:`3 levels`})]})}),(0,Y.jsx)(q,{label:`Budget per run`,help:`The most model tokens one run may use; it stops there. Empty: no limit.`,htmlFor:`ca-budget`,children:(0,Y.jsx)(V,{id:`ca-budget`,type:`number`,min:1e3,step:1e3,className:`w-[200px]`,value:r.runtime.maxTokens??``,placeholder:`No limit`,onChange:e=>{let{maxTokens:t,...n}=r.runtime;j({runtime:{...n,...e.target.value?{maxTokens:Math.max(0,Math.round(Number(e.target.value)))}:{}}})}})}),(0,Y.jsx)(q,{label:`Time limit per run`,help:`In minutes (1 to 1440): the longest one run may take; it stops there. Empty: no limit when someone is watching, 120 minutes when nobody is (a schedule, a trigger, another agent).`,htmlFor:`ca-minutes`,children:(0,Y.jsx)(V,{id:`ca-minutes`,type:`number`,min:1,max:1440,className:`w-[200px]`,value:r.runtime.maxMinutes??``,placeholder:`Minutes`,onChange:e=>{let{maxMinutes:t,...n}=r.runtime;j({runtime:{...n,...e.target.value?{maxMinutes:Math.max(1,Math.round(Number(e.target.value)))}:{}}})}})}),(0,Y.jsx)(q,{label:`Model`,help:`The model profile of llms.json its runs use. ForgeQE's choice: the model ForgeQE's agent would use.`,htmlFor:`ca-model`,children:(0,Y.jsxs)(B,{id:`ca-model`,value:r.runtime.model??``,className:`w-[200px]`,onChange:e=>{let{model:t,...n}=r.runtime;j({runtime:{...n,...e.target.value?{model:e.target.value}:{}}})},children:[(0,Y.jsx)(`option`,{value:``,children:`ForgeQE's choice`}),(u.models||[]).map(e=>(0,Y.jsxs)(`option`,{value:e.name,children:[e.name,` (`,e.model,`)`]},e.name)),r.runtime.model&&!(u.models||[]).some(e=>e.name===r.runtime.model)&&(0,Y.jsxs)(`option`,{value:r.runtime.model,children:[r.runtime.model,` (not in llms.json)`]})]})}),(0,Y.jsx)(K,{help:`On a schedule it runs the approved version with nobody watching: it does alone only what you tick under What it may do alone, and anything else waits for a person.`,icon:Oe,children:`Runs by itself`}),(0,Y.jsx)(q,{label:`When`,children:(0,Y.jsx)(jt,{label:`When`,value:sr(r.schedule),onChange:_e,options:[{id:``,label:`Only when asked`},{id:`every`,label:`Every`},{id:`cron`,label:`On a cron schedule`}]})}),(0,Y.jsx)(q,{label:`Tell the team`,help:`How a run with nobody watching (on its schedule, a trigger, or started with --unattended) ended, on the notification channels that take custom agents' runs (Settings, Notifications).`,htmlFor:`ca-notify`,children:(0,Y.jsxs)(B,{id:`ca-notify`,value:r.runtime.notify??`failed`,className:`w-[200px]`,onChange:e=>{let{notify:t,...n}=r.runtime;j({runtime:{...n,...e.target.value===`failed`?{}:{notify:e.target.value}}})},children:[(0,Y.jsx)(`option`,{value:`failed`,children:`When it does not finish`}),(0,Y.jsx)(`option`,{value:`always`,children:`Each time it ends`}),(0,Y.jsx)(`option`,{value:`never`,children:`Never`})]})}),(u.channels||[]).length>0&&(0,Y.jsx)(q,{label:`Its notices go to`,help:`The notification channels its notices go to, each still only for the events it takes (Settings, Notifications). None ticked: every channel that takes them.`,children:(0,Y.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.channels.map(e=>(0,Y.jsx)(Q,{checked:(r.runtime.channels||[]).includes(e.name),onChange:t=>j({runtime:{...r.runtime,channels:Z(r.runtime.channels||[],e.name,t)}}),help:e.on.some(e=>e.startsWith(`agent_`))?void 0:`It takes no custom agent's events: tick them for it in Settings, Notifications.`,children:e.name},e.name))})}),r.schedule&&(0,Y.jsxs)(Y.Fragment,{children:[sr(r.schedule)===`every`?(0,Y.jsx)(q,{label:`Every`,help:`15m, 1h, 1d.`,htmlFor:`ca-every`,children:(0,Y.jsx)(V,{id:`ca-every`,value:r.schedule.every??``,placeholder:`30m`,spellCheck:!1,className:`max-w-[120px] font-mono`,onChange:e=>ve({every:e.target.value})})}):(0,Y.jsx)(q,{label:`Cron`,help:`Five fields, this machine's time: 0 7 * * 1-5 is weekdays at 07:00.`,htmlFor:`ca-cron`,children:(0,Y.jsx)(V,{id:`ca-cron`,value:r.schedule.cron??``,spellCheck:!1,className:`max-w-[180px] font-mono`,onChange:e=>ve({cron:e.target.value})})}),(0,Y.jsx)(q,{label:`Request`,help:`What it is asked each time it runs by itself. {name} uses one of its inputs, filled with the value below.`,htmlFor:`ca-request`,stacked:!0,children:(0,Y.jsx)(V,{id:`ca-request`,value:r.schedule.request,maxLength:500,placeholder:`Run the checkout pack on qa`,onChange:e=>ve({request:e.target.value})})}),Pn(r.schedule.request).map(e=>(r.inputs||[]).find(t=>t.name===e)).filter(e=>!!e).map(e=>(0,Y.jsx)(q,{label:e.label||`{${e.name}}`,help:`The value of {${e.name}} when it runs by itself.`,htmlFor:`ca-with-${e.name}`,children:(0,Y.jsx)(fr,{id:`ca-with-${e.name}`,input:e,environments:r.scope.environments,value:r.schedule?.with?.[e.name]??``,onChange:t=>ve({with:{...r.schedule?.with||{},[e.name]:t}})})},e.name))]}),(0,Y.jsx)(K,{help:`Something that happens in ForgeQE, or a pull request or push on GitHub or Azure DevOps, can start its approved version too, with nobody watching. A schedule's name narrows it to that schedule; a custom agent's own schedules never start anything. A pull request or push needs the repository's webhook to reach ForgeQE, signed with the webhook secret (Settings, Secrets, FORGEQE_WEBHOOK_SECRET); the agent is told only the pull request's number, repository and branches, never its title or description.`,icon:T,children:`Starts when something happens`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[(r.triggers||[]).map((e,t)=>{let n=e=>j({triggers:(r.triggers||[]).map((n,r)=>r===t?{...n,...e}:n)});return(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(B,{"aria-label":`Trigger ${t+1} event`,className:`w-[200px]`,value:e.on,onChange:t=>{let r=t.target.value,i=er.includes(r);n({on:r,...r.startsWith(`job_`)?{}:{job:void 0},...i?{source:e.source||`github`}:{source:void 0,repo:void 0,branch:void 0}})},children:Kn.map(e=>(0,Y.jsx)(`option`,{value:e,children:tr[e]},e))}),er.includes(e.on)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(B,{"aria-label":`Trigger ${t+1} host`,className:`w-[200px]`,value:e.source||`github`,onChange:e=>n({source:e.target.value}),children:[(0,Y.jsx)(`option`,{value:`github`,children:`GitHub`}),(0,Y.jsx)(`option`,{value:`azure_devops`,children:`Azure DevOps`})]}),(0,Y.jsx)(V,{"aria-label":`Trigger ${t+1} repository`,className:`w-[200px] font-mono`,maxLength:201,spellCheck:!1,value:e.repo??``,placeholder:e.source===`azure_devops`?`project/repository`:`owner/name`,onChange:e=>n({repo:e.target.value||void 0})}),(0,Y.jsx)(V,{"aria-label":`Trigger ${t+1}: which branch, empty for any`,className:`w-[140px] font-mono`,maxLength:200,spellCheck:!1,value:e.branch??``,placeholder:e.on===`push`?`any branch`:`any target`,onChange:e=>n({branch:e.target.value||void 0})})]}),e.on.startsWith(`job_`)&&(0,Y.jsx)(V,{"aria-label":`Trigger ${t+1}: which schedule, empty for any`,className:`w-[140px] font-mono`,maxLength:40,spellCheck:!1,value:e.job??``,placeholder:`any schedule`,onChange:e=>n({job:e.target.value||void 0})}),(0,Y.jsx)(V,{"aria-label":`Trigger ${t+1} request`,className:`min-w-0 flex-[1_1_280px]`,maxLength:500,value:e.request,placeholder:`What it is asked then (no {name}: nobody gives a value)`,onChange:e=>n({request:e.target.value})}),(0,Y.jsx)(H,{variant:`icon`,size:`icon`,"aria-label":`Remove trigger ${t+1}`,"data-tip":`Remove trigger ${t+1}`,onClick:()=>{let e=(r.triggers||[]).filter((e,n)=>n!==t);j({triggers:e,...!e.length&&!r.schedule?{permissions:{...r.permissions,unattended:[]}}:{}})},children:(0,Y.jsx)(a,{"aria-hidden":`true`})})]},t)}),(r.triggers||[]).length<4&&(0,Y.jsxs)(H,{size:`sm`,className:`self-start`,onClick:()=>j({triggers:[...r.triggers||[],{on:`suite_failed`,request:``}]}),"data-tip":`Add a trigger`,children:[(0,Y.jsx)(i,{"aria-hidden":`true`}),`Add`]})]}),(r.schedule||(r.triggers||[]).length>0)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(K,{help:`With nobody watching, it does only these without asking. Anything else waits for a person: the team is told, and no answer in time is a no.`,icon:xe,children:`What it may do alone`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 py-4`,children:[lr(r,u.systems,fe(r)).length===0&&(0,Y.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Only reading: allow more under What it may do, or pick Systems it works with, first.`}),lr(r,u.systems,fe(r)).map(e=>(0,Y.jsx)(Q,{checked:e.ids.every(e=>(r.permissions.unattended||[]).includes(e)),onChange:t=>ge({unattended:t?[...new Set([...r.permissions.unattended||[],...e.ids])]:(r.permissions.unattended||[]).filter(t=>!e.ids.includes(t))}),children:e.label},e.key))]})]}),(0,Y.jsx)(K,{help:`One per line: what it should keep in mind. Guidance for the model, never a limit.`,icon:ue,children:`Guidance`}),(0,Y.jsx)(Xe,{"aria-label":`Guidance, one per line`,rows:3,value:r.policies.join(`
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{$ as t,A as n,B as r,Bn as i,Cr as a,Dr as o,Er as s,F as c,Fn as l,Fr as u,Gn as d,Hn as f,Hr as p,I as m,J as h,Kr as g,L as _,Ln as v,M as y,Mn as b,Mr as x,Mt as S,O as C,Or as ee,Rn as w,Rr as T,S as E,U as D,Ut as te,V as O,Vr as ne,W as k,Xn as A,Xt as re,Zn as ie,_t as ae,dr as oe,er as se,fr as ce,g as le,in as ue,jr as j,kr as de,l as fe,ln as pe,lr as me,mt as he,n as ge,nt as _e,or as ve,ot as ye,pt as be,r as M,rr as xe,sn as Se,sr as Ce,tr as we,u as N,ut as Te,v as Ee,vn as De,w as Oe,y as ke,yn as Ae,yt as je}from"./route-D8G-pTdk.js";import{C as Me,S as Ne,T as Pe,b as Fe,c as Ie,l as Le,o as Re,s as ze,v as Be,w as Ve,y as P}from"./agents-DPabR9dS.js";import{t as He}from"./jsx-runtime-LKYXHABd.js";import{A as F,Ct as I,F as Ue,I as We,J as L,L as Ge,R as Ke,Y as qe,Z as Je,et as R,j as z,l as Ye,n as B,r as Xe,t as V}from"./input-CK9KiscI.js";import{C as Ze,D as Qe,E as H,c as U,i as $e,l as et,o as tt,r as nt,s as rt,t as it,v as at,w as W}from"./pageBack-CGpBg0rz.js";import{B as ot,H as st,N as ct,V as lt,a as ut,u as dt,z as ft}from"./palette-sQXAx0hh.js";import{$t as G,At as pt,F as mt,Fn as ht,Ht as gt,Ln as _t,Lt as vt,Mn as yt,Mt as bt,Nn as xt,O as St,Ot as Ct,Pn as wt,Pt as Tt,R as Et,Rn as Dt,Un as Ot,Vn as kt,Vt as At,Wn as jt,Xt as Mt,a as Nt,an as Pt,bt as K,c as Ft,cn as It,d as Lt,dt as Rt,en as zt,f as Bt,ft as Vt,i as Ht,in as Ut,jt as Wt,k as Gt,kt as Kt,l as qt,ln as Jt,o as Yt,p as Xt,r as Zt,s as Qt,sn as $t,u as en,un as tn,yt as q,z as nn,zn as rn,zt as an}from"./index-CeVry7Jo.js";import{i as on,r as sn,t as cn}from"./RelationGraph-BlR8ewL9.js";import{t as ln}from"./diff-CdVbBfvE.js";import{l as un}from"./dataParts-DqE6xkYJ.js";var J=e(g(),1),Y=He();function dn({value:e,onChange:t,id:r}){let i=Ve(e),a=typeof e==`string`?e.trim().replace(/\s+/g,` `):``,o=!i&&a?a.slice(0,60):``,s=Ve(e)?e:o?null:``,{theme:c}=dt(),l=ct(c)===`icons`?`No icon: the Helper's face`:`No icon: its mascot`,[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(10),[m,h]=(0,J.useState)(()=>!!(ft(`ph:robot`)||ft(`lucide:bot`)));(0,J.useEffect)(()=>{ot().then(()=>h(!0))},[]),(0,J.useEffect)(()=>{p(10)},[u]);let g=!!u.trim(),{hits:_,total:v}=(0,J.useMemo)(()=>g?lt(u,f,0):lt(``,f,Fe.length),[u,f,g]),y=st.length,b=g?v>f:f<y,x=g?Math.max(0,v-f):Math.max(0,y-f);return(0,Y.jsxs)(`div`,{id:r,className:`flex flex-col gap-4`,children:[(0,Y.jsxs)(`label`,{className:`relative block`,children:[(0,Y.jsx)(ie,{"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted`}),(0,Y.jsx)(V,{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,Y.jsxs)(`p`,{className:`text-[13px] text-warn`,children:[`This agent names an icon ForgeQE does not have: `,(0,Y.jsx)(`span`,{className:`font-mono`,children:o}),`. Pick one below, or No icon.`]}),!g&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:`mb-2 text-[13px] text-muted`,children:`No icon`}),(0,Y.jsx)(`div`,{role:`listbox`,"aria-label":`No icon`,className:`flex flex-wrap gap-2`,children:(0,Y.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":s===``,"aria-label":`No icon`,"data-tip":l,className:fn(s===``),onClick:()=>t(``),children:(0,Y.jsx)(ut,{agent:`custom`,px:28,decorative:!0})})})]}),!g&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:`mb-2 text-[13px] text-muted`,children:`ForgeQE faces`}),(0,Y.jsx)(`div`,{role:`listbox`,"aria-label":`ForgeQE faces`,className:`flex flex-wrap gap-2`,children:Fe.map(e=>(0,Y.jsx)(pn,{icon:e,label:Ne(e),selected:e===s,ready:!0,onPick:t},e))})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:`mb-2 text-[13px] text-muted`,children:g?`Top matches (${v})`:`Library icons (Phosphor and Lucide)`}),(0,Y.jsxs)(`div`,{role:`listbox`,"aria-label":g?`Icon search results`:`Library icons`,className:`flex flex-wrap gap-2`,children:[_.map(e=>(0,Y.jsx)(pn,{icon:e.id,label:e.label,selected:e.id===s,ready:m||e.kind===`face`,onPick:t},e.id)),_.length===0&&(0,Y.jsx)(`p`,{className:`text-[13px] text-muted`,children:`No icons match that search.`})]}),b&&(0,Y.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,x)} of ${x} more`,onClick:()=>p(e=>e+10),children:[(0,Y.jsx)(n,{size:14,"aria-hidden":`true`}),`More (`,x,`)`]})]}),s&&Pe(s)&&(0,Y.jsxs)(`p`,{className:`text-[13px] text-muted`,children:[`Selected `,(0,Y.jsx)(`span`,{className:`font-mono text-fg`,children:s})]})]})}var fn=e=>F(`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 pn({icon:e,label:t,selected:n,ready:r,onPick:i}){return(0,Y.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":n,"aria-label":t,"data-tip":t,disabled:!r&&!!Pe(e),className:fn(n),onClick:()=>i(e),children:Me(e)?(0,Y.jsx)(Ye,{name:e,px:28}):(0,Y.jsx)(ut,{agent:`custom`,icon:e,px:28,decorative:!0})})}var mn=[{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 hn(){let[e,t]=(0,J.useState)(``),[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(``),[o,s]=(0,J.useState)([]),[c,l]=(0,J.useState)([]),u=At(n);(0,J.useEffect)(()=>{qe.list().then(e=>s(e.sessions.filter(e=>!e.saved)),()=>{}),R.templates().then(e=>l(e.templates),()=>{})},[]);let d=async()=>{if(e.trim()){r(!0),a(``);try{let t=await qe.start(e.trim());location.hash=M(`agents`,`custom`,`build`,t.sid)}catch(e){a(e.message),r(!1)}}};return(0,Y.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,Y.jsxs)(`header`,{className:`flex items-center gap-1 px-6 py-4`,children:[(0,Y.jsx)(Et,{}),(0,Y.jsx)(it,{href:M(`agents`,`category`,`custom`),label:`Custom agents`,className:`self-center`})]}),(0,Y.jsx)(`main`,{className:`flex flex-auto flex-col items-center justify-center px-6 pt-6 pb-30`,children:(0,Y.jsxs)(`div`,{className:`flex w-full max-w-[780px] flex-col items-center gap-10`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-4 text-center`,children:[(0,Y.jsx)(Ze,{state:n?`waiting`:u,px:112,label:n?`Starting the builder`:`ForgeQE is ready to build an agent`,className:`mb-1`}),(0,Y.jsx)(`h1`,{className:`m-0 text-[31px] leading-tight font-semibold tracking-[-0.015em] text-ink`,children:`What should your agent do?`}),(0,Y.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,Y.jsx)(rn,{id:`build-goal`,label:`What your agent should do`,value:e,onChange:e=>{t(e),a(``)},onSend:()=>void d(),busy:n,disabled:n,placeholder:`An agent that checks the checkout on QA and tells me what broke…`}),i&&(0,Y.jsx)(`p`,{role:`alert`,className:`m-0 -mt-6 text-sm text-fail`,children:i}),(0,Y.jsx)(G,{id:`build-starters`,icon:ue,title:`Or start from one of these, and change it to fit`,className:`w-full`,children:(0,Y.jsx)(`ul`,{className:`m-0 grid list-none grid-cols-1 gap-2 p-0 sm:grid-cols-2`,children:mn.map(n=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":e===n.text,onClick:()=>{t(n.text),a(``),document.getElementById(`build-goal`)?.focus()},className:F(`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,Y.jsx)(`span`,{className:`text-[13px] font-medium text-ink`,children:n.label}),(0,Y.jsx)(`span`,{className:`text-[13px] text-muted`,children:n.about})]})},n.label))})}),o.length>0&&(0,Y.jsx)(G,{id:`build-resume`,icon:te,title:`Pick up where you left off`,className:`w-full`,children:(0,Y.jsx)(`ul`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-2`,children:o.slice(0,5).map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`a`,{href:M(`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,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:e.goal}),(0,Y.jsxs)(`span`,{className:`flex-none text-[13px] text-muted`,children:[gn[e.step].label,` · `,Mt(e.updatedAt)]})]})},e.sid))})}),c.length>0&&(0,Y.jsx)(G,{id:`build-templates`,icon:le,title:`Or start from a template, and review it before you save`,className:`w-full`,children:(0,Y.jsx)(`ul`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-2`,children:c.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`a`,{href:M(`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,Y.jsx)(`span`,{className:`flex-none text-[13px]`,children:e.title}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px] text-muted`,children:e.why||e.about})]})},e.id))})}),(0,Y.jsxs)(`a`,{href:M(`agents`,`custom`,`new`,`form`),className:`inline-flex items-center gap-2 text-[13px]`,children:[(0,Y.jsx)(we,{size:14,"aria-hidden":`true`}),`Or set every option yourself`]})]})})]})}var gn={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 _n({sid:e}){let[t,n]=(0,J.useState)(null),[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(!1);if((0,J.useEffect)(()=>{qe.view(e).then(e=>{n(e),o(Math.min(e.reached,e.steps.length-1))},e=>i(e.message))},[e]),(0,J.useEffect)(()=>{if(!t?.working)return;let r=setTimeout(()=>{qe.view(e).then(n,()=>{})},1500);return()=>clearTimeout(r)},[t,e]),r&&!t)return(0,Y.jsx)(vn,{children:(0,Y.jsxs)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-4 py-2 text-sm text-fail`,children:[r,` `,(0,Y.jsx)(`a`,{href:M(`agents`,`custom`,`new`),children:`Start again`})]})});if(!t||a===null)return(0,Y.jsx)(vn,{children:(0,Y.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`})});let l=t.steps[a].id,u=gn[l],d=s||t.working===l,f=async(t,r=!1)=>{if(l!==`try`){c(!0),i(``);try{let i=await qe.answer(e,l,t);if(r&&i.saved){location.hash=M(`agents`,`custom`,i.saved,`edit`);return}n(i),o(Math.min(a+1,i.steps.length-1)),window.scrollTo({top:0})}catch(e){i(e.message),window.scrollTo({top:0})}finally{c(!1)}}};return(0,Y.jsxs)(vn,{children:[(0,Y.jsx)(it,{href:M(`agents`,`category`,`custom`),label:`Custom agents`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-[13px] text-muted`,children:`New agent`}),(0,Y.jsxs)(`p`,{className:`m-0 text-[16px] text-ink-2 [overflow-wrap:anywhere]`,children:[`“`,t.goal,`”`]})]}),(0,Y.jsx)(yn,{v:t,at:a,onGo:e=>!s&&o(e)}),(0,Y.jsxs)(`section`,{"aria-labelledby":`build-step`,className:`flex flex-col gap-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,Y.jsx)(Ze,{state:d?`working`:`idle`,px:36,label:d?u.working:`ForgeQE`,className:`flex-none`}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Y.jsx)(`h1`,{id:`build-step`,className:`m-0 text-[20px] font-semibold tracking-[-0.01em]`,children:u.title}),(0,Y.jsx)(`p`,{className:`m-0 text-[16px] leading-relaxed text-ink-2`,children:d?t.working===l?gn[l].thinking:u.working:t.says[l]}),!d&&t.source?.[l]&&(0,Y.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,Y.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,Y.jsx)(Sn,{v:t,busy:s,onNext:f,next:u.next},`u-${t.updatedAt}`),t.working!==l&&l===`plan`&&(0,Y.jsx)(wn,{v:t,busy:s,onNext:f,onBack:()=>o(a-1),next:u.next},`p-${t.updatedAt}`),l===`boundaries`&&(0,Y.jsx)(Tn,{v:t,busy:s,onNext:f,onBack:()=>o(a-1),next:u.next},`b-${t.updatedAt}`),l===`knowledge`&&(0,Y.jsx)(En,{v:t,busy:s,onNext:f,onBack:()=>o(a-1),next:u.next},`k-${t.updatedAt}`),t.working!==l&&l===`review`&&(0,Y.jsx)(Dn,{v:t,busy:s,onNext:f,onBack:()=>o(a-1),next:u.next},`r-${t.updatedAt}`),l===`try`&&(0,Y.jsx)(On,{v:t})]})]})}function vn({children:e}){return(0,Y.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,Y.jsx)(nn,{}),(0,Y.jsx)(`main`,{className:F(mt,`max-w-[920px] flex-auto gap-6`),children:e})]})}function yn({v:e,at:t,onGo:n}){return(0,Y.jsx)(`nav`,{"aria-label":`Steps`,children:(0,Y.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,Y.jsxs)(`li`,{className:`flex items-center gap-1`,children:[(0,Y.jsxs)(`button`,{type:`button`,disabled:!a,"aria-current":o?`step`:void 0,onClick:()=>n(i),className:F(`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,Y.jsx)(`span`,{"aria-hidden":`true`,className:F(`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,Y.jsx)(C,{size:12,strokeWidth:3}):i+1}),gn[r.id].label]}),i<e.steps.length-1&&(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`h-px w-4 bg-line`})]},r.id)})})})}function bn({busy:e,onBack:t,next:n,onNext:r,disabled:i,aside:a}){let o=n.startsWith(`Save`);return(0,Y.jsxs)(`div`,{className:`sticky bottom-0 flex flex-wrap items-center gap-4 border-t border-line-soft bg-bg py-4`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px]`,children:a}),t&&(0,Y.jsxs)(H,{variant:`ghost`,disabled:e,onClick:t,children:[(0,Y.jsx)(fe,{"aria-hidden":`true`}),`Back`]}),(0,Y.jsxs)(H,{variant:`primary`,disabled:e||i,onClick:r,"data-tip":n,children:[o?(0,Y.jsx)(C,{"aria-hidden":`true`}):(0,Y.jsx)(N,{"aria-hidden":`true`}),o?`Save`:`Next`]})]})}function xn({on:e,label:t,why:n,recommended:r,onToggle:i}){return(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":e,onClick:i,className:F(`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,Y.jsx)(`span`,{"aria-hidden":`true`,className:F(`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,Y.jsx)(C,{size:12,strokeWidth:3})}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-[13px] font-medium text-ink`,children:[t,r&&(0,Y.jsx)(U,{tone:`running`,icon:!1,children:`Recommended`})]}),n&&(0,Y.jsx)(`span`,{className:`text-[13px] text-muted`,children:n})]})]})}function Sn({v:e,busy:t,onNext:n,next:r}){let[i,a]=(0,J.useState)(()=>Object.fromEntries(e.questions.map(e=>[e.id,e.answer]))),[o,s]=(0,J.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,Y.jsxs)(Y.Fragment,{children:[e.questions.map(e=>{let t=e.assumed&&!o.includes(e.id);return(0,Y.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 rounded-[14px] card border p-4`,children:[(0,Y.jsx)(`legend`,{className:`sr-only`,children:e.text}),(0,Y.jsx)(`span`,{className:`text-[16px] font-semibold`,children:e.text}),t?(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm text-ink-2`,children:[(0,Y.jsx)(W,{icon:m,size:16,className:`text-pass`}),e.assumed,!(i[e.id]||[]).every(t=>e.assumed?.includes(t))&&(0,Y.jsxs)(`span`,{className:`text-muted`,children:[`(`,i[e.id]?.join(`, `),`)`]}),(0,Y.jsx)(H,{size:`sm`,variant:`ghost`,onClick:()=>s([...o,e.id]),"aria-label":`Change the answer`,"data-tip":`Change the answer`,children:(0,Y.jsx)(l,{"aria-hidden":`true`})})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`text-[13px] text-muted`,children:e.why}),(0,Y.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:e.options.map(t=>(0,Y.jsx)(xn,{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,Y.jsx)(bn,{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,Y.jsx)(`span`,{className:`text-fail`,children:`Add a test environment in Settings first: an agent needs one to work in.`}):void 0})]})}var Cn={ready:{icon:m,label:`Ready`,tone:`text-pass`},partial:{icon:_,label:`Partly set up`,tone:`text-warn`},needs_setup:{icon:O,label:`Not set up here yet`,tone:`text-muted`}};function wn({v:e,busy:t,onNext:n,onBack:r,next:o}){let[s,c]=(0,J.useState)(()=>e.plan.filter(e=>e.on).map(e=>e.capability)),[l,u]=(0,J.useState)(!1),d=s.map(t=>e.plan.find(e=>e.capability===t)).filter(Boolean),f=e.plan.filter(e=>!s.includes(e.capability));return(0,Y.jsxs)(Y.Fragment,{children:[e.planSteps&&e.planSteps.length>0&&(0,Y.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,Y.jsxs)(`li`,{className:F(`flex items-start gap-4 px-4 py-4`,n>0&&`border-t border-line-soft`),children:[(0,Y.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,Y.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-[16px] font-semibold`,children:t.title}),(0,Y.jsx)(`span`,{className:`text-[13px] text-ink-2`,children:t.why}),t.without&&(0,Y.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[`Without it: `,t.without]}),(0,Y.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,Y.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,Y.jsx)(zt,{icon:ne,title:`What it uses`,level:3,className:`mt-2`}),(0,Y.jsx)(`ol`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:d.map((e,t)=>{let n=Cn[e.state];return(0,Y.jsxs)(`li`,{className:`flex items-start gap-4 rounded-[14px] card border p-4`,children:[(0,Y.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,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-[16px] font-semibold`,children:e.title}),e.why&&(0,Y.jsx)(`span`,{className:`text-[13px] text-ink-2`,children:e.why}),(0,Y.jsx)(`span`,{className:`line-clamp-2 text-[13px] text-muted`,children:e.summary}),(0,Y.jsxs)(`span`,{className:F(`flex items-center gap-2 text-[13px]`,n.tone),children:[(0,Y.jsx)(W,{icon:n.icon,size:14}),n.label,e.state!==`ready`&&e.gaps.length?`: ${e.gaps.join(`; `)}`:``]})]}),(0,Y.jsx)(H,{variant:`icon`,size:`icon`,"aria-label":`Leave out ${e.title}`,"data-tip":`Leave out ${e.title}`,onClick:()=>c(s.filter(t=>t!==e.capability)),children:(0,Y.jsx)(a,{"aria-hidden":`true`})})]},e.capability)})}),l?(0,Y.jsx)(G,{id:`build-add`,icon:i,title:`What else should it do?`,level:3,className:`rounded-[14px] card border p-4`,children:(0,Y.jsx)(`ul`,{className:`m-0 grid list-none grid-cols-1 gap-2 p-0 sm:grid-cols-2`,children:f.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>c([...s,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,Y.jsx)(i,{size:16,"aria-hidden":`true`,className:`mt-1 flex-none text-muted`}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Y.jsx)(`span`,{className:`text-[13px] font-medium`,children:e.title}),(0,Y.jsx)(`span`,{className:`line-clamp-2 text-[13px] text-muted`,children:e.summary})]})]})},e.capability))})}):(0,Y.jsxs)(H,{size:`sm`,className:`self-start`,onClick:()=>u(!0),"data-tip":`Add something it should also do`,children:[(0,Y.jsx)(i,{"aria-hidden":`true`}),`Add`]}),(0,Y.jsx)(bn,{busy:t,onBack:r,next:o,onNext:()=>n({capabilities:s}),disabled:!s.length})]})}function X({text:e,help:t,on:n,onChange:r,locked:i}){return(0,Y.jsxs)(`div`,{className:`flex items-start gap-4 border-t border-line-soft py-4 first:border-t-0`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-[13px] text-ink`,children:e}),(t||i)&&(0,Y.jsx)(`span`,{className:`text-[13px] text-muted`,children:i||t})]}),i?(0,Y.jsx)(xe,{size:18,"aria-label":`Always`,className:`mt-1 flex-none text-muted`}):(0,Y.jsx)(tn,{checked:n,onChange:e=>r?.(e),label:e})]})}function Tn({v:e,busy:t,onNext:n,onBack:r,next:i}){let a=e.boundaries,[o,s]=(0,J.useState)(a.environments),[c,l]=(0,J.useState)(a.actions),[u,d]=(0,J.useState)(a.approve),[f,p]=(0,J.useState)(a.shell),[m,h]=(0,J.useState)(a.repository),[g,_]=(0,J.useState)(a.unattended),[v,y]=(0,J.useState)(a.trust||[]),[b,x]=(0,J.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)),ee=e.plan.filter(e=>e.on&&e.capability.startsWith(`system:`)),w=(e,t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],T=e=>c.includes(e),E=(e,t)=>l(t?[...new Set([...c,e])]:c.filter(t=>t!==e)),D=(e,t)=>d(t?[...new Set([...u,e])]:u.filter(t=>t!==e)),te=o.join(` and `)||`its environments`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 rounded-[14px] card border p-4`,children:[(0,Y.jsx)(`legend`,{className:`sr-only`,children:`Where it works`}),(0,Y.jsx)(`span`,{className:`text-[16px] font-semibold`,children:`Where it works`}),(0,Y.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,Y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,Y.jsx)(tt,{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,Y.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,Y.jsxs)(`section`,{"aria-labelledby":`build-may`,className:`flex flex-col rounded-[14px] card border px-4 py-1`,children:[(0,Y.jsx)(`h2`,{id:`build-may`,className:`sr-only`,children:`What it may do`}),(0,Y.jsx)(X,{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,Y.jsx)(X,{text:`Run tests and apps in ${te}`,help:`Browser runs, tests, API calls and database queries.`,on:T(`run`),onChange:e=>E(`run`,e)}),e.needs?.run&&T(`run`)&&(0,Y.jsx)(X,{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=>D(`run`,e)}),e.needs?.run&&T(`run`)&&S&&(0,Y.jsx)(X,{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,Y.jsx)(X,{text:`Change test assets on this computer`,help:`Regression packs, API contracts, page memory, recordings. Off unless its job is to make them.`,on:T(`change`),onChange:e=>E(`change`,e)}),T(`change`)&&(0,Y.jsx)(X,{text:`Ask me before each change`,on:u.includes(`change`),onChange:e=>D(`change`,e)}),e.needs?.external&&(0,Y.jsx)(X,{text:`Change other systems as you asked`,help:`Work items or the team's channel, as you chose.`,on:T(`external`),onChange:e=>E(`external`,e)}),T(`external`)&&(0,Y.jsx)(X,{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,Y.jsx)(X,{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&&E(`change`,!0))}),e.needs?.repository&&m===`write`&&(0,Y.jsx)(X,{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,Y.jsx)(X,{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,Y.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 rounded-[14px] card border p-4`,children:[(0,Y.jsx)(`legend`,{className:`sr-only`,children:`What it may do alone`}),(0,Y.jsxs)(`span`,{className:`text-[16px] font-semibold`,children:[`When it runs `,e.schedule.toLowerCase(),`, with nobody watching`]}),(0,Y.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,Y.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:[T(`run`)&&(0,Y.jsx)(xn,{on:g.includes(`run`),label:`Run tests and apps`,why:`Recommended: what it is there to do.`,recommended:!0,onToggle:()=>_(w(g,`run`))}),T(`change`)&&(0,Y.jsx)(xn,{on:g.includes(`change`),label:`Change test assets`,onToggle:()=>_(w(g,`change`))}),m===`write`&&v.includes(`coding`)&&(0,Y.jsx)(xn,{on:g.includes(`coding`),label:`Write or heal tests`,why:`The coding agent, when its test project names no address outside its environments.`,onToggle:()=>_(w(g,`coding`))}),ee.map(e=>(0,Y.jsx)(xn,{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:()=>_(w(g,`${e.capability.slice(7)}_*`))},e.capability))]})]}),(0,Y.jsx)(bn,{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 En({v:e,busy:t,onNext:n,onBack:r,next:i}){let a=e.knowledge,[o,s]=(0,J.useState)(a.files.filter(e=>e.on).map(e=>e.file)),[c,l]=(0,J.useState)(a.skills.filter(e=>e.on).map(e=>e.name)),[u,d]=(0,J.useState)(a.notes),f=(e,t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],p=e=>e.toSorted((e,t)=>Number(!!t.why)-Number(!!e.why));return(0,Y.jsxs)(Y.Fragment,{children:[(a.files.length>0||a.skills.length>0)&&(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:[p(a.files).map(e=>(0,Y.jsx)(xn,{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,Y.jsx)(xn,{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,Y.jsxs)(`label`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[16px] font-semibold`,children:`Anything else it should know?`}),(0,Y.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,Y.jsx)(Xe,{rows:5,value:u,maxLength:2e4,onChange:e=>d(e.target.value),placeholder:`A declined card shows “Payment failed” and keeps the basket.`})]}),(0,Y.jsx)(bn,{busy:t,onBack:r,next:i,onNext:()=>n({files:o,skills:c,notes:u})})]})}function Dn({v:e,busy:t,onNext:n,onBack:r,next:i}){let a=e.review,[o,s]=(0,J.useState)(a.name),[c,l]=(0,J.useState)(a.id),[u,d]=(0,J.useState)(a.description),[f,p]=(0,J.useState)(a.icon||``),[m,h]=(0,J.useState)(a.starters[0]?.text||e.goal),[g,_]=(0,J.useState)(a.model||``),[v,y]=(0,J.useState)(a.maxTokens?String(a.maxTokens):``),[b,x]=(0,J.useState)(a.maxMinutes?String(a.maxMinutes):``),S=[v&&!(Number.isInteger(Number(v))&&Number(v)>=1e3&&Number(v)<=1e8)?`The budget per run is a whole number of tokens, from 1,000 to 100,000,000.`:``,b&&!(Number.isInteger(Number(b))&&Number(b)>=1&&Number(b)<=1440)?`The time limit per run is a whole number of minutes, from 1 to 1440.`:``,g&&!(e.models||[]).some(e=>e.name===g)?`${g} is no longer in llms.json: pick another model, or ForgeQE's choice.`:``].filter(Boolean).join(` `),C={...g?{model:g}:{},...v?{maxTokens:Math.round(Number(v))}:{},...b?{maxMinutes:Math.round(Number(b))}:{}},ee=e.plan.filter(e=>e.on),w=e.boundaries,T=e.knowledge,E=[[`It works in`,w.environments.join(`, `)],[`It does`,ee.map(e=>e.title).join(`; `)],[`It may`,[w.actions.includes(`run`)?`run tests and apps${w.approve.includes(`run`)?` (asking you first)`:``}`:``,w.actions.includes(`change`)?`change test assets`:``,w.actions.includes(`external`)?`change other systems${(w.trust||[]).includes(`external`)?` (without asking)`:` (asking you first)`}`:``,w.repository===`write`?`write or heal tests${(w.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${w.unattended.length?`; alone it may ${w.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`],...w.shell?[[`Shell`,`yes, a person approves each command`]]:[],[`It knows`,[...T.files.filter(e=>e.on).map(e=>e.title),...T.skills.filter(e=>e.on).map(e=>e.name),...T.notes.trim()?[`your notes`]:[]].join(`, `)||`nothing extra`]];return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Name`}),(0,Y.jsx)(V,{value:o,maxLength:60,onChange:e=>s(e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Id`}),(0,Y.jsx)(V,{value:c,maxLength:40,spellCheck:!1,disabled:!!e.saved,onChange:e=>l(e.target.value.toLowerCase())})]})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`What it is for`}),(0,Y.jsx)(`span`,{className:`text-[13px] text-muted`,children:`One line. Atlas reads it to know when to hand it work.`}),(0,Y.jsx)(V,{value:u,maxLength:300,onChange:e=>d(e.target.value)})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Icon`}),(0,Y.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,Y.jsx)(dn,{value:f,onChange:p})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-3`,children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Budget per run`}),(0,Y.jsx)(`span`,{className:`text-[13px] text-muted`,children:`The most model tokens one run may use, 1,000 or more; it stops there. Empty: no limit.`}),(0,Y.jsx)(V,{type:`number`,min:1e3,step:1e3,value:v,placeholder:`No limit`,onChange:e=>y(e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Time limit per run`}),(0,Y.jsx)(`span`,{className:`text-[13px] text-muted`,children:`In minutes, 1 to 1440. Empty: no limit when someone is watching, 120 when nobody is (a schedule, a trigger, another agent).`}),(0,Y.jsx)(V,{type:`number`,min:1,max:1440,value:b,placeholder:`Minutes`,onChange:e=>x(e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Model`}),(0,Y.jsx)(`span`,{className:`text-[13px] text-muted`,children:`The model profile of llms.json its runs use.`}),(0,Y.jsxs)(B,{value:g,onChange:e=>_(e.target.value),children:[(0,Y.jsx)(`option`,{value:``,children:`ForgeQE's choice`}),(e.models||[]).map(e=>(0,Y.jsxs)(`option`,{value:e.name,children:[e.name,` (`,e.model,`)`]},e.name)),g&&!(e.models||[]).some(e=>e.name===g)&&(0,Y.jsxs)(`option`,{value:g,children:[g,` (not in llms.json)`]})]})]})]}),S&&(0,Y.jsx)(`p`,{role:`alert`,className:`m-0 text-sm text-fail`,children:S}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Its first request`}),(0,Y.jsx)(V,{value:m,maxLength:500,onChange:e=>h(e.target.value)})]}),(0,Y.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:E.map(([e,t])=>(0,Y.jsxs)(`div`,{className:`contents`,children:[(0,Y.jsx)(`dt`,{className:`text-muted`,children:e}),(0,Y.jsx)(`dd`,{className:`m-0 text-ink [overflow-wrap:anywhere]`,children:t})]},e))}),e.advice.filter(e=>e.blocking).length>0&&(0,Y.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,Y.jsxs)(`li`,{className:`flex flex-col gap-1 rounded-[12px] bg-warn-soft px-4 py-4 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-warn`,children:e.about}),(0,Y.jsx)(`span`,{className:`text-[13px] text-ink-2`,children:e.fix})]},t))}),(0,Y.jsx)(bn,{busy:t,onBack:r,next:e.saved?`Save the changes`:i,onNext:()=>n({name:o,id:c,description:u,icon:f,starters:[{label:`Run it now`,text:m}],...C}),disabled:!o.trim()||!c.trim()||!!S,aside:e.saved?(0,Y.jsxs)(`a`,{href:M(`agents`,`custom`,e.saved,`edit`),className:`inline-flex items-center gap-2`,children:[(0,Y.jsx)(we,{size:14,"aria-hidden":`true`}),`Open every setting`]}):(0,Y.jsxs)(H,{size:`sm`,variant:`ghost`,disabled:t||!o.trim()||!c.trim()||!!S,onClick:()=>n({name:o,id:c,description:u,icon:f,starters:[{label:`Run it now`,text:m}],...C},!0),"data-tip":`Save it as a draft, then open every setting`,children:[(0,Y.jsx)(we,{"aria-hidden":`true`}),`Save and open every setting`]})})]})}function On({v:e}){let t=e.saved,[n,r]=(0,J.useState)(e.review?.starters[0]?.text||e.goal),[i,a]=(0,J.useState)(``),[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(``),[u,d]=(0,J.useState)(!1),f=async()=>{s(!0);try{let{id:e}=await Je.start(n.trim(),{agent:t,try:!0});location.hash=M(`chats`,e)}catch(e){l(e.message),s(!1)}},p=async()=>{s(!0),l(``);try{await R.act(t,`approve`,{confirm:i,note:`Made with the agent builder`}),d(!0)}catch(e){l(e.message)}finally{s(!1)}};return u?(0,Y.jsxs)(`div`,{className:`flex flex-col items-start gap-4 rounded-[14px] bg-pass-soft px-4 py-4`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-2 text-[16px] font-semibold text-pass`,children:[(0,Y.jsx)(m,{size:18,"aria-hidden":`true`}),P(e.review?.name||`agent`,!0),` is ready.`]}),(0,Y.jsx)(`span`,{className:`text-sm text-ink-2`,children:`You, your team and Atlas can hand it work now.`}),(0,Y.jsxs)(`a`,{href:M(`agents`,`custom`,t),className:F(Qe({variant:`primary`,size:`sm`}),`no-underline`),"data-tip":`Open the agent`,children:[(0,Y.jsx)(N,{"aria-hidden":`true`}),`Open`]})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(G,{id:`build-try`,icon:v,title:`1. Try it on a real request`,level:3,className:`rounded-[14px] card border p-4`,children:[(0,Y.jsx)(Xe,{rows:2,"aria-label":`What to try`,value:n,onChange:e=>r(e.target.value)}),(0,Y.jsxs)(H,{variant:`primary`,size:`sm`,className:`self-start`,disabled:o||!n.trim(),onClick:()=>void f(),"data-tip":`Try it in a chat`,children:[(0,Y.jsx)(v,{"aria-hidden":`true`}),`Try`]}),(0,Y.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,Y.jsxs)(G,{id:`build-approve`,icon:m,title:`2. Approve it`,level:3,className:`rounded-[14px] card border p-4`,children:[(0,Y.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[`Only an approved version runs. Type its id to confirm: `,t]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(V,{"aria-label":`Type ${t} to confirm`,className:`w-[260px]`,value:i,spellCheck:!1,autoComplete:`off`,onChange:e=>a(e.target.value),placeholder:t}),(0,Y.jsxs)(H,{size:`sm`,disabled:o||i!==t,onClick:()=>void p(),children:[(0,Y.jsx)(m,{"aria-hidden":`true`}),`Approve`]})]})]}),c&&(0,Y.jsx)(`p`,{role:`alert`,className:`m-0 text-sm text-fail [overflow-wrap:anywhere]`,children:c}),(0,Y.jsx)(`a`,{href:M(`agents`,`custom`,t),className:`self-start text-[13px]`,children:`Open its page`})]})}function kn({text:e,file:t}){let n=e.replace(/\n$/,``).split(`
2
+ `);return(0,Y.jsx)(G,{id:`ca-manifest`,icon:he,title:(0,Y.jsxs)(Y.Fragment,{children:[`Its manifest, as it is in `,(0,Y.jsx)(`span`,{className:`font-mono`,children:t})]}),description:`Read only: fix it in that file, or start a new agent from the form and delete this one.`,className:`w-full text-left`,children:(0,Y.jsx)(`pre`,{tabIndex:0,"aria-label":`The manifest in ${t}`,className:`m-0 max-h-[50vh] overflow-auto rounded-[12px] card border px-4 py-4 font-mono text-[13px] leading-relaxed`,children:n.map((e,t)=>(0,Y.jsxs)(`span`,{className:`block pl-12 -indent-12 whitespace-pre-wrap [overflow-wrap:anywhere]`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`mr-4 inline-block w-8 text-right text-muted select-none`,children:t+1}),e]},t))})})}function An(e,t){let n=e.endedAt?Date.parse(e.endedAt)-Date.parse(e.startedAt):NaN,r=Number.isFinite(n)&&n>=0?n>=6e4?`${Math.floor(n/6e4)} min`:`${Math.max(1,Math.floor(n/1e3))}s`:``;return[e.model||``,e.usage?t.usage(e.usage):``,r,e.cost?`about ${t.money(e.cost.amount,e.cost.currency)}`:``].filter(Boolean).join(` · `)}var jn=[`text`,`environment`,`choice`],Mn=/[\u0000-\u001f\u007f\u2028\u2029]/,Nn=/\{([a-z][a-z0-9_]{0,31})\}/g;function Pn(e){return[...new Set([...e.matchAll(Nn)].map(e=>e[1]))]}function Fn(e,t,n){return typeof t!=`string`||!t.trim()?`${e.label} needs a value.`:t.length>200?`${e.label} is longer than 200 characters.`:Mn.test(t)?`${e.label} must be one line of text.`:t.trim().startsWith(`-`)?`${e.label} cannot start with a dash.`:e.kind===`environment`&&!n.includes(t)?`${e.label}: "${t.slice(0,40)}" is not one of its environments.`:e.kind===`choice`&&!(e.options||[]).includes(t)?`${e.label}: "${t.slice(0,40)}" is not one of its options.`:``}function In(e,t,n,r){let i=[];for(let a of Pn(e)){let e=t.find(e=>e.name===a);if(!e)i.push(`{${a}} is not one of its inputs.`);else{let t=Fn(e,Object.hasOwn(n,a)?n[a]:void 0,r);t&&i.push(t)}}if(i.length)throw Error(i.join(` `));let a=e.replace(Nn,(e,t)=>n[t].trim());if(a.trim().startsWith(`-`))throw Error(`The request cannot start with a dash.`);return a}var Ln=(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 Rn=`https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files-v1.0`,zn=Object.freeze([{file:`kokoro-onnx/kokoro-v1.0.onnx`,url:`${Rn}/kokoro-v1.0.onnx`,bytes:325532387,sha256:`7d5df8ecf7d4b1878015a32686053fd0eebe2bc377234608764cc0ef3636a6c5`},{file:`kokoro-onnx/voices-v1.0.bin`,url:`${Rn}/voices-v1.0.bin`,bytes:28214398,sha256:`bca610b8308e8d99f32e6fe4197e7ec01679264efed0cac9140fe9c29f1fbf7d`}]),Bn=`https://huggingface.co/Systran/faster-whisper-base.en/resolve/3d3d5dee26484f91867d81cb899cfcf72b96be6c`,Vn=Object.freeze([{file:`whisper-base.en/config.json`,url:`${Bn}/config.json`,bytes:2227,sha256:`f3bc3821e9fc76a27bae538e11ae5b677dcdd352b4600429ce7951d398569aeb`},{file:`whisper-base.en/tokenizer.json`,url:`${Bn}/tokenizer.json`,bytes:2128466,sha256:`929c5252409436dce1b38a75d1abbcb5e132d170d8e324e4e04ed915fa2d22df`},{file:`whisper-base.en/vocabulary.txt`,url:`${Bn}/vocabulary.txt`,bytes:422309,sha256:`ff77588746d3a2595d32ab5b69ffd7b95ce2441ac57533cb66fc3eb575a115cf`},{file:`whisper-base.en/model.bin`,url:`${Bn}/model.bin`,bytes:145216508,sha256:`2a166925539a16005f14ff328359f9b9adb9dc4fb631bb3b227526862e93e2ef`}]),Hn=Object.freeze(Ln(`onnx-community/silero-vad`,`e71cae966052b992a7eca6b17738916ce0eca4ec`,`silero-vad`,[[`onnx/model.onnx`,2243022,`a4a068cd6cf1ea8355b84327595838ca748ec29a25bc91fc82e6c299ccdc5808`]])),Un=Object.freeze(Ln(`pipecat-ai/smart-turn-v3`,`f766f81d3cfdf7737ac64aad813d91bbfd56bf93`,`smart-turn-v3`,[[`smart-turn-v3.2-cpu.onnx`,8679182,`2bb026316b14a660486a75b1733cd3fbab8c2fd0314dc9af7be49f8cca967e4f`]])),Wn=Object.freeze([...Hn,...Un]);Object.freeze([...zn,...Vn,...Wn]),Object.freeze({en:Object.freeze([`af_heart`,`am_michael`])}),Object.freeze({en:`af_heart`});var Gn=Object.freeze([`light`,`deep`]);Object.freeze({en:{light:`af_heart`,deep:`am_michael`}});var Kn=[`suite_failed`,`suite_passed`,`job_failed`,`job_recovered`,`eval_failed`,`pr_opened`,`pr_updated`,`push`],qn=[`pr_opened`,`pr_updated`,`push`],Jn=[`number`,`text`,`yes_no`],Yn={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 Xn(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^[^a-z]+/,``).replace(/(?<!-)-+$/,``).slice(0,40).replace(/(?<!-)-+$/,``)}var Zn={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.`}},Qn=6,$n={number:`A number`,text:`One line of text`,yes_no:`Yes or no`},er=qn,tr={suite_failed:`A suite failed`,suite_passed:`A suite passed`,job_failed:`A schedule failed`,job_recovered:`A schedule recovered`,eval_failed:`An eval failed`,pr_opened:`A pull request opened`,pr_updated:`A pull request updated`,push:`A branch pushed to`},nr={text:`Text`,environment:`One of its environments`,choice:`One of a list`},rr={read:`Read`,run:`Run`,change:`Change files`,external:`Change other systems`,schedule:`Schedule work`};function ir(e){let t=e.schedule?.with;if(!e.schedule||!t)return e;let n=new Set(Pn(e.schedule.request)),r=Object.fromEntries(Object.entries(t).filter(([t,r])=>{let i=(e.inputs||[]).find(e=>e.name===t);return!i||!n.has(t)?!1:i.kind===`choice`?(i.options||[]).map(e=>e.trim()).includes(r.trim()):i.kind!==`environment`||e.scope.environments.includes(r)}));if(Object.keys(r).length===Object.keys(t).length)return e;let{with:i,...a}=e.schedule;return{...e,schedule:{...a,...Object.keys(r).length?{with:r}:{}}}}function ar(e,t){let n=e.permissions.deny||[];if(!n.length)return e;let r=new Set(t.flatMap(e=>(e.usable||[]).map(e=>e.name))),i=new Set(t.filter(t=>e.scope.capabilities.includes(t.id)).flatMap(e=>(e.usable||[]).map(e=>e.name))),a=n.filter(e=>!r.has(e)||i.has(e));return a.length===n.length?e:{...e,permissions:{...e.permissions,deny:a}}}var or={ready:{icon:m,label:`Ready`,cls:`text-pass`},partial:{icon:_,label:`Partly set up`,cls:`text-warn`},needs_setup:{icon:O,label:`Needs setup`,cls:`text-muted`}},sr=e=>e?e.cron===void 0?`every`:`cron`:``,cr=e=>e.replace(/\s+MCP\s*$/i,``);function lr(e,t,n=[]){let r=e.permissions,i=r.repository===`write`?n.filter(e=>(r.trust||[]).includes(e)):[],a=[...r.actions.includes(`run`)?[{key:`run`,ids:[`run`],label:`Run tests and apps`}]:[],...r.actions.includes(`change`)?[{key:`change`,ids:[`change`],label:`Change test assets`}]:[],...i.length?[{key:`coding`,ids:i,label:`Write or heal tests`}]:[],...(e.scope.systems||[]).map(e=>({key:`${e}_*`,ids:[`${e}_*`],label:`Change ${cr(t.find(t=>t.name===e)?.label||e)}`}))],o=new Set(a.flatMap(e=>e.ids)),s={external:`Change other systems`,schedule:`Schedule work`};return[...a,...(r.unattended||[]).filter(e=>!o.has(e)).map(e=>({key:e,ids:[e],label:s[e]||e.replace(/_\*$/,` (all its tools)`).replace(/_/g,` `)}))]}function ur(e,t=[],n=t){let r=e.permissions,i=new Set(e.scope.systems||[]),a=new Set([`run`,`change`,`external`,`schedule`]),o=(r.unattended||[]).filter(e=>a.has(e)?r.actions.includes(e):e.endsWith(`_*`)?i.has(e.slice(0,-2)):!t.includes(e)||n.includes(e)&&r.repository===`write`&&(r.trust||[]).includes(e));return o.length===(r.unattended||[]).length?e:{...e,permissions:{...r,unattended:o}}}var Z=(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,Y.jsxs)(`label`,{className:F(`flex items-start gap-2 text-sm`,n?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,Y.jsx)(Lt,{checked:e,disabled:n,onCheckedChange:t,className:`mt-1`}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Y.jsx)(`span`,{className:`text-ink`,children:r}),i&&(0,Y.jsx)(`span`,{className:`text-[13px] text-muted`,children:i})]})]})}function dr({id:e,label:t,options:n,onChange:r,placeholder:i=`checkout, search`,max:a=12,mono:o=!1}){let[s,c]=(0,J.useState)(n.join(`, `)),l=e=>[...new Set(e.split(`,`).map(e=>e.trim()).filter(Boolean))].slice(0,a);return(0,J.useEffect)(()=>{l(s).join(`\0`)!==n.join(`\0`)&&c(n.join(`, `))},[n.join(`\0`)]),(0,Y.jsx)(V,{id:e,"aria-label":t,className:F(`min-w-0 flex-[1_1_200px]`,o&&`font-mono`),value:s,placeholder:i,maxLength:a*122,spellCheck:!o,onChange:e=>{let t=o?e.target.value.toLowerCase():e.target.value;c(t),r(l(t))}})}function fr({id:e,input:t,environments:n,value:r,onChange:i}){let a=t.kind===`environment`?n:t.kind===`choice`?t.options||[]:null;return a?(0,Y.jsxs)(B,{id:e,value:r,className:`w-[200px]`,onChange:e=>i(e.target.value),children:[(0,Y.jsx)(`option`,{value:``,children:`Pick one`}),a.map(e=>(0,Y.jsx)(`option`,{value:e,children:e},e))]}):(0,Y.jsx)(V,{id:e,value:r,maxLength:200,className:`w-[200px]`,onChange:e=>i(e.target.value)})}function pr({id:e,template:t}){let n=!e,[r,o]=(0,J.useState)(n&&!t?Yn:null),[c,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(null),[f,p]=(0,J.useState)(``),[h,g]=(0,J.useState)(``),[_,v]=(0,J.useState)(null),[b,ee]=(0,J.useState)([]),[D,te]=(0,J.useState)([]),[O,k]=(0,J.useState)(!1),[A,ie]=(0,J.useState)(!1),[ae,oe]=(0,J.useState)(!1);(0,J.useEffect)(()=>{R.choices().then(d,e=>p(e.message)),t&&R.template(t).then(e=>{l(e),o({...Yn,...e.fields,scope:{...Yn.scope,...e.fields.scope},permissions:{...Yn.permissions,...e.fields.permissions}}),oe(!0)},e=>p(e.message)),e&&R.view(e).then(t=>(g(t.approvedVersion||``),t.form?o({...Yn,...t.form,runtime:{...t.form.runtime}}):t.manifestText===void 0?p(`${e} has no manifest the editor can read (it may have been removed). Its page says what it has.`):(v({text:t.manifestText,file:t.manifestFile||`.forgeqe/agents/${e}.yaml`,problems:t.problems.working}),p(`${e}'s manifest is not one the editor can read. Fix it in ${t.manifestFile||`.forgeqe/agents/${e}.yaml`}; what is wrong, and the file as it is, are below.`))),e=>p(e.message))},[e,t]);let ce=(0,J.useRef)(0);(0,J.useEffect)(()=>{if(!r)return;let e=++ce.current;k(!0);let t=setTimeout(()=>{R.validate(ir(r)).then(t=>e===ce.current&&(ee(t.problems||[]),te(t.advice||[]),k(!1)),t=>e===ce.current&&(ee([t.message]),k(!1)))},350);return()=>clearTimeout(t)},[r]);let j=e=>o(t=>t&&{...t,...e}),de=u?.coding||[],fe=e=>de.filter(t=>(u?.capabilities||[]).some(n=>e.scope.capabilities.includes(n.id)&&n.tools.includes(t))),pe=e=>ar(ur(e,de,fe(e)),u?.capabilities||[]),me=e=>o(t=>t&&pe({...t,scope:{...t.scope,...e}})),he=e=>o(t=>t&&{...t,voice:e?{sound:e}:void 0}),ge=e=>o(t=>t&&pe({...t,permissions:{...t.permissions,...e}})),_e=e=>o(t=>{if(!t)return t;let n=t.schedule?.request??t.starters[0]?.text??``;if(!e)return{...t,schedule:void 0,...(t.triggers||[]).length?{}:{permissions:{...t.permissions,unattended:[]}}};let r=t.schedule?.with?{with:t.schedule.with}:{};return{...t,schedule:e===`every`?{every:t.schedule?.every??`1d`,request:n,...r}:{cron:t.schedule?.cron??`0 7 * * 1-5`,request:n,...r}}}),ve=e=>o(t=>t?.schedule?{...t,schedule:{...t.schedule,...e}}:t),ye=r?.schedule,we=[...ye&&sr(ye)===`every`&&!ye.every?.trim()?[`Say how often it runs: 15m, 1h, 1d.`]:[],...ye&&sr(ye)===`cron`&&!ye.cron?.trim()?[`Give its cron schedule: 0 7 * * 1-5.`]:[],...ye&&!ye.request.trim()?[`Say what it is asked each time it runs by itself.`]:[],...(r?.triggers||[]).flatMap((e,t)=>e.request.trim()?[]:[`Say what trigger ${t+1} asks it (${tr[e.on].toLowerCase()}).`])],N=[...we,...b],Te=(0,J.useMemo)(()=>{let e=new Map;for(let t of u?.capabilities||[])e.set(t.area,[...e.get(t.area)||[],t]);return[...e]},[u]),Ee=async()=>{if(r){ie(!0),p(``);try{let t=await R.save(ir(r),n?{create:!0}:{id:e});location.hash=M(`agents`,`custom`,t.id)}catch(e){p(e.message),ie(!1)}}},Ae=e?M(`agents`,`custom`,e):M(`agents`,`custom`,`new`);return(0,Y.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,Y.jsx)(nn,{}),(0,Y.jsxs)(`main`,{className:F(mt,`settings-fields flex-auto gap-2`),children:[(0,Y.jsx)(it,{href:Ae,label:e?`Back to the agent`:`Back to the builder`,className:`mb-2`}),(0,Y.jsx)(`h1`,{className:`m-0 text-[25px] font-semibold tracking-[-0.01em]`,children:n?`New custom agent`:`Edit ${r?.name||e}`}),(0,Y.jsx)(`p`,{className:`m-0 mb-2 text-sm leading-relaxed text-ink-2`,children:n?c?`ForgeQE's ${c.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.`}),f&&(0,Y.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-4 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:f}),c&&u&&(0,Y.jsx)(G,{id:`ca-template`,icon:le,title:(0,Y.jsxs)(Y.Fragment,{children:[`From the `,c.title,` template`]}),level:3,className:`mb-2`,children:(0,Y.jsxs)(`ul`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:[c.systems.length>0&&(0,Y.jsxs)(`li`,{className:`flex flex-col gap-1 rounded-[12px] bg-surface-muted px-4 py-4 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`font-medium text-ink`,children:[`It uses the tools of `,c.systems.map(e=>cr(u?.systems.find(t=>t.name===e)?.label||e)).join(`, `)]}),(0,Y.jsx)(`span`,{className:`text-[13px] text-ink-2`,children:`Through ForgeQE, which checks every call against what this agent may do. Change them under Systems it works with.`})]}),c.notes.map(e=>(0,Y.jsx)(`li`,{className:`flex flex-col gap-1 rounded-[12px] bg-surface-muted px-4 py-4 text-sm`,children:(0,Y.jsx)(`span`,{className:`font-medium text-ink`,children:e})},e))]})}),n&&!t&&(0,Y.jsx)(`p`,{className:`m-0 mb-2 text-sm`,children:(0,Y.jsx)(`a`,{href:M(`agents`,`custom`,`new`),children:`Or say what it should do, and let ForgeQE build it with you`})}),_&&(0,Y.jsxs)(Y.Fragment,{children:[_.problems.length>0&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-[12px] bg-fail-soft px-4 py-4 text-sm text-fail`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Its manifest needs fixing before it can be edited here:`}),(0,Y.jsx)(`ul`,{className:`m-0 list-disc pl-6 [overflow-wrap:anywhere]`,children:_.problems.map((e,t)=>(0,Y.jsx)(`li`,{children:e},t))})]}),(0,Y.jsx)(kn,{text:_.text,file:_.file})]}),!r||!u?!f&&(0,Y.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(q,{first:!0,icon:re,children:`What it is`}),(0,Y.jsx)(K,{label:`Name`,help:`What it does, then “agent”: Checkout guard agent.`,htmlFor:`ca-name`,children:(0,Y.jsx)(V,{id:`ca-name`,value:r.name,maxLength:60,onChange:e=>j({name:e.target.value,...n&&!ae?{id:Xn(e.target.value)}:{}})})}),(0,Y.jsx)(K,{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,Y.jsx)(V,{id:`ca-id`,value:r.id,maxLength:40,disabled:!n,spellCheck:!1,onChange:e=>(oe(!0),j({id:e.target.value.toLowerCase()}))})}),(0,Y.jsx)(K,{label:`Version`,help:`${h?`${h} is approved and runs now. `:``}Raise it for each change you approve: 1.0.0, then 1.1.0. A change saved under a version already approved is raised to the next free one, so each version names one set of settings.`,htmlFor:`ca-version`,children:(0,Y.jsx)(V,{id:`ca-version`,value:r.version,maxLength:14,onChange:e=>j({version:e.target.value})})}),(0,Y.jsx)(K,{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,Y.jsx)(V,{id:`ca-desc`,value:r.description,maxLength:300,onChange:e=>j({description:e.target.value})})}),(0,Y.jsx)(K,{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,Y.jsx)(dn,{id:`ca-icon`,value:r.icon,onChange:e=>j({icon:e})})}),(0,Y.jsx)(K,{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,Y.jsx)(an,{label:`Voice`,value:r.voice?.sound??``,onChange:e=>he(e),options:[{id:``,label:`Default`},...Gn.map(e=>({id:e,label:e[0].toUpperCase()+e.slice(1)}))]})}),(0,Y.jsx)(K,{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,Y.jsx)(Xe,{id:`ca-instr`,rows:5,value:r.instructions,maxLength:8e3,onChange:e=>j({instructions:e.target.value})})}),(0,Y.jsx)(q,{help:`Where its runs, tests and calls may go. In an environment named like production, reads go ahead, runs are asked unless you say otherwise, and every change is approved by a person.`,icon:se,children:`Where it works`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 py-4`,children:[u.environments.length===0&&(0,Y.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`No environments in env.yaml yet. Add them in Settings, Environments.`}),u.environments.map(e=>(0,Y.jsx)(Q,{checked:r.scope.environments.includes(e.name),onChange:t=>me({environments:Z(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,Y.jsx)(q,{help:`ForgeQE's capabilities it may use: their tools, and only theirs. Each says whether it is set up here.`,icon:ne,children:`What it can do`}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-4 py-4`,children:Te.map(([e,t])=>{let n=t.filter(e=>r.scope.capabilities.includes(e.id)).length;return(0,Y.jsxs)(`details`,{open:n>0||void 0,className:`group rounded-[12px] card border px-4 py-2`,children:[(0,Y.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 py-1 text-[13px] font-medium`,children:[(0,Y.jsx)(y,{size:14,"aria-hidden":`true`,className:`flex-none text-muted transition-transform duration-200 group-open:rotate-90`}),(0,Y.jsx)(`span`,{className:`flex-1`,children:e}),(0,Y.jsx)(`span`,{className:`text-[13px] font-normal text-muted tabular-nums`,children:n?`${n} of ${t.length} picked`:`${t.length}`})]}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-2 pt-2 pb-1 pl-6`,children:t.map(e=>{let t=or[e.state];return(0,Y.jsxs)(J.Fragment,{children:[(0,Y.jsx)(Q,{checked:r.scope.capabilities.includes(e.id),onChange:t=>me({capabilities:Z(r.scope.capabilities,e.id,t)}),help:(0,Y.jsxs)(`span`,{className:`flex items-start gap-2`,children:[(0,Y.jsx)(W,{icon:t.icon,size:13,className:F(`mt-1 flex-none`,t.cls)}),(0,Y.jsxs)(`span`,{children:[t.label,e.gaps.length?`: ${e.gaps.join(`; `)}`:``]})]}),children:(0,Y.jsx)(`span`,{"data-tip":e.summary,children:e.title})}),r.scope.capabilities.includes(e.id)&&((e.usable||[]).length>1||(e.usable||[]).some(e=>(r.permissions.deny||[]).includes(e.name)))&&(0,Y.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 border-0 p-0 pl-6`,children:[(0,Y.jsxs)(`legend`,{className:`sr-only`,children:[`Tools of `,e.title,` it uses`]}),(e.usable||[]).map(t=>(0,Y.jsx)(Q,{checked:!(r.permissions.deny||[]).includes(t.name),disabled:!(r.permissions.deny||[]).includes(t.name)&&(e.usable||[]).filter(e=>!(r.permissions.deny||[]).includes(e.name)).length===1,onChange:e=>ge({deny:Z(r.permissions.deny||[],t.name,!e)}),help:(rr[t.action]||t.action)+(!(r.permissions.deny||[]).includes(t.name)&&(e.usable||[]).filter(e=>!(r.permissions.deny||[]).includes(e.name)).length===1?`. Its last tool: untick the capability instead.`:``),children:(0,Y.jsx)(`span`,{className:`font-mono text-[13px]`,children:t.name})},t.name))]})]},e.id)})})]},e)})}),(0,Y.jsx)(q,{help:`ForgeQE's agents it may start: a capability that needs one (a browser run needs WebPilot) is refused without it.`,icon:ke,children:`Agents it may use`}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-2 py-4`,children:u.agents.map(e=>(0,Y.jsx)(Q,{checked:r.scope.agents.includes(e.name),onChange:t=>me({agents:Z(r.scope.agents,e.name,t)}),help:(0,Y.jsx)(`span`,{className:`font-mono text-[13px]`,children:e.name}),children:e.title},e.name))}),(0,Y.jsx)(q,{help:`Your team's other custom agents it may hand a request to. Each runs its approved version within its own limits and this one's, never more; one already working on the request is not handed it again. It needs Hands work on of 1 level or more.`,icon:S,children:`Custom agents it may hand work to`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 py-4`,children:[(u.customAgents||[]).filter(e=>e.id!==r.id).length===0&&(0,Y.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`No other custom agents in this project yet.`}),(u.customAgents||[]).filter(e=>e.id!==r.id).map(e=>(0,Y.jsx)(Q,{checked:(r.scope.customAgents||[]).includes(e.id),onChange:t=>me({customAgents:Z(r.scope.customAgents||[],e.id,t)}),help:(0,Y.jsxs)(`span`,{className:`font-mono text-[13px]`,children:[e.id,e.approved?``:` · not approved yet: it is handed nothing until it is`]}),children:e.name},e.id))]}),(0,Y.jsx)(q,{help:`Other systems' MCP servers this project has set up. It uses their tools through ForgeQE, which checks every call; a change in them is asked unless you lift it under What it may do.`,icon:w,children:`Systems it works with`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 py-4`,children:[u.systems.length===0&&(0,Y.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`None set up yet. Add them in Settings, MCP servers.`}),u.systems.map(e=>(0,Y.jsx)(Q,{checked:(r.scope.systems||[]).includes(e.name),onChange:t=>me({systems:Z(r.scope.systems||[],e.name,t)}),help:e.about.slice(0,160),children:cr(e.label)},e.name))]}),(0,Y.jsx)(q,{help:`Only these are loaded for it.`,icon:Ce,children:`Skills and knowledge`}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 py-4 sm:grid-cols-2`,children:[(0,Y.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 border-0 p-0`,children:[(0,Y.jsx)(`legend`,{className:`mb-1 p-0 text-[13px] font-semibold text-muted`,children:`Skills`}),u.skills.length===0&&(0,Y.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`None in this project yet.`}),u.skills.map(e=>(0,Y.jsx)(Q,{checked:r.scope.skills.includes(e.name),onChange:t=>me({skills:Z(r.scope.skills,e.name,t)}),help:e.about,children:e.name},e.name))]}),(0,Y.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 border-0 p-0`,children:[(0,Y.jsx)(`legend`,{className:`mb-1 p-0 text-[13px] font-semibold text-muted`,children:`Knowledge files`}),u.knowledge.length===0&&(0,Y.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`None in .forgeqe/knowledge yet.`}),u.knowledge.map(e=>(0,Y.jsx)(Q,{checked:r.scope.knowledge.includes(e.file),onChange:t=>me({knowledge:Z(r.scope.knowledge,e.file,t)}),help:e.title===e.file?void 0:e.title,children:e.file},e.file))]})]}),(0,Y.jsx)(q,{help:`Enforced on every call. Ask first: a person approves each such call in the chat. In production, every call is asked.`,icon:xe,children:`What it may do`}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-2 py-4`,children:u.actions.map(e=>(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-6 gap-y-1`,children:[(0,Y.jsx)(`div`,{className:`min-w-0 flex-[1_1_320px]`,children:(0,Y.jsx)(Q,{checked:r.permissions.actions.includes(e),onChange:t=>ge({actions:Z(r.permissions.actions,e,t)}),help:Zn[e]?.help,children:Zn[e]?.label||e})}),(0,Y.jsx)(Q,{checked:e===`external`?!(r.permissions.trust||[]).includes(`external`):r.permissions.approve.includes(e),disabled:!r.permissions.actions.includes(e),onChange:t=>ge(e===`external`?{trust:Z(r.permissions.trust||[],`external`,!t)}:{approve:Z(r.permissions.approve,e,t)}),children:`Ask first`})]},e))}),(0,Y.jsx)(K,{label:`Repository`,help:`Whether it may change files in the repository (with Change files).`,children:(0,Y.jsx)(an,{label:`Repository`,value:r.permissions.repository,onChange:e=>ge({repository:e}),options:[{id:`read`,label:`Read only`},{id:`write`,label:`May change files`}]})}),r.scope.environments.some(e=>u.environments.some(t=>t.name===e&&t.production))&&r.permissions.actions.includes(`run`)&&(0,Y.jsx)(K,{label:`Production`,help:`Reads there go ahead without asking; every change there is approved by a person.`,children:(0,Y.jsx)(Q,{checked:!(r.permissions.production||[]).includes(`run`),onChange:e=>ge({production:e?[]:[`run`]}),children:`Ask before each run`})}),r.permissions.repository===`write`&&(()=>{let e=(u.coding||[]).filter(e=>u.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,Y.jsx)(K,{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,Y.jsx)(Q,{checked:!t,onChange:t=>ge({trust:t?(r.permissions.trust||[]).filter(t=>!e.includes(t)):[...new Set([...r.permissions.trust||[],...e])]}),children:`Ask first`})})})(),(0,Y.jsx)(K,{label:`Shell`,help:`Commands on this computer, and fetching web pages. A person approves each one; ForgeQE's secrets stay out of reach.`,children:(0,Y.jsx)(Q,{checked:r.permissions.shell===!0,onChange:e=>ge({shell:e}),children:`Use the shell`})}),(0,Y.jsx)(K,{label:`Hands work on`,help:`How many levels deep it may give part of a task to a helper.`,htmlFor:`ca-depth`,children:(0,Y.jsxs)(B,{id:`ca-depth`,value:String(r.runtime.maxDelegationDepth),onChange:e=>j({runtime:{...r.runtime,maxDelegationDepth:Number(e.target.value)}}),className:`w-[200px]`,children:[(0,Y.jsx)(`option`,{value:`0`,children:`Never`}),(0,Y.jsx)(`option`,{value:`1`,children:`1 level`}),(0,Y.jsx)(`option`,{value:`2`,children:`2 levels`}),(0,Y.jsx)(`option`,{value:`3`,children:`3 levels`})]})}),(0,Y.jsx)(K,{label:`Budget per run`,help:`The most model tokens one run may use; it stops there. Empty: no limit.`,htmlFor:`ca-budget`,children:(0,Y.jsx)(V,{id:`ca-budget`,type:`number`,min:1e3,step:1e3,className:`w-[200px]`,value:r.runtime.maxTokens??``,placeholder:`No limit`,onChange:e=>{let{maxTokens:t,...n}=r.runtime;j({runtime:{...n,...e.target.value?{maxTokens:Math.max(0,Math.round(Number(e.target.value)))}:{}}})}})}),(0,Y.jsx)(K,{label:`Time limit per run`,help:`In minutes (1 to 1440): the longest one run may take; it stops there. Empty: no limit when someone is watching, 120 minutes when nobody is (a schedule, a trigger, another agent).`,htmlFor:`ca-minutes`,children:(0,Y.jsx)(V,{id:`ca-minutes`,type:`number`,min:1,max:1440,className:`w-[200px]`,value:r.runtime.maxMinutes??``,placeholder:`Minutes`,onChange:e=>{let{maxMinutes:t,...n}=r.runtime;j({runtime:{...n,...e.target.value?{maxMinutes:Math.max(1,Math.round(Number(e.target.value)))}:{}}})}})}),(0,Y.jsx)(K,{label:`Model`,help:`The model profile of llms.json its runs use. ForgeQE's choice: the model ForgeQE's agent would use.`,htmlFor:`ca-model`,children:(0,Y.jsxs)(B,{id:`ca-model`,value:r.runtime.model??``,className:`w-[200px]`,onChange:e=>{let{model:t,...n}=r.runtime;j({runtime:{...n,...e.target.value?{model:e.target.value}:{}}})},children:[(0,Y.jsx)(`option`,{value:``,children:`ForgeQE's choice`}),(u.models||[]).map(e=>(0,Y.jsxs)(`option`,{value:e.name,children:[e.name,` (`,e.model,`)`]},e.name)),r.runtime.model&&!(u.models||[]).some(e=>e.name===r.runtime.model)&&(0,Y.jsxs)(`option`,{value:r.runtime.model,children:[r.runtime.model,` (not in llms.json)`]})]})}),(0,Y.jsx)(q,{help:`On a schedule it runs the approved version with nobody watching: it does alone only what you tick under What it may do alone, and anything else waits for a person.`,icon:Oe,children:`Runs by itself`}),(0,Y.jsx)(K,{label:`When`,children:(0,Y.jsx)(an,{label:`When`,value:sr(r.schedule),onChange:_e,options:[{id:``,label:`Only when asked`},{id:`every`,label:`Every`},{id:`cron`,label:`On a cron schedule`}]})}),(0,Y.jsx)(K,{label:`Tell the team`,help:`How a run with nobody watching (on its schedule, a trigger, or started with --unattended) ended, on the notification channels that take custom agents' runs (Settings, Notifications).`,htmlFor:`ca-notify`,children:(0,Y.jsxs)(B,{id:`ca-notify`,value:r.runtime.notify??`failed`,className:`w-[200px]`,onChange:e=>{let{notify:t,...n}=r.runtime;j({runtime:{...n,...e.target.value===`failed`?{}:{notify:e.target.value}}})},children:[(0,Y.jsx)(`option`,{value:`failed`,children:`When it does not finish`}),(0,Y.jsx)(`option`,{value:`always`,children:`Each time it ends`}),(0,Y.jsx)(`option`,{value:`never`,children:`Never`})]})}),(u.channels||[]).length>0&&(0,Y.jsx)(K,{label:`Its notices go to`,help:`The notification channels its notices go to, each still only for the events it takes (Settings, Notifications). None ticked: every channel that takes them.`,children:(0,Y.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.channels.map(e=>(0,Y.jsx)(Q,{checked:(r.runtime.channels||[]).includes(e.name),onChange:t=>j({runtime:{...r.runtime,channels:Z(r.runtime.channels||[],e.name,t)}}),help:e.on.some(e=>e.startsWith(`agent_`))?void 0:`It takes no custom agent's events: tick them for it in Settings, Notifications.`,children:e.name},e.name))})}),r.schedule&&(0,Y.jsxs)(Y.Fragment,{children:[sr(r.schedule)===`every`?(0,Y.jsx)(K,{label:`Every`,help:`15m, 1h, 1d.`,htmlFor:`ca-every`,children:(0,Y.jsx)(V,{id:`ca-every`,value:r.schedule.every??``,placeholder:`30m`,spellCheck:!1,className:`max-w-[120px] font-mono`,onChange:e=>ve({every:e.target.value})})}):(0,Y.jsx)(K,{label:`Cron`,help:`Five fields, this machine's time: 0 7 * * 1-5 is weekdays at 07:00.`,htmlFor:`ca-cron`,children:(0,Y.jsx)(V,{id:`ca-cron`,value:r.schedule.cron??``,spellCheck:!1,className:`max-w-[180px] font-mono`,onChange:e=>ve({cron:e.target.value})})}),(0,Y.jsx)(K,{label:`Request`,help:`What it is asked each time it runs by itself. {name} uses one of its inputs, filled with the value below.`,htmlFor:`ca-request`,stacked:!0,children:(0,Y.jsx)(V,{id:`ca-request`,value:r.schedule.request,maxLength:500,placeholder:`Run the checkout pack on qa`,onChange:e=>ve({request:e.target.value})})}),Pn(r.schedule.request).map(e=>(r.inputs||[]).find(t=>t.name===e)).filter(e=>!!e).map(e=>(0,Y.jsx)(K,{label:e.label||`{${e.name}}`,help:`The value of {${e.name}} when it runs by itself.`,htmlFor:`ca-with-${e.name}`,children:(0,Y.jsx)(fr,{id:`ca-with-${e.name}`,input:e,environments:r.scope.environments,value:r.schedule?.with?.[e.name]??``,onChange:t=>ve({with:{...r.schedule?.with||{},[e.name]:t}})})},e.name))]}),(0,Y.jsx)(q,{help:`Something that happens in ForgeQE, or a pull request or push on GitHub or Azure DevOps, can start its approved version too, with nobody watching. A schedule's name narrows it to that schedule; a custom agent's own schedules never start anything. A pull request or push needs the repository's webhook to reach ForgeQE, signed with the webhook secret (Settings, Secrets, FORGEQE_WEBHOOK_SECRET); the agent is told only the pull request's number, repository and branches, never its title or description.`,icon:T,children:`Starts when something happens`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[(r.triggers||[]).map((e,t)=>{let n=e=>j({triggers:(r.triggers||[]).map((n,r)=>r===t?{...n,...e}:n)});return(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(B,{"aria-label":`Trigger ${t+1} event`,className:`w-[200px]`,value:e.on,onChange:t=>{let r=t.target.value,i=er.includes(r);n({on:r,...r.startsWith(`job_`)?{}:{job:void 0},...i?{source:e.source||`github`}:{source:void 0,repo:void 0,branch:void 0}})},children:Kn.map(e=>(0,Y.jsx)(`option`,{value:e,children:tr[e]},e))}),er.includes(e.on)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(B,{"aria-label":`Trigger ${t+1} host`,className:`w-[200px]`,value:e.source||`github`,onChange:e=>n({source:e.target.value}),children:[(0,Y.jsx)(`option`,{value:`github`,children:`GitHub`}),(0,Y.jsx)(`option`,{value:`azure_devops`,children:`Azure DevOps`})]}),(0,Y.jsx)(V,{"aria-label":`Trigger ${t+1} repository`,className:`w-[200px] font-mono`,maxLength:201,spellCheck:!1,value:e.repo??``,placeholder:e.source===`azure_devops`?`project/repository`:`owner/name`,onChange:e=>n({repo:e.target.value||void 0})}),(0,Y.jsx)(V,{"aria-label":`Trigger ${t+1}: which branch, empty for any`,className:`w-[140px] font-mono`,maxLength:200,spellCheck:!1,value:e.branch??``,placeholder:e.on===`push`?`any branch`:`any target`,onChange:e=>n({branch:e.target.value||void 0})})]}),e.on.startsWith(`job_`)&&(0,Y.jsx)(V,{"aria-label":`Trigger ${t+1}: which schedule, empty for any`,className:`w-[140px] font-mono`,maxLength:40,spellCheck:!1,value:e.job??``,placeholder:`any schedule`,onChange:e=>n({job:e.target.value||void 0})}),(0,Y.jsx)(V,{"aria-label":`Trigger ${t+1} request`,className:`min-w-0 flex-[1_1_280px]`,maxLength:500,value:e.request,placeholder:`What it is asked then (no {name}: nobody gives a value)`,onChange:e=>n({request:e.target.value})}),(0,Y.jsx)(H,{variant:`icon`,size:`icon`,"aria-label":`Remove trigger ${t+1}`,"data-tip":`Remove trigger ${t+1}`,onClick:()=>{let e=(r.triggers||[]).filter((e,n)=>n!==t);j({triggers:e,...!e.length&&!r.schedule?{permissions:{...r.permissions,unattended:[]}}:{}})},children:(0,Y.jsx)(a,{"aria-hidden":`true`})})]},t)}),(r.triggers||[]).length<4&&(0,Y.jsxs)(H,{size:`sm`,className:`self-start`,onClick:()=>j({triggers:[...r.triggers||[],{on:`suite_failed`,request:``}]}),"data-tip":`Add a trigger`,children:[(0,Y.jsx)(i,{"aria-hidden":`true`}),`Add`]})]}),(r.schedule||(r.triggers||[]).length>0)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(q,{help:`With nobody watching, it does only these without asking. Anything else waits for a person: the team is told, and no answer in time is a no.`,icon:xe,children:`What it may do alone`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 py-4`,children:[lr(r,u.systems,fe(r)).length===0&&(0,Y.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Only reading: allow more under What it may do, or pick Systems it works with, first.`}),lr(r,u.systems,fe(r)).map(e=>(0,Y.jsx)(Q,{checked:e.ids.every(e=>(r.permissions.unattended||[]).includes(e)),onChange:t=>ge({unattended:t?[...new Set([...r.permissions.unattended||[],...e.ids])]:(r.permissions.unattended||[]).filter(t=>!e.ids.includes(t))}),children:e.label},e.key))]})]}),(0,Y.jsx)(q,{help:`One per line: what it should keep in mind. Guidance for the model, never a limit.`,icon:ue,children:`Guidance`}),(0,Y.jsx)(Xe,{"aria-label":`Guidance, one per line`,rows:3,value:r.policies.join(`
3
3
  `),onChange:e=>j({policies:e.target.value.split(`
4
- `).map(e=>e.slice(0,300))})}),(0,Y.jsx)(K,{help:`What its starters and its schedule leave open, at most 6. Write {name} in a starter or the schedule's request (not a trigger's: nobody is there to give the value); its page asks for the value (one line of text, or a pick from its list) before the starter fills the message.`,icon:x,children:`Inputs`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[(r.inputs||[]).map((e,t)=>{let n=e=>j({inputs:(r.inputs||[]).map((n,r)=>r===t?{...n,...e}:n)});return(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(V,{"aria-label":`Input ${t+1} name`,className:`w-[140px] font-mono`,maxLength:32,spellCheck:!1,value:e.name,placeholder:`name`,onChange:e=>n({name:e.target.value.toLowerCase()})}),(0,Y.jsx)(V,{"aria-label":`Input ${t+1} label`,className:`w-[200px]`,maxLength:40,value:e.label,placeholder:`Label`,onChange:e=>n({label:e.target.value})}),(0,Y.jsx)(B,{"aria-label":`Input ${t+1} kind`,className:`w-[200px]`,value:e.kind,onChange:t=>{let r=t.target.value;n(r===`choice`?{kind:r,options:e.options||[]}:{kind:r,options:void 0})},children:jn.map(e=>(0,Y.jsx)(`option`,{value:e,children:nr[e]},e))}),e.kind===`choice`&&(0,Y.jsx)(dr,{label:`Input ${t+1} options, separated by commas`,options:e.options||[],onChange:e=>n({options:e})}),(0,Y.jsx)(H,{variant:`icon`,size:`icon`,"aria-label":`Remove input ${t+1}`,"data-tip":`Remove input ${t+1}`,onClick:()=>j({inputs:(r.inputs||[]).filter((e,n)=>n!==t)}),children:(0,Y.jsx)(a,{"aria-hidden":`true`})})]},t)}),(r.inputs||[]).length<6&&(0,Y.jsxs)(H,{size:`sm`,className:`self-start`,onClick:()=>j({inputs:[...r.inputs||[],{name:``,label:``,kind:`text`}]}),"data-tip":`Add an input`,children:[(0,Y.jsx)(i,{"aria-hidden":`true`}),`Add`]})]}),(0,Y.jsx)(K,{help:`Requests its page offers to start from (at most ${Qn}). {name} uses one of its inputs.`,icon:De,children:`Starters`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[r.starters.map((e,t)=>(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(V,{"aria-label":`Starter ${t+1} label`,className:`w-[200px]`,maxLength:40,value:e.label,placeholder:`Label`,onChange:e=>j({starters:r.starters.map((n,r)=>r===t?{...n,label:e.target.value}:n)})}),(0,Y.jsx)(V,{"aria-label":`Starter ${t+1} request`,className:`min-w-0 flex-[1_1_280px]`,maxLength:500,value:e.text,placeholder:`The request`,onChange:e=>j({starters:r.starters.map((n,r)=>r===t?{...n,text:e.target.value}:n)})}),(0,Y.jsx)(H,{variant:`icon`,size:`icon`,"aria-label":`Remove starter ${t+1}`,"data-tip":`Remove starter ${t+1}`,onClick:()=>j({starters:r.starters.filter((e,n)=>n!==t)}),children:(0,Y.jsx)(a,{"aria-hidden":`true`})})]},t)),r.starters.length<Qn&&(0,Y.jsxs)(H,{size:`sm`,className:`self-start`,onClick:()=>j({starters:[...r.starters,{label:``,text:``}]}),"data-tip":`Add a starter`,children:[(0,Y.jsx)(i,{"aria-hidden":`true`}),`Add`]})]}),(0,Y.jsx)(K,{help:`Short facts it keeps between runs with its remember tool and reads back with recall: what it found, never instructions. You can read and forget them on its page, under Details, Memory.`,icon:E,children:`Memory`}),(0,Y.jsx)(q,{label:`Notes it keeps`,htmlFor:`ca-notes`,help:`At most 200; past that the oldest go. None: it starts every run knowing only its manifest.`,children:(0,Y.jsxs)(B,{id:`ca-notes`,className:`w-[200px]`,value:String(r.memory?.notes||0),onChange:e=>j({memory:Number(e.target.value)?{notes:Number(e.target.value)}:void 0}),children:[(0,Y.jsx)(`option`,{value:`0`,children:`No memory`}),[20,50,100,200].map(e=>(0,Y.jsxs)(`option`,{value:e,children:[`Up to `,e,` notes`]},e)),r.memory&&![20,50,100,200].includes(r.memory.notes)&&(0,Y.jsxs)(`option`,{value:r.memory.notes,children:[`Up to `,r.memory.notes,` notes`]})]})}),(0,Y.jsx)(K,{help:`Who approves a version before it runs. ForgeQE knows a person by git's user name on their computer, so this is an agreement the history keeps, not a sign-in. A change is approved under the stricter of this and the version that runs.`,icon:m,children:`Approval`}),(0,Y.jsx)(q,{label:`People who approve`,htmlFor:`ca-people`,help:`How many different people approve a version. Each but the last signs it; it runs once the last approves.`,children:(0,Y.jsx)(B,{id:`ca-people`,className:`w-[200px]`,value:String(r.approval?.people||1),onChange:e=>j({approval:{people:Number(e.target.value),owners:r.approval?.owners||[]}}),children:[1,2,3].map(e=>(0,Y.jsx)(`option`,{value:e,children:e===1?`One person`:`${e} different people`},e))})}),(0,Y.jsx)(q,{label:`Who may approve`,htmlFor:`ca-owners`,help:`People's names as git knows them (user.name, or user.email). None: anyone who can approve agents in this project.`,children:(0,Y.jsx)(dr,{id:`ca-owners`,label:`Who may approve, separated by commas`,placeholder:`Ann Lee, Bo Chen`,max:20,options:r.approval?.owners||[],onChange:e=>j({approval:{people:r.approval?.people||1,owners:e}})})}),(0,Y.jsx)(K,{help:`Requests to try it on before it is approved, at most 8: forgeqe agent test runs them on the manifest as it is and grades each by code from the run (how it ended, words its reply holds or not, tools it used or never called). A version whose checks have not all passed is approved only when a person says so.`,icon:Se,children:`Checks`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4 py-2`,children:[(r.checks||[]).map((e,t)=>{let n=e=>j({checks:(r.checks||[]).map((n,r)=>r===t?{...n,...e}:n)}),i=t=>n({expect:{...e.expect,...t}});return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(V,{"aria-label":`Check ${t+1} name`,className:`w-[200px] font-mono`,maxLength:40,spellCheck:!1,value:e.name,placeholder:`basket-total`,onChange:e=>n({name:e.target.value.toLowerCase()})}),(0,Y.jsx)(V,{"aria-label":`Check ${t+1} request`,className:`min-w-0 flex-[1_1_280px]`,maxLength:500,value:e.request,placeholder:`The request it is tried on`,onChange:e=>n({request:e.target.value})}),(0,Y.jsx)(H,{variant:`icon`,size:`icon`,"aria-label":`Remove check ${t+1}`,"data-tip":`Remove check ${t+1}`,onClick:()=>j({checks:(r.checks||[]).filter((e,n)=>n!==t)}),children:(0,Y.jsx)(a,{"aria-hidden":`true`})})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pl-6`,children:[(0,Y.jsxs)(B,{"aria-label":`Check ${t+1} ends`,className:`w-[200px]`,value:e.expect.outcome,onChange:e=>i({outcome:e.target.value}),children:[(0,Y.jsx)(`option`,{value:`done`,children:`Ends done`}),(0,Y.jsx)(`option`,{value:`needs_input`,children:`Ends needing a person`}),(0,Y.jsx)(`option`,{value:`failed`,children:`Ends failed`})]}),(0,Y.jsx)(dr,{label:`Check ${t+1}: words its reply says, separated by commas`,placeholder:`Its reply says…`,max:16,options:e.expect.says,onChange:e=>i({says:e})}),(0,Y.jsx)(dr,{label:`Check ${t+1}: words its reply never says, separated by commas`,placeholder:`…and never says`,max:16,options:e.expect.neverSays,onChange:e=>i({neverSays:e})}),(0,Y.jsx)(dr,{label:`Check ${t+1}: tools it uses, separated by commas`,placeholder:`Tools it uses`,max:16,mono:!0,options:e.expect.uses,onChange:e=>i({uses:e})}),(0,Y.jsx)(dr,{label:`Check ${t+1}: tools it never calls, separated by commas`,placeholder:`Tools it never calls`,max:16,mono:!0,options:e.expect.neverUses,onChange:e=>i({neverUses:e})}),(r.output?.verdicts.length||0)>0&&(0,Y.jsxs)(B,{"aria-label":`Check ${t+1} verdict`,className:`w-[200px]`,value:e.expect.verdict||``,onChange:e=>i({verdict:e.target.value||void 0}),children:[(0,Y.jsx)(`option`,{value:``,children:`Any verdict`}),r.output.verdicts.map(e=>(0,Y.jsxs)(`option`,{value:e,children:[`Verdict `,e]},e))]})]})]},t)}),(r.checks||[]).length<8&&(0,Y.jsxs)(H,{size:`sm`,className:`self-start`,onClick:()=>j({checks:[...r.checks||[],{name:``,request:``,expect:{outcome:`done`,says:[],neverSays:[],uses:[],neverUses:[]}}]}),"data-tip":`Add a check`,children:[(0,Y.jsx)(i,{"aria-hidden":`true`}),`Add`]})]}),(0,Y.jsx)(K,{help:`What its reply ends with, read by ForgeQE, not by a model: a verdict of your words (at most 8) and named values (at most 12). Each run keeps them, checks can expect a verdict, a verdict you count as a failure tells the team as a failure, and forgeqe agent run exits 1 on it.`,icon:be,children:`Output`}),(0,Y.jsx)(q,{label:`Verdicts`,htmlFor:`ca-verdicts`,help:`Words for how a run came out, such as passed, failed, blocked. Lower-case letters, digits and underscores.`,children:(0,Y.jsx)(dr,{id:`ca-verdicts`,label:`Verdicts, separated by commas`,placeholder:`passed, failed, blocked`,max:8,mono:!0,options:r.output?.verdicts||[],onChange:e=>j({output:{verdicts:e,failOn:(r.output?.failOn||[]).filter(t=>e.includes(t)),fields:r.output?.fields||[]}})})}),(r.output?.verdicts.length||0)>0&&(0,Y.jsx)(q,{label:`Counts as a failure`,help:`A run with one of these verdicts, or with none, tells the team as a failure. Its checks still grade what they expect.`,children:(0,Y.jsx)(`div`,{className:`flex flex-col gap-2`,children:r.output.verdicts.map(e=>(0,Y.jsx)(Q,{checked:r.output.failOn.includes(e),onChange:t=>j({output:{...r.output,failOn:Z(r.output.failOn,e,t)}}),children:e},e))})}),(0,Y.jsx)(q,{label:`Fields`,stacked:!0,help:`Named values its reply reports, each of a kind. Leave a field out of the reply when it could not be found out.`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(r.output?.fields||[]).map((e,t)=>{let n=r.output||{verdicts:[],failOn:[],fields:[]},i=e=>j({output:{...n,fields:n.fields.map((n,r)=>r===t?{...n,...e}:n)}});return(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(V,{"aria-label":`Field ${t+1} name`,className:`w-[200px] font-mono`,maxLength:40,spellCheck:!1,value:e.name,placeholder:`defects_found`,onChange:e=>i({name:e.target.value.toLowerCase()})}),(0,Y.jsx)(B,{"aria-label":`Field ${t+1} kind`,className:`w-[200px]`,value:e.kind,onChange:e=>i({kind:e.target.value}),children:Jn.map(e=>(0,Y.jsx)(`option`,{value:e,children:$n[e]},e))}),(0,Y.jsx)(H,{variant:`icon`,size:`icon`,"aria-label":`Remove field ${t+1}`,"data-tip":`Remove field ${t+1}`,onClick:()=>j({output:{...n,fields:n.fields.filter((e,n)=>n!==t)}}),children:(0,Y.jsx)(a,{"aria-hidden":`true`})})]},t)}),(r.output?.fields.length||0)<12&&(0,Y.jsxs)(H,{size:`sm`,className:`self-start`,onClick:()=>j({output:{verdicts:r.output?.verdicts||[],failOn:r.output?.failOn||[],fields:[...r.output?.fields||[],{name:``,kind:`text`}]}}),"data-tip":`Add a field`,children:[(0,Y.jsx)(i,{"aria-hidden":`true`}),`Add`]})]})}),D.length>0&&(0,Y.jsx)(G,{id:`ca-advice`,icon:s,title:`What it still needs`,level:3,className:`mt-6`,children:(0,Y.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:D.map((e,t)=>(0,Y.jsxs)(`li`,{className:F(`flex flex-col gap-1 rounded-[12px] px-4 py-4 text-sm`,e.blocking?`bg-warn-soft`:`bg-surface-muted`),children:[(0,Y.jsx)(`span`,{className:F(`font-medium`,e.blocking?`text-warn`:`text-ink`),children:e.about}),(0,Y.jsx)(`span`,{className:`text-[13px] text-ink-2`,children:e.why}),(0,Y.jsx)(`span`,{className:`text-[13px] text-muted`,children:e.fix})]},t))})}),(0,Y.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,Y.jsx)(`div`,{role:`status`,className:`min-w-0 flex-[1_1_320px] text-[13px]`,children:O?(0,Y.jsx)(`span`,{className:`text-muted`,children:`Checking…`}):N.length?(0,Y.jsxs)(`ul`,{className:`m-0 list-disc pl-6 text-fail [overflow-wrap:anywhere]`,children:[N.slice(0,4).map((e,t)=>(0,Y.jsx)(`li`,{children:e},t)),N.length>4&&(0,Y.jsxs)(`li`,{children:[`and `,N.length-4,` more`]})]}):(0,Y.jsx)(`span`,{className:`text-pass`,children:`Ready to save. It can be tried once saved.`})}),(0,Y.jsx)(`a`,{href:Ae,className:`text-sm`,children:`Cancel`}),(0,Y.jsxs)(H,{variant:`primary`,disabled:A||!r.id||!r.name||we.length>0,onClick:()=>void Ee(),"data-tip":n?`Save the agent`:`Save changes`,children:[(0,Y.jsx)(C,{"aria-hidden":`true`}),`Save`]})]})]})]})]})}function mr({id:e}){let[t,n]=(0,J.useState)(null),[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(!1),s=(0,J.useCallback)(()=>{R.view(e).then(e=>{Be([{id:e.id,icon:e.icon}]),n(e),i(``)},e=>i(e.message))},[e]);(0,J.useEffect)(()=>s(),[s]);let[c,l]=(0,J.useState)(null);return Re.test(e)?(0,Y.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[t?(0,Y.jsx)(_r,{view:t,detailsOpen:a,onDetails:o}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`header`,{className:`flex items-center gap-1 px-6 py-4 short:py-2`,children:[(0,Y.jsx)(kt,{}),(0,Y.jsx)(it,{href:M(`agents`,`category`,`custom`),label:`Custom agents`,className:`self-center`})]}),(0,Y.jsx)(`main`,{className:`flex flex-auto flex-col items-center justify-center px-6 py-10`,children:r?(0,Y.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,Y.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`})})]}),t&&c&&(0,Y.jsx)(Rr,{view:t,action:c.action,to:c.to,onClose:()=>l(null),onDone:e=>{`deleted`in e?(l(null),location.hash=M(`agents`,`category`,`custom`)):(n(e),l(null))}}),t&&(0,Y.jsx)(wr,{view:t,open:a,onClose:()=>o(!1),onAct:l,onReload:s})]}):(0,Y.jsx)(hr,{})}function hr(){return(0,Y.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,Y.jsx)(`header`,{className:`flex items-center gap-1 px-6 py-4`,children:(0,Y.jsx)(kt,{})}),(0,Y.jsxs)(`p`,{className:`m-0 px-6 py-10 text-sm text-muted`,children:[`There is no such agent. `,(0,Y.jsx)(`a`,{href:M(`agents`),children:`See every agent`}),`.`]})]})}var gr=e=>e.length?e.join(`, `):`none`;function _r({view:e,detailsOpen:n,onDetails:r}){let i=Mt(),a=[...e.problems.working,...e.problems.active,...e.problems.other],o=e.state===`active`||e.state===`changed`,c=!!e.working,u=nn[e.state],[d,f]=(0,J.useState)(e.starters[0]&&!Pn(e.starters[0].text).length?e.starters[0].text:``),[p,m]=(0,J.useState)(null),[h,g]=(0,J.useState)({}),_=(e.active||e.working)?.environments||[];(0,J.useEffect)(()=>m(null),[e.active?.digest,e.working?.digest]);let[y,x]=(0,J.useState)(``),[S,C]=(0,J.useState)(``),[ee,w]=(0,J.useState)(!0),[T,E]=(0,J.useState)(!1),[D,te]=(0,J.useState)(!1),O=Lt(),{setup:ne}=O,k=`custom-agent-${e.id}`,A=ht(d,e=>{f(e),x(``)},k,{code:O.tools.code}),re=Ot(`custom-${e.id}`,e=>{f(e),wt(k)}),ie=async()=>{C(``);try{let t=await R.pack(e.id),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${e.id}.forgeqe-agent.zip`,r.click(),setTimeout(()=>URL.revokeObjectURL(n),1e3),w(!0),C(`Zip downloaded. A teammate imports it as a draft, then edits and approves it.`)}catch(e){w(!1),C(e.message)}},oe=async()=>{if(!T){E(!0),C(``);try{let t=await R.duplicate(e.id);location.hash=M(`agents`,`custom`,t.id,`edit`)}catch(e){w(!1),C(e.message),E(!1)}}},se=async(t,n=d)=>{if(!(D||!n.trim()&&!A.hasFiles)&&(t||o)&&(!t||c)){te(!0),x(``);try{let r=await A.wrap(n.trim());if(!r.trim()){te(!1);return}let{id:i}=await Je.start(r,{...O.choice,agent:e.id,...t||!o?{try:!0}:{}});A.reset({keep:!0}),location.hash=M(`chats`,i)}catch(e){x(e.message),te(!1)}}},ce=!o&&!c,le=(o?e.active:e.working)?.model;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`header`,{className:`flex items-center gap-1 px-6 py-4 short:py-2`,children:[(0,Y.jsx)(kt,{}),(0,Y.jsx)(it,{href:M(`agents`,`category`,`custom`),label:`Custom agents`,className:`self-center`}),(0,Y.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,children:[(0,Y.jsx)(U,{tone:u.tone,children:u.label}),(0,Y.jsx)(H,{variant:`icon`,size:`icon`,onClick:()=>void oe(),disabled:T||e.state===`invalid`,"aria-label":e.state===`invalid`?`Duplicate (fix its manifest first)`:`Duplicate`,"data-tip":e.state===`invalid`?`Duplicate (fix its manifest first)`:`Duplicate`,children:(0,Y.jsx)(t,{size:18,"aria-hidden":`true`})}),(0,Y.jsx)(H,{variant:`icon`,size:`icon`,onClick:()=>void ie(),"aria-label":`Export to share`,"data-tip":`Export to share`,children:(0,Y.jsx)(ye,{size:18,"aria-hidden":`true`})}),(0,Y.jsx)(H,{variant:`icon`,size:`icon`,onClick:()=>r(!n),"aria-label":`Details`,"aria-pressed":n,"data-tip":`Details`,children:(0,Y.jsx)(b,{size:18,"aria-hidden":`true`})}),(0,Y.jsx)(`a`,{href:M(`agents`,`custom`,e.id,`edit`),className:F(Qe({variant:`icon`,size:`icon`}),`no-underline`),"aria-label":`Edit`,"data-tip":`Edit`,children:(0,Y.jsx)(l,{size:18,"aria-hidden":`true`})})]})]}),(0,Y.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,Y.jsxs)(`div`,{className:`flex w-full max-w-[780px] flex-col items-center gap-10 short:gap-6`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-4 text-center short:gap-2`,children:[(0,Y.jsx)(ut,{agent:e.id,icon:e.icon,px:i?64:96,decorative:!0,working:D,className:`mb-1`}),(0,Y.jsx)(`h1`,{className:`m-0 text-[31px] leading-tight font-semibold tracking-[-0.015em] text-ink short:text-[25px] [overflow-wrap:anywhere]`,children:e.name}),(0,Y.jsx)(`p`,{className:`m-0 text-[16px] leading-relaxed text-ink-2`,children:e.description||(o?`Ask ${P(e.name)}. It runs version ${e.approvedVersion}, within its limits.`:e.state===`drifted`?`${e.name} ${e.approvedVersion} does not run until a person approves it again: what it knows changed. A try runs its manifest as it is.`:c?`Try ${P(e.name)}. It has no approved version yet: a try runs its manifest as it is.`:`Fix ${P(e.name)}'s manifest before it can be tried or approved.`)})]}),S&&(0,Y.jsx)(`p`,{role:`status`,className:F(`m-0 -mt-4 text-center text-[13px]`,ee?`text-muted`:`text-fail`),children:S}),a.length>0&&(0,Y.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,Y.jsx)(`span`,{className:`font-medium`,children:e.state===`invalid`?`Its manifest needs fixing before it can be tried or approved:`:`It cannot run as it is:`}),(0,Y.jsx)(`ul`,{className:`m-0 list-disc pl-6 [overflow-wrap:anywhere]`,children:a.map((e,t)=>(0,Y.jsx)(`li`,{children:e},t))})]}),e.manifestText!==void 0&&(0,Y.jsx)(kn,{text:e.manifestText,file:e.manifestFile||``}),e.state===`drifted`&&e.drift&&(0,Y.jsxs)(`section`,{"aria-labelledby":`ca-drift`,role:`alert`,className:`flex w-full flex-col gap-2 rounded-[12px] bg-warn-soft px-4 py-4 text-left text-sm`,children:[(0,Y.jsx)(pt,{id:`ca-drift`,icon:s,title:(0,Y.jsxs)(Y.Fragment,{children:[`What `,e.approvedVersion,` knows changed since it was approved`]}),level:3}),(0,Y.jsx)(`ul`,{className:`m-0 list-disc pl-6 text-ink-2`,children:e.drift.map(e=>(0,Y.jsx)(`li`,{children:e},e))}),(0,Y.jsxs)(`p`,{className:`m-0 text-[13px] text-ink-2`,children:[`It does not run (for you, your team, Atlas, its schedule or another agent) until a person reads the change and approves it again`,e.working?` under Details, Versions`:`: its manifest was removed, so put it back first`,`.`,e.changes.length>0?` Its manifest was also changed since: that change is below, and approving takes it too.`:``]})]}),e.changes.length>0&&(0,Y.jsx)(G,{id:`ca-changes`,icon:ae,title:(0,Y.jsxs)(Y.Fragment,{children:[`Changed since `,e.approvedVersion,` was approved`]}),description:(0,Y.jsxs)(Y.Fragment,{children:[e.state===`changed`?`The approved version keeps running until this change is approved.`:`Approving takes this change too.`,` Approve or discard it under Details, Versions.`]}),className:`w-full text-left`,children:(0,Y.jsx)(ln,{diff:e.changes})}),ce?(0,Y.jsx)(`p`,{className:`m-0 text-center text-sm text-muted`,children:e.manifestText===void 0?`See what is wrong above, or Edit the agent.`:`Fix what is listed above in its file, then come back.`}):(0,Y.jsxs)(Y.Fragment,{children:[ne&&!ne.ready&&(0,Y.jsx)(tn,{project:ne.project}),ne?.ready&&(0,Y.jsx)(Xt,{c:O}),(0,Y.jsx)(At,{id:k,label:`Message ${P(e.name)}`,value:d,onChange:e=>{f(e),x(``)},onSend:()=>void se(!o),disabled:D||!!ne&&!ne.ready||re.running,canSend:!!d.trim()||A.hasFiles,onEdit:A.onEdit,onKey:A.onKeyDown,onFiles:A.onFiles,dropping:A.dropping,drop:A.drop,mentions:A.mentions,combo:A.combo,placeholder:`Ask ${P(e.name)} to…`,top:(0,Y.jsxs)(Y.Fragment,{children:[A.chips,re.state&&(0,Y.jsx)(Ct,{state:re.state,onStop:()=>void re.stop(),onUndo:re.undo,onClose:re.close})]}),left:(0,Y.jsxs)(Y.Fragment,{children:[A.fileInput,(0,Y.jsx)($t,{attach:{pick:A.pick},choice:O}),(0,Y.jsx)(Ut,{running:re.running,disabled:!d.trim()||D||!!ne&&!ne.ready,onClick:()=>void re.start(d)})]}),right:le?(0,Y.jsxs)(H,{variant:`ghost`,className:`max-w-[46vw] min-w-0 px-2 text-[16px] sm:px-2`,disabled:!0,"aria-label":`Model: ${le}, as its manifest says`,"data-tip":`It runs on ${le}, as its manifest says${o&&c&&e.working?.model!==le?`; a try runs on ${e.working?.model||`ForgeQE's choice`}`:``}`,children:[(0,Y.jsx)(ve,{"aria-hidden":`true`,className:`size-4`}),(0,Y.jsx)(`span`,{className:`hidden truncate sm:inline`,children:le})]}):(0,Y.jsx)(Ht,{c:O})}),(0,Y.jsx)(`p`,{role:`status`,"aria-live":`polite`,className:F(`-mt-6 m-0 text-center text-sm text-ink-2 short:-mt-4`,!(y||A.error)&&`sr-only`),children:(0,Y.jsx)(`span`,{className:A.error&&!y?`text-fail`:``,children:y||A.error||``})}),p&&(0,Y.jsx)(vr,{starter:p,inputs:e.inputs||[],environments:_,values:h,onChange:g,onUse:e=>{f(e),m(null),document.getElementById(k)?.focus()},onCancel:()=>{let t=e.starters.findIndex(e=>e.label===p.label);m(null),t>=0&&requestAnimationFrame(()=>document.getElementById(`${k}-starter-${t}`)?.focus())}},p.label),(0,Y.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-4`,children:[e.starters.map((e,t)=>(0,Y.jsx)(H,{id:`${k}-starter-${t}`,"aria-expanded":Pn(e.text).length?p?.label===e.label:void 0,onClick:()=>{x(``),Pn(e.text).length?(m(p?.label===e.label?null:e),g({})):(m(null),f(e.text),document.getElementById(k)?.focus())},children:e.label},e.label)),o&&c&&(0,Y.jsxs)(H,{disabled:D||!d.trim(),onClick:()=>void se(!0),"data-tip":`Try the manifest`,children:[(0,Y.jsx)(v,{"aria-hidden":`true`}),`Try`]})]})]}),(0,Y.jsx)(br,{view:e})]})})]})}function vr({starter:e,inputs:t,environments:n,values:r,onChange:i,onUse:a,onCancel:o}){let s=Pn(e.text),c=s.map(e=>t.find(t=>t.name===e)).filter(e=>!!e),l=s.filter(e=>!t.some(t=>t.name===e)),[u,d]=(0,J.useState)(``),f=(0,J.useId)();(0,J.useEffect)(()=>{c[0]?document.getElementById(`starter-${c[0].name}`)?.focus():document.getElementById(f)?.focus()},[e.label]);let p=()=>{try{a(In(e.text,t,r,n))}catch(e){d(e.message)}};return(0,Y.jsxs)(`form`,{"aria-label":`Values for ${e.label}`,className:`flex w-full flex-col gap-4 rounded-[12px] card border px-4 py-4 text-left`,onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),o())},onSubmit:e=>{e.preventDefault(),p()},children:[(0,Y.jsx)(`span`,{className:`text-sm font-medium`,children:e.label}),c.map(e=>(0,Y.jsxs)(`label`,{htmlFor:`starter-${e.name}`,className:`flex flex-wrap items-center gap-x-4 gap-y-1 text-sm`,children:[(0,Y.jsx)(`span`,{className:`min-w-[140px] text-ink-2`,children:e.label}),(0,Y.jsx)(fr,{id:`starter-${e.name}`,input:e,environments:n,value:r[e.name]??``,onChange:t=>(i({...r,[e.name]:t}),d(``))})]},e.name)),l.length>0&&(0,Y.jsx)(`p`,{role:`alert`,className:`m-0 text-sm text-fail [overflow-wrap:anywhere]`,children:l.map(e=>`{${e}} is not one of its inputs, so this starter cannot be filled. Edit the agent.`).join(` `)}),u&&!l.length&&(0,Y.jsx)(`p`,{role:`alert`,className:`m-0 text-sm text-fail [overflow-wrap:anywhere]`,children:u}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,Y.jsx)(H,{type:`submit`,variant:`primary`,size:`sm`,children:`Use`}),(0,Y.jsx)(H,{id:f,type:`button`,variant:`ghost`,size:`sm`,onClick:o,children:`Cancel`})]})]})}function yr({view:e,onDone:t}){let n=e.memory?.kept||[],[r,i]=(0,J.useState)(!1),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(``),f=(0,J.useId)(),p=()=>{i(!1),s(``),setTimeout(()=>document.getElementById(f)?.focus(),0)},m=async n=>{l(!0),d(``);try{await R.forget(e.id,n),i(!1),s(``),t()}catch(e){d(e.message)}finally{l(!1)}};return(0,Y.jsxs)(Tr,{id:`ca-memory`,icon:E,title:`Memory · ${n.length} of ${e.memory?.notes||n.length} notes`,aside:n.length>0&&!r?(0,Y.jsxs)(H,{id:f,size:`sm`,variant:`danger`,onClick:()=>i(!0),children:[(0,Y.jsx)(a,{"aria-hidden":`true`}),`Forget all`]}):void 0,children:[r&&(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2 rounded-[12px] bg-warn-soft px-4 py-4 text-sm`,children:[(0,Y.jsxs)(`label`,{className:`flex min-w-0 flex-[1_1_240px] flex-col gap-2`,children:[(0,Y.jsxs)(`span`,{children:[`Type `,(0,Y.jsx)(`span`,{className:`font-mono`,children:e.id}),` to forget all `,n.length,` notes`]}),(0,Y.jsx)(V,{autoFocus:!0,value:o,onChange:e=>s(e.target.value),autoComplete:`off`,spellCheck:!1})]}),(0,Y.jsx)(H,{variant:`ghost`,onClick:p,children:`Cancel`}),(0,Y.jsx)(H,{variant:`destructive`,disabled:c||o!==e.id,onClick:()=>void m({all:!0,confirm:o}),children:`Forget all`})]}),u&&(0,Y.jsx)(`p`,{role:`alert`,className:`m-0 text-sm text-fail [overflow-wrap:anywhere]`,children:u}),n.length===0?(0,Y.jsxs)(et,{className:`py-4`,children:[P(e.name,!0),` has noted nothing yet. It keeps short facts it finds, to recall in later runs.`]}):(0,Y.jsx)(`ul`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-0`,children:n.map((e,t)=>(0,Y.jsxs)(`li`,{className:F(`flex items-start gap-2 px-4 py-2 text-[13px]`,t>0&&`border-t border-line-soft`),children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 [overflow-wrap:anywhere]`,children:e.text}),(0,Y.jsx)(`span`,{className:`flex-none text-muted tabular-nums`,children:Pt(e.at)}),(0,Y.jsx)(H,{variant:`icon`,size:`icon`,disabled:c,"aria-label":`Forget note ${t+1}`,"data-tip":`Forget this note (cannot be undone)`,onClick:()=>void m({at:e.at,text:e.text}),children:(0,Y.jsx)(a,{"aria-hidden":`true`})})]},`${e.at}-${t}`))})]})}function br({view:e}){let t=e.capabilities,n=t.some(e=>e.state===`needs_setup`)?`needs_setup`:t.some(e=>e.state===`partial`)?`partial`:`ready`,r=n===`ready`?`pass`:n===`partial`?`warn`:`neutral`,i=n===`ready`?`Ready`:n===`partial`?`Partly set up`:`Needs setup`,a=t.filter(e=>e.state!==`ready`);return(0,Y.jsxs)(`div`,{className:`flex w-full flex-col gap-6 pt-2 text-left`,children:[a.length>0&&(0,Y.jsxs)(G,{id:`ca-needs`,icon:s,title:`What it needs`,actions:(0,Y.jsx)(U,{tone:r,children:i}),children:[(0,Y.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:n===`needs_setup`?`${P(e.name,!0)} cannot work until these are set up.`:`${P(e.name,!0)} works, without the parts below.`}),(0,Y.jsx)(`ul`,{"aria-label":`What ${P(e.name)} needs`,className:`m-0 flex list-none flex-col rounded-[12px] card border p-0`,children:a.map((e,t)=>(0,Y.jsxs)(`li`,{className:F(`flex items-center gap-4 px-4 py-2`,t>0&&`border-t border-line-soft`),children:[(0,Y.jsx)(W,{icon:Cr[e.state].icon,size:16,className:F(`flex-none`,Cr[e.state].cls)}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Y.jsx)(`span`,{className:`text-[13px] font-medium`,children:e.title}),(0,Y.jsx)(`span`,{className:`text-[13px] text-muted [overflow-wrap:anywhere]`,children:e.gaps.join(`; `)||Cr[e.state].label})]})]},e.id))})]}),(0,Y.jsx)(Nt,{scope:{kind:`custom`,id:e.id,name:e.name}}),t.length>0&&(0,Y.jsx)(Bt,{title:`What ${P(e.name)} can use`,children:(0,Y.jsx)(`section`,{"aria-label":`What ${P(e.name)} can use`,className:`flex flex-col gap-2 pt-2`,children:(0,Y.jsx)(`ul`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-0`,children:t.map((e,t)=>{let n=Cr[e.state];return(0,Y.jsxs)(`li`,{className:F(`flex items-start gap-4 px-4 py-2`,t>0&&`border-t border-line-soft`),children:[(0,Y.jsx)(W,{icon:n.icon,size:16,className:F(`mt-1 flex-none`,n.cls)}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Y.jsx)(`span`,{className:`text-[13px] font-medium`,children:e.title}),(0,Y.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[n.label,e.gaps.length?`: ${e.gaps.join(`; `)}`:``]})]})]},e.id)})})})})]})}var xr={approved:`Approved`,signed:`Signed`,disabled:`Disabled`,enabled:`Enabled`,"rolled-back":`Rolled back to`};function Sr(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 Cr={ready:{icon:m,label:`Ready`,cls:`text-pass`},partial:{icon:_,label:`Partly set up`,cls:`text-warn`},needs_setup:{icon:O,label:`Needs setup`,cls:`text-muted`}};function wr({view:e,open:t,onClose:n,onAct:r,onReload:i}){let a=e.active||e.working,o=!!e.working&&(e.state===`draft`||e.state===`changed`||e.state===`drifted`||e.state===`broken`&&e.working!==void 0);return(0,Y.jsx)(yt,{open:t,onClose:n,wide:!0,title:`Details`,description:`${e.name} · ${e.id}`,footer:(0,Y.jsxs)(H,{variant:`ghost`,onClick:n,children:[(0,Y.jsx)(p,{"aria-hidden":`true`}),`Close`]}),children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[a&&(0,Y.jsx)(Er,{spec:a,view:e}),(e.checkResults||[]).length>0&&(0,Y.jsx)(Ar,{view:e,onDone:i}),((e.memory?.notes||0)>0||(e.memory?.kept.length||0)>0)&&(0,Y.jsx)(yr,{view:e,onDone:i}),(0,Y.jsx)(Dr,{view:e,approvable:o,onAct:r}),(0,Y.jsx)(Ir,{view:e})]})})}function Tr({id:e,icon:t,title:n,children:r,aside:i}){return(0,Y.jsx)(G,{id:e,icon:t,title:n,level:3,actions:i,children:r})}function Er({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`?gr(e.agents.map(e=>t.agentNames[e]||e)):n.text]):[[`Environments`,gr(e.environments)],[`Agents it may start`,gr(e.agents.map(e=>t.agentNames[e]||e))],[`It may`,gr(e.actions.map(e=>Or[e]||e))],[`A person approves first`,gr(e.approve.map(e=>Or[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`,gr(e.skills)],[`Knowledge`,gr(e.knowledge)]];return(0,Y.jsxs)(Tr,{id:`ca-reach`,icon:xe,title:t.active?`What version ${t.approvedVersion} may reach`:`What its manifest may reach`,children:[(0,Y.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,Y.jsxs)(`div`,{className:`contents`,children:[(0,Y.jsx)(`dt`,{className:`text-muted`,children:e}),(0,Y.jsx)(`dd`,{className:`m-0 text-ink [overflow-wrap:anywhere]`,children:t})]},e))}),e.policies.length>0&&(0,Y.jsxs)(`p`,{className:`m-0 text-[13px] text-muted`,children:[`Guidance it is given (not a limit): `,e.policies.join(`; `)]})]})}function Dr({view:e,approvable:t,onAct:n}){let[r,i]=(0,J.useState)(null),[s,c]=(0,J.useState)(null),[l,u]=(0,J.useState)(!1),f=async()=>{u(!0),c(null);try{let t=await R.library.publish(e.id);c({ok:!0,text:`Published ${e.approvedVersion} to your library: another project on this computer installs it from Import.${t.warnings.length?` ${t.warnings.join(`; `)}.`:``}`})}catch(e){c({ok:!1,text:e.message})}finally{u(!1)}};return(0,Y.jsxs)(Y.Fragment,{children:[r&&(0,Y.jsx)(Mr,{view:e,at:r.ref,canGoBack:r.canGoBack,onClose:()=>i(null),onAct:n}),(0,Y.jsxs)(Tr,{id:`ca-versions`,icon:te,title:`Versions`,aside:(0,Y.jsxs)(`span`,{className:`flex flex-wrap gap-2`,children:[t&&(e.approval?.signed.length||0)>0&&(0,Y.jsxs)(`span`,{className:`self-center text-[13px] text-muted`,children:[`Signed by `,e.approval.signed.map(e=>e.by).join(`, `),`; needs `,e.approval.people-e.approval.signed.length,` more`]}),t&&(0,Y.jsxs)(H,{size:`sm`,onClick:()=>n({action:`approve`}),"data-tip":`Approve ${e.manifestVersion}`,children:[(0,Y.jsx)(m,{"aria-hidden":`true`}),`Approve`]}),e.changes.length>0&&(0,Y.jsxs)(H,{size:`sm`,variant:`danger`,onClick:()=>n({action:`discard`}),"data-tip":`Back to ${e.approvedVersion}`,children:[(0,Y.jsx)(o,{"aria-hidden":`true`}),`Discard the change`]}),e.approvedVersion&&(0,Y.jsxs)(H,{size:`sm`,variant:`ghost`,onClick:()=>n({action:e.disabled?`enable`:`disable`}),children:[e.disabled?(0,Y.jsx)(m,{"aria-hidden":`true`}):(0,Y.jsx)(O,{"aria-hidden":`true`}),e.disabled?`Enable`:`Disable`]}),e.approvedVersion&&(0,Y.jsxs)(H,{size:`sm`,variant:`ghost`,disabled:l,onClick:()=>void f(),"data-tip":`Publish ${e.approvedVersion} to your library`,children:[(0,Y.jsx)(ee,{"aria-hidden":`true`}),`Publish`]}),(0,Y.jsxs)(H,{size:`sm`,variant:`danger`,onClick:()=>n({action:`delete`}),children:[(0,Y.jsx)(a,{"aria-hidden":`true`}),`Delete`]})]}),children:[s&&(0,Y.jsx)(`p`,{role:s.ok?`status`:`alert`,className:F(`m-0 rounded-[12px] px-4 py-2 text-[13px] [overflow-wrap:anywhere]`,s.ok?`bg-pass-soft text-pass`:`bg-fail-soft text-fail`),children:s.text}),e.tried&&e.manifestVersion&&(0,Y.jsxs)(`p`,{className:`m-0 text-[13px] text-muted`,children:[`Last try of manifest `,e.manifestVersion,`: `,e.tried.outcome,`.`]}),e.events.length===0?(0,Y.jsx)(et,{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,Y.jsx)(`ul`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-2`,children:e.events.toReversed().map((t,r)=>{let a=t.event===`approved`||t.event===`rolled-back`?t.version===e.approvedVersion:!1,o=t.event===`approved`&&t.version!==e.approvedVersion&&!e.events.slice(e.events.indexOf(t)+1).some(e=>e.event===`approved`&&e.version===t.version);return(0,Y.jsxs)(`li`,{className:`flex min-h-11 flex-wrap items-center gap-4 rounded-[8px] px-4 py-2`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-[13px] font-medium`,children:[(0,Y.jsxs)(`span`,{children:[xr[t.event],` `,t.version]}),a&&r===0?(0,Y.jsx)(U,{tone:`pass`,children:`Running`}):null]}),(0,Y.jsxs)(`span`,{className:`text-[13px] text-muted [overflow-wrap:anywhere]`,children:[Sr(t.by),` · `,Pt(t.at),t.note?` · ${t.note}`:``,t.tried?` · tried: ${t.tried.outcome}`:``]})]}),t.event===`approved`&&(0,Y.jsx)(H,{size:`sm`,variant:`ghost`,onClick:()=>i({ref:t.digest.slice(0,16),canGoBack:o}),"aria-label":`Read version ${t.version}`,"data-tip":`Read version ${t.version}`,children:(0,Y.jsx)(Te,{"aria-hidden":`true`})}),o&&(0,Y.jsx)(H,{size:`sm`,variant:`ghost`,onClick:()=>n({action:`rollback`,to:t.version}),"aria-label":`Roll back to ${t.version}`,"data-tip":`Roll back to ${t.version}`,children:(0,Y.jsx)(d,{"aria-hidden":`true`})})]},`${t.at}-${r}`)})})]})]})}var Or={read:`read`,run:`run tests and apps`,change:`change files`,external:`change other systems`,schedule:`schedule work`},kr={passed:{label:`Passed`,tone:`pass`},failed:{label:`Failed`,tone:`fail`},not_run:{label:`Not run on this version`,tone:`neutral`}};function Ar({view:e,onDone:t}){let[n,r]=(0,J.useState)(null),[i,a]=(0,J.useState)(``),o=n&&n.target===e.id?n:null,s=!!n?.running,c=(0,J.useRef)(null),l=(0,J.useRef)(``),u=n=>{n&&n.target===e.id&&!n.running&&l.current!==n.startedAt&&(l.current=n.startedAt,t())},d=e=>{r(e),u(e)};(0,J.useEffect)(()=>{R.checks.job().then(e=>d(e.job),e=>a(e.message))},[e.id]),(0,J.useEffect)(()=>{if(!s)return;let e=St(()=>{R.checks.job().then(e=>(a(``),d(e.job)),e=>a(e.message))},2e3);return()=>bt(e)},[s]),(0,J.useEffect)(()=>{c.current&&(c.current.scrollTop=c.current.scrollHeight)},[o?.lines.length]);let f=e=>{a(``),e.then(e=>d(e.job),e=>a(e.message))};return(0,Y.jsxs)(Tr,{id:`ca-checks`,icon:Se,title:`Checks`,aside:o?.running?(0,Y.jsxs)(H,{size:`sm`,variant:`danger`,onClick:()=>f(R.checks.stop()),children:[(0,Y.jsx)(me,{"aria-hidden":`true`}),`Stop`]}):(0,Y.jsxs)(H,{size:`sm`,onClick:()=>f(R.checks.start(e.id)),disabled:s,"data-tip":`Try each check on ${e.manifestVersion}`,children:[(0,Y.jsx)(v,{"aria-hidden":`true`}),`Run checks`]}),children:[s&&!o&&(0,Y.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`Another agent's checks are running: Run checks waits for them to end.`}),(0,Y.jsx)(`ul`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-0`,children:e.checkResults.map((e,t)=>(0,Y.jsxs)(`li`,{className:F(`flex flex-col gap-1 px-4 py-2 text-sm`,t>0&&`border-t border-line-soft`),children:[(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`font-mono text-[13px]`,children:e.name}),(0,Y.jsx)(U,{tone:kr[e.state].tone,children:kr[e.state].label}),e.at&&(0,Y.jsx)(`span`,{className:`text-[13px] text-muted`,children:Pt(e.at)})]}),(0,Y.jsx)(`span`,{className:`text-[13px] text-ink-2 [overflow-wrap:anywhere]`,children:e.request}),e.state===`failed`&&(e.reasons||[]).length>0&&(0,Y.jsx)(`ul`,{className:`m-0 list-disc pl-6 text-[13px] text-fail [overflow-wrap:anywhere]`,children:e.reasons.map(e=>(0,Y.jsx)(`li`,{children:e},e))})]},e.name))}),i&&(0,Y.jsx)(`p`,{role:`alert`,className:`m-0 text-sm text-fail [overflow-wrap:anywhere]`,children:i}),o&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`details`,{open:o.running,children:[(0,Y.jsxs)(`summary`,{className:`cursor-pointer text-sm text-muted`,children:[`Output (`,o.lines.length,` lines)`]}),(0,Y.jsx)(`pre`,{ref:c,className:`mt-2 max-h-[300px] overflow-auto rounded-[10px] bg-surface-muted p-4 font-mono text-[13px] leading-relaxed whitespace-pre-wrap text-ink-2`,children:(0,Y.jsx)(nt,{text:o.lines.join(`
5
- `)||`Starting…`})})]}),o.running&&o.question&&(0,Y.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 border-0 p-0`,children:[(0,Y.jsx)(`legend`,{className:`mb-1 text-sm font-medium`,children:o.question.title}),o.question.detail&&(0,Y.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:o.question.detail}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:o.question.options.map(e=>(0,Y.jsx)(H,{size:`sm`,variant:e.id===`deny`||e.id===`stop`?`outline`:`primary`,onClick:()=>f(R.checks.answer(o.question.id,e.id)),children:e.label},e.id))})]})]})]})}function jr({lines:e}){return(0,Y.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:e.map(e=>(0,Y.jsxs)(`div`,{className:`contents`,children:[(0,Y.jsxs)(`dt`,{className:F(e.mark===`same`?`text-muted`:`font-medium text-warn`),children:[e.label,e.mark!==`same`&&(0,Y.jsxs)(`span`,{className:`sr-only`,children:[` (`,Nr[e.mark],`)`]})]}),(0,Y.jsxs)(`dd`,{className:F(`m-0 [overflow-wrap:anywhere]`,e.mark===`removed`?`text-muted line-through`:`text-ink`),children:[e.mark!==`same`&&(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`mr-2 text-[13px] font-medium text-warn`,children:Nr[e.mark]}),e.text,e.before&&(0,Y.jsxs)(`span`,{className:`block text-[13px] text-muted`,children:[`Was: `,e.before]})]})]},`${e.mark}-${e.label}`))})}function Mr({view:e,at:t,canGoBack:n,onClose:r,onAct:i}){let[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(``);return(0,J.useEffect)(()=>{R.version(e.id,t).then(o,e=>c(e.message))},[e.id,t]),(0,Y.jsx)(yt,{open:!0,wide:!0,onClose:r,title:a?`Version ${a.version}`:`Version`,description:a?`Approved by ${Sr(a.by)} ${Pt(a.at)}${a.note?`: ${a.note}`:``}.${a.running?` It is the version that runs.`:``}`:void 0,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(H,{variant:`ghost`,onClick:r,children:[(0,Y.jsx)(p,{"aria-hidden":`true`}),`Close`]}),n&&a&&!a.running&&(0,Y.jsxs)(H,{variant:`primary`,onClick:()=>(r(),i({action:`rollback`,to:a.version})),children:[(0,Y.jsx)(d,{"aria-hidden":`true`}),`Roll back to `,a.version]})]}),children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[s&&(0,Y.jsx)(`p`,{role:`alert`,className:`m-0 text-sm text-fail [overflow-wrap:anywhere]`,children:s}),!a&&!s&&(0,Y.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}),a&&(0,Y.jsxs)(Y.Fragment,{children:[!a.running&&a.permissions.length>0&&(0,Y.jsx)(G,{id:`ca-version-may`,icon:xe,title:(0,Y.jsxs)(Y.Fragment,{children:[`What it may do, against `,e.approvedVersion]}),level:3,children:(0,Y.jsx)(jr,{lines:a.permissions})}),a.diff&&(0,Y.jsx)(G,{id:`ca-version-diff`,icon:ae,title:(0,Y.jsxs)(Y.Fragment,{children:[`Its manifest against `,e.approvedVersion]}),level:3,children:(0,Y.jsx)(ln,{diff:a.diff})}),(0,Y.jsx)(G,{id:`ca-version-source`,icon:h,title:`Its manifest as approved`,level:3,children:(0,Y.jsx)(`pre`,{className:`m-0 max-h-[50vh] overflow-auto rounded-[12px] card border px-4 py-4 font-mono text-[13px] whitespace-pre-wrap [overflow-wrap:anywhere]`,children:a.source})})]})]})})}var Nr={new:`New`,changed:`Changed`,removed:`No longer`},Pr={run:`Asked`,try:`Tried`,orchestrator:`From Atlas`,schedule:`Nobody watching`,agent:`Handed on by another agent`,check:`A saved check`},Fr={usage:zt,money:rn};function Ir({view:e}){let[t,n]=(0,J.useState)(``),r=async()=>{n(``);try{let t=await R.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,Y.jsxs)(Tr,{id:`ca-runs`,icon:v,title:`Recent runs`,aside:(0,Y.jsxs)(H,{size:`sm`,variant:`ghost`,onClick:()=>void r(),"data-tip":`Download its whole record, for audit`,children:[(0,Y.jsx)(ye,{"aria-hidden":`true`}),`Download`]}),children:[t&&(0,Y.jsx)(`p`,{className:`m-0 text-[13px] text-fail`,children:t}),e.runs.length===0?(0,Y.jsxs)(et,{className:`py-4`,children:[P(e.name,!0),` has not run yet.`]}):(0,Y.jsx)(`ul`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-0`,children:e.runs.map((e,t)=>(0,Y.jsx)(`li`,{className:F(t>0&&`border-t border-line-soft`),children:(0,Y.jsxs)(`details`,{className:`group px-4 py-2`,children:[(0,Y.jsxs)(`summary`,{className:`flex cursor-pointer list-none flex-wrap items-center gap-x-4 gap-y-1`,children:[(0,Y.jsx)(U,{tone:e.outcome===`done`?`pass`:e.outcome===`running`?`running`:e.outcome===`stopped`||e.outcome===`needs_input`?`neutral`:`fail`,children:e.outcome.replace(`_`,` `)}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] font-medium`,"data-tip":e.request,children:e.request}),(0,Y.jsxs)(`span`,{className:`text-[13px] text-muted tabular-nums`,children:[Pr[e.trigger]||`Started another way`,` · `,e.version,` · `,e.calls,` `,e.calls===1?`call`:`calls`,e.refused?`, ${e.refused} refused`:``,e.result?.verdict?` · verdict ${e.result.verdict}`:``,` · `,Pt(e.startedAt)]})]}),(0,Y.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2 pl-1 text-[13px]`,children:[(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-4 gap-y-1`,children:[(0,Y.jsxs)(`span`,{className:`text-muted`,children:[`By `,e.by]}),e.session&&(0,Y.jsxs)(`a`,{href:M(`runs`,encodeURIComponent(e.session)),className:`inline-flex items-center gap-1`,children:[`Open the run`,(0,Y.jsx)(N,{size:14,"aria-hidden":`true`})]})]}),An(e,Fr)&&(0,Y.jsx)(`span`,{className:`text-muted tabular-nums [overflow-wrap:anywhere]`,children:An(e,Fr)}),e.error&&(0,Y.jsx)(`span`,{className:`text-fail [overflow-wrap:anywhere]`,children:e.error}),e.result&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-muted`,children:`Its result`}),(0,Y.jsxs)(`dl`,{className:`m-0 grid grid-cols-[max-content_1fr] gap-x-4 gap-y-1`,children:[(0,Y.jsx)(`dt`,{className:`text-muted`,children:`Verdict`}),(0,Y.jsx)(`dd`,{className:`m-0`,children:e.result.verdict||`None given`}),Object.entries(e.result.fields).map(([e,t])=>(0,Y.jsxs)(J.Fragment,{children:[(0,Y.jsx)(`dt`,{className:`font-mono text-[13px] text-muted`,children:e}),(0,Y.jsx)(`dd`,{className:`m-0 [overflow-wrap:anywhere]`,children:typeof t==`boolean`?t?`Yes`:`No`:String(t)})]},e))]}),e.result.problems.length>0&&(0,Y.jsxs)(`span`,{className:`text-warn [overflow-wrap:anywhere]`,children:[`Not read: `,e.result.problems.join(`; `),`.`]})]}),e.reply&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-muted`,children:`Its reply`}),(0,Y.jsx)(`p`,{tabIndex:0,"aria-label":`Its reply`,className:`m-0 max-h-[240px] overflow-auto rounded-[10px] bg-surface-muted px-4 py-2 whitespace-pre-wrap text-ink-2 [overflow-wrap:anywhere]`,children:e.reply})]}),e.decisions.length>0&&(0,Y.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0`,children:e.decisions.map((e,t)=>(0,Y.jsxs)(`li`,{className:`flex items-start gap-2`,children:[e.allowed?(0,Y.jsx)(m,{size:14,"aria-label":`Allowed`,className:`mt-1 flex-none text-pass`}):(0,Y.jsx)(s,{size:14,"aria-label":`Refused`,className:`mt-1 flex-none text-fail`}),(0,Y.jsxs)(`span`,{className:`min-w-0 [overflow-wrap:anywhere]`,children:[(0,Y.jsx)(`span`,{className:`font-mono text-[13px]`,children:e.tool}),e.allowed?(0,Y.jsxs)(`span`,{className:`text-muted`,children:[` · `,Or[e.action||``]||e.action,e.approved?`, approved by a person`:``]}):(0,Y.jsxs)(`span`,{className:`text-fail`,children:[` · `,e.reason]})]})]},t))})]})]})},e.run))})]})}var Lr={approve:{title:`Approve this version`,button:`Approve`,icon:m},disable:{title:`Disable this agent`,button:`Disable`,icon:O},enable:{title:`Enable this agent`,button:`Enable`,icon:m},rollback:{title:`Run an earlier version`,button:`Roll back`,icon:d},delete:{title:`Delete this agent`,button:`Delete`,icon:a},discard:{title:`Discard the change`,button:`Discard the change`,icon:o}};function Rr({view:e,action:t,to:n,onClose:r,onDone:i}){let[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)(``),m=t===`approve`?e.checks:null,h=!!m&&(m.failed.length>0||m.missing.length>0),[g,_]=(0,J.useState)(!1),v=t===`approve`?e.approval:void 0,y=v?v.people-v.signed.length:1,b=(e,t)=>e.toLowerCase()===t.toLowerCase(),x=!!v&&v.owners.length>0&&!v.owners.some(e=>b(e,v.you)),S=!!v&&v.signed.some(e=>b(e.by,v.you)),C=Lr[t],ee=t===`approve`&&e.state===`drifted`&&e.changes.length===0?`Version ${e.approvedVersion} is approved again with what it knows now, and runs again for you, your team and Atlas. Commit .forgeqe/agents/.releases/${e.id} so your team has it.`:t===`approve`&&y>1?`Your approval of version ${e.manifestVersion} is kept; it runs once ${y-1} more ${y-1==1?`person approves`:`people approve`} it. Commit .forgeqe/agents/.releases/${e.id} so the next person sees your approval.`:t===`approve`?`Version ${e.manifestVersion} becomes what runs, for you, your team and Atlas${e.approvedVersion?`, in place of ${e.approvedVersion}`:``}.${e.tried?` Its last try: ${e.tried.outcome}.`:` It was never tried.`} Commit .forgeqe/agents/.releases/${e.id} so your team has it.`:t===`disable`?`Nothing of it runs (not you, your team, Atlas or its schedule) until a person enables it again, here or with forgeqe agent enable.${e.handedBy?.length?` ${e.handedBy.join(`, `)} ${e.handedBy.length===1?`hands`:`hand`} work to it: those hand-offs will be refused meanwhile.`:``}`:t===`enable`?`Version ${e.approvedVersion} runs again.`:t===`discard`?`Its manifest goes back to version ${e.approvedVersion}, the one that runs; the change waiting for approval is thrown away (the audit log keeps that it was).`:t===`delete`?`${e.name} will be removed for good: its manifest, approved versions, runs and waiting approvals. Knowledge files and skills it named stay in the project.${e.handedBy?.length?` ${e.handedBy.join(`, `)} ${e.handedBy.length===1?`hands`:`hand`} work to it: those hand-offs will be refused.`:``}`:`Version ${n} runs from now on, in place of ${e.approvedVersion}.`,w=async()=>{u(!0),f(``);try{i(await R.act(e.id,t,{confirm:a,...s.trim()?{note:s.trim()}:{},...n?{to:n}:{},...h&&g?{skipChecks:!0}:{}}))}catch(e){f(e.message),u(!1)}};return(0,Y.jsx)(yt,{open:!0,onClose:r,title:C.title,description:ee,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(H,{variant:`ghost`,onClick:r,children:[(0,Y.jsx)(p,{"aria-hidden":`true`}),`Cancel`]}),(0,Y.jsxs)(H,{variant:t===`delete`||t===`discard`?`destructive`:`primary`,disabled:l||a!==e.id||h&&!g||x||S,onClick:()=>void w(),children:[(0,Y.jsx)(C.icon,{"aria-hidden":`true`}),C.button]})]}),children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[t===`approve`&&e.state===`drifted`&&e.drift&&(0,Y.jsx)(G,{id:`ca-approve-drift`,icon:ae,title:(0,Y.jsxs)(Y.Fragment,{children:[`What it knows that changed since `,e.approvedVersion,` was approved`]}),level:3,children:(0,Y.jsx)(`ul`,{className:`m-0 list-disc rounded-[12px] card border py-4 pr-4 pl-10 text-sm text-ink`,children:e.drift.map(e=>(0,Y.jsx)(`li`,{children:e},e))})}),t===`approve`&&(e.permissions||[]).length>0&&(0,Y.jsx)(G,{id:`ca-approve-may`,icon:xe,title:(0,Y.jsx)(Y.Fragment,{children:e.approvedVersion?`What it may do, against ${e.approvedVersion}`:`What it may do`}),level:3,children:(0,Y.jsx)(jr,{lines:e.permissions})}),m&&(0,Y.jsxs)(`div`,{role:h?`alert`:void 0,className:F(`flex flex-col gap-2 rounded-[12px] px-4 py-4 text-sm`,h?`bg-warn-soft`:`bg-surface-muted`),children:[(0,Y.jsx)(`span`,{className:F(`font-medium`,h?`text-warn`:`text-ink`),children:h?`Its checks have not all passed on version ${e.manifestVersion}`:`Its ${m.total} ${m.total===1?`check`:`checks`} passed on version ${e.manifestVersion}`}),m.failed.length>0&&(0,Y.jsxs)(`span`,{className:`text-[13px] text-ink-2`,children:[`Failed: `,m.failed.join(`, `)]}),m.missing.length>0&&(0,Y.jsxs)(`span`,{className:`text-[13px] text-ink-2`,children:[`Not run on this version: `,m.missing.join(`, `),`. Run them under Details, Checks, or with `,(0,Y.jsxs)(`span`,{className:`font-mono`,children:[`forgeqe agent test `,e.id]}),`.`]}),h&&(0,Y.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2`,children:[(0,Y.jsx)(Rt,{checked:g,onCheckedChange:e=>_(e===!0),className:`mt-1`}),(0,Y.jsx)(`span`,{children:`Approve it without them (kept in its history)`})]})]}),v&&(v.people>1||v.owners.length>0)&&(0,Y.jsxs)(`div`,{role:x||S?`alert`:void 0,className:F(`flex flex-col gap-2 rounded-[12px] px-4 py-4 text-sm`,x||S?`bg-warn-soft`:`bg-surface-muted`),children:[(0,Y.jsx)(`span`,{className:F(`font-medium`,x||S?`text-warn`:`text-ink`),children:x?`Only ${v.owners.join(`, `)} may approve it`:S?`You already approved this version: another person approves it next`:v.people>1?`It needs ${v.people} different people to approve it`:`Only ${v.owners.join(`, `)} may approve it`}),v.people>1&&(0,Y.jsxs)(`span`,{className:`text-[13px] text-ink-2`,children:[`Approved so far by `,v.signed.map(e=>e.by).join(`, `)||`nobody`,`.`]}),(0,Y.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[`ForgeQE knows you as `,v.you||`nobody`,`, git's user name on this computer: an agreement the history keeps, not a sign-in.`]})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsxs)(`span`,{children:[`Type `,(0,Y.jsx)(`span`,{className:`font-mono`,children:e.id}),` to confirm`]}),(0,Y.jsx)(V,{value:a,onChange:e=>o(e.target.value),autoComplete:`off`,spellCheck:!1})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{children:`Note (optional)`}),(0,Y.jsx)(V,{value:s,maxLength:200,onChange:e=>c(e.target.value),placeholder:t===`rollback`?`Why it goes back`:`What changed, or why`})]}),d&&(0,Y.jsx)(`p`,{role:`alert`,className:`m-0 text-sm text-fail [overflow-wrap:anywhere]`,children:d})]})})}var zr={legitimate:`Legitimate`,opportunistic:`Opportunistic`,adversarial:`Adversarial`},Br={sme:`Subject matter expert`,end_user:`End user`,specialist:`Specialist`,business_user:`Business user`},Vr=[`personas`,`about`],Hr={personas:`Personas`,about:`Tools and conversations`},Ur={personas:j,about:re};function Wr({current:e,count:t}){let[n,r]=(0,J.useState)(null);(0,J.useEffect)(()=>{t===void 0&&I.list().then(e=>r(e.personas.length),()=>r(null))},[t===void 0]);let i=t??n;return(0,Y.jsx)(xt,{label:`Mask's pages`,current:e,links:[{id:`agent`,label:`Agent`,href:M(`agents`,`persona`),icon:Ft(`persona`)},{id:`personas`,label:i===null?`Personas`:`Personas (${i})`,href:M(`agents`,`persona`,`personas`),icon:Ur.personas},{id:`about`,label:`Tools and conversations`,href:M(`agents`,`persona`,`about`),icon:Ur.about}]})}var Gr=/^[a-z0-9][a-z0-9-]{0,39}$/,Kr=/^[a-z][a-z0-9-]{1,39}$/,qr=e=>M(`agents`,`persona`,`personas`,encodeURIComponent(e));function Jr({page:e,tab:t,sub:n}){let[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)([]),[s,c]=(0,J.useState)(``),l=t===`new`,u=Vr.includes(t)?t:`personas`,d=()=>I.list().then(e=>{i(e.personas),o(e.notLoaded),c(``)},e=>c(`The personas did not load: ${e.message}`));(0,J.useEffect)(()=>{d()},[]);let f=u===`personas`&&n?ge(n):``;return(0,Y.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,Y.jsx)(an,{}),(0,Y.jsxs)(`main`,{className:F(vt,`@container flex-auto gap-4`),children:[(0,Y.jsx)(Et,{agent:e,tabs:(0,Y.jsx)(Wr,{current:u,...r?{count:r.length}:{}})}),(0,Y.jsx)(pt,{icon:Ur[u],title:Hr[u]}),s&&(0,Y.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,Y.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}),r&&(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsxs)(`div`,{children:[u===`personas`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Yr,{personas:r,notLoaded:a,onChanged:e=>(i(e.personas),o(e.notLoaded))}),(0,Y.jsx)($r,{personas:r,opened:f,onChanged:e=>(i(e.personas),o(e.notLoaded))}),(0,Y.jsx)(li,{open:l,onClose:()=>location.hash=Xr,personas:r,onSaved:e=>{d().then(()=>(ni=e,location.hash=qr(e)))}})]}),u===`about`&&(0,Y.jsx)(en,{page:e,onTab:!0})]})})]})]})}function Yr({personas:e,notLoaded:t,onChanged:n}){let[r,a]=(0,J.useState)(`all`),[o,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(``),[d,f]=(0,J.useState)(``),[p,m]=(0,J.useState)(!1),h=(0,J.useRef)(null),g=e.filter(e=>!e.builtIn).length,_=async()=>{u(``),f(``);try{let e=await I.exportFile(),t=URL.createObjectURL(new Blob([`${JSON.stringify(e,null,2)}\n`],{type:`application/json;charset=utf-8`})),n=document.createElement(`a`);n.href=t,n.download=`forgeqe-personas.json`,n.click(),setTimeout(()=>URL.revokeObjectURL(t),1e3),u(`Exported ${z(g,`persona`)} of your own. Another project imports the file here.`)}catch(e){f(e.message)}},v=async e=>{let t=e?.[0];if(t){if(u(``),f(``),t.size>262144)return f(`${t.name} is over 256 KB.`);m(!0);try{let e=await I.importFile(await t.text());n(e),u(e.added.length?`Imported ${e.added.length===1?`the persona`:`${e.added.length} personas:`} ${e.added.join(`, `)}.`:`No new persona in the file.`),e.skipped.length&&f(`Not imported: ${e.skipped.map(e=>`${e.id} (${e.why})`).join(`; `)}`)}catch(e){f(e.message)}finally{m(!1)}}},y=o.toLowerCase().split(/\s+/).filter(Boolean),b=e.filter(e=>(r===`all`||e.kind===r)&&y.every(t=>`${e.name} ${e.role} ${e.domain} ${e.id} /${e.handle}`.toLowerCase().includes(t)));return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsxs)(`p`,{className:`m-0 mr-auto flex flex-wrap items-center gap-x-1 text-sm text-ink-2 tabular-nums`,children:[(0,Y.jsx)(W,{icon:j,size:14,className:`text-muted`}),z(e.length,`persona`),` · `,g,` of your own`,t.length?(0,Y.jsxs)(Y.Fragment,{children:[` · `,(0,Y.jsxs)(`span`,{className:`text-fail`,children:[t.length,` not loaded`]})]}):null]}),(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[g>0&&(0,Y.jsxs)(H,{size:`sm`,onClick:()=>void _(),"data-tip":`A file of your own personas, for another project to import`,children:[(0,Y.jsx)(ye,{"aria-hidden":`true`}),`Export`]}),(0,Y.jsxs)(H,{size:`sm`,disabled:p,onClick:()=>h.current?.click(),"data-tip":`Personas another project exported`,children:[(0,Y.jsx)(ee,{"aria-hidden":`true`}),p?`Importing…`:`Import`]}),(0,Y.jsxs)(H,{size:`sm`,variant:`primary`,onClick:()=>location.hash=M(`agents`,`persona`,`new`),"data-tip":`Describe a person and Mask drafts the persona, or write it yourself`,children:[(0,Y.jsx)(i,{"aria-hidden":`true`}),`New persona`]})]}),(0,Y.jsx)(`input`,{ref:h,type:`file`,accept:`.json,application/json`,hidden:!0,onChange:e=>(v(e.target.files),e.target.value=``)})]}),l&&(0,Y.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:l}),d&&(0,Y.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-4 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:d}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(rt,{id:`persona-find`,label:`Find a persona`,value:o,onChange:c}),(0,Y.jsx)($e,{items:[{id:`all`,label:`All`,n:e.length},...Ge.map(t=>({id:t,label:Br[t],n:e.filter(e=>e.kind===t).length}))],value:r,onChange:a})]}),b.length===0?(0,Y.jsx)(et,{className:`py-4`,children:e.length?`No persona matches.`:`There are no personas yet.`}):(0,Y.jsx)(`ul`,{"aria-label":`Personas`,className:`m-0 flex list-none flex-col rounded-[12px] card border p-2`,children:b.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`a`,{href:qr(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,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Y.jsxs)(`span`,{className:`truncate text-[13px] font-medium`,"data-tip":e.name,children:[e.name,!e.builtIn&&(0,Y.jsx)(`span`,{className:`font-normal text-muted`,children:` · yours`})]}),(0,Y.jsxs)(`span`,{className:`truncate text-[13px] text-muted`,children:[(0,Y.jsxs)(`span`,{className:`font-mono`,children:[`/`,e.handle]}),` · `,Br[e.kind],e.intent===`legitimate`?``:` · ${zr[e.intent].toLowerCase()}`,` · `,e.role,e.domain?` · ${e.domain}`:``]})]}),(0,Y.jsx)(`span`,{className:`flex-none text-[13px] text-muted tabular-nums`,children:z(e.validates.length,`check`)})]})},e.id))}),t.length>0&&(0,Y.jsx)(G,{id:`persona-not-loaded`,icon:s,title:`Not loaded`,level:3,children:(0,Y.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0`,children:t.map(e=>(0,Y.jsx)(`li`,{className:`text-[13px] text-fail [overflow-wrap:anywhere]`,children:e},e))})}),(0,Y.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 Xr=M(`agents`,`persona`,`personas`),Zr=e=>{let{builtIn:t,...n}=e;return n},Qr=(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 $r({personas:e,opened:n,onChanged:r}){let[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(!1),[c,u]=(0,J.useState)(``),d=i?void 0:e.find(e=>e.id===n),f=!!n&&!i&&!d,m=()=>location.hash=Xr,h=(t,n)=>{let r=new Set(e.flatMap(e=>[e.id,e.handle])),i=n===`copy`?{...Zr(t),id:Qr(t.id,r),handle:``}:Zr(t);u(``),a({mode:n,from:t,fields:i,listText:Object.fromEntries(si.map(({key:e})=>[e,t[e].join(`
6
- `)]))})},g=(0,J.useMemo)(()=>new Set(e.filter(e=>i?.mode!==`edit`||e.id!==i.from.id).flatMap(e=>[e.id,e.handle])),[e,i]),_=i?ui(i.fields,i.listText,g,i.mode===`edit`):null,v=ei(!!n||!!i),y=async(e,t,n)=>{e[t].includes(n)||r(await I.update(e.id,{...Zr(e),[t]:[...e[t],n]}))},b=async()=>{if(i&&_?.canSave){s(!0),u(``);try{let e={...i.fields,...Object.fromEntries(si.map(({key:e})=>[e,ci(i.listText[e]||``)]))},t=i.mode===`edit`?await I.update(i.from.id,e):await I.save(e);r(t),a(null),i.mode===`copy`&&(ni=t.saved),location.hash=qr(t.saved)}catch(e){u(e.message)}finally{s(!1)}}};return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(yt,{wide:!0,open:!!d||f,onClose:m,title:d?.name||`No such persona`,description:d?d.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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(H,{onClick:m,children:[(0,Y.jsx)(p,{"aria-hidden":`true`}),`Close`]}),d&&!d.builtIn&&(0,Y.jsxs)(H,{variant:`primary`,onClick:()=>h(d,`edit`),children:[(0,Y.jsx)(l,{"aria-hidden":`true`}),`Edit`]}),d?.builtIn&&(0,Y.jsxs)(H,{variant:`primary`,"data-tip":`Make your own persona from this one, under another id and command`,onClick:()=>h(d,`copy`),children:[(0,Y.jsx)(t,{"aria-hidden":`true`}),`Copy to edit`]})]}),children:d?(0,Y.jsx)(ai,{persona:d,resources:v,onAdd:d.builtIn?void 0:(e,t)=>y(d,e,t)}):(0,Y.jsxs)(et,{className:`py-6`,children:[`There is no persona "`,n,`" in this project.`]})}),(0,Y.jsx)(yt,{wide:!0,open:!!i,onClose:()=>a(null),title:i?.mode===`edit`?`Edit ${i.from.name}`:`Copy ${i?.from.name||``}`,description:(0,Y.jsxs)(Y.Fragment,{children:[i?.mode===`copy`&&(0,Y.jsx)(Y.Fragment,{children:`A persona of your own, made from the built-in one, which stays as it is. `}),`Saved in `,(0,Y.jsxs)(`span`,{className:`font-mono text-[13px]`,children:[`.forgeqe/business-personas/`,i?.fields.id||`<id>`,`.yaml`]}),`, shared with everyone who uses the repository.`]}),footer:(0,Y.jsxs)(Y.Fragment,{children:[c?(0,Y.jsx)(`span`,{role:`alert`,className:`mr-auto self-center text-sm text-fail [overflow-wrap:anywhere]`,children:c}):i&&!_?.canSave&&(0,Y.jsxs)(`span`,{className:`mr-auto self-center text-[13px] text-muted`,children:[`It needs a name, `,i.mode===`copy`?`an id, `:``,`a role, and what they check or want.`]}),(0,Y.jsxs)(H,{onClick:()=>a(null),children:[(0,Y.jsx)(p,{"aria-hidden":`true`}),`Cancel`]}),(0,Y.jsxs)(H,{variant:`primary`,disabled:o||!_?.canSave,onClick:()=>void b(),children:[(0,Y.jsx)(C,{"aria-hidden":`true`}),o?`Saving…`:i?.mode===`copy`?`Save copy`:`Save`]})]}),children:i&&_&&(0,Y.jsx)(`div`,{className:`pt-4`,children:(0,Y.jsx)(di,{fields:i.fields,listText:i.listText,onFields:e=>a({...i,fields:e}),onListText:e=>a({...i,listText:e}),check:_,idLocked:i.mode===`edit`,resources:v})})})]})}function ei(e){let[t,n]=(0,J.useState)(null);return(0,J.useEffect)(()=>{e&&!t&&I.resources().then(n,e=>n({skills:[],documents:[],error:`The skills and documents did not load: ${e.message}`}))},[e,t]),t}function ti({persona:e,resources:t,onAdd:n}){let[r,a]=(0,J.useState)(null),o=t?.error?null:t,[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(``),d=`${e.skills.join(`,`)}|${e.knowledge.join(`,`)}`;(0,J.useEffect)(()=>{a(null),I.suggest(e.id).then(a,e=>a({skills:[],documents:[],error:`The suggestions did not load: ${e.message}`}))},[e.id,d]);let f=e=>o?.skills.find(t=>t.name===e),p=e=>o?.documents.find(t=>t.ref===e),m=(0,Y.jsx)(`span`,{className:`text-warn`,children:` · not in this project`}),h=async(e,t)=>{if(n){c(`${e}:${t}`),u(``);try{await n(e,t)}catch(e){u(e.message)}finally{c(``)}}},g=r?[...r.skills.map(e=>({key:`skills`,...e})),...r.documents.map(e=>({key:`knowledge`,...e}))]:[];return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(G,{id:`persona-uses`,icon:Ce,title:`Shared skills and documents`,level:3,children:[e.skills.length+e.knowledge.length===0?(0,Y.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,Y.jsxs)(`ul`,{"aria-label":`Skills and documents`,className:`m-0 flex list-none flex-col p-0`,children:[e.skills.map(e=>(0,Y.jsxs)(`li`,{className:`flex items-start gap-4 border-t border-line-soft py-2`,children:[(0,Y.jsx)(W,{icon:Ce,size:16,className:`mt-1 text-muted`}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`font-mono text-[13px] [overflow-wrap:anywhere]`,children:e}),(0,Y.jsxs)(`span`,{className:`text-[13px] text-muted [overflow-wrap:anywhere]`,children:[`Skill`,o&&!f(e)?m:f(e)?` · ${f(e).description}`:``]})]})]},`s:${e}`)),e.knowledge.map(e=>(0,Y.jsxs)(`li`,{className:`flex items-start gap-4 border-t border-line-soft py-2`,children:[(0,Y.jsx)(W,{icon:Ee,size:16,className:`mt-1 text-muted`}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-[13px] font-medium [overflow-wrap:anywhere]`,children:p(e)?.title||e}),(0,Y.jsxs)(`span`,{className:`font-mono text-[13px] text-muted [overflow-wrap:anywhere]`,children:[e,o&&!p(e)?m:null]})]})]},`k:${e}`))]}),t?.error&&(0,Y.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,Y.jsxs)(G,{id:`persona-suggested`,icon:ue,title:`Suggested for them`,level:3,children:[r?r.error?(0,Y.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,Y.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Nothing else matches their domain and checks. Add documents in Settings › Product knowledge, or knowledge notes, to see more.`}):(0,Y.jsx)(`ul`,{"aria-label":`Suggested skills and documents`,className:`m-0 flex list-none flex-col p-0`,children:g.map(t=>(0,Y.jsxs)(`li`,{className:`flex items-center gap-4 border-t border-line-soft py-2`,children:[(0,Y.jsx)(W,{icon:t.key===`skills`?Ce:Ee,size:16,className:`text-muted`}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:F(`text-[13px] [overflow-wrap:anywhere]`,t.key===`skills`?`font-mono`:`font-medium`),children:t.key===`knowledge`&&p(t.name)?.title||t.name}),(0,Y.jsxs)(`span`,{className:`text-[13px] text-muted [overflow-wrap:anywhere]`,children:[t.key===`skills`?`Skill`:t.name,` · matched `,t.why]})]}),n&&(0,Y.jsxs)(H,{size:`sm`,disabled:!!s,onClick:()=>void h(t.key,t.name),"data-tip":`Add to what ${e.name} uses`,children:[(0,Y.jsx)(i,{"aria-hidden":`true`}),s===`${t.key}:${t.name}`?`Adding…`:`Add`]})]},`${t.key}:${t.name}`))}):(0,Y.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Looking for skills and documents that match…`}),l&&(0,Y.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})]})]})}var ni=``,ri=e=>e.name.split(`,`)[0].trim()||e.name;function ii({persona:e}){let[t,n]=(0,J.useState)(null),[r,i]=(0,J.useState)(null),[o,s]=(0,J.useState)(``),[c,d]=(0,J.useState)(``),[f,m]=(0,J.useState)(``),h=ri(e),g=()=>I.own(e.id).then(n,e=>n({skills:[],knowledge:[],problems:[],error:`${h}'s own skills and notes did not load: ${e.message}`})),_=async()=>{s(`draft`),d(``);try{let[t,n]=await Promise.all([I.draftOwn(e.id),I.own(e.id)]),r=(e,t)=>n[e].some(e=>e.name===t);m(``),i({drafted:!0,items:[t.skill,t.knowledge].map(e=>({...e,replace:r(e.kind,e.name)}))})}catch(e){d(e.message)}finally{s(``)}};(0,J.useEffect)(()=>{n(null),g(),ni===e.id&&(ni=``,_())},[e.id]);let v=async()=>{if(r){s(`save`),m(``);try{let t=r.items.filter(e=>e.was&&e.was!==e.name),a=await I.saveOwn(e.id,r.items.map(({was:e,...n})=>({...n,replace:n.replace&&!t.some(e=>e.kind===n.kind&&e.name===n.name)})));i({...r,items:r.items.map(e=>({...e,replace:!0}))});for(let n of t)await I.removeOwn(e.id,n.kind,n.was);n(t.length?await I.own(e.id):a),i(null)}catch(e){m(e.message),g()}finally{s(``)}}},y=async t=>{s(`remove:${t.kind}/${t.name}`),m(``);try{n(await I.removeOwn(e.id,t.kind,t.name)),i(null)}catch(e){m(e.message)}finally{s(``)}},b=t?[...t.skills,...t.knowledge]:[],x=(e,t)=>r&&i({...r,items:r.items.map((n,r)=>r===e?{...n,...t}:n)}),S=!!r&&r.items.every(e=>/^[a-z0-9]+(-[a-z0-9]+)*$/.test(e.name)&&e.body.trim()&&(e.kind===`knowledge`||e.description.trim()));return(0,Y.jsxs)(G,{id:`persona-own`,icon:E,level:3,title:(0,Y.jsxs)(Y.Fragment,{children:[h,`'s own skills and knowledge`]}),description:(0,Y.jsxs)(Y.Fragment,{children:[`Used only when someone works as `,h,`, never by other agents.`]}),actions:(0,Y.jsxs)(H,{size:`sm`,disabled:!!o||!t,onClick:()=>void _(),"data-tip":`Mask drafts a skill and a knowledge note for ${h}; you review them before anything is saved`,children:[(0,Y.jsx)(u,{"aria-hidden":`true`}),o===`draft`?`Generating…`:b.length?`Generate again`:`Generate skill and knowledge`]}),children:[o===`draft`&&(0,Y.jsxs)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:[`Mask is writing `,h,`'s skill and knowledge note…`]}),t?b.length===0?!t.error&&o!==`draft`&&(0,Y.jsxs)(`p`,{className:`m-0 text-sm text-muted`,children:[`None yet. Generate a skill and a knowledge note from `,h,`'s checks, then change them as you need.`]}):(0,Y.jsx)(`ul`,{"aria-label":`${h}'s own skills and knowledge`,className:`m-0 flex list-none flex-col p-0`,children:b.map(e=>(0,Y.jsxs)(`li`,{className:`flex items-center gap-4 border-t border-line-soft py-2`,children:[(0,Y.jsx)(W,{icon:e.kind===`skills`?Ce:Ee,size:16,className:`text-muted`}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`font-mono text-[13px] [overflow-wrap:anywhere]`,children:e.name}),(0,Y.jsx)(`span`,{className:`line-clamp-2 text-[13px] text-muted [overflow-wrap:anywhere]`,children:e.kind===`skills`?`Skill · ${e.description}`:`Knowledge note`})]}),(0,Y.jsxs)(H,{size:`sm`,disabled:!!o,onClick:()=>(m(``),i({drafted:!1,items:[{...e,replace:!0,was:e.name}]})),children:[(0,Y.jsx)(l,{"aria-hidden":`true`}),`Edit`]})]},`${e.kind}:${e.name}`))}):(0,Y.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}),t?.problems.length?(0,Y.jsxs)(`p`,{className:`m-0 text-[13px] text-warn [overflow-wrap:anywhere]`,children:[`Not read: `,t.problems.join(`; `)]}):null,(c||t?.error)&&(0,Y.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,Y.jsx)(yt,{wide:!0,open:!!r,onClose:()=>i(null),title:r?.drafted?`Review ${h}'s skill and knowledge`:`Edit ${r?.items[0]?.was||``}`,description:(0,Y.jsxs)(Y.Fragment,{children:[r?.drafted&&(0,Y.jsx)(Y.Fragment,{children:`Mask's draft: change anything, then save. `}),`Kept in `,(0,Y.jsxs)(`span`,{className:`font-mono text-[13px]`,children:[`.forgeqe/business-personas/`,e.id,`/`]}),` and used only when someone works as `,h,`.`]}),footer:(0,Y.jsxs)(Y.Fragment,{children:[f?(0,Y.jsx)(`span`,{role:`alert`,className:`mr-auto self-center text-sm text-fail [overflow-wrap:anywhere]`,children:f}):r&&!S&&(0,Y.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.`}),r&&!r.drafted&&r.items[0]?.was&&(0,Y.jsxs)(H,{disabled:!!o,onClick:()=>void y({...r.items[0],name:r.items[0].was}),className:F(!f&&S&&`mr-auto`,`text-fail`),children:[(0,Y.jsx)(a,{"aria-hidden":`true`}),o.startsWith(`remove:`)?`Deleting…`:`Delete`]}),(0,Y.jsxs)(H,{onClick:()=>i(null),children:[(0,Y.jsx)(p,{"aria-hidden":`true`}),`Cancel`]}),(0,Y.jsxs)(H,{variant:`primary`,disabled:o===`save`||!S,onClick:()=>void v(),children:[(0,Y.jsx)(C,{"aria-hidden":`true`}),o===`save`?`Saving…`:r?.drafted?`Save both`:`Save`]})]}),children:r&&(0,Y.jsx)(`div`,{className:`flex flex-col gap-6 pt-4`,children:r.items.map((e,t)=>(0,Y.jsxs)(`section`,{"aria-labelledby":`own-item-${t}`,className:`flex flex-col gap-4`,children:[(0,Y.jsxs)(`h3`,{id:`own-item-${t}`,className:`m-0 flex items-center gap-2 text-[13px] font-semibold text-muted`,children:[(0,Y.jsx)(W,{icon:e.kind===`skills`?Ce:Ee,size:14}),e.kind===`skills`?`Skill`:`Knowledge note`,e.replace&&!e.was&&(0,Y.jsx)(`span`,{className:`font-normal text-warn`,children:` · replaces the one of this name`})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Name`}),(0,Y.jsx)(V,{value:e.name,maxLength:64,spellCheck:!1,autoComplete:`off`,className:`font-mono`,onChange:e=>x(t,{name:e.target.value.toLowerCase().replace(/[^a-z0-9-]+/g,`-`)})})]}),e.kind===`skills`&&(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Use when`}),(0,Y.jsx)(V,{value:e.description,maxLength:400,onChange:e=>x(t,{description:e.target.value})})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`label`,{htmlFor:`own-body-${t}`,className:`font-medium`,children:e.kind===`skills`?`Instructions`:`What it says`}),(0,Y.jsx)(Zt,{id:`own-body-${t}`,value:e.body,lang:`markdown`,onChange:e=>x(t,{body:e})})]})]},t))})})]})}function ai({persona:e,resources:t,onAdd:n}){let r=[[`persona-validates`,`What they check before accepting the software`,e.validates,Se],[`persona-goals`,`What they want to do`,e.goals,_e],[`persona-knows`,`What they know`,e.knows,E],[`persona-frustrations`,`What puts them off`,e.frustrations,s],[`persona-scenarios`,`What they would try`,e.scenarios,pe],[`persona-motivations`,`What drives them`,e.motivations,ue],[`persona-permissions`,`What their role lets them do`,e.permissions,xe],[`persona-constraints`,`What limits them`,e.constraints,O],[`persona-mistakes`,`Mistakes they make`,e.mistakes,c],[`persona-relationships`,`Who they deal with`,e.relationships,j]];return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-6 pt-4`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`p`,{className:`m-0 text-[13px] text-muted`,children:[(0,Y.jsxs)(`span`,{className:`font-mono`,children:[`/`,e.handle]}),` · `,Br[e.kind],` · `,e.role,e.domain?` · ${e.domain}`:``,` · `,e.expertise.charAt(0).toUpperCase()+e.expertise.slice(1),e.intent===`legitimate`?``:` · ${zr[e.intent].toLowerCase()}, risk appetite ${e.risk_appetite}`,e.builtIn?``:` · version ${e.version}`]}),e.description&&(0,Y.jsx)(`p`,{className:`m-0 text-sm leading-relaxed text-ink-2`,children:e.description})]}),(0,Y.jsx)(ii,{persona:e}),(0,Y.jsx)(ti,{persona:e,resources:t,...n?{onAdd:n}:{}}),r.filter(([,,e])=>e.length).map(([e,t,n,r])=>(0,Y.jsx)(G,{id:e,icon:r,title:t,level:3,children:(0,Y.jsx)(`ul`,{className:`m-0 flex list-disc flex-col gap-1 pl-6 text-sm text-ink-2`,children:n.map(e=>(0,Y.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:e},e))})},e))]})}var oi={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:[]},si=[{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.`}],ci=e=>e.split(`
4
+ `).map(e=>e.slice(0,300))})}),(0,Y.jsx)(q,{help:`What its starters and its schedule leave open, at most 6. Write {name} in a starter or the schedule's request (not a trigger's: nobody is there to give the value); its page asks for the value (one line of text, or a pick from its list) before the starter fills the message.`,icon:x,children:`Inputs`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[(r.inputs||[]).map((e,t)=>{let n=e=>j({inputs:(r.inputs||[]).map((n,r)=>r===t?{...n,...e}:n)});return(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(V,{"aria-label":`Input ${t+1} name`,className:`w-[140px] font-mono`,maxLength:32,spellCheck:!1,value:e.name,placeholder:`name`,onChange:e=>n({name:e.target.value.toLowerCase()})}),(0,Y.jsx)(V,{"aria-label":`Input ${t+1} label`,className:`w-[200px]`,maxLength:40,value:e.label,placeholder:`Label`,onChange:e=>n({label:e.target.value})}),(0,Y.jsx)(B,{"aria-label":`Input ${t+1} kind`,className:`w-[200px]`,value:e.kind,onChange:t=>{let r=t.target.value;n(r===`choice`?{kind:r,options:e.options||[]}:{kind:r,options:void 0})},children:jn.map(e=>(0,Y.jsx)(`option`,{value:e,children:nr[e]},e))}),e.kind===`choice`&&(0,Y.jsx)(dr,{label:`Input ${t+1} options, separated by commas`,options:e.options||[],onChange:e=>n({options:e})}),(0,Y.jsx)(H,{variant:`icon`,size:`icon`,"aria-label":`Remove input ${t+1}`,"data-tip":`Remove input ${t+1}`,onClick:()=>j({inputs:(r.inputs||[]).filter((e,n)=>n!==t)}),children:(0,Y.jsx)(a,{"aria-hidden":`true`})})]},t)}),(r.inputs||[]).length<6&&(0,Y.jsxs)(H,{size:`sm`,className:`self-start`,onClick:()=>j({inputs:[...r.inputs||[],{name:``,label:``,kind:`text`}]}),"data-tip":`Add an input`,children:[(0,Y.jsx)(i,{"aria-hidden":`true`}),`Add`]})]}),(0,Y.jsx)(q,{help:`Requests its page offers to start from (at most ${Qn}). {name} uses one of its inputs.`,icon:De,children:`Starters`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[r.starters.map((e,t)=>(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(V,{"aria-label":`Starter ${t+1} label`,className:`w-[200px]`,maxLength:40,value:e.label,placeholder:`Label`,onChange:e=>j({starters:r.starters.map((n,r)=>r===t?{...n,label:e.target.value}:n)})}),(0,Y.jsx)(V,{"aria-label":`Starter ${t+1} request`,className:`min-w-0 flex-[1_1_280px]`,maxLength:500,value:e.text,placeholder:`The request`,onChange:e=>j({starters:r.starters.map((n,r)=>r===t?{...n,text:e.target.value}:n)})}),(0,Y.jsx)(H,{variant:`icon`,size:`icon`,"aria-label":`Remove starter ${t+1}`,"data-tip":`Remove starter ${t+1}`,onClick:()=>j({starters:r.starters.filter((e,n)=>n!==t)}),children:(0,Y.jsx)(a,{"aria-hidden":`true`})})]},t)),r.starters.length<Qn&&(0,Y.jsxs)(H,{size:`sm`,className:`self-start`,onClick:()=>j({starters:[...r.starters,{label:``,text:``}]}),"data-tip":`Add a starter`,children:[(0,Y.jsx)(i,{"aria-hidden":`true`}),`Add`]})]}),(0,Y.jsx)(q,{help:`Short facts it keeps between runs with its remember tool and reads back with recall: what it found, never instructions. You can read and forget them on its page, under Details, Memory.`,icon:E,children:`Memory`}),(0,Y.jsx)(K,{label:`Notes it keeps`,htmlFor:`ca-notes`,help:`At most 200; past that the oldest go. None: it starts every run knowing only its manifest.`,children:(0,Y.jsxs)(B,{id:`ca-notes`,className:`w-[200px]`,value:String(r.memory?.notes||0),onChange:e=>j({memory:Number(e.target.value)?{notes:Number(e.target.value)}:void 0}),children:[(0,Y.jsx)(`option`,{value:`0`,children:`No memory`}),[20,50,100,200].map(e=>(0,Y.jsxs)(`option`,{value:e,children:[`Up to `,e,` notes`]},e)),r.memory&&![20,50,100,200].includes(r.memory.notes)&&(0,Y.jsxs)(`option`,{value:r.memory.notes,children:[`Up to `,r.memory.notes,` notes`]})]})}),(0,Y.jsx)(q,{help:`Who approves a version before it runs. ForgeQE knows a person by git's user name on their computer, so this is an agreement the history keeps, not a sign-in. A change is approved under the stricter of this and the version that runs.`,icon:m,children:`Approval`}),(0,Y.jsx)(K,{label:`People who approve`,htmlFor:`ca-people`,help:`How many different people approve a version. Each but the last signs it; it runs once the last approves.`,children:(0,Y.jsx)(B,{id:`ca-people`,className:`w-[200px]`,value:String(r.approval?.people||1),onChange:e=>j({approval:{people:Number(e.target.value),owners:r.approval?.owners||[]}}),children:[1,2,3].map(e=>(0,Y.jsx)(`option`,{value:e,children:e===1?`One person`:`${e} different people`},e))})}),(0,Y.jsx)(K,{label:`Who may approve`,htmlFor:`ca-owners`,help:`People's names as git knows them (user.name, or user.email). None: anyone who can approve agents in this project.`,children:(0,Y.jsx)(dr,{id:`ca-owners`,label:`Who may approve, separated by commas`,placeholder:`Ann Lee, Bo Chen`,max:20,options:r.approval?.owners||[],onChange:e=>j({approval:{people:r.approval?.people||1,owners:e}})})}),(0,Y.jsx)(q,{help:`Requests to try it on before it is approved, at most 8: forgeqe agent test runs them on the manifest as it is and grades each by code from the run (how it ended, words its reply holds or not, tools it used or never called). A version whose checks have not all passed is approved only when a person says so.`,icon:Se,children:`Checks`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4 py-2`,children:[(r.checks||[]).map((e,t)=>{let n=e=>j({checks:(r.checks||[]).map((n,r)=>r===t?{...n,...e}:n)}),i=t=>n({expect:{...e.expect,...t}});return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(V,{"aria-label":`Check ${t+1} name`,className:`w-[200px] font-mono`,maxLength:40,spellCheck:!1,value:e.name,placeholder:`basket-total`,onChange:e=>n({name:e.target.value.toLowerCase()})}),(0,Y.jsx)(V,{"aria-label":`Check ${t+1} request`,className:`min-w-0 flex-[1_1_280px]`,maxLength:500,value:e.request,placeholder:`The request it is tried on`,onChange:e=>n({request:e.target.value})}),(0,Y.jsx)(H,{variant:`icon`,size:`icon`,"aria-label":`Remove check ${t+1}`,"data-tip":`Remove check ${t+1}`,onClick:()=>j({checks:(r.checks||[]).filter((e,n)=>n!==t)}),children:(0,Y.jsx)(a,{"aria-hidden":`true`})})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pl-6`,children:[(0,Y.jsxs)(B,{"aria-label":`Check ${t+1} ends`,className:`w-[200px]`,value:e.expect.outcome,onChange:e=>i({outcome:e.target.value}),children:[(0,Y.jsx)(`option`,{value:`done`,children:`Ends done`}),(0,Y.jsx)(`option`,{value:`needs_input`,children:`Ends needing a person`}),(0,Y.jsx)(`option`,{value:`failed`,children:`Ends failed`})]}),(0,Y.jsx)(dr,{label:`Check ${t+1}: words its reply says, separated by commas`,placeholder:`Its reply says…`,max:16,options:e.expect.says,onChange:e=>i({says:e})}),(0,Y.jsx)(dr,{label:`Check ${t+1}: words its reply never says, separated by commas`,placeholder:`…and never says`,max:16,options:e.expect.neverSays,onChange:e=>i({neverSays:e})}),(0,Y.jsx)(dr,{label:`Check ${t+1}: tools it uses, separated by commas`,placeholder:`Tools it uses`,max:16,mono:!0,options:e.expect.uses,onChange:e=>i({uses:e})}),(0,Y.jsx)(dr,{label:`Check ${t+1}: tools it never calls, separated by commas`,placeholder:`Tools it never calls`,max:16,mono:!0,options:e.expect.neverUses,onChange:e=>i({neverUses:e})}),(r.output?.verdicts.length||0)>0&&(0,Y.jsxs)(B,{"aria-label":`Check ${t+1} verdict`,className:`w-[200px]`,value:e.expect.verdict||``,onChange:e=>i({verdict:e.target.value||void 0}),children:[(0,Y.jsx)(`option`,{value:``,children:`Any verdict`}),r.output.verdicts.map(e=>(0,Y.jsxs)(`option`,{value:e,children:[`Verdict `,e]},e))]})]})]},t)}),(r.checks||[]).length<8&&(0,Y.jsxs)(H,{size:`sm`,className:`self-start`,onClick:()=>j({checks:[...r.checks||[],{name:``,request:``,expect:{outcome:`done`,says:[],neverSays:[],uses:[],neverUses:[]}}]}),"data-tip":`Add a check`,children:[(0,Y.jsx)(i,{"aria-hidden":`true`}),`Add`]})]}),(0,Y.jsx)(q,{help:`What its reply ends with, read by ForgeQE, not by a model: a verdict of your words (at most 8) and named values (at most 12). Each run keeps them, checks can expect a verdict, a verdict you count as a failure tells the team as a failure, and forgeqe agent run exits 1 on it.`,icon:be,children:`Output`}),(0,Y.jsx)(K,{label:`Verdicts`,htmlFor:`ca-verdicts`,help:`Words for how a run came out, such as passed, failed, blocked. Lower-case letters, digits and underscores.`,children:(0,Y.jsx)(dr,{id:`ca-verdicts`,label:`Verdicts, separated by commas`,placeholder:`passed, failed, blocked`,max:8,mono:!0,options:r.output?.verdicts||[],onChange:e=>j({output:{verdicts:e,failOn:(r.output?.failOn||[]).filter(t=>e.includes(t)),fields:r.output?.fields||[]}})})}),(r.output?.verdicts.length||0)>0&&(0,Y.jsx)(K,{label:`Counts as a failure`,help:`A run with one of these verdicts, or with none, tells the team as a failure. Its checks still grade what they expect.`,children:(0,Y.jsx)(`div`,{className:`flex flex-col gap-2`,children:r.output.verdicts.map(e=>(0,Y.jsx)(Q,{checked:r.output.failOn.includes(e),onChange:t=>j({output:{...r.output,failOn:Z(r.output.failOn,e,t)}}),children:e},e))})}),(0,Y.jsx)(K,{label:`Fields`,stacked:!0,help:`Named values its reply reports, each of a kind. Leave a field out of the reply when it could not be found out.`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(r.output?.fields||[]).map((e,t)=>{let n=r.output||{verdicts:[],failOn:[],fields:[]},i=e=>j({output:{...n,fields:n.fields.map((n,r)=>r===t?{...n,...e}:n)}});return(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(V,{"aria-label":`Field ${t+1} name`,className:`w-[200px] font-mono`,maxLength:40,spellCheck:!1,value:e.name,placeholder:`defects_found`,onChange:e=>i({name:e.target.value.toLowerCase()})}),(0,Y.jsx)(B,{"aria-label":`Field ${t+1} kind`,className:`w-[200px]`,value:e.kind,onChange:e=>i({kind:e.target.value}),children:Jn.map(e=>(0,Y.jsx)(`option`,{value:e,children:$n[e]},e))}),(0,Y.jsx)(H,{variant:`icon`,size:`icon`,"aria-label":`Remove field ${t+1}`,"data-tip":`Remove field ${t+1}`,onClick:()=>j({output:{...n,fields:n.fields.filter((e,n)=>n!==t)}}),children:(0,Y.jsx)(a,{"aria-hidden":`true`})})]},t)}),(r.output?.fields.length||0)<12&&(0,Y.jsxs)(H,{size:`sm`,className:`self-start`,onClick:()=>j({output:{verdicts:r.output?.verdicts||[],failOn:r.output?.failOn||[],fields:[...r.output?.fields||[],{name:``,kind:`text`}]}}),"data-tip":`Add a field`,children:[(0,Y.jsx)(i,{"aria-hidden":`true`}),`Add`]})]})}),D.length>0&&(0,Y.jsx)(G,{id:`ca-advice`,icon:s,title:`What it still needs`,level:3,className:`mt-6`,children:(0,Y.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:D.map((e,t)=>(0,Y.jsxs)(`li`,{className:F(`flex flex-col gap-1 rounded-[12px] px-4 py-4 text-sm`,e.blocking?`bg-warn-soft`:`bg-surface-muted`),children:[(0,Y.jsx)(`span`,{className:F(`font-medium`,e.blocking?`text-warn`:`text-ink`),children:e.about}),(0,Y.jsx)(`span`,{className:`text-[13px] text-ink-2`,children:e.why}),(0,Y.jsx)(`span`,{className:`text-[13px] text-muted`,children:e.fix})]},t))})}),(0,Y.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,Y.jsx)(`div`,{role:`status`,className:`min-w-0 flex-[1_1_320px] text-[13px]`,children:O?(0,Y.jsx)(`span`,{className:`text-muted`,children:`Checking…`}):N.length?(0,Y.jsxs)(`ul`,{className:`m-0 list-disc pl-6 text-fail [overflow-wrap:anywhere]`,children:[N.slice(0,4).map((e,t)=>(0,Y.jsx)(`li`,{children:e},t)),N.length>4&&(0,Y.jsxs)(`li`,{children:[`and `,N.length-4,` more`]})]}):(0,Y.jsx)(`span`,{className:`text-pass`,children:`Ready to save. It can be tried once saved.`})}),(0,Y.jsx)(`a`,{href:Ae,className:`text-sm`,children:`Cancel`}),(0,Y.jsxs)(H,{variant:`primary`,disabled:A||!r.id||!r.name||we.length>0,onClick:()=>void Ee(),"data-tip":n?`Save the agent`:`Save changes`,children:[(0,Y.jsx)(C,{"aria-hidden":`true`}),`Save`]})]})]})]})]})}function mr({id:e}){let[t,n]=(0,J.useState)(null),[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(!1),s=(0,J.useCallback)(()=>{R.view(e).then(e=>{Be([{id:e.id,icon:e.icon}]),n(e),i(``)},e=>i(e.message))},[e]);(0,J.useEffect)(()=>s(),[s]);let[c,l]=(0,J.useState)(null);return Re.test(e)?(0,Y.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[t?(0,Y.jsx)(_r,{view:t,detailsOpen:a,onDetails:o}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`header`,{className:`flex items-center gap-1 px-6 py-4 short:py-2`,children:[(0,Y.jsx)(Et,{}),(0,Y.jsx)(it,{href:M(`agents`,`category`,`custom`),label:`Custom agents`,className:`self-center`})]}),(0,Y.jsx)(`main`,{className:`flex flex-auto flex-col items-center justify-center px-6 py-10`,children:r?(0,Y.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,Y.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`})})]}),t&&c&&(0,Y.jsx)(Rr,{view:t,action:c.action,to:c.to,onClose:()=>l(null),onDone:e=>{`deleted`in e?(l(null),location.hash=M(`agents`,`category`,`custom`)):(n(e),l(null))}}),t&&(0,Y.jsx)(wr,{view:t,open:a,onClose:()=>o(!1),onAct:l,onReload:s})]}):(0,Y.jsx)(hr,{})}function hr(){return(0,Y.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,Y.jsx)(`header`,{className:`flex items-center gap-1 px-6 py-4`,children:(0,Y.jsx)(Et,{})}),(0,Y.jsxs)(`p`,{className:`m-0 px-6 py-10 text-sm text-muted`,children:[`There is no such agent. `,(0,Y.jsx)(`a`,{href:M(`agents`),children:`See every agent`}),`.`]})]})}var gr=e=>e.length?e.join(`, `):`none`;function _r({view:e,detailsOpen:n,onDetails:r}){let i=jt(),a=[...e.problems.working,...e.problems.active,...e.problems.other],o=e.state===`active`||e.state===`changed`,c=!!e.working,u=en[e.state],[d,f]=(0,J.useState)(e.starters[0]&&!Pn(e.starters[0].text).length?e.starters[0].text:``),[p,m]=(0,J.useState)(null),[h,g]=(0,J.useState)({}),_=(e.active||e.working)?.environments||[];(0,J.useEffect)(()=>m(null),[e.active?.digest,e.working?.digest]);let[y,x]=(0,J.useState)(``),[S,C]=(0,J.useState)(``),[ee,w]=(0,J.useState)(!0),[T,E]=(0,J.useState)(!1),[D,te]=(0,J.useState)(!1),O=Jt(),{setup:ne}=O,k=`custom-agent-${e.id}`,A=kt(d,e=>{f(e),x(``)},k,{code:O.tools.code}),re=ht(`custom-${e.id}`,e=>{f(e),wt(k)}),ie=async()=>{C(``);try{let t=await R.pack(e.id),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${e.id}.forgeqe-agent.zip`,r.click(),setTimeout(()=>URL.revokeObjectURL(n),1e3),w(!0),C(`Zip downloaded. A teammate imports it as a draft, then edits and approves it.`)}catch(e){w(!1),C(e.message)}},oe=async()=>{if(!T){E(!0),C(``);try{let t=await R.duplicate(e.id);location.hash=M(`agents`,`custom`,t.id,`edit`)}catch(e){w(!1),C(e.message),E(!1)}}},se=async(t,n=d)=>{if(!(D||!n.trim()&&!A.hasFiles)&&(t||o)&&(!t||c)){te(!0),x(``);try{let r=await A.wrap(n.trim());if(!r.trim()){te(!1);return}let{id:i}=await Je.start(r,{...O.choice,agent:e.id,...t||!o?{try:!0}:{}});A.reset({keep:!0}),location.hash=M(`chats`,i)}catch(e){x(e.message),te(!1)}}},ce=!o&&!c,le=(o?e.active:e.working)?.model;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`header`,{className:`flex items-center gap-1 px-6 py-4 short:py-2`,children:[(0,Y.jsx)(Et,{}),(0,Y.jsx)(it,{href:M(`agents`,`category`,`custom`),label:`Custom agents`,className:`self-center`}),(0,Y.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,children:[(0,Y.jsx)(U,{tone:u.tone,children:u.label}),(0,Y.jsx)(H,{variant:`icon`,size:`icon`,onClick:()=>void oe(),disabled:T||e.state===`invalid`,"aria-label":e.state===`invalid`?`Duplicate (fix its manifest first)`:`Duplicate`,"data-tip":e.state===`invalid`?`Duplicate (fix its manifest first)`:`Duplicate`,children:(0,Y.jsx)(t,{size:18,"aria-hidden":`true`})}),(0,Y.jsx)(H,{variant:`icon`,size:`icon`,onClick:()=>void ie(),"aria-label":`Export to share`,"data-tip":`Export to share`,children:(0,Y.jsx)(ye,{size:18,"aria-hidden":`true`})}),(0,Y.jsx)(H,{variant:`icon`,size:`icon`,onClick:()=>r(!n),"aria-label":`Details`,"aria-pressed":n,"data-tip":`Details`,children:(0,Y.jsx)(b,{size:18,"aria-hidden":`true`})}),(0,Y.jsx)(`a`,{href:M(`agents`,`custom`,e.id,`edit`),className:F(Qe({variant:`icon`,size:`icon`}),`no-underline`),"aria-label":`Edit`,"data-tip":`Edit`,children:(0,Y.jsx)(l,{size:18,"aria-hidden":`true`})})]})]}),(0,Y.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,Y.jsxs)(`div`,{className:`flex w-full max-w-[780px] flex-col items-center gap-10 short:gap-6`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-4 text-center short:gap-2`,children:[(0,Y.jsx)(ut,{agent:e.id,icon:e.icon,px:i?64:96,decorative:!0,working:D,className:`mb-1`}),(0,Y.jsx)(`h1`,{className:`m-0 text-[31px] leading-tight font-semibold tracking-[-0.015em] text-ink short:text-[25px] [overflow-wrap:anywhere]`,children:e.name}),(0,Y.jsx)(`p`,{className:`m-0 text-[16px] leading-relaxed text-ink-2`,children:e.description||(o?`Ask ${P(e.name)}. It runs version ${e.approvedVersion}, within its limits.`:e.state===`drifted`?`${e.name} ${e.approvedVersion} does not run until a person approves it again: what it knows changed. A try runs its manifest as it is.`:c?`Try ${P(e.name)}. It has no approved version yet: a try runs its manifest as it is.`:`Fix ${P(e.name)}'s manifest before it can be tried or approved.`)})]}),S&&(0,Y.jsx)(`p`,{role:`status`,className:F(`m-0 -mt-4 text-center text-[13px]`,ee?`text-muted`:`text-fail`),children:S}),a.length>0&&(0,Y.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,Y.jsx)(`span`,{className:`font-medium`,children:e.state===`invalid`?`Its manifest needs fixing before it can be tried or approved:`:`It cannot run as it is:`}),(0,Y.jsx)(`ul`,{className:`m-0 list-disc pl-6 [overflow-wrap:anywhere]`,children:a.map((e,t)=>(0,Y.jsx)(`li`,{children:e},t))})]}),e.manifestText!==void 0&&(0,Y.jsx)(kn,{text:e.manifestText,file:e.manifestFile||``}),e.state===`drifted`&&e.drift&&(0,Y.jsxs)(`section`,{"aria-labelledby":`ca-drift`,role:`alert`,className:`flex w-full flex-col gap-2 rounded-[12px] bg-warn-soft px-4 py-4 text-left text-sm`,children:[(0,Y.jsx)(zt,{id:`ca-drift`,icon:s,title:(0,Y.jsxs)(Y.Fragment,{children:[`What `,e.approvedVersion,` knows changed since it was approved`]}),level:3}),(0,Y.jsx)(`ul`,{className:`m-0 list-disc pl-6 text-ink-2`,children:e.drift.map(e=>(0,Y.jsx)(`li`,{children:e},e))}),(0,Y.jsxs)(`p`,{className:`m-0 text-[13px] text-ink-2`,children:[`It does not run (for you, your team, Atlas, its schedule or another agent) until a person reads the change and approves it again`,e.working?` under Details, Versions`:`: its manifest was removed, so put it back first`,`.`,e.changes.length>0?` Its manifest was also changed since: that change is below, and approving takes it too.`:``]})]}),e.changes.length>0&&(0,Y.jsx)(G,{id:`ca-changes`,icon:ae,title:(0,Y.jsxs)(Y.Fragment,{children:[`Changed since `,e.approvedVersion,` was approved`]}),description:(0,Y.jsxs)(Y.Fragment,{children:[e.state===`changed`?`The approved version keeps running until this change is approved.`:`Approving takes this change too.`,` Approve or discard it under Details, Versions.`]}),className:`w-full text-left`,children:(0,Y.jsx)(ln,{diff:e.changes})}),ce?(0,Y.jsx)(`p`,{className:`m-0 text-center text-sm text-muted`,children:e.manifestText===void 0?`See what is wrong above, or Edit the agent.`:`Fix what is listed above in its file, then come back.`}):(0,Y.jsxs)(Y.Fragment,{children:[ne&&!ne.ready&&(0,Y.jsx)(It,{project:ne.project}),ne?.ready&&(0,Y.jsx)($t,{c:O}),(0,Y.jsx)(rn,{id:k,label:`Message ${P(e.name)}`,value:d,onChange:e=>{f(e),x(``)},onSend:()=>void se(!o),disabled:D||!!ne&&!ne.ready||re.running,canSend:!!d.trim()||A.hasFiles,onEdit:A.onEdit,onKey:A.onKeyDown,onFiles:A.onFiles,dropping:A.dropping,drop:A.drop,mentions:A.mentions,combo:A.combo,placeholder:`Ask ${P(e.name)} to…`,top:(0,Y.jsxs)(Y.Fragment,{children:[A.chips,re.state&&(0,Y.jsx)(xt,{state:re.state,onStop:()=>void re.stop(),onUndo:re.undo,onClose:re.close})]}),left:(0,Y.jsxs)(Y.Fragment,{children:[A.fileInput,(0,Y.jsx)(Ut,{attach:{pick:A.pick},choice:O}),(0,Y.jsx)(yt,{running:re.running,disabled:!d.trim()||D||!!ne&&!ne.ready,onClick:()=>void re.start(d)})]}),right:le?(0,Y.jsxs)(H,{variant:`ghost`,className:`max-w-[46vw] min-w-0 px-2 text-[16px] sm:px-2`,disabled:!0,"aria-label":`Model: ${le}, as its manifest says`,"data-tip":`It runs on ${le}, as its manifest says${o&&c&&e.working?.model!==le?`; a try runs on ${e.working?.model||`ForgeQE's choice`}`:``}`,children:[(0,Y.jsx)(ve,{"aria-hidden":`true`,className:`size-4`}),(0,Y.jsx)(`span`,{className:`hidden truncate sm:inline`,children:le})]}):(0,Y.jsx)(Pt,{c:O})}),(0,Y.jsx)(`p`,{role:`status`,"aria-live":`polite`,className:F(`-mt-6 m-0 text-center text-sm text-ink-2 short:-mt-4`,!(y||A.error)&&`sr-only`),children:(0,Y.jsx)(`span`,{className:A.error&&!y?`text-fail`:``,children:y||A.error||``})}),p&&(0,Y.jsx)(vr,{starter:p,inputs:e.inputs||[],environments:_,values:h,onChange:g,onUse:e=>{f(e),m(null),document.getElementById(k)?.focus()},onCancel:()=>{let t=e.starters.findIndex(e=>e.label===p.label);m(null),t>=0&&requestAnimationFrame(()=>document.getElementById(`${k}-starter-${t}`)?.focus())}},p.label),(0,Y.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-4`,children:[e.starters.map((e,t)=>(0,Y.jsx)(H,{id:`${k}-starter-${t}`,"aria-expanded":Pn(e.text).length?p?.label===e.label:void 0,onClick:()=>{x(``),Pn(e.text).length?(m(p?.label===e.label?null:e),g({})):(m(null),f(e.text),document.getElementById(k)?.focus())},children:e.label},e.label)),o&&c&&(0,Y.jsxs)(H,{disabled:D||!d.trim(),onClick:()=>void se(!0),"data-tip":`Try the manifest`,children:[(0,Y.jsx)(v,{"aria-hidden":`true`}),`Try`]})]})]}),(0,Y.jsx)(br,{view:e})]})})]})}function vr({starter:e,inputs:t,environments:n,values:r,onChange:i,onUse:a,onCancel:o}){let s=Pn(e.text),c=s.map(e=>t.find(t=>t.name===e)).filter(e=>!!e),l=s.filter(e=>!t.some(t=>t.name===e)),[u,d]=(0,J.useState)(``),f=(0,J.useId)();(0,J.useEffect)(()=>{c[0]?document.getElementById(`starter-${c[0].name}`)?.focus():document.getElementById(f)?.focus()},[e.label]);let p=()=>{try{a(In(e.text,t,r,n))}catch(e){d(e.message)}};return(0,Y.jsxs)(`form`,{"aria-label":`Values for ${e.label}`,className:`flex w-full flex-col gap-4 rounded-[12px] card border px-4 py-4 text-left`,onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),o())},onSubmit:e=>{e.preventDefault(),p()},children:[(0,Y.jsx)(`span`,{className:`text-sm font-medium`,children:e.label}),c.map(e=>(0,Y.jsxs)(`label`,{htmlFor:`starter-${e.name}`,className:`flex flex-wrap items-center gap-x-4 gap-y-1 text-sm`,children:[(0,Y.jsx)(`span`,{className:`min-w-[140px] text-ink-2`,children:e.label}),(0,Y.jsx)(fr,{id:`starter-${e.name}`,input:e,environments:n,value:r[e.name]??``,onChange:t=>(i({...r,[e.name]:t}),d(``))})]},e.name)),l.length>0&&(0,Y.jsx)(`p`,{role:`alert`,className:`m-0 text-sm text-fail [overflow-wrap:anywhere]`,children:l.map(e=>`{${e}} is not one of its inputs, so this starter cannot be filled. Edit the agent.`).join(` `)}),u&&!l.length&&(0,Y.jsx)(`p`,{role:`alert`,className:`m-0 text-sm text-fail [overflow-wrap:anywhere]`,children:u}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,Y.jsx)(H,{type:`submit`,variant:`primary`,size:`sm`,children:`Use`}),(0,Y.jsx)(H,{id:f,type:`button`,variant:`ghost`,size:`sm`,onClick:o,children:`Cancel`})]})]})}function yr({view:e,onDone:t}){let n=e.memory?.kept||[],[r,i]=(0,J.useState)(!1),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(``),f=(0,J.useId)(),p=()=>{i(!1),s(``),setTimeout(()=>document.getElementById(f)?.focus(),0)},m=async n=>{l(!0),d(``);try{await R.forget(e.id,n),i(!1),s(``),t()}catch(e){d(e.message)}finally{l(!1)}};return(0,Y.jsxs)(Tr,{id:`ca-memory`,icon:E,title:`Memory · ${n.length} of ${e.memory?.notes||n.length} notes`,aside:n.length>0&&!r?(0,Y.jsxs)(H,{id:f,size:`sm`,variant:`danger`,onClick:()=>i(!0),children:[(0,Y.jsx)(a,{"aria-hidden":`true`}),`Forget all`]}):void 0,children:[r&&(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2 rounded-[12px] bg-warn-soft px-4 py-4 text-sm`,children:[(0,Y.jsxs)(`label`,{className:`flex min-w-0 flex-[1_1_240px] flex-col gap-2`,children:[(0,Y.jsxs)(`span`,{children:[`Type `,(0,Y.jsx)(`span`,{className:`font-mono`,children:e.id}),` to forget all `,n.length,` notes`]}),(0,Y.jsx)(V,{autoFocus:!0,value:o,onChange:e=>s(e.target.value),autoComplete:`off`,spellCheck:!1})]}),(0,Y.jsx)(H,{variant:`ghost`,onClick:p,children:`Cancel`}),(0,Y.jsx)(H,{variant:`destructive`,disabled:c||o!==e.id,onClick:()=>void m({all:!0,confirm:o}),children:`Forget all`})]}),u&&(0,Y.jsx)(`p`,{role:`alert`,className:`m-0 text-sm text-fail [overflow-wrap:anywhere]`,children:u}),n.length===0?(0,Y.jsxs)(et,{className:`py-4`,children:[P(e.name,!0),` has noted nothing yet. It keeps short facts it finds, to recall in later runs.`]}):(0,Y.jsx)(`ul`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-0`,children:n.map((e,t)=>(0,Y.jsxs)(`li`,{className:F(`flex items-start gap-2 px-4 py-2 text-[13px]`,t>0&&`border-t border-line-soft`),children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 [overflow-wrap:anywhere]`,children:e.text}),(0,Y.jsx)(`span`,{className:`flex-none text-muted tabular-nums`,children:Mt(e.at)}),(0,Y.jsx)(H,{variant:`icon`,size:`icon`,disabled:c,"aria-label":`Forget note ${t+1}`,"data-tip":`Forget this note (cannot be undone)`,onClick:()=>void m({at:e.at,text:e.text}),children:(0,Y.jsx)(a,{"aria-hidden":`true`})})]},`${e.at}-${t}`))})]})}function br({view:e}){let t=e.capabilities,n=t.some(e=>e.state===`needs_setup`)?`needs_setup`:t.some(e=>e.state===`partial`)?`partial`:`ready`,r=n===`ready`?`pass`:n===`partial`?`warn`:`neutral`,i=n===`ready`?`Ready`:n===`partial`?`Partly set up`:`Needs setup`,a=t.filter(e=>e.state!==`ready`);return(0,Y.jsxs)(`div`,{className:`flex w-full flex-col gap-6 pt-2 text-left`,children:[a.length>0&&(0,Y.jsxs)(G,{id:`ca-needs`,icon:s,title:`What it needs`,actions:(0,Y.jsx)(U,{tone:r,children:i}),children:[(0,Y.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:n===`needs_setup`?`${P(e.name,!0)} cannot work until these are set up.`:`${P(e.name,!0)} works, without the parts below.`}),(0,Y.jsx)(`ul`,{"aria-label":`What ${P(e.name)} needs`,className:`m-0 flex list-none flex-col rounded-[12px] card border p-0`,children:a.map((e,t)=>(0,Y.jsxs)(`li`,{className:F(`flex items-center gap-4 px-4 py-2`,t>0&&`border-t border-line-soft`),children:[(0,Y.jsx)(W,{icon:Cr[e.state].icon,size:16,className:F(`flex-none`,Cr[e.state].cls)}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Y.jsx)(`span`,{className:`text-[13px] font-medium`,children:e.title}),(0,Y.jsx)(`span`,{className:`text-[13px] text-muted [overflow-wrap:anywhere]`,children:e.gaps.join(`; `)||Cr[e.state].label})]})]},e.id))})]}),(0,Y.jsx)(gt,{scope:{kind:`custom`,id:e.id,name:e.name}}),t.length>0&&(0,Y.jsx)(Bt,{title:`What ${P(e.name)} can use`,children:(0,Y.jsx)(`section`,{"aria-label":`What ${P(e.name)} can use`,className:`flex flex-col gap-2 pt-2`,children:(0,Y.jsx)(`ul`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-0`,children:t.map((e,t)=>{let n=Cr[e.state];return(0,Y.jsxs)(`li`,{className:F(`flex items-start gap-4 px-4 py-2`,t>0&&`border-t border-line-soft`),children:[(0,Y.jsx)(W,{icon:n.icon,size:16,className:F(`mt-1 flex-none`,n.cls)}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Y.jsx)(`span`,{className:`text-[13px] font-medium`,children:e.title}),(0,Y.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[n.label,e.gaps.length?`: ${e.gaps.join(`; `)}`:``]})]})]},e.id)})})})})]})}var xr={approved:`Approved`,signed:`Signed`,disabled:`Disabled`,enabled:`Enabled`,"rolled-back":`Rolled back to`};function Sr(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 Cr={ready:{icon:m,label:`Ready`,cls:`text-pass`},partial:{icon:_,label:`Partly set up`,cls:`text-warn`},needs_setup:{icon:O,label:`Needs setup`,cls:`text-muted`}};function wr({view:e,open:t,onClose:n,onAct:r,onReload:i}){let a=e.active||e.working,o=!!e.working&&(e.state===`draft`||e.state===`changed`||e.state===`drifted`||e.state===`broken`&&e.working!==void 0);return(0,Y.jsx)(Ot,{open:t,onClose:n,wide:!0,title:`Details`,description:`${e.name} · ${e.id}`,footer:(0,Y.jsxs)(H,{variant:`ghost`,onClick:n,children:[(0,Y.jsx)(p,{"aria-hidden":`true`}),`Close`]}),children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[a&&(0,Y.jsx)(Er,{spec:a,view:e}),(e.checkResults||[]).length>0&&(0,Y.jsx)(Ar,{view:e,onDone:i}),((e.memory?.notes||0)>0||(e.memory?.kept.length||0)>0)&&(0,Y.jsx)(yr,{view:e,onDone:i}),(0,Y.jsx)(Dr,{view:e,approvable:o,onAct:r}),(0,Y.jsx)(Ir,{view:e})]})})}function Tr({id:e,icon:t,title:n,children:r,aside:i}){return(0,Y.jsx)(G,{id:e,icon:t,title:n,level:3,actions:i,children:r})}function Er({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`?gr(e.agents.map(e=>t.agentNames[e]||e)):n.text]):[[`Environments`,gr(e.environments)],[`Agents it may start`,gr(e.agents.map(e=>t.agentNames[e]||e))],[`It may`,gr(e.actions.map(e=>Or[e]||e))],[`A person approves first`,gr(e.approve.map(e=>Or[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`,gr(e.skills)],[`Knowledge`,gr(e.knowledge)]];return(0,Y.jsxs)(Tr,{id:`ca-reach`,icon:xe,title:t.active?`What version ${t.approvedVersion} may reach`:`What its manifest may reach`,children:[(0,Y.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,Y.jsxs)(`div`,{className:`contents`,children:[(0,Y.jsx)(`dt`,{className:`text-muted`,children:e}),(0,Y.jsx)(`dd`,{className:`m-0 text-ink [overflow-wrap:anywhere]`,children:t})]},e))}),e.policies.length>0&&(0,Y.jsxs)(`p`,{className:`m-0 text-[13px] text-muted`,children:[`Guidance it is given (not a limit): `,e.policies.join(`; `)]})]})}function Dr({view:e,approvable:t,onAct:n}){let[r,i]=(0,J.useState)(null),[s,c]=(0,J.useState)(null),[l,u]=(0,J.useState)(!1),f=async()=>{u(!0),c(null);try{let t=await R.library.publish(e.id);c({ok:!0,text:`Published ${e.approvedVersion} to your library: another project on this computer installs it from Import.${t.warnings.length?` ${t.warnings.join(`; `)}.`:``}`})}catch(e){c({ok:!1,text:e.message})}finally{u(!1)}};return(0,Y.jsxs)(Y.Fragment,{children:[r&&(0,Y.jsx)(Mr,{view:e,at:r.ref,canGoBack:r.canGoBack,onClose:()=>i(null),onAct:n}),(0,Y.jsxs)(Tr,{id:`ca-versions`,icon:te,title:`Versions`,aside:(0,Y.jsxs)(`span`,{className:`flex flex-wrap gap-2`,children:[t&&(e.approval?.signed.length||0)>0&&(0,Y.jsxs)(`span`,{className:`self-center text-[13px] text-muted`,children:[`Signed by `,e.approval.signed.map(e=>e.by).join(`, `),`; needs `,e.approval.people-e.approval.signed.length,` more`]}),t&&(0,Y.jsxs)(H,{size:`sm`,onClick:()=>n({action:`approve`}),"data-tip":`Approve ${e.manifestVersion}`,children:[(0,Y.jsx)(m,{"aria-hidden":`true`}),`Approve`]}),e.changes.length>0&&(0,Y.jsxs)(H,{size:`sm`,variant:`danger`,onClick:()=>n({action:`discard`}),"data-tip":`Back to ${e.approvedVersion}`,children:[(0,Y.jsx)(o,{"aria-hidden":`true`}),`Discard the change`]}),e.approvedVersion&&(0,Y.jsxs)(H,{size:`sm`,variant:`ghost`,onClick:()=>n({action:e.disabled?`enable`:`disable`}),children:[e.disabled?(0,Y.jsx)(m,{"aria-hidden":`true`}):(0,Y.jsx)(O,{"aria-hidden":`true`}),e.disabled?`Enable`:`Disable`]}),e.approvedVersion&&(0,Y.jsxs)(H,{size:`sm`,variant:`ghost`,disabled:l,onClick:()=>void f(),"data-tip":`Publish ${e.approvedVersion} to your library`,children:[(0,Y.jsx)(ee,{"aria-hidden":`true`}),`Publish`]}),(0,Y.jsxs)(H,{size:`sm`,variant:`danger`,onClick:()=>n({action:`delete`}),children:[(0,Y.jsx)(a,{"aria-hidden":`true`}),`Delete`]})]}),children:[s&&(0,Y.jsx)(`p`,{role:s.ok?`status`:`alert`,className:F(`m-0 rounded-[12px] px-4 py-2 text-[13px] [overflow-wrap:anywhere]`,s.ok?`bg-pass-soft text-pass`:`bg-fail-soft text-fail`),children:s.text}),e.tried&&e.manifestVersion&&(0,Y.jsxs)(`p`,{className:`m-0 text-[13px] text-muted`,children:[`Last try of manifest `,e.manifestVersion,`: `,e.tried.outcome,`.`]}),e.events.length===0?(0,Y.jsx)(et,{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,Y.jsx)(`ul`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-2`,children:e.events.toReversed().map((t,r)=>{let a=t.event===`approved`||t.event===`rolled-back`?t.version===e.approvedVersion:!1,o=t.event===`approved`&&t.version!==e.approvedVersion&&!e.events.slice(e.events.indexOf(t)+1).some(e=>e.event===`approved`&&e.version===t.version);return(0,Y.jsxs)(`li`,{className:`flex min-h-11 flex-wrap items-center gap-4 rounded-[8px] px-4 py-2`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-[13px] font-medium`,children:[(0,Y.jsxs)(`span`,{children:[xr[t.event],` `,t.version]}),a&&r===0?(0,Y.jsx)(U,{tone:`pass`,children:`Running`}):null]}),(0,Y.jsxs)(`span`,{className:`text-[13px] text-muted [overflow-wrap:anywhere]`,children:[Sr(t.by),` · `,Mt(t.at),t.note?` · ${t.note}`:``,t.tried?` · tried: ${t.tried.outcome}`:``]})]}),t.event===`approved`&&(0,Y.jsx)(H,{size:`sm`,variant:`ghost`,onClick:()=>i({ref:t.digest.slice(0,16),canGoBack:o}),"aria-label":`Read version ${t.version}`,"data-tip":`Read version ${t.version}`,children:(0,Y.jsx)(Te,{"aria-hidden":`true`})}),o&&(0,Y.jsx)(H,{size:`sm`,variant:`ghost`,onClick:()=>n({action:`rollback`,to:t.version}),"aria-label":`Roll back to ${t.version}`,"data-tip":`Roll back to ${t.version}`,children:(0,Y.jsx)(d,{"aria-hidden":`true`})})]},`${t.at}-${r}`)})})]})]})}var Or={read:`read`,run:`run tests and apps`,change:`change files`,external:`change other systems`,schedule:`schedule work`},kr={passed:{label:`Passed`,tone:`pass`},failed:{label:`Failed`,tone:`fail`},not_run:{label:`Not run on this version`,tone:`neutral`}};function Ar({view:e,onDone:t}){let[n,r]=(0,J.useState)(null),[i,a]=(0,J.useState)(``),o=n&&n.target===e.id?n:null,s=!!n?.running,c=(0,J.useRef)(null),l=(0,J.useRef)(``),u=n=>{n&&n.target===e.id&&!n.running&&l.current!==n.startedAt&&(l.current=n.startedAt,t())},d=e=>{r(e),u(e)};(0,J.useEffect)(()=>{R.checks.job().then(e=>d(e.job),e=>a(e.message))},[e.id]),(0,J.useEffect)(()=>{if(!s)return;let e=Dt(()=>{R.checks.job().then(e=>(a(``),d(e.job)),e=>a(e.message))},2e3);return()=>_t(e)},[s]),(0,J.useEffect)(()=>{c.current&&(c.current.scrollTop=c.current.scrollHeight)},[o?.lines.length]);let f=e=>{a(``),e.then(e=>d(e.job),e=>a(e.message))};return(0,Y.jsxs)(Tr,{id:`ca-checks`,icon:Se,title:`Checks`,aside:o?.running?(0,Y.jsxs)(H,{size:`sm`,variant:`danger`,onClick:()=>f(R.checks.stop()),children:[(0,Y.jsx)(me,{"aria-hidden":`true`}),`Stop`]}):(0,Y.jsxs)(H,{size:`sm`,onClick:()=>f(R.checks.start(e.id)),disabled:s,"data-tip":`Try each check on ${e.manifestVersion}`,children:[(0,Y.jsx)(v,{"aria-hidden":`true`}),`Run checks`]}),children:[s&&!o&&(0,Y.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`Another agent's checks are running: Run checks waits for them to end.`}),(0,Y.jsx)(`ul`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-0`,children:e.checkResults.map((e,t)=>(0,Y.jsxs)(`li`,{className:F(`flex flex-col gap-1 px-4 py-2 text-sm`,t>0&&`border-t border-line-soft`),children:[(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`font-mono text-[13px]`,children:e.name}),(0,Y.jsx)(U,{tone:kr[e.state].tone,children:kr[e.state].label}),e.at&&(0,Y.jsx)(`span`,{className:`text-[13px] text-muted`,children:Mt(e.at)})]}),(0,Y.jsx)(`span`,{className:`text-[13px] text-ink-2 [overflow-wrap:anywhere]`,children:e.request}),e.state===`failed`&&(e.reasons||[]).length>0&&(0,Y.jsx)(`ul`,{className:`m-0 list-disc pl-6 text-[13px] text-fail [overflow-wrap:anywhere]`,children:e.reasons.map(e=>(0,Y.jsx)(`li`,{children:e},e))})]},e.name))}),i&&(0,Y.jsx)(`p`,{role:`alert`,className:`m-0 text-sm text-fail [overflow-wrap:anywhere]`,children:i}),o&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`details`,{open:o.running,children:[(0,Y.jsxs)(`summary`,{className:`cursor-pointer text-sm text-muted`,children:[`Output (`,o.lines.length,` lines)`]}),(0,Y.jsx)(`pre`,{ref:c,className:`mt-2 max-h-[300px] overflow-auto rounded-[10px] bg-surface-muted p-4 font-mono text-[13px] leading-relaxed whitespace-pre-wrap text-ink-2`,children:(0,Y.jsx)(nt,{text:o.lines.join(`
5
+ `)||`Starting…`})})]}),o.running&&o.question&&(0,Y.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 border-0 p-0`,children:[(0,Y.jsx)(`legend`,{className:`mb-1 text-sm font-medium`,children:o.question.title}),o.question.detail&&(0,Y.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:o.question.detail}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:o.question.options.map(e=>(0,Y.jsx)(H,{size:`sm`,variant:e.id===`deny`||e.id===`stop`?`outline`:`primary`,onClick:()=>f(R.checks.answer(o.question.id,e.id)),children:e.label},e.id))})]})]})]})}function jr({lines:e}){return(0,Y.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:e.map(e=>(0,Y.jsxs)(`div`,{className:`contents`,children:[(0,Y.jsxs)(`dt`,{className:F(e.mark===`same`?`text-muted`:`font-medium text-warn`),children:[e.label,e.mark!==`same`&&(0,Y.jsxs)(`span`,{className:`sr-only`,children:[` (`,Nr[e.mark],`)`]})]}),(0,Y.jsxs)(`dd`,{className:F(`m-0 [overflow-wrap:anywhere]`,e.mark===`removed`?`text-muted line-through`:`text-ink`),children:[e.mark!==`same`&&(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`mr-2 text-[13px] font-medium text-warn`,children:Nr[e.mark]}),e.text,e.before&&(0,Y.jsxs)(`span`,{className:`block text-[13px] text-muted`,children:[`Was: `,e.before]})]})]},`${e.mark}-${e.label}`))})}function Mr({view:e,at:t,canGoBack:n,onClose:r,onAct:i}){let[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(``);return(0,J.useEffect)(()=>{R.version(e.id,t).then(o,e=>c(e.message))},[e.id,t]),(0,Y.jsx)(Ot,{open:!0,wide:!0,onClose:r,title:a?`Version ${a.version}`:`Version`,description:a?`Approved by ${Sr(a.by)} ${Mt(a.at)}${a.note?`: ${a.note}`:``}.${a.running?` It is the version that runs.`:``}`:void 0,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(H,{variant:`ghost`,onClick:r,children:[(0,Y.jsx)(p,{"aria-hidden":`true`}),`Close`]}),n&&a&&!a.running&&(0,Y.jsxs)(H,{variant:`primary`,onClick:()=>(r(),i({action:`rollback`,to:a.version})),children:[(0,Y.jsx)(d,{"aria-hidden":`true`}),`Roll back to `,a.version]})]}),children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[s&&(0,Y.jsx)(`p`,{role:`alert`,className:`m-0 text-sm text-fail [overflow-wrap:anywhere]`,children:s}),!a&&!s&&(0,Y.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}),a&&(0,Y.jsxs)(Y.Fragment,{children:[!a.running&&a.permissions.length>0&&(0,Y.jsx)(G,{id:`ca-version-may`,icon:xe,title:(0,Y.jsxs)(Y.Fragment,{children:[`What it may do, against `,e.approvedVersion]}),level:3,children:(0,Y.jsx)(jr,{lines:a.permissions})}),a.diff&&(0,Y.jsx)(G,{id:`ca-version-diff`,icon:ae,title:(0,Y.jsxs)(Y.Fragment,{children:[`Its manifest against `,e.approvedVersion]}),level:3,children:(0,Y.jsx)(ln,{diff:a.diff})}),(0,Y.jsx)(G,{id:`ca-version-source`,icon:h,title:`Its manifest as approved`,level:3,children:(0,Y.jsx)(`pre`,{className:`m-0 max-h-[50vh] overflow-auto rounded-[12px] card border px-4 py-4 font-mono text-[13px] whitespace-pre-wrap [overflow-wrap:anywhere]`,children:a.source})})]})]})})}var Nr={new:`New`,changed:`Changed`,removed:`No longer`},Pr={run:`Asked`,try:`Tried`,orchestrator:`From Atlas`,schedule:`Nobody watching`,agent:`Handed on by another agent`,check:`A saved check`},Fr={usage:Vt,money:Rt};function Ir({view:e}){let[t,n]=(0,J.useState)(``),r=async()=>{n(``);try{let t=await R.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,Y.jsxs)(Tr,{id:`ca-runs`,icon:v,title:`Recent runs`,aside:(0,Y.jsxs)(H,{size:`sm`,variant:`ghost`,onClick:()=>void r(),"data-tip":`Download its whole record, for audit`,children:[(0,Y.jsx)(ye,{"aria-hidden":`true`}),`Download`]}),children:[t&&(0,Y.jsx)(`p`,{className:`m-0 text-[13px] text-fail`,children:t}),e.runs.length===0?(0,Y.jsxs)(et,{className:`py-4`,children:[P(e.name,!0),` has not run yet.`]}):(0,Y.jsx)(`ul`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-0`,children:e.runs.map((e,t)=>(0,Y.jsx)(`li`,{className:F(t>0&&`border-t border-line-soft`),children:(0,Y.jsxs)(`details`,{className:`group px-4 py-2`,children:[(0,Y.jsxs)(`summary`,{className:`flex cursor-pointer list-none flex-wrap items-center gap-x-4 gap-y-1`,children:[(0,Y.jsx)(U,{tone:e.outcome===`done`?`pass`:e.outcome===`running`?`running`:e.outcome===`stopped`||e.outcome===`needs_input`?`neutral`:`fail`,children:e.outcome.replace(`_`,` `)}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] font-medium`,"data-tip":e.request,children:e.request}),(0,Y.jsxs)(`span`,{className:`text-[13px] text-muted tabular-nums`,children:[Pr[e.trigger]||`Started another way`,` · `,e.version,` · `,e.calls,` `,e.calls===1?`call`:`calls`,e.refused?`, ${e.refused} refused`:``,e.result?.verdict?` · verdict ${e.result.verdict}`:``,` · `,Mt(e.startedAt)]})]}),(0,Y.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2 pl-1 text-[13px]`,children:[(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-4 gap-y-1`,children:[(0,Y.jsxs)(`span`,{className:`text-muted`,children:[`By `,e.by]}),e.session&&(0,Y.jsxs)(`a`,{href:M(`runs`,encodeURIComponent(e.session)),className:`inline-flex items-center gap-1`,children:[`Open the run`,(0,Y.jsx)(N,{size:14,"aria-hidden":`true`})]})]}),An(e,Fr)&&(0,Y.jsx)(`span`,{className:`text-muted tabular-nums [overflow-wrap:anywhere]`,children:An(e,Fr)}),e.error&&(0,Y.jsx)(`span`,{className:`text-fail [overflow-wrap:anywhere]`,children:e.error}),e.result&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-muted`,children:`Its result`}),(0,Y.jsxs)(`dl`,{className:`m-0 grid grid-cols-[max-content_1fr] gap-x-4 gap-y-1`,children:[(0,Y.jsx)(`dt`,{className:`text-muted`,children:`Verdict`}),(0,Y.jsx)(`dd`,{className:`m-0`,children:e.result.verdict||`None given`}),Object.entries(e.result.fields).map(([e,t])=>(0,Y.jsxs)(J.Fragment,{children:[(0,Y.jsx)(`dt`,{className:`font-mono text-[13px] text-muted`,children:e}),(0,Y.jsx)(`dd`,{className:`m-0 [overflow-wrap:anywhere]`,children:typeof t==`boolean`?t?`Yes`:`No`:String(t)})]},e))]}),e.result.problems.length>0&&(0,Y.jsxs)(`span`,{className:`text-warn [overflow-wrap:anywhere]`,children:[`Not read: `,e.result.problems.join(`; `),`.`]})]}),e.reply&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-muted`,children:`Its reply`}),(0,Y.jsx)(`p`,{tabIndex:0,"aria-label":`Its reply`,className:`m-0 max-h-[240px] overflow-auto rounded-[10px] bg-surface-muted px-4 py-2 whitespace-pre-wrap text-ink-2 [overflow-wrap:anywhere]`,children:e.reply})]}),e.decisions.length>0&&(0,Y.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0`,children:e.decisions.map((e,t)=>(0,Y.jsxs)(`li`,{className:`flex items-start gap-2`,children:[e.allowed?(0,Y.jsx)(m,{size:14,"aria-label":`Allowed`,className:`mt-1 flex-none text-pass`}):(0,Y.jsx)(s,{size:14,"aria-label":`Refused`,className:`mt-1 flex-none text-fail`}),(0,Y.jsxs)(`span`,{className:`min-w-0 [overflow-wrap:anywhere]`,children:[(0,Y.jsx)(`span`,{className:`font-mono text-[13px]`,children:e.tool}),e.allowed?(0,Y.jsxs)(`span`,{className:`text-muted`,children:[` · `,Or[e.action||``]||e.action,e.approved?`, approved by a person`:``]}):(0,Y.jsxs)(`span`,{className:`text-fail`,children:[` · `,e.reason]})]})]},t))})]})]})},e.run))})]})}var Lr={approve:{title:`Approve this version`,button:`Approve`,icon:m},disable:{title:`Disable this agent`,button:`Disable`,icon:O},enable:{title:`Enable this agent`,button:`Enable`,icon:m},rollback:{title:`Run an earlier version`,button:`Roll back`,icon:d},delete:{title:`Delete this agent`,button:`Delete`,icon:a},discard:{title:`Discard the change`,button:`Discard the change`,icon:o}};function Rr({view:e,action:t,to:n,onClose:r,onDone:i}){let[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)(``),m=t===`approve`?e.checks:null,h=!!m&&(m.failed.length>0||m.missing.length>0),[g,_]=(0,J.useState)(!1),v=t===`approve`?e.approval:void 0,y=v?v.people-v.signed.length:1,b=(e,t)=>e.toLowerCase()===t.toLowerCase(),x=!!v&&v.owners.length>0&&!v.owners.some(e=>b(e,v.you)),S=!!v&&v.signed.some(e=>b(e.by,v.you)),C=Lr[t],ee=t===`approve`&&e.state===`drifted`&&e.changes.length===0?`Version ${e.approvedVersion} is approved again with what it knows now, and runs again for you, your team and Atlas. Commit .forgeqe/agents/.releases/${e.id} so your team has it.`:t===`approve`&&y>1?`Your approval of version ${e.manifestVersion} is kept; it runs once ${y-1} more ${y-1==1?`person approves`:`people approve`} it. Commit .forgeqe/agents/.releases/${e.id} so the next person sees your approval.`:t===`approve`?`Version ${e.manifestVersion} becomes what runs, for you, your team and Atlas${e.approvedVersion?`, in place of ${e.approvedVersion}`:``}.${e.tried?` Its last try: ${e.tried.outcome}.`:` It was never tried.`} Commit .forgeqe/agents/.releases/${e.id} so your team has it.`:t===`disable`?`Nothing of it runs (not you, your team, Atlas or its schedule) until a person enables it again, here or with forgeqe agent enable.${e.handedBy?.length?` ${e.handedBy.join(`, `)} ${e.handedBy.length===1?`hands`:`hand`} work to it: those hand-offs will be refused meanwhile.`:``}`:t===`enable`?`Version ${e.approvedVersion} runs again.`:t===`discard`?`Its manifest goes back to version ${e.approvedVersion}, the one that runs; the change waiting for approval is thrown away (the audit log keeps that it was).`:t===`delete`?`${e.name} will be removed for good: its manifest, approved versions, runs and waiting approvals. Knowledge files and skills it named stay in the project.${e.handedBy?.length?` ${e.handedBy.join(`, `)} ${e.handedBy.length===1?`hands`:`hand`} work to it: those hand-offs will be refused.`:``}`:`Version ${n} runs from now on, in place of ${e.approvedVersion}.`,w=async()=>{u(!0),f(``);try{i(await R.act(e.id,t,{confirm:a,...s.trim()?{note:s.trim()}:{},...n?{to:n}:{},...h&&g?{skipChecks:!0}:{}}))}catch(e){f(e.message),u(!1)}};return(0,Y.jsx)(Ot,{open:!0,onClose:r,title:C.title,description:ee,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(H,{variant:`ghost`,onClick:r,children:[(0,Y.jsx)(p,{"aria-hidden":`true`}),`Cancel`]}),(0,Y.jsxs)(H,{variant:t===`delete`||t===`discard`?`destructive`:`primary`,disabled:l||a!==e.id||h&&!g||x||S,onClick:()=>void w(),children:[(0,Y.jsx)(C.icon,{"aria-hidden":`true`}),C.button]})]}),children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[t===`approve`&&e.state===`drifted`&&e.drift&&(0,Y.jsx)(G,{id:`ca-approve-drift`,icon:ae,title:(0,Y.jsxs)(Y.Fragment,{children:[`What it knows that changed since `,e.approvedVersion,` was approved`]}),level:3,children:(0,Y.jsx)(`ul`,{className:`m-0 list-disc rounded-[12px] card border py-4 pr-4 pl-10 text-sm text-ink`,children:e.drift.map(e=>(0,Y.jsx)(`li`,{children:e},e))})}),t===`approve`&&(e.permissions||[]).length>0&&(0,Y.jsx)(G,{id:`ca-approve-may`,icon:xe,title:(0,Y.jsx)(Y.Fragment,{children:e.approvedVersion?`What it may do, against ${e.approvedVersion}`:`What it may do`}),level:3,children:(0,Y.jsx)(jr,{lines:e.permissions})}),m&&(0,Y.jsxs)(`div`,{role:h?`alert`:void 0,className:F(`flex flex-col gap-2 rounded-[12px] px-4 py-4 text-sm`,h?`bg-warn-soft`:`bg-surface-muted`),children:[(0,Y.jsx)(`span`,{className:F(`font-medium`,h?`text-warn`:`text-ink`),children:h?`Its checks have not all passed on version ${e.manifestVersion}`:`Its ${m.total} ${m.total===1?`check`:`checks`} passed on version ${e.manifestVersion}`}),m.failed.length>0&&(0,Y.jsxs)(`span`,{className:`text-[13px] text-ink-2`,children:[`Failed: `,m.failed.join(`, `)]}),m.missing.length>0&&(0,Y.jsxs)(`span`,{className:`text-[13px] text-ink-2`,children:[`Not run on this version: `,m.missing.join(`, `),`. Run them under Details, Checks, or with `,(0,Y.jsxs)(`span`,{className:`font-mono`,children:[`forgeqe agent test `,e.id]}),`.`]}),h&&(0,Y.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2`,children:[(0,Y.jsx)(Lt,{checked:g,onCheckedChange:e=>_(e===!0),className:`mt-1`}),(0,Y.jsx)(`span`,{children:`Approve it without them (kept in its history)`})]})]}),v&&(v.people>1||v.owners.length>0)&&(0,Y.jsxs)(`div`,{role:x||S?`alert`:void 0,className:F(`flex flex-col gap-2 rounded-[12px] px-4 py-4 text-sm`,x||S?`bg-warn-soft`:`bg-surface-muted`),children:[(0,Y.jsx)(`span`,{className:F(`font-medium`,x||S?`text-warn`:`text-ink`),children:x?`Only ${v.owners.join(`, `)} may approve it`:S?`You already approved this version: another person approves it next`:v.people>1?`It needs ${v.people} different people to approve it`:`Only ${v.owners.join(`, `)} may approve it`}),v.people>1&&(0,Y.jsxs)(`span`,{className:`text-[13px] text-ink-2`,children:[`Approved so far by `,v.signed.map(e=>e.by).join(`, `)||`nobody`,`.`]}),(0,Y.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[`ForgeQE knows you as `,v.you||`nobody`,`, git's user name on this computer: an agreement the history keeps, not a sign-in.`]})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsxs)(`span`,{children:[`Type `,(0,Y.jsx)(`span`,{className:`font-mono`,children:e.id}),` to confirm`]}),(0,Y.jsx)(V,{value:a,onChange:e=>o(e.target.value),autoComplete:`off`,spellCheck:!1})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{children:`Note (optional)`}),(0,Y.jsx)(V,{value:s,maxLength:200,onChange:e=>c(e.target.value),placeholder:t===`rollback`?`Why it goes back`:`What changed, or why`})]}),d&&(0,Y.jsx)(`p`,{role:`alert`,className:`m-0 text-sm text-fail [overflow-wrap:anywhere]`,children:d})]})})}var zr={legitimate:`Legitimate`,opportunistic:`Opportunistic`,adversarial:`Adversarial`},Br={sme:`Subject matter expert`,end_user:`End user`,specialist:`Specialist`,business_user:`Business user`},Vr=[`personas`,`about`],Hr={personas:`Personas`,about:`Tools and conversations`},Ur={personas:j,about:re};function Wr({current:e,count:t}){let[n,r]=(0,J.useState)(null);(0,J.useEffect)(()=>{t===void 0&&I.list().then(e=>r(e.personas.length),()=>r(null))},[t===void 0]);let i=t??n;return(0,Y.jsx)(vt,{label:`Mask's pages`,current:e,links:[{id:`agent`,label:`Agent`,href:M(`agents`,`persona`),icon:Nt(`persona`)},{id:`personas`,label:i===null?`Personas`:`Personas (${i})`,href:M(`agents`,`persona`,`personas`),icon:Ur.personas},{id:`about`,label:`Tools and conversations`,href:M(`agents`,`persona`,`about`),icon:Ur.about}]})}var Gr=/^[a-z0-9][a-z0-9-]{0,39}$/,Kr=/^[a-z][a-z0-9-]{1,39}$/,qr=e=>M(`agents`,`persona`,`personas`,encodeURIComponent(e));function Jr({page:e,tab:t,sub:n}){let[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)([]),[s,c]=(0,J.useState)(``),l=t===`new`,u=Vr.includes(t)?t:`personas`,d=()=>I.list().then(e=>{i(e.personas),o(e.notLoaded),c(``)},e=>c(`The personas did not load: ${e.message}`));(0,J.useEffect)(()=>{d()},[]);let f=u===`personas`&&n?ge(n):``;return(0,Y.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,Y.jsx)(nn,{}),(0,Y.jsxs)(`main`,{className:F(mt,`@container flex-auto gap-4`),children:[(0,Y.jsx)(St,{agent:e,tabs:(0,Y.jsx)(Wr,{current:u,...r?{count:r.length}:{}})}),(0,Y.jsx)(zt,{icon:Ur[u],title:Hr[u]}),s&&(0,Y.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,Y.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}),r&&(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsxs)(`div`,{children:[u===`personas`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Yr,{personas:r,notLoaded:a,onChanged:e=>(i(e.personas),o(e.notLoaded))}),(0,Y.jsx)($r,{personas:r,opened:f,onChanged:e=>(i(e.personas),o(e.notLoaded))}),(0,Y.jsx)(li,{open:l,onClose:()=>location.hash=Xr,personas:r,onSaved:e=>{d().then(()=>(ni=e,location.hash=qr(e)))}})]}),u===`about`&&(0,Y.jsx)(Qt,{page:e,onTab:!0})]})})]})]})}function Yr({personas:e,notLoaded:t,onChanged:n}){let[r,a]=(0,J.useState)(`all`),[o,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(``),[d,f]=(0,J.useState)(``),[p,m]=(0,J.useState)(!1),h=(0,J.useRef)(null),g=e.filter(e=>!e.builtIn).length,_=async()=>{u(``),f(``);try{let e=await I.exportFile(),t=URL.createObjectURL(new Blob([`${JSON.stringify(e,null,2)}\n`],{type:`application/json;charset=utf-8`})),n=document.createElement(`a`);n.href=t,n.download=`forgeqe-personas.json`,n.click(),setTimeout(()=>URL.revokeObjectURL(t),1e3),u(`Exported ${z(g,`persona`)} of your own. Another project imports the file here.`)}catch(e){f(e.message)}},v=async e=>{let t=e?.[0];if(t){if(u(``),f(``),t.size>262144)return f(`${t.name} is over 256 KB.`);m(!0);try{let e=await I.importFile(await t.text());n(e),u(e.added.length?`Imported ${e.added.length===1?`the persona`:`${e.added.length} personas:`} ${e.added.join(`, `)}.`:`No new persona in the file.`),e.skipped.length&&f(`Not imported: ${e.skipped.map(e=>`${e.id} (${e.why})`).join(`; `)}`)}catch(e){f(e.message)}finally{m(!1)}}},y=o.toLowerCase().split(/\s+/).filter(Boolean),b=e.filter(e=>(r===`all`||e.kind===r)&&y.every(t=>`${e.name} ${e.role} ${e.domain} ${e.id} /${e.handle}`.toLowerCase().includes(t)));return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsxs)(`p`,{className:`m-0 mr-auto flex flex-wrap items-center gap-x-1 text-sm text-ink-2 tabular-nums`,children:[(0,Y.jsx)(W,{icon:j,size:14,className:`text-muted`}),z(e.length,`persona`),` · `,g,` of your own`,t.length?(0,Y.jsxs)(Y.Fragment,{children:[` · `,(0,Y.jsxs)(`span`,{className:`text-fail`,children:[t.length,` not loaded`]})]}):null]}),(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[g>0&&(0,Y.jsxs)(H,{size:`sm`,onClick:()=>void _(),"data-tip":`A file of your own personas, for another project to import`,children:[(0,Y.jsx)(ye,{"aria-hidden":`true`}),`Export`]}),(0,Y.jsxs)(H,{size:`sm`,disabled:p,onClick:()=>h.current?.click(),"data-tip":`Personas another project exported`,children:[(0,Y.jsx)(ee,{"aria-hidden":`true`}),p?`Importing…`:`Import`]}),(0,Y.jsxs)(H,{size:`sm`,variant:`primary`,onClick:()=>location.hash=M(`agents`,`persona`,`new`),"data-tip":`Describe a person and Mask drafts the persona, or write it yourself`,children:[(0,Y.jsx)(i,{"aria-hidden":`true`}),`New persona`]})]}),(0,Y.jsx)(`input`,{ref:h,type:`file`,accept:`.json,application/json`,hidden:!0,onChange:e=>(v(e.target.files),e.target.value=``)})]}),l&&(0,Y.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:l}),d&&(0,Y.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-4 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:d}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(rt,{id:`persona-find`,label:`Find a persona`,value:o,onChange:c}),(0,Y.jsx)($e,{items:[{id:`all`,label:`All`,n:e.length},...Ge.map(t=>({id:t,label:Br[t],n:e.filter(e=>e.kind===t).length}))],value:r,onChange:a})]}),b.length===0?(0,Y.jsx)(et,{className:`py-4`,children:e.length?`No persona matches.`:`There are no personas yet.`}):(0,Y.jsx)(`ul`,{"aria-label":`Personas`,className:`m-0 flex list-none flex-col rounded-[12px] card border p-2`,children:b.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`a`,{href:qr(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,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Y.jsxs)(`span`,{className:`truncate text-[13px] font-medium`,"data-tip":e.name,children:[e.name,!e.builtIn&&(0,Y.jsx)(`span`,{className:`font-normal text-muted`,children:` · yours`})]}),(0,Y.jsxs)(`span`,{className:`truncate text-[13px] text-muted`,children:[(0,Y.jsxs)(`span`,{className:`font-mono`,children:[`/`,e.handle]}),` · `,Br[e.kind],e.intent===`legitimate`?``:` · ${zr[e.intent].toLowerCase()}`,` · `,e.role,e.domain?` · ${e.domain}`:``]})]}),(0,Y.jsx)(`span`,{className:`flex-none text-[13px] text-muted tabular-nums`,children:z(e.validates.length,`check`)})]})},e.id))}),t.length>0&&(0,Y.jsx)(G,{id:`persona-not-loaded`,icon:s,title:`Not loaded`,level:3,children:(0,Y.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0`,children:t.map(e=>(0,Y.jsx)(`li`,{className:`text-[13px] text-fail [overflow-wrap:anywhere]`,children:e},e))})}),(0,Y.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 Xr=M(`agents`,`persona`,`personas`),Zr=e=>{let{builtIn:t,...n}=e;return n},Qr=(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 $r({personas:e,opened:n,onChanged:r}){let[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(!1),[c,u]=(0,J.useState)(``),d=i?void 0:e.find(e=>e.id===n),f=!!n&&!i&&!d,m=()=>location.hash=Xr,h=(t,n)=>{let r=new Set(e.flatMap(e=>[e.id,e.handle])),i=n===`copy`?{...Zr(t),id:Qr(t.id,r),handle:``}:Zr(t);u(``),a({mode:n,from:t,fields:i,listText:Object.fromEntries(si.map(({key:e})=>[e,t[e].join(`
6
+ `)]))})},g=(0,J.useMemo)(()=>new Set(e.filter(e=>i?.mode!==`edit`||e.id!==i.from.id).flatMap(e=>[e.id,e.handle])),[e,i]),_=i?ui(i.fields,i.listText,g,i.mode===`edit`):null,v=ei(!!n||!!i),y=async(e,t,n)=>{e[t].includes(n)||r(await I.update(e.id,{...Zr(e),[t]:[...e[t],n]}))},b=async()=>{if(i&&_?.canSave){s(!0),u(``);try{let e={...i.fields,...Object.fromEntries(si.map(({key:e})=>[e,ci(i.listText[e]||``)]))},t=i.mode===`edit`?await I.update(i.from.id,e):await I.save(e);r(t),a(null),i.mode===`copy`&&(ni=t.saved),location.hash=qr(t.saved)}catch(e){u(e.message)}finally{s(!1)}}};return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Ot,{wide:!0,open:!!d||f,onClose:m,title:d?.name||`No such persona`,description:d?d.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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(H,{onClick:m,children:[(0,Y.jsx)(p,{"aria-hidden":`true`}),`Close`]}),d&&!d.builtIn&&(0,Y.jsxs)(H,{variant:`primary`,onClick:()=>h(d,`edit`),children:[(0,Y.jsx)(l,{"aria-hidden":`true`}),`Edit`]}),d?.builtIn&&(0,Y.jsxs)(H,{variant:`primary`,"data-tip":`Make your own persona from this one, under another id and command`,onClick:()=>h(d,`copy`),children:[(0,Y.jsx)(t,{"aria-hidden":`true`}),`Copy to edit`]})]}),children:d?(0,Y.jsx)(ai,{persona:d,resources:v,onAdd:d.builtIn?void 0:(e,t)=>y(d,e,t)}):(0,Y.jsxs)(et,{className:`py-6`,children:[`There is no persona "`,n,`" in this project.`]})}),(0,Y.jsx)(Ot,{wide:!0,open:!!i,onClose:()=>a(null),title:i?.mode===`edit`?`Edit ${i.from.name}`:`Copy ${i?.from.name||``}`,description:(0,Y.jsxs)(Y.Fragment,{children:[i?.mode===`copy`&&(0,Y.jsx)(Y.Fragment,{children:`A persona of your own, made from the built-in one, which stays as it is. `}),`Saved in `,(0,Y.jsxs)(`span`,{className:`font-mono text-[13px]`,children:[`.forgeqe/business-personas/`,i?.fields.id||`<id>`,`.yaml`]}),`, shared with everyone who uses the repository.`]}),footer:(0,Y.jsxs)(Y.Fragment,{children:[c?(0,Y.jsx)(`span`,{role:`alert`,className:`mr-auto self-center text-sm text-fail [overflow-wrap:anywhere]`,children:c}):i&&!_?.canSave&&(0,Y.jsxs)(`span`,{className:`mr-auto self-center text-[13px] text-muted`,children:[`It needs a name, `,i.mode===`copy`?`an id, `:``,`a role, and what they check or want.`]}),(0,Y.jsxs)(H,{onClick:()=>a(null),children:[(0,Y.jsx)(p,{"aria-hidden":`true`}),`Cancel`]}),(0,Y.jsxs)(H,{variant:`primary`,disabled:o||!_?.canSave,onClick:()=>void b(),children:[(0,Y.jsx)(C,{"aria-hidden":`true`}),o?`Saving…`:i?.mode===`copy`?`Save copy`:`Save`]})]}),children:i&&_&&(0,Y.jsx)(`div`,{className:`pt-4`,children:(0,Y.jsx)(di,{fields:i.fields,listText:i.listText,onFields:e=>a({...i,fields:e}),onListText:e=>a({...i,listText:e}),check:_,idLocked:i.mode===`edit`,resources:v})})})]})}function ei(e){let[t,n]=(0,J.useState)(null);return(0,J.useEffect)(()=>{e&&!t&&I.resources().then(n,e=>n({skills:[],documents:[],error:`The skills and documents did not load: ${e.message}`}))},[e,t]),t}function ti({persona:e,resources:t,onAdd:n}){let[r,a]=(0,J.useState)(null),o=t?.error?null:t,[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(``),d=`${e.skills.join(`,`)}|${e.knowledge.join(`,`)}`;(0,J.useEffect)(()=>{a(null),I.suggest(e.id).then(a,e=>a({skills:[],documents:[],error:`The suggestions did not load: ${e.message}`}))},[e.id,d]);let f=e=>o?.skills.find(t=>t.name===e),p=e=>o?.documents.find(t=>t.ref===e),m=(0,Y.jsx)(`span`,{className:`text-warn`,children:` · not in this project`}),h=async(e,t)=>{if(n){c(`${e}:${t}`),u(``);try{await n(e,t)}catch(e){u(e.message)}finally{c(``)}}},g=r?[...r.skills.map(e=>({key:`skills`,...e})),...r.documents.map(e=>({key:`knowledge`,...e}))]:[];return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(G,{id:`persona-uses`,icon:Ce,title:`Shared skills and documents`,level:3,children:[e.skills.length+e.knowledge.length===0?(0,Y.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,Y.jsxs)(`ul`,{"aria-label":`Skills and documents`,className:`m-0 flex list-none flex-col p-0`,children:[e.skills.map(e=>(0,Y.jsxs)(`li`,{className:`flex items-start gap-4 border-t border-line-soft py-2`,children:[(0,Y.jsx)(W,{icon:Ce,size:16,className:`mt-1 text-muted`}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`font-mono text-[13px] [overflow-wrap:anywhere]`,children:e}),(0,Y.jsxs)(`span`,{className:`text-[13px] text-muted [overflow-wrap:anywhere]`,children:[`Skill`,o&&!f(e)?m:f(e)?` · ${f(e).description}`:``]})]})]},`s:${e}`)),e.knowledge.map(e=>(0,Y.jsxs)(`li`,{className:`flex items-start gap-4 border-t border-line-soft py-2`,children:[(0,Y.jsx)(W,{icon:Ee,size:16,className:`mt-1 text-muted`}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-[13px] font-medium [overflow-wrap:anywhere]`,children:p(e)?.title||e}),(0,Y.jsxs)(`span`,{className:`font-mono text-[13px] text-muted [overflow-wrap:anywhere]`,children:[e,o&&!p(e)?m:null]})]})]},`k:${e}`))]}),t?.error&&(0,Y.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,Y.jsxs)(G,{id:`persona-suggested`,icon:ue,title:`Suggested for them`,level:3,children:[r?r.error?(0,Y.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,Y.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Nothing else matches their domain and checks. Add documents in Settings › Product knowledge, or knowledge notes, to see more.`}):(0,Y.jsx)(`ul`,{"aria-label":`Suggested skills and documents`,className:`m-0 flex list-none flex-col p-0`,children:g.map(t=>(0,Y.jsxs)(`li`,{className:`flex items-center gap-4 border-t border-line-soft py-2`,children:[(0,Y.jsx)(W,{icon:t.key===`skills`?Ce:Ee,size:16,className:`text-muted`}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:F(`text-[13px] [overflow-wrap:anywhere]`,t.key===`skills`?`font-mono`:`font-medium`),children:t.key===`knowledge`&&p(t.name)?.title||t.name}),(0,Y.jsxs)(`span`,{className:`text-[13px] text-muted [overflow-wrap:anywhere]`,children:[t.key===`skills`?`Skill`:t.name,` · matched `,t.why]})]}),n&&(0,Y.jsxs)(H,{size:`sm`,disabled:!!s,onClick:()=>void h(t.key,t.name),"data-tip":`Add to what ${e.name} uses`,children:[(0,Y.jsx)(i,{"aria-hidden":`true`}),s===`${t.key}:${t.name}`?`Adding…`:`Add`]})]},`${t.key}:${t.name}`))}):(0,Y.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Looking for skills and documents that match…`}),l&&(0,Y.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})]})]})}var ni=``,ri=e=>e.name.split(`,`)[0].trim()||e.name;function ii({persona:e}){let[t,n]=(0,J.useState)(null),[r,i]=(0,J.useState)(null),[o,s]=(0,J.useState)(``),[c,d]=(0,J.useState)(``),[f,m]=(0,J.useState)(``),h=ri(e),g=()=>I.own(e.id).then(n,e=>n({skills:[],knowledge:[],problems:[],error:`${h}'s own skills and notes did not load: ${e.message}`})),_=async()=>{s(`draft`),d(``);try{let[t,n]=await Promise.all([I.draftOwn(e.id),I.own(e.id)]),r=(e,t)=>n[e].some(e=>e.name===t);m(``),i({drafted:!0,items:[t.skill,t.knowledge].map(e=>({...e,replace:r(e.kind,e.name)}))})}catch(e){d(e.message)}finally{s(``)}};(0,J.useEffect)(()=>{n(null),g(),ni===e.id&&(ni=``,_())},[e.id]);let v=async()=>{if(r){s(`save`),m(``);try{let t=r.items.filter(e=>e.was&&e.was!==e.name),a=await I.saveOwn(e.id,r.items.map(({was:e,...n})=>({...n,replace:n.replace&&!t.some(e=>e.kind===n.kind&&e.name===n.name)})));i({...r,items:r.items.map(e=>({...e,replace:!0}))});for(let n of t)await I.removeOwn(e.id,n.kind,n.was);n(t.length?await I.own(e.id):a),i(null)}catch(e){m(e.message),g()}finally{s(``)}}},y=async t=>{s(`remove:${t.kind}/${t.name}`),m(``);try{n(await I.removeOwn(e.id,t.kind,t.name)),i(null)}catch(e){m(e.message)}finally{s(``)}},b=t?[...t.skills,...t.knowledge]:[],x=(e,t)=>r&&i({...r,items:r.items.map((n,r)=>r===e?{...n,...t}:n)}),S=!!r&&r.items.every(e=>/^[a-z0-9]+(-[a-z0-9]+)*$/.test(e.name)&&e.body.trim()&&(e.kind===`knowledge`||e.description.trim()));return(0,Y.jsxs)(G,{id:`persona-own`,icon:E,level:3,title:(0,Y.jsxs)(Y.Fragment,{children:[h,`'s own skills and knowledge`]}),description:(0,Y.jsxs)(Y.Fragment,{children:[`Used only when someone works as `,h,`, never by other agents.`]}),actions:(0,Y.jsxs)(H,{size:`sm`,disabled:!!o||!t,onClick:()=>void _(),"data-tip":`Mask drafts a skill and a knowledge note for ${h}; you review them before anything is saved`,children:[(0,Y.jsx)(u,{"aria-hidden":`true`}),o===`draft`?`Generating…`:b.length?`Generate again`:`Generate skill and knowledge`]}),children:[o===`draft`&&(0,Y.jsxs)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:[`Mask is writing `,h,`'s skill and knowledge note…`]}),t?b.length===0?!t.error&&o!==`draft`&&(0,Y.jsxs)(`p`,{className:`m-0 text-sm text-muted`,children:[`None yet. Generate a skill and a knowledge note from `,h,`'s checks, then change them as you need.`]}):(0,Y.jsx)(`ul`,{"aria-label":`${h}'s own skills and knowledge`,className:`m-0 flex list-none flex-col p-0`,children:b.map(e=>(0,Y.jsxs)(`li`,{className:`flex items-center gap-4 border-t border-line-soft py-2`,children:[(0,Y.jsx)(W,{icon:e.kind===`skills`?Ce:Ee,size:16,className:`text-muted`}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`font-mono text-[13px] [overflow-wrap:anywhere]`,children:e.name}),(0,Y.jsx)(`span`,{className:`line-clamp-2 text-[13px] text-muted [overflow-wrap:anywhere]`,children:e.kind===`skills`?`Skill · ${e.description}`:`Knowledge note`})]}),(0,Y.jsxs)(H,{size:`sm`,disabled:!!o,onClick:()=>(m(``),i({drafted:!1,items:[{...e,replace:!0,was:e.name}]})),children:[(0,Y.jsx)(l,{"aria-hidden":`true`}),`Edit`]})]},`${e.kind}:${e.name}`))}):(0,Y.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}),t?.problems.length?(0,Y.jsxs)(`p`,{className:`m-0 text-[13px] text-warn [overflow-wrap:anywhere]`,children:[`Not read: `,t.problems.join(`; `)]}):null,(c||t?.error)&&(0,Y.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,Y.jsx)(Ot,{wide:!0,open:!!r,onClose:()=>i(null),title:r?.drafted?`Review ${h}'s skill and knowledge`:`Edit ${r?.items[0]?.was||``}`,description:(0,Y.jsxs)(Y.Fragment,{children:[r?.drafted&&(0,Y.jsx)(Y.Fragment,{children:`Mask's draft: change anything, then save. `}),`Kept in `,(0,Y.jsxs)(`span`,{className:`font-mono text-[13px]`,children:[`.forgeqe/business-personas/`,e.id,`/`]}),` and used only when someone works as `,h,`.`]}),footer:(0,Y.jsxs)(Y.Fragment,{children:[f?(0,Y.jsx)(`span`,{role:`alert`,className:`mr-auto self-center text-sm text-fail [overflow-wrap:anywhere]`,children:f}):r&&!S&&(0,Y.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.`}),r&&!r.drafted&&r.items[0]?.was&&(0,Y.jsxs)(H,{disabled:!!o,onClick:()=>void y({...r.items[0],name:r.items[0].was}),className:F(!f&&S&&`mr-auto`,`text-fail`),children:[(0,Y.jsx)(a,{"aria-hidden":`true`}),o.startsWith(`remove:`)?`Deleting…`:`Delete`]}),(0,Y.jsxs)(H,{onClick:()=>i(null),children:[(0,Y.jsx)(p,{"aria-hidden":`true`}),`Cancel`]}),(0,Y.jsxs)(H,{variant:`primary`,disabled:o===`save`||!S,onClick:()=>void v(),children:[(0,Y.jsx)(C,{"aria-hidden":`true`}),o===`save`?`Saving…`:r?.drafted?`Save both`:`Save`]})]}),children:r&&(0,Y.jsx)(`div`,{className:`flex flex-col gap-6 pt-4`,children:r.items.map((e,t)=>(0,Y.jsxs)(`section`,{"aria-labelledby":`own-item-${t}`,className:`flex flex-col gap-4`,children:[(0,Y.jsxs)(`h3`,{id:`own-item-${t}`,className:`m-0 flex items-center gap-2 text-[13px] font-semibold text-muted`,children:[(0,Y.jsx)(W,{icon:e.kind===`skills`?Ce:Ee,size:14}),e.kind===`skills`?`Skill`:`Knowledge note`,e.replace&&!e.was&&(0,Y.jsx)(`span`,{className:`font-normal text-warn`,children:` · replaces the one of this name`})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Name`}),(0,Y.jsx)(V,{value:e.name,maxLength:64,spellCheck:!1,autoComplete:`off`,className:`font-mono`,onChange:e=>x(t,{name:e.target.value.toLowerCase().replace(/[^a-z0-9-]+/g,`-`)})})]}),e.kind===`skills`&&(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Use when`}),(0,Y.jsx)(V,{value:e.description,maxLength:400,onChange:e=>x(t,{description:e.target.value})})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`label`,{htmlFor:`own-body-${t}`,className:`font-medium`,children:e.kind===`skills`?`Instructions`:`What it says`}),(0,Y.jsx)(Xt,{id:`own-body-${t}`,value:e.body,lang:`markdown`,onChange:e=>x(t,{body:e})})]})]},t))})})]})}function ai({persona:e,resources:t,onAdd:n}){let r=[[`persona-validates`,`What they check before accepting the software`,e.validates,Se],[`persona-goals`,`What they want to do`,e.goals,_e],[`persona-knows`,`What they know`,e.knows,E],[`persona-frustrations`,`What puts them off`,e.frustrations,s],[`persona-scenarios`,`What they would try`,e.scenarios,pe],[`persona-motivations`,`What drives them`,e.motivations,ue],[`persona-permissions`,`What their role lets them do`,e.permissions,xe],[`persona-constraints`,`What limits them`,e.constraints,O],[`persona-mistakes`,`Mistakes they make`,e.mistakes,c],[`persona-relationships`,`Who they deal with`,e.relationships,j]];return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-6 pt-4`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`p`,{className:`m-0 text-[13px] text-muted`,children:[(0,Y.jsxs)(`span`,{className:`font-mono`,children:[`/`,e.handle]}),` · `,Br[e.kind],` · `,e.role,e.domain?` · ${e.domain}`:``,` · `,e.expertise.charAt(0).toUpperCase()+e.expertise.slice(1),e.intent===`legitimate`?``:` · ${zr[e.intent].toLowerCase()}, risk appetite ${e.risk_appetite}`,e.builtIn?``:` · version ${e.version}`]}),e.description&&(0,Y.jsx)(`p`,{className:`m-0 text-sm leading-relaxed text-ink-2`,children:e.description})]}),(0,Y.jsx)(ii,{persona:e}),(0,Y.jsx)(ti,{persona:e,resources:t,...n?{onAdd:n}:{}}),r.filter(([,,e])=>e.length).map(([e,t,n,r])=>(0,Y.jsx)(G,{id:e,icon:r,title:t,level:3,children:(0,Y.jsx)(`ul`,{className:`m-0 flex list-disc flex-col gap-1 pl-6 text-sm text-ink-2`,children:n.map(e=>(0,Y.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:e},e))})},e))]})}var oi={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:[]},si=[{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.`}],ci=e=>e.split(`
7
7
  `).map(e=>e.trim()).filter(Boolean);function li({open:e,onClose:t,personas:n,onSaved:r}){let[i,a]=(0,J.useState)(``),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(``),[d,f]=(0,J.useState)(null),[m,h]=(0,J.useState)({}),[g,_]=(0,J.useState)(!1),[v,y]=(0,J.useState)(``),[b,x]=(0,J.useState)(``),S=(0,J.useMemo)(()=>new Set(n.flatMap(e=>[e.id,e.handle])),[n]),ee=ei(!!d),w=(0,J.useRef)(0);(0,J.useEffect)(()=>{w.current+=1,e&&(a(``),s(``),l(``),f(null),h({}),_(!1),y(``),x(``))},[e]);let T=e=>{f(e),h(Object.fromEntries(si.map(({key:t})=>[t,e[t].join(`
8
- `)])))},E=async()=>{let e=w.current;y(`draft`),x(``);try{let{persona:t}=await I.draft({request:i.trim(),...o?{kind:o}:{},...c.trim()?{domain:c.trim()}:{}});if(e!==w.current)return;let{builtIn:n,...r}=t;T(r),_(!0)}catch(t){e===w.current&&x(t.message)}finally{e===w.current&&y(``)}},D=async()=>{if(d){y(`save`),x(``);try{let e={...d,...Object.fromEntries(si.map(({key:e})=>[e,ci(m[e]||``)]))};r((await I.save(e)).saved)}catch(e){x(e.message),y(``)}}},te=d?ui(d,m,S,!1):null,O=!!te?.canSave;return(0,Y.jsx)(yt,{wide:!0,open:e,onClose:t,title:`New persona`,description:(0,Y.jsxs)(Y.Fragment,{children:[`Saved in `,(0,Y.jsxs)(`span`,{className:`font-mono text-[13px]`,children:[`.forgeqe/business-personas/`,d?.id||`<id>`,`.yaml`]}),`, shared with the project.`]}),footer:(0,Y.jsxs)(Y.Fragment,{children:[b?(0,Y.jsx)(`span`,{role:`alert`,className:`mr-auto self-center text-sm text-fail [overflow-wrap:anywhere]`,children:b}):d&&!O&&(0,Y.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,Y.jsxs)(H,{onClick:t,children:[(0,Y.jsx)(p,{"aria-hidden":`true`}),`Cancel`]}),(0,Y.jsxs)(H,{variant:`primary`,disabled:!!v||!O,onClick:()=>void D(),children:[(0,Y.jsx)(C,{"aria-hidden":`true`}),v===`save`?`Saving…`:`Save`]})]}),children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-6 pt-4`,children:[(0,Y.jsxs)(G,{id:`persona-ask`,icon:j,title:`Who is the persona?`,level:3,children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Describe them`}),(0,Y.jsx)(`span`,{className:`text-[13px] text-muted`,children:`Their job, what they know and what they check. Mask drafts the rest.`}),(0,Y.jsx)(Xe,{rows:3,value:i,maxLength:2e3,onChange:e=>a(e.target.value),placeholder:`An SME in card payments who reconciles settlements every morning and signs off refunds`})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Kind`}),(0,Y.jsxs)(B,{value:o,onChange:e=>s(e.target.value),children:[(0,Y.jsx)(`option`,{value:``,children:`Let the agent choose`}),Ge.map(e=>(0,Y.jsx)(`option`,{value:e,children:Br[e]},e))]})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Domain`}),(0,Y.jsx)(V,{value:c,maxLength:80,onChange:e=>l(e.target.value),placeholder:`payments`})]})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsxs)(H,{disabled:!!v||!i.trim(),onClick:()=>void E(),"data-tip":g?`Ask Mask for another draft`:`Ask Mask for a draft`,children:[(0,Y.jsx)(u,{"aria-hidden":`true`}),g?`Draft again`:`Draft`]}),!d&&(0,Y.jsxs)(H,{disabled:!!v,onClick:()=>T(oi),"data-tip":`Write every field yourself`,children:[(0,Y.jsx)(ce,{"aria-hidden":`true`}),`Write`]}),v===`draft`&&(0,Y.jsx)(`span`,{role:`status`,className:`text-sm text-muted`,children:`Mask is drafting…`})]})]}),d&&te&&(0,Y.jsx)(G,{id:`persona-fields`,icon:de,title:`The persona`,level:3,children:(0,Y.jsx)(di,{fields:d,listText:m,onFields:f,onListText:h,check:te,idLocked:!1,resources:ee})})]})})}function ui(e,t,n,r){let i=r||e.id===``?``:Gr.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===``?``:Kr.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()&&(ci(t.validates||``).length>0||ci(t.goals||``).length>0)}}function di({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,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Name`}),(0,Y.jsx)(V,{value:e.name,maxLength:80,onChange:e=>s(`name`,e.target.value),placeholder:`Priya, payments SME`})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Id`}),(0,Y.jsx)(V,{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,Y.jsx)(`p`,{id:`persona-id-error`,role:`alert`,className:`m-0 text-[13px] text-fail`,children:c})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Command`}),(0,Y.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,Y.jsx)(V,{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,Y.jsx)(`p`,{id:`persona-handle-error`,role:`alert`,className:`m-0 text-[13px] text-fail`,children:l})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Kind`}),(0,Y.jsx)(B,{value:e.kind,onChange:e=>s(`kind`,e.target.value),children:Ge.map(e=>(0,Y.jsx)(`option`,{value:e,children:Br[e]},e))})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Expertise in the domain`}),(0,Y.jsx)(B,{value:e.expertise,onChange:e=>s(`expertise`,e.target.value),children:Ue.map(e=>(0,Y.jsx)(`option`,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Intent`}),(0,Y.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,Y.jsx)(B,{value:e.intent,onChange:e=>s(`intent`,e.target.value),children:We.map(e=>(0,Y.jsx)(`option`,{value:e,children:zr[e]},e))})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Risk appetite`}),(0,Y.jsx)(B,{value:e.risk_appetite,onChange:e=>s(`risk_appetite`,e.target.value),children:Ke.map(e=>(0,Y.jsx)(`option`,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Role`}),(0,Y.jsx)(V,{value:e.role,maxLength:120,onChange:e=>s(`role`,e.target.value),placeholder:`Payments operations lead`})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Domain`}),(0,Y.jsx)(V,{value:e.domain,maxLength:80,onChange:e=>s(`domain`,e.target.value)})]})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Who they are`}),(0,Y.jsx)(Xe,{rows:3,value:e.description,maxLength:1200,onChange:e=>s(`description`,e.target.value)})]}),si.map(({key:e,label:n,hint:i})=>(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:n}),(0,Y.jsx)(`span`,{className:`text-[13px] text-muted`,children:i}),(0,Y.jsx)(Xe,{rows:e===`validates`?5:3,value:t[e]||``,onChange:n=>r({...t,[e]:n.target.value})})]},e)),(0,Y.jsx)(pi,{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,Y.jsx)(pi,{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 fi=12;function pi({id:e,label:t,hint:n,items:r,error:i,value:a,onChange:o}){let[s,c]=(0,J.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>=fi;return(0,Y.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 border-0 p-0 text-sm`,children:[(0,Y.jsxs)(`legend`,{className:`mb-2 p-0 font-medium`,children:[t,` `,(0,Y.jsxs)(`span`,{className:`font-normal text-muted tabular-nums`,children:[`· `,a.length,` picked`]})]}),(0,Y.jsx)(`span`,{className:`text-[13px] text-muted`,children:n}),i?(0,Y.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,Y.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`There are none in this project yet.`}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,Y.jsx)(rt,{id:`${e}-find`,label:`Find in ${t.toLowerCase()}`,value:s,onChange:c})}),(0,Y.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,Y.jsx)(`li`,{className:`py-4 text-sm text-muted`,children:`Nothing matches.`}),d.map(e=>{let t=a.includes(e.id);return(0,Y.jsx)(`li`,{className:`border-t border-line-soft first:border-t-0`,children:(0,Y.jsxs)(`label`,{className:F(`flex min-h-12 items-center gap-4 py-2`,!t&&f?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,Y.jsx)(Rt,{checked:t,disabled:!t&&f,onCheckedChange:t=>o(t?[...a,e.id]:a.filter(t=>t!==e.id))}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:F(`text-[13px] [overflow-wrap:anywhere]`,e.mono?`font-mono`:`font-medium`),children:e.title}),(0,Y.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,Y.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[`At most `,fi,`: take one off to pick another.`]})]}):(0,Y.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`})]})}var mi=[`agent`,`tests`,`personas`,`findings`],hi={agent:`Agent`,tests:`Tests`,personas:`Personas`,findings:`Findings`},gi={agent:`BASAL`,tests:`Business tests`,personas:`Personas`,findings:`Findings`},_i={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.`},vi={tests:D,personas:j,findings:je},$=(e,t)=>e===`agent`?M(`agents`,`basal`):t?M(`agents`,`basal`,e,t):M(`agents`,`basal`,e),yi=[`ask`,`understand`,`strategy`,`cast`,`rehearse`,`approve`,`act`,`judge`],bi={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.`}},xi={asked:1,understood:2,planned:3,cast:4,rehearsed:5,approved:6,acted:8},Si={understand:1,strategy:2,cast:3,rehearse:4,act:6},Ci=e=>String(e).padStart(2,`0`),wi=[{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`}],Ti={confirmed_failure:`fail`,policy_ambiguity:`warn`,potential_risk:`warn`,missing_evidence:`neutral`,expected_behaviour:`pass`},Ei=[`confirmed_failure`,`policy_ambiguity`,`potential_risk`,`missing_evidence`,`expected_behaviour`];function Di({page:e,tab:t,sub:n}){let r=mi.includes(t)?t:`agent`,[i,a]=r===`tests`&&n?n.split(`/`):[],o=i?ge(i):``,s=(e,t)=>(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(pt,{icon:vi[e],title:gi[e],description:_i[e]}),t]});return(0,Y.jsx)(Vt,{page:e,title:at(`basal`),label:`BASAL`,current:r,onPick:e=>location.hash=$(e),tabs:mi.filter(e=>e!==Qt).map(e=>({id:e,label:hi[e],icon:vi[e]})),agentBody:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`m-0 text-[13px] leading-relaxed text-ink-2`,children:_i.agent}),(0,Y.jsx)(Mi,{}),(0,Y.jsx)(Nt,{scope:{kind:`page`,page:e}})]}),children:o?(0,Y.jsx)(Pi,{id:o,step:yi.includes(a)?a:void 0},o):r===`tests`?s(`tests`,(0,Y.jsx)(Ni,{})):r===`personas`?s(`personas`,(0,Y.jsx)(Xi,{})):r===`findings`?s(`findings`,(0,Y.jsx)(Zi,{})):null})}function Oi(){let[e,t]=(0,J.useState)(null),[n,r]=(0,J.useState)(``),i=(0,J.useCallback)(()=>L.home().then(t,e=>r(e.message)),[]);return(0,J.useEffect)(()=>void i(),[i]),{home:e,error:n,load:i}}function ki({g:e}){return(0,Y.jsx)(`p`,{className:`m-0 text-[13px] text-muted tabular-nums`,children:e.connected?(0,Y.jsxs)(Y.Fragment,{children:[`Graph store: running · `,z(e.product||0,`product node`),` · `,z(e.scenario||0,`scenario node`),e.embedding?` · found by meaning with ${e.embedding}`:` · by words only (no embedding model)`]}):(0,Y.jsxs)(Y.Fragment,{children:[`Graph store: the product graph's file`,e.reason?` (${e.reason})`:``,`. forgeqe graph setup starts it.`]})})}function Ai({home:e}){let[t,n]=(0,J.useState)(``),[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(``),c=async()=>{a(!0),s(``);try{let{id:e}=await L.ask(t.trim());await L.stage(e,`understand`),location.hash=$(`tests`,`${e}/understand`)}catch(e){s(e.message)}finally{a(!1)}};return(0,Y.jsxs)(G,{id:`basal-new`,icon:r,title:`New business test`,divider:!1,className:`rounded-[14px] card border p-4`,children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Your business question`}),(0,Y.jsx)(Xe,{id:`basal-request`,rows:3,value:t,onChange:e=>n(e.target.value),placeholder:`Should we launch saved cards with a fee? Test how merchants, shoppers and support would really be affected.`})]}),(0,Y.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,Y.jsx)(un,{text:o}),(0,Y.jsx)(`div`,{children:(0,Y.jsxs)(H,{variant:`primary`,disabled:i||t.trim().length<10||!e.model,onClick:()=>void c(),"data-tip":e.model?`Keeps the question and starts step 02, Understand`:`Set up a model in Settings › Models first`,children:[(0,Y.jsx)(v,{"aria-hidden":`true`}),i?`Starting…`:`Start`]})})]})}function ji({tests:e,search:t=!0,tools:n}){return(0,Y.jsx)(_t,{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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`th`,{scope:`col`,className:F(mt,`w-[55%]`),children:`Business question`}),(0,Y.jsx)(`th`,{scope:`col`,className:F(mt,`hidden @xl:table-cell`),children:`Asked`}),(0,Y.jsx)(`th`,{scope:`col`,className:F(Wt,`hidden @2xl:table-cell`),children:`Steps done`}),(0,Y.jsx)(`th`,{scope:`col`,className:mt,children:`Stage`})]}),children:e.map(e=>{let t=xi[e.stage];return(0,Y.jsxs)(`tr`,{onClick:()=>location.hash=$(`tests`,e.id),className:Tt,children:[(0,Y.jsxs)(`td`,{className:F(Dt,`max-w-0`),children:[(0,Y.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,Y.jsx)(`span`,{className:`block truncate font-mono text-muted`,children:e.id})]}),(0,Y.jsx)(`td`,{className:F(Dt,`hidden whitespace-nowrap text-muted @xl:table-cell`),children:e.created.slice(0,10)}),(0,Y.jsx)(`td`,{className:F(Kt,`hidden text-muted @2xl:table-cell`),children:t===void 0?`–`:`${t} of ${yi.length}`}),(0,Y.jsx)(`td`,{className:F(Dt,`whitespace-nowrap`),children:e.running?(0,Y.jsx)(U,{tone:`running`,children:e.running}):(0,Y.jsx)(U,{tone:`neutral`,children:e.stage})})]},e.id)})})}function Mi(){let{home:e,error:t}=Oi();return t?(0,Y.jsx)(un,{text:t}):e?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Y.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:yi.map((e,t)=>(0,Y.jsxs)(`li`,{className:`flex flex-col gap-1 rounded-[12px] bg-surface-muted p-4`,children:[(0,Y.jsxs)(`span`,{className:`font-mono text-[13px] text-muted`,children:[`STEP `,Ci(t+1)]}),(0,Y.jsx)(`span`,{className:`text-[13px] font-semibold`,children:bi[e].name})]},e))}),(0,Y.jsx)(ki,{g:e.graph}),(0,Y.jsx)(Ai,{home:e}),e.tests.length>0&&(0,Y.jsx)(G,{id:`basal-recent`,icon:te,title:`Recent tests`,actions:(0,Y.jsx)(`a`,{href:$(`tests`),className:`text-[13px] font-normal`,children:`Every test`}),children:(0,Y.jsx)(ji,{tests:e.tests.slice(0,5),search:!1})})]}):(0,Y.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`})}function Ni(){let{home:e,error:t,load:n}=Oi();return t?(0,Y.jsx)(un,{text:t}):e?(0,Y.jsx)(ji,{tests:e.tests,tools:(0,Y.jsxs)(H,{size:`sm`,variant:`ghost`,onClick:()=>void n(),className:`ml-auto`,"data-tip":`Read the tests again`,children:[(0,Y.jsx)(f,{"aria-hidden":`true`}),`Refresh`]})}):(0,Y.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`})}function Pi({id:e,step:t}){let[n,r]=(0,J.useState)(null),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(``),c=(0,J.useCallback)(()=>L.test(e).then(r,e=>s(e.message)),[e]),l=(0,J.useCallback)(()=>L.graph(e).then(a,e=>s(`The graph could not be read: ${e.message}`)),[e]);(0,J.useEffect)(()=>{c(),l()},[c,l]);let u=!(!n?.job||n.job.endedAt);if((0,J.useEffect)(()=>{if(!u)return;let e=St(()=>{c(),l()},2500);return()=>{bt(e),l()}},[u,c,l]),!n)return o?(0,Y.jsx)(un,{text:o}):(0,Y.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`});let d=xi[n.stage],f=n.job&&!n.job.endedAt?Si[n.job.stage]:-1,p=t||yi[f>=0?f:Math.min(d,yi.length-1)],m=yi.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,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(it,{href:$(`tests`),label:`Every test`}),(0,Y.jsx)(`div`,{"data-tip":n.scenario?.decision||n.request.request,children:(0,Y.jsx)(pt,{icon:D,title:n.scenario?.decision||n.request.request,description:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.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,Y.jsx)(`nav`,{"aria-label":`BASAL's steps`,className:`overflow-x-auto`,children:(0,Y.jsx)(`ol`,{className:`m-0 grid min-w-[800px] list-none grid-cols-8 gap-1 rounded-[12px] bg-surface-muted p-1`,children:yi.map((e,t)=>{let r=g(t),i=t<=d||t===f,a=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,Y.jsx)(`span`,{className:`font-mono text-[13px] text-muted`,children:Ci(t+1)}),(0,Y.jsx)(`span`,{className:`text-[13px] font-medium`,children:bi[e].name})]}),(0,Y.jsx)(U,{tone:r.tone,icon:r.tone===`running`,className:`self-start`,children:r.word})]});return(0,Y.jsx)(`li`,{className:`min-w-0`,children:i?(0,Y.jsx)(`a`,{href:$(`tests`,`${n.id}/${e}`),"aria-current":e===p?`step`:void 0,className:F(`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,Y.jsx)(`span`,{className:`flex h-full flex-col gap-1 rounded-[8px] px-2 py-2 opacity-60`,children:a})},e)})})}),o&&(0,Y.jsx)(un,{text:o}),(0,Y.jsxs)(`div`,{className:`grid items-start gap-4 @[960px]:grid-cols-[minmax(0,1fr)_minmax(0,1.15fr)]`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 @[960px]:sticky @[960px]:top-4`,children:[(0,Y.jsx)(`p`,{className:`m-0 text-[13px] text-muted tabular-nums`,children:i?.connected?`${z(i.nodes.length,`node`)} · ${z(i.edges.length,`edge`)} · scenario over the product graph`:`Graph store not connected`}),(0,Y.jsx)(Vi,{graph:i,onRefresh:()=>void L.regraph(e).then(l,e=>s(e.message))})]}),(0,Y.jsxs)(`section`,{"aria-labelledby":`basal-step`,className:`flex min-w-0 flex-col gap-4 rounded-[14px] card border p-4`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsxs)(`span`,{className:`rounded-[8px] bg-accent-soft px-2 py-1 font-mono text-[13px] font-medium text-accent-fg`,children:[`STEP `,Ci(m+1)]}),(0,Y.jsx)(`h3`,{id:`basal-step`,className:`m-0 text-[16px] font-semibold`,children:bi[p].name}),(0,Y.jsx)(`span`,{className:`ml-auto`,children:(0,Y.jsx)(U,{tone:_.tone,children:_.word})})]}),(0,Y.jsx)(`p`,{className:`m-0 text-[13px] text-ink-2`,children:bi[p].about}),n.job&&Si[n.job.stage]===m&&(0,Y.jsx)(Bi,{t:n}),(0,Y.jsx)(Fi,{step:p,t:n,onRun:h})]})]})]})}function Fi({step:e,t,onRun:n}){let r=!(!t.job||t.job.endedAt),i=(e,t,i,a)=>(0,Y.jsx)(`div`,{className:`border-t border-line pt-4`,children:(0,Y.jsxs)(H,{variant:`primary`,disabled:r,onClick:()=>void n(i,a),"data-tip":t,children:[(0,Y.jsx)(N,{"aria-hidden":`true`}),e]})}),a=(e,n)=>(0,Y.jsx)(`div`,{className:`border-t border-line pt-4`,children:(0,Y.jsxs)(`a`,{href:$(`tests`,`${t.id}/${n}`),className:Qe({variant:`primary`}),children:[(0,Y.jsx)(N,{"aria-hidden":`true`}),e]})});return e===`ask`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.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,Y.jsx)(cn,{label:`Files`,children:t.request.files.length?t.request.files.join(`, `):`none`}),(0,Y.jsx)(cn,{label:`Work items`,children:t.request.stories.length?t.request.stories.join(`, `):`none`}),(0,Y.jsx)(cn,{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`,()=>L.stage(t.id,`understand`),`understand`):a(`Next: Understand`,`understand`)]}):e===`understand`?t.scenario?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Yi,{t}),t.stage===`understood`?i(`Plan the test strategy`,`Scenarios, the agent for each step, and the business expectations`,()=>L.stage(t.id,`strategy`),`strategy`):a(`Next: Strategy`,`strategy`)]}):(0,Y.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`BASAL is reading the sources.`}):e===`strategy`?t.strategy?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(qi,{t}),t.stage===`planned`?i(`Cast the personas`,`One persona for each stakeholder who acts in the strategy`,()=>L.stage(t.id,`cast`),`cast`):a(`Next: Cast`,`cast`)]}):(0,Y.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`Not planned yet.`}):e===`cast`?t.cast.length?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Ji,{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`,()=>L.stage(t.id,`rehearse`),`rehearse`):a(`Next: Rehearse`,`rehearse`)]}):(0,Y.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`Not cast yet.`}):e===`rehearse`?(0,Y.jsx)(Li,{t,onRun:n}):e===`approve`?(0,Y.jsx)(Ri,{t,onRun:n}):e===`act`?(0,Y.jsx)(zi,{t,onRun:n}):t.verdicts.length?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Ui,{t,onObserve:(e,r,i)=>void n(()=>L.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`,()=>L.stage(t.id,`rehearse`),`rehearse`)]}):(0,Y.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`No verdict yet: the strategy has not been played.`})}var Ii={support:`pass`,oppose:`fail`,undecided:`neutral`};function Li({t:e,onRun:t}){let n=!(!e.job||e.job.endedAt),r=new Map(e.cast.map(e=>[e.id,e.name])),i=e.rounds.at(-1),a=e.rounds.flatMap(e=>e.posts),o=new Map(a.map(e=>[e.id,e]));if(!i)return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`No round yet.`}),(0,Y.jsx)(`div`,{className:`border-t border-line pt-4`,children:(0,Y.jsxs)(H,{variant:`primary`,disabled:n||!e.cast.length,onClick:()=>void t(()=>L.stage(e.id,`rehearse`)),children:[(0,Y.jsx)(v,{"aria-hidden":`true`}),`Play round 1`]})})]});let s={support:0,oppose:0,undecided:0};for(let e of i.turns)s[e.stance]=(s[e.stance]||0)+1;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`m-0 text-[13px] text-muted tabular-nums`,children:[`Round `,i.n,` · `,z(a.length,`post`),` on the feed · `,s.support,` support · `,s.oppose,` oppose · `,s.undecided,` undecided`,i.events.length?` · reacted to ${z(i.events.length,`outcome`)} on the product`:``]}),(0,Y.jsx)(G,{icon:Ae,title:`Feed`,level:3,children:(0,Y.jsx)(`ol`,{className:`m-0 flex max-h-[420px] list-none flex-col gap-2 overflow-y-auto p-0`,children:a.toReversed().map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-col gap-1 rounded-[8px] border border-line bg-bg p-2 text-[13px]`,children:[(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:r.get(e.author)||e.author}),(0,Y.jsxs)(`span`,{className:`text-muted`,children:[e.kind,e.target?` on ${r.get(o.get(e.target)?.author||``)||e.target}`:``,` · round `,e.round]})]}),(0,Y.jsx)(`span`,{className:`text-ink-2 [overflow-wrap:anywhere]`,children:e.text})]},e.id))})}),(0,Y.jsx)(G,{icon:j,title:(0,Y.jsxs)(Y.Fragment,{children:[`Where the cast stand after round `,i.n]}),level:3,children:(0,Y.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0 text-[13px]`,children:i.turns.map(e=>(0,Y.jsxs)(`li`,{className:`flex items-start justify-between gap-2`,children:[(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:r.get(e.id)||e.id}),` `,(0,Y.jsxs)(`span`,{className:`text-ink-2`,children:[`— `,e.feeling]})]}),(0,Y.jsx)(U,{tone:Ii[e.stance]||`neutral`,icon:!1,children:e.stance})]},e.id))})}),e.wanted.length>0&&(0,Y.jsx)(G,{icon:ue,title:`What the cast want tried`,level:3,className:`text-[13px]`,children:e.wanted.map(e=>(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{className:`font-mono`,children:e.scenario}),` `,(0,Y.jsxs)(`span`,{className:`text-muted`,children:[`· `,e.by.map(e=>r.get(e)||e).join(`, `)]})]},e.scenario))}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2 border-t border-line pt-4`,children:[(0,Y.jsxs)(`a`,{href:$(`tests`,`${e.id}/${e.strategy?.approved?`act`:`approve`}`),className:Qe({variant:`primary`}),children:[(0,Y.jsx)(N,{"aria-hidden":`true`}),e.strategy?.approved?`Next: Act`:`Next: Approve`]}),(0,Y.jsxs)(H,{variant:`outline`,disabled:n,onClick:()=>void t(()=>L.stage(e.id,`rehearse`)),children:[(0,Y.jsx)(v,{"aria-hidden":`true`}),`Play round `,i.n+1]})]})]})}function Ri({t:e,onRun:t}){let[n,r]=(0,J.useState)(``);if(e.strategy?.approved)return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.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,Y.jsx)(`div`,{className:`border-t border-line pt-4`,children:(0,Y.jsxs)(`a`,{href:$(`tests`,`${e.id}/act`),className:Qe({variant:`primary`}),children:[(0,Y.jsx)(N,{"aria-hidden":`true`}),`Next: Act`]})})]});let i=e.strategy;return(0,Y.jsxs)(Y.Fragment,{children:[i?(0,Y.jsxs)(`ul`,{className:`m-0 flex flex-col gap-1 pl-6 text-[13px] text-ink-2`,children:[(0,Y.jsxs)(`li`,{children:[z(i.scenarios.length,`scenario`),` on `,i.environment||`no test environment`,`, `,z(i.scenarios.reduce((e,t)=>e+t.steps.length,0),`step`)]}),(0,Y.jsx)(`li`,{children:e.writes.length?`${z(e.writes.length,`step`)} change data: Act lists them for your agreement before anything runs`:`No step changes data`}),(0,Y.jsxs)(`li`,{children:[`Plays on:`,` `,[...new Set(i.scenarios.flatMap(e=>e.steps.map(e=>e.app?`${e.app} (${Ki[e.channel]})`:Ki[e.channel])))].join(`, `)]}),i.needs.length>0&&(0,Y.jsxs)(`li`,{className:`text-warn`,children:[z(i.needs.length,`thing`),` still needed: see Strategy`]})]}):null,(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Type the test's id to approve`}),(0,Y.jsx)(V,{id:`basal-typed`,value:n,onChange:e=>r(e.target.value),placeholder:`Type the test's id`})]}),(0,Y.jsx)(`span`,{className:`font-mono text-[13px] text-muted`,children:e.id}),(0,Y.jsx)(`div`,{className:`border-t border-line pt-4`,children:(0,Y.jsxs)(H,{variant:`primary`,disabled:n.trim()!==e.id||!i,onClick:()=>void t(()=>L.approve(e.id,n.trim()),`act`),children:[(0,Y.jsx)(C,{"aria-hidden":`true`}),`Approve`]})})]})}function zi({t:e,onRun:t}){let[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(!0),o=!(!e.job||e.job.endedAt);if(!e.strategy?.approved)return(0,Y.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`Approve the strategy first.`});let s=i&&e.wanted.length?e.wanted.map(e=>e.scenario):[];return(0,Y.jsxs)(Y.Fragment,{children:[e.handovers.length>0&&(0,Y.jsx)(Hi,{handovers:e.handovers}),!o&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-line pt-4`,children:[e.wanted.length>0&&(0,Y.jsxs)(`label`,{className:`flex min-h-9 cursor-pointer items-center gap-2 text-[13px]`,children:[(0,Y.jsx)(Rt,{id:`basal-wanted`,checked:i,onCheckedChange:a}),`Only what the cast wants tried after round `,e.rounds.length,`: `,e.wanted.map(e=>e.scenario).join(`, `)]}),e.writes.length>0?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`m-0 text-[13px] text-ink-2`,children:[`These steps change data on `,e.strategy.environment,`. Without your agreement they are skipped and the agents change nothing.`]}),(0,Y.jsx)(`ul`,{className:`m-0 flex flex-col gap-1 pl-4 text-[13px] text-warn`,children:e.writes.map(e=>(0,Y.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:e},e))}),(0,Y.jsxs)(`label`,{className:`flex min-h-9 cursor-pointer items-center gap-2 text-[13px]`,children:[(0,Y.jsx)(Rt,{id:`basal-writes`,checked:n,onCheckedChange:r}),`Let these steps change data`]})]}):(0,Y.jsx)(`p`,{className:`m-0 text-[13px] text-ink-2`,children:`No step changes data.`}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Y.jsxs)(H,{variant:`primary`,onClick:()=>void t(()=>L.act(e.id,n?e.writes:[],s)),"data-tip":`Hands each step to ForgeQE's agents as its persona`,children:[(0,Y.jsx)(v,{"aria-hidden":`true`}),e.verdicts.length?`Play it again`:`Act`]}),e.verdicts.length>0&&(0,Y.jsxs)(`a`,{href:$(`tests`,`${e.id}/judge`),className:Qe({variant:`outline`}),children:[(0,Y.jsx)(N,{"aria-hidden":`true`}),`Next: Judge`]})]})]})]})}function Bi({t:e}){let t=e.job;return(0,Y.jsxs)(G,{id:`basal-feed`,icon:A,title:(0,Y.jsxs)(Y.Fragment,{children:[`Live · `,t.stage]}),level:3,className:`rounded-[14px] card border p-4`,actions:t.endedAt?(0,Y.jsx)(U,{tone:t.error?`fail`:`pass`,children:t.error?`stopped`:`finished`}):(0,Y.jsx)(U,{tone:`running`,children:`working`}),children:[(0,Y.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,Y.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:e},t))}),t.error&&(0,Y.jsx)(un,{text:t.error})]})}function Vi({graph:e,onRefresh:t}){let[n,r]=(0,J.useState)(null),{nodes:i,edges:a,types:o}=(0,J.useMemo)(()=>{let t=(e?.nodes||[]).map(e=>({id:e.id,name:e.type===`fact`?``:e.name.length>34?`${e.name.slice(0,32).trimEnd()}…`:e.name,type:e.layer===`product`?`product ${e.type}`:e.type}));return{nodes:t,edges:(e?.edges||[]).map((e,t)=>({id:`e${t}`,from:e.from,to:e.to,label:e.type})),types:[...new Set(t.map(e=>e.type))]}},[e]),s=e=>on[Math.max(0,o.indexOf(e))%on.length],c=null;if(n?.kind===`node`){let t=e?.nodes.find(e=>e.id===n.id);t&&(c={title:t.name,pill:{text:t.layer===`product`?`product ${t.type}`:t.type,colour:s(t.layer===`product`?`product ${t.type}`:t.type)},body:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`m-0 text-ink [overflow-wrap:anywhere]`,children:t.summary}),(0,Y.jsx)(cn,{label:`Layer`,children:t.layer}),t.state&&(0,Y.jsx)(cn,{label:`Evidence`,children:t.state})]})})}return e?.connected?i.length?(0,Y.jsx)(sn,{title:`Live knowledge graph`,nodes:i,edges:a,colourOfType:s,types:o,typesTitle:`Node types`,picked:n,onPick:r,detail:c,onRefresh:t}):(0,Y.jsx)(et,{icon:k,title:`No scenario in the graph yet`,children:`It appears once BASAL has understood the question.`}):(0,Y.jsx)(et,{icon:k,title:`The graph store is not connected`,children:e?.reason||`Start the graph store with forgeqe graph setup to see the scenario grow over the product graph.`})}function Hi({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,Y.jsx)(G,{id:`basal-board`,icon:oe,title:`Operations board`,level:3,description:`Each card is a handover from BASAL to one of ForgeQE's agents, as one persona.`,children:(0,Y.jsx)(`div`,{className:`grid gap-2 @[1200px]:grid-cols-2`,children:wi.filter(e=>n.some(t=>t.channel===e.channel)).map(e=>{let t=n.filter(t=>t.channel===e.channel);return(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 rounded-[12px] bg-surface-muted p-2`,children:[(0,Y.jsxs)(`h4`,{className:`m-0 px-2 pt-1 text-[13px] font-semibold`,children:[e.title,` `,(0,Y.jsxs)(`span`,{className:`font-normal text-muted`,children:[`· `,t.length]})]}),t.map(e=>(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-[8px] border border-line bg-bg p-2 text-[13px]`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:`truncate font-medium`,children:e.actor}),(0,Y.jsx)(U,{tone:r(e),children:i(e)})]}),(0,Y.jsxs)(`span`,{className:`text-muted`,children:[(0,Y.jsx)(`span`,{className:`font-mono`,children:e.scenario}),` · step `,e.step]}),e.note&&(0,Y.jsx)(`span`,{className:`text-ink-2 [overflow-wrap:anywhere]`,children:e.note}),e.run&&(0,Y.jsx)(`span`,{className:`font-mono text-muted`,children:e.run})]},`${e.scenario}#${e.step}`))]},e.channel)})})})}function Ui({t:e,onObserve:t}){let n=e.verdicts.toSorted((e,t)=>Ei.indexOf(e.outcome)-Ei.indexOf(t.outcome));return(0,Y.jsx)(`section`,{"aria-label":`Verdicts`,className:`flex flex-col gap-2`,children:(0,Y.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:n.map(e=>(0,Y.jsx)(Wi,{v:e,onObserve:(n,r)=>t(e.scenario,n,r)},e.scenario))})})}function Wi({v:e,onObserve:t}){return(0,Y.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-[12px] card border p-4`,children:[(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(U,{tone:Ti[e.outcome],children:e.label}),(0,Y.jsx)(`span`,{className:`text-[13px] font-medium`,children:e.title}),(0,Y.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[`· confidence `,e.confidence]})]}),(0,Y.jsx)(`p`,{className:`m-0 text-[13px] text-ink-2 [overflow-wrap:anywhere]`,children:e.why}),e.results.length>0&&(0,Y.jsx)(`ul`,{className:`m-0 flex flex-col gap-1 pl-4 text-[13px]`,children:e.results.map(e=>(0,Y.jsxs)(`li`,{className:F(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,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-[13px] text-warn`,children:[`Step `,e,` waits for a person:`,(0,Y.jsx)(H,{size:`sm`,variant:`outline`,onClick:()=>t(e,!0),children:`The app let them do it`}),(0,Y.jsx)(H,{size:`sm`,variant:`outline`,onClick:()=>t(e,!1),children:`The app refused it`})]},e))]})}var Gi=e=>e.map(e=>e.trim().replace(/(?<![.;])[.;]+$/,``)).join(`; `),Ki={browser:`browser`,api:`API`,mobile:`mobile`,desktop:`desktop`,person:`a person`,opinion:`opinion`};function qi({t:e}){let t=e.strategy;return(0,Y.jsxs)(`section`,{"aria-label":`Strategy`,className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`p`,{className:`m-0 text-[13px] text-muted`,children:[z(t.scenarios.length,`scenario`),` on `,t.environment||`no test environment`,` · `,z(t.rounds,`round`)]}),t.needs.length>0&&(0,Y.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,Y.jsx)(`li`,{children:e},e))}),(0,Y.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:t.scenarios.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-[12px] card border p-4`,children:[(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsxs)(U,{tone:e.priority===1?`warn`:`neutral`,icon:!1,children:[`P`,e.priority,` · `,e.risk]}),(0,Y.jsx)(`span`,{className:`text-[13px] font-medium`,children:e.title})]}),(0,Y.jsx)(`p`,{className:`m-0 text-[13px] text-ink-2`,children:e.question}),(0,Y.jsx)(`ol`,{className:`m-0 flex flex-col gap-1 pl-6 text-[13px]`,children:e.steps.map(e=>(0,Y.jsxs)(`li`,{className:`[overflow-wrap:anywhere]`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:e.actor}),` `,(0,Y.jsxs)(`span`,{className:`text-muted`,children:[`· `,Ki[e.channel],e.app?` ${e.app}`:``,e.changes_data?` · changes data`:``]}),` — `,e.does]},e.n))}),e.oracles.length>0&&(0,Y.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,Y.jsxs)(`li`,{children:[e.says,` `,(0,Y.jsxs)(`span`,{className:`text-muted`,children:[`(`,e.basis,`)`]})]},e.id))})]},e.id))})]})}function Ji({t:e}){return(0,Y.jsx)(`section`,{"aria-label":`Cast`,className:`flex flex-col gap-2`,children:(0,Y.jsx)(`ul`,{className:`m-0 grid list-none gap-2 p-0 @[1100px]:grid-cols-2`,children:e.cast.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-col gap-1 rounded-[12px] card border p-4 text-[13px]`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,Y.jsx)(U,{tone:e.intent===`legitimate`?`neutral`:`warn`,icon:!1,children:e.intent})]}),(0,Y.jsx)(`span`,{className:`text-muted`,children:e.role}),e.validates.length>0&&(0,Y.jsxs)(`span`,{className:`text-ink-2`,children:[`Checks: `,Gi(e.validates)]}),e.frustrations.length>0&&(0,Y.jsxs)(`span`,{className:`text-ink-2`,children:[`Objects to: `,Gi(e.frustrations)]}),e.mistakes.length>0&&(0,Y.jsxs)(`span`,{className:`text-ink-2`,children:[`Brings: `,Gi(e.mistakes)]})]},e.id))})})}function Yi({t:e}){let t=e.scenario,n=e=>(0,Y.jsx)(U,{tone:e===`observed`?`pass`:`neutral`,icon:!1,children:e});return(0,Y.jsxs)(`section`,{"aria-label":`What BASAL understood`,className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-[12px] card border p-4 text-[13px]`,children:[(0,Y.jsx)(pt,{icon:Se,title:`Success criteria`,level:3}),t.criteria.map(e=>(0,Y.jsxs)(`span`,{className:`flex items-start justify-between gap-2`,children:[(0,Y.jsxs)(`span`,{children:[e.text,e.measure?(0,Y.jsxs)(`span`,{className:`text-muted`,children:[` (`,e.measure,`)`]}):null]}),n(e.evidence)]},e.id))]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-[12px] card border p-4 text-[13px]`,children:[(0,Y.jsx)(pt,{icon:j,title:`Stakeholders`,level:3}),t.stakeholders.map(e=>(0,Y.jsxs)(`span`,{className:`flex items-start justify-between gap-2`,children:[(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:e.name}),` `,(0,Y.jsxs)(`span`,{className:`text-muted`,children:[`· `,e.kind]}),` — `,e.cares]}),n(e.evidence)]},e.id))]})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-[12px] card border p-4 text-[13px]`,children:[(0,Y.jsx)(pt,{icon:je,title:`Facts (${t.facts.length})`,level:3}),t.facts.map(e=>(0,Y.jsxs)(`span`,{className:`flex items-start justify-between gap-2`,children:[(0,Y.jsxs)(`span`,{className:`[overflow-wrap:anywhere]`,children:[e.text,e.about.length?(0,Y.jsxs)(`span`,{className:`text-muted`,children:[` → `,e.about.join(`, `)]}):null]}),n(e.evidence)]},e.id))]})]})}function Xi(){let{home:e,error:t}=Oi(),[n,r]=(0,J.useState)(null);return(0,J.useEffect)(()=>{e&&Promise.all(e.tests.slice(0,8).map(e=>L.test(e.id).catch(()=>null))).then(e=>r(e.filter(e=>!!(e&&e.cast.length))))},[e]),t?(0,Y.jsx)(un,{text:t}):n?n.length?(0,Y.jsx)(`div`,{className:`flex flex-col gap-6`,children:n.map(e=>(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`a`,{href:$(`tests`,e.id),className:`text-[13px] font-medium`,children:e.scenario?.decision||e.request.request}),(0,Y.jsx)(Ji,{t:e})]},e.id))}):(0,Y.jsx)(et,{icon:k,title:`No cast yet`,children:`A test is cast after its strategy is planned.`}):(0,Y.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`})}function Zi(){let{home:e,error:t}=Oi(),[n,r]=(0,J.useState)(null);return(0,J.useEffect)(()=>{e&&Promise.all(e.tests.slice(0,12).map(e=>L.test(e.id).catch(()=>null))).then(e=>r(e.filter(e=>!!e).flatMap(e=>e.verdicts.map(t=>({t:e,v:t}))).sort((e,t)=>Ei.indexOf(e.v.outcome)-Ei.indexOf(t.v.outcome))))},[e]),t?(0,Y.jsx)(un,{text:t}):n?n.length?(0,Y.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:n.map(({t:e,v:t})=>(0,Y.jsx)(Wi,{v:{...t,title:`${t.title} — ${e.scenario?.decision.slice(0,80)||e.id}`}},`${e.id}#${t.scenario}`))}):(0,Y.jsx)(et,{icon:k,title:`No verdict yet`,children:`A verdict appears when a test's strategy has been played.`}):(0,Y.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`})}function Qi({to:e}){return(0,J.useEffect)(()=>location.replace(`#${e.replace(/^#/,``)}`),[e]),null}function $i({id:e}){if(!e)return(0,Y.jsx)(qt,{});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,Y.jsx)(pr,{template:i[0]},i[0]);if(t===`custom`&&!i.length){if(n===`new`&&r===void 0)return(0,Y.jsx)(hn,{});if(n===`new`&&r===`form`)return(0,Y.jsx)(pr,{});if(n===`build`&&r&&/^[a-f0-9]{16}$/.test(r))return(0,Y.jsx)(_n,{sid:r},r);if(n&&Re.test(n)&&r===void 0)return(0,Y.jsx)(mr,{id:n},n);if(n&&Re.test(n)&&r===`edit`)return(0,Y.jsx)(pr,{id:n},n)}let[a,o,...s]=(e||``).split(`/`);if(a===`business`)return(0,Y.jsx)(Qi,{to:M(`agents`,`basal`)});if(a&&Object.hasOwn(ze,a))return(0,Y.jsx)(Qi,{to:M(`agents`,ze[a])});let c=Le(a),l=o===`tools`||o===`conversations`;if(c?.id===`persona`&&o===void 0)return(0,Y.jsx)(Gt,{agent:c,tabs:(0,Y.jsx)(Wr,{current:`agent`})},c.id);if(c?.id===`persona`&&!l)return(0,Y.jsx)(Jr,{page:c,tab:o,sub:s.join(`/`)},`${c.id}/${o}`);if(c?.opens&&!l)return(0,Y.jsx)(ea,{to:M(...c.opens,...[o,...s].filter(e=>!!e))});if(c?.id===`basal`&&!l)return(0,Y.jsx)(Di,{page:c,tab:o,sub:s.join(`/`)},c.id);let u=a===`category`&&!s.length?Ie(o):void 0;return u?(0,Y.jsx)(qt,{only:u.id},u.id):c&&o===`tools`&&!s.length?(0,Y.jsx)(It,{page:c},c.id):c&&o===`conversations`&&!s.length?(0,Y.jsx)(Yt,{page:c},c.id):!c||o!==void 0?(0,Y.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,Y.jsx)(an,{}),(0,Y.jsxs)(`p`,{className:`m-0 px-6 py-10 text-sm text-muted`,children:[`There is no such agent. `,(0,Y.jsx)(`a`,{href:M(`agents`),children:`See every agent`}),`, or `,(0,Y.jsx)(`a`,{href:M(),children:`start a chat`}),` instead.`]})]}):(0,Y.jsx)(Gt,{agent:c,below:(0,Y.jsx)(en,{page:c})},c.id)}function ea({to:e}){return(0,J.useEffect)(()=>{location.replace(e)},[e]),null}export{$i as Agent};
8
+ `)])))},E=async()=>{let e=w.current;y(`draft`),x(``);try{let{persona:t}=await I.draft({request:i.trim(),...o?{kind:o}:{},...c.trim()?{domain:c.trim()}:{}});if(e!==w.current)return;let{builtIn:n,...r}=t;T(r),_(!0)}catch(t){e===w.current&&x(t.message)}finally{e===w.current&&y(``)}},D=async()=>{if(d){y(`save`),x(``);try{let e={...d,...Object.fromEntries(si.map(({key:e})=>[e,ci(m[e]||``)]))};r((await I.save(e)).saved)}catch(e){x(e.message),y(``)}}},te=d?ui(d,m,S,!1):null,O=!!te?.canSave;return(0,Y.jsx)(Ot,{wide:!0,open:e,onClose:t,title:`New persona`,description:(0,Y.jsxs)(Y.Fragment,{children:[`Saved in `,(0,Y.jsxs)(`span`,{className:`font-mono text-[13px]`,children:[`.forgeqe/business-personas/`,d?.id||`<id>`,`.yaml`]}),`, shared with the project.`]}),footer:(0,Y.jsxs)(Y.Fragment,{children:[b?(0,Y.jsx)(`span`,{role:`alert`,className:`mr-auto self-center text-sm text-fail [overflow-wrap:anywhere]`,children:b}):d&&!O&&(0,Y.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,Y.jsxs)(H,{onClick:t,children:[(0,Y.jsx)(p,{"aria-hidden":`true`}),`Cancel`]}),(0,Y.jsxs)(H,{variant:`primary`,disabled:!!v||!O,onClick:()=>void D(),children:[(0,Y.jsx)(C,{"aria-hidden":`true`}),v===`save`?`Saving…`:`Save`]})]}),children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-6 pt-4`,children:[(0,Y.jsxs)(G,{id:`persona-ask`,icon:j,title:`Who is the persona?`,level:3,children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Describe them`}),(0,Y.jsx)(`span`,{className:`text-[13px] text-muted`,children:`Their job, what they know and what they check. Mask drafts the rest.`}),(0,Y.jsx)(Xe,{rows:3,value:i,maxLength:2e3,onChange:e=>a(e.target.value),placeholder:`An SME in card payments who reconciles settlements every morning and signs off refunds`})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Kind`}),(0,Y.jsxs)(B,{value:o,onChange:e=>s(e.target.value),children:[(0,Y.jsx)(`option`,{value:``,children:`Let the agent choose`}),Ge.map(e=>(0,Y.jsx)(`option`,{value:e,children:Br[e]},e))]})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Domain`}),(0,Y.jsx)(V,{value:c,maxLength:80,onChange:e=>l(e.target.value),placeholder:`payments`})]})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsxs)(H,{disabled:!!v||!i.trim(),onClick:()=>void E(),"data-tip":g?`Ask Mask for another draft`:`Ask Mask for a draft`,children:[(0,Y.jsx)(u,{"aria-hidden":`true`}),g?`Draft again`:`Draft`]}),!d&&(0,Y.jsxs)(H,{disabled:!!v,onClick:()=>T(oi),"data-tip":`Write every field yourself`,children:[(0,Y.jsx)(ce,{"aria-hidden":`true`}),`Write`]}),v===`draft`&&(0,Y.jsx)(`span`,{role:`status`,className:`text-sm text-muted`,children:`Mask is drafting…`})]})]}),d&&te&&(0,Y.jsx)(G,{id:`persona-fields`,icon:de,title:`The persona`,level:3,children:(0,Y.jsx)(di,{fields:d,listText:m,onFields:f,onListText:h,check:te,idLocked:!1,resources:ee})})]})})}function ui(e,t,n,r){let i=r||e.id===``?``:Gr.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===``?``:Kr.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()&&(ci(t.validates||``).length>0||ci(t.goals||``).length>0)}}function di({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,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Name`}),(0,Y.jsx)(V,{value:e.name,maxLength:80,onChange:e=>s(`name`,e.target.value),placeholder:`Priya, payments SME`})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Id`}),(0,Y.jsx)(V,{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,Y.jsx)(`p`,{id:`persona-id-error`,role:`alert`,className:`m-0 text-[13px] text-fail`,children:c})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Command`}),(0,Y.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,Y.jsx)(V,{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,Y.jsx)(`p`,{id:`persona-handle-error`,role:`alert`,className:`m-0 text-[13px] text-fail`,children:l})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Kind`}),(0,Y.jsx)(B,{value:e.kind,onChange:e=>s(`kind`,e.target.value),children:Ge.map(e=>(0,Y.jsx)(`option`,{value:e,children:Br[e]},e))})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Expertise in the domain`}),(0,Y.jsx)(B,{value:e.expertise,onChange:e=>s(`expertise`,e.target.value),children:Ue.map(e=>(0,Y.jsx)(`option`,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Intent`}),(0,Y.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,Y.jsx)(B,{value:e.intent,onChange:e=>s(`intent`,e.target.value),children:We.map(e=>(0,Y.jsx)(`option`,{value:e,children:zr[e]},e))})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Risk appetite`}),(0,Y.jsx)(B,{value:e.risk_appetite,onChange:e=>s(`risk_appetite`,e.target.value),children:Ke.map(e=>(0,Y.jsx)(`option`,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Role`}),(0,Y.jsx)(V,{value:e.role,maxLength:120,onChange:e=>s(`role`,e.target.value),placeholder:`Payments operations lead`})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Domain`}),(0,Y.jsx)(V,{value:e.domain,maxLength:80,onChange:e=>s(`domain`,e.target.value)})]})]}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Who they are`}),(0,Y.jsx)(Xe,{rows:3,value:e.description,maxLength:1200,onChange:e=>s(`description`,e.target.value)})]}),si.map(({key:e,label:n,hint:i})=>(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:n}),(0,Y.jsx)(`span`,{className:`text-[13px] text-muted`,children:i}),(0,Y.jsx)(Xe,{rows:e===`validates`?5:3,value:t[e]||``,onChange:n=>r({...t,[e]:n.target.value})})]},e)),(0,Y.jsx)(pi,{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,Y.jsx)(pi,{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 fi=12;function pi({id:e,label:t,hint:n,items:r,error:i,value:a,onChange:o}){let[s,c]=(0,J.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>=fi;return(0,Y.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 border-0 p-0 text-sm`,children:[(0,Y.jsxs)(`legend`,{className:`mb-2 p-0 font-medium`,children:[t,` `,(0,Y.jsxs)(`span`,{className:`font-normal text-muted tabular-nums`,children:[`· `,a.length,` picked`]})]}),(0,Y.jsx)(`span`,{className:`text-[13px] text-muted`,children:n}),i?(0,Y.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,Y.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`There are none in this project yet.`}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,Y.jsx)(rt,{id:`${e}-find`,label:`Find in ${t.toLowerCase()}`,value:s,onChange:c})}),(0,Y.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,Y.jsx)(`li`,{className:`py-4 text-sm text-muted`,children:`Nothing matches.`}),d.map(e=>{let t=a.includes(e.id);return(0,Y.jsx)(`li`,{className:`border-t border-line-soft first:border-t-0`,children:(0,Y.jsxs)(`label`,{className:F(`flex min-h-12 items-center gap-4 py-2`,!t&&f?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,Y.jsx)(Lt,{checked:t,disabled:!t&&f,onCheckedChange:t=>o(t?[...a,e.id]:a.filter(t=>t!==e.id))}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:F(`text-[13px] [overflow-wrap:anywhere]`,e.mono?`font-mono`:`font-medium`),children:e.title}),(0,Y.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,Y.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[`At most `,fi,`: take one off to pick another.`]})]}):(0,Y.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`})]})}var mi=[`agent`,`tests`,`personas`,`findings`],hi={agent:`Agent`,tests:`Tests`,personas:`Personas`,findings:`Findings`},gi={agent:`BASAL`,tests:`Business tests`,personas:`Personas`,findings:`Findings`},_i={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.`},vi={tests:D,personas:j,findings:je},$=(e,t)=>e===`agent`?M(`agents`,`basal`):t?M(`agents`,`basal`,e,t):M(`agents`,`basal`,e),yi=[`ask`,`understand`,`strategy`,`cast`,`rehearse`,`approve`,`act`,`judge`],bi={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.`}},xi={asked:1,understood:2,planned:3,cast:4,rehearsed:5,approved:6,acted:8},Si={understand:1,strategy:2,cast:3,rehearse:4,act:6},Ci=e=>String(e).padStart(2,`0`),wi=[{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`}],Ti={confirmed_failure:`fail`,policy_ambiguity:`warn`,potential_risk:`warn`,missing_evidence:`neutral`,expected_behaviour:`pass`},Ei=[`confirmed_failure`,`policy_ambiguity`,`potential_risk`,`missing_evidence`,`expected_behaviour`];function Di({page:e,tab:t,sub:n}){let r=mi.includes(t)?t:`agent`,[i,a]=r===`tests`&&n?n.split(`/`):[],o=i?ge(i):``,s=(e,t)=>(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(zt,{icon:vi[e],title:gi[e],description:_i[e]}),t]});return(0,Y.jsx)(Ht,{page:e,title:at(`basal`),label:`BASAL`,current:r,onPick:e=>location.hash=$(e),tabs:mi.filter(e=>e!==Zt).map(e=>({id:e,label:hi[e],icon:vi[e]})),agentBody:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`m-0 text-[13px] leading-relaxed text-ink-2`,children:_i.agent}),(0,Y.jsx)(Mi,{}),(0,Y.jsx)(gt,{scope:{kind:`page`,page:e}})]}),children:o?(0,Y.jsx)(Pi,{id:o,step:yi.includes(a)?a:void 0},o):r===`tests`?s(`tests`,(0,Y.jsx)(Ni,{})):r===`personas`?s(`personas`,(0,Y.jsx)(Xi,{})):r===`findings`?s(`findings`,(0,Y.jsx)(Zi,{})):null})}function Oi(){let[e,t]=(0,J.useState)(null),[n,r]=(0,J.useState)(``),i=(0,J.useCallback)(()=>L.home().then(t,e=>r(e.message)),[]);return(0,J.useEffect)(()=>void i(),[i]),{home:e,error:n,load:i}}function ki({g:e}){return(0,Y.jsx)(`p`,{className:`m-0 text-[13px] text-muted tabular-nums`,children:e.connected?(0,Y.jsxs)(Y.Fragment,{children:[`Graph store: running · `,z(e.product||0,`product node`),` · `,z(e.scenario||0,`scenario node`),e.embedding?` · found by meaning with ${e.embedding}`:` · by words only (no embedding model)`]}):(0,Y.jsxs)(Y.Fragment,{children:[`Graph store: the product graph's file`,e.reason?` (${e.reason})`:``,`. forgeqe graph setup starts it.`]})})}function Ai({home:e}){let[t,n]=(0,J.useState)(``),[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(``),c=async()=>{a(!0),s(``);try{let{id:e}=await L.ask(t.trim());await L.stage(e,`understand`),location.hash=$(`tests`,`${e}/understand`)}catch(e){s(e.message)}finally{a(!1)}};return(0,Y.jsxs)(G,{id:`basal-new`,icon:r,title:`New business test`,divider:!1,className:`rounded-[14px] card border p-4`,children:[(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Your business question`}),(0,Y.jsx)(Xe,{id:`basal-request`,rows:3,value:t,onChange:e=>n(e.target.value),placeholder:`Should we launch saved cards with a fee? Test how merchants, shoppers and support would really be affected.`})]}),(0,Y.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,Y.jsx)(un,{text:o}),(0,Y.jsx)(`div`,{children:(0,Y.jsxs)(H,{variant:`primary`,disabled:i||t.trim().length<10||!e.model,onClick:()=>void c(),"data-tip":e.model?`Keeps the question and starts step 02, Understand`:`Set up a model in Settings › Models first`,children:[(0,Y.jsx)(v,{"aria-hidden":`true`}),i?`Starting…`:`Start`]})})]})}function ji({tests:e,search:t=!0,tools:n}){return(0,Y.jsx)(Ct,{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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`th`,{scope:`col`,className:F(Wt,`w-[55%]`),children:`Business question`}),(0,Y.jsx)(`th`,{scope:`col`,className:F(Wt,`hidden @xl:table-cell`),children:`Asked`}),(0,Y.jsx)(`th`,{scope:`col`,className:F(bt,`hidden @2xl:table-cell`),children:`Steps done`}),(0,Y.jsx)(`th`,{scope:`col`,className:Wt,children:`Stage`})]}),children:e.map(e=>{let t=xi[e.stage];return(0,Y.jsxs)(`tr`,{onClick:()=>location.hash=$(`tests`,e.id),className:Tt,children:[(0,Y.jsxs)(`td`,{className:F(Kt,`max-w-0`),children:[(0,Y.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,Y.jsx)(`span`,{className:`block truncate font-mono text-muted`,children:e.id})]}),(0,Y.jsx)(`td`,{className:F(Kt,`hidden whitespace-nowrap text-muted @xl:table-cell`),children:e.created.slice(0,10)}),(0,Y.jsx)(`td`,{className:F(pt,`hidden text-muted @2xl:table-cell`),children:t===void 0?`–`:`${t} of ${yi.length}`}),(0,Y.jsx)(`td`,{className:F(Kt,`whitespace-nowrap`),children:e.running?(0,Y.jsx)(U,{tone:`running`,children:e.running}):(0,Y.jsx)(U,{tone:`neutral`,children:e.stage})})]},e.id)})})}function Mi(){let{home:e,error:t}=Oi();return t?(0,Y.jsx)(un,{text:t}):e?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Y.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:yi.map((e,t)=>(0,Y.jsxs)(`li`,{className:`flex flex-col gap-1 rounded-[12px] bg-surface-muted p-4`,children:[(0,Y.jsxs)(`span`,{className:`font-mono text-[13px] text-muted`,children:[`STEP `,Ci(t+1)]}),(0,Y.jsx)(`span`,{className:`text-[13px] font-semibold`,children:bi[e].name})]},e))}),(0,Y.jsx)(ki,{g:e.graph}),(0,Y.jsx)(Ai,{home:e}),e.tests.length>0&&(0,Y.jsx)(G,{id:`basal-recent`,icon:te,title:`Recent tests`,actions:(0,Y.jsx)(`a`,{href:$(`tests`),className:`text-[13px] font-normal`,children:`Every test`}),children:(0,Y.jsx)(ji,{tests:e.tests.slice(0,5),search:!1})})]}):(0,Y.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`})}function Ni(){let{home:e,error:t,load:n}=Oi();return t?(0,Y.jsx)(un,{text:t}):e?(0,Y.jsx)(ji,{tests:e.tests,tools:(0,Y.jsxs)(H,{size:`sm`,variant:`ghost`,onClick:()=>void n(),className:`ml-auto`,"data-tip":`Read the tests again`,children:[(0,Y.jsx)(f,{"aria-hidden":`true`}),`Refresh`]})}):(0,Y.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`})}function Pi({id:e,step:t}){let[n,r]=(0,J.useState)(null),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(``),c=(0,J.useCallback)(()=>L.test(e).then(r,e=>s(e.message)),[e]),l=(0,J.useCallback)(()=>L.graph(e).then(a,e=>s(`The graph could not be read: ${e.message}`)),[e]);(0,J.useEffect)(()=>{c(),l()},[c,l]);let u=!(!n?.job||n.job.endedAt);if((0,J.useEffect)(()=>{if(!u)return;let e=Dt(()=>{c(),l()},2500);return()=>{_t(e),l()}},[u,c,l]),!n)return o?(0,Y.jsx)(un,{text:o}):(0,Y.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`});let d=xi[n.stage],f=n.job&&!n.job.endedAt?Si[n.job.stage]:-1,p=t||yi[f>=0?f:Math.min(d,yi.length-1)],m=yi.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,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(it,{href:$(`tests`),label:`Every test`}),(0,Y.jsx)(`div`,{"data-tip":n.scenario?.decision||n.request.request,children:(0,Y.jsx)(zt,{icon:D,title:n.scenario?.decision||n.request.request,description:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.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,Y.jsx)(`nav`,{"aria-label":`BASAL's steps`,className:`overflow-x-auto`,children:(0,Y.jsx)(`ol`,{className:`m-0 grid min-w-[800px] list-none grid-cols-8 gap-1 rounded-[12px] bg-surface-muted p-1`,children:yi.map((e,t)=>{let r=g(t),i=t<=d||t===f,a=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,Y.jsx)(`span`,{className:`font-mono text-[13px] text-muted`,children:Ci(t+1)}),(0,Y.jsx)(`span`,{className:`text-[13px] font-medium`,children:bi[e].name})]}),(0,Y.jsx)(U,{tone:r.tone,icon:r.tone===`running`,className:`self-start`,children:r.word})]});return(0,Y.jsx)(`li`,{className:`min-w-0`,children:i?(0,Y.jsx)(`a`,{href:$(`tests`,`${n.id}/${e}`),"aria-current":e===p?`step`:void 0,className:F(`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,Y.jsx)(`span`,{className:`flex h-full flex-col gap-1 rounded-[8px] px-2 py-2 opacity-60`,children:a})},e)})})}),o&&(0,Y.jsx)(un,{text:o}),(0,Y.jsxs)(`div`,{className:`grid items-start gap-4 @[960px]:grid-cols-[minmax(0,1fr)_minmax(0,1.15fr)]`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 @[960px]:sticky @[960px]:top-4`,children:[(0,Y.jsx)(`p`,{className:`m-0 text-[13px] text-muted tabular-nums`,children:i?.connected?`${z(i.nodes.length,`node`)} · ${z(i.edges.length,`edge`)} · scenario over the product graph`:`Graph store not connected`}),(0,Y.jsx)(Vi,{graph:i,onRefresh:()=>void L.regraph(e).then(l,e=>s(e.message))})]}),(0,Y.jsxs)(`section`,{"aria-labelledby":`basal-step`,className:`flex min-w-0 flex-col gap-4 rounded-[14px] card border p-4`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsxs)(`span`,{className:`rounded-[8px] bg-accent-soft px-2 py-1 font-mono text-[13px] font-medium text-accent-fg`,children:[`STEP `,Ci(m+1)]}),(0,Y.jsx)(`h3`,{id:`basal-step`,className:`m-0 text-[16px] font-semibold`,children:bi[p].name}),(0,Y.jsx)(`span`,{className:`ml-auto`,children:(0,Y.jsx)(U,{tone:_.tone,children:_.word})})]}),(0,Y.jsx)(`p`,{className:`m-0 text-[13px] text-ink-2`,children:bi[p].about}),n.job&&Si[n.job.stage]===m&&(0,Y.jsx)(Bi,{t:n}),(0,Y.jsx)(Fi,{step:p,t:n,onRun:h})]})]})]})}function Fi({step:e,t,onRun:n}){let r=!(!t.job||t.job.endedAt),i=(e,t,i,a)=>(0,Y.jsx)(`div`,{className:`border-t border-line pt-4`,children:(0,Y.jsxs)(H,{variant:`primary`,disabled:r,onClick:()=>void n(i,a),"data-tip":t,children:[(0,Y.jsx)(N,{"aria-hidden":`true`}),e]})}),a=(e,n)=>(0,Y.jsx)(`div`,{className:`border-t border-line pt-4`,children:(0,Y.jsxs)(`a`,{href:$(`tests`,`${t.id}/${n}`),className:Qe({variant:`primary`}),children:[(0,Y.jsx)(N,{"aria-hidden":`true`}),e]})});return e===`ask`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.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,Y.jsx)(cn,{label:`Files`,children:t.request.files.length?t.request.files.join(`, `):`none`}),(0,Y.jsx)(cn,{label:`Work items`,children:t.request.stories.length?t.request.stories.join(`, `):`none`}),(0,Y.jsx)(cn,{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`,()=>L.stage(t.id,`understand`),`understand`):a(`Next: Understand`,`understand`)]}):e===`understand`?t.scenario?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Yi,{t}),t.stage===`understood`?i(`Plan the test strategy`,`Scenarios, the agent for each step, and the business expectations`,()=>L.stage(t.id,`strategy`),`strategy`):a(`Next: Strategy`,`strategy`)]}):(0,Y.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`BASAL is reading the sources.`}):e===`strategy`?t.strategy?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(qi,{t}),t.stage===`planned`?i(`Cast the personas`,`One persona for each stakeholder who acts in the strategy`,()=>L.stage(t.id,`cast`),`cast`):a(`Next: Cast`,`cast`)]}):(0,Y.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`Not planned yet.`}):e===`cast`?t.cast.length?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Ji,{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`,()=>L.stage(t.id,`rehearse`),`rehearse`):a(`Next: Rehearse`,`rehearse`)]}):(0,Y.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`Not cast yet.`}):e===`rehearse`?(0,Y.jsx)(Li,{t,onRun:n}):e===`approve`?(0,Y.jsx)(Ri,{t,onRun:n}):e===`act`?(0,Y.jsx)(zi,{t,onRun:n}):t.verdicts.length?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Ui,{t,onObserve:(e,r,i)=>void n(()=>L.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`,()=>L.stage(t.id,`rehearse`),`rehearse`)]}):(0,Y.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`No verdict yet: the strategy has not been played.`})}var Ii={support:`pass`,oppose:`fail`,undecided:`neutral`};function Li({t:e,onRun:t}){let n=!(!e.job||e.job.endedAt),r=new Map(e.cast.map(e=>[e.id,e.name])),i=e.rounds.at(-1),a=e.rounds.flatMap(e=>e.posts),o=new Map(a.map(e=>[e.id,e]));if(!i)return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`No round yet.`}),(0,Y.jsx)(`div`,{className:`border-t border-line pt-4`,children:(0,Y.jsxs)(H,{variant:`primary`,disabled:n||!e.cast.length,onClick:()=>void t(()=>L.stage(e.id,`rehearse`)),children:[(0,Y.jsx)(v,{"aria-hidden":`true`}),`Play round 1`]})})]});let s={support:0,oppose:0,undecided:0};for(let e of i.turns)s[e.stance]=(s[e.stance]||0)+1;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`m-0 text-[13px] text-muted tabular-nums`,children:[`Round `,i.n,` · `,z(a.length,`post`),` on the feed · `,s.support,` support · `,s.oppose,` oppose · `,s.undecided,` undecided`,i.events.length?` · reacted to ${z(i.events.length,`outcome`)} on the product`:``]}),(0,Y.jsx)(G,{icon:Ae,title:`Feed`,level:3,children:(0,Y.jsx)(`ol`,{className:`m-0 flex max-h-[420px] list-none flex-col gap-2 overflow-y-auto p-0`,children:a.toReversed().map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-col gap-1 rounded-[8px] border border-line bg-bg p-2 text-[13px]`,children:[(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:r.get(e.author)||e.author}),(0,Y.jsxs)(`span`,{className:`text-muted`,children:[e.kind,e.target?` on ${r.get(o.get(e.target)?.author||``)||e.target}`:``,` · round `,e.round]})]}),(0,Y.jsx)(`span`,{className:`text-ink-2 [overflow-wrap:anywhere]`,children:e.text})]},e.id))})}),(0,Y.jsx)(G,{icon:j,title:(0,Y.jsxs)(Y.Fragment,{children:[`Where the cast stand after round `,i.n]}),level:3,children:(0,Y.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0 text-[13px]`,children:i.turns.map(e=>(0,Y.jsxs)(`li`,{className:`flex items-start justify-between gap-2`,children:[(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:r.get(e.id)||e.id}),` `,(0,Y.jsxs)(`span`,{className:`text-ink-2`,children:[`— `,e.feeling]})]}),(0,Y.jsx)(U,{tone:Ii[e.stance]||`neutral`,icon:!1,children:e.stance})]},e.id))})}),e.wanted.length>0&&(0,Y.jsx)(G,{icon:ue,title:`What the cast want tried`,level:3,className:`text-[13px]`,children:e.wanted.map(e=>(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{className:`font-mono`,children:e.scenario}),` `,(0,Y.jsxs)(`span`,{className:`text-muted`,children:[`· `,e.by.map(e=>r.get(e)||e).join(`, `)]})]},e.scenario))}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2 border-t border-line pt-4`,children:[(0,Y.jsxs)(`a`,{href:$(`tests`,`${e.id}/${e.strategy?.approved?`act`:`approve`}`),className:Qe({variant:`primary`}),children:[(0,Y.jsx)(N,{"aria-hidden":`true`}),e.strategy?.approved?`Next: Act`:`Next: Approve`]}),(0,Y.jsxs)(H,{variant:`outline`,disabled:n,onClick:()=>void t(()=>L.stage(e.id,`rehearse`)),children:[(0,Y.jsx)(v,{"aria-hidden":`true`}),`Play round `,i.n+1]})]})]})}function Ri({t:e,onRun:t}){let[n,r]=(0,J.useState)(``);if(e.strategy?.approved)return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.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,Y.jsx)(`div`,{className:`border-t border-line pt-4`,children:(0,Y.jsxs)(`a`,{href:$(`tests`,`${e.id}/act`),className:Qe({variant:`primary`}),children:[(0,Y.jsx)(N,{"aria-hidden":`true`}),`Next: Act`]})})]});let i=e.strategy;return(0,Y.jsxs)(Y.Fragment,{children:[i?(0,Y.jsxs)(`ul`,{className:`m-0 flex flex-col gap-1 pl-6 text-[13px] text-ink-2`,children:[(0,Y.jsxs)(`li`,{children:[z(i.scenarios.length,`scenario`),` on `,i.environment||`no test environment`,`, `,z(i.scenarios.reduce((e,t)=>e+t.steps.length,0),`step`)]}),(0,Y.jsx)(`li`,{children:e.writes.length?`${z(e.writes.length,`step`)} change data: Act lists them for your agreement before anything runs`:`No step changes data`}),(0,Y.jsxs)(`li`,{children:[`Plays on:`,` `,[...new Set(i.scenarios.flatMap(e=>e.steps.map(e=>e.app?`${e.app} (${Ki[e.channel]})`:Ki[e.channel])))].join(`, `)]}),i.needs.length>0&&(0,Y.jsxs)(`li`,{className:`text-warn`,children:[z(i.needs.length,`thing`),` still needed: see Strategy`]})]}):null,(0,Y.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Type the test's id to approve`}),(0,Y.jsx)(V,{id:`basal-typed`,value:n,onChange:e=>r(e.target.value),placeholder:`Type the test's id`})]}),(0,Y.jsx)(`span`,{className:`font-mono text-[13px] text-muted`,children:e.id}),(0,Y.jsx)(`div`,{className:`border-t border-line pt-4`,children:(0,Y.jsxs)(H,{variant:`primary`,disabled:n.trim()!==e.id||!i,onClick:()=>void t(()=>L.approve(e.id,n.trim()),`act`),children:[(0,Y.jsx)(C,{"aria-hidden":`true`}),`Approve`]})})]})}function zi({t:e,onRun:t}){let[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(!0),o=!(!e.job||e.job.endedAt);if(!e.strategy?.approved)return(0,Y.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`Approve the strategy first.`});let s=i&&e.wanted.length?e.wanted.map(e=>e.scenario):[];return(0,Y.jsxs)(Y.Fragment,{children:[e.handovers.length>0&&(0,Y.jsx)(Hi,{handovers:e.handovers}),!o&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-line pt-4`,children:[e.wanted.length>0&&(0,Y.jsxs)(`label`,{className:`flex min-h-9 cursor-pointer items-center gap-2 text-[13px]`,children:[(0,Y.jsx)(Lt,{id:`basal-wanted`,checked:i,onCheckedChange:a}),`Only what the cast wants tried after round `,e.rounds.length,`: `,e.wanted.map(e=>e.scenario).join(`, `)]}),e.writes.length>0?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`m-0 text-[13px] text-ink-2`,children:[`These steps change data on `,e.strategy.environment,`. Without your agreement they are skipped and the agents change nothing.`]}),(0,Y.jsx)(`ul`,{className:`m-0 flex flex-col gap-1 pl-4 text-[13px] text-warn`,children:e.writes.map(e=>(0,Y.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:e},e))}),(0,Y.jsxs)(`label`,{className:`flex min-h-9 cursor-pointer items-center gap-2 text-[13px]`,children:[(0,Y.jsx)(Lt,{id:`basal-writes`,checked:n,onCheckedChange:r}),`Let these steps change data`]})]}):(0,Y.jsx)(`p`,{className:`m-0 text-[13px] text-ink-2`,children:`No step changes data.`}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Y.jsxs)(H,{variant:`primary`,onClick:()=>void t(()=>L.act(e.id,n?e.writes:[],s)),"data-tip":`Hands each step to ForgeQE's agents as its persona`,children:[(0,Y.jsx)(v,{"aria-hidden":`true`}),e.verdicts.length?`Play it again`:`Act`]}),e.verdicts.length>0&&(0,Y.jsxs)(`a`,{href:$(`tests`,`${e.id}/judge`),className:Qe({variant:`outline`}),children:[(0,Y.jsx)(N,{"aria-hidden":`true`}),`Next: Judge`]})]})]})]})}function Bi({t:e}){let t=e.job;return(0,Y.jsxs)(G,{id:`basal-feed`,icon:A,title:(0,Y.jsxs)(Y.Fragment,{children:[`Live · `,t.stage]}),level:3,className:`rounded-[14px] card border p-4`,actions:t.endedAt?(0,Y.jsx)(U,{tone:t.error?`fail`:`pass`,children:t.error?`stopped`:`finished`}):(0,Y.jsx)(U,{tone:`running`,children:`working`}),children:[(0,Y.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,Y.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:e},t))}),t.error&&(0,Y.jsx)(un,{text:t.error})]})}function Vi({graph:e,onRefresh:t}){let[n,r]=(0,J.useState)(null),{nodes:i,edges:a,types:o}=(0,J.useMemo)(()=>{let t=(e?.nodes||[]).map(e=>({id:e.id,name:e.type===`fact`?``:e.name.length>34?`${e.name.slice(0,32).trimEnd()}…`:e.name,type:e.layer===`product`?`product ${e.type}`:e.type}));return{nodes:t,edges:(e?.edges||[]).map((e,t)=>({id:`e${t}`,from:e.from,to:e.to,label:e.type})),types:[...new Set(t.map(e=>e.type))]}},[e]),s=e=>on[Math.max(0,o.indexOf(e))%on.length],c=null;if(n?.kind===`node`){let t=e?.nodes.find(e=>e.id===n.id);t&&(c={title:t.name,pill:{text:t.layer===`product`?`product ${t.type}`:t.type,colour:s(t.layer===`product`?`product ${t.type}`:t.type)},body:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`m-0 text-ink [overflow-wrap:anywhere]`,children:t.summary}),(0,Y.jsx)(cn,{label:`Layer`,children:t.layer}),t.state&&(0,Y.jsx)(cn,{label:`Evidence`,children:t.state})]})})}return e?.connected?i.length?(0,Y.jsx)(sn,{title:`Live knowledge graph`,nodes:i,edges:a,colourOfType:s,types:o,typesTitle:`Node types`,picked:n,onPick:r,detail:c,onRefresh:t}):(0,Y.jsx)(et,{icon:k,title:`No scenario in the graph yet`,children:`It appears once BASAL has understood the question.`}):(0,Y.jsx)(et,{icon:k,title:`The graph store is not connected`,children:e?.reason||`Start the graph store with forgeqe graph setup to see the scenario grow over the product graph.`})}function Hi({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,Y.jsx)(G,{id:`basal-board`,icon:oe,title:`Operations board`,level:3,description:`Each card is a handover from BASAL to one of ForgeQE's agents, as one persona.`,children:(0,Y.jsx)(`div`,{className:`grid gap-2 @[1200px]:grid-cols-2`,children:wi.filter(e=>n.some(t=>t.channel===e.channel)).map(e=>{let t=n.filter(t=>t.channel===e.channel);return(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 rounded-[12px] bg-surface-muted p-2`,children:[(0,Y.jsxs)(`h4`,{className:`m-0 px-2 pt-1 text-[13px] font-semibold`,children:[e.title,` `,(0,Y.jsxs)(`span`,{className:`font-normal text-muted`,children:[`· `,t.length]})]}),t.map(e=>(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-[8px] border border-line bg-bg p-2 text-[13px]`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:`truncate font-medium`,children:e.actor}),(0,Y.jsx)(U,{tone:r(e),children:i(e)})]}),(0,Y.jsxs)(`span`,{className:`text-muted`,children:[(0,Y.jsx)(`span`,{className:`font-mono`,children:e.scenario}),` · step `,e.step]}),e.note&&(0,Y.jsx)(`span`,{className:`text-ink-2 [overflow-wrap:anywhere]`,children:e.note}),e.run&&(0,Y.jsx)(`span`,{className:`font-mono text-muted`,children:e.run})]},`${e.scenario}#${e.step}`))]},e.channel)})})})}function Ui({t:e,onObserve:t}){let n=e.verdicts.toSorted((e,t)=>Ei.indexOf(e.outcome)-Ei.indexOf(t.outcome));return(0,Y.jsx)(`section`,{"aria-label":`Verdicts`,className:`flex flex-col gap-2`,children:(0,Y.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:n.map(e=>(0,Y.jsx)(Wi,{v:e,onObserve:(n,r)=>t(e.scenario,n,r)},e.scenario))})})}function Wi({v:e,onObserve:t}){return(0,Y.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-[12px] card border p-4`,children:[(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(U,{tone:Ti[e.outcome],children:e.label}),(0,Y.jsx)(`span`,{className:`text-[13px] font-medium`,children:e.title}),(0,Y.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[`· confidence `,e.confidence]})]}),(0,Y.jsx)(`p`,{className:`m-0 text-[13px] text-ink-2 [overflow-wrap:anywhere]`,children:e.why}),e.results.length>0&&(0,Y.jsx)(`ul`,{className:`m-0 flex flex-col gap-1 pl-4 text-[13px]`,children:e.results.map(e=>(0,Y.jsxs)(`li`,{className:F(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,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-[13px] text-warn`,children:[`Step `,e,` waits for a person:`,(0,Y.jsx)(H,{size:`sm`,variant:`outline`,onClick:()=>t(e,!0),children:`The app let them do it`}),(0,Y.jsx)(H,{size:`sm`,variant:`outline`,onClick:()=>t(e,!1),children:`The app refused it`})]},e))]})}var Gi=e=>e.map(e=>e.trim().replace(/(?<![.;])[.;]+$/,``)).join(`; `),Ki={browser:`browser`,api:`API`,mobile:`mobile`,desktop:`desktop`,person:`a person`,opinion:`opinion`};function qi({t:e}){let t=e.strategy;return(0,Y.jsxs)(`section`,{"aria-label":`Strategy`,className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`p`,{className:`m-0 text-[13px] text-muted`,children:[z(t.scenarios.length,`scenario`),` on `,t.environment||`no test environment`,` · `,z(t.rounds,`round`)]}),t.needs.length>0&&(0,Y.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,Y.jsx)(`li`,{children:e},e))}),(0,Y.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:t.scenarios.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-[12px] card border p-4`,children:[(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsxs)(U,{tone:e.priority===1?`warn`:`neutral`,icon:!1,children:[`P`,e.priority,` · `,e.risk]}),(0,Y.jsx)(`span`,{className:`text-[13px] font-medium`,children:e.title})]}),(0,Y.jsx)(`p`,{className:`m-0 text-[13px] text-ink-2`,children:e.question}),(0,Y.jsx)(`ol`,{className:`m-0 flex flex-col gap-1 pl-6 text-[13px]`,children:e.steps.map(e=>(0,Y.jsxs)(`li`,{className:`[overflow-wrap:anywhere]`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:e.actor}),` `,(0,Y.jsxs)(`span`,{className:`text-muted`,children:[`· `,Ki[e.channel],e.app?` ${e.app}`:``,e.changes_data?` · changes data`:``]}),` — `,e.does]},e.n))}),e.oracles.length>0&&(0,Y.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,Y.jsxs)(`li`,{children:[e.says,` `,(0,Y.jsxs)(`span`,{className:`text-muted`,children:[`(`,e.basis,`)`]})]},e.id))})]},e.id))})]})}function Ji({t:e}){return(0,Y.jsx)(`section`,{"aria-label":`Cast`,className:`flex flex-col gap-2`,children:(0,Y.jsx)(`ul`,{className:`m-0 grid list-none gap-2 p-0 @[1100px]:grid-cols-2`,children:e.cast.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-col gap-1 rounded-[12px] card border p-4 text-[13px]`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,Y.jsx)(U,{tone:e.intent===`legitimate`?`neutral`:`warn`,icon:!1,children:e.intent})]}),(0,Y.jsx)(`span`,{className:`text-muted`,children:e.role}),e.validates.length>0&&(0,Y.jsxs)(`span`,{className:`text-ink-2`,children:[`Checks: `,Gi(e.validates)]}),e.frustrations.length>0&&(0,Y.jsxs)(`span`,{className:`text-ink-2`,children:[`Objects to: `,Gi(e.frustrations)]}),e.mistakes.length>0&&(0,Y.jsxs)(`span`,{className:`text-ink-2`,children:[`Brings: `,Gi(e.mistakes)]})]},e.id))})})}function Yi({t:e}){let t=e.scenario,n=e=>(0,Y.jsx)(U,{tone:e===`observed`?`pass`:`neutral`,icon:!1,children:e});return(0,Y.jsxs)(`section`,{"aria-label":`What BASAL understood`,className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-[12px] card border p-4 text-[13px]`,children:[(0,Y.jsx)(zt,{icon:Se,title:`Success criteria`,level:3}),t.criteria.map(e=>(0,Y.jsxs)(`span`,{className:`flex items-start justify-between gap-2`,children:[(0,Y.jsxs)(`span`,{children:[e.text,e.measure?(0,Y.jsxs)(`span`,{className:`text-muted`,children:[` (`,e.measure,`)`]}):null]}),n(e.evidence)]},e.id))]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-[12px] card border p-4 text-[13px]`,children:[(0,Y.jsx)(zt,{icon:j,title:`Stakeholders`,level:3}),t.stakeholders.map(e=>(0,Y.jsxs)(`span`,{className:`flex items-start justify-between gap-2`,children:[(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:e.name}),` `,(0,Y.jsxs)(`span`,{className:`text-muted`,children:[`· `,e.kind]}),` — `,e.cares]}),n(e.evidence)]},e.id))]})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-[12px] card border p-4 text-[13px]`,children:[(0,Y.jsx)(zt,{icon:je,title:`Facts (${t.facts.length})`,level:3}),t.facts.map(e=>(0,Y.jsxs)(`span`,{className:`flex items-start justify-between gap-2`,children:[(0,Y.jsxs)(`span`,{className:`[overflow-wrap:anywhere]`,children:[e.text,e.about.length?(0,Y.jsxs)(`span`,{className:`text-muted`,children:[` → `,e.about.join(`, `)]}):null]}),n(e.evidence)]},e.id))]})]})}function Xi(){let{home:e,error:t}=Oi(),[n,r]=(0,J.useState)(null);return(0,J.useEffect)(()=>{e&&Promise.all(e.tests.slice(0,8).map(e=>L.test(e.id).catch(()=>null))).then(e=>r(e.filter(e=>!!(e&&e.cast.length))))},[e]),t?(0,Y.jsx)(un,{text:t}):n?n.length?(0,Y.jsx)(`div`,{className:`flex flex-col gap-6`,children:n.map(e=>(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`a`,{href:$(`tests`,e.id),className:`text-[13px] font-medium`,children:e.scenario?.decision||e.request.request}),(0,Y.jsx)(Ji,{t:e})]},e.id))}):(0,Y.jsx)(et,{icon:k,title:`No cast yet`,children:`A test is cast after its strategy is planned.`}):(0,Y.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`})}function Zi(){let{home:e,error:t}=Oi(),[n,r]=(0,J.useState)(null);return(0,J.useEffect)(()=>{e&&Promise.all(e.tests.slice(0,12).map(e=>L.test(e.id).catch(()=>null))).then(e=>r(e.filter(e=>!!e).flatMap(e=>e.verdicts.map(t=>({t:e,v:t}))).sort((e,t)=>Ei.indexOf(e.v.outcome)-Ei.indexOf(t.v.outcome))))},[e]),t?(0,Y.jsx)(un,{text:t}):n?n.length?(0,Y.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:n.map(({t:e,v:t})=>(0,Y.jsx)(Wi,{v:{...t,title:`${t.title} — ${e.scenario?.decision.slice(0,80)||e.id}`}},`${e.id}#${t.scenario}`))}):(0,Y.jsx)(et,{icon:k,title:`No verdict yet`,children:`A verdict appears when a test's strategy has been played.`}):(0,Y.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`})}function Qi({to:e}){return(0,J.useEffect)(()=>location.replace(`#${e.replace(/^#/,``)}`),[e]),null}function $i({id:e}){if(!e)return(0,Y.jsx)(qt,{});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,Y.jsx)(pr,{template:i[0]},i[0]);if(t===`custom`&&!i.length){if(n===`new`&&r===void 0)return(0,Y.jsx)(hn,{});if(n===`new`&&r===`form`)return(0,Y.jsx)(pr,{});if(n===`build`&&r&&/^[a-f0-9]{16}$/.test(r))return(0,Y.jsx)(_n,{sid:r},r);if(n&&Re.test(n)&&r===void 0)return(0,Y.jsx)(mr,{id:n},n);if(n&&Re.test(n)&&r===`edit`)return(0,Y.jsx)(pr,{id:n},n)}let[a,o,...s]=(e||``).split(`/`);if(a===`business`)return(0,Y.jsx)(Qi,{to:M(`agents`,`basal`)});if(a&&Object.hasOwn(ze,a))return(0,Y.jsx)(Qi,{to:M(`agents`,ze[a])});let c=Le(a),l=o===`tools`||o===`conversations`;if(c?.id===`persona`&&o===void 0)return(0,Y.jsx)(Gt,{agent:c,tabs:(0,Y.jsx)(Wr,{current:`agent`})},c.id);if(c?.id===`persona`&&!l)return(0,Y.jsx)(Jr,{page:c,tab:o,sub:s.join(`/`)},`${c.id}/${o}`);if(c?.opens&&!l)return(0,Y.jsx)(ea,{to:M(...c.opens,...[o,...s].filter(e=>!!e))});if(c?.id===`basal`&&!l)return(0,Y.jsx)(Di,{page:c,tab:o,sub:s.join(`/`)},c.id);let u=a===`category`&&!s.length?Ie(o):void 0;return u?(0,Y.jsx)(qt,{only:u.id},u.id):c&&o===`tools`&&!s.length?(0,Y.jsx)(Ft,{page:c},c.id):c&&o===`conversations`&&!s.length?(0,Y.jsx)(Yt,{page:c},c.id):!c||o!==void 0?(0,Y.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,Y.jsx)(nn,{}),(0,Y.jsxs)(`p`,{className:`m-0 px-6 py-10 text-sm text-muted`,children:[`There is no such agent. `,(0,Y.jsx)(`a`,{href:M(`agents`),children:`See every agent`}),`, or `,(0,Y.jsx)(`a`,{href:M(),children:`start a chat`}),` instead.`]})]}):(0,Y.jsx)(Gt,{agent:c,below:(0,Y.jsx)(Qt,{page:c})},c.id)}function ea({to:e}){return(0,J.useEffect)(()=>{location.replace(e)},[e]),null}export{$i as Agent};