@capagents/forgeqe 2.9.8 → 2.9.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 (106) hide show
  1. package/HOW_TO_USE.md +90 -33
  2. package/dist/docs-site/docs/index.html +53 -4
  3. package/dist/docs-site/docs/search.js +1 -1
  4. package/dist/forgeqe.js +1982 -1891
  5. package/dist/web/assets/Agent-B0R4tnqF.js +8 -0
  6. package/dist/web/assets/ApiTests-CqWPHWCs.js +10 -0
  7. package/dist/web/assets/Browse-DlbTQPA8.js +2 -0
  8. package/dist/web/assets/{Chat-DSlBwNAI.js → Chat-DtI3dgGs.js} +3 -3
  9. package/dist/web/assets/CommandPalette-BTI3Q3sc.js +1 -0
  10. package/dist/web/assets/{Compare-BI8IMq49.js → Compare-BMcHYq3I.js} +1 -1
  11. package/dist/web/assets/Cost-BcZ6gC9M.js +1 -0
  12. package/dist/web/assets/{Data-CjnqjcAx.js → Data-Cbl35RTK.js} +4 -4
  13. package/dist/web/assets/Desktop-D4JLSUnE.js +1 -0
  14. package/dist/web/assets/DesktopReview-vyosGOyC.js +1 -0
  15. package/dist/web/assets/Evidence-MDaV4ttv.js +1 -0
  16. package/dist/web/assets/{Explore-Cc-1cTwG.js → Explore-yjmJHnzH.js} +2 -2
  17. package/dist/web/assets/Features-kXt6Um2p.js +1 -0
  18. package/dist/web/assets/{Flags-CICcBCkH.js → Flags-CdLXiacX.js} +2 -2
  19. package/dist/web/assets/Flaky-BZx54uo3.js +1 -0
  20. package/dist/web/assets/Impact-_t7bwCwP.js +3 -0
  21. package/dist/web/assets/Jobs-D4PIAcdO.js +5 -0
  22. package/dist/web/assets/KindPage-CGfjoezZ.js +6 -0
  23. package/dist/web/assets/Migration-OGOnRmUX.js +2 -0
  24. package/dist/web/assets/Product-DycPE2MI.js +7 -0
  25. package/dist/web/assets/Production-DqnrcSfn.js +1 -0
  26. package/dist/web/assets/Quality-C__pEYpt.js +1 -0
  27. package/dist/web/assets/Readiness-j22NEcwR.js +1 -0
  28. package/dist/web/assets/Record-D7h6g_aw.js +2 -0
  29. package/dist/web/assets/Regression-ByBOHx96.js +5 -0
  30. package/dist/web/assets/RelationGraph-D_ZVeOBh.js +1 -0
  31. package/dist/web/assets/Reports-BGs_YnwI.js +2 -0
  32. package/dist/web/assets/{Response-CaWPiZyx.js → Response-DWF22-5i.js} +2 -2
  33. package/dist/web/assets/{RunDiff-BQKwTCbM.js → RunDiff-YxrBVtxF.js} +1 -1
  34. package/dist/web/assets/Runs-CP3CgO6s.js +2 -0
  35. package/dist/web/assets/Steps-BDSeIznj.js +2 -0
  36. package/dist/web/assets/TestCases-BzuM4M4t.js +1 -0
  37. package/dist/web/assets/TestData-CRmYpEgE.js +2 -0
  38. package/dist/web/assets/TestDebt-D3I2zyGE.js +1 -0
  39. package/dist/web/assets/Tosca-jVIQnyZv.js +3 -0
  40. package/dist/web/assets/{WhatsNew-CznfTEFM.js → WhatsNew-EKniIJ6W.js} +1 -1
  41. package/dist/web/assets/dataParts-DRO6c2Kb.js +3 -0
  42. package/dist/web/assets/{families-B0QIuAe3.js → families-zlLgApNV.js} +1 -1
  43. package/dist/web/assets/filters-CflRmNDz.js +1 -0
  44. package/dist/web/assets/flowLayout-cXVJhLpH.js +1 -0
  45. package/dist/web/assets/{fold-HnodvJWj.js → fold-D9yUIbTt.js} +1 -1
  46. package/dist/web/assets/frame--ur6lpMR.js +4 -0
  47. package/dist/web/assets/index-DwUumNPZ.css +2 -0
  48. package/dist/web/assets/index-GLMqsotN.js +66 -0
  49. package/dist/web/assets/{logos-CNarWSPL.js → logos-CdIbTq_J.js} +1 -1
  50. package/dist/web/assets/markdown-nTIj9lyp.js +10 -0
  51. package/dist/web/assets/{palette-B2YywN1k.js → palette-D5_w8xup.js} +1 -1
  52. package/dist/web/assets/{parts-z_AE9U-M.js → parts-C53RxMcR.js} +1 -1
  53. package/dist/web/assets/{productParts-C4vc_bLJ.js → productParts-DK3ULNpv.js} +1 -1
  54. package/dist/web/assets/qualityParts-BPBFzuHH.js +1 -0
  55. package/dist/web/assets/{recordTest-GvGQjhR4.js → recordTest-CqxnF953.js} +1 -1
  56. package/dist/web/assets/{rows-7zDrF-Yp.js → rows-BVHC-HKz.js} +1 -1
  57. package/dist/web/assets/{segmented-DANusepM.js → segmented-CAf_qz5Z.js} +1 -1
  58. package/dist/web/assets/{thread-BUBgX0xW.js → thread-B4g66SWA.js} +2 -2
  59. package/dist/web/assets/{usePageChat-DnOXyd_B.js → usePageChat-BU6VEv0K.js} +1 -1
  60. package/dist/web/index.html +5 -4
  61. package/docs/BUSINESS_ASSURANCE.md +105 -0
  62. package/docs/user-guide.html +53 -4
  63. package/package.json +1 -1
  64. package/prompts/README.md +3 -0
  65. package/prompts/brain.md +11 -0
  66. package/prompts/business-interview.md +43 -0
  67. package/prompts/business-persona.md +3 -1
  68. package/prompts/business-strategist.md +44 -0
  69. package/prompts/persona-own.md +47 -0
  70. package/py/forgeqe_engine/cli.py +5 -0
  71. package/py/forgeqe_engine/recordsession.py +134 -9
  72. package/py/forgeqe_engine/webrecord_page.py +18 -9
  73. package/dist/web/assets/Agent-D0jovbz1.js +0 -6
  74. package/dist/web/assets/ApiTests-CMMMApBR.js +0 -10
  75. package/dist/web/assets/Browse-Bimy9-t0.js +0 -2
  76. package/dist/web/assets/CommandPalette-D7NWAtOU.js +0 -1
  77. package/dist/web/assets/Cost-BV0JavsG.js +0 -1
  78. package/dist/web/assets/Desktop-Bu72INy4.js +0 -1
  79. package/dist/web/assets/DesktopReview-jDnb5Gfn.js +0 -1
  80. package/dist/web/assets/Evidence-CIlcAy5n.js +0 -1
  81. package/dist/web/assets/Features-CewFSOSI.js +0 -1
  82. package/dist/web/assets/Flaky-BrWbRajc.js +0 -1
  83. package/dist/web/assets/ForceGraph-BLYMwmyj.js +0 -1
  84. package/dist/web/assets/Impact-D7seby-G.js +0 -3
  85. package/dist/web/assets/Jobs-D7yPretO.js +0 -5
  86. package/dist/web/assets/KindPage-Cjt1s7Vd.js +0 -6
  87. package/dist/web/assets/Migration-CbCqOsJI.js +0 -2
  88. package/dist/web/assets/Product-CxXVrpoD.js +0 -7
  89. package/dist/web/assets/Production-D5jIe328.js +0 -1
  90. package/dist/web/assets/Quality-D3G8IKLZ.js +0 -1
  91. package/dist/web/assets/Readiness-B4Fy4Vln.js +0 -1
  92. package/dist/web/assets/Record-DLfODYjy.js +0 -2
  93. package/dist/web/assets/Regression-Daoc9Qvx.js +0 -5
  94. package/dist/web/assets/Reports-DEzDDoGF.js +0 -2
  95. package/dist/web/assets/Runs-BIUnN08h.js +0 -2
  96. package/dist/web/assets/Steps-DjR_K32c.js +0 -2
  97. package/dist/web/assets/TestCases-BZWiTLjC.js +0 -1
  98. package/dist/web/assets/TestData-D6YiouU4.js +0 -2
  99. package/dist/web/assets/TestDebt-COFagfQU.js +0 -1
  100. package/dist/web/assets/Tosca-B3sZ9uqe.js +0 -3
  101. package/dist/web/assets/dataParts-DpVitZdm.js +0 -3
  102. package/dist/web/assets/filters-mFECJpMB.js +0 -1
  103. package/dist/web/assets/frame-DiKY0GWx.js +0 -4
  104. package/dist/web/assets/index-HjX2EOmp.js +0 -75
  105. package/dist/web/assets/index-VgSzQGK8.css +0 -2
  106. package/dist/web/assets/qualityParts-jsPhayON.js +0 -1
@@ -1 +0,0 @@
1
- import{Ht as e,Ir as t,Nr as n,W as r,gr as i,o as a}from"./line-icons-CQ-3V8ax.js";import{B as o,V as s,f as c,l,nt as u,qt as d,t as f,z as p}from"./filters-mFECJpMB.js";import{Et as m,I as h,L as g,at as _,et as v,gt as y,it as b,nt as x,r as S,rt as C,t as w,tt as T,z as E}from"./frame-DiKY0GWx.js";import{r as D}from"./index-HjX2EOmp.js";import{_ as O,o as k}from"./qualityParts-jsPhayON.js";var A=t(n(),1),j={view:e=>u(`GET`,`/api/cost?days=${e}`)},M=d(),N=e=>e.input+e.output;function P(e,t){let n=N(e)-e.unpriced-e.otherCurrency;return[t&&n>0?`${e.estimates?`≈`:``}${g(e.amount,t)}`:``,e.unpriced?`${E(e.unpriced)} tokens with no price`:``,e.otherCurrency?`${E(e.otherCurrency)} in another currency`:``].filter(Boolean).join(`, `)||(N(e)?`no price`:`nothing`)}function F({series:e,currency:t}){let[n,r]=(0,A.useState)(-1),i=!!t&&e.some(e=>e.amount>0),a=e=>i?e.amount:N(e),s=e=>i?g(e,t):`${E(e)} tokens`,c=Math.max(Number.MIN_VALUE,...e.map(a)),l=e.reduce((e,t)=>e+a(t),0),u=e.filter(e=>e.sessions>0).length,d=e.reduce((e,t)=>a(t)>a(e)?t:e,e[0]),f=n>=0?e[n]:e[e.length-1],p=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString(void 0,{month:`short`,day:`numeric`});return(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,M.jsxs)(`p`,{"aria-live":`polite`,className:`m-0 text-[13px] text-ink-2`,children:[(0,M.jsx)(`span`,{className:`font-medium`,children:p(f.day)}),`: `,P(f,t),`, `,E(N(f)),` tokens in `,f.sessions,` session`,f.sessions===1?``:`s`]}),(0,M.jsx)(`div`,{role:`img`,"aria-label":`${i?`Spend`:`Tokens`} a day for the last ${e.length} days: ${s(l)} in all, on ${u} day${u===1?``:`s`} with sessions; the busiest was ${p(d.day)} with ${s(a(d))}.`,className:`flex h-[160px] items-end gap-[2px] border-b border-line`,onMouseLeave:()=>r(-1),children:e.map((t,i)=>{let s=a(t);return(0,M.jsx)(`div`,{className:`flex h-full flex-1 cursor-default items-end`,onMouseEnter:()=>r(i),children:(0,M.jsx)(`div`,{className:o(`w-full rounded-t-[4px] transition-[height]`,i===e.length-1||i===n?`bg-accent`:`bg-accent-line`),style:{height:s>0?`${Math.max(2,s/c*100)}%`:`0`}})},t.day)})}),(0,M.jsxs)(`div`,{"aria-hidden":`true`,className:`flex justify-between text-[12px] text-muted`,children:[(0,M.jsx)(`span`,{children:p(e[0].day)}),(0,M.jsx)(`span`,{children:p(e[e.length-1].day)})]})]})}var I=12;function L({rows:e,currency:t,label:n,empty:r}){if(!e.length)return(0,M.jsx)(l,{className:`py-4`,children:r});let i=!!t&&e.some(e=>e.amount>0),a=e=>i?e.amount:N(e),o=Math.max(Number.MIN_VALUE,...e.map(a));return(0,M.jsxs)(`ul`,{"aria-label":n,className:`m-0 flex list-none flex-col gap-3 p-0`,children:[e.slice(0,I).map(e=>(0,M.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,M.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-[13px]`,children:[(0,M.jsx)(`span`,{"data-tip":e.label,className:`min-w-0 truncate font-medium`,children:e.label}),(0,M.jsxs)(`span`,{className:`whitespace-nowrap text-ink-2 tabular-nums`,children:[E(N(e)),` tokens · `,P(e,t)]})]}),(0,M.jsx)(`div`,{"aria-hidden":`true`,className:`h-2 rounded-full bg-surface-strong`,children:(0,M.jsx)(`div`,{className:`h-2 rounded-full bg-accent transition-[width] duration-200 ease-out`,style:{width:a(e)>0?`${Math.max(1,a(e)/o*100)}%`:`0`}})})]},e.key)),e.length>I&&(0,M.jsxs)(`li`,{className:`text-[12.5px] text-muted`,children:[`and `,e.length-I,` more`]})]})}var R=[{id:`7`,label:`Last 7 days`},{id:`30`,label:`Last 30 days`},{id:`90`,label:`Last 90 days`}],z={off:`Routing is off (llm.routing): every call uses the active profile, or the model an agent names.`,shadow:`Routing is in test mode (llm.routing: shadow): picks are logged, the active profile is used.`,auto:`Routing is on (llm.routing: auto): each area gets the cheapest model rated at its bar.`};function B({id:e,title:t,children:n,note:r}){return(0,M.jsxs)(`section`,{"aria-labelledby":`${e}-h`,className:`flex min-w-0 flex-col gap-3`,children:[(0,M.jsx)(`h2`,{id:`${e}-h`,className:`m-0 text-[16px] leading-snug font-semibold`,children:t}),r&&(0,M.jsx)(`p`,{className:`m-0 max-w-[80ch] text-[13px] leading-relaxed text-ink-2`,children:r}),n]})}function V(){let[t,n]=(0,A.useState)(30),[u,d]=(0,A.useState)(null),[_,b]=(0,A.useState)(``),x=(0,A.useCallback)(()=>{b(``),j.view(t).then(d,e=>b(e.message))},[t]);(0,A.useEffect)(x,[x]);let C=u&&u.days===t?u:null,T=C?.totals,N=C?.currency,P=C?[h(N),C.ledger?.currency?`At the price of the day each call was made, this project's ${s(C.ledger.calls,`model call`)} in these days cost ${g(C.ledger.amount,C.ledger.currency)}, as the workspace panel and Tokenomics show; here they are priced at today's prices.`:``,C.totals.otherCurrency?`${E(C.totals.otherCurrency)} tokens are priced in another currency than ${N} and are left out of the amounts.`:``,C.source.skipped?`${C.source.skipped} log file${C.source.skipped===1?` was`:`s were`} skipped: a link, or not inside the logs folder.`:``,C.source.truncated?`${C.source.truncated} very long log${C.source.truncated===1?` was`:`s were`} read only in part.`:``].filter(Boolean):[];return(0,M.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,M.jsx)(S,{}),(0,M.jsxs)(`main`,{className:o(w,`@container max-w-[1320px] flex-auto gap-4`),children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,M.jsx)(m,{pixel:y.cost,size:`lg`}),(0,M.jsx)(`h1`,{className:`m-0 text-[26px] font-semibold tracking-[-0.01em]`,children:`Cost and model usage`})]}),(0,M.jsxs)(`p`,{className:`m-0 max-w-[80ch] text-[13px] leading-relaxed text-ink-2`,children:[`What this project's model calls cost, from the session logs`,C?(0,M.jsxs)(M.Fragment,{children:[` `,`in `,(0,M.jsx)(`code`,{className:`font-mono text-[12.5px]`,children:C.source.logs})]}):``,` `,`and the runs kept after them. Tokens are priced as ForgeQE prices them today: a profile's price in llms.json, else its model's list price`,C?.pricesFrom?` (list of ${C.pricesFrom})`:``,`. Tokens with no known price are counted apart, never as free. A GitHub Copilot seat is not billed per token. Each session is in the day it started.`]}),(0,M.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:(0,M.jsx)(f,{items:R,value:`${t}`,onChange:e=>n(Number(e))})}),_&&(0,M.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[10px] bg-fail-soft px-3 py-2 text-[13px] text-fail [overflow-wrap:anywhere]`,children:_}),!C&&!_&&(0,M.jsx)(`p`,{role:`status`,className:`m-0 text-[13px] text-muted`,children:`Loading…`}),C&&T&&!T.sessions&&(0,M.jsx)(l,{icon:r,title:`No model calls in the last ${t} days`,action:(0,M.jsxs)(`a`,{className:p({size:`sm`}),href:c(`runs`),"data-tip":`Open Runs`,children:[(0,M.jsx)(a,{"aria-hidden":`true`}),`Runs`]}),children:(0,M.jsx)(`span`,{className:`text-ink-2`,children:`Every ForgeQE session writes a log with the tokens its agents used. Start a chat or a run, and what it cost shows here.`})}),C&&T&&T.sessions>0&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`grid grid-cols-2 overflow-hidden border-y border-line-soft @xl:grid-cols-5 @xl:divide-x @xl:divide-line-soft`,children:[(0,M.jsx)(k,{label:`Spent`,value:N&&T.input+T.output>T.unpriced?`${T.estimates?`≈`:``}${g(T.amount,N)}`:`no price`,sub:T.estimates?`${T.estimates} session${T.estimates===1?``:`s`} estimated`:`${C.from} to ${C.to}`}),(0,M.jsx)(k,{label:`Tokens`,value:E(T.input+T.output),sub:`${E(T.cached)} of the input cached`}),(0,M.jsx)(k,{label:`No price`,value:E(T.unpriced),tone:T.unpriced?`text-warn`:void 0,sub:T.unpriced?`tokens, not in Spent`:`every token priced`}),(0,M.jsx)(k,{label:`Sessions`,value:T.sessions,sub:`with model calls`}),(0,M.jsx)(k,{label:`Per session`,value:N&&T.amount>0?g(T.amount/T.sessions,N):`–`,sub:`on average`})]}),P.length>0&&(0,M.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0 text-[12.5px] text-ink-2`,children:P.map(t=>(0,M.jsxs)(`li`,{className:`flex items-start gap-1.5`,children:[(0,M.jsx)(e,{size:14,"aria-hidden":`true`,className:`mt-0.5 flex-none text-muted`}),t]},t))}),(0,M.jsx)(B,{id:`cost-days`,title:`Over time`,children:(0,M.jsx)(F,{series:C.series,currency:N})}),(0,M.jsxs)(`div`,{className:`grid gap-6 @3xl:grid-cols-2`,children:[(0,M.jsx)(B,{id:`cost-agent`,title:`By agent`,children:(0,M.jsx)(L,{rows:C.byAgent,currency:N,label:`Spend by agent`,empty:`No agent used a model.`})}),(0,M.jsx)(B,{id:`cost-origin`,title:`By what started it`,children:(0,M.jsx)(L,{rows:C.byOrigin,currency:N,label:`Spend by what started the session`,empty:`Nothing yet.`})}),(0,M.jsx)(B,{id:`cost-model`,title:`By model`,children:(0,M.jsx)(L,{rows:C.byModel,currency:N,label:`Spend by model`,empty:`Nothing yet.`})}),(0,M.jsx)(B,{id:`cost-job`,title:`By job`,children:(0,M.jsx)(L,{rows:C.byJob,currency:N,label:`Spend by job`,empty:`No job's run used a model in this window.`})})]}),(0,M.jsx)(B,{id:`cost-sessions`,title:`Sessions`,children:(0,M.jsx)(v,{label:`Sessions`,placeholder:`Find a session, model or origin`,resetKey:t,empty:`No session used a model.`,head:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`th`,{scope:`col`,className:o(`px-3 py-1.5 text-left text-[11.5px] font-medium whitespace-nowrap text-muted`,`w-[38%]`),children:`Session`}),(0,M.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left text-[11.5px] font-medium whitespace-nowrap text-muted`,children:`Started`}),(0,M.jsx)(`th`,{scope:`col`,className:o(`px-3 py-1.5 text-left text-[11.5px] font-medium whitespace-nowrap text-muted`,`hidden @xl:table-cell`),children:`Started by`}),(0,M.jsx)(`th`,{scope:`col`,className:o(`px-3 py-1.5 text-left text-[11.5px] font-medium whitespace-nowrap text-muted`,`hidden @2xl:table-cell`),children:`Model`}),(0,M.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-right text-[11.5px] font-medium whitespace-nowrap text-muted`,children:`Tokens`}),(0,M.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-right text-[11.5px] font-medium whitespace-nowrap text-muted`,children:`Cost`})]}),children:C.sessions.map(e=>(0,M.jsxs)(`tr`,{className:`border-t border-line-soft align-top`,children:[(0,M.jsx)(`td`,{className:o(`px-3 py-2`,`max-w-0`),children:(0,M.jsx)(`a`,{href:c(`runs`,encodeURIComponent(e.name)),"data-tip":`${e.title} · forgeqe ${e.command}${e.from===`kept`?` · its log is gone; from the kept run`:``}`,className:`block truncate`,children:e.title})}),(0,M.jsx)(`td`,{className:o(`px-3 py-2`,`whitespace-nowrap text-muted`),"data-tip":O(e.startedAt),children:D(e.startedAt)}),(0,M.jsx)(`td`,{className:o(`px-3 py-2`,`hidden max-w-[180px] truncate @xl:table-cell`),"data-tip":e.origin,children:e.origin}),(0,M.jsx)(`td`,{className:o(`px-3 py-2`,`hidden max-w-[220px] truncate @2xl:table-cell`),"data-tip":e.models.join(`, `),children:e.models.join(`, `)}),(0,M.jsx)(`td`,{className:`px-3 py-2 text-right whitespace-nowrap tabular-nums`,children:E(e.tokens)}),(0,M.jsx)(`td`,{className:o(`px-3 py-2 text-right whitespace-nowrap tabular-nums`,e.amount===void 0&&`text-warn`),"data-tip":e.unpriced?`${E(e.unpriced)} tokens with no price`:e.estimate?`An estimate: part of it was routed to another model, or its cached price is derived`:void 0,children:e.amount===void 0||!N?(0,M.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,M.jsx)(i,{size:13,"aria-hidden":`true`}),`no price`]}):(0,M.jsxs)(M.Fragment,{children:[e.estimate?`≈`:``,g(e.amount,N),e.unpriced?(0,M.jsx)(`span`,{className:`text-warn`,children:` +?`}):null]})})]},e.name))})})]}),C&&C.packs.length>0&&(0,M.jsx)(B,{id:`cost-packs`,title:`Regression packs`,note:`What one run of a pack costs, from the sessions that ran or healed it in this window (forgeqe pack run or heal, or a job that runs it), divided by its runs that have a session.`,children:(0,M.jsx)(v,{label:`Regression packs`,placeholder:`Find a pack`,resetKey:t,empty:`No packs.`,head:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left text-[11.5px] font-medium whitespace-nowrap text-muted`,children:`Pack`}),(0,M.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-right text-[11.5px] font-medium whitespace-nowrap text-muted`,children:`Runs`}),(0,M.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-right text-[11.5px] font-medium whitespace-nowrap text-muted`,children:`Sessions`}),(0,M.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left text-[11.5px] font-medium whitespace-nowrap text-muted`,children:`Costs about`})]}),children:C.packs.map(e=>(0,M.jsxs)(`tr`,{className:`border-t border-line-soft align-top`,children:[(0,M.jsx)(`td`,{className:o(`px-3 py-2`,`max-w-0`),children:(0,M.jsx)(`a`,{href:c(`regression`,encodeURIComponent(e.name)),"data-tip":e.name,className:`block truncate`,children:e.name})}),(0,M.jsx)(`td`,{className:`px-3 py-2 text-right whitespace-nowrap tabular-nums`,children:e.runs}),(0,M.jsx)(`td`,{className:`px-3 py-2 text-right whitespace-nowrap tabular-nums`,children:e.sessions}),(0,M.jsx)(`td`,{className:o(`px-3 py-2`,`text-[13px]`),children:e.perRun!==void 0&&N?(0,M.jsxs)(`span`,{className:`tabular-nums`,children:[g(e.perRun,N),` per run`,e.unpriced?`, and ${E(e.unpriced)} tokens with no price`:``]}):e.missing?(0,M.jsxs)(`span`,{className:`flex items-start gap-1.5 text-ink-2`,children:[(0,M.jsx)(i,{size:14,"aria-label":`Not known`,className:`mt-0.5 flex-none text-warn`}),e.missing]}):(0,M.jsx)(`span`,{className:`text-muted`,children:`No runs in this window.`})})]},e.name))})}),C&&(0,M.jsx)(H,{router:C.router})]})]})}function H({router:e}){let t=e.areas.map(e=>e.area);return(0,M.jsxs)(B,{id:`cost-router`,title:`Model router`,note:(0,M.jsxs)(M.Fragment,{children:[z[e.mode],` `,e.exists?(0,M.jsxs)(M.Fragment,{children:[`Ratings from `,(0,M.jsx)(`code`,{className:`font-mono text-[12.5px]`,children:e.file}),e.profiledAt?(0,M.jsxs)(`span`,{"data-tip":O(e.profiledAt),children:[`, made `,D(e.profiledAt)]}):``,e.by?` by ${e.by}`:``,`.`,e.current?``:` They rate other profiles than llms.json has now, so the router does not use them; forgeqe models --profile-models rates them again.`]}):`No models are rated yet: forgeqe models --profile-models rates them, once, into .forgeqe/model-profile.json.`,e.escalations?` ${e.escalations} answer${e.escalations===1?` was`:`s were`} sent to a stronger model in this window.`:``]}),children:[(0,M.jsx)(v,{label:`Model ratings`,search:!1,empty:`No profiles in llms.json.`,head:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`th`,{scope:`col`,className:C,children:`Profile`}),(0,M.jsx)(`th`,{scope:`col`,className:o(C,`hidden @xl:table-cell`),children:`Model`}),t.map(e=>(0,M.jsx)(`th`,{scope:`col`,className:o(b,`hidden capitalize @2xl:table-cell`),children:e},e)),(0,M.jsx)(`th`,{scope:`col`,className:b,children:`Price per million`})]}),children:e.models.map(e=>(0,M.jsxs)(`tr`,{className:_,children:[(0,M.jsx)(`td`,{className:o(T,`max-w-0`),children:(0,M.jsx)(`span`,{"data-tip":e.reason?`${e.name} · ${e.tier??``} · ${e.reason}`:e.name,className:`block truncate font-medium`,children:e.name})}),(0,M.jsxs)(`td`,{className:o(T,`hidden max-w-[220px] truncate @xl:table-cell`),"data-tip":`${e.provider}/${e.model}`,children:[e.provider,`/`,e.model]}),t.map(t=>(0,M.jsx)(`td`,{className:o(x,`hidden @2xl:table-cell`,e.ratings[t]===void 0&&`text-muted`),children:e.ratings[t]??`–`},t)),(0,M.jsx)(`td`,{className:o(x,!e.price&&`text-muted`),children:e.price?`${g(e.price.input,e.price.currency)} in, ${g(e.price.output,e.price.currency)} out`:e.provider===`github_copilot`?`seat`:`no price`})]},e.name))}),(0,M.jsx)(v,{label:`Router picks`,search:!1,empty:`No areas.`,head:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`th`,{scope:`col`,className:C,children:`Area`}),(0,M.jsx)(`th`,{scope:`col`,className:b,children:`Bar`}),(0,M.jsx)(`th`,{scope:`col`,className:C,children:`Picks now`}),(0,M.jsx)(`th`,{scope:`col`,className:o(C,`hidden @xl:table-cell`),children:`Picked in this window`})]}),children:e.areas.map(t=>(0,M.jsxs)(`tr`,{className:_,children:[(0,M.jsx)(`td`,{className:o(T,`max-w-0`),children:(0,M.jsx)(`span`,{"data-tip":t.title,className:`block truncate capitalize`,children:t.area})}),(0,M.jsx)(`td`,{className:x,children:t.bar}),(0,M.jsx)(`td`,{className:o(T,`max-w-0`),children:t.pick?(0,M.jsxs)(`span`,{"data-tip":t.pick.reason,className:`block truncate`,children:[t.pick.profile,t.pick.rating===void 0?null:(0,M.jsxs)(`span`,{className:`text-muted`,children:[` · rated `,t.pick.rating]})]}):(0,M.jsx)(`span`,{className:`text-muted`,children:e.mode===`off`?`the active profile`:`nothing passes the checks`})}),(0,M.jsx)(`td`,{className:o(T,`hidden @xl:table-cell`),children:t.seen.length?t.seen.map(e=>`${e.profile} ×${e.n}`).join(`, `):(0,M.jsx)(`span`,{className:`text-muted`,children:`–`})})]},t.area))})]})}export{V as Cost};
@@ -1 +0,0 @@
1
- import{$n as e,$t as t,A as n,An as r,Ar as i,C as a,Dn as o,Ir as s,Nr as c,Tn as l,Zn as u,it as d,j as f,kr as p,ln as m,pn as h,pr as g,wr as _}from"./line-icons-CQ-3V8ax.js";import{At as v,B as y,R as b,V as x,a as S,c as C,ct as w,f as T,h as E,l as D,o as O,qt as ee,rt as te,t as k,z as ne}from"./filters-mFECJpMB.js";import{Et as re,Ot as A,_t as ie,at as j,ct as ae,et as M,gt as N,it as P,nt as F,r as I,rt as L,st as R,t as oe,tt as z}from"./frame-DiKY0GWx.js";import{l as se,r as B}from"./index-HjX2EOmp.js";import{n as V}from"./segmented-DANusepM.js";import{a as H,c as U}from"./dataParts-DpVitZdm.js";import{n as W,r as G,t as ce}from"./DesktopReview-jDnb5Gfn.js";var K=s(c(),1),q=ee(),J=[`workflows`,`runs`,`machine`],le={replay:[`Replaying the workflow`,`Replayed the workflow`,`working`],explore:[`Exploring the app`,`Explored the app`,`thinking`],validate:[`Checking the workflow`,`Checked the workflow`,`searching`],setup:[`Setting up the desktop engine`,`Set up the desktop engine`,`working`],doctor:[`Checking this machine`,`Checked this machine`,`searching`]},ue={explore:`Explored`,record:`Recorded`,project:`Project`},de={replay:`Replay`,explore:`Explore`,record:`Recording`},Y=e=>e.mode===`replay`&&e.ok&&e.heals>0&&!e.healsAccepted;async function X(e,t){try{let{id:t}=await te.start(e,{});location.hash=T(`chats`,t)}catch(e){t(e.message)}}function fe(){let[e,t]=(0,K.useState)(null),[n,r]=(0,K.useState)(``),[i,a]=(0,K.useState)(!1),o=(0,K.useCallback)(()=>{w.view().then(e=>{t(e),r(``)},e=>r(e.message))},[]);(0,K.useEffect)(o,[o]);let s=!!e?.job?.running;return(0,K.useEffect)(()=>{if(!s)return;let e=setInterval(o,1e3);return()=>clearInterval(e)},[s,o]),{view:e,error:n,setError:r,busy:i||s,act:async e=>{a(!0),r(``);try{return await e(),o(),!0}catch(e){return r(e.message),!1}finally{a(!1)}},load:o,stop:()=>void w.stop().then(o)}}function Z({on:e,set:t,children:n}){return(0,q.jsxs)(`label`,{className:`flex items-center gap-2.5 text-sm text-ink-2`,children:[(0,q.jsx)(ie,{checked:e,onChange:t,label:n}),n]})}function Q({label:e,hint:t,children:n}){return(0,q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium`,children:[e,n,t&&(0,q.jsx)(`span`,{className:`text-[12.5px] font-normal text-muted`,children:t})]})}function pe({w:e,page:t,onClose:n}){let{view:r}=t,[a,s]=(0,K.useState)({}),[c,l]=(0,K.useState)(``),[u,d]=(0,K.useState)(r.heal),[f,p]=(0,K.useState)(!1);(0,K.useEffect)(()=>{e&&(s(Object.fromEntries(e.variables.map(e=>[e.name,e.value]))),l(``),d(r.heal),p(!1))},[e,r.heal]);let m=c.startsWith(`file:`)?{file:c.slice(5)}:c.startsWith(`request:`)?{request:c.slice(8)}:void 0,h=`flex flex-col gap-3 rounded-[12px] card border p-3`;return(0,q.jsx)(A,{open:!!e,onClose:n,title:e?`Replay ${e.name}`:`Replay`,description:`Runs the workflow's steps in its app with no model, checking its expect steps. It takes over this machine's mouse and keyboard while it runs: use a test machine and a test account.`,footer:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(b,{onClick:n,children:[(0,q.jsx)(i,{"aria-hidden":`true`}),`Cancel`]}),(0,q.jsxs)(b,{variant:`primary`,disabled:t.busy||!e,onClick:async()=>{e&&await t.act(()=>w.replay({workflow:e.path,variables:a,...m?{rows:m}:{},heal:u,updateBaselines:f}))&&n()},"data-tip":`Replay now`,children:[(0,q.jsx)(o,{"aria-hidden":`true`}),`Replay`]})]}),children:e&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-4 pt-3`,children:[(0,q.jsxs)(`p`,{className:`m-0 flex flex-wrap gap-x-3 text-[13px] text-muted`,children:[(0,q.jsx)(`span`,{className:`font-mono`,children:e.path}),(0,q.jsxs)(`span`,{children:[e.app||`no app`,` · `,x(e.steps,`step`),` · `,x(e.checks,`check`)]})]}),e.checks===0&&(0,q.jsx)(`p`,{className:`m-0 rounded-[10px] bg-warn-soft px-3 py-2 text-[13px] text-warn`,children:`It has no checks of the outcome: a replay passes when its steps run. Ask the agent to add expect steps.`}),e.variables.length>0&&(0,q.jsxs)(`div`,{className:h,children:[(0,q.jsx)(`h3`,{className:`m-0 text-sm font-semibold`,children:`Values`}),(0,q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(200px,1fr))] gap-3`,children:e.variables.map(e=>(0,q.jsx)(Q,{label:e.name,children:(0,q.jsx)(S,{value:a[e.name]??``,onChange:t=>s({...a,[e.name]:t.target.value})})},e.name))})]}),(0,q.jsxs)(`div`,{className:h,children:[(0,q.jsx)(`h3`,{className:`m-0 text-sm font-semibold`,children:`Test data`}),(0,q.jsx)(Q,{label:`Rows`,hint:`Each row replays the workflow once, its columns over the values above.`,children:(0,q.jsxs)(O,{value:c,onChange:e=>l(e.target.value),children:[(0,q.jsx)(`option`,{value:``,children:`Once, with the values above`}),r.rows.files.map(e=>(0,q.jsxs)(`option`,{value:`file:${e}`,children:[`Each row of `,e]},e)),r.rows.requests.map(e=>(0,q.jsxs)(`option`,{value:`request:${e}`,children:[`Each row of request `,e]},e))]})})]}),(0,q.jsxs)(`div`,{className:h,children:[(0,q.jsx)(`h3`,{className:`m-0 text-sm font-semibold`,children:`While it runs`}),(0,q.jsx)(Z,{on:u,set:d,children:`Heal a step whose control moved`}),(0,q.jsx)(Z,{on:f,set:p,children:`Take new image baselines`})]})]})})}function me({open:e,page:t,onClose:r}){let{view:a}=t,[o,s]=(0,K.useState)(a.apps[0]?.name??``),[c,l]=(0,K.useState)(``),[d,f]=(0,K.useState)(``);return(0,q.jsx)(A,{open:e,onClose:r,title:`Explore a goal`,description:`UFO² carries out the goal in the app with a vision model and saves what it did as a workflow, with checks of the outcome, to replay with no model.`,footer:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(b,{onClick:r,children:[(0,q.jsx)(i,{"aria-hidden":`true`}),`Cancel`]}),(0,q.jsxs)(b,{variant:`primary`,disabled:t.busy||!c.trim()||!o,onClick:async()=>{await t.act(()=>w.explore(o,c.trim(),d.trim()))&&(l(``),f(``),r())},"data-tip":`Start: UFO² takes over the mouse and keyboard`,children:[(0,q.jsx)(u,{"aria-hidden":`true`}),`Start exploring`]})]}),children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-4 pt-3`,children:[(0,q.jsx)(Q,{label:`App`,children:(0,q.jsx)(O,{value:o,onChange:e=>s(e.target.value),children:a.apps.map(e=>(0,q.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),(0,q.jsx)(Q,{label:`Goal`,hint:`One line, as you would ask a tester.`,children:(0,q.jsx)(S,{value:c,maxLength:500,placeholder:`Create an invoice for Contoso and save it`,onChange:e=>l(e.target.value)})}),(0,q.jsx)(Q,{label:`Name`,hint:`Optional: the workflow's name.`,children:(0,q.jsx)(S,{value:d,maxLength:80,onChange:e=>f(e.target.value)})}),(0,q.jsxs)(`p`,{className:`m-0 flex gap-2 rounded-[10px] bg-warn-soft px-3 py-2 text-[13px] text-warn`,children:[(0,q.jsx)(n,{size:16,"aria-hidden":`true`,className:`mt-0.5 flex-none`}),`UFO² controls this machine's mouse and keyboard in `,o||`the app`,`, in that app's windows only (no shell commands). Use a test machine and a test account.`]})]})})}function he({open:e,page:t,onClose:n}){let{view:r}=t,[a,o]=(0,K.useState)(r.windows),[s,c]=(0,K.useState)(!1);return(0,q.jsx)(A,{open:e,onClose:n,title:`Set up the desktop engine`,description:`Downloads ForgeQE's pinned packages for desktop replay on this machine, and takes a few minutes.`,footer:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(b,{onClick:n,children:[(0,q.jsx)(i,{"aria-hidden":`true`}),`Cancel`]}),(0,q.jsxs)(b,{variant:`primary`,disabled:t.busy,onClick:async()=>{await t.act(()=>w.setup({ufo:r.windows&&a,force:s}))&&n()},children:[(0,q.jsx)(p,{"aria-hidden":`true`}),`Set up`]})]}),children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 pt-3`,children:[r.windows?(0,q.jsx)(Z,{on:a,set:o,children:`With UFO², for exploring a goal`}):(0,q.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`On this system workflows replay on agent-desktop, which this sets up too. Exploring and recording by hand need Windows.`}),(0,q.jsx)(Z,{on:s,set:c,children:`Set it up again from scratch`})]})})}var $=e=>(e??[]).map(e=>/\s/.test(e)?`"${e}"`:e).join(` `);function ge({open:e,editing:t,page:n,onClose:o}){let[s,c]=(0,K.useState)(``),[l,u]=(0,K.useState)(``),[d,f]=(0,K.useState)(!1),[p,m]=(0,K.useState)(``),[h,g]=(0,K.useState)(``),[_,v]=(0,K.useState)(``),[x,C]=(0,K.useState)(!1);(0,K.useEffect)(()=>{e&&(c(t?.path??``),u(t?.name??``),f(!!t),m(t?.description??``),g($(t?.args)),v(``))},[e,t]);let T=async()=>{C(!0),v(``);let e={name:l.trim(),path:s.trim(),...h.trim()?{args:h.trim()}:{},...p.trim()?{description:p.trim()}:{}};try{await(t?w.editApp(e):w.addApp(e)),n.load(),o()}catch(e){v(e.message)}finally{C(!1)}};return(0,q.jsx)(A,{open:e,onClose:o,title:t?`Change ${t.name}`:`Add a desktop app`,description:t?`Its program, arguments and description. Its name stays: workflows and the agent name it by it.`:`The app's program on this computer: an .exe on Windows. It is added to the active environment's apps (or forgeqe.yaml's), so it can be recorded, explored and replayed by its name.`,footer:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(b,{onClick:o,children:[(0,q.jsx)(i,{"aria-hidden":`true`}),`Cancel`]}),(0,q.jsxs)(b,{variant:`primary`,disabled:x||!s.trim()||!l.trim(),onClick:()=>void T(),children:[t?(0,q.jsx)(a,{"aria-hidden":`true`}):(0,q.jsx)(r,{"aria-hidden":`true`}),x?t?`Saving…`:`Adding…`:t?`Save`:`Add the app`]})]}),children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-4 pt-3`,children:[(0,q.jsx)(Q,{label:`Program`,hint:`Type its path, or Browse to choose it on this computer.`,children:(0,q.jsx)(W,{value:s,onChange:e=>{c(e),d||u(e.trim()?G(e):``)},onPicked:(e,t)=>{d||u(t)},onError:v})}),(0,q.jsx)(Q,{label:`Arguments`,hint:`Optional: what the app starts with. Quotes keep spaces together; each goes to the app as it is, no shell.`,children:(0,q.jsx)(S,{value:h,maxLength:500,spellCheck:!1,placeholder:`--server qa-db01 --profile "Test User"`,onChange:e=>g(e.target.value),className:`font-mono text-[13px]`})}),(0,q.jsx)(Q,{label:`Name`,hint:t?`Fixed: workflows name the app by it.`:`How workflows and the agent name it: letters, digits and _ . -`,children:(0,q.jsx)(S,{value:l,maxLength:40,spellCheck:!1,readOnly:!!t,className:y(t&&`bg-surface-muted text-muted`),onChange:e=>{f(!0),u(e.target.value)}})}),(0,q.jsx)(Q,{label:`What it is for`,hint:`Optional: one line the agent reads to pick the app.`,children:(0,q.jsx)(S,{value:p,maxLength:200,placeholder:`Back-office invoicing`,onChange:e=>m(e.target.value)})}),_&&(0,q.jsx)(U,{text:_})]})})}function _e({app:e,page:t,onClose:n}){let[r,a]=(0,K.useState)(null),[o,s]=(0,K.useState)(``),[c,l]=(0,K.useState)(!1);return(0,K.useEffect)(()=>{e&&(a(null),s(``),w.removeApp(e.name,!1).then(a,e=>s(e.message)))},[e]),(0,q.jsx)(A,{open:!!e,onClose:n,title:e?`Remove ${e.name}`:`Remove the app`,description:`It comes off the apps list, so it can no longer be recorded or replayed until it is added again. Its workflows and recordings stay.`,footer:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(b,{onClick:n,children:[(0,q.jsx)(i,{"aria-hidden":`true`}),`Cancel`]}),(0,q.jsxs)(b,{variant:`destructive`,disabled:c||!r,onClick:async()=>{if(e){l(!0);try{await w.removeApp(e.name,!0),t.load(),n()}catch(e){s(e.message)}finally{l(!1)}}},children:[(0,q.jsx)(g,{"aria-hidden":`true`}),c?`Removing…`:`Remove`]})]}),children:(0,q.jsx)(`div`,{className:`flex flex-col gap-3 pt-3 text-sm`,children:o?(0,q.jsx)(U,{text:o}):r?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`p`,{className:`m-0 text-ink-2`,children:[`From `,r.where,`.`]}),r.usedBy.length?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`p`,{className:`m-0 rounded-[10px] bg-warn-soft px-3 py-2 text-[13px] text-warn`,children:[x(r.usedBy.length,`workflow`),` name`,r.usedBy.length===1?`s`:``,` it and will not replay until an app of that name is added again.`]}),(0,q.jsxs)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0 font-mono text-[12.5px] text-ink-2`,children:[r.usedBy.slice(0,20).map(e=>(0,q.jsx)(`li`,{className:`truncate`,"data-tip":e,children:e},e)),r.usedBy.length>20&&(0,q.jsxs)(`li`,{className:`font-sans text-muted`,children:[`and `,r.usedBy.length-20,` more`]})]})]}):(0,q.jsx)(`p`,{className:`m-0 text-muted`,children:`No workflow names it.`})]}):(0,q.jsx)(`p`,{role:`status`,className:`m-0 text-muted`,children:`Looking for the workflows that use it…`})})})}function ve({page:e,onReplay:n,onExplore:r,onSteps:i}){let{view:a}=e,[s,c]=(0,K.useState)(a.apps[0]?.name??``),l=a.windows?void 0:a.windowsOnly,f=()=>e.act(async()=>{await v.start({kind:`desktop`,app:s}),location.hash=T(`record`)});return(0,q.jsx)(M,{label:`Desktop workflows`,minWidth:720,placeholder:`Find a workflow`,empty:`No workflows yet: record one by hand, explore a goal, or keep .yaml files with format: forgeqe-desktop-v1 in the project.`,tools:(0,q.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[a.apps.length>1&&(0,q.jsx)(O,{size:`sm`,"aria-label":`App to record`,value:s,onChange:e=>c(e.target.value),className:`w-auto`,children:a.apps.map(e=>(0,q.jsx)(`option`,{value:e.name,children:e.name},e.name))}),(0,q.jsxs)(b,{size:`sm`,disabled:e.busy||!a.windows||!s,onClick:()=>void f(),"data-tip":l??`Record your steps in ${s}: no model`,children:[(0,q.jsx)(h,{"aria-hidden":`true`}),`Record by hand`]}),(0,q.jsxs)(b,{size:`sm`,variant:`primary`,disabled:e.busy||!a.windows||!a.apps.length,onClick:r,"data-tip":l??`UFO² carries out a goal and saves it as a workflow`,children:[(0,q.jsx)(u,{"aria-hidden":`true`}),`Explore a goal`]})]}),head:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`th`,{className:L,children:`Workflow`}),(0,q.jsx)(`th`,{className:L,children:`App`}),(0,q.jsx)(`th`,{className:P,children:`Steps`}),(0,q.jsx)(`th`,{className:P,children:`Checks`}),(0,q.jsx)(`th`,{className:L,children:`From`}),(0,q.jsx)(`th`,{className:L,children:(0,q.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]}),children:a.workflows.map(r=>(0,q.jsxs)(`tr`,{className:j,children:[(0,q.jsx)(`td`,{className:z,children:(0,q.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>i(r),className:`cursor-pointer self-start border-0 bg-transparent p-0 text-left font-medium text-ink hover:text-accent-fg hover:underline`,children:r.name}),(0,q.jsx)(`span`,{className:`max-w-[300px] truncate font-mono text-[12px] text-muted`,"data-tip":r.path,children:r.path})]})}),(0,q.jsx)(`td`,{className:y(z,`whitespace-nowrap`),children:r.app||(0,q.jsx)(`span`,{className:`text-muted`,children:`—`})}),(0,q.jsx)(`td`,{className:F,children:r.steps}),(0,q.jsx)(`td`,{className:y(F,r.checks===0&&`text-warn`),"data-tip":r.checks===0?`No checks of the outcome: a replay passes when its steps run`:void 0,children:r.checks}),(0,q.jsxs)(`td`,{className:y(z,`whitespace-nowrap`),children:[ue[r.from],(0,q.jsx)(`span`,{className:`block text-[12px] text-muted`,children:B(r.modified)})]}),(0,q.jsx)(`td`,{className:y(z,`whitespace-nowrap text-right`),children:(0,q.jsxs)(`span`,{className:`inline-flex gap-1`,children:[(0,q.jsx)(b,{size:`icon`,variant:`icon`,onClick:()=>i(r),"aria-label":`Open ${r.name}`,"data-tip":`Open it: steps, checks, test data, last run`,className:`size-8`,children:(0,q.jsx)(d,{"aria-hidden":`true`})}),(0,q.jsx)(b,{size:`icon`,variant:`icon`,disabled:e.busy,onClick:()=>n(r),"aria-label":`Replay ${r.name}`,"data-tip":`Replay ${r.name}`,className:`size-8`,children:(0,q.jsx)(o,{"aria-hidden":`true`})}),(0,q.jsx)(b,{size:`icon`,variant:`icon`,disabled:e.busy,onClick:()=>void e.act(()=>w.validate(r.path)),"aria-label":`Check ${r.name}`,"data-tip":`Check it without running it`,className:`size-8`,children:(0,q.jsx)(t,{"aria-hidden":`true`})}),(0,q.jsx)(b,{size:`icon`,variant:`icon`,onClick:()=>void X(`Desktop agent: look at the desktop workflow ${r.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.`,e.setError),"aria-label":`Improve ${r.name} with the agent`,"data-tip":`Improve it with the agent`,className:`size-8`,children:(0,q.jsx)(_,{"aria-hidden":`true`})})]})})]},r.path))})}function ye({page:e}){let{view:t}=e,[n,r]=(0,K.useState)(`all`),[i,a]=(0,K.useState)(``),o=t.runs.filter(e=>!e.ok),s=t.runs.filter(Y),c=n===`failed`?o:n===`heals`?s:t.runs;return(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[i&&(0,q.jsx)(`p`,{role:`status`,className:`m-0 rounded-[10px] bg-pass-soft px-3 py-1.5 text-[13px] text-pass`,children:i}),(0,q.jsx)(M,{label:`Desktop runs`,minWidth:720,resetKey:n,placeholder:`Find a run`,empty:n===`all`?`No desktop runs yet: replay, record or explore a workflow.`:`None.`,tools:(0,q.jsx)(k,{value:n,onChange:r,items:[{id:`all`,label:`All`,n:t.runs.length},{id:`failed`,label:`Failed`,n:o.length,alert:!0},{id:`heals`,label:`Heals to accept`,n:s.length}]}),head:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`th`,{className:L,children:`Run`}),(0,q.jsx)(`th`,{className:L,children:`Result`}),(0,q.jsx)(`th`,{className:P,children:`Steps`}),(0,q.jsx)(`th`,{className:L,children:`Heals`}),(0,q.jsx)(`th`,{className:L,children:(0,q.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]}),children:c.map(t=>(0,q.jsxs)(`tr`,{className:j,children:[(0,q.jsx)(`td`,{className:z,children:(0,q.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,q.jsxs)(`span`,{className:`font-medium`,children:[de[t.mode],`: `,t.name]}),(0,q.jsx)(`span`,{className:`text-[12px] text-muted`,children:[t.app,B(t.at)].filter(Boolean).join(` · `)}),(t.failed||t.error)&&(0,q.jsx)(`span`,{className:`max-w-[380px] truncate text-[12px] text-fail`,"data-tip":t.failed?t.failed.error:t.error,children:t.failed?`Step ${t.failed.index} (${t.failed.op}): ${t.failed.error||`failed`}`:t.error})]})}),(0,q.jsx)(`td`,{className:y(z,`whitespace-nowrap`),children:(0,q.jsx)(C,{tone:t.ok?`pass`:`fail`,children:t.many?`${t.many.passed} of ${t.many.total}`:t.ok?`Passed`:`Failed`})}),(0,q.jsx)(`td`,{className:F,children:t.steps||(0,q.jsx)(`span`,{className:`text-muted`,children:`—`})}),(0,q.jsx)(`td`,{className:y(z,`whitespace-nowrap`),children:t.heals?t.healsAccepted?(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[13px] text-pass`,children:[(0,q.jsx)(f,{size:14,"aria-hidden":`true`}),`In the workflow`]}):t.ok?(0,q.jsxs)(b,{size:`sm`,disabled:e.busy,onClick:()=>void e.act(async()=>{let e=await w.acceptHeals(t.dir);a(`Wrote ${x(e.written,`healed step`)} into ${e.workflow}.`)}),"data-tip":`Write the new locators into the workflow`,children:[(0,q.jsx)(p,{"aria-hidden":`true`}),`Accept `,x(t.heals,`heal`)]}):(0,q.jsxs)(`span`,{className:`text-[13px] text-muted`,"data-tip":`The replay failed after healing, so its heals may be wrong`,children:[x(t.heals,`heal`),`, not offered`]}):(0,q.jsx)(`span`,{className:`text-muted`,children:`—`})}),(0,q.jsx)(`td`,{className:y(z,`whitespace-nowrap text-right`),children:(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[t.report&&(0,q.jsx)(se,{path:t.report,children:`Report`}),!t.ok&&(0,q.jsx)(b,{size:`icon`,variant:`icon`,onClick:()=>void X(`Desktop agent: the desktop ${t.mode} ${t.dir} failed${t.workflow?` (workflow ${t.workflow})`:``}. Read its report, tell me why, and offer a fix.`,e.setError),"aria-label":`Ask the agent why it failed`,"data-tip":`Ask the agent why it failed`,className:`size-8`,children:(0,q.jsx)(m,{"aria-hidden":`true`})})]})})]},t.dir))})]})}function be({page:e,onSetup:i,onAdd:a,onEdit:o,onRemove:s}){let{view:c}=e,u=c.driver===`auto`?c.windows?`pywinauto`:`agent-desktop`:c.driver,d=[{label:`Replay`,ok:c.engine.ready,note:c.engine.ready?`On ${u}`:(c.engine.error||`The desktop engine is not set up`).replace(/^./,e=>e.toUpperCase())},{label:`Explore and record`,ok:c.windows&&c.engine.ufo,note:c.windows?c.engine.ufo?`UFO² is set up`:`UFO² is not set up`:`Windows only`},{label:`Healing`,ok:c.heal,note:c.heal?`A moved control is healed with the model`:`desktop.heal is off`}],m=`flex flex-col rounded-[12px] card border`;return(0,q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,320px),1fr))] items-start gap-6`,children:[(0,q.jsxs)(`section`,{"aria-labelledby":`desktop-machine`,className:`flex flex-col gap-2`,children:[(0,q.jsx)(`h2`,{id:`desktop-machine`,className:`m-0 text-[13px] font-semibold text-muted`,children:`This machine`}),(0,q.jsx)(`ul`,{className:y(m,`m-0 list-none divide-y divide-line-soft p-0`),children:d.map(e=>(0,q.jsxs)(`li`,{className:`flex items-start gap-2.5 px-3 py-2.5`,children:[e.ok?(0,q.jsx)(f,{size:16,"aria-label":`Ready`,className:`mt-0.5 flex-none text-pass`}):(0,q.jsx)(n,{size:16,"aria-label":`Not ready`,className:`mt-0.5 flex-none text-warn`}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,q.jsx)(`span`,{className:`text-[14px] font-medium`,children:e.label}),(0,q.jsx)(`span`,{className:`text-[12.5px] text-muted [overflow-wrap:anywhere]`,"data-tip":!e.ok&&e.label===`Explore and record`&&c.windowsOnly?c.windowsOnly:void 0,children:e.note})]})]},e.label))}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsxs)(b,{size:`sm`,disabled:e.busy,onClick:()=>void e.act(()=>w.doctor()),"data-tip":`Whether replay can run here unattended`,children:[(0,q.jsx)(t,{"aria-hidden":`true`}),`Check`]}),(0,q.jsxs)(b,{size:`sm`,variant:c.engine.ready?`outline`:`primary`,disabled:e.busy,onClick:i,"data-tip":`Download and set up the desktop engine`,children:[(0,q.jsx)(p,{"aria-hidden":`true`}),`Set up`]})]})]}),(0,q.jsxs)(`section`,{"aria-labelledby":`desktop-apps`,className:`flex flex-col gap-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,q.jsx)(`h2`,{id:`desktop-apps`,className:`m-0 flex-1 text-[13px] font-semibold text-muted`,children:`Apps`}),(0,q.jsxs)(b,{size:`sm`,onClick:a,"data-tip":`Add an app by its program on this computer`,children:[(0,q.jsx)(r,{"aria-hidden":`true`}),`Add an app`]})]}),c.apps.length?(0,q.jsx)(`ul`,{className:y(m,`m-0 list-none divide-y divide-line-soft p-0`),children:c.apps.map(e=>(0,q.jsxs)(`li`,{className:`group flex items-start gap-2.5 px-3 py-2.5`,children:[(0,q.jsx)(E,{icon:h,size:16,className:`mt-0.5 flex-none text-muted`}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,q.jsx)(`span`,{className:`text-[14px] font-medium`,children:e.name}),(0,q.jsxs)(`span`,{className:`truncate font-mono text-[12px] text-muted`,"data-tip":[e.path,...e.args??[]].join(` `),children:[e.path||`No path`,e.args?.length?(0,q.jsxs)(`span`,{className:`text-ink-2`,children:[` `,$(e.args)]}):null]}),e.description&&(0,q.jsx)(`span`,{className:`text-[12.5px] text-muted`,children:e.description})]}),(0,q.jsxs)(`span`,{className:`flex flex-none gap-0.5`,children:[(0,q.jsx)(b,{size:`icon`,variant:`icon`,onClick:()=>o(e),"aria-label":`Change ${e.name}`,"data-tip":`Change ${e.name}`,className:`size-8`,children:(0,q.jsx)(l,{"aria-hidden":`true`})}),(0,q.jsx)(b,{size:`icon`,variant:`icon`,onClick:()=>s(e),"aria-label":`Remove ${e.name}`,"data-tip":`Remove ${e.name}`,className:`size-8 hover:text-fail`,children:(0,q.jsx)(g,{"aria-hidden":`true`})})]})]},e.name))}):(0,q.jsxs)(D,{className:`py-3`,children:[`No desktop apps yet: add one by its program, or in `,(0,q.jsx)(`a`,{href:T(`settings`,`environments`),children:`Settings, Environments`}),`.`]}),(0,q.jsxs)(`p`,{className:`m-0 text-[12.5px] text-muted`,children:[`Secrets a workflow may type: `,c.secrets.length?c.secrets.join(`, `):`none`,`.`,c.refusedSecrets.length>0&&(0,q.jsxs)(`span`,{className:`text-fail`,children:[` `,c.refusedSecrets.join(`, `),` `,c.refusedSecrets.length===1?`is`:`are`,` ForgeQE's own: take `,c.refusedSecrets.length===1?`it`:`them`,` out of desktop.secrets, or nothing replays.`]})]})]})]})}function xe({view:e,onTab:t}){let n=e.runs.filter(e=>e.mode===`replay`),r=n.filter(e=>e.ok).length,i=n[0],a=e.runs.filter(Y).length,o=e.workflows.filter(e=>e.checks===0).length;return(0,q.jsxs)(ae,{label:`Desktop at a glance`,children:[(0,q.jsx)(R,{compact:!0,label:`Workflows`,value:e.workflows.length,note:o?(0,q.jsxs)(`span`,{className:`text-warn`,children:[o,` without checks`]}):`${x(e.apps.length,`app`)}`}),(0,q.jsx)(R,{compact:!0,label:`Replays passed`,value:n.length?`${r} of ${n.length}`:`—`,tone:n.length&&r<n.length?`text-fail`:void 0,note:i?`Last ${B(i.at)}`:`None yet`}),(0,q.jsx)(R,{compact:!0,label:`Heals to accept`,value:a,tone:a?`text-accent-fg`:void 0,note:a?(0,q.jsx)(`button`,{type:`button`,onClick:()=>t(`runs`),className:`cursor-pointer border-0 bg-transparent p-0 text-[13px] text-accent-fg hover:underline`,children:`Review them`}):`From passed replays`}),(0,q.jsx)(R,{compact:!0,label:`Replay here`,value:e.engine.ready?`Ready`:`Not set up`,tone:e.engine.ready?`text-pass`:`text-warn`,note:e.engine.ready?e.windows?`Windows`:`Explore needs Windows`:(0,q.jsx)(`button`,{type:`button`,onClick:()=>t(`machine`),className:`cursor-pointer border-0 bg-transparent p-0 text-[13px] text-accent-fg hover:underline`,children:`Set it up`})})]})}function Se({sub:t}){let n=fe(),{view:r,error:i}=n,a=J.includes(t)?t:`workflows`,[o,s]=(0,K.useState)(null),[c,l]=(0,K.useState)(!1),[u,d]=(0,K.useState)(!1),[f,p]=(0,K.useState)(!1),[h,g]=(0,K.useState)(),[_,v]=(0,K.useState)(null),[x,S]=(0,K.useState)(null),C=r?.job??null,E=e=>location.hash=T(`desktop`,e),D={workflows:`Workflows${r?` (${r.workflows.length})`:``}`,runs:`Runs${r?` (${r.runs.length})`:``}`,machine:`Machine and apps`};return(0,q.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,q.jsx)(I,{}),(0,q.jsxs)(`main`,{className:y(oe,`@container flex-auto gap-4`),children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,q.jsx)(re,{pixel:N.desktop,size:`lg`}),(0,q.jsx)(`h1`,{className:`m-0 flex-1 text-[26px] font-semibold tracking-[-0.01em]`,children:`Desktop apps`}),(0,q.jsxs)(`a`,{href:T(`agents`,`desktop`),"data-tip":`Ask the Desktop agent`,className:y(ne({size:`sm`}),`no-underline`),children:[(0,q.jsx)(m,{"aria-hidden":`true`}),`Ask the agent`]})]}),(0,q.jsx)(`p`,{className:`m-0 max-w-[74ch] text-sm leading-relaxed text-ink-2`,children:`Workflows for Windows thick-client apps: explore a goal with UFO² or record your steps by hand, then replay them with no model, a moved control healed and offered for the workflow.`}),i&&(0,q.jsx)(U,{text:i}),!r&&!i&&(0,q.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}),r&&x&&(0,q.jsx)(ce,{workflow:x.path,backLabel:`Workflows`,onClose:()=>{S(null),n.load()}},x.path),r&&!x&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(xe,{view:r,onTab:E}),C&&(C.running||!C.endedAt||Date.now()-Date.parse(C.endedAt)<6e5)&&(0,q.jsx)(H,{job:C,onStop:n.stop,words:le}),C?.question&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-[12px] bg-accent-soft p-3 text-[13.5px]`,children:[(0,q.jsx)(`p`,{className:`m-0 font-medium`,children:C.question.title}),C.question.detail&&(0,q.jsx)(`p`,{className:`m-0 text-ink-2`,children:C.question.detail}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[C.question.options.map(e=>(0,q.jsx)(b,{size:`sm`,onClick:()=>void n.act(()=>w.answer(C.question.id,e.id)),children:e.label},e.id)),(0,q.jsxs)(b,{size:`sm`,variant:`danger`,onClick:()=>void n.act(()=>w.answer(C.question.id,null)),children:[(0,q.jsx)(e,{fill:`currentColor`,"aria-hidden":`true`}),`Stop`]})]})]}),(0,q.jsx)(V,{label:`Desktop apps`,current:a,onPick:E,tabs:J.map(e=>({id:e,label:D[e]}))}),(0,q.jsxs)(`div`,{role:`tabpanel`,id:`panel-${a}`,"aria-labelledby":`tab-${a}`,children:[a===`workflows`&&(0,q.jsx)(ve,{page:{...n,view:r},onReplay:s,onExplore:()=>l(!0),onSteps:S}),a===`runs`&&(0,q.jsx)(ye,{page:{...n,view:r}}),a===`machine`&&(0,q.jsx)(be,{page:{...n,view:r},onSetup:()=>d(!0),onAdd:()=>{g(void 0),p(!0)},onEdit:e=>{g(e),p(!0)},onRemove:v})]}),(0,q.jsx)(pe,{w:o,page:{...n,view:r},onClose:()=>s(null)}),(0,q.jsx)(me,{open:c,page:{...n,view:r},onClose:()=>l(!1)}),(0,q.jsx)(he,{open:u,page:{...n,view:r},onClose:()=>d(!1)}),(0,q.jsx)(ge,{open:f,editing:h,page:{...n,view:r},onClose:()=>p(!1)}),(0,q.jsx)(_e,{app:_,page:{...n,view:r},onClose:()=>v(null)})]})]})]})}export{Se as Desktop};
@@ -1 +0,0 @@
1
- import{An as e,Ar as t,C as n,Dn as r,Ir as i,Nr as a,Tn as o,a as s,fn as c,it as l,j as u,kr as d,ln as f,pr as p,wr as m,wt as h}from"./line-icons-CQ-3V8ax.js";import{B as g,R as _,V as v,a as y,c as b,ct as x,f as S,i as ee,l as C,o as w,qt as T,rt as te,t as E}from"./filters-mFECJpMB.js";import{_t as D}from"./frame-DiKY0GWx.js";import{M as O,l as k,r as A}from"./index-HjX2EOmp.js";import{i as j,r as ne}from"./segmented-DANusepM.js";import{a as M}from"./dataParts-DpVitZdm.js";var N=i(a(),1),P=T();function F(e){return(e.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||``).replace(/\.(exe|app)$/i,``).toLowerCase().replace(/[^a-z0-9_.-]+/g,`-`).replace(/^[^a-z]+/,``).replace(/-+$/,``).slice(0,40)||`app`}function I({value:e,onChange:t,onPicked:n,onError:r,className:i}){let[a,o]=(0,N.useState)(!1),s=async()=>{o(!0),r(``);try{let e=await x.browse();`path`in e?(t(e.path),n?.(e.path,e.name)):`unavailable`in e&&r(e.unavailable)}catch(e){r(e.message)}finally{o(!1)}};return(0,P.jsxs)(`div`,{className:g(`flex min-w-0 gap-2`,i),children:[(0,P.jsx)(y,{"aria-label":`App's path`,value:e,spellCheck:!1,placeholder:`C:\\Program Files\\Contoso\\Billing.exe`,onChange:e=>t(e.target.value),className:`min-w-0 flex-1 font-mono text-[13px]`}),(0,P.jsxs)(_,{type:`button`,disabled:a,onClick:()=>void s(),"data-tip":`Choose the app's .exe on this computer`,children:[(0,P.jsx)(h,{"aria-hidden":`true`}),a?`Choosing…`:`Browse…`]})]})}var L={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 re({p:e}){return(0,P.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,P.jsx)(`ul`,{className:`m-0 flex flex-col gap-0.5 pl-5 text-[13px] text-ink-2`,children:e.summary.map((e,t)=>(0,P.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:e},t))}),(0,P.jsx)(`pre`,{className:`m-0 max-h-[200px] overflow-auto rounded-[10px] bg-surface-muted p-2.5 font-mono text-[12px] leading-relaxed whitespace-pre-wrap`,children:e.diff.map((e,t)=>(0,P.jsx)(`span`,{className:g(`block`,e.startsWith(`+`)?`text-pass`:e.startsWith(`-`)?`text-fail`:`text-muted`),children:e},t))})]})}function R({label:e,children:t}){return(0,P.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-[13px] font-medium`,children:[e,t]})}function ie({workflow:e,step:r,mode:i,onDone:a,onCancel:s}){let c=L[r.op]??[`note`],l=r.fields??{},[u,d]=(0,N.useState)({automation_id:l.target?.automation_id??``,name:l.target?.name??``,control_type:l.target?.control_type??``}),[f,m]=(0,N.useState)(l.text??``),[h,g]=(0,N.useState)(l.value??``),[v,b]=(0,N.useState)(l.keys??``),[S,ee]=(0,N.useState)(l.seconds===void 0?``:String(l.seconds)),[C,w]=(0,N.useState)(l.timeout===void 0?``:String(l.timeout)),[T,te]=(0,N.useState)(l.note??``),[E,D]=(0,N.useState)(null),[O,k]=(0,N.useState)(``),[A,j]=(0,N.useState)(!1),ne=()=>{let e={};return c.includes(`target`)&&(u.automation_id!==(l.target?.automation_id??``)||u.name!==(l.target?.name??``)||u.control_type!==(l.target?.control_type??``))&&(e.target=u),c.includes(`text`)&&f!==(l.text??``)&&(e.text=f),c.includes(`value`)&&h!==(l.value??``)&&(e.value=h),c.includes(`keys`)&&v!==(l.keys??``)&&(e.keys=v),c.includes(`seconds`)&&S!==(l.seconds===void 0?``:String(l.seconds))&&(e.seconds=Number(S)),c.includes(`timeout`)&&C!==(l.timeout===void 0?``:String(l.timeout))&&C.trim()&&(e.timeout=Number(C)),c.includes(`note`)&&T!==(l.note??``)&&(e.note=T),e},M=async t=>{j(!0),k(``);try{let n=await x.editStep({workflow:e,step:r.n,action:i,...i===`edit`?{fields:ne()}:{},...t?{version:t}:{}});n.written?a():D(n)}catch(e){k(e.message)}finally{j(!1)}};(0,N.useEffect)(()=>{i===`remove`&&M()},[]);let F=()=>D(null);return(0,P.jsxs)(`div`,{className:`mb-2 ml-9 flex flex-col gap-3 rounded-[12px] bg-surface-muted p-3`,children:[i===`edit`&&!E&&(0,P.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,180px),1fr))] gap-2.5`,children:[c.includes(`target`)&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(R,{label:`Control's name`,children:(0,P.jsx)(y,{size:`sm`,value:u.name,maxLength:300,onChange:e=>(d({...u,name:e.target.value}),F()),className:`bg-bg`})}),(0,P.jsx)(R,{label:`Automation id`,children:(0,P.jsx)(y,{size:`sm`,value:u.automation_id,maxLength:300,spellCheck:!1,onChange:e=>(d({...u,automation_id:e.target.value}),F()),className:`bg-bg font-mono text-[12.5px]`})}),(0,P.jsx)(R,{label:`Control type`,children:(0,P.jsx)(y,{size:`sm`,value:u.control_type,maxLength:60,spellCheck:!1,placeholder:`Button`,onChange:e=>(d({...u,control_type:e.target.value}),F()),className:`bg-bg`})})]}),c.includes(`text`)&&(0,P.jsx)(R,{label:r.op===`type`?`Text to type`:`Text it shows`,children:(0,P.jsx)(y,{size:`sm`,value:f,maxLength:500,onChange:e=>m(e.target.value),className:`bg-bg`})}),c.includes(`value`)&&(0,P.jsx)(R,{label:`Item to choose`,children:(0,P.jsx)(y,{size:`sm`,value:h,maxLength:500,onChange:e=>g(e.target.value),className:`bg-bg`})}),c.includes(`keys`)&&(0,P.jsx)(R,{label:`Keys`,children:(0,P.jsx)(y,{size:`sm`,value:v,maxLength:100,spellCheck:!1,placeholder:`ctrl+s`,onChange:e=>b(e.target.value),className:`bg-bg font-mono text-[12.5px]`})}),c.includes(`seconds`)&&(0,P.jsx)(R,{label:`Wait (seconds)`,children:(0,P.jsx)(y,{size:`sm`,type:`number`,min:0,max:600,value:S,onChange:e=>ee(e.target.value),className:`bg-bg`})}),c.includes(`timeout`)&&(0,P.jsx)(R,{label:`Timeout (seconds)`,children:(0,P.jsx)(y,{size:`sm`,type:`number`,min:0,max:600,value:C,placeholder:`default`,onChange:e=>w(e.target.value),className:`bg-bg`})}),c.includes(`note`)&&(0,P.jsx)(R,{label:`Note`,children:(0,P.jsx)(y,{size:`sm`,value:T,maxLength:200,onChange:e=>te(e.target.value),className:`bg-bg`})})]}),i===`remove`&&!E&&!O&&(0,P.jsx)(`p`,{role:`status`,className:`m-0 text-[13px] text-muted`,children:`Working out the change…`}),E&&(0,P.jsx)(re,{p:E}),O&&(0,P.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[10px] bg-fail-soft px-3 py-2 text-[13px] text-fail [overflow-wrap:anywhere]`,children:O}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[E?(0,P.jsxs)(_,{size:`sm`,variant:i===`remove`?`destructive`:`primary`,disabled:A,onClick:()=>void M(E.version),children:[i===`remove`?(0,P.jsx)(p,{"aria-hidden":`true`}):(0,P.jsx)(n,{"aria-hidden":`true`}),A?`Saving…`:i===`remove`?`Delete step ${r.n}`:`Save the change`]}):i===`edit`&&(0,P.jsx)(_,{size:`sm`,variant:`primary`,disabled:A||!Object.keys(ne()).length,onClick:()=>void M(),children:A?`Checking…`:`Preview the change`}),E&&i===`edit`&&(0,P.jsxs)(_,{size:`sm`,onClick:()=>D(null),children:[(0,P.jsx)(o,{"aria-hidden":`true`}),`Change it more`]}),(0,P.jsxs)(_,{size:`sm`,variant:`ghost`,onClick:s,children:[(0,P.jsx)(t,{"aria-hidden":`true`}),`Cancel`]})]})]})}var z=[{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.`}],B={replay:[`Replaying the workflow`,`Replayed the workflow`,`working`],validate:[`Checking the workflow`,`Checked the workflow`,`searching`]};async function ae(e){let t=await x.editStep(e);await x.editStep({...e,version:t.version})}var V=[{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 oe({step:t,onAdd:n}){let[r,i]=(0,N.useState)(`check_text`),a=t.fields?.target,[o,s]=(0,N.useState)({name:a?.name??``,automation_id:a?.automation_id??``,control_type:a?.control_type??``}),[c,l]=(0,N.useState)(``),[u,d]=(0,N.useState)(`2`),[f,p]=(0,N.useState)(``),m=V.find(e=>e.id===r),h=m.control?!!(o.name.trim()||o.automation_id.trim())&&(m.text!==`need`||!!c.trim()):r===`wait`?Number(u)>0:!!f.trim();return(0,P.jsxs)(`form`,{className:`flex flex-col gap-2.5 p-3`,onSubmit:e=>{e.preventDefault(),h&&n({kind:r,...m.control?{target:o}:{},...m.text&&c.trim()?{text:c}:{},...r===`wait`?{seconds:Number(u)}:{},...r===`keys`?{keys:f}:{}})},children:[(0,P.jsxs)(`p`,{className:`m-0 text-[13px] font-semibold`,children:[`After step `,t.n]}),(0,P.jsx)(w,{size:`sm`,"aria-label":`What to add`,value:r,onChange:e=>i(e.target.value),children:V.map(e=>(0,P.jsx)(`option`,{value:e.id,children:e.label},e.id))}),m.control&&(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,P.jsxs)(`label`,{className:`flex flex-col gap-1 text-[12.5px] font-medium`,children:[`Control's name`,(0,P.jsx)(y,{size:`sm`,value:o.name,maxLength:300,onChange:e=>s({...o,name:e.target.value})})]}),(0,P.jsxs)(`label`,{className:`flex flex-col gap-1 text-[12.5px] font-medium`,children:[`Automation id`,(0,P.jsx)(y,{size:`sm`,value:o.automation_id,maxLength:300,spellCheck:!1,onChange:e=>s({...o,automation_id:e.target.value}),className:`font-mono text-[12.5px]`})]})]}),m.text&&(0,P.jsxs)(`label`,{className:`flex flex-col gap-1 text-[12.5px] font-medium`,children:[m.text===`need`?`The text it shows`:`Showing the text (optional)`,(0,P.jsx)(y,{size:`sm`,value:c,maxLength:500,placeholder:`Invoice saved`,onChange:e=>l(e.target.value)})]}),r===`wait`&&(0,P.jsxs)(`label`,{className:`flex flex-col gap-1 text-[12.5px] font-medium`,children:[`Seconds`,(0,P.jsx)(y,{size:`sm`,type:`number`,min:1,max:600,value:u,onChange:e=>d(e.target.value)})]}),r===`keys`&&(0,P.jsxs)(`label`,{className:`flex flex-col gap-1 text-[12.5px] font-medium`,children:[`Keys`,(0,P.jsx)(y,{size:`sm`,value:f,maxLength:100,spellCheck:!1,placeholder:`ctrl+s`,onChange:e=>p(e.target.value),className:`font-mono text-[12.5px]`})]}),(0,P.jsx)(`p`,{className:`m-0 text-[12px] 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,P.jsxs)(_,{type:`submit`,size:`sm`,variant:`primary`,disabled:!h,className:`self-start`,children:[(0,P.jsx)(e,{"aria-hidden":`true`}),`Add`]})]})}var H=e=>e.name||e.automation_id||`the control`;function se({pictures:e,step:t,busy:n,onPick:r}){let[i,a]=(0,N.useState)(0),o=e[Math.min(i,e.length-1)],[s,c]=(0,N.useState)(``),[l,u]=(0,N.useState)(``),[d,f]=(0,N.useState)(null);(0,N.useEffect)(()=>{let e=!1;return c(``),u(``),f(null),x.shot(o.run,o.n).then(t=>!e&&c(t),t=>!e&&u(t.message)),x.controls(o.run,o.n).then(t=>!e&&f(t),()=>{}),()=>{e=!0}},[o.run,o.n]);let p=(e,t)=>`${Math.max(0,Math.min(100,e/t*100))}%`,m=d&&d.w>0?[...d.controls].sort((e,t)=>t.w*t.h-e.w*e.h):[];return(0,P.jsxs)(`div`,{className:`flex flex-col gap-2 pr-3 pb-3 pl-3 sm:pl-[76px]`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.length>1&&(0,P.jsx)(`div`,{role:`radiogroup`,"aria-label":`Pictures of step ${t}`,className:`flex w-fit max-w-full flex-wrap gap-1 rounded-[10px] bg-surface-strong p-1`,children:e.map((e,t)=>(0,P.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":t===i,onClick:()=>a(t),className:j(t===i),children:e.label},e.label))}),(0,P.jsxs)(`p`,{className:`m-0 text-[12.5px] text-muted`,children:[o.note,m.length>0?` Click a control to check that it shows its text, or that it is there.`:``]})]}),l&&(0,P.jsx)(`p`,{className:`m-0 text-sm text-fail`,children:l}),!s&&!l&&(0,P.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Loading the picture…`}),s&&(0,P.jsxs)(`div`,{className:`relative w-full max-w-[720px] overflow-hidden rounded-[10px] border border-line-soft`,style:m.length?{aspectRatio:`${d.w} / ${d.h}`}:void 0,children:[(0,P.jsx)(`img`,{src:s,alt:`The app after step ${t}, ${o.label.toLowerCase()}`,className:m.length?`absolute inset-0 size-full object-fill`:`block w-full`}),m.map((e,t)=>{let i=e.text?`Check ${H(e)} shows "${e.text}"`:`Check ${H(e)} is there`;return(0,P.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:p(e.x,d.w),top:p(e.y,d.h),width:p(e.w,d.w),height:p(e.h,d.h)}},`${t}-${e.automation_id||e.name}`)})]})]})}function ce({v:e,secrets:t,onSave:r,busy:i}){let[a,o]=(0,N.useState)(e.as),[s,c]=(0,N.useState)(e.name??``),[l,u]=(0,N.useState)(e.value??``);(0,N.useEffect)(()=>{o(e.as),c(e.name??``),u(e.value??``)},[e]);let d=z.filter(t=>e.op===`type`||t.id!==`secret`),f=a!==e.as||s!==(e.name??``)||l!==(e.value??``),p=a===`typed`?!0:a===`data`?/^[A-Za-z_][A-Za-z0-9_]{0,63}$/.test(s):/^[A-Z_][A-Z0-9_]{0,63}$/.test(s);return(0,P.jsxs)(`li`,{className:`flex flex-wrap items-start gap-x-4 gap-y-2 border-t border-line-soft px-3 py-2.5 first:border-t-0`,children:[(0,P.jsx)(`span`,{className:`w-6 flex-none pt-2 text-right font-mono text-[12px] text-muted tabular-nums`,children:e.n}),(0,P.jsxs)(`span`,{className:`flex min-w-0 flex-[1_1_220px] flex-col pt-1.5`,children:[(0,P.jsx)(`span`,{className:`text-[14px] text-ink [overflow-wrap:anywhere]`,children:e.line}),(0,P.jsx)(`span`,{className:`text-[12.5px] text-ink-2`,children:z.find(e=>e.id===a)?.note})]}),(0,P.jsxs)(`span`,{className:`flex flex-[1_1_360px] flex-wrap items-center gap-2`,children:[(0,P.jsx)(w,{"aria-label":`Where the value of step ${e.n} comes from`,value:a,disabled:i,onChange:e=>o(e.target.value),className:`w-[150px] flex-none`,children:d.map(e=>(0,P.jsx)(`option`,{value:e.id,children:e.label},e.id))}),a!==`typed`&&(0,P.jsx)(y,{"aria-label":a===`secret`?`The secret's environment variable`:`The test data's name`,value:s,maxLength:64,spellCheck:!1,list:a===`secret`?`desktop-secrets`:void 0,placeholder:a===`secret`?`BILLING_PASSWORD`:`customer`,onChange:e=>c(a===`secret`?e.target.value.toUpperCase():e.target.value),className:`w-[170px] flex-none font-mono text-[13px]`}),a!==`secret`&&(0,P.jsx)(y,{"aria-label":a===`data`?`Its value`:`The value`,value:l,maxLength:500,onChange:e=>u(e.target.value),className:`min-w-[140px] flex-1`}),a===`secret`&&!t.includes(s)&&s&&(0,P.jsx)(`span`,{className:`text-[12px] text-warn`,children:`Not in desktop.secrets yet`}),(0,P.jsxs)(_,{size:`sm`,variant:`primary`,disabled:i||!f||!p,onClick:()=>r(a,a===`typed`?void 0:s,a===`secret`?void 0:l),children:[(0,P.jsx)(n,{"aria-hidden":`true`}),`Save`]})]}),(0,P.jsx)(`datalist`,{id:`desktop-secrets`,children:t.map(e=>(0,P.jsx)(`option`,{value:e},e))})]})}function le({view:e,job:t,rows:n,onRun:i,busy:a,heal:o}){let[s,c]=(0,N.useState)(()=>Object.fromEntries(e.variables.map(e=>[e.name,e.value]))),[l,u]=(0,N.useState)(``),[d,f]=(0,N.useState)(o),[p,m]=(0,N.useState)(!1),h=e.lastRun,g=l.startsWith(`file:`)?{file:l.slice(5)}:l.startsWith(`request:`)?{request:l.slice(8)}:void 0,S=t&&t.kind===`replay`&&t.target===e.workflow.path;return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`p`,{className:`m-0 text-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,P.jsxs)(`form`,{className:`flex flex-col gap-3 rounded-[12px] card border p-3`,onSubmit:e=>{e.preventDefault(),i({variables:s,...g?{rows:g}:{},heal:d,updateBaselines:p})},children:[e.variables.length>0&&(0,P.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,180px),1fr))] gap-3`,children:e.variables.map(e=>(0,P.jsxs)(`label`,{className:`flex flex-col gap-1 text-[13px] font-medium text-ink-2`,children:[e.name,(0,P.jsx)(y,{value:s[e.name]??``,onChange:t=>c({...s,[e.name]:t.target.value})})]},e.name))}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,P.jsxs)(`label`,{className:`flex min-w-[220px] flex-col gap-1 text-[13px] font-medium text-ink-2`,children:[`Test data`,(0,P.jsxs)(w,{value:l,onChange:e=>u(e.target.value),children:[(0,P.jsx)(`option`,{value:``,children:`Once, with the values above`}),n.files.map(e=>(0,P.jsxs)(`option`,{value:`file:${e}`,children:[`Each row of `,e]},e)),n.requests.map(e=>(0,P.jsxs)(`option`,{value:`request:${e}`,children:[`Each row of request `,e]},e))]})]}),(0,P.jsxs)(`label`,{className:`flex min-h-10 items-center gap-2.5 text-sm text-ink-2`,children:[(0,P.jsx)(D,{checked:d,onChange:f,label:`Heal a step whose control moved`}),`Heal a moved control`]}),(0,P.jsxs)(`label`,{className:`flex min-h-10 items-center gap-2.5 text-sm text-ink-2`,children:[(0,P.jsx)(D,{checked:p,onChange:m,label:`Take new image baselines`}),`New image baselines`]}),(0,P.jsx)(`span`,{className:`flex-1`}),(0,P.jsxs)(_,{type:`submit`,variant:`primary`,disabled:a,children:[(0,P.jsx)(r,{"aria-hidden":`true`}),`Replay`]})]})]}),S&&(0,P.jsx)(M,{job:t,onStop:()=>void x.stop(),words:B}),h?(0,P.jsxs)(`section`,{"aria-labelledby":`desktop-last-run`,className:`flex flex-col gap-2`,children:[(0,P.jsx)(`h3`,{id:`desktop-last-run`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Last replay`}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-[12px] card border px-3 py-2.5 text-sm`,children:[(0,P.jsx)(b,{tone:h.ok?`pass`:`fail`,children:h.many?`${h.many.passed} of ${h.many.total} passed`:h.ok?`Passed`:`Failed`}),(0,P.jsxs)(`span`,{className:`text-muted`,children:[A(h.at),` · `,v(e.replays,`replay`),` in all`]}),h.failed&&(0,P.jsxs)(`span`,{className:`min-w-0 flex-[1_1_240px] text-[13px] text-fail [overflow-wrap:anywhere]`,children:[`Step `,h.failed.index,`: `,h.failed.error]}),(0,P.jsx)(`span`,{className:`flex-1`}),h.report&&(0,P.jsx)(k,{path:h.report,children:`Report`})]})]}):(0,P.jsx)(C,{className:`py-3`,children:`Not replayed yet.`})]})}function ue({workflow:i,onClose:a,backLabel:h=`Back`,notices:y}){let[w,T]=(0,N.useState)(null),[D,k]=(0,N.useState)(``),[A,M]=(0,N.useState)(!1),[F,I]=(0,N.useState)(`steps`),[L,re]=(0,N.useState)(``),[R,z]=(0,N.useState)(`all`),[B,V]=(0,N.useState)(null),[H,ue]=(0,N.useState)(null),[U,W]=(0,N.useState)(null),[de,G]=(0,N.useState)(``),[K,fe]=(0,N.useState)(null),[pe,me]=(0,N.useState)({files:[],requests:[]}),[he,ge]=(0,N.useState)(!0),q=(0,N.useCallback)(()=>{x.review(i).then(e=>{T(e),k(``)},e=>k(e.message))},[i]);(0,N.useEffect)(q,[q]);let J=(0,N.useCallback)(()=>{x.view().then(e=>{fe(e.job),me(e.rows),ge(e.heal)},()=>{})},[]);(0,N.useEffect)(J,[J]);let Y=!!K?.running;(0,N.useEffect)(()=>{if(!Y)return;let e=setInterval(J,1e3);return()=>clearInterval(e)},[Y,J]);let _e=K&&!K.running?K.endedAt:``;(0,N.useEffect)(()=>{_e&&q()},[_e,q]);let X=async(e,t)=>{M(!0),k(``),G(``);try{await e(),q(),t&&G(t)}catch(e){k(e.message)}finally{M(!1)}},ve=e=>void te.start(e,{}).then(({id:e})=>location.hash=S(`chats`,e),e=>k(e.message));if(!w)return D?(0,P.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:D}):(0,P.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Opening the workflow…`});let Z=w.lastRun,ye=new Map((Z?.results??[]).map(e=>[e.n,e])),be=!!Z&&Date.parse(w.workflow.modified)>Date.parse(Z.at),xe=w.steps.filter(e=>e.op.startsWith(`expect`)).length,Q=Z&&!Z.ok?Z.failed?.index??0:0,$=Q?w.steps[Q-1]:void 0,Se=(Z?.results??[]).filter(e=>!e.ok).length,Ce=L.toLowerCase().split(/\s+/).filter(Boolean),we=w.steps.filter(e=>Ce.every(t=>`${e.n} ${e.text} ${e.fields?.note||``}`.toLowerCase().includes(t))&&(R===`all`||(R===`checks`?e.op.startsWith(`expect`):ye.get(e.n)?.ok===!1))),Te=e=>{I(`steps`),z(`all`),re(``),requestAnimationFrame(()=>document.getElementById(`dstep-${e}`)?.scrollIntoView({block:`center`,behavior:`smooth`}))},Ee=e=>void X(async()=>{await x.replay({workflow:w.workflow.path,...e}),J()},`Replaying: the app opens on this computer.`),De=[{id:`steps`,label:`Steps`,n:w.steps.length},{id:`data`,label:`Test data`,n:w.values.length},{id:`run`,label:`Last run`}];return(0,P.jsxs)(`section`,{"aria-labelledby":`dreview-title`,className:`flex min-w-0 flex-col gap-4`,children:[(0,P.jsxs)(`div`,{className:`sticky top-0 z-20 -mx-1 flex flex-col gap-3 border-b border-line bg-bg px-1 py-3`,children:[a&&(0,P.jsx)(`div`,{children:(0,P.jsxs)(_,{size:`sm`,variant:`ghost`,onClick:a,className:`-ml-2 text-ink-2`,children:[(0,P.jsx)(s,{"aria-hidden":`true`}),h]})}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-3`,children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 flex-[1_1_320px] flex-col gap-1`,children:[(0,P.jsx)(`h2`,{id:`dreview-title`,className:`m-0 min-w-0 truncate text-lg font-semibold`,"data-tip":w.workflow.name,children:w.workflow.name}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[13px] text-muted`,children:[(0,P.jsxs)(`span`,{children:[w.workflow.app||`no app`,` · `,v(w.steps.length,`step`),` · `,v(xe,`check`)]}),Y&&K?.target===w.workflow.path?(0,P.jsx)(b,{tone:`running`,children:`Replaying…`}):Z?(0,P.jsx)(b,{tone:Z.ok?`pass`:`fail`,children:Z.ok?`Last replay passed`:Q?`Last replay failed at step ${Q}`:`Last replay did not get through`}):(0,P.jsx)(b,{tone:`neutral`,icon:!1,children:`Not replayed yet`}),be&&(0,P.jsx)(`span`,{children:`· you changed it since`})]})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsxs)(_,{onClick:()=>ve(`Desktop agent: look at the desktop workflow ${w.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":`Ask the Desktop agent to improve it`,children:[(0,P.jsx)(m,{"aria-hidden":`true`}),`Improve`]}),(0,P.jsxs)(_,{variant:`primary`,disabled:Y,onClick:()=>I(`run`),"data-tip":Y?`A replay is going`:`Replay it with no model`,children:[(0,P.jsx)(r,{"aria-hidden":`true`}),`Replay`]})]})]})]}),y,D&&(0,P.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:D}),de&&(0,P.jsx)(`p`,{role:`status`,className:`m-0 rounded-[10px] bg-pass-soft px-3 py-1.5 text-[13px] text-pass`,children:de}),Z&&!Z.ok&&(0,P.jsxs)(`div`,{role:`alert`,className:`flex flex-col gap-2 rounded-[12px] border border-fail/30 bg-fail-soft px-4 py-3 text-sm`,children:[(0,P.jsxs)(`p`,{className:`m-0 font-semibold text-fail`,children:[Q?`Step ${Q} failed`:`The replay did not get through`,be&&(0,P.jsx)(`span`,{className:`font-normal text-ink-2`,children:` · before your last change`})]}),$&&(0,P.jsx)(`p`,{className:`m-0 font-medium text-ink [overflow-wrap:anywhere]`,children:$.text}),(0,P.jsx)(`p`,{className:`m-0 line-clamp-3 text-[13px] text-ink-2 [overflow-wrap:anywhere]`,children:Z.failed?.error||Z.error||`It failed.`}),(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[$&&(0,P.jsxs)(_,{size:`sm`,onClick:()=>Te(Q),children:[(0,P.jsx)(l,{"aria-hidden":`true`}),`Show`]}),$&&Q>1&&(0,P.jsxs)(_,{size:`sm`,onClick:()=>(Te(Q),W({n:Q,mode:`edit`})),"data-tip":`Change the failed step: its control, text or timeout`,children:[(0,P.jsx)(o,{"aria-hidden":`true`}),`Change`]}),(0,P.jsxs)(_,{size:`sm`,variant:`ghost`,onClick:()=>ve(`Desktop agent: the last replay of ${w.workflow.path} failed${Q?` at step ${Q}`:``}. Read its report (${Z.dir}), tell me why, and offer a fix.`),children:[(0,P.jsx)(f,{"aria-hidden":`true`}),`Ask why`]})]})]}),Z&&Z.ok&&Z.heals>0&&!Z.healsAccepted&&(0,P.jsxs)(`div`,{role:`status`,className:`flex flex-wrap items-center gap-3 rounded-[12px] bg-accent-soft px-3 py-2.5 text-sm`,children:[(0,P.jsxs)(`span`,{className:`min-w-0 flex-[1_1_240px]`,children:[`The last replay found `,v(Z.heals,`moved control`),` and healed `,Z.heals===1?`it`:`them`,`: write the new locators into the workflow?`]}),(0,P.jsxs)(_,{size:`sm`,disabled:A,onClick:()=>void X(()=>x.acceptHeals(Z.dir),`The healed locators are in the workflow.`),children:[(0,P.jsx)(d,{"aria-hidden":`true`}),`Accept`]})]}),(0,P.jsx)(`div`,{role:`tablist`,"aria-label":`This workflow`,className:ne,children:De.map(e=>(0,P.jsxs)(`button`,{type:`button`,role:`tab`,id:`dreview-tab-${e.id}`,"aria-selected":F===e.id,"aria-controls":`dreview-panel-${e.id}`,onClick:()=>I(e.id),className:j(F===e.id),children:[e.label,e.n!==void 0&&(0,P.jsx)(`span`,{className:`text-[12px] text-muted tabular-nums`,children:e.n}),e.id===`run`&&Z&&(0,P.jsx)(`span`,{"aria-label":Z.ok?`passed`:`failed`,className:g(`size-2 rounded-full`,Z.ok?`bg-pass`:`bg-fail`)})]},e.id))}),(0,P.jsxs)(`div`,{role:`tabpanel`,id:`dreview-panel-${F}`,"aria-labelledby":`dreview-tab-${F}`,className:`flex min-w-0 flex-col gap-4`,children:[F===`steps`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(ee,{id:`dreview-step-search`,label:`Find a step`,value:L,onChange:re}),(0,P.jsx)(E,{items:[{id:`all`,label:`All`,n:w.steps.length},{id:`checks`,label:`Checks`,n:xe},...Se?[{id:`failed`,label:`Failed`,n:Se,alert:!0}]:[]],value:R,onChange:z})]}),xe===0&&(0,P.jsx)(`p`,{className:`m-0 rounded-[10px] bg-warn-soft px-3 py-2 text-[13px] text-warn`,children:`No checks of the outcome: a replay passes when its steps run. Add one with + after the step whose result matters.`}),we.length===0?(0,P.jsx)(`p`,{className:`m-0 rounded-[12px] card border px-4 py-4 text-sm text-muted`,children:`No step matches.`}):(0,P.jsx)(`ol`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-0 [&>li:first-child]:rounded-t-[12px] [&>li:last-child]:rounded-b-[12px]`,children:we.map((r,i)=>{let a=ye.get(r.n),s=r.op.startsWith(`expect`),d=w.recorded?.shots[r.n],f=[...d&&w.recorded?[{label:`When recorded`,run:w.recorded.run,n:d,note:`The app after step ${r.n} as you recorded it.`}]:[],...a?.shot&&Z?[{label:`Last replay`,run:Z.dir,n:r.n,note:`The app after step ${r.n} on the last replay${be?`, before your last change`:``}.`}]:[]];return(0,P.jsxs)(`li`,{id:`dstep-${r.n}`,className:g(`flex scroll-mt-48 flex-col`,i>0&&`border-t border-line-soft`,a&&!a.ok&&`bg-fail-soft`),children:[(0,P.jsxs)(`div`,{className:`group flex min-h-11 items-start gap-3 px-3 py-2`,children:[(0,P.jsx)(`span`,{className:`w-6 flex-none pt-0.5 text-right font-mono text-[12px] text-muted tabular-nums`,children:r.n}),(0,P.jsx)(`span`,{className:`flex w-4 flex-none justify-center pt-1`,children:a?a.ok?(0,P.jsx)(n,{size:14,strokeWidth:2.5,"aria-label":`Passed on the last replay`,className:`text-pass`}):(0,P.jsx)(t,{size:14,strokeWidth:2.5,"aria-label":`Failed on the last replay`,className:`text-fail`}):Z?(0,P.jsx)(c,{size:14,"aria-label":`Not replayed`,className:`text-muted`}):s?(0,P.jsx)(u,{size:14,"aria-hidden":`true`,className:`text-pass`}):(0,P.jsx)(`span`,{"aria-hidden":`true`,className:`mt-1 size-1.5 rounded-full bg-line-strong`})}),(0,P.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,P.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[s&&(0,P.jsx)(b,{tone:`pass`,icon:!1,className:`min-h-5 px-2 text-[11px]`,children:`Check`}),r.op.startsWith(`wait`)&&(0,P.jsx)(b,{tone:`neutral`,icon:!1,className:`min-h-5 px-2 text-[11px]`,children:`Wait`}),(0,P.jsx)(`span`,{className:`min-w-0 text-[14px] text-ink [overflow-wrap:anywhere]`,children:r.text}),a?.healed&&(0,P.jsx)(b,{tone:`warn`,icon:!1,className:`min-h-5 px-2 text-[11px]`,children:`Healed`})]}),r.fields?.note&&(0,P.jsxs)(`span`,{className:`text-[12.5px] text-ink-2`,children:[`Note: `,r.fields.note]}),a&&!a.ok&&a.error&&(0,P.jsx)(`span`,{className:`line-clamp-2 text-[12.5px] text-fail [overflow-wrap:anywhere]`,"data-tip":a.error,children:a.error})]}),(0,P.jsxs)(`span`,{className:`relative flex flex-none items-center gap-0.5`,children:[(0,P.jsx)(_,{size:`icon`,variant:`icon`,disabled:A,"aria-haspopup":`dialog`,"aria-expanded":B===r.n,"aria-label":`Add a check or wait after step ${r.n}`,"data-tip":`Add a check or wait after step ${r.n}`,onClick:()=>V(B===r.n?null:r.n),className:`size-8`,children:(0,P.jsx)(e,{"aria-hidden":`true`})}),(0,P.jsx)(O,{open:B===r.n,onClose:()=>V(null),label:`Add after step ${r.n}`,role:`dialog`,side:`auto`,className:`right-0 w-[min(360px,calc(100vw-48px))]`,children:(0,P.jsx)(oe,{step:r,onAdd:e=>{V(null),X(()=>ae({workflow:w.workflow.path,step:r.n,action:`insert`,...e}),`Added after step ${r.n}.`)}})}),f.length>0&&(0,P.jsx)(_,{size:`icon`,variant:`icon`,"aria-label":`See the app after step ${r.n}`,"aria-expanded":H===r.n,"data-tip":`See the app after step ${r.n}`,onClick:()=>ue(H===r.n?null:r.n),className:`size-8`,children:(0,P.jsx)(l,{"aria-hidden":`true`})}),(0,P.jsx)(_,{size:`icon`,variant:`icon`,"aria-label":`Change step ${r.n}`,"data-tip":`Change step ${r.n}`,onClick:()=>W({n:r.n,mode:`edit`}),className:`size-8`,children:(0,P.jsx)(o,{"aria-hidden":`true`})}),r.n>1&&(0,P.jsx)(_,{size:`icon`,variant:`icon`,"aria-label":`Drop step ${r.n}`,"data-tip":`Drop step ${r.n}`,onClick:()=>W({n:r.n,mode:`remove`}),className:`size-8 hover:text-fail`,children:(0,P.jsx)(p,{"aria-hidden":`true`})})]})]}),U&&U.n===r.n&&(0,P.jsx)(`div`,{className:`pr-3`,children:(0,P.jsx)(ie,{workflow:w.workflow.path,step:r,mode:U.mode,onCancel:()=>W(null),onDone:()=>{G(U.mode===`remove`?`Step ${r.n} dropped.`:`Step ${r.n} changed.`),W(null),q()}},`${r.n}-${U.mode}`)}),H===r.n&&f.length>0&&(0,P.jsx)(se,{pictures:f,step:r.n,busy:A,onPick:e=>void X(()=>ae({workflow:w.workflow.path,step:r.n,action:`insert`,kind:e.text?`check_text`:`check_present`,target:e.target,...e.text?{text:e.text}:{}}),e.text?`Added after step ${r.n}: a check that ${e.target.name||e.target.automation_id} shows "${e.text}".`:`Added after step ${r.n}: a check that ${e.target.name||e.target.automation_id} is there.`)})]},`${r.n}-${r.text}`)})})]}),F===`data`&&(w.values.length===0?(0,P.jsx)(C,{className:`py-4`,children:`Nothing is typed or chosen in this workflow, so it has no test data.`}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`p`,{className:`m-0 text-sm text-ink-2`,children:`Where each value typed or chosen comes from when it replays. Test data can come from a data file's rows on the Last run tab.`}),(0,P.jsx)(`ul`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-0`,children:w.values.map(e=>(0,P.jsx)(ce,{v:e,secrets:w.secrets,busy:A,onSave:(t,n,r)=>void X(()=>ae({workflow:w.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))})]})),F===`run`&&(0,P.jsx)(le,{view:w,job:K,rows:pe,heal:he,busy:A||Y,onRun:Ee})]})]})}export{I as n,F as r,ue as t};
@@ -1 +0,0 @@
1
- import{$t as e,An as t,Ar as n,C as r,D as i,E as a,Et as o,Ht as s,I as c,Ir as l,L as u,Ln as d,Nr as f,O as p,R as m,Rn as h,T as g,Zn as _,Zt as v,a as y,b,g as x,gr as ee,ht as S,j as C,kr as w,ln as T,qn as E,st as D,tt as te,un as ne,yt as re}from"./line-icons-CQ-3V8ax.js";import{B as O,R as k,V as A,a as ie,c as j,d as M,dt as N,f as P,h as ae,i as oe,l as F,o as I,qt as se,s as ce}from"./filters-mFECJpMB.js";import{Et as le,at as ue,et as L,gt as de,it as fe,nt as pe,r as me,rt as he,t as ge,tt as _e}from"./frame-DiKY0GWx.js";import{i as ve,p as ye,r as R,s as be}from"./index-HjX2EOmp.js";import{t as xe}from"./segmented-DANusepM.js";import{t as Se}from"./families-B0QIuAe3.js";import{i as z,r as B}from"./productParts-C4vc_bLJ.js";var V=l(f(),1),H=se(),Ce={"forgeqe-session":`ForgeQE session`,otlp:`OpenTelemetry trace`,jsonl:`the agent's own log`,langfuse:`Langfuse`,langsmith:`LangSmith`},we={tool:w,model:_,say:T,plan:e,handoff:d,ask:T,policy:E,error:ee},Te={text:`What it said`,file_change:`A file it changed`,report:`A report`,test_result:`A test result`,message:`A message it sent`},Ee={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`},De={build:{title:`Does the change work?`,icon:re},behaviour:{title:`Did it work the agreed way?`,icon:m},decisions:{title:`Did it decide on the right grounds, with data it may use?`,icon:h},content:{title:`Was its answer right: on topic, grounded, complete?`,icon:D},domain:{title:`Was its change right for the product?`,icon:x}},J=200;function Y({id:e,children:t}){let n=Se.some(t=>t.id===e);return(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-3`,children:[(0,H.jsx)(le,{pixel:de[e],size:`lg`}),(0,H.jsx)(`h1`,{className:`m-0 text-[26px] font-semibold tracking-[-0.01em]`,children:t})]}),n&&(0,H.jsx)(xe,{label:`Governance`,links:Se,current:e})]})}function X(){return(0,H.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`})}function Oe(){return(0,H.jsxs)(F,{icon:re,title:`No agent run recorded yet`,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 ke({refused:e}){return e.length?(0,H.jsxs)(`section`,{"aria-label":`Files that are not run records`,className:`flex flex-col gap-1 rounded-[12px] bg-warn-soft px-3 py-2 text-sm text-ink-2`,children:[(0,H.jsxs)(`span`,{className:`font-medium`,children:[A(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 Ae(){let[e,t]=(0,V.useState)(null),[n,r]=(0,V.useState)(``);return(0,V.useEffect)(()=>{N.overview().then(t,e=>r(e.message))},[]),(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Y,{id:`evidence`,children:`Evidence`}),(0,H.jsx)(`p`,{className:`m-0 max-w-[74ch] text-sm leading-relaxed text-ink-2`,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.`}),n&&(0,H.jsx)(B,{text:n}),!e&&!n&&(0,H.jsx)(X,{}),e&&(0,H.jsx)(ke,{refused:e.refused}),e&&!e.runs&&(0,H.jsx)(Oe,{}),e&&e.runs>0&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-x-6 gap-y-1 text-[13px] text-muted`,children:[(0,H.jsxs)(`span`,{children:[(0,H.jsx)(`b`,{className:`text-ink tabular-nums`,children:e.runs}),` `,e.runs===1?`run`:`runs`,` recorded`]}),(0,H.jsxs)(`span`,{children:[(0,H.jsx)(`b`,{className:`text-ink tabular-nums`,children:e.agents.length}),` `,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:_,n:e.agents.length,children:(0,H.jsx)(`ul`,{"aria-label":`Agents`,className:`m-0 list-none rounded-[14px] card border p-1.5`,children:e.agents.map(e=>(0,H.jsx)(`li`,{children:(0,H.jsxs)(`a`,{href:P(`evidence`,encodeURIComponent(e.name)),className:`flex min-h-12 flex-wrap items-center gap-x-4 gap-y-0.5 rounded-[10px] px-3 py-2 text-ink no-underline hover:bg-surface-muted hover:text-ink`,children:[(0,H.jsxs)(`span`,{className:`flex min-w-0 flex-[1_1_320px] flex-col`,children:[(0,H.jsx)(`span`,{className:`truncate text-[14px] font-medium`,children:U(e.name)}),(0,H.jsxs)(`span`,{className:`truncate text-[12px] text-muted`,children:[e.versions.length?`versions ${e.versions.slice(0,4).join(`, `)}${e.versions.length>4?`, …`:``} · `:``,`from `,e.sources.map(e=>Ce[e]||e).join(`, `)]})]}),(0,H.jsx)(`span`,{className:`text-[13px] text-ink-2 tabular-nums`,children:A(e.runs,`run`)}),(0,H.jsx)(`span`,{className:`text-[13px] text-ink-2 tabular-nums`,children:A(e.decisions,`decision`)}),(0,H.jsxs)(`span`,{className:`text-[13px] text-muted tabular-nums`,children:[A(e.gaps,`thing`,`things`),` not known`]}),(0,H.jsx)(`span`,{className:`text-[13px] 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=>A(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-[12.5px] text-muted tabular-nums`,"data-tip":W(e.last),children:e.last?R(e.last):``})]})},e.name))})})]})]})}var Z={PASS:`Passed`,WARN:`Warned`,FAIL:`Failed`,UNKNOWN:`Not known`,NONE:`Not judged`};function je({t:e,label:t,on:n,onToggle:r,fail:i}){return e.n?(0,H.jsx)(`button`,{type:`button`,"aria-pressed":n,"aria-label":`${e.n}: ${t}. Show the runs`,onClick:r,className:O(`inline-flex min-h-7 min-w-7 cursor-pointer items-center justify-end rounded-[8px] border-0 px-1.5 tabular-nums hover:underline`,n?`bg-accent-soft text-accent-fg`:`bg-transparent text-accent-fg`,i&&!n&&`text-fail`),children:e.n}):(0,H.jsx)(`span`,{className:`inline-flex min-h-7 items-center justify-end px-1.5 text-muted tabular-nums`,children:`0`})}function Me({pick:e,d:t,onClose:r}){let[i,a]=(0,V.useState)(!1),o=i?e.runs:e.runs.slice(0,25);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-[12px] bg-surface-muted p-3`,children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,H.jsxs)(`span`,{className:`text-[13px] font-medium text-ink [overflow-wrap:anywhere]`,children:[A(e.runs.length,`run`),` behind `,U(e.label)]}),(0,H.jsxs)(k,{size:`sm`,variant:`ghost`,onClick:r,children:[(0,H.jsx)(n,{"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:o.map(e=>{let n=t.brief[e];return(0,H.jsx)(`li`,{children:(0,H.jsxs)(`a`,{href:P(`evidence-runs`,encodeURIComponent(e)),className:`grid min-h-10 grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-x-3 rounded-[8px] px-2.5 py-1 text-ink no-underline hover:bg-surface-muted hover:text-ink`,children:[n&&n.status!==`NONE`?(0,H.jsx)(j,{tone:K[n.status].tone,children:K[n.status].label}):(0,H.jsx)(`span`,{className:`text-[12px] text-muted`,children:`Not judged`}),(0,H.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,H.jsx)(`span`,{className:`truncate text-[13px]`,children:U(n?.request||e)}),(0,H.jsxs)(`span`,{className:`truncate font-mono text-[11.5px] text-muted`,children:[e,n?.version?` · ${U(n.version)}`:``]})]}),(0,H.jsx)(`span`,{className:`text-right text-[12px] text-muted tabular-nums`,"data-tip":W(n?.started),children:n?.started?R(n.started):``})]})},e)})}),e.runs.length>o.length&&(0,H.jsxs)(k,{size:`sm`,variant:`ghost`,onClick:()=>a(!0),children:[(0,H.jsx)(g,{"aria-hidden":`true`}),`All (`,e.runs.length,`)`]})]})}function Ne({agent:t}){let[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(``),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(null);(0,V.useEffect)(()=>{N.dashboard(t).then(r,e=>a(e.message))},[t]);let d=e=>e?U(e):`no version`,f=n?n.versions.find(e=>e.version===s)||n.versions[0]:void 0,p=e=>l&&n&&l.key.startsWith(`${e}|`)?(0,H.jsx)(Me,{pick:l,d:n,onClose:()=>u(null)},l.key):null,m=(e,t,n,r)=>{let i=`${e}|${n}`;return(0,H.jsx)(je,{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.jsxs)(`a`,{href:P(`evidence`),className:`inline-flex min-h-8 w-fit items-center gap-1.5 text-[13px] text-accent-fg no-underline hover:underline`,children:[(0,H.jsx)(ae,{icon:y,size:14}),` Evidence`]}),(0,H.jsx)(Y,{id:`evidence`,children:U(t)}),(0,H.jsx)(`p`,{className:`m-0 max-w-[74ch] text-sm leading-relaxed text-ink-2`,children:`How this agent's runs were judged, version by version and week by week. 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.`}),i&&(0,H.jsx)(B,{text:i}),!n&&!i&&(0,H.jsx)(X,{}),n?.problems.map(e=>(0,H.jsx)(B,{text:e},e)),n&&f&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-x-6 gap-y-1 text-[13px] text-muted`,children:[(0,H.jsxs)(`span`,{children:[(0,H.jsx)(`b`,{className:`text-ink tabular-nums`,children:n.runs.n}),` `,n.runs.n===1?`run`:`runs`]}),(0,H.jsxs)(`span`,{children:[(0,H.jsx)(`b`,{className:`text-ink tabular-nums`,children:n.versions.length}),` `,n.versions.length===1?`version`:`versions`]}),(0,H.jsx)(`a`,{href:P(`evidence-runs`,`agent`,encodeURIComponent(t)),children:`All its runs`}),(0,H.jsx)(`a`,{href:P(`evidence-learn`,encodeURIComponent(t)),children:`What to change`})]}),(0,H.jsx)(`h2`,{className:`sr-only`,children:`Its numbers`}),(0,H.jsxs)(z,{id:`versions`,title:`Versions`,icon:o,n:n.versions.length,children:[(0,H.jsx)(L,{label:`Versions of ${t}`,search:!1,minWidth:640,head:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left text-[11.5px] 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-3 py-1.5 text-right text-[11.5px] font-medium whitespace-nowrap text-muted`,children:e},e)),(0,H.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left text-[11.5px] font-medium whitespace-nowrap text-muted`,children:`Last run`})]}),children:n.versions.map(e=>(0,H.jsxs)(`tr`,{className:`border-t border-line-soft align-top`,children:[(0,H.jsx)(`th`,{scope:`row`,className:O(`px-3 py-2`,`text-left font-medium`),children:d(e.version)}),(0,H.jsx)(`td`,{className:`px-3 py-2 text-right whitespace-nowrap tabular-nums`,children:m(`versions`,e.runs,`${d(e.version)}: runs`)}),[`PASS`,`WARN`,`FAIL`,`UNKNOWN`,`NONE`].map(t=>(0,H.jsx)(`td`,{className:`px-3 py-2 text-right whitespace-nowrap tabular-nums`,children:m(`versions`,e.outcome[t],`${d(e.version)}: ${Z[t].toLowerCase()}`,t===`FAIL`)},t)),(0,H.jsx)(`td`,{className:O(`px-3 py-2`,`text-muted`),"data-tip":W(e.last),children:e.last?R(e.last):``})]},e.version))}),p(`versions`)]}),n.versions.length>1&&n.benchmark.length>0&&(0,H.jsxs)(z,{id:`benchmark`,title:`Versions side by side`,icon:h,children:[(0,H.jsx)(`p`,{className:`m-0 max-w-[74ch] text-[13px] 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)(L,{label:`Versions side by side`,search:!1,minWidth:480,head:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left text-[11.5px] font-medium whitespace-nowrap text-muted`,children:`Check`}),n.versions.map(e=>(0,H.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-right text-[11.5px] font-medium whitespace-nowrap text-muted`,children:d(e.version)},e.version))]}),children:n.benchmark.map(e=>(0,H.jsxs)(`tr`,{className:`border-t border-line-soft align-top`,children:[(0,H.jsx)(`th`,{scope:`row`,className:O(`px-3 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-3 py-2 text-right whitespace-nowrap tabular-nums`,children:t.rate===null?(0,H.jsx)(`span`,{className:`text-muted`,children:`not judged`}):(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,H.jsxs)(`span`,{className:O(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&&m(`benchmark`,n,`${q[e.check]} on ${d(t.version)}: not passed`,!0)]})},t.version)})]},`${e.lens}-${e.check}`))}),p(`benchmark`)]}),(0,H.jsxs)(z,{id:`checks`,title:`Checks`,icon:e,n:f.checks.length,children:[n.versions.length>1&&(0,H.jsxs)(`label`,{className:`flex w-fit items-center gap-2 text-[13px] text-ink-2`,children:[`Version`,(0,H.jsx)(I,{value:f.version,onChange:e=>{c(e.target.value),u(null)},children:n.versions.map(e=>(0,H.jsx)(`option`,{value:e.version,children:e.version||`no version`},e.version))})]}),f.checks.length?(0,H.jsx)(L,{label:`Checks of ${d(f.version)}`,search:!1,minWidth:600,head:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left text-[11.5px] font-medium whitespace-nowrap text-muted`,children:`Check`}),(0,H.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left text-[11.5px] font-medium whitespace-nowrap text-muted`,children:`Lens`}),[`Passed`,`Warned`,`Failed`,`Not known`,`Overruled`].map(e=>(0,H.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-right text-[11.5px] font-medium whitespace-nowrap text-muted`,children:e},e))]}),children:f.checks.map(e=>(0,H.jsxs)(`tr`,{className:`border-t border-line-soft align-top`,children:[(0,H.jsx)(`th`,{scope:`row`,className:O(`px-3 py-2`,`text-left font-medium`),children:q[e.check]}),(0,H.jsx)(`td`,{className:O(`px-3 py-2`,`text-muted`),children:Ue[e.lens]}),[`PASS`,`WARN`,`FAIL`,`UNKNOWN`].map(t=>(0,H.jsx)(`td`,{className:`px-3 py-2 text-right whitespace-nowrap tabular-nums`,children:m(`checks`,e.outcome[t],`${q[e.check]}: ${Z[t].toLowerCase()}`,t===`FAIL`)},t)),(0,H.jsx)(`td`,{className:`px-3 py-2 text-right whitespace-nowrap tabular-nums`,children:m(`checks`,e.overruled,`${q[e.check]}: overruled`)})]},`${e.lens}-${e.check}`))}):(0,H.jsxs)(`p`,{className:`m-0 text-sm text-muted`,children:[`No contract judged these runs: `,(0,H.jsx)(`a`,{href:P(`evidence-contracts`),children:`Contracts`}),` says what one agrees.`]}),p(`checks`)]}),f.rules.length>0&&(0,H.jsxs)(z,{id:`recurring`,title:`What keeps going wrong`,icon:ee,n:f.rules.length,children:[(0,H.jsx)(`ul`,{"aria-label":`What keeps going wrong`,className:`m-0 list-none rounded-[14px] card border p-1.5`,children:f.rules.slice(0,20).map(e=>(0,H.jsxs)(`li`,{className:`flex flex-col gap-0.5 border-b border-line-soft px-3 py-2 last:border-b-0`,children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,H.jsx)(j,{tone:K[e.status].tone,children:K[e.status].label}),(0,H.jsxs)(`span`,{className:`text-[13.5px] font-medium`,children:[q[e.check],`: `,U(e.rule)]}),(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[12.5px] text-muted`,children:[`in `,m(`recurring`,e.runs,`${q[e.check]}: ${e.rule}`),` `,e.runs.n===1?`run`:`runs`]})]}),(0,H.jsxs)(`span`,{className:`text-[12.5px] text-ink-2 [overflow-wrap:anywhere]`,children:[`For example: `,U(e.example)]})]},`${e.check}-${e.rule}`))}),p(`recurring`)]}),(0,H.jsxs)(z,{id:`weeks`,title:`Week by week`,icon:b,n:n.weeks.length,children:[(0,H.jsx)(L,{label:`Week by week`,search:!1,minWidth:520,head:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left text-[11.5px] font-medium whitespace-nowrap text-muted`,children:`Week`}),[`PASS`,`WARN`,`FAIL`,`UNKNOWN`,`NONE`].map(e=>(0,H.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-right text-[11.5px] font-medium whitespace-nowrap text-muted`,children:Z[e]},e))]}),children:[...n.weeks].reverse().map(e=>(0,H.jsxs)(`tr`,{className:`border-t border-line-soft align-top`,children:[(0,H.jsx)(`th`,{scope:`row`,className:O(`px-3 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-3 py-2 text-right whitespace-nowrap tabular-nums`,children:m(`weeks`,e.outcome[t],`${e.week}: ${Z[t].toLowerCase()}`,t===`FAIL`)},t))]},e.week))}),p(`weeks`)]})]})]})}function Pe({agent:e}){let[t,n]=(0,V.useState)(null),[r,o]=(0,V.useState)([]),[s,c]=(0,V.useState)(``),[l,d]=(0,V.useState)(``),[f,p]=(0,V.useState)(e),[m,h]=(0,V.useState)(`all`),[g,_]=(0,V.useState)(0);(0,V.useEffect)(()=>{N.runs().then(e=>{n(e.runs),o(e.refused)},e=>c(e.message))},[]),(0,V.useEffect)(()=>p(e),[e]);let v=(0,V.useMemo)(()=>[...new Set((t||[]).map(e=>e.agent))].sort(),[t]),y=l.toLowerCase().split(/\s+/).filter(Boolean),b=(t||[]).filter(e=>(!f||e.agent===f)&&y.every(t=>`${e.agent} ${e.request||``} ${e.id} ${e.source.name}`.toLowerCase().includes(t))),x=m===`failed`?b.filter(e=>e.failed):b,ee={all:b.length,failed:b.filter(e=>e.failed).length},S=Math.max(1,Math.ceil(x.length/G)),w=Math.min(g,S-1),T=x.slice(w*G,w*G+G);(0,V.useEffect)(()=>_(0),[l,f,m]);let E=t||[],D=E.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)(`p`,{className:`m-0 max-w-[74ch] text-sm leading-relaxed text-ink-2`,children:`Every agent run recorded here, newest first. 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.`}),s&&(0,H.jsx)(B,{text:s}),!t&&!s&&(0,H.jsx)(X,{}),(0,H.jsx)(ke,{refused:r}),t&&!t.length&&(0,H.jsx)(Oe,{}),t&&t.length>0&&(0,H.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-x-6 gap-y-1 text-[13px] text-muted`,children:[(0,H.jsxs)(`span`,{children:[(0,H.jsx)(`b`,{className:`text-ink tabular-nums`,children:E.length}),` `,E.length===1?`run`:`runs`]}),(0,H.jsxs)(`span`,{children:[(0,H.jsx)(`b`,{className:O(`tabular-nums`,D?`text-fail`:`text-ink`),children:D}),` with a failed step (`,Math.round(D/E.length*100),`%)`]}),(0,H.jsxs)(`span`,{children:[(0,H.jsx)(`b`,{className:`text-ink tabular-nums`,children:E.reduce((e,t)=>e+t.decisions,0)}),` `,E.reduce((e,t)=>e+t.decisions,0)===1?`decision`:`decisions`]}),(0,H.jsxs)(`span`,{children:[(0,H.jsx)(`b`,{className:`text-ink tabular-nums`,children:new Set(E.map(e=>e.agent)).size}),` `,new Set(E.map(e=>e.agent)).size===1?`agent`:`agents`]})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(oe,{id:`evidence-search`,label:`Find a run`,value:l,onChange:d,placeholder:`Find a run by what was asked`}),[[`all`,`All`],[`failed`,`Failed`]].map(([e,t])=>(0,H.jsxs)(`button`,{type:`button`,"aria-pressed":m===e,onClick:()=>h(e),className:O(`inline-flex min-h-8 cursor-pointer items-center gap-1 rounded-[8px] border px-3 text-[13px] font-medium`,m===e?`border-accent bg-accent-soft text-ink`:`border-transparent bg-surface-strong text-ink-2 hover:bg-line hover:text-ink`),children:[t,(0,H.jsx)(`span`,{className:O(`tabular-nums`,e===`failed`&&ee.failed?`text-fail`:``),children:ee[e]})]},e)),v.length>1&&(0,H.jsxs)(I,{size:`sm`,"aria-label":`Agent`,value:f,onChange:e=>p(e.target.value),className:`w-auto pr-7 pl-3`,children:[(0,H.jsx)(`option`,{value:``,children:`Every agent`}),v.map(e=>(0,H.jsx)(`option`,{value:e,children:U(e)},e))]})]}),(0,H.jsxs)(`div`,{className:`rounded-[14px] card border`,children:[(0,H.jsxs)(`ul`,{"aria-label":`Agent runs`,className:`m-0 list-none p-1.5`,children:[!T.length&&(0,H.jsx)(`li`,{className:`px-3 py-4 text-sm text-muted`,children:`Nothing matches.`}),T.map((e,t)=>(0,H.jsxs)(`li`,{className:`contents`,children:[(t===0||ve(T[t-1].started)!==ve(e.started))&&(0,H.jsx)(`span`,{className:`block px-3 pt-3 pb-1 text-[12px] font-semibold text-muted`,children:ve(e.started)}),(0,H.jsxs)(`a`,{href:P(`evidence-runs`,encodeURIComponent(e.id)),className:`grid min-h-12 grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-x-3 rounded-[10px] px-3 py-1.5 text-ink no-underline hover:bg-surface-muted hover:text-ink`,children:[e.failed?(0,H.jsx)(u,{size:16,"aria-label":`${e.failed} failed ${e.failed===1?`step`:`steps`}`,className:`flex-none text-fail`}):(0,H.jsx)(C,{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-[14px] font-medium`,"data-tip":e.request||e.agent,children:U(e.request||`${e.agent}: request not recorded`)}),(0,H.jsx)(`span`,{className:`truncate text-[12px] text-muted`,children:[U(`${e.agent}${e.version?` ${e.version}`:``}`),A(e.steps,`step`),A(e.decisions,`decision`),`${A(e.gaps,`thing`,`things`)} not known`,Ce[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-[12.5px] text-muted tabular-nums`,"data-tip":W(e.started),children:e.started?R(e.started):``})]})]},e.id))]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 border-t border-line-soft px-4 py-2.5 text-[13px] text-muted`,children:[(0,H.jsx)(`span`,{className:`flex-1`,children:x.length?`${w*G+1}–${Math.min(x.length,w*G+G)} of ${x.length}`:`0 runs`}),S>1&&(0,H.jsxs)(`nav`,{"aria-label":`Pages of agent runs`,className:`flex items-center gap-1`,children:[(0,H.jsx)(k,{size:`sm`,variant:`ghost`,disabled:w===0,onClick:()=>_(w-1),"aria-label":`Newer runs`,"data-tip":`Newer runs`,children:(0,H.jsx)(a,{"aria-hidden":`true`})}),(0,H.jsxs)(`span`,{className:`px-1 tabular-nums`,children:[`Page `,w+1,` of `,S]}),(0,H.jsx)(k,{size:`sm`,variant:`ghost`,disabled:w>=S-1,onClick:()=>_(w+1),"aria-label":`Older runs`,"data-tip":`Older runs`,children:(0,H.jsx)(i,{"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-[12px] 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-[13px] whitespace-pre-wrap text-ink-2 [overflow-wrap:anywhere]`,children:U(i&&!n?`${e.text.slice(0,600)}…`:e.text)}),i&&(0,H.jsxs)(`button`,{type:`button`,onClick:()=>r(!n),"data-tip":n?void 0:`Show all ${e.text.length.toLocaleString()} characters`,className:`inline-flex cursor-pointer items-center gap-1 border-0 bg-transparent p-0 text-[12px] text-accent-fg hover:underline`,children:[n?(0,H.jsx)(p,{size:12,"aria-hidden":`true`}):(0,H.jsx)(g,{size:12,"aria-hidden":`true`}),n?`Less`:`More`]})]})}function Fe({d:e}){return(0,H.jsxs)(`div`,{className:`flex flex-col gap-0.5 border-l-2 border-accent-line pl-3`,children:[(0,H.jsxs)(`span`,{className:`text-[12px] font-medium text-muted`,children:[`Decided`,e.by?` · by ${U(e.by)}`:``]}),(0,H.jsxs)(`span`,{className:`text-[13px] text-ink [overflow-wrap:anywhere]`,children:[U(e.what),`: `,(0,H.jsx)(`b`,{className:`font-semibold`,children:U(e.chose)})]}),e.options&&e.options.length>0&&(0,H.jsxs)(`span`,{className:`text-[12px] text-muted [overflow-wrap:anywhere]`,children:[`Options: `,U(e.options.join(`, `))]}),e.reason?(0,H.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,H.jsx)(`span`,{className:`text-[12px] 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-[12px] text-muted`,children:`No reason given.`})]})}function Ie({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.5 outline-none last:border-b-0 focus-visible:bg-accent-soft`,children:[(0,H.jsx)(`span`,{className:`pt-0.5 text-right text-[12px] text-muted tabular-nums`,children:e.seq}),(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,H.jsx)(ae,{icon:we[e.kind]||w,size:14,className:`flex-none`}),(0,H.jsx)(`span`,{className:`text-[14px] font-medium [overflow-wrap:anywhere]`,children:U(e.name)}),(0,H.jsx)(`span`,{className:`text-[12px] text-muted`,children:e.kind}),e.agent&&(0,H.jsxs)(`span`,{className:`text-[12px] text-muted`,children:[`· by `,U(e.agent)]}),e.ok===!1&&(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[12px] text-fail`,children:[(0,H.jsx)(u,{size:13,"aria-hidden":`true`}),`failed`]}),e.ms!==void 0&&(0,H.jsxs)(`span`,{className:`text-[12px] text-muted tabular-nums`,children:[`· `,e.ms.toLocaleString(),` ms`]})]}),a.length>0&&(0,H.jsx)(`span`,{className:`text-[12px] 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-3`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer text-[12px] 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-0.5 border-l-2 border-line pl-3`,children:[(0,H.jsxs)(`span`,{className:`text-[12px] font-medium text-muted [overflow-wrap:anywhere]`,children:[`Took in `,Ee[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)(Fe,{d:e},e.seq)),i.map(e=>(0,H.jsxs)(`div`,{className:`flex flex-col gap-0.5 border-l-2 border-line pl-3`,children:[(0,H.jsx)(`span`,{className:`text-[12px] 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 Le({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),c=e.outputs.filter(e=>e.kind!==`text`),l=e=>n.reduce((t,n)=>t+(typeof n.facts?.[e]==`number`?n.facts[e]:0),0),u=l(`tokens_in`),d=l(`tokens_out`),f=[...new Set(n.map(e=>e.name))],p=({children:e})=>(0,H.jsx)(`span`,{className:`text-[12px] font-medium text-muted`,children:e}),m=({seq:e})=>(0,H.jsxs)(`button`,{type:`button`,onClick:()=>t(e),className:`cursor-pointer border-0 bg-transparent p-0 text-[12px] text-accent-fg hover:underline`,children:[`step `,e]});return(0,H.jsx)(z,{id:`evidence-io`,title:`Prompt and output`,icon:ne,children:(0,H.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(n.length>0||u+d>0)&&(0,H.jsxs)(`p`,{className:`m-0 text-[13px] text-ink-2`,children:[n.length,` model `,n.length===1?`call`:`calls`,f.length?` (${U(f.join(`, `))})`:``,u+d>0?` · ${u.toLocaleString()} tokens in, ${d.toLocaleString()} out`:``]}),(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,H.jsxs)(p,{children:[`Instructions (system prompt)`,r?(0,H.jsxs)(H.Fragment,{children:[` · from `,(0,H.jsx)(m,{seq:r.seq})]}):null,i>1?` · ${i} different ones in this run`:``]}),(0,H.jsx)(`div`,{className:`rounded-[12px] bg-surface-muted px-3 py-2`,children:r?.instructions?(0,H.jsx)(Q,{t:r.instructions,label:`instructions`}):(0,H.jsx)(`span`,{className:`text-[13px] 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-1.5`,children:[(0,H.jsxs)(p,{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:`rounded-[12px] bg-surface-muted px-3 py-2`,children:e.request?.text?(0,H.jsx)(Q,{t:e.request.text,label:`request`}):(0,H.jsx)(`span`,{className:`text-[13px] 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-1.5`,children:[(0,H.jsxs)(p,{children:[`Final answer`,o?(0,H.jsxs)(H.Fragment,{children:[` · `,(0,H.jsx)(m,{seq:o.step})]}):null]}),(0,H.jsx)(`div`,{className:`rounded-[12px] bg-surface-muted px-3 py-2`,children:o?.data?(0,H.jsx)(Q,{t:o.data,label:`answer`}):(0,H.jsx)(`span`,{className:`text-[13px] text-muted`,children:`Not in the record: its source did not say what the agent answered.`})})]})]}),c.length>0&&(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,H.jsxs)(p,{children:[`What it produced (`,c.length,`)`]}),(0,H.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0`,children:c.map(e=>(0,H.jsxs)(`li`,{className:`flex flex-wrap items-center gap-x-1.5 text-[13px] text-ink-2`,children:[Te[e.kind]||e.kind,e.target?(0,H.jsx)(`span`,{className:`font-mono text-[12px] [overflow-wrap:anywhere]`,children:U(e.target)}):null,`· `,(0,H.jsx)(m,{seq:e.step})]},e.id))})]}),s.length>0&&(0,H.jsxs)(`details`,{className:`group flex flex-col gap-1.5`,children:[(0,H.jsxs)(`summary`,{className:`cursor-pointer text-[12px] 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-3`,children:[(0,H.jsx)(m,{seq:e.step}),e.data?(0,H.jsx)(Q,{t:e.data,label:`said`}):null]},e.id))})]})]})})}function Re({id:e}){let[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)(``),[a,o]=(0,V.useState)(J);(0,V.useEffect)(()=>{N.run(e).then(n,e=>i(e.message))},[e]);let c=(0,H.jsxs)(`a`,{href:P(`evidence-runs`),className:`inline-flex items-center gap-1.5 self-start text-sm`,children:[(0,H.jsx)(y,{size:16,"aria-hidden":`true`}),`All agent runs`]});if(!t)return(0,H.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[c,r?(0,H.jsx)(B,{text:r}):(0,H.jsx)(X,{})]});let l=t.decisions.filter(e=>!e.step),u=t.steps.filter(e=>e.ok===!1).length,f=e=>{e>a&&o(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-5`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[c,(0,H.jsx)(`h2`,{id:`evidence-run-h`,className:`m-0 text-[22px] font-semibold tracking-[-0.01em] [overflow-wrap:anywhere]`,children: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-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 `,Ce[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-[12px] text-muted`,children:t.id})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-x-6 gap-y-1 text-[13px] 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:O(`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)(Le,{r:t,goTo:f}),(0,H.jsx)(ze,{id:t.id,goTo:f}),(0,H.jsx)(z,{id:`evidence-gaps`,title:`What the record cannot say`,icon:s,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-[13px] text-ink-2 last:border-b-0 [overflow-wrap:anywhere]`,children:U(e)},e))}):(0,H.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Nothing: the source said everything the record holds.`})}),(0,H.jsxs)(z,{id:`evidence-timeline`,title:`Timeline`,icon:d,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,a).map(e=>(0,H.jsx)(Ie,{s:e,r:t},e.seq))}),t.steps.length>a&&(0,H.jsxs)(k,{size:`sm`,variant:`ghost`,className:`self-start`,onClick:()=>o(a+J),"data-tip":`Show ${Math.min(J,t.steps.length-a)} more of ${t.steps.length-a}`,children:[(0,H.jsx)(g,{"aria-hidden":`true`}),`More (`,Math.min(J,t.steps.length-a),`)`]})]}),l.length>0&&(0,H.jsx)(z,{id:`evidence-loose`,title:`Decisions not tied to a step`,icon:h,n:l.length,children:(0,H.jsx)(`div`,{className:`flex flex-col gap-3`,children:l.map(e=>(0,H.jsx)(Fe,{d:e},e.seq))})}),(0,H.jsx)(z,{id:`evidence-inputs`,title:`Data it took in`,icon:S,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-3 gap-y-0.5 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-[13px] [overflow-wrap:anywhere]`,children:[(0,H.jsx)(`span`,{className:`font-medium`,children:Ee[e.kind]||e.kind}),` `,(0,H.jsx)(`span`,{className:`text-muted`,children:`from`}),` `,U(e.source)]}),(0,H.jsxs)(`span`,{className:`text-[12px] text-muted tabular-nums`,children:[`step `,e.step]}),(0,H.jsx)(`span`,{className:`font-mono text-[12px] 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-sm text-muted`,children:`The record holds no input.`})})]})}function ze({id:e,goTo:t}){let[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(``),[o,s]=(0,V.useState)(0),c=()=>s(e=>e+1);if((0,V.useEffect)(()=>{N.verdict(e).then(r,e=>a(e.message))},[e,o]),i)return(0,H.jsx)(B,{text:i});if(!n)return(0,H.jsx)(X,{});let l=n.why||!n.verdicts.length?(0,H.jsx)(z,{id:`evidence-behaviour`,title:De.behaviour.title,icon:m,children:(0,H.jsxs)(`p`,{className:`m-0 max-w-[74ch] text-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:P(`evidence-contracts`),children:`Contracts`}),` lists them.`]})}):null;return(0,H.jsxs)(H.Fragment,{children:[n.work&&(0,H.jsxs)(`p`,{className:O(`m-0 rounded-[12px] px-3 py-2 text-sm`,n.work.personTakesOver?`bg-warn-soft text-ink`:`bg-surface-muted text-ink-2`),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:P(`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.`:`.`]}),l,n.verdicts.map(e=>(0,H.jsx)(z,{id:`evidence-${e.lens}`,title:De[e.lens].title,icon:De[e.lens].icon,children:(0,H.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,H.jsx)(j,{tone:K[e.status].tone,children:K[e.status].label}),(0,H.jsx)(`span`,{className:`text-[13px] 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-[13px] text-muted [overflow-wrap:anywhere]`,children:U(e)},e)),(0,H.jsx)(`ul`,{"aria-label":`Checks`,className:`m-0 flex list-none flex-col rounded-[14px] card border p-1.5`,children:e.checks.map(n=>(0,H.jsxs)(`li`,{className:`flex flex-col gap-1.5 border-b border-line-soft px-3 py-2.5 last:border-b-0`,children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,H.jsx)(`span`,{className:`min-w-[152px] text-[14px] font-medium`,children:q[n.check]}),(0,H.jsx)(j,{tone:K[n.status].tone,children:K[n.status].label}),(0,H.jsxs)(`span`,{className:`text-[12px] 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)(Ve,{f:n,run:e.run,goTo:t,onOverruled:c},n.id))]},n.check))}),e.lens===`content`&&n.rubric&&(0,H.jsx)(Be,{run:e.run,rubric:n.rubric,onGraded:c})]})},e.lens))]})}function Be({run:e,rubric:t,onGraded:i}){let[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(``),[l,u]=(0,V.useState)(!1),[d,f]=(0,V.useState)(``),p=s.trim().length>=10&&s.trim().length<=500,m=async()=>{if(a){u(!0),f(``);try{await N.grade(e,a.id,a.grade,s.trim()),o(null),c(``),i()}catch(e){f(e.message)}finally{u(!1)}}};return(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsx)(`h4`,{className:`m-0 text-sm font-semibold`,children:`Grade the answer`}),(0,H.jsxs)(`p`,{className:`m-0 max-w-[74ch] text-[13px] 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:`m-0 max-w-[74ch] whitespace-pre-wrap rounded-[12px] bg-surface-muted px-3 py-2 text-[13px] text-ink [overflow-wrap:anywhere]`,children:U(t.answer)}),(0,H.jsx)(`ul`,{"aria-label":`Rubric criteria`,className:`m-0 flex list-none flex-col rounded-[14px] card border p-1.5`,children:t.criteria.map(e=>(0,H.jsxs)(`li`,{className:`flex flex-col gap-1.5 border-b border-line-soft px-3 py-2.5 last:border-b-0`,children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,H.jsxs)(`span`,{className:`text-[13px] 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)(j,{tone:e.grade.grade===`meets`?`pass`:`warn`,children:e.grade.grade===`meets`?`Meets`:`Misses`}),(0,H.jsx)(`span`,{className:`text-[12px] text-muted`,children:e.grade?`Grade again:`:`Grade:`}),[`meets`,`misses`].map(t=>(0,H.jsx)(`button`,{type:`button`,"aria-label":`${e.id} ${t===`meets`?`meets`:`misses`}`,onClick:()=>o({id:e.id,grade:t}),className:`inline-flex min-h-7 cursor-pointer items-center rounded-[8px] border-0 bg-transparent px-2 text-[12px] text-accent-fg hover:underline`,children:t===`meets`?`Meets`:`Misses`},t))]}),e.grade&&(0,H.jsxs)(`span`,{className:`text-[12.5px] text-ink-2 [overflow-wrap:anywhere]`,children:[`Graded by `,U(e.grade.by),` `,W(e.grade.at),`: `,U(e.grade.reason)]}),a?.id===e.id&&(0,H.jsxs)(`div`,{className:`flex max-w-[640px] flex-col gap-2 rounded-[12px] bg-surface-muted p-3`,children:[(0,H.jsxs)(`label`,{htmlFor:`grade-${e.id}`,className:`text-[12.5px] font-medium text-ink-2`,children:[`Why does the answer `,a.grade===`meets`?`meet`:`miss`,` it?`]}),(0,H.jsx)(ce,{id:`grade-${e.id}`,value:s,onChange:e=>c(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)(k,{size:`sm`,disabled:!p||l,onClick:m,"data-tip":a.grade===`meets`?`Keep the grade: meets`:`Keep the grade: misses`,children:[(0,H.jsx)(r,{"aria-hidden":`true`}),l?`Keeping…`:`Keep`]}),(0,H.jsxs)(k,{size:`sm`,variant:`ghost`,onClick:()=>o(null),children:[(0,H.jsx)(n,{"aria-hidden":`true`}),`Cancel`]})]})]})]},e.id))})]})}function Ve({f:e,run:t,goTo:r,onOverruled:i}){let[a,o]=(0,V.useState)(!1),[s,l]=(0,V.useState)(``),[u,d]=(0,V.useState)(!1),[f,p]=(0,V.useState)(``),m=s.trim().length>=10&&s.trim().length<=500,h=async()=>{d(!0),p(``);try{await N.overrule(t,e.id,s.trim()),o(!1),i()}catch(e){p(e.message)}finally{d(!1)}};return(0,H.jsxs)(`div`,{className:O(`flex flex-col gap-1 border-l-2 pl-3`,e.overruled?`border-line opacity-80`:e.status===`FAIL`?`border-fail`:e.status===`WARN`?`border-warn`:`border-line`),children:[(0,H.jsx)(`span`,{className:O(`text-[13px] [overflow-wrap:anywhere]`,e.overruled?`text-ink-2`:`text-ink`),children:U(e.what)}),e.fix&&!e.overruled&&(0,H.jsxs)(`span`,{className:`text-[12.5px] text-ink-2 [overflow-wrap:anywhere]`,children:[`Fix: `,U(e.fix)]}),e.overruled&&(0,H.jsxs)(`span`,{className:`text-[12.5px] 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-[12px] 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)(`button`,{type:`button`,onClick:()=>r(e),className:`inline-flex min-h-7 cursor-pointer items-center rounded-[8px] border-0 bg-surface-strong px-2 text-[12px] text-accent-fg tabular-nums hover:underline`,children:[`step `,e]},e)),!e.overruled&&e.status!==`UNKNOWN`&&!a&&(0,H.jsxs)(`button`,{type:`button`,onClick:()=>o(!0),className:`inline-flex min-h-7 cursor-pointer items-center gap-1 rounded-[8px] border-0 bg-transparent px-2 text-[12px] text-accent-fg hover:underline`,children:[(0,H.jsx)(c,{size:12,"aria-hidden":`true`}),`Overrule`]})]}),a&&(0,H.jsxs)(`div`,{className:`flex max-w-[640px] flex-col gap-2 rounded-[12px] bg-surface-muted p-3`,children:[(0,H.jsx)(`label`,{htmlFor:`overrule-${e.id}`,className:`text-[12.5px] 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)(ce,{id:`overrule-${e.id}`,value:s,onChange:e=>l(e.target.value),rows:2,maxLength:500,placeholder:`For example: the owner agreed this removal in the change's review.`}),f&&(0,H.jsx)(B,{text:f}),(0,H.jsxs)(`span`,{className:`flex gap-2`,children:[(0,H.jsxs)(k,{size:`sm`,disabled:!m||u,onClick:h,children:[(0,H.jsx)(c,{"aria-hidden":`true`}),u?`Overruling…`:`Overrule`]}),(0,H.jsxs)(k,{size:`sm`,variant:`ghost`,onClick:()=>o(!1),children:[(0,H.jsx)(n,{"aria-hidden":`true`}),`Cancel`]})]})]})]})}function He(){let[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)(``);return(0,V.useEffect)(()=>{N.review().then(n,e=>i(e.message))},[]),(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Y,{id:`evidence-review`,children:`Review queue`}),(0,H.jsx)(`p`,{className:`m-0 max-w-[74ch] text-sm leading-relaxed text-ink-2`,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.`}),r&&(0,H.jsx)(B,{text:r}),!t&&!r&&(0,H.jsx)(X,{}),t?.problems.map(e=>(0,H.jsx)(B,{text:e},e)),t&&(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:m,n:t.waiting.length,children:t.waiting.length?(0,H.jsx)(`ul`,{"aria-label":`Waiting for a person`,className:`m-0 list-none rounded-[14px] card border p-1.5`,children:t.waiting.map(e=>(0,H.jsx)(`li`,{children:(0,H.jsxs)(`a`,{href:P(`evidence-runs`,encodeURIComponent(e.run)),className:`grid min-h-12 grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-x-3 rounded-[10px] px-3 py-1.5 text-ink no-underline hover:bg-surface-muted hover:text-ink`,children:[(0,H.jsx)(j,{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-[14px] font-medium`,children:U(e.request||`${e.agent}: request not recorded`)}),(0,H.jsx)(`span`,{className:`truncate text-[12px] text-muted`,children:[U(e.agent),A(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-[12.5px] text-muted tabular-nums`,"data-tip":W(e.started),children:e.started?R(e.started):``})]})},e.run))}):(0,H.jsx)(F,{className:`py-4`,children:`Nothing waits: no run has an open finding.`})}),t.grade.length>0&&(0,H.jsxs)(z,{id:`grade`,title:`Answers to grade`,icon:e,n:t.grade.length,children:[(0,H.jsx)(`p`,{className:`m-0 max-w-[74ch] text-[13px] 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:`m-0 list-none rounded-[14px] card border p-1.5`,children:t.grade.map(e=>(0,H.jsx)(`li`,{children:(0,H.jsxs)(`a`,{href:P(`evidence-runs`,encodeURIComponent(e.run)),className:`grid min-h-12 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 rounded-[10px] px-3 py-1.5 text-ink no-underline hover:bg-surface-muted hover:text-ink`,children:[(0,H.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,H.jsx)(`span`,{className:`truncate text-[14px] font-medium`,children:U(e.request||`${e.agent}: request not recorded`)}),(0,H.jsx)(`span`,{className:`truncate text-[12px] 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-[12.5px] text-muted tabular-nums`,"data-tip":W(e.started),children:e.started?R(e.started):``})]})},e.run))})]}),(0,H.jsx)(z,{id:`overruled`,title:`Overruled by people`,icon:h,n:t.overruled.length,children:t.overruled.length?(0,H.jsx)(`ul`,{"aria-label":`Overruled findings`,className:`m-0 list-none rounded-[14px] card border p-1.5`,children:t.overruled.map(e=>(0,H.jsxs)(`li`,{className:`flex flex-col gap-0.5 border-b border-line-soft px-3 py-2 last:border-b-0`,children:[(0,H.jsxs)(`span`,{className:`text-[13px] [overflow-wrap:anywhere]`,children:[(0,H.jsx)(`a`,{href:P(`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-[12.5px] 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-sm text-muted`,children:`No finding has been overruled.`})})]})]})}var Ue={build:`Build and test`,behaviour:`Behaviour`,decisions:`Decisions and data`,content:`Content`,domain:`Domain`};function We({s:e}){let[t,n]=(0,V.useState)(e.versions[0]||``),[r,i]=(0,V.useState)(e.versions[1]||``),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(``);(0,V.useEffect)(()=>{e.agent&&t&&(c(``),N.release(e.agent,t,r===t?``:r).then(o,e=>c(e.message)))},[e.agent,t,r]);let l=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`},u=a?[...new Set([...Object.keys(a.candidate.lensPass),...Object.keys(a.live?.lensPass||{})])]:[];return(0,H.jsxs)(`li`,{className:`flex flex-col gap-3 rounded-[14px] card border px-4 py-3`,children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,H.jsx)(`span`,{className:`text-[15px] font-medium [overflow-wrap:anywhere]`,children:U(e.agent||e.name)}),(0,H.jsxs)(`span`,{className:`text-[12px] text-muted`,children:[U(`${e.name}.yaml`),` · `,A(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-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-[13px]`,children:[(0,H.jsx)(`label`,{htmlFor:`cand-${e.name}`,children:`Candidate`}),(0,H.jsx)(I,{size:`sm`,id:`cand-${e.name}`,value:t,onChange:e=>n(e.target.value),className:`w-auto pr-7 pl-3`,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)(I,{size:`sm`,id:`live-${e.name}`,value:r,onChange:e=>i(e.target.value),className:`w-auto pr-7 pl-3`,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))]})]}),s&&(0,H.jsx)(B,{text:s}),a&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,H.jsx)(j,{tone:a.status===`ready`?`pass`:`fail`,children:a.status===`ready`?`Ready`:`Held`}),(0,H.jsx)(`span`,{className:`text-[13px] 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-0.5 pl-5 text-[13px] text-ink-2`,children:a.reasons.map(e=>(0,H.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:U(e)},e))}),(0,H.jsxs)(L,{label:`Scenarios of ${e.agent}`,search:!1,minWidth:520,head:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left text-[11.5px] font-medium whitespace-nowrap text-muted`,children:`Scenario`}),(0,H.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left text-[11.5px] font-medium whitespace-nowrap text-muted`,children:`Kind`}),a.live&&(0,H.jsxs)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left text-[11.5px] font-medium whitespace-nowrap text-muted`,children:[U(a.live.version),` (live)`]}),(0,H.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left text-[11.5px] font-medium whitespace-nowrap text-muted`,children:U(a.candidate.version)})]}),children:[e.scenarios.map(e=>(0,H.jsxs)(`tr`,{className:`border-t border-line-soft align-top`,children:[(0,H.jsx)(`th`,{scope:`row`,className:O(`px-3 py-2`,`text-left font-medium`),"data-tip":e.request,children:U(e.id)}),(0,H.jsx)(`td`,{className:`px-3 py-2`,children:e.kind}),a.live&&(0,H.jsx)(`td`,{className:O(`px-3 py-2`,a.live.cells[e.id]&&!a.live.cells[e.id].pass&&`text-fail`),children:l(a.live.cells[e.id])}),(0,H.jsx)(`td`,{className:O(`px-3 py-2`,(a.candidate.cells[e.id]===null||a.candidate.cells[e.id]&&!a.candidate.cells[e.id].pass)&&`text-fail`),children:l(a.candidate.cells[e.id])})]},e.id)),u.map(e=>(0,H.jsxs)(`tr`,{className:`border-t border-line-soft align-top`,children:[(0,H.jsxs)(`th`,{scope:`row`,className:O(`px-3 py-2`,`text-left text-muted`),children:[Ue[e],`: scenarios passed`]}),(0,H.jsx)(`td`,{className:`px-3 py-2`}),a.live&&(0,H.jsx)(`td`,{className:O(`px-3 py-2`,`tabular-nums`),children:a.live.lensPass[e]??0}),(0,H.jsx)(`td`,{className:O(`px-3 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:`border-t border-line-soft align-top`,children:[(0,H.jsx)(`th`,{scope:`row`,className:O(`px-3 py-2`,`text-left text-muted`),children:`The owners' expectations met`}),(0,H.jsx)(`td`,{className:`px-3 py-2`}),a.live&&(0,H.jsx)(`td`,{className:O(`px-3 py-2`,`tabular-nums`),children:a.live.golden}),(0,H.jsx)(`td`,{className:O(`px-3 py-2`,`tabular-nums`,a.live&&a.candidate.golden<a.live.golden&&`text-fail`),children:a.candidate.golden})]})]}),(0,H.jsx)(Ye,{g:a}),(0,H.jsx)(Ge,{g:a}),(0,H.jsx)(Xe,{g:a,ids:e.scenarios.map(e=>e.id)})]}),e.history.length>0&&(0,H.jsxs)(`details`,{className:`text-[13px]`,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-[12.5px] 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 Ge({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-sm font-semibold`,children:[`Answers waiting for your grade (`,t.length,`)`]}),(0,H.jsx)(`p`,{className:`m-0 max-w-[74ch] text-[13px] 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-0.5 p-0 text-[13px]`,children:t.map(e=>(0,H.jsx)(`li`,{children:(0,H.jsxs)(`a`,{href:P(`evidence-runs`,encodeURIComponent(e.run)),className:`text-accent-fg hover:underline`,children:[U(e.sid),`: `,e.run]})},e.run))})]}):null}function Ke({f:e}){return(0,H.jsxs)(`li`,{className:`flex flex-col gap-1.5 rounded-[14px] card border px-4 py-3`,children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,H.jsx)(j,{tone:e.applied||e.proven?`pass`:`fail`,children:e.applied?`Applied`:e.proven?`Proven`:`Not proven`}),(0,H.jsx)(`span`,{className:`text-[14px] font-medium [overflow-wrap:anywhere]`,children:U(e.instruction)}),(0,H.jsx)(`span`,{className:`font-mono text-[11.5px] text-muted`,children:e.id})]}),(0,H.jsxs)(`span`,{className:`text-[13px] text-ink-2 [overflow-wrap:anywhere]`,children:[`Adds it to `,U(e.file),`, for `,U(e.cause),` of `,(0,H.jsx)(`a`,{href:P(`evidence-runs`,encodeURIComponent(e.run)),className:`font-mono`,children:e.run}),` (scenario `,U(e.scenario),`, `,U(e.version),`).`]}),(0,H.jsxs)(`span`,{className:`text-[13px] 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 `,ut(e.replays)]}):null,`.`]}),(0,H.jsxs)(`span`,{className:`text-[13px] 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-[12.5px] 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-[13px]`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer text-ink-2`,children:`The patch`}),(0,H.jsx)(`pre`,{className:`m-0 mt-1 overflow-x-auto rounded-[12px] bg-surface-muted px-3 py-2 font-mono text-[12px] text-ink`,children:U(e.patch)})]})]})}function qe({d:e,onDecided:n}){let r=e.scenario,i=r.expect||{},a=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`,o=e=>(e||[]).map(e=>U(e)).join(`, `);return(0,H.jsxs)(`li`,{className:`flex flex-col gap-1.5 border-b border-line-soft px-3 py-3 last:border-b-0`,children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,H.jsx)(`span`,{className:`font-mono text-[12.5px] text-muted`,children:e.id}),(0,H.jsxs)(`span`,{className:`text-[14px] font-medium [overflow-wrap:anywhere]`,children:[U(r.id),` for `,U(e.agent)]}),(0,H.jsx)(j,{tone:`neutral`,children:r.kind}),r.held_out&&(0,H.jsx)(j,{tone:`neutral`,children:`Held out`}),e.decided&&(0,H.jsx)(j,{tone:e.decided.decision===`accepted`?`pass`:`warn`,children:e.decided.decision===`accepted`?`Accepted`:`Rejected`})]}),(0,H.jsxs)(`span`,{className:`text-[13px] text-ink-2 [overflow-wrap:anywhere]`,children:[`Drafted by `,e.by===`code`?`code`:`a model`,` from `,a,` `,e.source.url&&ye(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:`m-0 max-w-[74ch] whitespace-pre-wrap rounded-[12px] bg-surface-muted px-3 py-2 text-[13px] text-ink [overflow-wrap:anywhere]`,children:U(r.request)}),(0,H.jsxs)(`ul`,{className:`m-0 flex list-disc flex-col gap-0.5 pl-5 text-[12.5px] text-ink-2`,children:[i.chose&&(0,H.jsxs)(`li`,{children:[`Expects it to choose `,o(i.chose)]}),i.not_chose&&(0,H.jsxs)(`li`,{children:[`Expects it never to choose `,o(i.not_chose)]}),i.says&&(0,H.jsxs)(`li`,{children:[`Expects it to say: `,o(i.says)]}),i.not_says&&(0,H.jsxs)(`li`,{children:[`Expects it never to say: `,o(i.not_says)]}),i.graded&&(0,H.jsx)(`li`,{children:`A person grades each answer`}),(0,H.jsx)(`li`,{children:i.clean?`Every lens must find nothing`:`The lenses are counted lens by lens`})]}),e.decided?(0,H.jsxs)(`span`,{className:`text-[12.5px] 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)(lt,{agent:e.id,uid:`${e.id}-accept`,label:`Add`,icon:t,tip:`Add to the suite`,action:(t,n)=>N.decideDraft(e.id,`accepted`,t,n),onDone:n}),(0,H.jsx)(lt,{agent:e.id,uid:`${e.id}-reject`,label:`Reject`,icon:c,action:(t,n)=>N.decideDraft(e.id,`rejected`,t,n),onDone:n})]})]})}function Je({onDecided:t}){let[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(``),o=()=>N.drafts().then(r,e=>a(e.message));(0,V.useEffect)(()=>{o()},[]);let s=n?.drafts.filter(e=>!e.decided).length??0;return(0,H.jsxs)(z,{id:`drafts`,title:`Drafted scenarios`,icon:e,n:s,children:[(0,H.jsxs)(`p`,{className:`m-0 max-w-[74ch] text-[13px] 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.`]}),i&&(0,H.jsx)(B,{text:i}),n?.problems.map(e=>(0,H.jsx)(B,{text:e},e)),n&&!n.drafts.length&&(0,H.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`No draft yet.`}),n&&n.drafts.length>0&&(0,H.jsx)(`ul`,{"aria-label":`Drafted scenarios`,className:`m-0 flex list-none flex-col rounded-[14px] card border p-1.5`,children:n.drafts.map(e=>(0,H.jsx)(qe,{d:e,onDecided:()=>{o(),t()}},e.id))})]})}function Ye({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=>[Ue[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)}% (${Ue[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-[13px]`,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 max-w-[74ch] text-[12.5px] 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)(L,{label:`Scores`,search:!1,minWidth:420,head:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`th`,{scope:`col`,className:he,children:`Score`}),t.map(t=>(0,H.jsxs)(`th`,{scope:`col`,className:fe,children:[U(t.version),e.live&&t===e.live?` (live)`:``]},t.version))]}),children:r.map(([e,n])=>(0,H.jsxs)(`tr`,{className:ue,children:[(0,H.jsx)(`th`,{scope:`row`,className:O(_e,`text-left font-medium`),children:e}),t.map(e=>(0,H.jsx)(`td`,{className:pe,children:n(e)},e.version))]},e))})]})}function Xe({g:e,ids:t}){let n=e=>e?e.runs.find(e=>e.path?.unmet.length)??e.runs.find(e=>e.path):void 0,r=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(!r.length)return null;let i={same:``,missing:`expected, not done`,extra:`done, not expected`},a=(e,t)=>t?.path?(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,H.jsxs)(`span`,{className:`text-[12px] text-muted`,children:[e,`: `,(0,H.jsx)(`a`,{href:P(`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-0.5 p-0 font-mono text-[12.5px]`,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:O(`[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-[11.5px] text-muted`,children:[` (`,i[e.kind],`)`]})]},`${t}-${e.step}`))}),t.path.unmet.map(e=>(0,H.jsx)(`span`,{className:`text-[12.5px] text-fail [overflow-wrap:anywhere]`,children:U(e)},e))]}):(0,H.jsxs)(`span`,{className:`text-[12.5px] text-muted`,children:[e,`: not run`]});return(0,H.jsxs)(`details`,{className:`text-[13px]`,children:[(0,H.jsxs)(`summary`,{className:`cursor-pointer text-ink-2`,children:[`Paths: expected against actual (`,r.length,`)`]}),(0,H.jsx)(`ul`,{className:`m-0 mt-2 flex list-none flex-col gap-3 p-0`,children:r.map(t=>(0,H.jsxs)(`li`,{className:`flex flex-col gap-1.5 rounded-[12px] card border px-3 py-2.5`,children:[(0,H.jsx)(`span`,{className:`text-[13px] font-medium`,children:U(t.id)}),(0,H.jsxs)(`div`,{className:`grid gap-4 @[640px]:grid-cols-2`,children:[e.live&&a(`${e.live.version} (live)`,t.live),a(e.candidate.version,t.cand)]})]},t.id))})]})}function Ze(){let[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)(``),a=()=>N.releases().then(n,e=>i(e.message));return(0,V.useEffect)(()=>{a()},[]),(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Y,{id:`evidence-releases`,children:`Releases`}),(0,H.jsxs)(`p`,{className:`m-0 max-w-[74ch] text-sm leading-relaxed text-ink-2`,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.`]}),r&&(0,H.jsx)(B,{text:r}),!t&&!r&&(0,H.jsx)(X,{}),t&&!t.suites.length&&(0,H.jsx)(F,{className:`py-4`,children:`No scenario suite yet: write one in .forgeqe/evidence/scenarios/<agent>.yaml (docs/EVIDENCE.md has its form), or add drafted scenarios below.`}),t&&t.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:e,n:t.suites.length,children:(0,H.jsx)(`ul`,{"aria-label":`Scenario suites`,className:`m-0 flex list-none flex-col gap-3 p-0`,children:t.suites.map(e=>(0,H.jsx)(We,{s:e},e.name))})})]}),t&&(0,H.jsx)(Je,{onDecided:a})]})}var Qe={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 $e(){let[e,t]=(0,V.useState)(null),[n,r]=(0,V.useState)(``);(0,V.useEffect)(()=>{N.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.jsxs)(`p`,{className:`m-0 max-w-[74ch] text-sm leading-relaxed text-ink-2`,children:[`What each agent's owner agreed for it: the steps it 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>`}),`.`]}),n&&(0,H.jsx)(B,{text:n}),!e&&!n&&(0,H.jsx)(X,{}),e&&!e.contracts.length&&(0,H.jsx)(F,{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:S,n:e.contracts.length,children:(0,H.jsx)(`ul`,{"aria-label":`Contracts`,className:`m-0 flex list-none flex-col gap-3 p-0`,children:e.contracts.map(e=>(0,H.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-[14px] card border px-4 py-3`,children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,H.jsx)(`span`,{className:`text-[15px] font-medium [overflow-wrap:anywhere]`,children:U(e.agent||e.name)}),(0,H.jsx)(j,{tone:Qe[e.state].tone,children:Qe[e.state].label}),(0,H.jsxs)(`span`,{className:`text-[12px] 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-0.5 p-0`,children:e.says.map(e=>(0,H.jsx)(`li`,{className:`text-[13px] text-ink-2 [overflow-wrap:anywhere]`,children:U(e)},e))}),(0,H.jsx)(`span`,{className:`text-[12px] 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:o,children:[(0,H.jsxs)(`p`,{className:`m-0 max-w-[74ch] text-[13px] leading-relaxed text-ink-2`,children:[`On `,A(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)(L,{label:`How well each check is measured`,search:!1,head:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left text-[11.5px] 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:O(`px-3 py-1.5 text-right text-[11.5px] font-medium whitespace-nowrap text-muted`,`whitespace-normal`,et.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:`border-t border-line-soft align-top`,children:[(0,H.jsx)(`th`,{scope:`row`,className:O(`px-3 py-2`,`text-left font-medium`),children:q[t]}),(0,H.jsx)(`td`,{className:O(`px-3 py-2 text-right whitespace-nowrap tabular-nums`,n.labelled<e.measured.min&&`text-muted`),children:n.labelled}),(0,H.jsx)(`td`,{className:O(`px-3 py-2 text-right whitespace-nowrap tabular-nums`,`hidden @lg:table-cell`),children:n.tp}),(0,H.jsx)(`td`,{className:O(`px-3 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:O(`px-3 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-3 py-2 text-right whitespace-nowrap tabular-nums`,children:i(n.precision)}),(0,H.jsx)(`td`,{className:`px-3 py-2 text-right whitespace-nowrap tabular-nums`,children:i(n.recall)})]},t)})})})]})]})}var et=new Set([`Found right`,`Found wrong`,`Missed`]),tt={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`}},nt={instruction:`Its instructions`,tool:`A tool`,data:`Its data`};function rt({p:e,onDecided:t}){let[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(``),[s,l]=(0,V.useState)(!1),[u,d]=(0,V.useState)(``),f=a.trim().length>=10&&a.trim().length<=500,p=async()=>{if(r){l(!0),d(``);try{await N.decide(e.agent,e.id,r,a.trim()),i(null),t()}catch(e){d(e.message)}finally{l(!1)}}};return(0,H.jsxs)(`li`,{className:`flex flex-col gap-1 border-b border-line-soft px-3 py-2.5 last:border-b-0`,children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,H.jsx)(j,{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-[12.5px] 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-[11.5px] text-muted`,children:e.id})]}),(0,H.jsx)(`span`,{className:`text-[14px] text-ink [overflow-wrap:anywhere]`,children:U(e.text)}),(0,H.jsxs)(`span`,{className:`text-[12.5px] text-muted [overflow-wrap:anywhere]`,children:[`Because `,U(e.because),`. `,A(e.runs.length,`run`),e.replays?`, ${A(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:P(`evidence-runs`,encodeURIComponent(e)),className:`font-mono`,children:e})]},e))]}),e.decision&&(0,H.jsxs)(`span`,{className:`text-[12.5px] 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`&&!r&&(0,H.jsxs)(`span`,{className:`flex gap-2`,children:[(0,H.jsxs)(k,{size:`sm`,onClick:()=>i(`approved`),children:[(0,H.jsx)(C,{"aria-hidden":`true`}),`Approve`]}),(0,H.jsxs)(k,{size:`sm`,variant:`ghost`,onClick:()=>i(`declined`),children:[(0,H.jsx)(c,{"aria-hidden":`true`}),`Decline`]})]}),r&&(0,H.jsxs)(`div`,{className:`flex max-w-[640px] flex-col gap-2 rounded-[12px] bg-surface-muted p-3`,children:[(0,H.jsx)(`label`,{htmlFor:`decide-${e.id}`,className:`text-[12.5px] font-medium text-ink-2`,children:r===`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)(ce,{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)(k,{size:`sm`,disabled:!f||s,onClick:p,children:[r===`approved`?(0,H.jsx)(C,{"aria-hidden":`true`}):(0,H.jsx)(c,{"aria-hidden":`true`}),s?`Keeping…`:r===`approved`?`Approve`:`Decline`]}),(0,H.jsxs)(k,{size:`sm`,variant:`ghost`,onClick:()=>i(null),children:[(0,H.jsx)(n,{"aria-hidden":`true`}),`Cancel`]})]})]})]})}function it({agent:e,run:t,c:r,candidates:i,onLinked:a}){let o=i,[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)([]),[d,f]=(0,V.useState)(!1),[p,m]=(0,V.useState)(``);return(0,H.jsxs)(`div`,{className:O(`flex flex-col gap-1 border-l-2 pl-3`,r.status===`proven`?`border-pass`:r.status===`refuted`?`border-fail`:r.status===`side-effects`?`border-warn`:`border-line`),children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,H.jsx)(j,{tone:tt[r.status].tone,children:tt[r.status].label}),(0,H.jsxs)(`span`,{className:`text-[13px] font-medium`,children:[r.id,` · `,nt[r.kind],`: `,U(r.where)]}),(0,H.jsxs)(`span`,{className:`text-[12px] text-muted`,children:[`of `,q[r.finding.check],`: `,U(r.finding.rule)]})]}),(0,H.jsxs)(`span`,{className:`text-[13px] text-ink [overflow-wrap:anywhere]`,children:[`Change: `,U(r.change)]}),(0,H.jsxs)(`span`,{className:`text-[12.5px] text-muted [overflow-wrap:anywhere]`,children:[U(r.why),`.`]}),r.replays.map(e=>(0,H.jsxs)(`span`,{className:`text-[12.5px] text-ink-2 [overflow-wrap:anywhere]`,children:[`Replay `,(0,H.jsx)(`a`,{href:P(`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&&r.status!==`proven`&&(0,H.jsx)(`span`,{children:(0,H.jsxs)(`button`,{type:`button`,onClick:()=>c(!0),"data-tip":`Link replays`,className:`inline-flex min-h-7 cursor-pointer items-center gap-1 rounded-[8px] border-0 bg-transparent px-0 text-[12.5px] text-accent-fg hover:underline`,children:[(0,H.jsx)(v,{size:12,"aria-hidden":`true`}),`Link`]})}),s&&(0,H.jsxs)(`fieldset`,{className:`m-0 flex max-w-[640px] flex-col gap-1.5 rounded-[12px] border-0 bg-surface-muted p-3`,children:[(0,H.jsxs)(`legend`,{className:`sr-only`,children:[`Replays of `,r.id]}),(0,H.jsx)(`span`,{className:`text-[12.5px] 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-[12.5px]`,children:[(0,H.jsx)(be,{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)),p&&(0,H.jsx)(B,{text:p}),(0,H.jsxs)(`span`,{className:`flex gap-2`,children:[(0,H.jsxs)(k,{size:`sm`,disabled:!l.length||d,onClick:async()=>{f(!0),m(``);try{await N.replay(e,t,r.id,l),c(!1),u([]),a()}catch(e){m(e.message)}finally{f(!1)}},"data-tip":`Link the picked replays`,children:[(0,H.jsx)(v,{"aria-hidden":`true`}),d?`Linking…`:l.length?`Link (${l.length})`:`Link`]}),(0,H.jsxs)(k,{size:`sm`,variant:`ghost`,onClick:()=>c(!1),children:[(0,H.jsx)(n,{"aria-hidden":`true`}),`Cancel`]})]})]})]})}function at({sub:e}){let[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)(e?M(e):``),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(``),[l,u]=(0,V.useState)(0);(0,V.useEffect)(()=>{N.overview().then(e=>{let t=e.agents.map(e=>e.name);n(t),i(e=>e||t[0]||``)},e=>c(e.message))},[]),(0,V.useEffect)(()=>{r&&(o(null),N.learn(r).then(o,e=>c(e.message)))},[r,l]);let f=()=>u(e=>e+1);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Y,{id:`evidence-learn`,children:`Learn`}),(0,H.jsx)(`p`,{className:`m-0 max-w-[74ch] text-sm leading-relaxed text-ink-2`,children:`What to change in an agent, from what its runs got wrong. 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.`}),s&&(0,H.jsx)(B,{text:s}),t&&!t.length&&(0,H.jsx)(Oe,{}),t&&t.length>1&&(0,H.jsxs)(`label`,{className:`flex w-fit items-center gap-2 text-[13px] text-ink-2`,children:[`Agent`,(0,H.jsx)(I,{value:r,onChange:e=>i(e.target.value),children:t.map(e=>(0,H.jsx)(`option`,{value:e,children:U(e)},e))})]}),r&&!a&&!s&&(0,H.jsx)(X,{}),a?.problems.map(e=>(0,H.jsx)(B,{text:e},e)),a&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`h2`,{className:`sr-only`,children:[`Proposals and causes of `,U(a.agent)]}),(0,H.jsxs)(z,{id:`proposals`,title:`Proposals`,icon:_,n:a.proposals.length,children:[a.proposals.length?(0,H.jsx)(`ul`,{"aria-label":`Proposals`,className:`m-0 list-none rounded-[14px] card border p-1.5`,children:a.proposals.map(e=>(0,H.jsx)(rt,{p:e,onDecided:f},e.id))}):(0,H.jsx)(F,{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.`}),a.proposals.some(e=>e.state===`approved`)&&(0,H.jsxs)(`p`,{className:`m-0 text-[13px] text-muted`,children:[(0,H.jsxs)(`code`,{children:[`forgeqe evidence guidance `,U(a.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:w,n:a.fixes.length,children:[(0,H.jsxs)(`p`,{className:`m-0 max-w-[74ch] text-[13px] 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.`]}),a.fixes.length?(0,H.jsx)(`ul`,{"aria-label":`Fixes`,className:`m-0 flex list-none flex-col gap-2 p-0`,children:a.fixes.map(e=>(0,H.jsx)(Ke,{f:e},`${e.id}-${e.at}`))}):(0,H.jsxs)(`p`,{className:`m-0 text-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:d,n:a.runs.length,children:a.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:a.runs.map(e=>(0,H.jsxs)(`li`,{className:`flex flex-col gap-2.5 rounded-[14px] card border px-4 py-3`,children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-3 gap-y-0.5`,children:[(0,H.jsx)(`a`,{href:P(`evidence-runs`,encodeURIComponent(e.run)),className:`text-[14px] font-medium [overflow-wrap:anywhere]`,children:U(e.request||e.run)}),(0,H.jsxs)(`span`,{className:`font-mono text-[11.5px] text-muted`,children:[e.run,e.version?` · ${U(e.version)}`:``]})]}),e.causes.map(t=>(0,H.jsx)(it,{agent:a.agent,run:e.run,c:t,candidates:e.candidates,onLinked:f},t.key)),!e.candidates.length&&(0,H.jsxs)(`span`,{className:`text-[12.5px] 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-sm text-muted`,children:`No run of this agent has an open finding.`})})]})]})}var $={observe:`Observe`,assist:`Assist`,act:`Act`,autonomous:`Autonomous`},ot={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`},st={model:`Model`,tool:`Tool`,knowledge:`Knowledge`,check:`Check`,judge:`Judge`,trust:`Trust`},ct=[`observe`,`assist`,`act`,`autonomous`];function lt({agent:e,label:t,icon:r,tip:i,action:a,children:o,onDone:s,uid:c}){let[l,u]=(0,V.useState)(!1),[d,f]=(0,V.useState)(``),[p,m]=(0,V.useState)(``),[h,g]=(0,V.useState)(!1),[_,v]=(0,V.useState)(``),y=d.trim().length>=10&&d.trim().length<=500&&p===e,b=async()=>{g(!0),v(``);try{await a(p,d.trim()),u(!1),f(``),m(``),s()}catch(e){v(e.message)}finally{g(!1)}};if(!l)return(0,H.jsx)(`span`,{children:(0,H.jsxs)(k,{size:`sm`,onClick:()=>u(!0),"data-tip":i,children:[(0,H.jsx)(r,{"aria-hidden":`true`}),t]})});let x=`${t}${c?`-${c}`:``}`.toLowerCase().replace(/[^a-z0-9]+/g,`-`);return(0,H.jsxs)(`div`,{className:`flex max-w-[640px] flex-col gap-2 rounded-[12px] bg-surface-muted p-3`,children:[o,(0,H.jsx)(`label`,{htmlFor:`${x}-reason`,className:`text-[12.5px] font-medium text-ink-2`,children:`Why? It is kept with your name and in the audit.`}),(0,H.jsx)(ce,{id:`${x}-reason`,value:d,onChange:e=>f(e.target.value),rows:2,maxLength:500}),(0,H.jsxs)(`label`,{htmlFor:`${x}-confirm`,className:`text-[12.5px] font-medium text-ink-2`,children:[`Type `,U(e),` to confirm`]}),(0,H.jsx)(ie,{id:`${x}-confirm`,value:p,onChange:e=>m(e.target.value),autoComplete:`off`}),_&&(0,H.jsx)(B,{text:_}),(0,H.jsxs)(`span`,{className:`flex gap-2`,children:[(0,H.jsxs)(k,{size:`sm`,disabled:!y||h,onClick:b,"data-tip":i,children:[(0,H.jsx)(r,{"aria-hidden":`true`}),h?`Keeping…`:t]}),(0,H.jsxs)(k,{size:`sm`,variant:`ghost`,onClick:()=>u(!1),children:[(0,H.jsx)(n,{"aria-hidden":`true`}),`Cancel`]})]})]})}function ut(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:P(`evidence-runs`,encodeURIComponent(e)),className:`font-mono`,children:e})]},e)),e.length>8?`, and ${e.length-8} more`:``]})}function dt({sub:e}){let t=e?M(e):``,[n,i]=(0,V.useState)(null),[a,s]=(0,V.useState)(``),[c,l]=(0,V.useState)(0),[d,f]=(0,V.useState)(`observe`),p=()=>l(e=>e+1);(0,V.useEffect)(()=>{s(``),N.monitor(t||void 0).then(i,e=>s(e.message))},[t,c]);let m=async()=>{try{let e=await N.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){s(e.message)}},h=n?.agent;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Y,{id:`evidence-monitor`,children:`Monitor`}),(0,H.jsxs)(`p`,{className:`m-0 max-w-[74ch] text-sm leading-relaxed text-ink-2`,children:[`Every agent evaluated, and for each: 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`}),`.`]}),a&&(0,H.jsx)(B,{text:a}),!n&&!a&&(0,H.jsx)(X,{}),n?.problems.map(e=>(0,H.jsx)(B,{text:e},e)),n&&!n.inventory.length&&(0,H.jsx)(Oe,{}),n&&n.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:x,n:n.inventory.length,children:[(0,H.jsx)(L,{label:`Agents evaluated`,search:!1,minWidth:760,head:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left text-[11.5px] font-medium whitespace-nowrap text-muted`,children:`Agent`}),(0,H.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left text-[11.5px] font-medium whitespace-nowrap text-muted`,children:`Versions`}),(0,H.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left text-[11.5px] font-medium whitespace-nowrap text-muted`,children:`Models`}),(0,H.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-right text-[11.5px] font-medium whitespace-nowrap text-muted`,children:`Tools`}),(0,H.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left text-[11.5px] font-medium whitespace-nowrap text-muted`,children:`Contract`}),(0,H.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left text-[11.5px] font-medium whitespace-nowrap text-muted`,children:`Trust`}),(0,H.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-right text-[11.5px] font-medium whitespace-nowrap text-muted`,children:`Alerts`})]}),children:n.inventory.map(e=>(0,H.jsxs)(`tr`,{className:`border-t border-line-soft align-top`,children:[(0,H.jsx)(`th`,{scope:`row`,className:O(`px-3 py-2`,`text-left font-medium`),children:(0,H.jsx)(`a`,{href:P(`evidence-monitor`,encodeURIComponent(e.agent)),"aria-current":e.agent===t?`page`:void 0,children:U(e.agent)})}),(0,H.jsx)(`td`,{className:O(`px-3 py-2`,`text-muted`),children:e.versions.slice(0,3).map(U).join(`, `)||`none named`}),(0,H.jsx)(`td`,{className:O(`px-3 py-2`,`text-muted [overflow-wrap:anywhere]`),children:e.models.slice(0,3).map(U).join(`, `)||`none named`}),(0,H.jsx)(`td`,{className:`px-3 py-2 text-right whitespace-nowrap tabular-nums`,children:e.tools.length}),(0,H.jsx)(`td`,{className:O(`px-3 py-2`,`text-muted`),children:e.contract?e.contract.approved?`Approved`:`Not approved`:`None`}),(0,H.jsx)(`td`,{className:`px-3 py-2`,children:e.granted?`${$[e.granted]} (supports ${$[e.supported].toLowerCase()})`:`Not granted (supports ${$[e.supported].toLowerCase()})`}),(0,H.jsx)(`td`,{className:O(`px-3 py-2 text-right whitespace-nowrap tabular-nums`,e.alerts>0&&`text-fail`),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-[13px] text-muted`,children:`Open an agent to see its drift, its trust and its audit.`})]}),h&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(z,{id:`drift`,title:`Drift of ${h.name}`,icon:o,n:h.drift.alerts.length,children:[h.drift.baseline?(0,H.jsxs)(`p`,{className:`m-0 text-[13px] text-muted`,children:[`Since its baseline (`,h.drift.baseline.version?U(h.drift.baseline.version):`no version`,`, `,A(h.drift.baseline.runs,`run`),`, set by `,U(h.drift.baseline.by),` `,W(h.drift.baseline.at),`): `,A(h.drift.since.length,`run`),`.`]}):(0,H.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`No baseline is set: what changed cannot be said. Set one when a version is released.`}),h.drift.alerts.length>0&&(0,H.jsx)(`ul`,{"aria-label":`Drift alerts`,className:`m-0 list-none rounded-[14px] card border p-1.5`,children:h.drift.alerts.map(e=>(0,H.jsxs)(`li`,{className:`flex flex-col gap-0.5 border-b border-line-soft px-3 py-2 last:border-b-0`,children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,H.jsx)(j,{tone:`warn`,children:st[e.kind]}),(0,H.jsx)(`span`,{className:`text-[13.5px] [overflow-wrap:anywhere]`,children:U(e.what)})]}),e.runs.length>0&&(0,H.jsxs)(`span`,{className:`text-[12.5px] text-muted [overflow-wrap:anywhere]`,children:[`In `,ut(e.runs)]})]},`${e.kind}-${e.subject}`))}),h.drift.baseline&&!h.drift.alerts.length&&(0,H.jsx)(F,{className:`py-4`,children:`Nothing changed since the baseline.`}),(0,H.jsx)(lt,{agent:h.name,label:`Set baseline`,icon:r,tip:h.drift.baseline?`Set a new baseline`:`Set the baseline`,action:(e,t)=>N.baseline(h.name,e,t),onDone:p,children:(0,H.jsx)(`span`,{className:`text-[12.5px] 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 ${h.name}`,icon:E,children:[(0,H.jsxs)(`p`,{className:`m-0 text-[13.5px]`,children:[`Its evidence supports `,(0,H.jsx)(`b`,{children:$[h.trust.supported]}),`: `,ot[h.trust.supported],`.`,` `,h.trust.granted?(0,H.jsxs)(H.Fragment,{children:[`Granted: `,(0,H.jsx)(`b`,{children:$[h.trust.granted.level]}),`, by `,U(h.trust.granted.by),` `,W(h.trust.granted.at),`: `,U(h.trust.granted.reason)]}):`No level is granted.`]}),(0,H.jsx)(`ul`,{"aria-label":`What each level needs`,className:`m-0 list-none rounded-[14px] card border p-1.5`,children:h.trust.criteria.filter(e=>e.level!==`observe`).map(e=>(0,H.jsxs)(`li`,{className:`flex items-start gap-2.5 border-b border-line-soft px-3 py-2 text-[13px] last:border-b-0`,children:[(0,H.jsx)(ae,{icon:e.met?C:u,size:15,className:e.met?`mt-0.5 text-pass`:`mt-0.5 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)(lt,{agent:h.name,label:`Grant`,icon:C,tip:`Grant a trust level`,action:(e,t)=>N.trust(h.name,d,e,t),onDone:p,children:(0,H.jsxs)(`label`,{className:`flex w-fit items-center gap-2 text-[12.5px] font-medium text-ink-2`,children:[`Level`,(0,H.jsx)(I,{value:d,onChange:e=>f(e.target.value),children:ct.slice(0,ct.indexOf(h.trust.supported)+1).map(e=>(0,H.jsxs)(`option`,{value:e,children:[$[e],`: `,ot[e]]},e))})]})})]}),(0,H.jsxs)(z,{id:`audit`,title:`Audit`,icon:S,children:[(0,H.jsxs)(`p`,{className:`m-0 max-w-[74ch] text-[13px] text-muted`,children:[`Every decision people made about `,U(h.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)(k,{size:`sm`,onClick:m,"data-tip":`Download the audit`,children:[(0,H.jsx)(te,{"aria-hidden":`true`}),`Download`]})})]})]})]})]})}function ft({page:e,sub:t}){let n=(t||``).split(`/`),r=n[0]===`agent`&&n[1]?M(n[1]):``,i=e===`evidence-runs`&&n[0]&&n[0]!==`agent`?M(n[0]):``;return(0,H.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,H.jsx)(me,{}),(0,H.jsx)(`main`,{className:O(ge,`@container flex-auto gap-4`),children:e===`evidence`?t?(0,H.jsx)(Ne,{agent:M(t)},t):(0,H.jsx)(Ae,{}):e===`evidence-contracts`?(0,H.jsx)($e,{}):e===`evidence-review`?(0,H.jsx)(He,{}):e===`evidence-releases`?(0,H.jsx)(Ze,{}):e===`evidence-learn`?(0,H.jsx)(at,{sub:t}):e===`evidence-monitor`?(0,H.jsx)(dt,{sub:t},t||``):i?(0,H.jsx)(Re,{id:i},i):(0,H.jsx)(Pe,{agent:r})})]})}export{ft as Evidence};
@@ -1 +0,0 @@
1
- import{Ar as e,Gn as t,Ir as n,M as r,Nr as i,O as a,P as o,T as s,c,ln as l}from"./line-icons-CQ-3V8ax.js";import{B as u,R as d,V as f,c as p,f as m,i as h,o as g,pt as _,qt as v,rt as y}from"./filters-mFECJpMB.js";import{Et as b,Ot as x,ct as S,gt as C,r as w,st as T,t as E}from"./frame-DiKY0GWx.js";import{u as D}from"./index-HjX2EOmp.js";var O=n(i(),1),k=v(),A={ready:{label:`Ready`,tone:`pass`,icon:c,color:`text-pass`},partial:{label:`Partly set up`,tone:`warn`,icon:o,color:`text-warn`},needs_setup:{label:`Needs setup`,tone:`neutral`,icon:r,color:`text-muted`}},j={models:`Models`,integrations:`Integrations`,monitor:`Monitor`,notifications:`Notifications`,agents:`Agents`,environments:`Environments`,containers:`Containers`,databases:`Databases`},M=4;async function N(e,t){try{let{id:t}=await y.start(e,{});location.hash=m(`chats`,t)}catch(e){t(e.message)}}function P({f:e,onScope:n,busy:r}){let[i,a]=(0,O.useState)(null),[o,s]=(0,O.useState)(``),[c,p]=(0,O.useState)(``);(0,O.useEffect)(()=>{_.detail(e.id).then(a,e=>s(e.message))},[e.id]);let h=e.gaps.filter(e=>!e.optional),v=e.gaps.filter(e=>e.optional);return(0,k.jsxs)(`div`,{className:`flex flex-col gap-4 py-4`,children:[(0,k.jsx)(`p`,{className:`m-0 text-sm text-ink-2`,children:e.summary}),[[h,`Needs`],[v,`Would do more with`]].map(([e,n])=>e.length?(0,k.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium`,children:n}),(0,k.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:e.map((e,r)=>(0,k.jsxs)(`li`,{className:`flex flex-col gap-0.5 rounded-[10px] bg-bg px-3 py-2 text-sm`,children:[(0,k.jsx)(`span`,{className:u(n===`Needs`?`text-ink`:`text-ink-2`),children:e.missing}),(0,k.jsx)(`span`,{className:`text-[13px] text-muted`,children:e.fix}),e.settings&&(0,k.jsxs)(`a`,{href:m(`settings`,e.settings),className:`inline-flex items-center gap-1 self-start text-[13px] font-medium`,children:[(0,k.jsx)(t,{size:13,"aria-hidden":`true`}),`Set it up in Settings, `,j[e.settings]||e.settings]})]},r))})]},n):null),e.inputs.length>0&&(0,k.jsxs)(`p`,{className:`m-0 text-sm text-ink-2`,children:[`From your request: `,e.inputs.join(`; `),`.`]}),o&&(0,k.jsx)(`p`,{className:`m-0 text-sm text-fail`,children:o}),i&&(0,k.jsxs)(k.Fragment,{children:[i.examples.length>0&&(0,k.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium`,children:`Ask for it like this`}),(0,k.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:i.examples.slice(0,4).map(t=>(0,k.jsxs)(d,{size:`sm`,disabled:e.state===`needs_setup`,"data-tip":e.state===`needs_setup`?`Set it up first`:`Start a chat with this request`,onClick:()=>void N(t,p),className:`h-auto min-h-8 max-w-full py-1.5 text-left whitespace-normal`,children:[(0,k.jsx)(l,{"aria-hidden":`true`}),t]},t))}),c&&(0,k.jsx)(`span`,{className:`text-[13px] text-fail`,children:c})]}),i.limits.length>0&&(0,k.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium`,children:`What it does not do`}),(0,k.jsx)(`ul`,{className:`m-0 list-disc pl-5 text-sm text-ink-2`,children:i.limits.map(e=>(0,k.jsx)(`li`,{children:e},e))})]}),i.docs.length>0&&(0,k.jsxs)(`details`,{children:[(0,k.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:[`How it works (`,f(i.docs.length,`section`),`)`]}),(0,k.jsx)(`div`,{className:`mt-2 flex flex-col gap-4`,children:i.docs.map(e=>(0,k.jsxs)(`section`,{className:`rounded-[12px] bg-bg px-4 py-3`,children:[(0,k.jsx)(`h4`,{className:`m-0 mb-1 text-sm font-semibold`,children:e.heading}),(0,k.jsx)(D,{text:e.text,className:`text-sm`})]},e.heading))})]}),(0,k.jsxs)(`span`,{className:`font-mono text-[11.5px] text-muted [overflow-wrap:anywhere]`,children:[`Tools: `,i.tools.join(`, `)]})]}),(0,k.jsxs)(`label`,{className:`flex flex-wrap items-center gap-3 border-t border-line-soft pt-3 text-sm`,children:[(0,k.jsxs)(`span`,{className:`flex-[1_1_240px]`,children:[`The agent gets its tools`,(0,k.jsx)(`span`,{className:`block text-[13px] text-muted`,children:`agent.capabilities in forgeqe.yaml`})]}),(0,k.jsxs)(g,{value:e.scope,disabled:r,onChange:e=>n(e.target.value),className:`w-[240px]`,children:[(0,k.jsx)(`option`,{value:`auto`,children:`When a request is about it`}),(0,k.jsx)(`option`,{value:`always`,children:`Always`}),(0,k.jsx)(`option`,{value:`off`,children:`Never, in this project`})]})]})]})}function F({embedded:t=!1}={}){let[n,r]=(0,O.useState)(null),[i,o]=(0,O.useState)(``),[c,l]=(0,O.useState)(``),[f,m]=(0,O.useState)(`all`),[g,v]=(0,O.useState)(``),[y,D]=(0,O.useState)(!1),[j,N]=(0,O.useState)([]),F=(0,O.useCallback)(()=>_.view().then(r,e=>o(e.message)),[]);(0,O.useEffect)(()=>void F(),[F]);let I=(0,O.useMemo)(()=>{let e=g.toLowerCase().split(/\s+/).filter(Boolean);return(n?.areas||[]).map(t=>({...t,features:t.features.filter(n=>(f===`all`||(f===`ready`?n.state!==`needs_setup`:n.state!==`ready`))&&e.every(e=>`${n.title} ${n.summary} ${t.area}`.toLowerCase().includes(e)))})).filter(e=>e.features.length)},[n,f,g]),L=async(e,t)=>{D(!0);try{r(await _.scope(e,t)),o(``)}catch(e){o(e.message)}finally{D(!1)}},R=n?.counts,z=n?.areas.flatMap(e=>e.features).find(e=>e.id===c),B=(0,k.jsxs)(k.Fragment,{children:[i&&(0,k.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:i}),!n&&!i&&(0,k.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}),n&&R&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(S,{label:`Features`,children:[(0,k.jsx)(T,{icon:A.ready.icon,label:`Ready`,value:String(R.ready)}),(0,k.jsx)(T,{icon:A.partial.icon,label:`Partly set up`,value:String(R.partial)}),(0,k.jsx)(T,{icon:A.needs_setup.icon,label:`Need setup`,value:String(R.needs_setup)})]}),(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,k.jsx)(`div`,{role:`radiogroup`,"aria-label":`Show`,className:`flex gap-1 rounded-[10px] bg-surface-strong p-1`,children:[[`all`,`All`],[`needs`,`Needs setup`],[`ready`,`Ready`]].map(([e,t])=>(0,k.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":f===e,onClick:()=>m(e),className:u(`min-h-8 cursor-pointer rounded-[7px] border-0 px-3.5 text-sm font-medium`,f===e?`bg-bg text-ink shadow-sm`:`bg-transparent text-muted hover:text-ink`),children:t},e))}),(0,k.jsx)(h,{id:`find-a-feature`,label:`Find a feature`,value:g,onChange:v})]}),I.length===0&&(0,k.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Nothing matches.`}),(0,k.jsx)(`div`,{className:`@container`,children:(0,k.jsx)(`div`,{className:`grid auto-rows-fr grid-cols-1 items-stretch gap-4 @2xl:grid-cols-2 @5xl:grid-cols-3`,children:I.map((e,t)=>{let n=f!==`all`||g.trim()!==``||j.includes(e.area),r=n?e.features:e.features.slice(0,M),i=e.features.length-M,o=`area-list-${t}`;return(0,k.jsxs)(`section`,{"aria-labelledby":`area-${t}`,className:`@container/col flex min-w-0 flex-col rounded-[16px] card border p-2 @min-[260px]/col:p-3`,children:[(0,k.jsxs)(`h2`,{id:`area-${t}`,className:`m-0 px-2 pt-1.5 pb-3 text-[16px] font-semibold`,children:[e.area,(0,k.jsx)(`span`,{className:`ml-2 text-[13px] font-normal text-muted tabular-nums`,children:e.features.length})]}),(0,k.jsx)(`ul`,{id:o,className:`m-0 flex list-none flex-col gap-1 p-0`,children:r.map(e=>{let t=A[e.state];return(0,k.jsx)(`li`,{children:(0,k.jsxs)(`button`,{type:`button`,onClick:()=>l(e.id),className:`flex w-full cursor-pointer items-center gap-2.5 rounded-[10px] border-0 bg-transparent px-2 py-2 text-left text-sm text-ink hover:bg-surface-strong`,children:[(0,k.jsx)(t.icon,{size:16,"aria-hidden":`true`,className:u(`flex-none`,t.color)}),(0,k.jsx)(`span`,{className:`min-w-0 flex-1`,children:e.title}),(0,k.jsxs)(`span`,{className:`sr-only`,children:[`, `,t.label]}),e.scope!==`auto`&&(0,k.jsx)(`span`,{className:`flex-none text-[12px] text-muted`,children:e.scope===`always`?`Always given`:`Off here`}),(0,k.jsx)(`span`,{className:`flex-none text-[13px] font-medium text-accent`,children:`More`})]})},e.id)})}),i>0&&f===`all`&&!g.trim()&&(0,k.jsxs)(d,{variant:`ghost`,size:`sm`,"aria-expanded":n,"aria-controls":o,onClick:()=>N(n?j.filter(t=>t!==e.area):[...j,e.area]),"data-tip":n?`Fewer features`:`More features (${i})`,className:`mt-auto w-full justify-center gap-1.5 text-muted`,children:[n?(0,k.jsx)(a,{"aria-hidden":`true`}):(0,k.jsx)(s,{"aria-hidden":`true`}),n?`Less`:`More (${i})`]})]},e.area)})})}),(0,k.jsx)(x,{open:!!z,wide:!0,onClose:()=>l(``),title:z?.title||``,description:z&&(0,k.jsx)(p,{tone:A[z.state].tone,icon:z.state!==`needs_setup`,children:A[z.state].label}),footer:(0,k.jsxs)(d,{onClick:()=>l(``),children:[(0,k.jsx)(e,{"aria-hidden":`true`}),`Close`]}),children:z&&(0,k.jsx)(P,{f:z,busy:y,onScope:e=>void L(z.id,e)})}),n.outOfScope.length>0&&(0,k.jsxs)(`details`,{className:`rounded-[14px] card border px-4 py-3`,children:[(0,k.jsx)(`summary`,{className:`cursor-pointer`,children:(0,k.jsxs)(`h2`,{className:`m-0 inline text-base font-semibold`,children:[`Not what ForgeQE does (`,n.outOfScope.length,`)`]})}),(0,k.jsx)(`ul`,{className:`m-0 mt-2 flex list-none flex-col gap-1 p-0 text-sm`,children:n.outOfScope.map(e=>(0,k.jsxs)(`li`,{children:[e.what,e.instead?(0,k.jsxs)(`span`,{className:`text-muted`,children:[`; instead: `,e.instead]}):null]},e.what))})]})]})]});return t?(0,k.jsx)(`div`,{className:`flex flex-col gap-5`,children:B}):(0,k.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,k.jsx)(w,{}),(0,k.jsxs)(`main`,{className:u(E,`flex-auto gap-5`),children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,k.jsx)(b,{pixel:C.features,size:`lg`}),(0,k.jsx)(`h1`,{className:`m-0 flex-1 text-[26px] font-semibold tracking-[-0.01em]`,children:`What's ready`})]}),(0,k.jsx)(`p`,{className:`m-0 max-w-[70ch] text-sm leading-relaxed text-ink-2`,children:`What ForgeQE can do here. Pick one to see what it needs.`}),B]})]})}export{F as Features};
@@ -1 +0,0 @@
1
- import{Ar as e,Fn as t,Ir as n,L as r,Nr as i,gr as a,j as o,kr as ee,o as s,qn as c}from"./line-icons-CQ-3V8ax.js";import{B as l,Et as u,R as d,a as f,f as p,gt as m,l as h,qt as g,t as _,z as v}from"./filters-mFECJpMB.js";import{Et as te,et as ne,gt as re,r as y,t as b}from"./frame-DiKY0GWx.js";import{s as x}from"./index-HjX2EOmp.js";import{t as S}from"./segmented-DANusepM.js";import{r as C}from"./families-B0QIuAe3.js";import{o as w}from"./qualityParts-jsPhayON.js";var T=n(i(),1),E=g(),D={timing:`Timing`,locator:`Locator`,overlay:`Overlay`,data:`Data`,network:`Network`,environment:`Environment`,unknown:`No pattern`};function O(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 k=e=>e>=60?`${(e/60).toFixed(1)}m`:`${e.toFixed(+(e<10))}s`;function A({trail:e}){return(0,E.jsx)(`span`,{className:`font-mono text-[12.5px] tracking-[0.08em]`,"aria-label":`Last results, oldest first: ${e}`,children:[...e].map((e,t)=>(0,E.jsx)(`span`,{className:e===`✓`?`text-pass`:e===`✗`?`text-fail`:e===`↻`?`text-warn`:`text-muted`,children:e},t))})}function j(){let[n,i]=(0,T.useState)(null),[g,j]=(0,T.useState)(``),[M,N]=(0,T.useState)(`flaky`),[P,ie]=(0,T.useState)(`all`),[F,I]=(0,T.useState)(new Set),[L,R]=(0,T.useState)(null),[z,B]=(0,T.useState)(``),[V,H]=(0,T.useState)(!1),[U,W]=(0,T.useState)(``),G=(0,T.useCallback)(()=>{m.view().then(e=>{i(e),j(``)},e=>j(e.message))},[]);(0,T.useEffect)(G,[G]);let K=n?.tests??[],q=O(K,M,P),J=K.filter(e=>e.flaky&&!e.quarantined).length,ae=K.filter(e=>e.quarantined).length,Y=K.filter(e=>e.releasable).length,X=Object.keys(D).filter(e=>n?.causes[e]),Z=X.sort((e,t)=>(n.causes[t]??0)-(n.causes[e]??0))[0],Q=K.filter(e=>F.has(e.name)),oe=Q.some(e=>!e.quarantined),se=Q.some(e=>e.quarantined),ce=(e,t)=>{let n=new Set(F);t?n.add(e):n.delete(e),I(n)},le=async()=>{if(!L)return;let e=L===`release`,t=Q.filter(t=>e?t.quarantined:!t.quarantined).map(e=>e.name);H(!0);try{i(await m.quarantine(t,e,z.trim()||void 0)),W(`${t.length} test${t.length===1?``:`s`} ${e?`released from`:`put in`} quarantine.`),I(new Set),R(null),B(``)}catch(e){W(e.message)}finally{H(!1)}},ue=async e=>{let t=e.healIn[0];if(t){H(!0);try{await u.heal(t,[e.name]),location.hash=p(`regression`,encodeURIComponent(t))}catch(e){W(e.message),H(!1)}}},$=`py-2 pr-3 text-right tabular-nums`;return(0,E.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,E.jsx)(y,{}),(0,E.jsxs)(`main`,{className:l(b,`@container max-w-[1320px] flex-auto gap-4`),children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2`,children:[(0,E.jsxs)(`span`,{className:`flex items-center gap-3`,children:[(0,E.jsx)(te,{pixel:re.flaky,size:`lg`}),(0,E.jsx)(`h1`,{className:`m-0 text-[26px] font-semibold tracking-[-0.01em]`,children:`Flaky tests`})]}),(0,E.jsx)(S,{label:`Runs and reports`,links:C,current:`flaky`})]}),(0,E.jsxs)(`p`,{className:`m-0 max-w-[80ch] text-[13px] leading-relaxed text-ink-2`,children:[`Each automated test of `,n?.repo&&n.repo!==`.`?(0,E.jsx)(`code`,{className:`font-mono text-[12.5px]`,children:n.repo}):`the test repository`,` 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 `,n?.flakyAfter??2,` (flaky.flaky_after). Quarantine changes no test code: the test still runs, but its failure does not fail the run. Heal sends a test the last `,(0,E.jsx)(`a`,{href:p(`regression`),children:`Regression`}),` run sent to healing.`]}),g&&(0,E.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[10px] bg-fail-soft px-3 py-2 text-[13px] text-fail [overflow-wrap:anywhere]`,children:g}),!n&&!g&&(0,E.jsx)(`p`,{role:`status`,className:`m-0 text-[13px] text-muted`,children:`Loading…`}),n&&!K.length&&(0,E.jsx)(h,{icon:a,title:`No test history yet`,action:(0,E.jsxs)(`a`,{className:v({size:`sm`}),href:p(`regression`),"data-tip":`Open Regression`,children:[(0,E.jsx)(s,{"aria-hidden":`true`}),`Regression`]}),children:`ForgeQE keeps each automated test's results in .forgeqe/test-history.json whenever it runs the repository's tests: run a regression pack, or ask in a chat to run the tests, and their history shows here.`}),n&&K.length>0&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{className:`grid grid-cols-2 overflow-hidden border-y border-line-soft @xl:grid-cols-5 @xl:divide-x @xl:divide-line-soft`,children:[(0,E.jsx)(w,{label:`Tests tracked`,value:K.length,sub:`with a history`}),(0,E.jsx)(w,{label:`Flaky`,value:J,tone:J?`text-warn`:`text-pass`,sub:`not in quarantine`}),(0,E.jsx)(w,{label:`In quarantine`,value:ae,sub:`still run, not counted`}),(0,E.jsx)(w,{label:`Ready to release`,value:Y,tone:Y?`text-pass`:void 0,sub:`5 clean runs in a row`}),(0,E.jsx)(w,{label:`Most common cause`,value:Z?D[Z]:`–`,sub:Z?`${n.causes[Z]} test${n.causes[Z]===1?``:`s`}`:`nothing flaky`})]}),X.length>0&&(0,E.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,E.jsx)(`span`,{className:`text-[13px] font-medium`,children:`Likely cause`}),(0,E.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:(0,E.jsx)(_,{items:[{id:`all`,label:`All causes`},...X.map(e=>({id:e,label:D[e],n:n.causes[e]}))],value:P,onChange:ie})}),P!==`all`&&(0,E.jsx)(`p`,{className:`m-0 text-[12.5px] text-ink-2`,children:n.causeText[P]})]}),F.size>0&&(0,E.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-[10px] bg-surface-muted px-3 py-2 text-[13px]`,children:L?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`span`,{children:[L===`release`?`Release`:`Quarantine`,` `,Q.filter(e=>L===`release`?e.quarantined:!e.quarantined).length,` test(s)?`]}),L===`quarantine`&&(0,E.jsx)(f,{size:`sm`,"aria-label":`Reason`,placeholder:`Reason (optional)`,value:z,maxLength:200,onChange:e=>B(e.target.value),className:`w-full max-w-[320px] flex-[0_1_320px]`}),(0,E.jsxs)(d,{size:`sm`,disabled:V,onClick:()=>void le(),children:[L===`release`?(0,E.jsx)(t,{"aria-hidden":`true`}):(0,E.jsx)(c,{"aria-hidden":`true`}),L===`release`?`Release`:`Quarantine`]}),(0,E.jsxs)(d,{size:`sm`,variant:`ghost`,disabled:V,onClick:()=>R(null),children:[(0,E.jsx)(e,{"aria-hidden":`true`}),`Cancel`]})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`span`,{children:[F.size,` picked`]}),oe&&(0,E.jsxs)(d,{size:`sm`,onClick:()=>R(`quarantine`),children:[(0,E.jsx)(c,{"aria-hidden":`true`}),`Quarantine`]}),se&&(0,E.jsxs)(d,{size:`sm`,onClick:()=>R(`release`),"data-tip":`Release from quarantine`,children:[(0,E.jsx)(t,{"aria-hidden":`true`}),`Release`]}),(0,E.jsxs)(d,{size:`sm`,variant:`ghost`,onClick:()=>I(new Set),"data-tip":`Clear the selection`,children:[(0,E.jsx)(e,{"aria-hidden":`true`}),`Clear`]})]})}),U&&(0,E.jsx)(`p`,{role:`status`,className:`m-0 text-[13px] text-ink-2`,children:U}),(0,E.jsx)(ne,{label:`Tests`,placeholder:`Find a test by name`,resetKey:`${M}-${P}`,empty:`Nothing matches.`,tools:(0,E.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:(0,E.jsx)(_,{items:[{id:`flaky`,label:`Flaky`,n:O(K,`flaky`,P).length,alert:!0},{id:`quarantined`,label:`In quarantine`,n:O(K,`quarantined`,P).length},{id:`release`,label:`Ready to release`,n:O(K,`release`,P).length},{id:`all`,label:`All`,n:O(K,`all`,P).length}],value:M,onChange:N})}),head:(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`th`,{className:`w-8 py-1.5 pl-3 font-medium`,children:(0,E.jsx)(`span`,{className:`sr-only`,children:`Pick`})}),(0,E.jsx)(`th`,{className:`w-[38%] py-1.5 pr-3 font-medium`,children:`Test`}),(0,E.jsx)(`th`,{className:`hidden py-1.5 pr-3 font-medium @xl:table-cell`,children:`Last results`}),(0,E.jsx)(`th`,{className:`py-1.5 pr-3 text-right font-medium`,children:`Passed`}),(0,E.jsx)(`th`,{className:`hidden py-1.5 pr-3 text-right font-medium @2xl:table-cell`,children:`Flips`}),(0,E.jsx)(`th`,{className:`hidden py-1.5 pr-3 text-right font-medium @2xl:table-cell`,children:`Retry passes`}),(0,E.jsx)(`th`,{className:`hidden py-1.5 pr-3 text-right font-medium @3xl:table-cell`,children:`Run time`}),(0,E.jsx)(`th`,{className:`py-1.5 pr-3 font-medium`,children:`Cause`}),(0,E.jsx)(`th`,{className:`py-1.5 pr-3 font-medium`,children:(0,E.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]}),children:q.map(e=>{let t=e.quarantined?c:e.flaky?a:e.passRate===1?o:r,i=e.quarantined?e.releasable?`In quarantine, ready to release`:`In quarantine`:e.flaky?`Flaky`:e.passRate===1?`Steady`:`Failing`;return(0,E.jsxs)(`tr`,{className:`border-t border-line-soft hover:bg-surface-muted`,children:[(0,E.jsx)(`td`,{className:`py-2 pl-3`,children:(0,E.jsx)(x,{"aria-label":`Pick ${e.name}`,checked:F.has(e.name),onCheckedChange:t=>ce(e.name,t)})}),(0,E.jsx)(`td`,{className:`max-w-0 py-2 pr-3`,children:(0,E.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(t,{size:15,"aria-label":i,className:l(`flex-none`,e.quarantined?`text-muted`:e.flaky?`text-warn`:e.passRate===1?`text-pass`:`text-fail`)}),(0,E.jsx)(`span`,{"data-tip":e.quarantined?`${e.name} · quarantined: ${e.quarantined.reason}`:e.name,className:`truncate`,children:e.name})]})}),(0,E.jsx)(`td`,{className:`hidden py-2 pr-3 @xl:table-cell`,children:(0,E.jsx)(A,{trail:e.trail})}),(0,E.jsxs)(`td`,{className:l($,e.passRate<.8?`text-fail`:`text-muted`),children:[Math.round(e.passRate*100),`%`]}),(0,E.jsx)(`td`,{className:l($,`hidden @2xl:table-cell`,e.flips?`text-warn`:`text-muted`),children:e.flips}),(0,E.jsx)(`td`,{className:l($,`hidden @2xl:table-cell`,e.retryPasses?`text-warn`:`text-muted`),children:e.retryPasses}),(0,E.jsx)(`td`,{className:l($,`hidden @3xl:table-cell`,e.timing&&e.timing.spread>1?`text-warn`:`text-muted`),"data-tip":e.timing?`fastest ${k(e.timing.min)}, slowest ${k(e.timing.max)}`:void 0,children:e.timing?`${k(e.timing.median)} ±${Math.round(e.timing.spread*50)}%`:`–`}),(0,E.jsx)(`td`,{className:`py-2 pr-3 whitespace-nowrap text-[12.5px]`,"data-tip":e.example?`${n.causeText[e.cause]} · e.g. ${e.example}`:n.causeText[e.cause],children:e.flaky||e.quarantined||e.passRate<1?D[e.cause]:`–`}),(0,E.jsx)(`td`,{className:`py-2 pr-3 text-right whitespace-nowrap`,children:e.healIn.length>0&&(0,E.jsx)(d,{variant:`icon`,size:`icon-sm`,disabled:V,onClick:()=>void ue(e),"aria-label":`Heal ${e.name} with forgeqe pack heal in pack ${e.healIn[0]}`,"data-tip":`Heal ${e.name} with forgeqe pack heal in pack ${e.healIn[0]}`,children:(0,E.jsx)(ee,{"aria-hidden":`true`})})})]},e.name)})})]})]})]})}export{D as CAUSE_LABEL,j as Flaky,O as shown};
@@ -1 +0,0 @@
1
- import{An as e,Ir as t,Nr as n,Z as r,fn as i}from"./line-icons-CQ-3V8ax.js";import{B as a,qt as o}from"./filters-mFECJpMB.js";var s=14;function c(e){return 18+Math.min(2,Math.max(1,Math.ceil(e.title.length/30)))*20+(e.detail?18:0)+(e.personal?18:0)}function l(e,t,n,r){let i=new Map(t.map(t=>[t.id,e.indexOf(t.column)]));if(!i.has(r))return new Set;let a=new Set([r]),o=[r];for(;o.length;){let e=o.pop();for(let t of n){let n=t.from===e?t.to:t.to===e?t.from:void 0;n!==void 0&&!a.has(n)&&i.has(n)&&(i.get(n)<=i.get(e)||(a.add(n),o.push(n)))}}return a}function u(e,t,n){let r=e.filter(e=>t.some(t=>t.column===e)),i=new Map(t.map(e=>[e.id,r.indexOf(e.column)])),a=new Map;for(let e of n)i.has(e.from)&&i.has(e.to)&&e.from!==e.to&&(a.set(e.from,[...a.get(e.from)||[],e.to]),a.set(e.to,[...a.get(e.to)||[],e.from]));let o=r.map(e=>t.filter(t=>t.column===e)),l=new Map;o.forEach(e=>e.forEach((e,t)=>l.set(e.id,t)));let u=(e,t)=>{o[e]=o[e].map((e,n)=>{let r=(a.get(e.id)||[]).filter(e=>t(i.get(e))).map(e=>l.get(e));return{n:e,k:n,key:r.length?r.reduce((e,t)=>e+t,0)/r.length:n}}).sort((e,t)=>e.key-t.key||e.k-t.k).map(e=>e.n),o[e].forEach((e,t)=>l.set(e.id,t))};for(let e=1;e<o.length;e++)u(e,t=>t<e);for(let e=o.length-2;e>=0;e--)u(e,t=>t>e);for(let e=1;e<o.length;e++)u(e,t=>t<e);let d=new Map;o.forEach((e,t)=>{let n=-1/0;for(let r of e){let e=c(r),o=(a.get(r.id)||[]).filter(e=>i.get(e)<t&&d.has(e)).map(e=>d.get(e)),l=o.length?o.reduce((e,t)=>e+t.y+t.h/2,0)/o.length-e/2:0,u=Math.max(l,n===-1/0?0:n+s);d.set(r.id,{x:t*360,y:u,w:250,h:e}),n=u+e}});for(let e=o.length-2;e>=0;e--){let t=-1/0;for(let n of o[e]){let r=d.get(n.id),o=(a.get(n.id)||[]).filter(t=>i.get(t)>e).map(e=>d.get(e)),c=o.length?o.reduce((e,t)=>e+t.y+t.h/2,0)/o.length-r.h/2:r.y;r.y=Math.max(c,t===-1/0?-1/0:t+s),t=r.y+r.h}}let f=Math.min(...[...d.values()].map(e=>e.y));if(Number.isFinite(f))for(let e of d.values())e.y-=f;return d}function d(e){let t=+this._x.call(null,e),n=+this._y.call(null,e);return f(this.cover(t,n),t,n,e)}function f(e,t,n,r){if(isNaN(t)||isNaN(n))return e;var i,a=e._root,o={data:r},s=e._x0,c=e._y0,l=e._x1,u=e._y1,d,f,p,m,h,g,_,v;if(!a)return e._root=o,e;for(;a.length;)if((h=t>=(d=(s+l)/2))?s=d:l=d,(g=n>=(f=(c+u)/2))?c=f:u=f,i=a,!(a=a[_=g<<1|h]))return i[_]=o,e;if(p=+e._x.call(null,a.data),m=+e._y.call(null,a.data),t===p&&n===m)return o.next=a,i?i[_]=o:e._root=o,e;do i=i?i[_]=[,,,,]:e._root=[,,,,],(h=t>=(d=(s+l)/2))?s=d:l=d,(g=n>=(f=(c+u)/2))?c=f:u=f;while((_=g<<1|h)==(v=(m>=f)<<1|p>=d));return i[v]=a,i[_]=o,e}function p(e){Array.isArray(e)||(e=Array.from(e));let t=e.length,n=new Float64Array(t),r=new Float64Array(t),i=1/0,a=i,o=-i,s=o;for(let c=0,l,u,d;c<t;++c)isNaN(u=+this._x.call(null,l=e[c]))||isNaN(d=+this._y.call(null,l))?n[c]=NaN:(n[c]=u,r[c]=d,u<i&&(i=u),u>o&&(o=u),d<a&&(a=d),d>s&&(s=d));if(i>o||a>s)return this;this.cover(i,a).cover(o,s);for(let i=0;i<t;++i)f(this,n[i],r[i],e[i]);return this}function m(e,t){if(isNaN(e=+e)||isNaN(t=+t))return this;var n=this._x0,r=this._y0,i=this._x1,a=this._y1;if(isNaN(n))i=(n=Math.floor(e))+1,a=(r=Math.floor(t))+1;else{for(var o=i-n||1,s=this._root,c,l;n>e||e>=i||r>t||t>=a;)switch(l=(t<r)<<1|e<n,c=[,,,,],c[l]=s,s=c,o*=2,l){case 0:i=n+o,a=r+o;break;case 1:n=i-o,a=r+o;break;case 2:i=n+o,r=a-o;break;case 3:n=i-o,r=a-o}this._root&&this._root.length&&(this._root=s)}return this._x0=n,this._y0=r,this._x1=i,this._y1=a,this}function h(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function g(e){return arguments.length?this.cover(+e[0][0],+e[0][1]).cover(+e[1][0],+e[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function _(e,t,n,r,i){this.node=e,this.x0=t,this.y0=n,this.x1=r,this.y1=i}function v(e,t,n){var r,i=this._x0,a=this._y0,o,s,c,l,u=this._x1,d=this._y1,f=[],p=this._root,m,h;for(p&&f.push(new _(p,i,a,u,d)),n==null?n=1/0:(i=e-n,a=t-n,u=e+n,d=t+n,n*=n);m=f.pop();)if(!(!(p=m.node)||(o=m.x0)>u||(s=m.y0)>d||(c=m.x1)<i||(l=m.y1)<a)){if(p.length){var g=(o+c)/2,v=(s+l)/2;f.push(new _(p[3],g,v,c,l),new _(p[2],o,v,g,l),new _(p[1],g,s,c,v),new _(p[0],o,s,g,v)),(h=(t>=v)<<1|e>=g)&&(m=f[f.length-1],f[f.length-1]=f[f.length-1-h],f[f.length-1-h]=m)}else{var y=e-+this._x.call(null,p.data),b=t-+this._y.call(null,p.data),x=y*y+b*b;if(x<n){var S=Math.sqrt(n=x);i=e-S,a=t-S,u=e+S,d=t+S,r=p.data}}}return r}function y(e){if(isNaN(u=+this._x.call(null,e))||isNaN(d=+this._y.call(null,e)))return this;var t,n=this._root,r,i,a,o=this._x0,s=this._y0,c=this._x1,l=this._y1,u,d,f,p,m,h,g,_;if(!n)return this;if(n.length)for(;;){if((m=u>=(f=(o+c)/2))?o=f:c=f,(h=d>=(p=(s+l)/2))?s=p:l=p,t=n,!(n=n[g=h<<1|m]))return this;if(!n.length)break;(t[g+1&3]||t[g+2&3]||t[g+3&3])&&(r=t,_=g)}for(;n.data!==e;)if(i=n,!(n=n.next))return this;return(a=n.next)&&delete n.next,i?(a?i.next=a:delete i.next,this):t?(a?t[g]=a:delete t[g],(n=t[0]||t[1]||t[2]||t[3])&&n===(t[3]||t[2]||t[1]||t[0])&&!n.length&&(r?r[_]=n:this._root=n),this):(this._root=a,this)}function b(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this}function x(){return this._root}function S(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function C(e){var t=[],n,r=this._root,i,a,o,s,c;for(r&&t.push(new _(r,this._x0,this._y0,this._x1,this._y1));n=t.pop();)if(!e(r=n.node,a=n.x0,o=n.y0,s=n.x1,c=n.y1)&&r.length){var l=(a+s)/2,u=(o+c)/2;(i=r[3])&&t.push(new _(i,l,u,s,c)),(i=r[2])&&t.push(new _(i,a,u,l,c)),(i=r[1])&&t.push(new _(i,l,o,s,u)),(i=r[0])&&t.push(new _(i,a,o,l,u))}return this}function w(e){var t=[],n=[],r;for(this._root&&t.push(new _(this._root,this._x0,this._y0,this._x1,this._y1));r=t.pop();){var i=r.node;if(i.length){var a,o=r.x0,s=r.y0,c=r.x1,l=r.y1,u=(o+c)/2,d=(s+l)/2;(a=i[0])&&t.push(new _(a,o,s,u,d)),(a=i[1])&&t.push(new _(a,u,s,c,d)),(a=i[2])&&t.push(new _(a,o,d,u,l)),(a=i[3])&&t.push(new _(a,u,d,c,l))}n.push(r)}for(;r=n.pop();)e(r.node,r.x0,r.y0,r.x1,r.y1);return this}function T(e){return e[0]}function E(e){return arguments.length?(this._x=e,this):this._x}function D(e){return e[1]}function O(e){return arguments.length?(this._y=e,this):this._y}function k(e,t,n){var r=new A(t??T,n??D,NaN,NaN,NaN,NaN);return e==null?r:r.addAll(e)}function A(e,t,n,r,i,a){this._x=e,this._y=t,this._x0=n,this._y0=r,this._x1=i,this._y1=a,this._root=void 0}function j(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var M=k.prototype=A.prototype;M.copy=function(){var e=new A(this._x,this._y,this._x0,this._y0,this._x1,this._y1),t=this._root,n,r;if(!t)return e;if(!t.length)return e._root=j(t),e;for(n=[{source:t,target:e._root=[,,,,]}];t=n.pop();)for(var i=0;i<4;++i)(r=t.source[i])&&(r.length?n.push({source:r,target:t.target[i]=[,,,,]}):t.target[i]=j(r));return e},M.add=d,M.addAll=p,M.cover=m,M.data=h,M.extent=g,M.find=v,M.remove=y,M.removeAll=b,M.root=x,M.size=S,M.visit=C,M.visitAfter=w,M.x=E,M.y=O;function N(e){return function(){return e}}function P(e){return(e()-.5)*1e-6}function F(e){return e.x+e.vx}function I(e){return e.y+e.vy}function ee(e){var t,n,r,i=1,a=1;typeof e!=`function`&&(e=N(e==null?1:+e));function o(){for(var e,o=t.length,c,l,u,d,f,p,m=0;m<a;++m)for(c=k(t,F,I).visitAfter(s),e=0;e<o;++e)l=t[e],f=n[l.index],p=f*f,u=l.x+l.vx,d=l.y+l.vy,c.visit(h);function h(e,t,n,a,o){var s=e.data,c=e.r,m=f+c;if(s){if(s.index>l.index){var h=u-s.x-s.vx,g=d-s.y-s.vy,_=h*h+g*g;_<m*m&&(h===0&&(h=P(r),_+=h*h),g===0&&(g=P(r),_+=g*g),_=(m-(_=Math.sqrt(_)))/_*i,l.vx+=(h*=_)*(m=(c*=c)/(p+c)),l.vy+=(g*=_)*m,s.vx-=h*(m=1-m),s.vy-=g*m)}}else return t>u+m||a<u-m||n>d+m||o<d-m}}function s(e){if(e.data)return e.r=n[e.data.index];for(var t=e.r=0;t<4;++t)e[t]&&e[t].r>e.r&&(e.r=e[t].r)}function c(){if(t){var r,i=t.length,a;for(n=Array(i),r=0;r<i;++r)a=t[r],n[a.index]=+e(a,r,t)}}return o.initialize=function(e,n){t=e,r=n,c()},o.iterations=function(e){return arguments.length?(a=+e,o):a},o.strength=function(e){return arguments.length?(i=+e,o):i},o.radius=function(t){return arguments.length?(e=typeof t==`function`?t:N(+t),c(),o):e},o}function te(e){return e.index}function ne(e,t){var n=e.get(t);if(!n)throw Error(`node not found: `+t);return n}function re(e){var t=te,n=d,r,i=N(30),a,o,s,c,l,u=1;e??=[];function d(e){return 1/Math.min(s[e.source.index],s[e.target.index])}function f(t){for(var n=0,i=e.length;n<u;++n)for(var o=0,s,d,f,p,m,h,g;o<i;++o)s=e[o],d=s.source,f=s.target,p=f.x+f.vx-d.x-d.vx||P(l),m=f.y+f.vy-d.y-d.vy||P(l),h=Math.sqrt(p*p+m*m),h=(h-a[o])/h*t*r[o],p*=h,m*=h,f.vx-=p*(g=c[o]),f.vy-=m*g,d.vx+=p*(g=1-g),d.vy+=m*g}function p(){if(o){var n,i=o.length,l=e.length,u=new Map(o.map((e,n)=>[t(e,n,o),e])),d;for(n=0,s=Array(i);n<l;++n)d=e[n],d.index=n,typeof d.source!=`object`&&(d.source=ne(u,d.source)),typeof d.target!=`object`&&(d.target=ne(u,d.target)),s[d.source.index]=(s[d.source.index]||0)+1,s[d.target.index]=(s[d.target.index]||0)+1;for(n=0,c=Array(l);n<l;++n)d=e[n],c[n]=s[d.source.index]/(s[d.source.index]+s[d.target.index]);r=Array(l),m(),a=Array(l),h()}}function m(){if(o)for(var t=0,i=e.length;t<i;++t)r[t]=+n(e[t],t,e)}function h(){if(o)for(var t=0,n=e.length;t<n;++t)a[t]=+i(e[t],t,e)}return f.initialize=function(e,t){o=e,l=t,p()},f.links=function(t){return arguments.length?(e=t,p(),f):e},f.id=function(e){return arguments.length?(t=e,f):t},f.iterations=function(e){return arguments.length?(u=+e,f):u},f.strength=function(e){return arguments.length?(n=typeof e==`function`?e:N(+e),m(),f):n},f.distance=function(e){return arguments.length?(i=typeof e==`function`?e:N(+e),h(),f):i},f}var ie={value:()=>{}};function L(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new R(n)}function R(e){this._=e}function ae(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}R.prototype=L.prototype={constructor:R,on:function(e,t){var n=this._,r=ae(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=oe(n[i],e.name)))return i}else{if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=se(n[i],e.name,t);else if(t==null)for(i in n)n[i]=se(n[i],e.name,null);return this}},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new R(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function oe(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function se(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=ie,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var z=0,B=0,V=0,ce=1e3,H,U,W=0,G=0,K=0,q=typeof performance==`object`&&performance.now?performance:Date,le=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function J(){return G||=(le(ue),q.now()+K)}function ue(){G=0}function Y(){this._call=this._time=this._next=null}Y.prototype=X.prototype={constructor:Y,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?J():+n)+(t==null?0:+t),!this._next&&U!==this&&(U?U._next=this:H=this,U=this),this._call=e,this._time=n,Z()},stop:function(){this._call&&(this._call=null,this._time=1/0,Z())}};function X(e,t,n){var r=new Y;return r.restart(e,t,n),r}function de(){J(),++z;for(var e=H,t;e;)(t=G-e._time)>=0&&e._call.call(void 0,t),e=e._next;--z}function fe(){G=(W=q.now())+K,z=B=0;try{de()}finally{z=0,me(),G=0}}function pe(){var e=q.now(),t=e-W;t>ce&&(K-=t,W=e)}function me(){for(var e,t=H,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:H=n);U=e,Z(r)}function Z(e){z||(B&&=clearTimeout(B),e-G>24?(e<1/0&&(B=setTimeout(fe,Math.ceil(e-q.now()-K)+1)),V&&=clearInterval(V)):(V||=(W=q.now(),setInterval(pe,ce)),z=1,le(fe)))}function he(e,t,n){var r=new Y;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var ge=1664525,_e=1013904223,ve=4294967296;function ye(){let e=1;return()=>(e=(ge*e+_e)%ve)/ve}function be(e){return e.x}function xe(e){return e.y}var Se=10,Ce=Math.PI*(3-Math.sqrt(5));function we(e){var t,n=1,r=.001,i=1-r**(1/300),a=0,o=.6,s=new Map,c=X(d),l=L(`tick`,`end`),u=ye();e??=[];function d(){f(),l.call(`tick`,t),n<r&&(c.stop(),l.call(`end`,t))}function f(r){var c,l=e.length,u;r===void 0&&(r=1);for(var d=0;d<r;++d)for(n+=(a-n)*i,s.forEach(function(e){e(n)}),c=0;c<l;++c)u=e[c],u.fx==null?u.x+=u.vx*=o:(u.x=u.fx,u.vx=0),u.fy==null?u.y+=u.vy*=o:(u.y=u.fy,u.vy=0);return t}function p(){for(var t=0,n=e.length,r;t<n;++t){if(r=e[t],r.index=t,r.fx!=null&&(r.x=r.fx),r.fy!=null&&(r.y=r.fy),isNaN(r.x)||isNaN(r.y)){var i=Se*Math.sqrt(.5+t),a=t*Ce;r.x=i*Math.cos(a),r.y=i*Math.sin(a)}(isNaN(r.vx)||isNaN(r.vy))&&(r.vx=r.vy=0)}}function m(t){return t.initialize&&t.initialize(e,u),t}return p(),t={tick:f,restart:function(){return c.restart(d),t},stop:function(){return c.stop(),t},nodes:function(n){return arguments.length?(e=n,p(),s.forEach(m),t):e},alpha:function(e){return arguments.length?(n=+e,t):n},alphaMin:function(e){return arguments.length?(r=+e,t):r},alphaDecay:function(e){return arguments.length?(i=+e,t):+i},alphaTarget:function(e){return arguments.length?(a=+e,t):a},velocityDecay:function(e){return arguments.length?(o=1-e,t):1-o},randomSource:function(e){return arguments.length?(u=e,s.forEach(m),t):u},force:function(e,n){return arguments.length>1?(n==null?s.delete(e):s.set(e,m(n)),t):s.get(e)},find:function(t,n,r){var i=0,a=e.length,o,s,c,l,u;for(r==null?r=1/0:r*=r,i=0;i<a;++i)l=e[i],o=t-l.x,s=n-l.y,c=o*o+s*s,c<r&&(u=l,r=c);return u},on:function(e,n){return arguments.length>1?(l.on(e,n),t):l.on(e)}}}function Te(){var e,t,n,r,i=N(-30),a,o=1,s=1/0,c=.81;function l(n){var i,a=e.length,o=k(e,be,xe).visitAfter(d);for(r=n,i=0;i<a;++i)t=e[i],o.visit(f)}function u(){if(e){var t,n=e.length,r;for(a=Array(n),t=0;t<n;++t)r=e[t],a[r.index]=+i(r,t,e)}}function d(e){var t=0,n,r,i=0,o,s,c;if(e.length){for(o=s=c=0;c<4;++c)(n=e[c])&&(r=Math.abs(n.value))&&(t+=n.value,i+=r,o+=r*n.x,s+=r*n.y);e.x=o/i,e.y=s/i}else{n=e,n.x=n.data.x,n.y=n.data.y;do t+=a[n.data.index];while(n=n.next)}e.value=t}function f(e,i,l,u){if(!e.value)return!0;var d=e.x-t.x,f=e.y-t.y,p=u-i,m=d*d+f*f;if(p*p/c<m)return m<s&&(d===0&&(d=P(n),m+=d*d),f===0&&(f=P(n),m+=f*f),m<o&&(m=Math.sqrt(o*m)),t.vx+=d*e.value*r/m,t.vy+=f*e.value*r/m),!0;if(!(e.length||m>=s)){(e.data!==t||e.next)&&(d===0&&(d=P(n),m+=d*d),f===0&&(f=P(n),m+=f*f),m<o&&(m=Math.sqrt(o*m)));do e.data!==t&&(p=a[e.data.index]*r/m,t.vx+=d*p,t.vy+=f*p);while(e=e.next)}}return l.initialize=function(t,r){e=t,n=r,u()},l.strength=function(e){return arguments.length?(i=typeof e==`function`?e:N(+e),u(),l):i},l.distanceMin=function(e){return arguments.length?(o=e*e,l):Math.sqrt(o)},l.distanceMax=function(e){return arguments.length?(s=e*e,l):Math.sqrt(s)},l.theta=function(e){return arguments.length?(c=e*e,l):Math.sqrt(c)},l}function Ee(e){var t=N(.1),n,r,i;typeof e!=`function`&&(e=N(e==null?0:+e));function a(e){for(var t=0,a=n.length,o;t<a;++t)o=n[t],o.vx+=(i[t]-o.x)*r[t]*e}function o(){if(n){var a,o=n.length;for(r=Array(o),i=Array(o),a=0;a<o;++a)r[a]=isNaN(i[a]=+e(n[a],a,n))?0:+t(n[a],a,n)}}return a.initialize=function(e){n=e,o()},a.strength=function(e){return arguments.length?(t=typeof e==`function`?e:N(+e),o(),a):t},a.x=function(t){return arguments.length?(e=typeof t==`function`?t:N(+t),o(),a):e},a}function De(e){var t=N(.1),n,r,i;typeof e!=`function`&&(e=N(e==null?0:+e));function a(e){for(var t=0,a=n.length,o;t<a;++t)o=n[t],o.vy+=(i[t]-o.y)*r[t]*e}function o(){if(n){var a,o=n.length;for(r=Array(o),i=Array(o),a=0;a<o;++a)r[a]=isNaN(i[a]=+e(n[a],a,n))?0:+t(n[a],a,n)}}return a.initialize=function(e){n=e,o()},a.strength=function(e){return arguments.length?(t=typeof e==`function`?e:N(+e),o(),a):t},a.y=function(t){return arguments.length?(e=typeof t==`function`?t:N(+t),o(),a):e},a}var Q=t(n(),1);function Oe(e,t){let n=[];for(let r of e)for(let e=0;e<12;e++)n.push({x:r.x+Math.cos(e/12*2*Math.PI)*t,y:r.y+Math.sin(e/12*2*Math.PI)*t});if(n.length<3)return n;let r=[...n].sort((e,t)=>e.x-t.x||e.y-t.y),i=(e,t,n)=>(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x),a=[];for(let e of r){for(;a.length>=2&&i(a[a.length-2],a[a.length-1],e)<=0;)a.pop();a.push(e)}let o=[];for(let e of[...r].reverse()){for(;o.length>=2&&i(o[o.length-2],o[o.length-1],e)<=0;)o.pop();o.push(e)}return[...a.slice(0,-1),...o.slice(0,-1)]}function ke(e,t,n=3){let r=new Map;for(let t of e)t.from!==t.to&&r.set(t.to,[...r.get(t.to)||[],t.from]);let i=new Map,a=[t];for(let e=1;e<=n&&a.length;e++){let n=[];for(let o of a)for(let a of r.get(o)||[])a===t||i.has(a)||(i.set(a,e),n.push(a));a=n}return i}var $=o();function Ae(e){if(e.length<3)return e;let t=[...e].sort((e,t)=>e.x-t.x||e.y-t.y),n=(e,t,n)=>(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x),r=e=>{let t=[];for(let r of e){for(;t.length>=2&&n(t[t.length-2],t[t.length-1],r)<=0;)t.pop();t.push(r)}return t},i=r(t),a=r([...t].reverse());return[...i.slice(0,-1),...a.slice(0,-1)]}function je(e,t,n=1,r=0){let i=new Map;for(let e of t)i.set(e.group,(i.get(e.group)||0)+1);let a=e=>Math.max((Math.sqrt(i.get(e)||1)*26+40)*n,r);if(e.length===1)return new Map([[e[0],{x:0,y:0}]]);let o=e.reduce((e,t)=>e+a(t),0),s=Math.max(120,o/(2*Math.PI)),c=0;return new Map(e.map(e=>{let t=c+a(e)/2;c+=a(e);let n=t/o*2*Math.PI;return[e,{x:Math.cos(n)*s,y:Math.sin(n)*s}]}))}var Me=`var(--color-accent)`,Ne=`#8b5cf6`,Pe=`#f59e0b`,Fe=`'JetBrains Mono', ui-monospace, monospace`;function Ie({files:t,links:n,markOf:o,onPick:s,onHover:c,outlines:l,label:u,look:d=`map`,alwaysNamed:f,groupColour:p,keepColours:m,ringOf:h,colourOf:g,litLink:_}){let v=d===`codeflow`,y=(0,Q.useRef)(null),[,b]=(0,Q.useState)(0),[x,S]=(0,Q.useState)({x:0,y:0,k:1}),C=(0,Q.useRef)(!1),w=(0,Q.useRef)(null),T=(0,Q.useMemo)(()=>[...new Set(t.map(e=>e.group))],[t]),{nodes:E,edges:D}=(0,Q.useMemo)(()=>{let e=je(T,t,v?1.5:1,m&&v?170:0),r=t.map((t,n)=>{let r=e.get(t.group);return{id:t.id,f:t,x:r.x+Math.cos(n)*30,y:r.y+Math.sin(n)*30}}),i=new Set(r.map(e=>e.id));return{nodes:r,edges:n.filter(e=>i.has(e.from)&&i.has(e.to)).map(e=>({source:e.from,target:e.to,from:e.from,to:e.to,weight:e.weight})),home:e}},[t,n,T,v]);(0,Q.useEffect)(()=>{let e=new Map(E.map(e=>[e.id,e.f.group])),n=t=>e.get(t.from)===e.get(t.to),r=je(T,t,v?1.5:1,m&&v?170:0),i=v?we(E).force(`link`,re(D).id(e=>e.id).distance(48).strength(.3)).force(`charge`,Te().strength(-120).distanceMax(300)).force(`collide`,ee(e=>e.f.r+4)).force(`x`,Ee(e=>r.get(e.f.group).x).strength(.28)).force(`y`,De(e=>r.get(e.f.group).y).strength(.28)):we(E).force(`link`,re(D).id(e=>e.id).distance(e=>n(e)?30:160).strength(e=>n(e)?.35:.004)).force(`charge`,Te().strength(-34).distanceMax(180)).force(`collide`,ee(e=>e.f.r+3)).force(`x`,Ee(e=>r.get(e.f.group).x).strength(.22)).force(`y`,De(e=>r.get(e.f.group).y).strength(.22)).alphaDecay(.03);i.stop(),i.tick(320),C.current=!1;let a=0;return i.on(`tick`,()=>{cancelAnimationFrame(a),a=requestAnimationFrame(()=>b(e=>e+1))}),i.alpha(.25).restart(),w.current=i,b(e=>e+1),()=>{i.stop(),cancelAnimationFrame(a)}},[E,D,t.length,T,v]);let O=()=>{let e=y.current;if(!e||!E.length)return;let t=E.map(e=>e.x??0),n=E.map(e=>e.y??0),r=v?{l:50,r:150,t:75,b:45}:{l:40,r:40,t:50,b:30},[i,a,o,s]=[Math.min(...t)-r.l,Math.max(...t)+r.r,Math.min(...n)-r.t,Math.max(...n)+r.b],c=Math.min(2,e.clientWidth/Math.max(1,a-i),e.clientHeight/Math.max(1,s-o));S({k:c,x:e.clientWidth/2-(i+a)/2*c,y:e.clientHeight/2-(o+s)/2*c})};(0,Q.useEffect)(()=>{!C.current&&E.length&&y.current?.clientWidth&&(C.current=!0,O())}),(0,Q.useEffect)(()=>{let e=y.current;if(!e)return;let t=t=>{t.preventDefault();let n=e.getBoundingClientRect(),r=t.clientX-n.left,i=t.clientY-n.top;S(e=>{let n=Math.min(4,Math.max(.15,e.k*Math.exp(-t.deltaY*(t.ctrlKey?.01:.0015))));return{k:n,x:r-(r-e.x)/e.k*n,y:i-(i-e.y)/e.k*n}})};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]);let k=(0,Q.useRef)(null),A=(e,t)=>{e.stopPropagation(),e.currentTarget.setPointerCapture?.(e.pointerId),k.current={kind:t?`node`:`pan`,id:t,sx:e.clientX,sy:e.clientY,vx:x.x,vy:x.y,moved:!1},t&&w.current?.alphaTarget(.25).restart()},j=e=>{let t=k.current;if(t){if(Math.abs(e.clientX-t.sx)+Math.abs(e.clientY-t.sy)>3&&(t.moved=!0),t.kind===`pan`)S(n=>({...n,x:t.vx+e.clientX-t.sx,y:t.vy+e.clientY-t.sy}));else{let n=E.find(e=>e.id===t.id),r=y.current.getBoundingClientRect();n&&(n.fx=(e.clientX-r.left-x.x)/x.k,n.fy=(e.clientY-r.top-x.y)/x.k)}}},M=()=>{let e=k.current;if(k.current=null,e){if(e.kind===`node`){let t=E.find(t=>t.id===e.id);t&&(t.fx=null,t.fy=null),w.current?.alphaTarget(0),e.moved||s(e.id)}else e.moved||s(null)}},N=e=>{let t=y.current;S(n=>{let r=Math.min(4,Math.max(.15,n.k*e)),i=t.clientWidth/2,a=t.clientHeight/2;return{k:r,x:i-(i-n.x)/n.k*r,y:a-(a-n.y)/n.k*r}})},P=E.some(e=>o(e.id)===`on`),F=new Map(E.map(e=>[e.id,e])),I=E.find(e=>o(e.id)===`on`)?.id,te=new Set(I?D.filter(e=>e.from===I).map(e=>e.to):[]),ne=new Set(I?E.filter(e=>o(e.id)===`hit`||D.some(t=>t.to===I&&t.from===e.id)).map(e=>e.id):[]),ie=(e,t)=>t===`on`||t===`near`||!P&&!!f?.(e.id)||!P&&x.k>1.3&&e.f.r>6||x.k>2.2,L=l?T.map(e=>{let t=E.filter(t=>t.f.group===e),n=t.map(e=>({x:e.x??0,y:e.y??0})),r=p?.(e)??t[0]?.f.colour??`var(--color-muted)`;if(v){let t=Ae(n.flatMap(e=>[{x:e.x-30,y:e.y-30},{x:e.x+30,y:e.y-30},{x:e.x-30,y:e.y+30},{x:e.x+30,y:e.y+30}])),i={x:n.reduce((e,t)=>e+t.x,0)/Math.max(1,n.length),y:Math.min(...n.map(e=>e.y))-38};return{g:e,d:`M ${t.map(e=>`${e.x.toFixed(1)} ${e.y.toFixed(1)}`).join(` L `)} Z`,top:i,colour:r}}let i=Oe(n,22),a=i.reduce((e,t)=>t.y<e.y?t:e,i[0]??{x:0,y:0});return{g:e,d:i.length>2?`M ${i.map(e=>`${e.x.toFixed(1)} ${e.y.toFixed(1)}`).join(` L `)} Z`:``,top:{x:a.x,y:a.y-8/x.k},colour:r}}):[],R=e=>g?.(e.id)??e.f.colour,ae=e=>{if(!I)return{fill:R(e),r:e.f.r,opacity:1};if(m){let t=o(e.id);return e.id===I?{fill:R(e),r:e.f.r*1.6,opacity:1}:t===`hit`||t===`near`?{fill:R(e),r:e.f.r*1.15,opacity:1}:{fill:R(e),r:e.f.r*.8,opacity:.15}}return e.id===I?{fill:Me,r:e.f.r*1.6,opacity:1}:ne.has(e.id)?{fill:Ne,r:e.f.r*1.25,opacity:1}:te.has(e.id)?{fill:Pe,r:e.f.r*1.25,opacity:1}:{fill:e.f.colour,r:e.f.r*.7,opacity:.15}};return(0,$.jsxs)(`div`,{ref:y,className:`relative size-full touch-none select-none overflow-hidden`,onPointerMove:j,onPointerUp:M,onPointerLeave:M,children:[(0,$.jsx)(`svg`,{role:`group`,"aria-label":u,className:`block size-full cursor-grab active:cursor-grabbing`,onPointerDown:e=>A(e),children:(0,$.jsxs)(`g`,{transform:`translate(${x.x},${x.y}) scale(${x.k})`,children:[L.map(e=>(0,$.jsxs)(`g`,{className:a(`pointer-events-none transition-opacity`,P&&`opacity-40`),children:[e.d&&(0,$.jsx)(`path`,{d:e.d,fill:e.colour,fillOpacity:v?.04:.06,stroke:e.colour,strokeOpacity:v?.25:.35,strokeWidth:v?2:1.2/x.k,strokeLinejoin:`round`}),(0,$.jsx)(`text`,{x:e.top.x,y:e.top.y,textAnchor:`middle`,fill:e.colour,opacity:v?.85:1,style:{fontSize:v?12/x.k:Math.max(11,14/x.k),fontWeight:600,fontFamily:v?Fe:void 0,paintOrder:`stroke`},stroke:`var(--color-bg)`,strokeWidth:4/x.k,children:e.g})]},e.g)),D.map((e,t)=>{let n=F.get(e.from),r=F.get(e.to);if(!n||!r)return null;let i=o(e.from),a=o(e.to),s=i===`on`||a===`on`,c=!s&&i===`hit`&&a===`hit`;if(v){let i=((n.x??0)+(r.x??0))/2-((r.y??0)-(n.y??0))*.15,a=((n.y??0)+(r.y??0))/2+((r.x??0)-(n.x??0))*.15,o=!!I&&(e.from===I||e.to===I),s=m?o||c?_??`var(--color-ink-2)`:`var(--color-muted)`:o?e.from===I?Pe:Ne:c?Ne:`var(--color-muted)`;return(0,$.jsx)(`path`,{d:`M ${n.x} ${n.y} Q ${i} ${a} ${r.x} ${r.y}`,fill:`none`,stroke:s,strokeOpacity:I?o||c?.9:.05:.25,strokeWidth:o||c?1.8:1},t)}return(0,$.jsx)(`line`,{x1:n.x,y1:n.y,x2:r.x,y2:r.y,stroke:s?`var(--color-ink-2)`:c?`var(--color-warn)`:`var(--color-muted)`,strokeOpacity:P?s||c?.95:.06:.28,strokeWidth:Math.min(3,.8+Math.log2(e.weight+1)*.6)*(s||c?1.6:1)/Math.sqrt(x.k)},t)}),E.map(e=>{let t=o(e.id),n=t===`on`?`var(--color-ink)`:h?.(e.id)??(t===`hit`&&!m?`var(--color-warn)`:void 0);return(0,$.jsxs)(`g`,{role:`button`,tabIndex:0,"aria-label":e.f.label,transform:`translate(${e.x??0},${e.y??0})`,className:a(`cursor-pointer outline-none [&:focus-visible>circle]:stroke-accent [&:focus-visible>circle]:[stroke-width:3]`,!v&&t===`dim`&&`opacity-20`),onPointerDown:t=>A(t,e.id),onPointerEnter:()=>c(e.id),onPointerLeave:()=>c(null),onFocus:()=>c(e.id),onBlur:()=>c(null),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),s(e.id))},children:[v?(()=>{let n=ae(e);return(0,$.jsxs)(`g`,{opacity:n.opacity,children:[(h?.(e.id)||m&&t===`on`)&&(0,$.jsx)(`circle`,{r:n.r+4,fill:`none`,stroke:h?.(e.id)??`var(--color-ink)`,strokeWidth:2.5}),(0,$.jsx)(`circle`,{r:n.r,fill:n.fill,fillOpacity:.9,stroke:n.fill,strokeOpacity:.6,strokeWidth:1.5}),(!I||n.opacity===1)&&(!m||!f||f(e.id)||e.id===I||x.k>1.4)&&(0,$.jsx)(`text`,{x:n.r+3/x.k,dy:`0.35em`,className:`pointer-events-none`,fill:`var(--color-ink)`,style:{fontSize:11/x.k,fontFamily:Fe,fontWeight:600,paintOrder:`stroke`},stroke:`var(--color-bg)`,strokeWidth:3/x.k,children:e.f.name.length>26?`${e.f.name.slice(0,25)}…`:e.f.name})]})})():(0,$.jsxs)($.Fragment,{children:[n&&(0,$.jsx)(`circle`,{r:e.f.r+3.5,fill:`none`,stroke:n,strokeWidth:2}),(0,$.jsx)(`circle`,{r:e.f.r,fill:R(e),stroke:`var(--color-bg)`,strokeWidth:1})]}),!v&&ie(e,t)&&t!==`dim`&&(0,$.jsx)(`text`,{x:e.f.r+4,y:4,className:`pointer-events-none fill-ink-2`,style:{fontSize:Math.max(9,12/x.k),paintOrder:`stroke`},stroke:`var(--color-bg)`,strokeWidth:3/x.k,children:e.f.name})]},e.id)})]})}),(0,$.jsx)(`div`,{className:`absolute bottom-3 left-3 flex overflow-hidden rounded-[8px] border border-line bg-bg`,children:[[e,`Zoom in`,()=>N(1.3)],[i,`Zoom out`,()=>N(1/1.3)],[r,`Fit the map`,O]].map(([e,t,n])=>(0,$.jsx)(`button`,{type:`button`,"aria-label":t,"data-tip":t,onClick:n,className:`flex size-8 cursor-pointer items-center justify-center border-r border-line text-ink-2 last:border-r-0 hover:bg-surface-muted hover:text-ink`,children:(0,$.jsx)(e,{size:15,"aria-hidden":`true`})},t))})]})}export{X as a,l as c,he as i,ke as n,L as o,J as r,u as s,Ie as t};