@capagents/forgeqe 3.3.8 → 3.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/HOW_TO_USE.md +92 -0
  2. package/dist/a11y-runtime.mjs +3204 -0
  3. package/dist/docs-site/docs/area-quality/index.html +90 -2
  4. package/dist/docs-site/docs/overview/index.html +1 -1
  5. package/dist/docs-site/docs/search.js +1 -1
  6. package/dist/forgeqe.js +2215 -2094
  7. package/dist/template.html +69 -70
  8. package/dist/web/assets/{3d-force-graph-bqf5EzgX.js → 3d-force-graph-BPsVSYjw.js} +1 -1
  9. package/dist/web/assets/Agent-DY6pRvcD.js +10 -0
  10. package/dist/web/assets/{AgentWork-Dqa1UKaU.js → AgentWork-Brch_Mn3.js} +1 -1
  11. package/dist/web/assets/ApiTests-BtWKVPw5.js +17 -0
  12. package/dist/web/assets/{Browse-W54t28gX.js → Browse-DbIFxsy8.js} +1 -1
  13. package/dist/web/assets/Chat-BWiH0XGV.js +3 -0
  14. package/dist/web/assets/{CommandPalette-DnIxy2ga.js → CommandPalette-DfoEUEL6.js} +1 -1
  15. package/dist/web/assets/{Compare-VdisgqmY.js → Compare-DTZ_BW1P.js} +1 -1
  16. package/dist/web/assets/Cost-DDghPWch.js +1 -0
  17. package/dist/web/assets/Data-DZlKsTwA.js +6 -0
  18. package/dist/web/assets/Desktop-DTIZ62Pi.js +1 -0
  19. package/dist/web/assets/DesktopReview-B8-dSGJH.js +2 -0
  20. package/dist/web/assets/Evidence-BYw_Q4Ul.js +1 -0
  21. package/dist/web/assets/Explore-BL_c5WK1.js +2 -0
  22. package/dist/web/assets/{Features-CIhQJMAK.js → Features-DrFNrvbh.js} +1 -1
  23. package/dist/web/assets/Flags-CHrDwhqG.js +2 -0
  24. package/dist/web/assets/Flaky-DtcLf8h6.js +1 -0
  25. package/dist/web/assets/Impact-CMU_ijo2.js +3 -0
  26. package/dist/web/assets/Jobs-BjybdQb_.js +5 -0
  27. package/dist/web/assets/KindPage-VK-Vgkzv.js +6 -0
  28. package/dist/web/assets/{LiveDevice-CZZRu6xl.js → LiveDevice-BqL1P33F.js} +1 -1
  29. package/dist/web/assets/Migration-7BI7iXIv.js +8 -0
  30. package/dist/web/assets/Mobile-AgAhvlVL.js +1 -0
  31. package/dist/web/assets/Observability-5r36Xf3d.js +1 -0
  32. package/dist/web/assets/{OwnItems-BinKnGAs.js → OwnItems-CqCOuvba.js} +4 -4
  33. package/dist/web/assets/PageAgent-00NQxK49.js +1 -0
  34. package/dist/web/assets/Product-B75ztJFn.js +6 -0
  35. package/dist/web/assets/Production-lIUlcjf0.js +1 -0
  36. package/dist/web/assets/Quality-BlRpB6mx.js +1 -0
  37. package/dist/web/assets/Readiness-CesaSDtp.js +1 -0
  38. package/dist/web/assets/Record-CLy9jQ5N.js +1 -0
  39. package/dist/web/assets/Regression-BjpZrkfK.js +5 -0
  40. package/dist/web/assets/{RelationGraph-CszRGlEp.js → RelationGraph-ClPBGuMw.js} +1 -1
  41. package/dist/web/assets/{Reports-BPD6ODz4.js → Reports-Du8SNiHM.js} +2 -2
  42. package/dist/web/assets/Requirements-Dr1iLoMc.js +2 -0
  43. package/dist/web/assets/Responsive-DcD6MLzG.js +3 -0
  44. package/dist/web/assets/{RunDiff-aEt4BZYX.js → RunDiff-cLSFOsfC.js} +1 -1
  45. package/dist/web/assets/{Settings-D188FdLb.js → Settings-CUT5ggDd.js} +16 -16
  46. package/dist/web/assets/SiteScan-iUfWBeLV.js +5 -0
  47. package/dist/web/assets/{Steps-CgQ8E_Vv.js → Steps-DJYwIiDu.js} +2 -2
  48. package/dist/web/assets/{TestData-Dj73b-hW.js → TestData-DqEcL5o4.js} +2 -2
  49. package/dist/web/assets/TestManagement-mBcfWTVH.js +4 -0
  50. package/dist/web/assets/{WhatsNew-D-5E8NFV.js → WhatsNew-DrPf6l9-.js} +1 -1
  51. package/dist/web/assets/{agentSettingsSheet-5JMUsoLi.js → agentSettingsSheet-DyaVNewv.js} +1 -1
  52. package/dist/web/assets/api-Dr3U7W5w.js +1 -0
  53. package/dist/web/assets/{choice-C4-yW2x9.js → choice-W0qOx_1k.js} +1 -1
  54. package/dist/web/assets/{coverage-pqIlfEP0.js → coverage-DbHm8BUP.js} +3 -3
  55. package/dist/web/assets/{dataParts-bqVlyE0X.js → dataParts-Bdf97ZOD.js} +3 -3
  56. package/dist/web/assets/{desktopAppPath-BDSG0kvw.js → desktopAppPath-kQmQOW6a.js} +1 -1
  57. package/dist/web/assets/{flowTheme-DU5XjJr-.js → flowTheme-CVnIjV_m.js} +1 -1
  58. package/dist/web/assets/frame-CavkQick.js +13 -0
  59. package/dist/web/assets/index-BaEsXdFc.css +2 -0
  60. package/dist/web/assets/index-C1kXcI0E.js +57 -0
  61. package/dist/web/assets/line-icons-Cwj9OmCz.js +1 -0
  62. package/dist/web/assets/{logos-P2LOMyTK.js → logos-Cf-Wf5ex.js} +1 -1
  63. package/dist/web/assets/{markdown-DgUpsCX8.js → markdown-Bvv6oj4v.js} +3 -3
  64. package/dist/web/assets/{nav-IMBXh0Jg.js → nav-DVPiPhOy.js} +1 -1
  65. package/dist/web/assets/pageBack-Blig1Uqs.js +3 -0
  66. package/dist/web/assets/{palette-CeG8IIbL.js → palette-DwrGI2Fp.js} +1 -1
  67. package/dist/web/assets/{paletteCommands-Isq1rLs-.js → paletteCommands-DOF2o-rv.js} +1 -1
  68. package/dist/web/assets/parts-DgJ2y_ic.js +1 -0
  69. package/dist/web/assets/{productParts-ClDOvIlz.js → productParts-B78jij3z.js} +1 -1
  70. package/dist/web/assets/qualityParts-t5t9kEKG.js +2 -0
  71. package/dist/web/assets/{recordTest-BBDRjct0.js → recordTest-BbXVOuGZ.js} +1 -1
  72. package/dist/web/assets/{route-oDy8sV6H.js → route-9BkoTWUE.js} +1 -1
  73. package/dist/web/assets/{sectionList-B651VPon.js → sectionList-DMyhAqst.js} +1 -1
  74. package/dist/web/assets/{step-mark-CaKf4dAR.js → step-mark-Bu6fNKW8.js} +1 -1
  75. package/dist/web/assets/stepper-CE4yOLqn.js +1 -0
  76. package/dist/web/assets/wizardParts-Bxb9UG5k.js +1 -0
  77. package/dist/web/index.html +11 -11
  78. package/docs/ForgeQE-Static-Analysis-Report-4008e9ee.html +207 -0
  79. package/docs/ForgeQE-Static-Analysis-Report-4008e9ee.pdf +0 -0
  80. package/docs/user-guide.html +89 -1
  81. package/forgeqe.example.yaml +1 -1
  82. package/package.json +2 -2
  83. package/prompts/brain.md +7 -0
  84. package/py/forgeqe_engine/cli.py +57 -0
  85. package/py/forgeqe_engine/diagnostics.py +32 -2
  86. package/py/forgeqe_engine/logins.py +11 -0
  87. package/py/forgeqe_engine/persona.py +90 -1
  88. package/py/forgeqe_engine/scan.py +202 -0
  89. package/py/forgeqe_engine/seo.py +95 -0
  90. package/py/forgeqe_engine/seo_analytics.mjs +59 -0
  91. package/py/forgeqe_engine/seo_facts.mjs +63 -0
  92. package/py/forgeqe_engine/seo_site.mjs +36 -0
  93. package/py/forgeqe_engine/service.py +3 -2
  94. package/dist/web/assets/Agent-8Y47YLdR.js +0 -10
  95. package/dist/web/assets/ApiTests-BOdFugGs.js +0 -17
  96. package/dist/web/assets/Chat-DiIxGONU.js +0 -3
  97. package/dist/web/assets/Cost-qfQZZB7-.js +0 -1
  98. package/dist/web/assets/Data-CDyRsQ0U.js +0 -6
  99. package/dist/web/assets/Desktop-DEYZusRQ.js +0 -1
  100. package/dist/web/assets/DesktopReview-4YU21PCr.js +0 -2
  101. package/dist/web/assets/Evidence-l0_yQUpE.js +0 -1
  102. package/dist/web/assets/Explore-DkybdJjI.js +0 -2
  103. package/dist/web/assets/Flags-OCOPCt4-.js +0 -2
  104. package/dist/web/assets/Flaky-B9EYZK9j.js +0 -1
  105. package/dist/web/assets/Impact-BXDjDf_Q.js +0 -3
  106. package/dist/web/assets/Jobs-COZhEsxq.js +0 -5
  107. package/dist/web/assets/KindPage-DIeBVPZA.js +0 -6
  108. package/dist/web/assets/Migration-BTCG2m5B.js +0 -8
  109. package/dist/web/assets/Mobile-CLT5OlqS.js +0 -1
  110. package/dist/web/assets/Observability-Nd9uj2hQ.js +0 -1
  111. package/dist/web/assets/PageAgent-DrELdLct.js +0 -1
  112. package/dist/web/assets/Product-1SMtAUqO.js +0 -6
  113. package/dist/web/assets/Production-C5q3LjAR.js +0 -1
  114. package/dist/web/assets/Quality-DVb1L07l.js +0 -1
  115. package/dist/web/assets/Readiness-BN1VQDip.js +0 -1
  116. package/dist/web/assets/Record-C8ohbDBp.js +0 -1
  117. package/dist/web/assets/Regression-mAzdSpwD.js +0 -5
  118. package/dist/web/assets/Requirements-D1xVywdV.js +0 -2
  119. package/dist/web/assets/Responsive-DnK0Myzs.js +0 -3
  120. package/dist/web/assets/TestManagement-DxPMUroR.js +0 -4
  121. package/dist/web/assets/api-D_HT-I9y.js +0 -1
  122. package/dist/web/assets/frame-Dt9QcYNX.js +0 -13
  123. package/dist/web/assets/index-BdWLAq_n.js +0 -57
  124. package/dist/web/assets/index-CpAtlS2x.css +0 -2
  125. package/dist/web/assets/line-icons-CwCZidXs.js +0 -1
  126. package/dist/web/assets/pageBack-DwhsvsK7.js +0 -3
  127. package/dist/web/assets/parts-DVUUpFdW.js +0 -1
  128. package/dist/web/assets/qualityParts-DF3ZMgo5.js +0 -1
  129. package/dist/web/assets/stepper-uX1iUWez.js +0 -1
  130. package/dist/web/assets/wizardParts-qs3g8O6h.js +0 -1
@@ -1,2 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./react-BDur5s0O.js";import{r as n}from"./route-oDy8sV6H.js";import{B as r,F as i,L as a,a as o,l as s}from"./preload-helper-BupTYkQW.js";import{n as c,t as l}from"./utils-DJRAScIl.js";import{t as u}from"./jsx-runtime-LKYXHABd.js";import{U as d}from"./palette-CeG8IIbL.js";import{Y as f,w as p,y as m}from"./api-D_HT-I9y.js";import{C as h,_ as g,f as _,g as v,h as ee,x as y}from"./pageBack-DwhsvsK7.js";import{Bt as b,Fr as te,Ln as x,Lr as S,Mn as C,N as w,Pn as T,Rr as ne,a as E,an as D,et as re,f as O,jr as k,mn as ie,st as A,vn as ae,w as j,yr as oe,z as se}from"./line-icons-CwCZidXs.js";import{Jt as ce,Mt as M,Yt as le,dt as N,ft as ue}from"./frame-Dt9QcYNX.js";import{t as de}from"./when-BuWCTaKm.js";import{t as fe}from"./code-Jek8uWUO.js";import{n as pe}from"./markdown-DgUpsCX8.js";import{X as me,Y as P}from"./index-BdWLAq_n.js";import{o as he}from"./dataParts-bqVlyE0X.js";var F=e(t(),1),I=u(),ge={click:[`target`,`timeout`,`note`],double_click:[`target`,`timeout`,`note`],type:[`target`,`text`,`timeout`,`note`],select:[`target`,`value`,`timeout`,`note`],keys:[`keys`,`note`],expect:[`target`,`text`,`timeout`,`note`],wait:[`seconds`,`note`],wait_for:[`target`,`text`,`timeout`,`note`],launch:[`timeout`,`note`],close:[`note`],expect_image:[`timeout`,`note`]};function _e({p:e}){return(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsx)(`ul`,{className:`m-0 flex flex-col gap-1 pl-6 text-body-sm text-ink-2`,children:e.summary.map((e,t)=>(0,I.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:e},t))}),(0,I.jsx)(`pre`,{className:l(fe,`m-0 max-h-[200px]`),children:e.diff.map((e,t)=>(0,I.jsx)(`span`,{className:l(`block`,e.startsWith(`+`)?`text-pass`:e.startsWith(`-`)?`text-fail`:`text-muted`),children:e},t))})]})}function L({label:e,children:t}){return(0,I.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-body-sm font-medium`,children:[e,t]})}function ve({workflow:e,step:t,mode:n,onDone:r,onCancel:a}){let s=ge[t.op]??[`note`],c=t.fields??{},[u,d]=(0,F.useState)({automation_id:c.target?.automation_id??``,name:c.target?.name??``,control_type:c.target?.control_type??``}),[f,m]=(0,F.useState)(c.text??``),[g,_]=(0,F.useState)(c.value??``),[v,ee]=(0,F.useState)(c.keys??``),[b,te]=(0,F.useState)(c.seconds===void 0?``:String(c.seconds)),[x,S]=(0,F.useState)(c.timeout===void 0?``:String(c.timeout)),[w,T]=(0,F.useState)(c.note??``),[E,D]=(0,F.useState)(null),[re,O]=(0,F.useState)(``),[k,ie]=(0,F.useState)(!1),A=()=>{let e={};return s.includes(`target`)&&(u.automation_id!==(c.target?.automation_id??``)||u.name!==(c.target?.name??``)||u.control_type!==(c.target?.control_type??``))&&(e.target=u),s.includes(`text`)&&f!==(c.text??``)&&(e.text=f),s.includes(`value`)&&g!==(c.value??``)&&(e.value=g),s.includes(`keys`)&&v!==(c.keys??``)&&(e.keys=v),s.includes(`seconds`)&&b!==(c.seconds===void 0?``:String(c.seconds))&&(e.seconds=Number(b)),s.includes(`timeout`)&&x!==(c.timeout===void 0?``:String(c.timeout))&&x.trim()&&(e.timeout=Number(x)),s.includes(`note`)&&w!==(c.note??``)&&(e.note=w),e},ae=async i=>{ie(!0),O(``);try{let a=await p.editStep({workflow:e,step:t.n,action:n,...n===`edit`?{fields:A()}:{},...i?{version:i}:{}});a.written?r():D(a)}catch(e){O(e.message)}finally{ie(!1)}};(0,F.useEffect)(()=>{n===`remove`&&ae()},[]);let se=()=>D(null);return(0,I.jsxs)(`div`,{className:l(o,`mb-2 ml-10 flex flex-col gap-4`),children:[n===`edit`&&!E&&(0,I.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,180px),1fr))] gap-2`,children:[s.includes(`target`)&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(L,{label:`Control's name`,children:(0,I.jsx)(i,{size:`sm`,value:u.name,maxLength:300,onChange:e=>(d({...u,name:e.target.value}),se())})}),(0,I.jsx)(L,{label:`Automation id`,children:(0,I.jsx)(i,{size:`sm`,value:u.automation_id,maxLength:300,spellCheck:!1,onChange:e=>(d({...u,automation_id:e.target.value}),se()),className:`font-mono text-body-sm`})}),(0,I.jsx)(L,{label:`Control type`,children:(0,I.jsx)(i,{size:`sm`,value:u.control_type,maxLength:60,spellCheck:!1,placeholder:`Button`,onChange:e=>(d({...u,control_type:e.target.value}),se())})})]}),s.includes(`text`)&&(0,I.jsx)(L,{label:t.op===`type`?`Text to type`:`Text it shows`,children:(0,I.jsx)(i,{size:`sm`,value:f,maxLength:500,onChange:e=>m(e.target.value)})}),s.includes(`value`)&&(0,I.jsx)(L,{label:`Item to choose`,children:(0,I.jsx)(i,{size:`sm`,value:g,maxLength:500,onChange:e=>_(e.target.value)})}),s.includes(`keys`)&&(0,I.jsx)(L,{label:`Keys`,children:(0,I.jsx)(i,{size:`sm`,value:v,maxLength:100,spellCheck:!1,placeholder:`ctrl+s`,onChange:e=>ee(e.target.value),className:`font-mono text-body-sm`})}),s.includes(`seconds`)&&(0,I.jsx)(L,{label:`Wait (seconds)`,children:(0,I.jsx)(i,{size:`sm`,type:`number`,min:0,max:600,value:b,onChange:e=>te(e.target.value)})}),s.includes(`timeout`)&&(0,I.jsx)(L,{label:`Timeout (seconds)`,children:(0,I.jsx)(i,{size:`sm`,type:`number`,min:0,max:600,value:x,placeholder:`default`,onChange:e=>S(e.target.value)})}),s.includes(`note`)&&(0,I.jsx)(L,{label:`Note`,children:(0,I.jsx)(i,{size:`sm`,value:w,maxLength:200,onChange:e=>T(e.target.value)})})]}),n===`remove`&&!E&&!re&&(0,I.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Working out the change…`}),E&&(0,I.jsx)(_e,{p:E}),re&&(0,I.jsx)(`p`,{role:`alert`,className:l(h.fail,`m-0`),children:re}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[E?(0,I.jsxs)(y,{busy:k,size:`sm`,variant:n===`remove`?`destructive`:`primary`,disabled:k,onClick:()=>void ae(E.version),children:[n===`remove`?(0,I.jsx)(oe,{"aria-hidden":`true`}):(0,I.jsx)(j,{"aria-hidden":`true`}),k?`Saving…`:n===`remove`?`Delete step ${t.n}`:`Save the change`]}):n===`edit`&&(0,I.jsx)(y,{busy:k,size:`sm`,variant:`primary`,disabled:k||!Object.keys(A()).length,onClick:()=>void ae(),children:k?`Checking…`:`Preview the change`}),E&&n===`edit`&&(0,I.jsxs)(y,{size:`sm`,onClick:()=>D(null),children:[(0,I.jsx)(C,{"aria-hidden":`true`}),`Change it more`]}),(0,I.jsxs)(y,{size:`sm`,variant:`ghost`,onClick:a,children:[(0,I.jsx)(ne,{"aria-hidden":`true`}),`Cancel`]})]})]})}function R(e,t){let n={values:{},secrets:{}};for(let r of e?.inputs??[])r.kind!==`data`&&r.env&&t.includes(r.env)&&(n.secrets[r.name]=r.env);return n}function z(e,t){return(e?.inputs??[]).every(e=>e.kind===`data`?e.default!==void 0||!!t.values[e.name]?.trim():!!t.secrets[e.name])}function B(e){return{values:Object.fromEntries(Object.entries(e.values).filter(([,e])=>e.trim())),secrets:e.secrets}}function V({block:e,secrets:t,use:n,onChange:r,disabled:o,unset:s=[]}){return e.inputs.length?(0,I.jsxs)(`fieldset`,{className:`m-0 flex min-w-0 flex-col gap-2 border-0 p-0`,children:[(0,I.jsx)(`legend`,{className:`mb-1 p-0 text-body-sm font-medium text-ink-2`,children:`What the block types`}),e.inputs.map(e=>{let c=e.label||e.name;return e.kind===`data`?(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm text-ink-2`,children:[c,` `,(0,I.jsx)(`span`,{className:`text-muted`,children:`(test data)`}),(0,I.jsx)(i,{value:n.values[e.name]??``,maxLength:300,disabled:o,placeholder:e.default===void 0?`A value`:e.default||`(empty)`,onChange:t=>r({...n,values:{...n.values,[e.name]:t.target.value}})})]},e.name):(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm text-ink-2`,children:[c,` `,(0,I.jsxs)(`span`,{className:`text-muted`,children:[`(`,e.kind===`totp`?`authenticator secret`:`secret`,`)`]}),(0,I.jsxs)(a,{value:n.secrets[e.name]??``,disabled:o||!t.length,onChange:t=>r({...n,secrets:{...n.secrets,[e.name]:t.target.value}}),children:[(0,I.jsx)(`option`,{value:``,children:t.length?`Pick a saved secret`:`No saved secrets yet`}),t.map(e=>(0,I.jsxs)(`option`,{value:e,children:[e,s.includes(e)?` (no value here)`:``]},e))]}),n.secrets[e.name]&&s.includes(n.secrets[e.name])&&(0,I.jsxs)(`span`,{className:`text-warn`,children:[n.secrets[e.name],` has no value on this computer: save it in Settings › Secrets, or the step that types it fails.`]}),!t.length&&(0,I.jsx)(`span`,{className:`text-muted`,children:`Save one in Settings › Secrets, then come back.`}),e.env&&!t.includes(e.env)&&(0,I.jsxs)(`span`,{className:`text-muted`,children:[`The block was made with `,e.env,`, which has no saved value here.`]})]},e.name)})]}):null}function ye({block:e}){return e.lines.length?(0,I.jsxs)(`details`,{className:`text-body-sm text-ink-2`,children:[(0,I.jsxs)(`summary`,{className:`cursor-pointer select-none text-muted`,children:[`See its `,e.steps,` `,e.steps===1?`step`:`steps`]}),(0,I.jsxs)(`ol`,{className:`m-0 mt-1 flex list-decimal flex-col gap-1 pl-6`,children:[e.lines.map((e,t)=>(0,I.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:e},t)),e.steps>e.lines.length&&(0,I.jsxs)(`li`,{className:`list-none text-muted`,children:[`and `,e.steps-e.lines.length,` more`]})]})]}):null}var be=[`steps`,`data`,`run`],xe=[{id:`typed`,label:`As typed`,note:`The workflow types exactly this.`},{id:`data`,label:`Test data`,note:`A named value the replay fills in: its own value, a row of a data file, or one you give when it runs.`},{id:`secret`,label:`Secret`,note:`Read from an environment variable when it replays; what was typed leaves the workflow.`},{id:`unique`,label:`New on each run`,note:`A fresh value each time, like this one: for an email or a name that must not repeat.`},{id:`date`,label:`A date from today`,note:`Counted from today, the same number of days ahead on each replay, so a day that has passed is never clicked.`},{id:`any`,label:`Any free one`,note:`Each replay clicks the first control of this kind there that is not greyed out (an open slot); later checks compare with what it picked.`}],H={label:`As clicked`,note:`The workflow clicks exactly this one.`},U={replay:[`Replaying the workflow`,`Replayed the workflow`,`working`],validate:[`Checking the workflow`,`Checked the workflow`,`searching`]};async function W(e){let t=await p.editStep(e);await p.editStep({...e,version:t.version})}var Se=[{id:`check_text`,label:`Check a control shows a text`,control:!0,text:`need`},{id:`check_present`,label:`Check a control is there`,control:!0},{id:`wait_for`,label:`Wait for a control`,control:!0,text:`may`},{id:`wait_gone`,label:`Wait until a control is gone`,control:!0},{id:`wait`,label:`Wait some seconds`,control:!1},{id:`keys`,label:`Press keys`,control:!1}];function Ce({step:e,blocks:t,secrets:n,unset:r,onAdd:i}){let[o,s]=(0,F.useState)(t[0]?.id??``),c=t.find(e=>e.id===o)??t[0],[l,u]=(0,F.useState)(()=>R(c,n)),[d,f]=(0,F.useState)(!1);return c?d?(0,I.jsxs)(`form`,{className:`flex flex-col gap-2 border-t border-line-soft p-4`,onSubmit:e=>{e.preventDefault(),z(c,l)&&i(c.id,B(l))},children:[(0,I.jsxs)(`p`,{className:`m-0 text-body-sm font-medium`,children:[`Or put in a block after step `,e.n]}),(0,I.jsx)(a,{size:`sm`,"aria-label":`The block to put in after step ${e.n}`,value:c.id,onChange:e=>{s(e.target.value),u(R(t.find(t=>t.id===e.target.value),n))},children:t.map(e=>(0,I.jsxs)(`option`,{value:e.id,children:[e.section?`${e.section} › `:``,e.name,` · `,e.steps,` `,e.steps===1?`step`:`steps`]},e.id))}),(0,I.jsx)(ye,{block:c}),(0,I.jsx)(V,{block:c,secrets:n,use:l,onChange:u,unset:r}),(0,I.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`Its steps go in after this one, marked as the block's; its test data become variables of this workflow.`}),(0,I.jsxs)(y,{type:`submit`,size:`sm`,variant:`accent`,disabled:!z(c,l),className:`self-start`,"data-tip":`Put the block in after this step`,children:[(0,I.jsx)(x,{"aria-hidden":`true`}),`Add`]})]}):(0,I.jsx)(`div`,{className:`border-t border-line-soft px-4 py-2`,children:(0,I.jsxs)(y,{size:`sm`,variant:`ghost`,onClick:()=>f(!0),"data-tip":`Put a saved block of this app in after step ${e.n}`,children:[(0,I.jsx)(O,{"aria-hidden":`true`}),`Put in a block instead`]})}):null}function we({f:e,block:t,secrets:n,unset:r,busy:i,onUpdate:a}){let[o,s]=(0,F.useState)(!1),[c,u]=(0,F.useState)({values:{},secrets:{}});return(0,I.jsxs)(`div`,{role:`status`,className:l(h.info,`flex flex-col gap-2`),children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,I.jsxs)(`span`,{className:`min-w-0 flex-[1_1_240px]`,children:[`Steps `,e.from,` to `,e.to,` are `,e.version?`version ${e.version}`:`an older version`,` of the block `,(0,I.jsx)(`strong`,{className:`font-medium`,children:e.name}),`; version `,e.latest,` is saved now.`]}),(0,I.jsxs)(y,{size:`sm`,disabled:i,onClick:()=>void a(o?B(c):void 0).then(e=>{!e&&t?.inputs.length&&s(!0)}),"data-tip":`Put the saved version in their place, with the same values`,children:[(0,I.jsx)(j,{"aria-hidden":`true`}),o?`Update with these`:`Update`]})]}),o&&t&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`m-0 text-body-sm text-ink-2`,children:`Not every value of the old copy could be found: give the ones it needs. Empty ones keep the old copy's or the block's own.`}),(0,I.jsx)(V,{block:t,secrets:n,use:c,onChange:u,disabled:i,unset:r})]})]})}function Te({blocks:e,busy:t,act:n}){let[r,a]=(0,F.useState)(null),[o,u]=(0,F.useState)(null);return e.length?(0,I.jsx)(P,{level:3,icon:O,title:`Blocks of this app`,className:`gap-2`,children:(0,I.jsx)(`ul`,{className:l(s,`m-0 flex list-none flex-col p-0`),children:e.map((e,s)=>(0,I.jsxs)(`li`,{className:l(`flex flex-col gap-2 px-4 py-2`,s>0&&`border-t border-line-soft`),children:[r?.id===e.id?(0,I.jsxs)(`form`,{className:`flex flex-wrap items-end gap-2`,onSubmit:t=>{t.preventDefault(),n(async()=>(await f.updateBlock(e.id,{name:r.name,section:r.section}),a(null),`The block "${r.name}" is saved as a new version.`))},children:[(0,I.jsxs)(`label`,{className:`flex min-w-[160px] flex-1 flex-col gap-1 text-body-sm font-medium text-ink-2`,children:[`Name`,(0,I.jsx)(i,{size:`sm`,value:r.name,maxLength:80,onChange:e=>a({...r,name:e.target.value})})]}),(0,I.jsxs)(`label`,{className:`flex min-w-[120px] flex-col gap-1 text-body-sm font-medium text-ink-2`,children:[`Section`,(0,I.jsx)(i,{size:`sm`,value:r.section,maxLength:40,onChange:e=>a({...r,section:e.target.value})})]}),(0,I.jsxs)(y,{type:`submit`,size:`sm`,variant:`primary`,disabled:t||!r.name.trim(),"data-tip":`Save the block as a new version`,children:[(0,I.jsx)(j,{"aria-hidden":`true`}),`Save`]}),(0,I.jsxs)(y,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>a(null),children:[(0,I.jsx)(ne,{"aria-hidden":`true`}),`Cancel`]})]}):(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1`,children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-[1_1_220px] flex-col`,children:[(0,I.jsxs)(`span`,{className:`text-body-sm font-medium text-ink [overflow-wrap:anywhere]`,children:[e.section?`${e.section} › `:``,e.name,` `,(0,I.jsxs)(`span`,{className:`font-normal text-muted`,children:[`v`,e.version,` · `,c(e.steps,`step`)]})]}),e.inputs.length>0&&(0,I.jsxs)(`span`,{className:`text-body-sm text-muted`,children:[`Takes `,e.inputs.map(e=>`${e.label||e.name}${e.kind===`data`?``:` (secret)`}`).join(`, `)]}),(0,I.jsx)(ye,{block:e})]}),(0,I.jsx)(y,{size:`icon`,variant:`icon`,disabled:t,"aria-label":`Change the block ${e.name}`,"data-tip":`Change the block ${e.name}`,onClick:()=>a({id:e.id,name:e.name,section:e.section??``}),className:`size-8`,children:(0,I.jsx)(C,{"aria-hidden":`true`})}),(0,I.jsx)(y,{size:`icon`,variant:`icon`,disabled:t,"aria-label":o?.id===e.id?`Delete the block ${e.name} anyway`:`Delete the block ${e.name}`,"data-tip":o?.id===e.id?`Delete it anyway`:`Delete the block ${e.name}`,onClick:()=>n(async()=>{try{await f.deleteBlock(e.id,o?.id===e.id)}catch(t){let n=t;if(n.status!==409)throw n;u({id:e.id,why:n.message});return}return u(null),`The block "${e.name}" is deleted; the steps workflows have of it stay.`}),className:`size-8`,children:(0,I.jsx)(oe,{"aria-hidden":`true`})})]}),o?.id===e.id&&(0,I.jsxs)(`p`,{className:l(h.warn,`m-0`),children:[o.why,` Click delete again to delete it anyway.`]})]},e.id))})}):null}function Ee({history:e,busy:t,onPreview:n,onBack:r}){let[i,a]=(0,F.useState)(null);return e.length?(0,I.jsxs)(P,{level:3,icon:b,title:`Earlier versions`,className:`gap-2`,children:[(0,I.jsx)(`ol`,{className:l(s,`m-0 flex list-none flex-col p-0`),children:e.slice(0,10).map((e,r)=>(0,I.jsxs)(`li`,{className:l(`flex items-center gap-4 px-4 py-2`,r>0&&`border-t border-line-soft`),children:[(0,I.jsxs)(`span`,{className:`min-w-0 flex-1 text-body-sm text-ink-2`,children:[`Before the change of `,de(e.at)||e.name.slice(0,19)]}),(0,I.jsxs)(y,{size:`sm`,variant:`ghost`,disabled:t,onClick:()=>void n(e.name).then(t=>t&&a({name:e.name,...t})),"data-tip":`See what going back to this version changes`,children:[(0,I.jsx)(A,{"aria-hidden":`true`}),`Go back`]})]},e.name))}),i&&(0,I.jsxs)(`div`,{role:`status`,className:l(`surface rounded-lg bg-bg p-6 shadow-sm`,`flex flex-col gap-2`),children:[(0,I.jsx)(`p`,{className:`m-0 text-body-sm font-medium`,children:`Going back changes this:`}),(0,I.jsx)(`pre`,{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]`,`m-0 max-h-[240px]`),children:i.diff.join(`
2
- `)||`Nothing: the workflow is already that version.`}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsxs)(y,{size:`sm`,variant:`primary`,disabled:t,onClick:()=>(r(i.name,i.version),a(null)),"data-tip":`Write the workflow back at this version`,children:[(0,I.jsx)(j,{"aria-hidden":`true`}),`Go back to it`]}),(0,I.jsxs)(y,{size:`sm`,variant:`ghost`,onClick:()=>a(null),children:[(0,I.jsx)(ne,{"aria-hidden":`true`}),`Cancel`]})]})]})]}):null}function De({steps:e,busy:t,onKeep:n}){let[r,o]=(0,F.useState)(2),[c,u]=(0,F.useState)(2),[d,f]=(0,F.useState)(``),[p,m]=(0,F.useState)(``),h=e.filter(e=>e.n>1);if(!h.length)return null;let g=h[h.length-1].n,_=Math.min(Math.max(r,2),g),v=Math.min(Math.max(c,_),g);return(0,I.jsxs)(`form`,{"aria-label":`Keep steps as a block`,className:l(s,`flex flex-wrap items-end gap-2`),onSubmit:e=>{e.preventDefault(),d.trim()&&n(_,v,d.trim(),p.trim()).then(e=>{e&&f(``)})},children:[(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm font-medium text-ink-2`,children:[`Keep steps`,(0,I.jsx)(a,{value:_,onChange:e=>(o(Number(e.target.value)),u(Math.max(v,Number(e.target.value)))),className:`w-[84px]`,children:h.map(e=>(0,I.jsx)(`option`,{value:e.n,children:e.n},e.n))})]}),(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm font-medium text-ink-2`,children:[`to`,(0,I.jsx)(a,{value:v,onChange:e=>u(Number(e.target.value)),className:`w-[84px]`,children:h.filter(e=>e.n>=_).map(e=>(0,I.jsx)(`option`,{value:e.n,children:e.n},e.n))})]}),(0,I.jsxs)(`label`,{className:`flex min-w-[160px] flex-1 flex-col gap-1 text-body-sm font-medium text-ink-2`,children:[`as the block`,(0,I.jsx)(i,{value:d,maxLength:80,placeholder:`Sign in`,onChange:e=>f(e.target.value)})]}),(0,I.jsxs)(`label`,{className:`flex min-w-[120px] flex-col gap-1 text-body-sm font-medium text-ink-2`,children:[`in the section`,(0,I.jsx)(i,{value:p,maxLength:40,placeholder:`Account`,onChange:e=>m(e.target.value)})]}),(0,I.jsxs)(y,{type:`submit`,disabled:t||!d.trim(),"data-tip":`Keep these steps as a block of this app`,children:[(0,I.jsx)(j,{"aria-hidden":`true`}),`Keep`]}),(0,I.jsx)(`span`,{className:`basis-full text-body-sm text-muted`,children:`Put it into other workflows of this app from a step's +. What it types becomes its inputs: test data, or a secret picked each time.`})]})}function Oe({step:e,onAdd:t}){let[n,r]=(0,F.useState)(`check_text`),o=e.fields?.target,[s,c]=(0,F.useState)({name:o?.name??``,automation_id:o?.automation_id??``,control_type:o?.control_type??``}),[l,u]=(0,F.useState)(``),[d,f]=(0,F.useState)(`2`),[p,m]=(0,F.useState)(``),h=Se.find(e=>e.id===n),g=h.control?!!(s.name.trim()||s.automation_id.trim())&&(h.text!==`need`||!!l.trim()):n===`wait`?Number(d)>0:!!p.trim();return(0,I.jsxs)(`form`,{className:`flex flex-col gap-2 p-4`,onSubmit:e=>{e.preventDefault(),g&&t({kind:n,...h.control?{target:s}:{},...h.text&&l.trim()?{text:l}:{},...n===`wait`?{seconds:Number(d)}:{},...n===`keys`?{keys:p}:{}})},children:[(0,I.jsxs)(`p`,{className:`m-0 text-body-sm font-medium`,children:[`After step `,e.n]}),(0,I.jsx)(a,{size:`sm`,"aria-label":`What to add`,value:n,onChange:e=>r(e.target.value),children:Se.map(e=>(0,I.jsx)(`option`,{value:e.id,children:e.label},e.id))}),h.control&&(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm font-medium`,children:[`Control's name`,(0,I.jsx)(i,{size:`sm`,value:s.name,maxLength:300,onChange:e=>c({...s,name:e.target.value})})]}),(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm font-medium`,children:[`Automation id`,(0,I.jsx)(i,{size:`sm`,value:s.automation_id,maxLength:300,spellCheck:!1,onChange:e=>c({...s,automation_id:e.target.value}),className:`font-mono text-body-sm`})]})]}),h.text&&(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm font-medium`,children:[h.text===`need`?`The text it shows`:`Showing the text (optional)`,(0,I.jsx)(i,{size:`sm`,value:l,maxLength:500,placeholder:`Invoice saved`,onChange:e=>u(e.target.value)})]}),n===`wait`&&(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm font-medium`,children:[`Seconds`,(0,I.jsx)(i,{size:`sm`,type:`number`,min:1,max:600,value:d,onChange:e=>f(e.target.value)})]}),n===`keys`&&(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm font-medium`,children:[`Keys`,(0,I.jsx)(i,{size:`sm`,value:p,maxLength:100,spellCheck:!1,placeholder:`ctrl+s`,onChange:e=>m(e.target.value),className:`font-mono text-body-sm`})]}),(0,I.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`The control is filled from this step's; change it for another. A wait for a control is better than a fixed wait.`}),(0,I.jsxs)(y,{type:`submit`,size:`sm`,variant:`accent`,disabled:!g,className:`self-start`,children:[(0,I.jsx)(x,{"aria-hidden":`true`}),`Add`]})]})}var G=e=>e.name||e.automation_id||`the control`;function ke({pictures:e,step:t,busy:n,onPick:r}){let[i,a]=(0,F.useState)(0),o=e[Math.min(i,e.length-1)],[s,c]=(0,F.useState)(``),[u,d]=(0,F.useState)(``),[f,m]=(0,F.useState)(null);(0,F.useEffect)(()=>{let e=!1;return c(``),d(``),m(null),p.shot(o.run,o.n).then(t=>!e&&c(t),t=>!e&&d(t.message)),p.controls(o.run,o.n).then(t=>!e&&m(t),()=>{}),()=>{e=!0}},[o.run,o.n]);let h=(e,t)=>`${Math.max(0,Math.min(100,e/t*100))}%`,[g,_]=(0,F.useState)(!1),v=f&&f.w>0?f.controls.toSorted((e,t)=>t.w*t.h-e.w*e.h):[];return(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 pr-4 pb-4 pl-4 sm:pl-20`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.length>1&&(0,I.jsx)(N,{label:`Pictures of step ${t}`,value:String(i),onChange:e=>a(Number(e)),options:e.map((e,t)=>({id:String(t),label:e.label}))}),(0,I.jsxs)(`p`,{className:`m-0 text-body-sm text-muted`,children:[o.note,v.length>0?` Click a control to check that it shows its text, or that it is there.`:``]})]}),u&&(0,I.jsx)(`p`,{className:`m-0 text-body-sm text-fail`,children:u}),!s&&!u&&(0,I.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`Loading the picture…`}),s&&(0,I.jsxs)(`div`,{className:l(`rounded-base bg-surface-muted object-cover`,`relative w-full overflow-hidden`,g?`max-w-[360px]`:`max-w-[720px]`),style:v.length?{aspectRatio:`${f.w} / ${f.h}`}:void 0,children:[(0,I.jsx)(`img`,{src:s,alt:`The app after step ${t}, ${o.label.toLowerCase()}`,onLoad:e=>_(e.currentTarget.naturalHeight>e.currentTarget.naturalWidth),className:v.length?`absolute inset-0 size-full object-fill`:`block w-full`}),v.map((e,t)=>{let i=e.text?`Check ${G(e)} shows "${e.text}"`:`Check ${G(e)} is there`;return(0,I.jsx)(`button`,{type:`button`,disabled:n,"aria-label":i,"data-tip":i,onClick:()=>r({target:{...e.automation_id?{automation_id:e.automation_id}:{},...e.name?{name:e.name}:{},...e.control_type?{control_type:e.control_type}:{}},...e.text?{text:e.text}:{}}),className:`absolute cursor-pointer rounded-[3px] border-0 bg-transparent p-0 outline-none hover:bg-accent/15 hover:ring-2 hover:ring-accent focus-visible:bg-accent/15 focus-visible:ring-2 focus-visible:ring-accent`,style:{left:h(e.x,f.w),top:h(e.y,f.h),width:h(e.w,f.w),height:h(e.h,f.h)}},`${t}-${e.automation_id||e.name}`)})]})]})}function Ae({v:e,secrets:t,onSave:n,busy:r,mobile:o=!1}){let[s,c]=(0,F.useState)(e.as),[l,u]=(0,F.useState)(e.name??``),[d,f]=(0,F.useState)(e.value??``);(0,F.useEffect)(()=>{c(e.as),u(e.name??``),f(e.value??``)},[e]);let p=[`click`,`double_click`,`tap`,`double_tap`].includes(e.op),m=xe.filter(t=>e.choices?e.choices.includes(t.id):t.id!==`date`&&t.id!==`any`&&t.id!==`unique`&&(e.op===`type`||t.id!==`secret`)),h=s===`data`||s===`secret`||p&&s!==`typed`,g=s!==e.as||h&&l!==(e.name??``)||!p&&d!==(e.value??``),_=h?s===`secret`?/^[A-Z_][A-Z0-9_]{0,63}$/.test(l):/^[A-Za-z_][A-Za-z0-9_]{0,63}$/.test(l):s===`typed`||p||d.trim()!==``,v=e=>p&&e===`typed`?H.label:xe.find(t=>t.id===e)?.label,ee=p&&s===`typed`?H.note:xe.find(e=>e.id===s)?.note;return(0,I.jsxs)(`li`,{className:`flex flex-wrap items-start gap-x-4 gap-y-2 border-t border-line-soft px-4 py-2 first:border-t-0`,children:[(0,I.jsx)(`span`,{className:`w-6 flex-none pt-2 text-right font-mono text-body-sm text-muted tabular-nums`,children:e.n}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-[1_1_220px] flex-col pt-2`,children:[(0,I.jsx)(`span`,{className:`text-body-sm text-ink [overflow-wrap:anywhere]`,children:e.line}),(0,I.jsx)(`span`,{className:`text-body-sm text-ink-2`,children:ee})]}),(0,I.jsxs)(`span`,{className:`flex flex-[1_1_360px] flex-wrap items-center gap-2`,children:[(0,I.jsx)(a,{"aria-label":`Where the value of step ${e.n} comes from`,value:s,disabled:r,onChange:e=>c(e.target.value),className:`w-[150px] flex-none`,children:m.map(e=>(0,I.jsx)(`option`,{value:e.id,children:v(e.id)},e.id))}),h&&(0,I.jsx)(i,{"aria-label":s===`secret`?`The secret's environment variable`:`The test data's name`,value:l,maxLength:64,spellCheck:!1,list:s===`secret`?`desktop-secrets`:void 0,placeholder:s===`secret`?`BILLING_PASSWORD`:p?s===`date`?`date`:`slot`:`customer`,onChange:e=>u(s===`secret`?e.target.value.toUpperCase():e.target.value),className:`w-[170px] flex-none font-mono text-body-sm`}),s!==`secret`&&!p&&(0,I.jsx)(i,{"aria-label":s===`data`?`Its value`:s===`date`?`The date (counted from today)`:`The value`,value:d,maxLength:500,onChange:e=>f(e.target.value),className:`min-w-[140px] flex-1`}),s===`secret`&&!t.includes(l)&&l&&(0,I.jsxs)(`span`,{className:`text-body-sm text-warn`,children:[`Not in `,o?`mobile.secrets`:`desktop.secrets`,` yet`]}),(0,I.jsxs)(y,{size:`sm`,variant:`primary`,disabled:r||!g||!_,onClick:()=>n(s,h?l:void 0,s===`secret`||p?void 0:d),children:[(0,I.jsx)(j,{"aria-hidden":`true`}),`Save`]})]}),(0,I.jsx)(`datalist`,{id:`desktop-secrets`,children:t.map(e=>(0,I.jsx)(`option`,{value:e},e))})]})}function je({view:e,job:t,rows:n,onRun:r,busy:o,heal:u}){let[d,f]=(0,F.useState)(()=>Object.fromEntries(e.variables.map(e=>[e.name,e.value]))),[m,h]=(0,F.useState)(``),[_,ee]=(0,F.useState)(u),[b,te]=(0,F.useState)(!1),x=e.lastRun,S=m.startsWith(`file:`)?{file:m.slice(5)}:m.startsWith(`request:`)?{request:m.slice(8)}:void 0,C=t&&t.kind===`replay`&&t.target===e.workflow.path;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`m-0 text-body-sm text-ink-2`,children:`Replay plays the steps in the app with no model, as a scheduled run or CI will, and takes over the mouse and keyboard while it runs: use a test machine and a test account.`}),(0,I.jsxs)(`form`,{className:l(s,`flex flex-col gap-4`),onSubmit:e=>{e.preventDefault(),r({variables:d,...S?{rows:S}:{},heal:_,updateBaselines:b})},children:[e.variables.length>0&&(0,I.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,180px),1fr))] gap-4`,children:e.variables.map(e=>(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm font-medium text-ink-2`,children:[e.name,(0,I.jsx)(i,{value:d[e.name]??``,onChange:t=>f({...d,[e.name]:t.target.value})})]},e.name))}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-end gap-4`,children:[(0,I.jsxs)(`label`,{className:`flex min-w-[220px] flex-col gap-1 text-body-sm font-medium text-ink-2`,children:[`Test data`,(0,I.jsxs)(a,{value:m,onChange:e=>h(e.target.value),children:[(0,I.jsx)(`option`,{value:``,children:`Once, with the values above`}),n.files.map(e=>(0,I.jsxs)(`option`,{value:`file:${e}`,children:[`Each row of `,e]},e)),n.requests.map(e=>(0,I.jsxs)(`option`,{value:`request:${e}`,children:[`Each row of request `,e]},e))]})]}),(0,I.jsxs)(`label`,{className:`flex min-h-10 items-center gap-2 text-body-sm text-ink-2`,children:[(0,I.jsx)(M,{checked:_,onChange:ee,label:`Heal a step whose control moved`}),`Heal a moved control`]}),(0,I.jsxs)(`label`,{className:`flex min-h-10 items-center gap-2 text-body-sm text-ink-2`,children:[(0,I.jsx)(M,{checked:b,onChange:te,label:`Take new image baselines`}),`New image baselines`]}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsxs)(y,{type:`submit`,variant:`primary`,disabled:o,children:[(0,I.jsx)(T,{"aria-hidden":`true`}),`Replay`]})]})]}),C&&(0,I.jsx)(he,{job:t,onStop:()=>void p.stop(),words:U}),x?(0,I.jsx)(P,{id:`desktop-last-run`,level:3,icon:T,title:`Last replay`,className:`gap-2`,children:(0,I.jsxs)(`div`,{className:l(s,`flex flex-wrap items-center gap-4 text-body-sm`),children:[(0,I.jsx)(v,{tone:x.ok?`pass`:`fail`,children:x.many?`${x.many.passed} of ${x.many.total} passed`:x.ok?`Passed`:`Failed`}),(0,I.jsxs)(`span`,{className:`text-muted`,children:[de(x.at),` · `,c(e.replays,`replay`),` in all`]}),x.failed&&(0,I.jsxs)(`span`,{className:`min-w-0 flex-[1_1_240px] text-body-sm text-fail [overflow-wrap:anywhere]`,children:[`Step `,x.failed.index,`: `,x.failed.error]}),(0,I.jsx)(`span`,{className:`flex-1`}),x.report&&(0,I.jsx)(pe,{path:x.report,children:`Report`})]})}):(0,I.jsx)(g,{className:`py-4`,children:`Not replayed yet.`})]})}function K({workflow:e,onClose:t,backLabel:i=`Back`,notices:a,tab:o,onTab:s}){let[u,f]=(0,F.useState)(null),[b,M]=(0,F.useState)(``),[N,de]=(0,F.useState)(!1),[fe,pe]=(0,F.useState)(`steps`),P=s?be.includes(o??``)?o:`steps`:fe,he=e=>s?s(e):pe(e),[ge,_e]=(0,F.useState)(``),[L,R]=(0,F.useState)(`all`),[z,B]=(0,F.useState)(null),[V,xe]=(0,F.useState)(null),[H,U]=(0,F.useState)(null),[Se,G]=(0,F.useState)(``),[K,Me]=(0,F.useState)(null),[Ne,Pe]=(0,F.useState)({files:[],requests:[]}),[Fe,Ie]=(0,F.useState)(!0),q=(0,F.useCallback)(()=>{p.review(e).then(e=>{f(e),M(``)},e=>M(e.message))},[e]);(0,F.useEffect)(q,[q]);let J=(0,F.useCallback)(()=>{p.view().then(e=>{Me(e.job),Pe(e.rows),Ie(e.heal)},()=>{})},[]);(0,F.useEffect)(J,[J]);let Y=!!K?.running;(0,F.useEffect)(()=>{if(!Y)return;let e=le(J,1e3);return()=>ce(e)},[Y,J]);let Le=K&&!K.running?K.endedAt:``;(0,F.useEffect)(()=>{Le&&q()},[Le,q]);let X=async(e,t)=>{de(!0),M(``),G(``);try{await e(),q(),t&&G(t)}catch(e){M(e.message)}finally{de(!1)}},Re=e=>void m.start(e,{}).then(({id:e})=>location.hash=n(`chats`,e),e=>M(e.message));if(!u)return b?(0,I.jsx)(`p`,{role:`alert`,className:l(h.fail,`m-0`),children:b}):(0,I.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Opening the workflow…`});let Z=u.workflow.kind===`mobile`,Q=u.lastRun,ze=new Map((Q?.results??[]).map(e=>[e.n,e])),Be=!!Q&&Date.parse(u.workflow.modified)>Date.parse(Q.at),Ve=u.steps.filter(e=>e.op.startsWith(`expect`)).length,$=Q&&!Q.ok?Q.failed?.index??0:0,He=$?u.steps[$-1]:void 0,Ue=(Q?.results??[]).filter(e=>!e.ok).length,We=ge.toLowerCase().split(/\s+/).filter(Boolean),Ge=u.steps.filter(e=>We.every(t=>`${e.n} ${e.text} ${e.fields?.note||``}`.toLowerCase().includes(t))&&(L===`all`||(L===`checks`?e.op.startsWith(`expect`):ze.get(e.n)?.ok===!1))),Ke=e=>{he(`steps`),R(`all`),_e(``);let t=n=>requestAnimationFrame(()=>{let i=document.getElementById(`dstep-${e}`);i?i.scrollIntoView({block:`center`,behavior:r()}):n>0&&t(n-1)});t(30)},qe=e=>void X(async()=>{await p.replay({workflow:u.workflow.path,...e}),J()},Z?`Replaying on the device: a device cloud can take a minute or two to start it.`:`Replaying: the app opens on this computer.`),Je=[{id:`steps`,label:`Steps`,icon:D,n:u.steps.length},{id:`data`,label:`Test data`,icon:re,n:u.values.length},{id:`run`,label:`Last run`,icon:T}];return(0,I.jsxs)(`section`,{"aria-labelledby":`dreview-title`,className:`flex min-w-0 flex-col gap-4`,children:[(0,I.jsxs)(`div`,{className:`sticky top-0 z-20 -mx-1 flex flex-col gap-4 border-b border-line bg-canvas px-1 py-4`,children:[t&&(0,I.jsx)(`div`,{children:(0,I.jsxs)(y,{size:`sm`,variant:`ghost`,onClick:t,className:`-ml-2 text-ink-2`,children:[(0,I.jsx)(E,{"aria-hidden":`true`}),i]})}),(0,I.jsx)(me,{id:`dreview-title`,icon:te,title:(0,I.jsx)(`span`,{"data-tip":u.workflow.name,children:u.workflow.name}),description:(0,I.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsxs)(`span`,{children:[u.workflow.app||`no app`,` · `,c(u.steps.length,`step`),` · `,c(Ve,`check`)]}),Y&&K?.target===u.workflow.path?(0,I.jsx)(v,{tone:`running`,children:`Replaying…`}):Q?(0,I.jsx)(v,{tone:Q.ok?`pass`:`fail`,children:Q.ok?`Last replay passed`:$?`Last replay failed at step ${$}`:`Last replay did not get through`}):(0,I.jsx)(v,{tone:`neutral`,icon:!1,children:`Not replayed yet`}),Be&&(0,I.jsx)(`span`,{children:`· you changed it since`})]}),actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(y,{onClick:()=>Re(`${Z?`Look at the mobile workflow`:`DeskPilot: look at the desktop workflow`} ${u.workflow.path} and tell me what to fix or add (a wait, a timeout, a dialog to dismiss, checks of the outcome); change it with desktop_edit_workflow only after showing me the change.`),"data-tip":Z?`Ask the agent to improve it`:`Ask DeskPilot to improve it`,children:[(0,I.jsx)(k,{"aria-hidden":`true`}),`Improve`]}),(0,I.jsxs)(y,{variant:`primary`,disabled:Y,onClick:()=>he(`run`),"data-tip":Y?`A replay is going`:`Replay it with no model`,children:[(0,I.jsx)(T,{"aria-hidden":`true`}),`Replay`]})]})})]}),a,b&&(0,I.jsx)(`p`,{role:`alert`,className:l(h.fail,`m-0`),children:b}),Se&&(0,I.jsx)(`p`,{role:`status`,className:l(h.pass,`m-0`),children:Se}),Q&&!Q.ok&&(0,I.jsxs)(`div`,{role:`alert`,className:l(h.fail,`flex flex-col gap-2`),children:[(0,I.jsxs)(`p`,{className:`m-0 font-medium text-fail`,children:[$?`Step ${$} failed`:`The replay did not get through`,Be&&(0,I.jsx)(`span`,{className:`font-normal text-ink-2`,children:` · before your last change`})]}),He&&(0,I.jsx)(`p`,{className:`m-0 font-medium text-ink [overflow-wrap:anywhere]`,children:He.text}),(0,I.jsx)(`p`,{className:`m-0 line-clamp-3 text-body-sm text-ink-2 [overflow-wrap:anywhere]`,children:Q.failed?.error||Q.error||`It failed.`}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[He&&(0,I.jsxs)(y,{size:`sm`,onClick:()=>Ke($),children:[(0,I.jsx)(A,{"aria-hidden":`true`}),`Show`]}),He&&$>1&&(0,I.jsxs)(y,{size:`sm`,onClick:()=>(Ke($),U({n:$,mode:`edit`})),"data-tip":`Change the failed step: its control, text or timeout`,children:[(0,I.jsx)(C,{"aria-hidden":`true`}),`Change`]}),(0,I.jsxs)(y,{size:`sm`,variant:`ghost`,onClick:()=>Re(`${Z?`The`:`DeskPilot: the`} last replay of ${u.workflow.path} failed${$?` at step ${$}`:``}. Read its report (${Q.dir}), tell me why, and offer a fix.`),children:[(0,I.jsx)(ie,{"aria-hidden":`true`}),`Ask why`]})]})]}),Q&&Q.ok&&Q.heals>0&&!Q.healsAccepted&&(0,I.jsxs)(`div`,{role:`status`,className:l(h.info,`flex flex-wrap items-center gap-4`),children:[(0,I.jsxs)(`span`,{className:`min-w-0 flex-[1_1_240px]`,children:[`The last replay found `,c(Q.heals,`moved control`),` and healed `,Q.heals===1?`it`:`them`,`: write the new locators into the workflow?`]}),(0,I.jsxs)(y,{size:`sm`,disabled:N,onClick:()=>void X(()=>p.acceptHeals(Q.dir),`The healed locators are in the workflow.`),children:[(0,I.jsx)(S,{"aria-hidden":`true`}),`Accept`]})]}),u.blocksStale?.map(e=>(0,I.jsx)(we,{f:e,block:u.blocks?.find(t=>t.id===e.block),secrets:u.blockSecrets??[],unset:u.unsetSecrets??[],busy:N,onUpdate:async t=>{let n=!1;return await X(async()=>{await W({workflow:u.workflow.path,step:e.from,action:`refresh_block`,block:e.block,...t||{}}),n=!0},`Steps ${e.from} to ${e.to} are version ${e.latest} of "${e.name}" now.`),n}},`stale-${e.block}-${e.from}`)),u.blocksFound?.map(e=>(0,I.jsxs)(`div`,{role:`status`,className:l(h.info,`flex flex-wrap items-center gap-4`),children:[(0,I.jsxs)(`span`,{className:`min-w-0 flex-[1_1_240px]`,children:[`Steps `,e.from,` to `,e.to,` do what the block `,(0,I.jsx)(`strong`,{className:`font-medium`,children:e.name}),` does: mark them as the block's, and this workflow hears of its newer versions.`]}),(e=>e?(0,I.jsx)(`span`,{className:`basis-full`,children:(0,I.jsx)(ye,{block:e})}):null)(u.blocks?.find(t=>t.id===e.block)),(0,I.jsxs)(y,{size:`sm`,disabled:N,onClick:()=>void X(()=>W({workflow:u.workflow.path,step:e.from,action:`use_block`,block:e.block}),`Steps ${e.from} to ${e.to} are the block "${e.name}" now.`),"data-tip":`Mark these steps as the block's`,children:[(0,I.jsx)(j,{"aria-hidden":`true`}),`Use`]})]},`found-${e.block}-${e.from}`)),(0,I.jsx)(ue,{prefix:`dreview`,label:`This workflow`,className:`mb-0`,current:P,onPick:he,tabs:Je.map(e=>({id:e.id,label:e.label,...e.n===void 0?{}:{n:e.n},...e.id===`run`&&Q?{n:Q.ok?(0,I.jsx)(w,{size:12,role:`img`,"aria-label":`passed`,className:`text-pass`}):(0,I.jsx)(se,{size:12,role:`img`,"aria-label":`failed`,className:`text-fail`})}:{}}))}),(0,I.jsxs)(`div`,{role:`tabpanel`,id:`dreview-panel-${P}`,"aria-labelledby":`dreview-${P}`,className:`flex min-w-0 flex-col gap-4`,children:[P===`steps`&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(ee,{id:`dreview-step-search`,label:`Find a step`,value:ge,onChange:_e}),(0,I.jsx)(_,{items:[{id:`all`,label:`All`,n:u.steps.length},{id:`checks`,label:`Checks`,n:Ve},...Ue?[{id:`failed`,label:`Failed`,n:Ue,alert:!0}]:[]],value:L,onChange:R})]}),Ve===0&&(0,I.jsx)(`p`,{className:l(h.warn,`m-0`),children:`No checks of the outcome: a replay passes when its steps run. Add one with + after the step whose result matters.`}),Ge.length===0?(0,I.jsx)(`p`,{className:l(`surface rounded-lg bg-bg p-6 shadow-sm`,`m-0 text-body-sm text-muted`),children:`No step matches.`}):(0,I.jsx)(`ol`,{className:l(`surface rounded-lg bg-bg p-6 shadow-sm`,`m-0 flex list-none flex-col p-0 [&>li:first-child]:rounded-t-base [&>li:last-child]:rounded-b-base`),children:Ge.map((e,t)=>{let n=ze.get(e.n),r=e.op.startsWith(`expect`),i=u.recorded?.shots[e.n],a=[...i&&u.recorded?[{label:`When recorded`,run:u.recorded.run,n:i,note:`The app after step ${e.n} as you recorded it.`}]:[],...n?.shot&&Q?[{label:`Last replay`,run:Q.dir,n:e.n,note:`The app after step ${e.n} on the last replay${Be?`, before your last change`:``}.`}]:[]];return(0,I.jsxs)(`li`,{id:`dstep-${e.n}`,className:l(`flex scroll-mt-48 flex-col`,t>0&&`border-t border-line-soft`,n&&!n.ok&&`bg-fail-soft`),children:[(0,I.jsxs)(`div`,{className:`group flex min-h-11 items-start gap-4 px-4 py-2`,children:[(0,I.jsx)(`span`,{className:`w-6 flex-none pt-1 text-right font-mono text-body-sm text-muted tabular-nums`,children:e.n}),(0,I.jsx)(`span`,{className:`flex w-4 flex-none justify-center pt-1`,children:n?n.ok?(0,I.jsx)(j,{size:14,strokeWidth:2.5,"aria-label":`Passed on the last replay`,className:`text-pass`}):(0,I.jsx)(ne,{size:14,strokeWidth:2.5,"aria-label":`Failed on the last replay`,className:`text-fail`}):Q?(0,I.jsx)(ae,{size:14,"aria-label":`Not replayed`,className:`text-muted`}):r?(0,I.jsx)(w,{size:14,"aria-hidden":`true`,className:`text-pass`}):(0,I.jsx)(`span`,{"aria-hidden":`true`,className:`mt-1 size-1.5 rounded-full bg-line-strong`})}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[r&&(0,I.jsx)(v,{tone:`pass`,icon:!1,className:`min-h-5 px-2 text-body-sm`,children:`Check`}),e.op.startsWith(`wait`)&&(0,I.jsx)(v,{tone:`neutral`,icon:!1,className:`min-h-5 px-2 text-body-sm`,children:`Wait`}),(0,I.jsx)(`span`,{className:`min-w-0 text-body-sm text-ink [overflow-wrap:anywhere]`,children:e.text}),e.block&&(0,I.jsxs)(v,{tone:`neutral`,icon:!1,children:[(0,I.jsx)(O,{"aria-hidden":`true`,className:`size-[11px]`}),u.blocks?.find(t=>t.id===e.block)?.name||e.block]}),n?.healed&&(0,I.jsx)(v,{tone:`warn`,icon:!1,className:`min-h-5 px-2 text-body-sm`,children:`Healed`})]}),e.fields?.note&&(0,I.jsxs)(`span`,{className:`text-body-sm text-ink-2`,children:[`Note: `,e.fields.note]}),n&&!n.ok&&n.error&&(0,I.jsx)(`span`,{className:`line-clamp-2 text-body-sm text-fail [overflow-wrap:anywhere]`,"data-tip":n.error,children:n.error})]}),(0,I.jsxs)(`span`,{className:`relative flex flex-none items-center gap-1`,children:[(0,I.jsx)(y,{size:`icon`,variant:`icon`,disabled:N,"aria-haspopup":`dialog`,"aria-expanded":z===e.n,"aria-label":`Add a check, wait${u.blocks?.length?` or block`:``} after step ${e.n}`,"data-tip":`Add a check, wait${u.blocks?.length?` or block`:``} after step ${e.n}`,onClick:()=>B(z===e.n?null:e.n),className:`size-8`,children:(0,I.jsx)(x,{"aria-hidden":`true`})}),(0,I.jsxs)(d,{open:z===e.n,onClose:()=>B(null),label:`Add after step ${e.n}`,role:`dialog`,align:`end`,className:`w-[min(360px,calc(100vw-48px))]`,children:[(0,I.jsx)(Oe,{step:e,onAdd:t=>{B(null),X(()=>W({workflow:u.workflow.path,step:e.n,action:`insert`,...t}),`Added after step ${e.n}.`)}}),(u.blocks?.length??0)>0&&(0,I.jsx)(Ce,{step:e,blocks:u.blocks??[],secrets:u.blockSecrets??[],unset:u.unsetSecrets??[],onAdd:(t,n)=>{B(null),X(()=>W({workflow:u.workflow.path,step:e.n,action:`block`,block:t,...n}),`Put in the block after step ${e.n}.`)}})]}),a.length>0&&(0,I.jsx)(y,{size:`icon`,variant:`icon`,"aria-label":`See the app after step ${e.n}`,"aria-expanded":V===e.n,"data-tip":`See the app after step ${e.n}`,onClick:()=>xe(V===e.n?null:e.n),className:`size-8`,children:(0,I.jsx)(A,{"aria-hidden":`true`})}),(0,I.jsx)(y,{size:`icon`,variant:`icon`,"aria-label":`Change step ${e.n}`,"data-tip":`Change step ${e.n}`,onClick:()=>U({n:e.n,mode:`edit`}),className:`size-8`,children:(0,I.jsx)(C,{"aria-hidden":`true`})}),e.n>1&&(0,I.jsx)(y,{size:`icon`,variant:`icon`,"aria-label":`Drop step ${e.n}`,"data-tip":`Drop step ${e.n}`,onClick:()=>U({n:e.n,mode:`remove`}),className:`size-8 hover:text-fail`,children:(0,I.jsx)(oe,{"aria-hidden":`true`})})]})]}),H&&H.n===e.n&&(0,I.jsx)(`div`,{className:`pr-4`,children:(0,I.jsx)(ve,{workflow:u.workflow.path,step:e,mode:H.mode,onCancel:()=>U(null),onDone:()=>{G(H.mode===`remove`?`Step ${e.n} dropped.`:`Step ${e.n} changed.`),U(null),q()}},`${e.n}-${H.mode}`)}),V===e.n&&a.length>0&&(0,I.jsx)(ke,{pictures:a,step:e.n,busy:N,onPick:t=>void X(()=>W({workflow:u.workflow.path,step:e.n,action:`insert`,kind:t.text?`check_text`:`check_present`,target:t.target,...t.text?{text:t.text}:{}}),t.text?`Added after step ${e.n}: a check that ${t.target.name||t.target.automation_id} shows "${t.text}".`:`Added after step ${e.n}: a check that ${t.target.name||t.target.automation_id} is there.`)})]},`${e.n}-${e.text}`)})}),(0,I.jsx)(De,{steps:u.steps,busy:N,onKeep:async(e,t,n,r)=>{let i=!1;return await X(async()=>{await p.saveBlock(u.workflow.path,e,t,n,r),i=!0},`Kept steps ${e} to ${t} as the block "${n}": put it into other workflows of ${u.workflow.app} from a step's +.`),i}}),(0,I.jsx)(Te,{blocks:u.blocks??[],busy:N,act:e=>{let t;X(async()=>{t=await e()}).then(()=>t&&G(t))}}),(0,I.jsx)(Ee,{history:u.history??[],busy:N,onPreview:async e=>{M(``);try{let t=await p.restore(u.workflow.path,e);return{diff:t.diff,version:t.version}}catch(e){return M(e.message),null}},onBack:(e,t)=>void X(()=>p.restore(u.workflow.path,e,t),`The workflow is back at that version: the version before going back is kept too.`)})]}),P===`data`&&(u.values.length===0?(0,I.jsx)(g,{className:`py-4`,children:`Nothing is typed, chosen or clicked as data in this workflow, so it has no test data.`}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`m-0 text-body-sm text-ink-2`,children:`Where each value typed, chosen or clicked comes from when it replays. A slot or a day that cannot be used twice can be any free one or a date from today. Test data can come from a data file's rows on the Last run tab.`}),(0,I.jsx)(`ul`,{className:l(`surface rounded-lg bg-bg p-6 shadow-sm`,`m-0 flex list-none flex-col p-0`),children:u.values.map(e=>(0,I.jsx)(Ae,{v:e,secrets:u.secrets,mobile:Z,busy:N,onSave:(t,n,r)=>void X(()=>W({workflow:u.workflow.path,step:e.n,action:`data`,as:t,...n===void 0?{}:{name:n},...r===void 0?{}:{value:r}}),t===`secret`?`Step ${e.n} types the secret ${n}; what was typed left the workflow.`:`Step ${e.n} saved.`)},e.n))})]})),P===`run`&&(0,I.jsx)(je,{view:u,job:K,rows:Z?{...Ne,requests:[]}:Ne,heal:Fe,busy:N||Y,onRun:qe})]})]})}export{z as a,R as i,V as n,B as o,ye as r,K as t};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./react-BDur5s0O.js";import{n,r}from"./route-oDy8sV6H.js";import{F as i,H as a,L as o,R as s,a as c,c as l,l as u}from"./preload-helper-BupTYkQW.js";import{n as d,t as f}from"./utils-DJRAScIl.js";import{t as p}from"./jsx-runtime-LKYXHABd.js";import{L as m}from"./palette-CeG8IIbL.js";import{D as h}from"./api-D_HT-I9y.js";import{C as g,S as _,_ as v,b as y,f as b,g as x,h as ee,n as S,x as C}from"./pageBack-DwhsvsK7.js";import{At as w,B as T,D as te,E,Gn as D,Ln as O,Lr as k,N as A,O as ne,R as j,Rr as M,Sr as re,St as ie,Wn as N,_ as ae,er as oe,hn as se,in as P,ir as ce,k as le,mn as ue,nn as de,qt as fe,rt as pe,ut as me,vt as he,w as ge,x as _e,z as ve}from"./line-icons-CwCZidXs.js";import{Ct as ye,St as be,Tt as xe,_t as F,bt as Se,lt as Ce,s as we,t as Te,wt as Ee,zt as De}from"./frame-Dt9QcYNX.js";import{n as Oe,t as I}from"./when-BuWCTaKm.js";import{t as ke}from"./code-Jek8uWUO.js";import{a as Ae}from"./markdown-DgUpsCX8.js";import{H as L,J as je,L as Me,U as R,V as Ne,X as Pe}from"./index-BdWLAq_n.js";import{i as z,r as B}from"./productParts-ClDOvIlz.js";var V=e(t(),1),H=p(),Fe={"forgeqe-session":`ForgeQE session`,otlp:`OpenTelemetry trace`,jsonl:`the agent's own log`,langfuse:`Langfuse`,langsmith:`LangSmith`},Ie={tool:k,model:ce,say:ue,plan:P,handoff:N,ask:ue,policy:oe,error:re},Le={text:`What it said`,file_change:`A file it changed`,report:`A report`,test_result:`A test result`,message:`A message it sent`},Re={request:`the request`,tool_result:`a tool's result`,file:`a file`,document:`a document`,memory:`memory`,agent:`another agent's answer`,person:`a person`},U=e=>e.replace(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f\u2028\u2029]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`),W=e=>{if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString([],{month:`short`,day:`numeric`,...t.getFullYear()===new Date().getFullYear()?{}:{year:`numeric`},hour:`numeric`,minute:`2-digit`,second:`2-digit`})},G=25,K={PASS:{tone:`pass`,label:`Pass`},WARN:{tone:`warn`,label:`Warning`},FAIL:{tone:`fail`,label:`Fail`},UNKNOWN:{tone:`neutral`,label:`Not known`}},q={required_steps:`Required steps`,allowed_actions:`Allowed actions`,tool_inputs:`Tool inputs`,limits:`Limits`,handover:`Hand-over`,statements:`What it said`,grounded_decisions:`Grounded decisions`,data_allowed:`Data allowed`,data_used:`Facts from its data`,stated_reasons:`Stated reasons`,instructions_in_data:`Instructions in data`,business_rules:`Business rules`,architecture:`Architecture`,dependencies:`Dependencies`,regression:`Regression`,security:`Security`,acceptance:`Acceptance criteria`,build_and_test:`Build and test`,content_rules:`Answer rules`,grounded:`Grounded in its inputs`,rubric:`Owner's rubric`},ze={build:{title:`Does the change work?`,icon:ie},behaviour:{title:`Did it work the agreed way?`,icon:T},decisions:{title:`Did it decide on the right grounds, with data it may use?`,icon:D},content:{title:`Was its answer right: on topic, grounded, complete?`,icon:me},domain:{title:`Was its change right for the product?`,icon:ae}},J=200,Be=`Agent governance`;function Y({id:e,back:t=!0,children:n}){let r=Me.some(t=>t.id===e);return(0,H.jsxs)(H.Fragment,{children:[t&&(0,H.jsx)(S,{}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2`,children:[(0,H.jsxs)(`span`,{className:`flex items-center gap-4`,children:[(0,H.jsx)(De,{pixel:m[r?Me[0].id:e],size:`lg`}),(0,H.jsx)(`h1`,{className:`m-0 text-headline-lg`,children:r?Be:n})]}),r&&(0,H.jsx)(Ce,{label:`Governance`,links:Me,current:e})]})]})}function X(){return(0,H.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Loading…`})}function Z(){return(0,H.jsxs)(v,{page:!0,icon:ie,title:`No agent run recorded yet`,action:(0,H.jsx)(`a`,{href:`/help/guide`,target:`_blank`,rel:`noreferrer noopener`,className:_({size:`sm`}),children:`Read how to record a run`}),children:[`An agent's runs show here once they are recorded: while it runs, from its traces, or afterwards, from an export or its own log. At a terminal that is `,(0,H.jsx)(`code`,{children:`forgeqe evidence receive`}),` or `,(0,H.jsx)(`code`,{children:`forgeqe evidence record`}),`.`]})}var Ve=(0,H.jsxs)(H.Fragment,{children:[`Receive an agent's OpenTelemetry traces while it runs with `,(0,H.jsx)(`code`,{children:`forgeqe evidence receive`}),`; record a file with `,(0,H.jsx)(`code`,{children:`forgeqe evidence record`}),`: an OpenTelemetry export, a Langfuse or LangSmith export, an agent's own JSON log with `,(0,H.jsx)(`code`,{children:`--mapping mapping.yaml`}),`, or ForgeQE's own last session with `,(0,H.jsx)(`code`,{children:`--latest`}),`.`]});function He({refused:e}){return e.length?(0,H.jsxs)(`section`,{"aria-label":`Files that are not run records`,className:f(g.warn,`flex flex-col gap-1`),children:[(0,H.jsxs)(`span`,{className:`font-medium`,children:[d(e.length,`file`),` in the runs folder `,e.length===1?`is`:`are`,` not a run record and `,e.length===1?`is`:`are`,` not shown:`]}),e.slice(0,10).map(e=>(0,H.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:e},e))]}):null}function Ue(){let[e,t]=(0,V.useState)(null),[n,i]=(0,V.useState)(``);return(0,V.useEffect)(()=>{h.overview().then(t,e=>i(e.message))},[]),(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Y,{id:`evidence`,children:`Evidence`}),(0,H.jsx)(R,{more:(0,H.jsxs)(H.Fragment,{children:[`What AI agents did, how, what they decided and why, and what data they used, from the records of their runs. What an agent says about its own work is kept as a claim, to be checked against what it did; what a record cannot say is listed, never guessed. `,Ve]}),children:`See what your AI agents did and decided, and whether it was what was agreed.`}),n&&(0,H.jsx)(B,{text:n}),!e&&!n&&(0,H.jsx)(X,{}),e&&(0,H.jsx)(He,{refused:e.refused}),e&&!e.runs&&(0,H.jsx)(Z,{}),e&&e.runs>0&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(Ne,{label:`What is recorded`,children:[(0,H.jsx)(L,{dot:`neutral`,value:e.runs,label:e.runs===1?`run recorded`:`runs recorded`}),(0,H.jsx)(L,{dot:`neutral`,value:e.agents.length,label:e.agents.length===1?`agent`:`agents`})]}),(0,H.jsx)(`h2`,{className:`sr-only`,children:`What is recorded`}),(0,H.jsx)(z,{id:`agents`,title:`Agents`,icon:ce,n:e.agents.length,children:(0,H.jsx)(`ul`,{"aria-label":`Agents`,className:f(`surface rounded-lg bg-bg p-6 shadow-sm`,`m-0 list-none`),children:e.agents.map(e=>(0,H.jsx)(`li`,{children:(0,H.jsxs)(`a`,{href:r(`evidence`,encodeURIComponent(e.name)),className:f(`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`,`min-h-12 flex-wrap gap-x-4 gap-y-1`),children:[(0,H.jsxs)(`span`,{className:`flex min-w-0 flex-[1_1_320px] flex-col`,children:[(0,H.jsx)(`span`,{className:`truncate text-body-sm font-medium`,children:U(e.name)}),(0,H.jsxs)(`span`,{className:`truncate text-body-sm text-muted`,children:[e.versions.length?`versions ${e.versions.slice(0,4).join(`, `)}${e.versions.length>4?`, …`:``} · `:``,`from `,e.sources.map(e=>Fe[e]||e).join(`, `)]})]}),(0,H.jsx)(`span`,{className:`text-body-sm text-ink-2 tabular-nums`,children:d(e.runs,`run`)}),(0,H.jsx)(`span`,{className:`text-body-sm text-ink-2 tabular-nums`,children:d(e.decisions,`decision`)}),(0,H.jsxs)(`span`,{className:`text-body-sm text-muted tabular-nums`,children:[d(e.gaps,`thing`,`things`),` not known`]}),(0,H.jsx)(`span`,{className:`text-body-sm text-ink-2`,children:e.contract?`${e.contract.approved?`Contract approved`:`Contract not approved`}: ${[`FAIL`,`WARN`,`UNKNOWN`,`PASS`].filter(t=>e.verdicts[t]).map(t=>d(e.verdicts[t],{FAIL:`failed run`,WARN:`warning`,UNKNOWN:`not known`,PASS:`passed run`}[t],{FAIL:`failed runs`,WARN:`warnings`,UNKNOWN:`not known`,PASS:`passed runs`}[t])).join(`, `)}`:`No contract`}),(0,H.jsx)(`span`,{className:`text-body-sm text-muted tabular-nums`,"data-tip":W(e.last),children:e.last?I(e.last):``})]})},e.name))})})]})]})}var We={PASS:`Passed`,WARN:`Warned`,FAIL:`Failed`,UNKNOWN:`Not known`,NONE:`Not judged`};function Ge({t:e,label:t,on:n,onToggle:r,fail:i}){return e.n?(0,H.jsx)(C,{variant:`link`,size:`inline`,"aria-pressed":n,"aria-label":`${e.n}: ${t}. Show the runs`,onClick:r,className:f(`min-h-7 min-w-7 justify-end rounded-full px-2 tabular-nums aria-pressed:bg-accent-soft`,i&&!n&&`text-fail`),children:e.n}):(0,H.jsx)(`span`,{className:`inline-flex min-h-7 items-center justify-end px-2 text-muted tabular-nums`,children:`0`})}function Ke({pick:e,d:t,onClose:n}){let[i,o]=(0,V.useState)(!1),s=i?e.runs:e.runs.slice(0,25);return(0,H.jsxs)(`div`,{className:f(l,`flex flex-col gap-2`),children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1`,children:[(0,H.jsxs)(`span`,{className:`text-body-sm font-medium text-ink [overflow-wrap:anywhere]`,children:[d(e.runs.length,`run`),` behind `,U(e.label)]}),(0,H.jsxs)(C,{size:`sm`,variant:`ghost`,onClick:n,children:[(0,H.jsx)(M,{"aria-hidden":`true`}),`Close`]})]}),(0,H.jsx)(`ul`,{"aria-label":`Runs behind ${e.label}`,className:`m-0 list-none border-t border-line-soft py-1`,children:s.map(e=>{let n=t.brief[e];return(0,H.jsx)(`li`,{children:(0,H.jsxs)(`a`,{href:r(`evidence-runs`,encodeURIComponent(e)),className:f(a,`grid min-h-10 grid-cols-[auto_minmax(0,1fr)_auto] gap-x-4`),children:[n&&n.status!==`NONE`?(0,H.jsx)(x,{tone:K[n.status].tone,children:K[n.status].label}):(0,H.jsx)(`span`,{className:`text-body-sm text-muted`,children:`Not judged`}),(0,H.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,H.jsx)(`span`,{className:`truncate text-body-sm`,children:U(n?.request||e)}),(0,H.jsxs)(`span`,{className:`truncate font-mono text-body-sm text-muted`,children:[e,n?.version?` · ${U(n.version)}`:``]})]}),(0,H.jsx)(`span`,{className:`text-right text-body-sm text-muted tabular-nums`,"data-tip":W(n?.started),children:n?.started?I(n.started):``})]})},e)})}),e.runs.length>s.length&&(0,H.jsxs)(C,{size:`sm`,variant:`ghost`,onClick:()=>o(!0),children:[(0,H.jsx)(E,{"aria-hidden":`true`}),`All (`,e.runs.length,`)`]})]})}function qe({agent:e}){let[t,n]=(0,V.useState)(null),[i,a]=(0,V.useState)(``),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(null);(0,V.useEffect)(()=>{h.dashboard(e).then(n,e=>a(e.message))},[e]);let d=e=>e?U(e):`no version`,p=t?t.versions.find(e=>e.version===s)||t.versions[0]:void 0,m=e=>l&&t&&l.key.startsWith(`${e}|`)?(0,H.jsx)(Ke,{pick:l,d:t,onClose:()=>u(null)},l.key):null,g=(e,t,n,r)=>{let i=`${e}|${n}`;return(0,H.jsx)(Ge,{t,label:n,on:l?.key===i,onToggle:()=>u(l?.key===i?null:{key:i,label:n,runs:t.runs}),fail:r})};return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(S,{to:{href:r(`evidence`),label:`Evidence`}}),(0,H.jsx)(Y,{id:`evidence`,back:!1,children:U(e)}),(0,H.jsx)(R,{more:(0,H.jsx)(H.Fragment,{children:`Every number opens the runs it counts; not known and not judged are never counted as passed. Worked out now from the runs and their verdicts, with people's overrules applied.`}),children:`How this agent's runs were judged, version by version and week by week.`}),i&&(0,H.jsx)(B,{text:i}),!t&&!i&&(0,H.jsx)(X,{}),t?.problems.map(e=>(0,H.jsx)(B,{text:e},e)),t&&p&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-1 text-body-sm`,children:[(0,H.jsxs)(Ne,{label:`Its runs and versions`,children:[(0,H.jsx)(L,{dot:`neutral`,value:t.runs.n,label:t.runs.n===1?`run`:`runs`}),(0,H.jsx)(L,{dot:`neutral`,value:t.versions.length,label:t.versions.length===1?`version`:`versions`})]}),(0,H.jsx)(`a`,{href:r(`evidence-runs`,`agent`,encodeURIComponent(e)),children:`All its runs`}),(0,H.jsx)(`a`,{href:r(`evidence-learn`,encodeURIComponent(e)),children:`What to change`})]}),(0,H.jsx)(`h2`,{className:`sr-only`,children:`Its numbers`}),(0,H.jsxs)(z,{id:`versions`,title:`Versions`,icon:w,n:t.versions.length,children:[(0,H.jsx)(F,{label:`Versions of ${e}`,search:!1,minWidth:640,head:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,children:`Version`}),[`Runs`,`Passed`,`Warned`,`Failed`,`Not known`,`Not judged`].map(e=>(0,H.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-right text-label-md font-medium whitespace-nowrap text-muted`,children:e},e)),(0,H.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,children:`Last run`})]}),children:t.versions.map(e=>(0,H.jsxs)(`tr`,{className:`h-12 border-t border-line-soft align-middle transition-colors duration-150 data-[state=selected]:bg-tint-hover`,children:[(0,H.jsx)(`th`,{scope:`row`,className:f(`px-4 py-2`,`text-left font-medium`),children:d(e.version)}),(0,H.jsx)(`td`,{className:`px-4 py-2 text-right whitespace-nowrap tabular-nums`,"data-sort":e.runs.n,children:g(`versions`,e.runs,`${d(e.version)}: runs`)}),[`PASS`,`WARN`,`FAIL`,`UNKNOWN`,`NONE`].map(t=>(0,H.jsx)(`td`,{className:`px-4 py-2 text-right whitespace-nowrap tabular-nums`,"data-sort":e.outcome[t].n,children:g(`versions`,e.outcome[t],`${d(e.version)}: ${We[t].toLowerCase()}`,t===`FAIL`)},t)),(0,H.jsx)(`td`,{className:f(`px-4 py-2`,`text-muted`),"data-tip":W(e.last),"data-sort":e.last&&Date.parse(e.last)||0,children:e.last?I(e.last):``})]},e.version))}),m(`versions`)]}),t.versions.length>1&&t.benchmark.length>0&&(0,H.jsxs)(z,{id:`benchmark`,title:`Versions side by side`,icon:D,children:[(0,H.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`Each check: the share of a version's runs that passed it, of the runs it judged. The number after it opens the runs that did not pass.`}),(0,H.jsx)(F,{label:`Versions side by side`,search:!1,minWidth:480,head:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,children:`Check`}),t.versions.map(e=>(0,H.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-right text-label-md font-medium whitespace-nowrap text-muted`,children:d(e.version)},e.version))]}),children:t.benchmark.map(e=>(0,H.jsxs)(`tr`,{className:`h-12 border-t border-line-soft align-middle transition-colors duration-150 data-[state=selected]:bg-tint-hover`,children:[(0,H.jsx)(`th`,{scope:`row`,className:f(`px-4 py-2`,`text-left font-medium`),children:q[e.check]}),e.versions.map(t=>{let n={n:t.judged.n-t.pass.n,runs:t.judged.runs.filter(e=>!t.pass.runs.includes(e))};return(0,H.jsx)(`td`,{className:`px-4 py-2 text-right whitespace-nowrap tabular-nums`,"data-sort":t.rate??-1,children:t.rate===null?(0,H.jsx)(`span`,{className:`text-muted`,children:`not judged`}):(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,H.jsxs)(`span`,{className:f(t.rate<1&&`text-ink`),children:[Math.round(t.rate*100),`% of `,t.judged.n]}),n.n>0&&(0,H.jsx)(`span`,{className:`text-muted`,children:`·`}),n.n>0&&g(`benchmark`,n,`${q[e.check]} on ${d(t.version)}: not passed`,!0)]})},t.version)})]},`${e.lens}-${e.check}`))}),m(`benchmark`)]}),(0,H.jsxs)(z,{id:`checks`,title:`Checks`,icon:P,n:p.checks.length,children:[t.versions.length>1&&(0,H.jsxs)(`label`,{className:`flex w-fit items-center gap-2 text-body-sm text-ink-2`,children:[`Version`,(0,H.jsx)(o,{value:p.version,onChange:e=>{c(e.target.value),u(null)},children:t.versions.map(e=>(0,H.jsx)(`option`,{value:e.version,children:e.version||`no version`},e.version))})]}),p.checks.length?(0,H.jsx)(F,{label:`Checks of ${d(p.version)}`,search:!1,minWidth:600,head:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,children:`Check`}),(0,H.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,children:`Lens`}),[`Passed`,`Warned`,`Failed`,`Not known`,`Overruled`].map(e=>(0,H.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-right text-label-md font-medium whitespace-nowrap text-muted`,children:e},e))]}),children:p.checks.map(e=>(0,H.jsxs)(`tr`,{className:`h-12 border-t border-line-soft align-middle transition-colors duration-150 data-[state=selected]:bg-tint-hover`,children:[(0,H.jsx)(`th`,{scope:`row`,className:f(`px-4 py-2`,`text-left font-medium`),children:q[e.check]}),(0,H.jsx)(`td`,{className:f(`px-4 py-2`,`text-muted`),children:rt[e.lens]}),[`PASS`,`WARN`,`FAIL`,`UNKNOWN`].map(t=>(0,H.jsx)(`td`,{className:`px-4 py-2 text-right whitespace-nowrap tabular-nums`,"data-sort":e.outcome[t].n,children:g(`checks`,e.outcome[t],`${q[e.check]}: ${We[t].toLowerCase()}`,t===`FAIL`)},t)),(0,H.jsx)(`td`,{className:`px-4 py-2 text-right whitespace-nowrap tabular-nums`,"data-sort":e.overruled.n,children:g(`checks`,e.overruled,`${q[e.check]}: overruled`)})]},`${e.lens}-${e.check}`))}):(0,H.jsxs)(`p`,{className:`m-0 text-body-sm text-muted`,children:[`No contract judged these runs: `,(0,H.jsx)(`a`,{href:r(`evidence-contracts`),children:`Contracts`}),` says what one agrees.`]}),m(`checks`)]}),p.rules.length>0&&(0,H.jsxs)(z,{id:`recurring`,title:`What keeps going wrong`,icon:re,n:p.rules.length,children:[(0,H.jsx)(`ul`,{"aria-label":`What keeps going wrong`,className:f(`surface rounded-lg bg-bg p-6 shadow-sm`,`m-0 list-none`),children:p.rules.slice(0,20).map(e=>(0,H.jsxs)(`li`,{className:`flex flex-col gap-1 border-b border-line-soft px-4 py-2 last:border-b-0`,children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1`,children:[(0,H.jsx)(x,{tone:K[e.status].tone,children:K[e.status].label}),(0,H.jsxs)(`span`,{className:`text-body-sm font-medium`,children:[q[e.check],`: `,U(e.rule)]}),(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-body-sm text-muted`,children:[`in `,g(`recurring`,e.runs,`${q[e.check]}: ${e.rule}`),` `,e.runs.n===1?`run`:`runs`]})]}),(0,H.jsxs)(`span`,{className:`text-body-sm text-ink-2 [overflow-wrap:anywhere]`,children:[`For example: `,U(e.example)]})]},`${e.check}-${e.rule}`))}),m(`recurring`)]}),(0,H.jsxs)(z,{id:`weeks`,title:`Week by week`,icon:_e,n:t.weeks.length,children:[(0,H.jsx)(F,{label:`Week by week`,search:!1,minWidth:520,head:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,children:`Week`}),[`PASS`,`WARN`,`FAIL`,`UNKNOWN`,`NONE`].map(e=>(0,H.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-right text-label-md font-medium whitespace-nowrap text-muted`,children:We[e]},e))]}),children:t.weeks.toReversed().map(e=>(0,H.jsxs)(`tr`,{className:`h-12 border-t border-line-soft align-middle transition-colors duration-150 data-[state=selected]:bg-tint-hover`,children:[(0,H.jsx)(`th`,{scope:`row`,className:f(`px-4 py-2`,`text-left font-medium tabular-nums`),children:e.week===`undated`?`No date`:e.week}),[`PASS`,`WARN`,`FAIL`,`UNKNOWN`,`NONE`].map(t=>(0,H.jsx)(`td`,{className:`px-4 py-2 text-right whitespace-nowrap tabular-nums`,"data-sort":e.outcome[t].n,children:g(`weeks`,e.outcome[t],`${e.week}: ${We[t].toLowerCase()}`,t===`FAIL`)},t))]},e.week))}),m(`weeks`)]})]})]})}function Je({agent:e}){let[t,n]=(0,V.useState)(null),[i,a]=(0,V.useState)([]),[s,c]=(0,V.useState)(``),[l,u]=(0,V.useState)(``),[p,m]=(0,V.useState)(e),[g,_]=(0,V.useState)(`all`),[v,y]=(0,V.useState)(0);(0,V.useEffect)(()=>{h.runs().then(e=>{n(e.runs),a(e.refused)},e=>c(e.message))},[]),(0,V.useEffect)(()=>m(e),[e]);let x=(0,V.useMemo)(()=>[...new Set((t||[]).map(e=>e.agent))].sort(),[t]),S=l.toLowerCase().split(/\s+/).filter(Boolean),w=(t||[]).filter(e=>(!p||e.agent===p)&&S.every(t=>`${e.agent} ${e.request||``} ${e.id} ${e.source.name}`.toLowerCase().includes(t))),T=g===`failed`?w.filter(e=>e.failed):w,E={all:w.length,failed:w.filter(e=>e.failed).length},D=Math.max(1,Math.ceil(T.length/G)),O=Math.min(v,D-1),k=T.slice(O*G,O*G+G);(0,V.useEffect)(()=>y(0),[l,p,g]);let j=t||[],M=j.filter(e=>e.failed).length;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Y,{id:`evidence-runs`,children:`Agent runs`}),(0,H.jsx)(R,{more:(0,H.jsxs)(H.Fragment,{children:[`Open one for its timeline: each step, the data it took in, what it decided and the reason it gave, and what the record cannot say. `,Ve]}),children:`Every agent run recorded here, newest first.`}),s&&(0,H.jsx)(B,{text:s}),!t&&!s&&(0,H.jsx)(X,{}),(0,H.jsx)(He,{refused:i}),t&&!t.length&&(0,H.jsx)(Z,{}),t&&t.length>0&&(0,H.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,H.jsxs)(Ne,{label:`Runs recorded`,children:[(0,H.jsx)(L,{dot:`neutral`,value:j.length,label:j.length===1?`run`:`runs`}),(0,H.jsx)(L,{dot:M?`fail`:`pass`,value:M,label:`with a failed step (${Math.round(M/j.length*100)}%)`}),(0,H.jsx)(L,{dot:`neutral`,value:j.reduce((e,t)=>e+t.decisions,0),label:j.reduce((e,t)=>e+t.decisions,0)===1?`decision`:`decisions`}),(0,H.jsx)(L,{dot:`neutral`,value:new Set(j.map(e=>e.agent)).size,label:new Set(j.map(e=>e.agent)).size===1?`agent`:`agents`})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(ee,{id:`evidence-search`,label:`Find a run`,value:l,onChange:u,placeholder:`Find a run by what was asked`}),(0,H.jsx)(b,{items:[{id:`all`,label:`All`,n:E.all},{id:`failed`,label:`Failed`,n:E.failed,alert:!0}],value:g,onChange:_}),x.length>1&&(0,H.jsxs)(o,{size:`sm`,"aria-label":`Agent`,value:p,onChange:e=>m(e.target.value),className:`w-auto pr-8 pl-4`,children:[(0,H.jsx)(`option`,{value:``,children:`Every agent`}),x.map(e=>(0,H.jsx)(`option`,{value:e,children:U(e)},e))]})]}),(0,H.jsxs)(`div`,{className:`surface rounded-lg bg-bg p-6 shadow-sm`,children:[(0,H.jsxs)(`ul`,{"aria-label":`Agent runs`,className:`m-0 list-none p-2`,children:[!k.length&&(0,H.jsx)(`li`,{className:`px-4 py-4 text-body-sm text-muted`,children:`Nothing matches.`}),k.map((e,t)=>(0,H.jsxs)(`li`,{className:`contents`,children:[(t===0||Oe(k[t-1].started)!==Oe(e.started))&&(0,H.jsx)(`span`,{className:`block px-4 pt-4 pb-1 text-body-sm font-medium text-muted`,children:Oe(e.started)}),(0,H.jsxs)(`a`,{href:r(`evidence-runs`,encodeURIComponent(e.id)),className:f(`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`,`grid min-h-12 grid-cols-[auto_minmax(0,1fr)_auto] gap-x-4`),children:[e.failed?(0,H.jsx)(ve,{size:16,"aria-label":`${e.failed} failed ${e.failed===1?`step`:`steps`}`,className:`flex-none text-fail`}):(0,H.jsx)(A,{size:16,"aria-label":`No failed step`,className:`flex-none text-muted`}),(0,H.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,H.jsx)(`span`,{className:`truncate text-body-sm font-medium`,"data-tip":e.request||e.agent,children:U(e.request||`${e.agent}: request not recorded`)}),(0,H.jsx)(`span`,{className:`truncate text-body-sm text-muted`,children:[U(`${e.agent}${e.version?` ${e.version}`:``}`),d(e.steps,`step`),d(e.decisions,`decision`),`${d(e.gaps,`thing`,`things`)} not known`,Fe[e.source.kind],e.content?`content kept`:`inputs as fingerprints`,e.verdict?`verdict: ${K[e.verdict].label.toLowerCase()}`:`no contract`].join(` · `)})]}),(0,H.jsx)(`span`,{className:`text-right text-body-sm text-muted tabular-nums`,"data-tip":W(e.started),children:e.started?I(e.started):``})]})]},e.id))]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 border-t border-line-soft px-4 py-2 text-body-sm text-muted`,children:[(0,H.jsx)(`span`,{className:`flex-1`,children:T.length?`${O*G+1}–${Math.min(T.length,O*G+G)} of ${T.length}`:`0 runs`}),D>1&&(0,H.jsxs)(`nav`,{"aria-label":`Pages of agent runs`,className:`flex items-center gap-1`,children:[(0,H.jsx)(C,{size:`sm`,variant:`ghost`,disabled:O===0,onClick:()=>y(O-1),"aria-label":`Newer runs`,"data-tip":`Newer runs`,children:(0,H.jsx)(te,{"aria-hidden":`true`})}),(0,H.jsxs)(`span`,{className:`px-1 tabular-nums`,children:[`Page `,O+1,` of `,D]}),(0,H.jsx)(C,{size:`sm`,variant:`ghost`,disabled:O>=D-1,onClick:()=>y(O+1),"aria-label":`Older runs`,"data-tip":`Older runs`,children:(0,H.jsx)(ne,{"aria-hidden":`true`})})]})]})]})]})]})}function Q({t:e,label:t}){let[n,r]=(0,V.useState)(!1);if(e.text===void 0)return(0,H.jsxs)(`span`,{className:`font-mono text-body-sm text-muted`,children:[t,`: fingerprint only, `,e.chars.toLocaleString(),` characters, sha256 `,e.sha256.slice(0,12),`…`]});let i=e.text.length>600;return(0,H.jsxs)(`span`,{className:`flex flex-col items-start gap-1`,children:[(0,H.jsx)(`span`,{className:`text-body-sm whitespace-pre-wrap text-ink-2 [overflow-wrap:anywhere]`,children:U(i&&!n?`${e.text.slice(0,600)}…`:e.text)}),i&&(0,H.jsxs)(C,{variant:`link`,size:`inline`,onClick:()=>r(!n),"data-tip":n?void 0:`Show all ${e.text.length.toLocaleString()} characters`,className:`gap-1`,children:[n?(0,H.jsx)(le,{size:12,"aria-hidden":`true`}):(0,H.jsx)(E,{size:12,"aria-hidden":`true`}),n?`Less`:`More`]})]})}function Ye({d:e}){return(0,H.jsxs)(`div`,{className:`flex flex-col gap-1 border-l-2 border-accent-line pl-4`,children:[(0,H.jsxs)(`span`,{className:`text-body-sm font-medium text-muted`,children:[`Decided`,e.by?` · by ${U(e.by)}`:``]}),(0,H.jsxs)(`span`,{className:`text-body-sm text-ink [overflow-wrap:anywhere]`,children:[U(e.what),`: `,(0,H.jsx)(`b`,{className:`font-medium`,children:U(e.chose)})]}),e.options&&e.options.length>0&&(0,H.jsxs)(`span`,{className:`text-body-sm text-muted [overflow-wrap:anywhere]`,children:[`Options: `,U(e.options.join(`, `))]}),e.reason?(0,H.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-body-sm text-muted`,children:`The reason given (a claim, not checked yet):`}),(0,H.jsx)(Q,{t:e.reason,label:`reason`})]}):(0,H.jsx)(`span`,{className:`text-body-sm text-muted`,children:`No reason given.`})]})}function Xe({s:e,r:t}){let n=(e.inputs||[]).map(e=>t.inputs.find(t=>t.id===e)).filter(e=>!!e),r=t.decisions.filter(t=>t.step===e.seq),i=t.statements.filter(t=>t.step===e.seq),a=Object.entries(e.facts||{});return(0,H.jsxs)(`li`,{id:`evidence-step-${e.seq}`,tabIndex:-1,className:`grid scroll-mt-4 grid-cols-[36px_minmax(0,1fr)] gap-x-2 border-b border-line-soft py-2 outline-none last:border-b-0 focus-visible:bg-accent-soft`,children:[(0,H.jsx)(`span`,{className:`pt-1 text-right text-body-sm text-muted tabular-nums`,children:e.seq}),(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,H.jsx)(y,{icon:Ie[e.kind]||k,size:14,className:`flex-none`}),(0,H.jsx)(`span`,{className:`text-body-sm font-medium [overflow-wrap:anywhere]`,children:U(e.name)}),(0,H.jsx)(`span`,{className:`text-body-sm text-muted`,children:e.kind}),e.agent&&(0,H.jsxs)(`span`,{className:`text-body-sm text-muted`,children:[`· by `,U(e.agent)]}),e.ok===!1&&(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-body-sm text-fail`,children:[(0,H.jsx)(ve,{size:13,"aria-hidden":`true`}),`failed`]}),e.ms!==void 0&&(0,H.jsxs)(`span`,{className:`text-body-sm text-muted tabular-nums`,children:[`· `,e.ms.toLocaleString(),` ms`]})]}),a.length>0&&(0,H.jsx)(`span`,{className:`text-body-sm text-muted [overflow-wrap:anywhere]`,children:U(a.map(([e,t])=>`${e}: ${String(t)}`).join(` · `))}),e.detail&&(0,H.jsx)(Q,{t:e.detail,label:`details`}),e.instructions&&(0,H.jsxs)(`details`,{className:`border-l-2 border-line pl-4`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer text-body-sm font-medium text-muted`,children:(()=>{let n=t.steps.filter(t=>t.seq<e.seq&&t.instructions?.sha256===e.instructions.sha256);return n.length?`Instructions, the same as step ${n[n.length-1].seq}`:`Instructions given to the model`})()}),(0,H.jsx)(`div`,{className:`mt-1`,children:(0,H.jsx)(Q,{t:e.instructions,label:`instructions`})})]}),n.map(e=>(0,H.jsxs)(`div`,{className:`flex flex-col gap-1 border-l-2 border-line pl-4`,children:[(0,H.jsxs)(`span`,{className:`text-body-sm font-medium text-muted [overflow-wrap:anywhere]`,children:[`Took in `,Re[e.kind]||e.kind,` from `,U(e.source)]}),(0,H.jsx)(Q,{t:e.kind===`request`&&e.data.text===void 0&&t.request?.text?.text!==void 0&&t.request.text.sha256===e.data.sha256?t.request.text:e.data,label:`content`})]},e.id)),r.map(e=>(0,H.jsx)(Ye,{d:e},e.seq)),i.map(e=>(0,H.jsxs)(`div`,{className:`flex flex-col gap-1 border-l-2 border-line pl-4`,children:[(0,H.jsx)(`span`,{className:`text-body-sm font-medium text-muted`,children:`Said (a claim about its own work, not checked yet)`}),(0,H.jsx)(Q,{t:e.text,label:`statement`})]},e.seq))]})]})}function Ze({r:e,goTo:t}){let n=e.steps.filter(e=>e.kind===`model`),r=n.find(e=>e.instructions),i=new Set(n.filter(e=>e.instructions).map(e=>e.instructions.sha256)).size,a=e.outputs.filter(e=>e.kind===`text`),o=a[a.length-1],s=a.slice(0,-1),l=e.outputs.filter(e=>e.kind!==`text`),u=e=>n.reduce((t,n)=>t+(typeof n.facts?.[e]==`number`?n.facts[e]:0),0),d=u(`tokens_in`),f=u(`tokens_out`),p=[...new Set(n.map(e=>e.name))],m=({children:e})=>(0,H.jsx)(`span`,{className:`text-body-sm font-medium text-muted`,children:e}),h=({seq:e})=>(0,H.jsxs)(C,{variant:`link`,size:`inline`,onClick:()=>t(e),children:[`step `,e]});return(0,H.jsx)(z,{id:`evidence-io`,title:`Prompt and output`,icon:se,children:(0,H.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(n.length>0||d+f>0)&&(0,H.jsxs)(`p`,{className:`m-0 text-body-sm text-ink-2`,children:[n.length,` model `,n.length===1?`call`:`calls`,p.length?` (${U(p.join(`, `))})`:``,d+f>0?` · ${d.toLocaleString()} tokens in, ${f.toLocaleString()} out`:``]}),(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,H.jsxs)(m,{children:[`Instructions (system prompt)`,r?(0,H.jsxs)(H.Fragment,{children:[` · from `,(0,H.jsx)(h,{seq:r.seq})]}):null,i>1?` · ${i} different ones in this run`:``]}),(0,H.jsx)(`div`,{className:c,children:r?.instructions?(0,H.jsx)(Q,{t:r.instructions,label:`instructions`}):(0,H.jsx)(`span`,{className:`text-body-sm text-muted`,children:`Not in the record: its source did not hold the instructions the model was given.`})})]}),(0,H.jsxs)(`div`,{className:`grid gap-4 @3xl:grid-cols-2`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,H.jsxs)(m,{children:[`Request`,e.request?.by?` · from ${U(e.request.by)}`:``,e.request?.from?` · read from the ${U(e.request.from)}`:``]}),(0,H.jsx)(`div`,{className:c,children:e.request?.text?(0,H.jsx)(Q,{t:e.request.text,label:`request`}):(0,H.jsx)(`span`,{className:`text-body-sm text-muted`,children:`Not in the record: its source did not say what the agent was asked.`})})]}),(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,H.jsxs)(m,{children:[`Final answer`,o?(0,H.jsxs)(H.Fragment,{children:[` · `,(0,H.jsx)(h,{seq:o.step})]}):null]}),(0,H.jsx)(`div`,{className:c,children:o?.data?(0,H.jsx)(Q,{t:o.data,label:`answer`}):(0,H.jsx)(`span`,{className:`text-body-sm text-muted`,children:`Not in the record: its source did not say what the agent answered.`})})]})]}),l.length>0&&(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,H.jsxs)(m,{children:[`What it produced (`,l.length,`)`]}),(0,H.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0`,children:l.map(e=>(0,H.jsxs)(`li`,{className:`flex flex-wrap items-center gap-x-2 text-body-sm text-ink-2`,children:[Le[e.kind]||e.kind,e.target?(0,H.jsx)(`span`,{className:`font-mono text-body-sm [overflow-wrap:anywhere]`,children:U(e.target)}):null,`· `,(0,H.jsx)(h,{seq:e.step})]},e.id))})]}),s.length>0&&(0,H.jsxs)(`details`,{className:`group flex flex-col gap-2`,children:[(0,H.jsxs)(`summary`,{className:`cursor-pointer text-body-sm font-medium text-muted`,children:[`What it said on the way (`,s.length,`)`]}),(0,H.jsx)(`ol`,{className:`m-0 mt-2 flex list-none flex-col gap-2 p-0`,children:s.map(e=>(0,H.jsxs)(`li`,{className:`flex flex-col gap-1 border-l-2 border-line pl-4`,children:[(0,H.jsx)(h,{seq:e.step}),e.data?(0,H.jsx)(Q,{t:e.data,label:`said`}):null]},e.id))})]})]})})}function Qe({id:e}){let[t,n]=(0,V.useState)(null),[i,a]=(0,V.useState)(``),[o,s]=(0,V.useState)(J);(0,V.useEffect)(()=>{h.run(e).then(n,e=>a(e.message))},[e]);let c=(0,H.jsx)(S,{to:{href:r(`evidence-runs`),label:`All agent runs`}});if(!t)return(0,H.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[c,i?(0,H.jsx)(B,{text:i}):(0,H.jsx)(X,{})]});let l=t.decisions.filter(e=>!e.step),u=t.steps.filter(e=>e.ok===!1).length,d=e=>{e>o&&s(Math.ceil(e/J)*J),requestAnimationFrame(()=>{let t=document.getElementById(`evidence-step-${e}`);t?.scrollIntoView({block:`start`}),t?.focus({preventScroll:!0})})},p=[...t.gaps,...t.truncated?[t.truncated]:[]];return(0,H.jsxs)(`section`,{"aria-labelledby":`evidence-run-h`,className:`flex flex-col gap-6`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[c,(0,H.jsx)(Pe,{id:`evidence-run-h`,icon:N,title:U(t.request?.text?.text?t.request.text.text.slice(0,200):`${t.agent.name}: request not recorded`)}),(0,H.jsxs)(`p`,{className:`m-0 text-body-sm text-ink-2 [overflow-wrap:anywhere]`,children:[U(`${t.agent.name}${t.agent.version?` ${t.agent.version}`:``}${t.agent.model?` · ${t.agent.model}`:``}${t.agent.provider?` (${t.agent.provider})`:``}`),` · from `,Fe[t.source.kind],`, `,U(t.source.name),t.started?` · ${W(t.started)}`:``,t.ended&&t.ended!==t.started?` to ${W(t.ended)}`:``]}),(0,H.jsx)(`p`,{className:`m-0 font-mono text-body-sm text-muted`,children:t.id})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-x-6 gap-y-1 text-body-sm text-muted`,children:[(0,H.jsxs)(`span`,{children:[(0,H.jsx)(`b`,{className:`text-ink tabular-nums`,children:t.steps.length}),` `,t.steps.length===1?`step`:`steps`]}),(0,H.jsxs)(`span`,{children:[(0,H.jsx)(`b`,{className:f(`tabular-nums`,u?`text-fail`:`text-ink`),children:u}),` failed`]}),(0,H.jsxs)(`span`,{children:[(0,H.jsx)(`b`,{className:`text-ink tabular-nums`,children:t.inputs.length}),` `,t.inputs.length===1?`input`:`inputs`]}),(0,H.jsxs)(`span`,{children:[(0,H.jsx)(`b`,{className:`text-ink tabular-nums`,children:t.decisions.length}),` `,t.decisions.length===1?`decision`:`decisions`]}),(0,H.jsxs)(`span`,{children:[(0,H.jsx)(`b`,{className:`text-ink tabular-nums`,children:t.statements.length}),` `,t.statements.length===1?`claim`:`claims`]}),(0,H.jsx)(`span`,{children:t.content?`Content kept, with secrets cut out`:`Inputs kept as fingerprints only`})]}),(0,H.jsx)(Ze,{r:t,goTo:d}),(0,H.jsx)($e,{id:t.id,goTo:d}),(0,H.jsx)(z,{id:`evidence-gaps`,title:`What the record cannot say`,icon:fe,n:p.length,children:p.length?(0,H.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:p.map(e=>(0,H.jsx)(`li`,{className:`border-b border-line-soft py-2 text-body-sm text-ink-2 last:border-b-0 [overflow-wrap:anywhere]`,children:U(e)},e))}):(0,H.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`Nothing: the source said everything the record holds.`})}),(0,H.jsxs)(z,{id:`evidence-timeline`,title:`Timeline`,icon:N,n:t.steps.length,children:[(0,H.jsx)(`ol`,{"aria-label":`Steps`,className:`m-0 flex list-none flex-col p-0`,children:t.steps.slice(0,o).map(e=>(0,H.jsx)(Xe,{s:e,r:t},e.seq))}),t.steps.length>o&&(0,H.jsxs)(C,{size:`sm`,variant:`ghost`,className:`self-start`,onClick:()=>s(o+J),"data-tip":`Show ${Math.min(J,t.steps.length-o)} more of ${t.steps.length-o}`,children:[(0,H.jsx)(E,{"aria-hidden":`true`}),`More (`,Math.min(J,t.steps.length-o),`)`]})]}),l.length>0&&(0,H.jsx)(z,{id:`evidence-loose`,title:`Decisions not tied to a step`,icon:D,n:l.length,children:(0,H.jsx)(`div`,{className:`flex flex-col gap-4`,children:l.map(e=>(0,H.jsx)(Ye,{d:e},e.seq))})}),(0,H.jsx)(z,{id:`evidence-inputs`,title:`Data it took in`,icon:he,n:t.inputs.length,children:t.inputs.length?(0,H.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:t.inputs.map(e=>(0,H.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-x-4 gap-y-1 border-b border-line-soft py-2 last:border-b-0`,children:[(0,H.jsxs)(`span`,{className:`min-w-0 flex-[1_1_320px] text-body-sm [overflow-wrap:anywhere]`,children:[(0,H.jsx)(`span`,{className:`font-medium`,children:Re[e.kind]||e.kind}),` `,(0,H.jsx)(`span`,{className:`text-muted`,children:`from`}),` `,U(e.source)]}),(0,H.jsxs)(`span`,{className:`text-body-sm text-muted tabular-nums`,children:[`step `,e.step]}),(0,H.jsx)(`span`,{className:`font-mono text-body-sm text-muted`,children:e.data.text===void 0?`${e.data.chars.toLocaleString()} chars · ${e.data.sha256.slice(0,12)}`:`kept`})]},e.id))}):(0,H.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`The record holds no input.`})})]})}function $e({id:e,goTo:t}){let[n,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(``),[s,c]=(0,V.useState)(0),l=()=>c(e=>e+1);if((0,V.useEffect)(()=>{h.verdict(e).then(i,e=>o(e.message))},[e,s]),a)return(0,H.jsx)(B,{text:a});if(!n)return(0,H.jsx)(X,{});let d=n.why||!n.verdicts.length?(0,H.jsx)(z,{id:`evidence-behaviour`,title:ze.behaviour.title,icon:T,children:(0,H.jsxs)(`p`,{className:`m-0 text-body-sm leading-relaxed text-ink-2`,children:[`Not judged: `,U(n.why||`no contract judges this agent.`),` A contract says what was agreed for an agent; `,(0,H.jsx)(`a`,{href:r(`evidence-contracts`),children:`Contracts`}),` lists them.`]})}):null;return(0,H.jsxs)(H.Fragment,{children:[n.work&&(0,H.jsxs)(`p`,{className:f(`m-0`,g[n.work.personTakesOver?`warn`:`info`]),children:[n.work.attempt?`Fix attempt ${n.work.attempt} of 2 at `:`The first run of work tried again in `,n.work.attempt?(0,H.jsx)(`a`,{href:r(`evidence-runs`,encodeURIComponent(n.work.first)),children:n.work.first}):`${n.work.runs.length-1} ${n.work.runs.length===2?`fix attempt`:`fix attempts`}`,n.work.personTakesOver?`: findings are still open after the last attempt, so a person takes over.`:`.`]}),d,n.verdicts.map(e=>(0,H.jsx)(z,{id:`evidence-${e.lens}`,title:ze[e.lens].title,icon:ze[e.lens].icon,children:(0,H.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1`,children:[(0,H.jsx)(x,{tone:K[e.status].tone,children:K[e.status].label}),(0,H.jsx)(`span`,{className:`text-body-sm text-ink-2 [overflow-wrap:anywhere]`,children:e.contract?(0,H.jsxs)(H.Fragment,{children:[`By contract `,U(e.contract.name),`, version `,U(e.contract.version),`, `,e.contract.approved?`approved`:`not approved: it can only warn`]}):`Against the product graph: advisory, it can only warn`})]}),e.notes.map(e=>(0,H.jsx)(`p`,{className:`m-0 text-body-sm text-muted [overflow-wrap:anywhere]`,children:U(e)},e)),(0,H.jsx)(`ul`,{"aria-label":`Checks`,className:f(u,`m-0 flex list-none flex-col`),children:e.checks.map(n=>(0,H.jsxs)(`li`,{className:`flex flex-col gap-2 border-b border-line-soft px-4 py-2 last:border-b-0`,children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1`,children:[(0,H.jsx)(`span`,{className:`min-w-[152px] text-body-sm font-medium`,children:q[n.check]}),(0,H.jsx)(x,{tone:K[n.status].tone,children:K[n.status].label}),(0,H.jsxs)(`span`,{className:`text-body-sm text-muted [overflow-wrap:anywhere]`,children:[U(n.checked),n.gating?` · can fail a run`:n.advisory&&e.contract?.approved?` · ${n.advisory}`:``]})]}),n.findings.map(n=>(0,H.jsx)(tt,{f:n,run:e.run,goTo:t,onOverruled:l},n.id))]},n.check))}),e.lens===`content`&&n.rubric&&(0,H.jsx)(et,{run:e.run,rubric:n.rubric,onGraded:l})]})},e.lens))]})}function et({run:e,rubric:t,onGraded:n}){let[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(``),[c,l]=(0,V.useState)(!1),[d,p]=(0,V.useState)(``),m=a.trim().length>=10&&a.trim().length<=500,g=async()=>{if(r){l(!0),p(``);try{await h.grade(e,r.id,r.grade,a.trim()),i(null),o(``),n()}catch(e){p(e.message)}finally{l(!1)}}};return(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsx)(`h4`,{className:`m-0 text-body-sm font-medium`,children:`Grade the answer`}),(0,H.jsxs)(`p`,{className:`m-0 text-body-sm text-muted`,children:[t.criteria.some(e=>e.id===`scenario`)?`Its scenario is graded by a person: the release gate counts it only once you have graded it. `:``,t.criteria.some(e=>e.id!==`scenario`)?`The judge's misses count only once it agrees with people's grades. `:``,`Read the answer, then say whether it meets each criterion; your grade is kept with your name.`]}),t.answer!==void 0&&(0,H.jsx)(`p`,{className:f(`rounded-base bg-surface-muted p-4`,`m-0 whitespace-pre-wrap text-body-sm text-ink [overflow-wrap:anywhere]`),children:U(t.answer)}),(0,H.jsx)(`ul`,{"aria-label":`Rubric criteria`,className:f(u,`m-0 flex list-none flex-col`),children:t.criteria.map(e=>(0,H.jsxs)(`li`,{className:`flex flex-col gap-2 border-b border-line-soft px-4 py-2 last:border-b-0`,children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1`,children:[(0,H.jsxs)(`span`,{className:`text-body-sm text-ink [overflow-wrap:anywhere]`,children:[(0,H.jsx)(`span`,{className:`font-mono text-muted`,children:e.id}),` `,U(e.text)]}),e.grade&&(0,H.jsx)(x,{tone:e.grade.grade===`meets`?`pass`:`warn`,children:e.grade.grade===`meets`?`Meets`:`Misses`}),(0,H.jsx)(`span`,{className:`text-body-sm text-muted`,children:e.grade?`Grade again:`:`Grade:`}),[`meets`,`misses`].map(t=>(0,H.jsx)(C,{variant:`link`,size:`inline`,"aria-label":`${e.id} ${t===`meets`?`meets`:`misses`}`,onClick:()=>i({id:e.id,grade:t}),className:`min-h-7 px-2`,children:t===`meets`?`Meets`:`Misses`},t))]}),e.grade&&(0,H.jsxs)(`span`,{className:`text-body-sm text-ink-2 [overflow-wrap:anywhere]`,children:[`Graded by `,U(e.grade.by),` `,W(e.grade.at),`: `,U(e.grade.reason)]}),r?.id===e.id&&(0,H.jsxs)(`div`,{className:f(`panel rounded-md bg-(--page-surface-strong) p-6`,`flex max-w-[640px] flex-col gap-2`),children:[(0,H.jsxs)(`label`,{htmlFor:`grade-${e.id}`,className:`text-body-sm font-medium text-ink-2`,children:[`Why does the answer `,r.grade===`meets`?`meet`:`miss`,` it?`]}),(0,H.jsx)(s,{id:`grade-${e.id}`,value:a,onChange:e=>o(e.target.value),rows:2,maxLength:500,placeholder:`For example: it says the customer must send a photo by Friday.`}),d&&(0,H.jsx)(B,{text:d}),(0,H.jsxs)(`span`,{className:`flex gap-2`,children:[(0,H.jsxs)(C,{busy:c,size:`sm`,disabled:!m||c,onClick:g,"data-tip":r.grade===`meets`?`Keep the grade: meets`:`Keep the grade: misses`,children:[(0,H.jsx)(ge,{"aria-hidden":`true`}),c?`Keeping…`:`Keep`]}),(0,H.jsxs)(C,{size:`sm`,variant:`ghost`,onClick:()=>i(null),children:[(0,H.jsx)(M,{"aria-hidden":`true`}),`Cancel`]})]})]})]},e.id))})]})}function tt({f:e,run:t,goTo:n,onOverruled:r}){let[i,a]=(0,V.useState)(!1),[o,c]=(0,V.useState)(``),[l,u]=(0,V.useState)(!1),[d,p]=(0,V.useState)(``),m=o.trim().length>=10&&o.trim().length<=500,g=async()=>{u(!0),p(``);try{await h.overrule(t,e.id,o.trim()),a(!1),r()}catch(e){p(e.message)}finally{u(!1)}};return(0,H.jsxs)(`div`,{className:f(`flex flex-col gap-1 border-l-2 pl-4`,e.overruled?`border-line opacity-80`:e.status===`FAIL`?`border-fail`:e.status===`WARN`?`border-warn`:`border-line`),children:[(0,H.jsx)(`span`,{className:f(`text-body-sm [overflow-wrap:anywhere]`,e.overruled?`text-ink-2`:`text-ink`),children:U(e.what)}),e.fix&&!e.overruled&&(0,H.jsxs)(`span`,{className:`text-body-sm text-ink-2 [overflow-wrap:anywhere]`,children:[`Fix: `,U(e.fix)]}),e.overruled&&(0,H.jsxs)(`span`,{className:`text-body-sm text-ink-2 [overflow-wrap:anywhere]`,children:[`Overruled by `,U(e.overruled.by),` `,W(e.overruled.at),` (`,e.overruled.via===`web`?`on this page`:`at a terminal`,`): `,U(e.overruled.reason)]}),(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-body-sm text-muted`,children:[(0,H.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:U(e.source)}),e.location&&(0,H.jsx)(`span`,{className:`font-mono [overflow-wrap:anywhere]`,children:U(`${e.location.repo?`${e.location.repo}/`:``}${e.location.file}${e.location.line?`:${e.location.line}`:``}`)}),[...new Set(e.steps)].slice(0,12).map(e=>(0,H.jsxs)(C,{variant:`link`,size:`inline`,onClick:()=>n(e),className:`min-h-7 px-2 tabular-nums`,children:[`step `,e]},e)),!e.overruled&&e.status!==`UNKNOWN`&&!i&&(0,H.jsxs)(C,{variant:`link`,size:`inline`,onClick:()=>a(!0),className:`min-h-7 gap-1 px-2`,children:[(0,H.jsx)(j,{size:12,"aria-hidden":`true`}),`Overrule`]})]}),i&&(0,H.jsxs)(`div`,{className:f(`panel rounded-md bg-(--page-surface-strong) p-6`,`flex max-w-[640px] flex-col gap-2`),children:[(0,H.jsx)(`label`,{htmlFor:`overrule-${e.id}`,className:`text-body-sm font-medium text-ink-2`,children:`Why is this finding wrong, or right to accept? It is kept with your name, and the finding stops counting.`}),(0,H.jsx)(s,{id:`overrule-${e.id}`,value:o,onChange:e=>c(e.target.value),rows:2,maxLength:500,placeholder:`For example: the owner agreed this removal in the change's review.`}),d&&(0,H.jsx)(B,{text:d}),(0,H.jsxs)(`span`,{className:`flex gap-2`,children:[(0,H.jsxs)(C,{busy:l,size:`sm`,disabled:!m||l,onClick:g,children:[(0,H.jsx)(j,{"aria-hidden":`true`}),l?`Overruling…`:`Overrule`]}),(0,H.jsxs)(C,{size:`sm`,variant:`ghost`,onClick:()=>a(!1),children:[(0,H.jsx)(M,{"aria-hidden":`true`}),`Cancel`]})]})]})]})}function nt(){let[e,t]=(0,V.useState)(null),[n,i]=(0,V.useState)(``);return(0,V.useEffect)(()=>{h.review().then(t,e=>i(e.message))},[]),(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Y,{id:`evidence-review`,children:`Review queue`}),(0,H.jsx)(R,{more:(0,H.jsx)(H.Fragment,{children:`Runs whose findings are still open, the failed first, then work whose two fix attempts are used, where a person takes over. Open a run to read its findings, and overrule one with a reason where it is wrong or right to accept. Then the answers the rubric's judge could not settle, for a person to grade, and every finding people overruled, and why.`}),children:`What waits for a person: open findings to read, answers to grade, and what was overruled.`}),n&&(0,H.jsx)(B,{text:n}),!e&&!n&&(0,H.jsx)(X,{}),e?.problems.map(e=>(0,H.jsx)(B,{text:e},e)),e&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`h2`,{className:`sr-only`,children:`What waits, what to grade, and what was overruled`}),(0,H.jsx)(z,{id:`waiting`,title:`Waiting for a person`,icon:T,n:e.waiting.length,children:e.waiting.length?(0,H.jsx)(`ul`,{"aria-label":`Waiting for a person`,className:f(`surface rounded-lg bg-bg p-6 shadow-sm`,`m-0 list-none`),children:e.waiting.map(e=>(0,H.jsx)(`li`,{children:(0,H.jsxs)(`a`,{href:r(`evidence-runs`,encodeURIComponent(e.run)),className:f(`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`,`grid min-h-12 grid-cols-[auto_minmax(0,1fr)_auto] gap-x-4`),children:[(0,H.jsx)(x,{tone:K[e.status].tone,children:K[e.status].label}),(0,H.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,H.jsx)(`span`,{className:`truncate text-body-sm font-medium`,children:U(e.request||`${e.agent}: request not recorded`)}),(0,H.jsx)(`span`,{className:`truncate text-body-sm text-muted`,children:[U(e.agent),d(e.open,`open finding`),e.failed?`${e.failed} failing`:``,e.attempt?`fix attempt ${e.attempt} of 2`:``,e.personTakesOver?`a person takes over`:``].filter(Boolean).join(` · `)})]}),(0,H.jsx)(`span`,{className:`text-right text-body-sm text-muted tabular-nums`,"data-tip":W(e.started),children:e.started?I(e.started):``})]})},e.run))}):(0,H.jsx)(v,{className:`py-4`,children:`Nothing waits: no run has an open finding.`})}),e.grade.length>0&&(0,H.jsxs)(z,{id:`grade`,title:`Answers to grade`,icon:P,n:e.grade.length,children:[(0,H.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`The rubric's judge could not settle these answers: it is not yet calibrated against people's grades, or it disagreed with itself. Grading them settles each one and calibrates the judge.`}),(0,H.jsx)(`ul`,{"aria-label":`Answers to grade`,className:f(`surface rounded-lg bg-bg p-6 shadow-sm`,`m-0 list-none`),children:e.grade.map(e=>(0,H.jsx)(`li`,{children:(0,H.jsxs)(`a`,{href:r(`evidence-runs`,encodeURIComponent(e.run)),className:f(`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`,`grid min-h-12 grid-cols-[minmax(0,1fr)_auto] gap-x-4`),children:[(0,H.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,H.jsx)(`span`,{className:`truncate text-body-sm font-medium`,children:U(e.request||`${e.agent}: request not recorded`)}),(0,H.jsx)(`span`,{className:`truncate text-body-sm text-muted`,children:[U(e.agent),`${e.ungraded} of ${e.criteria} ${e.criteria===1?`criterion`:`criteria`} not graded`].join(` · `)})]}),(0,H.jsx)(`span`,{className:`text-right text-body-sm text-muted tabular-nums`,"data-tip":W(e.started),children:e.started?I(e.started):``})]})},e.run))})]}),(0,H.jsx)(z,{id:`overruled`,title:`Overruled by people`,icon:D,n:e.overruled.length,children:e.overruled.length?(0,H.jsx)(`ul`,{"aria-label":`Overruled findings`,className:f(`surface rounded-lg bg-bg p-6 shadow-sm`,`m-0 list-none`),children:e.overruled.map(e=>(0,H.jsxs)(`li`,{className:`flex flex-col gap-1 border-b border-line-soft px-4 py-2 last:border-b-0`,children:[(0,H.jsxs)(`span`,{className:`text-body-sm [overflow-wrap:anywhere]`,children:[(0,H.jsx)(`a`,{href:r(`evidence-runs`,encodeURIComponent(e.run)),children:U(e.agent||e.run)}),` · `,U(`${e.check}/${e.rule}`),e.what?`: ${U(e.what)}`:``]}),(0,H.jsxs)(`span`,{className:`text-body-sm text-ink-2 [overflow-wrap:anywhere]`,children:[U(e.by),` `,W(e.at),` (`,e.via===`web`?`on the page`:`at a terminal`,`): `,U(e.reason)]})]},`${e.run}-${e.finding}-${e.at}`))}):(0,H.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`No finding has been overruled.`})})]})]})}var rt={build:`Build and test`,behaviour:`Behaviour`,decisions:`Decisions and data`,content:`Content`,domain:`Domain`};function it({s:e}){let[t,n]=(0,V.useState)(e.versions[0]||``),[r,i]=(0,V.useState)(e.versions[1]||``),[a,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(``);(0,V.useEffect)(()=>{e.agent&&t&&(l(``),h.release(e.agent,t,r===t?``:r).then(s,e=>l(e.message)))},[e.agent,t,r]);let p=e=>{if(e===void 0)return``;if(e===null)return`Not run`;let t=e.runs.filter(e=>e.pass).length;return e.short?`Too few runs (${e.runs.length})`:e.pass?e.runs.length===1?`Pass`:t===e.runs.length?`Pass ×${e.runs.length}`:`Pass (${t} of ${e.runs.length})`:e.runs.length>1?`Fail (${e.runs.length-t} of ${e.runs.length} failed)`:`Fail`},m=a?[...new Set([...Object.keys(a.candidate.lensPass),...Object.keys(a.live?.lensPass||{})])]:[];return(0,H.jsxs)(`li`,{className:f(u,`flex flex-col gap-4`),children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1`,children:[(0,H.jsx)(`span`,{className:`text-body-lg font-medium [overflow-wrap:anywhere]`,children:U(e.agent||e.name)}),(0,H.jsxs)(`span`,{className:`text-body-sm text-muted`,children:[U(`${e.name}.yaml`),` · `,d(e.scenarios.length,`scenario`)]})]}),e.problem&&(0,H.jsx)(B,{text:e.problem}),e.agent&&!e.versions.length&&(0,H.jsxs)(`p`,{className:`m-0 text-body-sm text-muted`,children:[`No run of `,U(e.agent),` is recorded yet: run each scenario's request through a version and record it (forgeqe evidence scenarios lists them).`]}),e.versions.length>0&&(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-body-sm`,children:[(0,H.jsx)(`label`,{htmlFor:`cand-${e.name}`,children:`Candidate`}),(0,H.jsx)(o,{size:`sm`,id:`cand-${e.name}`,value:t,onChange:e=>n(e.target.value),className:`w-auto pr-8 pl-4`,children:e.versions.map(e=>(0,H.jsx)(`option`,{value:e,children:U(e)},e))}),(0,H.jsx)(`label`,{htmlFor:`live-${e.name}`,children:`against live`}),(0,H.jsxs)(o,{size:`sm`,id:`live-${e.name}`,value:r,onChange:e=>i(e.target.value),className:`w-auto pr-8 pl-4`,children:[(0,H.jsx)(`option`,{value:``,children:`No live version`}),e.versions.filter(e=>e!==t).map(e=>(0,H.jsx)(`option`,{value:e,children:U(e)},e))]})]}),c&&(0,H.jsx)(B,{text:c}),a&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1`,children:[(0,H.jsx)(x,{tone:a.status===`ready`?`pass`:`fail`,children:a.status===`ready`?`Ready`:`Held`}),(0,H.jsx)(`span`,{className:`text-body-sm text-ink-2`,children:a.status===`ready`?`Not worse on any lens, and every misuse and injection test passed. A person releases it.`:`Held: a person decides, with what follows.`})]}),a.reasons.length>0&&(0,H.jsx)(`ul`,{className:`m-0 flex list-disc flex-col gap-1 pl-6 text-body-sm text-ink-2`,children:a.reasons.map(e=>(0,H.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:U(e)},e))}),(0,H.jsxs)(F,{label:`Scenarios of ${e.agent}`,search:!1,sortable:!1,minWidth:520,head:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,children:`Scenario`}),(0,H.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,children:`Kind`}),a.live&&(0,H.jsxs)(`th`,{scope:`col`,className:`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,children:[U(a.live.version),` (live)`]}),(0,H.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,children:U(a.candidate.version)})]}),children:[e.scenarios.map(e=>(0,H.jsxs)(`tr`,{className:`h-12 border-t border-line-soft align-middle transition-colors duration-150 data-[state=selected]:bg-tint-hover`,children:[(0,H.jsx)(`th`,{scope:`row`,className:f(`px-4 py-2`,`text-left font-medium`),"data-tip":e.request,children:U(e.id)}),(0,H.jsx)(`td`,{className:`px-4 py-2`,children:e.kind}),a.live&&(0,H.jsx)(`td`,{className:f(`px-4 py-2`,a.live.cells[e.id]&&!a.live.cells[e.id].pass&&`text-fail`),children:p(a.live.cells[e.id])}),(0,H.jsx)(`td`,{className:f(`px-4 py-2`,(a.candidate.cells[e.id]===null||a.candidate.cells[e.id]&&!a.candidate.cells[e.id].pass)&&`text-fail`),children:p(a.candidate.cells[e.id])})]},e.id)),m.map(e=>(0,H.jsxs)(`tr`,{className:`h-12 border-t border-line-soft align-middle transition-colors duration-150 data-[state=selected]:bg-tint-hover`,children:[(0,H.jsxs)(`th`,{scope:`row`,className:f(`px-4 py-2`,`text-left text-muted`),children:[rt[e],`: scenarios passed`]}),(0,H.jsx)(`td`,{className:`px-4 py-2`}),a.live&&(0,H.jsx)(`td`,{className:f(`px-4 py-2`,`tabular-nums`),children:a.live.lensPass[e]??0}),(0,H.jsx)(`td`,{className:f(`px-4 py-2`,`tabular-nums`,a.live&&(a.candidate.lensPass[e]??0)<(a.live.lensPass[e]??0)&&`text-fail`),children:a.candidate.lensPass[e]??0})]},e)),(0,H.jsxs)(`tr`,{className:`h-12 border-t border-line-soft align-middle transition-colors duration-150 data-[state=selected]:bg-tint-hover`,children:[(0,H.jsx)(`th`,{scope:`row`,className:f(`px-4 py-2`,`text-left text-muted`),children:`The owners' expectations met`}),(0,H.jsx)(`td`,{className:`px-4 py-2`}),a.live&&(0,H.jsx)(`td`,{className:f(`px-4 py-2`,`tabular-nums`),children:a.live.golden}),(0,H.jsx)(`td`,{className:f(`px-4 py-2`,`tabular-nums`,a.live&&a.candidate.golden<a.live.golden&&`text-fail`),children:a.candidate.golden})]})]}),(0,H.jsx)(lt,{g:a}),(0,H.jsx)(at,{g:a}),(0,H.jsx)(ut,{g:a,ids:e.scenarios.map(e=>e.id)})]}),e.history.length>0&&(0,H.jsxs)(`details`,{className:`text-body-sm`,children:[(0,H.jsxs)(`summary`,{className:`cursor-pointer text-ink-2`,children:[`Gates kept (`,e.history.length,`)`]}),(0,H.jsx)(`ul`,{className:`m-0 mt-1 flex list-none flex-col gap-1 p-0`,children:e.history.map(e=>(0,H.jsxs)(`li`,{className:`text-body-sm text-ink-2 [overflow-wrap:anywhere]`,children:[W(e.at),` · `,U(e.by),` · `,U(e.candidate),e.live?` against ${U(e.live)}`:``,`: `,e.status===`ready`?`ready`:`held`,e.reasons.length?` (${U(e.reasons[0])}${e.reasons.length>1?`, and ${e.reasons.length-1} more`:``})`:``]},e.at))})]})]})}function at({g:e}){let t=Object.entries(e.candidate.cells).flatMap(([e,t])=>(t?.runs??[]).filter(e=>e.awaitingGrade).map(t=>({sid:e,run:t.run})));return t.length?(0,H.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,H.jsxs)(`h4`,{className:`m-0 text-body-sm font-medium`,children:[`Answers waiting for your grade (`,t.length,`)`]}),(0,H.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`These scenarios are graded by a person: until an answer is graded, it is not known, and the scenario does not pass.`}),(0,H.jsx)(`ul`,{"aria-label":`Answers waiting for a grade`,className:`m-0 flex list-none flex-col gap-1 p-0 text-body-sm`,children:t.map(e=>(0,H.jsx)(`li`,{children:(0,H.jsxs)(`a`,{href:r(`evidence-runs`,encodeURIComponent(e.run)),className:`text-accent-fg hover:underline`,children:[U(e.sid),`: `,e.run]})},e.run))})]}):null}function ot({f:e}){return(0,H.jsxs)(`li`,{className:f(u,`flex flex-col gap-2`),children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1`,children:[(0,H.jsx)(x,{tone:e.applied||e.proven?`pass`:`fail`,children:e.applied?`Applied`:e.proven?`Proven`:`Not proven`}),(0,H.jsx)(`span`,{className:`text-body-sm font-medium [overflow-wrap:anywhere]`,children:U(e.instruction)}),(0,H.jsx)(`span`,{className:`font-mono text-body-sm text-muted`,children:e.id})]}),(0,H.jsxs)(`span`,{className:`text-body-sm text-ink-2 [overflow-wrap:anywhere]`,children:[`Adds it to `,U(e.file),`, for `,U(e.cause),` of `,(0,H.jsx)(`a`,{href:r(`evidence-runs`,encodeURIComponent(e.run)),className:`font-mono`,children:e.run}),` (scenario `,U(e.scenario),`, `,U(e.version),`).`]}),(0,H.jsxs)(`span`,{className:`text-body-sm text-ink-2 [overflow-wrap:anywhere]`,children:[`The cause: `,e.proof.replace(`-`,` `),` (`,U(e.why),`)`,e.replays.length?(0,H.jsxs)(H.Fragment,{children:[`; replays `,wt(e.replays)]}):null,`.`]}),(0,H.jsxs)(`span`,{className:`text-body-sm text-ink-2 [overflow-wrap:anywhere]`,children:[`The suite, run from the patched copy against `,U(e.version),`: `,e.gate.status===`ready`?`no worse`:`held: ${U(e.gate.reasons.join(` `))}`]}),e.applied&&(0,H.jsxs)(`span`,{className:`text-body-sm text-ink-2 [overflow-wrap:anywhere]`,children:[`Applied by `,U(e.applied.by),` `,W(e.applied.at),`: `,U(e.applied.reason)]}),(0,H.jsxs)(`details`,{className:`text-body-sm`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer text-ink-2`,children:`The patch`}),(0,H.jsx)(`pre`,{className:f(ke,`m-0 mt-1 overflow-x-auto`),children:U(e.patch)})]})]})}function st({d:e,onDecided:t}){let n=e.scenario,r=n.expect||{},i=e.source.kind===`run`?`a run that failed`:e.source.kind===`story`?`an acceptance criterion`:e.source.kind===`rule`?`a business rule of the product, at`:`a defect`,a=e=>(e||[]).map(e=>U(e)).join(`, `);return(0,H.jsxs)(`li`,{className:`flex flex-col gap-2 border-b border-line-soft px-4 py-4 last:border-b-0`,children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1`,children:[(0,H.jsx)(`span`,{className:`font-mono text-body-sm text-muted`,children:e.id}),(0,H.jsxs)(`span`,{className:`text-body-sm font-medium [overflow-wrap:anywhere]`,children:[U(n.id),` for `,U(e.agent)]}),(0,H.jsx)(x,{tone:`neutral`,children:n.kind}),n.held_out&&(0,H.jsx)(x,{tone:`neutral`,children:`Held out`}),e.decided&&(0,H.jsx)(x,{tone:e.decided.decision===`accepted`?`pass`:`warn`,children:e.decided.decision===`accepted`?`Accepted`:`Rejected`})]}),(0,H.jsxs)(`span`,{className:`text-body-sm text-ink-2 [overflow-wrap:anywhere]`,children:[`Drafted by `,e.by===`code`?`code`:`a model`,` from `,i,` `,e.source.url&&Ae(e.source.url)===`web`?(0,H.jsx)(`a`,{href:e.source.url,target:`_blank`,rel:`noreferrer noopener`,className:`text-accent-fg hover:underline`,children:U(e.source.ref)}):U(e.source.ref),e.source.criterion?` ${U(e.source.criterion)}`:``,e.source.quote?(0,H.jsxs)(H.Fragment,{children:[`: “`,U(e.source.quote),`”`]}):e.source.why?(0,H.jsxs)(H.Fragment,{children:[`: `,U(e.source.why)]}):null]}),(0,H.jsx)(`p`,{className:f(c,`m-0 whitespace-pre-wrap text-body-sm text-ink [overflow-wrap:anywhere]`),children:U(n.request)}),(0,H.jsxs)(`ul`,{className:`m-0 flex list-disc flex-col gap-1 pl-6 text-body-sm text-ink-2`,children:[r.chose&&(0,H.jsxs)(`li`,{children:[`Expects it to choose `,a(r.chose)]}),r.not_chose&&(0,H.jsxs)(`li`,{children:[`Expects it never to choose `,a(r.not_chose)]}),r.says&&(0,H.jsxs)(`li`,{children:[`Expects it to say: `,a(r.says)]}),r.not_says&&(0,H.jsxs)(`li`,{children:[`Expects it never to say: `,a(r.not_says)]}),r.graded&&(0,H.jsx)(`li`,{children:`A person grades each answer`}),(0,H.jsx)(`li`,{children:r.clean?`Every lens must find nothing`:`The lenses are counted lens by lens`})]}),e.decided?(0,H.jsxs)(`span`,{className:`text-body-sm text-ink-2 [overflow-wrap:anywhere]`,children:[e.decided.decision===`accepted`?`Accepted`:`Rejected`,` by `,U(e.decided.by),` `,W(e.decided.at),e.decided.scenario?` as ${U(e.decided.scenario)}`:``,`: `,U(e.decided.reason)]}):(0,H.jsxs)(`span`,{className:`flex flex-wrap gap-2`,children:[(0,H.jsx)(Ct,{agent:e.id,uid:`${e.id}-accept`,label:`Add`,icon:O,tip:`Add to the suite`,action:(t,n)=>h.decideDraft(e.id,`accepted`,t,n),onDone:t}),(0,H.jsx)(Ct,{agent:e.id,uid:`${e.id}-reject`,label:`Reject`,icon:j,action:(t,n)=>h.decideDraft(e.id,`rejected`,t,n),onDone:t})]})]})}function ct({onDecided:e}){let[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)(``),a=()=>h.drafts().then(n,e=>i(e.message));(0,V.useEffect)(()=>{a()},[]);let o=t?.drafts.filter(e=>!e.decided).length??0;return(0,H.jsxs)(z,{id:`drafts`,title:`Drafted scenarios`,icon:P,n:o,children:[(0,H.jsxs)(`p`,{className:`m-0 text-body-sm text-muted`,children:[`Drafted from work items' acceptance criteria and defects (`,(0,H.jsx)(`code`,{children:`forgeqe evidence draft <agent> --from ado:N`}),`) or the product graph's business rules (`,(0,H.jsx)(`code`,{children:`--from-product`}),`), each resting on a quote of its source, or from a run that failed (`,(0,H.jsx)(`code`,{children:`--run <id>`}),`). Nothing is added by itself: add each to the suite, or reject it. About one in five is held out by ForgeQE, so the team tuning the agent does not choose what it is measured on.`]}),r&&(0,H.jsx)(B,{text:r}),t?.problems.map(e=>(0,H.jsx)(B,{text:e},e)),t&&!t.drafts.length&&(0,H.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`No draft yet.`}),t&&t.drafts.length>0&&(0,H.jsx)(`ul`,{"aria-label":`Drafted scenarios`,className:f(`surface rounded-lg bg-bg p-6 shadow-sm`,`m-0 flex list-none flex-col`),children:t.drafts.map(t=>(0,H.jsx)(st,{d:t,onDecided:()=>{a(),e()}},t.id))})]})}function lt({g:e}){let t=[...e.live?[e.live]:[],e.candidate],n=e=>e&&e.n?`${Math.round(e.pass/e.n*100)}% of ${e.n}`:`-`,r=[...[...new Set(t.flatMap(e=>Object.keys(e.pooled.lens)))].map(e=>[rt[e],t=>n(t.pooled.lens[e])]),[`The owners' expectations`,e=>n(e.pooled.golden)],[`Weakest lens (the summary)`,e=>e.pooled.weakest?`${Math.round(e.pooled.weakest.score*100)}% (${rt[e.pooled.weakest.lens]})`:`-`],...t.some(e=>e.pooled.heldOut.n)?[[`Held-out scenarios`,e=>n(e.pooled.heldOut)]]:[],[`Steps per run`,e=>e.pooled.effort.runs?e.pooled.effort.steps.toFixed(1):`-`],[`Tool calls per run`,e=>e.pooled.effort.runs?e.pooled.effort.tools.toFixed(1):`-`],[`Time per run`,e=>e.pooled.effort.ms===null?`-`:`${(e.pooled.effort.ms/1e3).toFixed(1)} s`]];return(0,H.jsxs)(`details`,{className:`text-body-sm`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer text-ink-2`,children:`Scores: runs passed, lens by lens`}),(0,H.jsx)(`p`,{className:`m-0 mt-1 text-body-sm text-muted`,children:`A lens's score is its runs passed of the runs it judged. The summary is the weakest lens, never an average: one lens cannot make up for another. Effort is shown, never held against a version on its own.`}),(0,H.jsx)(F,{label:`Scores`,search:!1,sortable:!1,minWidth:420,head:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`th`,{scope:`col`,className:ye,children:`Score`}),t.map(t=>(0,H.jsxs)(`th`,{scope:`col`,className:Ee,children:[U(t.version),e.live&&t===e.live?` (live)`:``]},t.version))]}),children:r.map(([e,n])=>(0,H.jsxs)(`tr`,{className:xe,children:[(0,H.jsx)(`th`,{scope:`row`,className:f(Se,`text-left font-medium`),children:e}),t.map(e=>(0,H.jsx)(`td`,{className:be,children:n(e)},e.version))]},e))})]})}function ut({g:e,ids:t}){let n=e=>e?e.runs.find(e=>e.path?.unmet.length)??e.runs.find(e=>e.path):void 0,i=t.flatMap(t=>{let r=n(e.candidate.cells[t]),i=e.live?n(e.live.cells[t]):void 0;return r?.path||i?.path?[{id:t,cand:r,live:i}]:[]});if(!i.length)return null;let a={same:``,missing:`expected, not done`,extra:`done, not expected`},o=(e,t)=>t?.path?(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,H.jsxs)(`span`,{className:`text-body-sm text-muted`,children:[e,`: `,(0,H.jsx)(`a`,{href:r(`evidence-runs`,encodeURIComponent(t.run)),className:`font-mono`,children:t.run}),t.path.match===null?``:` · match ${Math.round(t.path.match*100)}%, efficiency ${Math.round((t.path.efficiency??0)*100)}%`]}),(0,H.jsx)(`ol`,{className:`m-0 flex list-none flex-col gap-1 p-0 font-mono text-body-sm`,children:(t.path.alignment.length?t.path.alignment:t.path.actual.map(e=>({kind:`same`,step:e}))).map((e,t)=>(0,H.jsxs)(`li`,{className:f(`[overflow-wrap:anywhere]`,e.kind===`missing`&&`text-fail`,e.kind===`extra`&&`text-warn`),children:[e.kind===`missing`?`− `:e.kind===`extra`?`+ `:` `,U(e.step),e.kind!==`same`&&(0,H.jsxs)(`span`,{className:`font-sans text-body-sm text-muted`,children:[` (`,a[e.kind],`)`]})]},`${t}-${e.step}`))}),t.path.unmet.map(e=>(0,H.jsx)(`span`,{className:`text-body-sm text-fail [overflow-wrap:anywhere]`,children:U(e)},e))]}):(0,H.jsxs)(`span`,{className:`text-body-sm text-muted`,children:[e,`: not run`]});return(0,H.jsxs)(`details`,{className:`text-body-sm`,children:[(0,H.jsxs)(`summary`,{className:`cursor-pointer text-ink-2`,children:[`Paths: expected against actual (`,i.length,`)`]}),(0,H.jsx)(`ul`,{className:`m-0 mt-2 flex list-none flex-col gap-4 p-0`,children:i.map(t=>(0,H.jsxs)(`li`,{className:f(u,`flex flex-col gap-2`),children:[(0,H.jsx)(`span`,{className:`text-body-sm font-medium`,children:U(t.id)}),(0,H.jsxs)(`div`,{className:`grid gap-4 @[640px]:grid-cols-2`,children:[e.live&&o(`${e.live.version} (live)`,t.live),o(e.candidate.version,t.cand)]})]},t.id))})]})}function dt(){let[e,t]=(0,V.useState)(null),[n,r]=(0,V.useState)(``),i=()=>h.releases().then(t,e=>r(e.message));return(0,V.useEffect)(()=>{i()},[]),(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Y,{id:`evidence-releases`,children:`Releases`}),(0,H.jsx)(R,{more:(0,H.jsxs)(H.Fragment,{children:[`Before a version is released: its runs of the agent's scenario suite (stories, past defects, misuse and injection tests, each with what its owners expect) against the live version's. It is held when it is worse on any lens, meets fewer expectations, or fails a misuse or injection test; not run, or not known, is never a pass. A person releases; `,(0,H.jsx)(`code`,{children:`forgeqe evidence release`}),` keeps each gate. A suite is written in `,(0,H.jsx)(`code`,{children:`.forgeqe/evidence/scenarios/<agent>.yaml`}),` (docs/EVIDENCE.md has its form).`]}),children:`Release an agent's new version only when it does at least as well as the live one on its scenarios.`}),n&&(0,H.jsx)(B,{text:n}),!e&&!n&&(0,H.jsx)(X,{}),e&&!e.suites.length&&(0,H.jsx)(v,{className:`py-4`,children:`No scenario suite yet: add drafted scenarios below to start one. A suite can also be written by hand; How it works says where.`}),e&&e.suites.length>0&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`h2`,{className:`sr-only`,children:`Each agent's scenario suite and release gate`}),(0,H.jsx)(z,{id:`suites`,title:`Scenario suites`,icon:P,n:e.suites.length,children:(0,H.jsx)(`ul`,{"aria-label":`Scenario suites`,className:`m-0 flex list-none flex-col gap-4 p-0`,children:e.suites.map(e=>(0,H.jsx)(it,{s:e},e.name))})})]}),e&&(0,H.jsx)(ct,{onDecided:i})]})}var ft={approved:{tone:`pass`,label:`Approved`},changed:{tone:`warn`,label:`Changed since approved`},draft:{tone:`neutral`,label:`Not approved`},invalid:{tone:`fail`,label:`Cannot be read`}};function pt(){let[e,t]=(0,V.useState)(null),[n,r]=(0,V.useState)(``);(0,V.useEffect)(()=>{h.contracts().then(t,e=>r(e.message))},[]);let i=e=>e===null?`–`:`${Math.round(e*100)}%`;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Y,{id:`evidence-contracts`,children:`Contracts`}),(0,H.jsx)(R,{more:(0,H.jsxs)(H.Fragment,{children:[`A contract says the steps an agent must take, what it may and may never do, its limits, what a person decides, and what its statements need behind them. Each run is checked against its agent's approved contract. A contract nobody approved, or a check not yet measured well enough on labelled runs, only warns. Start one with `,(0,H.jsx)(`code`,{children:`forgeqe evidence contract new "<agent>"`}),`; a person approves it at a terminal with `,(0,H.jsx)(`code`,{children:`forgeqe evidence contract approve <name>`}),`.`]}),children:`What each agent's owner agreed it must and may do, and how well each check is measured.`}),n&&(0,H.jsx)(B,{text:n}),!e&&!n&&(0,H.jsx)(X,{}),e&&!e.contracts.length&&(0,H.jsx)(v,{className:`py-4`,children:`No contract yet. Without one, a run's record is kept, but nothing checks it against what was agreed.`}),e&&(0,H.jsx)(`h2`,{className:`sr-only`,children:`The contracts and how each check is measured`}),e&&e.contracts.length>0&&(0,H.jsx)(z,{id:`contracts`,title:`Contracts`,icon:he,n:e.contracts.length,children:(0,H.jsx)(`ul`,{"aria-label":`Contracts`,className:`m-0 flex list-none flex-col gap-4 p-0`,children:e.contracts.map(e=>(0,H.jsxs)(`li`,{className:f(`surface rounded-lg bg-bg p-6 shadow-sm`,`flex flex-col gap-2`),children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1`,children:[(0,H.jsx)(`span`,{className:`text-body-lg font-medium [overflow-wrap:anywhere]`,children:U(e.agent||e.name)}),(0,H.jsx)(x,{tone:ft[e.state].tone,children:ft[e.state].label}),(0,H.jsxs)(`span`,{className:`text-body-sm text-muted [overflow-wrap:anywhere]`,children:[U(`${e.name}.yaml`),e.version?` · version ${U(e.version)}`:``,e.approved?` · approved ${W(e.approved.at)} by ${U(e.approved.by)}`:``]})]}),e.problem&&(0,H.jsx)(B,{text:e.problem}),e.says.length>0&&(0,H.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0`,children:e.says.map(e=>(0,H.jsx)(`li`,{className:`text-body-sm text-ink-2 [overflow-wrap:anywhere]`,children:U(e)},e))}),(0,H.jsx)(`span`,{className:`text-body-sm text-muted`,children:e.gates.length?`Can fail a run: ${e.gates.map(e=>q[e]).join(`, `)}.`:`No check can fail a run under it yet: what they find is a warning.`})]},e.name))})}),e&&(0,H.jsxs)(z,{id:`measured`,title:`How well each check is measured`,icon:w,children:[(0,H.jsxs)(`p`,{className:`m-0 text-body-sm leading-relaxed text-ink-2`,children:[`On `,d(e.measured.records,`labelled run`),`: runs whose right findings a person wrote down (ForgeQE's own, and the project's in .forgeqe/evidence/labelled). A check may fail a run only when its owner's bar is met on at least `,e.measured.min,` labelled findings.`]}),e.measured.problems.map(e=>(0,H.jsx)(B,{text:`Not measured: ${e}`},e)),(0,H.jsx)(`div`,{className:`@container`,children:(0,H.jsx)(F,{label:`How well each check is measured`,search:!1,head:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,children:`Check`}),[`Labelled`,`Found right`,`Found wrong`,`Missed`,`Precision`,`Recall`].map(e=>(0,H.jsx)(`th`,{scope:`col`,className:f(`px-4 py-2 text-right text-label-md font-medium whitespace-nowrap text-muted`,`whitespace-normal`,mt.has(e)&&`hidden @lg:table-cell`),children:e},e))]}),children:Object.keys(q).filter(t=>e.measured.checks[t]).map(t=>{let n=e.measured.checks[t];return(0,H.jsxs)(`tr`,{className:`h-12 border-t border-line-soft align-middle transition-colors duration-150 data-[state=selected]:bg-tint-hover`,children:[(0,H.jsx)(`th`,{scope:`row`,className:f(`px-4 py-2`,`text-left font-medium`),children:q[t]}),(0,H.jsx)(`td`,{className:f(`px-4 py-2 text-right whitespace-nowrap tabular-nums`,n.labelled<e.measured.min&&`text-muted`),children:n.labelled}),(0,H.jsx)(`td`,{className:f(`px-4 py-2 text-right whitespace-nowrap tabular-nums`,`hidden @lg:table-cell`),children:n.tp}),(0,H.jsx)(`td`,{className:f(`px-4 py-2 text-right whitespace-nowrap tabular-nums`,`hidden @lg:table-cell`,n.fp>0&&`text-fail`),children:n.fp}),(0,H.jsx)(`td`,{className:f(`px-4 py-2 text-right whitespace-nowrap tabular-nums`,`hidden @lg:table-cell`,n.fn>0&&`text-fail`),children:n.fn}),(0,H.jsx)(`td`,{className:`px-4 py-2 text-right whitespace-nowrap tabular-nums`,children:i(n.precision)}),(0,H.jsx)(`td`,{className:`px-4 py-2 text-right whitespace-nowrap tabular-nums`,children:i(n.recall)})]},t)})})})]})]})}var mt=new Set([`Found right`,`Found wrong`,`Missed`]),ht={proven:{tone:`pass`,label:`Proven`},promising:{tone:`neutral`,label:`Promising`},"not-replayed":{tone:`neutral`,label:`Not replayed`},refuted:{tone:`fail`,label:`Refuted`},"side-effects":{tone:`warn`,label:`Side effects`}},gt={instruction:`Its instructions`,tool:`A tool`,data:`Its data`};function _t({p:e,onDecided:t}){let[n,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(``),[c,l]=(0,V.useState)(!1),[u,p]=(0,V.useState)(``),m=a.trim().length>=10&&a.trim().length<=500,g=async()=>{if(n){l(!0),p(``);try{await h.decide(e.agent,e.id,n,a.trim()),i(null),t()}catch(e){p(e.message)}finally{l(!1)}}};return(0,H.jsxs)(`li`,{className:`flex flex-col gap-1 border-b border-line-soft px-4 py-2 last:border-b-0`,children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1`,children:[(0,H.jsx)(x,{tone:e.state===`approved`?`pass`:e.state===`declined`?`neutral`:`warn`,children:e.state===`approved`?`Approved`:e.state===`declined`?`Declined`:`Open`}),(0,H.jsx)(`span`,{className:`text-body-sm font-medium text-ink-2`,children:e.kind===`fix`?`Fix, proven by replay`:`Guidance for its instructions`}),(0,H.jsx)(`span`,{className:`font-mono text-body-sm text-muted`,children:e.id})]}),(0,H.jsx)(`span`,{className:`text-body-sm text-ink [overflow-wrap:anywhere]`,children:U(e.text)}),(0,H.jsxs)(`span`,{className:`text-body-sm text-muted [overflow-wrap:anywhere]`,children:[`Because `,U(e.because),`. `,d(e.runs.length,`run`),e.replays?`, ${d(e.replays.length,`replay`)}`:``,`:`,` `,[...e.runs,...e.replays??[]].slice(0,8).map((e,t)=>(0,H.jsxs)(`span`,{children:[t?`, `:``,(0,H.jsx)(`a`,{href:r(`evidence-runs`,encodeURIComponent(e)),className:`font-mono`,children:e})]},e))]}),e.decision&&(0,H.jsxs)(`span`,{className:`text-body-sm text-ink-2 [overflow-wrap:anywhere]`,children:[e.state===`approved`?`Approved`:`Declined`,` by `,U(e.decision.by),` `,W(e.decision.at),` (`,e.decision.via===`web`?`on this page`:`at a terminal`,`): `,U(e.decision.reason)]}),e.state===`open`&&!n&&(0,H.jsxs)(`span`,{className:`flex gap-2`,children:[(0,H.jsxs)(C,{size:`sm`,onClick:()=>i(`approved`),children:[(0,H.jsx)(A,{"aria-hidden":`true`}),`Approve`]}),(0,H.jsxs)(C,{size:`sm`,variant:`ghost`,onClick:()=>i(`declined`),children:[(0,H.jsx)(j,{"aria-hidden":`true`}),`Decline`]})]}),n&&(0,H.jsxs)(`div`,{className:f(`panel rounded-md bg-(--page-surface-strong) p-6`,`flex max-w-[640px] flex-col gap-2`),children:[(0,H.jsx)(`label`,{htmlFor:`decide-${e.id}`,className:`text-body-sm font-medium text-ink-2`,children:n===`approved`?`Why approve it? It is kept with your name; the team then puts it into the agent: Evidence changes nothing itself.`:`Why decline it? It is kept with your name.`}),(0,H.jsx)(s,{id:`decide-${e.id}`,value:a,onChange:e=>o(e.target.value),rows:2,maxLength:500,placeholder:`For example: the replays show the claim data is the cause.`}),u&&(0,H.jsx)(B,{text:u}),(0,H.jsxs)(`span`,{className:`flex gap-2`,children:[(0,H.jsxs)(C,{busy:c,size:`sm`,disabled:!m||c,onClick:g,children:[n===`approved`?(0,H.jsx)(A,{"aria-hidden":`true`}):(0,H.jsx)(j,{"aria-hidden":`true`}),c?`Keeping…`:n===`approved`?`Approve`:`Decline`]}),(0,H.jsxs)(C,{size:`sm`,variant:`ghost`,onClick:()=>i(null),children:[(0,H.jsx)(M,{"aria-hidden":`true`}),`Cancel`]})]})]})]})}function vt({agent:e,run:t,c:n,candidates:i,onLinked:a}){let o=i,[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)([]),[d,p]=(0,V.useState)(!1),[m,g]=(0,V.useState)(``);return(0,H.jsxs)(`div`,{className:f(`flex flex-col gap-1 border-l-2 pl-4`,n.status===`proven`?`border-pass`:n.status===`refuted`?`border-fail`:n.status===`side-effects`?`border-warn`:`border-line`),children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1`,children:[(0,H.jsx)(x,{tone:ht[n.status].tone,children:ht[n.status].label}),(0,H.jsxs)(`span`,{className:`text-body-sm font-medium`,children:[n.id,` · `,gt[n.kind],`: `,U(n.where)]}),(0,H.jsxs)(`span`,{className:`text-body-sm text-muted`,children:[`of `,q[n.finding.check],`: `,U(n.finding.rule)]})]}),(0,H.jsxs)(`span`,{className:`text-body-sm text-ink [overflow-wrap:anywhere]`,children:[`Change: `,U(n.change)]}),(0,H.jsxs)(`span`,{className:`text-body-sm text-muted [overflow-wrap:anywhere]`,children:[U(n.why),`.`]}),n.replays.map(e=>(0,H.jsxs)(`span`,{className:`text-body-sm text-ink-2 [overflow-wrap:anywhere]`,children:[`Replay `,(0,H.jsx)(`a`,{href:r(`evidence-runs`,encodeURIComponent(e.run)),className:`font-mono`,children:e.run}),`: `,e.gone&&!e.broke.length&&e.changeSeen!==!1?`the finding is gone`:U(e.why.join(`; `))]},e.run)),!s&&o.length>0&&n.status!==`proven`&&(0,H.jsx)(`span`,{children:(0,H.jsxs)(C,{variant:`link`,size:`inline`,onClick:()=>c(!0),"data-tip":`Link replays`,className:`min-h-7 gap-1`,children:[(0,H.jsx)(de,{size:12,"aria-hidden":`true`}),`Link`]})}),s&&(0,H.jsxs)(`fieldset`,{className:f(`panel rounded-md bg-(--page-surface-strong) p-6`,`m-0 flex max-w-[640px] flex-col gap-2 border-0`),children:[(0,H.jsxs)(`legend`,{className:`sr-only`,children:[`Replays of `,n.id]}),(0,H.jsx)(`span`,{className:`text-body-sm font-medium text-ink-2`,children:`Which runs are this request run again with this change? Only runs of the same agent and request, after this one, are listed.`}),o.map(e=>(0,H.jsxs)(`label`,{className:`flex min-h-8 items-center gap-2 text-body-sm`,children:[(0,H.jsx)(je,{checked:l.includes(e),onCheckedChange:t=>u(n=>t?[...n,e]:n.filter(t=>t!==e))}),(0,H.jsx)(`span`,{className:`font-mono`,children:e})]},e)),m&&(0,H.jsx)(B,{text:m}),(0,H.jsxs)(`span`,{className:`flex gap-2`,children:[(0,H.jsxs)(C,{busy:d,size:`sm`,disabled:!l.length||d,onClick:async()=>{p(!0),g(``);try{await h.replay(e,t,n.id,l),c(!1),u([]),a()}catch(e){g(e.message)}finally{p(!1)}},"data-tip":`Link the picked replays`,children:[(0,H.jsx)(de,{"aria-hidden":`true`}),d?`Linking…`:l.length?`Link (${l.length})`:`Link`]}),(0,H.jsxs)(C,{size:`sm`,variant:`ghost`,onClick:()=>c(!1),children:[(0,H.jsx)(M,{"aria-hidden":`true`}),`Cancel`]})]})]})]})}function yt({sub:e}){let[t,i]=(0,V.useState)(null),[a,s]=(0,V.useState)(e?n(e):``),[c,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(``),[p,m]=(0,V.useState)(0);(0,V.useEffect)(()=>{h.overview().then(e=>{let t=e.agents.map(e=>e.name);i(t),s(e=>e||t[0]||``)},e=>d(e.message))},[]),(0,V.useEffect)(()=>{a&&(l(null),h.learn(a).then(l,e=>d(e.message)))},[a,p]);let g=()=>m(e=>e+1);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Y,{id:`evidence-learn`,children:`Learn`}),(0,H.jsx)(R,{more:(0,H.jsx)(H.Fragment,{children:`Each open finding has its possible causes (its instructions, a tool, the data it took in); a cause is proven when the same request, run again three times with that one change, no longer gives the finding and breaks nothing else. Proven causes and rules broken again and again are proposed; a person approves or declines each, and the team puts what is approved into the agent. Evidence changes nothing itself.`}),children:`What to change in an agent, from what its runs got wrong.`}),u&&(0,H.jsx)(B,{text:u}),t&&!t.length&&(0,H.jsx)(Z,{}),t&&t.length>1&&(0,H.jsxs)(`label`,{className:`flex w-fit items-center gap-2 text-body-sm text-ink-2`,children:[`Agent`,(0,H.jsx)(o,{value:a,onChange:e=>s(e.target.value),children:t.map(e=>(0,H.jsx)(`option`,{value:e,children:U(e)},e))})]}),a&&!c&&!u&&(0,H.jsx)(X,{}),c?.problems.map(e=>(0,H.jsx)(B,{text:e},e)),c&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`h2`,{className:`sr-only`,children:[`Proposals and causes of `,U(c.agent)]}),(0,H.jsxs)(z,{id:`proposals`,title:`Proposals`,icon:ce,n:c.proposals.length,children:[c.proposals.length?(0,H.jsx)(`ul`,{"aria-label":`Proposals`,className:f(`surface rounded-lg bg-bg p-6 shadow-sm`,`m-0 list-none`),children:c.proposals.map(e=>(0,H.jsx)(_t,{p:e,onDecided:g},e.id))}):(0,H.jsx)(v,{className:`py-4`,children:`Nothing to propose yet. A rule broken in three runs of the agent's latest version is proposed as guidance; a cause proven by replay, as a fix.`}),c.proposals.some(e=>e.state===`approved`)&&(0,H.jsxs)(`p`,{className:`m-0 text-body-sm text-muted`,children:[(0,H.jsxs)(`code`,{children:[`forgeqe evidence guidance `,U(c.agent)]}),` writes what was approved as Markdown, to put into the agent.`]})]}),(0,H.jsxs)(z,{id:`fixes`,title:`Fixes proven by the harness`,icon:k,n:c.fixes.length,children:[(0,H.jsxs)(`p`,{className:`m-0 text-body-sm text-muted`,children:[`A cause in the agent's instructions, added to a copy of them and run by ForgeQE's harness: proven on 3 clean replays and a suite that is no worse. The project is not changed: a person applies a proven fix at a terminal (`,(0,H.jsx)(`code`,{children:`forgeqe evidence fix apply <fix>`}),`), or puts its patch on a branch for a pull request.`]}),c.fixes.length?(0,H.jsx)(`ul`,{"aria-label":`Fixes`,className:`m-0 flex list-none flex-col gap-2 p-0`,children:c.fixes.map(e=>(0,H.jsx)(ot,{f:e},`${e.id}-${e.at}`))}):(0,H.jsxs)(`p`,{className:`m-0 text-body-sm text-muted`,children:[`No fix proven yet: `,(0,H.jsx)(`code`,{children:`forgeqe evidence fix <run> H1`}),` proves one of a cause below.`]})]}),(0,H.jsx)(z,{id:`causes`,title:`Causes of its findings`,icon:N,n:c.runs.length,children:c.runs.length?(0,H.jsx)(`ul`,{"aria-label":`Runs and their causes`,className:`m-0 flex list-none flex-col gap-2 p-0`,children:c.runs.map(e=>(0,H.jsxs)(`li`,{className:f(`surface rounded-lg bg-bg p-6 shadow-sm`,`flex flex-col gap-2`),children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1`,children:[(0,H.jsx)(`a`,{href:r(`evidence-runs`,encodeURIComponent(e.run)),className:`text-body-sm font-medium [overflow-wrap:anywhere]`,children:U(e.request||e.run)}),(0,H.jsxs)(`span`,{className:`font-mono text-body-sm text-muted`,children:[e.run,e.version?` · ${U(e.version)}`:``]})]}),e.causes.map(t=>(0,H.jsx)(vt,{agent:c.agent,run:e.run,c:t,candidates:e.candidates,onLinked:g},t.key)),!e.candidates.length&&(0,H.jsxs)(`span`,{className:`text-body-sm text-muted`,children:[`No run of the same request is recorded after it yet: `,(0,H.jsxs)(`code`,{children:[`forgeqe evidence replay-kit `,e.run,` H1`]}),` says what to change for a replay.`]})]},e.run))}):(0,H.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`No run of this agent has an open finding.`})})]})]})}var $={observe:`Observe`,assist:`Assist`,act:`Act`,autonomous:`Autonomous`},bt={observe:`a person reviews everything it does`,assist:`a person approves each change it makes`,act:`it acts alone within its contract; people review its findings`,autonomous:`it acts alone; only alerts reach people`},xt={model:`Model`,tool:`Tool`,knowledge:`Knowledge`,check:`Check`,judge:`Judge`,trust:`Trust`},St=[`observe`,`assist`,`act`,`autonomous`];function Ct({agent:e,label:t,icon:n,tip:r,action:a,children:o,onDone:c,uid:u}){let[d,p]=(0,V.useState)(!1),[m,h]=(0,V.useState)(``),[g,_]=(0,V.useState)(``),[v,y]=(0,V.useState)(!1),[b,x]=(0,V.useState)(``),ee=m.trim().length>=10&&m.trim().length<=500&&g===e,S=async()=>{y(!0),x(``);try{await a(g,m.trim()),p(!1),h(``),_(``),c()}catch(e){x(e.message)}finally{y(!1)}};if(!d)return(0,H.jsx)(`span`,{children:(0,H.jsxs)(C,{size:`sm`,onClick:()=>p(!0),"data-tip":r,children:[(0,H.jsx)(n,{"aria-hidden":`true`}),t]})});let w=`${t}${u?`-${u}`:``}`.toLowerCase().replace(/[^a-z0-9]+/g,`-`);return(0,H.jsxs)(`div`,{className:f(l,`flex max-w-[640px] flex-col gap-2`),children:[o,(0,H.jsx)(`label`,{htmlFor:`${w}-reason`,className:`text-body-sm font-medium text-ink-2`,children:`Why? It is kept with your name and in the audit.`}),(0,H.jsx)(s,{id:`${w}-reason`,value:m,onChange:e=>h(e.target.value),rows:2,maxLength:500}),(0,H.jsxs)(`label`,{htmlFor:`${w}-confirm`,className:`text-body-sm font-medium text-ink-2`,children:[`Type `,U(e),` to confirm`]}),(0,H.jsx)(i,{id:`${w}-confirm`,value:g,onChange:e=>_(e.target.value),autoComplete:`off`}),b&&(0,H.jsx)(B,{text:b}),(0,H.jsxs)(`span`,{className:`flex gap-2`,children:[(0,H.jsxs)(C,{busy:v,size:`sm`,disabled:!ee||v,onClick:S,"data-tip":r,children:[(0,H.jsx)(n,{"aria-hidden":`true`}),v?`Keeping…`:t]}),(0,H.jsxs)(C,{size:`sm`,variant:`ghost`,onClick:()=>p(!1),children:[(0,H.jsx)(M,{"aria-hidden":`true`}),`Cancel`]})]})]})}function wt(e){return(0,H.jsxs)(H.Fragment,{children:[e.slice(0,8).map((e,t)=>(0,H.jsxs)(`span`,{children:[t?`, `:``,(0,H.jsx)(`a`,{href:r(`evidence-runs`,encodeURIComponent(e)),className:`font-mono`,children:e})]},e)),e.length>8?`, and ${e.length-8} more`:``]})}function Tt({sub:e}){let t=e?n(e):``,[i,a]=(0,V.useState)(null),[s,c]=(0,V.useState)(``),[l,u]=(0,V.useState)(0),[p,m]=(0,V.useState)(`observe`),g=()=>u(e=>e+1);(0,V.useEffect)(()=>{c(``),h.monitor(t||void 0).then(a,e=>c(e.message))},[t,l]);let _=async()=>{try{let e=await h.audit(t),n=URL.createObjectURL(new Blob([`${JSON.stringify(e,null,2)}\n`],{type:`application/json`})),r=document.createElement(`a`);r.href=n,r.download=`${t.replace(/[^A-Za-z0-9_.-]+/g,`-`).replace(/^[-.]+/,``).slice(0,60)||`agent`}.audit.json`,r.click(),URL.revokeObjectURL(n)}catch(e){c(e.message)}},b=i?.agent;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Y,{id:`evidence-monitor`,children:`Monitor`}),(0,H.jsx)(R,{more:(0,H.jsxs)(H.Fragment,{children:[`For each agent evaluated: what changed since its baseline (a model, a tool, the documents it reads, a check doing worse, its contract or judge), how much autonomy its evidence supports and what a person granted it, and every decision people made about it, to export. The nightly job is `,(0,H.jsx)(`code`,{children:`forgeqe evidence drift --all`}),`.`]}),children:`Watch what changes in each agent, and how much it can be trusted to do alone.`}),s&&(0,H.jsx)(B,{text:s}),!i&&!s&&(0,H.jsx)(X,{}),i?.problems.map(e=>(0,H.jsx)(B,{text:e},e)),i&&!i.inventory.length&&(0,H.jsx)(Z,{}),i&&i.inventory.length>0&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`h2`,{className:`sr-only`,children:`Agents and their governance`}),(0,H.jsxs)(z,{id:`inventory`,title:`Inventory`,icon:ae,n:i.inventory.length,children:[(0,H.jsx)(F,{label:`Agents evaluated`,search:!1,minWidth:760,head:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,children:`Agent`}),(0,H.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,children:`Versions`}),(0,H.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,children:`Models`}),(0,H.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-right text-label-md font-medium whitespace-nowrap text-muted`,children:`Tools`}),(0,H.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,children:`Contract`}),(0,H.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,children:`Trust`}),(0,H.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-right text-label-md font-medium whitespace-nowrap text-muted`,children:`Alerts`})]}),children:i.inventory.map(e=>(0,H.jsxs)(`tr`,{className:`h-12 border-t border-line-soft align-middle transition-colors duration-150 data-[state=selected]:bg-tint-hover`,children:[(0,H.jsx)(`th`,{scope:`row`,className:f(`px-4 py-2`,`text-left font-medium`),children:(0,H.jsx)(`a`,{href:r(`evidence-monitor`,encodeURIComponent(e.agent)),"aria-current":e.agent===t?`page`:void 0,children:U(e.agent)})}),(0,H.jsx)(`td`,{className:f(`px-4 py-2`,`text-muted`),children:e.versions.slice(0,3).map(U).join(`, `)||`none named`}),(0,H.jsx)(`td`,{className:f(`px-4 py-2`,`text-muted [overflow-wrap:anywhere]`),children:e.models.slice(0,3).map(U).join(`, `)||`none named`}),(0,H.jsx)(`td`,{className:`px-4 py-2 text-right whitespace-nowrap tabular-nums`,children:e.tools.length}),(0,H.jsx)(`td`,{className:f(`px-4 py-2`,`text-muted`),children:e.contract?e.contract.approved?`Approved`:`Not approved`:`None`}),(0,H.jsx)(`td`,{className:`px-4 py-2`,children:e.granted?`${$[e.granted]} (supports ${$[e.supported].toLowerCase()})`:`Not granted (supports ${$[e.supported].toLowerCase()})`}),(0,H.jsx)(`td`,{className:f(`px-4 py-2 text-right whitespace-nowrap tabular-nums`,e.alerts>0&&`text-fail`),"data-sort":e.baseline||e.alerts?e.alerts:-1,children:e.baseline||e.alerts?e.alerts:(0,H.jsx)(`span`,{className:`text-muted`,children:`no baseline`})})]},e.agent))}),!t&&(0,H.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`Open an agent to see its drift, its trust and its audit.`})]}),b&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(z,{id:`drift`,title:`Drift of ${b.name}`,icon:w,n:b.drift.alerts.length,children:[b.drift.baseline?(0,H.jsxs)(`p`,{className:`m-0 text-body-sm text-muted`,children:[`Since its baseline (`,b.drift.baseline.version?U(b.drift.baseline.version):`no version`,`, `,d(b.drift.baseline.runs,`run`),`, set by `,U(b.drift.baseline.by),` `,W(b.drift.baseline.at),`): `,d(b.drift.since.length,`run`),`.`]}):(0,H.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`No baseline is set: what changed cannot be said. Set one when a version is released.`}),b.drift.alerts.length>0&&(0,H.jsx)(`ul`,{"aria-label":`Drift alerts`,className:f(`surface rounded-lg bg-bg p-6 shadow-sm`,`m-0 list-none`),children:b.drift.alerts.map(e=>(0,H.jsxs)(`li`,{className:`flex flex-col gap-1 border-b border-line-soft px-4 py-2 last:border-b-0`,children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1`,children:[(0,H.jsx)(x,{tone:`warn`,children:xt[e.kind]}),(0,H.jsx)(`span`,{className:`text-body-sm [overflow-wrap:anywhere]`,children:U(e.what)})]}),e.runs.length>0&&(0,H.jsxs)(`span`,{className:`text-body-sm text-muted [overflow-wrap:anywhere]`,children:[`In `,wt(e.runs)]})]},`${e.kind}-${e.subject}`))}),b.drift.baseline&&!b.drift.alerts.length&&(0,H.jsx)(v,{className:`py-4`,children:`Nothing changed since the baseline.`}),(0,H.jsx)(Ct,{agent:b.name,label:`Set baseline`,icon:ge,tip:b.drift.baseline?`Set a new baseline`:`Set the baseline`,action:(e,t)=>h.baseline(b.name,e,t),onDone:g,children:(0,H.jsx)(`span`,{className:`text-body-sm text-ink-2`,children:`The baseline becomes its latest version's runs as they are judged now: their models, tools, documents and each check's pass rate.`})})]}),(0,H.jsxs)(z,{id:`trust`,title:`Trust in ${b.name}`,icon:oe,children:[(0,H.jsxs)(`p`,{className:`m-0 text-body-sm`,children:[`Its evidence supports `,(0,H.jsx)(`b`,{children:$[b.trust.supported]}),`: `,bt[b.trust.supported],`.`,` `,b.trust.granted?(0,H.jsxs)(H.Fragment,{children:[`Granted: `,(0,H.jsx)(`b`,{children:$[b.trust.granted.level]}),`, by `,U(b.trust.granted.by),` `,W(b.trust.granted.at),`: `,U(b.trust.granted.reason)]}):`No level is granted.`]}),(0,H.jsx)(`ul`,{"aria-label":`What each level needs`,className:f(`surface rounded-lg bg-bg p-6 shadow-sm`,`m-0 list-none`),children:b.trust.criteria.filter(e=>e.level!==`observe`).map(e=>(0,H.jsxs)(`li`,{className:`flex items-start gap-2 border-b border-line-soft px-4 py-2 text-body-sm last:border-b-0`,children:[(0,H.jsx)(y,{icon:e.met?A:ve,size:15,className:e.met?`mt-1 text-pass`:`mt-1 text-muted`}),(0,H.jsx)(`span`,{className:`w-[96px] shrink-0 font-medium`,children:$[e.level]}),(0,H.jsxs)(`span`,{className:`text-ink-2 [overflow-wrap:anywhere]`,children:[(0,H.jsx)(`span`,{className:`sr-only`,children:e.met?`Met: `:`Not met: `}),U(e.what)]})]},`${e.level}-${e.what}`))}),(0,H.jsx)(Ct,{agent:b.name,label:`Grant`,icon:A,tip:`Grant a trust level`,action:(e,t)=>h.trust(b.name,p,e,t),onDone:g,children:(0,H.jsxs)(`label`,{className:`flex w-fit items-center gap-2 text-body-sm font-medium text-ink-2`,children:[`Level`,(0,H.jsx)(o,{value:p,onChange:e=>m(e.target.value),children:St.slice(0,St.indexOf(b.trust.supported)+1).map(e=>(0,H.jsxs)(`option`,{value:e,children:[$[e],`: `,bt[e]]},e))})]})})]}),(0,H.jsxs)(z,{id:`audit`,title:`Audit`,icon:he,children:[(0,H.jsxs)(`p`,{className:`m-0 text-body-sm text-muted`,children:[`Every decision people made about `,U(b.name),` (its contract's approval, overrules, grades, replays, proposals, release gates, baselines and trust), each with who made it, when, why, and the runs it rested on as they are recorded now.`]}),(0,H.jsx)(`span`,{children:(0,H.jsxs)(C,{size:`sm`,onClick:_,"data-tip":`Download the audit`,children:[(0,H.jsx)(pe,{"aria-hidden":`true`}),`Download`]})})]})]})]})]})}function Et({page:e,sub:t}){let r=(t||``).split(`/`),i=r[0]===`agent`&&r[1]?n(r[1]):``,a=e===`evidence-runs`&&r[0]&&r[0]!==`agent`?n(r[0]):``;return(0,H.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,H.jsx)(we,{}),(0,H.jsx)(`main`,{className:f(Te,`@container flex-auto gap-4`),children:e===`evidence`?t?(0,H.jsx)(qe,{agent:n(t)},t):(0,H.jsx)(Ue,{}):e===`evidence-contracts`?(0,H.jsx)(pt,{}):e===`evidence-review`?(0,H.jsx)(nt,{}):e===`evidence-releases`?(0,H.jsx)(dt,{}):e===`evidence-learn`?(0,H.jsx)(yt,{sub:t}):e===`evidence-monitor`?(0,H.jsx)(Tt,{sub:t},t||``):a?(0,H.jsx)(Qe,{id:a},a):(0,H.jsx)(Je,{agent:i})})]})}export{Et as Evidence};
@@ -1,2 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./react-BDur5s0O.js";import{n,r}from"./route-oDy8sV6H.js";import{F as i,L as a,l as o}from"./preload-helper-BupTYkQW.js";import{t as s}from"./utils-DJRAScIl.js";import{t as c}from"./jsx-runtime-LKYXHABd.js";import{d as l}from"./sectionList-B651VPon.js";import{v as u,y as d}from"./api-D_HT-I9y.js";import{C as f,S as p,g as m,m as h,r as g,x as _}from"./pageBack-DwhsvsK7.js";import{B as v,E as y,J as b,N as x,Pn as S,Rr as C,Sr as w,mn as T,or as E,ur as D,z as O}from"./line-icons-CwCZidXs.js";import{Jt as k,Yt as A,_t as j}from"./frame-Dt9QcYNX.js";import{t as M}from"./when-BuWCTaKm.js";import{u as N}from"./nav-IMBXh0Jg.js";import{t as P}from"./code-Jek8uWUO.js";import{H as F,U as I,V as L,X as R,Y as z,l as B,n as V,t as H}from"./index-BdWLAq_n.js";import{g as U}from"./qualityParts-DF3ZMgo5.js";var W=e(t(),1),G={view:()=>u(`GET`,`/api/explore`),start:e=>u(`POST`,`/api/explore/start`,{...e,confirmed:!0}),stop:()=>u(`POST`,`/api/explore/stop`,{}),answer:(e,t)=>u(`POST`,`/api/explore/answer`,{id:e,choice:t}),session:e=>u(`GET`,`/api/explore/sessions/${encodeURIComponent(e)}`)},K=c(),q=[2,3,4,6,8,12],J=[10,15,30,45,60,90,120],Y={passed:{label:`As expected`,icon:x,tone:`text-pass`},defect:{label:`Defect, confirmed`,icon:O,tone:`text-fail`},not_reproduced:{label:`Not reproduced`,icon:w,tone:`text-warn`},could_not_explore:{label:`Could not explore`,icon:w,tone:`text-muted`},stopped:{label:`Stopped`,icon:E,tone:`text-muted`}},X=e=>{let t=Math.max(0,Math.round(e/1e3));return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`};function Z({job:e,onStop:t,onAnswer:n}){let r=(0,W.useRef)(null),[,i]=(0,W.useState)(0);(0,W.useEffect)(()=>{r.current&&(r.current.scrollTop=r.current.scrollHeight)},[e.lines.length]),(0,W.useEffect)(()=>{if(!e.running)return;let t=A(()=>i(e=>e+1),1e3);return()=>k(t)},[e.running]);let a=(e.endedAt?Date.parse(e.endedAt):Date.now())-Date.parse(e.startedAt),c=e.deadline?Date.parse(e.deadline)-Date.now():void 0,l=e.exitCode===0?`No defect confirmed`:e.exitCode===1?`Defects confirmed`:`Did not finish`;return(0,K.jsxs)(`section`,{"aria-label":`Session`,className:s(o,`flex flex-col gap-2`),children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,K.jsx)(`span`,{className:`min-w-0 flex-1 font-medium [overflow-wrap:anywhere]`,children:e.goal||`Exploratory session`}),(0,K.jsx)(m,{orb:`working`,tone:e.running?`running`:e.exitCode===0?`pass`:`fail`,children:e.running?e.question?`Waiting for you`:`Exploring`:l}),(0,K.jsxs)(`span`,{className:`text-body-sm text-muted tabular-nums`,"data-tip":e.minutes?`Time limit ${e.minutes} minutes`:void 0,children:[X(a),e.running&&c!==void 0?` · ${X(c)} left`:``]}),e.running&&(0,K.jsxs)(_,{variant:`danger`,onClick:t,children:[(0,K.jsx)(E,{fill:`currentColor`,"aria-hidden":`true`}),`Stop`]})]}),e.running&&e.question&&(0,K.jsxs)(`fieldset`,{className:s(`panel rounded-md bg-(--page-surface-strong) p-6`,`m-0 flex flex-col gap-2 border-0`),children:[(0,K.jsx)(`legend`,{className:`float-left mb-1 text-body-sm font-medium`,children:e.question.title}),e.question.detail&&(0,K.jsx)(`p`,{className:`clear-left m-0 text-body-sm text-ink-2`,children:e.question.detail}),(0,K.jsx)(`div`,{className:`clear-left flex flex-wrap gap-2`,children:e.question.options.map((t,r)=>(0,K.jsx)(_,{size:`sm`,variant:r===0&&t.id!==`cancel`?`primary`:`outline`,onClick:()=>n(e.question.id,t.id),children:t.label},t.id))})]}),!e.running&&e.reason&&(0,K.jsx)(`p`,{role:`alert`,className:s(f.fail,`m-0`),children:e.reason}),(0,K.jsxs)(`details`,{open:e.running||!!e.reason,children:[(0,K.jsxs)(`summary`,{className:`cursor-pointer text-body-sm text-muted`,children:[`Output (`,e.lines.length,` lines): the charters, each run, and what it found`]}),(0,K.jsx)(`pre`,{ref:r,className:s(P,`mt-2 max-h-[340px]`),children:(0,K.jsx)(g,{text:e.lines.join(`
2
- `)||`Planning the charters…`})})]})]})}function Q({view:e,onStarted:t}){let[n,r]=(0,W.useState)(``),[c,l]=(0,W.useState)(e.production?``:e.apps[0]?.name??``),[u,d]=(0,W.useState)(``),[p,m]=(0,W.useState)(``),[g,v]=(0,W.useState)(4),[y,x]=(0,W.useState)(30),[w,T]=(0,W.useState)([]),[E,D]=(0,W.useState)(!1),[O,k]=(0,W.useState)(!1),[A,j]=(0,W.useState)(``),M=e.production?[]:e.apps,N=c||/^https?:\/\/\S+$/i.test(u.trim()),P=n.trim().length>=8&&N,F=async()=>{k(!0);try{t(await G.start({goal:n.trim(),...p.trim()?{story:p.trim()}:{},...c?{app:c}:{url:u.trim()},charters:g,minutes:y,...w.length?{roles:w}:{}})),D(!1),j(``)}catch(e){j(e.message)}finally{k(!1)}};return(0,K.jsxs)(`form`,{"aria-labelledby":`explore-new`,className:s(o,`flex flex-col gap-4`),onSubmit:e=>{e.preventDefault(),P&&D(!0)},children:[(0,K.jsx)(R,{id:`explore-new`,icon:b,title:`New session`}),(0,K.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm font-medium`,children:[`Goal`,(0,K.jsx)(i,{value:n,onChange:e=>r(e.target.value),maxLength:300,placeholder:`Try to break checkout with odd addresses and postcodes`,"aria-describedby":`explore-goal-help`}),(0,K.jsx)(`span`,{id:`explore-goal-help`,className:`font-normal text-muted`,children:`What to try to break, or what to look for. The session plans its charters from it, and stops when they have run.`})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsxs)(`label`,{className:`flex min-w-0 flex-[1_1_220px] flex-col gap-1 text-body-sm font-medium`,children:[`Start at`,(0,K.jsxs)(a,{size:`sm`,value:c,onChange:e=>l(e.target.value),children:[M.map(t=>(0,K.jsxs)(`option`,{value:t.name,children:[t.name,` (`,e.environment,`)`]},t.name)),(0,K.jsx)(`option`,{value:``,children:`Another address…`})]})]}),!c&&(0,K.jsxs)(`label`,{className:`flex min-w-0 flex-[2_1_280px] flex-col gap-1 text-body-sm font-medium`,children:[`Address`,(0,K.jsx)(i,{size:`sm`,value:u,onChange:e=>d(e.target.value),placeholder:`https://qa.shop.example.com/checkout`})]}),(0,K.jsxs)(`label`,{className:`flex min-w-0 flex-[1_1_160px] flex-col gap-1 text-body-sm font-medium`,children:[`Story (optional)`,(0,K.jsx)(i,{size:`sm`,value:p,onChange:e=>m(e.target.value),maxLength:40,placeholder:`ado:1234 or SHOP-12`})]}),(0,K.jsxs)(`label`,{className:`flex flex-[0_1_140px] flex-col gap-1 text-body-sm font-medium`,children:[`Charters, at most`,(0,K.jsx)(a,{size:`sm`,value:String(g),onChange:e=>v(Number(e.target.value)),children:q.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))})]}),(0,K.jsxs)(`label`,{className:`flex flex-[0_1_140px] flex-col gap-1 text-body-sm font-medium`,children:[`Time limit`,(0,K.jsx)(a,{size:`sm`,value:String(y),onChange:e=>x(Number(e.target.value)),children:J.map(e=>(0,K.jsxs)(`option`,{value:e,children:[e,` minutes`]},e))})]})]}),e.roles.length>1&&(0,K.jsxs)(`div`,{className:`flex flex-col gap-1 text-body-sm`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:`Roles`}),(0,K.jsx)(h,{items:e.roles.map(e=>({id:e,label:e})),value:w,onChange:T}),(0,K.jsx)(`span`,{className:`text-muted`,children:`Saved logins to explore as. None picked: each of them.`})]}),e.production&&(0,K.jsxs)(`p`,{className:`m-0 text-body-sm text-warn`,children:[`The active environment, `,e.environment,`, is named like production: give the address of a test environment.`]}),A&&(0,K.jsx)(`p`,{role:`alert`,className:s(f.fail,`m-0`),children:A}),E?(0,K.jsxs)(`div`,{className:s(f.info,`flex flex-wrap items-center gap-2`),children:[(0,K.jsxs)(`span`,{className:`flex-[1_1_280px]`,children:[`Start a session of up to `,g,` charters, for at most `,y,` minutes? Each charter is a browser run (two when it finds a possible defect); you choose which charters run once they are planned.`]}),(0,K.jsxs)(_,{size:`sm`,variant:`primary`,disabled:O,onClick:()=>void F(),children:[(0,K.jsx)(S,{"aria-hidden":`true`}),`Start`]}),(0,K.jsxs)(_,{size:`sm`,variant:`ghost`,disabled:O,onClick:()=>D(!1),children:[(0,K.jsx)(C,{"aria-hidden":`true`}),`Cancel`]})]}):(0,K.jsx)(`div`,{children:(0,K.jsxs)(_,{size:`sm`,variant:`primary`,type:`submit`,disabled:!P,"data-tip":`Plan charters, then explore`,children:[(0,K.jsx)(b,{"aria-hidden":`true`}),`Explore`]})})]})}function $({id:e}){let[t,n]=(0,W.useState)(null),[i,a]=(0,W.useState)(``),[o,c]=(0,W.useState)(``);(0,W.useEffect)(()=>{let t=!1;return G.session(e).then(e=>!t&&n(e),e=>!t&&a(e.message)),()=>{t=!0}},[e]);let l=(0,K.jsxs)(`a`,{href:r(`explore`,`sessions`),className:s(p({variant:`link`,size:`inline`}),`gap-1 self-start`),children:[(0,K.jsx)(y,{size:14,"aria-hidden":`true`,className:`rotate-90`}),`All sessions`]});if(i||!t)return(0,K.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[l,i?(0,K.jsx)(`p`,{role:`alert`,className:s(f.fail,`m-0`),children:i}):(0,K.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Loading…`})]});let u=async()=>{try{let{id:e}=await d.start(`Go through the exploratory session ${t.id} (in the reports folder's explore folder: exploration.md and exploration.json). Summarize the confirmed defects and the observations, and offer to save the proposed test cases and to file bugs for the confirmed defects.`,{});location.hash=r(`chats`,e)}catch(e){c(e.message)}};return(0,K.jsxs)(`section`,{"aria-labelledby":`explore-s-h`,className:`flex min-w-0 flex-col gap-4`,children:[l,(0,K.jsx)(R,{id:`explore-s-h`,icon:b,title:(0,K.jsx)(`span`,{"data-tip":t.title,children:t.title}),description:(0,K.jsxs)(K.Fragment,{children:[U(t.at),` · `,t.story.id&&t.story.id!==`story`?`${t.story.id} · `:``,(0,K.jsx)(`span`,{className:`font-mono`,children:t.id})]}),actions:(0,K.jsxs)(_,{size:`sm`,variant:`ghost`,onClick:()=>void u(),"data-tip":`Ask about this session in a chat`,children:[(0,K.jsx)(T,{"aria-hidden":`true`}),`Chat`]})}),o&&(0,K.jsx)(`p`,{className:`m-0 text-body-sm text-fail`,children:o}),(0,K.jsxs)(L,{label:`Charters by result`,children:[(0,K.jsx)(F,{dot:`neutral`,value:t.charters,label:`charters run`}),(0,K.jsx)(F,{dot:`fail`,value:t.defects,label:`defects confirmed`}),(0,K.jsx)(F,{dot:`pass`,value:t.passed,label:`as expected`}),(0,K.jsx)(F,{dot:`warn`,value:t.notReproduced,label:`not reproduced`}),(0,K.jsx)(F,{dot:`neutral`,value:t.stopped+t.notExplored,label:`stopped or not explored`})]}),(0,K.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:t.results.map(e=>{let t=Y[e.status];return(0,K.jsxs)(`li`,{className:`flex items-start gap-2 border-t border-line-soft py-2 text-body-sm`,children:[(0,K.jsx)(t.icon,{size:15,"aria-label":t.label,className:s(`mt-1 flex-none`,t.tone)}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,K.jsxs)(`span`,{className:`font-medium`,children:[e.id?`${e.id} · `:``,e.title,` `,(0,K.jsxs)(`span`,{className:s(`font-normal`,t.tone),children:[`· `,t.label]}),e.role?(0,K.jsxs)(`span`,{className:`font-normal text-muted`,children:[` · as `,e.role]}):null,e.changesData?(0,K.jsx)(`span`,{className:`font-normal text-muted`,children:` · changes data`}):null]}),e.mission&&(0,K.jsx)(`span`,{className:`text-ink-2`,children:e.mission}),(e.reason||e.summary)&&(0,K.jsx)(`span`,{className:s(`[overflow-wrap:anywhere]`,e.status===`defect`?`text-fail`:`text-ink-2`),children:e.reason||e.summary}),e.observations.map((e,t)=>(0,K.jsxs)(`span`,{className:`text-body-sm text-muted [overflow-wrap:anywhere]`,children:[`Noticed: `,e]},t)),e.runDir&&(0,K.jsxs)(`span`,{className:`truncate font-mono text-body-sm text-muted`,"data-tip":e.reproRunDir?`${e.runDir} · again: ${e.reproRunDir}`:e.runDir,children:[e.runDir,e.reproRunDir?` · ran again to confirm`:``]})]})]},e.id||e.title)})}),t.proposed.length>0&&(0,K.jsx)(z,{level:3,icon:v,title:`Proposed test cases`,className:`text-body-sm`,children:(0,K.jsx)(`ul`,{className:`m-0 flex list-disc flex-col gap-1 pl-6 text-ink-2`,children:t.proposed.map((e,t)=>(0,K.jsxs)(`li`,{children:[e.title,e.kind===`defect`?(0,K.jsx)(`span`,{className:`text-muted`,children:` · checks the defect is fixed`}):null]},t))})})]})}function ee({sub:e}){let[t,i]=(0,W.useState)(null),[a,o]=(0,W.useState)(``),c=(0,W.useCallback)(()=>{G.view().then(e=>(i(e),o(``)),e=>o(e.message))},[]);(0,W.useEffect)(c,[c]);let u=!!t?.job?.running;(0,W.useEffect)(()=>{if(!u)return;let e=A(c,2e3);return()=>k(e)},[u,c]);let d=async e=>{try{i(await e())}catch(e){o(e.message)}},p=l(`exploration`),m=e&&e!==`agent`?`sessions`:H,h=e&&e!==`sessions`&&e!==`agent`?n(e):``,g=e=>location.hash=r(`explore`,encodeURIComponent(e));return(0,K.jsxs)(V,{title:N(`explore`),page:p,label:`Exploratory testing`,current:m,tabHref:e=>e===`agent`?r(`explore`,H):r(`explore`,e),onPick:e=>location.hash=e===`agent`?r(`explore`,H):r(`explore`,e),tabs:[{id:`sessions`,label:`Sessions`,icon:D,...t?{n:t.sessions.length}:{}}],below:(0,K.jsx)(B,{page:p}),children:[!h&&(0,K.jsx)(I,{more:(0,K.jsx)(K.Fragment,{children:`ForgeQE plans charters from your goal (other paths, edge cases, invalid input, boundaries, roles, refresh and back), you choose which run, each runs in a browser, and a possible defect runs again to be confirmed. A session stops when its charters have run or its time limit is reached, and keeps what it found.`}),children:`Explore beyond your scripted test cases: give a goal, and ForgeQE tries to break it in a browser.`}),a&&(0,K.jsx)(`p`,{role:`alert`,className:s(f.fail,`m-0`),children:a}),!t&&!a&&(0,K.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Loading…`}),t&&h&&(0,K.jsx)($,{id:h}),t&&!h&&(0,K.jsxs)(K.Fragment,{children:[t.job&&(0,K.jsx)(Z,{job:t.job,onStop:()=>void d(G.stop),onAnswer:(e,t)=>void d(()=>G.answer(e,t))}),!u&&(0,K.jsx)(Q,{view:t,onStarted:i}),(0,K.jsx)(z,{icon:D,title:`Sessions`,children:(0,K.jsx)(j,{label:`Sessions`,placeholder:`Find a session`,empty:`No sessions yet. Give a goal above and start one: what it finds, the defects it confirmed and the test cases it proposes show here.`,head:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`th`,{scope:`col`,className:s(`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,`w-[50%]`),children:`Session`}),(0,K.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-right text-label-md font-medium whitespace-nowrap text-muted`,children:`Defects`}),(0,K.jsx)(`th`,{scope:`col`,className:s(`px-4 py-2 text-right text-label-md font-medium whitespace-nowrap text-muted`,`hidden @xl:table-cell`),children:`Charters`}),(0,K.jsx)(`th`,{scope:`col`,className:s(`px-4 py-2 text-right text-label-md font-medium whitespace-nowrap text-muted`,`hidden @2xl:table-cell`),children:`As expected`}),(0,K.jsx)(`th`,{scope:`col`,className:s(`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,`hidden @xl:table-cell`),children:`When`})]}),children:t.sessions.map(e=>{let t=e.defects?O:e.notReproduced?w:x;return(0,K.jsxs)(`tr`,{onClick:()=>g(e.id),className:`h-12 cursor-pointer border-t border-line-soft align-middle transition-colors duration-150 hover:bg-tint data-[state=selected]:bg-tint-hover`,children:[(0,K.jsx)(`td`,{className:s(`px-4 py-2`,`max-w-0`),children:(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(t,{size:15,"aria-label":e.defects?`Defects confirmed`:e.notReproduced?`Observations`:`Nothing confirmed`,className:s(`flex-none`,e.defects?`text-fail`:e.notReproduced?`text-warn`:`text-pass`)}),(0,K.jsx)(`a`,{href:r(`explore`,encodeURIComponent(e.id)),onClick:e=>e.stopPropagation(),"data-tip":e.title,className:`truncate text-ink no-underline hover:underline`,children:e.title})]})}),(0,K.jsx)(`td`,{className:s(`px-4 py-2 text-right whitespace-nowrap tabular-nums`,e.defects?`text-fail`:`text-muted`),children:e.defects}),(0,K.jsx)(`td`,{className:s(`px-4 py-2 text-right whitespace-nowrap tabular-nums`,`hidden text-muted @xl:table-cell`),children:e.charters}),(0,K.jsx)(`td`,{className:s(`px-4 py-2 text-right whitespace-nowrap tabular-nums`,`hidden text-muted @2xl:table-cell`),children:e.passed}),(0,K.jsx)(`td`,{className:s(`px-4 py-2`,`hidden whitespace-nowrap text-body-sm text-muted @xl:table-cell`),"data-tip":U(e.at),"data-sort":new Date(e.at).getTime()||0,children:M(e.at)})]},e.id)})})})]})]})}export{ee as Explore};
@@ -1,2 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./react-BDur5s0O.js";import{r as n}from"./route-oDy8sV6H.js";import{L as r}from"./preload-helper-BupTYkQW.js";import{t as i}from"./utils-DJRAScIl.js";import{t as a}from"./jsx-runtime-LKYXHABd.js";import{L as o}from"./palette-CeG8IIbL.js";import{v as s}from"./api-D_HT-I9y.js";import{C as c,S as ee,_ as te,f as ne,m as re,n as ie,r as l,x as u}from"./pageBack-DwhsvsK7.js";import{N as d,Or as ae,P as f,Pn as p,R as m,Rr as oe,Sr as se,cn as h,o as ce,or as g,z as _,zn as le}from"./line-icons-CwCZidXs.js";import{Ct as v,Jt as ue,St as y,Tt as b,Yt as de,_t as x,bt as S,s as fe,t as pe,wt as C,zt as me}from"./frame-Dt9QcYNX.js";import{t as w}from"./when-BuWCTaKm.js";import{u as he}from"./nav-IMBXh0Jg.js";import"./code-Jek8uWUO.js";import{H as T,J as ge,U as _e,V as ve,Y as ye}from"./index-BdWLAq_n.js";import{g as E,p as D}from"./qualityParts-DF3ZMgo5.js";var O=e(t(),1),k={view:()=>s(`GET`,`/api/flags`),catalog:(e,t=!1)=>s(`GET`,`/api/flags/catalog?env=${encodeURIComponent(e)}${t?`&refresh=1`:``}`),preview:e=>s(`POST`,`/api/flags/preview`,e),run:e=>s(`POST`,`/api/flags/run`,{...e,confirmed:!0}),job:()=>s(`GET`,`/api/flags/job`),stop:()=>s(`POST`,`/api/flags/stop`,{})},A=a(),j={cookie:`cookie`,header:`header`,query:`query`,localStorage:`localStorage`},M={"env.yaml":`env.yaml`,launchdarkly:`LaunchDarkly`,unleash:`Unleash`},N={queued:{icon:f,label:`Queued`,tone:`text-muted`},running:{icon:h,label:`Running`,tone:`text-accent`},passed:{icon:d,label:`Passed`,tone:`text-pass`},failed:{icon:_,label:`Tests failed`,tone:`text-fail`},error:{icon:se,label:`Did not finish`,tone:`text-warn`},stopped:{icon:m,label:`Stopped`,tone:`text-muted`}},P={failed:5,error:4,running:3,queued:2,stopped:1,passed:0};function be({status:e}){let t=N[e];return(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-2 whitespace-nowrap`,children:[(0,A.jsx)(t.icon,{size:15,"aria-label":t.label,className:i(`flex-none`,t.tone,e===`running`&&`animate-spin`)}),(0,A.jsx)(`span`,{className:`text-body-sm`,children:t.label})]})}var F=e=>Object.entries(e).map(([e,t])=>`${e}=${t}`).join(` · `);function xe({job:e,onStop:t,busy:n}){let r=e.runs.filter(e=>e.status===`passed`||e.status===`failed`||e.status===`error`||e.status===`stopped`).length,a=e.runs.filter(e=>e.status===`passed`).length,o=e.runs.filter(e=>e.status===`failed`||e.status===`error`).length;return(0,A.jsxs)(ye,{icon:p,title:(0,A.jsxs)(A.Fragment,{children:[e.running?`Running`:`Ran`,` `,e.pack,` on `,e.environment]}),actions:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`span`,{className:`text-body-sm text-muted`,"data-tip":E(e.startedAt),children:[`started `,w(e.startedAt)]}),e.running&&(0,A.jsxs)(u,{size:`sm`,variant:`danger`,disabled:n,onClick:t,children:[(0,A.jsx)(g,{fill:`currentColor`,"aria-hidden":`true`}),`Stop`]})]}),children:[(0,A.jsxs)(ve,{label:`Runs of the matrix`,children:[(0,A.jsx)(T,{dot:`neutral`,value:e.runs.length,label:e.mode===`pairwise`?`combinations, pairwise`:`combinations, every one`}),(0,A.jsx)(T,{tip:`${e.parallel} at once`,dot:`running`,value:`${r} of ${e.runs.length}`,label:`finished`}),(0,A.jsx)(T,{tip:`Every test passed`,dot:`pass`,value:a,label:`passed`}),(0,A.jsx)(T,{tip:`A test failed, or the run did not finish`,dot:`fail`,value:o,label:`failed`})]}),(0,A.jsx)(x,{label:`Runs`,placeholder:`Find a run by its values`,resetKey:e.startedAt,empty:`No runs.`,head:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`th`,{scope:`col`,className:i(v,`w-[64px]`),children:`Run`}),(0,A.jsx)(`th`,{scope:`col`,className:v,children:`Flag values`}),(0,A.jsx)(`th`,{scope:`col`,className:v,children:`Result`}),(0,A.jsx)(`th`,{scope:`col`,className:i(C,`hidden @xl:table-cell`),children:`Time`})]}),children:e.runs.map(e=>{let t=e.startedAt?Math.round(((e.endedAt?Date.parse(e.endedAt):Date.now())-Date.parse(e.startedAt))/1e3):void 0;return(0,A.jsxs)(`tr`,{className:b,children:[(0,A.jsx)(`td`,{className:i(S,`font-mono text-body-sm`),children:e.id}),(0,A.jsxs)(`td`,{className:i(S,`max-w-0`),children:[(0,A.jsx)(`span`,{className:`block truncate font-mono text-body-sm`,"data-tip":F(e.values),children:F(e.values)}),e.lines.length>0&&(0,A.jsxs)(`details`,{className:`mt-1`,children:[(0,A.jsxs)(`summary`,{className:`cursor-pointer text-body-sm text-muted`,children:[`Output (`,D(e.lines.length,`line`),`)`]}),(0,A.jsx)(`pre`,{className:i(`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-1 max-h-[240px]`),children:(0,A.jsx)(l,{text:e.lines.join(`
2
- `)})})]})]}),(0,A.jsx)(`td`,{className:S,"data-sort":P[e.status],children:(0,A.jsx)(be,{status:e.status})}),(0,A.jsx)(`td`,{className:i(y,`hidden text-muted @xl:table-cell`),"data-sort":t??-1,children:t===void 0?`–`:t>=60?`${(t/60).toFixed(1)}m`:`${t}s`})]},e.id)})}),(0,A.jsx)(`code`,{className:`font-mono text-body-sm text-muted [overflow-wrap:anywhere]`,children:e.runs[0]?.command})]})}function I(){let[e,t]=(0,O.useState)(null),[a,s]=(0,O.useState)(``),[l,f]=(0,O.useState)(``),[m,h]=(0,O.useState)(null),[g,v]=(0,O.useState)(``),[y,b]=(0,O.useState)(!1),[S,C]=(0,O.useState)(``),[E,N]=(0,O.useState)(`local`),[P,be]=(0,O.useState)(`pairwise`),[F,I]=(0,O.useState)({}),[L,R]=(0,O.useState)(null),[Se,z]=(0,O.useState)(``),[Ce,B]=(0,O.useState)(!1),[V,H]=(0,O.useState)(!1),[U,W]=(0,O.useState)(``),[G,K]=(0,O.useState)(null),q=(0,O.useCallback)(()=>{k.view().then(e=>{t(e),K(e.job),s(``),f(t=>t||e.environments.find(e=>e.flags&&!e.production)?.name||e.environments.find(e=>e.flags)?.name||``),C(t=>t||e.packs[0]?.name||``)},e=>s(e.message))},[]);(0,O.useEffect)(q,[q]);let J=(0,O.useCallback)((e,t=!1)=>{e&&(b(!0),k.catalog(e,t).then(e=>{h(e),v(``),b(!1)},e=>{h(null),v(e.message),b(!1)}))},[]);(0,O.useEffect)(()=>{I({}),R(null),B(!1),J(l)},[l,J]),(0,O.useEffect)(()=>{if(!G?.running)return;let e=de(()=>{k.job().then(K,()=>{})},1500);return()=>ue(e)},[G?.running]);let Y=(0,O.useMemo)(()=>Object.entries(F).filter(([,e])=>e.length).map(([e,t])=>({flag:e,values:t})),[F]),X=e?.environments.find(e=>e.name===l);(0,O.useEffect)(()=>{if(B(!1),!l||!Y.length||X?.production){R(null),z(``);return}let e=!0,t=setTimeout(()=>{k.preview({environment:l,picks:Y,mode:P,on:E,...S?{pack:S}:{}}).then(t=>{e&&(R(t),z(``))},t=>{e&&(R(null),z(t.message))})},250);return()=>{e=!1,clearTimeout(t)}},[l,Y,P,E,S,X?.production]);let we=e?.maxValues??10,Te=(e,t,n)=>{let r={...F};n?r[e]=t.slice(0,we):delete r[e],I(r)},Ee=async()=>{if(L&&S){H(!0);try{let e=await k.run({environment:l,picks:Y,mode:P,pack:S,on:E});K(e),B(!1),W(`${D(e.runs.length,`run`)} of ${S} started, ${e.parallel} at once.`)}catch(e){W(e.message)}finally{H(!1)}}},De=async()=>{H(!0);try{K(await k.stop())}catch(e){W(e.message)}finally{H(!1)}},Z=m?.flags??[],Oe=e?.cap??32,Q=e?.environments.filter(e=>e.flags)??[],ke=m?.sources.filter(e=>e.ok).length??0,$=Y.map(e=>e.flag);return(0,A.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,A.jsx)(fe,{}),(0,A.jsxs)(`main`,{className:i(pe,`@container flex-auto gap-4`),children:[(0,A.jsx)(ie,{}),(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,A.jsx)(me,{pixel:o.flags,size:`lg`}),(0,A.jsx)(`h1`,{className:`m-0 text-headline-lg`,children:he(`flags`)})]}),(0,A.jsx)(_e,{more:(0,A.jsxs)(A.Fragment,{children:[`Pick feature flags of a test environment and the values to try, and a `,(0,A.jsx)(`a`,{href:n(`regression`),children:`regression pack`}),` runs once per combination. Flags come from the environment's `,(0,A.jsx)(`code`,{className:`font-mono text-body-sm`,children:`flags:`}),` in env.yaml (a `,(0,A.jsx)(`code`,{className:`font-mono text-body-sm`,children:`list:`}),` of flags and their values) and from LaunchDarkly (`,(0,A.jsx)(`code`,{className:`font-mono text-body-sm`,children:`project`}),`, `,(0,A.jsx)(`code`,{className:`font-mono text-body-sm`,children:`environment`}),`, `,(0,A.jsx)(`code`,{className:`font-mono text-body-sm`,children:`token_env`}),`) and Unleash (`,(0,A.jsx)(`code`,{className:`font-mono text-body-sm`,children:`url`}),`, `,(0,A.jsx)(`code`,{className:`font-mono text-body-sm`,children:`token_env`}),`), read only: nothing is changed there, and the tokens stay in Settings › Secrets. Each run gets its values as `,(0,A.jsx)(`code`,{className:`font-mono text-body-sm`,children:`FORGEQE_FLAG_<KEY>`}),` and `,(0,A.jsx)(`code`,{className:`font-mono text-body-sm`,children:`FORGEQE_FLAGS`}),`, for the tests to apply as a cookie, header, query parameter or localStorage key. Environments named like production never run.`]}),children:`Run your regression tests once for each combination of feature flags, side by side.`}),a&&(0,A.jsx)(`p`,{role:`alert`,className:i(c.fail,`m-0`),children:a}),!e&&!a&&(0,A.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Loading…`}),e&&!Q.length&&(0,A.jsxs)(te,{page:!0,icon:se,title:`No environment lists flags yet`,action:(0,A.jsxs)(`a`,{className:ee({size:`sm`}),href:n(`settings`,`environments`),"data-tip":`Open Environments in Settings`,children:[(0,A.jsx)(ce,{"aria-hidden":`true`}),`Environments`]}),children:[`Give a test environment its feature flags and the values to try, or connect it to LaunchDarkly or Unleash. In env.yaml that is the environment's `,(0,A.jsx)(`code`,{className:`font-mono text-body-sm`,children:`flags:`}),`; How it works above has the keys.`]}),e&&Q.length>0&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-end gap-4`,children:[(0,A.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm font-medium`,children:[`Environment`,(0,A.jsx)(r,{size:`sm`,value:l,onChange:e=>f(e.target.value),children:Q.map(e=>(0,A.jsxs)(`option`,{value:e.name,children:[e.name,e.production?` (production: read only)`:``]},e.name))})]}),(0,A.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm font-medium`,children:[`Regression pack`,(0,A.jsxs)(r,{size:`sm`,value:S,onChange:e=>C(e.target.value),disabled:!e.packs.length,children:[!e.packs.length&&(0,A.jsx)(`option`,{value:``,children:`No packs yet`}),e.packs.map(e=>(0,A.jsxs)(`option`,{value:e.name,children:[e.name,` (`,D(e.tests,`test`),`)`]},e.name))]})]}),(0,A.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm font-medium`,children:[`Browsers`,(0,A.jsxs)(r,{size:`sm`,value:E,onChange:e=>N(e.target.value===`testmu`?`testmu`:`local`),children:[(0,A.jsx)(`option`,{value:`local`,children:`This machine`}),(0,A.jsx)(`option`,{value:`testmu`,children:`TestMu AI`})]})]}),(0,A.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,A.jsx)(`span`,{className:`text-body-sm font-medium`,children:`Combine`}),(0,A.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,A.jsx)(ne,{items:[{id:`pairwise`,label:`Pairwise`},{id:`all`,label:`Every combination`}],value:P,onChange:be})})]}),(0,A.jsxs)(u,{size:`sm`,variant:`ghost`,disabled:y||!l,onClick:()=>J(l,!0),"data-tip":`Read the flags from LaunchDarkly and Unleash again`,children:[(0,A.jsx)(le,{"aria-hidden":`true`}),`Refresh`]})]}),X?.production&&(0,A.jsxs)(`p`,{role:`status`,className:i(c.warn,`m-0`),children:[X.name,` is named like production: its flags are shown, but no combination runs there.`]}),!e.packs.length&&(0,A.jsxs)(`p`,{className:`m-0 text-body-sm text-ink-2`,children:[`No regression pack yet: build one on `,(0,A.jsx)(`a`,{href:n(`regression`),children:`Regression`}),` to run the combinations.`]}),(0,A.jsxs)(ve,{label:`Flags and combinations`,children:[(0,A.jsx)(T,{dot:`neutral`,value:Z.length,label:m?`flags from ${D(m.sources.length,`source`)}`:y?`flags, reading…`:`flags`}),(0,A.jsx)(T,{tip:m?`Read ${w(m.fetchedAt)}`:void 0,dot:m&&ke<m.sources.length?`warn`:m?`pass`:`neutral`,value:m?`${ke} of ${m.sources.length}`:`–`,label:`sources read`}),(0,A.jsx)(T,{dot:`neutral`,value:Y.length,label:Y.length?`picked, ${D(Y.reduce((e,t)=>e+t.values.length,0),`value`)}`:`picked`}),(0,A.jsx)(T,{tip:L?`At most ${Oe}${L.mode===`pairwise`?`; ${L.allCount} for every one`:``}`:`At most ${Oe}`,dot:L?.over?`fail`:`neutral`,value:L?L.count:`–`,label:`combinations`}),(0,A.jsx)(T,{tip:`As devices run (suite.parallel)`,dot:`neutral`,value:L&&!L.over?L.parallel:`–`,label:`at once`})]}),g&&(0,A.jsx)(`p`,{role:`alert`,className:i(c.fail,`m-0`),children:g}),m&&m.sources.length>0&&(0,A.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0 text-body-sm`,children:m.sources.map(e=>(0,A.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2`,children:[e.ok?(0,A.jsx)(d,{size:15,"aria-label":`Read`,className:`text-pass`}):(0,A.jsx)(_,{size:15,"aria-label":`Not read`,className:`text-fail`}),(0,A.jsx)(`span`,{className:`font-medium`,children:M[e.source]}),(0,A.jsx)(`span`,{className:`font-mono text-body-sm text-muted`,children:e.where}),(0,A.jsx)(`span`,{className:`text-ink-2`,children:e.ok?`${D(e.flags,`flag`)}${e.skipped?`, ${e.skipped} left out (not a plain shape)`:``}`:e.error})]},e.source))}),m&&m.problems.length>0&&(0,A.jsxs)(`details`,{className:`text-body-sm`,children:[(0,A.jsxs)(`summary`,{className:`cursor-pointer text-warn`,children:[D(m.problems.length,`problem`),` in env.yaml's flags`]}),(0,A.jsx)(`ul`,{className:`m-0 mt-1 flex flex-col gap-1 pl-6 text-ink-2`,children:m.problems.map((e,t)=>(0,A.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:e},t))})]}),m&&(0,A.jsx)(x,{label:`Flags`,placeholder:`Find a flag`,resetKey:m.environment,empty:y?`Reading…`:`No flags listed for this environment.`,selection:{count:Z.filter(e=>F[e.key]).length,onClear:()=>I({})},head:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`th`,{scope:`col`,className:i(`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,`w-8`),children:(0,A.jsx)(`span`,{className:`sr-only`,children:`Pick`})}),(0,A.jsx)(`th`,{scope:`col`,className:i(`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,`w-[26%]`),children:`Flag`}),(0,A.jsx)(`th`,{scope:`col`,className:i(`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,`hidden @xl:table-cell`),children:`Source`}),(0,A.jsx)(`th`,{scope:`col`,className:i(`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,`hidden @2xl:table-cell`),children:`Now`}),(0,A.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,children:`Values to try`}),(0,A.jsx)(`th`,{scope:`col`,className:i(`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,`hidden @3xl:table-cell`),children:`Delivered as`})]}),children:Z.map(t=>{let n=F[t.key];return(0,A.jsxs)(`tr`,{className:`h-12 border-t border-line-soft align-middle transition-colors duration-150 data-[state=selected]:bg-tint-hover`,"data-state":n?`selected`:void 0,children:[(0,A.jsx)(`td`,{className:`px-4 py-2`,children:(0,A.jsx)(ge,{"aria-label":`Pick ${t.key}`,checked:!!n,disabled:!n&&Y.length>=(e.maxFlags??12),onCheckedChange:e=>Te(t.key,t.values,e)})}),(0,A.jsx)(`td`,{className:i(`px-4 py-2`,`max-w-0`),children:(0,A.jsx)(`span`,{className:`block truncate font-mono text-body-sm`,"data-tip":t.title?`${t.key} · ${t.title}`:t.key,children:t.key})}),(0,A.jsx)(`td`,{className:i(`px-4 py-2`,`hidden text-body-sm whitespace-nowrap @xl:table-cell`),children:M[t.source]}),(0,A.jsx)(`td`,{className:i(`px-4 py-2`,`hidden font-mono text-body-sm text-muted @2xl:table-cell`),children:t.current??`–`}),(0,A.jsx)(`td`,{className:`px-4 py-2`,children:n?(0,A.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,A.jsx)(re,{items:t.values.map(e=>({id:e,label:e})),value:n,onChange:e=>I({...F,[t.key]:e.slice(0,we)})})}):(0,A.jsx)(`span`,{className:`block truncate font-mono text-body-sm text-muted`,"data-tip":t.values.join(`, `),children:t.values.join(`, `)})}),(0,A.jsxs)(`td`,{className:i(`px-4 py-2`,`hidden text-body-sm whitespace-nowrap @3xl:table-cell`),children:[j[t.via],` `,(0,A.jsx)(`span`,{className:`font-mono text-muted`,children:t.deliverAs})]})]},t.key)})}),Se&&(0,A.jsx)(`p`,{role:`alert`,className:i(c.fail,`m-0`),children:Se}),L?.over&&(0,A.jsxs)(`p`,{role:`alert`,className:i(c.fail,`m-0`),children:[L.count,` combinations: at most `,L.cap,` run. Pick fewer flags or values`,L.mode===`all`?`, or combine pairwise`:``,`.`]}),L&&!L.over&&L.runs.length>0&&(0,A.jsxs)(ye,{icon:ae,title:`What each run would get`,actions:Ce?(0,A.jsxs)(`div`,{className:i(c.info,`flex flex-wrap items-center gap-2`),children:[(0,A.jsxs)(`span`,{children:[`Run `,S,` `,D(L.runs.length,`time`),` on `,L.environment,`, `,L.parallel,` at once?`]}),(0,A.jsxs)(u,{size:`sm`,variant:`primary`,disabled:V,onClick:()=>void Ee(),children:[(0,A.jsx)(p,{"aria-hidden":`true`}),`Run`]}),(0,A.jsxs)(u,{size:`sm`,variant:`ghost`,disabled:V,onClick:()=>B(!1),children:[(0,A.jsx)(oe,{"aria-hidden":`true`}),`Cancel`]})]}):(0,A.jsxs)(u,{size:`sm`,disabled:!S||!!G?.running||V,onClick:()=>B(!0),"data-tip":G?.running?`A matrix is running: wait for it, or stop it`:S?`Run ${D(L.runs.length,`combination`)}`:`Pick a regression pack`,children:[(0,A.jsx)(p,{"aria-hidden":`true`}),`Run (`,L.runs.length,`)`]}),children:[(0,A.jsx)(x,{label:`Combinations`,placeholder:`Find a combination`,resetKey:`${L.mode}-${L.count}-${$.join(`,`)}`,empty:`No combinations.`,head:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`th`,{scope:`col`,className:i(`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,`w-[64px]`),children:`Run`}),$.map(e=>(0,A.jsx)(`th`,{scope:`col`,className:i(`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,`max-w-[160px] truncate`),"data-tip":e,children:e},e))]}),children:L.runs.map(e=>(0,A.jsxs)(`tr`,{className:`h-12 border-t border-line-soft align-middle transition-colors duration-150 data-[state=selected]:bg-tint-hover`,children:[(0,A.jsx)(`td`,{className:i(`px-4 py-2`,`font-mono text-body-sm`),children:e.id}),$.map(t=>{let n=e.deliver.find(e=>e.flag===t);return(0,A.jsx)(`td`,{className:i(`px-4 py-2`,`font-mono text-body-sm`),"data-tip":n?`${j[n.via]} ${n.name}=${n.value} · FORGEQE_FLAG_ variable`:void 0,children:e.values[t]},t)})]},e.id))}),L.pack&&(0,A.jsx)(`code`,{className:`font-mono text-body-sm text-muted [overflow-wrap:anywhere]`,children:L.commands[L.runs[0].id]})]}),U&&(0,A.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-ink-2`,children:U})]}),G&&(0,A.jsx)(xe,{job:G,busy:V,onStop:()=>void De()})]})]})}export{I as Flags};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./react-BDur5s0O.js";import{r as n}from"./route-oDy8sV6H.js";import{F as r}from"./preload-helper-BupTYkQW.js";import{t as i}from"./utils-DJRAScIl.js";import{t as a}from"./jsx-runtime-LKYXHABd.js";import{L as o}from"./palette-CeG8IIbL.js";import{M as s,W as c}from"./api-D_HT-I9y.js";import{C as l,S as u,_ as d,f,n as ee,s as p,x as m}from"./pageBack-DwhsvsK7.js";import{Hn as h,Lr as te,N as g,Rr as ne,Sr as _,er as v,o as y,z as b}from"./line-icons-CwCZidXs.js";import{_t as x,lt as S,s as re,t as ie,zt as ae}from"./frame-Dt9QcYNX.js";import{H as C,J as w,R as T,U as E,V as D}from"./index-BdWLAq_n.js";var O=e(t(),1),k=a(),A={timing:`Timing`,locator:`Locator`,overlay:`Overlay`,data:`Data`,network:`Network`,environment:`Environment`,unknown:`No pattern`};function j(e,t,n){return e.filter(e=>(t===`all`||t===`flaky`&&(e.flaky||e.quarantined)||t===`quarantined`&&e.quarantined||t===`release`&&e.releasable)&&(n===`all`||e.cause===n))}var M=e=>e>=60?`${(e/60).toFixed(1)}m`:`${e.toFixed(+(e<10))}s`,N={"✓":`passed`,"✗":`failed`,"↻":`passed on retry`,"–":`skipped`};function P({trail:e}){return(0,k.jsx)(p,{label:`Last results, oldest first: ${[...e].map(e=>N[e]??`unknown`).join(`, `)}`,runs:[...e].map(e=>({tone:e===`✓`?`pass`:e===`✗`?`fail`:e===`↻`?`warn`:`muted`,title:N[e]??`unknown`}))})}function F(){let[e,t]=(0,O.useState)(null),[a,p]=(0,O.useState)(``),[N,F]=(0,O.useState)(`flaky`),[I,L]=(0,O.useState)(`all`),[R,z]=(0,O.useState)(new Set),[B,V]=(0,O.useState)(null),[H,U]=(0,O.useState)(``),[W,G]=(0,O.useState)(!1),[K,q]=(0,O.useState)(``),J=(0,O.useCallback)(()=>{s.view().then(e=>{t(e),p(``)},e=>p(e.message))},[]);(0,O.useEffect)(J,[J]);let Y=e?.tests??[],oe=j(Y,N,I),X=Y.filter(e=>e.flaky&&!e.quarantined).length,se=Y.filter(e=>e.quarantined).length,ce=Y.filter(e=>e.releasable).length,Z=Object.keys(A).filter(t=>e?.causes[t]),Q=Z.sort((t,n)=>(e.causes[n]??0)-(e.causes[t]??0))[0],$=Y.filter(e=>R.has(e.name)),le=$.some(e=>!e.quarantined),ue=$.some(e=>e.quarantined),de=(e,t)=>{let n=new Set(R);t?n.add(e):n.delete(e),z(n)},fe=async()=>{if(!B)return;let e=B===`release`,n=$.filter(t=>e?t.quarantined:!t.quarantined).map(e=>e.name);G(!0);try{t(await s.quarantine(n,e,H.trim()||void 0)),q(`${n.length} test${n.length===1?``:`s`} ${e?`released from`:`put in`} quarantine.`),z(new Set),V(null),U(``)}catch(e){q(e.message)}finally{G(!1)}},pe=async e=>{let t=e.healIn[0];if(t){G(!0);try{await c.heal(t,[e.name]),location.hash=n(`regression`,encodeURIComponent(t))}catch(e){q(e.message),G(!1)}}};return(0,k.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,k.jsx)(re,{}),(0,k.jsxs)(`main`,{className:i(ie,`@container flex-auto gap-4`),children:[(0,k.jsx)(ee,{}),(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2`,children:[(0,k.jsxs)(`span`,{className:`flex items-center gap-4`,children:[(0,k.jsx)(ae,{pixel:o.flaky,size:`lg`}),(0,k.jsx)(`h1`,{className:`m-0 text-headline-lg`,children:`Runs and reports`})]}),(0,k.jsx)(S,{label:`Runs and reports`,links:T,current:`flaky`})]}),(0,k.jsx)(E,{more:(0,k.jsxs)(k.Fragment,{children:[`Each automated test of `,e?.repo&&e.repo!==`.`?(0,k.jsx)(`code`,{className:`font-mono text-body-sm`,children:e.repo}):`the test repository`,` is scored from its last 20 results: flips between passing and failing, passes on a retry, and how much its run time varies. A test counts as flaky from a score of `,e?.flakyAfter??2,` (flaky.flaky_after). A test is ready to release from quarantine after 5 clean runs in a row. Quarantine changes no test code: the test still runs, but its failure does not fail the run. Heal sends a test the last `,(0,k.jsx)(`a`,{href:n(`regression`),children:`Regression`}),` run sent to healing. Results are kept in .forgeqe/test-history.json.`]}),children:`Tests that pass one run and fail the next, why, and what to do with each.`}),a&&(0,k.jsx)(`p`,{role:`alert`,className:i(l.fail,`m-0`),children:a}),!e&&!a&&(0,k.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Loading…`}),e&&!Y.length&&(0,k.jsx)(d,{page:!0,icon:_,title:`No test history yet`,action:(0,k.jsxs)(`a`,{className:u({size:`sm`}),href:n(`regression`),"data-tip":`Open Regression`,children:[(0,k.jsx)(y,{"aria-hidden":`true`}),`Regression`]}),children:`Run a regression pack, or ask in a chat to run the tests, and each test's history shows here. ForgeQE keeps it in .forgeqe/test-history.json.`}),e&&Y.length>0&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(D,{label:`Tests by state`,children:[(0,k.jsx)(C,{dot:`neutral`,value:Y.length,label:`tracked`,onClick:()=>F(`all`),on:N===`all`}),(0,k.jsx)(C,{dot:`warn`,value:X,label:`flaky`,onClick:()=>F(`flaky`),on:N===`flaky`}),(0,k.jsx)(C,{dot:`neutral`,value:se,label:`in quarantine`,onClick:()=>F(`quarantined`),on:N===`quarantined`}),(0,k.jsx)(C,{dot:`pass`,value:ce,label:`ready to release`,onClick:()=>F(`release`),on:N===`release`}),Q&&(0,k.jsx)(C,{dot:`neutral`,value:A[Q],label:`most common cause (${e.causes[Q]} test${e.causes[Q]===1?``:`s`})`})]}),Z.length>0&&(0,k.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,k.jsx)(`span`,{className:`text-body-sm font-medium`,children:`Likely cause`}),(0,k.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,k.jsx)(f,{items:[{id:`all`,label:`All causes`},...Z.map(t=>({id:t,label:A[t],n:e.causes[t]}))],value:I,onChange:L})}),I!==`all`&&(0,k.jsx)(`p`,{className:`m-0 text-body-sm text-ink-2`,children:e.causeText[I]})]}),K&&(0,k.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-ink-2`,children:K}),(0,k.jsx)(x,{label:`Tests`,placeholder:`Find a test by name`,resetKey:`${N}-${I}`,empty:`Nothing matches.`,height:`max(320px, calc(var(--screen) - 288px))`,selection:{count:$.length,onClear:()=>{z(new Set),V(null)},actions:B?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`span`,{className:`text-body-sm`,children:[B===`release`?`Release`:`Quarantine`,` `,$.filter(e=>B===`release`?e.quarantined:!e.quarantined).length,` test(s)?`]}),B===`quarantine`&&(0,k.jsx)(r,{size:`sm`,"aria-label":`Reason`,placeholder:`Reason (optional)`,value:H,maxLength:200,onChange:e=>U(e.target.value),className:`w-full max-w-[320px] flex-[0_1_320px]`}),(0,k.jsxs)(m,{size:`sm`,disabled:W,onClick:()=>void fe(),children:[B===`release`?(0,k.jsx)(h,{"aria-hidden":`true`}):(0,k.jsx)(v,{"aria-hidden":`true`}),B===`release`?`Release`:`Quarantine`]}),(0,k.jsxs)(m,{size:`sm`,variant:`ghost`,disabled:W,onClick:()=>V(null),children:[(0,k.jsx)(ne,{"aria-hidden":`true`}),`Cancel`]})]}):(0,k.jsxs)(k.Fragment,{children:[le&&(0,k.jsxs)(m,{size:`sm`,onClick:()=>V(`quarantine`),children:[(0,k.jsx)(v,{"aria-hidden":`true`}),`Quarantine`]}),ue&&(0,k.jsxs)(m,{size:`sm`,onClick:()=>V(`release`),"data-tip":`Release from quarantine`,children:[(0,k.jsx)(h,{"aria-hidden":`true`}),`Release`]})]})},tools:(0,k.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,k.jsx)(f,{items:[{id:`flaky`,label:`Flaky`,n:j(Y,`flaky`,I).length,alert:!0},{id:`quarantined`,label:`In quarantine`,n:j(Y,`quarantined`,I).length},{id:`release`,label:`Ready to release`,n:j(Y,`release`,I).length},{id:`all`,label:`All`,n:j(Y,`all`,I).length}],value:N,onChange:F})}),head:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`th`,{scope:`col`,className:i(`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,`w-8`),children:(0,k.jsx)(`span`,{className:`sr-only`,children:`Pick`})}),(0,k.jsx)(`th`,{scope:`col`,className:i(`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,`w-[38%]`),children:`Test`}),(0,k.jsx)(`th`,{scope:`col`,className:i(`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,`hidden @xl:table-cell`),children:`Last results`}),(0,k.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-right text-label-md font-medium whitespace-nowrap text-muted`,children:`Passed`}),(0,k.jsx)(`th`,{scope:`col`,className:i(`px-4 py-2 text-right text-label-md font-medium whitespace-nowrap text-muted`,`hidden @2xl:table-cell`),children:`Flips`}),(0,k.jsx)(`th`,{scope:`col`,className:i(`px-4 py-2 text-right text-label-md font-medium whitespace-nowrap text-muted`,`hidden @2xl:table-cell`),children:`Retry passes`}),(0,k.jsx)(`th`,{scope:`col`,className:i(`px-4 py-2 text-right text-label-md font-medium whitespace-nowrap text-muted`,`hidden @3xl:table-cell`),children:`Run time`}),(0,k.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,children:`Cause`}),(0,k.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,children:(0,k.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]}),children:oe.map(t=>{let n=t.quarantined?v:t.flaky?_:t.passRate===1?g:b,r=t.quarantined?t.releasable?`In quarantine, ready to release`:`In quarantine`:t.flaky?`Flaky`:t.passRate===1?`Steady`:`Failing`;return(0,k.jsxs)(`tr`,{className:`h-12 border-t border-line-soft align-middle transition-colors duration-150 data-[state=selected]:bg-tint-hover`,"data-state":R.has(t.name)?`selected`:void 0,children:[(0,k.jsx)(`td`,{className:`px-4 py-2`,children:(0,k.jsx)(w,{"aria-label":`Pick ${t.name}`,checked:R.has(t.name),onCheckedChange:e=>de(t.name,e)})}),(0,k.jsx)(`td`,{className:i(`px-4 py-2`,`max-w-0`),children:(0,k.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(n,{size:15,"aria-label":r,className:i(`flex-none`,t.quarantined?`text-muted`:t.flaky?`text-warn`:t.passRate===1?`text-pass`:`text-fail`)}),(0,k.jsx)(`span`,{"data-tip":t.quarantined?`${t.name} · quarantined: ${t.quarantined.reason}`:t.name,className:`truncate`,children:t.name})]})}),(0,k.jsx)(`td`,{className:i(`px-4 py-2`,`hidden @xl:table-cell`),"data-sort":t.trail.length?[...t.trail].filter(e=>e===`✓`).length/[...t.trail].length:-1,children:(0,k.jsx)(P,{trail:t.trail})}),(0,k.jsxs)(`td`,{className:i(`px-4 py-2 text-right whitespace-nowrap tabular-nums`,t.passRate<.8?`text-fail`:`text-muted`),children:[Math.round(t.passRate*100),`%`]}),(0,k.jsx)(`td`,{className:i(`px-4 py-2 text-right whitespace-nowrap tabular-nums`,`hidden @2xl:table-cell`,t.flips?`text-warn`:`text-muted`),children:t.flips}),(0,k.jsx)(`td`,{className:i(`px-4 py-2 text-right whitespace-nowrap tabular-nums`,`hidden @2xl:table-cell`,t.retryPasses?`text-warn`:`text-muted`),children:t.retryPasses}),(0,k.jsx)(`td`,{className:i(`px-4 py-2 text-right whitespace-nowrap tabular-nums`,`hidden @3xl:table-cell`,t.timing&&t.timing.spread>1?`text-warn`:`text-muted`),"data-sort":t.timing?t.timing.median:-1,"data-tip":t.timing?`fastest ${M(t.timing.min)}, slowest ${M(t.timing.max)}`:void 0,children:t.timing?`${M(t.timing.median)} ±${Math.round(t.timing.spread*50)}%`:`–`}),(0,k.jsx)(`td`,{className:i(`px-4 py-2`,`whitespace-nowrap text-body-sm`),"data-tip":t.example?`${e.causeText[t.cause]} · e.g. ${t.example}`:e.causeText[t.cause],children:t.flaky||t.quarantined||t.passRate<1?A[t.cause]:`–`}),(0,k.jsx)(`td`,{className:`px-4 py-2 text-right whitespace-nowrap tabular-nums`,children:t.healIn.length>0&&(0,k.jsx)(m,{variant:`icon`,size:`icon-sm`,disabled:W,onClick:()=>void pe(t),"aria-label":`Heal ${t.name} with forgeqe pack heal in pack ${t.healIn[0]}`,"data-tip":`Heal ${t.name} with forgeqe pack heal in pack ${t.healIn[0]}`,children:(0,k.jsx)(te,{"aria-hidden":`true`})})})]},t.name)})})]})]})]})}export{A as CAUSE_LABEL,F as Flaky,j as shown};