@capagents/forgeqe 3.3.3 → 3.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HOW_TO_USE.md +18 -10
- package/dist/docs-site/docs/area-operations/index.html +18 -10
- package/dist/docs-site/docs/search.js +1 -1
- package/dist/forgeqe.js +1899 -1899
- package/dist/web/assets/Agent-CPDdNdzX.js +10 -0
- package/dist/web/assets/{AgentWork-CqMhsFBP.js → AgentWork-DmCMV4YL.js} +1 -1
- package/dist/web/assets/ApiTests-C8XEETqg.js +17 -0
- package/dist/web/assets/{Chat-DO-UvDWX.js → Chat-DKOatIXA.js} +1 -1
- package/dist/web/assets/{Compare-BFuLcrBB.js → Compare-BIUv2jE1.js} +1 -1
- package/dist/web/assets/{Cost-DbKrBm9m.js → Cost-DiCKET0E.js} +1 -1
- package/dist/web/assets/{Data-B6_6Rm7C.js → Data-CjWcmOft.js} +1 -1
- package/dist/web/assets/{Desktop-CnBxMp68.js → Desktop-ChCPGa4S.js} +1 -1
- package/dist/web/assets/{DesktopReview-DVITz4Jv.js → DesktopReview-Bg2GEMn0.js} +1 -1
- package/dist/web/assets/{Evidence-BZx9UF1t.js → Evidence-B7iO8OAV.js} +1 -1
- package/dist/web/assets/{Explore-Kkl9koqy.js → Explore-VSyrooF_.js} +1 -1
- package/dist/web/assets/{Features-_WrrIGBz.js → Features-CyL67W6D.js} +1 -1
- package/dist/web/assets/{Flags-BGqG09qD.js → Flags-CTndlZ8W.js} +1 -1
- package/dist/web/assets/{Flaky-B7mr96H8.js → Flaky-DUztfo-f.js} +1 -1
- package/dist/web/assets/{Impact-DzAtWie1.js → Impact-DgJIBG7L.js} +1 -1
- package/dist/web/assets/{Jobs-YSmfG7C9.js → Jobs-DGtR5ObS.js} +1 -1
- package/dist/web/assets/{KindPage-UqU2qh63.js → KindPage-BVr4n0ZP.js} +1 -1
- package/dist/web/assets/{Migration-CfHZeobD.js → Migration-DXRwsp94.js} +1 -1
- package/dist/web/assets/{Mobile-DTMPjWeO.js → Mobile-D5D-DcNd.js} +1 -1
- package/dist/web/assets/{Observability-B-9cikxK.js → Observability-D0Y8qi2t.js} +1 -1
- package/dist/web/assets/{OwnItems-BC9M20At.js → OwnItems-7-j-eCvZ.js} +1 -1
- package/dist/web/assets/{PageAgent-CvV8gwuP.js → PageAgent-hlUDoATU.js} +1 -1
- package/dist/web/assets/{Product-lDXsflpD.js → Product-B3dgOq3I.js} +1 -1
- package/dist/web/assets/{Production-BHXWX-ww.js → Production-CW8pMuAY.js} +1 -1
- package/dist/web/assets/{Quality-Bsljiu_v.js → Quality-DCzS_GuJ.js} +1 -1
- package/dist/web/assets/{Readiness-BZppEirK.js → Readiness-BQ811zqC.js} +1 -1
- package/dist/web/assets/{Record-7h0EFEiJ.js → Record-Slru4bw9.js} +1 -1
- package/dist/web/assets/{Regression-DdM66t2E.js → Regression-BT_dP1xn.js} +1 -1
- package/dist/web/assets/{Reports-u72R1XBV.js → Reports-C19TfbRO.js} +1 -1
- package/dist/web/assets/{Requirements-BAcEi5Fl.js → Requirements-ROyC5mNL.js} +1 -1
- package/dist/web/assets/{Responsive-CCPzSbdd.js → Responsive-Cwky2L-3.js} +1 -1
- package/dist/web/assets/{RunDiff-CGhLqPpP.js → RunDiff-BbekEd9C.js} +1 -1
- package/dist/web/assets/{Settings-DDCiQZ0T.js → Settings-CIEWLuAi.js} +3 -3
- package/dist/web/assets/{Steps-sfVkdv7g.js → Steps-BjV1MGz-.js} +1 -1
- package/dist/web/assets/{TestData-B4-xVlvt.js → TestData-ChL4QzCY.js} +1 -1
- package/dist/web/assets/{TestManagement-BGBKGV1L.js → TestManagement-B2oqBgb7.js} +1 -1
- package/dist/web/assets/{WhatsNew-BMTuBbaX.js → WhatsNew-ID__g8MH.js} +1 -1
- package/dist/web/assets/{agentSettingsSheet-Cc2W6lyp.js → agentSettingsSheet-CCkfMiKg.js} +1 -1
- package/dist/web/assets/{dataParts-CkwgLllh.js → dataParts-_X5zGtE9.js} +1 -1
- package/dist/web/assets/frame-CgBYYtdw.js +13 -0
- package/dist/web/assets/index-Cq1_-QV9.css +2 -0
- package/dist/web/assets/{index-6SZomYE0.js → index-Ctos0-8H.js} +5 -5
- package/dist/web/assets/{markdown-1wY7hIbM.js → markdown-CwgDQU8m.js} +5 -5
- package/dist/web/assets/{productParts-D18glCBr.js → productParts-CmNi_5fy.js} +1 -1
- package/dist/web/assets/{qualityParts-1F1Ee4Ay.js → qualityParts-BzzN4OCT.js} +1 -1
- package/dist/web/index.html +4 -4
- package/docs/user-guide.html +18 -10
- package/package.json +1 -1
- package/dist/web/assets/Agent-Bd54dLhD.js +0 -10
- package/dist/web/assets/ApiTests-BO_sKAg8.js +0 -15
- package/dist/web/assets/frame-BMpSUo2-.js +0 -13
- package/dist/web/assets/index-CWqwtFKz.css +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./react-BDur5s0O.js";import{n,r}from"./route-oDy8sV6H.js";import{F as i,L as a,l as o}from"./preload-helper-BupTYkQW.js";import{n as s,t as c}from"./utils-DJRAScIl.js";import{t as l}from"./jsx-runtime-LKYXHABd.js";import{d as u}from"./sectionList-B651VPon.js";import{Y as d,w as f,y as p}from"./api-BsiuHmJq.js";import{C as m,_ as h,b as g,f as _,g as v,x as y}from"./pageBack-CbyKfisx.js";import{Fr as b,Ln as x,Lr as S,M as C,Mn as w,N as T,Or as E,Pn as D,Qn as O,Rr as k,et as A,in as j,ir as M,jr as ee,mn as te,or as ne,r as re,st as ie,w as ae,yn as N,yr as P}from"./line-icons-CwCZidXs.js";import{Gt as oe,Kt as se,St as F,at as I,bt as L,gt as R,ht as z,ot as ce,qt as B,vt as V,xt as H,yt as U}from"./frame-BMpSUo2-.js";import{t as W}from"./when-BuWCTaKm.js";import{u as le}from"./nav-B_68FVw_.js";import{n as ue}from"./markdown-1wY7hIbM.js";import{U as G,l as de,n as fe,t as K}from"./index-6SZomYE0.js";import{f as q,l as J,o as pe,r as Y}from"./dataParts-CkwgLllh.js";import{n as me,t as he}from"./desktopAppPath-D3mGDKPz.js";import{t as ge}from"./DesktopReview-DVITz4Jv.js";var X=e(t(),1),Z=l(),Q=[`workflows`,`runs`,`machine`],_e={workflows:b,runs:D,machine:N},ve={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`]},ye={explore:`Explored`,record:`Recorded`,project:`Project`},be={replay:`Replay`,explore:`Explore`,record:`Recording`,maestro:`Maestro`},$=e=>e.mode===`replay`&&e.ok&&e.heals>0&&!e.healsAccepted;async function xe(e,t){try{let{id:t}=await p.start(e,{});location.hash=r(`chats`,t)}catch(e){t(e.message)}}function Se(){let[e,t]=(0,X.useState)(null),[n,r]=(0,X.useState)(``),[i,a]=(0,X.useState)(!1),o=(0,X.useCallback)(()=>{f.view().then(e=>{t(e),r(``)},e=>r(e.message))},[]);(0,X.useEffect)(o,[o]);let s=!!e?.job?.running;return(0,X.useEffect)(()=>{if(!s)return;let e=se(o,1e3);return()=>oe(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 f.stop().then(o)}}function Ce({w:e,page:t,onClose:n}){let{view:r}=t,[l,u]=(0,X.useState)({}),[d,p]=(0,X.useState)(``),[h,g]=(0,X.useState)(r.heal),[_,v]=(0,X.useState)(!1);(0,X.useEffect)(()=>{e&&(u(Object.fromEntries(e.variables.map(e=>[e.name,e.value]))),p(``),g(r.heal),v(!1))},[e,r.heal]);let b=d.startsWith(`file:`)?{file:d.slice(5)}:d.startsWith(`request:`)?{request:d.slice(8)}:void 0,x=c(o,`flex flex-col gap-4`);return(0,Z.jsx)(B,{open:!!e,onClose:n,title:e?`Replay ${e.name}`:`Replay`,description:`Runs the workflow's steps in its app with no model, checking its expect steps. It takes over this machine's mouse and keyboard while it runs: use a test machine and a test account.`,footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(y,{onClick:n,children:[(0,Z.jsx)(k,{"aria-hidden":`true`}),`Cancel`]}),(0,Z.jsxs)(y,{variant:`primary`,disabled:t.busy||!e,onClick:async()=>{e&&await t.act(()=>f.replay({workflow:e.path,variables:l,...b?{rows:b}:{},heal:h,updateBaselines:_}))&&n()},"data-tip":`Replay now`,children:[(0,Z.jsx)(D,{"aria-hidden":`true`}),`Replay`]})]}),children:e&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 pt-4`,children:[(0,Z.jsxs)(`p`,{className:`m-0 flex flex-wrap gap-x-4 text-body-sm text-muted`,children:[(0,Z.jsx)(`span`,{className:`font-mono`,children:e.path}),(0,Z.jsxs)(`span`,{children:[e.app||`no app`,` · `,s(e.steps,`step`),` · `,s(e.checks,`check`)]})]}),e.checks===0&&(0,Z.jsx)(`p`,{className:c(m.warn,`m-0`),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,Z.jsx)(G,{level:3,icon:E,title:`Values`,className:x,children:(0,Z.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(200px,1fr))] gap-4`,children:e.variables.map(e=>(0,Z.jsx)(Y,{label:e.name,children:(0,Z.jsx)(i,{value:l[e.name]??``,onChange:t=>u({...l,[e.name]:t.target.value})})},e.name))})}),(0,Z.jsx)(G,{level:3,icon:A,title:`Test data`,className:x,children:(0,Z.jsx)(Y,{label:`Rows`,hint:`Each row replays the workflow once, its columns over the values above.`,children:(0,Z.jsxs)(a,{value:d,onChange:e=>p(e.target.value),children:[(0,Z.jsx)(`option`,{value:``,children:`Once, with the values above`}),r.rows.files.map(e=>(0,Z.jsxs)(`option`,{value:`file:${e}`,children:[`Each row of `,e]},e)),r.rows.requests.map(e=>(0,Z.jsxs)(`option`,{value:`request:${e}`,children:[`Each row of request `,e]},e))]})})}),(0,Z.jsxs)(G,{level:3,icon:O,title:`While it runs`,className:x,children:[(0,Z.jsx)(q,{on:h,set:g,children:`Heal a step whose control moved`}),(0,Z.jsx)(q,{on:_,set:v,children:`Take new image baselines`})]})]})})}function we({open:e,page:t,onClose:n}){let{view:r}=t,[o,s]=(0,X.useState)(r.apps[0]?.name??``),[l,u]=(0,X.useState)(``),[d,p]=(0,X.useState)(``);return(0,Z.jsx)(B,{open:e,onClose:n,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,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(y,{onClick:n,children:[(0,Z.jsx)(k,{"aria-hidden":`true`}),`Cancel`]}),(0,Z.jsxs)(y,{variant:`primary`,disabled:t.busy||!l.trim()||!o,onClick:async()=>{await t.act(()=>f.explore(o,l.trim(),d.trim()))&&(u(``),p(``),n())},"data-tip":`Start: DeskPilot takes over the mouse and keyboard`,children:[(0,Z.jsx)(M,{"aria-hidden":`true`}),`Start exploring`]})]}),children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 pt-4`,children:[(0,Z.jsx)(Y,{label:`App`,children:(0,Z.jsx)(a,{value:o,onChange:e=>s(e.target.value),children:r.apps.map(e=>(0,Z.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),(0,Z.jsx)(Y,{label:`Goal`,hint:`One line, as you would ask a tester.`,children:(0,Z.jsx)(i,{value:l,maxLength:500,placeholder:`Create an invoice for Contoso and save it`,onChange:e=>u(e.target.value)})}),(0,Z.jsx)(Y,{label:`Name`,hint:`Optional: the workflow's name.`,children:(0,Z.jsx)(i,{value:d,maxLength:80,onChange:e=>p(e.target.value)})}),(0,Z.jsxs)(`p`,{className:c(m.warn,`m-0 flex gap-2`),children:[(0,Z.jsx)(C,{size:16,"aria-hidden":`true`,className:`mt-1 flex-none`}),`DeskPilot controls this machine's mouse and keyboard in `,o||`the app`,`, in that app's windows only (no shell commands). Use a test machine and a test account.`]})]})})}function Te({open:e,page:t,onClose:n}){let{view:r}=t,[i,a]=(0,X.useState)(r.windows),[o,s]=(0,X.useState)(!1);return(0,Z.jsx)(B,{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,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(y,{onClick:n,children:[(0,Z.jsx)(k,{"aria-hidden":`true`}),`Cancel`]}),(0,Z.jsxs)(y,{variant:`primary`,disabled:t.busy,onClick:async()=>{await t.act(()=>f.setup({ufo:r.windows&&i,force:o}))&&n()},children:[(0,Z.jsx)(S,{"aria-hidden":`true`}),`Set up`]})]}),children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 pt-4`,children:[r.windows?(0,Z.jsx)(q,{on:i,set:a,children:`Exploring a goal too (DeskPilot)`}):(0,Z.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`On this system workflows replay by accessibility calls, which this sets up too. Exploring and recording by hand need Windows.`}),(0,Z.jsx)(q,{on:o,set:s,children:`Set it up again from scratch`})]})})}var Ee=e=>(e??[]).map(e=>/\s/.test(e)?`"${e}"`:e).join(` `);function De({open:e,editing:t,page:n,onClose:r}){let[a,o]=(0,X.useState)(``),[s,l]=(0,X.useState)(``),[u,d]=(0,X.useState)(!1),[p,m]=(0,X.useState)(``),[h,g]=(0,X.useState)(``),[_,v]=(0,X.useState)(``),[b,S]=(0,X.useState)(!1);(0,X.useEffect)(()=>{e&&(o(t?.path??``),l(t?.name??``),d(!!t),m(t?.description??``),g(Ee(t?.args)),v(``))},[e,t]);let C=async()=>{S(!0),v(``);let e={name:s.trim(),path:a.trim(),...h.trim()?{args:h.trim()}:{},...p.trim()?{description:p.trim()}:{}};try{await(t?f.editApp(e):f.addApp(e)),n.load(),r()}catch(e){v(e.message)}finally{S(!1)}};return(0,Z.jsx)(B,{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,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(y,{onClick:r,children:[(0,Z.jsx)(k,{"aria-hidden":`true`}),`Cancel`]}),(0,Z.jsxs)(y,{variant:`accent`,disabled:b||!a.trim()||!s.trim(),onClick:()=>void C(),children:[t?(0,Z.jsx)(ae,{"aria-hidden":`true`}):(0,Z.jsx)(x,{"aria-hidden":`true`}),b?t?`Saving…`:`Adding…`:t?`Save`:`Add the app`]})]}),children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 pt-4`,children:[(0,Z.jsx)(Y,{label:`Program`,hint:`Type its path, or Browse to choose it on this computer.`,children:(0,Z.jsx)(he,{value:a,onChange:e=>{o(e),u||l(e.trim()?me(e):``)},onPicked:(e,t)=>{u||l(t)},onError:v})}),(0,Z.jsx)(Y,{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,Z.jsx)(i,{value:h,maxLength:500,spellCheck:!1,placeholder:`--server qa-db01 --profile "Test User"`,onChange:e=>g(e.target.value),className:`font-mono text-body-sm`})}),(0,Z.jsx)(Y,{label:`Name`,hint:t?`Fixed: workflows name the app by it.`:`How workflows and the agent name it: letters, digits and _ . -`,children:(0,Z.jsx)(i,{value:s,maxLength:40,spellCheck:!1,readOnly:!!t,className:c(t&&`bg-surface-muted text-muted`),onChange:e=>{d(!0),l(e.target.value)}})}),(0,Z.jsx)(Y,{label:`What it is for`,hint:`Optional: one line the agent reads to pick the app.`,children:(0,Z.jsx)(i,{value:p,maxLength:200,placeholder:`Back-office invoicing`,onChange:e=>m(e.target.value)})}),_&&(0,Z.jsx)(J,{text:_})]})})}function Oe({app:e,page:t,onClose:n}){let[r,i]=(0,X.useState)(null),[a,o]=(0,X.useState)(``),[l,u]=(0,X.useState)(!1);return(0,X.useEffect)(()=>{e&&(i(null),o(``),f.removeApp(e.name,!1).then(i,e=>o(e.message)))},[e]),(0,Z.jsx)(B,{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,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(y,{onClick:n,children:[(0,Z.jsx)(k,{"aria-hidden":`true`}),`Cancel`]}),(0,Z.jsxs)(y,{busy:l,variant:`destructive`,disabled:l||!r,onClick:async()=>{if(e){u(!0);try{await f.removeApp(e.name,!0),t.load(),n()}catch(e){o(e.message)}finally{u(!1)}}},children:[(0,Z.jsx)(P,{"aria-hidden":`true`}),l?`Removing…`:`Remove`]})]}),children:(0,Z.jsx)(`div`,{className:`flex flex-col gap-4 pt-4 text-body-sm`,children:a?(0,Z.jsx)(J,{text:a}):r?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`m-0 text-ink-2`,children:[`From `,r.where,`.`]}),r.usedBy.length?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:c(m.warn,`m-0`),children:[s(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,Z.jsxs)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0 font-mono text-body-sm text-ink-2`,children:[r.usedBy.slice(0,20).map(e=>(0,Z.jsx)(`li`,{className:`truncate`,"data-tip":e,children:e},e)),r.usedBy.length>20&&(0,Z.jsxs)(`li`,{className:`font-sans text-muted`,children:[`and `,r.usedBy.length-20,` more`]})]})]}):(0,Z.jsx)(`p`,{className:`m-0 text-muted`,children:`No workflow names it.`})]}):(0,Z.jsx)(`p`,{role:`status`,className:`m-0 text-muted`,children:`Looking for the workflows that use it…`})})})}function ke({page:e,onReplay:t,onExplore:n,onSteps:i}){let{view:o}=e,[s,l]=(0,X.useState)(o.apps[0]?.name??``),u=o.windows?void 0:o.windowsOnly,p=()=>e.act(async()=>{await d.start({kind:`desktop`,app:s}),location.hash=r(`record`)});return(0,Z.jsx)(z,{label:`Desktop workflows`,minWidth:720,height:R,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,Z.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[o.apps.length>1&&(0,Z.jsx)(a,{size:`sm`,"aria-label":`App to record`,value:s,onChange:e=>l(e.target.value),className:`w-auto`,children:o.apps.map(e=>(0,Z.jsx)(`option`,{value:e.name,children:e.name},e.name))}),(0,Z.jsxs)(y,{size:`sm`,disabled:e.busy||!o.windows||!s,onClick:()=>void p(),"data-tip":u??`Record your steps in ${s}: no model`,children:[(0,Z.jsx)(N,{"aria-hidden":`true`}),`Record by hand`]}),(0,Z.jsxs)(y,{size:`sm`,variant:`primary`,disabled:e.busy||!o.windows||!o.apps.length,onClick:n,"data-tip":u??`DeskPilot carries out a goal and saves it as a workflow`,children:[(0,Z.jsx)(M,{"aria-hidden":`true`}),`Explore a goal`]})]}),head:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`th`,{scope:`col`,className:L,children:`Workflow`}),(0,Z.jsx)(`th`,{scope:`col`,className:L,children:`App`}),(0,Z.jsx)(`th`,{scope:`col`,className:H,children:`Steps`}),(0,Z.jsx)(`th`,{scope:`col`,className:H,children:`Checks`}),(0,Z.jsx)(`th`,{scope:`col`,className:L,children:`From`}),(0,Z.jsx)(`th`,{scope:`col`,className:L,children:(0,Z.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]}),children:o.workflows.map(n=>(0,Z.jsxs)(`tr`,{className:F,children:[(0,Z.jsx)(`td`,{className:V,children:(0,Z.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(y,{variant:`link`,size:`inline`,onClick:()=>i(n),className:`self-start text-left whitespace-normal text-ink`,children:n.name}),(0,Z.jsx)(`span`,{className:`max-w-[300px] truncate font-mono text-body-sm text-muted`,"data-tip":n.path,children:n.path})]})}),(0,Z.jsx)(`td`,{className:c(V,`whitespace-nowrap`),children:n.app||(0,Z.jsx)(`span`,{className:`text-muted`,children:`—`})}),(0,Z.jsx)(`td`,{className:U,children:n.steps}),(0,Z.jsx)(`td`,{className:c(U,n.checks===0&&`text-warn`),"data-tip":n.checks===0?`No checks of the outcome: a replay passes when its steps run`:void 0,children:n.checks}),(0,Z.jsxs)(`td`,{className:c(V,`whitespace-nowrap`),children:[ye[n.from],(0,Z.jsx)(`span`,{className:`block text-body-sm text-muted`,children:W(n.modified)})]}),(0,Z.jsx)(`td`,{className:c(V,`whitespace-nowrap text-right`),children:(0,Z.jsxs)(`span`,{className:`inline-flex gap-1`,children:[(0,Z.jsx)(y,{size:`icon`,variant:`icon`,onClick:()=>i(n),"aria-label":`Open ${n.name}`,"data-tip":`Open it: steps, checks, test data, last run`,className:`size-8`,children:(0,Z.jsx)(ie,{"aria-hidden":`true`})}),(0,Z.jsx)(y,{size:`icon`,variant:`icon`,disabled:e.busy,onClick:()=>t(n),"aria-label":`Replay ${n.name}`,"data-tip":`Replay ${n.name}`,className:`size-8`,children:(0,Z.jsx)(D,{"aria-hidden":`true`})}),(0,Z.jsx)(y,{size:`icon`,variant:`icon`,disabled:e.busy,onClick:()=>void e.act(()=>f.validate(n.path)),"aria-label":`Check ${n.name}`,"data-tip":`Check it without running it`,className:`size-8`,children:(0,Z.jsx)(j,{"aria-hidden":`true`})}),(0,Z.jsx)(y,{size:`icon`,variant:`icon`,onClick:()=>void xe(`DeskPilot: look at the desktop workflow ${n.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 ${n.name} with the agent`,"data-tip":`Improve it with the agent`,className:`size-8`,children:(0,Z.jsx)(ee,{"aria-hidden":`true`})})]})})]},n.path))})}function Ae({page:e}){let{view:t}=e,[n,r]=(0,X.useState)(`all`),[i,a]=(0,X.useState)(``),o=t.runs.filter(e=>!e.ok),l=t.runs.filter($),u=n===`failed`?o:n===`heals`?l:t.runs;return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[i&&(0,Z.jsx)(`p`,{role:`status`,className:c(m.pass,`m-0`),children:i}),(0,Z.jsx)(z,{label:`Desktop runs`,minWidth:720,height:R,resetKey:n,placeholder:`Find a run`,empty:n===`all`?`No desktop runs yet: replay, record or explore a workflow.`:`None.`,tools:(0,Z.jsx)(_,{value:n,onChange:r,items:[{id:`all`,label:`All`,n:t.runs.length},{id:`failed`,label:`Failed`,n:o.length,alert:!0},{id:`heals`,label:`Heals to accept`,n:l.length}]}),head:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`th`,{scope:`col`,className:L,children:`Run`}),(0,Z.jsx)(`th`,{scope:`col`,className:L,children:`Result`}),(0,Z.jsx)(`th`,{scope:`col`,className:H,children:`Steps`}),(0,Z.jsx)(`th`,{scope:`col`,className:L,children:`Heals`}),(0,Z.jsx)(`th`,{scope:`col`,className:L,children:(0,Z.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]}),children:u.map(t=>(0,Z.jsxs)(`tr`,{className:F,children:[(0,Z.jsx)(`td`,{className:V,children:(0,Z.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,Z.jsxs)(`span`,{className:`font-medium`,children:[be[t.mode],`: `,t.name]}),(0,Z.jsx)(`span`,{className:`text-body-sm text-muted`,children:[t.app,W(t.at)].filter(Boolean).join(` · `)}),(t.failed||t.error)&&(0,Z.jsx)(`span`,{className:`max-w-[380px] truncate text-body-sm 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,Z.jsx)(`td`,{className:c(V,`whitespace-nowrap`),children:(0,Z.jsx)(v,{tone:t.ok?`pass`:`fail`,children:t.many?`${t.many.passed} of ${t.many.total}`:t.ok?`Passed`:`Failed`})}),(0,Z.jsx)(`td`,{className:U,children:t.steps||(0,Z.jsx)(`span`,{className:`text-muted`,children:`—`})}),(0,Z.jsx)(`td`,{className:c(V,`whitespace-nowrap`),children:t.heals?t.healsAccepted?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-body-sm text-pass`,children:[(0,Z.jsx)(T,{size:14,"aria-hidden":`true`}),`In the workflow`]}):t.ok?(0,Z.jsxs)(y,{size:`sm`,disabled:e.busy,onClick:()=>void e.act(async()=>{let e=await f.acceptHeals(t.dir);a(`Wrote ${s(e.written,`healed step`)} into ${e.workflow}.`)}),"data-tip":`Write the new locators into the workflow`,children:[(0,Z.jsx)(S,{"aria-hidden":`true`}),`Accept `,s(t.heals,`heal`)]}):(0,Z.jsxs)(`span`,{className:`text-body-sm text-muted`,"data-tip":`The replay failed after healing, so its heals may be wrong`,children:[s(t.heals,`heal`),`, not offered`]}):(0,Z.jsx)(`span`,{className:`text-muted`,children:`—`})}),(0,Z.jsx)(`td`,{className:c(V,`whitespace-nowrap text-right`),children:(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[t.report&&(0,Z.jsx)(ue,{path:t.report,children:`Report`}),!t.ok&&(0,Z.jsx)(y,{size:`icon`,variant:`icon`,onClick:()=>void xe(`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,Z.jsx)(te,{"aria-hidden":`true`})})]})})]},t.dir))})]})}function je({page:e,onSetup:t,onAdd:n,onEdit:i,onRemove:a}){let{view:s}=e,l=(s.driver===`auto`?s.windows?`pywinauto`:`agent-desktop`:s.driver)===`pywinauto`?`the mouse and keyboard`:`accessibility calls`,u=[{label:`Replay`,ok:s.engine.ready,note:s.engine.ready?`On ${l}`:(s.engine.error||`The desktop engine is not set up`).replace(/^./,e=>e.toUpperCase())},{label:`Explore and record`,ok:s.windows&&s.engine.ufo,note:s.windows?s.engine.ufo?`Set up`:`Not set up`:`Windows only`},{label:`Healing`,ok:s.heal,note:s.heal?`A moved control is healed with the model`:`desktop.heal is off`}],d=c(o,`flex flex-col`);return(0,Z.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,320px),1fr))] items-start gap-6`,children:[(0,Z.jsxs)(G,{id:`desktop-machine`,icon:N,title:`This machine`,divider:!1,children:[(0,Z.jsx)(`ul`,{className:c(d,`m-0 list-none divide-y divide-line-soft p-0`),children:u.map(e=>(0,Z.jsxs)(`li`,{className:`flex items-start gap-2 px-4 py-2`,children:[e.ok?(0,Z.jsx)(T,{size:16,"aria-label":`Ready`,className:`mt-1 flex-none text-pass`}):(0,Z.jsx)(C,{size:16,"aria-label":`Not ready`,className:`mt-1 flex-none text-warn`}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Z.jsx)(`span`,{className:`text-body-sm font-medium`,children:e.label}),(0,Z.jsx)(`span`,{className:`text-body-sm text-muted [overflow-wrap:anywhere]`,"data-tip":!e.ok&&e.label===`Explore and record`&&s.windowsOnly?s.windowsOnly:void 0,children:e.note})]})]},e.label))}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsxs)(y,{size:`sm`,disabled:e.busy,onClick:()=>void e.act(()=>f.doctor()),"data-tip":`Whether replay can run here unattended`,children:[(0,Z.jsx)(j,{"aria-hidden":`true`}),`Check`]}),(0,Z.jsxs)(y,{size:`sm`,variant:s.engine.ready?`outline`:`primary`,disabled:e.busy,onClick:t,"data-tip":`Download and set up the desktop engine`,children:[(0,Z.jsx)(S,{"aria-hidden":`true`}),`Set up`]})]})]}),(0,Z.jsxs)(G,{id:`desktop-apps`,icon:re,title:`Apps`,divider:!1,actions:(0,Z.jsxs)(y,{size:`sm`,onClick:n,"data-tip":`Add an app by its program on this computer`,children:[(0,Z.jsx)(x,{"aria-hidden":`true`}),`Add an app`]}),children:[s.apps.length?(0,Z.jsx)(`ul`,{className:c(d,`m-0 list-none divide-y divide-line-soft p-0`),children:s.apps.map(e=>(0,Z.jsxs)(`li`,{className:`group flex items-start gap-2 px-4 py-2`,children:[(0,Z.jsx)(g,{icon:N,size:16,className:`mt-1 flex-none text-muted`}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(`span`,{className:`text-body-sm font-medium`,children:e.name}),(0,Z.jsxs)(`span`,{className:`truncate font-mono text-body-sm text-muted`,"data-tip":[e.path,...e.args??[]].join(` `),children:[e.path||`No path`,e.args?.length?(0,Z.jsxs)(`span`,{className:`text-ink-2`,children:[` `,Ee(e.args)]}):null]}),e.description&&(0,Z.jsx)(`span`,{className:`text-body-sm text-muted`,children:e.description})]}),(0,Z.jsxs)(`span`,{className:`flex flex-none gap-1`,children:[(0,Z.jsx)(y,{size:`icon`,variant:`icon`,onClick:()=>i(e),"aria-label":`Change ${e.name}`,"data-tip":`Change ${e.name}`,className:`size-8`,children:(0,Z.jsx)(w,{"aria-hidden":`true`})}),(0,Z.jsx)(y,{size:`icon`,variant:`icon`,onClick:()=>a(e),"aria-label":`Remove ${e.name}`,"data-tip":`Remove ${e.name}`,className:`size-8 hover:text-fail`,children:(0,Z.jsx)(P,{"aria-hidden":`true`})})]})]},e.name))}):(0,Z.jsxs)(h,{className:`py-4`,children:[`No desktop apps yet: add one by its program, or in `,(0,Z.jsx)(`a`,{href:r(`settings`,`environments`),children:`Settings, Environments`}),`.`]}),(0,Z.jsxs)(`p`,{className:`m-0 text-body-sm text-muted`,children:[`Secrets a workflow may type: `,s.secrets.length?s.secrets.join(`, `):`none`,`.`,s.refusedSecrets.length>0&&(0,Z.jsxs)(`span`,{className:`text-fail`,children:[` `,s.refusedSecrets.join(`, `),` `,s.refusedSecrets.length===1?`is`:`are`,` ForgeQE's own: take `,s.refusedSecrets.length===1?`it`:`them`,` out of desktop.secrets, or nothing replays.`]})]})]})]})}function Me({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($).length,o=e.workflows.filter(e=>e.checks===0).length;return(0,Z.jsxs)(ce,{label:`Desktop at a glance`,children:[(0,Z.jsx)(I,{compact:!0,label:`Workflows`,value:e.workflows.length,note:o?(0,Z.jsxs)(`span`,{className:`text-warn`,children:[o,` without checks`]}):`${s(e.apps.length,`app`)}`}),(0,Z.jsx)(I,{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 ${W(i.at)}`:`None yet`}),(0,Z.jsx)(I,{compact:!0,label:`Heals to accept`,value:a,tone:a?`text-accent-fg`:void 0,note:a?(0,Z.jsx)(y,{variant:`link`,size:`inline`,onClick:()=>t(`runs`),children:`Review them`}):`From passed replays`}),(0,Z.jsx)(I,{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,Z.jsx)(y,{variant:`link`,size:`inline`,onClick:()=>t(`machine`),children:`Set it up`})})]})}function Ne({sub:e}){let t=Se(),{view:i,error:a}=t,o=u(`desktop`),s=(e??``).split(`/`),l=s[0]===`workflow`&&s[1]?n(s[1]):``,d=l?`workflows`:Q.includes(s[0])?s[0]:K,[p,h]=(0,X.useState)(null),[g,_]=(0,X.useState)(!1),[v,b]=(0,X.useState)(!1),[x,S]=(0,X.useState)(!1),[C,w]=(0,X.useState)(),[T,E]=(0,X.useState)(null),D=l&&i?.workflows.find(e=>e.path===l)||null,O=e=>location.hash=e?r(`desktop`,`workflow`,encodeURIComponent(e.path)):r(`desktop`,`workflows`),k=i?.job??null,A=e=>e===`agent`?r(`desktop`,K):r(`desktop`,e),j=e=>location.hash=A(e),M={workflows:`Workflows${i?` (${i.workflows.length})`:``}`,runs:`Runs${i?` (${i.runs.length})`:``}`,machine:`Machine and apps`};return(0,Z.jsxs)(fe,{title:le(`desktop`),page:o,label:`Desktop apps`,current:d,tabHref:A,onPick:j,tabs:Q.map(e=>({id:e,label:M[e],icon:_e[e]})),below:(0,Z.jsx)(de,{page:o}),children:[(0,Z.jsx)(`p`,{className:`m-0 text-body-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.`}),a&&(0,Z.jsx)(J,{text:a}),!i&&!a&&(0,Z.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Loading…`}),i&&D&&(0,Z.jsx)(ge,{workflow:D.path,backLabel:`Workflows`,tab:s[2],onTab:e=>location.hash=e===`steps`?r(`desktop`,`workflow`,encodeURIComponent(D.path)):r(`desktop`,`workflow`,encodeURIComponent(D.path),e),onClose:()=>{O(null),t.load()}},D.path),i&&!D&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Me,{view:i,onTab:j}),k&&(k.running||!k.endedAt||Date.now()-Date.parse(k.endedAt)<6e5)&&(0,Z.jsx)(pe,{job:k,onStop:t.stop,words:ve}),k?.question&&(0,Z.jsxs)(`div`,{className:c(m.info,`flex flex-col gap-2`),children:[(0,Z.jsx)(`p`,{className:`m-0 font-medium`,children:k.question.title}),k.question.detail&&(0,Z.jsx)(`p`,{className:`m-0 text-ink-2`,children:k.question.detail}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[k.question.options.map(e=>(0,Z.jsx)(y,{size:`sm`,onClick:()=>void t.act(()=>f.answer(k.question.id,e.id)),children:e.label},e.id)),(0,Z.jsxs)(y,{size:`sm`,variant:`danger`,onClick:()=>void t.act(()=>f.answer(k.question.id,null)),children:[(0,Z.jsx)(ne,{fill:`currentColor`,"aria-hidden":`true`}),`Stop`]})]})]}),(0,Z.jsxs)(`div`,{children:[d===`workflows`&&(0,Z.jsx)(ke,{page:{...t,view:i},onReplay:h,onExplore:()=>_(!0),onSteps:O}),d===`runs`&&(0,Z.jsx)(Ae,{page:{...t,view:i}}),d===`machine`&&(0,Z.jsx)(je,{page:{...t,view:i},onSetup:()=>b(!0),onAdd:()=>{w(void 0),S(!0)},onEdit:e=>{w(e),S(!0)},onRemove:E})]}),(0,Z.jsx)(Ce,{w:p,page:{...t,view:i},onClose:()=>h(null)}),(0,Z.jsx)(we,{open:g,page:{...t,view:i},onClose:()=>_(!1)}),(0,Z.jsx)(Te,{open:v,page:{...t,view:i},onClose:()=>b(!1)}),(0,Z.jsx)(De,{open:x,editing:C,page:{...t,view:i},onClose:()=>S(!1)}),(0,Z.jsx)(Oe,{app:T,page:{...t,view:i},onClose:()=>E(null)})]})]})}export{Ne as Desktop};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./react-BDur5s0O.js";import{n,r}from"./route-oDy8sV6H.js";import{F as i,L as a,l as o}from"./preload-helper-BupTYkQW.js";import{n as s,t as c}from"./utils-DJRAScIl.js";import{t as l}from"./jsx-runtime-LKYXHABd.js";import{d as u}from"./sectionList-B651VPon.js";import{Y as d,w as f,y as p}from"./api-BsiuHmJq.js";import{C as m,_ as h,b as g,f as _,g as v,x as y}from"./pageBack-CbyKfisx.js";import{Fr as b,Ln as x,Lr as S,M as C,Mn as w,N as T,Or as E,Pn as D,Qn as O,Rr as k,et as A,in as j,ir as M,jr as ee,mn as te,or as ne,r as re,st as ie,w as ae,yn as N,yr as P}from"./line-icons-CwCZidXs.js";import{Gt as oe,Kt as se,St as F,at as I,bt as L,gt as R,ht as z,ot as ce,qt as B,vt as V,xt as H,yt as U}from"./frame-CgBYYtdw.js";import{t as W}from"./when-BuWCTaKm.js";import{u as le}from"./nav-B_68FVw_.js";import{n as ue}from"./markdown-CwgDQU8m.js";import{U as G,l as de,n as fe,t as K}from"./index-Ctos0-8H.js";import{f as q,l as J,o as pe,r as Y}from"./dataParts-_X5zGtE9.js";import{n as me,t as he}from"./desktopAppPath-D3mGDKPz.js";import{t as ge}from"./DesktopReview-Bg2GEMn0.js";var X=e(t(),1),Z=l(),Q=[`workflows`,`runs`,`machine`],_e={workflows:b,runs:D,machine:N},ve={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`]},ye={explore:`Explored`,record:`Recorded`,project:`Project`},be={replay:`Replay`,explore:`Explore`,record:`Recording`,maestro:`Maestro`},$=e=>e.mode===`replay`&&e.ok&&e.heals>0&&!e.healsAccepted;async function xe(e,t){try{let{id:t}=await p.start(e,{});location.hash=r(`chats`,t)}catch(e){t(e.message)}}function Se(){let[e,t]=(0,X.useState)(null),[n,r]=(0,X.useState)(``),[i,a]=(0,X.useState)(!1),o=(0,X.useCallback)(()=>{f.view().then(e=>{t(e),r(``)},e=>r(e.message))},[]);(0,X.useEffect)(o,[o]);let s=!!e?.job?.running;return(0,X.useEffect)(()=>{if(!s)return;let e=se(o,1e3);return()=>oe(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 f.stop().then(o)}}function Ce({w:e,page:t,onClose:n}){let{view:r}=t,[l,u]=(0,X.useState)({}),[d,p]=(0,X.useState)(``),[h,g]=(0,X.useState)(r.heal),[_,v]=(0,X.useState)(!1);(0,X.useEffect)(()=>{e&&(u(Object.fromEntries(e.variables.map(e=>[e.name,e.value]))),p(``),g(r.heal),v(!1))},[e,r.heal]);let b=d.startsWith(`file:`)?{file:d.slice(5)}:d.startsWith(`request:`)?{request:d.slice(8)}:void 0,x=c(o,`flex flex-col gap-4`);return(0,Z.jsx)(B,{open:!!e,onClose:n,title:e?`Replay ${e.name}`:`Replay`,description:`Runs the workflow's steps in its app with no model, checking its expect steps. It takes over this machine's mouse and keyboard while it runs: use a test machine and a test account.`,footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(y,{onClick:n,children:[(0,Z.jsx)(k,{"aria-hidden":`true`}),`Cancel`]}),(0,Z.jsxs)(y,{variant:`primary`,disabled:t.busy||!e,onClick:async()=>{e&&await t.act(()=>f.replay({workflow:e.path,variables:l,...b?{rows:b}:{},heal:h,updateBaselines:_}))&&n()},"data-tip":`Replay now`,children:[(0,Z.jsx)(D,{"aria-hidden":`true`}),`Replay`]})]}),children:e&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 pt-4`,children:[(0,Z.jsxs)(`p`,{className:`m-0 flex flex-wrap gap-x-4 text-body-sm text-muted`,children:[(0,Z.jsx)(`span`,{className:`font-mono`,children:e.path}),(0,Z.jsxs)(`span`,{children:[e.app||`no app`,` · `,s(e.steps,`step`),` · `,s(e.checks,`check`)]})]}),e.checks===0&&(0,Z.jsx)(`p`,{className:c(m.warn,`m-0`),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,Z.jsx)(G,{level:3,icon:E,title:`Values`,className:x,children:(0,Z.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(200px,1fr))] gap-4`,children:e.variables.map(e=>(0,Z.jsx)(Y,{label:e.name,children:(0,Z.jsx)(i,{value:l[e.name]??``,onChange:t=>u({...l,[e.name]:t.target.value})})},e.name))})}),(0,Z.jsx)(G,{level:3,icon:A,title:`Test data`,className:x,children:(0,Z.jsx)(Y,{label:`Rows`,hint:`Each row replays the workflow once, its columns over the values above.`,children:(0,Z.jsxs)(a,{value:d,onChange:e=>p(e.target.value),children:[(0,Z.jsx)(`option`,{value:``,children:`Once, with the values above`}),r.rows.files.map(e=>(0,Z.jsxs)(`option`,{value:`file:${e}`,children:[`Each row of `,e]},e)),r.rows.requests.map(e=>(0,Z.jsxs)(`option`,{value:`request:${e}`,children:[`Each row of request `,e]},e))]})})}),(0,Z.jsxs)(G,{level:3,icon:O,title:`While it runs`,className:x,children:[(0,Z.jsx)(q,{on:h,set:g,children:`Heal a step whose control moved`}),(0,Z.jsx)(q,{on:_,set:v,children:`Take new image baselines`})]})]})})}function we({open:e,page:t,onClose:n}){let{view:r}=t,[o,s]=(0,X.useState)(r.apps[0]?.name??``),[l,u]=(0,X.useState)(``),[d,p]=(0,X.useState)(``);return(0,Z.jsx)(B,{open:e,onClose:n,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,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(y,{onClick:n,children:[(0,Z.jsx)(k,{"aria-hidden":`true`}),`Cancel`]}),(0,Z.jsxs)(y,{variant:`primary`,disabled:t.busy||!l.trim()||!o,onClick:async()=>{await t.act(()=>f.explore(o,l.trim(),d.trim()))&&(u(``),p(``),n())},"data-tip":`Start: DeskPilot takes over the mouse and keyboard`,children:[(0,Z.jsx)(M,{"aria-hidden":`true`}),`Start exploring`]})]}),children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 pt-4`,children:[(0,Z.jsx)(Y,{label:`App`,children:(0,Z.jsx)(a,{value:o,onChange:e=>s(e.target.value),children:r.apps.map(e=>(0,Z.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),(0,Z.jsx)(Y,{label:`Goal`,hint:`One line, as you would ask a tester.`,children:(0,Z.jsx)(i,{value:l,maxLength:500,placeholder:`Create an invoice for Contoso and save it`,onChange:e=>u(e.target.value)})}),(0,Z.jsx)(Y,{label:`Name`,hint:`Optional: the workflow's name.`,children:(0,Z.jsx)(i,{value:d,maxLength:80,onChange:e=>p(e.target.value)})}),(0,Z.jsxs)(`p`,{className:c(m.warn,`m-0 flex gap-2`),children:[(0,Z.jsx)(C,{size:16,"aria-hidden":`true`,className:`mt-1 flex-none`}),`DeskPilot controls this machine's mouse and keyboard in `,o||`the app`,`, in that app's windows only (no shell commands). Use a test machine and a test account.`]})]})})}function Te({open:e,page:t,onClose:n}){let{view:r}=t,[i,a]=(0,X.useState)(r.windows),[o,s]=(0,X.useState)(!1);return(0,Z.jsx)(B,{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,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(y,{onClick:n,children:[(0,Z.jsx)(k,{"aria-hidden":`true`}),`Cancel`]}),(0,Z.jsxs)(y,{variant:`primary`,disabled:t.busy,onClick:async()=>{await t.act(()=>f.setup({ufo:r.windows&&i,force:o}))&&n()},children:[(0,Z.jsx)(S,{"aria-hidden":`true`}),`Set up`]})]}),children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 pt-4`,children:[r.windows?(0,Z.jsx)(q,{on:i,set:a,children:`Exploring a goal too (DeskPilot)`}):(0,Z.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`On this system workflows replay by accessibility calls, which this sets up too. Exploring and recording by hand need Windows.`}),(0,Z.jsx)(q,{on:o,set:s,children:`Set it up again from scratch`})]})})}var Ee=e=>(e??[]).map(e=>/\s/.test(e)?`"${e}"`:e).join(` `);function De({open:e,editing:t,page:n,onClose:r}){let[a,o]=(0,X.useState)(``),[s,l]=(0,X.useState)(``),[u,d]=(0,X.useState)(!1),[p,m]=(0,X.useState)(``),[h,g]=(0,X.useState)(``),[_,v]=(0,X.useState)(``),[b,S]=(0,X.useState)(!1);(0,X.useEffect)(()=>{e&&(o(t?.path??``),l(t?.name??``),d(!!t),m(t?.description??``),g(Ee(t?.args)),v(``))},[e,t]);let C=async()=>{S(!0),v(``);let e={name:s.trim(),path:a.trim(),...h.trim()?{args:h.trim()}:{},...p.trim()?{description:p.trim()}:{}};try{await(t?f.editApp(e):f.addApp(e)),n.load(),r()}catch(e){v(e.message)}finally{S(!1)}};return(0,Z.jsx)(B,{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,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(y,{onClick:r,children:[(0,Z.jsx)(k,{"aria-hidden":`true`}),`Cancel`]}),(0,Z.jsxs)(y,{variant:`accent`,disabled:b||!a.trim()||!s.trim(),onClick:()=>void C(),children:[t?(0,Z.jsx)(ae,{"aria-hidden":`true`}):(0,Z.jsx)(x,{"aria-hidden":`true`}),b?t?`Saving…`:`Adding…`:t?`Save`:`Add the app`]})]}),children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 pt-4`,children:[(0,Z.jsx)(Y,{label:`Program`,hint:`Type its path, or Browse to choose it on this computer.`,children:(0,Z.jsx)(he,{value:a,onChange:e=>{o(e),u||l(e.trim()?me(e):``)},onPicked:(e,t)=>{u||l(t)},onError:v})}),(0,Z.jsx)(Y,{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,Z.jsx)(i,{value:h,maxLength:500,spellCheck:!1,placeholder:`--server qa-db01 --profile "Test User"`,onChange:e=>g(e.target.value),className:`font-mono text-body-sm`})}),(0,Z.jsx)(Y,{label:`Name`,hint:t?`Fixed: workflows name the app by it.`:`How workflows and the agent name it: letters, digits and _ . -`,children:(0,Z.jsx)(i,{value:s,maxLength:40,spellCheck:!1,readOnly:!!t,className:c(t&&`bg-surface-muted text-muted`),onChange:e=>{d(!0),l(e.target.value)}})}),(0,Z.jsx)(Y,{label:`What it is for`,hint:`Optional: one line the agent reads to pick the app.`,children:(0,Z.jsx)(i,{value:p,maxLength:200,placeholder:`Back-office invoicing`,onChange:e=>m(e.target.value)})}),_&&(0,Z.jsx)(J,{text:_})]})})}function Oe({app:e,page:t,onClose:n}){let[r,i]=(0,X.useState)(null),[a,o]=(0,X.useState)(``),[l,u]=(0,X.useState)(!1);return(0,X.useEffect)(()=>{e&&(i(null),o(``),f.removeApp(e.name,!1).then(i,e=>o(e.message)))},[e]),(0,Z.jsx)(B,{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,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(y,{onClick:n,children:[(0,Z.jsx)(k,{"aria-hidden":`true`}),`Cancel`]}),(0,Z.jsxs)(y,{busy:l,variant:`destructive`,disabled:l||!r,onClick:async()=>{if(e){u(!0);try{await f.removeApp(e.name,!0),t.load(),n()}catch(e){o(e.message)}finally{u(!1)}}},children:[(0,Z.jsx)(P,{"aria-hidden":`true`}),l?`Removing…`:`Remove`]})]}),children:(0,Z.jsx)(`div`,{className:`flex flex-col gap-4 pt-4 text-body-sm`,children:a?(0,Z.jsx)(J,{text:a}):r?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`m-0 text-ink-2`,children:[`From `,r.where,`.`]}),r.usedBy.length?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:c(m.warn,`m-0`),children:[s(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,Z.jsxs)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0 font-mono text-body-sm text-ink-2`,children:[r.usedBy.slice(0,20).map(e=>(0,Z.jsx)(`li`,{className:`truncate`,"data-tip":e,children:e},e)),r.usedBy.length>20&&(0,Z.jsxs)(`li`,{className:`font-sans text-muted`,children:[`and `,r.usedBy.length-20,` more`]})]})]}):(0,Z.jsx)(`p`,{className:`m-0 text-muted`,children:`No workflow names it.`})]}):(0,Z.jsx)(`p`,{role:`status`,className:`m-0 text-muted`,children:`Looking for the workflows that use it…`})})})}function ke({page:e,onReplay:t,onExplore:n,onSteps:i}){let{view:o}=e,[s,l]=(0,X.useState)(o.apps[0]?.name??``),u=o.windows?void 0:o.windowsOnly,p=()=>e.act(async()=>{await d.start({kind:`desktop`,app:s}),location.hash=r(`record`)});return(0,Z.jsx)(z,{label:`Desktop workflows`,minWidth:720,height:R,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,Z.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[o.apps.length>1&&(0,Z.jsx)(a,{size:`sm`,"aria-label":`App to record`,value:s,onChange:e=>l(e.target.value),className:`w-auto`,children:o.apps.map(e=>(0,Z.jsx)(`option`,{value:e.name,children:e.name},e.name))}),(0,Z.jsxs)(y,{size:`sm`,disabled:e.busy||!o.windows||!s,onClick:()=>void p(),"data-tip":u??`Record your steps in ${s}: no model`,children:[(0,Z.jsx)(N,{"aria-hidden":`true`}),`Record by hand`]}),(0,Z.jsxs)(y,{size:`sm`,variant:`primary`,disabled:e.busy||!o.windows||!o.apps.length,onClick:n,"data-tip":u??`DeskPilot carries out a goal and saves it as a workflow`,children:[(0,Z.jsx)(M,{"aria-hidden":`true`}),`Explore a goal`]})]}),head:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`th`,{scope:`col`,className:L,children:`Workflow`}),(0,Z.jsx)(`th`,{scope:`col`,className:L,children:`App`}),(0,Z.jsx)(`th`,{scope:`col`,className:H,children:`Steps`}),(0,Z.jsx)(`th`,{scope:`col`,className:H,children:`Checks`}),(0,Z.jsx)(`th`,{scope:`col`,className:L,children:`From`}),(0,Z.jsx)(`th`,{scope:`col`,className:L,children:(0,Z.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]}),children:o.workflows.map(n=>(0,Z.jsxs)(`tr`,{className:F,children:[(0,Z.jsx)(`td`,{className:V,children:(0,Z.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(y,{variant:`link`,size:`inline`,onClick:()=>i(n),className:`self-start text-left whitespace-normal text-ink`,children:n.name}),(0,Z.jsx)(`span`,{className:`max-w-[300px] truncate font-mono text-body-sm text-muted`,"data-tip":n.path,children:n.path})]})}),(0,Z.jsx)(`td`,{className:c(V,`whitespace-nowrap`),children:n.app||(0,Z.jsx)(`span`,{className:`text-muted`,children:`—`})}),(0,Z.jsx)(`td`,{className:U,children:n.steps}),(0,Z.jsx)(`td`,{className:c(U,n.checks===0&&`text-warn`),"data-tip":n.checks===0?`No checks of the outcome: a replay passes when its steps run`:void 0,children:n.checks}),(0,Z.jsxs)(`td`,{className:c(V,`whitespace-nowrap`),children:[ye[n.from],(0,Z.jsx)(`span`,{className:`block text-body-sm text-muted`,children:W(n.modified)})]}),(0,Z.jsx)(`td`,{className:c(V,`whitespace-nowrap text-right`),children:(0,Z.jsxs)(`span`,{className:`inline-flex gap-1`,children:[(0,Z.jsx)(y,{size:`icon`,variant:`icon`,onClick:()=>i(n),"aria-label":`Open ${n.name}`,"data-tip":`Open it: steps, checks, test data, last run`,className:`size-8`,children:(0,Z.jsx)(ie,{"aria-hidden":`true`})}),(0,Z.jsx)(y,{size:`icon`,variant:`icon`,disabled:e.busy,onClick:()=>t(n),"aria-label":`Replay ${n.name}`,"data-tip":`Replay ${n.name}`,className:`size-8`,children:(0,Z.jsx)(D,{"aria-hidden":`true`})}),(0,Z.jsx)(y,{size:`icon`,variant:`icon`,disabled:e.busy,onClick:()=>void e.act(()=>f.validate(n.path)),"aria-label":`Check ${n.name}`,"data-tip":`Check it without running it`,className:`size-8`,children:(0,Z.jsx)(j,{"aria-hidden":`true`})}),(0,Z.jsx)(y,{size:`icon`,variant:`icon`,onClick:()=>void xe(`DeskPilot: look at the desktop workflow ${n.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 ${n.name} with the agent`,"data-tip":`Improve it with the agent`,className:`size-8`,children:(0,Z.jsx)(ee,{"aria-hidden":`true`})})]})})]},n.path))})}function Ae({page:e}){let{view:t}=e,[n,r]=(0,X.useState)(`all`),[i,a]=(0,X.useState)(``),o=t.runs.filter(e=>!e.ok),l=t.runs.filter($),u=n===`failed`?o:n===`heals`?l:t.runs;return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[i&&(0,Z.jsx)(`p`,{role:`status`,className:c(m.pass,`m-0`),children:i}),(0,Z.jsx)(z,{label:`Desktop runs`,minWidth:720,height:R,resetKey:n,placeholder:`Find a run`,empty:n===`all`?`No desktop runs yet: replay, record or explore a workflow.`:`None.`,tools:(0,Z.jsx)(_,{value:n,onChange:r,items:[{id:`all`,label:`All`,n:t.runs.length},{id:`failed`,label:`Failed`,n:o.length,alert:!0},{id:`heals`,label:`Heals to accept`,n:l.length}]}),head:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`th`,{scope:`col`,className:L,children:`Run`}),(0,Z.jsx)(`th`,{scope:`col`,className:L,children:`Result`}),(0,Z.jsx)(`th`,{scope:`col`,className:H,children:`Steps`}),(0,Z.jsx)(`th`,{scope:`col`,className:L,children:`Heals`}),(0,Z.jsx)(`th`,{scope:`col`,className:L,children:(0,Z.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]}),children:u.map(t=>(0,Z.jsxs)(`tr`,{className:F,children:[(0,Z.jsx)(`td`,{className:V,children:(0,Z.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,Z.jsxs)(`span`,{className:`font-medium`,children:[be[t.mode],`: `,t.name]}),(0,Z.jsx)(`span`,{className:`text-body-sm text-muted`,children:[t.app,W(t.at)].filter(Boolean).join(` · `)}),(t.failed||t.error)&&(0,Z.jsx)(`span`,{className:`max-w-[380px] truncate text-body-sm 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,Z.jsx)(`td`,{className:c(V,`whitespace-nowrap`),children:(0,Z.jsx)(v,{tone:t.ok?`pass`:`fail`,children:t.many?`${t.many.passed} of ${t.many.total}`:t.ok?`Passed`:`Failed`})}),(0,Z.jsx)(`td`,{className:U,children:t.steps||(0,Z.jsx)(`span`,{className:`text-muted`,children:`—`})}),(0,Z.jsx)(`td`,{className:c(V,`whitespace-nowrap`),children:t.heals?t.healsAccepted?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-body-sm text-pass`,children:[(0,Z.jsx)(T,{size:14,"aria-hidden":`true`}),`In the workflow`]}):t.ok?(0,Z.jsxs)(y,{size:`sm`,disabled:e.busy,onClick:()=>void e.act(async()=>{let e=await f.acceptHeals(t.dir);a(`Wrote ${s(e.written,`healed step`)} into ${e.workflow}.`)}),"data-tip":`Write the new locators into the workflow`,children:[(0,Z.jsx)(S,{"aria-hidden":`true`}),`Accept `,s(t.heals,`heal`)]}):(0,Z.jsxs)(`span`,{className:`text-body-sm text-muted`,"data-tip":`The replay failed after healing, so its heals may be wrong`,children:[s(t.heals,`heal`),`, not offered`]}):(0,Z.jsx)(`span`,{className:`text-muted`,children:`—`})}),(0,Z.jsx)(`td`,{className:c(V,`whitespace-nowrap text-right`),children:(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[t.report&&(0,Z.jsx)(ue,{path:t.report,children:`Report`}),!t.ok&&(0,Z.jsx)(y,{size:`icon`,variant:`icon`,onClick:()=>void xe(`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,Z.jsx)(te,{"aria-hidden":`true`})})]})})]},t.dir))})]})}function je({page:e,onSetup:t,onAdd:n,onEdit:i,onRemove:a}){let{view:s}=e,l=(s.driver===`auto`?s.windows?`pywinauto`:`agent-desktop`:s.driver)===`pywinauto`?`the mouse and keyboard`:`accessibility calls`,u=[{label:`Replay`,ok:s.engine.ready,note:s.engine.ready?`On ${l}`:(s.engine.error||`The desktop engine is not set up`).replace(/^./,e=>e.toUpperCase())},{label:`Explore and record`,ok:s.windows&&s.engine.ufo,note:s.windows?s.engine.ufo?`Set up`:`Not set up`:`Windows only`},{label:`Healing`,ok:s.heal,note:s.heal?`A moved control is healed with the model`:`desktop.heal is off`}],d=c(o,`flex flex-col`);return(0,Z.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,320px),1fr))] items-start gap-6`,children:[(0,Z.jsxs)(G,{id:`desktop-machine`,icon:N,title:`This machine`,divider:!1,children:[(0,Z.jsx)(`ul`,{className:c(d,`m-0 list-none divide-y divide-line-soft p-0`),children:u.map(e=>(0,Z.jsxs)(`li`,{className:`flex items-start gap-2 px-4 py-2`,children:[e.ok?(0,Z.jsx)(T,{size:16,"aria-label":`Ready`,className:`mt-1 flex-none text-pass`}):(0,Z.jsx)(C,{size:16,"aria-label":`Not ready`,className:`mt-1 flex-none text-warn`}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Z.jsx)(`span`,{className:`text-body-sm font-medium`,children:e.label}),(0,Z.jsx)(`span`,{className:`text-body-sm text-muted [overflow-wrap:anywhere]`,"data-tip":!e.ok&&e.label===`Explore and record`&&s.windowsOnly?s.windowsOnly:void 0,children:e.note})]})]},e.label))}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsxs)(y,{size:`sm`,disabled:e.busy,onClick:()=>void e.act(()=>f.doctor()),"data-tip":`Whether replay can run here unattended`,children:[(0,Z.jsx)(j,{"aria-hidden":`true`}),`Check`]}),(0,Z.jsxs)(y,{size:`sm`,variant:s.engine.ready?`outline`:`primary`,disabled:e.busy,onClick:t,"data-tip":`Download and set up the desktop engine`,children:[(0,Z.jsx)(S,{"aria-hidden":`true`}),`Set up`]})]})]}),(0,Z.jsxs)(G,{id:`desktop-apps`,icon:re,title:`Apps`,divider:!1,actions:(0,Z.jsxs)(y,{size:`sm`,onClick:n,"data-tip":`Add an app by its program on this computer`,children:[(0,Z.jsx)(x,{"aria-hidden":`true`}),`Add an app`]}),children:[s.apps.length?(0,Z.jsx)(`ul`,{className:c(d,`m-0 list-none divide-y divide-line-soft p-0`),children:s.apps.map(e=>(0,Z.jsxs)(`li`,{className:`group flex items-start gap-2 px-4 py-2`,children:[(0,Z.jsx)(g,{icon:N,size:16,className:`mt-1 flex-none text-muted`}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(`span`,{className:`text-body-sm font-medium`,children:e.name}),(0,Z.jsxs)(`span`,{className:`truncate font-mono text-body-sm text-muted`,"data-tip":[e.path,...e.args??[]].join(` `),children:[e.path||`No path`,e.args?.length?(0,Z.jsxs)(`span`,{className:`text-ink-2`,children:[` `,Ee(e.args)]}):null]}),e.description&&(0,Z.jsx)(`span`,{className:`text-body-sm text-muted`,children:e.description})]}),(0,Z.jsxs)(`span`,{className:`flex flex-none gap-1`,children:[(0,Z.jsx)(y,{size:`icon`,variant:`icon`,onClick:()=>i(e),"aria-label":`Change ${e.name}`,"data-tip":`Change ${e.name}`,className:`size-8`,children:(0,Z.jsx)(w,{"aria-hidden":`true`})}),(0,Z.jsx)(y,{size:`icon`,variant:`icon`,onClick:()=>a(e),"aria-label":`Remove ${e.name}`,"data-tip":`Remove ${e.name}`,className:`size-8 hover:text-fail`,children:(0,Z.jsx)(P,{"aria-hidden":`true`})})]})]},e.name))}):(0,Z.jsxs)(h,{className:`py-4`,children:[`No desktop apps yet: add one by its program, or in `,(0,Z.jsx)(`a`,{href:r(`settings`,`environments`),children:`Settings, Environments`}),`.`]}),(0,Z.jsxs)(`p`,{className:`m-0 text-body-sm text-muted`,children:[`Secrets a workflow may type: `,s.secrets.length?s.secrets.join(`, `):`none`,`.`,s.refusedSecrets.length>0&&(0,Z.jsxs)(`span`,{className:`text-fail`,children:[` `,s.refusedSecrets.join(`, `),` `,s.refusedSecrets.length===1?`is`:`are`,` ForgeQE's own: take `,s.refusedSecrets.length===1?`it`:`them`,` out of desktop.secrets, or nothing replays.`]})]})]})]})}function Me({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($).length,o=e.workflows.filter(e=>e.checks===0).length;return(0,Z.jsxs)(ce,{label:`Desktop at a glance`,children:[(0,Z.jsx)(I,{compact:!0,label:`Workflows`,value:e.workflows.length,note:o?(0,Z.jsxs)(`span`,{className:`text-warn`,children:[o,` without checks`]}):`${s(e.apps.length,`app`)}`}),(0,Z.jsx)(I,{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 ${W(i.at)}`:`None yet`}),(0,Z.jsx)(I,{compact:!0,label:`Heals to accept`,value:a,tone:a?`text-accent-fg`:void 0,note:a?(0,Z.jsx)(y,{variant:`link`,size:`inline`,onClick:()=>t(`runs`),children:`Review them`}):`From passed replays`}),(0,Z.jsx)(I,{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,Z.jsx)(y,{variant:`link`,size:`inline`,onClick:()=>t(`machine`),children:`Set it up`})})]})}function Ne({sub:e}){let t=Se(),{view:i,error:a}=t,o=u(`desktop`),s=(e??``).split(`/`),l=s[0]===`workflow`&&s[1]?n(s[1]):``,d=l?`workflows`:Q.includes(s[0])?s[0]:K,[p,h]=(0,X.useState)(null),[g,_]=(0,X.useState)(!1),[v,b]=(0,X.useState)(!1),[x,S]=(0,X.useState)(!1),[C,w]=(0,X.useState)(),[T,E]=(0,X.useState)(null),D=l&&i?.workflows.find(e=>e.path===l)||null,O=e=>location.hash=e?r(`desktop`,`workflow`,encodeURIComponent(e.path)):r(`desktop`,`workflows`),k=i?.job??null,A=e=>e===`agent`?r(`desktop`,K):r(`desktop`,e),j=e=>location.hash=A(e),M={workflows:`Workflows${i?` (${i.workflows.length})`:``}`,runs:`Runs${i?` (${i.runs.length})`:``}`,machine:`Machine and apps`};return(0,Z.jsxs)(fe,{title:le(`desktop`),page:o,label:`Desktop apps`,current:d,tabHref:A,onPick:j,tabs:Q.map(e=>({id:e,label:M[e],icon:_e[e]})),below:(0,Z.jsx)(de,{page:o}),children:[(0,Z.jsx)(`p`,{className:`m-0 text-body-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.`}),a&&(0,Z.jsx)(J,{text:a}),!i&&!a&&(0,Z.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Loading…`}),i&&D&&(0,Z.jsx)(ge,{workflow:D.path,backLabel:`Workflows`,tab:s[2],onTab:e=>location.hash=e===`steps`?r(`desktop`,`workflow`,encodeURIComponent(D.path)):r(`desktop`,`workflow`,encodeURIComponent(D.path),e),onClose:()=>{O(null),t.load()}},D.path),i&&!D&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Me,{view:i,onTab:j}),k&&(k.running||!k.endedAt||Date.now()-Date.parse(k.endedAt)<6e5)&&(0,Z.jsx)(pe,{job:k,onStop:t.stop,words:ve}),k?.question&&(0,Z.jsxs)(`div`,{className:c(m.info,`flex flex-col gap-2`),children:[(0,Z.jsx)(`p`,{className:`m-0 font-medium`,children:k.question.title}),k.question.detail&&(0,Z.jsx)(`p`,{className:`m-0 text-ink-2`,children:k.question.detail}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[k.question.options.map(e=>(0,Z.jsx)(y,{size:`sm`,onClick:()=>void t.act(()=>f.answer(k.question.id,e.id)),children:e.label},e.id)),(0,Z.jsxs)(y,{size:`sm`,variant:`danger`,onClick:()=>void t.act(()=>f.answer(k.question.id,null)),children:[(0,Z.jsx)(ne,{fill:`currentColor`,"aria-hidden":`true`}),`Stop`]})]})]}),(0,Z.jsxs)(`div`,{children:[d===`workflows`&&(0,Z.jsx)(ke,{page:{...t,view:i},onReplay:h,onExplore:()=>_(!0),onSteps:O}),d===`runs`&&(0,Z.jsx)(Ae,{page:{...t,view:i}}),d===`machine`&&(0,Z.jsx)(je,{page:{...t,view:i},onSetup:()=>b(!0),onAdd:()=>{w(void 0),S(!0)},onEdit:e=>{w(e),S(!0)},onRemove:E})]}),(0,Z.jsx)(Ce,{w:p,page:{...t,view:i},onClose:()=>h(null)}),(0,Z.jsx)(we,{open:g,page:{...t,view:i},onClose:()=>_(!1)}),(0,Z.jsx)(Te,{open:v,page:{...t,view:i},onClose:()=>b(!1)}),(0,Z.jsx)(De,{open:x,editing:C,page:{...t,view:i},onClose:()=>S(!1)}),(0,Z.jsx)(Oe,{app:T,page:{...t,view:i},onClose:()=>E(null)})]})]})}export{Ne as Desktop};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./react-BDur5s0O.js";import{r as n}from"./route-oDy8sV6H.js";import{B as r,F as i,L as a,a as o,l as s}from"./preload-helper-BupTYkQW.js";import{n as c,t as l}from"./utils-DJRAScIl.js";import{t as u}from"./jsx-runtime-LKYXHABd.js";import{U as d}from"./palette-6YAAmgkD.js";import{Y as f,w as p,y as m}from"./api-BsiuHmJq.js";import{C as h,_ as g,f as _,g as v,h as ee,x as y}from"./pageBack-CbyKfisx.js";import{Bt as b,Fr as te,Ln as x,Lr as S,Mn as C,N as w,Pn as T,Rr as ne,a as E,an as D,et as re,f as O,jr as k,mn as ie,st as A,vn as ae,w as j,yr as oe,z as se}from"./line-icons-CwCZidXs.js";import{Gt as ce,Kt as le,dt as M,ft as ue,kt as N}from"./frame-BMpSUo2-.js";import{t as de}from"./when-BuWCTaKm.js";import{t as fe}from"./code-Jek8uWUO.js";import{n as pe}from"./markdown-1wY7hIbM.js";import{U as P,W as me}from"./index-6SZomYE0.js";import{o as he}from"./dataParts-CkwgLllh.js";var F=e(t(),1),I=u(),ge={click:[`target`,`timeout`,`note`],double_click:[`target`,`timeout`,`note`],type:[`target`,`text`,`timeout`,`note`],select:[`target`,`value`,`timeout`,`note`],keys:[`keys`,`note`],expect:[`target`,`text`,`timeout`,`note`],wait:[`seconds`,`note`],wait_for:[`target`,`text`,`timeout`,`note`],launch:[`timeout`,`note`],close:[`note`],expect_image:[`timeout`,`note`]};function _e({p:e}){return(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsx)(`ul`,{className:`m-0 flex flex-col gap-1 pl-6 text-body-sm text-ink-2`,children:e.summary.map((e,t)=>(0,I.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:e},t))}),(0,I.jsx)(`pre`,{className:l(fe,`m-0 max-h-[200px]`),children:e.diff.map((e,t)=>(0,I.jsx)(`span`,{className:l(`block`,e.startsWith(`+`)?`text-pass`:e.startsWith(`-`)?`text-fail`:`text-muted`),children:e},t))})]})}function L({label:e,children:t}){return(0,I.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-body-sm font-medium`,children:[e,t]})}function ve({workflow:e,step:t,mode:n,onDone:r,onCancel:a}){let s=ge[t.op]??[`note`],c=t.fields??{},[u,d]=(0,F.useState)({automation_id:c.target?.automation_id??``,name:c.target?.name??``,control_type:c.target?.control_type??``}),[f,m]=(0,F.useState)(c.text??``),[g,_]=(0,F.useState)(c.value??``),[v,ee]=(0,F.useState)(c.keys??``),[b,te]=(0,F.useState)(c.seconds===void 0?``:String(c.seconds)),[x,S]=(0,F.useState)(c.timeout===void 0?``:String(c.timeout)),[w,T]=(0,F.useState)(c.note??``),[E,D]=(0,F.useState)(null),[re,O]=(0,F.useState)(``),[k,ie]=(0,F.useState)(!1),A=()=>{let e={};return s.includes(`target`)&&(u.automation_id!==(c.target?.automation_id??``)||u.name!==(c.target?.name??``)||u.control_type!==(c.target?.control_type??``))&&(e.target=u),s.includes(`text`)&&f!==(c.text??``)&&(e.text=f),s.includes(`value`)&&g!==(c.value??``)&&(e.value=g),s.includes(`keys`)&&v!==(c.keys??``)&&(e.keys=v),s.includes(`seconds`)&&b!==(c.seconds===void 0?``:String(c.seconds))&&(e.seconds=Number(b)),s.includes(`timeout`)&&x!==(c.timeout===void 0?``:String(c.timeout))&&x.trim()&&(e.timeout=Number(x)),s.includes(`note`)&&w!==(c.note??``)&&(e.note=w),e},ae=async i=>{ie(!0),O(``);try{let a=await p.editStep({workflow:e,step:t.n,action:n,...n===`edit`?{fields:A()}:{},...i?{version:i}:{}});a.written?r():D(a)}catch(e){O(e.message)}finally{ie(!1)}};(0,F.useEffect)(()=>{n===`remove`&&ae()},[]);let se=()=>D(null);return(0,I.jsxs)(`div`,{className:l(o,`mb-2 ml-10 flex flex-col gap-4`),children:[n===`edit`&&!E&&(0,I.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,180px),1fr))] gap-2`,children:[s.includes(`target`)&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(L,{label:`Control's name`,children:(0,I.jsx)(i,{size:`sm`,value:u.name,maxLength:300,onChange:e=>(d({...u,name:e.target.value}),se())})}),(0,I.jsx)(L,{label:`Automation id`,children:(0,I.jsx)(i,{size:`sm`,value:u.automation_id,maxLength:300,spellCheck:!1,onChange:e=>(d({...u,automation_id:e.target.value}),se()),className:`font-mono text-body-sm`})}),(0,I.jsx)(L,{label:`Control type`,children:(0,I.jsx)(i,{size:`sm`,value:u.control_type,maxLength:60,spellCheck:!1,placeholder:`Button`,onChange:e=>(d({...u,control_type:e.target.value}),se())})})]}),s.includes(`text`)&&(0,I.jsx)(L,{label:t.op===`type`?`Text to type`:`Text it shows`,children:(0,I.jsx)(i,{size:`sm`,value:f,maxLength:500,onChange:e=>m(e.target.value)})}),s.includes(`value`)&&(0,I.jsx)(L,{label:`Item to choose`,children:(0,I.jsx)(i,{size:`sm`,value:g,maxLength:500,onChange:e=>_(e.target.value)})}),s.includes(`keys`)&&(0,I.jsx)(L,{label:`Keys`,children:(0,I.jsx)(i,{size:`sm`,value:v,maxLength:100,spellCheck:!1,placeholder:`ctrl+s`,onChange:e=>ee(e.target.value),className:`font-mono text-body-sm`})}),s.includes(`seconds`)&&(0,I.jsx)(L,{label:`Wait (seconds)`,children:(0,I.jsx)(i,{size:`sm`,type:`number`,min:0,max:600,value:b,onChange:e=>te(e.target.value)})}),s.includes(`timeout`)&&(0,I.jsx)(L,{label:`Timeout (seconds)`,children:(0,I.jsx)(i,{size:`sm`,type:`number`,min:0,max:600,value:x,placeholder:`default`,onChange:e=>S(e.target.value)})}),s.includes(`note`)&&(0,I.jsx)(L,{label:`Note`,children:(0,I.jsx)(i,{size:`sm`,value:w,maxLength:200,onChange:e=>T(e.target.value)})})]}),n===`remove`&&!E&&!re&&(0,I.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Working out the change…`}),E&&(0,I.jsx)(_e,{p:E}),re&&(0,I.jsx)(`p`,{role:`alert`,className:l(h.fail,`m-0`),children:re}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[E?(0,I.jsxs)(y,{busy:k,size:`sm`,variant:n===`remove`?`destructive`:`primary`,disabled:k,onClick:()=>void ae(E.version),children:[n===`remove`?(0,I.jsx)(oe,{"aria-hidden":`true`}):(0,I.jsx)(j,{"aria-hidden":`true`}),k?`Saving…`:n===`remove`?`Delete step ${t.n}`:`Save the change`]}):n===`edit`&&(0,I.jsx)(y,{busy:k,size:`sm`,variant:`primary`,disabled:k||!Object.keys(A()).length,onClick:()=>void ae(),children:k?`Checking…`:`Preview the change`}),E&&n===`edit`&&(0,I.jsxs)(y,{size:`sm`,onClick:()=>D(null),children:[(0,I.jsx)(C,{"aria-hidden":`true`}),`Change it more`]}),(0,I.jsxs)(y,{size:`sm`,variant:`ghost`,onClick:a,children:[(0,I.jsx)(ne,{"aria-hidden":`true`}),`Cancel`]})]})]})}function R(e,t){let n={values:{},secrets:{}};for(let r of e?.inputs??[])r.kind!==`data`&&r.env&&t.includes(r.env)&&(n.secrets[r.name]=r.env);return n}function z(e,t){return(e?.inputs??[]).every(e=>e.kind===`data`?e.default!==void 0||!!t.values[e.name]?.trim():!!t.secrets[e.name])}function B(e){return{values:Object.fromEntries(Object.entries(e.values).filter(([,e])=>e.trim())),secrets:e.secrets}}function V({block:e,secrets:t,use:n,onChange:r,disabled:o,unset:s=[]}){return e.inputs.length?(0,I.jsxs)(`fieldset`,{className:`m-0 flex min-w-0 flex-col gap-2 border-0 p-0`,children:[(0,I.jsx)(`legend`,{className:`mb-1 p-0 text-body-sm font-medium text-ink-2`,children:`What the block types`}),e.inputs.map(e=>{let c=e.label||e.name;return e.kind===`data`?(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm text-ink-2`,children:[c,` `,(0,I.jsx)(`span`,{className:`text-muted`,children:`(test data)`}),(0,I.jsx)(i,{value:n.values[e.name]??``,maxLength:300,disabled:o,placeholder:e.default===void 0?`A value`:e.default||`(empty)`,onChange:t=>r({...n,values:{...n.values,[e.name]:t.target.value}})})]},e.name):(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm text-ink-2`,children:[c,` `,(0,I.jsxs)(`span`,{className:`text-muted`,children:[`(`,e.kind===`totp`?`authenticator secret`:`secret`,`)`]}),(0,I.jsxs)(a,{value:n.secrets[e.name]??``,disabled:o||!t.length,onChange:t=>r({...n,secrets:{...n.secrets,[e.name]:t.target.value}}),children:[(0,I.jsx)(`option`,{value:``,children:t.length?`Pick a saved secret`:`No saved secrets yet`}),t.map(e=>(0,I.jsxs)(`option`,{value:e,children:[e,s.includes(e)?` (no value here)`:``]},e))]}),n.secrets[e.name]&&s.includes(n.secrets[e.name])&&(0,I.jsxs)(`span`,{className:`text-warn`,children:[n.secrets[e.name],` has no value on this computer: save it in Settings › Secrets, or the step that types it fails.`]}),!t.length&&(0,I.jsx)(`span`,{className:`text-muted`,children:`Save one in Settings › Secrets, then come back.`}),e.env&&!t.includes(e.env)&&(0,I.jsxs)(`span`,{className:`text-muted`,children:[`The block was made with `,e.env,`, which has no saved value here.`]})]},e.name)})]}):null}function ye({block:e}){return e.lines.length?(0,I.jsxs)(`details`,{className:`text-body-sm text-ink-2`,children:[(0,I.jsxs)(`summary`,{className:`cursor-pointer select-none text-muted`,children:[`See its `,e.steps,` `,e.steps===1?`step`:`steps`]}),(0,I.jsxs)(`ol`,{className:`m-0 mt-1 flex list-decimal flex-col gap-1 pl-6`,children:[e.lines.map((e,t)=>(0,I.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:e},t)),e.steps>e.lines.length&&(0,I.jsxs)(`li`,{className:`list-none text-muted`,children:[`and `,e.steps-e.lines.length,` more`]})]})]}):null}var be=[`steps`,`data`,`run`],xe=[{id:`typed`,label:`As typed`,note:`The workflow types exactly this.`},{id:`data`,label:`Test data`,note:`A named value the replay fills in: its own value, a row of a data file, or one you give when it runs.`},{id:`secret`,label:`Secret`,note:`Read from an environment variable when it replays; what was typed leaves the workflow.`},{id:`unique`,label:`New on each run`,note:`A fresh value each time, like this one: for an email or a name that must not repeat.`},{id:`date`,label:`A date from today`,note:`Counted from today, the same number of days ahead on each replay, so a day that has passed is never clicked.`},{id:`any`,label:`Any free one`,note:`Each replay clicks the first control of this kind there that is not greyed out (an open slot); later checks compare with what it picked.`}],H={label:`As clicked`,note:`The workflow clicks exactly this one.`},U={replay:[`Replaying the workflow`,`Replayed the workflow`,`working`],validate:[`Checking the workflow`,`Checked the workflow`,`searching`]};async function W(e){let t=await p.editStep(e);await p.editStep({...e,version:t.version})}var Se=[{id:`check_text`,label:`Check a control shows a text`,control:!0,text:`need`},{id:`check_present`,label:`Check a control is there`,control:!0},{id:`wait_for`,label:`Wait for a control`,control:!0,text:`may`},{id:`wait_gone`,label:`Wait until a control is gone`,control:!0},{id:`wait`,label:`Wait some seconds`,control:!1},{id:`keys`,label:`Press keys`,control:!1}];function Ce({step:e,blocks:t,secrets:n,unset:r,onAdd:i}){let[o,s]=(0,F.useState)(t[0]?.id??``),c=t.find(e=>e.id===o)??t[0],[l,u]=(0,F.useState)(()=>R(c,n)),[d,f]=(0,F.useState)(!1);return c?d?(0,I.jsxs)(`form`,{className:`flex flex-col gap-2 border-t border-line-soft p-4`,onSubmit:e=>{e.preventDefault(),z(c,l)&&i(c.id,B(l))},children:[(0,I.jsxs)(`p`,{className:`m-0 text-body-sm font-medium`,children:[`Or put in a block after step `,e.n]}),(0,I.jsx)(a,{size:`sm`,"aria-label":`The block to put in after step ${e.n}`,value:c.id,onChange:e=>{s(e.target.value),u(R(t.find(t=>t.id===e.target.value),n))},children:t.map(e=>(0,I.jsxs)(`option`,{value:e.id,children:[e.section?`${e.section} › `:``,e.name,` · `,e.steps,` `,e.steps===1?`step`:`steps`]},e.id))}),(0,I.jsx)(ye,{block:c}),(0,I.jsx)(V,{block:c,secrets:n,use:l,onChange:u,unset:r}),(0,I.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`Its steps go in after this one, marked as the block's; its test data become variables of this workflow.`}),(0,I.jsxs)(y,{type:`submit`,size:`sm`,variant:`accent`,disabled:!z(c,l),className:`self-start`,"data-tip":`Put the block in after this step`,children:[(0,I.jsx)(x,{"aria-hidden":`true`}),`Add`]})]}):(0,I.jsx)(`div`,{className:`border-t border-line-soft px-4 py-2`,children:(0,I.jsxs)(y,{size:`sm`,variant:`ghost`,onClick:()=>f(!0),"data-tip":`Put a saved block of this app in after step ${e.n}`,children:[(0,I.jsx)(O,{"aria-hidden":`true`}),`Put in a block instead`]})}):null}function we({f:e,block:t,secrets:n,unset:r,busy:i,onUpdate:a}){let[o,s]=(0,F.useState)(!1),[c,u]=(0,F.useState)({values:{},secrets:{}});return(0,I.jsxs)(`div`,{role:`status`,className:l(h.info,`flex flex-col gap-2`),children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,I.jsxs)(`span`,{className:`min-w-0 flex-[1_1_240px]`,children:[`Steps `,e.from,` to `,e.to,` are `,e.version?`version ${e.version}`:`an older version`,` of the block `,(0,I.jsx)(`strong`,{className:`font-medium`,children:e.name}),`; version `,e.latest,` is saved now.`]}),(0,I.jsxs)(y,{size:`sm`,disabled:i,onClick:()=>void a(o?B(c):void 0).then(e=>{!e&&t?.inputs.length&&s(!0)}),"data-tip":`Put the saved version in their place, with the same values`,children:[(0,I.jsx)(j,{"aria-hidden":`true`}),o?`Update with these`:`Update`]})]}),o&&t&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`m-0 text-body-sm text-ink-2`,children:`Not every value of the old copy could be found: give the ones it needs. Empty ones keep the old copy's or the block's own.`}),(0,I.jsx)(V,{block:t,secrets:n,use:c,onChange:u,disabled:i,unset:r})]})]})}function Te({blocks:e,busy:t,act:n}){let[r,a]=(0,F.useState)(null),[o,u]=(0,F.useState)(null);return e.length?(0,I.jsx)(P,{level:3,icon:O,title:`Blocks of this app`,className:`gap-2`,children:(0,I.jsx)(`ul`,{className:l(s,`m-0 flex list-none flex-col p-0`),children:e.map((e,s)=>(0,I.jsxs)(`li`,{className:l(`flex flex-col gap-2 px-4 py-2`,s>0&&`border-t border-line-soft`),children:[r?.id===e.id?(0,I.jsxs)(`form`,{className:`flex flex-wrap items-end gap-2`,onSubmit:t=>{t.preventDefault(),n(async()=>(await f.updateBlock(e.id,{name:r.name,section:r.section}),a(null),`The block "${r.name}" is saved as a new version.`))},children:[(0,I.jsxs)(`label`,{className:`flex min-w-[160px] flex-1 flex-col gap-1 text-body-sm font-medium text-ink-2`,children:[`Name`,(0,I.jsx)(i,{size:`sm`,value:r.name,maxLength:80,onChange:e=>a({...r,name:e.target.value})})]}),(0,I.jsxs)(`label`,{className:`flex min-w-[120px] flex-col gap-1 text-body-sm font-medium text-ink-2`,children:[`Section`,(0,I.jsx)(i,{size:`sm`,value:r.section,maxLength:40,onChange:e=>a({...r,section:e.target.value})})]}),(0,I.jsxs)(y,{type:`submit`,size:`sm`,variant:`primary`,disabled:t||!r.name.trim(),"data-tip":`Save the block as a new version`,children:[(0,I.jsx)(j,{"aria-hidden":`true`}),`Save`]}),(0,I.jsxs)(y,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>a(null),children:[(0,I.jsx)(ne,{"aria-hidden":`true`}),`Cancel`]})]}):(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1`,children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-[1_1_220px] flex-col`,children:[(0,I.jsxs)(`span`,{className:`text-body-sm font-medium text-ink [overflow-wrap:anywhere]`,children:[e.section?`${e.section} › `:``,e.name,` `,(0,I.jsxs)(`span`,{className:`font-normal text-muted`,children:[`v`,e.version,` · `,c(e.steps,`step`)]})]}),e.inputs.length>0&&(0,I.jsxs)(`span`,{className:`text-body-sm text-muted`,children:[`Takes `,e.inputs.map(e=>`${e.label||e.name}${e.kind===`data`?``:` (secret)`}`).join(`, `)]}),(0,I.jsx)(ye,{block:e})]}),(0,I.jsx)(y,{size:`icon`,variant:`icon`,disabled:t,"aria-label":`Change the block ${e.name}`,"data-tip":`Change the block ${e.name}`,onClick:()=>a({id:e.id,name:e.name,section:e.section??``}),className:`size-8`,children:(0,I.jsx)(C,{"aria-hidden":`true`})}),(0,I.jsx)(y,{size:`icon`,variant:`icon`,disabled:t,"aria-label":o?.id===e.id?`Delete the block ${e.name} anyway`:`Delete the block ${e.name}`,"data-tip":o?.id===e.id?`Delete it anyway`:`Delete the block ${e.name}`,onClick:()=>n(async()=>{try{await f.deleteBlock(e.id,o?.id===e.id)}catch(t){let n=t;if(n.status!==409)throw n;u({id:e.id,why:n.message});return}return u(null),`The block "${e.name}" is deleted; the steps workflows have of it stay.`}),className:`size-8`,children:(0,I.jsx)(oe,{"aria-hidden":`true`})})]}),o?.id===e.id&&(0,I.jsxs)(`p`,{className:l(h.warn,`m-0`),children:[o.why,` Click delete again to delete it anyway.`]})]},e.id))})}):null}function Ee({history:e,busy:t,onPreview:n,onBack:r}){let[i,a]=(0,F.useState)(null);return e.length?(0,I.jsxs)(P,{level:3,icon:b,title:`Earlier versions`,className:`gap-2`,children:[(0,I.jsx)(`ol`,{className:l(s,`m-0 flex list-none flex-col p-0`),children:e.slice(0,10).map((e,r)=>(0,I.jsxs)(`li`,{className:l(`flex items-center gap-4 px-4 py-2`,r>0&&`border-t border-line-soft`),children:[(0,I.jsxs)(`span`,{className:`min-w-0 flex-1 text-body-sm text-ink-2`,children:[`Before the change of `,de(e.at)||e.name.slice(0,19)]}),(0,I.jsxs)(y,{size:`sm`,variant:`ghost`,disabled:t,onClick:()=>void n(e.name).then(t=>t&&a({name:e.name,...t})),"data-tip":`See what going back to this version changes`,children:[(0,I.jsx)(A,{"aria-hidden":`true`}),`Go back`]})]},e.name))}),i&&(0,I.jsxs)(`div`,{role:`status`,className:l(`surface rounded-lg bg-bg p-6 shadow-sm`,`flex flex-col gap-2`),children:[(0,I.jsx)(`p`,{className:`m-0 text-body-sm font-medium`,children:`Going back changes this:`}),(0,I.jsx)(`pre`,{className:l(`overflow-auto rounded-base bg-surface-muted p-4 font-mono text-body-sm leading-relaxed whitespace-pre-wrap text-ink-2 [overflow-wrap:anywhere]`,`m-0 max-h-[240px]`),children:i.diff.join(`
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./react-BDur5s0O.js";import{r as n}from"./route-oDy8sV6H.js";import{B as r,F as i,L as a,a as o,l as s}from"./preload-helper-BupTYkQW.js";import{n as c,t as l}from"./utils-DJRAScIl.js";import{t as u}from"./jsx-runtime-LKYXHABd.js";import{U as d}from"./palette-6YAAmgkD.js";import{Y as f,w as p,y as m}from"./api-BsiuHmJq.js";import{C as h,_ as g,f as _,g as v,h as ee,x as y}from"./pageBack-CbyKfisx.js";import{Bt as b,Fr as te,Ln as x,Lr as S,Mn as C,N as w,Pn as T,Rr as ne,a as E,an as D,et as re,f as O,jr as k,mn as ie,st as A,vn as ae,w as j,yr as oe,z as se}from"./line-icons-CwCZidXs.js";import{Gt as ce,Kt as le,dt as M,ft as ue,kt as N}from"./frame-CgBYYtdw.js";import{t as de}from"./when-BuWCTaKm.js";import{t as fe}from"./code-Jek8uWUO.js";import{n as pe}from"./markdown-CwgDQU8m.js";import{U as P,W as me}from"./index-Ctos0-8H.js";import{o as he}from"./dataParts-_X5zGtE9.js";var F=e(t(),1),I=u(),ge={click:[`target`,`timeout`,`note`],double_click:[`target`,`timeout`,`note`],type:[`target`,`text`,`timeout`,`note`],select:[`target`,`value`,`timeout`,`note`],keys:[`keys`,`note`],expect:[`target`,`text`,`timeout`,`note`],wait:[`seconds`,`note`],wait_for:[`target`,`text`,`timeout`,`note`],launch:[`timeout`,`note`],close:[`note`],expect_image:[`timeout`,`note`]};function _e({p:e}){return(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsx)(`ul`,{className:`m-0 flex flex-col gap-1 pl-6 text-body-sm text-ink-2`,children:e.summary.map((e,t)=>(0,I.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:e},t))}),(0,I.jsx)(`pre`,{className:l(fe,`m-0 max-h-[200px]`),children:e.diff.map((e,t)=>(0,I.jsx)(`span`,{className:l(`block`,e.startsWith(`+`)?`text-pass`:e.startsWith(`-`)?`text-fail`:`text-muted`),children:e},t))})]})}function L({label:e,children:t}){return(0,I.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-body-sm font-medium`,children:[e,t]})}function ve({workflow:e,step:t,mode:n,onDone:r,onCancel:a}){let s=ge[t.op]??[`note`],c=t.fields??{},[u,d]=(0,F.useState)({automation_id:c.target?.automation_id??``,name:c.target?.name??``,control_type:c.target?.control_type??``}),[f,m]=(0,F.useState)(c.text??``),[g,_]=(0,F.useState)(c.value??``),[v,ee]=(0,F.useState)(c.keys??``),[b,te]=(0,F.useState)(c.seconds===void 0?``:String(c.seconds)),[x,S]=(0,F.useState)(c.timeout===void 0?``:String(c.timeout)),[w,T]=(0,F.useState)(c.note??``),[E,D]=(0,F.useState)(null),[re,O]=(0,F.useState)(``),[k,ie]=(0,F.useState)(!1),A=()=>{let e={};return s.includes(`target`)&&(u.automation_id!==(c.target?.automation_id??``)||u.name!==(c.target?.name??``)||u.control_type!==(c.target?.control_type??``))&&(e.target=u),s.includes(`text`)&&f!==(c.text??``)&&(e.text=f),s.includes(`value`)&&g!==(c.value??``)&&(e.value=g),s.includes(`keys`)&&v!==(c.keys??``)&&(e.keys=v),s.includes(`seconds`)&&b!==(c.seconds===void 0?``:String(c.seconds))&&(e.seconds=Number(b)),s.includes(`timeout`)&&x!==(c.timeout===void 0?``:String(c.timeout))&&x.trim()&&(e.timeout=Number(x)),s.includes(`note`)&&w!==(c.note??``)&&(e.note=w),e},ae=async i=>{ie(!0),O(``);try{let a=await p.editStep({workflow:e,step:t.n,action:n,...n===`edit`?{fields:A()}:{},...i?{version:i}:{}});a.written?r():D(a)}catch(e){O(e.message)}finally{ie(!1)}};(0,F.useEffect)(()=>{n===`remove`&&ae()},[]);let se=()=>D(null);return(0,I.jsxs)(`div`,{className:l(o,`mb-2 ml-10 flex flex-col gap-4`),children:[n===`edit`&&!E&&(0,I.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,180px),1fr))] gap-2`,children:[s.includes(`target`)&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(L,{label:`Control's name`,children:(0,I.jsx)(i,{size:`sm`,value:u.name,maxLength:300,onChange:e=>(d({...u,name:e.target.value}),se())})}),(0,I.jsx)(L,{label:`Automation id`,children:(0,I.jsx)(i,{size:`sm`,value:u.automation_id,maxLength:300,spellCheck:!1,onChange:e=>(d({...u,automation_id:e.target.value}),se()),className:`font-mono text-body-sm`})}),(0,I.jsx)(L,{label:`Control type`,children:(0,I.jsx)(i,{size:`sm`,value:u.control_type,maxLength:60,spellCheck:!1,placeholder:`Button`,onChange:e=>(d({...u,control_type:e.target.value}),se())})})]}),s.includes(`text`)&&(0,I.jsx)(L,{label:t.op===`type`?`Text to type`:`Text it shows`,children:(0,I.jsx)(i,{size:`sm`,value:f,maxLength:500,onChange:e=>m(e.target.value)})}),s.includes(`value`)&&(0,I.jsx)(L,{label:`Item to choose`,children:(0,I.jsx)(i,{size:`sm`,value:g,maxLength:500,onChange:e=>_(e.target.value)})}),s.includes(`keys`)&&(0,I.jsx)(L,{label:`Keys`,children:(0,I.jsx)(i,{size:`sm`,value:v,maxLength:100,spellCheck:!1,placeholder:`ctrl+s`,onChange:e=>ee(e.target.value),className:`font-mono text-body-sm`})}),s.includes(`seconds`)&&(0,I.jsx)(L,{label:`Wait (seconds)`,children:(0,I.jsx)(i,{size:`sm`,type:`number`,min:0,max:600,value:b,onChange:e=>te(e.target.value)})}),s.includes(`timeout`)&&(0,I.jsx)(L,{label:`Timeout (seconds)`,children:(0,I.jsx)(i,{size:`sm`,type:`number`,min:0,max:600,value:x,placeholder:`default`,onChange:e=>S(e.target.value)})}),s.includes(`note`)&&(0,I.jsx)(L,{label:`Note`,children:(0,I.jsx)(i,{size:`sm`,value:w,maxLength:200,onChange:e=>T(e.target.value)})})]}),n===`remove`&&!E&&!re&&(0,I.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Working out the change…`}),E&&(0,I.jsx)(_e,{p:E}),re&&(0,I.jsx)(`p`,{role:`alert`,className:l(h.fail,`m-0`),children:re}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[E?(0,I.jsxs)(y,{busy:k,size:`sm`,variant:n===`remove`?`destructive`:`primary`,disabled:k,onClick:()=>void ae(E.version),children:[n===`remove`?(0,I.jsx)(oe,{"aria-hidden":`true`}):(0,I.jsx)(j,{"aria-hidden":`true`}),k?`Saving…`:n===`remove`?`Delete step ${t.n}`:`Save the change`]}):n===`edit`&&(0,I.jsx)(y,{busy:k,size:`sm`,variant:`primary`,disabled:k||!Object.keys(A()).length,onClick:()=>void ae(),children:k?`Checking…`:`Preview the change`}),E&&n===`edit`&&(0,I.jsxs)(y,{size:`sm`,onClick:()=>D(null),children:[(0,I.jsx)(C,{"aria-hidden":`true`}),`Change it more`]}),(0,I.jsxs)(y,{size:`sm`,variant:`ghost`,onClick:a,children:[(0,I.jsx)(ne,{"aria-hidden":`true`}),`Cancel`]})]})]})}function R(e,t){let n={values:{},secrets:{}};for(let r of e?.inputs??[])r.kind!==`data`&&r.env&&t.includes(r.env)&&(n.secrets[r.name]=r.env);return n}function z(e,t){return(e?.inputs??[]).every(e=>e.kind===`data`?e.default!==void 0||!!t.values[e.name]?.trim():!!t.secrets[e.name])}function B(e){return{values:Object.fromEntries(Object.entries(e.values).filter(([,e])=>e.trim())),secrets:e.secrets}}function V({block:e,secrets:t,use:n,onChange:r,disabled:o,unset:s=[]}){return e.inputs.length?(0,I.jsxs)(`fieldset`,{className:`m-0 flex min-w-0 flex-col gap-2 border-0 p-0`,children:[(0,I.jsx)(`legend`,{className:`mb-1 p-0 text-body-sm font-medium text-ink-2`,children:`What the block types`}),e.inputs.map(e=>{let c=e.label||e.name;return e.kind===`data`?(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm text-ink-2`,children:[c,` `,(0,I.jsx)(`span`,{className:`text-muted`,children:`(test data)`}),(0,I.jsx)(i,{value:n.values[e.name]??``,maxLength:300,disabled:o,placeholder:e.default===void 0?`A value`:e.default||`(empty)`,onChange:t=>r({...n,values:{...n.values,[e.name]:t.target.value}})})]},e.name):(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm text-ink-2`,children:[c,` `,(0,I.jsxs)(`span`,{className:`text-muted`,children:[`(`,e.kind===`totp`?`authenticator secret`:`secret`,`)`]}),(0,I.jsxs)(a,{value:n.secrets[e.name]??``,disabled:o||!t.length,onChange:t=>r({...n,secrets:{...n.secrets,[e.name]:t.target.value}}),children:[(0,I.jsx)(`option`,{value:``,children:t.length?`Pick a saved secret`:`No saved secrets yet`}),t.map(e=>(0,I.jsxs)(`option`,{value:e,children:[e,s.includes(e)?` (no value here)`:``]},e))]}),n.secrets[e.name]&&s.includes(n.secrets[e.name])&&(0,I.jsxs)(`span`,{className:`text-warn`,children:[n.secrets[e.name],` has no value on this computer: save it in Settings › Secrets, or the step that types it fails.`]}),!t.length&&(0,I.jsx)(`span`,{className:`text-muted`,children:`Save one in Settings › Secrets, then come back.`}),e.env&&!t.includes(e.env)&&(0,I.jsxs)(`span`,{className:`text-muted`,children:[`The block was made with `,e.env,`, which has no saved value here.`]})]},e.name)})]}):null}function ye({block:e}){return e.lines.length?(0,I.jsxs)(`details`,{className:`text-body-sm text-ink-2`,children:[(0,I.jsxs)(`summary`,{className:`cursor-pointer select-none text-muted`,children:[`See its `,e.steps,` `,e.steps===1?`step`:`steps`]}),(0,I.jsxs)(`ol`,{className:`m-0 mt-1 flex list-decimal flex-col gap-1 pl-6`,children:[e.lines.map((e,t)=>(0,I.jsx)(`li`,{className:`[overflow-wrap:anywhere]`,children:e},t)),e.steps>e.lines.length&&(0,I.jsxs)(`li`,{className:`list-none text-muted`,children:[`and `,e.steps-e.lines.length,` more`]})]})]}):null}var be=[`steps`,`data`,`run`],xe=[{id:`typed`,label:`As typed`,note:`The workflow types exactly this.`},{id:`data`,label:`Test data`,note:`A named value the replay fills in: its own value, a row of a data file, or one you give when it runs.`},{id:`secret`,label:`Secret`,note:`Read from an environment variable when it replays; what was typed leaves the workflow.`},{id:`unique`,label:`New on each run`,note:`A fresh value each time, like this one: for an email or a name that must not repeat.`},{id:`date`,label:`A date from today`,note:`Counted from today, the same number of days ahead on each replay, so a day that has passed is never clicked.`},{id:`any`,label:`Any free one`,note:`Each replay clicks the first control of this kind there that is not greyed out (an open slot); later checks compare with what it picked.`}],H={label:`As clicked`,note:`The workflow clicks exactly this one.`},U={replay:[`Replaying the workflow`,`Replayed the workflow`,`working`],validate:[`Checking the workflow`,`Checked the workflow`,`searching`]};async function W(e){let t=await p.editStep(e);await p.editStep({...e,version:t.version})}var Se=[{id:`check_text`,label:`Check a control shows a text`,control:!0,text:`need`},{id:`check_present`,label:`Check a control is there`,control:!0},{id:`wait_for`,label:`Wait for a control`,control:!0,text:`may`},{id:`wait_gone`,label:`Wait until a control is gone`,control:!0},{id:`wait`,label:`Wait some seconds`,control:!1},{id:`keys`,label:`Press keys`,control:!1}];function Ce({step:e,blocks:t,secrets:n,unset:r,onAdd:i}){let[o,s]=(0,F.useState)(t[0]?.id??``),c=t.find(e=>e.id===o)??t[0],[l,u]=(0,F.useState)(()=>R(c,n)),[d,f]=(0,F.useState)(!1);return c?d?(0,I.jsxs)(`form`,{className:`flex flex-col gap-2 border-t border-line-soft p-4`,onSubmit:e=>{e.preventDefault(),z(c,l)&&i(c.id,B(l))},children:[(0,I.jsxs)(`p`,{className:`m-0 text-body-sm font-medium`,children:[`Or put in a block after step `,e.n]}),(0,I.jsx)(a,{size:`sm`,"aria-label":`The block to put in after step ${e.n}`,value:c.id,onChange:e=>{s(e.target.value),u(R(t.find(t=>t.id===e.target.value),n))},children:t.map(e=>(0,I.jsxs)(`option`,{value:e.id,children:[e.section?`${e.section} › `:``,e.name,` · `,e.steps,` `,e.steps===1?`step`:`steps`]},e.id))}),(0,I.jsx)(ye,{block:c}),(0,I.jsx)(V,{block:c,secrets:n,use:l,onChange:u,unset:r}),(0,I.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`Its steps go in after this one, marked as the block's; its test data become variables of this workflow.`}),(0,I.jsxs)(y,{type:`submit`,size:`sm`,variant:`accent`,disabled:!z(c,l),className:`self-start`,"data-tip":`Put the block in after this step`,children:[(0,I.jsx)(x,{"aria-hidden":`true`}),`Add`]})]}):(0,I.jsx)(`div`,{className:`border-t border-line-soft px-4 py-2`,children:(0,I.jsxs)(y,{size:`sm`,variant:`ghost`,onClick:()=>f(!0),"data-tip":`Put a saved block of this app in after step ${e.n}`,children:[(0,I.jsx)(O,{"aria-hidden":`true`}),`Put in a block instead`]})}):null}function we({f:e,block:t,secrets:n,unset:r,busy:i,onUpdate:a}){let[o,s]=(0,F.useState)(!1),[c,u]=(0,F.useState)({values:{},secrets:{}});return(0,I.jsxs)(`div`,{role:`status`,className:l(h.info,`flex flex-col gap-2`),children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,I.jsxs)(`span`,{className:`min-w-0 flex-[1_1_240px]`,children:[`Steps `,e.from,` to `,e.to,` are `,e.version?`version ${e.version}`:`an older version`,` of the block `,(0,I.jsx)(`strong`,{className:`font-medium`,children:e.name}),`; version `,e.latest,` is saved now.`]}),(0,I.jsxs)(y,{size:`sm`,disabled:i,onClick:()=>void a(o?B(c):void 0).then(e=>{!e&&t?.inputs.length&&s(!0)}),"data-tip":`Put the saved version in their place, with the same values`,children:[(0,I.jsx)(j,{"aria-hidden":`true`}),o?`Update with these`:`Update`]})]}),o&&t&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`m-0 text-body-sm text-ink-2`,children:`Not every value of the old copy could be found: give the ones it needs. Empty ones keep the old copy's or the block's own.`}),(0,I.jsx)(V,{block:t,secrets:n,use:c,onChange:u,disabled:i,unset:r})]})]})}function Te({blocks:e,busy:t,act:n}){let[r,a]=(0,F.useState)(null),[o,u]=(0,F.useState)(null);return e.length?(0,I.jsx)(P,{level:3,icon:O,title:`Blocks of this app`,className:`gap-2`,children:(0,I.jsx)(`ul`,{className:l(s,`m-0 flex list-none flex-col p-0`),children:e.map((e,s)=>(0,I.jsxs)(`li`,{className:l(`flex flex-col gap-2 px-4 py-2`,s>0&&`border-t border-line-soft`),children:[r?.id===e.id?(0,I.jsxs)(`form`,{className:`flex flex-wrap items-end gap-2`,onSubmit:t=>{t.preventDefault(),n(async()=>(await f.updateBlock(e.id,{name:r.name,section:r.section}),a(null),`The block "${r.name}" is saved as a new version.`))},children:[(0,I.jsxs)(`label`,{className:`flex min-w-[160px] flex-1 flex-col gap-1 text-body-sm font-medium text-ink-2`,children:[`Name`,(0,I.jsx)(i,{size:`sm`,value:r.name,maxLength:80,onChange:e=>a({...r,name:e.target.value})})]}),(0,I.jsxs)(`label`,{className:`flex min-w-[120px] flex-col gap-1 text-body-sm font-medium text-ink-2`,children:[`Section`,(0,I.jsx)(i,{size:`sm`,value:r.section,maxLength:40,onChange:e=>a({...r,section:e.target.value})})]}),(0,I.jsxs)(y,{type:`submit`,size:`sm`,variant:`primary`,disabled:t||!r.name.trim(),"data-tip":`Save the block as a new version`,children:[(0,I.jsx)(j,{"aria-hidden":`true`}),`Save`]}),(0,I.jsxs)(y,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>a(null),children:[(0,I.jsx)(ne,{"aria-hidden":`true`}),`Cancel`]})]}):(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1`,children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-[1_1_220px] flex-col`,children:[(0,I.jsxs)(`span`,{className:`text-body-sm font-medium text-ink [overflow-wrap:anywhere]`,children:[e.section?`${e.section} › `:``,e.name,` `,(0,I.jsxs)(`span`,{className:`font-normal text-muted`,children:[`v`,e.version,` · `,c(e.steps,`step`)]})]}),e.inputs.length>0&&(0,I.jsxs)(`span`,{className:`text-body-sm text-muted`,children:[`Takes `,e.inputs.map(e=>`${e.label||e.name}${e.kind===`data`?``:` (secret)`}`).join(`, `)]}),(0,I.jsx)(ye,{block:e})]}),(0,I.jsx)(y,{size:`icon`,variant:`icon`,disabled:t,"aria-label":`Change the block ${e.name}`,"data-tip":`Change the block ${e.name}`,onClick:()=>a({id:e.id,name:e.name,section:e.section??``}),className:`size-8`,children:(0,I.jsx)(C,{"aria-hidden":`true`})}),(0,I.jsx)(y,{size:`icon`,variant:`icon`,disabled:t,"aria-label":o?.id===e.id?`Delete the block ${e.name} anyway`:`Delete the block ${e.name}`,"data-tip":o?.id===e.id?`Delete it anyway`:`Delete the block ${e.name}`,onClick:()=>n(async()=>{try{await f.deleteBlock(e.id,o?.id===e.id)}catch(t){let n=t;if(n.status!==409)throw n;u({id:e.id,why:n.message});return}return u(null),`The block "${e.name}" is deleted; the steps workflows have of it stay.`}),className:`size-8`,children:(0,I.jsx)(oe,{"aria-hidden":`true`})})]}),o?.id===e.id&&(0,I.jsxs)(`p`,{className:l(h.warn,`m-0`),children:[o.why,` Click delete again to delete it anyway.`]})]},e.id))})}):null}function Ee({history:e,busy:t,onPreview:n,onBack:r}){let[i,a]=(0,F.useState)(null);return e.length?(0,I.jsxs)(P,{level:3,icon:b,title:`Earlier versions`,className:`gap-2`,children:[(0,I.jsx)(`ol`,{className:l(s,`m-0 flex list-none flex-col p-0`),children:e.slice(0,10).map((e,r)=>(0,I.jsxs)(`li`,{className:l(`flex items-center gap-4 px-4 py-2`,r>0&&`border-t border-line-soft`),children:[(0,I.jsxs)(`span`,{className:`min-w-0 flex-1 text-body-sm text-ink-2`,children:[`Before the change of `,de(e.at)||e.name.slice(0,19)]}),(0,I.jsxs)(y,{size:`sm`,variant:`ghost`,disabled:t,onClick:()=>void n(e.name).then(t=>t&&a({name:e.name,...t})),"data-tip":`See what going back to this version changes`,children:[(0,I.jsx)(A,{"aria-hidden":`true`}),`Go back`]})]},e.name))}),i&&(0,I.jsxs)(`div`,{role:`status`,className:l(`surface rounded-lg bg-bg p-6 shadow-sm`,`flex flex-col gap-2`),children:[(0,I.jsx)(`p`,{className:`m-0 text-body-sm font-medium`,children:`Going back changes this:`}),(0,I.jsx)(`pre`,{className:l(`overflow-auto rounded-base bg-surface-muted p-4 font-mono text-body-sm leading-relaxed whitespace-pre-wrap text-ink-2 [overflow-wrap:anywhere]`,`m-0 max-h-[240px]`),children:i.diff.join(`
|
|
2
2
|
`)||`Nothing: the workflow is already that version.`}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsxs)(y,{size:`sm`,variant:`primary`,disabled:t,onClick:()=>(r(i.name,i.version),a(null)),"data-tip":`Write the workflow back at this version`,children:[(0,I.jsx)(j,{"aria-hidden":`true`}),`Go back to it`]}),(0,I.jsxs)(y,{size:`sm`,variant:`ghost`,onClick:()=>a(null),children:[(0,I.jsx)(ne,{"aria-hidden":`true`}),`Cancel`]})]})]})]}):null}function De({steps:e,busy:t,onKeep:n}){let[r,o]=(0,F.useState)(2),[c,u]=(0,F.useState)(2),[d,f]=(0,F.useState)(``),[p,m]=(0,F.useState)(``),h=e.filter(e=>e.n>1);if(!h.length)return null;let g=h[h.length-1].n,_=Math.min(Math.max(r,2),g),v=Math.min(Math.max(c,_),g);return(0,I.jsxs)(`form`,{"aria-label":`Keep steps as a block`,className:l(s,`flex flex-wrap items-end gap-2`),onSubmit:e=>{e.preventDefault(),d.trim()&&n(_,v,d.trim(),p.trim()).then(e=>{e&&f(``)})},children:[(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm font-medium text-ink-2`,children:[`Keep steps`,(0,I.jsx)(a,{value:_,onChange:e=>(o(Number(e.target.value)),u(Math.max(v,Number(e.target.value)))),className:`w-[84px]`,children:h.map(e=>(0,I.jsx)(`option`,{value:e.n,children:e.n},e.n))})]}),(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm font-medium text-ink-2`,children:[`to`,(0,I.jsx)(a,{value:v,onChange:e=>u(Number(e.target.value)),className:`w-[84px]`,children:h.filter(e=>e.n>=_).map(e=>(0,I.jsx)(`option`,{value:e.n,children:e.n},e.n))})]}),(0,I.jsxs)(`label`,{className:`flex min-w-[160px] flex-1 flex-col gap-1 text-body-sm font-medium text-ink-2`,children:[`as the block`,(0,I.jsx)(i,{value:d,maxLength:80,placeholder:`Sign in`,onChange:e=>f(e.target.value)})]}),(0,I.jsxs)(`label`,{className:`flex min-w-[120px] flex-col gap-1 text-body-sm font-medium text-ink-2`,children:[`in the section`,(0,I.jsx)(i,{value:p,maxLength:40,placeholder:`Account`,onChange:e=>m(e.target.value)})]}),(0,I.jsxs)(y,{type:`submit`,disabled:t||!d.trim(),"data-tip":`Keep these steps as a block of this app`,children:[(0,I.jsx)(j,{"aria-hidden":`true`}),`Keep`]}),(0,I.jsx)(`span`,{className:`basis-full text-body-sm text-muted`,children:`Put it into other workflows of this app from a step's +. What it types becomes its inputs: test data, or a secret picked each time.`})]})}function Oe({step:e,onAdd:t}){let[n,r]=(0,F.useState)(`check_text`),o=e.fields?.target,[s,c]=(0,F.useState)({name:o?.name??``,automation_id:o?.automation_id??``,control_type:o?.control_type??``}),[l,u]=(0,F.useState)(``),[d,f]=(0,F.useState)(`2`),[p,m]=(0,F.useState)(``),h=Se.find(e=>e.id===n),g=h.control?!!(s.name.trim()||s.automation_id.trim())&&(h.text!==`need`||!!l.trim()):n===`wait`?Number(d)>0:!!p.trim();return(0,I.jsxs)(`form`,{className:`flex flex-col gap-2 p-4`,onSubmit:e=>{e.preventDefault(),g&&t({kind:n,...h.control?{target:s}:{},...h.text&&l.trim()?{text:l}:{},...n===`wait`?{seconds:Number(d)}:{},...n===`keys`?{keys:p}:{}})},children:[(0,I.jsxs)(`p`,{className:`m-0 text-body-sm font-medium`,children:[`After step `,e.n]}),(0,I.jsx)(a,{size:`sm`,"aria-label":`What to add`,value:n,onChange:e=>r(e.target.value),children:Se.map(e=>(0,I.jsx)(`option`,{value:e.id,children:e.label},e.id))}),h.control&&(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm font-medium`,children:[`Control's name`,(0,I.jsx)(i,{size:`sm`,value:s.name,maxLength:300,onChange:e=>c({...s,name:e.target.value})})]}),(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm font-medium`,children:[`Automation id`,(0,I.jsx)(i,{size:`sm`,value:s.automation_id,maxLength:300,spellCheck:!1,onChange:e=>c({...s,automation_id:e.target.value}),className:`font-mono text-body-sm`})]})]}),h.text&&(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm font-medium`,children:[h.text===`need`?`The text it shows`:`Showing the text (optional)`,(0,I.jsx)(i,{size:`sm`,value:l,maxLength:500,placeholder:`Invoice saved`,onChange:e=>u(e.target.value)})]}),n===`wait`&&(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm font-medium`,children:[`Seconds`,(0,I.jsx)(i,{size:`sm`,type:`number`,min:1,max:600,value:d,onChange:e=>f(e.target.value)})]}),n===`keys`&&(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm font-medium`,children:[`Keys`,(0,I.jsx)(i,{size:`sm`,value:p,maxLength:100,spellCheck:!1,placeholder:`ctrl+s`,onChange:e=>m(e.target.value),className:`font-mono text-body-sm`})]}),(0,I.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`The control is filled from this step's; change it for another. A wait for a control is better than a fixed wait.`}),(0,I.jsxs)(y,{type:`submit`,size:`sm`,variant:`accent`,disabled:!g,className:`self-start`,children:[(0,I.jsx)(x,{"aria-hidden":`true`}),`Add`]})]})}var G=e=>e.name||e.automation_id||`the control`;function ke({pictures:e,step:t,busy:n,onPick:r}){let[i,a]=(0,F.useState)(0),o=e[Math.min(i,e.length-1)],[s,c]=(0,F.useState)(``),[u,d]=(0,F.useState)(``),[f,m]=(0,F.useState)(null);(0,F.useEffect)(()=>{let e=!1;return c(``),d(``),m(null),p.shot(o.run,o.n).then(t=>!e&&c(t),t=>!e&&d(t.message)),p.controls(o.run,o.n).then(t=>!e&&m(t),()=>{}),()=>{e=!0}},[o.run,o.n]);let h=(e,t)=>`${Math.max(0,Math.min(100,e/t*100))}%`,[g,_]=(0,F.useState)(!1),v=f&&f.w>0?f.controls.toSorted((e,t)=>t.w*t.h-e.w*e.h):[];return(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 pr-4 pb-4 pl-4 sm:pl-20`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.length>1&&(0,I.jsx)(M,{label:`Pictures of step ${t}`,value:String(i),onChange:e=>a(Number(e)),options:e.map((e,t)=>({id:String(t),label:e.label}))}),(0,I.jsxs)(`p`,{className:`m-0 text-body-sm text-muted`,children:[o.note,v.length>0?` Click a control to check that it shows its text, or that it is there.`:``]})]}),u&&(0,I.jsx)(`p`,{className:`m-0 text-body-sm text-fail`,children:u}),!s&&!u&&(0,I.jsx)(`p`,{className:`m-0 text-body-sm text-muted`,children:`Loading the picture…`}),s&&(0,I.jsxs)(`div`,{className:l(`rounded-base bg-surface-muted object-cover`,`relative w-full overflow-hidden`,g?`max-w-[360px]`:`max-w-[720px]`),style:v.length?{aspectRatio:`${f.w} / ${f.h}`}:void 0,children:[(0,I.jsx)(`img`,{src:s,alt:`The app after step ${t}, ${o.label.toLowerCase()}`,onLoad:e=>_(e.currentTarget.naturalHeight>e.currentTarget.naturalWidth),className:v.length?`absolute inset-0 size-full object-fill`:`block w-full`}),v.map((e,t)=>{let i=e.text?`Check ${G(e)} shows "${e.text}"`:`Check ${G(e)} is there`;return(0,I.jsx)(`button`,{type:`button`,disabled:n,"aria-label":i,"data-tip":i,onClick:()=>r({target:{...e.automation_id?{automation_id:e.automation_id}:{},...e.name?{name:e.name}:{},...e.control_type?{control_type:e.control_type}:{}},...e.text?{text:e.text}:{}}),className:`absolute cursor-pointer rounded-[3px] border-0 bg-transparent p-0 outline-none hover:bg-accent/15 hover:ring-2 hover:ring-accent focus-visible:bg-accent/15 focus-visible:ring-2 focus-visible:ring-accent`,style:{left:h(e.x,f.w),top:h(e.y,f.h),width:h(e.w,f.w),height:h(e.h,f.h)}},`${t}-${e.automation_id||e.name}`)})]})]})}function Ae({v:e,secrets:t,onSave:n,busy:r,mobile:o=!1}){let[s,c]=(0,F.useState)(e.as),[l,u]=(0,F.useState)(e.name??``),[d,f]=(0,F.useState)(e.value??``);(0,F.useEffect)(()=>{c(e.as),u(e.name??``),f(e.value??``)},[e]);let p=[`click`,`double_click`,`tap`,`double_tap`].includes(e.op),m=xe.filter(t=>e.choices?e.choices.includes(t.id):t.id!==`date`&&t.id!==`any`&&t.id!==`unique`&&(e.op===`type`||t.id!==`secret`)),h=s===`data`||s===`secret`||p&&s!==`typed`,g=s!==e.as||h&&l!==(e.name??``)||!p&&d!==(e.value??``),_=h?s===`secret`?/^[A-Z_][A-Z0-9_]{0,63}$/.test(l):/^[A-Za-z_][A-Za-z0-9_]{0,63}$/.test(l):s===`typed`||p||d.trim()!==``,v=e=>p&&e===`typed`?H.label:xe.find(t=>t.id===e)?.label,ee=p&&s===`typed`?H.note:xe.find(e=>e.id===s)?.note;return(0,I.jsxs)(`li`,{className:`flex flex-wrap items-start gap-x-4 gap-y-2 border-t border-line-soft px-4 py-2 first:border-t-0`,children:[(0,I.jsx)(`span`,{className:`w-6 flex-none pt-2 text-right font-mono text-body-sm text-muted tabular-nums`,children:e.n}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-[1_1_220px] flex-col pt-2`,children:[(0,I.jsx)(`span`,{className:`text-body-sm text-ink [overflow-wrap:anywhere]`,children:e.line}),(0,I.jsx)(`span`,{className:`text-body-sm text-ink-2`,children:ee})]}),(0,I.jsxs)(`span`,{className:`flex flex-[1_1_360px] flex-wrap items-center gap-2`,children:[(0,I.jsx)(a,{"aria-label":`Where the value of step ${e.n} comes from`,value:s,disabled:r,onChange:e=>c(e.target.value),className:`w-[150px] flex-none`,children:m.map(e=>(0,I.jsx)(`option`,{value:e.id,children:v(e.id)},e.id))}),h&&(0,I.jsx)(i,{"aria-label":s===`secret`?`The secret's environment variable`:`The test data's name`,value:l,maxLength:64,spellCheck:!1,list:s===`secret`?`desktop-secrets`:void 0,placeholder:s===`secret`?`BILLING_PASSWORD`:p?s===`date`?`date`:`slot`:`customer`,onChange:e=>u(s===`secret`?e.target.value.toUpperCase():e.target.value),className:`w-[170px] flex-none font-mono text-body-sm`}),s!==`secret`&&!p&&(0,I.jsx)(i,{"aria-label":s===`data`?`Its value`:s===`date`?`The date (counted from today)`:`The value`,value:d,maxLength:500,onChange:e=>f(e.target.value),className:`min-w-[140px] flex-1`}),s===`secret`&&!t.includes(l)&&l&&(0,I.jsxs)(`span`,{className:`text-body-sm text-warn`,children:[`Not in `,o?`mobile.secrets`:`desktop.secrets`,` yet`]}),(0,I.jsxs)(y,{size:`sm`,variant:`primary`,disabled:r||!g||!_,onClick:()=>n(s,h?l:void 0,s===`secret`||p?void 0:d),children:[(0,I.jsx)(j,{"aria-hidden":`true`}),`Save`]})]}),(0,I.jsx)(`datalist`,{id:`desktop-secrets`,children:t.map(e=>(0,I.jsx)(`option`,{value:e},e))})]})}function je({view:e,job:t,rows:n,onRun:r,busy:o,heal:u}){let[d,f]=(0,F.useState)(()=>Object.fromEntries(e.variables.map(e=>[e.name,e.value]))),[m,h]=(0,F.useState)(``),[_,ee]=(0,F.useState)(u),[b,te]=(0,F.useState)(!1),x=e.lastRun,S=m.startsWith(`file:`)?{file:m.slice(5)}:m.startsWith(`request:`)?{request:m.slice(8)}:void 0,C=t&&t.kind===`replay`&&t.target===e.workflow.path;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`m-0 text-body-sm text-ink-2`,children:`Replay plays the steps in the app with no model, as a scheduled run or CI will, and takes over the mouse and keyboard while it runs: use a test machine and a test account.`}),(0,I.jsxs)(`form`,{className:l(s,`flex flex-col gap-4`),onSubmit:e=>{e.preventDefault(),r({variables:d,...S?{rows:S}:{},heal:_,updateBaselines:b})},children:[e.variables.length>0&&(0,I.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,180px),1fr))] gap-4`,children:e.variables.map(e=>(0,I.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-sm font-medium text-ink-2`,children:[e.name,(0,I.jsx)(i,{value:d[e.name]??``,onChange:t=>f({...d,[e.name]:t.target.value})})]},e.name))}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-end gap-4`,children:[(0,I.jsxs)(`label`,{className:`flex min-w-[220px] flex-col gap-1 text-body-sm font-medium text-ink-2`,children:[`Test data`,(0,I.jsxs)(a,{value:m,onChange:e=>h(e.target.value),children:[(0,I.jsx)(`option`,{value:``,children:`Once, with the values above`}),n.files.map(e=>(0,I.jsxs)(`option`,{value:`file:${e}`,children:[`Each row of `,e]},e)),n.requests.map(e=>(0,I.jsxs)(`option`,{value:`request:${e}`,children:[`Each row of request `,e]},e))]})]}),(0,I.jsxs)(`label`,{className:`flex min-h-10 items-center gap-2 text-body-sm text-ink-2`,children:[(0,I.jsx)(N,{checked:_,onChange:ee,label:`Heal a step whose control moved`}),`Heal a moved control`]}),(0,I.jsxs)(`label`,{className:`flex min-h-10 items-center gap-2 text-body-sm text-ink-2`,children:[(0,I.jsx)(N,{checked:b,onChange:te,label:`Take new image baselines`}),`New image baselines`]}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsxs)(y,{type:`submit`,variant:`primary`,disabled:o,children:[(0,I.jsx)(T,{"aria-hidden":`true`}),`Replay`]})]})]}),C&&(0,I.jsx)(he,{job:t,onStop:()=>void p.stop(),words:U}),x?(0,I.jsx)(P,{id:`desktop-last-run`,level:3,icon:T,title:`Last replay`,className:`gap-2`,children:(0,I.jsxs)(`div`,{className:l(s,`flex flex-wrap items-center gap-4 text-body-sm`),children:[(0,I.jsx)(v,{tone:x.ok?`pass`:`fail`,children:x.many?`${x.many.passed} of ${x.many.total} passed`:x.ok?`Passed`:`Failed`}),(0,I.jsxs)(`span`,{className:`text-muted`,children:[de(x.at),` · `,c(e.replays,`replay`),` in all`]}),x.failed&&(0,I.jsxs)(`span`,{className:`min-w-0 flex-[1_1_240px] text-body-sm text-fail [overflow-wrap:anywhere]`,children:[`Step `,x.failed.index,`: `,x.failed.error]}),(0,I.jsx)(`span`,{className:`flex-1`}),x.report&&(0,I.jsx)(pe,{path:x.report,children:`Report`})]})}):(0,I.jsx)(g,{className:`py-4`,children:`Not replayed yet.`})]})}function K({workflow:e,onClose:t,backLabel:i=`Back`,notices:a,tab:o,onTab:s}){let[u,f]=(0,F.useState)(null),[b,M]=(0,F.useState)(``),[N,de]=(0,F.useState)(!1),[fe,pe]=(0,F.useState)(`steps`),P=s?be.includes(o??``)?o:`steps`:fe,he=e=>s?s(e):pe(e),[ge,_e]=(0,F.useState)(``),[L,R]=(0,F.useState)(`all`),[z,B]=(0,F.useState)(null),[V,xe]=(0,F.useState)(null),[H,U]=(0,F.useState)(null),[Se,G]=(0,F.useState)(``),[K,Me]=(0,F.useState)(null),[Ne,Pe]=(0,F.useState)({files:[],requests:[]}),[Fe,Ie]=(0,F.useState)(!0),q=(0,F.useCallback)(()=>{p.review(e).then(e=>{f(e),M(``)},e=>M(e.message))},[e]);(0,F.useEffect)(q,[q]);let J=(0,F.useCallback)(()=>{p.view().then(e=>{Me(e.job),Pe(e.rows),Ie(e.heal)},()=>{})},[]);(0,F.useEffect)(J,[J]);let Y=!!K?.running;(0,F.useEffect)(()=>{if(!Y)return;let e=le(J,1e3);return()=>ce(e)},[Y,J]);let Le=K&&!K.running?K.endedAt:``;(0,F.useEffect)(()=>{Le&&q()},[Le,q]);let X=async(e,t)=>{de(!0),M(``),G(``);try{await e(),q(),t&&G(t)}catch(e){M(e.message)}finally{de(!1)}},Re=e=>void m.start(e,{}).then(({id:e})=>location.hash=n(`chats`,e),e=>M(e.message));if(!u)return b?(0,I.jsx)(`p`,{role:`alert`,className:l(h.fail,`m-0`),children:b}):(0,I.jsx)(`p`,{role:`status`,className:`m-0 text-body-sm text-muted`,children:`Opening the workflow…`});let Z=u.workflow.kind===`mobile`,Q=u.lastRun,ze=new Map((Q?.results??[]).map(e=>[e.n,e])),Be=!!Q&&Date.parse(u.workflow.modified)>Date.parse(Q.at),Ve=u.steps.filter(e=>e.op.startsWith(`expect`)).length,$=Q&&!Q.ok?Q.failed?.index??0:0,He=$?u.steps[$-1]:void 0,Ue=(Q?.results??[]).filter(e=>!e.ok).length,We=ge.toLowerCase().split(/\s+/).filter(Boolean),Ge=u.steps.filter(e=>We.every(t=>`${e.n} ${e.text} ${e.fields?.note||``}`.toLowerCase().includes(t))&&(L===`all`||(L===`checks`?e.op.startsWith(`expect`):ze.get(e.n)?.ok===!1))),Ke=e=>{he(`steps`),R(`all`),_e(``);let t=n=>requestAnimationFrame(()=>{let i=document.getElementById(`dstep-${e}`);i?i.scrollIntoView({block:`center`,behavior:r()}):n>0&&t(n-1)});t(30)},qe=e=>void X(async()=>{await p.replay({workflow:u.workflow.path,...e}),J()},Z?`Replaying on the device: a device cloud can take a minute or two to start it.`:`Replaying: the app opens on this computer.`),Je=[{id:`steps`,label:`Steps`,icon:D,n:u.steps.length},{id:`data`,label:`Test data`,icon:re,n:u.values.length},{id:`run`,label:`Last run`,icon:T}];return(0,I.jsxs)(`section`,{"aria-labelledby":`dreview-title`,className:`flex min-w-0 flex-col gap-4`,children:[(0,I.jsxs)(`div`,{className:`sticky top-0 z-20 -mx-1 flex flex-col gap-4 border-b border-line bg-canvas px-1 py-4`,children:[t&&(0,I.jsx)(`div`,{children:(0,I.jsxs)(y,{size:`sm`,variant:`ghost`,onClick:t,className:`-ml-2 text-ink-2`,children:[(0,I.jsx)(E,{"aria-hidden":`true`}),i]})}),(0,I.jsx)(me,{id:`dreview-title`,icon:te,title:(0,I.jsx)(`span`,{"data-tip":u.workflow.name,children:u.workflow.name}),description:(0,I.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsxs)(`span`,{children:[u.workflow.app||`no app`,` · `,c(u.steps.length,`step`),` · `,c(Ve,`check`)]}),Y&&K?.target===u.workflow.path?(0,I.jsx)(v,{tone:`running`,children:`Replaying…`}):Q?(0,I.jsx)(v,{tone:Q.ok?`pass`:`fail`,children:Q.ok?`Last replay passed`:$?`Last replay failed at step ${$}`:`Last replay did not get through`}):(0,I.jsx)(v,{tone:`neutral`,icon:!1,children:`Not replayed yet`}),Be&&(0,I.jsx)(`span`,{children:`· you changed it since`})]}),actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(y,{onClick:()=>Re(`${Z?`Look at the mobile workflow`:`DeskPilot: look at the desktop workflow`} ${u.workflow.path} and tell me what to fix or add (a wait, a timeout, a dialog to dismiss, checks of the outcome); change it with desktop_edit_workflow only after showing me the change.`),"data-tip":Z?`Ask the agent to improve it`:`Ask DeskPilot to improve it`,children:[(0,I.jsx)(k,{"aria-hidden":`true`}),`Improve`]}),(0,I.jsxs)(y,{variant:`primary`,disabled:Y,onClick:()=>he(`run`),"data-tip":Y?`A replay is going`:`Replay it with no model`,children:[(0,I.jsx)(T,{"aria-hidden":`true`}),`Replay`]})]})})]}),a,b&&(0,I.jsx)(`p`,{role:`alert`,className:l(h.fail,`m-0`),children:b}),Se&&(0,I.jsx)(`p`,{role:`status`,className:l(h.pass,`m-0`),children:Se}),Q&&!Q.ok&&(0,I.jsxs)(`div`,{role:`alert`,className:l(h.fail,`flex flex-col gap-2`),children:[(0,I.jsxs)(`p`,{className:`m-0 font-medium text-fail`,children:[$?`Step ${$} failed`:`The replay did not get through`,Be&&(0,I.jsx)(`span`,{className:`font-normal text-ink-2`,children:` · before your last change`})]}),He&&(0,I.jsx)(`p`,{className:`m-0 font-medium text-ink [overflow-wrap:anywhere]`,children:He.text}),(0,I.jsx)(`p`,{className:`m-0 line-clamp-3 text-body-sm text-ink-2 [overflow-wrap:anywhere]`,children:Q.failed?.error||Q.error||`It failed.`}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[He&&(0,I.jsxs)(y,{size:`sm`,onClick:()=>Ke($),children:[(0,I.jsx)(A,{"aria-hidden":`true`}),`Show`]}),He&&$>1&&(0,I.jsxs)(y,{size:`sm`,onClick:()=>(Ke($),U({n:$,mode:`edit`})),"data-tip":`Change the failed step: its control, text or timeout`,children:[(0,I.jsx)(C,{"aria-hidden":`true`}),`Change`]}),(0,I.jsxs)(y,{size:`sm`,variant:`ghost`,onClick:()=>Re(`${Z?`The`:`DeskPilot: the`} last replay of ${u.workflow.path} failed${$?` at step ${$}`:``}. Read its report (${Q.dir}), tell me why, and offer a fix.`),children:[(0,I.jsx)(ie,{"aria-hidden":`true`}),`Ask why`]})]})]}),Q&&Q.ok&&Q.heals>0&&!Q.healsAccepted&&(0,I.jsxs)(`div`,{role:`status`,className:l(h.info,`flex flex-wrap items-center gap-4`),children:[(0,I.jsxs)(`span`,{className:`min-w-0 flex-[1_1_240px]`,children:[`The last replay found `,c(Q.heals,`moved control`),` and healed `,Q.heals===1?`it`:`them`,`: write the new locators into the workflow?`]}),(0,I.jsxs)(y,{size:`sm`,disabled:N,onClick:()=>void X(()=>p.acceptHeals(Q.dir),`The healed locators are in the workflow.`),children:[(0,I.jsx)(S,{"aria-hidden":`true`}),`Accept`]})]}),u.blocksStale?.map(e=>(0,I.jsx)(we,{f:e,block:u.blocks?.find(t=>t.id===e.block),secrets:u.blockSecrets??[],unset:u.unsetSecrets??[],busy:N,onUpdate:async t=>{let n=!1;return await X(async()=>{await W({workflow:u.workflow.path,step:e.from,action:`refresh_block`,block:e.block,...t||{}}),n=!0},`Steps ${e.from} to ${e.to} are version ${e.latest} of "${e.name}" now.`),n}},`stale-${e.block}-${e.from}`)),u.blocksFound?.map(e=>(0,I.jsxs)(`div`,{role:`status`,className:l(h.info,`flex flex-wrap items-center gap-4`),children:[(0,I.jsxs)(`span`,{className:`min-w-0 flex-[1_1_240px]`,children:[`Steps `,e.from,` to `,e.to,` do what the block `,(0,I.jsx)(`strong`,{className:`font-medium`,children:e.name}),` does: mark them as the block's, and this workflow hears of its newer versions.`]}),(e=>e?(0,I.jsx)(`span`,{className:`basis-full`,children:(0,I.jsx)(ye,{block:e})}):null)(u.blocks?.find(t=>t.id===e.block)),(0,I.jsxs)(y,{size:`sm`,disabled:N,onClick:()=>void X(()=>W({workflow:u.workflow.path,step:e.from,action:`use_block`,block:e.block}),`Steps ${e.from} to ${e.to} are the block "${e.name}" now.`),"data-tip":`Mark these steps as the block's`,children:[(0,I.jsx)(j,{"aria-hidden":`true`}),`Use`]})]},`found-${e.block}-${e.from}`)),(0,I.jsx)(ue,{prefix:`dreview`,label:`This workflow`,className:`mb-0`,current:P,onPick:he,tabs:Je.map(e=>({id:e.id,label:e.label,...e.n===void 0?{}:{n:e.n},...e.id===`run`&&Q?{n:Q.ok?(0,I.jsx)(w,{size:12,role:`img`,"aria-label":`passed`,className:`text-pass`}):(0,I.jsx)(se,{size:12,role:`img`,"aria-label":`failed`,className:`text-fail`})}:{}}))}),(0,I.jsxs)(`div`,{role:`tabpanel`,id:`dreview-panel-${P}`,"aria-labelledby":`dreview-${P}`,className:`flex min-w-0 flex-col gap-4`,children:[P===`steps`&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(ee,{id:`dreview-step-search`,label:`Find a step`,value:ge,onChange:_e}),(0,I.jsx)(_,{items:[{id:`all`,label:`All`,n:u.steps.length},{id:`checks`,label:`Checks`,n:Ve},...Ue?[{id:`failed`,label:`Failed`,n:Ue,alert:!0}]:[]],value:L,onChange:R})]}),Ve===0&&(0,I.jsx)(`p`,{className:l(h.warn,`m-0`),children:`No checks of the outcome: a replay passes when its steps run. Add one with + after the step whose result matters.`}),Ge.length===0?(0,I.jsx)(`p`,{className:l(`surface rounded-lg bg-bg p-6 shadow-sm`,`m-0 text-body-sm text-muted`),children:`No step matches.`}):(0,I.jsx)(`ol`,{className:l(`surface rounded-lg bg-bg p-6 shadow-sm`,`m-0 flex list-none flex-col p-0 [&>li:first-child]:rounded-t-base [&>li:last-child]:rounded-b-base`),children:Ge.map((e,t)=>{let n=ze.get(e.n),r=e.op.startsWith(`expect`),i=u.recorded?.shots[e.n],a=[...i&&u.recorded?[{label:`When recorded`,run:u.recorded.run,n:i,note:`The app after step ${e.n} as you recorded it.`}]:[],...n?.shot&&Q?[{label:`Last replay`,run:Q.dir,n:e.n,note:`The app after step ${e.n} on the last replay${Be?`, before your last change`:``}.`}]:[]];return(0,I.jsxs)(`li`,{id:`dstep-${e.n}`,className:l(`flex scroll-mt-48 flex-col`,t>0&&`border-t border-line-soft`,n&&!n.ok&&`bg-fail-soft`),children:[(0,I.jsxs)(`div`,{className:`group flex min-h-11 items-start gap-4 px-4 py-2`,children:[(0,I.jsx)(`span`,{className:`w-6 flex-none pt-1 text-right font-mono text-body-sm text-muted tabular-nums`,children:e.n}),(0,I.jsx)(`span`,{className:`flex w-4 flex-none justify-center pt-1`,children:n?n.ok?(0,I.jsx)(j,{size:14,strokeWidth:2.5,"aria-label":`Passed on the last replay`,className:`text-pass`}):(0,I.jsx)(ne,{size:14,strokeWidth:2.5,"aria-label":`Failed on the last replay`,className:`text-fail`}):Q?(0,I.jsx)(ae,{size:14,"aria-label":`Not replayed`,className:`text-muted`}):r?(0,I.jsx)(w,{size:14,"aria-hidden":`true`,className:`text-pass`}):(0,I.jsx)(`span`,{"aria-hidden":`true`,className:`mt-1 size-1.5 rounded-full bg-line-strong`})}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[r&&(0,I.jsx)(v,{tone:`pass`,icon:!1,className:`min-h-5 px-2 text-body-sm`,children:`Check`}),e.op.startsWith(`wait`)&&(0,I.jsx)(v,{tone:`neutral`,icon:!1,className:`min-h-5 px-2 text-body-sm`,children:`Wait`}),(0,I.jsx)(`span`,{className:`min-w-0 text-body-sm text-ink [overflow-wrap:anywhere]`,children:e.text}),e.block&&(0,I.jsxs)(v,{tone:`neutral`,icon:!1,children:[(0,I.jsx)(O,{"aria-hidden":`true`,className:`size-[11px]`}),u.blocks?.find(t=>t.id===e.block)?.name||e.block]}),n?.healed&&(0,I.jsx)(v,{tone:`warn`,icon:!1,className:`min-h-5 px-2 text-body-sm`,children:`Healed`})]}),e.fields?.note&&(0,I.jsxs)(`span`,{className:`text-body-sm text-ink-2`,children:[`Note: `,e.fields.note]}),n&&!n.ok&&n.error&&(0,I.jsx)(`span`,{className:`line-clamp-2 text-body-sm text-fail [overflow-wrap:anywhere]`,"data-tip":n.error,children:n.error})]}),(0,I.jsxs)(`span`,{className:`relative flex flex-none items-center gap-1`,children:[(0,I.jsx)(y,{size:`icon`,variant:`icon`,disabled:N,"aria-haspopup":`dialog`,"aria-expanded":z===e.n,"aria-label":`Add a check, wait${u.blocks?.length?` or block`:``} after step ${e.n}`,"data-tip":`Add a check, wait${u.blocks?.length?` or block`:``} after step ${e.n}`,onClick:()=>B(z===e.n?null:e.n),className:`size-8`,children:(0,I.jsx)(x,{"aria-hidden":`true`})}),(0,I.jsxs)(d,{open:z===e.n,onClose:()=>B(null),label:`Add after step ${e.n}`,role:`dialog`,align:`end`,className:`w-[min(360px,calc(100vw-48px))]`,children:[(0,I.jsx)(Oe,{step:e,onAdd:t=>{B(null),X(()=>W({workflow:u.workflow.path,step:e.n,action:`insert`,...t}),`Added after step ${e.n}.`)}}),(u.blocks?.length??0)>0&&(0,I.jsx)(Ce,{step:e,blocks:u.blocks??[],secrets:u.blockSecrets??[],unset:u.unsetSecrets??[],onAdd:(t,n)=>{B(null),X(()=>W({workflow:u.workflow.path,step:e.n,action:`block`,block:t,...n}),`Put in the block after step ${e.n}.`)}})]}),a.length>0&&(0,I.jsx)(y,{size:`icon`,variant:`icon`,"aria-label":`See the app after step ${e.n}`,"aria-expanded":V===e.n,"data-tip":`See the app after step ${e.n}`,onClick:()=>xe(V===e.n?null:e.n),className:`size-8`,children:(0,I.jsx)(A,{"aria-hidden":`true`})}),(0,I.jsx)(y,{size:`icon`,variant:`icon`,"aria-label":`Change step ${e.n}`,"data-tip":`Change step ${e.n}`,onClick:()=>U({n:e.n,mode:`edit`}),className:`size-8`,children:(0,I.jsx)(C,{"aria-hidden":`true`})}),e.n>1&&(0,I.jsx)(y,{size:`icon`,variant:`icon`,"aria-label":`Drop step ${e.n}`,"data-tip":`Drop step ${e.n}`,onClick:()=>U({n:e.n,mode:`remove`}),className:`size-8 hover:text-fail`,children:(0,I.jsx)(oe,{"aria-hidden":`true`})})]})]}),H&&H.n===e.n&&(0,I.jsx)(`div`,{className:`pr-4`,children:(0,I.jsx)(ve,{workflow:u.workflow.path,step:e,mode:H.mode,onCancel:()=>U(null),onDone:()=>{G(H.mode===`remove`?`Step ${e.n} dropped.`:`Step ${e.n} changed.`),U(null),q()}},`${e.n}-${H.mode}`)}),V===e.n&&a.length>0&&(0,I.jsx)(ke,{pictures:a,step:e.n,busy:N,onPick:t=>void X(()=>W({workflow:u.workflow.path,step:e.n,action:`insert`,kind:t.text?`check_text`:`check_present`,target:t.target,...t.text?{text:t.text}:{}}),t.text?`Added after step ${e.n}: a check that ${t.target.name||t.target.automation_id} shows "${t.text}".`:`Added after step ${e.n}: a check that ${t.target.name||t.target.automation_id} is there.`)})]},`${e.n}-${e.text}`)})}),(0,I.jsx)(De,{steps:u.steps,busy:N,onKeep:async(e,t,n,r)=>{let i=!1;return await X(async()=>{await p.saveBlock(u.workflow.path,e,t,n,r),i=!0},`Kept steps ${e} to ${t} as the block "${n}": put it into other workflows of ${u.workflow.app} from a step's +.`),i}}),(0,I.jsx)(Te,{blocks:u.blocks??[],busy:N,act:e=>{let t;X(async()=>{t=await e()}).then(()=>t&&G(t))}}),(0,I.jsx)(Ee,{history:u.history??[],busy:N,onPreview:async e=>{M(``);try{let t=await p.restore(u.workflow.path,e);return{diff:t.diff,version:t.version}}catch(e){return M(e.message),null}},onBack:(e,t)=>void X(()=>p.restore(u.workflow.path,e,t),`The workflow is back at that version: the version before going back is kept too.`)})]}),P===`data`&&(u.values.length===0?(0,I.jsx)(g,{className:`py-4`,children:`Nothing is typed, chosen or clicked as data in this workflow, so it has no test data.`}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`m-0 text-body-sm text-ink-2`,children:`Where each value typed, chosen or clicked comes from when it replays. A slot or a day that cannot be used twice can be any free one or a date from today. Test data can come from a data file's rows on the Last run tab.`}),(0,I.jsx)(`ul`,{className:l(`surface rounded-lg bg-bg p-6 shadow-sm`,`m-0 flex list-none flex-col p-0`),children:u.values.map(e=>(0,I.jsx)(Ae,{v:e,secrets:u.secrets,mobile:Z,busy:N,onSave:(t,n,r)=>void X(()=>W({workflow:u.workflow.path,step:e.n,action:`data`,as:t,...n===void 0?{}:{name:n},...r===void 0?{}:{value:r}}),t===`secret`?`Step ${e.n} types the secret ${n}; what was typed left the workflow.`:`Step ${e.n} saved.`)},e.n))})]})),P===`run`&&(0,I.jsx)(je,{view:u,job:K,rows:Z?{...Ne,requests:[]}:Ne,heal:Fe,busy:N||Y,onRun:qe})]})]})}export{z as a,R as i,V as n,B as o,ye as r,K as t};
|