@capagents/forgeqe 2.8.7 → 2.8.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HOW_TO_USE.md +10 -2
- package/dist/docs-site/docs/index.html +9 -2
- package/dist/docs-site/docs/search.js +1 -1
- package/dist/docs-site/docs/web-app/index.html +34 -19
- package/dist/forgeqe.js +1443 -1443
- package/dist/web/assets/Agent-CHliM9aG.js +4 -0
- package/dist/web/assets/ApiTests-DcGDtIjl.js +10 -0
- package/dist/web/assets/Browse-DWZgEdaB.js +1 -0
- package/dist/web/assets/{Chat-fm1mQ6Dn.js → Chat-DVolc6Rs.js} +3 -3
- package/dist/web/assets/{CommandPalette-CKjhw2tZ.js → CommandPalette-CdwjRIsa.js} +1 -1
- package/dist/web/assets/Cost-BifpK_Ac.js +1 -0
- package/dist/web/assets/Data-Crk0ef8O.js +6 -0
- package/dist/web/assets/Evidence-EYGofupD.js +1 -0
- package/dist/web/assets/Explore-DtqBRQi7.js +2 -0
- package/dist/web/assets/{Features-C524ttY_.js → Features-B_ZtQEtR.js} +1 -1
- package/dist/web/assets/Flags-DCLSg8Na.js +2 -0
- package/dist/web/assets/Flaky-HpgrkJIF.js +1 -0
- package/dist/web/assets/{ForceGraph-CF_VTwpL.js → ForceGraph-Dm4VEUjO.js} +1 -1
- package/dist/web/assets/Impact-CyzbgGih.js +3 -0
- package/dist/web/assets/Jobs-CbTd9csb.js +5 -0
- package/dist/web/assets/KindPage-cfP76U_9.js +6 -0
- package/dist/web/assets/Migration-va16JqtB.js +2 -0
- package/dist/web/assets/Product-D0iY6orX.js +7 -0
- package/dist/web/assets/Production-CBUb6wZJ.js +1 -0
- package/dist/web/assets/Quality-OMhrUKTU.js +1 -0
- package/dist/web/assets/{Readiness-BB0cXc33.js → Readiness-B64Rxahv.js} +1 -1
- package/dist/web/assets/Record-B_JXq6Dv.js +2 -0
- package/dist/web/assets/Regression-2blJAX7v.js +5 -0
- package/dist/web/assets/{Reports-DKUL0k5P.js → Reports-DCgjGdw4.js} +2 -2
- package/dist/web/assets/Response-BtMM8nqx.js +4 -0
- package/dist/web/assets/{RunDiff-LRfdsMSV.js → RunDiff-KuUVRuQI.js} +1 -1
- package/dist/web/assets/Runs-zHDZ-rSo.js +2 -0
- package/dist/web/assets/TestCases-B1j2Oelt.js +1 -0
- package/dist/web/assets/TestData-CZSynoi-.js +2 -0
- package/dist/web/assets/TestDebt-DEdIBwdb.js +1 -0
- package/dist/web/assets/Tosca-BcuaHsQC.js +2 -0
- package/dist/web/assets/{WhatsNew-BER-EaIL.js → WhatsNew-CjvX6DNo.js} +1 -1
- package/dist/web/assets/dataParts-BImZKYEu.js +3 -0
- package/dist/web/assets/{families-CEvnlSA9.js → families-q4nF1Fqo.js} +1 -1
- package/dist/web/assets/frame-eAHxqKfn.js +4 -0
- package/dist/web/assets/index-COTk3Bz-.js +45 -0
- package/dist/web/assets/index-DvuGI8X3.css +2 -0
- package/dist/web/assets/{logos-BhPgCy8m.js → logos-DEPdha9g.js} +1 -1
- package/dist/web/assets/{parts-BSjKRNsS.js → parts-CVdJRIxI.js} +1 -1
- package/dist/web/assets/{productParts-DRnaru9e.js → productParts-CqY4Zs7J.js} +1 -1
- package/dist/web/assets/qualityParts-BcrXEQ9B.js +1 -0
- package/dist/web/assets/segmented-BJECij_J.js +1 -0
- package/dist/web/assets/{thread-D9rH8Pqa.js → thread-Cuvu0HhP.js} +1 -1
- package/dist/web/assets/{usePageChat-Dc5vwcs6.js → usePageChat-Bz7fuynu.js} +1 -1
- package/dist/web/index.html +3 -3
- package/docs/WEB_APP.md +23 -15
- package/docs/user-guide.html +13 -2
- package/forgeqe.example.yaml +1 -0
- package/package.json +1 -1
- package/py/forgeqe_engine/browser.py +347 -2
- package/py/forgeqe_engine/logins.py +8 -6
- package/py/forgeqe_engine/recordsession.py +8 -8
- package/py/forgeqe_engine/service.py +18 -1
- package/dist/web/assets/Agent-D4tEZgR9.js +0 -4
- package/dist/web/assets/ApiTests-D1-uM3Fv.js +0 -10
- package/dist/web/assets/Cost-B8e9LW5N.js +0 -1
- package/dist/web/assets/Data-CKh8Xfjg.js +0 -6
- package/dist/web/assets/Evidence-CB_eYXrI.js +0 -1
- package/dist/web/assets/Explore-8NeU-stI.js +0 -2
- package/dist/web/assets/Flags-CS0Z1uKT.js +0 -2
- package/dist/web/assets/Flaky-Dove4iHu.js +0 -1
- package/dist/web/assets/Impact-BtXbEuuU.js +0 -3
- package/dist/web/assets/Jobs-C87BMhJy.js +0 -5
- package/dist/web/assets/KindPage-CrIV2IIg.js +0 -6
- package/dist/web/assets/Migration-DVcQFlj_.js +0 -2
- package/dist/web/assets/Product-DqS1GJ3S.js +0 -7
- package/dist/web/assets/Production-hjSrU2D4.js +0 -1
- package/dist/web/assets/Quality-DKKQwotS.js +0 -1
- package/dist/web/assets/Record-CJDeATYI.js +0 -2
- package/dist/web/assets/Regression-C7pe1hch.js +0 -5
- package/dist/web/assets/Response-CeWmqeLe.js +0 -4
- package/dist/web/assets/Runs-Zas3nnfB.js +0 -2
- package/dist/web/assets/TestCases-DYEIEFbv.js +0 -1
- package/dist/web/assets/TestData-CL9aY1ud.js +0 -2
- package/dist/web/assets/TestDebt-htU1GPXa.js +0 -1
- package/dist/web/assets/Tosca-DxTzAjuU.js +0 -2
- package/dist/web/assets/dataParts-JknpHCgp.js +0 -3
- package/dist/web/assets/frame-ihNrEidT.js +0 -4
- package/dist/web/assets/index-3D5uDfcc.css +0 -2
- package/dist/web/assets/index-DHLqPOSP.js +0 -45
- package/dist/web/assets/qualityParts-D0zOx0qp.js +0 -1
- package/dist/web/assets/segmented-BgffNagW.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$ as e,Ao as t,Bn as n,Io as r,Kn as i,Lt as a,Na as o,No as s,Qn as c,Wi as l,ga as u,gn as d,go as f,ha as p,ht as m,ja as h,ma as g,ot as _,ri as v,ut as y,vr as b}from"./frame-eAHxqKfn.js";import{d as x,r as S,s as C}from"./index-COTk3Bz-.js";var w=r(s(),1),T=t(),E=[`critical`,`serious`,`moderate`,`minor`],D={critical:`fail`,serious:`fail`,moderate:`warn`,minor:`neutral`},O=[{key:`lcp`,label:`LCP`,good:2500,poor:4e3,unit:`ms`},{key:`cls`,label:`CLS`,good:.1,poor:.25,unit:``},{key:`inp`,label:`INP`,good:200,poor:500,unit:`ms`},{key:`fcp`,label:`FCP`,good:1800,poor:3e3,unit:`ms`},{key:`ttfb`,label:`TTFB`,good:800,poor:1800,unit:`ms`},{key:`load`,label:`Load`,good:1/0,poor:1/0,unit:`ms`}],k={same:{label:`Same`,tone:`pass`},changed:{label:`Changed`,tone:`warn`},new:{label:`New baseline`,tone:`neutral`},no_baseline:{label:`No baseline`,tone:`neutral`}},A=e=>new Date(e).toLocaleString([],{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}),j=(e,t)=>t?e>=1e3?`${(e/1e3).toFixed(1)}s`:`${Math.round(e)}ms`:e.toFixed(3).replace(/0+$/,``).replace(/\.$/,``),M=(e,t)=>`${e} ${t}${e===1?``:`s`}`,N=e=>e.replace(/(data:[\w/+.-]+;base64,)[A-Za-z0-9+/=]{24,}/g,`$1…`),P=e=>{try{let t=new URL(e),n=t.pathname===`/`?``:t.pathname.length>44?`${t.pathname.slice(0,20)}…${t.pathname.slice(-20)}`:t.pathname;return`${t.host}${n}${t.search?`?…`:``}`}catch{return e.length>70?`${e.slice(0,68)}…`:e}},F=e=>!!(e.breaches||e.a11y?.failed||e.perf.over||e.visual?.changed);function I({run:t,standard:r,disclaimer:i}){let a=t.report,[s,c]=(0,w.useState)(new Set),[l,u]=(0,w.useState)(`all`),[d,f]=(0,w.useState)(!1);if(!a?.accessibility.pages)return(0,T.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`This run has no accessibility results: report.accessibility was off, or the run visited no page.`});let p=a.accessibility,h=a.breaches.filter(e=>e.kind===`accessibility`),g=p.failed.filter(e=>l===`all`||e.impact===l).sort((e,t)=>E.indexOf(e.impact)-E.indexOf(t.impact)||t.count-e.count),_=e=>{let t=new Set(s);t.has(e)?t.delete(e):t.add(e),c(t)};return(0,T.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,T.jsxs)(`p`,{className:`m-0 text-[13px] text-muted`,children:[r,` with `,a.engine||`axe`,` on `,M(p.pages,`page`),`: `,(0,T.jsxs)(`span`,{className:`text-pass`,children:[M(p.passed.length,`rule`),` passed`]}),`, `,(0,T.jsxs)(`span`,{className:p.failed.length?`text-fail`:``,children:[p.failed.length,` failed`]}),`.`,` `,a.budgets.accessibility?h.length?`${M(h.length,`budget`)} exceeded.`:`Within the budget.`:`No budget set, so nothing here fails the run.`]}),h.map((e,t)=>(0,T.jsxs)(`p`,{className:`m-0 rounded-[8px] bg-fail-soft px-3 py-1.5 text-[13px] text-fail [overflow-wrap:anywhere]`,children:[`Over budget · `,P(e.page),`: `,e.text]},t)),p.failed.length>0&&(0,T.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,T.jsx)(`div`,{role:`group`,"aria-label":`Impact`,className:`flex flex-wrap gap-1`,children:[`all`,...E].map(e=>{let t=e===`all`?p.failed.length:p.failed.filter(t=>t.impact===e).length;return e!==`all`&&!t?null:(0,T.jsxs)(`button`,{type:`button`,"aria-pressed":l===e,onClick:()=>u(e),className:o(`inline-flex min-h-7 cursor-pointer items-center gap-1 rounded-[6px] border px-2 text-[12px] capitalize`,l===e?`border-accent bg-accent-soft text-ink`:`border-transparent bg-surface-strong text-ink-2 hover:text-ink`),children:[e,` `,(0,T.jsx)(`span`,{className:`tabular-nums opacity-75`,children:t})]},e)})})}),p.failed.length?(0,T.jsx)(e,{label:`Failed rules`,placeholder:`Find a rule, WCAG criterion, page or element`,resetKey:l,empty:`Nothing matches.`,head:(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`th`,{className:`w-[96px] py-1.5 pl-3 font-medium`,children:`Impact`}),(0,T.jsx)(`th`,{className:`py-1.5 pr-3 font-medium`,children:`Rule`}),(0,T.jsx)(`th`,{className:`hidden py-1.5 pr-3 font-medium @2xl:table-cell`,children:`WCAG`}),(0,T.jsx)(`th`,{className:`py-1.5 pr-3 text-right font-medium`,children:`Elements`}),(0,T.jsx)(`th`,{className:`py-1.5 pr-3 text-right font-medium`,children:`Pages`})]}),children:g.map(e=>{let r=s.has(e.rule),i=t.examples[e.rule]??[];return(0,T.jsxs)(w.Fragment,{children:[(0,T.jsxs)(`tr`,{onClick:()=>_(e.rule),"aria-expanded":r,className:o(`cursor-pointer border-t border-line-soft align-top hover:bg-surface-muted`,r&&`bg-surface-muted`),children:[(0,T.jsx)(`td`,{className:`py-1.5 pl-3`,children:(0,T.jsx)(m,{tone:D[e.impact],className:`min-h-5 px-2 text-[11px] capitalize`,children:e.impact})}),(0,T.jsx)(`td`,{className:`py-1.5 pr-3`,children:(0,T.jsxs)(`span`,{className:`flex items-start gap-1`,children:[(0,T.jsx)(n,{size:13,"aria-hidden":`true`,className:o(`mt-0.5 flex-none text-muted transition-transform`,!r&&`-rotate-90`)}),(0,T.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,T.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:e.help}),(0,T.jsx)(`span`,{className:`font-mono text-[11.5px] text-muted`,children:e.rule})]})]})}),(0,T.jsx)(`td`,{className:`hidden py-1.5 pr-3 whitespace-nowrap text-ink-2 @2xl:table-cell`,children:e.wcag?`${e.wcag}${e.level?` · ${e.level}`:``}`:`–`}),(0,T.jsx)(`td`,{className:`py-1.5 pr-3 text-right tabular-nums`,children:e.count}),(0,T.jsx)(`td`,{className:`py-1.5 pr-3 text-right tabular-nums`,children:e.pages})]}),r&&(0,T.jsxs)(`tr`,{className:`bg-surface-muted`,children:[(0,T.jsx)(`td`,{}),(0,T.jsx)(`td`,{colSpan:4,className:`pr-3 pb-3`,children:(0,T.jsxs)(`div`,{className:`flex flex-col gap-1.5 pl-[17px]`,children:[i.length?i.map((e,t)=>(0,T.jsxs)(`div`,{className:`flex flex-col gap-0.5 rounded-[8px] border border-line-soft bg-bg px-2.5 py-1.5`,children:[(0,T.jsxs)(`span`,{className:`flex min-w-0 gap-1.5 text-[12px] text-muted`,children:[(0,T.jsx)(`span`,{className:`flex-none`,"data-tip":e.page,children:P(e.page)}),e.target&&(0,T.jsxs)(`span`,{className:`min-w-0 truncate font-mono text-[11.5px]`,"data-tip":e.target,children:[`· `,e.target]})]}),e.html&&(0,T.jsx)(`code`,{className:`line-clamp-3 font-mono text-[12px] break-all text-ink-2`,children:N(e.html)})]},t)):(0,T.jsx)(`span`,{className:`text-[12.5px] text-muted`,children:`No elements were kept for this rule.`}),e.helpUrl&&x(e.helpUrl)===`web`&&(0,T.jsxs)(`a`,{href:e.helpUrl,target:`_blank`,rel:`noreferrer noopener`,className:`inline-flex items-center gap-1 self-start text-[12.5px]`,children:[`How to fix it `,(0,T.jsx)(b,{size:12,"aria-hidden":`true`})]})]})})]})]},e.rule)})}):(0,T.jsx)(`p`,{className:`m-0 text-[13px] text-pass`,children:`No rule failed on the pages this run visited.`}),p.passed.length>0&&(0,T.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,T.jsxs)(`button`,{type:`button`,"aria-expanded":d,onClick:()=>f(!d),className:`flex cursor-pointer items-center gap-1 self-start border-0 bg-transparent p-0 text-[13px] font-medium text-ink`,children:[(0,T.jsx)(n,{size:13,"aria-hidden":`true`,className:o(`text-muted transition-transform`,!d&&`-rotate-90`)}),`Rules that passed `,(0,T.jsx)(`span`,{className:`font-normal text-muted tabular-nums`,children:p.passed.length})]}),d&&(0,T.jsx)(`ul`,{className:`m-0 flex list-none flex-wrap gap-1 p-0`,children:p.passed.map(e=>(0,T.jsx)(`li`,{className:`rounded-[6px] bg-pass-soft px-2 py-0.5 font-mono text-[11.5px] text-pass`,children:e},e))})]}),(0,T.jsx)(`p`,{className:`m-0 text-[12px] text-muted`,children:i})]})}function L({run:t}){let n=t.report;if(!n?.performance.pages.length)return(0,T.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`This run has no timings: the run visited no page.`});let r=(e,t)=>e>t.poor?`poor`:e>t.good?`needs improvement`:`good`,i={poor:`text-fail`,"needs improvement":`text-warn`,good:`text-pass`},a=n.breaches.filter(e=>e.kind===`performance`);return(0,T.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,T.jsxs)(`p`,{className:`m-0 text-[13px] text-muted`,children:[`Core Web Vitals of each page, from one visit in the browser the agent drove, against Google's thresholds: `,(0,T.jsx)(`span`,{className:`text-pass`,children:`good`}),`, `,(0,T.jsx)(`span`,{className:`text-warn`,children:`needs improvement`}),`, `,(0,T.jsx)(`span`,{className:`text-fail`,children:`poor`}),`.`,` `,n.budgets.performance?`Pages over quality.budgets.performance are marked.`:`No performance budget set: nothing fails on timings.`]}),a.map((e,t)=>(0,T.jsxs)(`p`,{className:`m-0 rounded-[8px] bg-fail-soft px-3 py-1.5 text-[13px] text-fail [overflow-wrap:anywhere]`,children:[`Over budget · `,P(e.page),`: `,e.text]},t)),(0,T.jsx)(e,{label:`Timings`,minWidth:720,head:(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`th`,{className:`py-1.5 pr-3 pl-3 font-medium`,children:`Page`}),O.map(e=>(0,T.jsx)(`th`,{className:`px-2 py-1.5 text-right font-medium`,"data-tip":e.label,children:e.label},e.key)),(0,T.jsx)(`th`,{className:`px-2 py-1.5 text-right font-medium`,children:`Requests`}),(0,T.jsx)(`th`,{className:`py-1.5 pr-3 pl-2 text-right font-medium`,children:`Size`})]}),children:n.performance.pages.map((e,t)=>(0,T.jsxs)(`tr`,{className:`border-t border-line-soft align-top`,children:[(0,T.jsxs)(`td`,{className:`py-1.5 pr-3 pl-3`,children:[(0,T.jsx)(`span`,{className:`block max-w-[340px] truncate font-mono text-[12px]`,"data-tip":e.url,children:P(e.url)}),e.over.length>0&&(0,T.jsxs)(`span`,{className:`text-[11.5px] text-fail`,children:[`over: `,e.over.join(`, `)]})]}),O.map(t=>{let n=e[t.key];return(0,T.jsxs)(`td`,{className:o(`px-2 py-1.5 text-right whitespace-nowrap tabular-nums`,typeof n==`number`&&t.good!==1/0?i[r(n,t)]:typeof n==`number`?`text-ink-2`:`text-muted`),children:[typeof n==`number`?j(n,t.unit):`–`,typeof n==`number`&&t.good!==1/0&&(0,T.jsxs)(`span`,{className:`sr-only`,children:[` (`,r(n,t),`)`]})]},t.key)}),(0,T.jsx)(`td`,{className:`px-2 py-1.5 text-right whitespace-nowrap text-muted tabular-nums`,children:e.requests??`–`}),(0,T.jsx)(`td`,{className:`py-1.5 pr-3 pl-2 text-right whitespace-nowrap text-muted tabular-nums`,children:e.kb===void 0?`–`:`${e.kb} KB`})]},t))}),(0,T.jsxs)(`p`,{className:`m-0 text-[12px] text-muted`,children:[O.filter(e=>e.good!==1/0).map(e=>`${e.label}: good up to ${j(e.good,e.unit)}, poor over ${j(e.poor,e.unit)}`).join(` · `),`. Lab values from one visit, not data from real users.`]})]})}function R({run:e,index:t,which:n,label:r}){let[i,a]=(0,w.useState)(``),[o,s]=(0,w.useState)(!1);return(0,w.useEffect)(()=>{let r=!1;return a(``),s(!1),f.image(e,t,n).then(e=>!r&&a(e),()=>!r&&s(!0)),()=>{r=!0}},[e,t,n]),(0,T.jsxs)(`figure`,{className:`m-0 flex min-w-0 flex-col gap-1.5`,children:[(0,T.jsx)(`figcaption`,{className:`text-[12px] font-medium text-muted`,children:r}),i?(0,T.jsx)(`img`,{src:i,alt:`${r} of the page`,className:`block h-auto w-full rounded-[10px] border border-line-soft bg-surface-muted`}):(0,T.jsx)(`span`,{className:`flex h-[120px] items-center justify-center gap-2 rounded-[10px] border border-line-soft bg-surface-muted text-[12px] text-muted`,children:o?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(d,{icon:v,size:14}),` Not available`]}):`Loading…`})]})}function z({run:t,budget:r,onChange:a}){let[s,c]=(0,w.useState)(null),[u,d]=(0,w.useState)(``),[p,g]=(0,w.useState)(!1),[_,v]=(0,w.useState)(``),[b,x]=(0,w.useState)(new Set),[S,C]=(0,w.useState)(`all`),E=t.visual?.pages??[],D=E.find(e=>e.status===`changed`)?.index;(0,w.useEffect)(()=>x(D===void 0?new Set:new Set([D])),[t.id,D]);let O=async e=>{g(!0),v(``);try{a(await e()),c(null),d(``)}catch(e){v(e.message)}finally{g(!1)}};if(!t.visual)return t.captured?(0,T.jsxs)(`div`,{className:`flex flex-col items-start gap-2`,children:[(0,T.jsxs)(`p`,{className:`m-0 text-[13px] text-ink-2`,children:[`This run captured `,M(t.captured,`page`),` but they were not compared with the baselines yet.`]}),(0,T.jsxs)(h,{size:`sm`,variant:`primary`,disabled:p,onClick:()=>O(()=>f.compare(t.id)),children:[(0,T.jsx)(l,{"aria-hidden":`true`}),`Compare with the baselines`]}),_&&(0,T.jsx)(`p`,{className:`m-0 text-[13px] text-fail`,children:_})]}):(0,T.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`This run has no visual captures: quality.visual.enabled was off, or the run visited no page.`});let A=E.filter(e=>e.status===`changed`),j=(S===`changed`?A:E).slice().sort((e,t)=>Number(t.status===`changed`)-Number(e.status===`changed`)||(t.diffPercent??0)-(e.diffPercent??0)),N=e=>{let t=new Set(b);t.has(e)?t.delete(e):t.add(e),x(t)};return(0,T.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,T.jsxs)(`p`,{className:`m-0 text-[13px] text-muted`,children:[`Each page captured with animations frozen and masked regions hidden, against its approved baseline. `,r?`A page over quality.budgets.visual fails the run.`:`No visual budget set: a change does not fail the run.`]}),(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,T.jsx)(`div`,{role:`group`,"aria-label":`Show`,className:`flex gap-1`,children:[[`all`,`All pages`,E.length],[`changed`,`Changed`,A.length]].map(([e,t,n])=>(0,T.jsxs)(`button`,{type:`button`,"aria-pressed":S===e,onClick:()=>C(e),className:o(`inline-flex min-h-7 cursor-pointer items-center gap-1 rounded-[6px] border px-2 text-[12px]`,S===e?`border-accent bg-accent-soft text-ink`:`border-transparent bg-surface-strong text-ink-2 hover:text-ink`),children:[t,` `,(0,T.jsx)(`span`,{className:`tabular-nums opacity-75`,children:n})]},e))}),(0,T.jsx)(`span`,{className:`flex-1`}),A.length>1&&(0,T.jsxs)(h,{size:`sm`,disabled:p,onClick:()=>c(A.map(e=>e.url)),children:[`Approve all `,A.length,` changes`]})]}),s&&(0,T.jsxs)(`div`,{role:`alertdialog`,"aria-label":`Approve as baseline`,className:`flex flex-col gap-2 rounded-[10px] border border-accent-line bg-accent-soft p-3 text-[13px]`,children:[(0,T.jsxs)(`span`,{className:`font-medium`,children:[`Make this run's capture the baseline of `,s.length===1?P(s[0]):M(s.length,`page`),`?`]}),(0,T.jsx)(`span`,{className:`text-ink-2`,children:`Later runs are compared with it. Approve only a change that was intended; one that was not is a visual defect.`}),(0,T.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[`Why it changed (kept with the baseline)`,(0,T.jsx)(y,{size:`sm`,value:u,maxLength:300,placeholder:`New checkout banner`,onChange:e=>d(e.target.value),className:`max-w-[480px] bg-bg`})]}),(0,T.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,T.jsxs)(h,{size:`sm`,variant:`primary`,disabled:p,onClick:()=>O(()=>f.approve(t.id,s,u.trim()||void 0)),children:[(0,T.jsx)(i,{"aria-hidden":`true`}),`Approve`]}),(0,T.jsx)(h,{size:`sm`,onClick:()=>c(null),children:`Cancel`})]})]}),_&&(0,T.jsx)(`p`,{className:`m-0 text-[13px] text-fail`,children:_}),(0,T.jsx)(e,{label:`Pages against their baselines`,fixed:!0,resetKey:S,empty:`No page changed.`,head:(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`th`,{className:`py-1.5 pr-3 pl-3 font-medium`,children:`Page`}),(0,T.jsx)(`th`,{className:`hidden w-[110px] py-1.5 pr-3 font-medium @2xl:table-cell`,children:`Size`}),(0,T.jsx)(`th`,{className:`w-[90px] py-1.5 pr-3 text-right font-medium`,children:`Changed`}),(0,T.jsx)(`th`,{className:`w-[120px] py-1.5 pr-3 font-medium`,children:`Result`}),(0,T.jsx)(`th`,{className:`w-[96px] py-1.5 pr-3`,children:(0,T.jsx)(`span`,{className:`sr-only`,children:`Approve`})})]}),children:j.map(e=>{let r=b.has(e.index);return(0,T.jsxs)(w.Fragment,{children:[(0,T.jsxs)(`tr`,{onClick:()=>N(e.index),"aria-expanded":r,className:o(`cursor-pointer border-t border-line-soft align-top hover:bg-surface-muted`,r&&`bg-surface-muted`),children:[(0,T.jsx)(`td`,{className:`py-1.5 pr-3 pl-3`,children:(0,T.jsxs)(`span`,{className:`flex items-start gap-1`,children:[(0,T.jsx)(n,{size:13,"aria-hidden":`true`,className:o(`mt-0.5 flex-none text-muted transition-transform`,!r&&`-rotate-90`)}),(0,T.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,T.jsx)(`span`,{className:`truncate`,"data-tip":e.title||e.url,children:e.title||P(e.url)}),(0,T.jsx)(`span`,{className:`truncate font-mono text-[11.5px] text-muted`,"data-tip":e.url,children:P(e.url)})]})]})}),(0,T.jsxs)(`td`,{className:`hidden py-1.5 pr-3 whitespace-nowrap text-muted @2xl:table-cell`,children:[e.size||`–`,e.resized?` · resized ${e.resized}`:``]}),(0,T.jsx)(`td`,{className:o(`py-1.5 pr-3 text-right whitespace-nowrap tabular-nums`,e.over?`text-fail`:e.status===`changed`?`text-warn`:`text-muted`),children:e.status===`changed`?`${e.diffPercent}%${e.limit===void 0?``:` / ${e.limit}%`}`:`–`}),(0,T.jsx)(`td`,{className:`py-1.5 pr-3`,children:(0,T.jsx)(m,{tone:e.over?`fail`:k[e.status].tone,className:`min-h-5 px-2 text-[11px]`,children:e.over?`Over budget`:k[e.status].label})}),(0,T.jsx)(`td`,{className:`py-1 pr-3 text-right`,onClick:e=>e.stopPropagation(),children:e.status===`changed`&&(0,T.jsx)(h,{size:`sm`,variant:`ghost`,disabled:p,onClick:()=>c([e.url]),className:`min-h-7`,children:`Approve`})})]}),r&&(0,T.jsx)(`tr`,{className:`bg-surface-muted`,children:(0,T.jsx)(`td`,{colSpan:5,className:`px-3 pb-3`,children:(0,T.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(180px,1fr))] gap-3`,children:[e.images.baseline&&(0,T.jsx)(R,{run:t.id,index:e.index,which:`baseline`,label:`Baseline`}),e.images.current&&(0,T.jsx)(R,{run:t.id,index:e.index,which:`current`,label:`This run`}),e.images.diff&&(0,T.jsx)(R,{run:t.id,index:e.index,which:`diff`,label:`Difference (in red)`})]})})})]},e.index)})})]})}function B({values:e}){if(e.length<2)return null;let t=Math.max(1,...e),n=e.map((n,r)=>`${r/(e.length-1)*96+2},${22-n/t*20}`).join(` `);return(0,T.jsx)(`svg`,{width:`100`,height:`24`,viewBox:`0 0 100 24`,"aria-label":`Violations over the last ${e.length} runs: ${e.join(`, `)}`,role:`img`,className:`flex-none text-muted`,children:(0,T.jsx)(`polyline`,{points:n,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinejoin:`round`})})}function V({icon:e,className:t,lines:n}){return n.length?(0,T.jsxs)(`span`,{className:o(`flex items-start gap-1.5 text-[13px]`,t),children:[(0,T.jsx)(d,{icon:e,size:14,className:`mt-0.5 flex-none`}),(0,T.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:n.join(` · `)})]}):null}function H({trends:e}){return e.length?(0,T.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:e.map(e=>{let t=e.a11y.latest?E.reduce((t,n)=>t+(e.a11y.latest[n]||0),0):void 0;return(0,T.jsxs)(`li`,{className:`flex flex-col gap-1.5 border-t border-line-soft py-3 first:border-t-0`,children:[(0,T.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-3`,children:[(0,T.jsx)(`span`,{className:`min-w-0 flex-[1_1_240px] truncate font-mono text-[13px]`,"data-tip":e.page,children:/^https?:/.test(e.page)?P(e.page):e.page}),(0,T.jsx)(B,{values:e.a11y.trail}),(0,T.jsxs)(`span`,{className:`text-[12px] text-muted`,children:[M(e.runs,`run`),t===void 0?``:` · ${M(t,`violation`)} now`]})]}),(0,T.jsx)(V,{icon:p,className:`text-fail`,lines:[...e.perf.worse.map(e=>`slower: ${e}`),...e.a11y.newRules.map(e=>`newly failing: ${e}`)]}),(0,T.jsx)(V,{icon:g,className:`text-pass`,lines:[...e.perf.better.map(e=>`faster: ${e}`),...e.a11y.fixedRules.map(e=>`fixed: ${e}`)]})]},e.page)})}):(0,T.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`No history yet: every browser run adds each page's accessibility and timings to quality-history.json in the reports folder.`})}var U={accessibility:e=>!!e.a11y?.pages,performance:e=>e.perf.pages>0,visual:e=>!!e.visual||e.captured>0},W={accessibility:e=>!!e.a11y?.failed,performance:e=>e.perf.over>0,visual:e=>!!(e.visual?.changed||e.visual?.over)},G=(e,t)=>t.filter(U[e]);function K({kind:t,runs:n}){let[r,s]=(0,w.useState)(`all`),l=G(t,n),d=r===`attention`?l.filter(W[t]):l,f=e=>location.hash=a(t,encodeURIComponent(e)),p=`py-2 pr-3 text-right tabular-nums`;return(0,T.jsx)(e,{label:`Runs`,placeholder:`Find a run by what it did`,resetKey:r,empty:`Nothing matches.`,tools:(0,T.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:(0,T.jsx)(_,{items:[{id:`all`,label:`All`,n:l.length},{id:`attention`,label:`Needs a look`,n:l.filter(W[t]).length,alert:!0}],value:r,onChange:s})}),head:(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`th`,{className:`w-[46%] py-1.5 pr-3 pl-3 font-medium`,children:`Run`}),t===`accessibility`&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`th`,{className:`py-1.5 pr-3 text-right font-medium`,children:`Rules failed`}),(0,T.jsx)(`th`,{className:`hidden py-1.5 pr-3 text-right font-medium @2xl:table-cell`,children:`Critical · serious`}),(0,T.jsx)(`th`,{className:`hidden py-1.5 pr-3 text-right font-medium @3xl:table-cell`,children:`Moderate · minor`}),(0,T.jsx)(`th`,{className:`hidden py-1.5 pr-3 text-right font-medium @xl:table-cell`,children:`Pages`})]}),t===`performance`&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`th`,{className:`py-1.5 pr-3 text-right font-medium`,children:`Over budget`}),(0,T.jsx)(`th`,{className:`hidden py-1.5 pr-3 text-right font-medium @xl:table-cell`,children:`Pages timed`})]}),t===`visual`&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`th`,{className:`py-1.5 pr-3 text-right font-medium`,children:`Changed`}),(0,T.jsx)(`th`,{className:`hidden py-1.5 pr-3 text-right font-medium @2xl:table-cell`,children:`New`}),(0,T.jsx)(`th`,{className:`hidden py-1.5 pr-3 text-right font-medium @xl:table-cell`,children:`Same`})]}),(0,T.jsx)(`th`,{className:`hidden py-1.5 pr-3 font-medium @xl:table-cell`,children:`When`})]}),children:d.map(e=>{let n=W[t](e),r=(e.over?.[t]??0)>0;return(0,T.jsxs)(`tr`,{onClick:()=>f(e.id),className:`cursor-pointer border-t border-line-soft hover:bg-surface-muted`,children:[(0,T.jsx)(`td`,{className:`max-w-0 py-2 pr-3 pl-3`,children:(0,T.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(r?c:n?u:i,{size:15,"aria-label":r?`Over a budget`:n?`Needs a look`:`Within budgets`,className:o(`flex-none`,r?`text-fail`:n?`text-warn`:`text-pass`)}),(0,T.jsx)(`a`,{href:a(t,encodeURIComponent(e.id)),onClick:e=>e.stopPropagation(),"data-tip":e.goal,className:`truncate text-ink no-underline hover:underline`,children:e.goal})]})}),t===`accessibility`&&e.a11y&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`td`,{className:o(p,e.a11y.failed?`text-fail`:`text-muted`),children:e.a11y.failed}),(0,T.jsx)(`td`,{className:o(p,`hidden @2xl:table-cell`,e.a11y.critical+e.a11y.serious?`text-fail`:`text-muted`),children:`${e.a11y.critical} · ${e.a11y.serious}`}),(0,T.jsx)(`td`,{className:o(p,`hidden text-muted @3xl:table-cell`),children:`${e.a11y.moderate} · ${e.a11y.minor}`}),(0,T.jsx)(`td`,{className:o(p,`hidden text-muted @xl:table-cell`),children:e.a11y.pages})]}),t===`performance`&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`td`,{className:o(p,e.perf.over?`text-fail`:`text-muted`),children:e.perf.over}),(0,T.jsx)(`td`,{className:o(p,`hidden text-muted @xl:table-cell`),children:e.perf.pages})]}),t===`visual`&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`td`,{className:o(p,e.visual?.changed?`text-warn`:`text-muted`),children:e.visual?e.visual.changed:`not compared`}),(0,T.jsx)(`td`,{className:o(p,`hidden text-muted @2xl:table-cell`),children:e.visual?e.visual.new+e.visual.no_baseline:`–`}),(0,T.jsx)(`td`,{className:o(p,`hidden text-muted @xl:table-cell`),children:e.visual?e.visual.same:`–`})]}),(0,T.jsx)(`td`,{className:`hidden py-2 pr-3 whitespace-nowrap text-[12.5px] text-muted @xl:table-cell`,"data-tip":A(e.at),children:S(e.at)})]},e.id)})})}function q({kind:e,id:t,view:r,onChanged:i}){let[o,s]=(0,w.useState)(null),[c,l]=(0,w.useState)(``);(0,w.useEffect)(()=>{let e=!1;return s(null),f.run(t).then(t=>{e||(s(t),l(``))},t=>!e&&l(t.message)),()=>{e=!0}},[t]);let u=(0,T.jsxs)(`a`,{href:a(e),className:`inline-flex items-center gap-1 self-start text-[13px] no-underline`,children:[(0,T.jsx)(n,{size:14,"aria-hidden":`true`,className:`rotate-90`}),`All runs`]});return c||!o?(0,T.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[u,c?(0,T.jsx)(`p`,{className:`m-0 rounded-[10px] bg-fail-soft px-3 py-2 text-[13px] text-fail`,children:c}):(0,T.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`Loading…`})]}):(0,T.jsxs)(`section`,{"aria-labelledby":`run-h`,className:`flex min-w-0 flex-col gap-3`,children:[u,(0,T.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,T.jsx)(`h2`,{id:`run-h`,"data-tip":o.goal,className:`m-0 truncate text-[16px] leading-snug font-semibold`,children:o.goal}),(0,T.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 text-[12.5px] text-muted`,children:[A(o.at),` · `,(0,T.jsx)(C,{path:o.dir}),` · `,(0,T.jsx)(`a`,{href:a(`quality`,encodeURIComponent(o.id)),children:`Everything it measured`})]})]}),e===`accessibility`&&(0,T.jsx)(I,{run:o,standard:r.standard,disclaimer:r.disclaimer}),e===`performance`&&(0,T.jsx)(L,{run:o}),e===`visual`&&(0,T.jsx)(z,{run:o,budget:r.budgets.visual,onChange:e=>{s(e),i()}})]})}function J({r:e,to:t,line:n}){return(0,T.jsxs)(`div`,{className:`ml-12 flex flex-wrap items-center gap-x-4 gap-y-2 rounded-[14px] card border px-4 py-3`,children:[(0,T.jsxs)(`span`,{className:`flex min-w-0 flex-[1_1_240px] flex-col`,children:[(0,T.jsx)(`span`,{className:`text-[14.5px] font-medium [overflow-wrap:anywhere]`,children:e.goal}),(0,T.jsx)(`span`,{className:`text-[12.5px] text-muted`,children:n})]}),(0,T.jsx)(h,{size:`sm`,variant:`primary`,onClick:()=>location.hash=t,children:`Open the run`})]})}function Y({label:e,value:t,sub:n,tone:r}){return(0,T.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5 px-3 py-2`,children:[(0,T.jsx)(`span`,{className:`text-[11.5px] text-muted`,children:e}),(0,T.jsx)(`span`,{className:o(`text-[16px] leading-tight font-semibold tabular-nums`,r),children:t}),n&&(0,T.jsx)(`span`,{className:`truncate text-[11.5px] text-muted`,children:n})]})}export{A as _,K as a,J as c,z as d,j as f,P as g,G as h,q as i,H as l,M as m,E as n,Y as o,F as p,D as r,L as s,I as t,O as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Ao as e,Na as t}from"./frame-eAHxqKfn.js";var n=e(),r=`flex w-fit max-w-full flex-wrap gap-1 rounded-[10px] bg-surface-strong p-1`,i=e=>t(`inline-flex min-h-8 cursor-pointer items-center gap-1.5 rounded-[7px] border-0 px-3 text-sm font-medium whitespace-nowrap`,e?`bg-bg text-ink shadow-sm`:`bg-transparent text-muted hover:text-ink`);function a({tabs:e,current:a,onPick:o,label:s,className:c}){return(0,n.jsx)(`div`,{role:`tablist`,"aria-label":s,className:t(`mb-5`,r,c),children:e.map((t,r)=>(0,n.jsxs)(`button`,{id:`tab-${t.id}`,type:`button`,role:`tab`,"aria-selected":a===t.id,"aria-controls":`panel-${t.id}`,tabIndex:a===t.id?0:-1,onClick:()=>o(t.id),onKeyDown:t=>{let n=t.key===`ArrowRight`?e[(r+1)%e.length]:t.key===`ArrowLeft`?e[(r-1+e.length)%e.length]:void 0;n&&(o(n.id),document.getElementById(`tab-${n.id}`)?.focus())},className:i(a===t.id),children:[t.label,t.n!==void 0&&(0,n.jsx)(`span`,{className:`text-[12px] text-muted tabular-nums`,children:t.n})]},t.id))})}function o({links:e,current:a,label:o,className:s}){return(0,n.jsx)(`nav`,{"aria-label":o,className:t(r,s),children:e.map(e=>(0,n.jsx)(`a`,{href:e.href,"aria-current":a===e.id?`page`:void 0,className:t(i(a===e.id),`no-underline hover:no-underline`,a===e.id&&`hover:text-ink`),children:e.label},e.id))})}export{i,a as n,r,o as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{en as e,on as t}from"./frame-eAHxqKfn.js";var n=e=>e&&typeof e==`object`&&!Array.isArray(e)?e:{},r=e=>typeof e==`string`?e:e==null?``:String(e),i=(e,t=400)=>e.length>t?`${e.slice(0,t-1)}…`:e,a=e=>typeof e==`number`?` in ${Math.round(e/1e3)}s`:``;function o(e,t=400){return i(e.replace(/\s+/g,` `).trim(),t).replace(/([\\`*_[\]<>#|~!])/g,`\\$1`)}function s(e){let t=e.replace(/\s+/g,` `).trim();if(!t)return``;let n=t.includes("`")?"``":"`";return`${n}${n==="``"?` `:``}${t}${n==="``"?` `:``}${n}`}function c(e,t){return/^https?:\/\/[^\s)]+$/i.test(t)?`[${o(e||t,120)}](${t})`:o(e)}var l=e=>[s(r(n(e).id)),o(r(n(e).title),200)].filter(Boolean).join(` `);function u(e){return e.replace(/<!--[\s\S]*?(?:-->|$)/g,``).trim()}function d(e){return e.replace(/\[((?:\\.|[^\]\\])*)\]\(https?:\/\/[^\s)]+\)/g,`$1`).replace(/\\(.)/g,`$1`).replace(/[*`]/g,``)}var f=(e,t)=>({tone:e,kind:`item`,md:t}),p=(e,t)=>({tone:e,kind:`sub`,md:t});function m(e,t=``){let i=t||(e.agent&&e.agent!==`forgeqe`?`**${o(r(e.agent))}:** `:``);switch(e.kind){case`info`:return f(`info`,`${i}${o(r(e.text))}`);case`start`:return f(`dim`,`${i}→ ${s(r(e.tool))}${e.text&&e.text!==e.tool?` ${o(r(e.text),200)}`:``}`);case`tool`:{let t=n(e.file);return f(e.ok===!1?`warn`:`dim`,`${i}${e.ok===!1?`⚠`:`✓`} ${o(r(e.text)||r(e.tool),240)}${t.path?` (${o(r(t.action))} ${s(r(t.path))})`:``}`)}case`say`:{let t=u(r(e.text));return t?f(`say`,`${i}*${o(t)}*`):null}case`test`:return Number(e.attempt)>0?f(e.ok?`ok`:`fail`,`${i}${e.ok?`✓`:`✗`} **Test, attempt ${o(r(e.attempt))}:** ${o(r(e.text),240)}`):f(e.ok?`ok`:`fail`,`${i}${e.ok?`✓`:`✗`} ${o(r(e.text),240)}`);case`plan`:{let t=Array.isArray(e.items)?e.items.map(n):[],a=t.find(e=>e.status===`in_progress`);return f(`info`,`${i}**Plan:** ${t.filter(e=>e.status===`completed`).length} of ${t.length} done${a?`; now: ${o(r(a.text))}`:``}`)}case`review`:return f(e.approved?`ok`:`warn`,`${i}**Review, attempt ${o(r(e.attempt))}:** ${e.approved?`approved`:`changes asked`}. ${o(r(e.summary),240)}`);case`attempt`:return f(`warn`,`${i}**Attempt ${o(r(e.attempt))} of ${o(r(e.max))}:** ${o(r(e.why),240)}`);case`answer`:return f(`dim`,`${i}Attempt ${o(r(e.attempt))}: ${o(r(e.notes)||`changed ${(Array.isArray(e.changed)?e.changed:[]).map(r).join(`, `)}`,240)}`);case`context`:return e.compacted?f(`info`,`${i}Context compacted: the conversation was summarised to make room.`):null;default:return null}}function h(e,t=``){switch(e.type){case`log`:return f(e.level===`error`?`fail`:e.level===`warn`?`warn`:`dim`,`${t}${e.level===`warn`||e.level===`error`?`⚠ `:``}${o(r(e.text))}`);case`step`:return f(`dim`,`${t}**Step ${o(r(e.step))}** · ${e.source===`memory`?`from memory`:o(r(e.category))} · ${c(r(e.title)||`untitled`,r(e.url))}`);case`memory`:return f(`info`,`${t}↻ ${o(r(e.text))}`);case`thought`:return p(`think`,`*${o(r(e.text))}*`);case`outcome`:return p(e.ok?`ok`:`fail`,`${e.ok?`✓`:`✗`} ${o(r(e.text),300)}`);case`done`:{let i=n(e.result);return f(i.status===`complete`?`ok`:`fail`,`${t}**${o(r(i.status))}:** ${o(r(i.summary))}`)}case`code`:return m(e,t);default:return null}}function g(e){switch(e.type){case`run-start`:return{tone:`info`,kind:`head`,md:`Browser run: ${o(r(e.goal),200)}${e.url?` · ${c(r(e.url).replace(/^https?:\/\//,``),r(e.url))}`:``}`};case`run-event`:return h(n(e.event));case`run-done`:{let t=n(e.result),i=!e.error&&(t.outcome===`passed`||!t.outcome&&t.status===`complete`);return f(i?`ok`:`fail`,`${i?`✓`:`✗`} **Run ${i?`passed`:`failed`}**${a(e.ms)}: ${o(r(e.error)||r(t.summary))}${e.runDir?` · ${s(r(e.runDir))}`:``}`)}case`suite-start`:return{tone:`info`,kind:`head`,md:`Suite: ${(Array.isArray(e.cases)?e.cases:[]).length} cases, ${o(r(e.parallel))} at once`};case`suite-event`:{let t=n(e.event);if(t.type===`case-start`)return f(`info`,`**Case ${Number(t.index)+1} of ${o(r(t.total))}:** ${l(t.case)}`);if(t.type===`case-event`)return h(n(t.event),`${s(r(n(t.case).id))} `);if(t.type===`case-done`){let e=n(t.result);return f(e.status===`passed`?`ok`:`fail`,`${e.status===`passed`?`✓`:`✗`} ${l(e.case)}: **${o(r(e.status))}**${a(e.ms)}${e.summary?`. ${o(r(e.summary),240)}`:``}`)}return t.type===`code-start`?f(`info`,`${s(r(n(t.case).id))} writing its test`):t.type===`writeback`?f(`dim`,`Posted the result back: ${o(JSON.stringify(t.item),240)}`):null}case`suite-done`:{let t=(Array.isArray(n(e.suite).results)?n(e.suite).results:[]).map(n),r=t.filter(e=>e.status===`passed`).length;return f(r===t.length?`ok`:`fail`,`**Suite: ${r} of ${t.length} passed**${a(n(e.suite).ms)}`)}case`info`:return f(e.ok===!1?`fail`:e.ok===!0?`ok`:`info`,o(r(e.text)));case`agent`:return m(n(n(e.event)),`**Coding agent:** `);case`code-start`:return{tone:`info`,kind:`head`,md:`Writing a test: ${o(r(e.goal),200)}`};case`code-done`:return f(e.error?`fail`:`ok`,`${e.error?`✗`:`✓`} **Test ${e.error?`not written`:`written`}**${a(e.ms)}${e.error?`: ${o(r(e.error),240)}`:``}`);case`card`:{let t=n(e.card),i=(Array.isArray(t.body)?t.body:[]).map(r).filter(Boolean);return f(t.status===`ok`?`ok`:t.status===`fail`?`fail`:`info`,`**${o(r(t.title))}**${t.stats?` · ${o(r(t.stats))}`:``}${i.length?`: ${o(i.join(`; `),300)}`:``}`)}case`report`:return f(`ok`,`✓ Report saved: ${o(r(e.title))}`);case`call-start`:return f(`dim`,`→ ${o(r(e.text),240)}`);case`call`:return f(e.ok===!1?`warn`:`dim`,`${e.ok===!1?`⚠`:`✓`} ${o(r(e.text),240)}`);default:return null}}function _(e){let t=r(e.at)||r(e.t),i=null;switch(e.type){case`user`:i=f(`you`,`**You:** ${o(r(e.text),240)}`);break;case`agent`:i=m(n(e.event));break;case`tool`:i=g(n(e.event));break;case`ask`:i=f(`you`,`**Asked:** ${o(r(n(e.question).title))}`);break;case`wait`:i=f(`you`,`**Waiting for you:** ${o(r(e.prompt))}`);break;case`answered`:i=f(`you`,`**You:** ${e.label===void 0?e.ok?`done, continue`:`cancel`:o(r(e.label))}`);break;case`turn_done`:i=f(e.outcome===`done`?`ok`:e.outcome===`stopped`?`warn`:`fail`,`**${e.outcome===`done`?`Done`:e.outcome===`stopped`?`Stopped`:e.outcome===`needs_input`?`Needs your input`:`Failed`}**${e.error?`: ${o(r(e.error),300)}`:``}`);break;case`settings`:i=f(`you`,`**Settings:** browser ${e.headed?`shown`:`headless`}, ${e.writeTests?`passed runs become tests`:`no tests written`}`);break;case`model`:i=f(`you`,`**Model:** ${o(r(n(e.profile).name),80)}`);break;case`settings_applied`:i=f(`you`,`**Settings:** carried on with the settings as they are on disk now`);break;case`stderr`:i={tone:`dim`,kind:`out`,md:r(e.text)};break;case`error`:i=f(`warn`,`⚠ ${o(r(e.message))}`);break;case`fatal`:i=f(`fail`,`✗ **ForgeQE cannot go on:** ${o(r(e.message))}`);break;case`exit`:i=f(e.code===0?`dim`:`fail`,`ForgeQE stopped${e.code!==null&&e.code!==void 0?` (exit ${o(r(e.code))})`:``}${e.message?`: ${o(r(e.message))}`:``}`)}return i?{at:t,...i,plain:i.kind===`out`?i.md:d(i.md)}:null}function v(e,t){if(!e||!t)return``;let n=Math.max(0,Math.round((Date.parse(t)-Date.parse(e))/1e3));return Number.isFinite(n)?`+${Math.floor(n/60)}:${String(n%60).padStart(2,`0`)}`:``}function y(e,t,n){let r=n?[`## ${o(n,200)}`,``]:[],i=[],a=()=>{if(!i.length)return;let e=Math.max(2,...i.map(e=>Math.max(0,...(e.match(/`+/g)||[]).map(e=>e.length)))),t="`".repeat(e+1);r.push(``,`${t}text`,...i,t,``),i=[]};for(let n of e){let e=v(t,n.at),o=e?`\`${e}\``:``;n.kind===`out`?i.push(e?`${e} ${n.md}`:n.md):(a(),n.kind===`head`?r.push(``,`#### ${n.md}${o?` ${o}`:``}`,``):n.kind===`sub`?r.push(` - ${n.md}`):r.push(`- ${o?`${o} `:``}${n.md}`))}return a(),r.join(`
|
|
2
2
|
`).replace(/\n{3,}/g,`
|
|
3
3
|
|
|
4
4
|
`).trim()+`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Io as e,Ka as t,No as n}from"./frame-eAHxqKfn.js";import{n as r}from"./thread-Cuvu0HhP.js";var i=e(n(),1),a=e=>e&&/^No model in llms\.json/.test(e)?`No model is set up for the agent yet: add one in Settings, Models (or sign in to GitHub Copilot there), then send this again.`:e;function o(e){let n=()=>{try{return localStorage.getItem(e)}catch{return null}},a=t=>{try{t?localStorage.setItem(e,t):localStorage.removeItem(e)}catch{}},[o,s]=(0,i.useState)(n),[c,l]=(0,i.useState)([]),[u,d]=(0,i.useState)(null);(0,i.useEffect)(()=>{if(!o){l([]),d(null);return}let e=!1,n=0;return l([]),(async()=>{for(;!e;)try{let r=await t.events(o,n,n>0);if(e||(d(r.state),r.events.length&&(n=r.events.at(-1).n,l(e=>[...e,...r.events])),(r.state===`closed`||r.state===`failed`)&&!r.events.length))return}catch(t){if(e)return;if(t.status===404){a(null),s(null);return}await new Promise(e=>setTimeout(e,2e3))}})(),()=>{e=!0}},[o]);let f=(0,i.useMemo)(()=>r(c),[c]),p=f.turns.at(-1),m=u===`closed`||u===`failed`;return{chat:o,thread:f,last:p,busy:u===`busy`||u===`starting`||!!p&&!p.outcome&&!m,ended:m,send:async(e,n,r={})=>{if(o&&!m)await t.send(o,e);else{let{id:i}=await t.start(`${n}\n${e}`,r);a(i),s(i)}},reset:()=>{a(null),s(null)}}}export{o as n,a as t};
|
package/dist/web/index.html
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<meta name="referrer" content="no-referrer" />
|
|
7
7
|
<title>ForgeQE</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
9
|
-
<link rel="modulepreload" crossorigin href="/assets/frame-
|
|
10
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-COTk3Bz-.js"></script>
|
|
9
|
+
<link rel="modulepreload" crossorigin href="/assets/frame-eAHxqKfn.js">
|
|
10
|
+
<link rel="stylesheet" crossorigin href="/assets/index-DvuGI8X3.css">
|
|
11
11
|
</head>
|
|
12
12
|
<body>
|
|
13
13
|
<div id="root"></div>
|
package/docs/WEB_APP.md
CHANGED
|
@@ -94,19 +94,27 @@ files: each person's are in their own credential store.
|
|
|
94
94
|
- **Search, at the top of the sidebar** (or **Ctrl+K**, **⌘K** on a Mac, on any page): type to go to any page, agent,
|
|
95
95
|
Settings section or setting (by its name or its forgeqe.yaml key, such as `browser.headless`); the arrow keys move,
|
|
96
96
|
Enter opens, Esc closes.
|
|
97
|
-
- **The sidebar, on the left.** New chat (opens Home, where a chat starts
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
97
|
+
- **The sidebar, on the left.** Search, **New chat** (opens Home, where a chat starts), the pages you pinned, and
|
|
98
|
+
ForgeQE's parts under **Browse**, one level at a time:
|
|
99
|
+
- **Agents**: chat, the built-in agents (Advisers, Builders, Operators), custom agents, and jobs on a schedule.
|
|
100
|
+
- **Knowledge**: Knowledge, the product (landscape, services, code map, business view), Memory, Skills, Prompts and
|
|
101
|
+
Guardrails.
|
|
102
|
+
- **Quality Engineering**: test design (Test cases, Exploratory), automation (Record, Migration, Tosca), execution
|
|
103
|
+
(Regression packs, Runs), specialised testing (API tests, Quality, Accessibility, Performance, Visual) and insights
|
|
104
|
+
(reports, Run diff, Flaky tests, Test debt).
|
|
105
|
+
- **Data**: the Data agent, databases, Ask, data flows and test data.
|
|
106
|
+
- **Delivery & Operations**: Change impact, Release readiness, Feature flags and Production signals.
|
|
107
|
+
- **AI Assurance**: evaluation (Overview, Agent runs, Review queue), governance (Contracts, Releases) and improvement
|
|
108
|
+
(Learn, Monitor).
|
|
109
|
+
- **Administration**: every Settings section, in the same areas, and Cost.
|
|
110
|
+
|
|
111
|
+
Open a category and the sidebar steps into its areas; open an area and it shows its pages. **‹** steps back up
|
|
112
|
+
without leaving the page, and the sidebar opens at the area of the page you are on. Each category and area has its
|
|
113
|
+
own page (**Browse**, `#/browse`), which lists what is inside, what needs a look, and the agents that work there;
|
|
114
|
+
the star beside a page pins it to the top of the sidebar (in this browser, up to eight). At the bottom: Settings, with
|
|
115
|
+
Help (the docs, the same pages as forgeqe.github.io/docs/ with the architecture map, served by ForgeQE itself, so they
|
|
116
|
+
work offline) and Dark/Light beside it. The sidebar closes to a narrow rail of New chat, your pins and the categories
|
|
117
|
+
(each named when you point at it), with the small logo on top, to give the page the width; on a phone it is a drawer.
|
|
110
118
|
- **The workspace panel, on the right.** The project, its repository and branch, and the test environment; the context
|
|
111
119
|
and tokens of the chat and of the project, in your local currency (pounds in the UK, from the European Central Bank's
|
|
112
120
|
daily rates); the background tasks running now; the files a chat changed, with **Create pull request**; and what it
|
|
@@ -116,8 +124,8 @@ files: each person's are in their own credential store.
|
|
|
116
124
|
|
|
117
125
|
## Home and a chat
|
|
118
126
|
|
|
119
|
-
Home is one box: say what
|
|
120
|
-
|
|
127
|
+
Home is one box: say what you need, in your words. Under it, suggestions from different parts of ForgeQE (Find it in
|
|
128
|
+
the code, Ask the data, Check a release, Run test cases) fill the box with an example; they do not send.
|
|
121
129
|
|
|
122
130
|
**The Agents page** is one directory of every agent in four columns side by side, one per category (Advisers, which
|
|
123
131
|
help you decide; Builders, which do the work for you; Operators, which work on their own; and Custom agents; once
|
package/docs/user-guide.html
CHANGED
|
@@ -4089,8 +4089,15 @@ forgeqe jobs shutdown # stop the service; scheduled jobs wait until
|
|
|
4089
4089
|
<code>.forgeqe/agents/<id>.yaml</code>. It uses ForgeQE's own agents, capabilities, skills, knowledge and environments, and is
|
|
4090
4090
|
held in code, on every tool call, to what its manifest allows: which environments and addresses, which capabilities,
|
|
4091
4091
|
which agents it may start, which kinds of action (read, run, change, external) and which a person approves first. An
|
|
4092
|
-
environment named like production is never allowed. It has no shell, web fetch or web search
|
|
4093
|
-
|
|
4092
|
+
environment named like production is never allowed. It has no shell, web fetch or web search unless its manifest says
|
|
4093
|
+
<code>shell: true</code> (then a person approves each command), and uses only the other systems <code>scope.systems</code> names. Writing and
|
|
4094
|
+
healing tests start a coding agent, which a person approves each call of unless <code>permissions.trust</code> lists it.</p>
|
|
4095
|
+
<p>The agents it may start are checked on every call, including the ones a tool starts for it: <code>write_test</code> starts
|
|
4096
|
+
<code>forgeqe-test</code> and, from a recording, <code>forgeqe-test-plan</code>; <code>request_test_data</code> starts the DB agent (<code>forgeqe-data</code>);
|
|
4097
|
+
<code>product_knowledge</code> starts <code>forgeqe-investigate</code> to answer a question and <code>forgeqe-knowledge</code> to read the product with
|
|
4098
|
+
the model. A run that finds a new defect explains it with <code>forgeqe-defect-rca</code> only when the agent may use it; otherwise
|
|
4099
|
+
the run goes ahead with the analysis that uses no model. <code>forgeqe agent check</code> and the editor say what each capability
|
|
4100
|
+
needs.</p>
|
|
4094
4101
|
<pre><code class="language-yaml">id: checkout-guard
|
|
4095
4102
|
name: Checkout guard agent
|
|
4096
4103
|
version: 1.0.0
|
|
@@ -4117,9 +4124,13 @@ forgeqe agent disable <id> | enable <id> # also on its page; several
|
|
|
4117
4124
|
forgeqe agent rollback <id> <version> # an earlier approved version runs again
|
|
4118
4125
|
forgeqe agent history <id> # its versions and its runs, with every tool call and the policy's decision
|
|
4119
4126
|
forgeqe agent export <id> --out a.jsonl # its whole record as JSON lines, for audit (also on its page: Download audit record)
|
|
4127
|
+
forgeqe agent pack <id> --out a.zip # a shareable zip: agent.json + knowledge files + skills (also on its page: Export to share)
|
|
4128
|
+
forgeqe agent import a.zip [--id new] # import that zip as a draft to edit and approve (also Agents › Custom › Import agent)
|
|
4120
4129
|
forgeqe agent run <id> "request" --unattended # as a schedule runs it: what it may not do alone waits for a person
|
|
4121
4130
|
forgeqe agent approvals [<id>] # what agents running with nobody watching wait for; answer: approvals <id> <approval> allow | allow_run | deny
|
|
4122
4131
|
</code></pre>
|
|
4132
|
+
<p>Same-repo teams still commit <code>.forgeqe/agents</code> (and <code>.releases</code> after approve). Pack/import is for sharing a draft across
|
|
4133
|
+
projects or machines; the recipient must try and approve it. Environments and systems are not in the package.</p>
|
|
4123
4134
|
<p><strong>Starting from a template.</strong> <code>forgeqe agent new cloud-verifier</code> writes a draft of the cloud verifier: after a test
|
|
4124
4135
|
run, it checks in the cloud that what the run should have done there happened (a message on a queue, an object
|
|
4125
4136
|
written, a row in a table, a function invoked), and changes nothing. It is filled from this project: the clouds of
|
package/forgeqe.example.yaml
CHANGED
|
@@ -121,6 +121,7 @@ browser:
|
|
|
121
121
|
width: 1280
|
|
122
122
|
height: 800
|
|
123
123
|
window: maximized # visible browser: maximized | viewport
|
|
124
|
+
local_browser: auto # auto: installed Chrome, then Microsoft Edge, then Playwright's Chromium when one does not start | chrome | edge | chromium (that one only)
|
|
124
125
|
video: true # video.mp4 of each run, shown in its report
|
|
125
126
|
allowed_hosts: []
|
|
126
127
|
judge: false # true: a second model call checks each finished run against the goal and can fail it
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capagents/forgeqe",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.9",
|
|
4
4
|
"description": "ForgeQE: a browser agent CLI that runs goals and test cases in local Chrome or Chromium, or BrowserStack and TestMu AI/LambdaTest when configured, and turns passing runs into tests in your repo",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"repository": {
|
|
@@ -159,6 +159,339 @@ def local_browser_launch_kwargs(*, headless: bool) -> Dict[str, Any]:
|
|
|
159
159
|
# The library's words when Chrome exits before its DevTools port answers, and close variants of other versions.
|
|
160
160
|
_EARLY_EXIT = ("exited before CDP", "before CDP became available", "Browser process exited", "Failed to start browser", "Chrome failed to start")
|
|
161
161
|
|
|
162
|
+
# How long one browser's DevTools port has to answer before the next browser is tried. Company PCs are slow to start a
|
|
163
|
+
# browser (security software scans it first); FORGEQE_ENGINE_BROWSER_START_SECONDS changes it, from 15 to 600.
|
|
164
|
+
DEVTOOLS_WAIT_SECONDS = 90.0
|
|
165
|
+
# After the process ForgeQE started has exited, how long a browser it handed over to has to answer on the same port.
|
|
166
|
+
HANDOVER_SECONDS = 30.0
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def devtools_wait_seconds() -> float:
|
|
170
|
+
try:
|
|
171
|
+
value = float((os.getenv("FORGEQE_ENGINE_BROWSER_START_SECONDS") or "").strip())
|
|
172
|
+
except ValueError:
|
|
173
|
+
return DEVTOOLS_WAIT_SECONDS
|
|
174
|
+
return min(600.0, max(15.0, value)) if value == value else DEVTOOLS_WAIT_SECONDS
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
start_logger = logging.getLogger("forgeqe_engine.browser_start")
|
|
178
|
+
|
|
179
|
+
# Browsers a launcher handed over to (not this engine's own descendants), closed with the ones it started.
|
|
180
|
+
_HANDED_OVER: Dict[int, List[str]] = {}
|
|
181
|
+
|
|
182
|
+
_SAFE_FLAG_VALUES = ("--remote-debugging-port", "--user-data-dir", "--profile-directory", "--headless", "--window-size")
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def describe_args(args: List[str]) -> str:
|
|
186
|
+
"""A browser's command line for the log: the program, and each flag by name, with a value only for flags whose
|
|
187
|
+
value says how it was started (never a proxy, a URL or anything else that may hold a credential)."""
|
|
188
|
+
if not args:
|
|
189
|
+
return "(unknown)"
|
|
190
|
+
shown = [args[0]]
|
|
191
|
+
for a in args[1:]:
|
|
192
|
+
name = a.split("=", 1)[0]
|
|
193
|
+
if not name.startswith("--"):
|
|
194
|
+
continue
|
|
195
|
+
shown.append(a if name in _SAFE_FLAG_VALUES else name)
|
|
196
|
+
return " ".join(shown)
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def _process_args(proc: Any) -> List[str]:
|
|
200
|
+
try:
|
|
201
|
+
return list(proc.cmdline())
|
|
202
|
+
except Exception:
|
|
203
|
+
return []
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def _alive(proc: Any) -> bool:
|
|
207
|
+
import psutil
|
|
208
|
+
|
|
209
|
+
try:
|
|
210
|
+
return bool(proc.is_running()) and proc.status() != psutil.STATUS_ZOMBIE
|
|
211
|
+
except psutil.AccessDenied:
|
|
212
|
+
return True
|
|
213
|
+
except Exception:
|
|
214
|
+
return False
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def _exit_code(proc: Any) -> str:
|
|
218
|
+
try:
|
|
219
|
+
code = proc.wait(timeout=0)
|
|
220
|
+
except Exception:
|
|
221
|
+
return "not known"
|
|
222
|
+
if code is None:
|
|
223
|
+
return "not known"
|
|
224
|
+
# Windows reports codes like 0xC0000022 (access denied) as large unsigned numbers: show them as Windows does.
|
|
225
|
+
return f"{code} (0x{code & 0xFFFFFFFF:08X})" if isinstance(code, int) and (code < 0 or code > 255) else str(code)
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
def port_owner(port: int, *, not_pid: Optional[int] = None) -> Optional[Any]:
|
|
229
|
+
"""The browser's main process started with this DevTools port, when it is not the one ForgeQE started (a launcher
|
|
230
|
+
on the PC may start the browser again under another process and exit). None when there is none."""
|
|
231
|
+
import psutil
|
|
232
|
+
|
|
233
|
+
flag = f"--remote-debugging-port={port}"
|
|
234
|
+
for proc in psutil.process_iter():
|
|
235
|
+
if proc.pid == not_pid:
|
|
236
|
+
continue
|
|
237
|
+
args = _process_args(proc)
|
|
238
|
+
if flag in args and not any(a.startswith("--type=") for a in args):
|
|
239
|
+
return proc
|
|
240
|
+
return None
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def _handed_over(proc: Any) -> None:
|
|
244
|
+
args = _process_args(proc)
|
|
245
|
+
if args:
|
|
246
|
+
_HANDED_OVER[proc.pid] = args
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
async def wait_for_devtools(port: int, timeout: float = 30, process: Any = None) -> str:
|
|
250
|
+
"""
|
|
251
|
+
Wait for a browser's DevTools port to answer; the library's own wait, made patient and logged. The library gives up
|
|
252
|
+
the moment the process it started has exited; on a company PC that process is often a launcher that starts the
|
|
253
|
+
browser again under another process (security software, a browser wrapper) and exits, and the browser answers on
|
|
254
|
+
the same port a few seconds later. So an exit is noted and the port still watched, for HANDOVER_SECONDS more when no
|
|
255
|
+
other browser has the port and up to the full wait when one has. Every step goes to the run's log.
|
|
256
|
+
"""
|
|
257
|
+
import aiohttp
|
|
258
|
+
|
|
259
|
+
loop = asyncio.get_running_loop()
|
|
260
|
+
started = loop.time()
|
|
261
|
+
limit = max(float(timeout or 0), devtools_wait_seconds())
|
|
262
|
+
pid = getattr(process, "pid", None)
|
|
263
|
+
start_logger.info("browser start: PID %s, %s", pid, describe_args(_process_args(process)) if process is not None else "(no process)")
|
|
264
|
+
start_logger.info("browser start: waiting up to %ds for DevTools on 127.0.0.1:%d", int(limit), port)
|
|
265
|
+
exited_at: Optional[float] = None
|
|
266
|
+
exit_code = "not known"
|
|
267
|
+
children: Dict[int, Any] = {}
|
|
268
|
+
owner: Any = None
|
|
269
|
+
last = "no answer yet"
|
|
270
|
+
next_note = started + 5
|
|
271
|
+
next_scan = started
|
|
272
|
+
async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=3)) as session:
|
|
273
|
+
while True:
|
|
274
|
+
now = loop.time()
|
|
275
|
+
waited = now - started
|
|
276
|
+
try:
|
|
277
|
+
async with session.get(f"http://127.0.0.1:{port}/json/version") as resp:
|
|
278
|
+
if resp.status == 200:
|
|
279
|
+
if owner is None and exited_at is not None:
|
|
280
|
+
owner = port_owner(port, not_pid=pid)
|
|
281
|
+
if owner is not None:
|
|
282
|
+
_handed_over(owner)
|
|
283
|
+
start_logger.info("browser start: DevTools answered after %.1fs from PID %s, which took over from PID %s", waited, owner.pid, pid)
|
|
284
|
+
else:
|
|
285
|
+
start_logger.info("browser start: DevTools answered after %.1fs", waited)
|
|
286
|
+
return f"http://127.0.0.1:{port}/"
|
|
287
|
+
last = f"HTTP {resp.status}"
|
|
288
|
+
except Exception as ex:
|
|
289
|
+
last = type(ex).__name__
|
|
290
|
+
if process is not None and exited_at is None:
|
|
291
|
+
if _alive(process):
|
|
292
|
+
try:
|
|
293
|
+
for child in process.children(recursive=True):
|
|
294
|
+
children.setdefault(child.pid, child)
|
|
295
|
+
except Exception:
|
|
296
|
+
pass
|
|
297
|
+
else:
|
|
298
|
+
exited_at = waited
|
|
299
|
+
exit_code = _exit_code(process)
|
|
300
|
+
start_logger.warning(
|
|
301
|
+
"browser start: PID %s exited after %.1fs, exit code %s, before DevTools answered; it started %d other process%s",
|
|
302
|
+
pid, waited, exit_code, len(children), "" if len(children) == 1 else "es",
|
|
303
|
+
)
|
|
304
|
+
if exited_at is not None and owner is None and now >= next_scan:
|
|
305
|
+
next_scan = now + 1
|
|
306
|
+
owner = next((c for c in children.values() if _alive(c) and f"--remote-debugging-port={port}" in _process_args(c)), None)
|
|
307
|
+
owner = owner or port_owner(port, not_pid=pid)
|
|
308
|
+
if owner is not None:
|
|
309
|
+
_handed_over(owner)
|
|
310
|
+
start_logger.warning("browser start: PID %s now runs the browser with DevTools port %d (%s); still waiting for it", owner.pid, port, describe_args(_process_args(owner)))
|
|
311
|
+
if exited_at is not None and owner is None and waited - exited_at >= HANDOVER_SECONDS:
|
|
312
|
+
raise RuntimeError(
|
|
313
|
+
f"Browser process (PID {pid}) exited before CDP became available on port {port}. It exited after "
|
|
314
|
+
f"{exited_at:.1f}s with exit code {exit_code}, and no other browser took its port in {int(HANDOVER_SECONDS)}s ({last})."
|
|
315
|
+
)
|
|
316
|
+
if owner is not None and not _alive(owner) and exited_at is not None:
|
|
317
|
+
raise RuntimeError(
|
|
318
|
+
f"Browser process (PID {pid}) exited before CDP became available on port {port}, and PID {owner.pid}, "
|
|
319
|
+
f"which took it over, exited too ({last})."
|
|
320
|
+
)
|
|
321
|
+
if waited >= limit:
|
|
322
|
+
state = f"PID {pid} " + (f"exited after {exited_at:.1f}s with exit code {exit_code}" if exited_at is not None else "still runs")
|
|
323
|
+
if owner is not None:
|
|
324
|
+
state += f"; PID {owner.pid} has the port"
|
|
325
|
+
raise RuntimeError(f"Failed to start browser: DevTools on port {port} did not answer within {int(limit)}s ({state}; {last}).")
|
|
326
|
+
if now >= next_note:
|
|
327
|
+
next_note = now + 5
|
|
328
|
+
start_logger.info(
|
|
329
|
+
"browser start: still waiting after %.0fs (%s; PID %s %s)", waited, last, pid,
|
|
330
|
+
"running" if exited_at is None else f"exited at {exited_at:.1f}s" + (f", PID {owner.pid} has the port" if owner is not None else ""),
|
|
331
|
+
)
|
|
332
|
+
await asyncio.sleep(0.25)
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
def install_patient_start() -> None:
|
|
336
|
+
"""Use `wait_for_devtools` for every local browser the library starts."""
|
|
337
|
+
from browser_use.browser.watchdogs.local_browser_watchdog import LocalBrowserWatchdog
|
|
338
|
+
|
|
339
|
+
if getattr(LocalBrowserWatchdog._wait_for_cdp_url, "__name__", "") != "wait_for_devtools":
|
|
340
|
+
LocalBrowserWatchdog._wait_for_cdp_url = staticmethod(wait_for_devtools)
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
def find_playwright_chromium() -> Optional[str]:
|
|
344
|
+
"""
|
|
345
|
+
The Chromium Playwright installed for its own tests (ms-playwright), newest first. On a company PC this one often
|
|
346
|
+
starts when the installed Chrome does not: a Chrome policy (RemoteDebuggingAllowed) or security software that stops
|
|
347
|
+
Chrome started for automation does not apply to it.
|
|
348
|
+
"""
|
|
349
|
+
import glob
|
|
350
|
+
|
|
351
|
+
base = (os.getenv("PLAYWRIGHT_BROWSERS_PATH") or "").strip()
|
|
352
|
+
if sys.platform == "win32":
|
|
353
|
+
root = base or os.path.join(os.environ.get("LOCALAPPDATA") or "", "ms-playwright")
|
|
354
|
+
tails = (("chrome-win64", "chrome.exe"), ("chrome-win", "chrome.exe"))
|
|
355
|
+
elif sys.platform == "darwin":
|
|
356
|
+
root = base or os.path.expanduser("~/Library/Caches/ms-playwright")
|
|
357
|
+
app = ("Chromium.app", "Contents", "MacOS", "Chromium")
|
|
358
|
+
tails = (("chrome-mac-arm64", *app), ("chrome-mac", *app))
|
|
359
|
+
else:
|
|
360
|
+
root = base or os.path.expanduser("~/.cache/ms-playwright")
|
|
361
|
+
tails = (("chrome-linux64", "chrome"), ("chrome-linux", "chrome"))
|
|
362
|
+
if not root or base == "0":
|
|
363
|
+
return None
|
|
364
|
+
found: List[str] = []
|
|
365
|
+
for tail in tails:
|
|
366
|
+
found += glob.glob(os.path.join(glob.escape(root), "chromium-*", *tail))
|
|
367
|
+
|
|
368
|
+
def build(path: str) -> int:
|
|
369
|
+
name = Path(path).relative_to(root).parts[0]
|
|
370
|
+
digits = name.rsplit("-", 1)[-1]
|
|
371
|
+
return int(digits) if digits.isdigit() else -1
|
|
372
|
+
|
|
373
|
+
files = [p for p in found if Path(p).is_file()]
|
|
374
|
+
return max(files, key=build) if files else None
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
LOCAL_BROWSERS = ("auto", "chrome", "edge", "chromium")
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
def local_browser_choice(value: Any) -> str:
|
|
381
|
+
"""browser.local_browser of forgeqe.yaml: auto (the default), chrome, edge or chromium; anything else is auto."""
|
|
382
|
+
v = str(value or "").strip().lower()
|
|
383
|
+
return v if v in LOCAL_BROWSERS else "auto"
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
def local_launch_candidates(*, headless: bool, choice: Any = "auto") -> List[Dict[str, Any]]:
|
|
387
|
+
"""
|
|
388
|
+
The local browsers to try, in order. With browser.local_browser auto: the one `local_browser_launch_kwargs` picks
|
|
389
|
+
(installed Chrome by default), then Microsoft Edge, then Playwright's Chromium; the same browser is never listed
|
|
390
|
+
twice. chrome, edge or chromium: that browser only. A browser named with BROWSER_USE_EXECUTABLE_PATH wins over the
|
|
391
|
+
setting, and it or BROWSER_USE_FALLBACK=0 means that one only. Each is a full set of launch kwargs.
|
|
392
|
+
"""
|
|
393
|
+
first = local_browser_launch_kwargs(headless=headless)
|
|
394
|
+
pinned = bool((os.getenv("BROWSER_USE_EXECUTABLE_PATH") or "").strip()) and first.get("executable_path")
|
|
395
|
+
if pinned:
|
|
396
|
+
return [first]
|
|
397
|
+
base = {k: v for k, v in first.items() if k not in ("channel", "executable_path")}
|
|
398
|
+
pick = local_browser_choice(choice)
|
|
399
|
+
if pick == "edge":
|
|
400
|
+
edge = find_edge_executable()
|
|
401
|
+
if not edge:
|
|
402
|
+
raise RuntimeError("browser.local_browser is edge, but Microsoft Edge is not installed on this computer.")
|
|
403
|
+
return [{**base, "channel": "msedge", "executable_path": edge}]
|
|
404
|
+
if pick == "chromium":
|
|
405
|
+
pw = find_playwright_chromium()
|
|
406
|
+
# Without Playwright's Chromium here, the library finds a Chromium or installs its own.
|
|
407
|
+
return [{**base, "channel": "chromium", **({"executable_path": pw} if pw else {})}]
|
|
408
|
+
if pick == "chrome":
|
|
409
|
+
return [first]
|
|
410
|
+
off = (os.getenv("BROWSER_USE_FALLBACK") or "").strip().lower() in ("0", "false", "no", "off")
|
|
411
|
+
out = [first]
|
|
412
|
+
if off:
|
|
413
|
+
return out
|
|
414
|
+
seen = {os.path.normcase(str(first.get("executable_path") or ""))}
|
|
415
|
+
for channel, exe in (("msedge", find_edge_executable()), ("chromium", find_playwright_chromium())):
|
|
416
|
+
key = os.path.normcase(str(exe or ""))
|
|
417
|
+
if exe and key not in seen:
|
|
418
|
+
seen.add(key)
|
|
419
|
+
out.append({**base, "channel": channel, "executable_path": exe})
|
|
420
|
+
return out
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
def browser_name(launch: Dict[str, Any]) -> str:
|
|
424
|
+
exe = str(launch.get("executable_path") or "")
|
|
425
|
+
if launch.get("channel") == "msedge":
|
|
426
|
+
return "Microsoft Edge"
|
|
427
|
+
if "ms-playwright" in exe.replace("\\", "/"):
|
|
428
|
+
return "Playwright's Chromium"
|
|
429
|
+
if launch.get("channel") == "chromium":
|
|
430
|
+
return "Chromium"
|
|
431
|
+
return "Google Chrome"
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
def can_fall_back(error: BaseException) -> bool:
|
|
435
|
+
"""A browser that did not start (closed early, or never answered): another may. Any other error is not about it."""
|
|
436
|
+
if isinstance(error, (asyncio.TimeoutError, TimeoutError)):
|
|
437
|
+
return True
|
|
438
|
+
text = str(error).lower()
|
|
439
|
+
return any(m.lower() in text for m in _EARLY_EXIT) or "failed to launch browser" in text
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
async def _within(coro: Any, seconds: float) -> Any:
|
|
443
|
+
"""Await coro in the caller's own task, as it was before a time limit was put on it (asyncio.wait_for would run the
|
|
444
|
+
browser's start in a task of its own); on Python before 3.11, which has no asyncio.timeout, through wait_for."""
|
|
445
|
+
limit = getattr(asyncio, "timeout", None)
|
|
446
|
+
if limit is None:
|
|
447
|
+
return await asyncio.wait_for(coro, timeout=seconds)
|
|
448
|
+
async with limit(seconds):
|
|
449
|
+
return await coro
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
async def start_local_browser(
|
|
453
|
+
candidates: List[Dict[str, Any]],
|
|
454
|
+
*,
|
|
455
|
+
make: Any,
|
|
456
|
+
on_fallback: Any = None,
|
|
457
|
+
timeout: Optional[float] = None,
|
|
458
|
+
) -> "tuple[Any, Dict[str, Any]]":
|
|
459
|
+
"""
|
|
460
|
+
Start the first candidate browser that starts; returns it with its launch kwargs. A browser that closes before it
|
|
461
|
+
can be driven, or never answers, is shut down and the next one tried (`on_fallback(failed, next, error)` says so).
|
|
462
|
+
When none starts, the first browser's error is raised, so its explanation (`explain_browser_start`) still applies,
|
|
463
|
+
with the others' results added.
|
|
464
|
+
"""
|
|
465
|
+
failures: List[str] = []
|
|
466
|
+
first_error: Optional[BaseException] = None
|
|
467
|
+
with contextlib.suppress(Exception):
|
|
468
|
+
install_patient_start()
|
|
469
|
+
# The library's setup around the DevTools wait (devtools_wait_seconds) gets 30s more.
|
|
470
|
+
timeout = timeout if timeout is not None else devtools_wait_seconds() + 30.0
|
|
471
|
+
for i, launch in enumerate(candidates):
|
|
472
|
+
browser = make(launch)
|
|
473
|
+
start_logger.info("browser start: trying %s (%s)", browser_name(launch), launch.get("executable_path") or f"channel {launch.get('channel')}")
|
|
474
|
+
try:
|
|
475
|
+
await _within(browser.start(), timeout)
|
|
476
|
+
return browser, launch
|
|
477
|
+
except Exception as ex:
|
|
478
|
+
await _shutdown_browser_instance(browser)
|
|
479
|
+
if not can_fall_back(ex):
|
|
480
|
+
raise
|
|
481
|
+
if isinstance(ex, (asyncio.TimeoutError, TimeoutError)):
|
|
482
|
+
ex = RuntimeError(f"Failed to start browser: {browser_name(launch)} did not answer within {int(timeout)} seconds")
|
|
483
|
+
if first_error is None:
|
|
484
|
+
first_error = ex
|
|
485
|
+
reason = str(ex).strip().splitlines()[0][:300]
|
|
486
|
+
failures.append(f"{browser_name(launch)}: {reason}")
|
|
487
|
+
if i + 1 < len(candidates) and on_fallback is not None:
|
|
488
|
+
on_fallback(launch, candidates[i + 1], reason)
|
|
489
|
+
if first_error is None:
|
|
490
|
+
raise RuntimeError("No local browser to start.")
|
|
491
|
+
if len(failures) > 1:
|
|
492
|
+
raise RuntimeError(f"{first_error}\nBrowsers tried: " + "; ".join(failures)) from first_error
|
|
493
|
+
raise first_error
|
|
494
|
+
|
|
162
495
|
_CHROME_POLICY_KEYS = (r"HKLM\SOFTWARE\Policies\Google\Chrome", r"HKCU\SOFTWARE\Policies\Google\Chrome")
|
|
163
496
|
_LINUX_POLICY_DIRS = ("/etc/opt/chrome/policies/managed", "/etc/chromium/policies/managed")
|
|
164
497
|
_MAC_POLICY_FILE = "/Library/Managed Preferences/com.google.Chrome.plist"
|
|
@@ -230,7 +563,11 @@ def explain_browser_start(message: str, policy: Optional[str] = None, *, check_p
|
|
|
230
563
|
f"{text}\nChrome closed before ForgeQE could control it. On a company computer the usual causes are a Chrome "
|
|
231
564
|
"policy that turns off remote debugging (open chrome://policy and look for RemoteDebuggingAllowed), security "
|
|
232
565
|
"software that stops a Chrome started for automation, or a Chrome update in progress (restart Chrome once). "
|
|
233
|
-
"
|
|
566
|
+
"ForgeQE also tries Microsoft Edge and Playwright's Chromium (npx playwright install chromium) when they are "
|
|
567
|
+
"installed; browser.local_browser in forgeqe.yaml picks one of them. On a slow computer, give the browser longer "
|
|
568
|
+
"to answer with FORGEQE_ENGINE_BROWSER_START_SECONDS (90 by default); the run's log has each step of the start "
|
|
569
|
+
"(browser start: ...). Run with --headed to watch it start, or set "
|
|
570
|
+
"BROWSER_USE_EXECUTABLE_PATH to another Chrome or Edge."
|
|
234
571
|
)
|
|
235
572
|
|
|
236
573
|
|
|
@@ -499,6 +836,14 @@ async def stop_video(browser: Any) -> Optional[Path]:
|
|
|
499
836
|
return Path(path) if path and Path(path).is_file() and Path(path).stat().st_size else None
|
|
500
837
|
|
|
501
838
|
|
|
839
|
+
def _handed_over_browsers() -> Dict[int, List[str]]:
|
|
840
|
+
"""Browsers a launcher started for this engine (`wait_for_devtools` found them by their DevTools port): taken out of
|
|
841
|
+
the list here, so each is closed once, and only while it still runs with the same command line (`_end_browsers`)."""
|
|
842
|
+
out = dict(_HANDED_OVER)
|
|
843
|
+
_HANDED_OVER.clear()
|
|
844
|
+
return out
|
|
845
|
+
|
|
846
|
+
|
|
502
847
|
def _automation_browsers_of_mine() -> Dict[int, List[str]]:
|
|
503
848
|
"""
|
|
504
849
|
The browsers this engine started for automation that run now: its own descendants started with a debugging port,
|
|
@@ -564,7 +909,7 @@ async def _shutdown_browser_instance(browser: Any) -> None:
|
|
|
564
909
|
"""
|
|
565
910
|
if browser is None:
|
|
566
911
|
return
|
|
567
|
-
mine = _automation_browsers_of_mine()
|
|
912
|
+
mine = {**_handed_over_browsers(), **_automation_browsers_of_mine()}
|
|
568
913
|
for name in ("kill", "stop"):
|
|
569
914
|
fn = getattr(browser, name, None)
|
|
570
915
|
if not callable(fn):
|