@capagents/forgeqe 3.1.5 → 3.1.7
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/dist/forgeqe.js +1731 -1730
- package/dist/web/assets/{3d-force-graph-hjtSHzwp.js → 3d-force-graph-BmczCBlL.js} +1 -1
- package/dist/web/assets/{Agent-DS9r0POp.js → Agent-y4MCu8wo.js} +1 -1
- package/dist/web/assets/{AgentWork-B4dhGqk9.js → AgentWork-BWblSkId.js} +1 -1
- package/dist/web/assets/ApiTests-DMwtosgK.js +10 -0
- package/dist/web/assets/{Browse-ExW0OnPd.js → Browse-C3r1fDvS.js} +1 -1
- package/dist/web/assets/{Chat-D1OTNGdW.js → Chat-C5WRZ7EO.js} +1 -1
- package/dist/web/assets/{CommandPalette-qrAs5Txr.js → CommandPalette-ab9Dujgu.js} +1 -1
- package/dist/web/assets/{Compare-Bkqw1oRm.js → Compare-ObjtkAZ2.js} +1 -1
- package/dist/web/assets/{Cost-DmVkHLeO.js → Cost-XLrxpQZz.js} +1 -1
- package/dist/web/assets/{Data-Bbk-n9UL.js → Data-DmfILc8f.js} +1 -1
- package/dist/web/assets/{Desktop-_taGnxrW.js → Desktop-C9cgaHSS.js} +1 -1
- package/dist/web/assets/{DesktopReview-B7eW9uGp.js → DesktopReview-QuculN-N.js} +1 -1
- package/dist/web/assets/{Evidence-C736fdDs.js → Evidence-IFtgLPK-.js} +1 -1
- package/dist/web/assets/{Explore-k200B_-C.js → Explore-DhskIcmJ.js} +1 -1
- package/dist/web/assets/{Features-3udxLXyA.js → Features-OMov_t5a.js} +1 -1
- package/dist/web/assets/{Flags-CVFLoDbs.js → Flags-v34h7tMQ.js} +1 -1
- package/dist/web/assets/{Flaky-Bm3Uzr0n.js → Flaky-llIyrSlY.js} +1 -1
- package/dist/web/assets/{Impact-zwLt4Avz.js → Impact-BDY3keAo.js} +1 -1
- package/dist/web/assets/{Jobs-7Uu8mTQr.js → Jobs-C6W440Zy.js} +1 -1
- package/dist/web/assets/{KindPage-iyMgS7G3.js → KindPage-DalVU3V4.js} +1 -1
- package/dist/web/assets/{Migration-BtDJ5cyL.js → Migration-DycKheEL.js} +1 -1
- package/dist/web/assets/{PageAgent-Ct1Jb7IN.js → PageAgent-qe1dHEIV.js} +1 -1
- package/dist/web/assets/{Product-_FzZmjM2.js → Product-xPHPwyRb.js} +3 -3
- package/dist/web/assets/{Production-JkDkkFbl.js → Production-C0xJTE_A.js} +1 -1
- package/dist/web/assets/{Quality-BwS6MSB_.js → Quality-HN4Y1xcO.js} +1 -1
- package/dist/web/assets/{Readiness-2a9FtsE9.js → Readiness-CtTpkOIF.js} +1 -1
- package/dist/web/assets/{Record-DVNSGJnb.js → Record-DEEvHQMt.js} +1 -1
- package/dist/web/assets/{Regression-Df45XidH.js → Regression-BlTPM7di.js} +1 -1
- package/dist/web/assets/{Reports-JONxomX4.js → Reports-C-pKyOOd.js} +1 -1
- package/dist/web/assets/{Response-CIPGKeYG.js → Response-xh7r4ldF.js} +1 -1
- package/dist/web/assets/{Responsive-CroRTTVP.js → Responsive-7uoXE0-6.js} +1 -1
- package/dist/web/assets/{RunDiff-C-WXGjif.js → RunDiff-wZSP-_yc.js} +1 -1
- package/dist/web/assets/{Runs-DMet85TW.js → Runs-CatjSiWh.js} +1 -1
- package/dist/web/assets/{Settings-Tma6UABh.js → Settings-26cvU21X.js} +3 -3
- package/dist/web/assets/{Steps-Ck3MknhZ.js → Steps-DlqnuxiM.js} +1 -1
- package/dist/web/assets/{TestCases-DgcWer52.js → TestCases-DWhXIHc9.js} +1 -1
- package/dist/web/assets/{TestData-BFBJWoDl.js → TestData-Z9fozptW.js} +1 -1
- package/dist/web/assets/{TestDebt-Do4McWEQ.js → TestDebt-_R-P8oXN.js} +1 -1
- package/dist/web/assets/{TestManagement-D-Wj-oP8.js → TestManagement-BS8Al6g-.js} +1 -1
- package/dist/web/assets/{Tosca-CjllP-Ha.js → Tosca-zhsG-p3K.js} +1 -1
- package/dist/web/assets/{WhatsNew-vSeZwL6h.js → WhatsNew-gJQO1DB7.js} +1 -1
- package/dist/web/assets/{dataParts-Dbay5ALL.js → dataParts-Ds4Gjeep.js} +1 -1
- package/dist/web/assets/{fold-D4M3Zxck.js → fold-DQqF7F_f.js} +1 -1
- package/dist/web/assets/{head-0IYa1v5A.js → head-BQ9P1hk0.js} +1 -1
- package/dist/web/assets/{highlight-PxLG2GcL.js → highlight-CQWNqo7N.js} +1 -1
- package/dist/web/assets/{index-DLjZ6tbN.js → index-DeYZJBWf.js} +5 -5
- package/dist/web/assets/{logos-Be_9dA3t.js → logos-Cbs1qp4G.js} +1 -1
- package/dist/web/assets/{paletteCommands-pZZMTJx1.js → paletteCommands-BSqUaeAr.js} +1 -1
- package/dist/web/assets/{qualityParts-CRZVVfxq.js → qualityParts-j9yO6-qk.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/prompts/test-plan.md +1 -1
- package/prompts/test-reviewer.md +1 -1
- package/prompts/test-rules.md +6 -1
- package/skills/bdd-gherkin/SKILL.md +3 -0
- package/dist/web/assets/ApiTests-CutrWik-.js +0 -10
- package/docs/ForgeQE-Client-Overview.pdf +0 -0
- package/docs/ForgeQE-Installation-Guide.pdf +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{F as t,Fn as n,Hr as r,I as i,Lr as a,Mr as o,Nn as s,O as c,Rn as l,Rr as u,ar as d,gn as f,on as p,r as m,sr as h,ut as g,xn as _,xr as v}from"./route-Dg53WdFu.js";import{l as y}from"./agents-C0Jg2pN8.js";import{t as b}from"./jsx-runtime-LKYXHABd.js";import{A as x,Tt as S,Z as C,j as w,n as T,nt as E,t as D}from"./input-D7iHeNXz.js";import{a as O,d as k,l as ee,o as te,t as ne}from"./filters-Culzq1j1.js";import{Bn as re,D as A,Ft as j,Ht as M,It as N,Kn as P,Lt as F,Pt as I,Rt as L,Vn as ie,Vt as R,g as z,i as ae,nn as oe,o as se,r as B,un as V,zt as H}from"./index-DLjZ6tbN.js";import{a as U,c as W}from"./dataParts-Dbay5ALL.js";import{n as G,r as ce,t as le}from"./DesktopReview-B7eW9uGp.js";var K=e(r(),1),q=b(),J=[`workflows`,`runs`,`machine`],ue={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`]},de={explore:`Explored`,record:`Recorded`,project:`Project`},fe={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 C.start(e,{});location.hash=m(`chats`,t)}catch(e){t(e.message)}}function pe(){let[e,t]=(0,K.useState)(null),[n,r]=(0,K.useState)(``),[i,a]=(0,K.useState)(!1),o=(0,K.useCallback)(()=>{E.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=ie(o,1e3);return()=>re(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 E.stop().then(o)}}function Z({on:e,set:t,children:n}){return(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-ink-2`,children:[(0,q.jsx)(V,{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-2 text-sm font-medium`,children:[e,n,t&&(0,q.jsx)(`span`,{className:`text-[13px] font-normal text-muted`,children:t})]})}function me({w:e,page:t,onClose:r}){let{view:i}=t,[a,o]=(0,K.useState)({}),[s,c]=(0,K.useState)(``),[l,d]=(0,K.useState)(i.heal),[f,p]=(0,K.useState)(!1);(0,K.useEffect)(()=>{e&&(o(Object.fromEntries(e.variables.map(e=>[e.name,e.value]))),c(``),d(i.heal),p(!1))},[e,i.heal]);let m=s.startsWith(`file:`)?{file:s.slice(5)}:s.startsWith(`request:`)?{request:s.slice(8)}:void 0,h=`flex flex-col gap-4 rounded-[12px] card border p-4`;return(0,q.jsx)(P,{open:!!e,onClose:r,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)(k,{onClick:r,children:[(0,q.jsx)(u,{"aria-hidden":`true`}),`Cancel`]}),(0,q.jsxs)(k,{variant:`primary`,disabled:t.busy||!e,onClick:async()=>{e&&await t.act(()=>E.replay({workflow:e.path,variables:a,...m?{rows:m}:{},heal:l,updateBaselines:f}))&&r()},"data-tip":`Replay now`,children:[(0,q.jsx)(n,{"aria-hidden":`true`}),`Replay`]})]}),children:e&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-4 pt-4`,children:[(0,q.jsxs)(`p`,{className:`m-0 flex flex-wrap gap-x-4 text-[13px] text-muted`,children:[(0,q.jsx)(`span`,{className:`font-mono`,children:e.path}),(0,q.jsxs)(`span`,{children:[e.app||`no app`,` · `,w(e.steps,`step`),` · `,w(e.checks,`check`)]})]}),e.checks===0&&(0,q.jsx)(`p`,{className:`m-0 rounded-[10px] bg-warn-soft px-4 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-4`,children:e.variables.map(e=>(0,q.jsx)(Q,{label:e.name,children:(0,q.jsx)(D,{value:a[e.name]??``,onChange:t=>o({...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)(T,{value:s,onChange:e=>c(e.target.value),children:[(0,q.jsx)(`option`,{value:``,children:`Once, with the values above`}),i.rows.files.map(e=>(0,q.jsxs)(`option`,{value:`file:${e}`,children:[`Each row of `,e]},e)),i.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:l,set:d,children:`Heal a step whose control moved`}),(0,q.jsx)(Z,{on:f,set:p,children:`Take new image baselines`})]})]})})}function he({open:e,page:n,onClose:r}){let{view:i}=n,[a,o]=(0,K.useState)(i.apps[0]?.name??``),[s,c]=(0,K.useState)(``),[l,f]=(0,K.useState)(``);return(0,q.jsx)(P,{open:e,onClose:r,title:`Explore a goal`,description:`DeskPilot 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)(k,{onClick:r,children:[(0,q.jsx)(u,{"aria-hidden":`true`}),`Cancel`]}),(0,q.jsxs)(k,{variant:`primary`,disabled:n.busy||!s.trim()||!a,onClick:async()=>{await n.act(()=>E.explore(a,s.trim(),l.trim()))&&(c(``),f(``),r())},"data-tip":`Start: DeskPilot takes over the mouse and keyboard`,children:[(0,q.jsx)(d,{"aria-hidden":`true`}),`Start exploring`]})]}),children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-4 pt-4`,children:[(0,q.jsx)(Q,{label:`App`,children:(0,q.jsx)(T,{value:a,onChange:e=>o(e.target.value),children:i.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)(D,{value:s,maxLength:500,placeholder:`Create an invoice for Contoso and save it`,onChange:e=>c(e.target.value)})}),(0,q.jsx)(Q,{label:`Name`,hint:`Optional: the workflow's name.`,children:(0,q.jsx)(D,{value:l,maxLength:80,onChange:e=>f(e.target.value)})}),(0,q.jsxs)(`p`,{className:`m-0 flex gap-2 rounded-[10px] bg-warn-soft px-4 py-2 text-[13px] text-warn`,children:[(0,q.jsx)(t,{size:16,"aria-hidden":`true`,className:`mt-1 flex-none`}),`DeskPilot controls this machine's mouse and keyboard in `,a||`the app`,`, in that app's windows only (no shell commands). Use a test machine and a test account.`]})]})})}function ge({open:e,page:t,onClose:n}){let{view:r}=t,[i,o]=(0,K.useState)(r.windows),[s,c]=(0,K.useState)(!1);return(0,q.jsx)(P,{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)(k,{onClick:n,children:[(0,q.jsx)(u,{"aria-hidden":`true`}),`Cancel`]}),(0,q.jsxs)(k,{variant:`primary`,disabled:t.busy,onClick:async()=>{await t.act(()=>E.setup({ufo:r.windows&&i,force:s}))&&n()},children:[(0,q.jsx)(a,{"aria-hidden":`true`}),`Set up`]})]}),children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-4 pt-4`,children:[r.windows?(0,q.jsx)(Z,{on:i,set:o,children:`Exploring a goal too (DeskPilot)`}):(0,q.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`On this system workflows replay by accessibility calls, 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 _e({open:e,editing:t,page:n,onClose:r}){let[i,a]=(0,K.useState)(``),[o,s]=(0,K.useState)(``),[d,f]=(0,K.useState)(!1),[p,m]=(0,K.useState)(``),[h,g]=(0,K.useState)(``),[_,v]=(0,K.useState)(``),[y,b]=(0,K.useState)(!1);(0,K.useEffect)(()=>{e&&(a(t?.path??``),s(t?.name??``),f(!!t),m(t?.description??``),g($(t?.args)),v(``))},[e,t]);let S=async()=>{b(!0),v(``);let e={name:o.trim(),path:i.trim(),...h.trim()?{args:h.trim()}:{},...p.trim()?{description:p.trim()}:{}};try{await(t?E.editApp(e):E.addApp(e)),n.load(),r()}catch(e){v(e.message)}finally{b(!1)}};return(0,q.jsx)(P,{open:e,onClose:r,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)(k,{onClick:r,children:[(0,q.jsx)(u,{"aria-hidden":`true`}),`Cancel`]}),(0,q.jsxs)(k,{variant:`primary`,disabled:y||!i.trim()||!o.trim(),onClick:()=>void S(),children:[t?(0,q.jsx)(c,{"aria-hidden":`true`}):(0,q.jsx)(l,{"aria-hidden":`true`}),y?t?`Saving…`:`Adding…`:t?`Save`:`Add the app`]})]}),children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-4 pt-4`,children:[(0,q.jsx)(Q,{label:`Program`,hint:`Type its path, or Browse to choose it on this computer.`,children:(0,q.jsx)(G,{value:i,onChange:e=>{a(e),d||s(e.trim()?ce(e):``)},onPicked:(e,t)=>{d||s(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)(D,{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)(D,{value:o,maxLength:40,spellCheck:!1,readOnly:!!t,className:x(t&&`bg-surface-muted text-muted`),onChange:e=>{f(!0),s(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)(D,{value:p,maxLength:200,placeholder:`Back-office invoicing`,onChange:e=>m(e.target.value)})}),_&&(0,q.jsx)(W,{text:_})]})})}function ve({app:e,page:t,onClose:n}){let[r,i]=(0,K.useState)(null),[a,o]=(0,K.useState)(``),[s,c]=(0,K.useState)(!1);return(0,K.useEffect)(()=>{e&&(i(null),o(``),E.removeApp(e.name,!1).then(i,e=>o(e.message)))},[e]),(0,q.jsx)(P,{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)(k,{onClick:n,children:[(0,q.jsx)(u,{"aria-hidden":`true`}),`Cancel`]}),(0,q.jsxs)(k,{variant:`destructive`,disabled:s||!r,onClick:async()=>{if(e){c(!0);try{await E.removeApp(e.name,!0),t.load(),n()}catch(e){o(e.message)}finally{c(!1)}}},children:[(0,q.jsx)(v,{"aria-hidden":`true`}),s?`Removing…`:`Remove`]})]}),children:(0,q.jsx)(`div`,{className:`flex flex-col gap-4 pt-4 text-sm`,children:a?(0,q.jsx)(W,{text:a}):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-4 py-2 text-[13px] text-warn`,children:[w(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-[13px] 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 ye({page:e,onReplay:t,onExplore:r,onSteps:i}){let{view:a}=e,[s,c]=(0,K.useState)(a.apps[0]?.name??``),l=a.windows?void 0:a.windowsOnly,u=()=>e.act(async()=>{await S.start({kind:`desktop`,app:s}),location.hash=m(`record`)});return(0,q.jsx)(I,{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)(T,{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)(k,{size:`sm`,disabled:e.busy||!a.windows||!s,onClick:()=>void u(),"data-tip":l??`Record your steps in ${s}: no model`,children:[(0,q.jsx)(_,{"aria-hidden":`true`}),`Record by hand`]}),(0,q.jsxs)(k,{size:`sm`,variant:`primary`,disabled:e.busy||!a.windows||!a.apps.length,onClick:r,"data-tip":l??`DeskPilot carries out a goal and saves it as a workflow`,children:[(0,q.jsx)(d,{"aria-hidden":`true`}),`Explore a goal`]})]}),head:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`th`,{scope:`col`,className:F,children:`Workflow`}),(0,q.jsx)(`th`,{scope:`col`,className:F,children:`App`}),(0,q.jsx)(`th`,{scope:`col`,className:L,children:`Steps`}),(0,q.jsx)(`th`,{scope:`col`,className:L,children:`Checks`}),(0,q.jsx)(`th`,{scope:`col`,className:F,children:`From`}),(0,q.jsx)(`th`,{scope:`col`,className:F,children:(0,q.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]}),children:a.workflows.map(r=>(0,q.jsxs)(`tr`,{className:H,children:[(0,q.jsx)(`td`,{className:j,children:(0,q.jsxs)(`span`,{className:`flex flex-col gap-1`,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-[13px] text-muted`,"data-tip":r.path,children:r.path})]})}),(0,q.jsx)(`td`,{className:x(j,`whitespace-nowrap`),children:r.app||(0,q.jsx)(`span`,{className:`text-muted`,children:`—`})}),(0,q.jsx)(`td`,{className:N,children:r.steps}),(0,q.jsx)(`td`,{className:x(N,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:x(j,`whitespace-nowrap`),children:[de[r.from],(0,q.jsx)(`span`,{className:`block text-[13px] text-muted`,children:z(r.modified)})]}),(0,q.jsx)(`td`,{className:x(j,`whitespace-nowrap text-right`),children:(0,q.jsxs)(`span`,{className:`inline-flex gap-1`,children:[(0,q.jsx)(k,{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)(g,{"aria-hidden":`true`})}),(0,q.jsx)(k,{size:`icon`,variant:`icon`,disabled:e.busy,onClick:()=>t(r),"aria-label":`Replay ${r.name}`,"data-tip":`Replay ${r.name}`,className:`size-8`,children:(0,q.jsx)(n,{"aria-hidden":`true`})}),(0,q.jsx)(k,{size:`icon`,variant:`icon`,disabled:e.busy,onClick:()=>void e.act(()=>E.validate(r.path)),"aria-label":`Check ${r.name}`,"data-tip":`Check it without running it`,className:`size-8`,children:(0,q.jsx)(p,{"aria-hidden":`true`})}),(0,q.jsx)(k,{size:`icon`,variant:`icon`,onClick:()=>void X(`DeskPilot: 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)(o,{"aria-hidden":`true`})})]})})]},r.path))})}function be({page:e}){let{view:t}=e,[n,r]=(0,K.useState)(`all`),[o,s]=(0,K.useState)(``),c=t.runs.filter(e=>!e.ok),l=t.runs.filter(Y),u=n===`failed`?c:n===`heals`?l:t.runs;return(0,q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[o&&(0,q.jsx)(`p`,{role:`status`,className:`m-0 rounded-[10px] bg-pass-soft px-4 py-2 text-[13px] text-pass`,children:o}),(0,q.jsx)(I,{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)(ne,{value:n,onChange:r,items:[{id:`all`,label:`All`,n:t.runs.length},{id:`failed`,label:`Failed`,n:c.length,alert:!0},{id:`heals`,label:`Heals to accept`,n:l.length}]}),head:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`th`,{scope:`col`,className:F,children:`Run`}),(0,q.jsx)(`th`,{scope:`col`,className:F,children:`Result`}),(0,q.jsx)(`th`,{scope:`col`,className:L,children:`Steps`}),(0,q.jsx)(`th`,{scope:`col`,className:F,children:`Heals`}),(0,q.jsx)(`th`,{scope:`col`,className:F,children:(0,q.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]}),children:u.map(t=>(0,q.jsxs)(`tr`,{className:H,children:[(0,q.jsx)(`td`,{className:j,children:(0,q.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,q.jsxs)(`span`,{className:`font-medium`,children:[fe[t.mode],`: `,t.name]}),(0,q.jsx)(`span`,{className:`text-[13px] text-muted`,children:[t.app,z(t.at)].filter(Boolean).join(` · `)}),(t.failed||t.error)&&(0,q.jsx)(`span`,{className:`max-w-[380px] truncate text-[13px] 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:x(j,`whitespace-nowrap`),children:(0,q.jsx)(O,{tone:t.ok?`pass`:`fail`,children:t.many?`${t.many.passed} of ${t.many.total}`:t.ok?`Passed`:`Failed`})}),(0,q.jsx)(`td`,{className:N,children:t.steps||(0,q.jsx)(`span`,{className:`text-muted`,children:`—`})}),(0,q.jsx)(`td`,{className:x(j,`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)(i,{size:14,"aria-hidden":`true`}),`In the workflow`]}):t.ok?(0,q.jsxs)(k,{size:`sm`,disabled:e.busy,onClick:()=>void e.act(async()=>{let e=await E.acceptHeals(t.dir);s(`Wrote ${w(e.written,`healed step`)} into ${e.workflow}.`)}),"data-tip":`Write the new locators into the workflow`,children:[(0,q.jsx)(a,{"aria-hidden":`true`}),`Accept `,w(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:[w(t.heals,`heal`),`, not offered`]}):(0,q.jsx)(`span`,{className:`text-muted`,children:`—`})}),(0,q.jsx)(`td`,{className:x(j,`whitespace-nowrap text-right`),children:(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[t.report&&(0,q.jsx)(A,{path:t.report,children:`Report`}),!t.ok&&(0,q.jsx)(k,{size:`icon`,variant:`icon`,onClick:()=>void X(`DeskPilot: 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)(f,{"aria-hidden":`true`})})]})})]},t.dir))})]})}function xe({page:e,onSetup:n,onAdd:r,onEdit:o,onRemove:c}){let{view:u}=e,d=(u.driver===`auto`?u.windows?`pywinauto`:`agent-desktop`:u.driver)===`pywinauto`?`the mouse and keyboard`:`accessibility calls`,f=[{label:`Replay`,ok:u.engine.ready,note:u.engine.ready?`On ${d}`:(u.engine.error||`The desktop engine is not set up`).replace(/^./,e=>e.toUpperCase())},{label:`Explore and record`,ok:u.windows&&u.engine.ufo,note:u.windows?u.engine.ufo?`Set up`:`Not set up`:`Windows only`},{label:`Healing`,ok:u.heal,note:u.heal?`A moved control is healed with the model`:`desktop.heal is off`}],h=`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:x(h,`m-0 list-none divide-y divide-line-soft p-0`),children:f.map(e=>(0,q.jsxs)(`li`,{className:`flex items-start gap-2 px-4 py-2`,children:[e.ok?(0,q.jsx)(i,{size:16,"aria-label":`Ready`,className:`mt-1 flex-none text-pass`}):(0,q.jsx)(t,{size:16,"aria-label":`Not ready`,className:`mt-1 flex-none text-warn`}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,q.jsx)(`span`,{className:`text-[13px] font-medium`,children:e.label}),(0,q.jsx)(`span`,{className:`text-[13px] text-muted [overflow-wrap:anywhere]`,"data-tip":!e.ok&&e.label===`Explore and record`&&u.windowsOnly?u.windowsOnly:void 0,children:e.note})]})]},e.label))}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsxs)(k,{size:`sm`,disabled:e.busy,onClick:()=>void e.act(()=>E.doctor()),"data-tip":`Whether replay can run here unattended`,children:[(0,q.jsx)(p,{"aria-hidden":`true`}),`Check`]}),(0,q.jsxs)(k,{size:`sm`,variant:u.engine.ready?`outline`:`primary`,disabled:e.busy,onClick:n,"data-tip":`Download and set up the desktop engine`,children:[(0,q.jsx)(a,{"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)(k,{size:`sm`,onClick:r,"data-tip":`Add an app by its program on this computer`,children:[(0,q.jsx)(l,{"aria-hidden":`true`}),`Add an app`]})]}),u.apps.length?(0,q.jsx)(`ul`,{className:x(h,`m-0 list-none divide-y divide-line-soft p-0`),children:u.apps.map(e=>(0,q.jsxs)(`li`,{className:`group flex items-start gap-2 px-4 py-2`,children:[(0,q.jsx)(ee,{icon:_,size:16,className:`mt-1 flex-none text-muted`}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,q.jsx)(`span`,{className:`text-[13px] font-medium`,children:e.name}),(0,q.jsxs)(`span`,{className:`truncate font-mono text-[13px] 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-[13px] text-muted`,children:e.description})]}),(0,q.jsxs)(`span`,{className:`flex flex-none gap-1`,children:[(0,q.jsx)(k,{size:`icon`,variant:`icon`,onClick:()=>o(e),"aria-label":`Change ${e.name}`,"data-tip":`Change ${e.name}`,className:`size-8`,children:(0,q.jsx)(s,{"aria-hidden":`true`})}),(0,q.jsx)(k,{size:`icon`,variant:`icon`,onClick:()=>c(e),"aria-label":`Remove ${e.name}`,"data-tip":`Remove ${e.name}`,className:`size-8 hover:text-fail`,children:(0,q.jsx)(v,{"aria-hidden":`true`})})]})]},e.name))}):(0,q.jsxs)(te,{className:`py-4`,children:[`No desktop apps yet: add one by its program, or in `,(0,q.jsx)(`a`,{href:m(`settings`,`environments`),children:`Settings, Environments`}),`.`]}),(0,q.jsxs)(`p`,{className:`m-0 text-[13px] text-muted`,children:[`Secrets a workflow may type: `,u.secrets.length?u.secrets.join(`, `):`none`,`.`,u.refusedSecrets.length>0&&(0,q.jsxs)(`span`,{className:`text-fail`,children:[` `,u.refusedSecrets.join(`, `),` `,u.refusedSecrets.length===1?`is`:`are`,` ForgeQE's own: take `,u.refusedSecrets.length===1?`it`:`them`,` out of desktop.secrets, or nothing replays.`]})]})]})]})}function Se({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)(M,{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`]}):`${w(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 ${z(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 Ce({sub:e}){let t=pe(),{view:n,error:r}=t,i=y(`desktop`),a=J.includes(e)?e:B,[o,s]=(0,K.useState)(null),[c,l]=(0,K.useState)(!1),[u,d]=(0,K.useState)(!1),[f,p]=(0,K.useState)(!1),[g,_]=(0,K.useState)(),[v,b]=(0,K.useState)(null),[x,S]=(0,K.useState)(null),C=n?.job??null,w=e=>location.hash=e===`agent`?m(`desktop`):m(`desktop`,e),T={workflows:`Workflows${n?` (${n.workflows.length})`:``}`,runs:`Runs${n?` (${n.runs.length})`:``}`,machine:`Machine and apps`};return(0,q.jsxs)(ae,{title:oe(`desktop`),page:i,label:`Desktop apps`,current:a,onPick:w,tabs:J.map(e=>({id:e,label:T[e]})),below:(0,q.jsx)(se,{page:i}),children:[(0,q.jsx)(`p`,{className:`m-0 text-sm leading-relaxed text-ink-2`,children:`Workflows for Windows thick-client apps: explore a goal with DeskPilot or record your steps by hand, then replay them with no model, a moved control healed and offered for the workflow.`}),r&&(0,q.jsx)(W,{text:r}),!n&&!r&&(0,q.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}),n&&x&&(0,q.jsx)(le,{workflow:x.path,backLabel:`Workflows`,onClose:()=>{S(null),t.load()}},x.path),n&&!x&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Se,{view:n,onTab:w}),C&&(C.running||!C.endedAt||Date.now()-Date.parse(C.endedAt)<6e5)&&(0,q.jsx)(U,{job:C,onStop:t.stop,words:ue}),C?.question&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-[12px] bg-accent-soft p-4 text-[13px]`,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)(k,{size:`sm`,onClick:()=>void t.act(()=>E.answer(C.question.id,e.id)),children:e.label},e.id)),(0,q.jsxs)(k,{size:`sm`,variant:`danger`,onClick:()=>void t.act(()=>E.answer(C.question.id,null)),children:[(0,q.jsx)(h,{fill:`currentColor`,"aria-hidden":`true`}),`Stop`]})]})]}),(0,q.jsxs)(`div`,{children:[a===`workflows`&&(0,q.jsx)(ye,{page:{...t,view:n},onReplay:s,onExplore:()=>l(!0),onSteps:S}),a===`runs`&&(0,q.jsx)(be,{page:{...t,view:n}}),a===`machine`&&(0,q.jsx)(xe,{page:{...t,view:n},onSetup:()=>d(!0),onAdd:()=>{_(void 0),p(!0)},onEdit:e=>{_(e),p(!0)},onRemove:b})]}),(0,q.jsx)(me,{w:o,page:{...t,view:n},onClose:()=>s(null)}),(0,q.jsx)(he,{open:c,page:{...t,view:n},onClose:()=>l(!1)}),(0,q.jsx)(ge,{open:u,page:{...t,view:n},onClose:()=>d(!1)}),(0,q.jsx)(_e,{open:f,editing:g,page:{...t,view:n},onClose:()=>p(!1)}),(0,q.jsx)(ve,{app:v,page:{...t,view:n},onClose:()=>b(null)})]})]})}export{Ce as Desktop};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{F as t,Fn as n,Hr as r,I as i,Lr as a,Mr as o,Nn as s,O as c,Rn as l,Rr as u,ar as d,gn as f,on as p,r as m,sr as h,ut as g,xn as _,xr as v}from"./route-Dg53WdFu.js";import{l as y}from"./agents-C0Jg2pN8.js";import{t as b}from"./jsx-runtime-LKYXHABd.js";import{A as x,Tt as S,Z as C,j as w,n as T,nt as E,t as D}from"./input-D7iHeNXz.js";import{a as O,d as k,l as ee,o as te,t as ne}from"./filters-Culzq1j1.js";import{Bn as re,D as A,Ft as j,Ht as M,It as N,Kn as P,Lt as F,Pt as I,Rt as L,Vn as ie,Vt as R,g as z,i as ae,nn as oe,o as se,r as B,un as V,zt as H}from"./index-DeYZJBWf.js";import{a as U,c as W}from"./dataParts-Ds4Gjeep.js";import{n as G,r as ce,t as le}from"./DesktopReview-QuculN-N.js";var K=e(r(),1),q=b(),J=[`workflows`,`runs`,`machine`],ue={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`]},de={explore:`Explored`,record:`Recorded`,project:`Project`},fe={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 C.start(e,{});location.hash=m(`chats`,t)}catch(e){t(e.message)}}function pe(){let[e,t]=(0,K.useState)(null),[n,r]=(0,K.useState)(``),[i,a]=(0,K.useState)(!1),o=(0,K.useCallback)(()=>{E.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=ie(o,1e3);return()=>re(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 E.stop().then(o)}}function Z({on:e,set:t,children:n}){return(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-ink-2`,children:[(0,q.jsx)(V,{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-2 text-sm font-medium`,children:[e,n,t&&(0,q.jsx)(`span`,{className:`text-[13px] font-normal text-muted`,children:t})]})}function me({w:e,page:t,onClose:r}){let{view:i}=t,[a,o]=(0,K.useState)({}),[s,c]=(0,K.useState)(``),[l,d]=(0,K.useState)(i.heal),[f,p]=(0,K.useState)(!1);(0,K.useEffect)(()=>{e&&(o(Object.fromEntries(e.variables.map(e=>[e.name,e.value]))),c(``),d(i.heal),p(!1))},[e,i.heal]);let m=s.startsWith(`file:`)?{file:s.slice(5)}:s.startsWith(`request:`)?{request:s.slice(8)}:void 0,h=`flex flex-col gap-4 rounded-[12px] card border p-4`;return(0,q.jsx)(P,{open:!!e,onClose:r,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)(k,{onClick:r,children:[(0,q.jsx)(u,{"aria-hidden":`true`}),`Cancel`]}),(0,q.jsxs)(k,{variant:`primary`,disabled:t.busy||!e,onClick:async()=>{e&&await t.act(()=>E.replay({workflow:e.path,variables:a,...m?{rows:m}:{},heal:l,updateBaselines:f}))&&r()},"data-tip":`Replay now`,children:[(0,q.jsx)(n,{"aria-hidden":`true`}),`Replay`]})]}),children:e&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-4 pt-4`,children:[(0,q.jsxs)(`p`,{className:`m-0 flex flex-wrap gap-x-4 text-[13px] text-muted`,children:[(0,q.jsx)(`span`,{className:`font-mono`,children:e.path}),(0,q.jsxs)(`span`,{children:[e.app||`no app`,` · `,w(e.steps,`step`),` · `,w(e.checks,`check`)]})]}),e.checks===0&&(0,q.jsx)(`p`,{className:`m-0 rounded-[10px] bg-warn-soft px-4 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-4`,children:e.variables.map(e=>(0,q.jsx)(Q,{label:e.name,children:(0,q.jsx)(D,{value:a[e.name]??``,onChange:t=>o({...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)(T,{value:s,onChange:e=>c(e.target.value),children:[(0,q.jsx)(`option`,{value:``,children:`Once, with the values above`}),i.rows.files.map(e=>(0,q.jsxs)(`option`,{value:`file:${e}`,children:[`Each row of `,e]},e)),i.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:l,set:d,children:`Heal a step whose control moved`}),(0,q.jsx)(Z,{on:f,set:p,children:`Take new image baselines`})]})]})})}function he({open:e,page:n,onClose:r}){let{view:i}=n,[a,o]=(0,K.useState)(i.apps[0]?.name??``),[s,c]=(0,K.useState)(``),[l,f]=(0,K.useState)(``);return(0,q.jsx)(P,{open:e,onClose:r,title:`Explore a goal`,description:`DeskPilot 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)(k,{onClick:r,children:[(0,q.jsx)(u,{"aria-hidden":`true`}),`Cancel`]}),(0,q.jsxs)(k,{variant:`primary`,disabled:n.busy||!s.trim()||!a,onClick:async()=>{await n.act(()=>E.explore(a,s.trim(),l.trim()))&&(c(``),f(``),r())},"data-tip":`Start: DeskPilot takes over the mouse and keyboard`,children:[(0,q.jsx)(d,{"aria-hidden":`true`}),`Start exploring`]})]}),children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-4 pt-4`,children:[(0,q.jsx)(Q,{label:`App`,children:(0,q.jsx)(T,{value:a,onChange:e=>o(e.target.value),children:i.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)(D,{value:s,maxLength:500,placeholder:`Create an invoice for Contoso and save it`,onChange:e=>c(e.target.value)})}),(0,q.jsx)(Q,{label:`Name`,hint:`Optional: the workflow's name.`,children:(0,q.jsx)(D,{value:l,maxLength:80,onChange:e=>f(e.target.value)})}),(0,q.jsxs)(`p`,{className:`m-0 flex gap-2 rounded-[10px] bg-warn-soft px-4 py-2 text-[13px] text-warn`,children:[(0,q.jsx)(t,{size:16,"aria-hidden":`true`,className:`mt-1 flex-none`}),`DeskPilot controls this machine's mouse and keyboard in `,a||`the app`,`, in that app's windows only (no shell commands). Use a test machine and a test account.`]})]})})}function ge({open:e,page:t,onClose:n}){let{view:r}=t,[i,o]=(0,K.useState)(r.windows),[s,c]=(0,K.useState)(!1);return(0,q.jsx)(P,{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)(k,{onClick:n,children:[(0,q.jsx)(u,{"aria-hidden":`true`}),`Cancel`]}),(0,q.jsxs)(k,{variant:`primary`,disabled:t.busy,onClick:async()=>{await t.act(()=>E.setup({ufo:r.windows&&i,force:s}))&&n()},children:[(0,q.jsx)(a,{"aria-hidden":`true`}),`Set up`]})]}),children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-4 pt-4`,children:[r.windows?(0,q.jsx)(Z,{on:i,set:o,children:`Exploring a goal too (DeskPilot)`}):(0,q.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`On this system workflows replay by accessibility calls, 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 _e({open:e,editing:t,page:n,onClose:r}){let[i,a]=(0,K.useState)(``),[o,s]=(0,K.useState)(``),[d,f]=(0,K.useState)(!1),[p,m]=(0,K.useState)(``),[h,g]=(0,K.useState)(``),[_,v]=(0,K.useState)(``),[y,b]=(0,K.useState)(!1);(0,K.useEffect)(()=>{e&&(a(t?.path??``),s(t?.name??``),f(!!t),m(t?.description??``),g($(t?.args)),v(``))},[e,t]);let S=async()=>{b(!0),v(``);let e={name:o.trim(),path:i.trim(),...h.trim()?{args:h.trim()}:{},...p.trim()?{description:p.trim()}:{}};try{await(t?E.editApp(e):E.addApp(e)),n.load(),r()}catch(e){v(e.message)}finally{b(!1)}};return(0,q.jsx)(P,{open:e,onClose:r,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)(k,{onClick:r,children:[(0,q.jsx)(u,{"aria-hidden":`true`}),`Cancel`]}),(0,q.jsxs)(k,{variant:`primary`,disabled:y||!i.trim()||!o.trim(),onClick:()=>void S(),children:[t?(0,q.jsx)(c,{"aria-hidden":`true`}):(0,q.jsx)(l,{"aria-hidden":`true`}),y?t?`Saving…`:`Adding…`:t?`Save`:`Add the app`]})]}),children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-4 pt-4`,children:[(0,q.jsx)(Q,{label:`Program`,hint:`Type its path, or Browse to choose it on this computer.`,children:(0,q.jsx)(G,{value:i,onChange:e=>{a(e),d||s(e.trim()?ce(e):``)},onPicked:(e,t)=>{d||s(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)(D,{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)(D,{value:o,maxLength:40,spellCheck:!1,readOnly:!!t,className:x(t&&`bg-surface-muted text-muted`),onChange:e=>{f(!0),s(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)(D,{value:p,maxLength:200,placeholder:`Back-office invoicing`,onChange:e=>m(e.target.value)})}),_&&(0,q.jsx)(W,{text:_})]})})}function ve({app:e,page:t,onClose:n}){let[r,i]=(0,K.useState)(null),[a,o]=(0,K.useState)(``),[s,c]=(0,K.useState)(!1);return(0,K.useEffect)(()=>{e&&(i(null),o(``),E.removeApp(e.name,!1).then(i,e=>o(e.message)))},[e]),(0,q.jsx)(P,{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)(k,{onClick:n,children:[(0,q.jsx)(u,{"aria-hidden":`true`}),`Cancel`]}),(0,q.jsxs)(k,{variant:`destructive`,disabled:s||!r,onClick:async()=>{if(e){c(!0);try{await E.removeApp(e.name,!0),t.load(),n()}catch(e){o(e.message)}finally{c(!1)}}},children:[(0,q.jsx)(v,{"aria-hidden":`true`}),s?`Removing…`:`Remove`]})]}),children:(0,q.jsx)(`div`,{className:`flex flex-col gap-4 pt-4 text-sm`,children:a?(0,q.jsx)(W,{text:a}):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-4 py-2 text-[13px] text-warn`,children:[w(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-[13px] 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 ye({page:e,onReplay:t,onExplore:r,onSteps:i}){let{view:a}=e,[s,c]=(0,K.useState)(a.apps[0]?.name??``),l=a.windows?void 0:a.windowsOnly,u=()=>e.act(async()=>{await S.start({kind:`desktop`,app:s}),location.hash=m(`record`)});return(0,q.jsx)(I,{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)(T,{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)(k,{size:`sm`,disabled:e.busy||!a.windows||!s,onClick:()=>void u(),"data-tip":l??`Record your steps in ${s}: no model`,children:[(0,q.jsx)(_,{"aria-hidden":`true`}),`Record by hand`]}),(0,q.jsxs)(k,{size:`sm`,variant:`primary`,disabled:e.busy||!a.windows||!a.apps.length,onClick:r,"data-tip":l??`DeskPilot carries out a goal and saves it as a workflow`,children:[(0,q.jsx)(d,{"aria-hidden":`true`}),`Explore a goal`]})]}),head:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`th`,{scope:`col`,className:F,children:`Workflow`}),(0,q.jsx)(`th`,{scope:`col`,className:F,children:`App`}),(0,q.jsx)(`th`,{scope:`col`,className:L,children:`Steps`}),(0,q.jsx)(`th`,{scope:`col`,className:L,children:`Checks`}),(0,q.jsx)(`th`,{scope:`col`,className:F,children:`From`}),(0,q.jsx)(`th`,{scope:`col`,className:F,children:(0,q.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]}),children:a.workflows.map(r=>(0,q.jsxs)(`tr`,{className:H,children:[(0,q.jsx)(`td`,{className:j,children:(0,q.jsxs)(`span`,{className:`flex flex-col gap-1`,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-[13px] text-muted`,"data-tip":r.path,children:r.path})]})}),(0,q.jsx)(`td`,{className:x(j,`whitespace-nowrap`),children:r.app||(0,q.jsx)(`span`,{className:`text-muted`,children:`—`})}),(0,q.jsx)(`td`,{className:N,children:r.steps}),(0,q.jsx)(`td`,{className:x(N,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:x(j,`whitespace-nowrap`),children:[de[r.from],(0,q.jsx)(`span`,{className:`block text-[13px] text-muted`,children:z(r.modified)})]}),(0,q.jsx)(`td`,{className:x(j,`whitespace-nowrap text-right`),children:(0,q.jsxs)(`span`,{className:`inline-flex gap-1`,children:[(0,q.jsx)(k,{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)(g,{"aria-hidden":`true`})}),(0,q.jsx)(k,{size:`icon`,variant:`icon`,disabled:e.busy,onClick:()=>t(r),"aria-label":`Replay ${r.name}`,"data-tip":`Replay ${r.name}`,className:`size-8`,children:(0,q.jsx)(n,{"aria-hidden":`true`})}),(0,q.jsx)(k,{size:`icon`,variant:`icon`,disabled:e.busy,onClick:()=>void e.act(()=>E.validate(r.path)),"aria-label":`Check ${r.name}`,"data-tip":`Check it without running it`,className:`size-8`,children:(0,q.jsx)(p,{"aria-hidden":`true`})}),(0,q.jsx)(k,{size:`icon`,variant:`icon`,onClick:()=>void X(`DeskPilot: 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)(o,{"aria-hidden":`true`})})]})})]},r.path))})}function be({page:e}){let{view:t}=e,[n,r]=(0,K.useState)(`all`),[o,s]=(0,K.useState)(``),c=t.runs.filter(e=>!e.ok),l=t.runs.filter(Y),u=n===`failed`?c:n===`heals`?l:t.runs;return(0,q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[o&&(0,q.jsx)(`p`,{role:`status`,className:`m-0 rounded-[10px] bg-pass-soft px-4 py-2 text-[13px] text-pass`,children:o}),(0,q.jsx)(I,{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)(ne,{value:n,onChange:r,items:[{id:`all`,label:`All`,n:t.runs.length},{id:`failed`,label:`Failed`,n:c.length,alert:!0},{id:`heals`,label:`Heals to accept`,n:l.length}]}),head:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`th`,{scope:`col`,className:F,children:`Run`}),(0,q.jsx)(`th`,{scope:`col`,className:F,children:`Result`}),(0,q.jsx)(`th`,{scope:`col`,className:L,children:`Steps`}),(0,q.jsx)(`th`,{scope:`col`,className:F,children:`Heals`}),(0,q.jsx)(`th`,{scope:`col`,className:F,children:(0,q.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]}),children:u.map(t=>(0,q.jsxs)(`tr`,{className:H,children:[(0,q.jsx)(`td`,{className:j,children:(0,q.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,q.jsxs)(`span`,{className:`font-medium`,children:[fe[t.mode],`: `,t.name]}),(0,q.jsx)(`span`,{className:`text-[13px] text-muted`,children:[t.app,z(t.at)].filter(Boolean).join(` · `)}),(t.failed||t.error)&&(0,q.jsx)(`span`,{className:`max-w-[380px] truncate text-[13px] 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:x(j,`whitespace-nowrap`),children:(0,q.jsx)(O,{tone:t.ok?`pass`:`fail`,children:t.many?`${t.many.passed} of ${t.many.total}`:t.ok?`Passed`:`Failed`})}),(0,q.jsx)(`td`,{className:N,children:t.steps||(0,q.jsx)(`span`,{className:`text-muted`,children:`—`})}),(0,q.jsx)(`td`,{className:x(j,`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)(i,{size:14,"aria-hidden":`true`}),`In the workflow`]}):t.ok?(0,q.jsxs)(k,{size:`sm`,disabled:e.busy,onClick:()=>void e.act(async()=>{let e=await E.acceptHeals(t.dir);s(`Wrote ${w(e.written,`healed step`)} into ${e.workflow}.`)}),"data-tip":`Write the new locators into the workflow`,children:[(0,q.jsx)(a,{"aria-hidden":`true`}),`Accept `,w(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:[w(t.heals,`heal`),`, not offered`]}):(0,q.jsx)(`span`,{className:`text-muted`,children:`—`})}),(0,q.jsx)(`td`,{className:x(j,`whitespace-nowrap text-right`),children:(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[t.report&&(0,q.jsx)(A,{path:t.report,children:`Report`}),!t.ok&&(0,q.jsx)(k,{size:`icon`,variant:`icon`,onClick:()=>void X(`DeskPilot: 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)(f,{"aria-hidden":`true`})})]})})]},t.dir))})]})}function xe({page:e,onSetup:n,onAdd:r,onEdit:o,onRemove:c}){let{view:u}=e,d=(u.driver===`auto`?u.windows?`pywinauto`:`agent-desktop`:u.driver)===`pywinauto`?`the mouse and keyboard`:`accessibility calls`,f=[{label:`Replay`,ok:u.engine.ready,note:u.engine.ready?`On ${d}`:(u.engine.error||`The desktop engine is not set up`).replace(/^./,e=>e.toUpperCase())},{label:`Explore and record`,ok:u.windows&&u.engine.ufo,note:u.windows?u.engine.ufo?`Set up`:`Not set up`:`Windows only`},{label:`Healing`,ok:u.heal,note:u.heal?`A moved control is healed with the model`:`desktop.heal is off`}],h=`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:x(h,`m-0 list-none divide-y divide-line-soft p-0`),children:f.map(e=>(0,q.jsxs)(`li`,{className:`flex items-start gap-2 px-4 py-2`,children:[e.ok?(0,q.jsx)(i,{size:16,"aria-label":`Ready`,className:`mt-1 flex-none text-pass`}):(0,q.jsx)(t,{size:16,"aria-label":`Not ready`,className:`mt-1 flex-none text-warn`}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,q.jsx)(`span`,{className:`text-[13px] font-medium`,children:e.label}),(0,q.jsx)(`span`,{className:`text-[13px] text-muted [overflow-wrap:anywhere]`,"data-tip":!e.ok&&e.label===`Explore and record`&&u.windowsOnly?u.windowsOnly:void 0,children:e.note})]})]},e.label))}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsxs)(k,{size:`sm`,disabled:e.busy,onClick:()=>void e.act(()=>E.doctor()),"data-tip":`Whether replay can run here unattended`,children:[(0,q.jsx)(p,{"aria-hidden":`true`}),`Check`]}),(0,q.jsxs)(k,{size:`sm`,variant:u.engine.ready?`outline`:`primary`,disabled:e.busy,onClick:n,"data-tip":`Download and set up the desktop engine`,children:[(0,q.jsx)(a,{"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)(k,{size:`sm`,onClick:r,"data-tip":`Add an app by its program on this computer`,children:[(0,q.jsx)(l,{"aria-hidden":`true`}),`Add an app`]})]}),u.apps.length?(0,q.jsx)(`ul`,{className:x(h,`m-0 list-none divide-y divide-line-soft p-0`),children:u.apps.map(e=>(0,q.jsxs)(`li`,{className:`group flex items-start gap-2 px-4 py-2`,children:[(0,q.jsx)(ee,{icon:_,size:16,className:`mt-1 flex-none text-muted`}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,q.jsx)(`span`,{className:`text-[13px] font-medium`,children:e.name}),(0,q.jsxs)(`span`,{className:`truncate font-mono text-[13px] 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-[13px] text-muted`,children:e.description})]}),(0,q.jsxs)(`span`,{className:`flex flex-none gap-1`,children:[(0,q.jsx)(k,{size:`icon`,variant:`icon`,onClick:()=>o(e),"aria-label":`Change ${e.name}`,"data-tip":`Change ${e.name}`,className:`size-8`,children:(0,q.jsx)(s,{"aria-hidden":`true`})}),(0,q.jsx)(k,{size:`icon`,variant:`icon`,onClick:()=>c(e),"aria-label":`Remove ${e.name}`,"data-tip":`Remove ${e.name}`,className:`size-8 hover:text-fail`,children:(0,q.jsx)(v,{"aria-hidden":`true`})})]})]},e.name))}):(0,q.jsxs)(te,{className:`py-4`,children:[`No desktop apps yet: add one by its program, or in `,(0,q.jsx)(`a`,{href:m(`settings`,`environments`),children:`Settings, Environments`}),`.`]}),(0,q.jsxs)(`p`,{className:`m-0 text-[13px] text-muted`,children:[`Secrets a workflow may type: `,u.secrets.length?u.secrets.join(`, `):`none`,`.`,u.refusedSecrets.length>0&&(0,q.jsxs)(`span`,{className:`text-fail`,children:[` `,u.refusedSecrets.join(`, `),` `,u.refusedSecrets.length===1?`is`:`are`,` ForgeQE's own: take `,u.refusedSecrets.length===1?`it`:`them`,` out of desktop.secrets, or nothing replays.`]})]})]})]})}function Se({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)(M,{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`]}):`${w(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 ${z(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 Ce({sub:e}){let t=pe(),{view:n,error:r}=t,i=y(`desktop`),a=J.includes(e)?e:B,[o,s]=(0,K.useState)(null),[c,l]=(0,K.useState)(!1),[u,d]=(0,K.useState)(!1),[f,p]=(0,K.useState)(!1),[g,_]=(0,K.useState)(),[v,b]=(0,K.useState)(null),[x,S]=(0,K.useState)(null),C=n?.job??null,w=e=>location.hash=e===`agent`?m(`desktop`):m(`desktop`,e),T={workflows:`Workflows${n?` (${n.workflows.length})`:``}`,runs:`Runs${n?` (${n.runs.length})`:``}`,machine:`Machine and apps`};return(0,q.jsxs)(ae,{title:oe(`desktop`),page:i,label:`Desktop apps`,current:a,onPick:w,tabs:J.map(e=>({id:e,label:T[e]})),below:(0,q.jsx)(se,{page:i}),children:[(0,q.jsx)(`p`,{className:`m-0 text-sm leading-relaxed text-ink-2`,children:`Workflows for Windows thick-client apps: explore a goal with DeskPilot or record your steps by hand, then replay them with no model, a moved control healed and offered for the workflow.`}),r&&(0,q.jsx)(W,{text:r}),!n&&!r&&(0,q.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}),n&&x&&(0,q.jsx)(le,{workflow:x.path,backLabel:`Workflows`,onClose:()=>{S(null),t.load()}},x.path),n&&!x&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Se,{view:n,onTab:w}),C&&(C.running||!C.endedAt||Date.now()-Date.parse(C.endedAt)<6e5)&&(0,q.jsx)(U,{job:C,onStop:t.stop,words:ue}),C?.question&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-[12px] bg-accent-soft p-4 text-[13px]`,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)(k,{size:`sm`,onClick:()=>void t.act(()=>E.answer(C.question.id,e.id)),children:e.label},e.id)),(0,q.jsxs)(k,{size:`sm`,variant:`danger`,onClick:()=>void t.act(()=>E.answer(C.question.id,null)),children:[(0,q.jsx)(h,{fill:`currentColor`,"aria-hidden":`true`}),`Stop`]})]})]}),(0,q.jsxs)(`div`,{children:[a===`workflows`&&(0,q.jsx)(ye,{page:{...t,view:n},onReplay:s,onExplore:()=>l(!0),onSteps:S}),a===`runs`&&(0,q.jsx)(be,{page:{...t,view:n}}),a===`machine`&&(0,q.jsx)(xe,{page:{...t,view:n},onSetup:()=>d(!0),onAdd:()=>{_(void 0),p(!0)},onEdit:e=>{_(e),p(!0)},onRemove:b})]}),(0,q.jsx)(me,{w:o,page:{...t,view:n},onClose:()=>s(null)}),(0,q.jsx)(he,{open:c,page:{...t,view:n},onClose:()=>l(!1)}),(0,q.jsx)(ge,{open:u,page:{...t,view:n},onClose:()=>d(!1)}),(0,q.jsx)(_e,{open:f,editing:g,page:{...t,view:n},onClose:()=>p(!1)}),(0,q.jsx)(ve,{app:v,page:{...t,view:n},onClose:()=>b(null)})]})]})}export{Ce as Desktop};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{At as t,Fn as n,Hr as r,I as i,Lr as a,Mr as o,Nn as s,O as c,Rn as l,Rr as u,bn as d,gn as f,l as p,r as m,ut as h,xr as g}from"./route-Dg53WdFu.js";import{t as _}from"./jsx-runtime-LKYXHABd.js";import{A as v,Z as y,a as ee,j as b,n as x,nt as S,t as C}from"./input-D7iHeNXz.js";import{a as w,d as T,i as te,o as E,t as D}from"./filters-Culzq1j1.js";import{Bn as O,D as k,Gt as A,Vn as ne,Wt as re,g as j,un as M,wn as ie}from"./index-DLjZ6tbN.js";import{a as N}from"./dataParts-Dbay5ALL.js";var P=e(r(),1),F=_();function I(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 L({value:e,onChange:n,onPicked:r,onError:i,className:a}){let[o,s]=(0,P.useState)(!1),c=async()=>{s(!0),i(``);try{let e=await S.browse();`path`in e?(n(e.path),r?.(e.path,e.name)):`unavailable`in e&&i(e.unavailable)}catch(e){i(e.message)}finally{s(!1)}};return(0,F.jsxs)(`div`,{className:v(`flex min-w-0 gap-2`,a),children:[(0,F.jsx)(C,{"aria-label":`App's path`,value:e,spellCheck:!1,placeholder:`C:\\Program Files\\Contoso\\Billing.exe`,onChange:e=>n(e.target.value),className:`min-w-0 flex-1 font-mono text-[13px]`}),(0,F.jsxs)(T,{type:`button`,disabled:o,onClick:()=>void c(),"data-tip":`Choose the app's .exe on this computer`,children:[(0,F.jsx)(t,{"aria-hidden":`true`}),o?`Choosing…`:`Browse…`]})]})}var ae={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 R({p:e}){return(0,F.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,F.jsx)(`ul`,{className:`m-0 flex flex-col gap-1 pl-6 text-[13px] text-ink-2`,children:e.summary.map((e,t)=>(0,F.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:e},t))}),(0,F.jsx)(`pre`,{className:`m-0 max-h-[200px] overflow-auto rounded-[10px] bg-surface-muted p-2 font-mono text-[13px] leading-relaxed whitespace-pre-wrap`,children:e.diff.map((e,t)=>(0,F.jsx)(`span`,{className:v(`block`,e.startsWith(`+`)?`text-pass`:e.startsWith(`-`)?`text-fail`:`text-muted`),children:e},t))})]})}function z({label:e,children:t}){return(0,F.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-[13px] font-medium`,children:[e,t]})}function oe({workflow:e,step:t,mode:n,onDone:r,onCancel:i}){let a=ae[t.op]??[`note`],o=t.fields??{},[l,d]=(0,P.useState)({automation_id:o.target?.automation_id??``,name:o.target?.name??``,control_type:o.target?.control_type??``}),[f,p]=(0,P.useState)(o.text??``),[m,h]=(0,P.useState)(o.value??``),[_,v]=(0,P.useState)(o.keys??``),[y,ee]=(0,P.useState)(o.seconds===void 0?``:String(o.seconds)),[b,x]=(0,P.useState)(o.timeout===void 0?``:String(o.timeout)),[w,te]=(0,P.useState)(o.note??``),[E,D]=(0,P.useState)(null),[O,k]=(0,P.useState)(``),[A,ne]=(0,P.useState)(!1),re=()=>{let e={};return a.includes(`target`)&&(l.automation_id!==(o.target?.automation_id??``)||l.name!==(o.target?.name??``)||l.control_type!==(o.target?.control_type??``))&&(e.target=l),a.includes(`text`)&&f!==(o.text??``)&&(e.text=f),a.includes(`value`)&&m!==(o.value??``)&&(e.value=m),a.includes(`keys`)&&_!==(o.keys??``)&&(e.keys=_),a.includes(`seconds`)&&y!==(o.seconds===void 0?``:String(o.seconds))&&(e.seconds=Number(y)),a.includes(`timeout`)&&b!==(o.timeout===void 0?``:String(o.timeout))&&b.trim()&&(e.timeout=Number(b)),a.includes(`note`)&&w!==(o.note??``)&&(e.note=w),e},j=async i=>{ne(!0),k(``);try{let a=await S.editStep({workflow:e,step:t.n,action:n,...n===`edit`?{fields:re()}:{},...i?{version:i}:{}});a.written?r():D(a)}catch(e){k(e.message)}finally{ne(!1)}};(0,P.useEffect)(()=>{n===`remove`&&j()},[]);let M=()=>D(null);return(0,F.jsxs)(`div`,{className:`mb-2 ml-10 flex flex-col gap-4 rounded-[12px] bg-surface-muted p-4`,children:[n===`edit`&&!E&&(0,F.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,180px),1fr))] gap-2`,children:[a.includes(`target`)&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(z,{label:`Control's name`,children:(0,F.jsx)(C,{size:`sm`,value:l.name,maxLength:300,onChange:e=>(d({...l,name:e.target.value}),M()),className:`bg-bg`})}),(0,F.jsx)(z,{label:`Automation id`,children:(0,F.jsx)(C,{size:`sm`,value:l.automation_id,maxLength:300,spellCheck:!1,onChange:e=>(d({...l,automation_id:e.target.value}),M()),className:`bg-bg font-mono text-[13px]`})}),(0,F.jsx)(z,{label:`Control type`,children:(0,F.jsx)(C,{size:`sm`,value:l.control_type,maxLength:60,spellCheck:!1,placeholder:`Button`,onChange:e=>(d({...l,control_type:e.target.value}),M()),className:`bg-bg`})})]}),a.includes(`text`)&&(0,F.jsx)(z,{label:t.op===`type`?`Text to type`:`Text it shows`,children:(0,F.jsx)(C,{size:`sm`,value:f,maxLength:500,onChange:e=>p(e.target.value),className:`bg-bg`})}),a.includes(`value`)&&(0,F.jsx)(z,{label:`Item to choose`,children:(0,F.jsx)(C,{size:`sm`,value:m,maxLength:500,onChange:e=>h(e.target.value),className:`bg-bg`})}),a.includes(`keys`)&&(0,F.jsx)(z,{label:`Keys`,children:(0,F.jsx)(C,{size:`sm`,value:_,maxLength:100,spellCheck:!1,placeholder:`ctrl+s`,onChange:e=>v(e.target.value),className:`bg-bg font-mono text-[13px]`})}),a.includes(`seconds`)&&(0,F.jsx)(z,{label:`Wait (seconds)`,children:(0,F.jsx)(C,{size:`sm`,type:`number`,min:0,max:600,value:y,onChange:e=>ee(e.target.value),className:`bg-bg`})}),a.includes(`timeout`)&&(0,F.jsx)(z,{label:`Timeout (seconds)`,children:(0,F.jsx)(C,{size:`sm`,type:`number`,min:0,max:600,value:b,placeholder:`default`,onChange:e=>x(e.target.value),className:`bg-bg`})}),a.includes(`note`)&&(0,F.jsx)(z,{label:`Note`,children:(0,F.jsx)(C,{size:`sm`,value:w,maxLength:200,onChange:e=>te(e.target.value),className:`bg-bg`})})]}),n===`remove`&&!E&&!O&&(0,F.jsx)(`p`,{role:`status`,className:`m-0 text-[13px] text-muted`,children:`Working out the change…`}),E&&(0,F.jsx)(R,{p:E}),O&&(0,F.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[10px] bg-fail-soft px-4 py-2 text-[13px] text-fail [overflow-wrap:anywhere]`,children:O}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[E?(0,F.jsxs)(T,{size:`sm`,variant:n===`remove`?`destructive`:`primary`,disabled:A,onClick:()=>void j(E.version),children:[n===`remove`?(0,F.jsx)(g,{"aria-hidden":`true`}):(0,F.jsx)(c,{"aria-hidden":`true`}),A?`Saving…`:n===`remove`?`Delete step ${t.n}`:`Save the change`]}):n===`edit`&&(0,F.jsx)(T,{size:`sm`,variant:`primary`,disabled:A||!Object.keys(re()).length,onClick:()=>void j(),children:A?`Checking…`:`Preview the change`}),E&&n===`edit`&&(0,F.jsxs)(T,{size:`sm`,onClick:()=>D(null),children:[(0,F.jsx)(s,{"aria-hidden":`true`}),`Change it more`]}),(0,F.jsxs)(T,{size:`sm`,variant:`ghost`,onClick:i,children:[(0,F.jsx)(u,{"aria-hidden":`true`}),`Cancel`]})]})]})}var B=[{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.`}],V={replay:[`Replaying the workflow`,`Replayed the workflow`,`working`],validate:[`Checking the workflow`,`Checked the workflow`,`searching`]};async function se(e){let t=await S.editStep(e);await S.editStep({...e,version:t.version})}var H=[{id:`check_text`,label:`Check a control shows a text`,control:!0,text:`need`},{id:`check_present`,label:`Check a control is there`,control:!0},{id:`wait_for`,label:`Wait for a control`,control:!0,text:`may`},{id:`wait_gone`,label:`Wait until a control is gone`,control:!0},{id:`wait`,label:`Wait some seconds`,control:!1},{id:`keys`,label:`Press keys`,control:!1}];function ce({step:e,onAdd:t}){let[n,r]=(0,P.useState)(`check_text`),i=e.fields?.target,[a,o]=(0,P.useState)({name:i?.name??``,automation_id:i?.automation_id??``,control_type:i?.control_type??``}),[s,c]=(0,P.useState)(``),[u,d]=(0,P.useState)(`2`),[f,p]=(0,P.useState)(``),m=H.find(e=>e.id===n),h=m.control?!!(a.name.trim()||a.automation_id.trim())&&(m.text!==`need`||!!s.trim()):n===`wait`?Number(u)>0:!!f.trim();return(0,F.jsxs)(`form`,{className:`flex flex-col gap-2 p-4`,onSubmit:e=>{e.preventDefault(),h&&t({kind:n,...m.control?{target:a}:{},...m.text&&s.trim()?{text:s}:{},...n===`wait`?{seconds:Number(u)}:{},...n===`keys`?{keys:f}:{}})},children:[(0,F.jsxs)(`p`,{className:`m-0 text-[13px] font-semibold`,children:[`After step `,e.n]}),(0,F.jsx)(x,{size:`sm`,"aria-label":`What to add`,value:n,onChange:e=>r(e.target.value),children:H.map(e=>(0,F.jsx)(`option`,{value:e.id,children:e.label},e.id))}),m.control&&(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,F.jsxs)(`label`,{className:`flex flex-col gap-1 text-[13px] font-medium`,children:[`Control's name`,(0,F.jsx)(C,{size:`sm`,value:a.name,maxLength:300,onChange:e=>o({...a,name:e.target.value})})]}),(0,F.jsxs)(`label`,{className:`flex flex-col gap-1 text-[13px] font-medium`,children:[`Automation id`,(0,F.jsx)(C,{size:`sm`,value:a.automation_id,maxLength:300,spellCheck:!1,onChange:e=>o({...a,automation_id:e.target.value}),className:`font-mono text-[13px]`})]})]}),m.text&&(0,F.jsxs)(`label`,{className:`flex flex-col gap-1 text-[13px] font-medium`,children:[m.text===`need`?`The text it shows`:`Showing the text (optional)`,(0,F.jsx)(C,{size:`sm`,value:s,maxLength:500,placeholder:`Invoice saved`,onChange:e=>c(e.target.value)})]}),n===`wait`&&(0,F.jsxs)(`label`,{className:`flex flex-col gap-1 text-[13px] font-medium`,children:[`Seconds`,(0,F.jsx)(C,{size:`sm`,type:`number`,min:1,max:600,value:u,onChange:e=>d(e.target.value)})]}),n===`keys`&&(0,F.jsxs)(`label`,{className:`flex flex-col gap-1 text-[13px] font-medium`,children:[`Keys`,(0,F.jsx)(C,{size:`sm`,value:f,maxLength:100,spellCheck:!1,placeholder:`ctrl+s`,onChange:e=>p(e.target.value),className:`font-mono text-[13px]`})]}),(0,F.jsx)(`p`,{className:`m-0 text-[13px] 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,F.jsxs)(T,{type:`submit`,size:`sm`,variant:`primary`,disabled:!h,className:`self-start`,children:[(0,F.jsx)(l,{"aria-hidden":`true`}),`Add`]})]})}var le=e=>e.name||e.automation_id||`the control`;function ue({pictures:e,step:t,busy:n,onPick:r}){let[i,a]=(0,P.useState)(0),o=e[Math.min(i,e.length-1)],[s,c]=(0,P.useState)(``),[l,u]=(0,P.useState)(``),[d,f]=(0,P.useState)(null);(0,P.useEffect)(()=>{let e=!1;return c(``),u(``),f(null),S.shot(o.run,o.n).then(t=>!e&&c(t),t=>!e&&u(t.message)),S.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,h]=(0,P.useState)(!1),g=d&&d.w>0?d.controls.toSorted((e,t)=>t.w*t.h-e.w*e.h):[];return(0,F.jsxs)(`div`,{className:`flex flex-col gap-2 pr-4 pb-4 pl-4 sm:pl-20`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.length>1&&(0,F.jsx)(A,{label:`Pictures of step ${t}`,value:String(i),onChange:e=>a(Number(e)),options:e.map((e,t)=>({id:String(t),label:e.label}))}),(0,F.jsxs)(`p`,{className:`m-0 text-[13px] text-muted`,children:[o.note,g.length>0?` Click a control to check that it shows its text, or that it is there.`:``]})]}),l&&(0,F.jsx)(`p`,{className:`m-0 text-sm text-fail`,children:l}),!s&&!l&&(0,F.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Loading the picture…`}),s&&(0,F.jsxs)(`div`,{className:v(`relative w-full overflow-hidden rounded-[10px] border border-line-soft`,m?`max-w-[360px]`:`max-w-[720px]`),style:g.length?{aspectRatio:`${d.w} / ${d.h}`}:void 0,children:[(0,F.jsx)(`img`,{src:s,alt:`The app after step ${t}, ${o.label.toLowerCase()}`,onLoad:e=>h(e.currentTarget.naturalHeight>e.currentTarget.naturalWidth),className:g.length?`absolute inset-0 size-full object-fill`:`block w-full`}),g.map((e,t)=>{let i=e.text?`Check ${le(e)} shows "${e.text}"`:`Check ${le(e)} is there`;return(0,F.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 de({v:e,secrets:t,onSave:n,busy:r,mobile:i=!1}){let[a,o]=(0,P.useState)(e.as),[s,l]=(0,P.useState)(e.name??``),[u,d]=(0,P.useState)(e.value??``);(0,P.useEffect)(()=>{o(e.as),l(e.name??``),d(e.value??``)},[e]);let f=B.filter(t=>e.op===`type`||t.id!==`secret`),p=a!==e.as||s!==(e.name??``)||u!==(e.value??``),m=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,F.jsxs)(`li`,{className:`flex flex-wrap items-start gap-x-4 gap-y-2 border-t border-line-soft px-4 py-2 first:border-t-0`,children:[(0,F.jsx)(`span`,{className:`w-6 flex-none pt-2 text-right font-mono text-[13px] text-muted tabular-nums`,children:e.n}),(0,F.jsxs)(`span`,{className:`flex min-w-0 flex-[1_1_220px] flex-col pt-2`,children:[(0,F.jsx)(`span`,{className:`text-[13px] text-ink [overflow-wrap:anywhere]`,children:e.line}),(0,F.jsx)(`span`,{className:`text-[13px] text-ink-2`,children:B.find(e=>e.id===a)?.note})]}),(0,F.jsxs)(`span`,{className:`flex flex-[1_1_360px] flex-wrap items-center gap-2`,children:[(0,F.jsx)(x,{"aria-label":`Where the value of step ${e.n} comes from`,value:a,disabled:r,onChange:e=>o(e.target.value),className:`w-[150px] flex-none`,children:f.map(e=>(0,F.jsx)(`option`,{value:e.id,children:e.label},e.id))}),a!==`typed`&&(0,F.jsx)(C,{"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=>l(a===`secret`?e.target.value.toUpperCase():e.target.value),className:`w-[170px] flex-none font-mono text-[13px]`}),a!==`secret`&&(0,F.jsx)(C,{"aria-label":a===`data`?`Its value`:`The value`,value:u,maxLength:500,onChange:e=>d(e.target.value),className:`min-w-[140px] flex-1`}),a===`secret`&&!t.includes(s)&&s&&(0,F.jsxs)(`span`,{className:`text-[13px] text-warn`,children:[`Not in `,i?`mobile.secrets`:`desktop.secrets`,` yet`]}),(0,F.jsxs)(T,{size:`sm`,variant:`primary`,disabled:r||!p||!m,onClick:()=>n(a,a===`typed`?void 0:s,a===`secret`?void 0:u),children:[(0,F.jsx)(c,{"aria-hidden":`true`}),`Save`]})]}),(0,F.jsx)(`datalist`,{id:`desktop-secrets`,children:t.map(e=>(0,F.jsx)(`option`,{value:e},e))})]})}function fe({view:e,job:t,rows:r,onRun:i,busy:a,heal:o}){let[s,c]=(0,P.useState)(()=>Object.fromEntries(e.variables.map(e=>[e.name,e.value]))),[l,u]=(0,P.useState)(``),[d,f]=(0,P.useState)(o),[p,m]=(0,P.useState)(!1),h=e.lastRun,g=l.startsWith(`file:`)?{file:l.slice(5)}:l.startsWith(`request:`)?{request:l.slice(8)}:void 0,_=t&&t.kind===`replay`&&t.target===e.workflow.path;return(0,F.jsxs)(F.Fragment,{children:[(0,F.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,F.jsxs)(`form`,{className:`flex flex-col gap-4 rounded-[12px] card border p-4`,onSubmit:e=>{e.preventDefault(),i({variables:s,...g?{rows:g}:{},heal:d,updateBaselines:p})},children:[e.variables.length>0&&(0,F.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,180px),1fr))] gap-4`,children:e.variables.map(e=>(0,F.jsxs)(`label`,{className:`flex flex-col gap-1 text-[13px] font-medium text-ink-2`,children:[e.name,(0,F.jsx)(C,{value:s[e.name]??``,onChange:t=>c({...s,[e.name]:t.target.value})})]},e.name))}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-end gap-4`,children:[(0,F.jsxs)(`label`,{className:`flex min-w-[220px] flex-col gap-1 text-[13px] font-medium text-ink-2`,children:[`Test data`,(0,F.jsxs)(x,{value:l,onChange:e=>u(e.target.value),children:[(0,F.jsx)(`option`,{value:``,children:`Once, with the values above`}),r.files.map(e=>(0,F.jsxs)(`option`,{value:`file:${e}`,children:[`Each row of `,e]},e)),r.requests.map(e=>(0,F.jsxs)(`option`,{value:`request:${e}`,children:[`Each row of request `,e]},e))]})]}),(0,F.jsxs)(`label`,{className:`flex min-h-10 items-center gap-2 text-sm text-ink-2`,children:[(0,F.jsx)(M,{checked:d,onChange:f,label:`Heal a step whose control moved`}),`Heal a moved control`]}),(0,F.jsxs)(`label`,{className:`flex min-h-10 items-center gap-2 text-sm text-ink-2`,children:[(0,F.jsx)(M,{checked:p,onChange:m,label:`Take new image baselines`}),`New image baselines`]}),(0,F.jsx)(`span`,{className:`flex-1`}),(0,F.jsxs)(T,{type:`submit`,variant:`primary`,disabled:a,children:[(0,F.jsx)(n,{"aria-hidden":`true`}),`Replay`]})]})]}),_&&(0,F.jsx)(N,{job:t,onStop:()=>void S.stop(),words:V}),h?(0,F.jsxs)(`section`,{"aria-labelledby":`desktop-last-run`,className:`flex flex-col gap-2`,children:[(0,F.jsx)(`h3`,{id:`desktop-last-run`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Last replay`}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 rounded-[12px] card border px-4 py-2 text-sm`,children:[(0,F.jsx)(w,{tone:h.ok?`pass`:`fail`,children:h.many?`${h.many.passed} of ${h.many.total} passed`:h.ok?`Passed`:`Failed`}),(0,F.jsxs)(`span`,{className:`text-muted`,children:[j(h.at),` · `,b(e.replays,`replay`),` in all`]}),h.failed&&(0,F.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,F.jsx)(`span`,{className:`flex-1`}),h.report&&(0,F.jsx)(k,{path:h.report,children:`Report`})]})]}):(0,F.jsx)(E,{className:`py-4`,children:`Not replayed yet.`})]})}function U({workflow:e,onClose:t,backLabel:r=`Back`,notices:_}){let[x,C]=(0,P.useState)(null),[k,A]=(0,P.useState)(``),[j,M]=(0,P.useState)(!1),[N,I]=(0,P.useState)(`steps`),[L,ae]=(0,P.useState)(``),[R,z]=(0,P.useState)(`all`),[B,V]=(0,P.useState)(null),[H,le]=(0,P.useState)(null),[U,W]=(0,P.useState)(null),[pe,me]=(0,P.useState)(``),[G,he]=(0,P.useState)(null),[ge,_e]=(0,P.useState)({files:[],requests:[]}),[ve,ye]=(0,P.useState)(!0),K=(0,P.useCallback)(()=>{S.review(e).then(e=>{C(e),A(``)},e=>A(e.message))},[e]);(0,P.useEffect)(K,[K]);let q=(0,P.useCallback)(()=>{S.view().then(e=>{he(e.job),_e(e.rows),ye(e.heal)},()=>{})},[]);(0,P.useEffect)(q,[q]);let J=!!G?.running;(0,P.useEffect)(()=>{if(!J)return;let e=ne(q,1e3);return()=>O(e)},[J,q]);let be=G&&!G.running?G.endedAt:``;(0,P.useEffect)(()=>{be&&K()},[be,K]);let Y=async(e,t)=>{M(!0),A(``),me(``);try{await e(),K(),t&&me(t)}catch(e){A(e.message)}finally{M(!1)}},xe=e=>void y.start(e,{}).then(({id:e})=>location.hash=m(`chats`,e),e=>A(e.message));if(!x)return k?(0,F.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-4 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:k}):(0,F.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Opening the workflow…`});let X=x.workflow.kind===`mobile`,Z=x.lastRun,Se=new Map((Z?.results??[]).map(e=>[e.n,e])),Ce=!!Z&&Date.parse(x.workflow.modified)>Date.parse(Z.at),we=x.steps.filter(e=>e.op.startsWith(`expect`)).length,Q=Z&&!Z.ok?Z.failed?.index??0:0,$=Q?x.steps[Q-1]:void 0,Te=(Z?.results??[]).filter(e=>!e.ok).length,Ee=L.toLowerCase().split(/\s+/).filter(Boolean),De=x.steps.filter(e=>Ee.every(t=>`${e.n} ${e.text} ${e.fields?.note||``}`.toLowerCase().includes(t))&&(R===`all`||(R===`checks`?e.op.startsWith(`expect`):Se.get(e.n)?.ok===!1))),Oe=e=>{I(`steps`),z(`all`),ae(``),requestAnimationFrame(()=>document.getElementById(`dstep-${e}`)?.scrollIntoView({block:`center`,behavior:ee()}))},ke=e=>void Y(async()=>{await S.replay({workflow:x.workflow.path,...e}),q()},X?`Replaying on the device: a device cloud can take a minute or two to start it.`:`Replaying: the app opens on this computer.`),Ae=[{id:`steps`,label:`Steps`,n:x.steps.length},{id:`data`,label:`Test data`,n:x.values.length},{id:`run`,label:`Last run`}];return(0,F.jsxs)(`section`,{"aria-labelledby":`dreview-title`,className:`flex min-w-0 flex-col gap-4`,children:[(0,F.jsxs)(`div`,{className:`sticky top-0 z-20 -mx-1 flex flex-col gap-4 border-b border-line bg-bg px-1 py-4`,children:[t&&(0,F.jsx)(`div`,{children:(0,F.jsxs)(T,{size:`sm`,variant:`ghost`,onClick:t,className:`-ml-2 text-ink-2`,children:[(0,F.jsx)(p,{"aria-hidden":`true`}),r]})}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-4`,children:[(0,F.jsxs)(`div`,{className:`flex min-w-0 flex-[1_1_320px] flex-col gap-1`,children:[(0,F.jsx)(`h2`,{id:`dreview-title`,className:`m-0 min-w-0 truncate text-lg font-semibold`,"data-tip":x.workflow.name,children:x.workflow.name}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[13px] text-muted`,children:[(0,F.jsxs)(`span`,{children:[x.workflow.app||`no app`,` · `,b(x.steps.length,`step`),` · `,b(we,`check`)]}),J&&G?.target===x.workflow.path?(0,F.jsx)(w,{tone:`running`,children:`Replaying…`}):Z?(0,F.jsx)(w,{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,F.jsx)(w,{tone:`neutral`,icon:!1,children:`Not replayed yet`}),Ce&&(0,F.jsx)(`span`,{children:`· you changed it since`})]})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsxs)(T,{onClick:()=>xe(`${X?`Look at the mobile workflow`:`DeskPilot: look at the desktop workflow`} ${x.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":X?`Ask the agent to improve it`:`Ask DeskPilot to improve it`,children:[(0,F.jsx)(o,{"aria-hidden":`true`}),`Improve`]}),(0,F.jsxs)(T,{variant:`primary`,disabled:J,onClick:()=>I(`run`),"data-tip":J?`A replay is going`:`Replay it with no model`,children:[(0,F.jsx)(n,{"aria-hidden":`true`}),`Replay`]})]})]})]}),_,k&&(0,F.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-4 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:k}),pe&&(0,F.jsx)(`p`,{role:`status`,className:`m-0 rounded-[10px] bg-pass-soft px-4 py-2 text-[13px] text-pass`,children:pe}),Z&&!Z.ok&&(0,F.jsxs)(`div`,{role:`alert`,className:`flex flex-col gap-2 rounded-[12px] border border-fail/30 bg-fail-soft px-4 py-4 text-sm`,children:[(0,F.jsxs)(`p`,{className:`m-0 font-semibold text-fail`,children:[Q?`Step ${Q} failed`:`The replay did not get through`,Ce&&(0,F.jsx)(`span`,{className:`font-normal text-ink-2`,children:` · before your last change`})]}),$&&(0,F.jsx)(`p`,{className:`m-0 font-medium text-ink [overflow-wrap:anywhere]`,children:$.text}),(0,F.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,F.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[$&&(0,F.jsxs)(T,{size:`sm`,onClick:()=>Oe(Q),children:[(0,F.jsx)(h,{"aria-hidden":`true`}),`Show`]}),$&&Q>1&&(0,F.jsxs)(T,{size:`sm`,onClick:()=>(Oe(Q),W({n:Q,mode:`edit`})),"data-tip":`Change the failed step: its control, text or timeout`,children:[(0,F.jsx)(s,{"aria-hidden":`true`}),`Change`]}),(0,F.jsxs)(T,{size:`sm`,variant:`ghost`,onClick:()=>xe(`${X?`The`:`DeskPilot: the`} last replay of ${x.workflow.path} failed${Q?` at step ${Q}`:``}. Read its report (${Z.dir}), tell me why, and offer a fix.`),children:[(0,F.jsx)(f,{"aria-hidden":`true`}),`Ask why`]})]})]}),Z&&Z.ok&&Z.heals>0&&!Z.healsAccepted&&(0,F.jsxs)(`div`,{role:`status`,className:`flex flex-wrap items-center gap-4 rounded-[12px] bg-accent-soft px-4 py-2 text-sm`,children:[(0,F.jsxs)(`span`,{className:`min-w-0 flex-[1_1_240px]`,children:[`The last replay found `,b(Z.heals,`moved control`),` and healed `,Z.heals===1?`it`:`them`,`: write the new locators into the workflow?`]}),(0,F.jsxs)(T,{size:`sm`,disabled:j,onClick:()=>void Y(()=>S.acceptHeals(Z.dir),`The healed locators are in the workflow.`),children:[(0,F.jsx)(a,{"aria-hidden":`true`}),`Accept`]})]}),(0,F.jsx)(re,{prefix:`dreview`,label:`This workflow`,className:`mb-0`,current:N,onPick:I,tabs:Ae.map(e=>({id:e.id,label:e.label,...e.n===void 0?{}:{n:e.n},...e.id===`run`&&Z?{icon:(0,F.jsx)(`span`,{"aria-label":Z.ok?`passed`:`failed`,className:v(`order-last size-2 rounded-full`,Z.ok?`bg-pass`:`bg-fail`)})}:{}}))}),(0,F.jsxs)(`div`,{role:`tabpanel`,id:`dreview-panel-${N}`,"aria-labelledby":`dreview-${N}`,className:`flex min-w-0 flex-col gap-4`,children:[N===`steps`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(te,{id:`dreview-step-search`,label:`Find a step`,value:L,onChange:ae}),(0,F.jsx)(D,{items:[{id:`all`,label:`All`,n:x.steps.length},{id:`checks`,label:`Checks`,n:we},...Te?[{id:`failed`,label:`Failed`,n:Te,alert:!0}]:[]],value:R,onChange:z})]}),we===0&&(0,F.jsx)(`p`,{className:`m-0 rounded-[10px] bg-warn-soft px-4 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.`}),De.length===0?(0,F.jsx)(`p`,{className:`m-0 rounded-[12px] card border px-4 py-4 text-sm text-muted`,children:`No step matches.`}):(0,F.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:De.map((e,t)=>{let n=Se.get(e.n),r=e.op.startsWith(`expect`),a=x.recorded?.shots[e.n],o=[...a&&x.recorded?[{label:`When recorded`,run:x.recorded.run,n:a,note:`The app after step ${e.n} as you recorded it.`}]:[],...n?.shot&&Z?[{label:`Last replay`,run:Z.dir,n:e.n,note:`The app after step ${e.n} on the last replay${Ce?`, before your last change`:``}.`}]:[]];return(0,F.jsxs)(`li`,{id:`dstep-${e.n}`,className:v(`flex scroll-mt-48 flex-col`,t>0&&`border-t border-line-soft`,n&&!n.ok&&`bg-fail-soft`),children:[(0,F.jsxs)(`div`,{className:`group flex min-h-11 items-start gap-4 px-4 py-2`,children:[(0,F.jsx)(`span`,{className:`w-6 flex-none pt-1 text-right font-mono text-[13px] text-muted tabular-nums`,children:e.n}),(0,F.jsx)(`span`,{className:`flex w-4 flex-none justify-center pt-1`,children:n?n.ok?(0,F.jsx)(c,{size:14,strokeWidth:2.5,"aria-label":`Passed on the last replay`,className:`text-pass`}):(0,F.jsx)(u,{size:14,strokeWidth:2.5,"aria-label":`Failed on the last replay`,className:`text-fail`}):Z?(0,F.jsx)(d,{size:14,"aria-label":`Not replayed`,className:`text-muted`}):r?(0,F.jsx)(i,{size:14,"aria-hidden":`true`,className:`text-pass`}):(0,F.jsx)(`span`,{"aria-hidden":`true`,className:`mt-1 size-1.5 rounded-full bg-line-strong`})}),(0,F.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,F.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[r&&(0,F.jsx)(w,{tone:`pass`,icon:!1,className:`min-h-5 px-2 text-[13px]`,children:`Check`}),e.op.startsWith(`wait`)&&(0,F.jsx)(w,{tone:`neutral`,icon:!1,className:`min-h-5 px-2 text-[13px]`,children:`Wait`}),(0,F.jsx)(`span`,{className:`min-w-0 text-[13px] text-ink [overflow-wrap:anywhere]`,children:e.text}),n?.healed&&(0,F.jsx)(w,{tone:`warn`,icon:!1,className:`min-h-5 px-2 text-[13px]`,children:`Healed`})]}),e.fields?.note&&(0,F.jsxs)(`span`,{className:`text-[13px] text-ink-2`,children:[`Note: `,e.fields.note]}),n&&!n.ok&&n.error&&(0,F.jsx)(`span`,{className:`line-clamp-2 text-[13px] text-fail [overflow-wrap:anywhere]`,"data-tip":n.error,children:n.error})]}),(0,F.jsxs)(`span`,{className:`relative flex flex-none items-center gap-1`,children:[(0,F.jsx)(T,{size:`icon`,variant:`icon`,disabled:j,"aria-haspopup":`dialog`,"aria-expanded":B===e.n,"aria-label":`Add a check or wait after step ${e.n}`,"data-tip":`Add a check or wait after step ${e.n}`,onClick:()=>V(B===e.n?null:e.n),className:`size-8`,children:(0,F.jsx)(l,{"aria-hidden":`true`})}),(0,F.jsx)(ie,{open:B===e.n,onClose:()=>V(null),label:`Add after step ${e.n}`,role:`dialog`,align:`end`,className:`w-[min(360px,calc(100vw-48px))]`,children:(0,F.jsx)(ce,{step:e,onAdd:t=>{V(null),Y(()=>se({workflow:x.workflow.path,step:e.n,action:`insert`,...t}),`Added after step ${e.n}.`)}})}),o.length>0&&(0,F.jsx)(T,{size:`icon`,variant:`icon`,"aria-label":`See the app after step ${e.n}`,"aria-expanded":H===e.n,"data-tip":`See the app after step ${e.n}`,onClick:()=>le(H===e.n?null:e.n),className:`size-8`,children:(0,F.jsx)(h,{"aria-hidden":`true`})}),(0,F.jsx)(T,{size:`icon`,variant:`icon`,"aria-label":`Change step ${e.n}`,"data-tip":`Change step ${e.n}`,onClick:()=>W({n:e.n,mode:`edit`}),className:`size-8`,children:(0,F.jsx)(s,{"aria-hidden":`true`})}),e.n>1&&(0,F.jsx)(T,{size:`icon`,variant:`icon`,"aria-label":`Drop step ${e.n}`,"data-tip":`Drop step ${e.n}`,onClick:()=>W({n:e.n,mode:`remove`}),className:`size-8 hover:text-fail`,children:(0,F.jsx)(g,{"aria-hidden":`true`})})]})]}),U&&U.n===e.n&&(0,F.jsx)(`div`,{className:`pr-4`,children:(0,F.jsx)(oe,{workflow:x.workflow.path,step:e,mode:U.mode,onCancel:()=>W(null),onDone:()=>{me(U.mode===`remove`?`Step ${e.n} dropped.`:`Step ${e.n} changed.`),W(null),K()}},`${e.n}-${U.mode}`)}),H===e.n&&o.length>0&&(0,F.jsx)(ue,{pictures:o,step:e.n,busy:j,onPick:t=>void Y(()=>se({workflow:x.workflow.path,step:e.n,action:`insert`,kind:t.text?`check_text`:`check_present`,target:t.target,...t.text?{text:t.text}:{}}),t.text?`Added after step ${e.n}: a check that ${t.target.name||t.target.automation_id} shows "${t.text}".`:`Added after step ${e.n}: a check that ${t.target.name||t.target.automation_id} is there.`)})]},`${e.n}-${e.text}`)})})]}),N===`data`&&(x.values.length===0?(0,F.jsx)(E,{className:`py-4`,children:`Nothing is typed or chosen in this workflow, so it has no test data.`}):(0,F.jsxs)(F.Fragment,{children:[(0,F.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,F.jsx)(`ul`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-0`,children:x.values.map(e=>(0,F.jsx)(de,{v:e,secrets:x.secrets,mobile:X,busy:j,onSave:(t,n,r)=>void Y(()=>se({workflow:x.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))})]})),N===`run`&&(0,F.jsx)(fe,{view:x,job:G,rows:X?{...ge,requests:[]}:ge,heal:ve,busy:j||J,onRun:ke})]})]})}export{L as n,I as r,U as t};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{At as t,Fn as n,Hr as r,I as i,Lr as a,Mr as o,Nn as s,O as c,Rn as l,Rr as u,bn as d,gn as f,l as p,r as m,ut as h,xr as g}from"./route-Dg53WdFu.js";import{t as _}from"./jsx-runtime-LKYXHABd.js";import{A as v,Z as y,a as ee,j as b,n as x,nt as S,t as C}from"./input-D7iHeNXz.js";import{a as w,d as T,i as te,o as E,t as D}from"./filters-Culzq1j1.js";import{Bn as O,D as k,Gt as A,Vn as ne,Wt as re,g as j,un as M,wn as ie}from"./index-DeYZJBWf.js";import{a as N}from"./dataParts-Ds4Gjeep.js";var P=e(r(),1),F=_();function I(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 L({value:e,onChange:n,onPicked:r,onError:i,className:a}){let[o,s]=(0,P.useState)(!1),c=async()=>{s(!0),i(``);try{let e=await S.browse();`path`in e?(n(e.path),r?.(e.path,e.name)):`unavailable`in e&&i(e.unavailable)}catch(e){i(e.message)}finally{s(!1)}};return(0,F.jsxs)(`div`,{className:v(`flex min-w-0 gap-2`,a),children:[(0,F.jsx)(C,{"aria-label":`App's path`,value:e,spellCheck:!1,placeholder:`C:\\Program Files\\Contoso\\Billing.exe`,onChange:e=>n(e.target.value),className:`min-w-0 flex-1 font-mono text-[13px]`}),(0,F.jsxs)(T,{type:`button`,disabled:o,onClick:()=>void c(),"data-tip":`Choose the app's .exe on this computer`,children:[(0,F.jsx)(t,{"aria-hidden":`true`}),o?`Choosing…`:`Browse…`]})]})}var ae={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 R({p:e}){return(0,F.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,F.jsx)(`ul`,{className:`m-0 flex flex-col gap-1 pl-6 text-[13px] text-ink-2`,children:e.summary.map((e,t)=>(0,F.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:e},t))}),(0,F.jsx)(`pre`,{className:`m-0 max-h-[200px] overflow-auto rounded-[10px] bg-surface-muted p-2 font-mono text-[13px] leading-relaxed whitespace-pre-wrap`,children:e.diff.map((e,t)=>(0,F.jsx)(`span`,{className:v(`block`,e.startsWith(`+`)?`text-pass`:e.startsWith(`-`)?`text-fail`:`text-muted`),children:e},t))})]})}function z({label:e,children:t}){return(0,F.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-[13px] font-medium`,children:[e,t]})}function oe({workflow:e,step:t,mode:n,onDone:r,onCancel:i}){let a=ae[t.op]??[`note`],o=t.fields??{},[l,d]=(0,P.useState)({automation_id:o.target?.automation_id??``,name:o.target?.name??``,control_type:o.target?.control_type??``}),[f,p]=(0,P.useState)(o.text??``),[m,h]=(0,P.useState)(o.value??``),[_,v]=(0,P.useState)(o.keys??``),[y,ee]=(0,P.useState)(o.seconds===void 0?``:String(o.seconds)),[b,x]=(0,P.useState)(o.timeout===void 0?``:String(o.timeout)),[w,te]=(0,P.useState)(o.note??``),[E,D]=(0,P.useState)(null),[O,k]=(0,P.useState)(``),[A,ne]=(0,P.useState)(!1),re=()=>{let e={};return a.includes(`target`)&&(l.automation_id!==(o.target?.automation_id??``)||l.name!==(o.target?.name??``)||l.control_type!==(o.target?.control_type??``))&&(e.target=l),a.includes(`text`)&&f!==(o.text??``)&&(e.text=f),a.includes(`value`)&&m!==(o.value??``)&&(e.value=m),a.includes(`keys`)&&_!==(o.keys??``)&&(e.keys=_),a.includes(`seconds`)&&y!==(o.seconds===void 0?``:String(o.seconds))&&(e.seconds=Number(y)),a.includes(`timeout`)&&b!==(o.timeout===void 0?``:String(o.timeout))&&b.trim()&&(e.timeout=Number(b)),a.includes(`note`)&&w!==(o.note??``)&&(e.note=w),e},j=async i=>{ne(!0),k(``);try{let a=await S.editStep({workflow:e,step:t.n,action:n,...n===`edit`?{fields:re()}:{},...i?{version:i}:{}});a.written?r():D(a)}catch(e){k(e.message)}finally{ne(!1)}};(0,P.useEffect)(()=>{n===`remove`&&j()},[]);let M=()=>D(null);return(0,F.jsxs)(`div`,{className:`mb-2 ml-10 flex flex-col gap-4 rounded-[12px] bg-surface-muted p-4`,children:[n===`edit`&&!E&&(0,F.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,180px),1fr))] gap-2`,children:[a.includes(`target`)&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(z,{label:`Control's name`,children:(0,F.jsx)(C,{size:`sm`,value:l.name,maxLength:300,onChange:e=>(d({...l,name:e.target.value}),M()),className:`bg-bg`})}),(0,F.jsx)(z,{label:`Automation id`,children:(0,F.jsx)(C,{size:`sm`,value:l.automation_id,maxLength:300,spellCheck:!1,onChange:e=>(d({...l,automation_id:e.target.value}),M()),className:`bg-bg font-mono text-[13px]`})}),(0,F.jsx)(z,{label:`Control type`,children:(0,F.jsx)(C,{size:`sm`,value:l.control_type,maxLength:60,spellCheck:!1,placeholder:`Button`,onChange:e=>(d({...l,control_type:e.target.value}),M()),className:`bg-bg`})})]}),a.includes(`text`)&&(0,F.jsx)(z,{label:t.op===`type`?`Text to type`:`Text it shows`,children:(0,F.jsx)(C,{size:`sm`,value:f,maxLength:500,onChange:e=>p(e.target.value),className:`bg-bg`})}),a.includes(`value`)&&(0,F.jsx)(z,{label:`Item to choose`,children:(0,F.jsx)(C,{size:`sm`,value:m,maxLength:500,onChange:e=>h(e.target.value),className:`bg-bg`})}),a.includes(`keys`)&&(0,F.jsx)(z,{label:`Keys`,children:(0,F.jsx)(C,{size:`sm`,value:_,maxLength:100,spellCheck:!1,placeholder:`ctrl+s`,onChange:e=>v(e.target.value),className:`bg-bg font-mono text-[13px]`})}),a.includes(`seconds`)&&(0,F.jsx)(z,{label:`Wait (seconds)`,children:(0,F.jsx)(C,{size:`sm`,type:`number`,min:0,max:600,value:y,onChange:e=>ee(e.target.value),className:`bg-bg`})}),a.includes(`timeout`)&&(0,F.jsx)(z,{label:`Timeout (seconds)`,children:(0,F.jsx)(C,{size:`sm`,type:`number`,min:0,max:600,value:b,placeholder:`default`,onChange:e=>x(e.target.value),className:`bg-bg`})}),a.includes(`note`)&&(0,F.jsx)(z,{label:`Note`,children:(0,F.jsx)(C,{size:`sm`,value:w,maxLength:200,onChange:e=>te(e.target.value),className:`bg-bg`})})]}),n===`remove`&&!E&&!O&&(0,F.jsx)(`p`,{role:`status`,className:`m-0 text-[13px] text-muted`,children:`Working out the change…`}),E&&(0,F.jsx)(R,{p:E}),O&&(0,F.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[10px] bg-fail-soft px-4 py-2 text-[13px] text-fail [overflow-wrap:anywhere]`,children:O}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[E?(0,F.jsxs)(T,{size:`sm`,variant:n===`remove`?`destructive`:`primary`,disabled:A,onClick:()=>void j(E.version),children:[n===`remove`?(0,F.jsx)(g,{"aria-hidden":`true`}):(0,F.jsx)(c,{"aria-hidden":`true`}),A?`Saving…`:n===`remove`?`Delete step ${t.n}`:`Save the change`]}):n===`edit`&&(0,F.jsx)(T,{size:`sm`,variant:`primary`,disabled:A||!Object.keys(re()).length,onClick:()=>void j(),children:A?`Checking…`:`Preview the change`}),E&&n===`edit`&&(0,F.jsxs)(T,{size:`sm`,onClick:()=>D(null),children:[(0,F.jsx)(s,{"aria-hidden":`true`}),`Change it more`]}),(0,F.jsxs)(T,{size:`sm`,variant:`ghost`,onClick:i,children:[(0,F.jsx)(u,{"aria-hidden":`true`}),`Cancel`]})]})]})}var B=[{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.`}],V={replay:[`Replaying the workflow`,`Replayed the workflow`,`working`],validate:[`Checking the workflow`,`Checked the workflow`,`searching`]};async function se(e){let t=await S.editStep(e);await S.editStep({...e,version:t.version})}var H=[{id:`check_text`,label:`Check a control shows a text`,control:!0,text:`need`},{id:`check_present`,label:`Check a control is there`,control:!0},{id:`wait_for`,label:`Wait for a control`,control:!0,text:`may`},{id:`wait_gone`,label:`Wait until a control is gone`,control:!0},{id:`wait`,label:`Wait some seconds`,control:!1},{id:`keys`,label:`Press keys`,control:!1}];function ce({step:e,onAdd:t}){let[n,r]=(0,P.useState)(`check_text`),i=e.fields?.target,[a,o]=(0,P.useState)({name:i?.name??``,automation_id:i?.automation_id??``,control_type:i?.control_type??``}),[s,c]=(0,P.useState)(``),[u,d]=(0,P.useState)(`2`),[f,p]=(0,P.useState)(``),m=H.find(e=>e.id===n),h=m.control?!!(a.name.trim()||a.automation_id.trim())&&(m.text!==`need`||!!s.trim()):n===`wait`?Number(u)>0:!!f.trim();return(0,F.jsxs)(`form`,{className:`flex flex-col gap-2 p-4`,onSubmit:e=>{e.preventDefault(),h&&t({kind:n,...m.control?{target:a}:{},...m.text&&s.trim()?{text:s}:{},...n===`wait`?{seconds:Number(u)}:{},...n===`keys`?{keys:f}:{}})},children:[(0,F.jsxs)(`p`,{className:`m-0 text-[13px] font-semibold`,children:[`After step `,e.n]}),(0,F.jsx)(x,{size:`sm`,"aria-label":`What to add`,value:n,onChange:e=>r(e.target.value),children:H.map(e=>(0,F.jsx)(`option`,{value:e.id,children:e.label},e.id))}),m.control&&(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,F.jsxs)(`label`,{className:`flex flex-col gap-1 text-[13px] font-medium`,children:[`Control's name`,(0,F.jsx)(C,{size:`sm`,value:a.name,maxLength:300,onChange:e=>o({...a,name:e.target.value})})]}),(0,F.jsxs)(`label`,{className:`flex flex-col gap-1 text-[13px] font-medium`,children:[`Automation id`,(0,F.jsx)(C,{size:`sm`,value:a.automation_id,maxLength:300,spellCheck:!1,onChange:e=>o({...a,automation_id:e.target.value}),className:`font-mono text-[13px]`})]})]}),m.text&&(0,F.jsxs)(`label`,{className:`flex flex-col gap-1 text-[13px] font-medium`,children:[m.text===`need`?`The text it shows`:`Showing the text (optional)`,(0,F.jsx)(C,{size:`sm`,value:s,maxLength:500,placeholder:`Invoice saved`,onChange:e=>c(e.target.value)})]}),n===`wait`&&(0,F.jsxs)(`label`,{className:`flex flex-col gap-1 text-[13px] font-medium`,children:[`Seconds`,(0,F.jsx)(C,{size:`sm`,type:`number`,min:1,max:600,value:u,onChange:e=>d(e.target.value)})]}),n===`keys`&&(0,F.jsxs)(`label`,{className:`flex flex-col gap-1 text-[13px] font-medium`,children:[`Keys`,(0,F.jsx)(C,{size:`sm`,value:f,maxLength:100,spellCheck:!1,placeholder:`ctrl+s`,onChange:e=>p(e.target.value),className:`font-mono text-[13px]`})]}),(0,F.jsx)(`p`,{className:`m-0 text-[13px] 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,F.jsxs)(T,{type:`submit`,size:`sm`,variant:`primary`,disabled:!h,className:`self-start`,children:[(0,F.jsx)(l,{"aria-hidden":`true`}),`Add`]})]})}var le=e=>e.name||e.automation_id||`the control`;function ue({pictures:e,step:t,busy:n,onPick:r}){let[i,a]=(0,P.useState)(0),o=e[Math.min(i,e.length-1)],[s,c]=(0,P.useState)(``),[l,u]=(0,P.useState)(``),[d,f]=(0,P.useState)(null);(0,P.useEffect)(()=>{let e=!1;return c(``),u(``),f(null),S.shot(o.run,o.n).then(t=>!e&&c(t),t=>!e&&u(t.message)),S.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,h]=(0,P.useState)(!1),g=d&&d.w>0?d.controls.toSorted((e,t)=>t.w*t.h-e.w*e.h):[];return(0,F.jsxs)(`div`,{className:`flex flex-col gap-2 pr-4 pb-4 pl-4 sm:pl-20`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.length>1&&(0,F.jsx)(A,{label:`Pictures of step ${t}`,value:String(i),onChange:e=>a(Number(e)),options:e.map((e,t)=>({id:String(t),label:e.label}))}),(0,F.jsxs)(`p`,{className:`m-0 text-[13px] text-muted`,children:[o.note,g.length>0?` Click a control to check that it shows its text, or that it is there.`:``]})]}),l&&(0,F.jsx)(`p`,{className:`m-0 text-sm text-fail`,children:l}),!s&&!l&&(0,F.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Loading the picture…`}),s&&(0,F.jsxs)(`div`,{className:v(`relative w-full overflow-hidden rounded-[10px] border border-line-soft`,m?`max-w-[360px]`:`max-w-[720px]`),style:g.length?{aspectRatio:`${d.w} / ${d.h}`}:void 0,children:[(0,F.jsx)(`img`,{src:s,alt:`The app after step ${t}, ${o.label.toLowerCase()}`,onLoad:e=>h(e.currentTarget.naturalHeight>e.currentTarget.naturalWidth),className:g.length?`absolute inset-0 size-full object-fill`:`block w-full`}),g.map((e,t)=>{let i=e.text?`Check ${le(e)} shows "${e.text}"`:`Check ${le(e)} is there`;return(0,F.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 de({v:e,secrets:t,onSave:n,busy:r,mobile:i=!1}){let[a,o]=(0,P.useState)(e.as),[s,l]=(0,P.useState)(e.name??``),[u,d]=(0,P.useState)(e.value??``);(0,P.useEffect)(()=>{o(e.as),l(e.name??``),d(e.value??``)},[e]);let f=B.filter(t=>e.op===`type`||t.id!==`secret`),p=a!==e.as||s!==(e.name??``)||u!==(e.value??``),m=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,F.jsxs)(`li`,{className:`flex flex-wrap items-start gap-x-4 gap-y-2 border-t border-line-soft px-4 py-2 first:border-t-0`,children:[(0,F.jsx)(`span`,{className:`w-6 flex-none pt-2 text-right font-mono text-[13px] text-muted tabular-nums`,children:e.n}),(0,F.jsxs)(`span`,{className:`flex min-w-0 flex-[1_1_220px] flex-col pt-2`,children:[(0,F.jsx)(`span`,{className:`text-[13px] text-ink [overflow-wrap:anywhere]`,children:e.line}),(0,F.jsx)(`span`,{className:`text-[13px] text-ink-2`,children:B.find(e=>e.id===a)?.note})]}),(0,F.jsxs)(`span`,{className:`flex flex-[1_1_360px] flex-wrap items-center gap-2`,children:[(0,F.jsx)(x,{"aria-label":`Where the value of step ${e.n} comes from`,value:a,disabled:r,onChange:e=>o(e.target.value),className:`w-[150px] flex-none`,children:f.map(e=>(0,F.jsx)(`option`,{value:e.id,children:e.label},e.id))}),a!==`typed`&&(0,F.jsx)(C,{"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=>l(a===`secret`?e.target.value.toUpperCase():e.target.value),className:`w-[170px] flex-none font-mono text-[13px]`}),a!==`secret`&&(0,F.jsx)(C,{"aria-label":a===`data`?`Its value`:`The value`,value:u,maxLength:500,onChange:e=>d(e.target.value),className:`min-w-[140px] flex-1`}),a===`secret`&&!t.includes(s)&&s&&(0,F.jsxs)(`span`,{className:`text-[13px] text-warn`,children:[`Not in `,i?`mobile.secrets`:`desktop.secrets`,` yet`]}),(0,F.jsxs)(T,{size:`sm`,variant:`primary`,disabled:r||!p||!m,onClick:()=>n(a,a===`typed`?void 0:s,a===`secret`?void 0:u),children:[(0,F.jsx)(c,{"aria-hidden":`true`}),`Save`]})]}),(0,F.jsx)(`datalist`,{id:`desktop-secrets`,children:t.map(e=>(0,F.jsx)(`option`,{value:e},e))})]})}function fe({view:e,job:t,rows:r,onRun:i,busy:a,heal:o}){let[s,c]=(0,P.useState)(()=>Object.fromEntries(e.variables.map(e=>[e.name,e.value]))),[l,u]=(0,P.useState)(``),[d,f]=(0,P.useState)(o),[p,m]=(0,P.useState)(!1),h=e.lastRun,g=l.startsWith(`file:`)?{file:l.slice(5)}:l.startsWith(`request:`)?{request:l.slice(8)}:void 0,_=t&&t.kind===`replay`&&t.target===e.workflow.path;return(0,F.jsxs)(F.Fragment,{children:[(0,F.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,F.jsxs)(`form`,{className:`flex flex-col gap-4 rounded-[12px] card border p-4`,onSubmit:e=>{e.preventDefault(),i({variables:s,...g?{rows:g}:{},heal:d,updateBaselines:p})},children:[e.variables.length>0&&(0,F.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,180px),1fr))] gap-4`,children:e.variables.map(e=>(0,F.jsxs)(`label`,{className:`flex flex-col gap-1 text-[13px] font-medium text-ink-2`,children:[e.name,(0,F.jsx)(C,{value:s[e.name]??``,onChange:t=>c({...s,[e.name]:t.target.value})})]},e.name))}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-end gap-4`,children:[(0,F.jsxs)(`label`,{className:`flex min-w-[220px] flex-col gap-1 text-[13px] font-medium text-ink-2`,children:[`Test data`,(0,F.jsxs)(x,{value:l,onChange:e=>u(e.target.value),children:[(0,F.jsx)(`option`,{value:``,children:`Once, with the values above`}),r.files.map(e=>(0,F.jsxs)(`option`,{value:`file:${e}`,children:[`Each row of `,e]},e)),r.requests.map(e=>(0,F.jsxs)(`option`,{value:`request:${e}`,children:[`Each row of request `,e]},e))]})]}),(0,F.jsxs)(`label`,{className:`flex min-h-10 items-center gap-2 text-sm text-ink-2`,children:[(0,F.jsx)(M,{checked:d,onChange:f,label:`Heal a step whose control moved`}),`Heal a moved control`]}),(0,F.jsxs)(`label`,{className:`flex min-h-10 items-center gap-2 text-sm text-ink-2`,children:[(0,F.jsx)(M,{checked:p,onChange:m,label:`Take new image baselines`}),`New image baselines`]}),(0,F.jsx)(`span`,{className:`flex-1`}),(0,F.jsxs)(T,{type:`submit`,variant:`primary`,disabled:a,children:[(0,F.jsx)(n,{"aria-hidden":`true`}),`Replay`]})]})]}),_&&(0,F.jsx)(N,{job:t,onStop:()=>void S.stop(),words:V}),h?(0,F.jsxs)(`section`,{"aria-labelledby":`desktop-last-run`,className:`flex flex-col gap-2`,children:[(0,F.jsx)(`h3`,{id:`desktop-last-run`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Last replay`}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 rounded-[12px] card border px-4 py-2 text-sm`,children:[(0,F.jsx)(w,{tone:h.ok?`pass`:`fail`,children:h.many?`${h.many.passed} of ${h.many.total} passed`:h.ok?`Passed`:`Failed`}),(0,F.jsxs)(`span`,{className:`text-muted`,children:[j(h.at),` · `,b(e.replays,`replay`),` in all`]}),h.failed&&(0,F.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,F.jsx)(`span`,{className:`flex-1`}),h.report&&(0,F.jsx)(k,{path:h.report,children:`Report`})]})]}):(0,F.jsx)(E,{className:`py-4`,children:`Not replayed yet.`})]})}function U({workflow:e,onClose:t,backLabel:r=`Back`,notices:_}){let[x,C]=(0,P.useState)(null),[k,A]=(0,P.useState)(``),[j,M]=(0,P.useState)(!1),[N,I]=(0,P.useState)(`steps`),[L,ae]=(0,P.useState)(``),[R,z]=(0,P.useState)(`all`),[B,V]=(0,P.useState)(null),[H,le]=(0,P.useState)(null),[U,W]=(0,P.useState)(null),[pe,me]=(0,P.useState)(``),[G,he]=(0,P.useState)(null),[ge,_e]=(0,P.useState)({files:[],requests:[]}),[ve,ye]=(0,P.useState)(!0),K=(0,P.useCallback)(()=>{S.review(e).then(e=>{C(e),A(``)},e=>A(e.message))},[e]);(0,P.useEffect)(K,[K]);let q=(0,P.useCallback)(()=>{S.view().then(e=>{he(e.job),_e(e.rows),ye(e.heal)},()=>{})},[]);(0,P.useEffect)(q,[q]);let J=!!G?.running;(0,P.useEffect)(()=>{if(!J)return;let e=ne(q,1e3);return()=>O(e)},[J,q]);let be=G&&!G.running?G.endedAt:``;(0,P.useEffect)(()=>{be&&K()},[be,K]);let Y=async(e,t)=>{M(!0),A(``),me(``);try{await e(),K(),t&&me(t)}catch(e){A(e.message)}finally{M(!1)}},xe=e=>void y.start(e,{}).then(({id:e})=>location.hash=m(`chats`,e),e=>A(e.message));if(!x)return k?(0,F.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-4 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:k}):(0,F.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Opening the workflow…`});let X=x.workflow.kind===`mobile`,Z=x.lastRun,Se=new Map((Z?.results??[]).map(e=>[e.n,e])),Ce=!!Z&&Date.parse(x.workflow.modified)>Date.parse(Z.at),we=x.steps.filter(e=>e.op.startsWith(`expect`)).length,Q=Z&&!Z.ok?Z.failed?.index??0:0,$=Q?x.steps[Q-1]:void 0,Te=(Z?.results??[]).filter(e=>!e.ok).length,Ee=L.toLowerCase().split(/\s+/).filter(Boolean),De=x.steps.filter(e=>Ee.every(t=>`${e.n} ${e.text} ${e.fields?.note||``}`.toLowerCase().includes(t))&&(R===`all`||(R===`checks`?e.op.startsWith(`expect`):Se.get(e.n)?.ok===!1))),Oe=e=>{I(`steps`),z(`all`),ae(``),requestAnimationFrame(()=>document.getElementById(`dstep-${e}`)?.scrollIntoView({block:`center`,behavior:ee()}))},ke=e=>void Y(async()=>{await S.replay({workflow:x.workflow.path,...e}),q()},X?`Replaying on the device: a device cloud can take a minute or two to start it.`:`Replaying: the app opens on this computer.`),Ae=[{id:`steps`,label:`Steps`,n:x.steps.length},{id:`data`,label:`Test data`,n:x.values.length},{id:`run`,label:`Last run`}];return(0,F.jsxs)(`section`,{"aria-labelledby":`dreview-title`,className:`flex min-w-0 flex-col gap-4`,children:[(0,F.jsxs)(`div`,{className:`sticky top-0 z-20 -mx-1 flex flex-col gap-4 border-b border-line bg-bg px-1 py-4`,children:[t&&(0,F.jsx)(`div`,{children:(0,F.jsxs)(T,{size:`sm`,variant:`ghost`,onClick:t,className:`-ml-2 text-ink-2`,children:[(0,F.jsx)(p,{"aria-hidden":`true`}),r]})}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-4`,children:[(0,F.jsxs)(`div`,{className:`flex min-w-0 flex-[1_1_320px] flex-col gap-1`,children:[(0,F.jsx)(`h2`,{id:`dreview-title`,className:`m-0 min-w-0 truncate text-lg font-semibold`,"data-tip":x.workflow.name,children:x.workflow.name}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[13px] text-muted`,children:[(0,F.jsxs)(`span`,{children:[x.workflow.app||`no app`,` · `,b(x.steps.length,`step`),` · `,b(we,`check`)]}),J&&G?.target===x.workflow.path?(0,F.jsx)(w,{tone:`running`,children:`Replaying…`}):Z?(0,F.jsx)(w,{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,F.jsx)(w,{tone:`neutral`,icon:!1,children:`Not replayed yet`}),Ce&&(0,F.jsx)(`span`,{children:`· you changed it since`})]})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsxs)(T,{onClick:()=>xe(`${X?`Look at the mobile workflow`:`DeskPilot: look at the desktop workflow`} ${x.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":X?`Ask the agent to improve it`:`Ask DeskPilot to improve it`,children:[(0,F.jsx)(o,{"aria-hidden":`true`}),`Improve`]}),(0,F.jsxs)(T,{variant:`primary`,disabled:J,onClick:()=>I(`run`),"data-tip":J?`A replay is going`:`Replay it with no model`,children:[(0,F.jsx)(n,{"aria-hidden":`true`}),`Replay`]})]})]})]}),_,k&&(0,F.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-4 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:k}),pe&&(0,F.jsx)(`p`,{role:`status`,className:`m-0 rounded-[10px] bg-pass-soft px-4 py-2 text-[13px] text-pass`,children:pe}),Z&&!Z.ok&&(0,F.jsxs)(`div`,{role:`alert`,className:`flex flex-col gap-2 rounded-[12px] border border-fail/30 bg-fail-soft px-4 py-4 text-sm`,children:[(0,F.jsxs)(`p`,{className:`m-0 font-semibold text-fail`,children:[Q?`Step ${Q} failed`:`The replay did not get through`,Ce&&(0,F.jsx)(`span`,{className:`font-normal text-ink-2`,children:` · before your last change`})]}),$&&(0,F.jsx)(`p`,{className:`m-0 font-medium text-ink [overflow-wrap:anywhere]`,children:$.text}),(0,F.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,F.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[$&&(0,F.jsxs)(T,{size:`sm`,onClick:()=>Oe(Q),children:[(0,F.jsx)(h,{"aria-hidden":`true`}),`Show`]}),$&&Q>1&&(0,F.jsxs)(T,{size:`sm`,onClick:()=>(Oe(Q),W({n:Q,mode:`edit`})),"data-tip":`Change the failed step: its control, text or timeout`,children:[(0,F.jsx)(s,{"aria-hidden":`true`}),`Change`]}),(0,F.jsxs)(T,{size:`sm`,variant:`ghost`,onClick:()=>xe(`${X?`The`:`DeskPilot: the`} last replay of ${x.workflow.path} failed${Q?` at step ${Q}`:``}. Read its report (${Z.dir}), tell me why, and offer a fix.`),children:[(0,F.jsx)(f,{"aria-hidden":`true`}),`Ask why`]})]})]}),Z&&Z.ok&&Z.heals>0&&!Z.healsAccepted&&(0,F.jsxs)(`div`,{role:`status`,className:`flex flex-wrap items-center gap-4 rounded-[12px] bg-accent-soft px-4 py-2 text-sm`,children:[(0,F.jsxs)(`span`,{className:`min-w-0 flex-[1_1_240px]`,children:[`The last replay found `,b(Z.heals,`moved control`),` and healed `,Z.heals===1?`it`:`them`,`: write the new locators into the workflow?`]}),(0,F.jsxs)(T,{size:`sm`,disabled:j,onClick:()=>void Y(()=>S.acceptHeals(Z.dir),`The healed locators are in the workflow.`),children:[(0,F.jsx)(a,{"aria-hidden":`true`}),`Accept`]})]}),(0,F.jsx)(re,{prefix:`dreview`,label:`This workflow`,className:`mb-0`,current:N,onPick:I,tabs:Ae.map(e=>({id:e.id,label:e.label,...e.n===void 0?{}:{n:e.n},...e.id===`run`&&Z?{icon:(0,F.jsx)(`span`,{"aria-label":Z.ok?`passed`:`failed`,className:v(`order-last size-2 rounded-full`,Z.ok?`bg-pass`:`bg-fail`)})}:{}}))}),(0,F.jsxs)(`div`,{role:`tabpanel`,id:`dreview-panel-${N}`,"aria-labelledby":`dreview-${N}`,className:`flex min-w-0 flex-col gap-4`,children:[N===`steps`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(te,{id:`dreview-step-search`,label:`Find a step`,value:L,onChange:ae}),(0,F.jsx)(D,{items:[{id:`all`,label:`All`,n:x.steps.length},{id:`checks`,label:`Checks`,n:we},...Te?[{id:`failed`,label:`Failed`,n:Te,alert:!0}]:[]],value:R,onChange:z})]}),we===0&&(0,F.jsx)(`p`,{className:`m-0 rounded-[10px] bg-warn-soft px-4 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.`}),De.length===0?(0,F.jsx)(`p`,{className:`m-0 rounded-[12px] card border px-4 py-4 text-sm text-muted`,children:`No step matches.`}):(0,F.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:De.map((e,t)=>{let n=Se.get(e.n),r=e.op.startsWith(`expect`),a=x.recorded?.shots[e.n],o=[...a&&x.recorded?[{label:`When recorded`,run:x.recorded.run,n:a,note:`The app after step ${e.n} as you recorded it.`}]:[],...n?.shot&&Z?[{label:`Last replay`,run:Z.dir,n:e.n,note:`The app after step ${e.n} on the last replay${Ce?`, before your last change`:``}.`}]:[]];return(0,F.jsxs)(`li`,{id:`dstep-${e.n}`,className:v(`flex scroll-mt-48 flex-col`,t>0&&`border-t border-line-soft`,n&&!n.ok&&`bg-fail-soft`),children:[(0,F.jsxs)(`div`,{className:`group flex min-h-11 items-start gap-4 px-4 py-2`,children:[(0,F.jsx)(`span`,{className:`w-6 flex-none pt-1 text-right font-mono text-[13px] text-muted tabular-nums`,children:e.n}),(0,F.jsx)(`span`,{className:`flex w-4 flex-none justify-center pt-1`,children:n?n.ok?(0,F.jsx)(c,{size:14,strokeWidth:2.5,"aria-label":`Passed on the last replay`,className:`text-pass`}):(0,F.jsx)(u,{size:14,strokeWidth:2.5,"aria-label":`Failed on the last replay`,className:`text-fail`}):Z?(0,F.jsx)(d,{size:14,"aria-label":`Not replayed`,className:`text-muted`}):r?(0,F.jsx)(i,{size:14,"aria-hidden":`true`,className:`text-pass`}):(0,F.jsx)(`span`,{"aria-hidden":`true`,className:`mt-1 size-1.5 rounded-full bg-line-strong`})}),(0,F.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,F.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[r&&(0,F.jsx)(w,{tone:`pass`,icon:!1,className:`min-h-5 px-2 text-[13px]`,children:`Check`}),e.op.startsWith(`wait`)&&(0,F.jsx)(w,{tone:`neutral`,icon:!1,className:`min-h-5 px-2 text-[13px]`,children:`Wait`}),(0,F.jsx)(`span`,{className:`min-w-0 text-[13px] text-ink [overflow-wrap:anywhere]`,children:e.text}),n?.healed&&(0,F.jsx)(w,{tone:`warn`,icon:!1,className:`min-h-5 px-2 text-[13px]`,children:`Healed`})]}),e.fields?.note&&(0,F.jsxs)(`span`,{className:`text-[13px] text-ink-2`,children:[`Note: `,e.fields.note]}),n&&!n.ok&&n.error&&(0,F.jsx)(`span`,{className:`line-clamp-2 text-[13px] text-fail [overflow-wrap:anywhere]`,"data-tip":n.error,children:n.error})]}),(0,F.jsxs)(`span`,{className:`relative flex flex-none items-center gap-1`,children:[(0,F.jsx)(T,{size:`icon`,variant:`icon`,disabled:j,"aria-haspopup":`dialog`,"aria-expanded":B===e.n,"aria-label":`Add a check or wait after step ${e.n}`,"data-tip":`Add a check or wait after step ${e.n}`,onClick:()=>V(B===e.n?null:e.n),className:`size-8`,children:(0,F.jsx)(l,{"aria-hidden":`true`})}),(0,F.jsx)(ie,{open:B===e.n,onClose:()=>V(null),label:`Add after step ${e.n}`,role:`dialog`,align:`end`,className:`w-[min(360px,calc(100vw-48px))]`,children:(0,F.jsx)(ce,{step:e,onAdd:t=>{V(null),Y(()=>se({workflow:x.workflow.path,step:e.n,action:`insert`,...t}),`Added after step ${e.n}.`)}})}),o.length>0&&(0,F.jsx)(T,{size:`icon`,variant:`icon`,"aria-label":`See the app after step ${e.n}`,"aria-expanded":H===e.n,"data-tip":`See the app after step ${e.n}`,onClick:()=>le(H===e.n?null:e.n),className:`size-8`,children:(0,F.jsx)(h,{"aria-hidden":`true`})}),(0,F.jsx)(T,{size:`icon`,variant:`icon`,"aria-label":`Change step ${e.n}`,"data-tip":`Change step ${e.n}`,onClick:()=>W({n:e.n,mode:`edit`}),className:`size-8`,children:(0,F.jsx)(s,{"aria-hidden":`true`})}),e.n>1&&(0,F.jsx)(T,{size:`icon`,variant:`icon`,"aria-label":`Drop step ${e.n}`,"data-tip":`Drop step ${e.n}`,onClick:()=>W({n:e.n,mode:`remove`}),className:`size-8 hover:text-fail`,children:(0,F.jsx)(g,{"aria-hidden":`true`})})]})]}),U&&U.n===e.n&&(0,F.jsx)(`div`,{className:`pr-4`,children:(0,F.jsx)(oe,{workflow:x.workflow.path,step:e,mode:U.mode,onCancel:()=>W(null),onDone:()=>{me(U.mode===`remove`?`Step ${e.n} dropped.`:`Step ${e.n} changed.`),W(null),K()}},`${e.n}-${U.mode}`)}),H===e.n&&o.length>0&&(0,F.jsx)(ue,{pictures:o,step:e.n,busy:j,onPick:t=>void Y(()=>se({workflow:x.workflow.path,step:e.n,action:`insert`,kind:t.text?`check_text`:`check_present`,target:t.target,...t.text?{text:t.text}:{}}),t.text?`Added after step ${e.n}: a check that ${t.target.name||t.target.automation_id} shows "${t.text}".`:`Added after step ${e.n}: a check that ${t.target.name||t.target.automation_id} is there.`)})]},`${e.n}-${e.text}`)})})]}),N===`data`&&(x.values.length===0?(0,F.jsx)(E,{className:`py-4`,children:`Nothing is typed or chosen in this workflow, so it has no test data.`}):(0,F.jsxs)(F.Fragment,{children:[(0,F.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,F.jsx)(`ul`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-0`,children:x.values.map(e=>(0,F.jsx)(de,{v:e,secrets:x.secrets,mobile:X,busy:j,onSave:(t,n,r)=>void Y(()=>se({workflow:x.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))})]})),N===`run`&&(0,F.jsx)(fe,{view:x,job:G,rows:X?{...ge,requests:[]}:ge,heal:ve,busy:j||J,onRun:ke})]})]})}export{L as n,I as r,U as t};
|