@capagents/forgeqe 2.4.9 → 2.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/docs-site/architecture-map/index.html +1 -0
  2. package/dist/docs-site/docs/architecture/index.html +5 -5
  3. package/dist/docs-site/docs/containers/index.html +3 -3
  4. package/dist/docs-site/docs/cost-architecture/index.html +3 -3
  5. package/dist/docs-site/docs/desktop/index.html +3 -3
  6. package/dist/docs-site/docs/desktop-ci/index.html +3 -3
  7. package/dist/docs-site/docs/feature-test-prompts/index.html +3 -3
  8. package/dist/docs-site/docs/guardrails/index.html +3 -3
  9. package/dist/docs-site/docs/index.html +41 -77
  10. package/dist/docs-site/docs/mobile/index.html +32 -10
  11. package/dist/docs-site/docs/model-routing/index.html +3 -3
  12. package/dist/docs-site/docs/product-knowledge/index.html +3 -3
  13. package/dist/docs-site/docs/search.js +1 -1
  14. package/dist/docs-site/docs/web-app/index.html +14 -6
  15. package/dist/docs-site/img/icons/mail.svg +1 -0
  16. package/dist/forgeqe.js +997 -987
  17. package/dist/web/assets/{Agent-DJMzvP5e.js → Agent-BMqCDZeZ.js} +1 -1
  18. package/dist/web/assets/{ApiTests-CatQogdX.js → ApiTests-CkxIx6sI.js} +2 -2
  19. package/dist/web/assets/{Chat-BnMf86ti.js → Chat-BT6yGqKW.js} +3 -3
  20. package/dist/web/assets/{Data-Dv1J1F3q.js → Data-BPtl_mUy.js} +4 -4
  21. package/dist/web/assets/{Features-BoUfO669.js → Features-DwHyOoJu.js} +1 -1
  22. package/dist/web/assets/Jobs-DW2uXMkv.js +3 -0
  23. package/dist/web/assets/Quality-BeuhtzZi.js +1 -0
  24. package/dist/web/assets/Record-EHgUTspl.js +1 -0
  25. package/dist/web/assets/{Regression-icTMw-63.js → Regression-BDq3BUP_.js} +2 -2
  26. package/dist/web/assets/Reports-Bapldq1A.js +2 -0
  27. package/dist/web/assets/{Response-DhcE4o_e.js → Response-Dh_kxnCt.js} +3 -3
  28. package/dist/web/assets/Runs-BOi2fP0o.js +2 -0
  29. package/dist/web/assets/{circle-dashed-DJoDKq93.js → circle-dashed-C84s5T0C.js} +1 -1
  30. package/dist/web/assets/frame-z3iL_6aL.js +3 -0
  31. package/dist/web/assets/index-BVw2ygO2.js +26 -0
  32. package/dist/web/assets/index-CBa29-yG.css +2 -0
  33. package/dist/web/assets/markdown-BtqKvAEi.js +10 -0
  34. package/dist/web/assets/{sticky-note-BHLEsD2N.js → sticky-note-C_NJNONZ.js} +1 -1
  35. package/dist/web/assets/{trending-up-DWgCJxJf.js → trending-up-DK1wDqic.js} +1 -1
  36. package/dist/web/index.html +3 -3
  37. package/docs/MOBILE.md +29 -7
  38. package/docs/WEB_APP.md +11 -1
  39. package/docs/user-guide.html +29 -7
  40. package/forgeqe.example.yaml +7 -0
  41. package/package.json +1 -1
  42. package/py/forgeqe_mobile/cli.py +9 -2
  43. package/py/forgeqe_mobile/hyperexecute.py +133 -19
  44. package/py/forgeqe_mobile/maestro.py +45 -3
  45. package/py/forgeqe_mobile/service.py +51 -14
  46. package/dist/web/assets/Jobs-DHLGBQQg.js +0 -3
  47. package/dist/web/assets/Quality-D0xYMvar.js +0 -1
  48. package/dist/web/assets/Record-Dnt4y9hn.js +0 -1
  49. package/dist/web/assets/Reports-C_IwjymA.js +0 -2
  50. package/dist/web/assets/Runs-5qNwwohN.js +0 -2
  51. package/dist/web/assets/external-link-Cu8-HMUj.js +0 -1
  52. package/dist/web/assets/frame-3JV5tjBP.js +0 -3
  53. package/dist/web/assets/index-C65qlV-q.css +0 -2
  54. package/dist/web/assets/index-XRjCGJfG.js +0 -26
  55. package/dist/web/assets/markdown-Bca_tHZ5.js +0 -10
@@ -1 +1 @@
1
- import{Ar as e,Nr as t,Wn as n,Z as r,_t as i,bt as a,cr as o,gt as s,ht as c,ir as l,pt as u,r as d,sr as f,st as p,t as m,vt as h,wn as g,wr as _,yt as v}from"./frame-3JV5tjBP.js";import{D as y,a as b,w as x}from"./index-XRjCGJfG.js";import{t as S}from"./when-CHnpLdYw.js";import{StatusIcon as C}from"./Runs-5qNwwohN.js";var w={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};w.node;var T=l(w),E={name:`circle-slash`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`9`,x2:`15`,y1:`15`,y2:`9`,key:`1dfufj`}]]};E.node;var D=l(E),O=t(e(),1),k=v(),A=5;function j({id:e}){let[t,n,...i]=(e||``).split(`/`),a=c(t);return a&&n===`tools`&&!i.length?(0,k.jsx)(F,{page:a},a.id):!a||n!==void 0?(0,k.jsxs)(`div`,{className:`flex min-h-screen flex-col`,children:[(0,k.jsx)(d,{}),(0,k.jsxs)(`p`,{className:`m-0 px-6 py-10 text-sm text-muted`,children:[`There is no such agent. `,(0,k.jsx)(`a`,{href:r(),children:`Start a chat`}),` instead.`]})]}):(0,k.jsx)(b,{agent:a,below:(0,k.jsx)(M,{page:a})},a.id)}function M({page:e}){let[t,n]=(0,O.useState)(null),[a,c]=(0,O.useState)([]),[l,u]=(0,O.useState)(null),[d,p]=(0,O.useState)(``);(0,O.useEffect)(()=>{let t=!1;return o.tools(e.agent).then(e=>!t&&u(e),e=>!t&&p(e.message)),_.list().then(r=>!t&&n(r.runs.filter(t=>t.agents.some(t=>e.runs.includes(t.name))).slice(0,A)),()=>!t&&n([])),f.prompts().then(n=>!t&&c(n.agents.filter(t=>e.runs.includes(t.name))),()=>{}),()=>{t=!0}},[e]);let m=s(e.agent).name,h=[...new Set(a.map(e=>e.prompt))];return(0,k.jsxs)(`div`,{className:`flex w-full flex-col gap-6 pt-2`,children:[(0,k.jsxs)(`section`,{"aria-labelledby":`agent-tools`,className:`flex flex-col gap-2`,children:[(0,k.jsx)(`h2`,{id:`agent-tools`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Tools it can use`}),d?(0,k.jsx)(`p`,{className:`m-0 text-sm text-fail`,children:d}):l?(0,k.jsx)(I,{view:l,limit:A,more:r(`agents`,e.id,`tools`)}):(0,k.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Reading its tools…`})]}),l&&l.connections.length>0&&(0,k.jsxs)(`section`,{"aria-labelledby":`agent-connected`,className:`flex flex-col gap-2`,children:[(0,k.jsx)(`h2`,{id:`agent-connected`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Connected to`}),(0,k.jsx)(P,{list:l.connections,limit:4,more:r(`agents`,e.id,`tools`)})]}),(0,k.jsxs)(`section`,{"aria-labelledby":`agent-prompt`,className:`flex flex-col gap-2`,children:[(0,k.jsx)(`h2`,{id:`agent-prompt`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Its instructions`}),(0,k.jsxs)(`a`,{href:r(`prompts`),className:`flex items-center gap-3 rounded-[12px] border border-line-soft px-4 py-3 text-ink no-underline hover:bg-surface-muted hover:text-ink`,children:[(0,k.jsx)(i,{icon:g,size:18,className:`flex-none text-muted`}),(0,k.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,k.jsx)(`span`,{className:`text-[14px] font-medium`,children:h.length?h.map(e=>`${e}.md`).join(`, `):`The prompt it starts from`}),(0,k.jsxs)(`span`,{className:`text-[12.5px] text-muted`,children:[`What the `,m,` starts with, and your team's additions: change them in Prompts.`]})]}),(0,k.jsx)(T,{size:16,"aria-hidden":`true`,className:`flex-none text-muted`})]})]}),(0,k.jsxs)(`section`,{"aria-labelledby":`agent-runs`,className:`flex flex-col gap-2`,children:[(0,k.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,k.jsx)(`h2`,{id:`agent-runs`,className:`m-0 flex-1 text-[13px] font-semibold text-muted`,children:`Recent runs`}),(0,k.jsx)(`a`,{href:r(`runs`),className:`text-[13px]`,children:`All runs`})]}),t===null?(0,k.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Reading the runs…`}):t.length===0?(0,k.jsxs)(`p`,{className:`m-0 rounded-[12px] bg-surface-muted px-4 py-3 text-sm text-ink-2`,children:[`The `,m,` has not worked in this project yet.`]}):(0,k.jsx)(`ul`,{"aria-label":`The ${m}'s recent runs`,className:`m-0 flex list-none flex-col rounded-[12px] border border-line-soft p-1.5`,children:t.map(e=>(0,k.jsx)(`li`,{children:(0,k.jsxs)(`a`,{href:r(`runs`,encodeURIComponent(e.name)),className:`flex min-h-11 items-center gap-3 rounded-[8px] px-3 py-1.5 text-ink no-underline hover:bg-surface-muted hover:text-ink`,children:[(0,k.jsx)(C,{status:e.status}),(0,k.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,k.jsx)(`span`,{className:`truncate text-[14px] font-medium`,title:e.title,children:e.title}),e.error&&(0,k.jsx)(`span`,{className:`truncate text-[12px] text-fail`,children:e.error})]}),(0,k.jsx)(`span`,{className:`flex-none text-[12.5px] text-muted tabular-nums`,children:S(e.startedAt)})]})},e.name))})]})]})}var N={repository:`branch`,database:`container`,environment:`web`,system:`plug`};function P({list:e,limit:t,more:n}){let r=t?e.slice(0,t):e;return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`ul`,{className:`m-0 grid list-none grid-cols-1 gap-2 p-0 sm:grid-cols-2`,children:r.map((e,t)=>(0,k.jsxs)(`li`,{className:a(`flex items-center gap-3 rounded-[12px] border border-line-soft px-3 py-2.5`,!e.on&&`bg-surface-muted`),children:[(0,k.jsx)(h,{name:N[e.kind],px:22,className:a(!e.on&&`opacity-50 grayscale`)}),(0,k.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,k.jsx)(`span`,{className:`truncate text-[14px] font-medium`,title:e.name,children:e.name}),(0,k.jsx)(`span`,{className:`truncate text-[12.5px] text-muted`,children:e.on?e.detail:`Not connected: ${e.why||`not set up`}`})]})]},`${e.kind}:${e.name}:${t}`))}),n&&r.length<e.length&&(0,k.jsxs)(`a`,{href:n,className:`self-start text-[13px]`,children:[`Show all `,e.length,` connections`]})]})}function F({page:e}){let[t,n]=(0,O.useState)(null),[i,a]=(0,O.useState)(``);(0,O.useEffect)(()=>{let t=!1;return o.tools(e.agent).then(e=>!t&&n(e),e=>!t&&a(e.message)),()=>{t=!0}},[e]);let c=s(e.agent).name;return(0,k.jsxs)(`div`,{className:`flex min-h-screen flex-col`,children:[(0,k.jsx)(d,{}),(0,k.jsxs)(`main`,{className:m,children:[(0,k.jsxs)(`a`,{href:r(`agents`,e.id),className:`mb-4 inline-flex items-center gap-1.5 text-sm`,children:[(0,k.jsx)(y,{size:16,"aria-hidden":`true`}),c]}),(0,k.jsxs)(`div`,{className:`mb-1 flex items-center gap-3`,children:[(0,k.jsx)(`span`,{"aria-hidden":`true`,className:`theme-side inline-flex size-10 border border-line-soft flex-none items-center justify-center rounded-[10px]`,children:(0,k.jsx)(u,{agent:e.agent,px:24,decorative:!0})}),(0,k.jsxs)(`h1`,{className:`m-0 text-[26px] font-semibold tracking-[-0.01em]`,children:[`What the `,c,` can use`]})]}),(0,k.jsxs)(`p`,{className:`mt-1 mb-6 max-w-[64ch] text-sm leading-relaxed text-muted`,children:[t?`${t.title.replace(/\.$/,``)}.`:e.about,` Every tool it has, in the groups its session is given, and what it reaches from this project.`]}),i?(0,k.jsx)(`p`,{className:`m-0 text-sm text-fail`,children:i}):t?(0,k.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,k.jsxs)(`section`,{"aria-labelledby":`all-tools`,className:`flex flex-col gap-2`,children:[(0,k.jsx)(`h2`,{id:`all-tools`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Tools it can use`}),(0,k.jsx)(I,{view:t,openAll:!0})]}),t.connections.length>0&&(0,k.jsxs)(`section`,{"aria-labelledby":`all-connected`,className:`flex flex-col gap-2`,children:[(0,k.jsx)(`h2`,{id:`all-connected`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Connected to`}),(0,k.jsx)(P,{list:t.connections})]})]}):(0,k.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Reading its tools…`})]})]})}function I({view:e,limit:t,more:r,openAll:i}){let[o,s]=(0,O.useState)(()=>i?e.groups.map(e=>e.id):[]),c=t?e.groups.slice(0,t):e.groups,l=e.groups.reduce((e,t)=>e+t.tools.length,0),u=e.groups.filter(e=>e.on).length;return(0,k.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,k.jsxs)(`p`,{className:`m-0 text-[12.5px] text-muted`,children:[u,` of `,e.groups.length,` `,e.groups.length===1?`group`:`groups`,` usable here.`]}),(0,k.jsx)(`ul`,{className:`m-0 flex list-none flex-col rounded-[12px] border border-line-soft p-0`,children:c.map((e,r)=>{let i=o.includes(e.id);return(0,k.jsxs)(`li`,{className:a(r>0&&`border-t border-line-soft`),children:[(0,k.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-controls":`tools-${r}`,disabled:!e.tools.length,onClick:()=>s(i?o.filter(t=>t!==e.id):[...o,e.id]),className:`flex w-full cursor-pointer items-center gap-3 border-0 bg-transparent px-3 py-2.5 text-left text-ink disabled:cursor-default`,children:[e.on?(0,k.jsx)(x,{size:16,"aria-label":`Usable`,className:`flex-none text-pass`}):(0,k.jsx)(D,{size:16,"aria-label":`Not usable here`,className:`flex-none text-muted`}),(0,k.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,k.jsxs)(`span`,{className:`text-[14px] font-medium`,children:[e.label,e.tools.length>0&&(0,k.jsxs)(`span`,{className:`font-normal text-muted`,children:[` · `,e.tools.length]})]}),(0,k.jsx)(`span`,{className:a(`text-[12.5px] text-muted`,t&&`truncate`),children:e.on?[e.about,e.limited].filter(Boolean).join(` · `):`Not here: ${e.why||`not set up`}`})]}),e.tools.length>0&&(0,k.jsx)(n,{size:16,"aria-hidden":`true`,className:a(`flex-none text-muted transition-transform duration-200`,i&&`rotate-90`)})]}),(0,k.jsx)(p,{open:i,id:`tools-${r}`,children:(0,k.jsx)(`ul`,{className:`m-0 flex list-none flex-wrap gap-1.5 px-3 pb-3 pl-10`,children:e.tools.map(e=>(0,k.jsxs)(`li`,{title:e.what||void 0,className:`rounded-[6px] bg-surface-strong px-2 py-1 font-mono text-[12px] text-ink-2`,children:[e.name,e.what&&(0,k.jsx)(`span`,{className:`ml-1.5 font-sans text-muted`,children:e.what})]},e.name))})})]},e.id)})}),r&&(c.length<e.groups.length||l>0)&&(0,k.jsx)(`a`,{href:r,className:`self-start text-[13px]`,children:c.length<e.groups.length?`Show all ${e.groups.length} groups and ${l} tools`:`Show every tool (${l})`})]})}export{j as Agent};
1
+ import{Er as e,Fr as t,Gn as n,Mr as r,Z as i,_t as a,ar as o,bt as s,cr as c,gt as l,ht as u,lr as d,ot as f,pt as p,r as m,t as h,vt as g,wn as _,yt as v}from"./frame-z3iL_6aL.js";import{E as y,a as b,k as x}from"./index-BVw2ygO2.js";import{t as S}from"./when-CHnpLdYw.js";import{StatusIcon as C}from"./Runs-BOi2fP0o.js";var w={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};w.node;var T=o(w),E={name:`circle-slash`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`9`,x2:`15`,y1:`15`,y2:`9`,key:`1dfufj`}]]};E.node;var D=o(E),O=t(r(),1),k=v(),A=5;function j({id:e}){let[t,n,...r]=(e||``).split(`/`),a=u(t);return a&&n===`tools`&&!r.length?(0,k.jsx)(F,{page:a},a.id):!a||n!==void 0?(0,k.jsxs)(`div`,{className:`flex min-h-screen flex-col`,children:[(0,k.jsx)(m,{}),(0,k.jsxs)(`p`,{className:`m-0 px-6 py-10 text-sm text-muted`,children:[`There is no such agent. `,(0,k.jsx)(`a`,{href:i(),children:`Start a chat`}),` instead.`]})]}):(0,k.jsx)(b,{agent:a,below:(0,k.jsx)(M,{page:a})},a.id)}function M({page:t}){let[n,r]=(0,O.useState)(null),[o,s]=(0,O.useState)([]),[u,f]=(0,O.useState)(null),[p,m]=(0,O.useState)(``);(0,O.useEffect)(()=>{let n=!1;return d.tools(t.agent).then(e=>!n&&f(e),e=>!n&&m(e.message)),e.list().then(e=>!n&&r(e.runs.filter(e=>e.agents.some(e=>t.runs.includes(e.name))).slice(0,A)),()=>!n&&r([])),c.prompts().then(e=>!n&&s(e.agents.filter(e=>t.runs.includes(e.name))),()=>{}),()=>{n=!0}},[t]);let h=l(t.agent).name,g=[...new Set(o.map(e=>e.prompt))];return(0,k.jsxs)(`div`,{className:`flex w-full flex-col gap-6 pt-2`,children:[(0,k.jsxs)(`section`,{"aria-labelledby":`agent-tools`,className:`flex flex-col gap-2`,children:[(0,k.jsx)(`h2`,{id:`agent-tools`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Tools it can use`}),p?(0,k.jsx)(`p`,{className:`m-0 text-sm text-fail`,children:p}):u?(0,k.jsx)(I,{view:u,limit:A,more:i(`agents`,t.id,`tools`)}):(0,k.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Reading its tools…`})]}),u&&u.connections.length>0&&(0,k.jsxs)(`section`,{"aria-labelledby":`agent-connected`,className:`flex flex-col gap-2`,children:[(0,k.jsx)(`h2`,{id:`agent-connected`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Connected to`}),(0,k.jsx)(P,{list:u.connections,limit:4,more:i(`agents`,t.id,`tools`)})]}),(0,k.jsxs)(`section`,{"aria-labelledby":`agent-prompt`,className:`flex flex-col gap-2`,children:[(0,k.jsx)(`h2`,{id:`agent-prompt`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Its instructions`}),(0,k.jsxs)(`a`,{href:i(`prompts`),className:`flex items-center gap-3 rounded-[12px] border border-line-soft px-4 py-3 text-ink no-underline hover:bg-surface-muted hover:text-ink`,children:[(0,k.jsx)(a,{icon:_,size:18,className:`flex-none text-muted`}),(0,k.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,k.jsx)(`span`,{className:`text-[14px] font-medium`,children:g.length?g.map(e=>`${e}.md`).join(`, `):`The prompt it starts from`}),(0,k.jsxs)(`span`,{className:`text-[12.5px] text-muted`,children:[`What the `,h,` starts with, and your team's additions: change them in Prompts.`]})]}),(0,k.jsx)(T,{size:16,"aria-hidden":`true`,className:`flex-none text-muted`})]})]}),(0,k.jsxs)(`section`,{"aria-labelledby":`agent-runs`,className:`flex flex-col gap-2`,children:[(0,k.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,k.jsx)(`h2`,{id:`agent-runs`,className:`m-0 flex-1 text-[13px] font-semibold text-muted`,children:`Recent runs`}),(0,k.jsx)(`a`,{href:i(`runs`),className:`text-[13px]`,children:`All runs`})]}),n===null?(0,k.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Reading the runs…`}):n.length===0?(0,k.jsxs)(`p`,{className:`m-0 rounded-[12px] bg-surface-muted px-4 py-3 text-sm text-ink-2`,children:[`The `,h,` has not worked in this project yet.`]}):(0,k.jsx)(`ul`,{"aria-label":`The ${h}'s recent runs`,className:`m-0 flex list-none flex-col rounded-[12px] border border-line-soft p-1.5`,children:n.map(e=>(0,k.jsx)(`li`,{children:(0,k.jsxs)(`a`,{href:i(`runs`,encodeURIComponent(e.name)),className:`flex min-h-11 items-center gap-3 rounded-[8px] px-3 py-1.5 text-ink no-underline hover:bg-surface-muted hover:text-ink`,children:[(0,k.jsx)(C,{status:e.status}),(0,k.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,k.jsx)(`span`,{className:`truncate text-[14px] font-medium`,title:e.title,children:e.title}),e.error&&(0,k.jsx)(`span`,{className:`truncate text-[12px] text-fail`,children:e.error})]}),(0,k.jsx)(`span`,{className:`flex-none text-[12.5px] text-muted tabular-nums`,children:S(e.startedAt)})]})},e.name))})]})]})}var N={repository:`branch`,database:`container`,environment:`web`,system:`plug`};function P({list:e,limit:t,more:n}){let r=t?e.slice(0,t):e;return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`ul`,{className:`m-0 grid list-none grid-cols-1 gap-2 p-0 sm:grid-cols-2`,children:r.map((e,t)=>(0,k.jsxs)(`li`,{className:s(`flex items-center gap-3 rounded-[12px] border border-line-soft px-3 py-2.5`,!e.on&&`bg-surface-muted`),children:[(0,k.jsx)(g,{name:N[e.kind],px:22,className:s(!e.on&&`opacity-50 grayscale`)}),(0,k.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,k.jsx)(`span`,{className:`truncate text-[14px] font-medium`,title:e.name,children:e.name}),(0,k.jsx)(`span`,{className:`truncate text-[12.5px] text-muted`,children:e.on?e.detail:`Not connected: ${e.why||`not set up`}`})]})]},`${e.kind}:${e.name}:${t}`))}),n&&r.length<e.length&&(0,k.jsxs)(`a`,{href:n,className:`self-start text-[13px]`,children:[`Show all `,e.length,` connections`]})]})}function F({page:e}){let[t,n]=(0,O.useState)(null),[r,a]=(0,O.useState)(``);(0,O.useEffect)(()=>{let t=!1;return d.tools(e.agent).then(e=>!t&&n(e),e=>!t&&a(e.message)),()=>{t=!0}},[e]);let o=l(e.agent).name;return(0,k.jsxs)(`div`,{className:`flex min-h-screen flex-col`,children:[(0,k.jsx)(m,{}),(0,k.jsxs)(`main`,{className:h,children:[(0,k.jsxs)(`a`,{href:i(`agents`,e.id),className:`mb-4 inline-flex items-center gap-1.5 text-sm`,children:[(0,k.jsx)(x,{size:16,"aria-hidden":`true`}),o]}),(0,k.jsxs)(`div`,{className:`mb-1 flex items-center gap-3`,children:[(0,k.jsx)(`span`,{"aria-hidden":`true`,className:`theme-side inline-flex size-10 border border-line-soft flex-none items-center justify-center rounded-[10px]`,children:(0,k.jsx)(p,{agent:e.agent,px:24,decorative:!0})}),(0,k.jsxs)(`h1`,{className:`m-0 text-[26px] font-semibold tracking-[-0.01em]`,children:[`What the `,o,` can use`]})]}),(0,k.jsxs)(`p`,{className:`mt-1 mb-6 max-w-[64ch] text-sm leading-relaxed text-muted`,children:[t?`${t.title.replace(/\.$/,``)}.`:e.about,` Every tool it has, in the groups its session is given, and what it reaches from this project.`]}),r?(0,k.jsx)(`p`,{className:`m-0 text-sm text-fail`,children:r}):t?(0,k.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,k.jsxs)(`section`,{"aria-labelledby":`all-tools`,className:`flex flex-col gap-2`,children:[(0,k.jsx)(`h2`,{id:`all-tools`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Tools it can use`}),(0,k.jsx)(I,{view:t,openAll:!0})]}),t.connections.length>0&&(0,k.jsxs)(`section`,{"aria-labelledby":`all-connected`,className:`flex flex-col gap-2`,children:[(0,k.jsx)(`h2`,{id:`all-connected`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Connected to`}),(0,k.jsx)(P,{list:t.connections})]})]}):(0,k.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Reading its tools…`})]})]})}function I({view:e,limit:t,more:r,openAll:i}){let[a,o]=(0,O.useState)(()=>i?e.groups.map(e=>e.id):[]),c=t?e.groups.slice(0,t):e.groups,l=e.groups.reduce((e,t)=>e+t.tools.length,0),u=e.groups.filter(e=>e.on).length;return(0,k.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,k.jsxs)(`p`,{className:`m-0 text-[12.5px] text-muted`,children:[u,` of `,e.groups.length,` `,e.groups.length===1?`group`:`groups`,` usable here.`]}),(0,k.jsx)(`ul`,{className:`m-0 flex list-none flex-col rounded-[12px] border border-line-soft p-0`,children:c.map((e,r)=>{let i=a.includes(e.id);return(0,k.jsxs)(`li`,{className:s(r>0&&`border-t border-line-soft`),children:[(0,k.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-controls":`tools-${r}`,disabled:!e.tools.length,onClick:()=>o(i?a.filter(t=>t!==e.id):[...a,e.id]),className:`flex w-full cursor-pointer items-center gap-3 border-0 bg-transparent px-3 py-2.5 text-left text-ink disabled:cursor-default`,children:[e.on?(0,k.jsx)(y,{size:16,"aria-label":`Usable`,className:`flex-none text-pass`}):(0,k.jsx)(D,{size:16,"aria-label":`Not usable here`,className:`flex-none text-muted`}),(0,k.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,k.jsxs)(`span`,{className:`text-[14px] font-medium`,children:[e.label,e.tools.length>0&&(0,k.jsxs)(`span`,{className:`font-normal text-muted`,children:[` · `,e.tools.length]})]}),(0,k.jsx)(`span`,{className:s(`text-[12.5px] text-muted`,t&&`truncate`),children:e.on?[e.about,e.limited].filter(Boolean).join(` · `):`Not here: ${e.why||`not set up`}`})]}),e.tools.length>0&&(0,k.jsx)(n,{size:16,"aria-hidden":`true`,className:s(`flex-none text-muted transition-transform duration-200`,i&&`rotate-90`)})]}),(0,k.jsx)(f,{open:i,id:`tools-${r}`,children:(0,k.jsx)(`ul`,{className:`m-0 flex list-none flex-wrap gap-1.5 px-3 pb-3 pl-10`,children:e.tools.map(e=>(0,k.jsxs)(`li`,{title:e.what||void 0,className:`rounded-[6px] bg-surface-strong px-2 py-1 font-mono text-[12px] text-ink-2`,children:[e.name,e.what&&(0,k.jsx)(`span`,{className:`ml-1.5 font-sans text-muted`,children:e.what})]},e.name))})})]},e.id)})}),r&&(c.length<e.groups.length||l>0)&&(0,k.jsx)(`a`,{href:r,className:`self-start text-[13px]`,children:c.length<e.groups.length?`Show all ${e.groups.length} groups and ${l} tools`:`Show every tool (${l})`})]})}export{j as Agent};
@@ -1,2 +1,2 @@
1
- import{Ar as e,At as t,G as n,J as r,K as i,Nr as a,Tt as o,Un as s,X as c,Y as l,Z as u,_t as d,at as f,bt as p,ct as m,dr as h,dt as g,ot as _,qt as v,r as y,st as b,t as x,ur as S,wt as C,xt as w,yt as T}from"./frame-3JV5tjBP.js";import{t as E}from"./circle-dashed-DJoDKq93.js";import"./markdown-Bca_tHZ5.js";import{C as D,S as O,i as k,n as A,r as j,t as M,w as N}from"./index-XRjCGJfG.js";import{t as P}from"./when-CHnpLdYw.js";var F=a(e(),1),I=T(),L={passed:`pass`,failed:`fail`,error:`fail`,skipped:`neutral`},R={GET:`text-pass`,POST:`text-accent-fg`,PUT:`text-warn`,PATCH:`text-warn`,DELETE:`text-fail`},ee={run:`a browser run's calls`,openapi:`OpenAPI`,swagger:`Swagger`,wsdl:`WSDL`,graphql:`GraphQL`,proto:`.proto`,case:`a test case`,text:`a description`},z=e=>new Date(e).toLocaleString([],{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`});function B({job:e,onStop:n}){let r=(0,F.useRef)(null);(0,F.useEffect)(()=>{r.current&&(r.current.scrollTop=r.current.scrollHeight)},[e.lines.length]);let[i,a]={contracts:[`Making contracts`,`Made contracts`],run:[`Running the contracts`,`Ran the contracts`],scenarios:[`Making scenarios`,`Made scenarios`],"run-scenarios":[`Running the scenarios`,`Ran the scenarios`]}[e.kind]??[`Working`,`Done`],o=(e.kind===`run`||e.kind===`run-scenarios`)&&e.exitCode===1;return(0,I.jsxs)(`section`,{"aria-label":e.running?i:a,className:`flex flex-col gap-2 rounded-[14px] border border-line-soft p-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,I.jsx)(`span`,{className:`flex-1 font-medium`,children:e.running?i:a}),(0,I.jsx)(k,{orb:e.kind===`contracts`?`handing`:e.kind===`scenarios`?`writing`:`working`,tone:e.running?`running`:e.exitCode===0?`pass`:o?`warn`:`fail`,children:e.running?`Working`:e.exitCode===0?`Done`:o?`Some failed`:`Did not finish`}),e.running&&(0,I.jsxs)(g,{onClick:n,className:`border-fail text-fail hover:bg-fail-soft`,children:[(0,I.jsx)(t,{size:14,fill:`currentColor`,"aria-hidden":`true`}),`Stop`]})]}),(0,I.jsx)(`code`,{className:`font-mono text-[12px] text-muted [overflow-wrap:anywhere]`,children:e.command}),(0,I.jsxs)(`details`,{open:e.running,children:[(0,I.jsxs)(`summary`,{className:`cursor-pointer text-sm text-muted`,children:[`Output (`,e.lines.length,` lines)`]}),(0,I.jsx)(`pre`,{ref:r,className:`mt-2 max-h-[300px] overflow-auto rounded-[10px] bg-surface-muted p-3 font-mono text-[12px] leading-relaxed whitespace-pre-wrap text-ink-2`,children:e.lines.join(`
2
- `)||`Starting…`})]})]})}var V=({m:e})=>(0,I.jsx)(`span`,{className:p(`w-[58px] flex-none font-mono text-[12px] font-semibold`,R[e.toUpperCase()]||`text-ink-2`),children:e.toUpperCase()});function te({c:e,r:t}){let n=Array.isArray(e.expect.status)?e.expect.status.join(` or `):e.expect.status,r=t&&t.status!==`passed`?[t.reason,...t.checks.filter(e=>!e.ok).map(e=>`${e.name}${e.detail?`: ${e.detail}`:``}`)].filter(Boolean).join(` · `):``;return(0,I.jsxs)(`li`,{className:`grid min-h-11 grid-cols-[58px_minmax(0,1fr)_auto] items-center gap-x-3 rounded-[10px] px-3 py-1.5 hover:bg-surface-muted @3xl:grid-cols-[58px_minmax(0,1fr)_200px_auto]`,children:[(0,I.jsx)(V,{m:e.method}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,I.jsx)(`span`,{className:`truncate font-mono text-[13px]`,title:e.protocol===`rest`?e.path:e.name,children:e.protocol===`rest`?e.path:e.name}),r?(0,I.jsx)(`span`,{className:p(`truncate text-[12px]`,t?.status===`skipped`?`text-muted`:`text-fail`),title:r,children:r}):(e.writes||e.needsData?.length)&&(0,I.jsx)(`span`,{className:`truncate text-[12px] text-warn`,children:[e.writes?`Changes data`:``,e.needsData?.length?`Needs real ${e.needsData.join(`, `)}`:``].filter(Boolean).join(` · `)})]}),(0,I.jsx)(`span`,{className:`hidden truncate text-[12px] text-muted @3xl:block`,children:[n?`expects ${n}`:``,e.expect.contentType,e.auth?`${e.auth.type} auth`:``].filter(Boolean).join(` · `)}),(0,I.jsx)(`span`,{className:`flex justify-end`,children:t?(0,I.jsx)(k,{tone:L[t.status],children:t.status===`skipped`?`Skipped`:t.httpStatus?`${t.httpStatus}`:t.status}):(0,I.jsx)(`span`,{className:`text-[12px] text-muted`,children:`Not run`})})]})}function ne({s:e,r:t}){let[n,r]=(0,F.useState)(!1);return(0,I.jsxs)(`li`,{className:`border-t border-line-soft first:border-t-0`,children:[(0,I.jsxs)(`button`,{type:`button`,"aria-expanded":n,onClick:()=>r(!n),className:`flex min-h-[52px] w-full cursor-pointer items-center gap-3 border-0 bg-transparent px-1 py-2 text-left text-ink hover:bg-surface-muted`,children:[(0,I.jsx)(d,{icon:C,size:16,className:`flex-none text-muted`}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,I.jsx)(`span`,{className:`text-sm [overflow-wrap:anywhere]`,children:e.name}),(0,I.jsxs)(`span`,{className:`truncate text-[12px] text-muted`,children:[e.kind,` · `,e.steps.length,` step`,e.steps.length===1?``:`s`,e.cleanup?.length?` · ${e.cleanup.length} cleanup`:``,e.caseId?` · ${e.caseId}`:``]})]}),e.writes&&(0,I.jsx)(k,{tone:`warn`,children:`Changes data`}),t&&(0,I.jsx)(k,{tone:L[t.status],children:t.status.charAt(0).toUpperCase()+t.status.slice(1)})]}),(0,I.jsx)(b,{open:n,children:(0,I.jsxs)(`ol`,{className:`m-0 mb-3 ml-8 flex list-none flex-col gap-1 border-l border-line pl-3 text-sm`,children:[e.steps.map((e,n)=>{let r=t?.steps[n];return(0,I.jsxs)(`li`,{className:`flex flex-col`,children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(V,{m:e.method}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 font-mono text-[12px] [overflow-wrap:anywhere]`,children:e.path}),r&&(0,I.jsx)(k,{tone:L[r.status],children:r.httpStatus?String(r.httpStatus):r.status})]}),(0,I.jsxs)(`span`,{className:`pl-[66px] text-[12px] text-muted`,children:[e.name,e.save&&Object.keys(e.save).length?` · keeps ${Object.keys(e.save).join(`, `)}`:``,e.noAuth?` · without credentials`:``]}),r&&r.checks.some(e=>!e.ok)&&(0,I.jsx)(`span`,{className:`pl-[66px] text-[12px] text-fail`,children:r.checks.filter(e=>!e.ok).map(e=>`${e.name}${e.detail?`: ${e.detail}`:``}`).join(` · `)})]},n)}),e.cleanup?.map((e,t)=>(0,I.jsxs)(`li`,{className:`flex items-center gap-2 text-muted`,children:[(0,I.jsx)(V,{m:e.method}),(0,I.jsx)(`span`,{className:`font-mono text-[12px]`,children:e.path}),(0,I.jsx)(`span`,{className:`text-[12px]`,children:`cleanup`})]},`c${t}`)),t?.reason&&(0,I.jsx)(`li`,{className:`text-[12px] text-fail [overflow-wrap:anywhere]`,children:t.reason})]})})]})}function H({what:e,writes:t,defaultUrl:r,onRun:i,onCancel:a,needsData:o}){let[s,c]=(0,F.useState)(r),[l,u]=(0,F.useState)(!1),[p,m]=(0,F.useState)(!1);return(0,I.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-[12px] border border-accent-line bg-accent-soft p-4`,children:[(0,I.jsx)(`span`,{className:`font-medium`,children:e}),(0,I.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[`Against`,(0,I.jsx)(n,{value:s,spellCheck:!1,placeholder:`https://qa.example.com/api`,onChange:e=>c(e.target.value),className:`max-w-[480px] bg-bg`})]}),t>0&&(0,I.jsxs)(`span`,{className:`flex items-start gap-3 text-sm`,children:[(0,I.jsx)(f,{checked:l,onChange:u,label:`Also run the calls that change data`}),(0,I.jsxs)(`span`,{className:`flex flex-col`,children:[`Also run the `,t,` call`,t===1?``:`s`,` that change data`,(0,I.jsx)(`span`,{className:`text-[13px] text-warn`,children:`Only on a test environment: they create, change or delete data there.`})]})]}),o?(0,I.jsxs)(`span`,{className:`flex items-center gap-3 text-sm`,children:[(0,I.jsx)(f,{checked:p,onChange:m,label:`Also run calls with made-up values`}),`Also run the `,o,` call`,o===1?``:`s`,` whose values were made up`]}):null,(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,I.jsxs)(g,{variant:`primary`,onClick:()=>i({...s.trim()?{baseUrl:s.trim()}:{},allowWrites:l,includeNeedsData:p}),children:[(0,I.jsx)(d,{icon:v,size:16}),`Run`]}),(0,I.jsx)(g,{onClick:a,children:`Don't run`})]})]})}function re({open:e,onClose:t,view:a,set:o,onMake:s,busy:c}){let[l,u]=(0,F.useState)(`spec`),[d,m]=(0,F.useState)(``),[h,_]=(0,F.useState)(``),[v,y]=(0,F.useState)(``),[b,x]=(0,F.useState)(!0);(0,F.useEffect)(()=>{e&&(u(o.source.kind===`run`?`run`:`spec`),m(o.source.kind===`run`?``:a.runs[0]?.id??``))},[e,o.source.kind,a.runs]);let S=(e,t,n)=>(0,I.jsxs)(`label`,{className:p(`flex cursor-pointer items-start gap-3 rounded-[12px] border px-3 py-2.5`,l===e?`border-accent bg-accent-soft`:`border-line-soft hover:bg-surface-muted`),children:[(0,I.jsx)(`input`,{type:`radio`,name:`sc-from`,checked:l===e,onChange:()=>u(e),className:`mt-1 size-4 accent-accent`}),(0,I.jsxs)(`span`,{className:`flex flex-col`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium`,children:t}),(0,I.jsx)(`span`,{className:`text-[13px] text-muted`,children:n})]})]});return(0,I.jsx)(r,{open:e,onClose:t,title:`Make scenarios`,description:`API calls in order, where later calls use values earlier answers gave, added to ${o.name}. Nothing runs until you run them.`,footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(g,{onClick:t,children:`Cancel`}),(0,I.jsx)(g,{variant:`primary`,disabled:c||l===`cases`&&!h.trim()||l===`text`&&!v.trim(),onClick:()=>s({from:l,...l===`run`&&d?{run:d}:{},...l===`cases`?{cases:h}:{},...l===`text`?{text:v}:{},...l===`spec`?{negative:b}:{}}),children:`Make scenarios`})]}),children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 pt-3`,children:[S(`spec`,`From the API description`,`Each resource's lifecycle, browsing, the description's links, and negative cases (no model)`),l===`spec`&&(0,I.jsxs)(`span`,{className:`flex items-center gap-2 pl-10 text-sm`,children:[(0,I.jsx)(f,{checked:b,onChange:x,label:`Negative cases`}),` Negative cases: an id that does not exist, no credentials, an empty body`]}),S(`run`,`From a browser run`,`The calls the application made, in order, with the values passed on (no model)`),l===`run`&&(0,I.jsxs)(i,{"aria-label":`Browser run`,value:d,onChange:e=>m(e.target.value),className:`ml-10 max-w-[440px]`,children:[(0,I.jsx)(`option`,{value:``,children:`The latest run`}),a.runs.map(e=>(0,I.jsxs)(`option`,{value:e.id,children:[e.goal,` · `,w(e.calls,`call`),` · `,z(e.at)]},e.id))]}),S(`cases`,`From test cases`,`One scenario per case, planned by the model against the set's operations`),l===`cases`&&(0,I.jsx)(n,{"aria-label":`Test cases`,value:h,spellCheck:!1,placeholder:`ado:2238, jira:SHOP-12`,onChange:e=>_(e.target.value),className:`ml-10 max-w-[440px]`}),S(`text`,`From a description`,`In plain words, planned by the model; a step no operation does is listed, never invented`),l===`text`&&(0,I.jsx)(n,{"aria-label":`The scenario`,value:v,maxLength:1e3,placeholder:`Create a user, log in, add two items, check out, the total is the sum`,onChange:e=>y(e.target.value),className:`ml-10`})]})})}function U({open:e,onClose:t,view:a,onMake:o,busy:s}){let[c,l]=(0,F.useState)(`spec`),[u,d]=(0,F.useState)(``),[f,p]=(0,F.useState)(``),[m,h]=(0,F.useState)(``),[_,v]=(0,F.useState)(``);return(0,F.useEffect)(()=>{e&&(d(a.specs[0]??``),p(``),h(``),v(a.baseUrl??``),l(a.specs.length||!a.runs.length?`spec`:`run`))},[e,a]),(0,I.jsx)(r,{open:e,onClose:t,title:`New contract set`,description:`One contract per operation: an example call and what its answer must have (status, content type, schema, key fields). Making them runs nothing.`,footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(g,{onClick:t,children:`Cancel`}),(0,I.jsx)(g,{variant:`primary`,disabled:s||c===`spec`&&!u.trim(),onClick:()=>o({from:c,...c===`spec`?{spec:u.trim()}:f?{run:f}:{},...m.trim()?{name:m.trim()}:{},..._.trim()?{baseUrl:_.trim()}:{}}),children:`Make contracts`})]}),children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-4 pt-3`,children:[(0,I.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 border-0 p-0`,children:[(0,I.jsx)(`legend`,{className:`mb-1.5 text-sm font-medium`,children:`From`}),(0,I.jsxs)(`label`,{className:`flex min-h-9 cursor-pointer items-center gap-2 text-sm`,children:[(0,I.jsx)(`input`,{type:`radio`,name:`set-from`,checked:c===`spec`,onChange:()=>l(`spec`),className:`size-4 accent-accent`}),`An API description: OpenAPI or Swagger, WSDL, GraphQL, .proto, or grpc://`]}),c===`spec`&&(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5 pl-6`,children:[(0,I.jsx)(n,{"aria-label":`API description`,value:u,spellCheck:!1,list:`spec-files`,placeholder:`https://shop.test/openapi.json, or a file in the project`,onChange:e=>d(e.target.value)}),(0,I.jsx)(`datalist`,{id:`spec-files`,children:a.specs.map(e=>(0,I.jsx)(`option`,{value:e},e))}),a.specs.length>0&&(0,I.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[`In this project: `,a.specs.slice(0,6).join(`, `)]})]}),(0,I.jsxs)(`label`,{className:`flex min-h-9 cursor-pointer items-center gap-2 text-sm`,children:[(0,I.jsx)(`input`,{type:`radio`,name:`set-from`,checked:c===`run`,onChange:()=>l(`run`),className:`size-4 accent-accent`}),`The calls a browser run saw the application make`]}),c===`run`&&(0,I.jsxs)(i,{"aria-label":`Browser run`,value:f,onChange:e=>p(e.target.value),className:`ml-6 max-w-[440px]`,children:[(0,I.jsx)(`option`,{value:``,children:`The latest run`}),a.runs.map(e=>(0,I.jsxs)(`option`,{value:e.id,children:[e.goal,` · `,w(e.calls,`call`),` · `,z(e.at)]},e.id))]})]}),(0,I.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium`,children:[`Name`,(0,I.jsx)(n,{value:m,maxLength:120,placeholder:`Petstore`,onChange:e=>h(e.target.value)})]}),(0,I.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium`,children:[`Base URL`,(0,I.jsx)(n,{value:_,spellCheck:!1,placeholder:`https://qa.shop.test/api`,onChange:e=>v(e.target.value)}),(0,I.jsxs)(`span`,{className:`text-[13px] font-normal text-muted`,children:[`Where the contracts run when not where they were recorded or described.`,a.headers.length?` Each call sends ${a.headers.join(`, `)} from api.headers in forgeqe.yaml.`:` Credentials go in api.headers in forgeqe.yaml, as references to environment variables.`]})]})]})})}var W=50,ie=e=>e.length>48?`…/${e.split(/[\\/]/).filter(Boolean).slice(-2).join(`/`)}`:e;function G({label:e,last:t,onOpen:n}){if(!t)return(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[13px] text-muted`,children:[(0,I.jsx)(E,{size:14,"aria-hidden":`true`}),e,`: not run yet`]});let r=t.counts.failed+t.counts.error,i=t.counts.passed+r;return(0,I.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-x-1.5 text-[13px] text-ink-2`,children:[r?(0,I.jsx)(s,{size:14,"aria-label":`Failures`,className:`text-fail`}):(0,I.jsx)(N,{size:14,"aria-label":`Passed`,className:`text-pass`}),e,`:`,` `,(0,I.jsxs)(`b`,{className:p(`tabular-nums`,r?`text-fail`:`text-ink`),children:[t.counts.passed,`/`,i,` passed`]}),t.counts.skipped?(0,I.jsxs)(`span`,{className:`text-muted`,children:[`· `,t.counts.skipped,` skipped`]}):null,(0,I.jsxs)(`span`,{className:`text-muted`,children:[`· `,P(t.at)]}),t.report&&(0,I.jsx)(`button`,{type:`button`,onClick:()=>n(t.report),className:`cursor-pointer border-0 bg-transparent p-0 text-[13px] text-accent-fg hover:underline`,children:`· Report`})]})}function K({id:e,view:t,busy:n,act:r,version:i}){let[a,s]=(0,F.useState)(null),[c,f]=(0,F.useState)(``),[m,_]=(0,F.useState)(null),[y,b]=(0,F.useState)(!1),[x,C]=(0,F.useState)(``),[T,E]=(0,F.useState)(`contracts`),[D,k]=(0,F.useState)(``),[N,P]=(0,F.useState)(`all`),[L,R]=(0,F.useState)(0);(0,F.useEffect)(()=>{let t=!1;return S.set(e).then(e=>!t&&(s(e),f(``)),e=>!t&&f(e.message)),()=>{t=!0}},[e,i]),(0,F.useEffect)(()=>{_(null),E(`contracts`),k(``),P(`all`)},[e]),(0,F.useEffect)(()=>R(0),[e,T,D,N]);let B=(0,F.useMemo)(()=>new Map((a?.last.contracts?.results??[]).map(e=>[e.id,e])),[a]),V=(0,F.useMemo)(()=>new Map((a?.last.scenarios?.results??[]).map(e=>[e.id,e])),[a]);if(c)return(0,I.jsx)(`p`,{className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail`,children:c});if(!a)return(0,I.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Loading…`});let U=a.contracts.filter(e=>e.writes).length,K=a.contracts.filter(e=>e.needsData?.length).length,q=a.scenarios??[],J=a.last.contracts,ae=a.last.scenarios,Y=t.baseUrl||a.baseUrl||``,X=async e=>C(await l(e)),oe=async e=>{try{let{id:t}=await h.start(`Write the API contracts${e?` and scenarios`:``} of set ${a.id} as tests in the repository: call write_api_tests with set_id ${a.id}${e?` and scenarios ["all"]`:``}. Show me the plan before you write.`,{});location.hash=u(`chats`,t)}catch(e){C(e.message)}},Z=e=>{let t=B.get(e.id);return!!t&&(t.status===`failed`||t.status===`error`)},se=D.toLowerCase().split(/\s+/).filter(Boolean),Q=a.contracts.filter(e=>se.every(t=>`${e.method} ${e.path} ${e.name}`.toLowerCase().includes(t))),ce=[{id:`all`,label:`All`,n:Q.length},{id:`failed`,label:`Failed`,n:Q.filter(Z).length,alert:!0},...U?[{id:`writes`,label:`Changes data`,n:Q.filter(e=>e.writes).length}]:[],...J?[{id:`unrun`,label:`Not run`,n:Q.filter(e=>!B.has(e.id)).length}]:[]],$=[...Q.filter(e=>N===`failed`?Z(e):N===`writes`?e.writes:N!==`unrun`||!B.has(e.id))].sort((e,t)=>Number(Z(t))-Number(Z(e))),le=q.filter(e=>se.every(t=>e.name.toLowerCase().includes(t)));return(0,I.jsxs)(`section`,{"aria-labelledby":`set-h`,className:`flex min-w-0 flex-1 flex-col gap-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,I.jsx)(`h2`,{id:`set-h`,className:`m-0 text-[22px] font-semibold tracking-[-0.01em] [overflow-wrap:anywhere]`,children:a.name}),(0,I.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 text-[13px] text-muted`,children:[(0,I.jsxs)(`span`,{children:[`From `,ee[a.source.kind]||a.source.kind,` `,(0,I.jsx)(`span`,{className:`font-mono text-[12px]`,title:a.source.ref,children:ie(a.source.ref)})]}),`· `,(0,I.jsx)(`span`,{children:z(a.createdAt)}),a.baseUrl&&(0,I.jsxs)(I.Fragment,{children:[`· `,(0,I.jsx)(`span`,{className:`font-mono text-[12px] [overflow-wrap:anywhere]`,children:a.baseUrl})]})]})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsxs)(g,{variant:`primary`,size:`sm`,disabled:n||!a.contracts.length,onClick:()=>_(`contracts`),children:[(0,I.jsx)(d,{icon:v,size:15}),`Run contracts`]}),(0,I.jsxs)(g,{size:`sm`,disabled:n||!q.length,onClick:()=>_(`scenarios`),children:[(0,I.jsx)(d,{icon:v,size:15}),`Run scenarios`]}),(0,I.jsxs)(g,{size:`sm`,disabled:n,onClick:()=>b(!0),children:[(0,I.jsx)(O,{size:15,"aria-hidden":`true`}),`Make scenarios`]}),(0,I.jsxs)(g,{size:`sm`,variant:`ghost`,onClick:()=>void oe(q.length>0),children:[(0,I.jsx)(d,{icon:o,size:15}),`Write them as tests`]})]}),x&&(0,I.jsx)(`p`,{className:`m-0 text-[13px] text-fail`,children:x}),m===`contracts`&&(0,I.jsx)(H,{what:`Run ${a.contracts.length} contract${a.contracts.length===1?``:`s`}`,writes:U,needsData:K,defaultUrl:Y,onCancel:()=>_(null),onRun:e=>{_(null),r(()=>S.run(a.id,e))}}),m===`scenarios`&&(0,I.jsx)(H,{what:`Run ${q.length} scenario${q.length===1?``:`s`}`,writes:q.filter(e=>e.writes).length,defaultUrl:Y,onCancel:()=>_(null),onRun:e=>{_(null),r(()=>S.runScenarios(a.id,{...e.baseUrl?{baseUrl:e.baseUrl}:{},allowWrites:e.allowWrites}))}}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-[12px] bg-surface-muted px-4 py-2.5`,children:[(0,I.jsx)(G,{label:`Contracts`,last:J,onOpen:e=>void X(e)}),q.length>0&&(0,I.jsx)(G,{label:`Scenarios`,last:ae,onOpen:e=>void X(e)})]}),(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-col rounded-[14px] border border-line-soft bg-bg`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-line-soft px-3 py-2.5`,children:[(0,I.jsx)(`div`,{role:`tablist`,"aria-label":`In this set`,className:`flex gap-1 rounded-[10px] bg-surface-strong p-1`,children:[[`contracts`,`Contracts`,a.contracts.length],[`scenarios`,`Scenarios`,q.length]].map(([e,t,n])=>(0,I.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":T===e,onClick:()=>E(e),className:p(`inline-flex min-h-8 cursor-pointer items-center gap-1.5 rounded-[7px] border-0 px-3 text-sm font-medium`,T===e?`bg-bg text-ink shadow-sm`:`bg-transparent text-muted hover:text-ink`),children:[t,(0,I.jsx)(`span`,{className:`text-[12px] text-muted tabular-nums`,children:n})]},e))}),(0,I.jsx)(j,{id:`api-search`,label:T===`contracts`?`Find a call`:`Find a scenario`,placeholder:T===`contracts`?`Find a call by its path`:`Find a scenario`,value:D,onChange:k})]}),T===`contracts`?(0,I.jsxs)(I.Fragment,{children:[ce.length>1&&(0,I.jsx)(`div`,{className:`flex flex-wrap gap-1.5 px-3 pt-2.5`,children:(0,I.jsx)(M,{items:ce,value:N,onChange:P})}),(0,I.jsxs)(`ul`,{"aria-label":`Contracts`,className:`@container m-0 flex list-none flex-col p-1.5`,children:[$.length===0&&(0,I.jsx)(`li`,{className:`px-3 py-4 text-sm text-muted`,children:a.contracts.length?`Nothing matches.`:`This set has no contracts.`}),$.slice(L*W,L*W+W).map(e=>(0,I.jsx)(te,{c:e,r:B.get(e.id)},e.id))]}),(0,I.jsx)(A,{page:L,size:W,total:$.length,onPage:R,label:`Pages of contracts`,children:a.skipped?.length?(0,I.jsxs)(`span`,{title:a.skipped.join(`; `),children:[` · `,w(a.skipped.length,`operation`),` left out`]}):null})]}):q.length?(0,I.jsxs)(`ul`,{"aria-label":`Scenarios`,className:`m-0 flex list-none flex-col px-3 py-1.5`,children:[le.length===0&&(0,I.jsx)(`li`,{className:`py-4 text-sm text-muted`,children:`Nothing matches.`}),le.map(e=>(0,I.jsx)(ne,{s:e,r:V.get(e.id)},e.id))]}):(0,I.jsxs)(`div`,{className:`flex flex-col items-start gap-2 px-4 py-5`,children:[(0,I.jsx)(`span`,{className:`text-sm text-muted`,children:`No scenarios yet. A scenario chains calls end to end, each using what the one before answered.`}),(0,I.jsxs)(g,{size:`sm`,disabled:n,onClick:()=>b(!0),children:[(0,I.jsx)(O,{size:15,"aria-hidden":`true`}),`Make scenarios`]})]})]}),(0,I.jsx)(re,{open:y,onClose:()=>b(!1),view:t,set:a,busy:n,onMake:e=>{b(!1),r(()=>S.scenarios(a.id,e))}})]})}function q({sub:e}){let[t,n]=(0,F.useState)(null),[r,i]=(0,F.useState)(``),[a,o]=(0,F.useState)(!1),[l,d]=(0,F.useState)(!1),f=(0,F.useCallback)(()=>{S.view().then(e=>{n(e),i(``)},e=>i(e.message))},[]);(0,F.useEffect)(f,[f]);let h=!!t?.job?.running;(0,F.useEffect)(()=>{if(!h)return;let e=setInterval(f,1500);return()=>clearInterval(e)},[h,f]);let v=async e=>{o(!0),i(``);try{await e(),f()}catch(e){i(e.message)}finally{o(!1)}},b=e?decodeURIComponent(e):``,C=t?.sets.find(e=>e.id===b)||t?.sets[0],T=`${t?.job?.endedAt??``}|${C?.at??``}`,[k,A]=(0,F.useState)(``),M=(t?.sets??[]).filter(e=>k.toLowerCase().split(/\s+/).filter(Boolean).every(t=>e.name.toLowerCase().includes(t)));return(0,I.jsxs)(`div`,{className:`flex min-h-screen flex-col`,children:[(0,I.jsx)(y,{}),(0,I.jsxs)(`main`,{className:p(x,`@container flex-auto gap-4`),children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,I.jsx)(_,{pixel:c[`api-tests`],size:`lg`}),(0,I.jsx)(`h1`,{className:`m-0 flex-1 text-[26px] font-semibold tracking-[-0.01em]`,children:`API tests`}),(0,I.jsxs)(g,{variant:`primary`,disabled:!t||h,onClick:()=>d(!0),children:[(0,I.jsx)(O,{size:16,"aria-hidden":`true`}),`New contract set`]})]}),(0,I.jsx)(`p`,{className:`m-0 max-w-[74ch] text-sm leading-relaxed text-muted`,children:`REST, GraphQL, SOAP and gRPC, tested straight against the API with no browser and no model. A contract is one call and what its answer must have; a scenario chains calls end to end.`}),r&&(0,I.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:r}),!t&&!r&&(0,I.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}),t?.job&&(0,I.jsx)(B,{job:t.job,onStop:()=>v(()=>S.stop())}),t&&(t.sets.length?(0,I.jsxs)(`div`,{className:`flex flex-col gap-6 @2xl:flex-row @2xl:items-start @2xl:gap-8`,children:[(0,I.jsxs)(`nav`,{"aria-label":`Contract sets`,className:`flex min-w-0 flex-col gap-2 @2xl:sticky @2xl:top-6 @2xl:w-[280px] @2xl:flex-none`,children:[(0,I.jsxs)(`span`,{className:`px-1 text-[13px] font-medium text-muted`,children:[`Contract sets (`,t.sets.length,`)`]}),t.sets.length>6&&(0,I.jsx)(j,{id:`set-search`,label:`Find a set`,value:k,onChange:A,className:`flex-none`}),(0,I.jsxs)(`ul`,{className:`m-0 flex max-h-[60vh] list-none flex-col overflow-y-auto p-0 @2xl:max-h-[calc(100vh-240px)]`,children:[M.length===0&&(0,I.jsx)(`li`,{className:`px-3 py-3 text-sm text-muted`,children:`Nothing matches.`}),M.map(e=>{let n=e.last?.contracts,r=!!n&&n.counts.failed+n.counts.error>0;return(0,I.jsx)(`li`,{children:(0,I.jsxs)(`a`,{href:u(`api-tests`,encodeURIComponent(e.id)),"aria-current":C?.id===e.id?`page`:void 0,className:p(`flex min-h-12 items-center gap-2.5 rounded-[10px] px-3 py-1.5 text-ink no-underline`,C?.id===e.id?`bg-surface-strong hover:text-ink`:`hover:bg-surface-muted hover:text-ink`),children:[t?.job?.running&&t.job.target===e.id?(0,I.jsx)(m,{state:`working`,label:`Working on it`,px:16}):n?r?(0,I.jsx)(s,{size:16,"aria-label":`Failures`,className:`flex-none text-fail`}):(0,I.jsx)(N,{size:16,"aria-label":`Passed`,className:`flex-none text-pass`}):(0,I.jsx)(E,{size:16,"aria-label":`Not run`,className:`flex-none text-muted`}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,I.jsx)(`span`,{className:`truncate text-[14px] font-medium`,children:e.name}),(0,I.jsxs)(`span`,{className:`truncate text-[12px] text-muted`,children:[w(e.contracts,`contract`),e.scenarios?` · ${w(e.scenarios,`scenario`)}`:``,n?` · ${n.counts.passed}/${n.counts.passed+n.counts.failed+n.counts.error} passed`:``]})]}),(0,I.jsx)(`span`,{className:`flex-none text-[12px] text-muted tabular-nums`,children:P(e.at)})]})},e.id)})]})]}),C&&(0,I.jsx)(K,{id:C.id,view:t,busy:a||h,act:v,version:T})]}):(0,I.jsxs)(`div`,{className:`flex flex-col items-start gap-3 rounded-[18px] border border-line p-6`,children:[(0,I.jsx)(D,{size:24,"aria-hidden":`true`,className:`text-muted`}),(0,I.jsxs)(`p`,{className:`m-0 max-w-[62ch] leading-relaxed text-ink-2`,children:[`No API contracts yet. Make a set from your OpenAPI, Swagger, WSDL, GraphQL or .proto description`,t.runs.length?`, or from the ${w(t.runs[0].calls,`call`)} the run "${t.runs[0].goal}" saw`:``,`.`]}),(0,I.jsx)(g,{onClick:()=>d(!0),children:`New contract set`})]}))]}),t&&(0,I.jsx)(U,{open:l,onClose:()=>d(!1),view:t,busy:a||h,onMake:e=>v(async()=>{await S.contracts(e),d(!1)})})]})}export{q as ApiTests};
1
+ import{At as e,Fr as t,G as n,J as r,K as i,Mr as a,Tt as o,Wn as s,X as c,Y as l,Z as u,_t as d,at as f,bt as p,dr as m,dt as h,fr as g,ot as _,qt as v,r as y,st as b,t as x,ut as S,wt as C,xt as w,yt as T}from"./frame-z3iL_6aL.js";import{t as E}from"./circle-dashed-C84s5T0C.js";import"./markdown-BtqKvAEi.js";import{C as D,E as O,i as k,n as A,r as j,t as M,w as N}from"./index-BVw2ygO2.js";import{t as P}from"./when-CHnpLdYw.js";var F=t(a(),1),I=T(),L={passed:`pass`,failed:`fail`,error:`fail`,skipped:`neutral`},R={GET:`text-pass`,POST:`text-accent-fg`,PUT:`text-warn`,PATCH:`text-warn`,DELETE:`text-fail`},ee={run:`a browser run's calls`,openapi:`OpenAPI`,swagger:`Swagger`,wsdl:`WSDL`,graphql:`GraphQL`,proto:`.proto`,case:`a test case`,text:`a description`},z=e=>new Date(e).toLocaleString([],{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`});function B({job:t,onStop:n}){let r=(0,F.useRef)(null);(0,F.useEffect)(()=>{r.current&&(r.current.scrollTop=r.current.scrollHeight)},[t.lines.length]);let[i,a]={contracts:[`Making contracts`,`Made contracts`],run:[`Running the contracts`,`Ran the contracts`],scenarios:[`Making scenarios`,`Made scenarios`],"run-scenarios":[`Running the scenarios`,`Ran the scenarios`]}[t.kind]??[`Working`,`Done`],o=(t.kind===`run`||t.kind===`run-scenarios`)&&t.exitCode===1;return(0,I.jsxs)(`section`,{"aria-label":t.running?i:a,className:`flex flex-col gap-2 rounded-[14px] border border-line-soft p-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,I.jsx)(`span`,{className:`flex-1 font-medium`,children:t.running?i:a}),(0,I.jsx)(k,{orb:t.kind===`contracts`?`handing`:t.kind===`scenarios`?`writing`:`working`,tone:t.running?`running`:t.exitCode===0?`pass`:o?`warn`:`fail`,children:t.running?`Working`:t.exitCode===0?`Done`:o?`Some failed`:`Did not finish`}),t.running&&(0,I.jsxs)(h,{onClick:n,className:`border-fail text-fail hover:bg-fail-soft`,children:[(0,I.jsx)(e,{size:14,fill:`currentColor`,"aria-hidden":`true`}),`Stop`]})]}),(0,I.jsx)(`code`,{className:`font-mono text-[12px] text-muted [overflow-wrap:anywhere]`,children:t.command}),(0,I.jsxs)(`details`,{open:t.running,children:[(0,I.jsxs)(`summary`,{className:`cursor-pointer text-sm text-muted`,children:[`Output (`,t.lines.length,` lines)`]}),(0,I.jsx)(`pre`,{ref:r,className:`mt-2 max-h-[300px] overflow-auto rounded-[10px] bg-surface-muted p-3 font-mono text-[12px] leading-relaxed whitespace-pre-wrap text-ink-2`,children:t.lines.join(`
2
+ `)||`Starting…`})]})]})}var V=({m:e})=>(0,I.jsx)(`span`,{className:p(`w-[58px] flex-none font-mono text-[12px] font-semibold`,R[e.toUpperCase()]||`text-ink-2`),children:e.toUpperCase()});function te({c:e,r:t}){let n=Array.isArray(e.expect.status)?e.expect.status.join(` or `):e.expect.status,r=t&&t.status!==`passed`?[t.reason,...t.checks.filter(e=>!e.ok).map(e=>`${e.name}${e.detail?`: ${e.detail}`:``}`)].filter(Boolean).join(` · `):``;return(0,I.jsxs)(`li`,{className:`grid min-h-11 grid-cols-[58px_minmax(0,1fr)_auto] items-center gap-x-3 rounded-[10px] px-3 py-1.5 hover:bg-surface-muted @3xl:grid-cols-[58px_minmax(0,1fr)_200px_auto]`,children:[(0,I.jsx)(V,{m:e.method}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,I.jsx)(`span`,{className:`truncate font-mono text-[13px]`,title:e.protocol===`rest`?e.path:e.name,children:e.protocol===`rest`?e.path:e.name}),r?(0,I.jsx)(`span`,{className:p(`truncate text-[12px]`,t?.status===`skipped`?`text-muted`:`text-fail`),title:r,children:r}):(e.writes||e.needsData?.length)&&(0,I.jsx)(`span`,{className:`truncate text-[12px] text-warn`,children:[e.writes?`Changes data`:``,e.needsData?.length?`Needs real ${e.needsData.join(`, `)}`:``].filter(Boolean).join(` · `)})]}),(0,I.jsx)(`span`,{className:`hidden truncate text-[12px] text-muted @3xl:block`,children:[n?`expects ${n}`:``,e.expect.contentType,e.auth?`${e.auth.type} auth`:``].filter(Boolean).join(` · `)}),(0,I.jsx)(`span`,{className:`flex justify-end`,children:t?(0,I.jsx)(k,{tone:L[t.status],children:t.status===`skipped`?`Skipped`:t.httpStatus?`${t.httpStatus}`:t.status}):(0,I.jsx)(`span`,{className:`text-[12px] text-muted`,children:`Not run`})})]})}function ne({s:e,r:t}){let[n,r]=(0,F.useState)(!1);return(0,I.jsxs)(`li`,{className:`border-t border-line-soft first:border-t-0`,children:[(0,I.jsxs)(`button`,{type:`button`,"aria-expanded":n,onClick:()=>r(!n),className:`flex min-h-[52px] w-full cursor-pointer items-center gap-3 border-0 bg-transparent px-1 py-2 text-left text-ink hover:bg-surface-muted`,children:[(0,I.jsx)(d,{icon:C,size:16,className:`flex-none text-muted`}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,I.jsx)(`span`,{className:`text-sm [overflow-wrap:anywhere]`,children:e.name}),(0,I.jsxs)(`span`,{className:`truncate text-[12px] text-muted`,children:[e.kind,` · `,e.steps.length,` step`,e.steps.length===1?``:`s`,e.cleanup?.length?` · ${e.cleanup.length} cleanup`:``,e.caseId?` · ${e.caseId}`:``]})]}),e.writes&&(0,I.jsx)(k,{tone:`warn`,children:`Changes data`}),t&&(0,I.jsx)(k,{tone:L[t.status],children:t.status.charAt(0).toUpperCase()+t.status.slice(1)})]}),(0,I.jsx)(_,{open:n,children:(0,I.jsxs)(`ol`,{className:`m-0 mb-3 ml-8 flex list-none flex-col gap-1 border-l border-line pl-3 text-sm`,children:[e.steps.map((e,n)=>{let r=t?.steps[n];return(0,I.jsxs)(`li`,{className:`flex flex-col`,children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(V,{m:e.method}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 font-mono text-[12px] [overflow-wrap:anywhere]`,children:e.path}),r&&(0,I.jsx)(k,{tone:L[r.status],children:r.httpStatus?String(r.httpStatus):r.status})]}),(0,I.jsxs)(`span`,{className:`pl-[66px] text-[12px] text-muted`,children:[e.name,e.save&&Object.keys(e.save).length?` · keeps ${Object.keys(e.save).join(`, `)}`:``,e.noAuth?` · without credentials`:``]}),r&&r.checks.some(e=>!e.ok)&&(0,I.jsx)(`span`,{className:`pl-[66px] text-[12px] text-fail`,children:r.checks.filter(e=>!e.ok).map(e=>`${e.name}${e.detail?`: ${e.detail}`:``}`).join(` · `)})]},n)}),e.cleanup?.map((e,t)=>(0,I.jsxs)(`li`,{className:`flex items-center gap-2 text-muted`,children:[(0,I.jsx)(V,{m:e.method}),(0,I.jsx)(`span`,{className:`font-mono text-[12px]`,children:e.path}),(0,I.jsx)(`span`,{className:`text-[12px]`,children:`cleanup`})]},`c${t}`)),t?.reason&&(0,I.jsx)(`li`,{className:`text-[12px] text-fail [overflow-wrap:anywhere]`,children:t.reason})]})})]})}function H({what:e,writes:t,defaultUrl:r,onRun:i,onCancel:a,needsData:o}){let[s,c]=(0,F.useState)(r),[l,u]=(0,F.useState)(!1),[p,m]=(0,F.useState)(!1);return(0,I.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-[12px] border border-accent-line bg-accent-soft p-4`,children:[(0,I.jsx)(`span`,{className:`font-medium`,children:e}),(0,I.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[`Against`,(0,I.jsx)(n,{value:s,spellCheck:!1,placeholder:`https://qa.example.com/api`,onChange:e=>c(e.target.value),className:`max-w-[480px] bg-bg`})]}),t>0&&(0,I.jsxs)(`span`,{className:`flex items-start gap-3 text-sm`,children:[(0,I.jsx)(f,{checked:l,onChange:u,label:`Also run the calls that change data`}),(0,I.jsxs)(`span`,{className:`flex flex-col`,children:[`Also run the `,t,` call`,t===1?``:`s`,` that change data`,(0,I.jsx)(`span`,{className:`text-[13px] text-warn`,children:`Only on a test environment: they create, change or delete data there.`})]})]}),o?(0,I.jsxs)(`span`,{className:`flex items-center gap-3 text-sm`,children:[(0,I.jsx)(f,{checked:p,onChange:m,label:`Also run calls with made-up values`}),`Also run the `,o,` call`,o===1?``:`s`,` whose values were made up`]}):null,(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,I.jsxs)(h,{variant:`primary`,onClick:()=>i({...s.trim()?{baseUrl:s.trim()}:{},allowWrites:l,includeNeedsData:p}),children:[(0,I.jsx)(d,{icon:v,size:16}),`Run`]}),(0,I.jsx)(h,{onClick:a,children:`Don't run`})]})]})}function re({open:e,onClose:t,view:a,set:o,onMake:s,busy:c}){let[l,u]=(0,F.useState)(`spec`),[d,m]=(0,F.useState)(``),[g,_]=(0,F.useState)(``),[v,y]=(0,F.useState)(``),[b,x]=(0,F.useState)(!0);(0,F.useEffect)(()=>{e&&(u(o.source.kind===`run`?`run`:`spec`),m(o.source.kind===`run`?``:a.runs[0]?.id??``))},[e,o.source.kind,a.runs]);let S=(e,t,n)=>(0,I.jsxs)(`label`,{className:p(`flex cursor-pointer items-start gap-3 rounded-[12px] border px-3 py-2.5`,l===e?`border-accent bg-accent-soft`:`border-line-soft hover:bg-surface-muted`),children:[(0,I.jsx)(`input`,{type:`radio`,name:`sc-from`,checked:l===e,onChange:()=>u(e),className:`mt-1 size-4 accent-accent`}),(0,I.jsxs)(`span`,{className:`flex flex-col`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium`,children:t}),(0,I.jsx)(`span`,{className:`text-[13px] text-muted`,children:n})]})]});return(0,I.jsx)(r,{open:e,onClose:t,title:`Make scenarios`,description:`API calls in order, where later calls use values earlier answers gave, added to ${o.name}. Nothing runs until you run them.`,footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(h,{onClick:t,children:`Cancel`}),(0,I.jsx)(h,{variant:`primary`,disabled:c||l===`cases`&&!g.trim()||l===`text`&&!v.trim(),onClick:()=>s({from:l,...l===`run`&&d?{run:d}:{},...l===`cases`?{cases:g}:{},...l===`text`?{text:v}:{},...l===`spec`?{negative:b}:{}}),children:`Make scenarios`})]}),children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 pt-3`,children:[S(`spec`,`From the API description`,`Each resource's lifecycle, browsing, the description's links, and negative cases (no model)`),l===`spec`&&(0,I.jsxs)(`span`,{className:`flex items-center gap-2 pl-10 text-sm`,children:[(0,I.jsx)(f,{checked:b,onChange:x,label:`Negative cases`}),` Negative cases: an id that does not exist, no credentials, an empty body`]}),S(`run`,`From a browser run`,`The calls the application made, in order, with the values passed on (no model)`),l===`run`&&(0,I.jsxs)(i,{"aria-label":`Browser run`,value:d,onChange:e=>m(e.target.value),className:`ml-10 max-w-[440px]`,children:[(0,I.jsx)(`option`,{value:``,children:`The latest run`}),a.runs.map(e=>(0,I.jsxs)(`option`,{value:e.id,children:[e.goal,` · `,w(e.calls,`call`),` · `,z(e.at)]},e.id))]}),S(`cases`,`From test cases`,`One scenario per case, planned by the model against the set's operations`),l===`cases`&&(0,I.jsx)(n,{"aria-label":`Test cases`,value:g,spellCheck:!1,placeholder:`ado:2238, jira:SHOP-12`,onChange:e=>_(e.target.value),className:`ml-10 max-w-[440px]`}),S(`text`,`From a description`,`In plain words, planned by the model; a step no operation does is listed, never invented`),l===`text`&&(0,I.jsx)(n,{"aria-label":`The scenario`,value:v,maxLength:1e3,placeholder:`Create a user, log in, add two items, check out, the total is the sum`,onChange:e=>y(e.target.value),className:`ml-10`})]})})}function U({open:e,onClose:t,view:a,onMake:o,busy:s}){let[c,l]=(0,F.useState)(`spec`),[u,d]=(0,F.useState)(``),[f,p]=(0,F.useState)(``),[m,g]=(0,F.useState)(``),[_,v]=(0,F.useState)(``);return(0,F.useEffect)(()=>{e&&(d(a.specs[0]??``),p(``),g(``),v(a.baseUrl??``),l(a.specs.length||!a.runs.length?`spec`:`run`))},[e,a]),(0,I.jsx)(r,{open:e,onClose:t,title:`New contract set`,description:`One contract per operation: an example call and what its answer must have (status, content type, schema, key fields). Making them runs nothing.`,footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(h,{onClick:t,children:`Cancel`}),(0,I.jsx)(h,{variant:`primary`,disabled:s||c===`spec`&&!u.trim(),onClick:()=>o({from:c,...c===`spec`?{spec:u.trim()}:f?{run:f}:{},...m.trim()?{name:m.trim()}:{},..._.trim()?{baseUrl:_.trim()}:{}}),children:`Make contracts`})]}),children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-4 pt-3`,children:[(0,I.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 border-0 p-0`,children:[(0,I.jsx)(`legend`,{className:`mb-1.5 text-sm font-medium`,children:`From`}),(0,I.jsxs)(`label`,{className:`flex min-h-9 cursor-pointer items-center gap-2 text-sm`,children:[(0,I.jsx)(`input`,{type:`radio`,name:`set-from`,checked:c===`spec`,onChange:()=>l(`spec`),className:`size-4 accent-accent`}),`An API description: OpenAPI or Swagger, WSDL, GraphQL, .proto, or grpc://`]}),c===`spec`&&(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5 pl-6`,children:[(0,I.jsx)(n,{"aria-label":`API description`,value:u,spellCheck:!1,list:`spec-files`,placeholder:`https://shop.test/openapi.json, or a file in the project`,onChange:e=>d(e.target.value)}),(0,I.jsx)(`datalist`,{id:`spec-files`,children:a.specs.map(e=>(0,I.jsx)(`option`,{value:e},e))}),a.specs.length>0&&(0,I.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[`In this project: `,a.specs.slice(0,6).join(`, `)]})]}),(0,I.jsxs)(`label`,{className:`flex min-h-9 cursor-pointer items-center gap-2 text-sm`,children:[(0,I.jsx)(`input`,{type:`radio`,name:`set-from`,checked:c===`run`,onChange:()=>l(`run`),className:`size-4 accent-accent`}),`The calls a browser run saw the application make`]}),c===`run`&&(0,I.jsxs)(i,{"aria-label":`Browser run`,value:f,onChange:e=>p(e.target.value),className:`ml-6 max-w-[440px]`,children:[(0,I.jsx)(`option`,{value:``,children:`The latest run`}),a.runs.map(e=>(0,I.jsxs)(`option`,{value:e.id,children:[e.goal,` · `,w(e.calls,`call`),` · `,z(e.at)]},e.id))]})]}),(0,I.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium`,children:[`Name`,(0,I.jsx)(n,{value:m,maxLength:120,placeholder:`Petstore`,onChange:e=>g(e.target.value)})]}),(0,I.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium`,children:[`Base URL`,(0,I.jsx)(n,{value:_,spellCheck:!1,placeholder:`https://qa.shop.test/api`,onChange:e=>v(e.target.value)}),(0,I.jsxs)(`span`,{className:`text-[13px] font-normal text-muted`,children:[`Where the contracts run when not where they were recorded or described.`,a.headers.length?` Each call sends ${a.headers.join(`, `)} from api.headers in forgeqe.yaml.`:` Credentials go in api.headers in forgeqe.yaml, as references to environment variables.`]})]})]})})}var W=50,ie=e=>e.length>48?`…/${e.split(/[\\/]/).filter(Boolean).slice(-2).join(`/`)}`:e;function G({label:e,last:t,onOpen:n}){if(!t)return(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[13px] text-muted`,children:[(0,I.jsx)(E,{size:14,"aria-hidden":`true`}),e,`: not run yet`]});let r=t.counts.failed+t.counts.error,i=t.counts.passed+r;return(0,I.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-x-1.5 text-[13px] text-ink-2`,children:[r?(0,I.jsx)(s,{size:14,"aria-label":`Failures`,className:`text-fail`}):(0,I.jsx)(O,{size:14,"aria-label":`Passed`,className:`text-pass`}),e,`:`,` `,(0,I.jsxs)(`b`,{className:p(`tabular-nums`,r?`text-fail`:`text-ink`),children:[t.counts.passed,`/`,i,` passed`]}),t.counts.skipped?(0,I.jsxs)(`span`,{className:`text-muted`,children:[`· `,t.counts.skipped,` skipped`]}):null,(0,I.jsxs)(`span`,{className:`text-muted`,children:[`· `,P(t.at)]}),t.report&&(0,I.jsx)(`button`,{type:`button`,onClick:()=>n(t.report),className:`cursor-pointer border-0 bg-transparent p-0 text-[13px] text-accent-fg hover:underline`,children:`· Report`})]})}function K({id:e,view:t,busy:n,act:r,version:i}){let[a,s]=(0,F.useState)(null),[c,f]=(0,F.useState)(``),[_,y]=(0,F.useState)(null),[b,x]=(0,F.useState)(!1),[S,C]=(0,F.useState)(``),[T,E]=(0,F.useState)(`contracts`),[O,k]=(0,F.useState)(``),[N,P]=(0,F.useState)(`all`),[L,R]=(0,F.useState)(0);(0,F.useEffect)(()=>{let t=!1;return m.set(e).then(e=>!t&&(s(e),f(``)),e=>!t&&f(e.message)),()=>{t=!0}},[e,i]),(0,F.useEffect)(()=>{y(null),E(`contracts`),k(``),P(`all`)},[e]),(0,F.useEffect)(()=>R(0),[e,T,O,N]);let B=(0,F.useMemo)(()=>new Map((a?.last.contracts?.results??[]).map(e=>[e.id,e])),[a]),V=(0,F.useMemo)(()=>new Map((a?.last.scenarios?.results??[]).map(e=>[e.id,e])),[a]);if(c)return(0,I.jsx)(`p`,{className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail`,children:c});if(!a)return(0,I.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Loading…`});let U=a.contracts.filter(e=>e.writes).length,K=a.contracts.filter(e=>e.needsData?.length).length,q=a.scenarios??[],J=a.last.contracts,ae=a.last.scenarios,Y=t.baseUrl||a.baseUrl||``,X=async e=>C(await l(e)),oe=async e=>{try{let{id:t}=await g.start(`Write the API contracts${e?` and scenarios`:``} of set ${a.id} as tests in the repository: call write_api_tests with set_id ${a.id}${e?` and scenarios ["all"]`:``}. Show me the plan before you write.`,{});location.hash=u(`chats`,t)}catch(e){C(e.message)}},Z=e=>{let t=B.get(e.id);return!!t&&(t.status===`failed`||t.status===`error`)},se=O.toLowerCase().split(/\s+/).filter(Boolean),Q=a.contracts.filter(e=>se.every(t=>`${e.method} ${e.path} ${e.name}`.toLowerCase().includes(t))),ce=[{id:`all`,label:`All`,n:Q.length},{id:`failed`,label:`Failed`,n:Q.filter(Z).length,alert:!0},...U?[{id:`writes`,label:`Changes data`,n:Q.filter(e=>e.writes).length}]:[],...J?[{id:`unrun`,label:`Not run`,n:Q.filter(e=>!B.has(e.id)).length}]:[]],$=[...Q.filter(e=>N===`failed`?Z(e):N===`writes`?e.writes:N!==`unrun`||!B.has(e.id))].sort((e,t)=>Number(Z(t))-Number(Z(e))),le=q.filter(e=>se.every(t=>e.name.toLowerCase().includes(t)));return(0,I.jsxs)(`section`,{"aria-labelledby":`set-h`,className:`flex min-w-0 flex-1 flex-col gap-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,I.jsx)(`h2`,{id:`set-h`,className:`m-0 text-[22px] font-semibold tracking-[-0.01em] [overflow-wrap:anywhere]`,children:a.name}),(0,I.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 text-[13px] text-muted`,children:[(0,I.jsxs)(`span`,{children:[`From `,ee[a.source.kind]||a.source.kind,` `,(0,I.jsx)(`span`,{className:`font-mono text-[12px]`,title:a.source.ref,children:ie(a.source.ref)})]}),`· `,(0,I.jsx)(`span`,{children:z(a.createdAt)}),a.baseUrl&&(0,I.jsxs)(I.Fragment,{children:[`· `,(0,I.jsx)(`span`,{className:`font-mono text-[12px] [overflow-wrap:anywhere]`,children:a.baseUrl})]})]})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsxs)(h,{variant:`primary`,size:`sm`,disabled:n||!a.contracts.length,onClick:()=>y(`contracts`),children:[(0,I.jsx)(d,{icon:v,size:15}),`Run contracts`]}),(0,I.jsxs)(h,{size:`sm`,disabled:n||!q.length,onClick:()=>y(`scenarios`),children:[(0,I.jsx)(d,{icon:v,size:15}),`Run scenarios`]}),(0,I.jsxs)(h,{size:`sm`,disabled:n,onClick:()=>x(!0),children:[(0,I.jsx)(D,{size:15,"aria-hidden":`true`}),`Make scenarios`]}),(0,I.jsxs)(h,{size:`sm`,variant:`ghost`,onClick:()=>void oe(q.length>0),children:[(0,I.jsx)(d,{icon:o,size:15}),`Write them as tests`]})]}),S&&(0,I.jsx)(`p`,{className:`m-0 text-[13px] text-fail`,children:S}),_===`contracts`&&(0,I.jsx)(H,{what:`Run ${a.contracts.length} contract${a.contracts.length===1?``:`s`}`,writes:U,needsData:K,defaultUrl:Y,onCancel:()=>y(null),onRun:e=>{y(null),r(()=>m.run(a.id,e))}}),_===`scenarios`&&(0,I.jsx)(H,{what:`Run ${q.length} scenario${q.length===1?``:`s`}`,writes:q.filter(e=>e.writes).length,defaultUrl:Y,onCancel:()=>y(null),onRun:e=>{y(null),r(()=>m.runScenarios(a.id,{...e.baseUrl?{baseUrl:e.baseUrl}:{},allowWrites:e.allowWrites}))}}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-[12px] bg-surface-muted px-4 py-2.5`,children:[(0,I.jsx)(G,{label:`Contracts`,last:J,onOpen:e=>void X(e)}),q.length>0&&(0,I.jsx)(G,{label:`Scenarios`,last:ae,onOpen:e=>void X(e)})]}),(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-col rounded-[14px] border border-line-soft bg-bg`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-line-soft px-3 py-2.5`,children:[(0,I.jsx)(`div`,{role:`tablist`,"aria-label":`In this set`,className:`flex gap-1 rounded-[10px] bg-surface-strong p-1`,children:[[`contracts`,`Contracts`,a.contracts.length],[`scenarios`,`Scenarios`,q.length]].map(([e,t,n])=>(0,I.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":T===e,onClick:()=>E(e),className:p(`inline-flex min-h-8 cursor-pointer items-center gap-1.5 rounded-[7px] border-0 px-3 text-sm font-medium`,T===e?`bg-bg text-ink shadow-sm`:`bg-transparent text-muted hover:text-ink`),children:[t,(0,I.jsx)(`span`,{className:`text-[12px] text-muted tabular-nums`,children:n})]},e))}),(0,I.jsx)(j,{id:`api-search`,label:T===`contracts`?`Find a call`:`Find a scenario`,placeholder:T===`contracts`?`Find a call by its path`:`Find a scenario`,value:O,onChange:k})]}),T===`contracts`?(0,I.jsxs)(I.Fragment,{children:[ce.length>1&&(0,I.jsx)(`div`,{className:`flex flex-wrap gap-1.5 px-3 pt-2.5`,children:(0,I.jsx)(M,{items:ce,value:N,onChange:P})}),(0,I.jsxs)(`ul`,{"aria-label":`Contracts`,className:`@container m-0 flex list-none flex-col p-1.5`,children:[$.length===0&&(0,I.jsx)(`li`,{className:`px-3 py-4 text-sm text-muted`,children:a.contracts.length?`Nothing matches.`:`This set has no contracts.`}),$.slice(L*W,L*W+W).map(e=>(0,I.jsx)(te,{c:e,r:B.get(e.id)},e.id))]}),(0,I.jsx)(A,{page:L,size:W,total:$.length,onPage:R,label:`Pages of contracts`,children:a.skipped?.length?(0,I.jsxs)(`span`,{title:a.skipped.join(`; `),children:[` · `,w(a.skipped.length,`operation`),` left out`]}):null})]}):q.length?(0,I.jsxs)(`ul`,{"aria-label":`Scenarios`,className:`m-0 flex list-none flex-col px-3 py-1.5`,children:[le.length===0&&(0,I.jsx)(`li`,{className:`py-4 text-sm text-muted`,children:`Nothing matches.`}),le.map(e=>(0,I.jsx)(ne,{s:e,r:V.get(e.id)},e.id))]}):(0,I.jsxs)(`div`,{className:`flex flex-col items-start gap-2 px-4 py-5`,children:[(0,I.jsx)(`span`,{className:`text-sm text-muted`,children:`No scenarios yet. A scenario chains calls end to end, each using what the one before answered.`}),(0,I.jsxs)(h,{size:`sm`,disabled:n,onClick:()=>x(!0),children:[(0,I.jsx)(D,{size:15,"aria-hidden":`true`}),`Make scenarios`]})]})]}),(0,I.jsx)(re,{open:b,onClose:()=>x(!1),view:t,set:a,busy:n,onMake:e=>{x(!1),r(()=>m.scenarios(a.id,e))}})]})}function q({sub:e}){let[t,n]=(0,F.useState)(null),[r,i]=(0,F.useState)(``),[a,o]=(0,F.useState)(!1),[l,d]=(0,F.useState)(!1),f=(0,F.useCallback)(()=>{m.view().then(e=>{n(e),i(``)},e=>i(e.message))},[]);(0,F.useEffect)(f,[f]);let g=!!t?.job?.running;(0,F.useEffect)(()=>{if(!g)return;let e=setInterval(f,1500);return()=>clearInterval(e)},[g,f]);let _=async e=>{o(!0),i(``);try{await e(),f()}catch(e){i(e.message)}finally{o(!1)}},v=e?decodeURIComponent(e):``,C=t?.sets.find(e=>e.id===v)||t?.sets[0],T=`${t?.job?.endedAt??``}|${C?.at??``}`,[k,A]=(0,F.useState)(``),M=(t?.sets??[]).filter(e=>k.toLowerCase().split(/\s+/).filter(Boolean).every(t=>e.name.toLowerCase().includes(t)));return(0,I.jsxs)(`div`,{className:`flex min-h-screen flex-col`,children:[(0,I.jsx)(y,{}),(0,I.jsxs)(`main`,{className:p(x,`@container flex-auto gap-4`),children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,I.jsx)(S,{pixel:c[`api-tests`],size:`lg`}),(0,I.jsx)(`h1`,{className:`m-0 flex-1 text-[26px] font-semibold tracking-[-0.01em]`,children:`API tests`}),(0,I.jsxs)(h,{variant:`primary`,disabled:!t||g,onClick:()=>d(!0),children:[(0,I.jsx)(D,{size:16,"aria-hidden":`true`}),`New contract set`]})]}),(0,I.jsx)(`p`,{className:`m-0 max-w-[74ch] text-sm leading-relaxed text-muted`,children:`REST, GraphQL, SOAP and gRPC, tested straight against the API with no browser and no model. A contract is one call and what its answer must have; a scenario chains calls end to end.`}),r&&(0,I.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:r}),!t&&!r&&(0,I.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}),t?.job&&(0,I.jsx)(B,{job:t.job,onStop:()=>_(()=>m.stop())}),t&&(t.sets.length?(0,I.jsxs)(`div`,{className:`flex flex-col gap-6 @2xl:flex-row @2xl:items-start @2xl:gap-8`,children:[(0,I.jsxs)(`nav`,{"aria-label":`Contract sets`,className:`flex min-w-0 flex-col gap-2 @2xl:sticky @2xl:top-6 @2xl:w-[280px] @2xl:flex-none`,children:[(0,I.jsxs)(`span`,{className:`px-1 text-[13px] font-medium text-muted`,children:[`Contract sets (`,t.sets.length,`)`]}),t.sets.length>6&&(0,I.jsx)(j,{id:`set-search`,label:`Find a set`,value:k,onChange:A,className:`flex-none`}),(0,I.jsxs)(`ul`,{className:`m-0 flex max-h-[60vh] list-none flex-col overflow-y-auto p-0 @2xl:max-h-[calc(100vh-240px)]`,children:[M.length===0&&(0,I.jsx)(`li`,{className:`px-3 py-3 text-sm text-muted`,children:`Nothing matches.`}),M.map(e=>{let n=e.last?.contracts,r=!!n&&n.counts.failed+n.counts.error>0;return(0,I.jsx)(`li`,{children:(0,I.jsxs)(`a`,{href:u(`api-tests`,encodeURIComponent(e.id)),"aria-current":C?.id===e.id?`page`:void 0,className:p(`flex min-h-12 items-center gap-2.5 rounded-[10px] px-3 py-1.5 text-ink no-underline`,C?.id===e.id?`bg-surface-strong hover:text-ink`:`hover:bg-surface-muted hover:text-ink`),children:[t?.job?.running&&t.job.target===e.id?(0,I.jsx)(b,{state:`working`,label:`Working on it`,px:16}):n?r?(0,I.jsx)(s,{size:16,"aria-label":`Failures`,className:`flex-none text-fail`}):(0,I.jsx)(O,{size:16,"aria-label":`Passed`,className:`flex-none text-pass`}):(0,I.jsx)(E,{size:16,"aria-label":`Not run`,className:`flex-none text-muted`}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,I.jsx)(`span`,{className:`truncate text-[14px] font-medium`,children:e.name}),(0,I.jsxs)(`span`,{className:`truncate text-[12px] text-muted`,children:[w(e.contracts,`contract`),e.scenarios?` · ${w(e.scenarios,`scenario`)}`:``,n?` · ${n.counts.passed}/${n.counts.passed+n.counts.failed+n.counts.error} passed`:``]})]}),(0,I.jsx)(`span`,{className:`flex-none text-[12px] text-muted tabular-nums`,children:P(e.at)})]})},e.id)})]})]}),C&&(0,I.jsx)(K,{id:C.id,view:t,busy:a||g,act:_,version:T})]}):(0,I.jsxs)(`div`,{className:`flex flex-col items-start gap-3 rounded-[18px] border border-line p-6`,children:[(0,I.jsx)(N,{size:24,"aria-hidden":`true`,className:`text-muted`}),(0,I.jsxs)(`p`,{className:`m-0 max-w-[62ch] leading-relaxed text-ink-2`,children:[`No API contracts yet. Make a set from your OpenAPI, Swagger, WSDL, GraphQL or .proto description`,t.runs.length?`, or from the ${w(t.runs[0].calls,`call`)} the run "${t.runs[0].goal}" saw`:``,`.`]}),(0,I.jsx)(h,{onClick:()=>d(!0),children:`New contract set`})]}))]}),t&&(0,I.jsx)(U,{open:l,onClose:()=>d(!1),view:t,busy:a||g,onMake:e=>_(async()=>{await m.contracts(e),d(!1)})})]})}export{q as ApiTests};
@@ -1,3 +1,3 @@
1
- import{Ar as e,G as t,Nr as n,Pt as r,X as i,Z as a,_t as o,bt as s,dr as c,dt as l,ft as u,ir as d,lr as f,n as p,o as m,ot as h,r as g,t as _,xt as v,yt as y}from"./frame-3JV5tjBP.js";import{n as b,r as x}from"./Response-DhcE4o_e.js";import{_ as S,c as ee,d as te,f as C,g as w,i as T,l as ne,o as re,p as ie,s as E,u as D,y as O}from"./index-XRjCGJfG.js";import{n as k,t as A}from"./when-CHnpLdYw.js";var j={name:`arrow-down`,size:24,node:[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]};j.node;var ae=d(j),M=n(e(),1),N=y();function P({id:e}){let[t,n]=(0,M.useState)([]),[i,d]=(0,M.useState)(null),[h,g]=(0,M.useState)(``),[_,v]=(0,M.useState)(``),[y,w]=(0,M.useState)(!1),T=(0,M.useRef)(null),O=(0,M.useRef)(null),k=(0,M.useRef)(!0),[A,j]=(0,M.useState)(!0);(0,M.useEffect)(()=>{let t=!1,r=0;return n([]),d(null),g(``),(async()=>{for(;!t;)try{let i=await c.events(e,r,r>0);if(t||(g(``),d({title:i.title,state:i.state,profile:i.profile}),i.events.length&&(r=i.events[i.events.length-1].n,n(e=>[...e,...i.events])),(i.state===`closed`||i.state===`failed`)&&!i.events.length))return}catch(e){if(t||(g(e.message),e.status===404))return;await new Promise(e=>setTimeout(e,2e3))}})(),()=>{t=!0}},[e]);let P=(0,M.useMemo)(()=>x(t),[t]),F=(0,M.useMemo)(()=>{let e=new Map;for(let t of P.turns.flatMap(e=>e.changes)){let n=e.get(t.path);e.set(t.path,n?{...n,added:n.added+t.added,removed:n.removed+t.removed}:{path:t.path,added:t.added,removed:t.removed})}return[...e.values()]},[P]),I=(0,M.useMemo)(()=>{let e=[];for(let t of P.turns){for(let n of t.tests)n.testFile&&e.push({label:n.ok?`Test`:`Test (failed)`,path:n.testFile,kind:`test`});for(let n of t.reports)e.push({label:/\.html?$/i.test(n.path)?`Report`:`Run report`,path:n.path,kind:`report`})}return e.filter((t,n)=>e.findIndex(e=>e.path===t.path)===n)},[P]),L=(0,M.useRef)(()=>{});m(P.context||P.usage||F.length||I.length?{context:P.context,usage:P.usage,model:P.model?.name,changes:F,outputs:I,busy:i?.state===`busy`||i?.state===`starting`,...F.length?{onCreatePr:()=>L.current()}:{}}:null);let R=i?.state,z=R===`busy`||R===`starting`,B=R===`closed`||R===`failed`,V=P.turns.at(-1),H=!!V&&!V.outcome&&(V.asks.some(e=>e.answer===void 0)||V.waits.some(e=>e.answer===void 0));(0,M.useEffect)(()=>{let e=document.documentElement,t=()=>window.innerHeight+window.scrollY>=e.scrollHeight-48,n=e=>{k.current=e,j(e)},r=window.scrollY,i=()=>{t()?n(!0):window.scrollY<r-2&&n(!1),r=window.scrollY},a=new ResizeObserver(()=>{k.current&&!t()&&window.scrollTo({top:e.scrollHeight,behavior:`instant`})});return T.current&&a.observe(T.current),O.current&&a.observe(O.current),window.addEventListener(`scroll`,i,{passive:!0}),()=>{a.disconnect(),window.removeEventListener(`scroll`,i)}},[]);let U=()=>{k.current=!0,j(!0),window.scrollTo({top:document.documentElement.scrollHeight,behavior:`smooth`})},[W,G]=(0,M.useState)(null);(0,M.useEffect)(()=>void f.settings().then(G,()=>{}),[]);let[K,q]=(0,M.useState)(!1),[J,Y]=(0,M.useState)({});(0,M.useEffect)(()=>Y({}),[P.headed,P.writeTests]);let X={...E(W),headed:J.headed??P.headed??!1,code:J.code??P.writeTests??!0},Z=(0,M.useCallback)(async e=>{try{await e()}catch(e){g(e.message)}},[]),Q=te(`chat-${e}`.replace(/[^\w-]/g,``).slice(0,80),e=>{v(e),D(`reply`)}),$=async t=>{if(t.trim()&&!y){w(!0),k.current=!0,j(!0);try{await c.send(e,t.trim()),v(``),g(``),Q.close()}catch(e){g(e.message)}finally{w(!1)}}};return L.current=()=>{if(i?.state===`busy`||i?.state===`starting`||y)return;let e=F.map(e=>`- ${e.path}`).join(`
2
- `);$(`Open a pull request with the changes you made in this chat:\n${e}\n\nUse a new branch, a clear title and description, and tell me its link.`)},(0,N.jsxs)(`div`,{className:`flex min-h-screen flex-col`,children:[(0,N.jsxs)(`header`,{className:`sticky top-0 z-20 flex items-center gap-1 border-b border-line-soft bg-bg py-3 pr-16 pl-5 md:pr-5`,children:[(0,N.jsx)(p,{}),(0,N.jsx)(`h1`,{className:`m-0 ml-2 min-w-0 flex-1 truncate text-base font-semibold`,children:i?.title||`Chat`}),P.model&&(0,N.jsxs)(`span`,{className:`hidden min-h-9 items-center gap-1.5 rounded-lg px-2 text-sm text-ink-2 sm:inline-flex`,title:`The model this chat uses`,children:[(0,N.jsx)(o,{icon:r,size:14,className:`text-accent-fg`}),P.model.name]})]}),(0,N.jsxs)(`main`,{ref:T,className:`mx-auto box-border flex w-full max-w-[960px] flex-auto flex-col gap-8 px-6 pt-8 pb-6`,children:[!i&&!h&&(0,N.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Opening the chat…`}),P.turns.map((t,n)=>(0,N.jsxs)(`section`,{"aria-label":`Message ${n+1}`,className:`flex flex-col gap-5`,children:[(0,N.jsx)(`div`,{className:`ml-auto max-w-[min(85%,640px)] rounded-[18px] bg-surface-strong px-4 py-2.5 text-[15px] leading-relaxed whitespace-pre-wrap text-ink [overflow-wrap:anywhere]`,children:t.user}),(0,N.jsx)(b,{turn:t,live:n===P.turns.length-1&&!B,onAnswer:(t,n)=>Z(()=>c.answer(e,t,n)),onProceed:(t,n)=>Z(()=>c.proceed(e,t,n))})]},t.id)),V?.outcome===`done`&&V.next.length>0&&!z&&!B&&(0,N.jsx)(`div`,{className:`flex flex-wrap gap-2 pl-12`,children:V.next.map(e=>(0,N.jsx)(`button`,{type:`button`,title:e.request===e.label?void 0:e.request,onClick:()=>void $(e.request),className:`inline-flex min-h-10 cursor-pointer items-center rounded-[8px] border-0 bg-surface-strong px-4 text-sm font-medium text-ink-2 hover:bg-line hover:text-ink`,children:e.label},e.label))}),(P.fatal||B&&P.ended)&&(0,N.jsxs)(`div`,{role:`alert`,className:s(`flex flex-col gap-2 rounded-[14px] px-4 py-3 text-sm leading-relaxed`,P.fatal||R===`failed`?`bg-fail-soft text-fail`:`bg-surface-muted text-ink-2`),children:[(0,N.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:P.fatal||P.ended?.message||(R===`failed`?`ForgeQE stopped unexpectedly.`:`This chat has ended.`)}),P.ended?.stderr&&(0,N.jsx)(`pre`,{className:`m-0 max-h-[200px] overflow-auto rounded-lg bg-bg/60 px-3 py-2 font-mono text-[12px] whitespace-pre-wrap text-ink-2 [overflow-wrap:anywhere]`,children:P.ended.stderr.join(`
3
- `)}),(0,N.jsxs)(`span`,{className:`flex flex-wrap gap-2`,children:[(0,N.jsx)(`a`,{className:u({size:`sm`}),href:a(),children:`Start a new chat`}),P.fatal&&/model|key|sign/i.test(P.fatal)&&(0,N.jsx)(`a`,{className:u({size:`sm`}),href:a(`settings`,`models`),children:`Models`}),P.fatal&&/runtime|engine|setup/i.test(P.fatal)&&(0,N.jsx)(`a`,{className:u({size:`sm`}),href:a(`settings`,`setup`),children:`Set up`})]})]}),P.notes.map((e,t)=>(0,N.jsx)(`p`,{className:`m-0 text-sm text-muted [overflow-wrap:anywhere]`,children:e},t))]}),(0,N.jsx)(`div`,{ref:O,className:`sticky bottom-0 z-10 bg-gradient-to-t from-bg from-70% to-transparent px-6 pt-4 pb-5`,children:(0,N.jsxs)(`div`,{className:`relative mx-auto flex w-full max-w-[880px] flex-col gap-2`,children:[!A&&z&&(0,N.jsxs)(`button`,{type:`button`,onClick:U,className:`absolute -top-11 left-1/2 inline-flex min-h-8 -translate-x-1/2 cursor-pointer items-center gap-1.5 rounded-[8px] border-0 bg-surface-strong px-3 text-[13px] font-medium text-ink-2 shadow-sm hover:bg-line hover:text-ink`,children:[(0,N.jsx)(ae,{size:14,"aria-hidden":`true`}),`Latest activity`]}),(0,N.jsx)(`div`,{"aria-live":`polite`,children:h&&(0,N.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:h})}),(0,N.jsx)(C,{id:`reply`,label:`Reply to ForgeQE`,rows:1,value:_,onChange:v,onSend:()=>void $(_),onStop:()=>Z(()=>c.stop(e)),busy:z&&!H,disabled:B||y||H||Q.running,top:Q.state&&(0,N.jsx)(ne,{state:Q.state,onStop:()=>void Q.stop(),onUndo:Q.undo,onClose:Q.close}),left:(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{className:`relative`,children:[(0,N.jsxs)(l,{variant:`ghost`,className:`px-2.5 text-[15px]`,disabled:B,"aria-expanded":K,"aria-haspopup":`dialog`,onClick:()=>q(!K),children:[(0,N.jsx)(S,{size:18,strokeWidth:1.8,"aria-hidden":`true`}),`Tools`,(X.headed||!X.code)&&(0,N.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 rounded-full bg-accent`})]}),(0,N.jsx)(ie,{open:K,onClose:()=>q(!1),label:`Tools for this chat`,role:`dialog`,side:`auto`,className:`left-0 w-[min(380px,calc(100vw-48px))]`,children:(0,N.jsx)(re,{tools:X,chat:{model:P.model?.name,provider:P.model?.provider},onChange:t=>{let n={};t.headed!==X.headed&&(n.headed=t.headed),t.code!==X.code&&(n.writeTests=t.code),Object.keys(n).length&&(Y({headed:t.headed,code:t.code}),Z(()=>c.settings(e,n)))}})})]}),(0,N.jsx)(ee,{running:Q.running,disabled:!_.trim()||B||y||H,onClick:()=>void Q.start(_)})]}),placeholder:B?`This chat has ended`:H?`Answer above to go on`:z?`ForgeQE is working…`:`Reply to ForgeQE…`})]})})]})}function F(e){return e.waiting||e.state===`ready`&&e.outcome===`needs_input`?`waiting`:e.state===`busy`||e.state===`starting`?`working`:e.state===`closed`||e.state===`failed`?`ended`:`done`}var I={working:{label:`Working`,tone:`running`},waiting:{label:`Needs you`,tone:`warn`},done:{label:`Your turn`,tone:`pass`},ended:{label:`Ended`,tone:`neutral`}},L=[{id:`all`,label:`All`},{id:`working`,label:`Working`},{id:`waiting`,label:`Needs you`},{id:`done`,label:`Your turn`},{id:`ended`,label:`Ended`}];function R({c:e}){let t=F(e),n=I[t];return(0,N.jsxs)(`a`,{href:a(`chats`,e.id),className:`group grid min-h-14 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-4 rounded-[10px] px-3 py-2 text-ink no-underline hover:bg-surface-muted hover:text-ink @3xl:grid-cols-[minmax(0,1fr)_120px_90px_150px_96px]`,children:[(0,N.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,N.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[t===`waiting`&&(0,N.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 flex-none rounded-full bg-warn`}),(0,N.jsx)(`span`,{className:`truncate text-[14px] font-medium`,children:e.title})]}),(0,N.jsx)(`span`,{className:s(`truncate text-[12.5px]`,e.lastReply?`text-muted`:`text-muted italic`),children:e.lastReply||(t===`working`?`Working on the first answer…`:`No answer yet`)})]}),(0,N.jsx)(`span`,{className:`justify-self-end @3xl:justify-self-start`,children:(0,N.jsx)(T,{tone:n.tone,orb:e.state===`starting`?`waiting`:`working`,children:n.label})}),(0,N.jsx)(`span`,{className:`hidden text-[13px] text-muted tabular-nums @3xl:block`,children:e.turns?v(e.turns,`message`):`—`}),(0,N.jsx)(`span`,{className:`hidden min-w-0 items-center gap-1 truncate text-[13px] text-muted @3xl:flex`,children:e.profile?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(o,{icon:r,size:11,className:`flex-none text-accent-fg`}),(0,N.jsx)(`span`,{className:`truncate`,children:e.profile})]}):`Default model`}),(0,N.jsx)(`span`,{className:`hidden text-right text-[13px] text-muted tabular-nums @3xl:block`,children:A(e.lastAt||e.started)})]})}var z=50;function B(){let[e,n]=(0,M.useState)(null),[r,o]=(0,M.useState)(``),[d,f]=(0,M.useState)(`all`),[p,m]=(0,M.useState)(``),[v,y]=(0,M.useState)(z);(0,M.useEffect)(()=>y(z),[d,p]),(0,M.useEffect)(()=>{let e=!1,t=()=>c.list().then(t=>!e&&n(t.chats),t=>!e&&o(t.message));t();let r=setInterval(t,5e3);return()=>{e=!0,clearInterval(r)}},[]);let b=(0,M.useMemo)(()=>{let t={all:0,working:0,waiting:0,done:0,ended:0};for(let n of e||[])t.all++,t[F(n)]++;return t},[e]),x=(0,M.useMemo)(()=>{let t=p.toLowerCase().split(/\s+/).filter(Boolean),n=e=>Date.parse(e.lastAt||e.started)||0;return(e||[]).filter(e=>(d===`all`||F(e)===d)&&t.every(t=>`${e.title} ${e.lastReply||``} ${e.profile||``}`.toLowerCase().includes(t))).sort((e,t)=>n(t)-n(e))},[e,d,p]),S=(0,M.useMemo)(()=>{let e=[];for(let t of x.slice(0,v)){let n=k(t.lastAt||t.started),r=e.find(e=>e.day===n);r?r.chats.push(t):e.push({day:n,chats:[t]})}return e},[x,v]);return(0,N.jsxs)(`div`,{className:`flex min-h-screen flex-col`,children:[(0,N.jsx)(g,{}),(0,N.jsxs)(`main`,{className:s(_,`gap-5`),children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,N.jsx)(h,{pixel:i.chats,size:`lg`}),(0,N.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,N.jsx)(`h1`,{className:`m-0 text-[26px] font-semibold tracking-[-0.01em]`,children:`Chats`}),(0,N.jsx)(`span`,{className:`text-[13px] text-muted`,children:`Each one is its own ForgeQE agent in your project folder, for as long as forgeqe web runs.`})]}),(0,N.jsxs)(`a`,{className:s(u({variant:`primary`}),`gap-2`),href:a(),children:[(0,N.jsx)(w,{size:16,"aria-hidden":`true`}),`New chat`]})]}),e&&e.length>0&&(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,N.jsx)(`div`,{role:`radiogroup`,"aria-label":`Show`,className:`flex flex-wrap gap-1 rounded-[10px] bg-surface-strong p-1`,children:L.map(e=>(0,N.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":d===e.id,onClick:()=>f(e.id),className:s(`inline-flex min-h-8 cursor-pointer items-center gap-1.5 rounded-[7px] border-0 px-3 text-sm font-medium`,d===e.id?`bg-bg text-ink shadow-sm`:`bg-transparent text-muted hover:text-ink`),children:[e.label,(0,N.jsx)(`span`,{className:s(`tabular-nums text-[12px]`,e.id===`waiting`&&b.waiting?`text-warn`:`text-muted`),children:b[e.id]})]},e.id))}),(0,N.jsxs)(`div`,{className:`relative min-w-0 flex-[1_1_240px]`,children:[(0,N.jsx)(O,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-muted`}),(0,N.jsx)(t,{type:`search`,"aria-label":`Find a chat`,value:p,placeholder:`Find a chat`,onChange:e=>m(e.target.value),className:`pl-9`})]})]}),r&&(0,N.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail`,children:r}),!e&&!r&&(0,N.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Loading…`}),e&&e.length===0&&(0,N.jsxs)(`div`,{className:`flex flex-col items-center gap-4 rounded-[18px] border border-dashed border-line px-6 py-14 text-center`,children:[(0,N.jsx)(h,{pixel:i.chats,size:`lg`}),(0,N.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,N.jsx)(`span`,{className:`text-lg font-semibold`,children:`No chats yet`}),(0,N.jsx)(`span`,{className:`max-w-[48ch] text-sm text-muted`,children:`Ask ForgeQE to run test cases, explore a journey, write a test or review requirements. Each chat shows up here while forgeqe web runs.`})]}),(0,N.jsx)(`a`,{className:u({variant:`primary`}),href:a(),children:`Start a chat`})]}),e&&e.length>0&&x.length===0&&(0,N.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`No chat matches.`}),x.length>0&&(0,N.jsxs)(`div`,{className:`@container rounded-[14px] border border-line-soft bg-bg`,children:[(0,N.jsxs)(`div`,{"aria-hidden":`true`,className:`hidden grid-cols-[minmax(0,1fr)_120px_90px_150px_96px] gap-x-4 border-b border-line-soft px-6 py-2 text-[12px] font-medium text-muted @3xl:grid`,children:[(0,N.jsx)(`span`,{children:`Chat`}),(0,N.jsx)(`span`,{children:`Status`}),(0,N.jsx)(`span`,{children:`Messages`}),(0,N.jsx)(`span`,{children:`Model`}),(0,N.jsx)(`span`,{className:`text-right`,children:`Last activity`})]}),S.map(e=>(0,N.jsxs)(`section`,{"aria-labelledby":`day-${e.day}`,children:[(0,N.jsxs)(`h2`,{id:`day-${e.day}`,className:`sticky top-0 z-[1] m-0 border-b border-line-soft bg-surface-muted/95 px-6 py-1.5 text-[12px] font-semibold tracking-wide text-muted uppercase backdrop-blur`,children:[e.day,` `,(0,N.jsxs)(`span`,{className:`font-normal tabular-nums`,children:[`· `,e.chats.length]})]}),(0,N.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-1.5`,children:e.chats.map(e=>(0,N.jsx)(`li`,{children:(0,N.jsx)(R,{c:e})},e.id))})]},e.day)),x.length>v&&(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-line-soft px-6 py-3 text-[13px] text-muted`,children:[(0,N.jsxs)(`span`,{children:[`Showing `,v,` of `,x.length]}),(0,N.jsxs)(l,{size:`sm`,onClick:()=>y(v+z),children:[`Show `,Math.min(z,x.length-v),` more`]})]})]})]})]})}export{P as Chat,B as Chats};
1
+ import{Fr as e,G as t,Mr as n,Pt as r,X as i,Z as a,_t as o,ar as s,bt as c,dt as l,fr as u,ft as d,n as f,o as p,r as m,t as h,ur as g,ut as _,xt as v,yt as y}from"./frame-z3iL_6aL.js";import{n as b,r as x}from"./Response-Dh_kxnCt.js";import{_ as S,b as C,c as w,d as ee,f as te,i as T,l as ne,o as re,p as ie,s as E,u as D,v as O}from"./index-BVw2ygO2.js";import{n as k,t as A}from"./when-CHnpLdYw.js";var j={name:`arrow-down`,size:24,node:[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]};j.node;var ae=s(j),M=e(n(),1),N=y();function P({id:e}){let[t,n]=(0,M.useState)([]),[i,s]=(0,M.useState)(null),[m,h]=(0,M.useState)(``),[_,v]=(0,M.useState)(``),[y,S]=(0,M.useState)(!1),C=(0,M.useRef)(null),T=(0,M.useRef)(null),k=(0,M.useRef)(!0),[A,j]=(0,M.useState)(!0);(0,M.useEffect)(()=>{let t=!1,r=0;return n([]),s(null),h(``),(async()=>{for(;!t;)try{let i=await u.events(e,r,r>0);if(t||(h(``),s({title:i.title,state:i.state,profile:i.profile}),i.events.length&&(r=i.events[i.events.length-1].n,n(e=>[...e,...i.events])),(i.state===`closed`||i.state===`failed`)&&!i.events.length))return}catch(e){if(t||(h(e.message),e.status===404))return;await new Promise(e=>setTimeout(e,2e3))}})(),()=>{t=!0}},[e]);let P=(0,M.useMemo)(()=>x(t),[t]),F=(0,M.useMemo)(()=>{let e=new Map;for(let t of P.turns.flatMap(e=>e.changes)){let n=e.get(t.path);e.set(t.path,n?{...n,added:n.added+t.added,removed:n.removed+t.removed}:{path:t.path,added:t.added,removed:t.removed})}return[...e.values()]},[P]),I=(0,M.useMemo)(()=>{let e=[];for(let t of P.turns){for(let n of t.tests)n.testFile&&e.push({label:n.ok?`Test`:`Test (failed)`,path:n.testFile,kind:`test`});for(let n of t.reports)e.push({label:/\.html?$/i.test(n.path)?`Report`:`Run report`,path:n.path,kind:`report`})}return e.filter((t,n)=>e.findIndex(e=>e.path===t.path)===n)},[P]),L=(0,M.useRef)(()=>{});p(P.context||P.usage||F.length||I.length?{context:P.context,usage:P.usage,model:P.model?.name,changes:F,outputs:I,busy:i?.state===`busy`||i?.state===`starting`,...F.length?{onCreatePr:()=>L.current()}:{}}:null);let R=i?.state,z=R===`busy`||R===`starting`,B=R===`closed`||R===`failed`,V=P.turns.at(-1),H=!!V&&!V.outcome&&(V.asks.some(e=>e.answer===void 0)||V.waits.some(e=>e.answer===void 0));(0,M.useEffect)(()=>{let e=document.documentElement,t=()=>window.innerHeight+window.scrollY>=e.scrollHeight-48,n=e=>{k.current=e,j(e)},r=window.scrollY,i=()=>{t()?n(!0):window.scrollY<r-2&&n(!1),r=window.scrollY},a=new ResizeObserver(()=>{k.current&&!t()&&window.scrollTo({top:e.scrollHeight,behavior:`instant`})});return C.current&&a.observe(C.current),T.current&&a.observe(T.current),window.addEventListener(`scroll`,i,{passive:!0}),()=>{a.disconnect(),window.removeEventListener(`scroll`,i)}},[]);let U=()=>{k.current=!0,j(!0),window.scrollTo({top:document.documentElement.scrollHeight,behavior:`smooth`})},[W,G]=(0,M.useState)(null);(0,M.useEffect)(()=>void g.settings().then(G,()=>{}),[]);let[K,q]=(0,M.useState)(!1),[J,Y]=(0,M.useState)({});(0,M.useEffect)(()=>Y({}),[P.headed,P.writeTests]);let X={...E(W),headed:J.headed??P.headed??!1,code:J.code??P.writeTests??!0},Z=(0,M.useCallback)(async e=>{try{await e()}catch(e){h(e.message)}},[]),Q=ee(`chat-${e}`.replace(/[^\w-]/g,``).slice(0,80),e=>{v(e),D(`reply`)}),$=async t=>{if(t.trim()&&!y){S(!0),k.current=!0,j(!0);try{await u.send(e,t.trim()),v(``),h(``),Q.close()}catch(e){h(e.message)}finally{S(!1)}}};return L.current=()=>{if(i?.state===`busy`||i?.state===`starting`||y)return;let e=F.map(e=>`- ${e.path}`).join(`
2
+ `);$(`Open a pull request with the changes you made in this chat:\n${e}\n\nUse a new branch, a clear title and description, and tell me its link.`)},(0,N.jsxs)(`div`,{className:`flex min-h-screen flex-col`,children:[(0,N.jsxs)(`header`,{className:`sticky top-0 z-20 flex items-center gap-1 border-b border-line-soft bg-bg py-3 pr-16 pl-5 md:pr-5`,children:[(0,N.jsx)(f,{}),(0,N.jsx)(`h1`,{className:`m-0 ml-2 min-w-0 flex-1 truncate text-base font-semibold`,children:i?.title||`Chat`}),P.model&&(0,N.jsxs)(`span`,{className:`hidden min-h-9 items-center gap-1.5 rounded-lg px-2 text-sm text-ink-2 sm:inline-flex`,title:`The model this chat uses`,children:[(0,N.jsx)(o,{icon:r,size:14,className:`text-accent-fg`}),P.model.name]})]}),(0,N.jsxs)(`main`,{ref:C,className:`mx-auto box-border flex w-full max-w-[960px] flex-auto flex-col gap-8 px-6 pt-8 pb-6`,children:[!i&&!m&&(0,N.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Opening the chat…`}),P.turns.map((t,n)=>(0,N.jsxs)(`section`,{"aria-label":`Message ${n+1}`,className:`flex flex-col gap-5`,children:[(0,N.jsx)(`div`,{className:`ml-auto max-w-[min(85%,640px)] rounded-[18px] bg-surface-strong px-4 py-2.5 text-[15px] leading-relaxed whitespace-pre-wrap text-ink [overflow-wrap:anywhere]`,children:t.user}),(0,N.jsx)(b,{turn:t,live:n===P.turns.length-1&&!B,onAnswer:(t,n)=>Z(()=>u.answer(e,t,n)),onProceed:(t,n)=>Z(()=>u.proceed(e,t,n))})]},t.id)),V?.outcome===`done`&&V.next.length>0&&!z&&!B&&(0,N.jsx)(`div`,{className:`flex flex-wrap gap-2 pl-12`,children:V.next.map(e=>(0,N.jsx)(`button`,{type:`button`,title:e.request===e.label?void 0:e.request,onClick:()=>void $(e.request),className:`inline-flex min-h-10 cursor-pointer items-center rounded-[8px] border-0 bg-surface-strong px-4 text-sm font-medium text-ink-2 hover:bg-line hover:text-ink`,children:e.label},e.label))}),(P.fatal||B&&P.ended)&&(0,N.jsxs)(`div`,{role:`alert`,className:c(`flex flex-col gap-2 rounded-[14px] px-4 py-3 text-sm leading-relaxed`,P.fatal||R===`failed`?`bg-fail-soft text-fail`:`bg-surface-muted text-ink-2`),children:[(0,N.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:P.fatal||P.ended?.message||(R===`failed`?`ForgeQE stopped unexpectedly.`:`This chat has ended.`)}),P.ended?.stderr&&(0,N.jsx)(`pre`,{className:`m-0 max-h-[200px] overflow-auto rounded-lg bg-bg/60 px-3 py-2 font-mono text-[12px] whitespace-pre-wrap text-ink-2 [overflow-wrap:anywhere]`,children:P.ended.stderr.join(`
3
+ `)}),(0,N.jsxs)(`span`,{className:`flex flex-wrap gap-2`,children:[(0,N.jsx)(`a`,{className:d({size:`sm`}),href:a(),children:`Start a new chat`}),P.fatal&&/model|key|sign/i.test(P.fatal)&&(0,N.jsx)(`a`,{className:d({size:`sm`}),href:a(`settings`,`models`),children:`Models`}),P.fatal&&/runtime|engine|setup/i.test(P.fatal)&&(0,N.jsx)(`a`,{className:d({size:`sm`}),href:a(`settings`,`setup`),children:`Set up`})]})]}),P.notes.map((e,t)=>(0,N.jsx)(`p`,{className:`m-0 text-sm text-muted [overflow-wrap:anywhere]`,children:e},t))]}),(0,N.jsx)(`div`,{ref:T,className:`sticky bottom-0 z-10 bg-gradient-to-t from-bg from-70% to-transparent px-6 pt-4 pb-5`,children:(0,N.jsxs)(`div`,{className:`relative mx-auto flex w-full max-w-[880px] flex-col gap-2`,children:[!A&&z&&(0,N.jsxs)(`button`,{type:`button`,onClick:U,className:`absolute -top-11 left-1/2 inline-flex min-h-8 -translate-x-1/2 cursor-pointer items-center gap-1.5 rounded-[8px] border-0 bg-surface-strong px-3 text-[13px] font-medium text-ink-2 shadow-sm hover:bg-line hover:text-ink`,children:[(0,N.jsx)(ae,{size:14,"aria-hidden":`true`}),`Latest activity`]}),(0,N.jsx)(`div`,{"aria-live":`polite`,children:m&&(0,N.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:m})}),(0,N.jsx)(te,{id:`reply`,label:`Reply to ForgeQE`,rows:1,value:_,onChange:v,onSend:()=>void $(_),onStop:()=>Z(()=>u.stop(e)),busy:z&&!H,disabled:B||y||H||Q.running,top:Q.state&&(0,N.jsx)(ne,{state:Q.state,onStop:()=>void Q.stop(),onUndo:Q.undo,onClose:Q.close}),left:(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{className:`relative`,children:[(0,N.jsxs)(l,{variant:`ghost`,className:`px-2.5 text-[15px]`,disabled:B,"aria-expanded":K,"aria-haspopup":`dialog`,onClick:()=>q(!K),children:[(0,N.jsx)(O,{size:18,strokeWidth:1.8,"aria-hidden":`true`}),`Tools`,(X.headed||!X.code)&&(0,N.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 rounded-full bg-accent`})]}),(0,N.jsx)(ie,{open:K,onClose:()=>q(!1),label:`Tools for this chat`,role:`dialog`,side:`auto`,className:`left-0 w-[min(380px,calc(100vw-48px))]`,children:(0,N.jsx)(re,{tools:X,chat:{model:P.model?.name,provider:P.model?.provider},onChange:t=>{let n={};t.headed!==X.headed&&(n.headed=t.headed),t.code!==X.code&&(n.writeTests=t.code),Object.keys(n).length&&(Y({headed:t.headed,code:t.code}),Z(()=>u.settings(e,n)))}})})]}),(0,N.jsx)(w,{running:Q.running,disabled:!_.trim()||B||y||H,onClick:()=>void Q.start(_)})]}),placeholder:B?`This chat has ended`:H?`Answer above to go on`:z?`ForgeQE is working…`:`Reply to ForgeQE…`})]})})]})}function F(e){return e.waiting||e.state===`ready`&&e.outcome===`needs_input`?`waiting`:e.state===`busy`||e.state===`starting`?`working`:e.state===`closed`||e.state===`failed`?`ended`:`done`}var I={working:{label:`Working`,tone:`running`},waiting:{label:`Needs you`,tone:`warn`},done:{label:`Your turn`,tone:`pass`},ended:{label:`Ended`,tone:`neutral`}},L=[{id:`all`,label:`All`},{id:`working`,label:`Working`},{id:`waiting`,label:`Needs you`},{id:`done`,label:`Your turn`},{id:`ended`,label:`Ended`}];function R({c:e}){let t=F(e),n=I[t];return(0,N.jsxs)(`a`,{href:a(`chats`,e.id),className:`group grid min-h-14 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-4 rounded-[10px] px-3 py-2 text-ink no-underline hover:bg-surface-muted hover:text-ink @3xl:grid-cols-[minmax(0,1fr)_120px_90px_150px_96px]`,children:[(0,N.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,N.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[t===`waiting`&&(0,N.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 flex-none rounded-full bg-warn`}),(0,N.jsx)(`span`,{className:`truncate text-[14px] font-medium`,children:e.title})]}),(0,N.jsx)(`span`,{className:c(`truncate text-[12.5px]`,e.lastReply?`text-muted`:`text-muted italic`),children:e.lastReply||(t===`working`?`Working on the first answer…`:`No answer yet`)})]}),(0,N.jsx)(`span`,{className:`justify-self-end @3xl:justify-self-start`,children:(0,N.jsx)(T,{tone:n.tone,orb:e.state===`starting`?`waiting`:`working`,children:n.label})}),(0,N.jsx)(`span`,{className:`hidden text-[13px] text-muted tabular-nums @3xl:block`,children:e.turns?v(e.turns,`message`):`—`}),(0,N.jsx)(`span`,{className:`hidden min-w-0 items-center gap-1 truncate text-[13px] text-muted @3xl:flex`,children:e.profile?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(o,{icon:r,size:11,className:`flex-none text-accent-fg`}),(0,N.jsx)(`span`,{className:`truncate`,children:e.profile})]}):`Default model`}),(0,N.jsx)(`span`,{className:`hidden text-right text-[13px] text-muted tabular-nums @3xl:block`,children:A(e.lastAt||e.started)})]})}var z=50;function B(){let[e,n]=(0,M.useState)(null),[r,o]=(0,M.useState)(``),[s,f]=(0,M.useState)(`all`),[p,g]=(0,M.useState)(``),[v,y]=(0,M.useState)(z);(0,M.useEffect)(()=>y(z),[s,p]),(0,M.useEffect)(()=>{let e=!1,t=()=>u.list().then(t=>!e&&n(t.chats),t=>!e&&o(t.message));t();let r=setInterval(t,5e3);return()=>{e=!0,clearInterval(r)}},[]);let b=(0,M.useMemo)(()=>{let t={all:0,working:0,waiting:0,done:0,ended:0};for(let n of e||[])t.all++,t[F(n)]++;return t},[e]),x=(0,M.useMemo)(()=>{let t=p.toLowerCase().split(/\s+/).filter(Boolean),n=e=>Date.parse(e.lastAt||e.started)||0;return(e||[]).filter(e=>(s===`all`||F(e)===s)&&t.every(t=>`${e.title} ${e.lastReply||``} ${e.profile||``}`.toLowerCase().includes(t))).sort((e,t)=>n(t)-n(e))},[e,s,p]),w=(0,M.useMemo)(()=>{let e=[];for(let t of x.slice(0,v)){let n=k(t.lastAt||t.started),r=e.find(e=>e.day===n);r?r.chats.push(t):e.push({day:n,chats:[t]})}return e},[x,v]);return(0,N.jsxs)(`div`,{className:`flex min-h-screen flex-col`,children:[(0,N.jsx)(m,{}),(0,N.jsxs)(`main`,{className:c(h,`gap-5`),children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,N.jsx)(_,{pixel:i.chats,size:`lg`}),(0,N.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,N.jsx)(`h1`,{className:`m-0 text-[26px] font-semibold tracking-[-0.01em]`,children:`Chats`}),(0,N.jsx)(`span`,{className:`text-[13px] text-muted`,children:`Each one is its own ForgeQE agent in your project folder, for as long as forgeqe web runs.`})]}),(0,N.jsxs)(`a`,{className:c(d({variant:`primary`}),`gap-2`),href:a(),children:[(0,N.jsx)(S,{size:16,"aria-hidden":`true`}),`New chat`]})]}),e&&e.length>0&&(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,N.jsx)(`div`,{role:`radiogroup`,"aria-label":`Show`,className:`flex flex-wrap gap-1 rounded-[10px] bg-surface-strong p-1`,children:L.map(e=>(0,N.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":s===e.id,onClick:()=>f(e.id),className:c(`inline-flex min-h-8 cursor-pointer items-center gap-1.5 rounded-[7px] border-0 px-3 text-sm font-medium`,s===e.id?`bg-bg text-ink shadow-sm`:`bg-transparent text-muted hover:text-ink`),children:[e.label,(0,N.jsx)(`span`,{className:c(`tabular-nums text-[12px]`,e.id===`waiting`&&b.waiting?`text-warn`:`text-muted`),children:b[e.id]})]},e.id))}),(0,N.jsxs)(`div`,{className:`relative min-w-0 flex-[1_1_240px]`,children:[(0,N.jsx)(C,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-muted`}),(0,N.jsx)(t,{type:`search`,"aria-label":`Find a chat`,value:p,placeholder:`Find a chat`,onChange:e=>g(e.target.value),className:`pl-9`})]})]}),r&&(0,N.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail`,children:r}),!e&&!r&&(0,N.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Loading…`}),e&&e.length===0&&(0,N.jsxs)(`div`,{className:`flex flex-col items-center gap-4 rounded-[18px] border border-dashed border-line px-6 py-14 text-center`,children:[(0,N.jsx)(_,{pixel:i.chats,size:`lg`}),(0,N.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,N.jsx)(`span`,{className:`text-lg font-semibold`,children:`No chats yet`}),(0,N.jsx)(`span`,{className:`max-w-[48ch] text-sm text-muted`,children:`Ask ForgeQE to run test cases, explore a journey, write a test or review requirements. Each chat shows up here while forgeqe web runs.`})]}),(0,N.jsx)(`a`,{className:d({variant:`primary`}),href:a(),children:`Start a chat`})]}),e&&e.length>0&&x.length===0&&(0,N.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`No chat matches.`}),x.length>0&&(0,N.jsxs)(`div`,{className:`@container rounded-[14px] border border-line-soft bg-bg`,children:[(0,N.jsxs)(`div`,{"aria-hidden":`true`,className:`hidden grid-cols-[minmax(0,1fr)_120px_90px_150px_96px] gap-x-4 border-b border-line-soft px-6 py-2 text-[12px] font-medium text-muted @3xl:grid`,children:[(0,N.jsx)(`span`,{children:`Chat`}),(0,N.jsx)(`span`,{children:`Status`}),(0,N.jsx)(`span`,{children:`Messages`}),(0,N.jsx)(`span`,{children:`Model`}),(0,N.jsx)(`span`,{className:`text-right`,children:`Last activity`})]}),w.map(e=>(0,N.jsxs)(`section`,{"aria-labelledby":`day-${e.day}`,children:[(0,N.jsxs)(`h2`,{id:`day-${e.day}`,className:`sticky top-0 z-[1] m-0 border-b border-line-soft bg-surface-muted/95 px-6 py-1.5 text-[12px] font-semibold tracking-wide text-muted uppercase backdrop-blur`,children:[e.day,` `,(0,N.jsxs)(`span`,{className:`font-normal tabular-nums`,children:[`· `,e.chats.length]})]}),(0,N.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-1.5`,children:e.chats.map(e=>(0,N.jsx)(`li`,{children:(0,N.jsx)(R,{c:e})},e.id))})]},e.day)),x.length>v&&(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-line-soft px-6 py-3 text-[13px] text-muted`,children:[(0,N.jsxs)(`span`,{children:[`Showing `,v,` of `,x.length]}),(0,N.jsxs)(l,{size:`sm`,onClick:()=>y(v+z),children:[`Show `,Math.min(z,x.length-v),` more`]})]})]})]})]})}export{P as Chat,B as Chats};
@@ -1,4 +1,4 @@
1
- import{$t as e,An as t,Ar as n,At as r,E as i,G as a,K as o,Kt as s,Nr as c,Pn as l,Sn as u,Vt as d,X as f,Y as p,Z as m,_t as h,bt as g,dr as _,dt as v,fr as y,ir as b,kt as x,ot as S,q as C,qt as w,r as T,t as E,xt as D,yt as O}from"./frame-3JV5tjBP.js";import"./markdown-Bca_tHZ5.js";import{h as k,i as A,w as j,y as M}from"./index-XRjCGJfG.js";var N={name:`sprout`,size:24,node:[[`path`,{d:`M14 9.536V7a4 4 0 0 1 4-4h1.5a.5.5 0 0 1 .5.5V5a4 4 0 0 1-4 4 4 4 0 0 0-4 4c0 2 1 3 1 5a5 5 0 0 1-1 3`,key:`139s4v`}],[`path`,{d:`M4 9a5 5 0 0 1 8 4 5 5 0 0 1-8-4`,key:`1dlkgp`}],[`path`,{d:`M5 21h14`,key:`11awu3`}]]};N.node;var P=b(N),F={name:`waypoints`,size:24,node:[[`path`,{d:`m10.586 5.414-5.172 5.172`,key:`4mc350`}],[`path`,{d:`m18.586 13.414-5.172 5.172`,key:`8c96vv`}],[`path`,{d:`M6 12h12`,key:`8npq4p`}],[`circle`,{cx:`12`,cy:`20`,r:`2`,key:`144qzu`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}],[`circle`,{cx:`20`,cy:`12`,r:`2`,key:`1xzzfp`}],[`circle`,{cx:`4`,cy:`12`,r:`2`,key:`1hvhnz`}]]};F.node;var I=b(F),L=c(n(),1),R=O(),z=[`databases`,`testdata`,`flows`],B={test:`databases`,tables:`databases`,query:`databases`,gen:`testdata`,files:`testdata`,insert:`testdata`,batches:`testdata`,clean:`testdata`,check:`flows`,trace:`flows`},V={test:[`Testing the connection`,`Tested the connection`,`waiting`],tables:[`Reading the tables`,`Read the tables`,`searching`],query:[`Running the query`,`Ran the query`,`working`],gen:[`Making a preview`,`Made a preview`,`writing`],files:[`Writing the files`,`Wrote the files`,`writing`],insert:[`Inserting test data`,`Inserted test data`,`working`],batches:[`Listing the batches`,`Listed the batches`,`searching`],clean:[`Removing a batch`,`Removed a batch`,`working`],check:[`Checking the flows`,`Checked the flows`,`working`],trace:[`Following the record`,`Followed the record`,`searching`]},H=e=>e==null?`NULL`:typeof e==`object`?JSON.stringify(e):String(e),U=e=>(e?.keys||[]).map(e=>typeof e==`object`&&e?`${e.key}×${e.times}`:String(e)).join(`, `);function W({job:e,onStop:t}){let[n,i,a]=V[e.kind]??[`Working`,`Done`,`working`],o=(0,L.useRef)(null);(0,L.useEffect)(()=>{o.current&&(o.current.scrollTop=o.current.scrollHeight)},[e.lines.length]);let s=e.exitCode===0,c=!s&&(e.kind===`check`||e.kind===`trace`)&&e.result!==void 0&&!e.result.error;return(0,R.jsxs)(`section`,{"aria-label":e.running?n:i,className:`flex flex-col gap-2 rounded-[14px] border border-line-soft p-4`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,R.jsxs)(`span`,{className:`min-w-0 flex-1 font-medium [overflow-wrap:anywhere]`,children:[e.running?n:i,e.target?(0,R.jsxs)(`span`,{className:`font-normal text-muted`,children:[` · `,e.target]}):null]}),(0,R.jsx)(A,{tone:e.running?`running`:s?`pass`:e.exitCode===2||c?`warn`:`fail`,orb:a,children:e.running?`Working`:s?`Done`:c?`Some broken`:e.exitCode===2?`Not done`:`Failed`}),e.running&&(0,R.jsxs)(v,{onClick:t,className:`border-fail text-fail hover:bg-fail-soft`,children:[(0,R.jsx)(r,{size:14,fill:`currentColor`,"aria-hidden":`true`}),`Stop`]})]}),(0,R.jsxs)(`details`,{open:e.running||!s&&!e.result,children:[(0,R.jsxs)(`summary`,{className:`cursor-pointer text-sm text-muted`,children:[`Output (`,D(e.lines.length,`line`),`)`]}),(0,R.jsx)(`code`,{className:`mt-2 block font-mono text-[12px] text-muted [overflow-wrap:anywhere]`,children:e.command}),(0,R.jsx)(`pre`,{ref:o,className:`mt-2 max-h-[240px] overflow-auto rounded-[10px] bg-surface-muted p-3 font-mono text-[12px] leading-relaxed whitespace-pre-wrap text-ink-2`,children:e.lines.join(`
2
- `)||`Starting…`})]})]})}function G({text:e}){return(0,R.jsx)(`p`,{className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:e})}function K({columns:e,rows:t}){return(0,R.jsx)(`div`,{className:`max-h-[420px] overflow-auto rounded-[12px] border border-line-soft`,children:(0,R.jsxs)(`table`,{className:`w-full border-collapse text-[13px]`,children:[(0,R.jsx)(`thead`,{className:`sticky top-0 bg-surface-muted`,children:(0,R.jsx)(`tr`,{children:e.map(e=>(0,R.jsx)(`th`,{className:`px-3 py-2 text-left font-medium whitespace-nowrap text-muted`,children:e},e))})}),(0,R.jsx)(`tbody`,{children:t.map((e,t)=>(0,R.jsx)(`tr`,{className:`border-t border-line-soft`,children:e.map((e,t)=>(0,R.jsx)(`td`,{className:g(`max-w-[320px] px-3 py-1.5 align-top font-mono text-[12px] [overflow-wrap:anywhere]`,e===null&&`text-muted`),children:H(e)},t))},t))})]})})}function q({db:t,job:n,busy:r,act:i}){let[c,l]=(0,L.useState)(``),[u,d]=(0,L.useState)(``),[f,p]=(0,L.useState)(`200`),[g,y]=(0,L.useState)(``),[b,S]=(0,L.useState)(``),T=n&&!n.running&&n.target===t.name?n:null,E=T?.kind===`query`?T.result:void 0,O=async()=>{try{let{id:e}=await _.start(`On the ${t.name} database: ${g.trim()} Read the schema first, check the SQL with run_sql dry_run: true, then run it and show the rows. End with the final SQL in one sql code block.`,{});location.hash=m(`chats`,e)}catch(e){S(e.message)}};return(0,R.jsxs)(`section`,{"aria-labelledby":`db-h`,className:`flex min-w-0 flex-1 flex-col gap-5`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-[1_1_240px] flex-col gap-1`,children:[(0,R.jsx)(`h2`,{id:`db-h`,className:`m-0 text-[22px] font-semibold tracking-[-0.01em]`,children:t.name}),(0,R.jsx)(`span`,{className:`text-sm text-muted [overflow-wrap:anywhere]`,children:[t.engine||`from its connection string`,t.where,t.auth===`password`?``:t.auth].filter(Boolean).join(` · `)}),t.description&&(0,R.jsx)(`span`,{className:`text-sm text-ink-2`,children:t.description})]}),(0,R.jsx)(A,{tone:t.writable?`warn`:`neutral`,icon:t.writable,children:t.writable?`Writable, after asking`:`Read only`})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsxs)(v,{disabled:r,onClick:()=>i(`test`,{db:t.name}),children:[(0,R.jsx)(h,{icon:s,size:16}),`Test the connection`]}),(0,R.jsxs)(`form`,{className:`flex min-w-0 flex-[1_1_280px] items-center gap-2`,onSubmit:e=>{e.preventDefault(),i(`tables`,{db:t.name,...c.trim()?{search:c.trim()}:{}})},children:[(0,R.jsx)(a,{"aria-label":`Tables matching`,value:c,placeholder:`Tables matching…`,onChange:e=>l(e.target.value),className:`min-w-0 flex-1`}),(0,R.jsxs)(v,{type:`submit`,disabled:r,children:[(0,R.jsx)(h,{icon:x,size:16}),`Show tables`]})]})]}),T&&(T.kind===`test`||T.kind===`tables`)&&(0,R.jsx)(`pre`,{className:`m-0 max-h-[320px] overflow-auto rounded-[12px] bg-surface-muted p-3 font-mono text-[12px] leading-relaxed whitespace-pre-wrap text-ink-2`,children:T.lines.filter(e=>!/^args |^token /.test(e)).join(`
3
- `)}),(0,R.jsxs)(`section`,{"aria-labelledby":`query-h`,className:`flex flex-col gap-3`,children:[(0,R.jsx)(`h3`,{id:`query-h`,className:`m-0 text-base font-semibold`,children:`Query`}),(0,R.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`One read. A change to the data goes through a chat, which asks before it writes.`}),(0,R.jsx)(`label`,{className:`sr-only`,htmlFor:`sql`,children:`SQL`}),(0,R.jsx)(C,{id:`sql`,rows:5,value:u,spellCheck:!1,placeholder:t.engine===`mongodb`?`{"find": "orders", "filter": {"status": "open"}}`:`select * from orders where created_at > now() - interval '1 day'`,onChange:e=>d(e.target.value),className:`font-mono text-[13px]`}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsxs)(v,{variant:`primary`,disabled:r||!u.trim(),onClick:()=>i(`query`,{db:t.name,sql:u,maxRows:Number(f)}),children:[(0,R.jsx)(h,{icon:w,size:16}),`Run`]}),(0,R.jsxs)(v,{disabled:r||!u.trim(),onClick:()=>i(`query`,{db:t.name,sql:u,dryRun:!0}),children:[(0,R.jsx)(j,{size:16,"aria-hidden":`true`}),`Check only`]}),(0,R.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-muted`,children:[`Rows`,(0,R.jsx)(o,{value:f,onChange:e=>p(e.target.value),className:`w-[96px]`,children:[`50`,`200`,`1000`].map(e=>(0,R.jsx)(`option`,{children:e},e))})]})]}),E&&!E.ok&&(0,R.jsx)(G,{text:E.needs_confirmation?`Only reads run here. Ask in a chat to change data: it shows the statement and asks first.`:E.error||`The query failed.`}),E?.ok&&E.dry_run&&(0,R.jsxs)(`p`,{className:`m-0 rounded-[12px] bg-pass-soft px-3 py-2 text-sm text-pass`,children:[E.note||`The database accepts it.`,E.columns?.length?` Columns: ${E.columns.join(`, `)}`:``]}),E?.ok&&!E.dry_run&&E.columns&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(K,{columns:E.columns,rows:E.rows||[]}),(0,R.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[D(E.row_count??E.rows?.length??0,`row`),E.truncated?` (more not shown)`:``,E.ms===void 0?``:` in ${E.ms} ms`]})]})]}),(0,R.jsxs)(`section`,{"aria-labelledby":`ask-h`,className:`flex flex-col gap-2`,children:[(0,R.jsx)(`h3`,{id:`ask-h`,className:`m-0 text-base font-semibold`,children:`Ask in your words`}),(0,R.jsxs)(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),g.trim()&&O()},children:[(0,R.jsx)(a,{"aria-label":`Your question`,value:g,maxLength:500,placeholder:`Which customers ordered more than twice last week?`,onChange:e=>y(e.target.value),className:`min-w-0 flex-[1_1_280px]`}),(0,R.jsxs)(v,{type:`submit`,disabled:!g.trim(),children:[(0,R.jsx)(h,{icon:e,size:16}),`Ask in a chat`]})]}),b&&(0,R.jsx)(G,{text:b})]})]})}function J({view:e,job:t,busy:n,act:r,sub:i}){let a=e.databases.find(e=>e.name===i)||e.databases[0];return e.databases.length?(0,R.jsxs)(`div`,{className:`flex flex-col gap-6 @2xl:flex-row @2xl:items-start @2xl:gap-8`,children:[(0,R.jsxs)(`nav`,{"aria-label":`Databases`,className:`flex min-w-0 flex-col gap-1 @2xl:sticky @2xl:top-6 @2xl:w-[250px] @2xl:flex-none`,children:[(0,R.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:e.databases.map(e=>(0,R.jsx)(`li`,{children:(0,R.jsxs)(`a`,{href:m(`data`,`databases/${encodeURIComponent(e.name)}`),"aria-current":a?.name===e.name?`page`:void 0,className:g(`flex min-h-[60px] items-center gap-3 rounded-[12px] px-3 py-2 text-ink no-underline`,a?.name===e.name?`bg-surface-strong hover:text-ink`:`hover:bg-surface-muted hover:text-ink`),children:[(0,R.jsx)(h,{icon:l,size:18,className:`flex-none text-muted`}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,R.jsx)(`span`,{className:`truncate text-[15px] font-medium`,children:e.name}),(0,R.jsx)(`span`,{className:`truncate text-[13px] text-muted`,children:[e.engine||`connection string`,e.writable?`writable`:`read only`].join(` · `)})]})]})},e.name))}),(0,R.jsx)(`a`,{href:m(`settings`,`databases`),className:`px-3 pt-1 text-[13px]`,children:`Add or change in Settings`})]}),a&&(0,R.jsx)(q,{db:a,job:t,busy:n,act:r},a.name)]}):(0,R.jsxs)(`div`,{className:`flex flex-col items-start gap-3 rounded-[18px] border border-line p-6`,children:[(0,R.jsx)(h,{icon:l,size:24,className:`text-muted`}),(0,R.jsx)(`p`,{className:`m-0 max-w-[62ch] leading-relaxed text-ink-2`,children:`No databases yet. Add one in Settings: a connection string, or its host, user and password, kept in your credential store.`}),(0,R.jsx)(`a`,{href:m(`settings`,`databases`),className:`text-sm font-medium`,children:`Settings, Databases`})]})}function Y({r:e}){return(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(e.order||[]).map(t=>{let n=e.preview?.[t],r=n?.sample||[],i=r.length?Object.keys(r[0]):[];return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsxs)(`span`,{className:`text-sm`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:t}),` · `,D(e.rows?.[t]??0,`row`),n?.database_fills?.length?(0,R.jsxs)(`span`,{className:`text-muted`,children:[` · the database fills `,n.database_fills.join(`, `)]}):null,e.masked?.[t]?.length?(0,R.jsxs)(`span`,{className:`text-muted`,children:[` · masked `,e.masked[t].join(`, `)]}):null]}),i.length>0&&(0,R.jsx)(K,{columns:i,rows:r.slice(0,3).map(e=>i.map(t=>e[t]))})]},t)}),(e.warnings||[]).map((e,t)=>(0,R.jsx)(`p`,{className:`m-0 text-[13px] text-warn`,children:e},t))]})}function X({view:t,job:n,busy:r,act:i}){let s=t.databases.filter(e=>e.writable),[c,l]=(0,L.useState)(t.specs[0]??``),[d,f]=(0,L.useState)(``),[g,y]=(0,L.useState)(``),[b,x]=(0,L.useState)(`csv`),[S,C]=(0,L.useState)(!1),[w,T]=(0,L.useState)(s[0]?.name??``),[E,D]=(0,L.useState)(``),[O,A]=(0,L.useState)(``),j={spec:c,...d?{db:d}:{},...g?{seed:g}:{}},M=n&&!n.running?n:null,N=M&&[`gen`,`files`,`insert`].includes(M.kind)&&M.target===c?M.result:void 0,F=M?.kind===`batches`?(Array.isArray(M.result)?M.result.flatMap(e=>e.batches||[]):M.result?.batches)??[]:null,I=t.databases.find(e=>e.name===d),z=async()=>{try{let{id:e}=await _.start(`Write a test data spec for this project (a YAML file with tables: under test-data/), from the database's schema. Show me the spec and a preview before you save it.`,{});location.hash=m(`chats`,e)}catch(e){A(e.message)}};return(0,R.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,R.jsxs)(`section`,{"aria-labelledby":`spec-h`,className:`flex flex-col gap-4`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,R.jsx)(`h2`,{id:`spec-h`,className:`m-0 flex-1 text-lg font-semibold`,children:`Make test data`}),(0,R.jsxs)(v,{variant:`ghost`,onClick:()=>void z(),children:[(0,R.jsx)(h,{icon:e,size:16}),`Write a spec in a chat`]})]}),(0,R.jsx)(`p`,{className:`m-0 max-w-[70ch] text-sm leading-relaxed text-muted`,children:`A spec is a YAML file with tables: and what goes in each column. The same spec and seed make the same data again, so a test or a pipeline can rely on it. No model is used.`}),O&&(0,R.jsx)(G,{text:O}),t.specs.length===0?(0,R.jsx)(`p`,{className:`m-0 rounded-[12px] border border-line-soft px-4 py-3 text-sm text-muted`,children:`No specs in this project yet: a YAML file with tables: in test-data/, data/ or specs/. Write one in a chat, from a database's schema.`}):(0,R.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-[14px] border border-line-soft p-4`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,R.jsxs)(`label`,{className:`flex min-w-0 flex-[2_1_260px] flex-col gap-1.5 text-sm font-medium`,children:[`Spec`,(0,R.jsx)(o,{value:c,onChange:e=>l(e.target.value),children:t.specs.map(e=>(0,R.jsx)(`option`,{children:e},e))})]}),(0,R.jsxs)(`label`,{className:`flex min-w-0 flex-[1_1_180px] flex-col gap-1.5 text-sm font-medium`,children:[`Database`,(0,R.jsxs)(o,{value:d,onChange:e=>f(e.target.value),children:[(0,R.jsx)(`option`,{value:``,children:`The spec's own`}),t.databases.map(e=>(0,R.jsxs)(`option`,{value:e.name,children:[e.name,e.writable?``:` (read only)`]},e.name))]})]}),(0,R.jsxs)(`label`,{className:`flex w-[120px] flex-col gap-1.5 text-sm font-medium`,children:[`Seed`,(0,R.jsx)(a,{value:g,inputMode:`numeric`,placeholder:`Random`,onChange:e=>y(e.target.value.replace(/\D/g,``).slice(0,9))})]})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsxs)(v,{variant:`primary`,disabled:r||!c,onClick:()=>i(`gen`,j),children:[(0,R.jsx)(h,{icon:u,size:16}),`Preview`]}),(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,R.jsx)(v,{disabled:r||!c,onClick:()=>i(`gen`,{...j,mode:`files`,format:b}),children:`Write files`}),(0,R.jsx)(o,{"aria-label":`File format`,value:b,onChange:e=>x(e.target.value),className:`w-[88px]`,children:[`csv`,`json`,`sql`].map(e=>(0,R.jsx)(`option`,{children:e},e))})]}),(0,R.jsxs)(v,{disabled:r||!c||!I?.writable,title:I?.writable?void 0:`Pick a writable database to insert into`,onClick:()=>C(!0),children:[(0,R.jsx)(P,{size:16,"aria-hidden":`true`}),`Insert into `,I?.writable?I.name:`a database`]})]}),S&&I&&(0,R.jsxs)(`div`,{role:`alertdialog`,"aria-label":`Insert test data`,className:`flex flex-col gap-3 rounded-[12px] border border-warn bg-warn-soft p-4`,children:[(0,R.jsxs)(`span`,{className:`font-medium`,children:[`Insert the rows of `,c,` into `,I.name,`?`]}),(0,R.jsx)(`span`,{className:`text-sm text-ink-2`,children:`They go in as one batch, which you can remove again below. Only on a test database.`}),(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,R.jsx)(v,{variant:`primary`,onClick:()=>{C(!1),i(`gen`,{...j,mode:`insert`,confirmed:!0})},children:`Insert`}),(0,R.jsx)(v,{onClick:()=>C(!1),children:`Don't insert`})]})]}),N&&!N.ok&&(0,R.jsx)(G,{text:N.error||`It did not make the data.`}),N?.ok&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[N.batch&&(0,R.jsxs)(`p`,{className:`m-0 rounded-[12px] bg-pass-soft px-3 py-2 text-sm text-pass`,children:[`Inserted as batch `,(0,R.jsx)(`span`,{className:`font-mono text-[13px]`,children:N.batch}),`.`]}),N.files?.length?(0,R.jsxs)(`p`,{className:`m-0 flex flex-wrap items-center gap-2 text-sm`,children:[`Wrote`,N.files.map(e=>(0,R.jsx)(`button`,{type:`button`,onClick:async()=>A(await p(e)),className:`cursor-pointer rounded-md border border-line-soft bg-surface-muted px-1.5 py-0.5 font-mono text-[12px] text-ink-2 hover:bg-surface-strong`,children:e},e))]}):null,(0,R.jsx)(Y,{r:N})]})]})]}),(0,R.jsxs)(`section`,{"aria-labelledby":`batch-h`,className:`flex flex-col gap-3`,children:[(0,R.jsx)(`h2`,{id:`batch-h`,className:`m-0 text-lg font-semibold`,children:`Inserted batches`}),s.length===0?(0,R.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`No writable database: test data is inserted only into one marked writable in Settings, Databases.`}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(o,{"aria-label":`Database`,value:w,onChange:e=>T(e.target.value),className:`w-[220px]`,children:s.map(e=>(0,R.jsx)(`option`,{children:e.name},e.name))}),(0,R.jsx)(v,{disabled:r||!w,onClick:()=>i(`batches`,{db:w}),children:`List batches`})]}),F&&F.length===0&&(0,R.jsxs)(`p`,{className:`m-0 text-sm text-muted`,children:[`No batches in `,M?.target,`.`]}),F&&F.length>0&&(0,R.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:F.map(e=>(0,R.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 border-t border-line-soft py-2.5 text-sm first:border-t-0`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-[1_1_240px] flex-col gap-0.5`,children:[(0,R.jsx)(`span`,{className:`font-mono text-[13px]`,children:e.batch}),(0,R.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[new Date(e.created).toLocaleString([],{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}),e.spec?` · ${e.spec}`:``,` ·`,` `,Object.entries(e.rows).map(([e,t])=>`${e} ${t}`).join(`, `)]})]}),E===e.batch?(0,R.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,R.jsxs)(`span`,{className:`text-[13px] text-warn`,children:[`Remove its rows from `,M?.target,`?`]}),(0,R.jsx)(v,{size:`sm`,className:`border-fail text-fail hover:bg-fail-soft`,onClick:()=>{D(``),i(`clean`,{db:M?.target,batch:e.batch,confirmed:!0})},children:`Remove`}),(0,R.jsx)(v,{size:`sm`,onClick:()=>D(``),children:`Keep`})]}):(0,R.jsxs)(v,{size:`sm`,disabled:r,onClick:()=>D(e.batch),children:[(0,R.jsx)(k,{size:14,"aria-hidden":`true`}),`Remove`]})]},e.batch))}),M?.kind===`clean`&&M.result?.ok&&(0,R.jsxs)(`p`,{className:`m-0 rounded-[12px] bg-pass-soft px-3 py-2 text-sm text-pass`,children:[`Removed:`,` `,Object.entries(M.result.removed||{}).map(([e,t])=>`${e} ${t}`).join(`, `)]})]})]})]})}function Z({c:e}){let t=e=>e?.count??0;return(0,R.jsxs)(`li`,{className:`flex flex-col gap-1 border-t border-line-soft py-3 text-sm first:border-t-0`,children:[(0,R.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(A,{tone:e.ok?`pass`:`fail`,children:e.ok?`Holds`:`Broken`}),(0,R.jsx)(`span`,{className:`font-medium`,children:e.flow}),(0,R.jsxs)(`span`,{className:`font-mono text-[12px] text-muted [overflow-wrap:anywhere]`,children:[e.from,` → `,e.to]})]}),e.error?(0,R.jsx)(`span`,{className:`text-fail [overflow-wrap:anywhere]`,children:e.error}):(0,R.jsxs)(`span`,{className:`text-ink-2`,children:[e.matched??0,` of `,e.source_rows??0,` arrived · `,e.late?`${t(e.late)} late (${t(e.in_flight)} in flight)`:`${t(e.missing)} missing`,` · `,e.wrong?.rows??0,` wrong · `,t(e.duplicates),` duplicated`,e.extra?` · ${t(e.extra)} with no source`:``]}),e.note&&(0,R.jsx)(`span`,{className:`text-[13px] text-muted`,children:e.note}),U(e.late??e.missing)&&(0,R.jsxs)(`span`,{className:`text-[13px] text-fail [overflow-wrap:anywhere]`,children:[`Missing: `,U(e.late??e.missing)]}),(e.wrong?.examples||[]).map((e,t)=>(0,R.jsxs)(`span`,{className:`font-mono text-[12px] text-fail [overflow-wrap:anywhere]`,children:[String(e.key),`: `,e.column,` expected `,H(e.expected),`, found `,H(e.target)]},t))]})}function Q({view:n,job:r,busy:i,act:s}){let[c,l]=(0,L.useState)([]),u=(0,L.useMemo)(()=>[...new Set(n.flows.map(e=>e.from).filter(e=>!e.startsWith(`api:`)))],[n.flows]),[f,g]=(0,L.useState)(u[0]??n.flows[0]?.name??``),[b,x]=(0,L.useState)(``),[S,C]=(0,L.useState)(``),[w,T]=(0,L.useState)(``),[E,O]=(0,L.useState)(null),[k,N]=(0,L.useState)(``),P=r&&!r.running?r:null,F=P?.kind===`check`?P.result??null:null,z=P?.kind===`trace`?P.result??null:null;return n.flowsError?(0,R.jsx)(G,{text:`${n.flowsFile} does not read: ${n.flowsError}`}):n.flows.length?(0,R.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,R.jsxs)(`section`,{"aria-labelledby":`flows-h`,className:`flex flex-col gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsxs)(`h2`,{id:`flows-h`,className:`m-0 flex-1 text-lg font-semibold`,children:[`Flows `,(0,R.jsxs)(`span`,{className:`text-sm font-normal text-muted`,children:[`(`,n.flowsFile,`)`]})]}),(0,R.jsxs)(v,{variant:`primary`,disabled:i,onClick:()=>s(`check`,{flows:c}),children:[(0,R.jsx)(j,{size:16,"aria-hidden":`true`}),c.length?`Check ${D(c.length,`flow`)}`:`Check all`]}),P?.report&&(P.kind===`check`||P.kind===`trace`)&&(0,R.jsxs)(v,{onClick:async()=>N(await p(P.report)),children:[(0,R.jsx)(h,{icon:t,size:16}),`Report`]})]}),(0,R.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`Each hop: did every record arrive, complete, correct, on time.`}),k&&(0,R.jsx)(G,{text:k}),(0,R.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:n.flows.map(e=>(0,R.jsxs)(`li`,{className:`flex items-start gap-3 border-t border-line-soft py-2.5 first:border-t-0`,children:[(0,R.jsx)(`input`,{type:`checkbox`,"aria-label":`Check ${e.name}`,checked:c.includes(e.name),onChange:t=>l(t.target.checked?[...c,e.name]:c.filter(t=>t!==e.name)),className:`mt-1 size-5 flex-none accent-accent`}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5 text-sm`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,R.jsxs)(`span`,{className:`font-mono text-[12px] text-ink-2 [overflow-wrap:anywhere]`,children:[e.from,` → `,e.to]}),(0,R.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[[e.mode,e.sla?`SLA ${e.sla}`:``,D(e.columns,`column`)].filter(Boolean).join(` · `),e.description?` · ${e.description}`:``]})]})]},e.name))}),F?.error&&(0,R.jsx)(G,{text:F.error}),F?.flows&&(0,R.jsx)(`ul`,{"aria-label":`Check results`,className:`m-0 flex list-none flex-col rounded-[14px] border border-line-soft px-4 py-1`,children:F.flows.map(e=>(0,R.jsx)(Z,{c:e},e.flow))})]}),(0,R.jsxs)(`section`,{"aria-labelledby":`trace-h`,className:`flex flex-col gap-3`,children:[(0,R.jsx)(`h2`,{id:`trace-h`,className:`m-0 text-lg font-semibold`,children:`Follow one record`}),(0,R.jsxs)(`form`,{className:`flex flex-wrap items-end gap-3`,onSubmit:e=>{e.preventDefault(),f&&b.trim()&&s(`trace`,{start:f,key:b.trim(),...S?{wait:Number(S)}:{}})},children:[(0,R.jsxs)(`label`,{className:`flex min-w-0 flex-[1_1_220px] flex-col gap-1.5 text-sm font-medium`,children:[`From`,(0,R.jsxs)(o,{value:f,onChange:e=>g(e.target.value),children:[(0,R.jsx)(`optgroup`,{label:`A table`,children:u.map(e=>(0,R.jsx)(`option`,{children:e},e))}),(0,R.jsx)(`optgroup`,{label:`A flow`,children:n.flows.map(e=>(0,R.jsx)(`option`,{children:e.name},e.name))})]})]}),(0,R.jsxs)(`label`,{className:`flex w-[160px] flex-col gap-1.5 text-sm font-medium`,children:[`Its key`,(0,R.jsx)(a,{value:b,maxLength:200,placeholder:`1042`,onChange:e=>x(e.target.value)})]}),(0,R.jsxs)(`label`,{className:`flex w-[130px] flex-col gap-1.5 text-sm font-medium`,children:[`Wait up to (s)`,(0,R.jsx)(a,{value:S,inputMode:`numeric`,placeholder:`0`,onChange:e=>C(e.target.value.replace(/\D/g,``).slice(0,3))})]}),(0,R.jsxs)(v,{type:`submit`,disabled:i||!f||!b.trim(),children:[(0,R.jsx)(h,{icon:d,size:16}),`Follow it`]})]}),z?.error&&(0,R.jsx)(G,{text:z.error}),z?.hops&&(0,R.jsx)(`ol`,{className:`m-0 flex list-none flex-col gap-2 border-l border-line pl-4`,children:z.hops.map((e,t)=>(0,R.jsxs)(`li`,{className:`flex flex-col gap-0.5 text-sm`,children:[(0,R.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(A,{tone:e.ok?`pass`:`fail`,children:e.ok?`Arrived`:e.found_in_source===!1?`Not in the source`:e.arrived===!1?`Did not arrive`:`Differs`}),(0,R.jsx)(`span`,{className:`font-medium`,children:e.flow}),(0,R.jsxs)(`span`,{className:`font-mono text-[12px] text-muted`,children:[e.from,` → `,e.to,` · key `,H(e.key)]})]}),(e.differences||[]).map((e,t)=>(0,R.jsxs)(`span`,{className:`font-mono text-[12px] text-fail [overflow-wrap:anywhere]`,children:[e.column,`: expected `,H(e.expected),`, found `,H(e.target)]},t)),Number(e.copies)>1&&(0,R.jsxs)(`span`,{className:`text-[13px] text-warn`,children:[e.copies,` copies`]})]},t))})]}),(0,R.jsxs)(`section`,{"aria-labelledby":`impact-h`,className:`flex flex-col gap-3`,children:[(0,R.jsx)(`h2`,{id:`impact-h`,className:`m-0 text-lg font-semibold`,children:`What a change reaches`}),(0,R.jsxs)(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:async e=>{e.preventDefault();try{O(await y.impact(w.trim())),N(``)}catch(e){N(e.message)}},children:[(0,R.jsx)(a,{"aria-label":`A table or column`,value:w,spellCheck:!1,placeholder:`shop.orders.total`,onChange:e=>T(e.target.value),className:`min-w-0 flex-[1_1_260px] font-mono text-[13px]`}),(0,R.jsxs)(v,{type:`submit`,disabled:!w.trim(),children:[(0,R.jsx)(M,{size:16,"aria-hidden":`true`}),`Show what reads it`]})]}),E&&E.length===0&&(0,R.jsxs)(`p`,{className:`m-0 text-sm text-muted`,children:[`Nothing in the flows reads `,w,`.`]}),E&&E.length>0&&(0,R.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0`,children:E.map((e,t)=>(0,R.jsxs)(`li`,{className:`font-mono text-[12px] text-ink-2 [overflow-wrap:anywhere]`,style:{paddingLeft:`${(e.depth-1)*16}px`},children:[e.from,` → `,e.to,e.columns.length?` (${e.columns.join(`, `)})`:``,` `,(0,R.jsxs)(`span`,{className:`text-muted`,children:[`[`,e.flow,`]`]})]},t))}),n.map.length>0&&(0,R.jsxs)(`details`,{children:[(0,R.jsx)(`summary`,{className:`cursor-pointer text-sm text-muted`,children:`The whole map`}),(0,R.jsx)(`pre`,{className:`mt-2 overflow-auto rounded-[12px] bg-surface-muted p-3 font-mono text-[12px] leading-relaxed text-ink-2`,children:n.map.join(`
4
- `)})]})]})]}):(0,R.jsxs)(`div`,{className:`flex flex-col items-start gap-3 rounded-[18px] border border-line p-6`,children:[(0,R.jsx)(I,{size:24,"aria-hidden":`true`,className:`text-muted`}),(0,R.jsxs)(`p`,{className:`m-0 max-w-[62ch] leading-relaxed text-ink-2`,children:[`No data flows yet. A flow says how records move from one system to another (a table, a topic or an API), by which key, and what each column becomes; `,(0,R.jsx)(`span`,{className:`font-mono text-[13px]`,children:n.flowsFile}),` holds them. ForgeQE can write them from your mapping documents.`]}),(0,R.jsxs)(v,{onClick:async()=>{try{let{id:e}=await _.start(`Write the data flows of this project into flows.yaml from our mapping documents and the databases' schemas. Show me each flow before you save it.`,{});location.hash=m(`chats`,e)}catch(e){N(e.message)}},children:[(0,R.jsx)(h,{icon:e,size:16}),`Write flows in a chat`]}),k&&(0,R.jsx)(G,{text:k})]})}function $({sub:e}){let[t,n]=(0,L.useState)(null),[r,a]=(0,L.useState)(``),[o,s]=(0,L.useState)(!1),[c,...l]=(e||``).split(`/`),u=z.includes(c)?c:`databases`,d=(0,L.useCallback)(()=>{y.view().then(e=>{n(e),a(``)},e=>a(e.message))},[]);(0,L.useEffect)(d,[d]);let p=!!t?.job?.running;(0,L.useEffect)(()=>{if(!p)return;let e=setInterval(d,1e3);return()=>clearInterval(e)},[p,d]);let h=async(e,t)=>{s(!0),a(``);try{await y.run(e,t),d()}catch(e){a(e.message)}finally{s(!1)}},_=t?.job??null,v={databases:`Databases${t?` (${t.databases.length})`:``}`,testdata:`Test data${t?` (${t.specs.length})`:``}`,flows:`Data flows${t?` (${t.flows.length})`:``}`};return(0,R.jsxs)(`div`,{className:`flex min-h-screen flex-col`,children:[(0,R.jsx)(T,{}),(0,R.jsxs)(`main`,{className:g(E,`@container flex-auto gap-4`),children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,R.jsx)(S,{pixel:f.data,size:`lg`}),(0,R.jsx)(`h1`,{className:`m-0 flex-1 text-[26px] font-semibold tracking-[-0.01em]`,children:`Data`})]}),(0,R.jsx)(`p`,{className:`m-0 max-w-[74ch] text-sm leading-relaxed text-muted`,children:`The databases the agents may read, test data made from specs and inserted as batches you can remove again, and the data flows between systems: did every record arrive, complete and correct.`}),r&&(0,R.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:r}),!t&&!r&&(0,R.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}),t&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(i,{label:`Data`,current:u,onPick:e=>location.hash=m(`data`,e),tabs:z.map(e=>({id:e,label:v[e]}))}),_&&(_.running||B[_.kind]===u)&&(0,R.jsx)(W,{job:_,onStop:()=>void y.stop().then(d)}),(0,R.jsxs)(`div`,{role:`tabpanel`,id:`panel-${u}`,"aria-labelledby":`tab-${u}`,children:[u===`databases`&&(0,R.jsx)(J,{view:t,job:_,busy:o||p,act:h,sub:l[0]?decodeURIComponent(l[0]):void 0}),u===`testdata`&&(0,R.jsx)(X,{view:t,job:_,busy:o||p,act:h}),u===`flows`&&(0,R.jsx)(Q,{view:t,job:_,busy:o||p,act:h})]})]})]})]})}export{$ as Data};
1
+ import{$t as e,An as t,At as n,E as r,Fn as i,Fr as a,G as o,K as s,Kt as c,Mr as l,Sn as u,Vt as d,X as f,Y as p,Z as m,_t as h,ar as g,bt as _,dt as v,fr as y,kt as b,mr as x,q as S,qt as C,r as w,t as T,ut as E,xt as D,yt as O}from"./frame-z3iL_6aL.js";import"./markdown-BtqKvAEi.js";import{E as k,b as A,g as j,i as M}from"./index-BVw2ygO2.js";var N={name:`sprout`,size:24,node:[[`path`,{d:`M14 9.536V7a4 4 0 0 1 4-4h1.5a.5.5 0 0 1 .5.5V5a4 4 0 0 1-4 4 4 4 0 0 0-4 4c0 2 1 3 1 5a5 5 0 0 1-1 3`,key:`139s4v`}],[`path`,{d:`M4 9a5 5 0 0 1 8 4 5 5 0 0 1-8-4`,key:`1dlkgp`}],[`path`,{d:`M5 21h14`,key:`11awu3`}]]};N.node;var P=g(N),F={name:`waypoints`,size:24,node:[[`path`,{d:`m10.586 5.414-5.172 5.172`,key:`4mc350`}],[`path`,{d:`m18.586 13.414-5.172 5.172`,key:`8c96vv`}],[`path`,{d:`M6 12h12`,key:`8npq4p`}],[`circle`,{cx:`12`,cy:`20`,r:`2`,key:`144qzu`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}],[`circle`,{cx:`20`,cy:`12`,r:`2`,key:`1xzzfp`}],[`circle`,{cx:`4`,cy:`12`,r:`2`,key:`1hvhnz`}]]};F.node;var I=g(F),L=a(l(),1),R=O(),z=[`databases`,`testdata`,`flows`],B={test:`databases`,tables:`databases`,query:`databases`,gen:`testdata`,files:`testdata`,insert:`testdata`,batches:`testdata`,clean:`testdata`,check:`flows`,trace:`flows`},V={test:[`Testing the connection`,`Tested the connection`,`waiting`],tables:[`Reading the tables`,`Read the tables`,`searching`],query:[`Running the query`,`Ran the query`,`working`],gen:[`Making a preview`,`Made a preview`,`writing`],files:[`Writing the files`,`Wrote the files`,`writing`],insert:[`Inserting test data`,`Inserted test data`,`working`],batches:[`Listing the batches`,`Listed the batches`,`searching`],clean:[`Removing a batch`,`Removed a batch`,`working`],check:[`Checking the flows`,`Checked the flows`,`working`],trace:[`Following the record`,`Followed the record`,`searching`]},H=e=>e==null?`NULL`:typeof e==`object`?JSON.stringify(e):String(e),U=e=>(e?.keys||[]).map(e=>typeof e==`object`&&e?`${e.key}×${e.times}`:String(e)).join(`, `);function W({job:e,onStop:t}){let[r,i,a]=V[e.kind]??[`Working`,`Done`,`working`],o=(0,L.useRef)(null);(0,L.useEffect)(()=>{o.current&&(o.current.scrollTop=o.current.scrollHeight)},[e.lines.length]);let s=e.exitCode===0,c=!s&&(e.kind===`check`||e.kind===`trace`)&&e.result!==void 0&&!e.result.error;return(0,R.jsxs)(`section`,{"aria-label":e.running?r:i,className:`flex flex-col gap-2 rounded-[14px] border border-line-soft p-4`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,R.jsxs)(`span`,{className:`min-w-0 flex-1 font-medium [overflow-wrap:anywhere]`,children:[e.running?r:i,e.target?(0,R.jsxs)(`span`,{className:`font-normal text-muted`,children:[` · `,e.target]}):null]}),(0,R.jsx)(M,{tone:e.running?`running`:s?`pass`:e.exitCode===2||c?`warn`:`fail`,orb:a,children:e.running?`Working`:s?`Done`:c?`Some broken`:e.exitCode===2?`Not done`:`Failed`}),e.running&&(0,R.jsxs)(v,{onClick:t,className:`border-fail text-fail hover:bg-fail-soft`,children:[(0,R.jsx)(n,{size:14,fill:`currentColor`,"aria-hidden":`true`}),`Stop`]})]}),(0,R.jsxs)(`details`,{open:e.running||!s&&!e.result,children:[(0,R.jsxs)(`summary`,{className:`cursor-pointer text-sm text-muted`,children:[`Output (`,D(e.lines.length,`line`),`)`]}),(0,R.jsx)(`code`,{className:`mt-2 block font-mono text-[12px] text-muted [overflow-wrap:anywhere]`,children:e.command}),(0,R.jsx)(`pre`,{ref:o,className:`mt-2 max-h-[240px] overflow-auto rounded-[10px] bg-surface-muted p-3 font-mono text-[12px] leading-relaxed whitespace-pre-wrap text-ink-2`,children:e.lines.join(`
2
+ `)||`Starting…`})]})]})}function G({text:e}){return(0,R.jsx)(`p`,{className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:e})}function K({columns:e,rows:t}){return(0,R.jsx)(`div`,{className:`max-h-[420px] overflow-auto rounded-[12px] border border-line-soft`,children:(0,R.jsxs)(`table`,{className:`w-full border-collapse text-[13px]`,children:[(0,R.jsx)(`thead`,{className:`sticky top-0 bg-surface-muted`,children:(0,R.jsx)(`tr`,{children:e.map(e=>(0,R.jsx)(`th`,{className:`px-3 py-2 text-left font-medium whitespace-nowrap text-muted`,children:e},e))})}),(0,R.jsx)(`tbody`,{children:t.map((e,t)=>(0,R.jsx)(`tr`,{className:`border-t border-line-soft`,children:e.map((e,t)=>(0,R.jsx)(`td`,{className:_(`max-w-[320px] px-3 py-1.5 align-top font-mono text-[12px] [overflow-wrap:anywhere]`,e===null&&`text-muted`),children:H(e)},t))},t))})]})})}function q({db:t,job:n,busy:r,act:i}){let[a,l]=(0,L.useState)(``),[u,d]=(0,L.useState)(``),[f,p]=(0,L.useState)(`200`),[g,_]=(0,L.useState)(``),[x,w]=(0,L.useState)(``),T=n&&!n.running&&n.target===t.name?n:null,E=T?.kind===`query`?T.result:void 0,O=async()=>{try{let{id:e}=await y.start(`On the ${t.name} database: ${g.trim()} Read the schema first, check the SQL with run_sql dry_run: true, then run it and show the rows. End with the final SQL in one sql code block.`,{});location.hash=m(`chats`,e)}catch(e){w(e.message)}};return(0,R.jsxs)(`section`,{"aria-labelledby":`db-h`,className:`flex min-w-0 flex-1 flex-col gap-5`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-[1_1_240px] flex-col gap-1`,children:[(0,R.jsx)(`h2`,{id:`db-h`,className:`m-0 text-[22px] font-semibold tracking-[-0.01em]`,children:t.name}),(0,R.jsx)(`span`,{className:`text-sm text-muted [overflow-wrap:anywhere]`,children:[t.engine||`from its connection string`,t.where,t.auth===`password`?``:t.auth].filter(Boolean).join(` · `)}),t.description&&(0,R.jsx)(`span`,{className:`text-sm text-ink-2`,children:t.description})]}),(0,R.jsx)(M,{tone:t.writable?`warn`:`neutral`,icon:t.writable,children:t.writable?`Writable, after asking`:`Read only`})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsxs)(v,{disabled:r,onClick:()=>i(`test`,{db:t.name}),children:[(0,R.jsx)(h,{icon:c,size:16}),`Test the connection`]}),(0,R.jsxs)(`form`,{className:`flex min-w-0 flex-[1_1_280px] items-center gap-2`,onSubmit:e=>{e.preventDefault(),i(`tables`,{db:t.name,...a.trim()?{search:a.trim()}:{}})},children:[(0,R.jsx)(o,{"aria-label":`Tables matching`,value:a,placeholder:`Tables matching…`,onChange:e=>l(e.target.value),className:`min-w-0 flex-1`}),(0,R.jsxs)(v,{type:`submit`,disabled:r,children:[(0,R.jsx)(h,{icon:b,size:16}),`Show tables`]})]})]}),T&&(T.kind===`test`||T.kind===`tables`)&&(0,R.jsx)(`pre`,{className:`m-0 max-h-[320px] overflow-auto rounded-[12px] bg-surface-muted p-3 font-mono text-[12px] leading-relaxed whitespace-pre-wrap text-ink-2`,children:T.lines.filter(e=>!/^args |^token /.test(e)).join(`
3
+ `)}),(0,R.jsxs)(`section`,{"aria-labelledby":`query-h`,className:`flex flex-col gap-3`,children:[(0,R.jsx)(`h3`,{id:`query-h`,className:`m-0 text-base font-semibold`,children:`Query`}),(0,R.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`One read. A change to the data goes through a chat, which asks before it writes.`}),(0,R.jsx)(`label`,{className:`sr-only`,htmlFor:`sql`,children:`SQL`}),(0,R.jsx)(S,{id:`sql`,rows:5,value:u,spellCheck:!1,placeholder:t.engine===`mongodb`?`{"find": "orders", "filter": {"status": "open"}}`:`select * from orders where created_at > now() - interval '1 day'`,onChange:e=>d(e.target.value),className:`font-mono text-[13px]`}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsxs)(v,{variant:`primary`,disabled:r||!u.trim(),onClick:()=>i(`query`,{db:t.name,sql:u,maxRows:Number(f)}),children:[(0,R.jsx)(h,{icon:C,size:16}),`Run`]}),(0,R.jsxs)(v,{disabled:r||!u.trim(),onClick:()=>i(`query`,{db:t.name,sql:u,dryRun:!0}),children:[(0,R.jsx)(k,{size:16,"aria-hidden":`true`}),`Check only`]}),(0,R.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-muted`,children:[`Rows`,(0,R.jsx)(s,{value:f,onChange:e=>p(e.target.value),className:`w-[96px]`,children:[`50`,`200`,`1000`].map(e=>(0,R.jsx)(`option`,{children:e},e))})]})]}),E&&!E.ok&&(0,R.jsx)(G,{text:E.needs_confirmation?`Only reads run here. Ask in a chat to change data: it shows the statement and asks first.`:E.error||`The query failed.`}),E?.ok&&E.dry_run&&(0,R.jsxs)(`p`,{className:`m-0 rounded-[12px] bg-pass-soft px-3 py-2 text-sm text-pass`,children:[E.note||`The database accepts it.`,E.columns?.length?` Columns: ${E.columns.join(`, `)}`:``]}),E?.ok&&!E.dry_run&&E.columns&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(K,{columns:E.columns,rows:E.rows||[]}),(0,R.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[D(E.row_count??E.rows?.length??0,`row`),E.truncated?` (more not shown)`:``,E.ms===void 0?``:` in ${E.ms} ms`]})]})]}),(0,R.jsxs)(`section`,{"aria-labelledby":`ask-h`,className:`flex flex-col gap-2`,children:[(0,R.jsx)(`h3`,{id:`ask-h`,className:`m-0 text-base font-semibold`,children:`Ask in your words`}),(0,R.jsxs)(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),g.trim()&&O()},children:[(0,R.jsx)(o,{"aria-label":`Your question`,value:g,maxLength:500,placeholder:`Which customers ordered more than twice last week?`,onChange:e=>_(e.target.value),className:`min-w-0 flex-[1_1_280px]`}),(0,R.jsxs)(v,{type:`submit`,disabled:!g.trim(),children:[(0,R.jsx)(h,{icon:e,size:16}),`Ask in a chat`]})]}),x&&(0,R.jsx)(G,{text:x})]})]})}function J({view:e,job:t,busy:n,act:r,sub:a}){let o=e.databases.find(e=>e.name===a)||e.databases[0];return e.databases.length?(0,R.jsxs)(`div`,{className:`flex flex-col gap-6 @2xl:flex-row @2xl:items-start @2xl:gap-8`,children:[(0,R.jsxs)(`nav`,{"aria-label":`Databases`,className:`flex min-w-0 flex-col gap-1 @2xl:sticky @2xl:top-6 @2xl:w-[250px] @2xl:flex-none`,children:[(0,R.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:e.databases.map(e=>(0,R.jsx)(`li`,{children:(0,R.jsxs)(`a`,{href:m(`data`,`databases/${encodeURIComponent(e.name)}`),"aria-current":o?.name===e.name?`page`:void 0,className:_(`flex min-h-[60px] items-center gap-3 rounded-[12px] px-3 py-2 text-ink no-underline`,o?.name===e.name?`bg-surface-strong hover:text-ink`:`hover:bg-surface-muted hover:text-ink`),children:[(0,R.jsx)(h,{icon:i,size:18,className:`flex-none text-muted`}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,R.jsx)(`span`,{className:`truncate text-[15px] font-medium`,children:e.name}),(0,R.jsx)(`span`,{className:`truncate text-[13px] text-muted`,children:[e.engine||`connection string`,e.writable?`writable`:`read only`].join(` · `)})]})]})},e.name))}),(0,R.jsx)(`a`,{href:m(`settings`,`databases`),className:`px-3 pt-1 text-[13px]`,children:`Add or change in Settings`})]}),o&&(0,R.jsx)(q,{db:o,job:t,busy:n,act:r},o.name)]}):(0,R.jsxs)(`div`,{className:`flex flex-col items-start gap-3 rounded-[18px] border border-line p-6`,children:[(0,R.jsx)(h,{icon:i,size:24,className:`text-muted`}),(0,R.jsx)(`p`,{className:`m-0 max-w-[62ch] leading-relaxed text-ink-2`,children:`No databases yet. Add one in Settings: a connection string, or its host, user and password, kept in your credential store.`}),(0,R.jsx)(`a`,{href:m(`settings`,`databases`),className:`text-sm font-medium`,children:`Settings, Databases`})]})}function Y({r:e}){return(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(e.order||[]).map(t=>{let n=e.preview?.[t],r=n?.sample||[],i=r.length?Object.keys(r[0]):[];return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsxs)(`span`,{className:`text-sm`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:t}),` · `,D(e.rows?.[t]??0,`row`),n?.database_fills?.length?(0,R.jsxs)(`span`,{className:`text-muted`,children:[` · the database fills `,n.database_fills.join(`, `)]}):null,e.masked?.[t]?.length?(0,R.jsxs)(`span`,{className:`text-muted`,children:[` · masked `,e.masked[t].join(`, `)]}):null]}),i.length>0&&(0,R.jsx)(K,{columns:i,rows:r.slice(0,3).map(e=>i.map(t=>e[t]))})]},t)}),(e.warnings||[]).map((e,t)=>(0,R.jsx)(`p`,{className:`m-0 text-[13px] text-warn`,children:e},t))]})}function X({view:t,job:n,busy:r,act:i}){let a=t.databases.filter(e=>e.writable),[c,l]=(0,L.useState)(t.specs[0]??``),[d,f]=(0,L.useState)(``),[g,_]=(0,L.useState)(``),[b,x]=(0,L.useState)(`csv`),[S,C]=(0,L.useState)(!1),[w,T]=(0,L.useState)(a[0]?.name??``),[E,D]=(0,L.useState)(``),[O,k]=(0,L.useState)(``),A={spec:c,...d?{db:d}:{},...g?{seed:g}:{}},M=n&&!n.running?n:null,N=M&&[`gen`,`files`,`insert`].includes(M.kind)&&M.target===c?M.result:void 0,F=M?.kind===`batches`?(Array.isArray(M.result)?M.result.flatMap(e=>e.batches||[]):M.result?.batches)??[]:null,I=t.databases.find(e=>e.name===d),z=async()=>{try{let{id:e}=await y.start(`Write a test data spec for this project (a YAML file with tables: under test-data/), from the database's schema. Show me the spec and a preview before you save it.`,{});location.hash=m(`chats`,e)}catch(e){k(e.message)}};return(0,R.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,R.jsxs)(`section`,{"aria-labelledby":`spec-h`,className:`flex flex-col gap-4`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,R.jsx)(`h2`,{id:`spec-h`,className:`m-0 flex-1 text-lg font-semibold`,children:`Make test data`}),(0,R.jsxs)(v,{variant:`ghost`,onClick:()=>void z(),children:[(0,R.jsx)(h,{icon:e,size:16}),`Write a spec in a chat`]})]}),(0,R.jsx)(`p`,{className:`m-0 max-w-[70ch] text-sm leading-relaxed text-muted`,children:`A spec is a YAML file with tables: and what goes in each column. The same spec and seed make the same data again, so a test or a pipeline can rely on it. No model is used.`}),O&&(0,R.jsx)(G,{text:O}),t.specs.length===0?(0,R.jsx)(`p`,{className:`m-0 rounded-[12px] border border-line-soft px-4 py-3 text-sm text-muted`,children:`No specs in this project yet: a YAML file with tables: in test-data/, data/ or specs/. Write one in a chat, from a database's schema.`}):(0,R.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-[14px] border border-line-soft p-4`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,R.jsxs)(`label`,{className:`flex min-w-0 flex-[2_1_260px] flex-col gap-1.5 text-sm font-medium`,children:[`Spec`,(0,R.jsx)(s,{value:c,onChange:e=>l(e.target.value),children:t.specs.map(e=>(0,R.jsx)(`option`,{children:e},e))})]}),(0,R.jsxs)(`label`,{className:`flex min-w-0 flex-[1_1_180px] flex-col gap-1.5 text-sm font-medium`,children:[`Database`,(0,R.jsxs)(s,{value:d,onChange:e=>f(e.target.value),children:[(0,R.jsx)(`option`,{value:``,children:`The spec's own`}),t.databases.map(e=>(0,R.jsxs)(`option`,{value:e.name,children:[e.name,e.writable?``:` (read only)`]},e.name))]})]}),(0,R.jsxs)(`label`,{className:`flex w-[120px] flex-col gap-1.5 text-sm font-medium`,children:[`Seed`,(0,R.jsx)(o,{value:g,inputMode:`numeric`,placeholder:`Random`,onChange:e=>_(e.target.value.replace(/\D/g,``).slice(0,9))})]})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsxs)(v,{variant:`primary`,disabled:r||!c,onClick:()=>i(`gen`,A),children:[(0,R.jsx)(h,{icon:u,size:16}),`Preview`]}),(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,R.jsx)(v,{disabled:r||!c,onClick:()=>i(`gen`,{...A,mode:`files`,format:b}),children:`Write files`}),(0,R.jsx)(s,{"aria-label":`File format`,value:b,onChange:e=>x(e.target.value),className:`w-[88px]`,children:[`csv`,`json`,`sql`].map(e=>(0,R.jsx)(`option`,{children:e},e))})]}),(0,R.jsxs)(v,{disabled:r||!c||!I?.writable,title:I?.writable?void 0:`Pick a writable database to insert into`,onClick:()=>C(!0),children:[(0,R.jsx)(P,{size:16,"aria-hidden":`true`}),`Insert into `,I?.writable?I.name:`a database`]})]}),S&&I&&(0,R.jsxs)(`div`,{role:`alertdialog`,"aria-label":`Insert test data`,className:`flex flex-col gap-3 rounded-[12px] border border-warn bg-warn-soft p-4`,children:[(0,R.jsxs)(`span`,{className:`font-medium`,children:[`Insert the rows of `,c,` into `,I.name,`?`]}),(0,R.jsx)(`span`,{className:`text-sm text-ink-2`,children:`They go in as one batch, which you can remove again below. Only on a test database.`}),(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,R.jsx)(v,{variant:`primary`,onClick:()=>{C(!1),i(`gen`,{...A,mode:`insert`,confirmed:!0})},children:`Insert`}),(0,R.jsx)(v,{onClick:()=>C(!1),children:`Don't insert`})]})]}),N&&!N.ok&&(0,R.jsx)(G,{text:N.error||`It did not make the data.`}),N?.ok&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[N.batch&&(0,R.jsxs)(`p`,{className:`m-0 rounded-[12px] bg-pass-soft px-3 py-2 text-sm text-pass`,children:[`Inserted as batch `,(0,R.jsx)(`span`,{className:`font-mono text-[13px]`,children:N.batch}),`.`]}),N.files?.length?(0,R.jsxs)(`p`,{className:`m-0 flex flex-wrap items-center gap-2 text-sm`,children:[`Wrote`,N.files.map(e=>(0,R.jsx)(`button`,{type:`button`,onClick:async()=>k(await p(e)),className:`cursor-pointer rounded-md border border-line-soft bg-surface-muted px-1.5 py-0.5 font-mono text-[12px] text-ink-2 hover:bg-surface-strong`,children:e},e))]}):null,(0,R.jsx)(Y,{r:N})]})]})]}),(0,R.jsxs)(`section`,{"aria-labelledby":`batch-h`,className:`flex flex-col gap-3`,children:[(0,R.jsx)(`h2`,{id:`batch-h`,className:`m-0 text-lg font-semibold`,children:`Inserted batches`}),a.length===0?(0,R.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`No writable database: test data is inserted only into one marked writable in Settings, Databases.`}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(s,{"aria-label":`Database`,value:w,onChange:e=>T(e.target.value),className:`w-[220px]`,children:a.map(e=>(0,R.jsx)(`option`,{children:e.name},e.name))}),(0,R.jsx)(v,{disabled:r||!w,onClick:()=>i(`batches`,{db:w}),children:`List batches`})]}),F&&F.length===0&&(0,R.jsxs)(`p`,{className:`m-0 text-sm text-muted`,children:[`No batches in `,M?.target,`.`]}),F&&F.length>0&&(0,R.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:F.map(e=>(0,R.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 border-t border-line-soft py-2.5 text-sm first:border-t-0`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-[1_1_240px] flex-col gap-0.5`,children:[(0,R.jsx)(`span`,{className:`font-mono text-[13px]`,children:e.batch}),(0,R.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[new Date(e.created).toLocaleString([],{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}),e.spec?` · ${e.spec}`:``,` ·`,` `,Object.entries(e.rows).map(([e,t])=>`${e} ${t}`).join(`, `)]})]}),E===e.batch?(0,R.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,R.jsxs)(`span`,{className:`text-[13px] text-warn`,children:[`Remove its rows from `,M?.target,`?`]}),(0,R.jsx)(v,{size:`sm`,className:`border-fail text-fail hover:bg-fail-soft`,onClick:()=>{D(``),i(`clean`,{db:M?.target,batch:e.batch,confirmed:!0})},children:`Remove`}),(0,R.jsx)(v,{size:`sm`,onClick:()=>D(``),children:`Keep`})]}):(0,R.jsxs)(v,{size:`sm`,disabled:r,onClick:()=>D(e.batch),children:[(0,R.jsx)(j,{size:14,"aria-hidden":`true`}),`Remove`]})]},e.batch))}),M?.kind===`clean`&&M.result?.ok&&(0,R.jsxs)(`p`,{className:`m-0 rounded-[12px] bg-pass-soft px-3 py-2 text-sm text-pass`,children:[`Removed:`,` `,Object.entries(M.result.removed||{}).map(([e,t])=>`${e} ${t}`).join(`, `)]})]})]})]})}function Z({c:e}){let t=e=>e?.count??0;return(0,R.jsxs)(`li`,{className:`flex flex-col gap-1 border-t border-line-soft py-3 text-sm first:border-t-0`,children:[(0,R.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(M,{tone:e.ok?`pass`:`fail`,children:e.ok?`Holds`:`Broken`}),(0,R.jsx)(`span`,{className:`font-medium`,children:e.flow}),(0,R.jsxs)(`span`,{className:`font-mono text-[12px] text-muted [overflow-wrap:anywhere]`,children:[e.from,` → `,e.to]})]}),e.error?(0,R.jsx)(`span`,{className:`text-fail [overflow-wrap:anywhere]`,children:e.error}):(0,R.jsxs)(`span`,{className:`text-ink-2`,children:[e.matched??0,` of `,e.source_rows??0,` arrived · `,e.late?`${t(e.late)} late (${t(e.in_flight)} in flight)`:`${t(e.missing)} missing`,` · `,e.wrong?.rows??0,` wrong · `,t(e.duplicates),` duplicated`,e.extra?` · ${t(e.extra)} with no source`:``]}),e.note&&(0,R.jsx)(`span`,{className:`text-[13px] text-muted`,children:e.note}),U(e.late??e.missing)&&(0,R.jsxs)(`span`,{className:`text-[13px] text-fail [overflow-wrap:anywhere]`,children:[`Missing: `,U(e.late??e.missing)]}),(e.wrong?.examples||[]).map((e,t)=>(0,R.jsxs)(`span`,{className:`font-mono text-[12px] text-fail [overflow-wrap:anywhere]`,children:[String(e.key),`: `,e.column,` expected `,H(e.expected),`, found `,H(e.target)]},t))]})}function Q({view:n,job:r,busy:i,act:a}){let[c,l]=(0,L.useState)([]),u=(0,L.useMemo)(()=>[...new Set(n.flows.map(e=>e.from).filter(e=>!e.startsWith(`api:`)))],[n.flows]),[f,g]=(0,L.useState)(u[0]??n.flows[0]?.name??``),[_,b]=(0,L.useState)(``),[S,C]=(0,L.useState)(``),[w,T]=(0,L.useState)(``),[E,O]=(0,L.useState)(null),[j,N]=(0,L.useState)(``),P=r&&!r.running?r:null,F=P?.kind===`check`?P.result??null:null,z=P?.kind===`trace`?P.result??null:null;return n.flowsError?(0,R.jsx)(G,{text:`${n.flowsFile} does not read: ${n.flowsError}`}):n.flows.length?(0,R.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,R.jsxs)(`section`,{"aria-labelledby":`flows-h`,className:`flex flex-col gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsxs)(`h2`,{id:`flows-h`,className:`m-0 flex-1 text-lg font-semibold`,children:[`Flows `,(0,R.jsxs)(`span`,{className:`text-sm font-normal text-muted`,children:[`(`,n.flowsFile,`)`]})]}),(0,R.jsxs)(v,{variant:`primary`,disabled:i,onClick:()=>a(`check`,{flows:c}),children:[(0,R.jsx)(k,{size:16,"aria-hidden":`true`}),c.length?`Check ${D(c.length,`flow`)}`:`Check all`]}),P?.report&&(P.kind===`check`||P.kind===`trace`)&&(0,R.jsxs)(v,{onClick:async()=>N(await p(P.report)),children:[(0,R.jsx)(h,{icon:t,size:16}),`Report`]})]}),(0,R.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`Each hop: did every record arrive, complete, correct, on time.`}),j&&(0,R.jsx)(G,{text:j}),(0,R.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:n.flows.map(e=>(0,R.jsxs)(`li`,{className:`flex items-start gap-3 border-t border-line-soft py-2.5 first:border-t-0`,children:[(0,R.jsx)(`input`,{type:`checkbox`,"aria-label":`Check ${e.name}`,checked:c.includes(e.name),onChange:t=>l(t.target.checked?[...c,e.name]:c.filter(t=>t!==e.name)),className:`mt-1 size-5 flex-none accent-accent`}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5 text-sm`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,R.jsxs)(`span`,{className:`font-mono text-[12px] text-ink-2 [overflow-wrap:anywhere]`,children:[e.from,` → `,e.to]}),(0,R.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[[e.mode,e.sla?`SLA ${e.sla}`:``,D(e.columns,`column`)].filter(Boolean).join(` · `),e.description?` · ${e.description}`:``]})]})]},e.name))}),F?.error&&(0,R.jsx)(G,{text:F.error}),F?.flows&&(0,R.jsx)(`ul`,{"aria-label":`Check results`,className:`m-0 flex list-none flex-col rounded-[14px] border border-line-soft px-4 py-1`,children:F.flows.map(e=>(0,R.jsx)(Z,{c:e},e.flow))})]}),(0,R.jsxs)(`section`,{"aria-labelledby":`trace-h`,className:`flex flex-col gap-3`,children:[(0,R.jsx)(`h2`,{id:`trace-h`,className:`m-0 text-lg font-semibold`,children:`Follow one record`}),(0,R.jsxs)(`form`,{className:`flex flex-wrap items-end gap-3`,onSubmit:e=>{e.preventDefault(),f&&_.trim()&&a(`trace`,{start:f,key:_.trim(),...S?{wait:Number(S)}:{}})},children:[(0,R.jsxs)(`label`,{className:`flex min-w-0 flex-[1_1_220px] flex-col gap-1.5 text-sm font-medium`,children:[`From`,(0,R.jsxs)(s,{value:f,onChange:e=>g(e.target.value),children:[(0,R.jsx)(`optgroup`,{label:`A table`,children:u.map(e=>(0,R.jsx)(`option`,{children:e},e))}),(0,R.jsx)(`optgroup`,{label:`A flow`,children:n.flows.map(e=>(0,R.jsx)(`option`,{children:e.name},e.name))})]})]}),(0,R.jsxs)(`label`,{className:`flex w-[160px] flex-col gap-1.5 text-sm font-medium`,children:[`Its key`,(0,R.jsx)(o,{value:_,maxLength:200,placeholder:`1042`,onChange:e=>b(e.target.value)})]}),(0,R.jsxs)(`label`,{className:`flex w-[130px] flex-col gap-1.5 text-sm font-medium`,children:[`Wait up to (s)`,(0,R.jsx)(o,{value:S,inputMode:`numeric`,placeholder:`0`,onChange:e=>C(e.target.value.replace(/\D/g,``).slice(0,3))})]}),(0,R.jsxs)(v,{type:`submit`,disabled:i||!f||!_.trim(),children:[(0,R.jsx)(h,{icon:d,size:16}),`Follow it`]})]}),z?.error&&(0,R.jsx)(G,{text:z.error}),z?.hops&&(0,R.jsx)(`ol`,{className:`m-0 flex list-none flex-col gap-2 border-l border-line pl-4`,children:z.hops.map((e,t)=>(0,R.jsxs)(`li`,{className:`flex flex-col gap-0.5 text-sm`,children:[(0,R.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(M,{tone:e.ok?`pass`:`fail`,children:e.ok?`Arrived`:e.found_in_source===!1?`Not in the source`:e.arrived===!1?`Did not arrive`:`Differs`}),(0,R.jsx)(`span`,{className:`font-medium`,children:e.flow}),(0,R.jsxs)(`span`,{className:`font-mono text-[12px] text-muted`,children:[e.from,` → `,e.to,` · key `,H(e.key)]})]}),(e.differences||[]).map((e,t)=>(0,R.jsxs)(`span`,{className:`font-mono text-[12px] text-fail [overflow-wrap:anywhere]`,children:[e.column,`: expected `,H(e.expected),`, found `,H(e.target)]},t)),Number(e.copies)>1&&(0,R.jsxs)(`span`,{className:`text-[13px] text-warn`,children:[e.copies,` copies`]})]},t))})]}),(0,R.jsxs)(`section`,{"aria-labelledby":`impact-h`,className:`flex flex-col gap-3`,children:[(0,R.jsx)(`h2`,{id:`impact-h`,className:`m-0 text-lg font-semibold`,children:`What a change reaches`}),(0,R.jsxs)(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:async e=>{e.preventDefault();try{O(await x.impact(w.trim())),N(``)}catch(e){N(e.message)}},children:[(0,R.jsx)(o,{"aria-label":`A table or column`,value:w,spellCheck:!1,placeholder:`shop.orders.total`,onChange:e=>T(e.target.value),className:`min-w-0 flex-[1_1_260px] font-mono text-[13px]`}),(0,R.jsxs)(v,{type:`submit`,disabled:!w.trim(),children:[(0,R.jsx)(A,{size:16,"aria-hidden":`true`}),`Show what reads it`]})]}),E&&E.length===0&&(0,R.jsxs)(`p`,{className:`m-0 text-sm text-muted`,children:[`Nothing in the flows reads `,w,`.`]}),E&&E.length>0&&(0,R.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0`,children:E.map((e,t)=>(0,R.jsxs)(`li`,{className:`font-mono text-[12px] text-ink-2 [overflow-wrap:anywhere]`,style:{paddingLeft:`${(e.depth-1)*16}px`},children:[e.from,` → `,e.to,e.columns.length?` (${e.columns.join(`, `)})`:``,` `,(0,R.jsxs)(`span`,{className:`text-muted`,children:[`[`,e.flow,`]`]})]},t))}),n.map.length>0&&(0,R.jsxs)(`details`,{children:[(0,R.jsx)(`summary`,{className:`cursor-pointer text-sm text-muted`,children:`The whole map`}),(0,R.jsx)(`pre`,{className:`mt-2 overflow-auto rounded-[12px] bg-surface-muted p-3 font-mono text-[12px] leading-relaxed text-ink-2`,children:n.map.join(`
4
+ `)})]})]})]}):(0,R.jsxs)(`div`,{className:`flex flex-col items-start gap-3 rounded-[18px] border border-line p-6`,children:[(0,R.jsx)(I,{size:24,"aria-hidden":`true`,className:`text-muted`}),(0,R.jsxs)(`p`,{className:`m-0 max-w-[62ch] leading-relaxed text-ink-2`,children:[`No data flows yet. A flow says how records move from one system to another (a table, a topic or an API), by which key, and what each column becomes; `,(0,R.jsx)(`span`,{className:`font-mono text-[13px]`,children:n.flowsFile}),` holds them. ForgeQE can write them from your mapping documents.`]}),(0,R.jsxs)(v,{onClick:async()=>{try{let{id:e}=await y.start(`Write the data flows of this project into flows.yaml from our mapping documents and the databases' schemas. Show me each flow before you save it.`,{});location.hash=m(`chats`,e)}catch(e){N(e.message)}},children:[(0,R.jsx)(h,{icon:e,size:16}),`Write flows in a chat`]}),j&&(0,R.jsx)(G,{text:j})]})}function $({sub:e}){let[t,n]=(0,L.useState)(null),[i,a]=(0,L.useState)(``),[o,s]=(0,L.useState)(!1),[c,...l]=(e||``).split(`/`),u=z.includes(c)?c:`databases`,d=(0,L.useCallback)(()=>{x.view().then(e=>{n(e),a(``)},e=>a(e.message))},[]);(0,L.useEffect)(d,[d]);let p=!!t?.job?.running;(0,L.useEffect)(()=>{if(!p)return;let e=setInterval(d,1e3);return()=>clearInterval(e)},[p,d]);let h=async(e,t)=>{s(!0),a(``);try{await x.run(e,t),d()}catch(e){a(e.message)}finally{s(!1)}},g=t?.job??null,v={databases:`Databases${t?` (${t.databases.length})`:``}`,testdata:`Test data${t?` (${t.specs.length})`:``}`,flows:`Data flows${t?` (${t.flows.length})`:``}`};return(0,R.jsxs)(`div`,{className:`flex min-h-screen flex-col`,children:[(0,R.jsx)(w,{}),(0,R.jsxs)(`main`,{className:_(T,`@container flex-auto gap-4`),children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,R.jsx)(E,{pixel:f.data,size:`lg`}),(0,R.jsx)(`h1`,{className:`m-0 flex-1 text-[26px] font-semibold tracking-[-0.01em]`,children:`Data`})]}),(0,R.jsx)(`p`,{className:`m-0 max-w-[74ch] text-sm leading-relaxed text-muted`,children:`The databases the agents may read, test data made from specs and inserted as batches you can remove again, and the data flows between systems: did every record arrive, complete and correct.`}),i&&(0,R.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:i}),!t&&!i&&(0,R.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}),t&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(r,{label:`Data`,current:u,onPick:e=>location.hash=m(`data`,e),tabs:z.map(e=>({id:e,label:v[e]}))}),g&&(g.running||B[g.kind]===u)&&(0,R.jsx)(W,{job:g,onStop:()=>void x.stop().then(d)}),(0,R.jsxs)(`div`,{role:`tabpanel`,id:`panel-${u}`,"aria-labelledby":`tab-${u}`,children:[u===`databases`&&(0,R.jsx)(J,{view:t,job:g,busy:o||p,act:h,sub:l[0]?decodeURIComponent(l[0]):void 0}),u===`testdata`&&(0,R.jsx)(X,{view:t,job:g,busy:o||p,act:h}),u===`flows`&&(0,R.jsx)(Q,{view:t,job:g,busy:o||p,act:h})]})]})]})]})}export{$ as Data};
@@ -1 +1 @@
1
- import{$t as e,Ar as t,G as n,K as r,N as i,Nr as a,T as o,X as s,Z as c,_t as l,bt as u,dr as d,dt as f,ir as p,mr as m,ot as h,r as g,t as _,tr as v,xt as y,yt as b}from"./frame-3JV5tjBP.js";import{t as x}from"./circle-dashed-DJoDKq93.js";import{n as S}from"./markdown-Bca_tHZ5.js";import{i as C,v as w,y as T}from"./index-XRjCGJfG.js";var E={name:`circle-question-mark`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`help-circle`,`circle-help`]};E.node;var D=p(E),O=a(t(),1),k=b(),A={ready:{label:`Ready`,tone:`pass`},partial:{label:`Ready, some parts need setup`,tone:`warn`},needs_setup:{label:`Needs setup`,tone:`neutral`}},j={models:`Models`,integrations:`Integrations`,monitor:`Monitor`,notifications:`Notifications`,agents:`Agents`,environments:`Environments`,containers:`Containers`,databases:`Databases`};async function M(e,t){try{let{id:t}=await d.start(e,{});location.hash=c(`chats`,t)}catch(e){t(e.message)}}function N({f:t,onScope:n,busy:i}){let[a,o]=(0,O.useState)(null),[s,d]=(0,O.useState)(``),[p,h]=(0,O.useState)(``);(0,O.useEffect)(()=>{m.detail(t.id).then(o,e=>d(e.message))},[t.id]);let g=t.gaps.filter(e=>!e.optional),_=t.gaps.filter(e=>e.optional);return(0,k.jsxs)(`div`,{className:`flex flex-col gap-4 py-4`,children:[[[g,`Needs`],[_,`Would do more with`]].map(([e,t])=>e.length?(0,k.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium`,children:t}),(0,k.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:e.map((e,n)=>(0,k.jsxs)(`li`,{className:`flex flex-col gap-0.5 rounded-[10px] bg-bg px-3 py-2 text-sm`,children:[(0,k.jsx)(`span`,{className:u(t===`Needs`?`text-ink`:`text-ink-2`),children:e.missing}),(0,k.jsx)(`span`,{className:`text-[13px] text-muted`,children:e.fix}),e.settings&&(0,k.jsxs)(`a`,{href:c(`settings`,e.settings),className:`inline-flex items-center gap-1 self-start text-[13px] font-medium`,children:[(0,k.jsx)(w,{size:13,"aria-hidden":`true`}),`Set it up in Settings, `,j[e.settings]||e.settings]})]},n))})]},t):null),t.inputs.length>0&&(0,k.jsxs)(`p`,{className:`m-0 text-sm text-ink-2`,children:[`From your request: `,t.inputs.join(`; `),`.`]}),s&&(0,k.jsx)(`p`,{className:`m-0 text-sm text-fail`,children:s}),a&&(0,k.jsxs)(k.Fragment,{children:[a.examples.length>0&&(0,k.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium`,children:`Ask for it like this`}),(0,k.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:a.examples.slice(0,4).map(n=>(0,k.jsxs)(f,{size:`sm`,disabled:t.state===`needs_setup`,title:t.state===`needs_setup`?`Set it up first`:`Start a chat with this request`,onClick:()=>void M(n,h),className:`h-auto min-h-8 max-w-full py-1.5 text-left whitespace-normal`,children:[(0,k.jsx)(l,{icon:e,size:14,className:`flex-none`}),n]},n))}),p&&(0,k.jsx)(`span`,{className:`text-[13px] text-fail`,children:p})]}),a.limits.length>0&&(0,k.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium`,children:`What it does not do`}),(0,k.jsx)(`ul`,{className:`m-0 list-disc pl-5 text-sm text-ink-2`,children:a.limits.map(e=>(0,k.jsx)(`li`,{children:e},e))})]}),a.docs.length>0&&(0,k.jsxs)(`details`,{children:[(0,k.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:[`How it works (`,y(a.docs.length,`section`),`)`]}),(0,k.jsx)(`div`,{className:`mt-2 flex flex-col gap-4`,children:a.docs.map(e=>(0,k.jsxs)(`section`,{className:`rounded-[12px] bg-bg px-4 py-3`,children:[(0,k.jsx)(`h4`,{className:`m-0 mb-1 text-sm font-semibold`,children:e.heading}),(0,k.jsx)(S,{text:e.text,className:`text-sm`})]},e.heading))})]}),(0,k.jsxs)(`span`,{className:`font-mono text-[11.5px] text-muted [overflow-wrap:anywhere]`,children:[`Tools: `,a.tools.join(`, `)]})]}),(0,k.jsxs)(`label`,{className:`flex flex-wrap items-center gap-3 border-t border-line-soft pt-3 text-sm`,children:[(0,k.jsxs)(`span`,{className:`flex-[1_1_240px]`,children:[`The agent gets its tools`,(0,k.jsx)(`span`,{className:`block text-[13px] text-muted`,children:`agent.capabilities in forgeqe.yaml`})]}),(0,k.jsxs)(r,{value:t.scope,disabled:i,onChange:e=>n(e.target.value),className:`w-[240px]`,children:[(0,k.jsx)(`option`,{value:`auto`,children:`When a request is about it`}),(0,k.jsx)(`option`,{value:`always`,children:`Always`}),(0,k.jsx)(`option`,{value:`off`,children:`Never, in this project`})]})]})]})}function P(){let[e,t]=(0,O.useState)(null),[r,a]=(0,O.useState)(``),[c,l]=(0,O.useState)(``),[d,f]=(0,O.useState)(`all`),[p,y]=(0,O.useState)(``),[b,S]=(0,O.useState)(!1),w=(0,O.useCallback)(()=>m.view().then(t,e=>a(e.message)),[]);(0,O.useEffect)(()=>void w(),[w]);let E=(0,O.useMemo)(()=>{let t=p.toLowerCase().split(/\s+/).filter(Boolean);return(e?.areas||[]).map(e=>({...e,features:e.features.filter(n=>(d===`all`||(d===`ready`?n.state!==`needs_setup`:n.state!==`ready`))&&t.every(t=>`${n.title} ${n.summary} ${e.area}`.toLowerCase().includes(t)))})).filter(e=>e.features.length)},[e,d,p]),j=async(e,n)=>{S(!0);try{t(await m.scope(e,n)),a(``)}catch(e){a(e.message)}finally{S(!1)}},M=e?.counts;return(0,k.jsxs)(`div`,{className:`flex min-h-screen flex-col`,children:[(0,k.jsx)(g,{}),(0,k.jsxs)(`main`,{className:u(_,`flex-auto gap-5`),children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,k.jsx)(h,{pixel:s.features,size:`lg`}),(0,k.jsx)(`h1`,{className:`m-0 flex-1 text-[26px] font-semibold tracking-[-0.01em]`,children:`What's ready`})]}),(0,k.jsx)(`p`,{className:`m-0 max-w-[70ch] text-sm leading-relaxed text-muted`,children:`Everything ForgeQE can do, and whether it works here: in this project, with these settings, on this machine. Each one says what it still needs and where to set it up, and how to ask for it.`}),r&&(0,k.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:r}),!e&&!r&&(0,k.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}),e&&M&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,k.jsx)(o,{icon:v,label:`Ready`,value:String(M.ready)}),(0,k.jsx)(o,{icon:D,label:`Some parts need setup`,value:String(M.partial)}),(0,k.jsx)(o,{icon:x,label:`Need setup`,value:String(M.needs_setup)})]}),(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,k.jsx)(`div`,{role:`radiogroup`,"aria-label":`Show`,className:`flex gap-1 rounded-[10px] bg-surface-strong p-1`,children:[[`all`,`All`],[`needs`,`Needs setup`],[`ready`,`Ready`]].map(([e,t])=>(0,k.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":d===e,onClick:()=>f(e),className:u(`min-h-8 cursor-pointer rounded-[7px] border-0 px-3.5 text-sm font-medium`,d===e?`bg-bg text-ink shadow-sm`:`bg-transparent text-muted hover:text-ink`),children:t},e))}),(0,k.jsxs)(`div`,{className:`relative min-w-0 flex-[1_1_220px]`,children:[(0,k.jsx)(T,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-muted`}),(0,k.jsx)(n,{type:`search`,"aria-label":`Find a feature`,value:p,placeholder:`Find a feature`,onChange:e=>y(e.target.value),className:`pl-9`})]})]}),E.length===0&&(0,k.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Nothing matches.`}),E.map(e=>(0,k.jsxs)(`section`,{"aria-labelledby":`area-${e.area}`,children:[(0,k.jsx)(`h2`,{id:`area-${e.area}`,className:`m-0 mb-1 text-base font-semibold`,children:e.area}),e.features.map(e=>(0,k.jsx)(i,{title:e.title,meta:(0,k.jsx)(`span`,{className:u(c!==e.id&&`line-clamp-2`),children:e.summary}),open:c===e.id,onToggle:()=>l(c===e.id?``:e.id),state:(0,k.jsxs)(`span`,{className:`flex flex-wrap items-center justify-end gap-1.5`,children:[e.scope!==`auto`&&(0,k.jsx)(C,{tone:`neutral`,icon:!1,children:e.scope===`always`?`Always given`:`Off here`}),(0,k.jsx)(C,{tone:A[e.state].tone,icon:e.state!==`needs_setup`,children:A[e.state].label})]}),children:(0,k.jsx)(N,{f:e,busy:b,onScope:t=>void j(e.id,t)})},e.id))]},e.area)),e.outOfScope.length>0&&(0,k.jsxs)(`section`,{"aria-labelledby":`oos-h`,className:`flex flex-col gap-2 rounded-[14px] border border-line-soft px-4 py-3`,children:[(0,k.jsx)(`h2`,{id:`oos-h`,className:`m-0 text-base font-semibold`,children:`Not what ForgeQE does`}),(0,k.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0 text-sm`,children:e.outOfScope.map(e=>(0,k.jsxs)(`li`,{children:[e.what,e.instead?(0,k.jsxs)(`span`,{className:`text-muted`,children:[`; instead: `,e.instead]}):null]},e.what))})]})]})]})]})}export{P as Features};
1
+ import{$t as e,Fr as t,G as n,K as r,Mr as i,N as a,T as o,X as s,Z as c,_t as l,ar as u,bt as d,dt as f,fr as p,gr as m,nr as h,r as g,t as _,ut as v,xt as y,yt as b}from"./frame-z3iL_6aL.js";import{t as x}from"./circle-dashed-C84s5T0C.js";import{n as S}from"./markdown-BtqKvAEi.js";import{b as C,i as w,y as T}from"./index-BVw2ygO2.js";var E={name:`circle-question-mark`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`help-circle`,`circle-help`]};E.node;var D=u(E),O=t(i(),1),k=b(),A={ready:{label:`Ready`,tone:`pass`},partial:{label:`Ready, some parts need setup`,tone:`warn`},needs_setup:{label:`Needs setup`,tone:`neutral`}},j={models:`Models`,integrations:`Integrations`,monitor:`Monitor`,notifications:`Notifications`,agents:`Agents`,environments:`Environments`,containers:`Containers`,databases:`Databases`};async function M(e,t){try{let{id:t}=await p.start(e,{});location.hash=c(`chats`,t)}catch(e){t(e.message)}}function N({f:t,onScope:n,busy:i}){let[a,o]=(0,O.useState)(null),[s,u]=(0,O.useState)(``),[p,h]=(0,O.useState)(``);(0,O.useEffect)(()=>{m.detail(t.id).then(o,e=>u(e.message))},[t.id]);let g=t.gaps.filter(e=>!e.optional),_=t.gaps.filter(e=>e.optional);return(0,k.jsxs)(`div`,{className:`flex flex-col gap-4 py-4`,children:[[[g,`Needs`],[_,`Would do more with`]].map(([e,t])=>e.length?(0,k.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium`,children:t}),(0,k.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:e.map((e,n)=>(0,k.jsxs)(`li`,{className:`flex flex-col gap-0.5 rounded-[10px] bg-bg px-3 py-2 text-sm`,children:[(0,k.jsx)(`span`,{className:d(t===`Needs`?`text-ink`:`text-ink-2`),children:e.missing}),(0,k.jsx)(`span`,{className:`text-[13px] text-muted`,children:e.fix}),e.settings&&(0,k.jsxs)(`a`,{href:c(`settings`,e.settings),className:`inline-flex items-center gap-1 self-start text-[13px] font-medium`,children:[(0,k.jsx)(T,{size:13,"aria-hidden":`true`}),`Set it up in Settings, `,j[e.settings]||e.settings]})]},n))})]},t):null),t.inputs.length>0&&(0,k.jsxs)(`p`,{className:`m-0 text-sm text-ink-2`,children:[`From your request: `,t.inputs.join(`; `),`.`]}),s&&(0,k.jsx)(`p`,{className:`m-0 text-sm text-fail`,children:s}),a&&(0,k.jsxs)(k.Fragment,{children:[a.examples.length>0&&(0,k.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium`,children:`Ask for it like this`}),(0,k.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:a.examples.slice(0,4).map(n=>(0,k.jsxs)(f,{size:`sm`,disabled:t.state===`needs_setup`,title:t.state===`needs_setup`?`Set it up first`:`Start a chat with this request`,onClick:()=>void M(n,h),className:`h-auto min-h-8 max-w-full py-1.5 text-left whitespace-normal`,children:[(0,k.jsx)(l,{icon:e,size:14,className:`flex-none`}),n]},n))}),p&&(0,k.jsx)(`span`,{className:`text-[13px] text-fail`,children:p})]}),a.limits.length>0&&(0,k.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium`,children:`What it does not do`}),(0,k.jsx)(`ul`,{className:`m-0 list-disc pl-5 text-sm text-ink-2`,children:a.limits.map(e=>(0,k.jsx)(`li`,{children:e},e))})]}),a.docs.length>0&&(0,k.jsxs)(`details`,{children:[(0,k.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:[`How it works (`,y(a.docs.length,`section`),`)`]}),(0,k.jsx)(`div`,{className:`mt-2 flex flex-col gap-4`,children:a.docs.map(e=>(0,k.jsxs)(`section`,{className:`rounded-[12px] bg-bg px-4 py-3`,children:[(0,k.jsx)(`h4`,{className:`m-0 mb-1 text-sm font-semibold`,children:e.heading}),(0,k.jsx)(S,{text:e.text,className:`text-sm`})]},e.heading))})]}),(0,k.jsxs)(`span`,{className:`font-mono text-[11.5px] text-muted [overflow-wrap:anywhere]`,children:[`Tools: `,a.tools.join(`, `)]})]}),(0,k.jsxs)(`label`,{className:`flex flex-wrap items-center gap-3 border-t border-line-soft pt-3 text-sm`,children:[(0,k.jsxs)(`span`,{className:`flex-[1_1_240px]`,children:[`The agent gets its tools`,(0,k.jsx)(`span`,{className:`block text-[13px] text-muted`,children:`agent.capabilities in forgeqe.yaml`})]}),(0,k.jsxs)(r,{value:t.scope,disabled:i,onChange:e=>n(e.target.value),className:`w-[240px]`,children:[(0,k.jsx)(`option`,{value:`auto`,children:`When a request is about it`}),(0,k.jsx)(`option`,{value:`always`,children:`Always`}),(0,k.jsx)(`option`,{value:`off`,children:`Never, in this project`})]})]})]})}function P(){let[e,t]=(0,O.useState)(null),[r,i]=(0,O.useState)(``),[c,l]=(0,O.useState)(``),[u,f]=(0,O.useState)(`all`),[p,y]=(0,O.useState)(``),[b,S]=(0,O.useState)(!1),T=(0,O.useCallback)(()=>m.view().then(t,e=>i(e.message)),[]);(0,O.useEffect)(()=>void T(),[T]);let E=(0,O.useMemo)(()=>{let t=p.toLowerCase().split(/\s+/).filter(Boolean);return(e?.areas||[]).map(e=>({...e,features:e.features.filter(n=>(u===`all`||(u===`ready`?n.state!==`needs_setup`:n.state!==`ready`))&&t.every(t=>`${n.title} ${n.summary} ${e.area}`.toLowerCase().includes(t)))})).filter(e=>e.features.length)},[e,u,p]),j=async(e,n)=>{S(!0);try{t(await m.scope(e,n)),i(``)}catch(e){i(e.message)}finally{S(!1)}},M=e?.counts;return(0,k.jsxs)(`div`,{className:`flex min-h-screen flex-col`,children:[(0,k.jsx)(g,{}),(0,k.jsxs)(`main`,{className:d(_,`flex-auto gap-5`),children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,k.jsx)(v,{pixel:s.features,size:`lg`}),(0,k.jsx)(`h1`,{className:`m-0 flex-1 text-[26px] font-semibold tracking-[-0.01em]`,children:`What's ready`})]}),(0,k.jsx)(`p`,{className:`m-0 max-w-[70ch] text-sm leading-relaxed text-muted`,children:`Everything ForgeQE can do, and whether it works here: in this project, with these settings, on this machine. Each one says what it still needs and where to set it up, and how to ask for it.`}),r&&(0,k.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:r}),!e&&!r&&(0,k.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}),e&&M&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,k.jsx)(o,{icon:h,label:`Ready`,value:String(M.ready)}),(0,k.jsx)(o,{icon:D,label:`Some parts need setup`,value:String(M.partial)}),(0,k.jsx)(o,{icon:x,label:`Need setup`,value:String(M.needs_setup)})]}),(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,k.jsx)(`div`,{role:`radiogroup`,"aria-label":`Show`,className:`flex gap-1 rounded-[10px] bg-surface-strong p-1`,children:[[`all`,`All`],[`needs`,`Needs setup`],[`ready`,`Ready`]].map(([e,t])=>(0,k.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":u===e,onClick:()=>f(e),className:d(`min-h-8 cursor-pointer rounded-[7px] border-0 px-3.5 text-sm font-medium`,u===e?`bg-bg text-ink shadow-sm`:`bg-transparent text-muted hover:text-ink`),children:t},e))}),(0,k.jsxs)(`div`,{className:`relative min-w-0 flex-[1_1_220px]`,children:[(0,k.jsx)(C,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-muted`}),(0,k.jsx)(n,{type:`search`,"aria-label":`Find a feature`,value:p,placeholder:`Find a feature`,onChange:e=>y(e.target.value),className:`pl-9`})]})]}),E.length===0&&(0,k.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Nothing matches.`}),E.map(e=>(0,k.jsxs)(`section`,{"aria-labelledby":`area-${e.area}`,children:[(0,k.jsx)(`h2`,{id:`area-${e.area}`,className:`m-0 mb-1 text-base font-semibold`,children:e.area}),e.features.map(e=>(0,k.jsx)(a,{title:e.title,meta:(0,k.jsx)(`span`,{className:d(c!==e.id&&`line-clamp-2`),children:e.summary}),open:c===e.id,onToggle:()=>l(c===e.id?``:e.id),state:(0,k.jsxs)(`span`,{className:`flex flex-wrap items-center justify-end gap-1.5`,children:[e.scope!==`auto`&&(0,k.jsx)(w,{tone:`neutral`,icon:!1,children:e.scope===`always`?`Always given`:`Off here`}),(0,k.jsx)(w,{tone:A[e.state].tone,icon:e.state!==`needs_setup`,children:A[e.state].label})]}),children:(0,k.jsx)(N,{f:e,busy:b,onScope:t=>void j(e.id,t)})},e.id))]},e.area)),e.outOfScope.length>0&&(0,k.jsxs)(`section`,{"aria-labelledby":`oos-h`,className:`flex flex-col gap-2 rounded-[14px] border border-line-soft px-4 py-3`,children:[(0,k.jsx)(`h2`,{id:`oos-h`,className:`m-0 text-base font-semibold`,children:`Not what ForgeQE does`}),(0,k.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0 text-sm`,children:e.outOfScope.map(e=>(0,k.jsxs)(`li`,{children:[e.what,e.instead?(0,k.jsxs)(`span`,{className:`text-muted`,children:[`; instead: `,e.instead]}):null]},e.what))})]})]})]})]})}export{P as Features};
@@ -0,0 +1,3 @@
1
+ import{At as e,Fr as t,G as n,Ht as r,J as i,Jn as a,K as o,Mr as s,Nn as c,Ot as l,Rt as u,T as d,Tr as f,Wt as p,X as m,Y as h,Z as g,_t as _,ar as v,at as y,bn as b,bt as x,dt as S,er as C,fn as w,in as T,ot as E,qt as D,r as O,st as k,t as ee,tr as A,ut as j,yr as M,yt as N}from"./frame-z3iL_6aL.js";import{n as P,t as F}from"./markdown-BtqKvAEi.js";import{C as te,E as ne,g as I,i as L}from"./index-BVw2ygO2.js";var R={name:`calendar-plus`,size:24,node:[[`path`,{d:`M16 18h6`,key:`987eiv`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`path`,{d:`M19 15v6`,key:`10aioa`}],[`path`,{d:`M21 11.5V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h8.3`,key:`jgwkxf`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M8 2v3`,key:`1ioesn`}]]};R.node;var z=v(R),B={name:`power`,size:24,node:[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]};B.node;var V=v(B),H={name:`search-check`,size:24,node:[[`path`,{d:`m8 11 2 2 4-4`,key:`1sed1v`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]};H.node;var U=v(H),W={name:`timer-off`,size:24,node:[[`path`,{d:`M10 2h4`,key:`n1abiw`}],[`path`,{d:`M4.6 11a8 8 0 0 0 1.7 8.7 8 8 0 0 0 8.7 1.7`,key:`10he05`}],[`path`,{d:`M7.4 7.4a8 8 0 0 1 10.3 1 8 8 0 0 1 .9 10.2`,key:`15f7sh`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M12 12v-2`,key:`fwoke6`}]]};W.node;var G=v(W),K=t(s(),1),q=N(),J={monitor:`Monitor`,suite:`Suite`,run:`Browser run`,heal:`Heal`,"pr-tests":`PR tests`,pack:`Pack`,pipeline:`Pipeline watch`},Y={running:{label:`Running`,tone:`running`},passed:{label:`Passed`,tone:`pass`},failed:{label:`Failed`,tone:`fail`},stopped:{label:`Stopped`,tone:`neutral`},timed_out:{label:`Timed out`,tone:`fail`},interrupted:{label:`Interrupted`,tone:`warn`}},X=e=>{if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString([],{month:`short`,day:`numeric`,...t.getFullYear()===new Date().getFullYear()?{}:{year:`numeric`},hour:`numeric`,minute:`2-digit`})},Z=e=>{if(!e.endedAt)return``;let t=Math.max(0,Math.round((Date.parse(e.endedAt)-Date.parse(e.startedAt))/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`};function Q(e){return e.running?Y.running:e.enabled?e.last?Y[e.last.status]:{label:`Not run yet`,tone:`neutral`}:{label:`Disabled`,tone:`neutral`}}var re={pass:`bg-pass`,fail:`bg-fail`,warn:`bg-warn`,running:`bg-accent`,neutral:`bg-line`};function $({label:e,icon:t,children:n}){return(0,q.jsxs)(`div`,{className:`flex min-h-[48px] flex-wrap items-baseline gap-x-4 gap-y-1 border-t border-line-soft py-2.5`,children:[(0,q.jsxs)(`span`,{className:`flex w-[170px] flex-none items-center gap-2 text-sm text-muted`,children:[t&&(0,q.jsx)(_,{icon:t,size:16,className:`flex-none`}),e]}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 text-sm [overflow-wrap:anywhere]`,children:n})]})}function ie({m:e,rounds:t}){let[n,r]=(0,K.useState)(``);return(0,q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,q.jsxs)(`h3`,{className:`m-0 mb-1 flex items-center gap-2 text-base font-semibold`,children:[(0,q.jsx)(_,{icon:w,size:18,className:`text-accent-fg`}),`Monitor`]}),(0,q.jsx)($,{icon:T,label:`Checks`,children:e.checks.length?(0,q.jsx)(P,{text:e.checks.map(e=>`\`${e.replace(/`/g,``)}\``).join(`, `),className:`text-sm [&_p]:my-0`}):`The checks in forgeqe.yaml (monitor.checks)`}),(0,q.jsxs)($,{icon:A,label:`Alerts after`,children:[e.failAfter,` failing round`,e.failAfter===1?``:`s`,` in a row`,e.remind?`, again every ${e.remind} while it keeps failing`:``]}),(0,q.jsx)($,{icon:u,label:`Alerts go to`,children:e.alerts.length?e.alerts.join(` and `):`Nowhere yet: add Teams or email in Settings, Monitor`}),(0,q.jsxs)($,{icon:p,label:`Each round`,children:[e.parallel,` check`,e.parallel===1?``:`s`,` at once; a recorded run `,e.replay===`trust`?`is trusted`:e.replay===`off`?`is not replayed`:`is verified with one model call`]}),(0,q.jsx)($,{icon:b,label:`Rounds kept in`,children:(0,q.jsx)(F,{path:e.outDir})}),(0,q.jsx)(`p`,{className:`m-0 border-t border-line-soft py-2.5 text-sm`,children:(0,q.jsx)(`a`,{href:g(`settings`,`monitor`),children:`Change the monitor in Settings`})}),(0,q.jsx)(`h4`,{className:`m-0 mt-3 mb-1 text-sm font-semibold`,children:`Latest rounds`}),n&&(0,q.jsx)(`p`,{className:`m-0 text-[13px] text-fail`,children:n}),t.length===0?(0,q.jsx)(`p`,{className:`m-0 border-t border-line-soft py-3 text-sm text-muted`,children:`No rounds yet.`}):(0,q.jsx)(`ul`,{className:`m-0 list-none p-0`,children:t.slice(0,8).map(e=>(0,q.jsxs)(`li`,{className:`flex min-h-[48px] items-center gap-3 border-t border-line-soft py-2`,children:[(0,q.jsxs)(L,{tone:e.counts.failed?`fail`:`pass`,children:[e.counts.passed,`/`,e.counts.total,` passed`]}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm`,children:X(e.startedAt)}),e.report?(0,q.jsxs)(S,{size:`sm`,"aria-label":`Open the report of the round of ${X(e.startedAt)} in a new tab`,onClick:async()=>r(await h(e.report)),children:[(0,q.jsx)(c,{size:14,"aria-hidden":`true`}),`Open report`]}):(0,q.jsx)(F,{path:e.folder})]},e.key))})]})}function ae({jobId:e,run:t}){let[n,r]=(0,K.useState)(null),[i,a]=(0,K.useState)(``);(0,K.useEffect)(()=>{let n=!1;r(null);let i=()=>M.log(e,t.id).then(e=>!n&&r(e.lines),e=>!n&&a(e.message));i();let o=t.status===`running`?setInterval(i,2e3):void 0;return()=>{n=!0,o&&clearInterval(o)}},[e,t.id,t.status]);let o=Math.max(2,...(n||[]).map(e=>Math.max(0,...(e.match(/`+/g)||[]).map(e=>e.length)))),s="`".repeat(o+1),c=[`**${Y[t.status].label}**${t.endedAt?` after ${Z(t)}`:``}${t.exitCode!==void 0&&t.exitCode!==null?`, exit ${t.exitCode}`:``}. Started ${X(t.startedAt)}, ${t.reason===`asked`?`asked for`:`on schedule`}.`,...t.investigating?[``,`_Its failures are being investigated._`]:[],...t.findings?.length?[``,`**Investigated:**`,...t.findings.map(e=>`- ${e.verdict}: ${e.tests.map(e=>`\`${e.replace(/`/g,``)}\``).join(`, `)}${e.branch?` on branch \`${e.branch.replace(/`/g,``)}\``:``}`)]:[],...t.investigationNote?[``,t.investigationNote]:[],``,`${s}text`,...n||[],s].join(`
2
+ `);return(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-[12px] border border-line-soft bg-surface-muted px-4 py-3`,children:[i&&(0,q.jsx)(`p`,{className:`m-0 text-sm text-fail`,children:i}),!n&&!i?(0,q.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Reading its output…`}):(0,q.jsx)(P,{text:c,className:`text-sm [&_pre]:max-h-[320px] [&_pre]:overflow-auto`})]})}function oe({job:t,rounds:n,busy:i,act:o}){let[s,c]=(0,K.useState)(null),[u,f]=(0,K.useState)(null),[p,m]=(0,K.useState)(!1),h=`${t.running?.id}|${t.last?.id}|${t.last?.status}`;(0,K.useEffect)(()=>{let e=!1;return M.detail(t.id).then(t=>{e||(c(t.runs),f(e=>e??t.runs[0]?.id??null))},()=>{}),()=>{e=!0}},[t.id,h]),(0,K.useEffect)(()=>{f(null),m(!1)},[t.id]);let g=Q(t),v=s?.filter(e=>e.status===`passed`).length??0,b=s?.filter(e=>e.status!==`running`).length??0;return(0,q.jsxs)(`section`,{"aria-labelledby":`job-h`,className:`flex min-w-0 flex-1 flex-col gap-5`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-3 gap-y-3`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-[1_1_260px] flex-col gap-1`,children:[(0,q.jsx)(`h2`,{id:`job-h`,className:`m-0 text-[22px] font-semibold tracking-[-0.01em] [overflow-wrap:anywhere]`,children:t.name}),(0,q.jsxs)(`span`,{className:`text-sm text-muted`,children:[J[t.kind]||t.kind,` · `,t.schedule]})]}),(0,q.jsx)(L,{tone:g.tone,children:g.label}),t.running?(0,q.jsxs)(S,{disabled:i,onClick:()=>o(`stop`),children:[(0,q.jsx)(e,{size:14,fill:`currentColor`,"aria-hidden":`true`}),`Stop`]}):(0,q.jsxs)(S,{variant:`primary`,disabled:i,onClick:()=>o(`run`),children:[(0,q.jsx)(_,{icon:D,size:16}),`Run now`]})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,q.jsx)(d,{icon:r,label:`Runs kept`,value:String(s?.length??`–`)}),(0,q.jsx)(d,{icon:ne,label:`Passed`,value:b?`${Math.round(v/b*100)}%`:`–`,note:b?`${v} of ${b}`:void 0}),(0,q.jsx)(d,{icon:a,label:`Next run`,value:t.nextAt?new Date(t.nextAt).toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`}):`–`,note:t.nextAt?X(t.nextAt):t.enabled?void 0:`Disabled`})]}),(0,q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,q.jsx)($,{icon:l,label:`Runs`,children:(0,q.jsx)(P,{text:`\`${t.command.replace(/`/g,``)}\``,className:`text-sm [&_p]:my-0`})}),(0,q.jsx)($,{icon:a,label:`When`,children:t.schedule}),(0,q.jsx)($,{icon:V,label:`Enabled`,children:(0,q.jsx)(y,{checked:t.enabled,disabled:i,onChange:e=>o(e?`enable`:`disable`),label:`${t.name} enabled`})}),(0,q.jsxs)($,{icon:G,label:`Stopped after`,children:[t.timeoutMs?t.timeoutMs%36e5==0?`${t.timeoutMs/36e5} hour${t.timeoutMs===36e5?``:`s`}`:`${Math.round(t.timeoutMs/6e4)} minutes`:`the service's default`,` of running`]}),(0,q.jsx)($,{icon:C,label:`Tells the team`,children:t.notify?`When it fails, recovers or ends (the notify channels that take job events)`:t.kind===`monitor`?`The monitor sends its own alerts`:`No`}),(0,q.jsx)($,{icon:U,label:`Investigates failures`,children:t.investigate?`Yes, on branches of their own`:`No`}),(0,q.jsxs)($,{icon:z,label:`Added`,children:[X(t.createdAt),` `,t.by===`agent`?`by ForgeQE's agent, after you agreed`:`from the command line or here`]})]}),t.monitor&&(0,q.jsx)(ie,{m:t.monitor,rounds:n}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`h3`,{className:`m-0 mb-1 text-base font-semibold`,children:`Runs`}),s?s.length===0?(0,q.jsx)(`p`,{className:`m-0 border-t border-line-soft py-3 text-sm text-muted`,children:`No runs yet. Run now starts one.`}):(0,q.jsx)(`ul`,{className:`m-0 list-none p-0`,children:s.map(e=>(0,q.jsxs)(`li`,{className:`border-t border-line-soft`,children:[(0,q.jsxs)(`button`,{type:`button`,"aria-expanded":u===e.id,onClick:()=>f(u===e.id?null:e.id),className:`flex min-h-[52px] w-full cursor-pointer items-center gap-3 border-0 bg-transparent px-1 py-2 text-left text-ink hover:bg-surface-muted`,children:[(0,q.jsx)(L,{tone:Y[e.status].tone,children:Y[e.status].label}),(0,q.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-sm`,children:[X(e.startedAt),(0,q.jsxs)(`span`,{className:`text-muted`,children:[` `,`· `,e.reason===`asked`?`asked for`:`scheduled`,Z(e)?` · ${Z(e)}`:``]})]}),e.summary?.length?(0,q.jsx)(`span`,{className:`hidden max-w-[40%] truncate text-[13px] text-muted sm:inline`,children:e.summary.at(-1)}):null]}),(0,q.jsx)(E,{open:u===e.id,children:(0,q.jsx)(`div`,{className:`pb-3`,children:(0,q.jsx)(ae,{jobId:t.id,run:e})})})]},e.id))}):(0,q.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Loading…`})]}),(0,q.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-line-soft pt-4`,children:p?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`span`,{className:`text-sm text-ink-2`,children:[`Remove `,t.name,`? Its runs and logs go with it.`]}),(0,q.jsx)(S,{disabled:i,onClick:()=>o(`remove`),className:`border-fail text-fail hover:bg-fail-soft`,children:`Remove`}),(0,q.jsx)(S,{onClick:()=>m(!1),children:`Keep it`})]}):(0,q.jsxs)(S,{variant:`ghost`,onClick:()=>m(!0),className:`text-fail`,children:[(0,q.jsx)(I,{size:16,"aria-hidden":`true`}),`Remove this job`]})})]})}function se({open:e,onClose:t,commands:r,initial:a,onAdded:s}){let[c,l]=(0,K.useState)(``),[u,d]=(0,K.useState)(`suite`),[f,p]=(0,K.useState)(``),[m,h]=(0,K.useState)(`every`),[g,_]=(0,K.useState)(`30m`),[v,b]=(0,K.useState)(`0 2 * * 1-5`),[x,C]=(0,K.useState)(!0),[w,T]=(0,K.useState)(``),[E,D]=(0,K.useState)(!1);(0,K.useEffect)(()=>{e&&(l(a?.name??``),d(a?.command??`suite`),p(a?.args??``),h(`every`),_(a?.every??`30m`),C(a?.command!==`monitor`),T(``))},[e,a]);let O=async()=>{D(!0),T(``);try{s(await M.add({name:c.trim(),command:u,args:f,...m===`every`?{every:g}:m===`cron`?{cron:v}:{now:!0},notify:x}),c.trim())}catch(e){T(e.message)}finally{D(!1)}},k=`flex flex-col gap-1.5 py-3`;return(0,q.jsx)(i,{open:e,onClose:t,title:`Add a job`,description:`A ForgeQE command the jobs service runs on a schedule, or once now, in a process of its own; it keeps going with this page closed.`,footer:(0,q.jsxs)(q.Fragment,{children:[w&&(0,q.jsx)(`span`,{role:`alert`,className:`mr-auto self-center text-sm text-fail [overflow-wrap:anywhere]`,children:w}),(0,q.jsx)(S,{onClick:t,children:`Cancel`}),(0,q.jsx)(S,{variant:`primary`,disabled:E||!c.trim(),onClick:()=>void O(),children:E?`Adding…`:`Add job`})]}),children:(0,q.jsxs)(`div`,{className:`flex flex-col pt-3`,children:[(0,q.jsxs)(`div`,{className:k,children:[(0,q.jsx)(`label`,{htmlFor:`job-name`,className:`font-medium`,children:`Name`}),(0,q.jsx)(n,{id:`job-name`,value:c,spellCheck:!1,placeholder:`nightly-smoke`,onChange:e=>l(e.target.value)}),(0,q.jsx)(`span`,{className:`text-sm text-muted`,children:`Letters, digits and dashes.`})]}),(0,q.jsxs)(`div`,{className:k,children:[(0,q.jsx)(`label`,{htmlFor:`job-command`,className:`font-medium`,children:`Runs`}),(0,q.jsx)(o,{id:`job-command`,value:u,onChange:e=>d(e.target.value),children:r.map(e=>(0,q.jsxs)(`option`,{value:e,children:[`forgeqe `,e]},e))})]}),(0,q.jsxs)(`div`,{className:k,children:[(0,q.jsx)(`label`,{htmlFor:`job-args`,className:`font-medium`,children:`With`}),(0,q.jsx)(n,{id:`job-args`,value:f,spellCheck:!1,placeholder:u===`monitor`?`Empty: the checks in forgeqe.yaml`:`checks/smoke.yaml --parallel 2`,onChange:e=>p(e.target.value),className:`font-mono text-[13px]`}),(0,q.jsx)(`span`,{className:`text-sm text-muted`,children:`Test case sources and flags, as you would type them after the command. "…" keeps spaces in one. Nothing goes through a shell.`})]}),(0,q.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 border-0 p-0 py-3`,children:[(0,q.jsx)(`legend`,{className:`mb-1 font-medium`,children:`When`}),[[`every`,`Every`],[`cron`,`On a schedule (cron, this machine's time)`],[`once`,`Once, now`]].map(([e,t])=>(0,q.jsxs)(`label`,{className:`flex min-h-10 cursor-pointer items-center gap-3`,children:[(0,q.jsx)(`input`,{type:`radio`,name:`job-when`,checked:m===e,onChange:()=>h(e),className:`size-4 accent-accent`}),(0,q.jsx)(`span`,{className:`flex-none`,children:t}),e===`every`&&m===`every`&&(0,q.jsx)(n,{"aria-label":`Every`,value:g,onChange:e=>_(e.target.value),placeholder:`30m`,className:`max-w-[120px] font-mono text-[13px]`}),e===`cron`&&m===`cron`&&(0,q.jsx)(n,{"aria-label":`Cron schedule`,value:v,onChange:e=>b(e.target.value),className:`max-w-[180px] font-mono text-[13px]`})]},e))]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-4 py-3`,children:[(0,q.jsxs)(`span`,{className:`flex flex-1 flex-col gap-0.5`,children:[(0,q.jsx)(`span`,{className:`font-medium`,children:`Tell the team`}),(0,q.jsx)(`span`,{className:`text-sm text-muted`,children:`When it fails, recovers or ends, on the notify channels that take job events. A monitor sends its own alerts.`})]}),(0,q.jsx)(y,{checked:x,onChange:C,label:`Tell the team`})]})]})})}function ce({sub:e}){let[t,n]=(0,K.useState)(null),[r,i]=(0,K.useState)([]),[o,s]=(0,K.useState)(``),[c,l]=(0,K.useState)(!1),[u,d]=(0,K.useState)(null),p=(0,K.useCallback)(()=>{M.list().then(e=>{n(e),s(``)},e=>s(e.message))},[]);(0,K.useEffect)(p,[p]),(0,K.useEffect)(()=>{f.list().then(e=>i(e.rows.filter(e=>e.scope===`monitor`)),()=>{})},[t?.jobs.map(e=>e.last?.id).join()]);let h=t?.jobs.some(e=>e.running);(0,K.useEffect)(()=>{let e=setInterval(p,h?3e3:2e4);return()=>clearInterval(e)},[p,h]);let v=e?decodeURIComponent(e):``,y=t?.jobs.find(e=>e.id===v)||t?.jobs[0],b=(0,K.useMemo)(()=>t?.jobs.filter(e=>e.kind===`monitor`)??[],[t]),C=(0,K.useMemo)(()=>t?.jobs.filter(e=>e.kind!==`monitor`)??[],[t]),T=async e=>{if(y){l(!0),s(``);try{n(e===`remove`?await M.remove(y.id):await M.act(y.id,e)),e===`remove`&&(location.hash=g(`jobs`))}catch(e){s(e.message)}finally{l(!1)}}},E=e=>{let t=Q(e),n=y?.id===e.id;return(0,q.jsx)(`li`,{children:(0,q.jsxs)(`a`,{href:g(`jobs`,encodeURIComponent(e.id)),"aria-current":n?`page`:void 0,className:x(`flex min-h-[60px] items-center gap-3 rounded-[12px] px-3 py-2 text-ink no-underline`,n?`bg-surface-strong hover:text-ink`:`hover:bg-surface-muted hover:text-ink`),children:[e.running?(0,q.jsx)(k,{label:t.label,px:16}):(0,q.jsx)(`span`,{"aria-label":t.label,className:x(`size-2.5 flex-none rounded-full`,re[t.tone])}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,q.jsx)(`span`,{className:`truncate text-[15px] font-medium`,children:e.name}),(0,q.jsx)(`span`,{className:`truncate text-[13px] text-muted`,children:[t.label,e.schedule,e.nextAt&&e.enabled?`next ${X(e.nextAt)}`:``].filter(Boolean).join(` · `)})]})]})},e.id)};return(0,q.jsxs)(`div`,{className:`flex min-h-screen flex-col`,children:[(0,q.jsx)(O,{}),(0,q.jsxs)(`main`,{className:x(ee,`@container flex-auto gap-4`),children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,q.jsx)(j,{pixel:m.jobs,size:`lg`}),(0,q.jsx)(`h1`,{className:`m-0 text-[26px] font-semibold tracking-[-0.01em]`,children:`Jobs`}),t&&(0,q.jsx)(L,{tone:t.service.running?`pass`:`neutral`,children:t.service.running?`Service running since ${X(t.service.startedAt)}`:`Service stopped: jobs wait until it starts`}),(0,q.jsx)(`div`,{className:`flex-auto`}),(0,q.jsxs)(S,{variant:`primary`,disabled:!t,onClick:()=>d({}),children:[(0,q.jsx)(te,{size:16,"aria-hidden":`true`}),`Add a job`]})]}),(0,q.jsx)(`p`,{className:`m-0 max-w-[70ch] text-sm leading-relaxed text-muted`,children:`ForgeQE commands that run on a schedule, or once, in a service of their own, so they keep going while you work on something else or with this page closed: monitors, suites, packs and pipeline watches.`}),o&&(0,q.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:o}),!t&&!o&&(0,q.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}),t?.monitor&&!t.monitor.scheduled&&(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-3 rounded-[14px] border border-accent-line bg-accent-soft px-4 py-3`,children:[(0,q.jsx)(_,{icon:w,size:20,className:`flex-none text-accent-fg`}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-[1_1_300px] flex-col gap-0.5 text-sm`,children:[(0,q.jsx)(`span`,{className:`font-medium`,children:`The monitor in forgeqe.yaml is not scheduled`}),(0,q.jsxs)(`span`,{className:`text-ink-2`,children:[t.monitor.checks.length,` check`,t.monitor.checks.length===1?``:`s`,`, every `,t.monitor.every,`. As a job it runs a round each time, with this page closed.`]})]}),(0,q.jsx)(S,{onClick:()=>d({name:`monitor`,command:`monitor`,args:``,every:t.monitor.every}),children:`Schedule it`})]}),t&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-6 @2xl:flex-row @2xl:items-start @2xl:gap-8`,children:[(0,q.jsxs)(`nav`,{"aria-label":`Jobs`,className:`flex min-w-0 flex-col gap-4 @2xl:sticky @2xl:top-6 @2xl:w-[250px] @2xl:flex-none`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,q.jsxs)(`span`,{className:`flex items-center gap-2 px-3 text-[13px] font-medium text-muted`,children:[(0,q.jsx)(_,{icon:w,size:14}),`Monitoring (`,b.length,`)`]}),b.length?(0,q.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:b.map(E)}):(0,q.jsx)(`p`,{className:`m-0 px-3 py-2 text-sm text-muted`,children:`No monitor jobs.`})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,q.jsxs)(`span`,{className:`flex items-center gap-2 px-3 text-[13px] font-medium text-muted`,children:[(0,q.jsx)(_,{icon:a,size:14}),`Other jobs (`,C.length,`)`]}),C.length?(0,q.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:C.map(E)}):(0,q.jsx)(`p`,{className:`m-0 px-3 py-2 text-sm text-muted`,children:`None.`})]}),t.events.length>0&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`span`,{className:`px-3 text-[13px] font-medium text-muted`,children:`Recent activity`}),(0,q.jsx)(P,{text:t.events.slice(0,12).map(e=>`- \`${X(e.at)}\` ${e.text.replace(/([\\`*_[\]<>#|~!])/g,`\\$1`)}`).join(`
3
+ `),className:`px-3 text-[13px] text-ink-2 [&_li]:my-1 [&_ul]:my-0 [&_ul]:pl-4`})]})]}),y?(0,q.jsx)(oe,{job:y,rounds:r,busy:c,act:T}):(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col items-start gap-3 rounded-[18px] border border-line p-6`,children:[(0,q.jsx)(_,{icon:a,size:24,className:`text-muted`}),(0,q.jsx)(`p`,{className:`m-0 max-w-[60ch] leading-relaxed text-ink-2`,children:`No jobs yet. Add one to run a suite every night, a monitor every 15 minutes, or watch a CI pipeline.`}),(0,q.jsx)(S,{onClick:()=>d({}),children:`Add a job`})]})]})]}),(0,q.jsx)(se,{open:!!u,onClose:()=>d(null),commands:t?.commands??[],initial:u??void 0,onAdded:(e,t)=>{n(e),d(null);let r=e.jobs.find(e=>e.name===t);r&&(location.hash=g(`jobs`,encodeURIComponent(r.id)))}})]})}export{ce as Jobs};
@@ -0,0 +1 @@
1
+ import{$t as e,Bt as t,E as n,Et as r,Fr as i,G as a,Mr as o,Nn as s,Sr as c,Wn as l,X as u,Z as d,_t as f,ar as p,bt as m,dt as h,fr as g,ir as _,ln as v,ot as y,r as b,t as x,ut as S,vn as C,yt as w}from"./frame-z3iL_6aL.js";import{t as T}from"./circle-dashed-C84s5T0C.js";import{i as E,t as D}from"./markdown-BtqKvAEi.js";import{n as O,t as k}from"./trending-up-DK1wDqic.js";import{E as A,i as j,n as M,r as N,t as P}from"./index-BVw2ygO2.js";import{n as F,t as I}from"./when-CHnpLdYw.js";var L={name:`image-off`,size:24,node:[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M10.41 10.41a2 2 0 1 1-2.83-2.83`,key:`1bzlo9`}],[`line`,{x1:`13.5`,x2:`6`,y1:`13.5`,y2:`21`,key:`1q0aeu`}],[`line`,{x1:`18`,x2:`21`,y1:`12`,y2:`15`,key:`5mozeu`}],[`path`,{d:`M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59`,key:`mmje98`}],[`path`,{d:`M21 15V5a2 2 0 0 0-2-2H9`,key:`43el77`}]]};L.node;var R=p(L),z=i(o(),1),B=w(),V=[`critical`,`serious`,`moderate`,`minor`],H={critical:`fail`,serious:`fail`,moderate:`warn`,minor:`neutral`},U=[{key:`lcp`,label:`LCP`,good:2500,poor:4e3,unit:`ms`},{key:`cls`,label:`CLS`,good:.1,poor:.25,unit:``},{key:`inp`,label:`INP`,good:200,poor:500,unit:`ms`},{key:`fcp`,label:`FCP`,good:1800,poor:3e3,unit:`ms`},{key:`ttfb`,label:`TTFB`,good:800,poor:1800,unit:`ms`},{key:`load`,label:`Load`,good:1/0,poor:1/0,unit:`ms`}],W={same:{label:`Same`,tone:`pass`},changed:{label:`Changed`,tone:`warn`},new:{label:`New baseline`,tone:`neutral`},no_baseline:{label:`No baseline`,tone:`neutral`}},G=e=>new Date(e).toLocaleString([],{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}),K=(e,t)=>t?e>=1e3?`${(e/1e3).toFixed(1)}s`:`${Math.round(e)}ms`:e.toFixed(3).replace(/0+$/,``).replace(/\.$/,``),q=(e,t)=>`${e} ${t}${e===1?``:`s`}`,J=e=>{try{let t=new URL(e);return`${t.host}${t.pathname}${t.search}`}catch{return e}};function Y(e){let t=[];return e.a11y&&t.push(e.a11y.failed?`${q(e.a11y.failed,`rule`)} failed`:`WCAG clean`),e.perf.over&&t.push(`${q(e.perf.over,`page`)} slow`),e.visual?.changed&&t.push(`${e.visual.changed} changed`),e.captured&&t.push(`not compared`),t.join(` · `)||`measured`}var X=e=>!!(e.breaches||e.a11y?.failed||e.perf.over||e.visual?.changed),Z=25;function ee({run:e,standard:t}){let n=e.report,[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)(`all`);if(!n?.accessibility.pages)return(0,B.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`This run has no accessibility results: report.accessibility was off, or the run visited no page.`});let s=n.accessibility,c=n.breaches.filter(e=>e.kind===`accessibility`),l=a===`all`?s.failed:s.failed.filter(e=>e.impact===a),u=[{id:`all`,label:`All`,n:s.failed.length},...V.filter(e=>s.failed.some(t=>t.impact===e)).map(e=>({id:e,label:e.charAt(0).toUpperCase()+e.slice(1),n:s.failed.filter(t=>t.impact===e).length,alert:e===`critical`||e===`serious`}))];return(0,B.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,B.jsxs)(`p`,{className:`m-0 text-[13px] text-muted`,children:[t,` with `,n.engine||`axe`,`: `,q(s.passed.length,`rule`),` passed, `,s.failed.length,` failed, on `,q(s.pages,`page`),`. `,n.budgets.accessibility?c.length?`${q(c.length,`budget`)} exceeded.`:`Within the budget.`:`No budget set, so nothing here fails the run.`]}),c.map((e,t)=>(0,B.jsxs)(`p`,{className:`m-0 rounded-[10px] bg-fail-soft px-3 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:[J(e.page),`: `,e.text]},t)),s.failed.length?(0,B.jsxs)(B.Fragment,{children:[u.length>2&&(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:(0,B.jsx)(P,{items:u,value:a,onChange:o})}),(0,B.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:l.map(t=>(0,B.jsx)(te,{f:t,examples:e.examples[t.rule]??[],open:r===t.rule,onToggle:()=>i(r===t.rule?null:t.rule)},t.rule))})]}):(0,B.jsx)(`p`,{className:`m-0 text-sm text-pass`,children:`No rule failed on the pages this run visited.`})]})}function te({f:e,examples:t,open:n,onToggle:r}){return(0,B.jsxs)(`li`,{className:`border-t border-line-soft first:border-t-0`,children:[(0,B.jsxs)(`button`,{type:`button`,"aria-expanded":n,onClick:r,className:`flex min-h-12 w-full cursor-pointer items-center gap-3 border-0 bg-transparent px-1 py-1.5 text-left text-ink hover:bg-surface-muted`,children:[(0,B.jsx)(j,{tone:H[e.impact],className:`w-[88px] flex-none justify-center`,children:e.impact}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,B.jsx)(`span`,{className:`text-sm [overflow-wrap:anywhere]`,children:e.help}),(0,B.jsxs)(`span`,{className:`truncate text-[12px] text-muted`,children:[e.rule,e.wcag?` · WCAG ${e.wcag}${e.level?` (${e.level})`:``}`:``,` · `,q(e.count,`element`),` on `,q(e.pages,`page`)]})]})]}),(0,B.jsx)(y,{open:n,children:(0,B.jsxs)(`div`,{className:`mb-3 ml-[104px] flex flex-col gap-2 text-sm max-sm:ml-2`,children:[t.length?t.map((e,t)=>(0,B.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-[10px] bg-surface-muted p-2.5`,children:[(0,B.jsxs)(`span`,{className:`text-[12px] text-muted [overflow-wrap:anywhere]`,children:[J(e.page),e.target?` · ${e.target}`:``]}),e.html&&(0,B.jsx)(`code`,{className:`font-mono text-[12px] whitespace-pre-wrap text-ink-2 [overflow-wrap:anywhere]`,children:e.html})]},t)):(0,B.jsx)(`span`,{className:`text-muted`,children:`No elements were kept for this rule.`}),e.helpUrl&&E(e.helpUrl)===`web`&&(0,B.jsxs)(`a`,{href:e.helpUrl,target:`_blank`,rel:`noreferrer noopener`,className:`inline-flex items-center gap-1 self-start text-[13px]`,children:[`How to fix it `,(0,B.jsx)(s,{size:13,"aria-hidden":`true`})]})]})})]})}function ne({run:e}){let t=e.report;if(!t?.performance.pages.length)return(0,B.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`This run has no timings: the run visited no page.`});let n=(e,t)=>e>t.poor?`poor`:e>t.good?`needs improvement`:`good`,r={poor:`text-fail`,"needs improvement":`text-warn`,good:`text-pass`};return(0,B.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,B.jsxs)(`p`,{className:`m-0 text-[13px] text-muted`,children:[`Core Web Vitals per page against Google's thresholds: `,(0,B.jsx)(`span`,{className:`text-pass`,children:`good`}),`, `,(0,B.jsx)(`span`,{className:`text-warn`,children:`needs improvement`}),`, `,(0,B.jsx)(`span`,{className:`text-fail`,children:`poor`}),`.`,` `,t.budgets.performance?`Pages over the budget in quality.budgets.performance are marked.`:`No performance budget set: nothing fails on timings (quality.budgets.performance).`]}),(0,B.jsx)(`div`,{className:`overflow-x-auto`,children:(0,B.jsxs)(`table`,{className:`w-full min-w-[640px] border-collapse text-sm`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{className:`text-left text-[12px] text-muted`,children:[(0,B.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:`Page`}),U.map(e=>(0,B.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:e.label},e.key)),(0,B.jsx)(`th`,{className:`py-2 pl-2 text-right font-medium`,children:`Requests`})]})}),(0,B.jsx)(`tbody`,{children:t.performance.pages.map((e,t)=>(0,B.jsxs)(`tr`,{className:`border-t border-line-soft align-top`,children:[(0,B.jsxs)(`td`,{className:`py-2 pr-3`,children:[(0,B.jsx)(`span`,{className:`block font-mono text-[12px] [overflow-wrap:anywhere]`,children:J(e.url)}),e.over.length>0&&(0,B.jsx)(`span`,{className:`text-[12px] text-fail`,children:e.over.join(`, `)})]}),U.map(t=>{let i=e[t.key];return(0,B.jsxs)(`td`,{className:m(`px-2 py-2 text-right tabular-nums`,typeof i==`number`&&t.good!==1/0?r[n(i,t)]:typeof i==`number`?`text-ink-2`:`text-muted`),children:[typeof i==`number`?K(i,t.unit):`–`,typeof i==`number`&&t.good!==1/0&&(0,B.jsxs)(`span`,{className:`sr-only`,children:[` (`,n(i,t),`)`]})]},t.key)}),(0,B.jsx)(`td`,{className:`py-2 pl-2 text-right text-muted tabular-nums`,children:e.requests?`${e.requests} · ${e.kb} KB`:`–`})]},t))})]})})]})}function Q({run:e,index:t,which:n,label:r}){let[i,a]=(0,z.useState)(``),[o,s]=(0,z.useState)(!1);return(0,z.useEffect)(()=>{let r=!1;return a(``),s(!1),c.image(e,t,n).then(e=>!r&&a(e),()=>!r&&s(!0)),()=>{r=!0}},[e,t,n]),(0,B.jsxs)(`figure`,{className:`m-0 flex min-w-0 flex-col gap-1.5`,children:[(0,B.jsx)(`figcaption`,{className:`text-[12px] font-medium text-muted`,children:r}),i?(0,B.jsx)(`img`,{src:i,alt:`${r} of the page`,className:`block h-auto w-full rounded-[10px] border border-line-soft bg-surface-muted`}):(0,B.jsx)(`span`,{className:`flex h-[120px] items-center justify-center gap-2 rounded-[10px] border border-line-soft bg-surface-muted text-[12px] text-muted`,children:o?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(R,{size:14,"aria-hidden":`true`}),` Not available`]}):`Loading…`})]})}function re({run:e,budget:n,onChange:r}){let[i,o]=(0,z.useState)(null),[s,l]=(0,z.useState)(``),[u,d]=(0,z.useState)(!1),[p,g]=(0,z.useState)(``),[_,b]=(0,z.useState)(null),x=e.visual?.pages??[],S=x.find(e=>e.status===`changed`)?.index??null;(0,z.useEffect)(()=>b(S),[e.id,S]);let C=async e=>{d(!0),g(``);try{r(await e()),o(null),l(``)}catch(e){g(e.message)}finally{d(!1)}};if(!e.visual)return e.captured?(0,B.jsxs)(`div`,{className:`flex flex-col items-start gap-3`,children:[(0,B.jsxs)(`p`,{className:`m-0 text-sm text-ink-2`,children:[`This run captured `,q(e.captured,`page`),` but they were not compared with the baselines yet.`]}),(0,B.jsxs)(h,{variant:`primary`,disabled:u,onClick:()=>C(()=>c.compare(e.id)),children:[(0,B.jsx)(f,{icon:t,size:16}),`Compare with the baselines`]}),p&&(0,B.jsx)(`p`,{className:`m-0 text-sm text-fail`,children:p})]}):(0,B.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`This run has no visual captures: quality.visual.enabled was off, or the run visited no page.`});let w=x.filter(e=>e.status===`changed`);return(0,B.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsxs)(`p`,{className:`m-0 flex-1 text-[13px] text-muted`,children:[`Each page captured with animations frozen and masked regions hidden, against its approved baseline. `,n?`A page over quality.budgets.visual fails the run.`:`No visual budget set: a change does not fail the run (quality.budgets.visual).`]}),w.length>1&&(0,B.jsxs)(h,{disabled:u,onClick:()=>o(w.map(e=>e.url)),children:[`Approve all `,w.length,` changes`]})]}),i&&(0,B.jsxs)(`div`,{role:`alertdialog`,"aria-label":`Approve as baseline`,className:`flex flex-col gap-3 rounded-[12px] border border-accent-line bg-accent-soft p-4`,children:[(0,B.jsxs)(`span`,{className:`font-medium`,children:[`Make this run's capture the baseline of `,i.length===1?J(i[0]):q(i.length,`page`),`?`]}),(0,B.jsx)(`span`,{className:`text-sm text-ink-2`,children:`Later runs are compared with it. Approve only a change that was intended; one that was not is a visual defect.`}),(0,B.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[`Why it changed (kept with the baseline)`,(0,B.jsx)(a,{value:s,maxLength:300,placeholder:`New checkout banner`,onChange:e=>l(e.target.value),className:`max-w-[480px] bg-bg`})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsxs)(h,{variant:`primary`,disabled:u,onClick:()=>C(()=>c.approve(e.id,i,s.trim()||void 0)),children:[(0,B.jsx)(A,{size:16,"aria-hidden":`true`}),`Approve`]}),(0,B.jsx)(h,{onClick:()=>o(null),children:`Cancel`})]})]}),p&&(0,B.jsx)(`p`,{className:`m-0 text-sm text-fail`,children:p}),(0,B.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:x.map(t=>(0,B.jsxs)(`li`,{className:`border-t border-line-soft first:border-t-0`,children:[(0,B.jsxs)(`button`,{type:`button`,"aria-expanded":_===t.index,onClick:()=>b(_===t.index?null:t.index),className:`flex min-h-[52px] w-full cursor-pointer items-center gap-3 border-0 bg-transparent px-1 py-2 text-left text-ink hover:bg-surface-muted`,children:[(0,B.jsx)(f,{icon:v,size:16,className:`flex-none text-muted`}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,B.jsx)(`span`,{className:`text-sm [overflow-wrap:anywhere]`,children:t.title||J(t.url)}),(0,B.jsxs)(`span`,{className:`truncate text-[12px] text-muted`,children:[J(t.url),t.size?` · ${t.size}`:``,t.resized?` · resized ${t.resized}`:``]})]}),t.status===`changed`&&(0,B.jsxs)(`span`,{className:m(`text-sm tabular-nums`,t.over?`text-fail`:`text-warn`),children:[t.diffPercent,`%`,t.limit===void 0?``:` / ${t.limit}%`]}),(0,B.jsx)(j,{tone:t.over?`fail`:W[t.status].tone,children:t.over?`Over budget`:W[t.status].label})]}),(0,B.jsx)(y,{open:_===t.index,children:(0,B.jsxs)(`div`,{className:`mb-4 flex flex-col gap-3 px-1`,children:[(0,B.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(160px,1fr))] gap-3`,children:[t.images.baseline&&(0,B.jsx)(Q,{run:e.id,index:t.index,which:`baseline`,label:`Baseline`}),t.images.current&&(0,B.jsx)(Q,{run:e.id,index:t.index,which:`current`,label:`This run`}),t.images.diff&&(0,B.jsx)(Q,{run:e.id,index:t.index,which:`diff`,label:`Difference (in red)`})]}),t.status===`changed`&&(0,B.jsxs)(h,{className:`self-start`,disabled:u,onClick:()=>o([t.url]),children:[(0,B.jsx)(A,{size:16,"aria-hidden":`true`}),`Approve as the new baseline`]})]})})]},t.index))})]})}function ie({values:e}){if(e.length<2)return null;let t=Math.max(1,...e),n=e.map((n,r)=>`${r/(e.length-1)*96+2},${22-n/t*20}`).join(` `);return(0,B.jsx)(`svg`,{width:`100`,height:`24`,viewBox:`0 0 100 24`,"aria-label":`Violations over the last ${e.length} runs: ${e.join(`, `)}`,role:`img`,className:`flex-none text-muted`,children:(0,B.jsx)(`polyline`,{points:n,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinejoin:`round`})})}function $({icon:e,className:t,lines:n}){return n.length?(0,B.jsxs)(`span`,{className:m(`flex items-start gap-1.5 text-[13px]`,t),children:[(0,B.jsx)(f,{icon:e,size:14,className:`mt-0.5 flex-none`}),(0,B.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:n.join(` · `)})]}):null}function ae({trends:e}){return e.length?(0,B.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:e.map(e=>{let t=e.a11y.latest?V.reduce((t,n)=>t+(e.a11y.latest[n]||0),0):void 0;return(0,B.jsxs)(`li`,{className:`flex flex-col gap-1.5 border-t border-line-soft py-3 first:border-t-0`,children:[(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-3`,children:[(0,B.jsx)(`span`,{className:`min-w-0 flex-[1_1_240px] font-mono text-[13px] [overflow-wrap:anywhere]`,children:e.page}),(0,B.jsx)(ie,{values:e.a11y.trail}),(0,B.jsxs)(`span`,{className:`text-[12px] text-muted`,children:[q(e.runs,`run`),t===void 0?``:` · ${q(t,`violation`)} now`]})]}),(0,B.jsx)($,{icon:k,className:`text-fail`,lines:[...e.perf.worse.map(e=>`slower: ${e}`),...e.a11y.newRules.map(e=>`newly failing: ${e}`)]}),(0,B.jsx)($,{icon:O,className:`text-pass`,lines:[...e.perf.better.map(e=>`faster: ${e}`),...e.a11y.fixedRules.map(e=>`fixed: ${e}`)]})]},e.page)})}):(0,B.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`No history yet: every browser run adds each page's accessibility and timings to quality-history.json in the reports folder.`})}function oe({id:t,view:n,onChanged:i}){let[a,o]=(0,z.useState)(null),[s,u]=(0,z.useState)(``),[p,y]=(0,z.useState)(`accessibility`),[b,x]=(0,z.useState)(``);if((0,z.useEffect)(()=>{let e=!1;return o(null),c.run(t).then(t=>{if(e)return;o(t),u(``);let n=t.visual?.pages.some(e=>e.status===`changed`)||!t.visual&&t.captured;y(t.report?.breaches.some(e=>e.kind===`performance`)&&!t.report.accessibility.failed.length?`performance`:n&&!t.report?.accessibility.failed.length?`visual`:t.report?.accessibility.pages?`accessibility`:t.report?.performance.pages.length?`performance`:`visual`)},t=>!e&&u(t.message)),()=>{e=!0}},[t]),s)return(0,B.jsx)(`p`,{className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail`,children:s});if(!a)return(0,B.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Loading…`});let S=async()=>{try{let{id:e}=await g.start(`Explain the accessibility, performance and visual results of the run in ${a.dir}: call quality_report and visual_compare with run_dir ${a.dir}. Say what matters most to fix first, and why.`,{});location.hash=d(`chats`,e)}catch(e){x(e.message)}},w=a.report,E=w?.accessibility.failed??[],O=V.find(e=>E.some(t=>t.impact===e)),k=w?.performance.pages.filter(e=>e.over.length).length??0,j=a.visual?.pages.filter(e=>e.status===`changed`).length??0,M=e=>!!w?.breaches.some(t=>t.kind===e),N=[{id:`accessibility`,label:`Accessibility`,icon:_,state:w?.accessibility.pages?M(`accessibility`)||O===`critical`?`fail`:E.length?`warn`:`pass`:`none`,headline:w?.accessibility.pages?E.length?`${q(E.length,`rule`)} failed`:`No rule failed`:`Not measured`,note:w?.accessibility.pages?V.filter(e=>w.accessibility.byImpact[e]).map(e=>`${w.accessibility.byImpact[e]} ${e}`).join(` · `)||`${q(w.accessibility.pages,`page`)} checked`:``},{id:`performance`,label:`Performance`,icon:C,state:w?.performance.pages.length?M(`performance`)?`fail`:k?`warn`:`pass`:`none`,headline:w?.performance.pages.length?k?`${q(k,`page`)} over budget`:`Within budget`:`Not measured`,note:w?.performance.pages.length?`${q(w.performance.pages.length,`page`)} timed`:``},{id:`visual`,label:`Visual`,icon:v,state:a.visual?M(`visual`)?`fail`:j?`warn`:`pass`:`none`,headline:a.visual?j?`${q(j,`page`)} changed`:`No change`:a.captured?`Not compared yet`:`Not captured`,note:a.visual?`${q(a.visual.pages.length,`page`)} against the baseline`:a.captured?`${q(a.captured,`page`)} captured`:``}],P={pass:A,warn:r,fail:l,none:T},F={pass:`text-pass`,warn:`text-warn`,fail:`text-fail`,none:`text-muted`};return(0,B.jsxs)(`section`,{"aria-labelledby":`run-h`,className:`flex min-w-0 flex-1 flex-col gap-4`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-[1_1_260px] flex-col gap-1`,children:[(0,B.jsx)(`h2`,{id:`run-h`,title:a.goal,className:`m-0 line-clamp-2 text-[20px] leading-snug font-semibold tracking-[-0.01em] [overflow-wrap:anywhere]`,children:a.goal}),(0,B.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 text-[13px] text-muted`,children:[G(a.at),` · `,(0,B.jsx)(D,{path:a.dir})]})]}),(0,B.jsxs)(h,{size:`sm`,variant:`ghost`,onClick:()=>void S(),children:[(0,B.jsx)(f,{icon:e,size:15}),`Ask in a chat`]})]}),b&&(0,B.jsx)(`p`,{className:`m-0 text-sm text-fail`,children:b}),(0,B.jsx)(`div`,{role:`tablist`,"aria-label":`Results`,className:`grid gap-2 @xl:grid-cols-3`,children:N.map(e=>{let t=P[e.state];return(0,B.jsxs)(`button`,{type:`button`,role:`tab`,id:`tab-${e.id}`,"aria-selected":p===e.id,"aria-controls":`panel-${e.id}`,onClick:()=>y(e.id),className:m(`flex min-w-0 cursor-pointer flex-col gap-1 rounded-[14px] border px-4 py-3 text-left`,p===e.id?`border-accent bg-accent-soft`:`border-line-soft bg-bg hover:bg-surface-muted`),children:[(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[13px] text-muted`,children:[(0,B.jsx)(f,{icon:e.icon,size:14}),e.label]}),(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[16px] font-semibold text-ink`,children:[(0,B.jsx)(t,{size:16,"aria-hidden":`true`,className:m(`flex-none`,F[e.state])}),e.headline]}),e.note&&(0,B.jsx)(`span`,{className:`truncate text-[12.5px] text-muted`,children:e.note})]},e.id)})}),(0,B.jsxs)(`div`,{role:`tabpanel`,id:`panel-${p}`,"aria-labelledby":`tab-${p}`,className:`flex min-w-0 flex-col`,children:[p===`accessibility`&&(0,B.jsx)(ee,{run:a,standard:n.standard}),p===`performance`&&(0,B.jsx)(ne,{run:a}),p===`visual`&&(0,B.jsx)(re,{run:a,budget:n.budgets.visual,onChange:e=>{o(e),i()}})]}),p===`accessibility`&&a.report?.accessibility.pages?(0,B.jsx)(`p`,{className:`m-0 text-[12px] text-muted`,children:n.disclaimer}):null]})}function se({sub:e}){let[t,i]=(0,z.useState)(null),[a,o]=(0,z.useState)(``),[s,p]=(0,z.useState)(e===`trends`?`trends`:`runs`),h=(0,z.useCallback)(()=>{c.view().then(e=>{i(e),o(``)},e=>o(e.message))},[]);(0,z.useEffect)(h,[h]);let g=e&&e!==`trends`?decodeURIComponent(e):``;(0,z.useEffect)(()=>{e===`trends`?p(`trends`):e&&p(`runs`)},[e]);let v=(0,z.useMemo)(()=>t?.runs.find(e=>e.id===g)||t?.runs[0],[t,g]),y=t?.trends.filter(e=>e.perf.worse.length||e.a11y.newRules.length).length??0,[C,w]=(0,z.useState)(``),[T,E]=(0,z.useState)(`all`),[D,O]=(0,z.useState)(0);(0,z.useEffect)(()=>O(0),[C,T]);let k=C.toLowerCase().split(/\s+/).filter(Boolean),j=(t?.runs??[]).filter(e=>k.every(t=>e.goal.toLowerCase().includes(t))),L=T===`attention`?j.filter(X):j;return(0,B.jsxs)(`div`,{className:`flex min-h-screen flex-col`,children:[(0,B.jsx)(b,{}),(0,B.jsxs)(`main`,{className:m(x,`@container flex-auto gap-4`),children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,B.jsx)(S,{pixel:u.quality,size:`lg`}),(0,B.jsx)(`h1`,{className:`m-0 flex-1 text-[26px] font-semibold tracking-[-0.01em]`,children:`Quality`})]}),(0,B.jsxs)(`p`,{className:`m-0 max-w-[74ch] text-sm leading-relaxed text-muted`,children:[`What each browser run measured on the pages it visited: accessibility (`,t?.standard||`WCAG`,`), Core Web Vitals, and visual changes against approved baselines. Budgets (quality.budgets) decide what fails a run.`]}),a&&(0,B.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:a}),!t&&!a&&(0,B.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}),t&&(0,B.jsx)(n,{label:`Quality`,current:s,onPick:e=>{p(e),e===`trends`?location.hash=d(`quality`,`trends`):location.hash=v?d(`quality`,encodeURIComponent(v.id)):d(`quality`)},tabs:[{id:`runs`,label:`Runs (${t.runs.length})`},{id:`trends`,label:`Trends${y?` (${y} worse)`:``}`}]}),t&&s===`trends`&&(0,B.jsx)(`div`,{role:`tabpanel`,id:`panel-trends`,"aria-labelledby":`tab-trends`,children:(0,B.jsx)(ae,{trends:t.trends})}),t&&s===`runs`&&(t.runs.length?(0,B.jsxs)(`div`,{role:`tabpanel`,id:`panel-runs`,"aria-labelledby":`tab-runs`,className:`flex flex-col gap-6 @2xl:flex-row @2xl:items-start @2xl:gap-8`,children:[(0,B.jsxs)(`nav`,{"aria-label":`Runs`,className:`flex min-w-0 flex-col gap-2 @2xl:sticky @2xl:top-6 @2xl:w-[290px] @2xl:flex-none`,children:[(0,B.jsx)(N,{id:`quality-search`,label:`Find a run`,value:C,onChange:w,className:`flex-none`}),(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:(0,B.jsx)(P,{items:[{id:`all`,label:`All`,n:j.length},{id:`attention`,label:`Needs a look`,n:j.filter(X).length,alert:!0}],value:T,onChange:E})}),(0,B.jsxs)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:[L.length===0&&(0,B.jsx)(`li`,{className:`px-3 py-3 text-sm text-muted`,children:`Nothing matches.`}),L.slice(D*Z,D*Z+Z).map((e,t,n)=>{let i=F(e.at),a=e.breaches?l:X(e)?r:A;return(0,B.jsxs)(`li`,{className:`contents`,children:[(t===0||F(n[t-1].at)!==i)&&(0,B.jsx)(`span`,{className:`block px-3 pt-2 pb-1 text-[12px] font-semibold text-muted`,children:i}),(0,B.jsxs)(`a`,{href:d(`quality`,encodeURIComponent(e.id)),"aria-current":v?.id===e.id?`page`:void 0,className:m(`flex min-h-12 items-center gap-2.5 rounded-[10px] px-3 py-1.5 text-ink no-underline`,v?.id===e.id?`bg-surface-strong hover:text-ink`:`hover:bg-surface-muted hover:text-ink`),children:[(0,B.jsx)(a,{size:16,"aria-label":e.breaches?`Over a budget`:X(e)?`Needs a look`:`Within budgets`,className:m(`flex-none`,e.breaches?`text-fail`:X(e)?`text-warn`:`text-pass`)}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,B.jsx)(`span`,{className:`truncate text-[14px] font-medium`,title:e.goal,children:e.goal}),(0,B.jsx)(`span`,{className:`truncate text-[12px] text-muted`,children:Y(e)})]}),(0,B.jsx)(`span`,{className:`flex-none text-[12px] text-muted tabular-nums`,children:I(e.at)})]})]},e.id)})]}),L.length>Z&&(0,B.jsx)(M,{page:D,size:Z,total:L.length,onPage:O,label:`Pages of runs`})]}),v&&(0,B.jsx)(oe,{id:v.id,view:t,onChanged:h})]}):(0,B.jsxs)(`div`,{className:`flex flex-col items-start gap-3 rounded-[18px] border border-line p-6`,children:[(0,B.jsx)(f,{icon:_,size:24,className:`text-muted`}),(0,B.jsx)(`p`,{className:`m-0 max-w-[62ch] leading-relaxed text-ink-2`,children:`No run has measured anything yet. Every browser run checks accessibility, timings and visual changes of the pages it visits; run a flow from a chat or the Record page, and its results show here.`})]}))]})]})}export{se as Quality};