@capagents/forgeqe 3.2.7 → 3.2.8

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 (96) hide show
  1. package/dist/forgeqe.js +2 -2
  2. package/dist/web/assets/{3d-force-graph-CUGt_TSW.js → 3d-force-graph-CbGbqGhp.js} +1 -1
  3. package/dist/web/assets/Agent-g57O0gf2.js +8 -0
  4. package/dist/web/assets/{AgentWork-BpfMY_xu.js → AgentWork-DEZxLOeM.js} +1 -1
  5. package/dist/web/assets/ApiTests-DhxqD5GK.js +15 -0
  6. package/dist/web/assets/Browse-DfvSk_5f.js +1 -0
  7. package/dist/web/assets/Chat-CuuX_MnF.js +3 -0
  8. package/dist/web/assets/{CommandPalette-CKJHtRjo.js → CommandPalette-DLXhO1e4.js} +1 -1
  9. package/dist/web/assets/{Compare-DtW2g-qb.js → Compare-DFRzCXyA.js} +1 -1
  10. package/dist/web/assets/{Cost-DW-kVEL8.js → Cost-CZ1xMPze.js} +1 -1
  11. package/dist/web/assets/Data-jxeBry5m.js +6 -0
  12. package/dist/web/assets/Desktop-4S45Nhc5.js +1 -0
  13. package/dist/web/assets/DesktopReview-CUyNT0Hl.js +2 -0
  14. package/dist/web/assets/{DeviceScreen-DzVNfMwl.js → DeviceScreen-DlJqIxZ-.js} +1 -1
  15. package/dist/web/assets/Evidence-BP-fY7HX.js +1 -0
  16. package/dist/web/assets/{Explore-ChpAuezG.js → Explore-DY5e98Jz.js} +2 -2
  17. package/dist/web/assets/Features-CKpQ7ilm.js +1 -0
  18. package/dist/web/assets/{Flags-Do-pvmCF.js → Flags-CLm40jFw.js} +2 -2
  19. package/dist/web/assets/Flaky-CQx5RPZt.js +1 -0
  20. package/dist/web/assets/Impact-DsvECtFV.js +3 -0
  21. package/dist/web/assets/Jobs-Dzgeugby.js +5 -0
  22. package/dist/web/assets/KindPage-Dy8mhe14.js +6 -0
  23. package/dist/web/assets/{LiveDevice-OyxEiqBt.js → LiveDevice-DGXIulGh.js} +1 -1
  24. package/dist/web/assets/Migration-ecdFw6JR.js +8 -0
  25. package/dist/web/assets/Mobile-89JRhyfb.js +1 -0
  26. package/dist/web/assets/{Observability-DdTOLp2C.js → Observability-BTxPNYcK.js} +1 -1
  27. package/dist/web/assets/PageAgent-CtHfmMj1.js +1 -0
  28. package/dist/web/assets/Product-DutzjAnI.js +12 -0
  29. package/dist/web/assets/{Production-oTXhv40a.js → Production-DVc4vly0.js} +1 -1
  30. package/dist/web/assets/Quality-DDRPOOgr.js +1 -0
  31. package/dist/web/assets/{Readiness-Bv9uTTiI.js → Readiness-BRtsOnY7.js} +1 -1
  32. package/dist/web/assets/Record-BgX9IgVU.js +1 -0
  33. package/dist/web/assets/Regression-B5TZmljh.js +5 -0
  34. package/dist/web/assets/{RelationGraph-BQl3M4zd.js → RelationGraph-Bf7JxnoO.js} +1 -1
  35. package/dist/web/assets/Reports-Ckul-6_Z.js +2 -0
  36. package/dist/web/assets/Responsive-BuFvnY-7.js +3 -0
  37. package/dist/web/assets/{RunDiff-BBT1sQLh.js → RunDiff-lbzcjQPB.js} +1 -1
  38. package/dist/web/assets/Settings-DICPHvyS.js +21 -0
  39. package/dist/web/assets/{Steps-C_vL6-8p.js → Steps-Bgta9n5a.js} +3 -3
  40. package/dist/web/assets/TestData-DhzYxkRb.js +2 -0
  41. package/dist/web/assets/TestManagement-DOTikKBJ.js +4 -0
  42. package/dist/web/assets/{WhatsNew-DTcaqdOJ.js → WhatsNew-BNpscacD.js} +1 -1
  43. package/dist/web/assets/{agentSettingsSheet-DM1aa237.js → agentSettingsSheet-CE2-cOUE.js} +1 -1
  44. package/dist/web/assets/{choice-B6z9CWyZ.js → choice-DPE-97iI.js} +1 -1
  45. package/dist/web/assets/{coverage-BhtF065n.js → coverage-8y4Ntf5j.js} +4 -4
  46. package/dist/web/assets/{dataParts-BNDVxwFb.js → dataParts-BWLBAktB.js} +3 -3
  47. package/dist/web/assets/desktopAppPath-CNgKUGx-.js +1 -0
  48. package/dist/web/assets/frame-CILGAQMi.js +13 -0
  49. package/dist/web/assets/index-CAiu49as.css +2 -0
  50. package/dist/web/assets/index-jQktxp_0.js +56 -0
  51. package/dist/web/assets/{markdown-BhU7ng6c.js → markdown-C3_rYFsI.js} +4 -4
  52. package/dist/web/assets/pageBack-CpPsn9m9.js +3 -0
  53. package/dist/web/assets/{palette-BsY8OLxd.js → palette-B4gvOIk7.js} +1 -1
  54. package/dist/web/assets/{paletteCommands-DflHQ05x.js → paletteCommands-Df6J2Ddx.js} +1 -1
  55. package/dist/web/assets/parts-CoaptHZw.js +1 -0
  56. package/dist/web/assets/{preload-helper-qorOEK5q.js → preload-helper-Bjdk4wEa.js} +1 -1
  57. package/dist/web/assets/{productParts-Dxl-TQKY.js → productParts-yX7pkb5g.js} +1 -1
  58. package/dist/web/assets/{qualityParts-ClGKtjEv.js → qualityParts-DfUjhv4u.js} +1 -1
  59. package/dist/web/assets/{radio-DDxnnflQ.js → radio-BerZ8bce.js} +1 -1
  60. package/dist/web/assets/{recordTest-B33rIncn.js → recordTest-CYjGtHjQ.js} +1 -1
  61. package/dist/web/assets/{route-D9uPlFWw.js → route-M6BKgobp.js} +1 -1
  62. package/dist/web/assets/{sectionList-e5mFDaS2.js → sectionList-K06uJ9W7.js} +1 -1
  63. package/dist/web/assets/{stepper-DSDz0uu8.js → stepper-yRhSVs0I.js} +1 -1
  64. package/dist/web/index.html +9 -9
  65. package/package.json +1 -1
  66. package/dist/web/assets/Agent-DiX8ljlC.js +0 -8
  67. package/dist/web/assets/ApiTests-4jfzlfVd.js +0 -15
  68. package/dist/web/assets/Browse-ByDemInL.js +0 -1
  69. package/dist/web/assets/Chat-C3wKV0CI.js +0 -3
  70. package/dist/web/assets/Data--HGneNun.js +0 -6
  71. package/dist/web/assets/Desktop-DQf5gv7D.js +0 -1
  72. package/dist/web/assets/DesktopReview-BaPYt0kl.js +0 -2
  73. package/dist/web/assets/Evidence-CxRMnZch.js +0 -1
  74. package/dist/web/assets/Features-VsLb8QTH.js +0 -1
  75. package/dist/web/assets/Flaky-CyhTszAg.js +0 -1
  76. package/dist/web/assets/Impact-BWBAXRuw.js +0 -3
  77. package/dist/web/assets/Jobs-C_MjXv0_.js +0 -5
  78. package/dist/web/assets/KindPage-Bb3Kp4-q.js +0 -6
  79. package/dist/web/assets/Migration-C80mGA3h.js +0 -8
  80. package/dist/web/assets/Mobile-C4wVBYfr.js +0 -1
  81. package/dist/web/assets/PageAgent-Bi53-H99.js +0 -1
  82. package/dist/web/assets/Product-0LXndvp-.js +0 -12
  83. package/dist/web/assets/Quality-CY0CJF9e.js +0 -1
  84. package/dist/web/assets/Record-C-kyOkYq.js +0 -1
  85. package/dist/web/assets/Regression-CwKxvG1h.js +0 -5
  86. package/dist/web/assets/Reports-Ck8rc3br.js +0 -2
  87. package/dist/web/assets/Responsive-COmV2NXo.js +0 -3
  88. package/dist/web/assets/Settings-7aMk9Sqx.js +0 -21
  89. package/dist/web/assets/TestData-KzMy9N9f.js +0 -2
  90. package/dist/web/assets/TestManagement-BCEhOGB9.js +0 -4
  91. package/dist/web/assets/desktopAppPath-D4hHP56R.js +0 -1
  92. package/dist/web/assets/frame-CNYHTG4T.js +0 -13
  93. package/dist/web/assets/index-B1Q2Dlqw.js +0 -56
  94. package/dist/web/assets/index-sxUpjgyw.css +0 -2
  95. package/dist/web/assets/pageBack-BoSbGSU6.js +0 -3
  96. package/dist/web/assets/parts-C4QMgN_N.js +0 -1
@@ -1,8 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{A as t,Ar as n,Dr as r,G as i,H as a,Hr as o,I as s,In as c,Ir as l,Kn as u,L as d,M as f,Mr as p,Nn as m,Nr as h,Nt as g,O as _,Or as v,Qn as y,R as b,Rn as x,S,Un as C,Ur as w,V as T,Vn as E,W as D,Wt as ee,Y as O,Zn as te,Zt as k,an as A,bn as ne,bt as re,cn as ie,cr as ae,dt as oe,et as se,fr as j,g as ce,ht as le,ir as ue,kr as de,l as fe,mt as pe,n as me,nr as he,pr as ge,qr as _e,r as M,rt as ve,sr as ye,st as be,tr as xe,u as N,un as Se,ur as Ce,v as we,vt as Te,w as Ee,wr as De,y as Oe,yn as ke,zn as Ae,zr as je}from"./route-D9uPlFWw.js";import{D as P,E as F,G as Me,Ht as I,M as Ne,N as Pe,O as Fe,P as Ie,Vt as L,W as R,X as z,j as Le,q as Re,qt as ze,r as Be,yt as B}from"./preload-helper-qorOEK5q.js";import{t as Ve}from"./jsx-runtime-LKYXHABd.js";import{B as He,H as Ue,N as We,V as Ge,a as Ke,u as qe,z as Je}from"./palette-BsY8OLxd.js";import{D as Ye,E as Xe,S as Ze,T as Qe,b as $e,c as et,d as tt,l as nt,u as rt,w as it,x as V}from"./sectionList-e5mFDaS2.js";import{A as at,D as ot,F as H,N as U,O as W,P as st,c as G,i as ct,j as lt,l as ut,n as dt,o as ft,r as pt,s as mt,t as ht,v as gt}from"./pageBack-BoSbGSU6.js";import{Ct as _t,Gt as vt,K,Kt as yt,L as bt,R as xt,Y as q,bt as St,dt as Ct,gt as wt,ht as Tt,kt as Et,lt as Dt,o as Ot,qt as kt,s as At,t as jt,vt as Mt,xt as Nt,yt as Pt}from"./frame-CNYHTG4T.js";import{t as Ft}from"./when-BuWCTaKm.js";import"./code-DzYywAs5.js";import{$ as It,F as Lt,G as Rt,I as zt,J as Bt,L as Vt,Q as Ht,U as Ut,W as J,Y as Wt,Z as Gt,_ as Kt,a as qt,at as Jt,c as Yt,ct as Xt,ft as Zt,g as Qt,i as $t,it as en,k as tn,l as nn,n as rn,o as an,ot as on,r as sn,s as cn,st as ln,t as un,ut as dn}from"./index-B1Q2Dlqw.js";import{i as fn,r as pn,t as mn}from"./RelationGraph-BQl3M4zd.js";import{r as hn,t as gn}from"./choice-B6z9CWyZ.js";import{l as _n}from"./dataParts-BNDVxwFb.js";var Y=e(_e(),1),X=Ve();function vn({value:e,onChange:n,id:r}){let i=Xe(e),a=typeof e==`string`?e.trim().replace(/\s+/g,` `):``,o=!i&&a?a.slice(0,60):``,s=Xe(e)?e:o?null:``,{theme:c}=qe(),l=We(c)===`icons`?`No icon: the Helper's face`:`No icon: its mascot`,[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(10),[m,h]=(0,Y.useState)(()=>!!(Je(`ph:robot`)||Je(`lucide:bot`)));(0,Y.useEffect)(()=>{He().then(()=>h(!0))},[]),(0,Y.useEffect)(()=>{p(10)},[u]);let g=!!u.trim(),{hits:_,total:v}=(0,Y.useMemo)(()=>g?Ge(u,f,0):Ge(``,f,Ze.length),[u,f,g]),b=Ue.length,x=g?v>f:f<b,S=g?Math.max(0,v-f):Math.max(0,b-f);return(0,X.jsxs)(`div`,{id:r,className:`flex flex-col gap-4`,children:[(0,X.jsxs)(`label`,{className:`relative block`,children:[(0,X.jsx)(y,{"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted`}),(0,X.jsx)(F,{value:u,onChange:e=>d(e.target.value),placeholder:`Search Phosphor and Lucide icons…`,"aria-label":`Search icons`,className:`pl-10`,spellCheck:!1})]}),o&&(0,X.jsxs)(`p`,{className:`text-body-sm text-warn`,children:[`This agent names an icon ForgeQE does not have: `,(0,X.jsx)(`span`,{className:`font-mono`,children:o}),`. Pick one below, or No icon.`]}),!g&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`mb-2 text-body-sm text-muted`,children:`No icon`}),(0,X.jsx)(`div`,{role:`listbox`,"aria-label":`No icon`,className:`flex flex-wrap gap-2`,children:(0,X.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":s===``,"aria-label":`No icon`,"data-tip":l,className:yn,onClick:()=>n(``),children:(0,X.jsx)(Ke,{agent:`custom`,px:28,decorative:!0})})})]}),!g&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`mb-2 text-body-sm text-muted`,children:`ForgeQE faces`}),(0,X.jsx)(`div`,{role:`listbox`,"aria-label":`ForgeQE faces`,className:`flex flex-wrap gap-2`,children:Ze.map(e=>(0,X.jsx)(bn,{icon:e,label:it(e),selected:e===s,ready:!0,onPick:n},e))})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`mb-2 text-body-sm text-muted`,children:g?`Top matches (${v})`:`Library icons (Phosphor and Lucide)`}),(0,X.jsxs)(`div`,{role:`listbox`,"aria-label":g?`Icon search results`:`Library icons`,className:`flex flex-wrap gap-2`,children:[_.map(e=>(0,X.jsx)(bn,{icon:e.id,label:e.label,selected:e.id===s,ready:m||e.kind===`face`,onPick:n},e.id)),_.length===0&&(0,X.jsx)(`p`,{className:`text-body-sm text-muted`,children:`No icons match that search.`})]}),x&&(0,X.jsxs)(U,{variant:`link`,size:`inline`,className:`mt-4 gap-1`,"data-tip":`Show ${Math.min(10,S)} of ${S} more`,onClick:()=>p(e=>e+10),children:[(0,X.jsx)(t,{size:14,"aria-hidden":`true`}),`More (`,S,`)`]})]}),s&&Ye(s)&&(0,X.jsxs)(`p`,{className:`text-body-sm text-muted`,children:[`Selected `,(0,X.jsx)(`span`,{className:`font-mono text-fg`,children:s})]})]})}var yn=L(ze,`size-11 min-h-0 justify-center p-0 disabled:cursor-wait`);function bn({icon:e,label:t,selected:n,ready:r,onPick:i}){return(0,X.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":n,"aria-label":t,"data-tip":t,disabled:!r&&!!Ye(e),className:yn,onClick:()=>i(e),children:Qe(e)?(0,X.jsx)(Be,{name:e,px:28}):(0,X.jsx)(Ke,{agent:`custom`,icon:e,px:28,decorative:!0})})}var xn=[{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 Sn(){let[e,t]=(0,Y.useState)(``),[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(``),[o,s]=(0,Y.useState)([]),[c,l]=(0,Y.useState)([]),u=tn(n);(0,Y.useEffect)(()=>{Me.list().then(e=>s(e.sessions.filter(e=>!e.saved)),()=>{}),z.templates().then(e=>l(e.templates),()=>{})},[]);let d=async()=>{if(e.trim()){r(!0),a(``);try{let t=await Me.start(e.trim());location.hash=M(`agents`,`custom`,`build`,t.sid)}catch(e){a(e.message),r(!1)}}};return(0,X.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,X.jsxs)(`header`,{className:`flex items-center gap-1 px-6 py-4`,children:[(0,X.jsx)(Ot,{}),(0,X.jsx)(dt,{to:{href:M(`agents`,`category`,`custom`),label:`Custom agents`},className:`self-center`})]}),(0,X.jsx)(`main`,{className:`flex flex-auto flex-col items-center justify-center px-6 pt-6 pb-30`,children:(0,X.jsxs)(`div`,{className:`flex w-full max-w-[780px] flex-col items-center gap-10`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col items-center gap-4 text-center`,children:[(0,X.jsx)(at,{state:n?`waiting`:u,px:112,label:n?`Starting the builder`:`ForgeQE is ready to build an agent`,className:`mb-1`}),(0,X.jsx)(`h1`,{className:`m-0 text-headline-lg text-ink`,children:`What should your agent do?`}),(0,X.jsx)(`p`,{className:`m-0 text-body-lg leading-relaxed text-ink-2`,children:`Say it in your own words. ForgeQE works out what it needs from what your project has, asks only what it cannot decide, and builds it with you step by step.`})]}),(0,X.jsx)(Xt,{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,X.jsx)(`p`,{role:`alert`,className:`m-0 -mt-6 text-body-sm text-fail`,children:i}),(0,X.jsx)(J,{id:`build-starters`,icon:A,title:`Or start from one of these, and change it to fit`,className:`w-full`,children:(0,X.jsx)(`ul`,{className:`m-0 grid list-none grid-cols-1 gap-2 p-0 sm:grid-cols-2`,children:xn.map(n=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":e===n.text,onClick:()=>{t(n.text),a(``),document.getElementById(`build-goal`)?.focus()},className:L(hn,`h-full w-full flex-col gap-1`),children:[(0,X.jsx)(`span`,{className:`text-body-sm font-medium text-ink`,children:n.label}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:n.about})]})},n.label))})}),o.length>0&&(0,X.jsx)(J,{id:`build-resume`,icon:ee,title:`Pick up where you left off`,className:`w-full`,children:(0,X.jsx)(`ul`,{className:L(`rounded-lg bg-bg p-6 shadow-sm`,`m-0 flex list-none flex-col`),children:o.slice(0,5).map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`a`,{href:M(`agents`,`custom`,`build`,e.sid),className:`flex w-full min-h-11 cursor-pointer items-center gap-4 rounded-base border-0 bg-transparent px-4 py-2 text-left text-body-sm text-ink no-underline transition-colors duration-150 hover:bg-tint hover:text-ink aria-[current]:bg-tint-hover aria-selected:bg-tint-hover aria-pressed:bg-tint-hover aria-checked:bg-tint-hover has-[:checked]:bg-tint-hover disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-body-sm`,children:e.goal}),(0,X.jsxs)(`span`,{className:`flex-none text-body-sm text-muted`,children:[Cn[e.step].label,` · `,Ft(e.updatedAt)]})]})},e.sid))})}),c.length>0&&(0,X.jsx)(J,{id:`build-templates`,icon:ce,title:`Or start from a template, and review it before you save`,className:`w-full`,children:(0,X.jsx)(`ul`,{className:L(`rounded-lg bg-bg p-6 shadow-sm`,`m-0 flex list-none flex-col`),children:c.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`a`,{href:M(`agents`,`custom`,`new`,`template`,e.id),className:`flex w-full min-h-11 cursor-pointer items-center gap-4 rounded-base border-0 bg-transparent px-4 py-2 text-left text-body-sm text-ink no-underline transition-colors duration-150 hover:bg-tint hover:text-ink aria-[current]:bg-tint-hover aria-selected:bg-tint-hover aria-pressed:bg-tint-hover aria-checked:bg-tint-hover has-[:checked]:bg-tint-hover disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,X.jsx)(`span`,{className:`flex-none text-body-sm`,children:e.title}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 text-body-sm text-muted`,children:e.why||e.about})]})},e.id))})}),(0,X.jsxs)(`a`,{href:M(`agents`,`custom`,`new`,`form`),className:`inline-flex items-center gap-2 text-body-sm`,children:[(0,X.jsx)(he,{size:14,"aria-hidden":`true`}),`Or set every option yourself`]})]})})]})}var Cn={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 wn({sid:e}){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(!1);if((0,Y.useEffect)(()=>{Me.view(e).then(e=>{n(e),o(Math.min(e.reached,e.steps.length-1))},e=>i(e.message))},[e]),(0,Y.useEffect)(()=>{if(!t?.working)return;let r=setTimeout(()=>{Me.view(e).then(n,()=>{})},1500);return()=>clearTimeout(r)},[t,e]),r&&!t)return(0,X.jsx)(Tn,{children:(0,X.jsxs)(`p`,{role:`alert`,className:L(H.fail,`m-0`),children:[r,` `,(0,X.jsx)(`a`,{href:M(`agents`,`custom`,`new`),children:`Start again`})]})});if(!t||a===null)return(0,X.jsx)(Tn,{children:(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Loading…`})});let l=t.steps[a].id,u=Cn[l],d=s||t.working===l,f=async(t,r=!1)=>{if(l!==`try`){c(!0),i(``);try{let i=await Me.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,X.jsxs)(Tn,{children:[(0,X.jsx)(dt,{to:{href:M(`agents`,`category`,`custom`),label:`Custom agents`}}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:`New agent`}),(0,X.jsxs)(`p`,{className:`m-0 text-body-lg text-ink-2 [overflow-wrap:anywhere]`,children:[`“`,t.goal,`”`]})]}),(0,X.jsx)(En,{v:t,at:a,onGo:e=>!s&&o(e)}),(0,X.jsxs)(`section`,{"aria-labelledby":`build-step`,className:`flex flex-col gap-6`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,X.jsx)(at,{state:d?`working`:`idle`,px:36,label:d?u.working:`ForgeQE`,className:`flex-none`}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,X.jsx)(`h1`,{id:`build-step`,className:`m-0 text-headline-sm`,children:u.title}),(0,X.jsx)(`p`,{className:`m-0 text-body-lg leading-relaxed text-ink-2`,children:d?t.working===l?Cn[l].thinking:u.working:t.says[l]}),!d&&t.source?.[l]&&(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:t.source[l]===`model`?`Worked out by ForgeQE's model from what you said and what your project has.`:t.note||`Worked out by ForgeQE's rules: no model is set up.`})]})]}),r&&(0,X.jsx)(`p`,{role:`alert`,className:L(H.fail,`m-0`),children:r}),t.working===l?null:l===`understand`&&(0,X.jsx)(kn,{v:t,busy:s,onNext:f,next:u.next},`u-${t.updatedAt}`),t.working!==l&&l===`plan`&&(0,X.jsx)(jn,{v:t,busy:s,onNext:f,onBack:()=>o(a-1),next:u.next},`p-${t.updatedAt}`),l===`boundaries`&&(0,X.jsx)(Nn,{v:t,busy:s,onNext:f,onBack:()=>o(a-1),next:u.next},`b-${t.updatedAt}`),l===`knowledge`&&(0,X.jsx)(Pn,{v:t,busy:s,onNext:f,onBack:()=>o(a-1),next:u.next},`k-${t.updatedAt}`),t.working!==l&&l===`review`&&(0,X.jsx)(Fn,{v:t,busy:s,onNext:f,onBack:()=>o(a-1),next:u.next},`r-${t.updatedAt}`),l===`try`&&(0,X.jsx)(In,{v:t})]})]})}function Tn({children:e}){return(0,X.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,X.jsx)(At,{}),(0,X.jsx)(`main`,{className:L(jt,`max-w-[920px] flex-auto gap-6`),children:e})]})}function En({v:e,at:t,onGo:n}){return(0,X.jsx)(`nav`,{"aria-label":`Steps`,children:(0,X.jsx)(`ol`,{className:`m-0 flex list-none flex-wrap gap-x-1 gap-y-2 p-0`,children:e.steps.map((r,i)=>{let a=i<=e.reached,o=i===t;return(0,X.jsxs)(`li`,{className:`flex items-center gap-1`,children:[(0,X.jsxs)(U,{variant:`ghost`,size:`sm`,disabled:!a,"aria-current":o?`step`:void 0,onClick:()=>n(i),children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:L(`inline-flex size-5 items-center justify-center rounded-full text-body-sm tabular-nums`,r.done&&!o?`bg-pass-soft text-pass`:o?`bg-accent text-accent-ink`:`bg-surface-strong text-muted`),children:r.done&&!o?(0,X.jsx)(_,{size:12,strokeWidth:3}):i+1}),Cn[r.id].label]}),i<e.steps.length-1&&(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`h-px w-4 bg-line`})]},r.id)})})})}function Dn({busy:e,onBack:t,next:n,onNext:r,disabled:i,aside:a}){let o=n.startsWith(`Save`);return(0,X.jsxs)(`div`,{className:`sticky bottom-0 flex flex-wrap items-center gap-4 border-t border-line-soft bg-canvas py-4`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 text-body-sm`,children:a}),t&&(0,X.jsxs)(U,{variant:`ghost`,disabled:e,onClick:t,children:[(0,X.jsx)(fe,{"aria-hidden":`true`}),`Back`]}),(0,X.jsxs)(U,{variant:`primary`,disabled:e||i,onClick:r,"data-tip":n,children:[o?(0,X.jsx)(_,{"aria-hidden":`true`}):(0,X.jsx)(N,{"aria-hidden":`true`}),o?`Save`:`Next`]})]})}function On({on:e,label:t,why:n,recommended:r,onToggle:i}){return(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":e,onClick:i,className:L(gn,`w-full items-start`),children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:L(`mt-1 inline-flex size-4 flex-none items-center justify-center rounded-sm`,e?`bg-accent text-accent-ink`:`bg-bg`),children:e&&(0,X.jsx)(_,{size:12,strokeWidth:3})}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-body-sm font-medium text-ink`,children:[t,r&&(0,X.jsx)(G,{tone:`running`,icon:!1,children:`Recommended`})]}),n&&(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:n})]})]})}function kn({v:e,busy:t,onNext:n,next:r}){let[i,a]=(0,Y.useState)(()=>Object.fromEntries(e.questions.map(e=>[e.id,e.answer]))),[o,s]=(0,Y.useState)([]),l=(e,t,n)=>a(r=>{let i=r[e]||[];return{...r,[e]:t===`one`?[n]:i.includes(n)?i.filter(e=>e!==n):[...i,n]}});return(0,X.jsxs)(X.Fragment,{children:[e.questions.map(e=>{let t=e.assumed&&!o.includes(e.id);return(0,X.jsxs)(`fieldset`,{className:L(W,`m-0 flex flex-col gap-2`),children:[(0,X.jsx)(`legend`,{className:`sr-only`,children:e.text}),(0,X.jsx)(`span`,{className:`text-body-lg font-medium`,children:e.text}),t?(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-body-sm text-ink-2`,children:[(0,X.jsx)(lt,{icon:d,size:16,className:`text-pass`}),e.assumed,!(i[e.id]||[]).every(t=>e.assumed?.includes(t))&&(0,X.jsxs)(`span`,{className:`text-muted`,children:[`(`,i[e.id]?.join(`, `),`)`]}),(0,X.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>s([...o,e.id]),"aria-label":`Change the answer`,"data-tip":`Change the answer`,children:(0,X.jsx)(c,{"aria-hidden":`true`})})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:e.why}),(0,X.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:e.options.map(t=>(0,X.jsx)(On,{on:(i[e.id]||[]).includes(t.id),label:t.label,why:t.why,recommended:t.recommended,onToggle:()=>l(e.id,e.kind,t.id)},t.id))})]})]},e.id)}),(0,X.jsx)(Dn,{busy:t,next:r,onNext:()=>n({answers:i}),disabled:e.questions.some(e=>e.id===`environment`&&!(i[e.id]||[]).length),aside:e.environments.length===0?(0,X.jsx)(`span`,{className:`text-fail`,children:`Add a test environment in Settings first: an agent needs one to work in.`}):void 0})]})}var An={ready:{icon:d,label:`Ready`,tone:`text-pass`},partial:{icon:b,label:`Partly set up`,tone:`text-warn`},needs_setup:{icon:a,label:`Not set up here yet`,tone:`text-muted`}};function jn({v:e,busy:t,onNext:n,onBack:r,next:i}){let[a,s]=(0,Y.useState)(()=>e.plan.filter(e=>e.on).map(e=>e.capability)),[c,l]=(0,Y.useState)(!1),u=a.map(t=>e.plan.find(e=>e.capability===t)).filter(Boolean),d=e.plan.filter(e=>!a.includes(e.capability));return(0,X.jsxs)(X.Fragment,{children:[e.planSteps&&e.planSteps.length>0&&(0,X.jsx)(`ol`,{"aria-label":`How it will work`,className:L(`rounded-lg bg-bg p-6 shadow-sm`,`m-0 flex list-none flex-col gap-0 p-0`),children:e.planSteps.map((t,n)=>(0,X.jsxs)(`li`,{className:L(`flex items-start gap-4 px-4 py-4`,n>0&&`border-t border-line-soft`),children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex size-7 flex-none items-center justify-center rounded-full bg-accent-soft text-body-sm font-medium text-accent-fg tabular-nums`,children:n+1}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-body-lg font-medium`,children:t.title}),(0,X.jsx)(`span`,{className:`text-body-sm text-ink-2`,children:t.why}),t.without&&(0,X.jsxs)(`span`,{className:`text-body-sm text-muted`,children:[`Without it: `,t.without]}),(0,X.jsx)(`span`,{className:`flex flex-wrap gap-2 pt-1`,children:t.uses.map(t=>{let n=e.plan.find(e=>e.capability===t);return(0,X.jsx)(G,{tone:`neutral`,icon:!1,children:n?.title||t},t)})})]})]},n))}),e.planSteps&&e.planSteps.length>0&&(0,X.jsx)(Rt,{icon:o,title:`What it uses`,level:3,className:`mt-2`}),(0,X.jsx)(`ol`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:u.map((e,t)=>{let n=An[e.state];return(0,X.jsxs)(`li`,{className:L(W,`flex items-start gap-4`),children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex size-7 flex-none items-center justify-center rounded-full bg-accent-soft text-body-sm font-medium text-accent-fg tabular-nums`,children:t+1}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-body-lg font-medium`,children:e.title}),e.why&&(0,X.jsx)(`span`,{className:`text-body-sm text-ink-2`,children:e.why}),(0,X.jsx)(`span`,{className:`line-clamp-2 text-body-sm text-muted`,children:e.summary}),(0,X.jsxs)(`span`,{className:L(`flex items-center gap-2 text-body-sm`,n.tone),children:[(0,X.jsx)(lt,{icon:n.icon,size:14}),n.label,e.state!==`ready`&&e.gaps.length?`: ${e.gaps.join(`; `)}`:``]})]}),(0,X.jsx)(U,{variant:`icon`,size:`icon`,"aria-label":`Leave out ${e.title}`,"data-tip":`Leave out ${e.title}`,onClick:()=>s(a.filter(t=>t!==e.capability)),children:(0,X.jsx)(De,{"aria-hidden":`true`})})]},e.capability)})}),c?(0,X.jsx)(J,{id:`build-add`,icon:E,title:`What else should it do?`,level:3,className:W,children:(0,X.jsx)(`ul`,{className:`m-0 grid list-none grid-cols-1 gap-2 p-0 sm:grid-cols-2`,children:d.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,onClick:()=>s([...a,e.capability]),className:L(gn,`h-full w-full items-start gap-2`),children:[(0,X.jsx)(E,{size:16,"aria-hidden":`true`,className:`mt-1 flex-none text-muted`}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,X.jsx)(`span`,{className:`text-body-sm font-medium`,children:e.title}),(0,X.jsx)(`span`,{className:`line-clamp-2 text-body-sm text-muted`,children:e.summary})]})]})},e.capability))})}):(0,X.jsxs)(U,{size:`sm`,className:`self-start`,onClick:()=>l(!0),"data-tip":`Add something it should also do`,children:[(0,X.jsx)(E,{"aria-hidden":`true`}),`Add`]}),(0,X.jsx)(Dn,{busy:t,onBack:r,next:i,onNext:()=>n({capabilities:a}),disabled:!a.length})]})}function Mn({text:e,help:t,on:n,onChange:r,locked:i}){return(0,X.jsxs)(`div`,{className:`flex items-start gap-4 border-t border-line-soft py-4 first:border-t-0`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-body-sm text-ink`,children:e}),(t||i)&&(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:i||t})]}),i?(0,X.jsx)(ue,{size:18,"aria-label":`Always`,className:`mt-1 flex-none text-muted`}):(0,X.jsx)(Et,{checked:n,onChange:e=>r?.(e),label:e})]})}function Nn({v:e,busy:t,onNext:n,onBack:r,next:i}){let a=e.boundaries,[o,s]=(0,Y.useState)(a.environments),[c,l]=(0,Y.useState)(a.actions),[u,d]=(0,Y.useState)(a.approve),[f,p]=(0,Y.useState)(a.shell),[m,h]=(0,Y.useState)(a.repository),[g,_]=(0,Y.useState)(a.unattended),[v,y]=(0,Y.useState)(a.trust||[]),[b,x]=(0,Y.useState)((a.production||[]).includes(`run`)),S=o.some(t=>e.production.includes(t)),C=(e,t)=>y(t?[...new Set([...v,e])]:v.filter(t=>t!==e)),w=e.plan.filter(e=>e.on&&e.capability.startsWith(`system:`)),T=(e,t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],E=e=>c.includes(e),D=(e,t)=>l(t?[...new Set([...c,e])]:c.filter(t=>t!==e)),ee=(e,t)=>d(t?[...new Set([...u,e])]:u.filter(t=>t!==e)),O=o.join(` and `)||`its environments`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`fieldset`,{className:L(W,`m-0 flex flex-col gap-2`),children:[(0,X.jsx)(`legend`,{className:`sr-only`,children:`Where it works`}),(0,X.jsx)(`span`,{className:`text-body-lg font-medium`,children:`Where it works`}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:`Every run, test and call goes only here. In production it reads without asking, and a person approves every change.`}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,X.jsx)(ft,{items:e.environments.map(t=>({id:t,label:t,...e.production.includes(t)&&!/prod/i.test(t)?{note:`production`,noteClass:`text-warn`}:{}})),value:o,onChange:s})}),S&&(0,X.jsx)(`span`,{className:`text-body-sm text-warn`,children:`In production, it reads without asking; a person approves every change there, on a schedule too (it waits, and the team is told). Before a step that could reach real customers, it asks you itself.`})]}),(0,X.jsxs)(`section`,{"aria-labelledby":`build-may`,className:L(W,`flex flex-col`),children:[(0,X.jsx)(`h2`,{id:`build-may`,className:`sr-only`,children:`What it may do`}),(0,X.jsx)(Mn,{text:`Read test cases, runs, reports and your systems' data`,on:!0,locked:`Always: it cannot work without it, and it changes nothing.`}),e.needs?.run&&(0,X.jsx)(Mn,{text:`Run tests and apps in ${O}`,help:`Browser runs, tests, API calls and database queries.`,on:E(`run`),onChange:e=>D(`run`,e)}),e.needs?.run&&E(`run`)&&(0,X.jsx)(Mn,{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=>ee(`run`,e)}),e.needs?.run&&E(`run`)&&S&&(0,X.jsx)(Mn,{text:`Ask me before each run in production`,help:`Off: browser runs, tests and API calls there go ahead without asking. Each question also offers to allow the rest of the run.`,on:!b,onChange:e=>x(!e)}),(0,X.jsx)(Mn,{text:`Change test assets on this computer`,help:`Regression packs, API contracts, page memory, recordings. Off unless its job is to make them.`,on:E(`change`),onChange:e=>D(`change`,e)}),E(`change`)&&(0,X.jsx)(Mn,{text:`Ask me before each change`,on:u.includes(`change`),onChange:e=>ee(`change`,e)}),e.needs?.external&&(0,X.jsx)(Mn,{text:`Change other systems as you asked`,help:`Work items or the team's channel, as you chose.`,on:E(`external`),onChange:e=>D(`external`,e)}),E(`external`)&&(0,X.jsx)(Mn,{text:`Ask me before each change to another system`,help:`Recommended. Off: it comments, updates and attaches as its job says, without asking.`,on:!v.includes(`external`),onChange:e=>C(`external`,!e)}),e.needs?.repository&&(0,X.jsx)(Mn,{text:`Change your repository to write or heal tests`,help:`A coding agent does it on this computer.`,on:m===`write`,onChange:e=>(h(e?`write`:`read`),e&&D(`change`,!0))}),e.needs?.repository&&m===`write`&&(0,X.jsx)(Mn,{text:`Ask me before the coding agent works`,help:`Off: it writes and heals tests without asking. The tests it runs can reach any address, so ForgeQE first looks in your test project's config and env files, and asks you when they name an address outside its environments.`,on:!v.includes(`coding`),onChange:e=>C(`coding`,!e)}),(0,X.jsx)(Mn,{text:`Use the shell`,help:`Commands on this computer, and fetching web pages. A person approves each one; ForgeQE's secrets stay out of reach.`,on:f,onChange:p})]}),e.schedule&&(0,X.jsxs)(`fieldset`,{className:L(`rounded-lg bg-bg p-6 shadow-sm`,`m-0 flex flex-col gap-2`),children:[(0,X.jsx)(`legend`,{className:`sr-only`,children:`What it may do alone`}),(0,X.jsxs)(`span`,{className:`text-body-lg font-medium`,children:[`When it runs `,e.schedule.toLowerCase(),`, with nobody watching`]}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:`What it may do without asking. Anything else waits for a person: the team is told, and no answer in four hours is a no. It may always ask a person itself.`}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:[E(`run`)&&(0,X.jsx)(On,{on:g.includes(`run`),label:`Run tests and apps`,why:`Recommended: what it is there to do.`,recommended:!0,onToggle:()=>_(T(g,`run`))}),E(`change`)&&(0,X.jsx)(On,{on:g.includes(`change`),label:`Change test assets`,onToggle:()=>_(T(g,`change`))}),m===`write`&&v.includes(`coding`)&&(0,X.jsx)(On,{on:g.includes(`coding`),label:`Write or heal tests`,why:`The coding agent, when its test project names no address outside its environments.`,onToggle:()=>_(T(g,`coding`))}),w.map(e=>(0,X.jsx)(On,{on:g.includes(`${e.capability.slice(7)}_*`),label:`Change ${e.title.replace(/^Work with /,``)}`,why:`Comment, update states, attach evidence, without a person approving each.`,onToggle:()=>_(T(g,`${e.capability.slice(7)}_*`))},e.capability))]})]}),(0,X.jsx)(Dn,{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 Pn({v:e,busy:t,onNext:n,onBack:r,next:i}){let a=e.knowledge,[o,s]=(0,Y.useState)(a.files.filter(e=>e.on).map(e=>e.file)),[c,l]=(0,Y.useState)(a.skills.filter(e=>e.on).map(e=>e.name)),[u,d]=(0,Y.useState)(a.notes),f=(e,t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],p=e=>e.toSorted((e,t)=>Number(!!t.why)-Number(!!e.why));return(0,X.jsxs)(X.Fragment,{children:[(a.files.length>0||a.skills.length>0)&&(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:[p(a.files).map(e=>(0,X.jsx)(On,{on:o.includes(e.file),label:e.title,why:e.why||e.file,recommended:e.on,onToggle:()=>s(f(o,e.file))},e.file)),p(a.skills).map(e=>(0,X.jsx)(On,{on:c.includes(e.name),label:`Skill: ${e.name}`,why:e.why||e.about,recommended:e.on,onToggle:()=>l(f(c,e.name))},e.name))]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`span`,{className:`text-body-lg font-medium`,children:`Anything else it should know?`}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:`Business rules, what “done” looks like, which test accounts to use (never passwords). It is kept as this agent's own knowledge.`}),(0,X.jsx)(Fe,{rows:5,value:u,maxLength:2e4,onChange:e=>d(e.target.value),placeholder:`A declined card shows “Payment failed” and keeps the basket.`})]}),(0,X.jsx)(Dn,{busy:t,onBack:r,next:i,onNext:()=>n({files:o,skills:c,notes:u})})]})}function Fn({v:e,busy:t,onNext:n,onBack:r,next:i}){let a=e.review,[o,s]=(0,Y.useState)(a.name),[c,l]=(0,Y.useState)(a.id),[u,d]=(0,Y.useState)(a.description),[f,p]=(0,Y.useState)(a.icon||``),[m,h]=(0,Y.useState)(a.starters[0]?.text||e.goal),[g,_]=(0,Y.useState)(a.model||``),[v,y]=(0,Y.useState)(a.maxTokens?String(a.maxTokens):``),[b,x]=(0,Y.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))}:{}},w=e.plan.filter(e=>e.on),T=e.boundaries,E=e.knowledge,D=[[`It works in`,T.environments.join(`, `)],[`It does`,w.map(e=>e.title).join(`; `)],[`It may`,[T.actions.includes(`run`)?`run tests and apps${T.approve.includes(`run`)?` (asking you first)`:``}`:``,T.actions.includes(`change`)?`change test assets`:``,T.actions.includes(`external`)?`change other systems${(T.trust||[]).includes(`external`)?` (without asking)`:` (asking you first)`}`:``,T.repository===`write`?`write or heal tests${(T.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${T.unattended.length?`; alone it may ${T.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`],...T.shell?[[`Shell`,`yes, a person approves each command`]]:[],[`It knows`,[...E.files.filter(e=>e.on).map(e=>e.title),...E.skills.filter(e=>e.on).map(e=>e.name),...E.notes.trim()?[`your notes`]:[]].join(`, `)||`nothing extra`]];return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Name`}),(0,X.jsx)(F,{value:o,maxLength:60,onChange:e=>s(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Id`}),(0,X.jsx)(F,{value:c,maxLength:40,spellCheck:!1,disabled:!!e.saved,onChange:e=>l(e.target.value.toLowerCase())})]})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`What it is for`}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:`One line. Atlas reads it to know when to hand it work.`}),(0,X.jsx)(F,{value:u,maxLength:300,onChange:e=>d(e.target.value)})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Icon`}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:`What it wears on the Agents page: its mascot, or one of ForgeQE's agent icons.`}),(0,X.jsx)(vn,{value:f,onChange:p})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-3`,children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Budget per run`}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:`The most model tokens one run may use, 1,000 or more; it stops there. Empty: no limit.`}),(0,X.jsx)(F,{type:`number`,min:1e3,step:1e3,value:v,placeholder:`No limit`,onChange:e=>y(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Time limit per run`}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:`In minutes, 1 to 1440. Empty: no limit when someone is watching, 120 when nobody is (a schedule, a trigger, another agent).`}),(0,X.jsx)(F,{type:`number`,min:1,max:1440,value:b,placeholder:`Minutes`,onChange:e=>x(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Model`}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:`The model profile of llms.json its runs use.`}),(0,X.jsxs)(P,{value:g,onChange:e=>_(e.target.value),children:[(0,X.jsx)(`option`,{value:``,children:`ForgeQE's choice`}),(e.models||[]).map(e=>(0,X.jsxs)(`option`,{value:e.name,children:[e.name,` (`,e.model,`)`]},e.name)),g&&!(e.models||[]).some(e=>e.name===g)&&(0,X.jsxs)(`option`,{value:g,children:[g,` (not in llms.json)`]})]})]})]}),S&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 text-body-sm text-fail`,children:S}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Its first request`}),(0,X.jsx)(F,{value:m,maxLength:500,onChange:e=>h(e.target.value)})]}),(0,X.jsx)(`dl`,{className:L(ot,`m-0 grid grid-cols-1 gap-x-6 gap-y-2 text-body-sm sm:grid-cols-[140px_1fr]`),children:D.map(([e,t])=>(0,X.jsxs)(`div`,{className:`contents`,children:[(0,X.jsx)(`dt`,{className:`text-muted`,children:e}),(0,X.jsx)(`dd`,{className:`m-0 text-ink [overflow-wrap:anywhere]`,children:t})]},e))}),e.advice.filter(e=>e.blocking).length>0&&(0,X.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:e.advice.filter(e=>e.blocking).map((e,t)=>(0,X.jsxs)(`li`,{className:L(H.warn,`flex flex-col gap-1`),children:[(0,X.jsx)(`span`,{className:`font-medium text-warn`,children:e.about}),(0,X.jsx)(`span`,{className:`text-body-sm text-ink-2`,children:e.fix})]},t))}),(0,X.jsx)(Dn,{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,X.jsxs)(`a`,{href:M(`agents`,`custom`,e.saved,`edit`),className:`inline-flex items-center gap-2`,children:[(0,X.jsx)(he,{size:14,"aria-hidden":`true`}),`Open every setting`]}):(0,X.jsxs)(U,{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,X.jsx)(he,{"aria-hidden":`true`}),`Save and open every setting`]})})]})}function In({v:e}){let t=e.saved,[n,r]=(0,Y.useState)(e.review?.starters[0]?.text||e.goal),[i,a]=(0,Y.useState)(``),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(``),[u,f]=(0,Y.useState)(!1),p=async()=>{s(!0);try{let{id:e}=await Re.start(n.trim(),{agent:t,try:!0});location.hash=M(`chats`,e)}catch(e){l(e.message),s(!1)}},m=async()=>{s(!0),l(``);try{await z.act(t,`approve`,{confirm:i,note:`Made with the agent builder`}),f(!0)}catch(e){l(e.message)}finally{s(!1)}};return u?(0,X.jsxs)(`div`,{className:L(H.pass,`flex flex-col items-start gap-4`),children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-2 text-body-lg font-medium text-pass`,children:[(0,X.jsx)(d,{size:18,"aria-hidden":`true`}),V(e.review?.name||`agent`,!0),` is ready.`]}),(0,X.jsx)(`span`,{className:`text-body-sm text-ink-2`,children:`You, your team and Atlas can hand it work now.`}),(0,X.jsxs)(`a`,{href:M(`agents`,`custom`,t),className:L(st({variant:`primary`,size:`sm`}),`no-underline`),"data-tip":`Open the agent`,children:[(0,X.jsx)(N,{"aria-hidden":`true`}),`Open`]})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(J,{id:`build-try`,icon:x,title:`1. Try it on a real request`,level:3,className:W,children:[(0,X.jsx)(Fe,{rows:2,"aria-label":`What to try`,value:n,onChange:e=>r(e.target.value)}),(0,X.jsxs)(U,{variant:`primary`,size:`sm`,className:`self-start`,disabled:o||!n.trim(),onClick:()=>void p(),"data-tip":`Try it in a chat`,children:[(0,X.jsx)(x,{"aria-hidden":`true`}),`Try`]}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:`It opens as a chat. Come back here to approve it: Agents, Custom agents, then this agent.`})]}),(0,X.jsxs)(J,{id:`build-approve`,icon:d,title:`2. Approve it`,level:3,className:W,children:[(0,X.jsxs)(`span`,{className:`text-body-sm text-muted`,children:[`Only an approved version runs. Type its id to confirm: `,t]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(F,{"aria-label":`Type ${t} to confirm`,className:`w-[260px]`,value:i,spellCheck:!1,autoComplete:`off`,onChange:e=>a(e.target.value),placeholder:t}),(0,X.jsxs)(U,{size:`sm`,disabled:o||i!==t,onClick:()=>void m(),children:[(0,X.jsx)(d,{"aria-hidden":`true`}),`Approve`]})]})]}),c&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 text-body-sm text-fail [overflow-wrap:anywhere]`,children:c}),(0,X.jsx)(`a`,{href:M(`agents`,`custom`,t),className:`self-start text-body-sm`,children:`Open its page`})]})}function Ln({text:e,file:t}){let n=e.replace(/\n$/,``).split(`
2
- `);return(0,X.jsx)(J,{id:`ca-manifest`,icon:le,title:(0,X.jsxs)(X.Fragment,{children:[`Its manifest, as it is in `,(0,X.jsx)(`span`,{className:`font-mono`,children:t})]}),description:`Read only: fix it in that file, or start a new agent from the form and delete this one.`,className:`w-full text-left`,children:(0,X.jsx)(`pre`,{tabIndex:0,"aria-label":`The manifest in ${t}`,className:L(W,`m-0 max-h-[50vh] overflow-auto font-mono text-body-sm leading-relaxed`),children:n.map((e,t)=>(0,X.jsxs)(`span`,{className:`block pl-12 -indent-12 whitespace-pre-wrap [overflow-wrap:anywhere]`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`mr-4 inline-block w-8 text-right text-muted select-none`,children:t+1}),e]},t))})})}function Rn(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 zn=[`text`,`environment`,`choice`],Bn=/[\u0000-\u001f\u007f\u2028\u2029]/,Vn=/\{([a-z][a-z0-9_]{0,31})\}/g;function Hn(e){return[...new Set([...e.matchAll(Vn)].map(e=>e[1]))]}function Un(e,t,n){return typeof t!=`string`||!t.trim()?`${e.label} needs a value.`:t.length>200?`${e.label} is longer than 200 characters.`:Bn.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 Wn(e,t,n,r){let i=[];for(let a of Hn(e)){let e=t.find(e=>e.name===a);if(!e)i.push(`{${a}} is not one of its inputs.`);else{let t=Un(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(Vn,(e,t)=>n[t].trim());if(a.trim().startsWith(`-`))throw Error(`The request cannot start with a dash.`);return a}var Gn=(e,t,n,r)=>r.map(([r,i,a])=>({file:`${n}/${r}`,url:`https://huggingface.co/${e}/resolve/${t}/${r}`,bytes:i,sha256:a}));Object.freeze(`anyio==4.15.1 ; sys_platform != 'emscripten',attrs==26.1.0,av==19.0.2,click==8.5.0,cloudpickle==3.1.2,colorama==0.4.6 ; sys_platform == 'win32',ctranslate2==4.8.4,dlinfo==2.0.0,espeakng-loader==0.2.4,faster-whisper==1.2.1,filelock==4.2.6,flatbuffers==25.12.19,fsspec==2026.9.0,h11==0.16.0 ; sys_platform != 'emscripten',hf-xet==1.8.0 ; platform_machine == 'AMD64' or platform_machine == 'ARM64' or platform_machine == 'aarch64' or platform_machine == 'amd64' or platform_machine == 'arm64' or platform_machine == 'x86_64',httpcore2==2.16.0 ; sys_platform != 'emscripten',httpx2==2.16.0,httpx2-jsfetch==1.0 ; sys_platform == 'emscripten',huggingface-hub==2.4.0,idna==3.20,joblib==1.6.0,kokoro-onnx==0.6.1,numpy==2.5.4,onnxruntime==1.31.1,packaging==26.3,phonemizer==3.4.0,protobuf==7.36.2,pyyaml==6.0.3,tokenizers==0.23.3,tqdm==4.70.1,truststore==0.10.5 ; sys_platform != 'emscripten',typing-extensions==4.16.0`.split(`,`));var Kn=`https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files-v1.0`,qn=Object.freeze([{file:`kokoro-onnx/kokoro-v1.0.onnx`,url:`${Kn}/kokoro-v1.0.onnx`,bytes:325532387,sha256:`7d5df8ecf7d4b1878015a32686053fd0eebe2bc377234608764cc0ef3636a6c5`},{file:`kokoro-onnx/voices-v1.0.bin`,url:`${Kn}/voices-v1.0.bin`,bytes:28214398,sha256:`bca610b8308e8d99f32e6fe4197e7ec01679264efed0cac9140fe9c29f1fbf7d`}]),Jn=`https://huggingface.co/Systran/faster-whisper-base.en/resolve/3d3d5dee26484f91867d81cb899cfcf72b96be6c`,Yn=Object.freeze([{file:`whisper-base.en/config.json`,url:`${Jn}/config.json`,bytes:2227,sha256:`f3bc3821e9fc76a27bae538e11ae5b677dcdd352b4600429ce7951d398569aeb`},{file:`whisper-base.en/tokenizer.json`,url:`${Jn}/tokenizer.json`,bytes:2128466,sha256:`929c5252409436dce1b38a75d1abbcb5e132d170d8e324e4e04ed915fa2d22df`},{file:`whisper-base.en/vocabulary.txt`,url:`${Jn}/vocabulary.txt`,bytes:422309,sha256:`ff77588746d3a2595d32ab5b69ffd7b95ce2441ac57533cb66fc3eb575a115cf`},{file:`whisper-base.en/model.bin`,url:`${Jn}/model.bin`,bytes:145216508,sha256:`2a166925539a16005f14ff328359f9b9adb9dc4fb631bb3b227526862e93e2ef`}]),Xn=Object.freeze(Gn(`onnx-community/silero-vad`,`e71cae966052b992a7eca6b17738916ce0eca4ec`,`silero-vad`,[[`onnx/model.onnx`,2243022,`a4a068cd6cf1ea8355b84327595838ca748ec29a25bc91fc82e6c299ccdc5808`]])),Zn=Object.freeze(Gn(`pipecat-ai/smart-turn-v3`,`f766f81d3cfdf7737ac64aad813d91bbfd56bf93`,`smart-turn-v3`,[[`smart-turn-v3.2-cpu.onnx`,8679182,`2bb026316b14a660486a75b1733cd3fbab8c2fd0314dc9af7be49f8cca967e4f`]])),Qn=Object.freeze([...Xn,...Zn]);Object.freeze([...qn,...Yn,...Qn]),Object.freeze({en:Object.freeze([`af_heart`,`am_michael`])}),Object.freeze({en:`af_heart`});var $n=Object.freeze([`light`,`deep`]);Object.freeze({en:{light:`af_heart`,deep:`am_michael`}});var er=[`suite_failed`,`suite_passed`,`job_failed`,`job_recovered`,`eval_failed`,`pr_opened`,`pr_updated`,`push`],tr=[`pr_opened`,`pr_updated`,`push`],nr=[`number`,`text`,`yes_no`],rr={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 ir(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^[^a-z]+/,``).replace(/(?<!-)-+$/,``).slice(0,40).replace(/(?<!-)-+$/,``)}var ar={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.`}},or=6,sr={number:`A number`,text:`One line of text`,yes_no:`Yes or no`},cr=tr,lr={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`},ur={text:`Text`,environment:`One of its environments`,choice:`One of a list`},dr={read:`Read`,run:`Run`,change:`Change files`,external:`Change other systems`,schedule:`Schedule work`};function fr(e){let t=e.schedule?.with;if(!e.schedule||!t)return e;let n=new Set(Hn(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 pr(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 mr={ready:{icon:d,label:`Ready`,cls:`text-pass`},partial:{icon:b,label:`Partly set up`,cls:`text-warn`},needs_setup:{icon:a,label:`Needs setup`,cls:`text-muted`}},hr=e=>e?e.cron===void 0?`every`:`cron`:``,gr=e=>e.replace(/\s+MCP\s*$/i,``);function _r(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 ${gr(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 vr(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,X.jsxs)(`label`,{className:L(`flex items-start gap-2 text-body-sm`,n?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,X.jsx)(Ut,{checked:e,disabled:n,onCheckedChange:t,className:`mt-1`}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,X.jsx)(`span`,{className:`text-ink`,children:r}),i&&(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:i})]})]})}function yr({id:e,label:t,options:n,onChange:r,placeholder:i=`checkout, search`,max:a=12,mono:o=!1}){let[s,c]=(0,Y.useState)(n.join(`, `)),l=e=>[...new Set(e.split(`,`).map(e=>e.trim()).filter(Boolean))].slice(0,a);return(0,Y.useEffect)(()=>{l(s).join(`\0`)!==n.join(`\0`)&&c(n.join(`, `))},[n.join(`\0`)]),(0,X.jsx)(F,{id:e,"aria-label":t,className:L(`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 br({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,X.jsxs)(P,{id:e,value:r,className:`w-[200px]`,onChange:e=>i(e.target.value),children:[(0,X.jsx)(`option`,{value:``,children:`Pick one`}),a.map(e=>(0,X.jsx)(`option`,{value:e,children:e},e))]}):(0,X.jsx)(F,{id:e,value:r,maxLength:200,className:`w-[200px]`,onChange:e=>i(e.target.value)})}function xr({id:e,template:t}){let n=!e,[i,a]=(0,Y.useState)(n&&!t?rr:null),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(``),[v,y]=(0,Y.useState)(``),[b,x]=(0,Y.useState)(null),[C,w]=(0,Y.useState)([]),[T,D]=(0,Y.useState)([]),[ee,O]=(0,Y.useState)(!1),[te,ne]=(0,Y.useState)(!1),[re,oe]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{z.choices().then(u,e=>m(e.message)),t&&z.template(t).then(e=>{c(e),a({...rr,...e.fields,scope:{...rr.scope,...e.fields.scope},permissions:{...rr.permissions,...e.fields.permissions}}),oe(!0)},e=>m(e.message)),e&&z.view(e).then(t=>(y(t.approvedVersion||``),t.form?a({...rr,...t.form,runtime:{...t.form.runtime}}):t.manifestText===void 0?m(`${e} has no manifest the editor can read (it may have been removed). Its page says what it has.`):(x({text:t.manifestText,file:t.manifestFile||`.forgeqe/agents/${e}.yaml`,problems:t.problems.working}),m(`${e}'s manifest is not one the editor can read. Fix it in ${t.manifestFile||`.forgeqe/agents/${e}.yaml`}; what is wrong, and the file as it is, are below.`))),e=>m(e.message))},[e,t]);let se=(0,Y.useRef)(0);(0,Y.useEffect)(()=>{if(!i)return;let e=++se.current;O(!0);let t=setTimeout(()=>{z.validate(fr(i)).then(t=>e===se.current&&(w(t.problems||[]),D(t.advice||[]),O(!1)),t=>e===se.current&&(w([t.message]),O(!1)))},350);return()=>clearTimeout(t)},[i]);let j=e=>a(t=>t&&{...t,...e}),le=l?.coding||[],de=e=>le.filter(t=>(l?.capabilities||[]).some(n=>e.scope.capabilities.includes(n.id)&&n.tools.includes(t))),fe=e=>pr(vr(e,le,de(e)),l?.capabilities||[]),me=e=>a(t=>t&&fe({...t,scope:{...t.scope,...e}})),he=e=>a(t=>t&&{...t,voice:e?{sound:e}:void 0}),ge=e=>a(t=>t&&fe({...t,permissions:{...t.permissions,...e}})),_e=e=>a(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=>a(t=>t?.schedule?{...t,schedule:{...t.schedule,...e}}:t),ye=i?.schedule,be=[...ye&&hr(ye)===`every`&&!ye.every?.trim()?[`Say how often it runs: 15m, 1h, 1d.`]:[],...ye&&hr(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.`]:[],...(i?.triggers||[]).flatMap((e,t)=>e.request.trim()?[]:[`Say what trigger ${t+1} asks it (${lr[e.on].toLowerCase()}).`])],N=[...be,...C],Se=(0,Y.useMemo)(()=>{let e=new Map;for(let t of l?.capabilities||[])e.set(t.area,[...e.get(t.area)||[],t]);return[...e]},[l]),Ce=async()=>{if(i){ne(!0),m(``);try{let t=await z.save(fr(i),n?{create:!0}:{id:e});location.hash=M(`agents`,`custom`,t.id)}catch(e){m(e.message),ne(!1)}}},we=e?M(`agents`,`custom`,e):M(`agents`,`custom`,`new`);return(0,X.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,X.jsx)(At,{}),(0,X.jsxs)(`main`,{className:L(jt,`flex-auto gap-2`),children:[(0,X.jsx)(ht,{href:we,label:e?`Back to the agent`:`Back to the builder`,className:`mb-2`}),(0,X.jsx)(`h1`,{className:`m-0 text-headline-lg`,children:n?`New custom agent`:`Edit ${i?.name||e}`}),(0,X.jsx)(`p`,{className:`m-0 mb-2 text-body-sm leading-relaxed text-ink-2`,children:n?s?`ForgeQE's ${s.title} template, filled from this project. Read every setting and change what does not fit: it is saved as a draft, and runs once a person has tried and approved it.`:`An agent for one job your team repeats. It uses ForgeQE's own agents, tools, skills and knowledge, and is held to the environments and actions you pick here, on every call. It runs once a person has tried and approved it.`:`Saving changes its manifest only. The approved version keeps running until this change is approved on its page.`}),p&&(0,X.jsx)(`p`,{role:`alert`,className:L(H.fail,`m-0`),children:p}),s&&l&&(0,X.jsx)(J,{id:`ca-template`,icon:ce,title:(0,X.jsxs)(X.Fragment,{children:[`From the `,s.title,` template`]}),level:3,className:`mb-2`,children:(0,X.jsxs)(`ul`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:[s.systems.length>0&&(0,X.jsxs)(`li`,{className:`flex flex-col gap-1 rounded-base bg-surface-muted px-4 py-4 text-body-sm`,children:[(0,X.jsxs)(`span`,{className:`font-medium text-ink`,children:[`It uses the tools of `,s.systems.map(e=>gr(l?.systems.find(t=>t.name===e)?.label||e)).join(`, `)]}),(0,X.jsx)(`span`,{className:`text-body-sm text-ink-2`,children:`Through ForgeQE, which checks every call against what this agent may do. Change them under Systems it works with.`})]}),s.notes.map(e=>(0,X.jsx)(`li`,{className:`flex flex-col gap-1 rounded-base bg-surface-muted px-4 py-4 text-body-sm`,children:(0,X.jsx)(`span`,{className:`font-medium text-ink`,children:e})},e))]})}),n&&!t&&(0,X.jsx)(`p`,{className:`m-0 mb-2 text-body-sm`,children:(0,X.jsx)(`a`,{href:M(`agents`,`custom`,`new`),children:`Or say what it should do, and let ForgeQE build it with you`})}),b&&(0,X.jsxs)(X.Fragment,{children:[b.problems.length>0&&(0,X.jsxs)(`div`,{className:L(H.fail,`flex flex-col gap-1`),children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Its manifest needs fixing before it can be edited here:`}),(0,X.jsx)(`ul`,{className:`m-0 list-disc pl-6 [overflow-wrap:anywhere]`,children:b.problems.map((e,t)=>(0,X.jsx)(`li`,{children:e},t))})]}),(0,X.jsx)(Ln,{text:b.text,file:b.file})]}),!i||!l?!p&&(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Loading…`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(K,{first:!0,icon:k,children:`What it is`}),(0,X.jsx)(q,{label:`Name`,help:`What it does, then “agent”: Checkout guard agent.`,htmlFor:`ca-name`,children:(0,X.jsx)(F,{id:`ca-name`,value:i.name,maxLength:60,onChange:e=>j({name:e.target.value,...n&&!re?{id:ir(e.target.value)}:{}})})}),(0,X.jsx)(q,{label:`Id`,help:n?`Its file name and address: lower-case words and hyphens. It cannot change later.`:`It cannot change. Make a new agent for another id.`,htmlFor:`ca-id`,children:(0,X.jsx)(F,{id:`ca-id`,value:i.id,maxLength:40,disabled:!n,spellCheck:!1,onChange:e=>(oe(!0),j({id:e.target.value.toLowerCase()}))})}),(0,X.jsx)(q,{label:`Version`,help:`${v?`${v} is approved and runs now. `:``}Raise it for each change you approve: 1.0.0, then 1.1.0. A change saved under a version already approved is raised to the next free one, so each version names one set of settings.`,htmlFor:`ca-version`,children:(0,X.jsx)(F,{id:`ca-version`,value:i.version,maxLength:14,onChange:e=>j({version:e.target.value})})}),(0,X.jsx)(q,{label:`Description`,help:`One line: what it is for. Atlas reads it to know when to hand it work.`,htmlFor:`ca-desc`,stacked:!0,children:(0,X.jsx)(F,{id:`ca-desc`,value:i.description,maxLength:300,onChange:e=>j({description:e.target.value})})}),(0,X.jsx)(q,{label:`Icon`,help:`What it wears on the Agents page and its own page: its mascot, or one of ForgeQE's agent icons.`,htmlFor:`ca-icon`,stacked:!0,children:(0,X.jsx)(vn,{id:`ca-icon`,value:i.icon,onChange:e=>j({icon:e})})}),(0,X.jsx)(q,{label:`Voice`,help:`How it sounds when you talk with it. Default is ForgeQE's own voice; ForgeQE picks each from the speech set up on that computer.`,children:(0,X.jsx)(Ct,{label:`Voice`,value:i.voice?.sound??``,onChange:e=>he(e),options:[{id:``,label:`Default`},...$n.map(e=>({id:e,label:e[0].toUpperCase()+e.slice(1)}))]})}),(0,X.jsx)(q,{label:`Instructions`,help:`Its focus and how to work, in plain words. Guidance for the model: the limits below are what holds it.`,htmlFor:`ca-instr`,stacked:!0,children:(0,X.jsx)(Fe,{id:`ca-instr`,rows:5,value:i.instructions,maxLength:8e3,onChange:e=>j({instructions:e.target.value})})}),(0,X.jsx)(K,{help:`Where its runs, tests and calls may go. In an environment named like production, reads go ahead, runs are asked unless you say otherwise, and every change is approved by a person.`,icon:xe,children:`Where it works`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 py-4`,children:[l.environments.length===0&&(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`No environments in env.yaml yet. Add them in Settings, Environments.`}),l.environments.map(e=>(0,X.jsx)(Q,{checked:i.scope.environments.includes(e.name),onChange:t=>me({environments:Z(i.scope.environments,e.name,t)}),help:e.production?`Production: reads go ahead; a person approves every change there.`:void 0,children:e.name},e.name))]}),(0,X.jsx)(K,{help:`ForgeQE's capabilities it may use: their tools, and only theirs. Each says whether it is set up here.`,icon:o,children:`What it can do`}),(0,X.jsx)(`div`,{className:`flex flex-col gap-4 py-4`,children:Se.map(([e,t])=>{let n=t.filter(e=>i.scope.capabilities.includes(e.id)).length;return(0,X.jsxs)(`details`,{open:n>0||void 0,className:L(W,`group`),children:[(0,X.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 py-1 text-body-sm font-medium`,children:[(0,X.jsx)(f,{size:14,"aria-hidden":`true`,className:`flex-none text-muted transition-transform duration-200 group-open:rotate-90`}),(0,X.jsx)(`span`,{className:`flex-1`,children:e}),(0,X.jsx)(`span`,{className:`text-body-sm font-normal text-muted tabular-nums`,children:n?`${n} of ${t.length} picked`:`${t.length}`})]}),(0,X.jsx)(`div`,{className:`flex flex-col gap-2 pt-2 pb-1 pl-6`,children:t.map(e=>{let t=mr[e.state];return(0,X.jsxs)(Y.Fragment,{children:[(0,X.jsx)(Q,{checked:i.scope.capabilities.includes(e.id),onChange:t=>me({capabilities:Z(i.scope.capabilities,e.id,t)}),help:(0,X.jsxs)(`span`,{className:`flex items-start gap-2`,children:[(0,X.jsx)(lt,{icon:t.icon,size:13,className:L(`mt-1 flex-none`,t.cls)}),(0,X.jsxs)(`span`,{children:[t.label,e.gaps.length?`: ${e.gaps.join(`; `)}`:``]})]}),children:(0,X.jsx)(`span`,{"data-tip":e.summary,children:e.title})}),i.scope.capabilities.includes(e.id)&&((e.usable||[]).length>1||(e.usable||[]).some(e=>(i.permissions.deny||[]).includes(e.name)))&&(0,X.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 border-0 p-0 pl-6`,children:[(0,X.jsxs)(`legend`,{className:`sr-only`,children:[`Tools of `,e.title,` it uses`]}),(e.usable||[]).map(t=>(0,X.jsx)(Q,{checked:!(i.permissions.deny||[]).includes(t.name),disabled:!(i.permissions.deny||[]).includes(t.name)&&(e.usable||[]).filter(e=>!(i.permissions.deny||[]).includes(e.name)).length===1,onChange:e=>ge({deny:Z(i.permissions.deny||[],t.name,!e)}),help:(dr[t.action]||t.action)+(!(i.permissions.deny||[]).includes(t.name)&&(e.usable||[]).filter(e=>!(i.permissions.deny||[]).includes(e.name)).length===1?`. Its last tool: untick the capability instead.`:``),children:(0,X.jsx)(`span`,{className:`font-mono text-body-sm`,children:t.name})},t.name))]})]},e.id)})})]},e)})}),(0,X.jsx)(K,{help:`ForgeQE's agents it may start: a capability that needs one (a browser run needs WebPilot) is refused without it.`,icon:Oe,children:`Agents it may use`}),(0,X.jsx)(`div`,{className:`flex flex-col gap-2 py-4`,children:l.agents.map(e=>(0,X.jsx)(Q,{checked:i.scope.agents.includes(e.name),onChange:t=>me({agents:Z(i.scope.agents,e.name,t)}),help:(0,X.jsx)(`span`,{className:`font-mono text-body-sm`,children:e.name}),children:e.title},e.name))}),(0,X.jsx)(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:g,children:`Custom agents it may hand work to`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 py-4`,children:[(l.customAgents||[]).filter(e=>e.id!==i.id).length===0&&(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`No other custom agents in this project yet.`}),(l.customAgents||[]).filter(e=>e.id!==i.id).map(e=>(0,X.jsx)(Q,{checked:(i.scope.customAgents||[]).includes(e.id),onChange:t=>me({customAgents:Z(i.scope.customAgents||[],e.id,t)}),help:(0,X.jsxs)(`span`,{className:`font-mono text-body-sm`,children:[e.id,e.approved?``:` · not approved yet: it is handed nothing until it is`]}),children:e.name},e.id))]}),(0,X.jsx)(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:Ae,children:`Systems it works with`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 py-4`,children:[l.systems.length===0&&(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`None set up yet. Add them in Settings, MCP servers.`}),l.systems.map(e=>(0,X.jsx)(Q,{checked:(i.scope.systems||[]).includes(e.name),onChange:t=>me({systems:Z(i.scope.systems||[],e.name,t)}),help:e.about.slice(0,160),children:gr(e.label)},e.name))]}),(0,X.jsx)(K,{help:`Only these are loaded for it.`,icon:ae,children:`Skills and knowledge`}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 py-4 sm:grid-cols-2`,children:[(0,X.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 border-0 p-0`,children:[(0,X.jsx)(`legend`,{className:`mb-1 p-0 text-body-sm font-medium text-muted`,children:`Skills`}),l.skills.length===0&&(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`None in this project yet.`}),l.skills.map(e=>(0,X.jsx)(Q,{checked:i.scope.skills.includes(e.name),onChange:t=>me({skills:Z(i.scope.skills,e.name,t)}),help:e.about,children:e.name},e.name))]}),(0,X.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 border-0 p-0`,children:[(0,X.jsx)(`legend`,{className:`mb-1 p-0 text-body-sm font-medium text-muted`,children:`Knowledge files`}),l.knowledge.length===0&&(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`None in .forgeqe/knowledge yet.`}),l.knowledge.map(e=>(0,X.jsx)(Q,{checked:i.scope.knowledge.includes(e.file),onChange:t=>me({knowledge:Z(i.scope.knowledge,e.file,t)}),help:e.title===e.file?void 0:e.title,children:e.file},e.file))]})]}),(0,X.jsx)(K,{help:`Enforced on every call. Ask first: a person approves each such call in the chat. In production, every call is asked.`,icon:ue,children:`What it may do`}),(0,X.jsx)(`div`,{className:`flex flex-col gap-2 py-4`,children:l.actions.map(e=>(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-6 gap-y-1`,children:[(0,X.jsx)(`div`,{className:`min-w-0 flex-[1_1_320px]`,children:(0,X.jsx)(Q,{checked:i.permissions.actions.includes(e),onChange:t=>ge({actions:Z(i.permissions.actions,e,t)}),help:ar[e]?.help,children:ar[e]?.label||e})}),(0,X.jsx)(Q,{checked:e===`external`?!(i.permissions.trust||[]).includes(`external`):i.permissions.approve.includes(e),disabled:!i.permissions.actions.includes(e),onChange:t=>ge(e===`external`?{trust:Z(i.permissions.trust||[],`external`,!t)}:{approve:Z(i.permissions.approve,e,t)}),children:`Ask first`})]},e))}),(0,X.jsx)(q,{label:`Repository`,help:`Whether it may change files in the repository (with Change files).`,children:(0,X.jsx)(Ct,{label:`Repository`,value:i.permissions.repository,onChange:e=>ge({repository:e}),options:[{id:`read`,label:`Read only`},{id:`write`,label:`May change files`}]})}),i.scope.environments.some(e=>l.environments.some(t=>t.name===e&&t.production))&&i.permissions.actions.includes(`run`)&&(0,X.jsx)(q,{label:`Production`,help:`Reads there go ahead without asking; every change there is approved by a person.`,children:(0,X.jsx)(Q,{checked:!(i.permissions.production||[]).includes(`run`),onChange:e=>ge({production:e?[]:[`run`]}),children:`Ask before each run`})}),i.permissions.repository===`write`&&(()=>{let e=(l.coding||[]).filter(e=>l.capabilities.some(t=>i.scope.capabilities.includes(t.id)&&t.tools.includes(e)));if(!e.length)return null;let t=e.every(e=>(i.permissions.trust||[]).includes(e));return(0,X.jsx)(q,{label:`Quill`,help:`The tests it runs can reach any address. Without asking, ForgeQE first looks in the test project's config and env files, and asks when they name an address outside its environments.`,children:(0,X.jsx)(Q,{checked:!t,onChange:t=>ge({trust:t?(i.permissions.trust||[]).filter(t=>!e.includes(t)):[...new Set([...i.permissions.trust||[],...e])]}),children:`Ask first`})})})(),(0,X.jsx)(q,{label:`Shell`,help:`Commands on this computer, and fetching web pages. A person approves each one; ForgeQE's secrets stay out of reach.`,children:(0,X.jsx)(Q,{checked:i.permissions.shell===!0,onChange:e=>ge({shell:e}),children:`Use the shell`})}),(0,X.jsx)(q,{label:`Hands work on`,help:`How many levels deep it may give part of a task to a helper.`,htmlFor:`ca-depth`,children:(0,X.jsxs)(P,{id:`ca-depth`,value:String(i.runtime.maxDelegationDepth),onChange:e=>j({runtime:{...i.runtime,maxDelegationDepth:Number(e.target.value)}}),className:`w-[200px]`,children:[(0,X.jsx)(`option`,{value:`0`,children:`Never`}),(0,X.jsx)(`option`,{value:`1`,children:`1 level`}),(0,X.jsx)(`option`,{value:`2`,children:`2 levels`}),(0,X.jsx)(`option`,{value:`3`,children:`3 levels`})]})}),(0,X.jsx)(q,{label:`Budget per run`,help:`The most model tokens one run may use; it stops there. Empty: no limit.`,htmlFor:`ca-budget`,children:(0,X.jsx)(F,{id:`ca-budget`,type:`number`,min:1e3,step:1e3,className:`w-[200px]`,value:i.runtime.maxTokens??``,placeholder:`No limit`,onChange:e=>{let{maxTokens:t,...n}=i.runtime;j({runtime:{...n,...e.target.value?{maxTokens:Math.max(0,Math.round(Number(e.target.value)))}:{}}})}})}),(0,X.jsx)(q,{label:`Time limit per run`,help:`In minutes (1 to 1440): the longest one run may take; it stops there. Empty: no limit when someone is watching, 120 minutes when nobody is (a schedule, a trigger, another agent).`,htmlFor:`ca-minutes`,children:(0,X.jsx)(F,{id:`ca-minutes`,type:`number`,min:1,max:1440,className:`w-[200px]`,value:i.runtime.maxMinutes??``,placeholder:`Minutes`,onChange:e=>{let{maxMinutes:t,...n}=i.runtime;j({runtime:{...n,...e.target.value?{maxMinutes:Math.max(1,Math.round(Number(e.target.value)))}:{}}})}})}),(0,X.jsx)(q,{label:`Model`,help:`The model profile of llms.json its runs use. ForgeQE's choice: the model ForgeQE's agent would use.`,htmlFor:`ca-model`,children:(0,X.jsxs)(P,{id:`ca-model`,value:i.runtime.model??``,className:`w-[200px]`,onChange:e=>{let{model:t,...n}=i.runtime;j({runtime:{...n,...e.target.value?{model:e.target.value}:{}}})},children:[(0,X.jsx)(`option`,{value:``,children:`ForgeQE's choice`}),(l.models||[]).map(e=>(0,X.jsxs)(`option`,{value:e.name,children:[e.name,` (`,e.model,`)`]},e.name)),i.runtime.model&&!(l.models||[]).some(e=>e.name===i.runtime.model)&&(0,X.jsxs)(`option`,{value:i.runtime.model,children:[i.runtime.model,` (not in llms.json)`]})]})}),(0,X.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:Ee,children:`Runs by itself`}),(0,X.jsx)(q,{label:`When`,children:(0,X.jsx)(Ct,{label:`When`,value:hr(i.schedule),onChange:_e,options:[{id:``,label:`Only when asked`},{id:`every`,label:`Every`},{id:`cron`,label:`On a cron schedule`}]})}),(0,X.jsx)(q,{label:`Tell the team`,help:`How a run with nobody watching (on its schedule, a trigger, or started with --unattended) ended, on the notification channels that take custom agents' runs (Settings, Notifications).`,htmlFor:`ca-notify`,children:(0,X.jsxs)(P,{id:`ca-notify`,value:i.runtime.notify??`failed`,className:`w-[200px]`,onChange:e=>{let{notify:t,...n}=i.runtime;j({runtime:{...n,...e.target.value===`failed`?{}:{notify:e.target.value}}})},children:[(0,X.jsx)(`option`,{value:`failed`,children:`When it does not finish`}),(0,X.jsx)(`option`,{value:`always`,children:`Each time it ends`}),(0,X.jsx)(`option`,{value:`never`,children:`Never`})]})}),(l.channels||[]).length>0&&(0,X.jsx)(q,{label:`Its notices go to`,help:`The notification channels its notices go to, each still only for the events it takes (Settings, Notifications). None ticked: every channel that takes them.`,children:(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:l.channels.map(e=>(0,X.jsx)(Q,{checked:(i.runtime.channels||[]).includes(e.name),onChange:t=>j({runtime:{...i.runtime,channels:Z(i.runtime.channels||[],e.name,t)}}),help:e.on.some(e=>e.startsWith(`agent_`))?void 0:`It takes no custom agent's events: tick them for it in Settings, Notifications.`,children:e.name},e.name))})}),i.schedule&&(0,X.jsxs)(X.Fragment,{children:[hr(i.schedule)===`every`?(0,X.jsx)(q,{label:`Every`,help:`15m, 1h, 1d.`,htmlFor:`ca-every`,children:(0,X.jsx)(F,{id:`ca-every`,value:i.schedule.every??``,placeholder:`30m`,spellCheck:!1,className:`max-w-[120px] font-mono`,onChange:e=>ve({every:e.target.value})})}):(0,X.jsx)(q,{label:`Cron`,help:`Five fields, this machine's time: 0 7 * * 1-5 is weekdays at 07:00.`,htmlFor:`ca-cron`,children:(0,X.jsx)(F,{id:`ca-cron`,value:i.schedule.cron??``,spellCheck:!1,className:`max-w-[180px] font-mono`,onChange:e=>ve({cron:e.target.value})})}),(0,X.jsx)(q,{label:`Request`,help:`What it is asked each time it runs by itself. {name} uses one of its inputs, filled with the value below.`,htmlFor:`ca-request`,stacked:!0,children:(0,X.jsx)(F,{id:`ca-request`,value:i.schedule.request,maxLength:500,placeholder:`Run the checkout pack on qa`,onChange:e=>ve({request:e.target.value})})}),Hn(i.schedule.request).map(e=>(i.inputs||[]).find(t=>t.name===e)).filter(e=>!!e).map(e=>(0,X.jsx)(q,{label:e.label||`{${e.name}}`,help:`The value of {${e.name}} when it runs by itself.`,htmlFor:`ca-with-${e.name}`,children:(0,X.jsx)(br,{id:`ca-with-${e.name}`,input:e,environments:i.scope.environments,value:i.schedule?.with?.[e.name]??``,onChange:t=>ve({with:{...i.schedule?.with||{},[e.name]:t}})})},e.name))]}),(0,X.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:je,children:`Starts when something happens`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[(i.triggers||[]).map((e,t)=>{let n=e=>j({triggers:(i.triggers||[]).map((n,r)=>r===t?{...n,...e}:n)});return(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(P,{"aria-label":`Trigger ${t+1} event`,className:`w-[200px]`,value:e.on,onChange:t=>{let r=t.target.value,i=cr.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:er.map(e=>(0,X.jsx)(`option`,{value:e,children:lr[e]},e))}),cr.includes(e.on)&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(P,{"aria-label":`Trigger ${t+1} host`,className:`w-[200px]`,value:e.source||`github`,onChange:e=>n({source:e.target.value}),children:[(0,X.jsx)(`option`,{value:`github`,children:`GitHub`}),(0,X.jsx)(`option`,{value:`azure_devops`,children:`Azure DevOps`})]}),(0,X.jsx)(F,{"aria-label":`Trigger ${t+1} repository`,className:`w-[200px] font-mono`,maxLength:201,spellCheck:!1,value:e.repo??``,placeholder:e.source===`azure_devops`?`project/repository`:`owner/name`,onChange:e=>n({repo:e.target.value||void 0})}),(0,X.jsx)(F,{"aria-label":`Trigger ${t+1}: which branch, empty for any`,className:`w-[140px] font-mono`,maxLength:200,spellCheck:!1,value:e.branch??``,placeholder:e.on===`push`?`any branch`:`any target`,onChange:e=>n({branch:e.target.value||void 0})})]}),e.on.startsWith(`job_`)&&(0,X.jsx)(F,{"aria-label":`Trigger ${t+1}: which schedule, empty for any`,className:`w-[140px] font-mono`,maxLength:40,spellCheck:!1,value:e.job??``,placeholder:`any schedule`,onChange:e=>n({job:e.target.value||void 0})}),(0,X.jsx)(F,{"aria-label":`Trigger ${t+1} request`,className:`min-w-0 flex-[1_1_280px]`,maxLength:500,value:e.request,placeholder:`What it is asked then (no {name}: nobody gives a value)`,onChange:e=>n({request:e.target.value})}),(0,X.jsx)(U,{variant:`icon`,size:`icon`,"aria-label":`Remove trigger ${t+1}`,"data-tip":`Remove trigger ${t+1}`,onClick:()=>{let e=(i.triggers||[]).filter((e,n)=>n!==t);j({triggers:e,...!e.length&&!i.schedule?{permissions:{...i.permissions,unattended:[]}}:{}})},children:(0,X.jsx)(De,{"aria-hidden":`true`})})]},t)}),(i.triggers||[]).length<4&&(0,X.jsxs)(U,{size:`sm`,className:`self-start`,onClick:()=>j({triggers:[...i.triggers||[],{on:`suite_failed`,request:``}]}),"data-tip":`Add a trigger`,children:[(0,X.jsx)(E,{"aria-hidden":`true`}),`Add`]})]}),(i.schedule||(i.triggers||[]).length>0)&&(0,X.jsxs)(X.Fragment,{children:[(0,X.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:ue,children:`What it may do alone`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 py-4`,children:[_r(i,l.systems,de(i)).length===0&&(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`Only reading: allow more under What it may do, or pick Systems it works with, first.`}),_r(i,l.systems,de(i)).map(e=>(0,X.jsx)(Q,{checked:e.ids.every(e=>(i.permissions.unattended||[]).includes(e)),onChange:t=>ge({unattended:t?[...new Set([...i.permissions.unattended||[],...e.ids])]:(i.permissions.unattended||[]).filter(t=>!e.ids.includes(t))}),children:e.label},e.key))]})]}),(0,X.jsx)(K,{help:`One per line: what it should keep in mind. Guidance for the model, never a limit.`,icon:A,children:`Guidance`}),(0,X.jsx)(Fe,{"aria-label":`Guidance, one per line`,rows:3,value:i.policies.join(`
3
- `),onChange:e=>j({policies:e.target.value.split(`
4
- `).map(e=>e.slice(0,300))})}),(0,X.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:h,children:`Inputs`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[(i.inputs||[]).map((e,t)=>{let n=e=>j({inputs:(i.inputs||[]).map((n,r)=>r===t?{...n,...e}:n)});return(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(F,{"aria-label":`Input ${t+1} name`,className:`w-[140px] font-mono`,maxLength:32,spellCheck:!1,value:e.name,placeholder:`name`,onChange:e=>n({name:e.target.value.toLowerCase()})}),(0,X.jsx)(F,{"aria-label":`Input ${t+1} label`,className:`w-[200px]`,maxLength:40,value:e.label,placeholder:`Label`,onChange:e=>n({label:e.target.value})}),(0,X.jsx)(P,{"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:zn.map(e=>(0,X.jsx)(`option`,{value:e,children:ur[e]},e))}),e.kind===`choice`&&(0,X.jsx)(yr,{label:`Input ${t+1} options, separated by commas`,options:e.options||[],onChange:e=>n({options:e})}),(0,X.jsx)(U,{variant:`icon`,size:`icon`,"aria-label":`Remove input ${t+1}`,"data-tip":`Remove input ${t+1}`,onClick:()=>j({inputs:(i.inputs||[]).filter((e,n)=>n!==t)}),children:(0,X.jsx)(De,{"aria-hidden":`true`})})]},t)}),(i.inputs||[]).length<6&&(0,X.jsxs)(U,{size:`sm`,className:`self-start`,onClick:()=>j({inputs:[...i.inputs||[],{name:``,label:``,kind:`text`}]}),"data-tip":`Add an input`,children:[(0,X.jsx)(E,{"aria-hidden":`true`}),`Add`]})]}),(0,X.jsx)(K,{help:`Requests its page offers to start from (at most ${or}). {name} uses one of its inputs.`,icon:ke,children:`Starters`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[i.starters.map((e,t)=>(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(F,{"aria-label":`Starter ${t+1} label`,className:`w-[200px]`,maxLength:40,value:e.label,placeholder:`Label`,onChange:e=>j({starters:i.starters.map((n,r)=>r===t?{...n,label:e.target.value}:n)})}),(0,X.jsx)(F,{"aria-label":`Starter ${t+1} request`,className:`min-w-0 flex-[1_1_280px]`,maxLength:500,value:e.text,placeholder:`The request`,onChange:e=>j({starters:i.starters.map((n,r)=>r===t?{...n,text:e.target.value}:n)})}),(0,X.jsx)(U,{variant:`icon`,size:`icon`,"aria-label":`Remove starter ${t+1}`,"data-tip":`Remove starter ${t+1}`,onClick:()=>j({starters:i.starters.filter((e,n)=>n!==t)}),children:(0,X.jsx)(De,{"aria-hidden":`true`})})]},t)),i.starters.length<or&&(0,X.jsxs)(U,{size:`sm`,className:`self-start`,onClick:()=>j({starters:[...i.starters,{label:``,text:``}]}),"data-tip":`Add a starter`,children:[(0,X.jsx)(E,{"aria-hidden":`true`}),`Add`]})]}),(0,X.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:S,children:`Memory`}),(0,X.jsx)(q,{label:`Notes it keeps`,htmlFor:`ca-notes`,help:`At most 200; past that the oldest go. None: it starts every run knowing only its manifest.`,children:(0,X.jsxs)(P,{id:`ca-notes`,className:`w-[200px]`,value:String(i.memory?.notes||0),onChange:e=>j({memory:Number(e.target.value)?{notes:Number(e.target.value)}:void 0}),children:[(0,X.jsx)(`option`,{value:`0`,children:`No memory`}),[20,50,100,200].map(e=>(0,X.jsxs)(`option`,{value:e,children:[`Up to `,e,` notes`]},e)),i.memory&&![20,50,100,200].includes(i.memory.notes)&&(0,X.jsxs)(`option`,{value:i.memory.notes,children:[`Up to `,i.memory.notes,` notes`]})]})}),(0,X.jsx)(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:d,children:`Approval`}),(0,X.jsx)(q,{label:`People who approve`,htmlFor:`ca-people`,help:`How many different people approve a version. Each but the last signs it; it runs once the last approves.`,children:(0,X.jsx)(P,{id:`ca-people`,className:`w-[200px]`,value:String(i.approval?.people||1),onChange:e=>j({approval:{people:Number(e.target.value),owners:i.approval?.owners||[]}}),children:[1,2,3].map(e=>(0,X.jsx)(`option`,{value:e,children:e===1?`One person`:`${e} different people`},e))})}),(0,X.jsx)(q,{label:`Who may approve`,htmlFor:`ca-owners`,help:`People's names as git knows them (user.name, or user.email). None: anyone who can approve agents in this project.`,children:(0,X.jsx)(yr,{id:`ca-owners`,label:`Who may approve, separated by commas`,placeholder:`Ann Lee, Bo Chen`,max:20,options:i.approval?.owners||[],onChange:e=>j({approval:{people:i.approval?.people||1,owners:e}})})}),(0,X.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:ie,children:`Checks`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-4 py-2`,children:[(i.checks||[]).map((e,t)=>{let n=e=>j({checks:(i.checks||[]).map((n,r)=>r===t?{...n,...e}:n)}),r=t=>n({expect:{...e.expect,...t}});return(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(F,{"aria-label":`Check ${t+1} name`,className:`w-[200px] font-mono`,maxLength:40,spellCheck:!1,value:e.name,placeholder:`basket-total`,onChange:e=>n({name:e.target.value.toLowerCase()})}),(0,X.jsx)(F,{"aria-label":`Check ${t+1} request`,className:`min-w-0 flex-[1_1_280px]`,maxLength:500,value:e.request,placeholder:`The request it is tried on`,onChange:e=>n({request:e.target.value})}),(0,X.jsx)(U,{variant:`icon`,size:`icon`,"aria-label":`Remove check ${t+1}`,"data-tip":`Remove check ${t+1}`,onClick:()=>j({checks:(i.checks||[]).filter((e,n)=>n!==t)}),children:(0,X.jsx)(De,{"aria-hidden":`true`})})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pl-6`,children:[(0,X.jsxs)(P,{"aria-label":`Check ${t+1} ends`,className:`w-[200px]`,value:e.expect.outcome,onChange:e=>r({outcome:e.target.value}),children:[(0,X.jsx)(`option`,{value:`done`,children:`Ends done`}),(0,X.jsx)(`option`,{value:`needs_input`,children:`Ends needing a person`}),(0,X.jsx)(`option`,{value:`failed`,children:`Ends failed`})]}),(0,X.jsx)(yr,{label:`Check ${t+1}: words its reply says, separated by commas`,placeholder:`Its reply says…`,max:16,options:e.expect.says,onChange:e=>r({says:e})}),(0,X.jsx)(yr,{label:`Check ${t+1}: words its reply never says, separated by commas`,placeholder:`…and never says`,max:16,options:e.expect.neverSays,onChange:e=>r({neverSays:e})}),(0,X.jsx)(yr,{label:`Check ${t+1}: tools it uses, separated by commas`,placeholder:`Tools it uses`,max:16,mono:!0,options:e.expect.uses,onChange:e=>r({uses:e})}),(0,X.jsx)(yr,{label:`Check ${t+1}: tools it never calls, separated by commas`,placeholder:`Tools it never calls`,max:16,mono:!0,options:e.expect.neverUses,onChange:e=>r({neverUses:e})}),(i.output?.verdicts.length||0)>0&&(0,X.jsxs)(P,{"aria-label":`Check ${t+1} verdict`,className:`w-[200px]`,value:e.expect.verdict||``,onChange:e=>r({verdict:e.target.value||void 0}),children:[(0,X.jsx)(`option`,{value:``,children:`Any verdict`}),i.output.verdicts.map(e=>(0,X.jsxs)(`option`,{value:e,children:[`Verdict `,e]},e))]})]})]},t)}),(i.checks||[]).length<8&&(0,X.jsxs)(U,{size:`sm`,className:`self-start`,onClick:()=>j({checks:[...i.checks||[],{name:``,request:``,expect:{outcome:`done`,says:[],neverSays:[],uses:[],neverUses:[]}}]}),"data-tip":`Add a check`,children:[(0,X.jsx)(E,{"aria-hidden":`true`}),`Add`]})]}),(0,X.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:pe,children:`Output`}),(0,X.jsx)(q,{label:`Verdicts`,htmlFor:`ca-verdicts`,help:`Words for how a run came out, such as passed, failed, blocked. Lower-case letters, digits and underscores.`,children:(0,X.jsx)(yr,{id:`ca-verdicts`,label:`Verdicts, separated by commas`,placeholder:`passed, failed, blocked`,max:8,mono:!0,options:i.output?.verdicts||[],onChange:e=>j({output:{verdicts:e,failOn:(i.output?.failOn||[]).filter(t=>e.includes(t)),fields:i.output?.fields||[]}})})}),(i.output?.verdicts.length||0)>0&&(0,X.jsx)(q,{label:`Counts as a failure`,help:`A run with one of these verdicts, or with none, tells the team as a failure. Its checks still grade what they expect.`,children:(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:i.output.verdicts.map(e=>(0,X.jsx)(Q,{checked:i.output.failOn.includes(e),onChange:t=>j({output:{...i.output,failOn:Z(i.output.failOn,e,t)}}),children:e},e))})}),(0,X.jsx)(q,{label:`Fields`,stacked:!0,help:`Named values its reply reports, each of a kind. Leave a field out of the reply when it could not be found out.`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(i.output?.fields||[]).map((e,t)=>{let n=i.output||{verdicts:[],failOn:[],fields:[]},r=e=>j({output:{...n,fields:n.fields.map((n,r)=>r===t?{...n,...e}:n)}});return(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(F,{"aria-label":`Field ${t+1} name`,className:`w-[200px] font-mono`,maxLength:40,spellCheck:!1,value:e.name,placeholder:`defects_found`,onChange:e=>r({name:e.target.value.toLowerCase()})}),(0,X.jsx)(P,{"aria-label":`Field ${t+1} kind`,className:`w-[200px]`,value:e.kind,onChange:e=>r({kind:e.target.value}),children:nr.map(e=>(0,X.jsx)(`option`,{value:e,children:sr[e]},e))}),(0,X.jsx)(U,{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,X.jsx)(De,{"aria-hidden":`true`})})]},t)}),(i.output?.fields.length||0)<12&&(0,X.jsxs)(U,{size:`sm`,className:`self-start`,onClick:()=>j({output:{verdicts:i.output?.verdicts||[],failOn:i.output?.failOn||[],fields:[...i.output?.fields||[],{name:``,kind:`text`}]}}),"data-tip":`Add a field`,children:[(0,X.jsx)(E,{"aria-hidden":`true`}),`Add`]})]})}),T.length>0&&(0,X.jsx)(J,{id:`ca-advice`,icon:r,title:`What it still needs`,level:3,className:`mt-6`,children:(0,X.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:T.map((e,t)=>(0,X.jsxs)(`li`,{className:L(`flex flex-col gap-1 rounded-base px-4 py-4 text-body-sm`,e.blocking?`bg-warn-soft`:`bg-surface-muted`),children:[(0,X.jsx)(`span`,{className:L(`font-medium`,e.blocking?`text-warn`:`text-ink`),children:e.about}),(0,X.jsx)(`span`,{className:`text-body-sm text-ink-2`,children:e.why}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:e.fix})]},t))})}),(0,X.jsxs)(`div`,{className:`sticky bottom-0 mt-4 flex flex-wrap items-center gap-4 border-t border-line-soft bg-canvas py-4`,children:[(0,X.jsx)(`div`,{role:`status`,className:`min-w-0 flex-[1_1_320px] text-body-sm`,children:ee?(0,X.jsx)(`span`,{className:`text-muted`,children:`Checking…`}):N.length?(0,X.jsxs)(`ul`,{className:`m-0 list-disc pl-6 text-fail [overflow-wrap:anywhere]`,children:[N.slice(0,4).map((e,t)=>(0,X.jsx)(`li`,{children:e},t)),N.length>4&&(0,X.jsxs)(`li`,{children:[`and `,N.length-4,` more`]})]}):(0,X.jsx)(`span`,{className:`text-pass`,children:`Ready to save. It can be tried once saved.`})}),(0,X.jsx)(`a`,{href:we,className:`text-body-sm`,children:`Cancel`}),(0,X.jsxs)(U,{variant:`primary`,disabled:te||!i.id||!i.name||be.length>0,onClick:()=>void Ce(),"data-tip":n?`Save the agent`:`Save changes`,children:[(0,X.jsx)(_,{"aria-hidden":`true`}),`Save`]})]})]})]})]})}function Sr({id:e}){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(!1),s=(0,Y.useCallback)(()=>{z.view(e).then(e=>{$e([{id:e.id,icon:e.icon}]),n(e),i(``)},e=>i(e.message))},[e]);(0,Y.useEffect)(()=>s(),[s]);let[c,l]=(0,Y.useState)(null);return et.test(e)?(0,X.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[t?(0,X.jsx)(Tr,{view:t,detailsOpen:a,onDetails:o}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`header`,{className:`flex items-center gap-1 px-6 py-4 short:py-2`,children:[(0,X.jsx)(Ot,{}),(0,X.jsx)(dt,{to:{href:M(`agents`,`category`,`custom`),label:`Custom agents`},className:`self-center`})]}),(0,X.jsx)(`main`,{className:`flex flex-auto flex-col items-center justify-center px-6 py-10`,children:r?(0,X.jsx)(`p`,{role:`alert`,className:L(H.fail,`m-0`),children:r}):(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Loading…`})})]}),t&&c&&(0,X.jsx)(Kr,{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,X.jsx)(Mr,{view:t,open:a,onClose:()=>o(!1),onAct:l,onReload:s})]}):(0,X.jsx)(Cr,{})}function Cr(){return(0,X.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,X.jsx)(`header`,{className:`flex items-center gap-1 px-6 py-4`,children:(0,X.jsx)(Ot,{})}),(0,X.jsxs)(`p`,{className:`m-0 px-6 py-10 text-body-sm text-muted`,children:[`There is no such agent. `,(0,X.jsx)(`a`,{href:M(`agents`),children:`See every agent`}),`.`]})]})}var wr=e=>e.length?e.join(`, `):`none`;function Tr({view:e,detailsOpen:t,onDetails:n}){let i=Zt(),a=[...e.problems.working,...e.problems.active,...e.problems.other],o=e.state===`active`||e.state===`changed`,s=!!e.working,l=Yt[e.state],[u,d]=(0,Y.useState)(e.starters[0]&&!Hn(e.starters[0].text).length?e.starters[0].text:``),[f,p]=(0,Y.useState)(null),[h,g]=(0,Y.useState)({}),_=(e.active||e.working)?.environments||[];(0,Y.useEffect)(()=>p(null),[e.active?.digest,e.working?.digest]);let[v,y]=(0,Y.useState)(``),[b,S]=(0,Y.useState)(``),[C,w]=(0,Y.useState)(!0),[T,E]=(0,Y.useState)(!1),[D,ee]=(0,Y.useState)(!1),O=It(),{setup:te}=O,k=`custom-agent-${e.id}`,A=dn(u,e=>{d(e),y(``)},k,{code:O.tools.code}),ne=ln(`custom-${e.id}`,e=>{d(e),on(k)}),re=async()=>{S(``);try{let t=await z.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),S(`Zip downloaded. A teammate imports it as a draft, then edits and approves it.`)}catch(e){w(!1),S(e.message)}},ie=async()=>{if(!T){E(!0),S(``);try{let t=await z.duplicate(e.id);location.hash=M(`agents`,`custom`,t.id,`edit`)}catch(e){w(!1),S(e.message),E(!1)}}},ae=async(t,n=u)=>{if(!(D||!n.trim()&&!A.hasFiles)&&(t||o)&&(!t||s)){ee(!0),y(``);try{let r=await A.wrap(n.trim());if(!r.trim()){ee(!1);return}let{id:i}=await Re.start(r,{...O.choice,agent:e.id,...t||!o?{try:!0}:{}});A.reset({keep:!0}),location.hash=M(`chats`,i)}catch(e){y(e.message),ee(!1)}}},oe=!o&&!s,j=(o?e.active:e.working)?.model;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`header`,{className:`flex items-center gap-1 px-6 py-4 short:py-2`,children:[(0,X.jsx)(Ot,{}),(0,X.jsx)(dt,{to:{href:M(`agents`,`category`,`custom`),label:`Custom agents`},className:`self-center`}),(0,X.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,children:[(0,X.jsx)(G,{tone:l.tone,children:l.label}),(0,X.jsx)(U,{variant:`icon`,size:`icon`,onClick:()=>void ie(),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,X.jsx)(se,{size:18,"aria-hidden":`true`})}),(0,X.jsx)(U,{variant:`icon`,size:`icon`,onClick:()=>void re(),"aria-label":`Export to share`,"data-tip":`Export to share`,children:(0,X.jsx)(be,{size:18,"aria-hidden":`true`})}),(0,X.jsx)(U,{variant:`icon`,size:`icon`,onClick:()=>n(!t),"aria-label":`Details`,"aria-pressed":t,"data-tip":`Details`,children:(0,X.jsx)(m,{size:18,"aria-hidden":`true`})}),(0,X.jsx)(`a`,{href:M(`agents`,`custom`,e.id,`edit`),className:L(st({variant:`icon`,size:`icon`}),`no-underline`),"aria-label":`Edit`,"data-tip":`Edit`,children:(0,X.jsx)(c,{size:18,"aria-hidden":`true`})})]})]}),(0,X.jsx)(`main`,{className:`flex flex-auto flex-col items-center justify-center px-6 pt-6 pb-30 short:pt-0 short:pb-8`,children:(0,X.jsxs)(`div`,{className:`flex w-full max-w-[780px] flex-col items-center gap-10 short:gap-6`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col items-center gap-4 text-center short:gap-2`,children:[(0,X.jsx)(Ke,{agent:e.id,icon:e.icon,px:i?64:96,decorative:!0,working:D,className:`mb-1`}),(0,X.jsx)(`h1`,{className:`m-0 text-headline-lg text-ink [overflow-wrap:anywhere]`,children:e.name}),(0,X.jsx)(`p`,{className:`m-0 text-body-lg leading-relaxed text-ink-2`,children:e.description||(o?`Ask ${V(e.name)}. It runs version ${e.approvedVersion}, within its limits.`:e.state===`drifted`?`${e.name} ${e.approvedVersion} does not run until a person approves it again: what it knows changed. A try runs its manifest as it is.`:s?`Try ${V(e.name)}. It has no approved version yet: a try runs its manifest as it is.`:`Fix ${V(e.name)}'s manifest before it can be tried or approved.`)})]}),b&&(0,X.jsx)(`p`,{role:`status`,className:L(`m-0 -mt-4 text-center text-body-sm`,C?`text-muted`:`text-fail`),children:b}),a.length>0&&(0,X.jsxs)(`div`,{role:`alert`,className:L(H.fail,`flex w-full flex-col gap-1 text-left`),children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.state===`invalid`?`Its manifest needs fixing before it can be tried or approved:`:`It cannot run as it is:`}),(0,X.jsx)(`ul`,{className:`m-0 list-disc pl-6 [overflow-wrap:anywhere]`,children:a.map((e,t)=>(0,X.jsx)(`li`,{children:e},t))})]}),e.manifestText!==void 0&&(0,X.jsx)(Ln,{text:e.manifestText,file:e.manifestFile||``}),e.state===`drifted`&&e.drift&&(0,X.jsxs)(`section`,{"aria-labelledby":`ca-drift`,role:`alert`,className:L(H.warn,`flex w-full flex-col gap-2 text-left`),children:[(0,X.jsx)(Rt,{id:`ca-drift`,icon:r,title:(0,X.jsxs)(X.Fragment,{children:[`What `,e.approvedVersion,` knows changed since it was approved`]}),level:3}),(0,X.jsx)(`ul`,{className:`m-0 list-disc pl-6 text-ink-2`,children:e.drift.map(e=>(0,X.jsx)(`li`,{children:e},e))}),(0,X.jsxs)(`p`,{className:`m-0 text-body-sm text-ink-2`,children:[`It does not run (for you, your team, Atlas, its schedule or another agent) until a person reads the change and approves it again`,e.working?` under Details, Versions`:`: its manifest was removed, so put it back first`,`.`,e.changes.length>0?` Its manifest was also changed since: that change is below, and approving takes it too.`:``]})]}),e.changes.length>0&&(0,X.jsx)(J,{id:`ca-changes`,icon:Te,title:(0,X.jsxs)(X.Fragment,{children:[`Changed since `,e.approvedVersion,` was approved`]}),description:(0,X.jsxs)(X.Fragment,{children:[e.state===`changed`?`The approved version keeps running until this change is approved.`:`Approving takes this change too.`,` Approve or discard it under Details, Versions.`]}),className:`w-full text-left`,children:(0,X.jsx)(Lt,{diff:e.changes})}),oe?(0,X.jsx)(`p`,{className:`m-0 text-center text-body-sm text-muted`,children:e.manifestText===void 0?`See what is wrong above, or Edit the agent.`:`Fix what is listed above in its file, then come back.`}):(0,X.jsxs)(X.Fragment,{children:[te&&!te.ready&&(0,X.jsx)(Ht,{project:te.project}),te?.ready&&(0,X.jsx)(Gt,{c:O}),(0,X.jsx)(Xt,{id:k,label:`Message ${V(e.name)}`,value:u,onChange:e=>{d(e),y(``)},onSend:()=>void ae(!o),disabled:D||!!te&&!te.ready||ne.running,canSend:!!u.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 ${V(e.name)} to…`,top:(0,X.jsxs)(X.Fragment,{children:[A.chips,ne.state&&(0,X.jsx)(Jt,{state:ne.state,onStop:()=>void ne.stop(),onUndo:ne.undo,onClose:ne.close})]}),left:(0,X.jsxs)(X.Fragment,{children:[A.fileInput,(0,X.jsx)(Bt,{attach:{pick:A.pick},choice:O}),(0,X.jsx)(en,{running:ne.running,disabled:!u.trim()||D||!!te&&!te.ready,onClick:()=>void ne.start(u)})]}),right:j?(0,X.jsxs)(U,{variant:`ghost`,className:`max-w-[46vw] min-w-0 px-2 text-body-lg sm:px-2`,disabled:!0,"aria-label":`Model: ${j}, as its manifest says`,"data-tip":`It runs on ${j}, as its manifest says${o&&s&&e.working?.model!==j?`; a try runs on ${e.working?.model||`ForgeQE's choice`}`:``}`,children:[(0,X.jsx)(ye,{"aria-hidden":`true`,className:`size-4`}),(0,X.jsx)(`span`,{className:`hidden truncate sm:inline`,children:j})]}):(0,X.jsx)(Wt,{c:O})}),(0,X.jsx)(`p`,{role:`status`,"aria-live":`polite`,className:L(`-mt-6 m-0 text-center text-body-sm text-ink-2 short:-mt-4`,!(v||A.error)&&`sr-only`),children:(0,X.jsx)(`span`,{className:A.error&&!v?`text-fail`:``,children:v||A.error||``})}),f&&(0,X.jsx)(Er,{starter:f,inputs:e.inputs||[],environments:_,values:h,onChange:g,onUse:e=>{d(e),p(null),document.getElementById(k)?.focus()},onCancel:()=>{let t=e.starters.findIndex(e=>e.label===f.label);p(null),t>=0&&requestAnimationFrame(()=>document.getElementById(`${k}-starter-${t}`)?.focus())}},f.label),(0,X.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-4`,children:[e.starters.map((e,t)=>(0,X.jsx)(U,{id:`${k}-starter-${t}`,"aria-expanded":Hn(e.text).length?f?.label===e.label:void 0,onClick:()=>{y(``),Hn(e.text).length?(p(f?.label===e.label?null:e),g({})):(p(null),d(e.text),document.getElementById(k)?.focus())},children:e.label},e.label)),o&&s&&(0,X.jsxs)(U,{disabled:D||!u.trim(),onClick:()=>void ae(!0),"data-tip":`Try the manifest`,children:[(0,X.jsx)(x,{"aria-hidden":`true`}),`Try`]})]})]}),(0,X.jsx)(Or,{view:e})]})})]})}function Er({starter:e,inputs:t,environments:n,values:r,onChange:i,onUse:a,onCancel:o}){let s=Hn(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,Y.useState)(``),f=(0,Y.useId)();(0,Y.useEffect)(()=>{c[0]?document.getElementById(`starter-${c[0].name}`)?.focus():document.getElementById(f)?.focus()},[e.label]);let p=()=>{try{a(Wn(e.text,t,r,n))}catch(e){d(e.message)}};return(0,X.jsxs)(`form`,{"aria-label":`Values for ${e.label}`,className:L(W,`flex w-full flex-col gap-4 text-left`),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),o())},onSubmit:e=>{e.preventDefault(),p()},children:[(0,X.jsx)(`span`,{className:`text-body-sm font-medium`,children:e.label}),c.map(e=>(0,X.jsxs)(`label`,{htmlFor:`starter-${e.name}`,className:`flex flex-wrap items-center gap-x-4 gap-y-1 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`min-w-[140px] text-ink-2`,children:e.label}),(0,X.jsx)(br,{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,X.jsx)(`p`,{role:`alert`,className:`m-0 text-body-sm text-fail [overflow-wrap:anywhere]`,children:l.map(e=>`{${e}} is not one of its inputs, so this starter cannot be filled. Edit the agent.`).join(` `)}),u&&!l.length&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 text-body-sm text-fail [overflow-wrap:anywhere]`,children:u}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,X.jsx)(U,{type:`submit`,variant:`primary`,size:`sm`,children:`Use`}),(0,X.jsx)(U,{id:f,type:`button`,variant:`ghost`,size:`sm`,onClick:o,children:`Cancel`})]})]})}function Dr({view:e,onDone:t}){let n=e.memory?.kept||[],[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(``),d=(0,Y.useId)(),f=()=>{i(!1),o(``),setTimeout(()=>document.getElementById(d)?.focus(),0)},p=async n=>{c(!0),u(``);try{await z.forget(e.id,n),i(!1),o(``),t()}catch(e){u(e.message)}finally{c(!1)}};return(0,X.jsxs)(Nr,{id:`ca-memory`,icon:S,title:`Memory · ${n.length} of ${e.memory?.notes||n.length} notes`,aside:n.length>0&&!r?(0,X.jsxs)(U,{id:d,size:`sm`,variant:`danger`,onClick:()=>i(!0),children:[(0,X.jsx)(De,{"aria-hidden":`true`}),`Forget all`]}):void 0,children:[r&&(0,X.jsxs)(`div`,{className:L(H.warn,`flex flex-wrap items-end gap-2`),children:[(0,X.jsxs)(`label`,{className:`flex min-w-0 flex-[1_1_240px] flex-col gap-2`,children:[(0,X.jsxs)(`span`,{children:[`Type `,(0,X.jsx)(`span`,{className:`font-mono`,children:e.id}),` to forget all `,n.length,` notes`]}),(0,X.jsx)(F,{autoFocus:!0,value:a,onChange:e=>o(e.target.value),autoComplete:`off`,spellCheck:!1})]}),(0,X.jsx)(U,{variant:`ghost`,onClick:f,children:`Cancel`}),(0,X.jsx)(U,{variant:`destructive`,disabled:s||a!==e.id,onClick:()=>void p({all:!0,confirm:a}),children:`Forget all`})]}),l&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 text-body-sm text-fail [overflow-wrap:anywhere]`,children:l}),n.length===0?(0,X.jsxs)(ut,{className:`py-4`,children:[V(e.name,!0),` has noted nothing yet. It keeps short facts it finds, to recall in later runs.`]}):(0,X.jsx)(`ul`,{className:L(W,`m-0 flex list-none flex-col p-0`),children:n.map((e,t)=>(0,X.jsxs)(`li`,{className:L(`flex items-start gap-2 px-4 py-2 text-body-sm`,t>0&&`border-t border-line-soft`),children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 [overflow-wrap:anywhere]`,children:e.text}),(0,X.jsx)(`span`,{className:`flex-none text-muted tabular-nums`,children:Ft(e.at)}),(0,X.jsx)(U,{variant:`icon`,size:`icon`,disabled:s,"aria-label":`Forget note ${t+1}`,"data-tip":`Forget this note (cannot be undone)`,onClick:()=>void p({at:e.at,text:e.text}),children:(0,X.jsx)(De,{"aria-hidden":`true`})})]},`${e.at}-${t}`))})]})}function Or({view:e}){let t=e.capabilities,n=t.some(e=>e.state===`needs_setup`)?`needs_setup`:t.some(e=>e.state===`partial`)?`partial`:`ready`,i=n===`ready`?`pass`:n===`partial`?`warn`:`neutral`,a=n===`ready`?`Ready`:n===`partial`?`Partly set up`:`Needs setup`,o=t.filter(e=>e.state!==`ready`);return(0,X.jsxs)(`div`,{className:`flex w-full flex-col gap-6 pt-2 text-left`,children:[o.length>0&&(0,X.jsxs)(J,{id:`ca-needs`,icon:r,title:`What it needs`,actions:(0,X.jsx)(G,{tone:i,children:a}),children:[(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:n===`needs_setup`?`${V(e.name,!0)} cannot work until these are set up.`:`${V(e.name,!0)} works, without the parts below.`}),(0,X.jsx)(`ul`,{"aria-label":`What ${V(e.name)} needs`,className:L(`rounded-lg bg-bg p-6 shadow-sm`,`m-0 flex list-none flex-col p-0`),children:o.map((e,t)=>(0,X.jsxs)(`li`,{className:L(`flex items-center gap-4 px-4 py-2`,t>0&&`border-t border-line-soft`),children:[(0,X.jsx)(lt,{icon:jr[e.state].icon,size:16,className:L(`flex-none`,jr[e.state].cls)}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,X.jsx)(`span`,{className:`text-body-sm font-medium`,children:e.title}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted [overflow-wrap:anywhere]`,children:e.gaps.join(`; `)||jr[e.state].label})]})]},e.id))})]}),(0,X.jsx)(Vt,{scope:{kind:`custom`,id:e.id,name:e.name}}),t.length>0&&(0,X.jsx)(zt,{title:`What ${V(e.name)} can use`,children:(0,X.jsx)(`section`,{"aria-label":`What ${V(e.name)} can use`,className:`flex flex-col gap-2 pt-2`,children:(0,X.jsx)(`ul`,{className:L(`rounded-lg bg-bg p-6 shadow-sm`,`m-0 flex list-none flex-col p-0`),children:t.map((e,t)=>{let n=jr[e.state];return(0,X.jsxs)(`li`,{className:L(`flex items-start gap-4 px-4 py-2`,t>0&&`border-t border-line-soft`),children:[(0,X.jsx)(lt,{icon:n.icon,size:16,className:L(`mt-1 flex-none`,n.cls)}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,X.jsx)(`span`,{className:`text-body-sm font-medium`,children:e.title}),(0,X.jsxs)(`span`,{className:`text-body-sm text-muted`,children:[n.label,e.gaps.length?`: ${e.gaps.join(`; `)}`:``]})]})]},e.id)})})})})]})}var kr={approved:`Approved`,signed:`Signed`,disabled:`Disabled`,enabled:`Enabled`,"rolled-back":`Rolled back to`};function Ar(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 jr={ready:{icon:d,label:`Ready`,cls:`text-pass`},partial:{icon:b,label:`Partly set up`,cls:`text-warn`},needs_setup:{icon:a,label:`Needs setup`,cls:`text-muted`}};function Mr({view:e,open:t,onClose:n,onAct:r,onReload:i}){let a=e.active||e.working,o=!!e.working&&(e.state===`draft`||e.state===`changed`||e.state===`drifted`||e.state===`broken`&&e.working!==void 0);return(0,X.jsx)(kt,{open:t,onClose:n,wide:!0,title:`Details`,description:`${e.name} · ${e.id}`,footer:(0,X.jsxs)(U,{variant:`ghost`,onClick:n,children:[(0,X.jsx)(w,{"aria-hidden":`true`}),`Close`]}),children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[a&&(0,X.jsx)(Pr,{spec:a,view:e}),(e.checkResults||[]).length>0&&(0,X.jsx)(Rr,{view:e,onDone:i}),((e.memory?.notes||0)>0||(e.memory?.kept.length||0)>0)&&(0,X.jsx)(Dr,{view:e,onDone:i}),(0,X.jsx)(Fr,{view:e,approvable:o,onAct:r}),(0,X.jsx)(Wr,{view:e})]})})}function Nr({id:e,icon:t,title:n,children:r,aside:i}){return(0,X.jsx)(J,{id:e,icon:t,title:n,level:3,actions:i,children:r})}function Pr({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`?wr(e.agents.map(e=>t.agentNames[e]||e)):n.text]):[[`Environments`,wr(e.environments)],[`Agents it may start`,wr(e.agents.map(e=>t.agentNames[e]||e))],[`It may`,wr(e.actions.map(e=>Ir[e]||e))],[`A person approves first`,wr(e.approve.map(e=>Ir[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`,wr(e.skills)],[`Knowledge`,wr(e.knowledge)]];return(0,X.jsxs)(Nr,{id:`ca-reach`,icon:ue,title:t.active?`What version ${t.approvedVersion} may reach`:`What its manifest may reach`,children:[(0,X.jsx)(`dl`,{className:L(W,`m-0 grid grid-cols-1 gap-x-6 gap-y-2 text-body-sm sm:grid-cols-[160px_1fr]`),children:r.map(([e,t])=>(0,X.jsxs)(`div`,{className:`contents`,children:[(0,X.jsx)(`dt`,{className:`text-muted`,children:e}),(0,X.jsx)(`dd`,{className:`m-0 text-ink [overflow-wrap:anywhere]`,children:t})]},e))}),e.policies.length>0&&(0,X.jsxs)(`p`,{className:`m-0 text-body-sm text-muted`,children:[`Guidance it is given (not a limit): `,e.policies.join(`; `)]})]})}function Fr({view:e,approvable:t,onAct:n}){let[r,i]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(null),[c,l]=(0,Y.useState)(!1),f=async()=>{l(!0),s(null);try{let t=await z.library.publish(e.id);s({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){s({ok:!1,text:e.message})}finally{l(!1)}};return(0,X.jsxs)(X.Fragment,{children:[r&&(0,X.jsx)(Br,{view:e,at:r.ref,canGoBack:r.canGoBack,onClose:()=>i(null),onAct:n}),(0,X.jsxs)(Nr,{id:`ca-versions`,icon:ee,title:`Versions`,aside:(0,X.jsxs)(`span`,{className:`flex flex-wrap gap-2`,children:[t&&(e.approval?.signed.length||0)>0&&(0,X.jsxs)(`span`,{className:`self-center text-body-sm text-muted`,children:[`Signed by `,e.approval.signed.map(e=>e.by).join(`, `),`; needs `,e.approval.people-e.approval.signed.length,` more`]}),t&&(0,X.jsxs)(U,{size:`sm`,onClick:()=>n({action:`approve`}),"data-tip":`Approve ${e.manifestVersion}`,children:[(0,X.jsx)(d,{"aria-hidden":`true`}),`Approve`]}),e.changes.length>0&&(0,X.jsxs)(U,{size:`sm`,variant:`danger`,onClick:()=>n({action:`discard`}),"data-tip":`Back to ${e.approvedVersion}`,children:[(0,X.jsx)(v,{"aria-hidden":`true`}),`Discard the change`]}),e.approvedVersion&&(0,X.jsxs)(U,{size:`sm`,variant:`ghost`,onClick:()=>n({action:e.disabled?`enable`:`disable`}),children:[e.disabled?(0,X.jsx)(d,{"aria-hidden":`true`}):(0,X.jsx)(a,{"aria-hidden":`true`}),e.disabled?`Enable`:`Disable`]}),e.approvedVersion&&(0,X.jsxs)(U,{size:`sm`,variant:`ghost`,disabled:c,onClick:()=>void f(),"data-tip":`Publish ${e.approvedVersion} to your library`,children:[(0,X.jsx)(de,{"aria-hidden":`true`}),`Publish`]}),(0,X.jsxs)(U,{size:`sm`,variant:`danger`,onClick:()=>n({action:`delete`}),children:[(0,X.jsx)(De,{"aria-hidden":`true`}),`Delete`]})]}),children:[o&&(0,X.jsx)(`p`,{role:o.ok?`status`:`alert`,className:L(`m-0 rounded-base px-4 py-2 text-body-sm [overflow-wrap:anywhere]`,o.ok?`bg-pass-soft text-pass`:`bg-fail-soft text-fail`),children:o.text}),e.tried&&e.manifestVersion&&(0,X.jsxs)(`p`,{className:`m-0 text-body-sm text-muted`,children:[`Last try of manifest `,e.manifestVersion,`: `,e.tried.outcome,`.`]}),e.events.length===0?(0,X.jsx)(ut,{className:`py-4`,children:`No version has been approved yet. Try it, then approve it: only an approved version runs, for you, your team and Atlas.`}):(0,X.jsx)(`ul`,{className:L(W,`m-0 flex list-none flex-col`),children:e.events.toReversed().map((t,r)=>{let a=t.event===`approved`||t.event===`rolled-back`?t.version===e.approvedVersion:!1,o=t.event===`approved`&&t.version!==e.approvedVersion&&!e.events.slice(e.events.indexOf(t)+1).some(e=>e.event===`approved`&&e.version===t.version);return(0,X.jsxs)(`li`,{className:`flex min-h-11 flex-wrap items-center gap-4 rounded-sm px-4 py-2`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-body-sm font-medium`,children:[(0,X.jsxs)(`span`,{children:[kr[t.event],` `,t.version]}),a&&r===0?(0,X.jsx)(G,{tone:`pass`,children:`Running`}):null]}),(0,X.jsxs)(`span`,{className:`text-body-sm text-muted [overflow-wrap:anywhere]`,children:[Ar(t.by),` · `,Ft(t.at),t.note?` · ${t.note}`:``,t.tried?` · tried: ${t.tried.outcome}`:``]})]}),t.event===`approved`&&(0,X.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>i({ref:t.digest.slice(0,16),canGoBack:o}),"aria-label":`Read version ${t.version}`,"data-tip":`Read version ${t.version}`,children:(0,X.jsx)(oe,{"aria-hidden":`true`})}),o&&(0,X.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>n({action:`rollback`,to:t.version}),"aria-label":`Roll back to ${t.version}`,"data-tip":`Roll back to ${t.version}`,children:(0,X.jsx)(u,{"aria-hidden":`true`})})]},`${t.at}-${r}`)})})]})]})}var Ir={read:`read`,run:`run tests and apps`,change:`change files`,external:`change other systems`,schedule:`schedule work`},Lr={passed:{label:`Passed`,tone:`pass`},failed:{label:`Failed`,tone:`fail`},not_run:{label:`Not run on this version`,tone:`neutral`}};function Rr({view:e,onDone:t}){let[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(``),o=n&&n.target===e.id?n:null,s=!!n?.running,c=(0,Y.useRef)(null),l=(0,Y.useRef)(``),u=n=>{n&&n.target===e.id&&!n.running&&l.current!==n.startedAt&&(l.current=n.startedAt,t())},d=e=>{r(e),u(e)};(0,Y.useEffect)(()=>{z.checks.job().then(e=>d(e.job),e=>a(e.message))},[e.id]),(0,Y.useEffect)(()=>{if(!s)return;let e=yt(()=>{z.checks.job().then(e=>(a(``),d(e.job)),e=>a(e.message))},2e3);return()=>vt(e)},[s]),(0,Y.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,X.jsxs)(Nr,{id:`ca-checks`,icon:ie,title:`Checks`,aside:o?.running?(0,X.jsxs)(U,{size:`sm`,variant:`danger`,onClick:()=>f(z.checks.stop()),children:[(0,X.jsx)(Ce,{"aria-hidden":`true`}),`Stop`]}):(0,X.jsxs)(U,{size:`sm`,onClick:()=>f(z.checks.start(e.id)),disabled:s,"data-tip":`Try each check on ${e.manifestVersion}`,children:[(0,X.jsx)(x,{"aria-hidden":`true`}),`Run checks`]}),children:[s&&!o&&(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`Another agent's checks are running: Run checks waits for them to end.`}),(0,X.jsx)(`ul`,{className:L(W,`m-0 flex list-none flex-col p-0`),children:e.checkResults.map((e,t)=>(0,X.jsxs)(`li`,{className:L(`flex flex-col gap-1 px-4 py-2 text-body-sm`,t>0&&`border-t border-line-soft`),children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`font-mono text-body-sm`,children:e.name}),(0,X.jsx)(G,{tone:Lr[e.state].tone,children:Lr[e.state].label}),e.at&&(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:Ft(e.at)})]}),(0,X.jsx)(`span`,{className:`text-body-sm text-ink-2 [overflow-wrap:anywhere]`,children:e.request}),e.state===`failed`&&(e.reasons||[]).length>0&&(0,X.jsx)(`ul`,{className:`m-0 list-disc pl-6 text-body-sm text-fail [overflow-wrap:anywhere]`,children:e.reasons.map(e=>(0,X.jsx)(`li`,{children:e},e))})]},e.name))}),i&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 text-body-sm text-fail [overflow-wrap:anywhere]`,children:i}),o&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`details`,{open:o.running,children:[(0,X.jsxs)(`summary`,{className:`cursor-pointer text-body-sm text-muted`,children:[`Output (`,o.lines.length,` lines)`]}),(0,X.jsx)(`pre`,{ref:c,className:L(`overflow-auto rounded-base bg-surface-muted p-4 font-mono text-body-sm leading-relaxed whitespace-pre-wrap text-ink-2 [overflow-wrap:anywhere]`,`mt-2 max-h-[300px]`),children:(0,X.jsx)(pt,{text:o.lines.join(`
5
- `)||`Starting…`})})]}),o.running&&o.question&&(0,X.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 border-0 p-0`,children:[(0,X.jsx)(`legend`,{className:`mb-1 text-body-sm font-medium`,children:o.question.title}),o.question.detail&&(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:o.question.detail}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:o.question.options.map(e=>(0,X.jsx)(U,{size:`sm`,variant:e.id===`deny`||e.id===`stop`?`outline`:`primary`,onClick:()=>f(z.checks.answer(o.question.id,e.id)),children:e.label},e.id))})]})]})]})}function zr({lines:e}){return(0,X.jsx)(`dl`,{className:L(W,`m-0 grid grid-cols-1 gap-x-6 gap-y-2 text-body-sm sm:grid-cols-[160px_1fr]`),children:e.map(e=>(0,X.jsxs)(`div`,{className:`contents`,children:[(0,X.jsxs)(`dt`,{className:L(e.mark===`same`?`text-muted`:`font-medium text-warn`),children:[e.label,e.mark!==`same`&&(0,X.jsxs)(`span`,{className:`sr-only`,children:[` (`,Vr[e.mark],`)`]})]}),(0,X.jsxs)(`dd`,{className:L(`m-0 [overflow-wrap:anywhere]`,e.mark===`removed`?`text-muted line-through`:`text-ink`),children:[e.mark!==`same`&&(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`mr-2 text-body-sm font-medium text-warn`,children:Vr[e.mark]}),e.text,e.before&&(0,X.jsxs)(`span`,{className:`block text-body-sm text-muted`,children:[`Was: `,e.before]})]})]},`${e.mark}-${e.label}`))})}function Br({view:e,at:t,canGoBack:n,onClose:r,onAct:i}){let[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(``);return(0,Y.useEffect)(()=>{z.version(e.id,t).then(o,e=>c(e.message))},[e.id,t]),(0,X.jsx)(kt,{open:!0,wide:!0,onClose:r,title:a?`Version ${a.version}`:`Version`,description:a?`Approved by ${Ar(a.by)} ${Ft(a.at)}${a.note?`: ${a.note}`:``}.${a.running?` It is the version that runs.`:``}`:void 0,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(U,{variant:`ghost`,onClick:r,children:[(0,X.jsx)(w,{"aria-hidden":`true`}),`Close`]}),n&&a&&!a.running&&(0,X.jsxs)(U,{variant:`primary`,onClick:()=>(r(),i({action:`rollback`,to:a.version})),children:[(0,X.jsx)(u,{"aria-hidden":`true`}),`Roll back to `,a.version]})]}),children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[s&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 text-body-sm text-fail [overflow-wrap:anywhere]`,children:s}),!a&&!s&&(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Loading…`}),a&&(0,X.jsxs)(X.Fragment,{children:[!a.running&&a.permissions.length>0&&(0,X.jsx)(J,{id:`ca-version-may`,icon:ue,title:(0,X.jsxs)(X.Fragment,{children:[`What it may do, against `,e.approvedVersion]}),level:3,children:(0,X.jsx)(zr,{lines:a.permissions})}),a.diff&&(0,X.jsx)(J,{id:`ca-version-diff`,icon:Te,title:(0,X.jsxs)(X.Fragment,{children:[`Its manifest against `,e.approvedVersion]}),level:3,children:(0,X.jsx)(Lt,{diff:a.diff})}),(0,X.jsx)(J,{id:`ca-version-source`,icon:O,title:`Its manifest as approved`,level:3,children:(0,X.jsx)(`pre`,{className:L(`rounded-lg bg-bg p-6 shadow-sm`,`m-0 max-h-[50vh] overflow-auto font-mono text-body-sm whitespace-pre-wrap [overflow-wrap:anywhere]`),children:a.source})})]})]})})}var Vr={new:`New`,changed:`Changed`,removed:`No longer`},Hr={run:`Asked`,try:`Tried`,orchestrator:`From Atlas`,schedule:`Nobody watching`,agent:`Handed on by another agent`,check:`A saved check`},Ur={usage:xt,money:bt};function Wr({view:e}){let[t,n]=(0,Y.useState)(``),i=async()=>{n(``);try{let t=await z.audit(e.id),n=URL.createObjectURL(new Blob([t],{type:`application/x-ndjson;charset=utf-8`})),r=document.createElement(`a`);r.href=n,r.download=`${e.id}-audit.jsonl`,r.click(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}catch(e){n(e.message)}};return(0,X.jsxs)(Nr,{id:`ca-runs`,icon:x,title:`Recent runs`,aside:(0,X.jsxs)(U,{size:`sm`,variant:`ghost`,onClick:()=>void i(),"data-tip":`Download its whole record, for audit`,children:[(0,X.jsx)(be,{"aria-hidden":`true`}),`Download`]}),children:[t&&(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-fail`,children:t}),e.runs.length===0?(0,X.jsxs)(ut,{className:`py-4`,children:[V(e.name,!0),` has not run yet.`]}):(0,X.jsx)(`ul`,{className:L(W,`m-0 flex list-none flex-col p-0`),children:e.runs.map((e,t)=>(0,X.jsx)(`li`,{className:L(t>0&&`border-t border-line-soft`),children:(0,X.jsxs)(`details`,{className:`group px-4 py-2`,children:[(0,X.jsxs)(`summary`,{className:`flex cursor-pointer list-none flex-wrap items-center gap-x-4 gap-y-1`,children:[(0,X.jsx)(G,{tone:e.outcome===`done`?`pass`:e.outcome===`running`?`running`:e.outcome===`stopped`||e.outcome===`needs_input`?`neutral`:`fail`,children:e.outcome.replace(`_`,` `)}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-body-sm font-medium`,"data-tip":e.request,children:e.request}),(0,X.jsxs)(`span`,{className:`text-body-sm text-muted tabular-nums`,children:[Hr[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}`:``,` · `,Ft(e.startedAt)]})]}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2 pl-1 text-body-sm`,children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-4 gap-y-1`,children:[(0,X.jsxs)(`span`,{className:`text-muted`,children:[`By `,e.by]}),e.session&&(0,X.jsxs)(`a`,{href:M(`runs`,encodeURIComponent(e.session)),className:`inline-flex items-center gap-1`,children:[`Open the run`,(0,X.jsx)(N,{size:14,"aria-hidden":`true`})]})]}),Rn(e,Ur)&&(0,X.jsx)(`span`,{className:`text-muted tabular-nums [overflow-wrap:anywhere]`,children:Rn(e,Ur)}),e.error&&(0,X.jsx)(`span`,{className:`text-fail [overflow-wrap:anywhere]`,children:e.error}),e.result&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-muted`,children:`Its result`}),(0,X.jsxs)(`dl`,{className:`m-0 grid grid-cols-[max-content_1fr] gap-x-4 gap-y-1`,children:[(0,X.jsx)(`dt`,{className:`text-muted`,children:`Verdict`}),(0,X.jsx)(`dd`,{className:`m-0`,children:e.result.verdict||`None given`}),Object.entries(e.result.fields).map(([e,t])=>(0,X.jsxs)(Y.Fragment,{children:[(0,X.jsx)(`dt`,{className:`font-mono text-body-sm text-muted`,children:e}),(0,X.jsx)(`dd`,{className:`m-0 [overflow-wrap:anywhere]`,children:typeof t==`boolean`?t?`Yes`:`No`:String(t)})]},e))]}),e.result.problems.length>0&&(0,X.jsxs)(`span`,{className:`text-warn [overflow-wrap:anywhere]`,children:[`Not read: `,e.result.problems.join(`; `),`.`]})]}),e.reply&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-muted`,children:`Its reply`}),(0,X.jsx)(`p`,{tabIndex:0,"aria-label":`Its reply`,className:`m-0 max-h-[240px] overflow-auto rounded-base bg-surface-muted px-4 py-2 whitespace-pre-wrap text-ink-2 [overflow-wrap:anywhere]`,children:e.reply})]}),e.decisions.length>0&&(0,X.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0`,children:e.decisions.map((e,t)=>(0,X.jsxs)(`li`,{className:`flex items-start gap-2`,children:[e.allowed?(0,X.jsx)(d,{size:14,"aria-label":`Allowed`,className:`mt-1 flex-none text-pass`}):(0,X.jsx)(r,{size:14,"aria-label":`Refused`,className:`mt-1 flex-none text-fail`}),(0,X.jsxs)(`span`,{className:`min-w-0 [overflow-wrap:anywhere]`,children:[(0,X.jsx)(`span`,{className:`font-mono text-body-sm`,children:e.tool}),e.allowed?(0,X.jsxs)(`span`,{className:`text-muted`,children:[` · `,Ir[e.action||``]||e.action,e.approved?`, approved by a person`:``]}):(0,X.jsxs)(`span`,{className:`text-fail`,children:[` · `,e.reason]})]})]},t))})]})]})},e.run))})]})}var Gr={approve:{title:`Approve this version`,button:`Approve`,icon:d},disable:{title:`Disable this agent`,button:`Disable`,icon:a},enable:{title:`Enable this agent`,button:`Enable`,icon:d},rollback:{title:`Run an earlier version`,button:`Roll back`,icon:u},delete:{title:`Delete this agent`,button:`Delete`,icon:De},discard:{title:`Discard the change`,button:`Discard the change`,icon:v}};function Kr({view:e,action:t,to:n,onClose:r,onDone:i}){let[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(``),p=t===`approve`?e.checks:null,m=!!p&&(p.failed.length>0||p.missing.length>0),[h,g]=(0,Y.useState)(!1),_=t===`approve`?e.approval:void 0,v=_?_.people-_.signed.length:1,y=(e,t)=>e.toLowerCase()===t.toLowerCase(),b=!!_&&_.owners.length>0&&!_.owners.some(e=>y(e,_.you)),x=!!_&&_.signed.some(e=>y(e.by,_.you)),S=Gr[t],C=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`&&v>1?`Your approval of version ${e.manifestVersion} is kept; it runs once ${v-1} more ${v-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}.`,T=async()=>{u(!0),f(``);try{i(await z.act(e.id,t,{confirm:a,...s.trim()?{note:s.trim()}:{},...n?{to:n}:{},...m&&h?{skipChecks:!0}:{}}))}catch(e){f(e.message),u(!1)}};return(0,X.jsx)(kt,{open:!0,onClose:r,title:S.title,description:C,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(U,{variant:`ghost`,onClick:r,children:[(0,X.jsx)(w,{"aria-hidden":`true`}),`Cancel`]}),(0,X.jsxs)(U,{variant:t===`delete`||t===`discard`?`destructive`:`primary`,disabled:l||a!==e.id||m&&!h||b||x,onClick:()=>void T(),children:[(0,X.jsx)(S.icon,{"aria-hidden":`true`}),S.button]})]}),children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[t===`approve`&&e.state===`drifted`&&e.drift&&(0,X.jsx)(J,{id:`ca-approve-drift`,icon:Te,title:(0,X.jsxs)(X.Fragment,{children:[`What it knows that changed since `,e.approvedVersion,` was approved`]}),level:3,children:(0,X.jsx)(`ul`,{className:L(`rounded-lg bg-bg p-6 shadow-sm`,`m-0 list-disc text-body-sm text-ink`),children:e.drift.map(e=>(0,X.jsx)(`li`,{children:e},e))})}),t===`approve`&&(e.permissions||[]).length>0&&(0,X.jsx)(J,{id:`ca-approve-may`,icon:ue,title:(0,X.jsx)(X.Fragment,{children:e.approvedVersion?`What it may do, against ${e.approvedVersion}`:`What it may do`}),level:3,children:(0,X.jsx)(zr,{lines:e.permissions})}),p&&(0,X.jsxs)(`div`,{role:m?`alert`:void 0,className:L(`flex flex-col gap-2 rounded-base px-4 py-4 text-body-sm`,m?`bg-warn-soft`:`bg-surface-muted`),children:[(0,X.jsx)(`span`,{className:L(`font-medium`,m?`text-warn`:`text-ink`),children:m?`Its checks have not all passed on version ${e.manifestVersion}`:`Its ${p.total} ${p.total===1?`check`:`checks`} passed on version ${e.manifestVersion}`}),p.failed.length>0&&(0,X.jsxs)(`span`,{className:`text-body-sm text-ink-2`,children:[`Failed: `,p.failed.join(`, `)]}),p.missing.length>0&&(0,X.jsxs)(`span`,{className:`text-body-sm text-ink-2`,children:[`Not run on this version: `,p.missing.join(`, `),`. Run them under Details, Checks, or with `,(0,X.jsxs)(`span`,{className:`font-mono`,children:[`forgeqe agent test `,e.id]}),`.`]}),m&&(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2`,children:[(0,X.jsx)(Ut,{checked:h,onCheckedChange:e=>g(e===!0),className:`mt-1`}),(0,X.jsx)(`span`,{children:`Approve it without them (kept in its history)`})]})]}),_&&(_.people>1||_.owners.length>0)&&(0,X.jsxs)(`div`,{role:b||x?`alert`:void 0,className:L(`flex flex-col gap-2 rounded-base px-4 py-4 text-body-sm`,b||x?`bg-warn-soft`:`bg-surface-muted`),children:[(0,X.jsx)(`span`,{className:L(`font-medium`,b||x?`text-warn`:`text-ink`),children:b?`Only ${_.owners.join(`, `)} may approve it`:x?`You already approved this version: another person approves it next`:_.people>1?`It needs ${_.people} different people to approve it`:`Only ${_.owners.join(`, `)} may approve it`}),_.people>1&&(0,X.jsxs)(`span`,{className:`text-body-sm text-ink-2`,children:[`Approved so far by `,_.signed.map(e=>e.by).join(`, `)||`nobody`,`.`]}),(0,X.jsxs)(`span`,{className:`text-body-sm text-muted`,children:[`ForgeQE knows you as `,_.you||`nobody`,`, git's user name on this computer: an agreement the history keeps, not a sign-in.`]})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsxs)(`span`,{children:[`Type `,(0,X.jsx)(`span`,{className:`font-mono`,children:e.id}),` to confirm`]}),(0,X.jsx)(F,{value:a,onChange:e=>o(e.target.value),autoComplete:`off`,spellCheck:!1})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{children:`Note (optional)`}),(0,X.jsx)(F,{value:s,maxLength:200,onChange:e=>c(e.target.value),placeholder:t===`rollback`?`Why it goes back`:`What changed, or why`})]}),d&&(0,X.jsx)(`p`,{role:`alert`,className:`m-0 text-body-sm text-fail [overflow-wrap:anywhere]`,children:d})]})})}var qr={legitimate:`Legitimate`,opportunistic:`Opportunistic`,adversarial:`Adversarial`},Jr={sme:`Subject matter expert`,end_user:`End user`,specialist:`Specialist`,business_user:`Business user`},Yr=[`personas`,`about`],Xr={personas:`Personas`,about:`Tools and conversations`},Zr={personas:p,about:k};function Qr({current:e,count:t}){let[n,r]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{t===void 0&&B.list().then(e=>r(e.personas.length),()=>r(null))},[t===void 0]);let i=t??n;return(0,X.jsx)(Dt,{label:`Mask's pages`,current:e,links:[{id:`agent`,label:`Agent`,href:M(`agents`,`persona`),icon:sn(`persona`)},{id:`personas`,label:i===null?`Personas`:`Personas (${i})`,href:M(`agents`,`persona`,`personas`),icon:Zr.personas},{id:`about`,label:`Tools and conversations`,href:M(`agents`,`persona`,`about`),icon:Zr.about}]})}var $r=/^[a-z0-9][a-z0-9-]{0,39}$/,ei=/^[a-z][a-z0-9-]{1,39}$/,ti=e=>M(`agents`,`persona`,`personas`,encodeURIComponent(e));function ni({page:e,tab:t,sub:n}){let[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)([]),[s,c]=(0,Y.useState)(``),l=t===`new`,u=Yr.includes(t)?t:`personas`,d=()=>B.list().then(e=>{i(e.personas),o(e.notLoaded),c(``)},e=>c(`The personas did not load: ${e.message}`));(0,Y.useEffect)(()=>{d()},[]);let f=u===`personas`&&n?me(n):``;return(0,X.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,X.jsx)(At,{}),(0,X.jsxs)(`main`,{className:L(jt,`@container flex-auto gap-4`),children:[(0,X.jsx)(Qt,{agent:e,tabs:(0,X.jsx)(Qr,{current:u,...r?{count:r.length}:{}})}),(0,X.jsx)(Rt,{icon:Zr[u],title:Xr[u]}),s&&(0,X.jsx)(`p`,{role:`alert`,className:L(H.fail,`m-0`),children:s}),!r&&!s&&(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Loading…`}),r&&(0,X.jsx)(X.Fragment,{children:(0,X.jsxs)(`div`,{children:[u===`personas`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ri,{personas:r,notLoaded:a,onChanged:e=>(i(e.personas),o(e.notLoaded))}),(0,X.jsx)(si,{personas:r,opened:f,onChanged:e=>(i(e.personas),o(e.notLoaded))}),(0,X.jsx)(_i,{open:l,onClose:()=>location.hash=ii,personas:r,onSaved:e=>{d().then(()=>(ui=e,location.hash=ti(e)))}})]}),u===`about`&&(0,X.jsx)(qt,{page:e,onTab:!0})]})})]})]})}function ri({personas:e,notLoaded:t,onChanged:n}){let[i,a]=(0,Y.useState)(`all`),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(``),[f,m]=(0,Y.useState)(!1),h=(0,Y.useRef)(null),g=e.filter(e=>!e.builtIn).length,_=async()=>{l(``),d(``);try{let e=await B.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),l(`Exported ${I(g,`persona`)} of your own. Another project imports the file here.`)}catch(e){d(e.message)}},v=async e=>{let t=e?.[0];if(t){if(l(``),d(``),t.size>262144)return d(`${t.name} is over 256 KB.`);m(!0);try{let e=await B.importFile(await t.text());n(e),l(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&&d(`Not imported: ${e.skipped.map(e=>`${e.id} (${e.why})`).join(`; `)}`)}catch(e){d(e.message)}finally{m(!1)}}},y=o.toLowerCase().split(/\s+/).filter(Boolean),b=e.filter(e=>(i===`all`||e.kind===i)&&y.every(t=>`${e.name} ${e.role} ${e.domain} ${e.id} /${e.handle}`.toLowerCase().includes(t)));return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`p`,{className:`m-0 mr-auto flex flex-wrap items-center gap-x-1 text-body-sm text-ink-2 tabular-nums`,children:[(0,X.jsx)(lt,{icon:p,size:14,className:`text-muted`}),I(e.length,`persona`),` · `,g,` of your own`,t.length?(0,X.jsxs)(X.Fragment,{children:[` · `,(0,X.jsxs)(`span`,{className:`text-fail`,children:[t.length,` not loaded`]})]}):null]}),(0,X.jsxs)(`span`,{className:`flex items-center gap-2`,children:[g>0&&(0,X.jsxs)(U,{size:`sm`,onClick:()=>void _(),"data-tip":`A file of your own personas, for another project to import`,children:[(0,X.jsx)(be,{"aria-hidden":`true`}),`Export`]}),(0,X.jsxs)(U,{size:`sm`,disabled:f,onClick:()=>h.current?.click(),"data-tip":`Personas another project exported`,children:[(0,X.jsx)(de,{"aria-hidden":`true`}),f?`Importing…`:`Import`]}),(0,X.jsxs)(U,{size:`sm`,variant:`accent`,onClick:()=>location.hash=M(`agents`,`persona`,`new`),"data-tip":`Describe a person and Mask drafts the persona, or write it yourself`,children:[(0,X.jsx)(E,{"aria-hidden":`true`}),`New persona`]})]}),(0,X.jsx)(`input`,{ref:h,type:`file`,accept:`.json,application/json`,hidden:!0,onChange:e=>(v(e.target.files),e.target.value=``)})]}),c&&(0,X.jsx)(`p`,{role:`status`,className:L(H.info,`m-0`),children:c}),u&&(0,X.jsx)(`p`,{role:`alert`,className:L(H.fail,`m-0`),children:u}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(mt,{id:`persona-find`,label:`Find a persona`,value:o,onChange:s}),(0,X.jsx)(ct,{items:[{id:`all`,label:`All`,n:e.length},...Pe.map(t=>({id:t,label:Jr[t],n:e.filter(e=>e.kind===t).length}))],value:i,onChange:a})]}),b.length===0?(0,X.jsx)(ut,{className:`py-4`,children:e.length?`No persona matches.`:`There are no personas yet.`}):(0,X.jsx)(`ul`,{"aria-label":`Personas`,className:L(W,`m-0 flex list-none flex-col`),children:b.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`a`,{href:ti(e.id),className:ze,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,X.jsxs)(`span`,{className:`truncate text-body-sm font-medium`,"data-tip":e.name,children:[e.name,!e.builtIn&&(0,X.jsx)(`span`,{className:`font-normal text-muted`,children:` · yours`})]}),(0,X.jsxs)(`span`,{className:`truncate text-body-sm text-muted`,children:[(0,X.jsxs)(`span`,{className:`font-mono`,children:[`/`,e.handle]}),` · `,Jr[e.kind],e.intent===`legitimate`?``:` · ${qr[e.intent].toLowerCase()}`,` · `,e.role,e.domain?` · ${e.domain}`:``]})]}),(0,X.jsx)(`span`,{className:`flex-none text-body-sm text-muted tabular-nums`,children:I(e.validates.length,`check`)})]})},e.id))}),t.length>0&&(0,X.jsx)(J,{id:`persona-not-loaded`,icon:r,title:`Not loaded`,level:3,children:(0,X.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0`,children:t.map(e=>(0,X.jsx)(`li`,{className:`text-body-sm text-fail [overflow-wrap:anywhere]`,children:e},e))})}),(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`Your own personas are in .forgeqe/business-personas (each with its profile as a .md file), shared with everyone who uses the repository. Type a persona's command in any agent's chat, such as /priya and the task.`})]})}var ii=M(`agents`,`persona`,`personas`),ai=e=>{let{builtIn:t,...n}=e;return n},oi=(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 si({personas:e,opened:t,onChanged:n}){let[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(!1),[s,l]=(0,Y.useState)(``),u=r?void 0:e.find(e=>e.id===t),d=!!t&&!r&&!u,f=()=>location.hash=ii,p=(t,n)=>{let r=new Set(e.flatMap(e=>[e.id,e.handle])),a=n===`copy`?{...ai(t),id:oi(t.id,r),handle:``}:ai(t);l(``),i({mode:n,from:t,fields:a,listText:Object.fromEntries(hi.map(({key:e})=>[e,t[e].join(`
6
- `)]))})},m=(0,Y.useMemo)(()=>new Set(e.filter(e=>r?.mode!==`edit`||e.id!==r.from.id).flatMap(e=>[e.id,e.handle])),[e,r]),h=r?vi(r.fields,r.listText,m,r.mode===`edit`):null,g=ci(!!t||!!r),v=async(e,t,r)=>{e[t].includes(r)||n(await B.update(e.id,{...ai(e),[t]:[...e[t],r]}))},y=async()=>{if(r&&h?.canSave){o(!0),l(``);try{let e={...r.fields,...Object.fromEntries(hi.map(({key:e})=>[e,gi(r.listText[e]||``)]))},t=r.mode===`edit`?await B.update(r.from.id,e):await B.save(e);n(t),i(null),r.mode===`copy`&&(ui=t.saved),location.hash=ti(t.saved)}catch(e){l(e.message)}finally{o(!1)}}};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(kt,{wide:!0,open:!!u||d,onClose:f,title:u?.name||`No such persona`,description:u?u.builtIn?`ForgeQE's persona: read only. Copy it to edit your own version for this project.`:`This project's own persona: you can edit it.`:void 0,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(U,{onClick:f,children:[(0,X.jsx)(w,{"aria-hidden":`true`}),`Close`]}),u&&!u.builtIn&&(0,X.jsxs)(U,{variant:`primary`,onClick:()=>p(u,`edit`),children:[(0,X.jsx)(c,{"aria-hidden":`true`}),`Edit`]}),u?.builtIn&&(0,X.jsxs)(U,{variant:`primary`,"data-tip":`Make your own persona from this one, under another id and command`,onClick:()=>p(u,`copy`),children:[(0,X.jsx)(se,{"aria-hidden":`true`}),`Copy to edit`]})]}),children:u?(0,X.jsx)(pi,{persona:u,resources:g,onAdd:u.builtIn?void 0:(e,t)=>v(u,e,t)}):(0,X.jsxs)(ut,{className:`py-6`,children:[`There is no persona "`,t,`" in this project.`]})}),(0,X.jsx)(kt,{wide:!0,open:!!r,onClose:()=>i(null),title:r?.mode===`edit`?`Edit ${r.from.name}`:`Copy ${r?.from.name||``}`,description:(0,X.jsxs)(X.Fragment,{children:[r?.mode===`copy`&&(0,X.jsx)(X.Fragment,{children:`A persona of your own, made from the built-in one, which stays as it is. `}),`Saved in `,(0,X.jsxs)(`span`,{className:`font-mono text-body-sm`,children:[`.forgeqe/business-personas/`,r?.fields.id||`<id>`,`.yaml`]}),`, shared with everyone who uses the repository.`]}),footer:(0,X.jsxs)(X.Fragment,{children:[s?(0,X.jsx)(`span`,{role:`alert`,className:`mr-auto self-center text-body-sm text-fail [overflow-wrap:anywhere]`,children:s}):r&&!h?.canSave&&(0,X.jsxs)(`span`,{className:`mr-auto self-center text-body-sm text-muted`,children:[`It needs a name, `,r.mode===`copy`?`an id, `:``,`a role, and what they check or want.`]}),(0,X.jsxs)(U,{onClick:()=>i(null),children:[(0,X.jsx)(w,{"aria-hidden":`true`}),`Cancel`]}),(0,X.jsxs)(U,{variant:`primary`,disabled:a||!h?.canSave,onClick:()=>void y(),children:[(0,X.jsx)(_,{"aria-hidden":`true`}),a?`Saving…`:r?.mode===`copy`?`Save copy`:`Save`]})]}),children:r&&h&&(0,X.jsx)(`div`,{className:`pt-4`,children:(0,X.jsx)(yi,{fields:r.fields,listText:r.listText,onFields:e=>i({...r,fields:e}),onListText:e=>i({...r,listText:e}),check:h,idLocked:r.mode===`edit`,resources:g})})})]})}function ci(e){let[t,n]=(0,Y.useState)(null);return(0,Y.useEffect)(()=>{e&&!t&&B.resources().then(n,e=>n({skills:[],documents:[],error:`The skills and documents did not load: ${e.message}`}))},[e,t]),t}function li({persona:e,resources:t,onAdd:n}){let[r,i]=(0,Y.useState)(null),a=t?.error?null:t,[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(``),u=`${e.skills.join(`,`)}|${e.knowledge.join(`,`)}`;(0,Y.useEffect)(()=>{i(null),B.suggest(e.id).then(i,e=>i({skills:[],documents:[],error:`The suggestions did not load: ${e.message}`}))},[e.id,u]);let d=e=>a?.skills.find(t=>t.name===e),f=e=>a?.documents.find(t=>t.ref===e),p=(0,X.jsx)(`span`,{className:`text-warn`,children:` · not in this project`}),m=async(e,t)=>{if(n){s(`${e}:${t}`),l(``);try{await n(e,t)}catch(e){l(e.message)}finally{s(``)}}},h=r?[...r.skills.map(e=>({key:`skills`,...e})),...r.documents.map(e=>({key:`knowledge`,...e}))]:[];return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(J,{id:`persona-uses`,icon:ae,title:`Shared skills and documents`,level:3,children:[e.skills.length+e.knowledge.length===0?(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:n?`No skills or documents yet. Add a suggestion below, or pick them in Edit.`:`No skills or documents. Copy it to edit, then pick them.`}):(0,X.jsxs)(`ul`,{"aria-label":`Skills and documents`,className:`m-0 flex list-none flex-col p-0`,children:[e.skills.map(e=>(0,X.jsxs)(`li`,{className:`flex items-start gap-4 border-t border-line-soft py-2`,children:[(0,X.jsx)(lt,{icon:ae,size:16,className:`mt-1 text-muted`}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`font-mono text-body-sm [overflow-wrap:anywhere]`,children:e}),(0,X.jsxs)(`span`,{className:`text-body-sm text-muted [overflow-wrap:anywhere]`,children:[`Skill`,a&&!d(e)?p:d(e)?` · ${d(e).description}`:``]})]})]},`s:${e}`)),e.knowledge.map(e=>(0,X.jsxs)(`li`,{className:`flex items-start gap-4 border-t border-line-soft py-2`,children:[(0,X.jsx)(lt,{icon:we,size:16,className:`mt-1 text-muted`}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-body-sm font-medium [overflow-wrap:anywhere]`,children:f(e)?.title||e}),(0,X.jsxs)(`span`,{className:`font-mono text-body-sm text-muted [overflow-wrap:anywhere]`,children:[e,a&&!f(e)?p:null]})]})]},`k:${e}`))]}),t?.error&&(0,X.jsx)(`p`,{role:`alert`,className:L(H.fail,`m-0`),children:t.error})]}),(0,X.jsxs)(J,{id:`persona-suggested`,icon:A,title:`Suggested for them`,level:3,children:[r?r.error?(0,X.jsx)(`p`,{role:`alert`,className:L(H.fail,`m-0`),children:r.error}):h.length===0?(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`Nothing else matches their domain and checks. Add documents in Settings › Product knowledge, or knowledge notes, to see more.`}):(0,X.jsx)(`ul`,{"aria-label":`Suggested skills and documents`,className:`m-0 flex list-none flex-col p-0`,children:h.map(t=>(0,X.jsxs)(`li`,{className:`flex items-center gap-4 border-t border-line-soft py-2`,children:[(0,X.jsx)(lt,{icon:t.key===`skills`?ae:we,size:16,className:`text-muted`}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:L(`text-body-sm [overflow-wrap:anywhere]`,t.key===`skills`?`font-mono`:`font-medium`),children:t.key===`knowledge`&&f(t.name)?.title||t.name}),(0,X.jsxs)(`span`,{className:`text-body-sm text-muted [overflow-wrap:anywhere]`,children:[t.key===`skills`?`Skill`:t.name,` · matched `,t.why]})]}),n&&(0,X.jsxs)(U,{size:`sm`,disabled:!!o,onClick:()=>void m(t.key,t.name),"data-tip":`Add to what ${e.name} uses`,children:[(0,X.jsx)(E,{"aria-hidden":`true`}),o===`${t.key}:${t.name}`?`Adding…`:`Add`]})]},`${t.key}:${t.name}`))}):(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Looking for skills and documents that match…`}),c&&(0,X.jsx)(`p`,{role:`alert`,className:L(H.fail,`m-0`),children:c})]})]})}var ui=``,di=e=>e.name.split(`,`)[0].trim()||e.name;function fi({persona:e}){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(``),[s,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(``),p=di(e),m=()=>B.own(e.id).then(n,e=>n({skills:[],knowledge:[],problems:[],error:`${p}'s own skills and notes did not load: ${e.message}`})),h=async()=>{o(`draft`),u(``);try{let[t,n]=await Promise.all([B.draftOwn(e.id),B.own(e.id)]),r=(e,t)=>n[e].some(e=>e.name===t);f(``),i({drafted:!0,items:[t.skill,t.knowledge].map(e=>({...e,replace:r(e.kind,e.name)}))})}catch(e){u(e.message)}finally{o(``)}};(0,Y.useEffect)(()=>{n(null),m(),ui===e.id&&(ui=``,h())},[e.id]);let g=async()=>{if(r){o(`save`),f(``);try{let t=r.items.filter(e=>e.was&&e.was!==e.name),a=await B.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 B.removeOwn(e.id,n.kind,n.was);n(t.length?await B.own(e.id):a),i(null)}catch(e){f(e.message),m()}finally{o(``)}}},v=async t=>{o(`remove:${t.kind}/${t.name}`),f(``);try{n(await B.removeOwn(e.id,t.kind,t.name)),i(null)}catch(e){f(e.message)}finally{o(``)}},y=t?[...t.skills,...t.knowledge]:[],b=(e,t)=>r&&i({...r,items:r.items.map((n,r)=>r===e?{...n,...t}:n)}),x=!!r&&r.items.every(e=>/^[a-z0-9]+(-[a-z0-9]+)*$/.test(e.name)&&e.body.trim()&&(e.kind===`knowledge`||e.description.trim()));return(0,X.jsxs)(J,{id:`persona-own`,icon:S,level:3,title:(0,X.jsxs)(X.Fragment,{children:[p,`'s own skills and knowledge`]}),description:(0,X.jsxs)(X.Fragment,{children:[`Used only when someone works as `,p,`, never by other agents.`]}),actions:(0,X.jsxs)(U,{size:`sm`,disabled:!!a||!t,onClick:()=>void h(),"data-tip":`Mask drafts a skill and a knowledge note for ${p}; you review them before anything is saved`,children:[(0,X.jsx)(l,{"aria-hidden":`true`}),a===`draft`?`Generating…`:y.length?`Generate again`:`Generate skill and knowledge`]}),children:[a===`draft`&&(0,X.jsxs)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:[`Mask is writing `,p,`'s skill and knowledge note…`]}),t?y.length===0?!t.error&&a!==`draft`&&(0,X.jsxs)(`p`,{className:`m-0 text-body-sm text-muted`,children:[`None yet. Generate a skill and a knowledge note from `,p,`'s checks, then change them as you need.`]}):(0,X.jsx)(`ul`,{"aria-label":`${p}'s own skills and knowledge`,className:`m-0 flex list-none flex-col p-0`,children:y.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center gap-4 border-t border-line-soft py-2`,children:[(0,X.jsx)(lt,{icon:e.kind===`skills`?ae:we,size:16,className:`text-muted`}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`font-mono text-body-sm [overflow-wrap:anywhere]`,children:e.name}),(0,X.jsx)(`span`,{className:`line-clamp-2 text-body-sm text-muted [overflow-wrap:anywhere]`,children:e.kind===`skills`?`Skill · ${e.description}`:`Knowledge note`})]}),(0,X.jsxs)(U,{size:`sm`,disabled:!!a,onClick:()=>(f(``),i({drafted:!1,items:[{...e,replace:!0,was:e.name}]})),children:[(0,X.jsx)(c,{"aria-hidden":`true`}),`Edit`]})]},`${e.kind}:${e.name}`))}):(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Loading…`}),t?.problems.length?(0,X.jsxs)(`p`,{className:`m-0 text-body-sm text-warn [overflow-wrap:anywhere]`,children:[`Not read: `,t.problems.join(`; `)]}):null,(s||t?.error)&&(0,X.jsx)(`p`,{role:`alert`,className:L(H.fail,`m-0`),children:s||t?.error}),(0,X.jsx)(kt,{wide:!0,open:!!r,onClose:()=>i(null),title:r?.drafted?`Review ${p}'s skill and knowledge`:`Edit ${r?.items[0]?.was||``}`,description:(0,X.jsxs)(X.Fragment,{children:[r?.drafted&&(0,X.jsx)(X.Fragment,{children:`Mask's draft: change anything, then save. `}),`Kept in `,(0,X.jsxs)(`span`,{className:`font-mono text-body-sm`,children:[`.forgeqe/business-personas/`,e.id,`/`]}),` and used only when someone works as `,p,`.`]}),footer:(0,X.jsxs)(X.Fragment,{children:[d?(0,X.jsx)(`span`,{role:`alert`,className:`mr-auto self-center text-body-sm text-fail [overflow-wrap:anywhere]`,children:d}):r&&!x&&(0,X.jsx)(`span`,{className:`mr-auto self-center text-body-sm text-muted`,children:`Each needs a name of lower-case words joined by dashes and its text; a skill also its "use when" line.`}),r&&!r.drafted&&r.items[0]?.was&&(0,X.jsxs)(U,{disabled:!!a,onClick:()=>void v({...r.items[0],name:r.items[0].was}),className:L(!d&&x&&`mr-auto`,`text-fail`),children:[(0,X.jsx)(De,{"aria-hidden":`true`}),a.startsWith(`remove:`)?`Deleting…`:`Delete`]}),(0,X.jsxs)(U,{onClick:()=>i(null),children:[(0,X.jsx)(w,{"aria-hidden":`true`}),`Cancel`]}),(0,X.jsxs)(U,{variant:`primary`,disabled:a===`save`||!x,onClick:()=>void g(),children:[(0,X.jsx)(_,{"aria-hidden":`true`}),a===`save`?`Saving…`:r?.drafted?`Save both`:`Save`]})]}),children:r&&(0,X.jsx)(`div`,{className:`flex flex-col gap-6 pt-4`,children:r.items.map((e,t)=>(0,X.jsxs)(`section`,{"aria-labelledby":`own-item-${t}`,className:`flex flex-col gap-4`,children:[(0,X.jsxs)(`h3`,{id:`own-item-${t}`,className:`m-0 flex items-center gap-2 text-body-sm font-medium text-muted`,children:[(0,X.jsx)(lt,{icon:e.kind===`skills`?ae:we,size:14}),e.kind===`skills`?`Skill`:`Knowledge note`,e.replace&&!e.was&&(0,X.jsx)(`span`,{className:`font-normal text-warn`,children:` · replaces the one of this name`})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Name`}),(0,X.jsx)(F,{value:e.name,maxLength:64,spellCheck:!1,autoComplete:`off`,className:`font-mono`,onChange:e=>b(t,{name:e.target.value.toLowerCase().replace(/[^a-z0-9-]+/g,`-`)})})]}),e.kind===`skills`&&(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Use when`}),(0,X.jsx)(F,{value:e.description,maxLength:400,onChange:e=>b(t,{description:e.target.value})})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`label`,{htmlFor:`own-body-${t}`,className:`font-medium`,children:e.kind===`skills`?`Instructions`:`What it says`}),(0,X.jsx)(nn,{id:`own-body-${t}`,value:e.body,lang:`markdown`,onChange:e=>b(t,{body:e})})]})]},t))})})]})}function pi({persona:e,resources:t,onAdd:n}){let i=[[`persona-validates`,`What they check before accepting the software`,e.validates,ie],[`persona-goals`,`What they want to do`,e.goals,ve],[`persona-knows`,`What they know`,e.knows,S],[`persona-frustrations`,`What puts them off`,e.frustrations,r],[`persona-scenarios`,`What they would try`,e.scenarios,Se],[`persona-motivations`,`What drives them`,e.motivations,A],[`persona-permissions`,`What their role lets them do`,e.permissions,ue],[`persona-constraints`,`What limits them`,e.constraints,a],[`persona-mistakes`,`Mistakes they make`,e.mistakes,s],[`persona-relationships`,`Who they deal with`,e.relationships,p]];return(0,X.jsxs)(`div`,{className:`flex flex-col gap-6 pt-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`p`,{className:`m-0 text-body-sm text-muted`,children:[(0,X.jsxs)(`span`,{className:`font-mono`,children:[`/`,e.handle]}),` · `,Jr[e.kind],` · `,e.role,e.domain?` · ${e.domain}`:``,` · `,e.expertise.charAt(0).toUpperCase()+e.expertise.slice(1),e.intent===`legitimate`?``:` · ${qr[e.intent].toLowerCase()}, risk appetite ${e.risk_appetite}`,e.builtIn?``:` · version ${e.version}`]}),e.description&&(0,X.jsx)(`p`,{className:`m-0 text-body-sm leading-relaxed text-ink-2`,children:e.description})]}),(0,X.jsx)(fi,{persona:e}),(0,X.jsx)(li,{persona:e,resources:t,...n?{onAdd:n}:{}}),i.filter(([,,e])=>e.length).map(([e,t,n,r])=>(0,X.jsx)(J,{id:e,icon:r,title:t,level:3,children:(0,X.jsx)(`ul`,{className:`m-0 flex list-disc flex-col gap-1 pl-6 text-body-sm text-ink-2`,children:n.map(e=>(0,X.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:e},e))})},e))]})}var mi={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:[]},hi=[{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.`}],gi=e=>e.split(`
7
- `).map(e=>e.trim()).filter(Boolean);function _i({open:e,onClose:t,personas:r,onSaved:i}){let[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(``),[f,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)({}),[v,y]=(0,Y.useState)(!1),[b,x]=(0,Y.useState)(``),[S,C]=(0,Y.useState)(``),T=(0,Y.useMemo)(()=>new Set(r.flatMap(e=>[e.id,e.handle])),[r]),E=ci(!!f),D=(0,Y.useRef)(0);(0,Y.useEffect)(()=>{D.current+=1,e&&(o(``),c(``),d(``),m(null),g({}),y(!1),x(``),C(``))},[e]);let ee=e=>{m(e),g(Object.fromEntries(hi.map(({key:t})=>[t,e[t].join(`
8
- `)])))},O=async()=>{let e=D.current;x(`draft`),C(``);try{let{persona:t}=await B.draft({request:a.trim(),...s?{kind:s}:{},...u.trim()?{domain:u.trim()}:{}});if(e!==D.current)return;let{builtIn:n,...r}=t;ee(r),y(!0)}catch(t){e===D.current&&C(t.message)}finally{e===D.current&&x(``)}},te=async()=>{if(f){x(`save`),C(``);try{let e={...f,...Object.fromEntries(hi.map(({key:e})=>[e,gi(h[e]||``)]))};i((await B.save(e)).saved)}catch(e){C(e.message),x(``)}}},k=f?vi(f,h,T,!1):null,A=!!k?.canSave;return(0,X.jsx)(kt,{wide:!0,open:e,onClose:t,title:`New persona`,description:(0,X.jsxs)(X.Fragment,{children:[`Saved in `,(0,X.jsxs)(`span`,{className:`font-mono text-body-sm`,children:[`.forgeqe/business-personas/`,f?.id||`<id>`,`.yaml`]}),`, shared with the project.`]}),footer:(0,X.jsxs)(X.Fragment,{children:[S?(0,X.jsx)(`span`,{role:`alert`,className:`mr-auto self-center text-body-sm text-fail [overflow-wrap:anywhere]`,children:S}):f&&!A&&(0,X.jsx)(`span`,{className:`mr-auto self-center text-body-sm text-muted`,children:`It needs a name, an id, a role, and what they check or want.`}),(0,X.jsxs)(U,{onClick:t,children:[(0,X.jsx)(w,{"aria-hidden":`true`}),`Cancel`]}),(0,X.jsxs)(U,{variant:`primary`,disabled:!!b||!A,onClick:()=>void te(),children:[(0,X.jsx)(_,{"aria-hidden":`true`}),b===`save`?`Saving…`:`Save`]})]}),children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-6 pt-4`,children:[(0,X.jsxs)(J,{id:`persona-ask`,icon:p,title:`Who is the persona?`,level:3,children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Describe them`}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:`Their job, what they know and what they check. Mask drafts the rest.`}),(0,X.jsx)(Fe,{rows:3,value:a,maxLength:2e3,onChange:e=>o(e.target.value),placeholder:`An SME in card payments who reconciles settlements every morning and signs off refunds`})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Kind`}),(0,X.jsxs)(P,{value:s,onChange:e=>c(e.target.value),children:[(0,X.jsx)(`option`,{value:``,children:`Let the agent choose`}),Pe.map(e=>(0,X.jsx)(`option`,{value:e,children:Jr[e]},e))]})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Domain`}),(0,X.jsx)(F,{value:u,maxLength:80,onChange:e=>d(e.target.value),placeholder:`payments`})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(U,{disabled:!!b||!a.trim(),onClick:()=>void O(),"data-tip":v?`Ask Mask for another draft`:`Ask Mask for a draft`,children:[(0,X.jsx)(l,{"aria-hidden":`true`}),v?`Draft again`:`Draft`]}),!f&&(0,X.jsxs)(U,{disabled:!!b,onClick:()=>ee(mi),"data-tip":`Write every field yourself`,children:[(0,X.jsx)(ge,{"aria-hidden":`true`}),`Write`]}),b===`draft`&&(0,X.jsx)(`span`,{role:`status`,className:`text-body-sm text-muted`,children:`Mask is drafting…`})]})]}),f&&k&&(0,X.jsx)(J,{id:`persona-fields`,icon:n,title:`The persona`,level:3,children:(0,X.jsx)(yi,{fields:f,listText:h,onFields:m,onListText:g,check:k,idLocked:!1,resources:E})})]})})}function vi(e,t,n,r){let i=r||e.id===``?``:$r.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===``?``:ei.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()&&(gi(t.validates||``).length>0||gi(t.goals||``).length>0)}}function yi({fields:e,listText:t,onFields:n,onListText:r,check:i,idLocked:a,resources:o}){let s=(t,r)=>n({...e,[t]:r}),{idProblem:c,handleProblem:l}=i;return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Name`}),(0,X.jsx)(F,{value:e.name,maxLength:80,onChange:e=>s(`name`,e.target.value),placeholder:`Priya, payments SME`})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Id`}),(0,X.jsx)(F,{value:e.id,disabled:a,maxLength:40,spellCheck:!1,autoComplete:`off`,"aria-invalid":!!c,"aria-describedby":c?`persona-id-error`:void 0,onChange:e=>s(`id`,e.target.value.toLowerCase()),className:`font-mono`}),c&&(0,X.jsx)(`p`,{id:`persona-id-error`,role:`alert`,className:`m-0 text-body-sm text-fail`,children:c})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Command`}),(0,X.jsxs)(`span`,{className:`text-body-sm text-muted`,children:[`Type it in any agent's chat: /`,e.handle||e.id||`priya`,` Validate the payment change.`]}),(0,X.jsx)(F,{value:e.handle,maxLength:40,spellCheck:!1,autoComplete:`off`,"aria-invalid":!!l,"aria-describedby":l?`persona-handle-error`:void 0,onChange:e=>s(`handle`,e.target.value.toLowerCase().replace(/^\//,``)),className:`font-mono`,placeholder:e.id||`priya`}),l&&(0,X.jsx)(`p`,{id:`persona-handle-error`,role:`alert`,className:`m-0 text-body-sm text-fail`,children:l})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Kind`}),(0,X.jsx)(P,{value:e.kind,onChange:e=>s(`kind`,e.target.value),children:Pe.map(e=>(0,X.jsx)(`option`,{value:e,children:Jr[e]},e))})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Expertise in the domain`}),(0,X.jsx)(P,{value:e.expertise,onChange:e=>s(`expertise`,e.target.value),children:Le.map(e=>(0,X.jsx)(`option`,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Intent`}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:`Opportunistic takes any advantage the app gives; adversarial sets out to misuse it. Watchdog tests as them.`}),(0,X.jsx)(P,{value:e.intent,onChange:e=>s(`intent`,e.target.value),children:Ne.map(e=>(0,X.jsx)(`option`,{value:e,children:qr[e]},e))})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Risk appetite`}),(0,X.jsx)(P,{value:e.risk_appetite,onChange:e=>s(`risk_appetite`,e.target.value),children:Ie.map(e=>(0,X.jsx)(`option`,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Role`}),(0,X.jsx)(F,{value:e.role,maxLength:120,onChange:e=>s(`role`,e.target.value),placeholder:`Payments operations lead`})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Domain`}),(0,X.jsx)(F,{value:e.domain,maxLength:80,onChange:e=>s(`domain`,e.target.value)})]})]}),(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Who they are`}),(0,X.jsx)(Fe,{rows:3,value:e.description,maxLength:1200,onChange:e=>s(`description`,e.target.value)})]}),hi.map(({key:e,label:n,hint:i})=>(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:n}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:i}),(0,X.jsx)(Fe,{rows:e===`validates`?5:3,value:t[e]||``,onChange:n=>r({...t,[e]:n.target.value})})]},e)),(0,X.jsx)(xi,{id:`persona-skills`,label:`Skills an agent loads as them`,hint:`The agent loads these with its skill tool whenever someone works as this persona.`,items:o?.skills.map(e=>({id:e.name,title:e.name,note:e.description,mono:!0}))??null,...o?.error?{error:o.error}:{},value:e.skills,onChange:e=>s(`skills`,e)}),(0,X.jsx)(xi,{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 bi=12;function xi({id:e,label:t,hint:n,items:r,error:i,value:a,onChange:o}){let[s,c]=(0,Y.useState)(``),l=s.toLowerCase().split(/\s+/).filter(Boolean),u=r?[...a.filter(e=>!r.some(t=>t.id===e)).map(e=>({id:e,title:e,note:`Not in this project`,mono:!0})),...r]:[],d=u.filter(e=>l.every(t=>`${e.title} ${e.note} ${e.id}`.toLowerCase().includes(t))).sort((e,t)=>Number(a.includes(t.id))-Number(a.includes(e.id))),f=a.length>=bi;return(0,X.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 border-0 p-0 text-body-sm`,children:[(0,X.jsxs)(`legend`,{className:`mb-2 p-0 font-medium`,children:[t,` `,(0,X.jsxs)(`span`,{className:`font-normal text-muted tabular-nums`,children:[`· `,a.length,` picked`]})]}),(0,X.jsx)(`span`,{className:`text-body-sm text-muted`,children:n}),i?(0,X.jsx)(`p`,{role:`alert`,className:L(H.fail,`m-0`),children:i}):r?u.length===0?(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`There are none in this project yet.`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,X.jsx)(mt,{id:`${e}-find`,label:`Find in ${t.toLowerCase()}`,value:s,onChange:c})}),(0,X.jsxs)(`ul`,{"aria-label":t,className:L(W,`m-0 max-h-72 list-none overflow-y-auto`),children:[d.length===0&&(0,X.jsx)(`li`,{className:`py-4 text-body-sm text-muted`,children:`Nothing matches.`}),d.map(e=>{let t=a.includes(e.id);return(0,X.jsx)(`li`,{className:`border-t border-line-soft first:border-t-0`,children:(0,X.jsxs)(`label`,{className:L(`flex min-h-12 items-center gap-4 py-2`,!t&&f?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,X.jsx)(Ut,{checked:t,disabled:!t&&f,onCheckedChange:t=>o(t?[...a,e.id]:a.filter(t=>t!==e.id))}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:L(`text-body-sm [overflow-wrap:anywhere]`,e.mono?`font-mono`:`font-medium`),children:e.title}),(0,X.jsx)(`span`,{className:`line-clamp-2 text-body-sm text-muted [overflow-wrap:anywhere]`,"data-tip":e.note.length>120?e.note:void 0,children:e.note})]})]})},e.id)})]}),f&&(0,X.jsxs)(`span`,{className:`text-body-sm text-muted`,children:[`At most `,bi,`: take one off to pick another.`]})]}):(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Loading…`})]})}var Si=[`agent`,`tests`,`personas`,`findings`],Ci={agent:`Agent`,tests:`Tests`,personas:`Personas`,findings:`Findings`},wi={agent:`BASAL`,tests:`Business tests`,personas:`Personas`,findings:`Findings`},Ti={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.`},Ei={tests:D,personas:p,findings:re},$=(e,t)=>e===`agent`?M(`agents`,`basal`):t?M(`agents`,`basal`,e,t):M(`agents`,`basal`,e),Di=[`ask`,`understand`,`strategy`,`cast`,`rehearse`,`approve`,`act`,`judge`],Oi={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.`}},ki={asked:1,understood:2,planned:3,cast:4,rehearsed:5,approved:6,acted:8},Ai={understand:1,strategy:2,cast:3,rehearse:4,act:6},ji=e=>String(e).padStart(2,`0`),Mi=[{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`}],Ni={confirmed_failure:`fail`,policy_ambiguity:`warn`,potential_risk:`warn`,missing_evidence:`neutral`,expected_behaviour:`pass`},Pi=[`confirmed_failure`,`policy_ambiguity`,`potential_risk`,`missing_evidence`,`expected_behaviour`];function Fi({page:e,tab:t,sub:n}){let r=Si.includes(t)?t:`agent`,[i,a]=r===`tests`&&n?n.split(`/`):[],o=i?me(i):``,s=(e,t)=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Rt,{icon:Ei[e],title:wi[e],description:Ti[e]}),t]});return(0,X.jsx)(rn,{page:e,title:gt(`basal`),label:`BASAL`,current:r,onPick:e=>location.hash=$(e),tabs:Si.filter(e=>e!==un).map(e=>({id:e,label:Ci[e],icon:Ei[e]})),agentBody:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`m-0 text-body-sm leading-relaxed text-ink-2`,children:Ti.agent}),(0,X.jsx)(Bi,{}),(0,X.jsx)(Vt,{scope:{kind:`page`,page:e}})]}),children:o?(0,X.jsx)(Hi,{id:o,step:Di.includes(a)?a:void 0},o):r===`tests`?s(`tests`,(0,X.jsx)(Vi,{})):r===`personas`?s(`personas`,(0,X.jsx)(ia,{})):r===`findings`?s(`findings`,(0,X.jsx)(aa,{})):null})}function Ii(){let[e,t]=(0,Y.useState)(null),[n,r]=(0,Y.useState)(``),i=(0,Y.useCallback)(()=>R.home().then(t,e=>r(e.message)),[]);return(0,Y.useEffect)(()=>void i(),[i]),{home:e,error:n,load:i}}function Li({g:e}){return(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted tabular-nums`,children:e.connected?(0,X.jsxs)(X.Fragment,{children:[`Graph store: running · `,I(e.product||0,`product node`),` · `,I(e.scenario||0,`scenario node`),e.embedding?` · found by meaning with ${e.embedding}`:` · by words only (no embedding model)`]}):(0,X.jsxs)(X.Fragment,{children:[`Graph store: the product graph's file`,e.reason?` (${e.reason})`:``,`. forgeqe graph setup starts it.`]})})}function Ri({home:e}){let[t,n]=(0,Y.useState)(``),[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(``),s=async()=>{i(!0),o(``);try{let{id:e}=await R.ask(t.trim());await R.stage(e,`understand`),location.hash=$(`tests`,`${e}/understand`)}catch(e){o(e.message)}finally{i(!1)}};return(0,X.jsxs)(J,{id:`basal-new`,icon:T,title:`New business test`,divider:!1,className:W,children:[(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Your business question`}),(0,X.jsx)(Fe,{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,X.jsx)(`span`,{className:`text-body-sm 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.`}),a&&(0,X.jsx)(_n,{text:a}),(0,X.jsx)(`div`,{children:(0,X.jsxs)(U,{variant:`primary`,disabled:r||t.trim().length<10||!e.model,onClick:()=>void s(),"data-tip":e.model?`Keeps the question and starts step 02, Understand`:`Set up a model in Settings › Models first`,children:[(0,X.jsx)(x,{"aria-hidden":`true`}),r?`Starting…`:`Start`]})})]})}function zi({tests:e,search:t=!0,tools:n}){return(0,X.jsx)(Tt,{label:`Business tests`,placeholder:`Find a business test`,empty:`No business test yet. Ask a business question on the Agent tab.`,search:t,...t?{height:wt}:{},...n?{tools:n}:{},head:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`th`,{scope:`col`,className:L(St,`w-[55%]`),children:`Business question`}),(0,X.jsx)(`th`,{scope:`col`,className:L(St,`hidden @xl:table-cell`),children:`Asked`}),(0,X.jsx)(`th`,{scope:`col`,className:L(Nt,`hidden @2xl:table-cell`),children:`Steps done`}),(0,X.jsx)(`th`,{scope:`col`,className:St,children:`Stage`})]}),children:e.map(e=>{let t=ki[e.stage];return(0,X.jsxs)(`tr`,{onClick:()=>location.hash=$(`tests`,e.id),className:_t,children:[(0,X.jsxs)(`td`,{className:L(Mt,`max-w-0`),children:[(0,X.jsx)(`a`,{href:$(`tests`,e.id),onClick:e=>e.stopPropagation(),"data-tip":e.request,className:`block truncate font-medium text-ink no-underline hover:underline`,children:e.request}),(0,X.jsx)(`span`,{className:`block truncate font-mono text-muted`,children:e.id})]}),(0,X.jsx)(`td`,{className:L(Mt,`hidden whitespace-nowrap text-muted @xl:table-cell`),children:e.created.slice(0,10)}),(0,X.jsx)(`td`,{className:L(Pt,`hidden text-muted @2xl:table-cell`),"data-sort":t??-1,children:t===void 0?`–`:`${t} of ${Di.length}`}),(0,X.jsx)(`td`,{className:L(Mt,`whitespace-nowrap`),children:e.running?(0,X.jsx)(G,{tone:`running`,children:e.running}):(0,X.jsx)(G,{tone:`neutral`,children:e.stage})})]},e.id)})})}function Bi(){let{home:e,error:t}=Ii();return t?(0,X.jsx)(_n,{text:t}):e?(0,X.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,X.jsx)(`ol`,{"aria-label":`BASAL's steps`,className:`m-0 grid list-none gap-2 p-0 @[640px]:grid-cols-4 @[1040px]:grid-cols-8`,children:Di.map((e,t)=>(0,X.jsxs)(`li`,{className:L(ot,`flex flex-col gap-1`),children:[(0,X.jsxs)(`span`,{className:`font-mono text-body-sm text-muted`,children:[`STEP `,ji(t+1)]}),(0,X.jsx)(`span`,{className:`text-body-sm font-medium`,children:Oi[e].name})]},e))}),(0,X.jsx)(Li,{g:e.graph}),(0,X.jsx)(Ri,{home:e}),e.tests.length>0&&(0,X.jsx)(J,{id:`basal-recent`,icon:ee,title:`Recent tests`,actions:(0,X.jsx)(`a`,{href:$(`tests`),className:`text-body-sm font-normal`,children:`Every test`}),children:(0,X.jsx)(zi,{tests:e.tests.slice(0,5),search:!1})})]}):(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Loading…`})}function Vi(){let{home:e,error:t,load:n}=Ii();return t?(0,X.jsx)(_n,{text:t}):e?(0,X.jsx)(zi,{tests:e.tests,tools:(0,X.jsxs)(U,{size:`sm`,variant:`ghost`,onClick:()=>void n(),className:`ml-auto`,"data-tip":`Read the tests again`,children:[(0,X.jsx)(C,{"aria-hidden":`true`}),`Refresh`]})}):(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Loading…`})}function Hi({id:e,step:t}){let[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(``),c=(0,Y.useCallback)(()=>R.test(e).then(r,e=>s(e.message)),[e]),l=(0,Y.useCallback)(()=>R.graph(e).then(a,e=>s(`The graph could not be read: ${e.message}`)),[e]);(0,Y.useEffect)(()=>{c(),l()},[c,l]);let u=!(!n?.job||n.job.endedAt);if((0,Y.useEffect)(()=>{if(!u)return;let e=yt(()=>{c(),l()},2500);return()=>{vt(e),l()}},[u,c,l]),!n)return o?(0,X.jsx)(_n,{text:o}):(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Loading…`});let d=ki[n.stage],f=n.job&&!n.job.endedAt?Ai[n.job.stage]:-1,p=t||Di[f>=0?f:Math.min(d,Di.length-1)],m=Di.indexOf(p),h=async(e,t)=>{s(``);try{await e(),await c(),t&&(location.hash=$(`tests`,`${n.id}/${t}`))}catch(e){s(e.message)}},g=e=>e===f?{tone:`running`,word:`Working`}:e<d?{tone:`pass`,word:`Completed`}:e===d?{tone:`warn`,word:`Next`}:{tone:`neutral`,word:`Waiting`},_=g(m);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(dt,{to:{href:$(`tests`),label:`Every test`}}),(0,X.jsx)(`div`,{"data-tip":n.scenario?.decision||n.request.request,children:(0,X.jsx)(Rt,{icon:D,title:n.scenario?.decision||n.request.request,description:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`font-mono`,children:n.id}),` · asked `,n.request.created.slice(0,10),n.strategy?.environment?` · on ${n.strategy.environment}`:``,n.strategy?.approved?` · approved by ${n.strategy.approved.by}`:``]})})})]}),(0,X.jsx)(`nav`,{"aria-label":`BASAL's steps`,className:`overflow-x-auto`,children:(0,X.jsx)(`ol`,{className:`m-0 grid min-w-[800px] list-none grid-cols-8 gap-1 p-0`,children:Di.map((e,t)=>{let r=g(t),i=t<=d||t===f,a=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,X.jsx)(`span`,{className:`font-mono text-body-sm text-muted`,children:ji(t+1)}),(0,X.jsx)(`span`,{className:`text-body-sm font-medium`,children:Oi[e].name})]}),(0,X.jsx)(G,{tone:r.tone,icon:r.tone===`running`,className:`self-start`,children:r.word})]});return(0,X.jsx)(`li`,{className:`min-w-0`,children:i?(0,X.jsx)(`a`,{href:$(`tests`,`${n.id}/${e}`),"aria-current":e===p?`step`:void 0,className:L(ze,`h-full flex-col items-start gap-1`),children:a}):(0,X.jsx)(`span`,{className:`flex h-full flex-col gap-1 px-4 py-2 opacity-60`,children:a})},e)})})}),o&&(0,X.jsx)(_n,{text:o}),(0,X.jsxs)(`div`,{className:`grid items-start gap-4 @[960px]:grid-cols-[minmax(0,1fr)_minmax(0,1.15fr)]`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 @[960px]:sticky @[960px]:top-4`,children:[(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted tabular-nums`,children:i?.connected?`${I(i.nodes.length,`node`)} · ${I(i.edges.length,`edge`)} · scenario over the product graph`:`Graph store not connected`}),(0,X.jsx)(Yi,{graph:i,onRefresh:()=>void R.regraph(e).then(l,e=>s(e.message))})]}),(0,X.jsxs)(`section`,{"aria-labelledby":`basal-step`,className:L(W,`flex min-w-0 flex-col gap-4`),children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(G,{tone:`running`,icon:!1,className:`font-mono`,children:[`STEP `,ji(m+1)]}),(0,X.jsx)(`h3`,{id:`basal-step`,className:`m-0 text-body-lg font-medium`,children:Oi[p].name}),(0,X.jsx)(`span`,{className:`ml-auto`,children:(0,X.jsx)(G,{tone:_.tone,children:_.word})})]}),(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-ink-2`,children:Oi[p].about}),n.job&&Ai[n.job.stage]===m&&(0,X.jsx)(Ji,{t:n}),(0,X.jsx)(Ui,{step:p,t:n,onRun:h})]})]})]})}function Ui({step:e,t,onRun:n}){let r=!(!t.job||t.job.endedAt),i=(e,t,i,a)=>(0,X.jsx)(`div`,{className:`pt-4`,children:(0,X.jsxs)(U,{variant:`primary`,disabled:r,onClick:()=>void n(i,a),"data-tip":t,children:[(0,X.jsx)(N,{"aria-hidden":`true`}),e]})}),a=(e,n)=>(0,X.jsx)(`div`,{className:`pt-4`,children:(0,X.jsxs)(`a`,{href:$(`tests`,`${t.id}/${n}`),className:st({variant:`primary`}),children:[(0,X.jsx)(N,{"aria-hidden":`true`}),e]})});return e===`ask`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:L(ot,`m-0 text-body-sm text-ink [overflow-wrap:anywhere]`),children:t.request.request}),(0,X.jsx)(mn,{label:`Files`,children:t.request.files.length?t.request.files.join(`, `):`none`}),(0,X.jsx)(mn,{label:`Work items`,children:t.request.stories.length?t.request.stories.join(`, `):`none`}),(0,X.jsx)(mn,{label:`Environment`,children:t.request.environment||`the active test environment`}),t.stage===`asked`?i(`Understand the question`,`Reads the request, its files and the product graph into the scenario`,()=>R.stage(t.id,`understand`),`understand`):a(`Next: Understand`,`understand`)]}):e===`understand`?t.scenario?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ra,{t}),t.stage===`understood`?i(`Plan the test strategy`,`Scenarios, the agent for each step, and the business expectations`,()=>R.stage(t.id,`strategy`),`strategy`):a(`Next: Strategy`,`strategy`)]}):(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`BASAL is reading the sources.`}):e===`strategy`?t.strategy?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ta,{t}),t.stage===`planned`?i(`Cast the personas`,`One persona for each stakeholder who acts in the strategy`,()=>R.stage(t.id,`cast`),`cast`):a(`Next: Cast`,`cast`)]}):(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`Not planned yet.`}):e===`cast`?t.cast.length?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(na,{t}),t.stage===`cast`?i(`Play round 1`,`The cast react to the decision on a feed; what they want to try picks the scenarios`,()=>R.stage(t.id,`rehearse`),`rehearse`):a(`Next: Rehearse`,`rehearse`)]}):(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`Not cast yet.`}):e===`rehearse`?(0,X.jsx)(Gi,{t,onRun:n}):e===`approve`?(0,X.jsx)(Ki,{t,onRun:n}):e===`act`?(0,X.jsx)(qi,{t,onRun:n}):t.verdicts.length?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Zi,{t,onObserve:(e,r,i)=>void n(()=>R.observe(t.id,{scenario:e,step:r,...i?{accepted:!0}:{refused:!0}}))}),t.cast.length>0&&i(`Next round: the cast react to these outcomes`,`Round `+(t.rounds.length+1)+`: what the agents saw goes back to the personas`,()=>R.stage(t.id,`rehearse`),`rehearse`)]}):(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`No verdict yet: the strategy has not been played.`})}var Wi={support:`pass`,oppose:`fail`,undecided:`neutral`};function Gi({t:e,onRun:t}){let n=!(!e.job||e.job.endedAt),r=new Map(e.cast.map(e=>[e.id,e.name])),i=e.rounds.at(-1),a=e.rounds.flatMap(e=>e.posts),o=new Map(a.map(e=>[e.id,e]));if(!i)return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`No round yet.`}),(0,X.jsx)(`div`,{className:`pt-4`,children:(0,X.jsxs)(U,{variant:`primary`,disabled:n||!e.cast.length,onClick:()=>void t(()=>R.stage(e.id,`rehearse`)),children:[(0,X.jsx)(x,{"aria-hidden":`true`}),`Play round 1`]})})]});let s={support:0,oppose:0,undecided:0};for(let e of i.turns)s[e.stance]=(s[e.stance]||0)+1;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`m-0 text-body-sm text-muted tabular-nums`,children:[`Round `,i.n,` · `,I(a.length,`post`),` on the feed · `,s.support,` support · `,s.oppose,` oppose · `,s.undecided,` undecided`,i.events.length?` · reacted to ${I(i.events.length,`outcome`)} on the product`:``]}),(0,X.jsx)(J,{icon:ne,title:`Feed`,level:3,children:(0,X.jsx)(`ol`,{className:`m-0 flex max-h-[420px] list-none flex-col gap-2 overflow-y-auto p-0`,children:a.toReversed().map(e=>(0,X.jsxs)(`li`,{className:L(W,`flex flex-col gap-1 text-body-sm`),children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:r.get(e.author)||e.author}),(0,X.jsxs)(`span`,{className:`text-muted`,children:[e.kind,e.target?` on ${r.get(o.get(e.target)?.author||``)||e.target}`:``,` · round `,e.round]})]}),(0,X.jsx)(`span`,{className:`text-ink-2 [overflow-wrap:anywhere]`,children:e.text})]},e.id))})}),(0,X.jsx)(J,{icon:p,title:(0,X.jsxs)(X.Fragment,{children:[`Where the cast stand after round `,i.n]}),level:3,children:(0,X.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0 text-body-sm`,children:i.turns.map(e=>(0,X.jsxs)(`li`,{className:`flex items-start justify-between gap-2`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`font-medium`,children:r.get(e.id)||e.id}),` `,(0,X.jsxs)(`span`,{className:`text-ink-2`,children:[`— `,e.feeling]})]}),(0,X.jsx)(G,{tone:Wi[e.stance]||`neutral`,icon:!1,children:e.stance})]},e.id))})}),e.wanted.length>0&&(0,X.jsx)(J,{icon:A,title:`What the cast want tried`,level:3,className:`text-body-sm`,children:e.wanted.map(e=>(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`font-mono`,children:e.scenario}),` `,(0,X.jsxs)(`span`,{className:`text-muted`,children:[`· `,e.by.map(e=>r.get(e)||e).join(`, `)]})]},e.scenario))}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2 pt-4`,children:[(0,X.jsxs)(`a`,{href:$(`tests`,`${e.id}/${e.strategy?.approved?`act`:`approve`}`),className:st({variant:`primary`}),children:[(0,X.jsx)(N,{"aria-hidden":`true`}),e.strategy?.approved?`Next: Act`:`Next: Approve`]}),(0,X.jsxs)(U,{variant:`outline`,disabled:n,onClick:()=>void t(()=>R.stage(e.id,`rehearse`)),children:[(0,X.jsx)(x,{"aria-hidden":`true`}),`Play round `,i.n+1]})]})]})}function Ki({t:e,onRun:t}){let[n,r]=(0,Y.useState)(``);if(e.strategy?.approved)return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`m-0 text-body-sm text-ink-2`,children:[`Approved by `,e.strategy.approved.by,` on `,e.strategy.approved.at.slice(0,16).replace(`T`,` `),`.`]}),(0,X.jsx)(`div`,{className:`pt-4`,children:(0,X.jsxs)(`a`,{href:$(`tests`,`${e.id}/act`),className:st({variant:`primary`}),children:[(0,X.jsx)(N,{"aria-hidden":`true`}),`Next: Act`]})})]});let i=e.strategy;return(0,X.jsxs)(X.Fragment,{children:[i?(0,X.jsxs)(`ul`,{className:`m-0 flex flex-col gap-1 pl-6 text-body-sm text-ink-2`,children:[(0,X.jsxs)(`li`,{children:[I(i.scenarios.length,`scenario`),` on `,i.environment||`no test environment`,`, `,I(i.scenarios.reduce((e,t)=>e+t.steps.length,0),`step`)]}),(0,X.jsx)(`li`,{children:e.writes.length?`${I(e.writes.length,`step`)} change data: Act lists them for your agreement before anything runs`:`No step changes data`}),(0,X.jsxs)(`li`,{children:[`Plays on:`,` `,[...new Set(i.scenarios.flatMap(e=>e.steps.map(e=>e.app?`${e.app} (${ea[e.channel]})`:ea[e.channel])))].join(`, `)]}),i.needs.length>0&&(0,X.jsxs)(`li`,{className:`text-warn`,children:[I(i.needs.length,`thing`),` still needed: see Strategy`]})]}):null,(0,X.jsxs)(`label`,{className:`flex flex-col gap-2 text-body-sm`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Type the test's id to approve`}),(0,X.jsx)(F,{id:`basal-typed`,value:n,onChange:e=>r(e.target.value),placeholder:`Type the test's id`})]}),(0,X.jsx)(`span`,{className:`font-mono text-body-sm text-muted`,children:e.id}),(0,X.jsx)(`div`,{className:`pt-4`,children:(0,X.jsxs)(U,{variant:`primary`,disabled:n.trim()!==e.id||!i,onClick:()=>void t(()=>R.approve(e.id,n.trim()),`act`),children:[(0,X.jsx)(_,{"aria-hidden":`true`}),`Approve`]})})]})}function qi({t:e,onRun:t}){let[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(!0),o=!(!e.job||e.job.endedAt);if(!e.strategy?.approved)return(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`Approve the strategy first.`});let s=i&&e.wanted.length?e.wanted.map(e=>e.scenario):[];return(0,X.jsxs)(X.Fragment,{children:[e.handovers.length>0&&(0,X.jsx)(Xi,{handovers:e.handovers}),!o&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 pt-4`,children:[e.wanted.length>0&&(0,X.jsxs)(`label`,{className:`flex min-h-9 cursor-pointer items-center gap-2 text-body-sm`,children:[(0,X.jsx)(Ut,{id:`basal-wanted`,checked:i,onCheckedChange:a}),`Only what the cast wants tried after round `,e.rounds.length,`: `,e.wanted.map(e=>e.scenario).join(`, `)]}),e.writes.length>0?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`m-0 text-body-sm text-ink-2`,children:[`These steps change data on `,e.strategy.environment,`. Without your agreement they are skipped and the agents change nothing.`]}),(0,X.jsx)(`ul`,{className:`m-0 flex flex-col gap-1 pl-4 text-body-sm text-warn`,children:e.writes.map(e=>(0,X.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:e},e))}),(0,X.jsxs)(`label`,{className:`flex min-h-9 cursor-pointer items-center gap-2 text-body-sm`,children:[(0,X.jsx)(Ut,{id:`basal-writes`,checked:n,onCheckedChange:r}),`Let these steps change data`]})]}):(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-ink-2`,children:`No step changes data.`}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsxs)(U,{variant:`primary`,onClick:()=>void t(()=>R.act(e.id,n?e.writes:[],s)),"data-tip":`Hands each step to ForgeQE's agents as its persona`,children:[(0,X.jsx)(x,{"aria-hidden":`true`}),e.verdicts.length?`Play it again`:`Act`]}),e.verdicts.length>0&&(0,X.jsxs)(`a`,{href:$(`tests`,`${e.id}/judge`),className:st({variant:`outline`}),children:[(0,X.jsx)(N,{"aria-hidden":`true`}),`Next: Judge`]})]})]})]})}function Ji({t:e}){let t=e.job;return(0,X.jsxs)(J,{id:`basal-feed`,icon:te,title:(0,X.jsxs)(X.Fragment,{children:[`Live · `,t.stage]}),level:3,className:W,actions:t.endedAt?(0,X.jsx)(G,{tone:t.error?`fail`:`pass`,children:t.error?`stopped`:`finished`}):(0,X.jsx)(G,{tone:`running`,children:`working`}),children:[(0,X.jsx)(`ol`,{"aria-live":`polite`,className:`m-0 flex max-h-64 list-none flex-col gap-1 overflow-y-auto p-0 text-body-sm text-ink-2`,children:t.lines.slice(-40).map((e,t)=>(0,X.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:e},t))}),t.error&&(0,X.jsx)(_n,{text:t.error})]})}function Yi({graph:e,onRefresh:t}){let[n,r]=(0,Y.useState)(null),{nodes:a,edges:o,types:s}=(0,Y.useMemo)(()=>{let t=(e?.nodes||[]).map(e=>({id:e.id,name:e.type===`fact`?``:e.name.length>34?`${e.name.slice(0,32).trimEnd()}…`:e.name,type:e.layer===`product`?`product ${e.type}`:e.type}));return{nodes:t,edges:(e?.edges||[]).map((e,t)=>({id:`e${t}`,from:e.from,to:e.to,label:e.type})),types:[...new Set(t.map(e=>e.type))]}},[e]),c=e=>fn[Math.max(0,s.indexOf(e))%fn.length],l=null;if(n?.kind===`node`){let t=e?.nodes.find(e=>e.id===n.id);t&&(l={title:t.name,pill:{text:t.layer===`product`?`product ${t.type}`:t.type,colour:c(t.layer===`product`?`product ${t.type}`:t.type)},body:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`m-0 text-ink [overflow-wrap:anywhere]`,children:t.summary}),(0,X.jsx)(mn,{label:`Layer`,children:t.layer}),t.state&&(0,X.jsx)(mn,{label:`Evidence`,children:t.state})]})})}return e?.connected?a.length?(0,X.jsx)(pn,{title:`Live knowledge graph`,nodes:a,edges:o,colourOfType:c,types:s,typesTitle:`Node types`,picked:n,onPick:r,detail:l,onRefresh:t}):(0,X.jsx)(ut,{icon:i,title:`No scenario in the graph yet`,children:`It appears once BASAL has understood the question.`}):(0,X.jsx)(ut,{icon:i,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 Xi({handovers:e}){let t=new Map;for(let n of e)t.set(`${n.scenario}#${n.step}`,n);let n=[...t.values()],r=e=>e.state===`started`?`running`:e.state===`waiting`?`warn`:e.state===`skipped`?`neutral`:e.outcome===`accepted`?`pass`:e.outcome===`refused`?`fail`:`neutral`,i=e=>e.state===`started`?`in progress`:e.state===`waiting`?`waiting for you`:e.state===`skipped`?`skipped`:e.outcome||`done`;return(0,X.jsx)(J,{id:`basal-board`,icon:j,title:`Operations board`,level:3,description:`Each card is a handover from BASAL to one of ForgeQE's agents, as one persona.`,children:(0,X.jsx)(`div`,{className:`grid gap-2 @[1200px]:grid-cols-2`,children:Mi.filter(e=>n.some(t=>t.channel===e.channel)).map(e=>{let t=n.filter(t=>t.channel===e.channel);return(0,X.jsxs)(`div`,{className:L(ot,`flex min-w-0 flex-col gap-2`),children:[(0,X.jsxs)(`h4`,{className:`m-0 px-2 pt-1 text-body-sm font-medium`,children:[e.title,` `,(0,X.jsxs)(`span`,{className:`font-normal text-muted`,children:[`· `,t.length]})]}),t.map(e=>(0,X.jsxs)(`div`,{className:L(W,`flex flex-col gap-1 text-body-sm`),children:[(0,X.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`truncate font-medium`,children:e.actor}),(0,X.jsx)(G,{tone:r(e),children:i(e)})]}),(0,X.jsxs)(`span`,{className:`text-muted`,children:[(0,X.jsx)(`span`,{className:`font-mono`,children:e.scenario}),` · step `,e.step]}),e.note&&(0,X.jsx)(`span`,{className:`text-ink-2 [overflow-wrap:anywhere]`,children:e.note}),e.run&&(0,X.jsx)(`span`,{className:`font-mono text-muted`,children:e.run})]},`${e.scenario}#${e.step}`))]},e.channel)})})})}function Zi({t:e,onObserve:t}){let n=e.verdicts.toSorted((e,t)=>Pi.indexOf(e.outcome)-Pi.indexOf(t.outcome));return(0,X.jsx)(`section`,{"aria-label":`Verdicts`,className:`flex flex-col gap-2`,children:(0,X.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:n.map(e=>(0,X.jsx)(Qi,{v:e,onObserve:(n,r)=>t(e.scenario,n,r)},e.scenario))})})}function Qi({v:e,onObserve:t}){return(0,X.jsxs)(`li`,{className:L(W,`flex flex-col gap-2`),children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(G,{tone:Ni[e.outcome],children:e.label}),(0,X.jsx)(`span`,{className:`text-body-sm font-medium`,children:e.title}),(0,X.jsxs)(`span`,{className:`text-body-sm text-muted`,children:[`· confidence `,e.confidence]})]}),(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-ink-2 [overflow-wrap:anywhere]`,children:e.why}),e.results.length>0&&(0,X.jsx)(`ul`,{className:`m-0 flex flex-col gap-1 pl-4 text-body-sm`,children:e.results.map(e=>(0,X.jsxs)(`li`,{className:L(e.status===`violated`?`text-fail`:e.status===`held`?`text-ink`:`text-muted`),children:[e.status===`held`?`Held`:e.status===`violated`?`Broken`:`Not known`,`: `,e.says,e.detail?` — ${e.detail}`:``]},e.id))}),t&&e.pending.map(e=>(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-body-sm text-warn`,children:[`Step `,e,` waits for a person:`,(0,X.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>t(e,!0),children:`The app let them do it`}),(0,X.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>t(e,!1),children:`The app refused it`})]},e))]})}var $i=e=>e.map(e=>e.trim().replace(/(?<![.;])[.;]+$/,``)).join(`; `),ea={browser:`browser`,api:`API`,mobile:`mobile`,desktop:`desktop`,person:`a person`,opinion:`opinion`};function ta({t:e}){let t=e.strategy;return(0,X.jsxs)(`section`,{"aria-label":`Strategy`,className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`p`,{className:`m-0 text-body-sm text-muted`,children:[I(t.scenarios.length,`scenario`),` on `,t.environment||`no test environment`,` · `,I(t.rounds,`round`)]}),t.needs.length>0&&(0,X.jsx)(`ul`,{"aria-label":`What the strategy still needs`,className:`m-0 flex flex-col gap-1 pl-6 text-body-sm text-warn`,children:t.needs.map(e=>(0,X.jsx)(`li`,{children:e},e))}),(0,X.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:t.scenarios.map(e=>(0,X.jsxs)(`li`,{className:L(W,`flex flex-col gap-2`),children:[(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(G,{tone:e.priority===1?`warn`:`neutral`,icon:!1,children:[`P`,e.priority,` · `,e.risk]}),(0,X.jsx)(`span`,{className:`text-body-sm font-medium`,children:e.title})]}),(0,X.jsx)(`p`,{className:`m-0 text-body-sm text-ink-2`,children:e.question}),(0,X.jsx)(`ol`,{className:`m-0 flex flex-col gap-1 pl-6 text-body-sm`,children:e.steps.map(e=>(0,X.jsxs)(`li`,{className:`[overflow-wrap:anywhere]`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.actor}),` `,(0,X.jsxs)(`span`,{className:`text-muted`,children:[`· `,ea[e.channel],e.app?` ${e.app}`:``,e.changes_data?` · changes data`:``]}),` — `,e.does]},e.n))}),e.oracles.length>0&&(0,X.jsx)(`ul`,{"aria-label":`Business expectations`,className:`m-0 flex flex-col gap-1 pl-4 text-body-sm text-ink-2`,children:e.oracles.map(e=>(0,X.jsxs)(`li`,{children:[e.says,` `,(0,X.jsxs)(`span`,{className:`text-muted`,children:[`(`,e.basis,`)`]})]},e.id))})]},e.id))})]})}function na({t:e}){return(0,X.jsx)(`section`,{"aria-label":`Cast`,className:`flex flex-col gap-2`,children:(0,X.jsx)(`ul`,{className:`m-0 grid list-none gap-2 p-0 @[1100px]:grid-cols-2`,children:e.cast.map(e=>(0,X.jsxs)(`li`,{className:L(W,`flex flex-col gap-1 text-body-sm`),children:[(0,X.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,X.jsx)(G,{tone:e.intent===`legitimate`?`neutral`:`warn`,icon:!1,children:e.intent})]}),(0,X.jsx)(`span`,{className:`text-muted`,children:e.role}),e.validates.length>0&&(0,X.jsxs)(`span`,{className:`text-ink-2`,children:[`Checks: `,$i(e.validates)]}),e.frustrations.length>0&&(0,X.jsxs)(`span`,{className:`text-ink-2`,children:[`Objects to: `,$i(e.frustrations)]}),e.mistakes.length>0&&(0,X.jsxs)(`span`,{className:`text-ink-2`,children:[`Brings: `,$i(e.mistakes)]})]},e.id))})})}function ra({t:e}){let t=e.scenario,n=e=>(0,X.jsx)(G,{tone:e===`observed`?`pass`:`neutral`,icon:!1,children:e});return(0,X.jsxs)(`section`,{"aria-label":`What BASAL understood`,className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[(0,X.jsxs)(`div`,{className:L(W,`flex flex-col gap-1 text-body-sm`),children:[(0,X.jsx)(Rt,{icon:ie,title:`Success criteria`,level:3}),t.criteria.map(e=>(0,X.jsxs)(`span`,{className:`flex items-start justify-between gap-2`,children:[(0,X.jsxs)(`span`,{children:[e.text,e.measure?(0,X.jsxs)(`span`,{className:`text-muted`,children:[` (`,e.measure,`)`]}):null]}),n(e.evidence)]},e.id))]}),(0,X.jsxs)(`div`,{className:L(W,`flex flex-col gap-1 text-body-sm`),children:[(0,X.jsx)(Rt,{icon:p,title:`Stakeholders`,level:3}),t.stakeholders.map(e=>(0,X.jsxs)(`span`,{className:`flex items-start justify-between gap-2`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.name}),` `,(0,X.jsxs)(`span`,{className:`text-muted`,children:[`· `,e.kind]}),` — `,e.cares]}),n(e.evidence)]},e.id))]})]}),(0,X.jsxs)(`div`,{className:L(W,`flex flex-col gap-1 text-body-sm`),children:[(0,X.jsx)(Rt,{icon:re,title:`Facts (${t.facts.length})`,level:3}),t.facts.map(e=>(0,X.jsxs)(`span`,{className:`flex items-start justify-between gap-2`,children:[(0,X.jsxs)(`span`,{className:`[overflow-wrap:anywhere]`,children:[e.text,e.about.length?(0,X.jsxs)(`span`,{className:`text-muted`,children:[` → `,e.about.join(`, `)]}):null]}),n(e.evidence)]},e.id))]})]})}function ia(){let{home:e,error:t}=Ii(),[n,r]=(0,Y.useState)(null);return(0,Y.useEffect)(()=>{e&&Promise.all(e.tests.slice(0,8).map(e=>R.test(e.id).catch(()=>null))).then(e=>r(e.filter(e=>!!(e&&e.cast.length))))},[e]),t?(0,X.jsx)(_n,{text:t}):n?n.length?(0,X.jsx)(`div`,{className:`flex flex-col gap-6`,children:n.map(e=>(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`a`,{href:$(`tests`,e.id),className:`text-body-sm font-medium`,children:e.scenario?.decision||e.request.request}),(0,X.jsx)(na,{t:e})]},e.id))}):(0,X.jsx)(ut,{icon:i,title:`No cast yet`,children:`A test is cast after its strategy is planned.`}):(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Loading…`})}function aa(){let{home:e,error:t}=Ii(),[n,r]=(0,Y.useState)(null);return(0,Y.useEffect)(()=>{e&&Promise.all(e.tests.slice(0,12).map(e=>R.test(e.id).catch(()=>null))).then(e=>r(e.filter(e=>!!e).flatMap(e=>e.verdicts.map(t=>({t:e,v:t}))).sort((e,t)=>Pi.indexOf(e.v.outcome)-Pi.indexOf(t.v.outcome))))},[e]),t?(0,X.jsx)(_n,{text:t}):n?n.length?(0,X.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:n.map(({t:e,v:t})=>(0,X.jsx)(Qi,{v:{...t,title:`${t.title} — ${e.scenario?.decision.slice(0,80)||e.id}`}},`${e.id}#${t.scenario}`))}):(0,X.jsx)(ut,{icon:i,title:`No verdict yet`,children:`A verdict appears when a test's strategy has been played.`}):(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Loading…`})}function oa({to:e}){return(0,Y.useEffect)(()=>location.replace(`#${e.replace(/^#/,``)}`),[e]),null}function sa({id:e}){if(!e)return(0,X.jsx)(cn,{});let[t,n,r,...i]=e.split(`/`);if(t===`custom`&&n===`new`&&r===`template`&&i.length===1&&/^[a-z][a-z0-9-]{0,39}$/.test(i[0]))return(0,X.jsx)(xr,{template:i[0]},i[0]);if(t===`custom`&&!i.length){if(n===`new`&&r===void 0)return(0,X.jsx)(Sn,{});if(n===`new`&&r===`form`)return(0,X.jsx)(xr,{});if(n===`build`&&r&&/^[a-f0-9]{16}$/.test(r))return(0,X.jsx)(wn,{sid:r},r);if(n&&et.test(n)&&r===void 0)return(0,X.jsx)(Sr,{id:n},n);if(n&&et.test(n)&&r===`edit`)return(0,X.jsx)(xr,{id:n},n)}let[a,o,...s]=(e||``).split(`/`);if(a===`business`)return(0,X.jsx)(oa,{to:M(`agents`,`basal`)});if(a&&Object.hasOwn(nt,a))return(0,X.jsx)(oa,{to:M(`agents`,nt[a])});let c=tt(a),l=o===`tools`||o===`conversations`;return c?.id===`persona`&&o===void 0?(0,X.jsx)(Kt,{agent:c,tabs:(0,X.jsx)(Qr,{current:`agent`})},c.id):c?.id===`persona`&&!l?(0,X.jsx)(ni,{page:c,tab:o,sub:s.join(`/`)},`${c.id}/${o}`):c?.opens&&!l?(0,X.jsx)(ca,{to:M(...c.opens,...[o,...s].filter(e=>!!e))}):c?.id===`basal`&&!l?(0,X.jsx)(Fi,{page:c,tab:o,sub:s.join(`/`)},c.id):a===`category`&&!s.length&&rt(o)?o===`custom`?(0,X.jsx)(cn,{only:`custom`},`custom`):(0,X.jsx)(ca,{to:M(`agents`)}):c&&o===`tools`&&!s.length?(0,X.jsx)(an,{page:c},c.id):c&&o===`conversations`&&!s.length?(0,X.jsx)($t,{page:c},c.id):!c||o!==void 0?(0,X.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,X.jsx)(At,{}),(0,X.jsxs)(`p`,{className:`m-0 px-6 py-10 text-body-sm text-muted`,children:[`There is no such agent. `,(0,X.jsx)(`a`,{href:M(`agents`),children:`See every agent`}),`, or `,(0,X.jsx)(`a`,{href:M(),children:`start a chat`}),` instead.`]})]}):(0,X.jsx)(Kt,{agent:c,below:(0,X.jsx)(qt,{page:c})},c.id)}function ca({to:e}){return(0,Y.useEffect)(()=>{location.replace(e)},[e]),null}export{sa as Agent};