@wjarka/cezarion 0.14.9-dev.842 → 0.14.9-dev.884
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/core/claude-cli-runner.js +1 -1
- package/dist/core/claude-cli-runner.js.map +1 -1
- package/dist/core/cursor-acp-runner.d.ts +2 -0
- package/dist/core/cursor-acp-runner.js +116 -26
- package/dist/core/cursor-acp-runner.js.map +1 -1
- package/dist/core/cursor-provider-error.d.ts +3 -0
- package/dist/core/cursor-provider-error.js +13 -3
- package/dist/core/cursor-provider-error.js.map +1 -1
- package/dist/core/opencode-server-runner.js +12 -5
- package/dist/core/opencode-server-runner.js.map +1 -1
- package/dist/core/pi-runner.js +17 -4
- package/dist/core/pi-runner.js.map +1 -1
- package/dist/delegation/results.js +10 -6
- package/dist/delegation/results.js.map +1 -1
- package/dist/delegation/transport.d.ts +50 -50
- package/dist/git-worktree.d.ts +3 -1
- package/dist/git-worktree.js +26 -4
- package/dist/git-worktree.js.map +1 -1
- package/dist/runs/retention.d.ts +7 -2
- package/dist/runs/retention.js +39 -7
- package/dist/runs/retention.js.map +1 -1
- package/dist/runs/store.js +1 -1
- package/dist/runs/store.js.map +1 -1
- package/dist/server/server.js +5 -2
- package/dist/server/server.js.map +1 -1
- package/dist/task-cli/cli.js +36 -2
- package/dist/task-cli/cli.js.map +1 -1
- package/dist/workflows/run.d.ts +8 -0
- package/dist/workflows/run.js +80 -13
- package/dist/workflows/run.js.map +1 -1
- package/package.json +3 -3
- package/scripts/mock-cursor-acp.mjs +17 -3
- package/scripts/mock-cursor-hang-stdin.mjs +16 -0
- package/scripts/mock-pi-rpc.mjs +15 -4
- package/web/dist/assets/{agent-accounts-JPfZPgKn.js → agent-accounts-tNk0wiKj.js} +1 -1
- package/web/dist/assets/centered-state-DXxIJA15.js +43 -0
- package/web/dist/assets/{collapsible-CTymFdL7.js → collapsible-D3Lh_nlG.js} +1 -1
- package/web/dist/assets/{commit-list-BZpYGQl2.js → commit-list-CgoIXaVd.js} +1 -1
- package/web/dist/assets/{compare-variants-9VkybaQ7.js → compare-variants-2AnPP6ez.js} +1 -1
- package/web/dist/assets/{diff-controls-CpcHG3Mm.js → diff-controls-BCazakYu.js} +1 -1
- package/web/dist/assets/{dropdown-menu-_YAzCaoQ.js → dropdown-menu-CyFz8H2A.js} +1 -1
- package/web/dist/assets/{git-toolbar-BvKDz6uS.js → git-toolbar-DT4Q02mZ.js} +1 -1
- package/web/dist/assets/{github-CgjJCGrD.js → github-vwoJvCTz.js} +1 -1
- package/web/dist/assets/{index-BJtve0Pm.js → index-1YNk4P3I.js} +4 -4
- package/web/dist/assets/{markdown-CFWZnvMh.js → markdown-0VE-LMFx.js} +1 -1
- package/web/dist/assets/{pill-QfwkuR50.js → pill-BU5y1CTd.js} +1 -1
- package/web/dist/assets/{project-router-CkAA39N5.js → project-router-EEnXzYjj.js} +1 -1
- package/web/dist/assets/{prompt-templates-Cfna_S0T.js → prompt-templates-D8lCwJds.js} +1 -1
- package/web/dist/assets/{repo-git-DgzgJ0cP.js → repo-git-CYDGngEk.js} +1 -1
- package/web/dist/assets/{run-diff-YbCEQn5I.js → run-diff-C-Ij6Y04.js} +1 -1
- package/web/dist/assets/{run-header-DMgIbr1d.js → run-header-DYiqx0qE.js} +1 -1
- package/web/dist/assets/{skills-BW79kUTd.js → skills-CH6TkMy9.js} +1 -1
- package/web/dist/assets/{tab-link-MIHvczEm.js → tab-link-CQc65wEy.js} +1 -1
- package/web/dist/assets/{task-changes-C96ekt94.js → task-changes-CEi-l2GZ.js} +1 -1
- package/web/dist/assets/{task-commits-DBfcMZyG.js → task-commits-BYdWmsx1.js} +1 -1
- package/web/dist/assets/{task-files-BKpH8dKQ.js → task-files-DHUEF1Fh.js} +1 -1
- package/web/dist/assets/{task-thread-Dnq7Ek6W.js → task-thread-DAxvkDvr.js} +2 -2
- package/web/dist/assets/{textarea-D2vAVgYW.js → textarea-BOXhPgVD.js} +1 -1
- package/web/dist/assets/{thread-loading-NW8Mthco.js → thread-loading-D9dDLmql.js} +1 -1
- package/web/dist/assets/{token-metrics-D188e6_0.js → token-metrics-DJeOZ5n-.js} +1 -1
- package/web/dist/assets/{workflows-BFY1hgp3.js → workflows-CpHaJbUe.js} +1 -1
- package/web/dist/index.html +11 -11
- package/web/dist/assets/centered-state-HwCqQkH3.js +0 -43
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Ba as r,Bn as i,Ci as a,Cr as o,Fa as s,Gt as c,It as l,Lt as u,Pa as d,Q as f,Rt as p,Tr as m,U as h,Ut as g,Wt as _,Yt as v,_i as y,aa as b,d as x,ga as S,gr as C,hr as w,in as T,jt as E,kn as D,li as O,nn as k,oi as A,ot as j,ra as M,t as N,xr as P}from"./centered-state-HwCqQkH3.js";import{t as F}from"./utils-DKheTxGD.js";import{a as I,i as ee,n as te,o as ne,r as re,s as ie}from"./textarea-D2vAVgYW.js";import{T as ae}from"./prompt-templates-Cfna_S0T.js";import{c as oe,t as L}from"./project-router-CkAA39N5.js";import{i as R,l as z,n as B,o as V,p as H}from"./skills-DFBiAuJG.js";import{c as U,h as W,o as G,t as K}from"./index-BJtve0Pm.js";import{t as se}from"./skill-empty-hint-oOtzR3v0.js";var q=e(t(),1),J=n(),ce=`https://github.com/open-mercato/skills`;function le(e){let t=e?.importedSkills;if(Array.isArray(t))return t.filter(e=>typeof e==`string`&&!!e)}function Y(e,t){return le(e)??[...t]}function X({projectId:e}){let t=r(),n=o(),i=D(),[a,s]=(0,q.useState)(``),u=C(e,!!e),d=i.data??[],f=(0,q.useMemo)(()=>d.map(e=>e.name),[d]),h=(0,q.useRef)([]);h.current=f;let g=(0,q.useMemo)(()=>new Set(Y(n.data,f)),[n.data,f]),y=(0,q.useRef)(Promise.resolve()),b=(0,q.useRef)(0),x=(0,q.useCallback)(e=>{let n=m.uiState,r=t.getQueryData(n),i=e(Y(r,h.current));t.setQueryData(n,{...r,importedSkills:i});let a=++b.current;y.current=y.current.then(async()=>{try{let e=await M({importedSkills:i});a===b.current&&(t.setQueryData(n,e),t.invalidateQueries({queryKey:T.skills}))}catch(e){S(e instanceof Error?e.message:String(e),{tone:`danger`}),a===b.current&&t.invalidateQueries({queryKey:n})}})},[t]),w=(0,q.useCallback)(e=>{x(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[x]),O=f.length>0&&f.every(e=>g.has(e)),k=(0,q.useCallback)(()=>{if(O){let e=new Set(h.current);x(t=>t.filter(t=>!e.has(t)))}else x(e=>[...new Set([...e,...h.current])])},[O,x]);if(i.isError)return(0,J.jsx)(N,{icon:(0,J.jsx)(v,{}),tone:`danger`,heading:`h2`,title:`Could not load importable skills`,subtitle:i.error.message});let A=z(d,a);return(0,J.jsxs)(`div`,{"data-slot":`skills-import-panel`,className:`w-full min-w-0 [&_button]:min-h-11`,children:[(0,J.jsx)(`p`,{className:`mb-4 text-[12px] font-medium tracking-wide text-link-foreground`,children:`OPEN-MERCATO / SKILLS`}),(0,J.jsx)(`h2`,{className:`text-2xl font-medium`,children:`Manage skills`}),(0,J.jsxs)(`p`,{className:`mt-2 text-[13px] leading-relaxed text-muted-foreground`,children:[`Choose which `,(0,J.jsx)(`a`,{href:ce,target:`_blank`,rel:`noreferrer`,children:`open-mercato`}),` skills appear in your catalog and composer picker. All are enabled by default; uncheck any you don’t want.`]}),(0,J.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`Applies across projects · saved automatically`}),(0,J.jsx)(ue,{projectId:e,state:u.data,loadError:u.error}),(0,J.jsx)(`p`,{className:`mt-4 text-xs text-soft-foreground`,children:`Checkboxes control visibility. Updating refreshes installed skill files; it does not change your selection.`}),(0,J.jsxs)(`div`,{className:`sw-import-controls mt-4 flex flex-wrap items-center gap-2`,children:[(0,J.jsxs)(`div`,{className:`sw-search relative min-w-0 flex-1`,children:[(0,J.jsx)(p,{"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,J.jsx)(W,{"data-slot":`import-filter`,placeholder:`Filter skills…`,"aria-label":`Filter skills`,value:a,onChange:e=>s(e.target.value),className:`h-11 min-w-0 pl-9 text-xs`})]}),(0,J.jsxs)(`button`,{type:`button`,"data-slot":`import-all`,disabled:f.length===0||n.isPending,onClick:k,className:`h-11 shrink-0 rounded-md border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-55`,children:[O?(0,J.jsx)(E,{"aria-hidden":`true`,className:`size-4`}):(0,J.jsx)(l,{"aria-hidden":`true`,className:`size-4`}),O?`Remove all`:`Enable all`]})]}),(0,J.jsx)(`div`,{"data-slot":`import-list`,className:`mt-3 flex flex-col gap-1.5`,children:i.isPending?(0,J.jsx)(`p`,{className:`px-1 py-2 text-[13px] text-soft-foreground`,children:`Loading…`}):A.length>0?A.map(e=>{let t=g.has(e.name);return(0,J.jsxs)(`label`,{"data-slot":`import-row`,"data-skill":e.name,"data-imported":t?`true`:void 0,className:F(`flex min-h-16 cursor-pointer items-start gap-3 rounded-lg border border-border p-4 transition-colors hover:bg-muted`,t&&`bg-background`),children:[(0,J.jsxs)(`span`,{className:`relative size-5 shrink-0`,children:[(0,J.jsx)(`input`,{type:`checkbox`,"data-slot":`import-toggle`,checked:t,onChange:()=>w(e.name),className:`peer absolute inset-0 m-0 size-5 opacity-0`}),t?(0,J.jsx)(_,{"aria-hidden":`true`,className:`pointer-events-none size-5 text-link-foreground peer-focus-visible:outline-2 peer-focus-visible:outline-ring`}):(0,J.jsx)(c,{"aria-hidden":`true`,className:`pointer-events-none size-5 text-link-foreground peer-focus-visible:outline-2 peer-focus-visible:outline-ring`})]}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`span`,{className:`flex min-w-0 items-center gap-2`,children:(0,J.jsx)(`span`,{className:`min-w-0 break-words text-[13px] font-medium text-foreground`,children:e.name})}),e.description?(0,J.jsx)(`span`,{className:`mt-2 block text-xs leading-relaxed text-soft-foreground`,children:e.description}):null]})]},e.name)}):(0,J.jsx)(`p`,{className:`px-1 py-2 text-xs text-soft-foreground`,children:d.length>0?`(no skills match)`:`(no skills available — the repo may still be cloning)`})})]})}function Z(e){return e===`project`?`Project installation`:`Global installation`}function ue({projectId:e,state:t,loadError:n}){let i=r(),o=oe(),c=(0,q.useRef)(0),[l,d]=(0,q.useState)(!1),p=s({mutationFn:()=>a({task:`Apply the upgrade notes after updating the installed Open Mercato skills.`,steps:[{id:`apply-upgrade-notes`,name:`Apply upgrade notes`,skill:`om-apply-upgrade-notes`,prompt:`{{task}}`}]}),onSuccess:e=>{d(!1),o(ae(e))},onError:e=>S(e.message,{tone:`danger`})}),h=(t,n)=>{n.seq===c.current&&(i.setQueryData(m.skillsUpdate(e),t),n.action===`apply`&&t.updatedAt&&t.updatedAt!==n.previousUpdatedAt&&(i.invalidateQueries({queryKey:T.skills}),S(t.status===`error`?`Some skill updates failed.`:`Open Mercato skills updated.`),d(!0)))},g=(e,t)=>{t.seq===c.current&&S(e.message,{tone:`danger`})},_=s({mutationFn:t=>y(e).then(e=>({result:e,request:t})),onSuccess:({result:e,request:t})=>h(e,t),onError:(e,t)=>g(e,t)}),v=s({mutationFn:t=>O(e).then(e=>({result:e,request:t})),onSuccess:({result:e,request:t})=>h(e,t),onError:(e,t)=>g(e,t)}),b=e=>{let n=++c.current;e===`apply`?v.mutate({action:e,seq:n,previousUpdatedAt:t?.updatedAt??null}):_.mutate({action:e,seq:n})},C=t?.scopes.some(e=>e.skills.length>0)??!1,w=t?.status===`error`,E=C&&(t?.available||w),D=v.isPending||t?.status===`updating`,k=t?.scopes.filter(e=>e.status===`error`||e.status===`unavailable`)??[],A=t?.scopes.filter(e=>e.updatedAt&&!k.includes(e))??[],j=`Checking installed Open Mercato skills…`;return n?j=`Update status is unavailable right now.`:t?.status===`available`?j=`An update is available for your installed Open Mercato skills.`:t?.status===`updating`?j=`Updating installed Open Mercato skills…`:t?.status===`current`?j=`Installed Open Mercato skills are up to date.`:t?.status===`unavailable`?j=t.scopes.find(e=>e.reason)?.reason??`Automatic updates are unavailable.`:t?.status===`error`&&(j=`The update did not finish for every installation.`),(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`section`,{"data-slot":`skills-update-card`,"aria-live":`polite`,className:`mt-4 rounded-lg border border-border bg-background p-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col items-start gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`p`,{className:`text-[13px] font-medium text-foreground`,children:j}),(0,J.jsx)(`p`,{className:`mt-4 text-xs text-soft-foreground`,children:`Project and global installations are checked separately.`}),t?.checkedAt?(0,J.jsxs)(`p`,{className:`mt-1 text-xs text-soft-foreground`,children:[`Last checked `,new Date(t.checkedAt).toLocaleString(),`.`]}):null,t?.scopes.some(e=>e.skills.length>0)?(0,J.jsx)(`ul`,{className:`mt-1 text-xs text-soft-foreground`,children:t.scopes.filter(e=>e.skills.length>0).map(e=>(0,J.jsxs)(`li`,{children:[Z(e.scope),` · `,e.skills.length,` tracked`]},e.scope))}):null,k.length>0?(0,J.jsxs)(`p`,{className:`mt-1 text-xs text-destructive`,children:[`Failed: `,k.map(e=>Z(e.scope)).join(`, `),A.length?`; updated: ${A.map(e=>Z(e.scope)).join(`, `)}`:``,`.`]}):null]}),E?(0,J.jsxs)(x,{"data-action":`skills-update-apply`,size:`sm`,disabled:D,onClick:()=>b(`apply`),children:[(0,J.jsx)(u,{"aria-hidden":`true`,className:F(`size-3.5`,D&&`motion-safe:animate-spin`)}),D?`Updating…`:w?`Retry`:`Update now`]}):t?.status===`current`?(0,J.jsxs)(x,{"data-action":`skills-update-check`,variant:`outline`,size:`sm`,disabled:_.isPending,onClick:()=>b(`check`),children:[(0,J.jsx)(u,{"aria-hidden":`true`,className:`size-4`}),`Check again`]}):t?.status===`unavailable`||n?(0,J.jsx)(x,{"data-action":`skills-update-check`,variant:`outline`,size:`sm`,disabled:_.isPending,onClick:()=>b(`check`),children:`Retry check`}):null]}),t?.status===`unavailable`||n?(0,J.jsxs)(`div`,{className:`mt-2 text-xs text-soft-foreground`,children:[`Manual examples: `,(0,J.jsx)(`code`,{children:`npx skills update -p`}),` · `,(0,J.jsx)(`code`,{children:`npx skills update -g`}),`. These broad commands may update other tracked sources.`]}):null,t?.needsUpgradeNotes?(0,J.jsxs)(`div`,{"data-slot":`skills-upgrade-notes`,className:`mt-3 flex gap-2 rounded-md border border-accent-strong/30 bg-background p-2.5 text-xs text-foreground`,children:[(0,J.jsx)(f,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-link-foreground`}),(0,J.jsxs)(`span`,{children:[`Skill files were updated. Run `,(0,J.jsx)(`code`,{children:`/om-apply-upgrade-notes`}),` in each configured repository to apply descriptor migrations while preserving local edits.`]})]}):null]}),(0,J.jsx)(te,{open:l,onOpenChange:e=>p.isPending?void 0:d(e),children:(0,J.jsxs)(re,{"data-slot":`skills-upgrade-notes-dialog`,showCloseButton:!1,children:[(0,J.jsxs)(ne,{children:[(0,J.jsx)(ie,{children:`Apply the upgrade notes now?`}),(0,J.jsxs)(ee,{children:[`The skill files were updated successfully. Start a new session with`,` `,(0,J.jsx)(`code`,{children:`/om-apply-upgrade-notes`}),` to sync repository descriptors while preserving local edits?`]})]}),(0,J.jsxs)(I,{children:[(0,J.jsx)(x,{type:`button`,variant:`outline`,disabled:p.isPending,onClick:()=>d(!1),children:`No`}),(0,J.jsx)(x,{type:`button`,disabled:p.isPending,onClick:()=>p.mutate(),children:p.isPending?`Starting…`:`Yes, start session`})]})]})})]})}var Q=`__bm`,$=`__import`;function de(){return(0,J.jsx)(`div`,{"data-route":`skills`,className:`mx-auto min-h-full w-full px-[18px] py-6 md:p-9`,children:(0,J.jsx)(fe,{})})}function fe(){let e=w(),t=P(),n=D(),[a]=d(),[o,c]=(0,q.useState)(``),l=r(),f=i(),m=A().projectId??f.data?.bootProject??``,_=s({mutationFn:()=>b(),onSuccess:e=>{l.setQueryData(T.skills,e),S(`Team skills refreshed.`)},onError:e=>S(e.message,{tone:`danger`})});if(e.isError)return(0,J.jsx)(N,{icon:(0,J.jsx)(v,{}),tone:`danger`,heading:`h2`,title:`Could not load skills`,subtitle:e.error.message});let y=V(e.data??[]),x=(n.data?.length??0)>0,C=a.get(`skill`),E=C===Q||C===$||C!==null&&y.some(e=>e.name===C)?C:y[0]?.name??(x?$:Q),O=y.find(e=>e.name===E)??null,M=B(y,o);return(0,J.jsxs)(`div`,{"data-slot":`skills-section`,className:`@container flex min-w-0 flex-col gap-[22px]`,children:[(0,J.jsxs)(`header`,{className:`flex flex-col gap-4 @min-[700px]:flex-row @min-[700px]:items-center @min-[700px]:justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h1`,{className:`text-[25px] font-semibold md:text-[30px]`,children:`Skills`}),(0,J.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground md:text-[13px]`,children:`Markdown playbooks your agents can follow.`})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[x?(0,J.jsxs)(L,{to:`/skills?skill=${$}`,"data-slot":`import-skills-row`,"aria-current":E===$?`page`:void 0,className:`inline-flex min-h-11 items-center gap-2 rounded-lg border border-border bg-card px-3 text-xs font-medium aria-[current=page]:bg-accent-strong/10 hover:bg-muted focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,J.jsx)(j,{"aria-hidden":`true`,className:`size-4 text-link-foreground`}),`Manage skills`]}):null,(0,J.jsxs)(L,{to:`/skills?skill=${Q}`,"data-slot":`bookmarklets-row`,"aria-current":E===Q?`page`:void 0,className:`inline-flex min-h-11 items-center gap-2 rounded-lg border border-border bg-card px-3 text-xs font-medium aria-[current=page]:bg-accent-strong/10 hover:bg-muted focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,J.jsx)(k,{"aria-hidden":`true`,className:`size-4 text-link-foreground`}),`Run from GitHub`]})]})]}),(0,J.jsxs)(`div`,{className:F(`flex-col items-start gap-2 sm:flex-row sm:items-center md:flex`,C===null?`flex`:`hidden`),children:[(0,J.jsxs)(`div`,{className:`sw-search relative w-full min-w-0 flex-1`,children:[(0,J.jsx)(p,{"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,J.jsx)(W,{"data-slot":`skills-filter`,placeholder:`Filter skills…`,"aria-label":`Filter skills`,value:o,onChange:e=>c(e.target.value),className:`h-11 min-w-0 bg-card pl-9 text-xs`})]}),(0,J.jsxs)(`button`,{type:`button`,"data-slot":`skills-refresh`,title:`git fetch the team skills repos`,disabled:_.isPending,onClick:()=>_.mutate(),className:`flex h-11 shrink-0 items-center gap-1.5 rounded-md border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-55`,children:[(0,J.jsx)(u,{"aria-hidden":`true`,className:F(`size-3`,_.isPending&&`motion-safe:animate-spin`)}),`Refresh`]})]}),(0,J.jsxs)(`div`,{className:`grid min-w-0 items-start gap-[22px] md:grid-cols-[minmax(220px,310px)_minmax(0,1fr)]`,children:[(0,J.jsx)(`section`,{"data-slot":`skills-list`,className:F(`min-w-0 flex-col rounded-xl border border-border bg-card p-3 md:flex`,C===null?`flex`:`hidden`),children:(0,J.jsx)(`ul`,{"data-slot":`skill-rows`,className:`flex min-h-0 flex-col gap-1 overflow-y-auto md:max-h-[calc(100dvh-280px)]`,children:e.isPending?(0,J.jsx)(`li`,{role:`status`,"aria-busy":`true`,className:`min-h-72 p-3 text-[13px] text-soft-foreground`,children:`Loading skills…`}):M.length>0?M.map(e=>(0,J.jsx)(pe,{skill:e,active:E===e.name,highlighted:E===$&&e===y[0]},e.path)):(0,J.jsx)(`li`,{className:`px-2.5 py-2 text-xs leading-relaxed text-soft-foreground`,children:y.length>0?`(no skills match)`:(0,J.jsx)(se,{})})})}),(0,J.jsx)(`section`,{"data-slot":`skills-detail`,className:F(`min-w-0 flex-col rounded-xl border border-border bg-card md:flex`,C===null?`hidden`:`flex`),children:(0,J.jsxs)(`div`,{className:`min-w-0 p-5`,children:[(0,J.jsxs)(L,{to:`/skills`,"data-slot":`skills-back`,className:`mb-4 inline-flex min-h-11 items-center gap-2 rounded-lg border border-border px-3 text-xs font-medium hover:bg-muted md:hidden`,children:[(0,J.jsx)(h,{"aria-hidden":`true`,className:`size-3.5`}),`Back to skills`]}),E===$?(0,J.jsx)(X,{projectId:m}):E===Q?(0,J.jsx)(K,{skills:y}):O?(0,J.jsx)(G,{skill:O,usedBy:H(t.data?.workflows??[],O.name)}):e.isPending?(0,J.jsx)(`div`,{role:`status`,"aria-busy":`true`,className:`min-h-72 text-xs text-muted-foreground`,children:`Loading skill…`}):(0,J.jsx)(N,{icon:(0,J.jsx)(g,{}),tone:`neutral`,heading:`h2`,title:`No skill selected`,subtitle:`Pick a skill from the catalog.`})]})})]})]})}function pe({skill:e,active:t,highlighted:n}){let r=R(e);return(0,J.jsx)(`li`,{children:(0,J.jsxs)(L,{to:`/skills?skill=${encodeURIComponent(e.name)}`,"data-slot":`skill-row`,"data-skill":e.name,"data-highlighted":n||void 0,"data-project":r?`true`:void 0,"aria-current":t?`page`:void 0,className:F(`selection-row flex min-h-24 flex-col gap-2 rounded-lg border-b border-border p-3 transition-colors hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`,(t||n)&&`border-transparent bg-accent-strong/10`),children:[(0,J.jsx)(`span`,{className:`flex min-w-0 items-center gap-2`,children:(0,J.jsx)(`span`,{className:F(`min-w-0 break-words text-[13px]`,r?`font-semibold text-foreground`:`font-normal text-muted-foreground`),children:e.name})}),e.description?(0,J.jsx)(`span`,{className:`line-clamp-2 text-xs leading-relaxed text-supporting-foreground`,children:e.description}):null,(0,J.jsx)(U,{source:e.source,className:`self-start border-0 bg-transparent p-0 text-link-foreground`})]})})}export{de as SkillsRoute};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Ba as r,Bn as i,Ci as a,Cr as o,Fa as s,Gt as c,It as l,Lt as u,Pa as d,Q as f,Rt as p,Tr as m,U as h,Ut as g,Wt as _,Yt as v,_i as y,aa as b,d as x,ga as S,gr as C,hr as w,in as T,jt as E,kn as D,li as O,nn as k,oi as A,ot as j,ra as M,t as N,xr as P}from"./centered-state-DXxIJA15.js";import{t as F}from"./utils-DKheTxGD.js";import{a as I,i as ee,n as te,o as ne,r as re,s as ie}from"./textarea-BOXhPgVD.js";import{T as ae}from"./prompt-templates-D8lCwJds.js";import{c as oe,t as L}from"./project-router-EEnXzYjj.js";import{i as R,l as z,n as B,o as V,p as H}from"./skills-DFBiAuJG.js";import{c as U,h as W,o as G,t as K}from"./index-1YNk4P3I.js";import{t as se}from"./skill-empty-hint-oOtzR3v0.js";var q=e(t(),1),J=n(),ce=`https://github.com/open-mercato/skills`;function le(e){let t=e?.importedSkills;if(Array.isArray(t))return t.filter(e=>typeof e==`string`&&!!e)}function Y(e,t){return le(e)??[...t]}function X({projectId:e}){let t=r(),n=o(),i=D(),[a,s]=(0,q.useState)(``),u=C(e,!!e),d=i.data??[],f=(0,q.useMemo)(()=>d.map(e=>e.name),[d]),h=(0,q.useRef)([]);h.current=f;let g=(0,q.useMemo)(()=>new Set(Y(n.data,f)),[n.data,f]),y=(0,q.useRef)(Promise.resolve()),b=(0,q.useRef)(0),x=(0,q.useCallback)(e=>{let n=m.uiState,r=t.getQueryData(n),i=e(Y(r,h.current));t.setQueryData(n,{...r,importedSkills:i});let a=++b.current;y.current=y.current.then(async()=>{try{let e=await M({importedSkills:i});a===b.current&&(t.setQueryData(n,e),t.invalidateQueries({queryKey:T.skills}))}catch(e){S(e instanceof Error?e.message:String(e),{tone:`danger`}),a===b.current&&t.invalidateQueries({queryKey:n})}})},[t]),w=(0,q.useCallback)(e=>{x(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[x]),O=f.length>0&&f.every(e=>g.has(e)),k=(0,q.useCallback)(()=>{if(O){let e=new Set(h.current);x(t=>t.filter(t=>!e.has(t)))}else x(e=>[...new Set([...e,...h.current])])},[O,x]);if(i.isError)return(0,J.jsx)(N,{icon:(0,J.jsx)(v,{}),tone:`danger`,heading:`h2`,title:`Could not load importable skills`,subtitle:i.error.message});let A=z(d,a);return(0,J.jsxs)(`div`,{"data-slot":`skills-import-panel`,className:`w-full min-w-0 [&_button]:min-h-11`,children:[(0,J.jsx)(`p`,{className:`mb-4 text-[12px] font-medium tracking-wide text-link-foreground`,children:`OPEN-MERCATO / SKILLS`}),(0,J.jsx)(`h2`,{className:`text-2xl font-medium`,children:`Manage skills`}),(0,J.jsxs)(`p`,{className:`mt-2 text-[13px] leading-relaxed text-muted-foreground`,children:[`Choose which `,(0,J.jsx)(`a`,{href:ce,target:`_blank`,rel:`noreferrer`,children:`open-mercato`}),` skills appear in your catalog and composer picker. All are enabled by default; uncheck any you don’t want.`]}),(0,J.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`Applies across projects · saved automatically`}),(0,J.jsx)(ue,{projectId:e,state:u.data,loadError:u.error}),(0,J.jsx)(`p`,{className:`mt-4 text-xs text-soft-foreground`,children:`Checkboxes control visibility. Updating refreshes installed skill files; it does not change your selection.`}),(0,J.jsxs)(`div`,{className:`sw-import-controls mt-4 flex flex-wrap items-center gap-2`,children:[(0,J.jsxs)(`div`,{className:`sw-search relative min-w-0 flex-1`,children:[(0,J.jsx)(p,{"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,J.jsx)(W,{"data-slot":`import-filter`,placeholder:`Filter skills…`,"aria-label":`Filter skills`,value:a,onChange:e=>s(e.target.value),className:`h-11 min-w-0 pl-9 text-xs`})]}),(0,J.jsxs)(`button`,{type:`button`,"data-slot":`import-all`,disabled:f.length===0||n.isPending,onClick:k,className:`h-11 shrink-0 rounded-md border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-55`,children:[O?(0,J.jsx)(E,{"aria-hidden":`true`,className:`size-4`}):(0,J.jsx)(l,{"aria-hidden":`true`,className:`size-4`}),O?`Remove all`:`Enable all`]})]}),(0,J.jsx)(`div`,{"data-slot":`import-list`,className:`mt-3 flex flex-col gap-1.5`,children:i.isPending?(0,J.jsx)(`p`,{className:`px-1 py-2 text-[13px] text-soft-foreground`,children:`Loading…`}):A.length>0?A.map(e=>{let t=g.has(e.name);return(0,J.jsxs)(`label`,{"data-slot":`import-row`,"data-skill":e.name,"data-imported":t?`true`:void 0,className:F(`flex min-h-16 cursor-pointer items-start gap-3 rounded-lg border border-border p-4 transition-colors hover:bg-muted`,t&&`bg-background`),children:[(0,J.jsxs)(`span`,{className:`relative size-5 shrink-0`,children:[(0,J.jsx)(`input`,{type:`checkbox`,"data-slot":`import-toggle`,checked:t,onChange:()=>w(e.name),className:`peer absolute inset-0 m-0 size-5 opacity-0`}),t?(0,J.jsx)(_,{"aria-hidden":`true`,className:`pointer-events-none size-5 text-link-foreground peer-focus-visible:outline-2 peer-focus-visible:outline-ring`}):(0,J.jsx)(c,{"aria-hidden":`true`,className:`pointer-events-none size-5 text-link-foreground peer-focus-visible:outline-2 peer-focus-visible:outline-ring`})]}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`span`,{className:`flex min-w-0 items-center gap-2`,children:(0,J.jsx)(`span`,{className:`min-w-0 break-words text-[13px] font-medium text-foreground`,children:e.name})}),e.description?(0,J.jsx)(`span`,{className:`mt-2 block text-xs leading-relaxed text-soft-foreground`,children:e.description}):null]})]},e.name)}):(0,J.jsx)(`p`,{className:`px-1 py-2 text-xs text-soft-foreground`,children:d.length>0?`(no skills match)`:`(no skills available — the repo may still be cloning)`})})]})}function Z(e){return e===`project`?`Project installation`:`Global installation`}function ue({projectId:e,state:t,loadError:n}){let i=r(),o=oe(),c=(0,q.useRef)(0),[l,d]=(0,q.useState)(!1),p=s({mutationFn:()=>a({task:`Apply the upgrade notes after updating the installed Open Mercato skills.`,steps:[{id:`apply-upgrade-notes`,name:`Apply upgrade notes`,skill:`om-apply-upgrade-notes`,prompt:`{{task}}`}]}),onSuccess:e=>{d(!1),o(ae(e))},onError:e=>S(e.message,{tone:`danger`})}),h=(t,n)=>{n.seq===c.current&&(i.setQueryData(m.skillsUpdate(e),t),n.action===`apply`&&t.updatedAt&&t.updatedAt!==n.previousUpdatedAt&&(i.invalidateQueries({queryKey:T.skills}),S(t.status===`error`?`Some skill updates failed.`:`Open Mercato skills updated.`),d(!0)))},g=(e,t)=>{t.seq===c.current&&S(e.message,{tone:`danger`})},_=s({mutationFn:t=>y(e).then(e=>({result:e,request:t})),onSuccess:({result:e,request:t})=>h(e,t),onError:(e,t)=>g(e,t)}),v=s({mutationFn:t=>O(e).then(e=>({result:e,request:t})),onSuccess:({result:e,request:t})=>h(e,t),onError:(e,t)=>g(e,t)}),b=e=>{let n=++c.current;e===`apply`?v.mutate({action:e,seq:n,previousUpdatedAt:t?.updatedAt??null}):_.mutate({action:e,seq:n})},C=t?.scopes.some(e=>e.skills.length>0)??!1,w=t?.status===`error`,E=C&&(t?.available||w),D=v.isPending||t?.status===`updating`,k=t?.scopes.filter(e=>e.status===`error`||e.status===`unavailable`)??[],A=t?.scopes.filter(e=>e.updatedAt&&!k.includes(e))??[],j=`Checking installed Open Mercato skills…`;return n?j=`Update status is unavailable right now.`:t?.status===`available`?j=`An update is available for your installed Open Mercato skills.`:t?.status===`updating`?j=`Updating installed Open Mercato skills…`:t?.status===`current`?j=`Installed Open Mercato skills are up to date.`:t?.status===`unavailable`?j=t.scopes.find(e=>e.reason)?.reason??`Automatic updates are unavailable.`:t?.status===`error`&&(j=`The update did not finish for every installation.`),(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`section`,{"data-slot":`skills-update-card`,"aria-live":`polite`,className:`mt-4 rounded-lg border border-border bg-background p-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col items-start gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`p`,{className:`text-[13px] font-medium text-foreground`,children:j}),(0,J.jsx)(`p`,{className:`mt-4 text-xs text-soft-foreground`,children:`Project and global installations are checked separately.`}),t?.checkedAt?(0,J.jsxs)(`p`,{className:`mt-1 text-xs text-soft-foreground`,children:[`Last checked `,new Date(t.checkedAt).toLocaleString(),`.`]}):null,t?.scopes.some(e=>e.skills.length>0)?(0,J.jsx)(`ul`,{className:`mt-1 text-xs text-soft-foreground`,children:t.scopes.filter(e=>e.skills.length>0).map(e=>(0,J.jsxs)(`li`,{children:[Z(e.scope),` · `,e.skills.length,` tracked`]},e.scope))}):null,k.length>0?(0,J.jsxs)(`p`,{className:`mt-1 text-xs text-destructive`,children:[`Failed: `,k.map(e=>Z(e.scope)).join(`, `),A.length?`; updated: ${A.map(e=>Z(e.scope)).join(`, `)}`:``,`.`]}):null]}),E?(0,J.jsxs)(x,{"data-action":`skills-update-apply`,size:`sm`,disabled:D,onClick:()=>b(`apply`),children:[(0,J.jsx)(u,{"aria-hidden":`true`,className:F(`size-3.5`,D&&`motion-safe:animate-spin`)}),D?`Updating…`:w?`Retry`:`Update now`]}):t?.status===`current`?(0,J.jsxs)(x,{"data-action":`skills-update-check`,variant:`outline`,size:`sm`,disabled:_.isPending,onClick:()=>b(`check`),children:[(0,J.jsx)(u,{"aria-hidden":`true`,className:`size-4`}),`Check again`]}):t?.status===`unavailable`||n?(0,J.jsx)(x,{"data-action":`skills-update-check`,variant:`outline`,size:`sm`,disabled:_.isPending,onClick:()=>b(`check`),children:`Retry check`}):null]}),t?.status===`unavailable`||n?(0,J.jsxs)(`div`,{className:`mt-2 text-xs text-soft-foreground`,children:[`Manual examples: `,(0,J.jsx)(`code`,{children:`npx skills update -p`}),` · `,(0,J.jsx)(`code`,{children:`npx skills update -g`}),`. These broad commands may update other tracked sources.`]}):null,t?.needsUpgradeNotes?(0,J.jsxs)(`div`,{"data-slot":`skills-upgrade-notes`,className:`mt-3 flex gap-2 rounded-md border border-accent-strong/30 bg-background p-2.5 text-xs text-foreground`,children:[(0,J.jsx)(f,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-link-foreground`}),(0,J.jsxs)(`span`,{children:[`Skill files were updated. Run `,(0,J.jsx)(`code`,{children:`/om-apply-upgrade-notes`}),` in each configured repository to apply descriptor migrations while preserving local edits.`]})]}):null]}),(0,J.jsx)(te,{open:l,onOpenChange:e=>p.isPending?void 0:d(e),children:(0,J.jsxs)(re,{"data-slot":`skills-upgrade-notes-dialog`,showCloseButton:!1,children:[(0,J.jsxs)(ne,{children:[(0,J.jsx)(ie,{children:`Apply the upgrade notes now?`}),(0,J.jsxs)(ee,{children:[`The skill files were updated successfully. Start a new session with`,` `,(0,J.jsx)(`code`,{children:`/om-apply-upgrade-notes`}),` to sync repository descriptors while preserving local edits?`]})]}),(0,J.jsxs)(I,{children:[(0,J.jsx)(x,{type:`button`,variant:`outline`,disabled:p.isPending,onClick:()=>d(!1),children:`No`}),(0,J.jsx)(x,{type:`button`,disabled:p.isPending,onClick:()=>p.mutate(),children:p.isPending?`Starting…`:`Yes, start session`})]})]})})]})}var Q=`__bm`,$=`__import`;function de(){return(0,J.jsx)(`div`,{"data-route":`skills`,className:`mx-auto min-h-full w-full px-[18px] py-6 md:p-9`,children:(0,J.jsx)(fe,{})})}function fe(){let e=w(),t=P(),n=D(),[a]=d(),[o,c]=(0,q.useState)(``),l=r(),f=i(),m=A().projectId??f.data?.bootProject??``,_=s({mutationFn:()=>b(),onSuccess:e=>{l.setQueryData(T.skills,e),S(`Team skills refreshed.`)},onError:e=>S(e.message,{tone:`danger`})});if(e.isError)return(0,J.jsx)(N,{icon:(0,J.jsx)(v,{}),tone:`danger`,heading:`h2`,title:`Could not load skills`,subtitle:e.error.message});let y=V(e.data??[]),x=(n.data?.length??0)>0,C=a.get(`skill`),E=C===Q||C===$||C!==null&&y.some(e=>e.name===C)?C:y[0]?.name??(x?$:Q),O=y.find(e=>e.name===E)??null,M=B(y,o);return(0,J.jsxs)(`div`,{"data-slot":`skills-section`,className:`@container flex min-w-0 flex-col gap-[22px]`,children:[(0,J.jsxs)(`header`,{className:`flex flex-col gap-4 @min-[700px]:flex-row @min-[700px]:items-center @min-[700px]:justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h1`,{className:`text-[25px] font-semibold md:text-[30px]`,children:`Skills`}),(0,J.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground md:text-[13px]`,children:`Markdown playbooks your agents can follow.`})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[x?(0,J.jsxs)(L,{to:`/skills?skill=${$}`,"data-slot":`import-skills-row`,"aria-current":E===$?`page`:void 0,className:`inline-flex min-h-11 items-center gap-2 rounded-lg border border-border bg-card px-3 text-xs font-medium aria-[current=page]:bg-accent-strong/10 hover:bg-muted focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,J.jsx)(j,{"aria-hidden":`true`,className:`size-4 text-link-foreground`}),`Manage skills`]}):null,(0,J.jsxs)(L,{to:`/skills?skill=${Q}`,"data-slot":`bookmarklets-row`,"aria-current":E===Q?`page`:void 0,className:`inline-flex min-h-11 items-center gap-2 rounded-lg border border-border bg-card px-3 text-xs font-medium aria-[current=page]:bg-accent-strong/10 hover:bg-muted focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,J.jsx)(k,{"aria-hidden":`true`,className:`size-4 text-link-foreground`}),`Run from GitHub`]})]})]}),(0,J.jsxs)(`div`,{className:F(`flex-col items-start gap-2 sm:flex-row sm:items-center md:flex`,C===null?`flex`:`hidden`),children:[(0,J.jsxs)(`div`,{className:`sw-search relative w-full min-w-0 flex-1`,children:[(0,J.jsx)(p,{"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,J.jsx)(W,{"data-slot":`skills-filter`,placeholder:`Filter skills…`,"aria-label":`Filter skills`,value:o,onChange:e=>c(e.target.value),className:`h-11 min-w-0 bg-card pl-9 text-xs`})]}),(0,J.jsxs)(`button`,{type:`button`,"data-slot":`skills-refresh`,title:`git fetch the team skills repos`,disabled:_.isPending,onClick:()=>_.mutate(),className:`flex h-11 shrink-0 items-center gap-1.5 rounded-md border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-55`,children:[(0,J.jsx)(u,{"aria-hidden":`true`,className:F(`size-3`,_.isPending&&`motion-safe:animate-spin`)}),`Refresh`]})]}),(0,J.jsxs)(`div`,{className:`grid min-w-0 items-start gap-[22px] md:grid-cols-[minmax(220px,310px)_minmax(0,1fr)]`,children:[(0,J.jsx)(`section`,{"data-slot":`skills-list`,className:F(`min-w-0 flex-col rounded-xl border border-border bg-card p-3 md:flex`,C===null?`flex`:`hidden`),children:(0,J.jsx)(`ul`,{"data-slot":`skill-rows`,className:`flex min-h-0 flex-col gap-1 overflow-y-auto md:max-h-[calc(100dvh-280px)]`,children:e.isPending?(0,J.jsx)(`li`,{role:`status`,"aria-busy":`true`,className:`min-h-72 p-3 text-[13px] text-soft-foreground`,children:`Loading skills…`}):M.length>0?M.map(e=>(0,J.jsx)(pe,{skill:e,active:E===e.name,highlighted:E===$&&e===y[0]},e.path)):(0,J.jsx)(`li`,{className:`px-2.5 py-2 text-xs leading-relaxed text-soft-foreground`,children:y.length>0?`(no skills match)`:(0,J.jsx)(se,{})})})}),(0,J.jsx)(`section`,{"data-slot":`skills-detail`,className:F(`min-w-0 flex-col rounded-xl border border-border bg-card md:flex`,C===null?`hidden`:`flex`),children:(0,J.jsxs)(`div`,{className:`min-w-0 p-5`,children:[(0,J.jsxs)(L,{to:`/skills`,"data-slot":`skills-back`,className:`mb-4 inline-flex min-h-11 items-center gap-2 rounded-lg border border-border px-3 text-xs font-medium hover:bg-muted md:hidden`,children:[(0,J.jsx)(h,{"aria-hidden":`true`,className:`size-3.5`}),`Back to skills`]}),E===$?(0,J.jsx)(X,{projectId:m}):E===Q?(0,J.jsx)(K,{skills:y}):O?(0,J.jsx)(G,{skill:O,usedBy:H(t.data?.workflows??[],O.name)}):e.isPending?(0,J.jsx)(`div`,{role:`status`,"aria-busy":`true`,className:`min-h-72 text-xs text-muted-foreground`,children:`Loading skill…`}):(0,J.jsx)(N,{icon:(0,J.jsx)(g,{}),tone:`neutral`,heading:`h2`,title:`No skill selected`,subtitle:`Pick a skill from the catalog.`})]})})]})]})}function pe({skill:e,active:t,highlighted:n}){let r=R(e);return(0,J.jsx)(`li`,{children:(0,J.jsxs)(L,{to:`/skills?skill=${encodeURIComponent(e.name)}`,"data-slot":`skill-row`,"data-skill":e.name,"data-highlighted":n||void 0,"data-project":r?`true`:void 0,"aria-current":t?`page`:void 0,className:F(`selection-row flex min-h-24 flex-col gap-2 rounded-lg border-b border-border p-3 transition-colors hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`,(t||n)&&`border-transparent bg-accent-strong/10`),children:[(0,J.jsx)(`span`,{className:`flex min-w-0 items-center gap-2`,children:(0,J.jsx)(`span`,{className:F(`min-w-0 break-words text-[13px]`,r?`font-semibold text-foreground`:`font-normal text-muted-foreground`),children:e.name})}),e.description?(0,J.jsx)(`span`,{className:`line-clamp-2 text-xs leading-relaxed text-supporting-foreground`,children:e.description}):null,(0,J.jsx)(U,{source:e.source,className:`self-start border-0 bg-transparent p-0 text-link-foreground`})]})})}export{de as SkillsRoute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./react-runtime-CCIEwYL0.js";import{t}from"./utils-DKheTxGD.js";import{t as n}from"./project-router-
|
|
1
|
+
import{t as e}from"./react-runtime-CCIEwYL0.js";import{t}from"./utils-DKheTxGD.js";import{t as n}from"./project-router-EEnXzYjj.js";var r=e();function i({to:e,active:i=!1,onClick:a,children:o}){return(0,r.jsx)(n,{to:e,"aria-current":i?`page`:void 0,onClick:a,className:t(`-mb-px flex h-8 items-center rounded-t-md border-b-2 px-3 text-[13px] font-medium`,i?`border-foreground font-semibold text-foreground`:`border-transparent text-muted-foreground hover:bg-muted hover:text-foreground`),children:o})}export{i as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{$i as r,Ba as i,Dn as a,Fa as o,Gi as s,Na as c,Xr as l,Zn as u,_t as d,d as f,ga as p,in as m,la as h,lt as g,nr as _,qi as v,si as y,t as b,tr as x,vi as S,wi as C,zi as w}from"./centered-state-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{$i as r,Ba as i,Dn as a,Fa as o,Gi as s,Na as c,Xr as l,Zn as u,_t as d,d as f,ga as p,in as m,la as h,lt as g,nr as _,qi as v,si as y,t as b,tr as x,vi as S,wi as C,zi as w}from"./centered-state-DXxIJA15.js";import{a as T,i as E,n as D,o as O,r as k,s as A,t as j}from"./textarea-BOXhPgVD.js";import{p as M,u as ee}from"./pill-BU5y1CTd.js";import{i as te,n as N,r as P}from"./git-toolbar-DT4Q02mZ.js";import{t as F}from"./run-header-DYiqx0qE.js";import{t as I}from"./use-submit-shortcut-KWJsC906.js";import{n as L,r as R}from"./index-1YNk4P3I.js";import{t as z}from"./diff-CZcD4D1r2.js";import{t as B}from"./use-desktop-BaYgO7YW.js";var V=e(t(),1),H=e=>e===`running`||e===`queued`||e===`waiting`,U=`no worktree — this task ran directly in the repo working tree`;function W(e){let t=e=>({id:`commit`,label:`Commit`,enabled:!1,reason:e});return e.hasWorktree?e.status===`running`?t(`Commit unavailable — the agent is still working in this worktree`):e.changedFiles===void 0?t(`Commit unavailable — changes are still loading`):e.changedFiles===0?t(`Commit unavailable — no changes to commit`):{id:`commit`,label:`Commit`,enabled:!0}:t(`Commit unavailable — ${U}`)}function G(e){let t=e=>({id:`push`,label:`Push`,enabled:!1,reason:e});return e.hasWorktree?e.remote===void 0?t(`Push unavailable — no remote configured`):e.branch===void 0?t(`Push unavailable — the run has no branch to push`):e.status===`running`?t(`Push unavailable — the agent is still working in this worktree`):{id:`push`,label:`Push`,enabled:!0}:t(`Push unavailable — ${U}`)}function K(e){let t=e=>({id:`create-pr`,label:`Create PR`,enabled:!1,reason:e});return!e.hasWorktree||e.branch===void 0?t(`Create PR unavailable — ${U}`):e.forge===null?t(`Create PR unavailable — no supported forge remote (GitHub) detected`):e.forge.available?H(e.status)?t(`Create PR unavailable — the run is still active; wait for the review gate`):{id:`create-pr`,label:`Create PR`,enabled:!0}:t(`Create PR unavailable — ${e.forge.reason??`the forge is unreachable`}`)}function q(e){let t=e.prUrl?{id:`view-pr`,label:`View PR`,enabled:!0,href:e.prUrl}:W(e),n=e.prUrl?[W(e),G(e)]:[G(e),K(e)],r=[];if(e.localHandoff){let t=e.hasSession?H(e.status)?{id:`open-terminal`,label:`Open in terminal`,enabled:!1,reason:`Terminal unavailable — the session is still active in the engine`}:{id:`open-terminal`,label:`Open in terminal`,enabled:!0}:{id:`open-terminal`,label:`Open in terminal`,enabled:!1,reason:`Terminal unavailable — no agent session to resume`};r.push(t)}return{primary:t,secondary:n,menu:r}}var J=n();function Y({run:e,open:t,onOpenChange:n}){let r=i(),[a,s]=(0,V.useState)(``),c=l(e),u=(0,V.useRef)(c);u.current=c,(0,V.useEffect)(()=>{t&&s(u.current)},[t]);let d=o({mutationFn:t=>S(e.id,t),onSuccess:t=>{p(`Committed ${t.sha.slice(0,7)}`),n(!1),r.invalidateQueries({queryKey:m.runs.changes(e.id)}),r.invalidateQueries({queryKey:m.runs.all})},onError:e=>p(e.message,{tone:`danger`})}),h=()=>{let e=a.trim();e.length===0||d.isPending||d.mutate(e)};return(0,J.jsx)(D,{open:t,onOpenChange:n,children:(0,J.jsxs)(k,{"data-slot":`commit-dialog`,children:[(0,J.jsxs)(O,{children:[(0,J.jsx)(A,{children:`Commit changes`}),(0,J.jsxs)(E,{children:[`Stages everything in the task's worktree (git add -A) and commits to`,` `,e.branch?(0,J.jsx)(`span`,{className:`font-mono`,children:e.branch}):`its branch`,`.`]})]}),(0,J.jsx)(j,{"data-slot":`commit-message`,"aria-label":`Commit message`,rows:3,value:a,onChange:e=>s(e.target.value),onKeyDown:e=>{I({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),h())}}),(0,J.jsxs)(T,{children:[(0,J.jsx)(f,{variant:`outline`,onClick:()=>n(!1),children:`Cancel`}),(0,J.jsx)(f,{"data-slot":`commit-confirm`,disabled:a.trim().length===0||d.isPending,onClick:h,children:d.isPending?`Committing…`:`Commit`})]})]})})}function X(){let{id:e}=c(),t=x(e);return t.isPending?(0,J.jsx)(R,{tab:`changes`}):t.isError?(0,J.jsx)(L,{tab:`changes`,error:t.error}):(0,J.jsx)(Z,{run:t.data})}function Z({run:e}){let t=a(),n=u(),c=_(e.id,ee(e.status)),l=B(),[f,x]=(0,V.useState)(`unified`),[S,w]=(0,V.useState)(!1),[T,E]=(0,V.useState)(null),[D,O]=(0,V.useState)(!1),k=(0,V.useRef)(null),A=i(),j=()=>A.invalidateQueries({queryKey:m.runs.all}),I=e=>p(e.message,{tone:`danger`}),L=o({mutationFn:()=>r(e.id),onSuccess:e=>p(e.upstreamSet?`Pushed ${e.branch} to ${e.remote} (upstream set)`:`Pushed ${e.branch} to ${e.remote}`),onError:I}),R=o({mutationFn:()=>C(e.id),onSuccess:e=>{p(`Draft PR created — ${e.url}`),j()},onError:I}),H=o({mutationFn:()=>v(e.id),onError:e=>{if(e instanceof y&&e.command){navigator.clipboard.writeText(e.command).then(()=>p(`No terminal found — command copied to clipboard.`)).catch(()=>p(`Run manually: ${e.command}`));return}I(e)}}),U=o({mutationFn:t=>s(e.id,t),onError:I}),W=c.isError&&c.error instanceof y&&c.error.status===409,G=q({status:e.status,hasWorktree:!!e.worktreePath&&!W,branch:e.branch,changedFiles:c.data?.stat.files,remote:n.data?.info?.remote,forge:t.data?.forge??null,localHandoff:t.data?.capabilities.localHandoff??!1,hasSession:M(e)!==void 0,prUrl:e.pullRequestUrl}),K=e=>{switch(e){case`commit`:O(!0);break;case`push`:L.mutate();break;case`create-pr`:R.mutate();break;case`open-terminal`:H.mutate();break;case`view-pr`:break}},X=c.data?.files??[],Z=(0,V.useMemo)(()=>P(X),[X]),Q=l?f:`unified`,$=!l||S;return(0,J.jsxs)(`div`,{"data-route":`task-changes`,className:`flex min-h-full flex-col`,children:[(0,J.jsx)(F,{run:e,tab:`changes`}),(0,J.jsx)(N,{bar:G,branch:e.branch,stat:c.data?.stat,mode:Q,wrap:$,onModeChange:x,onWrapChange:w,onAction:K}),c.data?.repointedHead?(0,J.jsxs)(`p`,{"data-slot":`repointed-head-note`,className:`border-b px-4 py-2 text-xs text-soft-foreground md:px-9`,children:[`HEAD is on `,(0,J.jsx)(`code`,{children:c.data.repointedHead.headBranch}),`, not this task's branch`,` `,(0,J.jsx)(`code`,{children:c.data.repointedHead.taskBranch}),` — showing only what this task changed there.`]}):null,c.isPending?(0,J.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-9`,children:`Loading changes…`}):c.isError?(0,J.jsx)(b,{icon:W?(0,J.jsx)(g,{size:16}):(0,J.jsx)(d,{size:16}),tone:W?`neutral`:`danger`,heading:`h2`,title:W?`No changes to show`:`Could not load the changes`,subtitle:c.error.message}):X.length===0?(0,J.jsx)(b,{icon:(0,J.jsx)(g,{size:16}),tone:`neutral`,heading:`h2`,title:`No changes yet`,subtitle:`The worktree matches its base branch. Changes appear here as the agent works.`}):(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 md:flex-row md:items-start px-[18px] pb-9 pt-0 [--diff-sticky-top:0px] md:[--diff-sticky-top:1rem] md:px-9`,children:[(0,J.jsxs)(`aside`,{"data-slot":`changes-tree-pane`,className:`md:sticky md:top-4 max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] w-full md:w-60 shrink-0 overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 md:block lg:w-[250px]`,children:[(0,J.jsx)(`h2`,{className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,J.jsx)(te,{root:Z,selected:T,onSelect:e=>{E(e),k.current?.scrollToPath(e)}})]}),(0,J.jsx)(z,{files:X,viewRef:k,mode:Q,wrap:$,loadFileText:t=>ne(e.id,t),imageSrc:t=>h(e.id,t),onOpenInApp:t.data?.capabilities.localHandoff?e=>U.mutate(e):void 0,className:`min-w-0 flex-1`})]}),(0,J.jsx)(Y,{run:e,open:D,onOpenChange:O})]})}async function ne(e,t){try{let n=await w(e,t);return n.type!==`file`||n.binary||n.tooLarge?null:n.content??null}catch{return null}}export{X as TaskChangesRoute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Na as r,U as i,Yt as a,_t as o,ct as s,d as c,ir as l,nr as u,rr as d,si as f,t as p,tr as m}from"./centered-state-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Na as r,U as i,Yt as a,_t as o,ct as s,d as c,ir as l,nr as u,rr as d,si as f,t as p,tr as m}from"./centered-state-DXxIJA15.js";import{u as h}from"./pill-BU5y1CTd.js";import{n as g}from"./diff-controls-BCazakYu.js";import{t as _}from"./run-header-DYiqx0qE.js";import{t as v}from"./project-router-EEnXzYjj.js";import{t as y}from"./search-x-I9Q8pgUa.js";import{t as b}from"./diff-stat-Cn7rzy1H.js";import{n as x,r as S}from"./index-1YNk4P3I.js";import{t as C}from"./diff-CZcD4D1r2.js";import{t as w}from"./use-desktop-BaYgO7YW.js";import{t as T}from"./commit-list-CgoIXaVd.js";var E=e(t(),1),D=n();function O(){let{id:e}=r(),t=m(e);return t.isPending?(0,D.jsx)(S,{tab:`changes`}):t.isError?(0,D.jsx)(x,{tab:`changes`,error:t.error}):(0,D.jsx)(k,{run:t.data})}function k({run:e}){let{sha:t}=r(),n=l(e.id,h(e.status));return(0,D.jsxs)(`div`,{"data-route":`task-commits`,className:`flex min-h-full flex-col`,children:[(0,D.jsx)(_,{run:e,tab:`commits`}),t?(0,D.jsx)(A,{runId:e.id,sha:t}):n.isPending?(0,D.jsx)(`p`,{"data-slot":`commits-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading commits…`}):n.isError?(0,D.jsx)(p,{icon:(0,D.jsx)(o,{size:16}),tone:n.error instanceof f&&n.error.status===409?`neutral`:`danger`,heading:`h2`,title:n.error instanceof f&&n.error.status===409?`No commits to show`:`Could not load the commits`,subtitle:n.error.message}):n.data.commits.length===0?(0,D.jsx)(p,{icon:(0,D.jsx)(o,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`This task hasn't committed anything on its branch. Autosave commits and any the agent makes appear here.`}):(0,D.jsxs)(`div`,{className:`px-[18px] py-[22px] md:px-9`,children:[(0,D.jsx)(T,{slot:`task-commits`,heading:(0,D.jsxs)(`h2`,{className:`text-base font-semibold`,children:[n.data.commits.length,` `,n.data.commits.length===1?`commit`:`commits`,` in this task`]}),className:`w-full`,commits:n.data.commits.map(t=>({...t,shaLabel:t.sha.slice(0,8),href:`/tasks/${e.id}/commits/${t.sha}`}))}),(0,D.jsx)(j,{run:e})]})]})}function A({runId:e,sha:t}){let n=d(e,t),r=w(),[s,l]=(0,E.useState)(`unified`),[u,m]=(0,E.useState)(!1),h=n.isError&&n.error instanceof f&&n.error.status===409,_=r?s:`unified`,x=!r||u;return(0,D.jsxs)(`section`,{"data-slot":`task-commit`,"data-sha":t,className:`mx-auto flex min-h-0 w-full max-w-[var(--measure)] flex-1 flex-col`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1.5 border-b border-border px-4 py-2 md:px-6`,children:[(0,D.jsx)(c,{asChild:!0,variant:`ghost`,size:`sm`,"data-slot":`commit-back`,children:(0,D.jsxs)(v,{to:`/tasks/${e}/commits`,children:[(0,D.jsx)(i,{size:16,"aria-hidden":`true`}),`All commits`]})}),n.data?(0,D.jsx)(b,{stat:n.data.stat}):null,(0,D.jsx)(`span`,{className:`ml-auto hidden items-center gap-1 md:flex`,children:(0,D.jsx)(g,{mode:s,wrap:u,onModeChange:l,onWrapChange:m})})]}),n.isPending?(0,D.jsx)(`p`,{"data-slot":`commit-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading commit…`}):n.isError?(0,D.jsx)(p,{icon:h?(0,D.jsx)(y,{}):(0,D.jsx)(a,{size:16}),tone:h?`neutral`:`danger`,heading:`h2`,title:h?`Commit not found`:`Could not load the commit`,subtitle:n.error.message}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{"data-slot":`commit-meta`,className:`border-b border-border px-4 py-3 md:px-6`,children:[(0,D.jsx)(`h2`,{className:`text-sm font-semibold`,children:n.data.subject}),(0,D.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-soft-foreground`,children:[n.data.author,` · `,n.data.when,` ·`,` `,(0,D.jsx)(`span`,{className:`font-mono select-all`,children:n.data.sha})]})]}),n.data.files.length===0?(0,D.jsx)(p,{icon:(0,D.jsx)(o,{size:16}),tone:`neutral`,heading:`h2`,title:`No file changes`,subtitle:`This commit carries no diff of its own — a merge commit's changes live on the commits it merged.`}):(0,D.jsx)(`div`,{className:`px-4 py-4 [--diff-sticky-top:0px] md:[--diff-sticky-top:1rem] md:px-6`,children:(0,D.jsx)(C,{files:n.data.files,mode:_,wrap:x,className:`min-w-0`})})]})]})}function j({run:e}){let t=u(e.id,h(e.status));return t.isPending?(0,D.jsx)(`p`,{className:`mt-[22px] text-xs text-muted-foreground`,children:`Loading changed files…`}):t.isError?(0,D.jsxs)(`p`,{role:`status`,className:`mt-[22px] text-xs text-danger`,children:[`Could not load changed files: `,t.error.message]}):t.data.files.length===0?null:(0,D.jsxs)(`section`,{"data-slot":`task-commit-files`,className:`mt-[22px] rounded-[10px] border border-border bg-card p-5`,children:[(0,D.jsxs)(`h2`,{className:`mb-4 text-[16px] font-semibold`,children:[t.data.files.length,` changed files`]}),(0,D.jsx)(`ul`,{className:`space-y-4`,children:t.data.files.map(t=>(0,D.jsx)(`li`,{children:(0,D.jsxs)(v,{to:`/tasks/${e.id}/changes`,className:`flex min-h-11 items-center gap-2 text-xs text-muted-foreground hover:text-foreground`,children:[(0,D.jsx)(s,{size:16,"aria-hidden":`true`,className:`size-[15px] shrink-0`}),(0,D.jsx)(`span`,{className:`break-all`,children:t.path})]})},t.path))})]})}export{O as TaskCommitsRoute};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Na as r,Oi as i,Pa as a,Rt as o,Yt as s,Z as c,ct as l,d as u,dn as d,dt as f,fn as p,la as m,or as h,pi as g,si as _,t as v,tr as y,ut as b,yn as x}from"./centered-state-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Na as r,Oi as i,Pa as a,Rt as o,Yt as s,Z as c,ct as l,d as u,dn as d,dt as f,fn as p,la as m,or as h,pi as g,si as _,t as v,tr as y,ut as b,yn as x}from"./centered-state-DXxIJA15.js";import{t as S}from"./utils-DKheTxGD.js";import{t as C}from"./createLucideIcon-BHp8sXmF.js";import{l as w,t as T}from"./run-header-DYiqx0qE.js";import{n as E,t as D}from"./markdown-0VE-LMFx.js";import{a as O,i as k,r as A}from"./highlighter-CdHqIwFr.js";import{h as j,n as M,r as N}from"./index-1YNk4P3I.js";var P=C(`file-exclamation-point`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),F=C(`file-question-mark`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}]]),I=C(`file-x`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m14.5 12.5-5 5`,key:`b62r18`}],[`path`,{d:`m9.5 12.5 5 5`,key:`1rk7el`}]]),L=C(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),R=C(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),z=e(t(),1),B=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`bmp`,`ico`,`avif`]);function V(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n<=0?!1:B.has(t.slice(n+1).toLowerCase())}function H(e){return e.tooLarge?`too-large`:V(e.path)?`image`:e.binary?`binary`:`text`}function U(e){return e>=1024**2?`${(e/1024**2).toFixed(1)} MB`:e>=1024?`${(e/1024).toFixed(1)} kB`:`${e} B`}var W=n();function G({runId:e,path:t,className:n}){let r=h(e,t??void 0);if(t===null)return(0,W.jsx)(q,{className:n,children:(0,W.jsx)(v,{icon:(0,W.jsx)(b,{size:16}),tone:`neutral`,heading:`h2`,title:`Select a file`,subtitle:`Pick a file from this task’s worktree to inspect its contents.`,className:`[&_[data-slot=centered-state-tile]]:size-10 [&_[data-slot=centered-state-tile]]:border-0 [&_[data-slot=centered-state-tile]]:bg-transparent [&_[data-slot=centered-state-tile]]:text-accent-text [&_[data-slot=centered-state-tile]]:shadow-none [&_h2]:text-xl`})});if(r.isPending)return(0,W.jsx)(q,{className:n,children:(0,W.jsxs)(`p`,{"data-slot":`file-preview-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground`,children:[`Loading `,t,`…`]})});if(r.isError){let e=r.error instanceof _&&r.error.status===409;return(0,W.jsx)(q,{className:n,children:(0,W.jsx)(v,{icon:e?(0,W.jsx)(I,{}):(0,W.jsx)(s,{size:16}),tone:e?`neutral`:`danger`,heading:`h2`,title:e?`Cannot preview this file`:`Could not load this file`,subtitle:r.error.message})})}return r.data.type===`file`?(0,W.jsx)(K,{runId:e,entry:r.data,className:n}):(0,W.jsx)(q,{className:n,children:(0,W.jsx)(v,{icon:(0,W.jsx)(F,{}),tone:`neutral`,heading:`h2`,title:`Choose a file inside this directory`,subtitle:`Expand the folder in the tree, or enter the full path to a file.`})})}function K({runId:e,entry:t,className:n,imageUrl:r,downloadUrl:i,snapshot:a,documentPreview:o=!1}){let[s,c]=(0,z.useState)(!1),l=o&&/\.(?:md|markdown)$/i.test(t.path),u=/\.(?:png|jpe?g|gif|webp|bmp|ico|avif)$/i.test(t.path),d=o&&u&&t.size<=10*1024*1024?`image`:H(t);return(0,W.jsxs)(q,{className:n,children:[(0,W.jsxs)(`header`,{"data-slot":`file-preview-head`,className:`flex items-center gap-2 border-b border-border bg-muted/40 px-4 py-2 text-xs`,children:[(0,W.jsx)(`span`,{className:`min-w-0 truncate font-mono font-medium`,children:t.path}),(0,W.jsx)(`span`,{className:`ml-auto shrink-0 tabular-nums text-soft-foreground`,children:U(t.size)})]}),a||i||l?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 border-b border-border px-4 py-2 text-xs`,children:[a?(0,W.jsxs)(`span`,{children:[`Published snapshot · `,a]}):null,i?(0,W.jsx)(`a`,{className:`inline-flex min-h-11 items-center text-accent-text underline`,href:i,children:`Download`}):null,l?(0,W.jsx)(`button`,{className:`min-h-11 rounded px-2 text-accent-text underline focus-visible:ring-2`,onClick:()=>c(e=>!e),children:s?`Preview`:`View source`}):null]}):null,d===`image`&&(!o||u)?(0,W.jsx)(`div`,{className:`flex justify-center p-4`,children:(0,W.jsx)(`img`,{"data-slot":`file-preview-image`,src:r??m(e,t.path),alt:t.path,className:`max-h-[70vh] max-w-full rounded-sm`})}):d===`too-large`?(0,W.jsx)(v,{icon:(0,W.jsx)(P,{}),tone:`neutral`,heading:`h2`,title:`Too large to preview`,subtitle:`${U(t.size)} — past the preview cap. Open it in your editor instead.`}):d===`binary`?(0,W.jsx)(v,{icon:(0,W.jsx)(F,{}),tone:`neutral`,heading:`h2`,title:`Binary file`,subtitle:`${U(t.size)} of binary data — no text preview.`}):l&&!s?(0,W.jsx)(`div`,{className:`p-4`,children:(0,W.jsx)(D,{document:!0,children:t.content??``})}):(0,W.jsx)(X,{path:t.path,text:t.content??``})]})}function q({className:e,children:t}){return(0,W.jsx)(`section`,{"data-slot":`file-preview`,className:S(`flex flex-col overflow-hidden rounded-lg border border-border bg-card`,e),children:t})}var J=1500;function Y(e,t){let n=(0,z.useMemo)(()=>t.split(`
|
|
2
2
|
`).map(e=>[{content:e}]),[t]),r=(0,z.useMemo)(()=>O(e),[e]),i=n.length>J,[a,o]=(0,z.useState)(null);return(0,z.useEffect)(()=>{if(r===null||i)return;let n=!1;return A(t,r).then(r=>{n||o({key:`${e}\0${t}`,tokens:r.tokens})}),()=>{n=!0}},[e,t,r,i]),r===null||i?n:a?.key===`${e}\0${t}`?a.tokens:k(t,r)?.tokens??n}function X({path:e,text:t}){let n=Y(e,t);return(0,W.jsx)(`div`,{"data-slot":`file-preview-code`,"data-lang":O(e)??`plaintext`,className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7]`,children:n.map((e,t)=>(0,W.jsxs)(`div`,{className:`flex px-4`,children:[(0,W.jsx)(`span`,{className:`w-10 shrink-0 select-none pr-3 text-right tabular-nums text-soft-foreground`,children:t+1}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-pre pr-4`,children:e.map((e,t)=>(0,W.jsx)(`span`,{style:e.color===void 0?void 0:{color:e.color},children:e.content},t))})]},t))})}function Z({runId:e,path:t,artifactId:n}){let r=x(e,n?null:t),a=d(e,n),o=n?a:r,s=(0,z.useContext)(E),c=o.data,l=(0,z.useMemo)(()=>c?.type===`file`&&c.source!==`artifact`?{runId:e,...s,basePath:c.path}:null,[c,s,e]);if(!t&&!n)return(0,W.jsx)(G,{runId:e,path:null,className:`min-w-0 flex-1`});if(o.isPending)return(0,W.jsx)(`p`,{role:`status`,className:`p-4`,children:`Loading file…`});if(o.isError)return(0,W.jsxs)(`section`,{"data-slot":`file-preview`,className:`min-w-0 flex-1 rounded-lg border p-4`,children:[(0,W.jsx)(`h2`,{children:`Could not load this file`}),(0,W.jsx)(`p`,{className:`wrap-anywhere text-sm`,children:o.error.message}),(0,W.jsx)(u,{variant:`outline`,onClick:()=>void o.refetch(),children:`Retry`})]});if(!c)return(0,W.jsx)(`p`,{role:`alert`,className:`p-4`,children:`No file data was returned.`});if(c.type!==`file`)return(0,W.jsxs)(`section`,{"data-slot":`file-preview`,className:`min-w-0 flex-1 rounded-lg border p-4`,children:[(0,W.jsx)(`h2`,{children:c.type===`unpublished`?`File not published`:`Cannot preview this file`}),(0,W.jsx)(`p`,{className:`wrap-anywhere py-2 font-mono text-xs`,children:c.path}),(0,W.jsx)(`p`,{className:`text-sm`,children:c.reason}),(0,W.jsx)(u,{variant:`outline`,onClick:()=>void o.refetch(),children:`Retry`})]});let f=c.artifact;return(0,W.jsx)(E.Provider,{value:l,children:(0,W.jsx)(K,{runId:e,entry:c,documentPreview:!0,className:`min-w-0 flex-1`,imageUrl:f?g(e,f.id,`image`):i(e,t),...f?{downloadUrl:g(e,f.id,`download`),snapshot:new Date(f.createdAt).toLocaleString()}:{}},f?.id??c.path)})}function Q({runId:e,selected:t,onSelect:n}){return(0,W.jsx)(`nav`,{"data-slot":`files-tree`,"aria-label":`Worktree files`,className:`min-w-0 text-[13px]`,children:(0,W.jsx)(`ul`,{className:`flex flex-col gap-px`,children:(0,W.jsx)($,{runId:e,path:``,depth:0,selected:t,onSelect:n})})})}function $({runId:e,path:t,depth:n,selected:r,onSelect:i}){let a=h(e,t);return a.isPending?(0,W.jsx)(`li`,{"data-slot":`files-tree-loading`,className:`px-1.5 py-1 text-xs text-soft-foreground`,style:{paddingLeft:`${6+n*14}px`},children:`Loading…`}):a.isError?(0,W.jsx)(`li`,{"data-slot":`files-tree-error`,className:`px-1.5 py-1 text-xs text-danger`,style:{paddingLeft:`${6+n*14}px`},children:a.error.message}):a.data.type===`dir`?a.data.entries.length===0?(0,W.jsx)(`li`,{"data-slot":`files-tree-empty`,className:`px-1.5 py-1 text-xs text-soft-foreground`,style:{paddingLeft:`${6+n*14}px`},children:`Empty directory`}):(0,W.jsx)(W.Fragment,{children:a.data.entries.map(a=>a.type===`dir`?(0,W.jsx)(ee,{runId:e,name:a.name,path:t===``?a.name:`${t}/${a.name}`,depth:n,selected:r,onSelect:i},a.name):(0,W.jsx)(te,{name:a.name,path:t===``?a.name:`${t}/${a.name}`,size:a.size,depth:n,selected:r,onSelect:i},a.name))}):null}function ee({runId:e,name:t,path:n,depth:r,selected:i,onSelect:a}){let[o,s]=(0,z.useState)(!1);return(0,W.jsxs)(`li`,{children:[(0,W.jsxs)(`button`,{type:`button`,"data-slot":`files-dir`,"data-path":n,"data-state":o?`open`:`closed`,"aria-expanded":o,onClick:()=>s(e=>!e),className:`flex min-h-11 md:min-h-8 w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left text-muted-foreground hover:bg-muted hover:text-foreground`,style:{paddingLeft:`${6+r*14}px`},children:[(0,W.jsx)(c,{size:16,"aria-hidden":`true`,className:S(`order-last ml-auto size-3.5 shrink-0 transition-transform motion-reduce:transition-none`,o&&`rotate-90`)}),(0,W.jsx)(f,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,W.jsx)(`span`,{className:`min-w-0 truncate font-normal`,children:t})]}),o?(0,W.jsx)(`ul`,{className:`flex flex-col gap-px`,children:(0,W.jsx)($,{runId:e,path:n,depth:r+1,selected:i,onSelect:a})}):null]})}function te({name:e,path:t,size:n,depth:r,selected:i,onSelect:a}){let o=i===t,s=V(t)?R:l;return(0,W.jsx)(`li`,{children:(0,W.jsxs)(`button`,{type:`button`,"data-slot":`files-file`,"data-path":t,"aria-current":o?`true`:void 0,onClick:()=>a(t),className:S(`flex min-h-11 md:min-h-8 w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left hover:bg-muted`,o?`bg-muted font-medium text-foreground`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${6+r*14}px`},children:[(0,W.jsx)(s,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,W.jsx)(`span`,{className:`min-w-0 truncate`,children:e}),n===void 0?null:(0,W.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 font-mono text-[11px] tabular-nums text-soft-foreground`,children:U(n)})]})})}function ne(){let{id:e}=r(),t=y(e);return t.isPending?(0,W.jsx)(N,{tab:`files`}):t.isError?(0,W.jsx)(M,{tab:`files`,error:t.error}):(0,W.jsx)(w,{runId:t.data.id,children:(0,W.jsx)(re,{run:t.data},t.data.id)})}function re({run:e}){let t=h(e.id,``),n=p(e.id),[r,i]=a(),c=r.get(`path`),l=r.get(`artifact`),d=r.getAll(`path`).length>1||r.getAll(`artifact`).length>1||c!==null&&l!==null,[f,m]=(0,z.useState)(c??``);(0,z.useEffect)(()=>m(c??``),[c]);let g=(e,t)=>{let n=new URLSearchParams(r);n.delete(`path`),n.delete(`artifact`),n.set(e,t),i(n)},y=t.isError&&t.error instanceof _&&t.error.status===409;return(0,W.jsxs)(`div`,{"data-route":`task-files`,className:`flex min-h-full flex-col`,children:[(0,W.jsx)(T,{run:e,tab:`files`}),(0,W.jsxs)(`form`,{className:`flex min-w-0 gap-2 px-[18px] pt-[22px] md:px-9`,onSubmit:e=>{e.preventDefault(),f.trim()&&g(`path`,f.trim())},children:[(0,W.jsxs)(`label`,{className:`relative min-w-0 flex-1`,children:[(0,W.jsx)(o,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,W.jsx)(j,{"aria-label":`File path in the worktree`,placeholder:`Open a file by path…`,value:f,onChange:e=>m(e.target.value),className:`h-11 min-w-0 bg-card pl-10`})]}),(0,W.jsx)(u,{type:`submit`,variant:`outline`,className:`h-11 shrink-0`,disabled:!f.trim(),children:`Open file`})]}),(0,W.jsxs)(`div`,{className:`flex min-h-0 flex-col items-stretch gap-5 px-[18px] py-[22px] [--diff-sticky-top:1rem] md:flex-row md:items-start md:px-9`,children:[(0,W.jsxs)(`aside`,{"data-slot":`files-tree-pane`,className:`w-full shrink-0 rounded-xl border border-border bg-card p-3.5 md:sticky md:top-[var(--diff-sticky-top)] md:max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] md:w-60 md:overflow-y-auto md:overscroll-contain lg:w-72`,children:[(0,W.jsx)(`h2`,{className:`sr-only`,children:`Worktree files`}),t.isPending?(0,W.jsx)(`p`,{"data-slot":`files-loading`,className:`py-4 text-xs`,children:`Loading files…`}):t.isError?(0,W.jsx)(v,{icon:y?(0,W.jsx)(L,{}):(0,W.jsx)(s,{size:16}),tone:y?`neutral`:`danger`,heading:`h2`,title:y?`No files to browse`:`Could not load the files`,subtitle:t.error.message}):(0,W.jsx)(Q,{runId:e.id,selected:c,onSelect:e=>g(`path`,e)}),(0,W.jsxs)(`section`,{className:`mt-4 border-t border-border pt-3`,"aria-label":`Published artifacts`,children:[(0,W.jsx)(`h2`,{className:`text-sm font-medium`,children:`Published artifacts`}),n.isPending?(0,W.jsx)(`p`,{className:`py-2 text-xs`,children:`Loading published files…`}):n.isError?(0,W.jsx)(`p`,{role:`alert`,className:`py-2 text-xs`,children:`Could not load published files.`}):n.data.artifacts.length===0?(0,W.jsx)(`p`,{className:`py-2 text-xs text-muted-foreground`,children:`No published files yet.`}):(0,W.jsx)(`ul`,{children:n.data.artifacts.map(e=>(0,W.jsx)(`li`,{children:(0,W.jsx)(`button`,{type:`button`,"aria-current":e.id===l?`true`:void 0,className:`min-h-11 w-full rounded px-2 py-2 text-left text-xs wrap-anywhere hover:bg-muted focus-visible:ring-2`,onClick:()=>g(`artifact`,e.id),children:e.name})},e.id))}),(0,W.jsx)(u,{variant:`ghost`,className:`min-h-11`,onClick:()=>void n.refetch(),children:`Refresh published files`})]})]}),d?(0,W.jsx)(`p`,{role:`alert`,className:`p-4`,children:`Invalid file link: choose either a path or a published artifact.`}):c!==null||l!==null||t.isSuccess?(0,W.jsx)(Z,{runId:e.id,path:c,artifactId:l}):null]}),(0,W.jsx)(`p`,{className:`px-[18px] pb-6 text-xs text-muted-foreground md:px-9`,children:`Browsing files is read-only. Worktree contents may differ from your main checkout. Published files are snapshots.`})]})}export{ne as TaskFilesRoute};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Ba as r,Bi as i,Ca as a,Dt as o,Et as s,Fa as c,Fn as l,Ga as u,H as d,Ha as f,Ia as p,J as m,Jt as h,La as g,Ln as _,Lr as v,Na as y,Pt as b,Q as x,Rr as S,Rt as C,Vi as w,Vn as T,Wa as E,X as D,Xn as O,Xr as k,Y as A,Z as j,at as M,bi as N,d as P,dr as F,en as I,et as L,ga as R,hi as z,ht as B,in as V,it as ee,ja as te,jn as ne,ki as re,mi as ie,mn as ae,mr as oe,n as se,nt as ce,qt as H,si as le,t as ue,ti as de,tr as fe,ur as pe,vn as me,wi as he,xa as ge,xt as _e}from"./centered-state-HwCqQkH3.js";import{C as ve,S as ye,T as be,c as xe,i as Se,n as Ce,s as we,t as U,w as Te,x as Ee,y as De}from"./utils-DKheTxGD.js";import{n as W,r as G,t as Oe}from"./collapsible-CTymFdL7.js";import{n as ke,s as Ae,t as je}from"./agent-accounts-JPfZPgKn.js";import{t as Me}from"./textarea-D2vAVgYW.js";import{t as Ne}from"./createLucideIcon-BHp8sXmF.js";import{D as Pe,_ as Fe,d as Ie,h as Le,j as Re,k as ze,l as Be,m as Ve,s as He,u as Ue,x as We}from"./pill-QfwkuR50.js";import{t as Ge}from"./external-link-BE6y205O.js";import{I as Ke,S as qe,_ as Je,b as Ye,c as Xe,g as Ze,l as Qe,v as $e,x as et}from"./prompt-templates-Cfna_S0T.js";import{a as tt,c as nt,d as rt,i as it,l as at,n as ot,o as st,r as ct,s as lt,t as ut,u as dt}from"./run-header-DMgIbr1d.js";import{s as ft,t as K,u as pt}from"./project-router-CkAA39N5.js";import{t as mt}from"./message-square-B-MD-8rD.js";import{t as ht}from"./search-x-I9Q8pgUa.js";import{t as gt}from"./square-terminal-B6RYYieR.js";import{t as _t}from"./markdown-CFWZnvMh.js";import{c as vt,i as yt,l as bt,n as xt,o as St,s as Ct,t as wt}from"./thread-loading-NW8Mthco.js";import{t as Tt}from"./use-submit-shortcut-KWJsC906.js";import{t as Et}from"./lib-BQXq3kEf.js";import{t as Dt}from"./zoomable-image-YW3Qdrr_.js";import{t as Ot}from"./run-diff-YbCEQn5I.js";import{t as kt}from"./use-desktop-BaYgO7YW.js";var At=120;function jt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Mt(e){let t=e.replace(/\s+/g,` `).trim();return t.length>At?`${t.slice(0,At-1)}…`:t}function q(e,...t){if(jt(e))for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim()!==``)return Mt(t)}}function Nt(e){if(!jt(e))return;let t=e.command;if(typeof t==`string`&&t.trim()!==``)return Mt(t);if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return Mt(e.join(` `))}}function Pt(e){if(!jt(e)||!Array.isArray(e.changes))return[];let t=[];for(let n of e.changes)jt(n)&&typeof n.path==`string`&&n.path.trim()!==``&&t.push(n.path);return t}function Ft(e){return q(e,`description`,`query`,`url`,`filePath`,`file_path`,`path`,`pattern`,`name`)}function J(e,t){return t?`${e} ${t}`:e}function It(e,t){let n=typeof e==`string`?e.toLowerCase():``;switch(n){case`bash`:case`commandexecution`:return{toolKind:`execute`,title:J(`Ran`,Nt(t)),subtitle:q(t,`description`)};case`edit`:case`multiedit`:return{toolKind:`edit`,title:J(`Edit`,q(t,`file_path`,`filePath`,`path`))};case`write`:return{toolKind:`edit`,title:J(`Write`,q(t,`file_path`,`filePath`,`path`))};case`notebookedit`:return{toolKind:`edit`,title:J(`Edit`,q(t,`notebook_path`,`notebookPath`,`file_path`,`filePath`,`path`))};case`filechange`:{let e=Pt(t);return{toolKind:`edit`,title:J(`Edit`,e.length===1?e[0]:e.length>1?`${e.length} files`:void 0)}}case`read`:return{toolKind:`read`,title:J(`Read`,q(t,`file_path`,`filePath`,`path`))};case`imageview`:return{toolKind:`read`,title:J(`View image`,q(t,`path`))};case`glob`:case`grep`:return{toolKind:`search`,title:J(`Search`,q(t,`pattern`,`query`)),subtitle:q(t,`path`)};case`webfetch`:return{toolKind:`fetch`,title:J(`Fetch`,q(t,`url`))};case`websearch`:return{toolKind:`fetch`,title:J(`Web search`,q(t,`query`))};case`task`:case`agent`:{let e=n===`agent`?`Agent`:`Task`,r=q(t,`subagent_type`,`subagentType`),i=q(t,`description`,`prompt`)??r;return{toolKind:`task`,title:i?`${e}: ${i}`:e,subtitle:i===r?void 0:r}}case`skill`:{let e=q(t,`skill`,`name`,`command`);return{toolKind:`task`,title:e?`Skill: ${e}`:`Skill`,subtitle:q(t,`args`,`description`)}}case`todowrite`:case`todolist`:case`plan`:case`taskcreate`:case`taskupdate`:case`tasklist`:return{toolKind:`plan`,title:`Update plan`};case`contextcompaction`:return{toolKind:`other`,title:`Compacted context`};case`mcptoolcall`:{let e=q(t,`server`),n=q(t,`tool`);return e&&n?{toolKind:`other`,title:`${e}.${n}`}:{toolKind:`other`,title:`MCP tool`,subtitle:Ft(t)}}}if(n.startsWith(`mcp__`)){let t=e.split(`__`).filter(e=>e!==``);if(t.length>=3)return{toolKind:`other`,title:`${t[1]}.${t.slice(2).join(`__`)}`}}return{toolKind:`other`,title:typeof e==`string`&&e.trim()!==``?Mt(e):`Tool`,subtitle:Ft(t)}}var Lt=class extends f{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,d=i&&c===`forward`,f=o&&c===`backward`,p=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:E(t,n.data),hasPreviousPage:u(t,n.data),isFetchNextPageError:l,isFetchingNextPage:d,isFetchPreviousPageError:f,isFetchingPreviousPage:p,isRefetchError:s&&!l&&!f,isRefetching:a&&!d&&!p}}};function Rt(e,t){return g(e,Lt,t)}var zt=Ne(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),Bt=Ne(`corner-up-left`,[[`path`,{d:`M20 20v-7a4 4 0 0 0-4-4H4`,key:`1nkjon`}],[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}]]),Vt=Ne(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),Ht=Ne(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),Ut=Ne(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),Y=e(t(),1),Wt=[`run-event`,`ui-event`];function Gt(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!=`object`||!t||Array.isArray(t))return null;let{seq:n,type:r}=t;return typeof n!=`number`||typeof r!=`string`||r===``?null:t}function Kt(e,t={}){let[n,r]=(0,Y.useState)([]),{cursor:i,afterSeq:a=0,maxEvents:o,compactAt:s,onCompact:c}=t;return(0,Y.useEffect)(()=>{if(r([]),!e)return;let t=globalThis.EventSource;if(typeof t!=`function`)return;let n=a,l=null,u,d=!1,f=!1,p=Date.now(),m,h=e=>{p=Date.now();let t=Gt(e.data);!t||!(t.seq>n)||(n=t.seq,r(e=>{let n=[...e,t];return!f&&s!==void 0&&n.length>=s&&(f=!0,queueMicrotask(()=>{d||c?.()})),o===void 0||n.length<=o?n:n.slice(-o)}))},g=()=>{p=Date.now()},_=()=>{d||u!==void 0||(u=setTimeout(()=>{u=void 0,d||v()},1500))},v=()=>{l?.close(),p=Date.now();let r=new URLSearchParams;i!==void 0&&r.set(`cursor`,i),(i!==void 0||a>0)&&r.set(`afterSeq`,String(n));let o=r.size>0?`?${r.toString()}`:``;l=new t(Se(`/runs/${encodeURIComponent(e)}/events${o}`),{withCredentials:!0});for(let e of Wt)l.addEventListener(e,h);l.addEventListener(`ping`,g),l.addEventListener(`error`,()=>{l?.readyState===2&&_()})},y=()=>{document.visibilityState===`visible`&&(!l||l.readyState===2)&&(clearTimeout(u),u=void 0,v())},b=()=>{clearTimeout(u),u=void 0,l?.close()},x=e=>{e.persisted&&v()};return m=setInterval(()=>{d||document.visibilityState!==`visible`||Date.now()-p<=4e4||(clearTimeout(u),u=void 0,v())},1e4),document.addEventListener(`visibilitychange`,y),window.addEventListener(`pagehide`,b),window.addEventListener(`pageshow`,x),v(),()=>{d=!0,clearTimeout(u),clearInterval(m),document.removeEventListener(`visibilitychange`,y),window.removeEventListener(`pagehide`,b),window.removeEventListener(`pageshow`,x),l?.close()}},[e,i,a,o,s,c]),n}var qt=5,Jt=200,Yt=5e3;function Xt(...e){let t=new Map;for(let n of e)for(let e of n)t.set(e.seq,e);return[...t.values()].sort((e,t)=>e.seq-t.seq)}function Zt(e){let t=we(),n=r(),a=[`run-history`,t,e],o=[`run-history-context`,t,e],s=Rt({queryKey:a,enabled:e!==void 0,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>i(e,t,{signal:n}),getPreviousPageParam:e=>e.olderCursor,getNextPageParam:e=>e.newerCursor,maxPages:qt,retry:1}),c=p({queryKey:o,enabled:e!==void 0,queryFn:({signal:t})=>w(e,{signal:t}),retry:1}),l=s.isError||c.isError,u=Kt(l?e:void 0),d=s.data?.pages??[],f=d.reduce((e,t)=>t.newerCursor===void 0?t:e??t,void 0),m=(0,Y.useRef)(!1),h=(0,Y.useCallback)(()=>{e===void 0||m.current||(m.current=!0,i(e,void 0).then(r=>{n.setQueryData([`run-history`,t,e],e=>{if(!e)return{pages:[r],pageParams:[void 0]};let t=[...e.pages],n=[...e.pageParams],i=-1;for(let e=0;e<t.length;e+=1)(i===-1||t[e].asOfSeq>t[i].asOfSeq)&&(i=e);for(i>=0&&t[i].newerCursor===void 0?(t[i]=r,n[i]=void 0):(t.push(r),n.push(void 0));t.length>qt;)t.shift(),n.shift();return{pages:t,pageParams:n}})}).catch(()=>{}).finally(()=>{m.current=!1}))},[n,e,t]),g=Kt(!l&&f?e:void 0,{cursor:f?.liveCursor,afterSeq:f?.asOfSeq,maxEvents:Yt,compactAt:Jt,onCompact:h}),_=(0,Y.useMemo)(()=>Xt(...d.map(e=>e.events)),[d]),v=(0,Y.useMemo)(()=>l?u:Xt(_,g),[l,u,_,g]),y=(0,Y.useMemo)(()=>{if(l)return u;let e=c.data?.contextEvents??[],t=c.data?.asOfSeq??0;return Xt(e,v.filter(({seq:e})=>e>t))},[c.data,l,u,v]),b=(0,Y.useCallback)(async()=>{await s.fetchPreviousPage()},[s.fetchPreviousPage]),x=(0,Y.useCallback)(async()=>{l||await n.resetQueries({queryKey:a,exact:!0})},[l,a,n]);return{visibleEvents:v,currentEvents:y,isPending:!l&&s.isPending,contextPending:!l&&c.isPending,fallback:l,hasOlder:!l&&!!s.hasPreviousPage,isFetchingOlder:s.isFetchingPreviousPage,olderError:s.isFetchPreviousPageError?s.error instanceof Error?s.error.message:`Could not load earlier items`:void 0,loadOlder:b,jumpToLatest:x,retainedPages:d.length}}var X=n();function Qt({run:e}){let t=r(),n=c({mutationFn:()=>ie(e.id),onSuccess:()=>{t.invalidateQueries({queryKey:V.runs.detail(e.id)}),t.invalidateQueries({queryKey:V.runs.list()}),R(`This task will not resume itself`)},onError:e=>R(e.message,{tone:`danger`})});if(e.status!==`failed`||!e.autoResumeAt)return null;let i=new Date(e.autoResumeAt);if(!Number.isFinite(i.getTime()))return null;let o=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(i);return(0,X.jsxs)(`div`,{"data-slot":`auto-resume-hint`,role:`status`,className:`flex flex-wrap items-center gap-x-2 gap-y-1 px-1 text-xs text-muted-foreground`,children:[(0,X.jsx)(ze,{tone:`pending`,pulse:!0}),(0,X.jsxs)(`span`,{children:[`Usage limit reached — this task resumes automatically at`,` `,(0,X.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:o})]}),(0,X.jsx)(`button`,{type:`button`,"data-action":`auto-resume-cancel`,disabled:n.isPending,onClick:()=>n.mutate(),className:`font-medium text-foreground underline decoration-border underline-offset-2 hover:decoration-foreground disabled:opacity-50`,children:`Don’t resume`}),(0,X.jsx)(a,{to:`/settings/global/resources`,"data-slot":`auto-resume-settings-link`,className:`font-medium text-foreground underline decoration-border underline-offset-2 hover:decoration-foreground`,children:`Auto-resume settings`})]})}var $t=e=>e.kind===`tool`,en=e=>e.kind===`conversation`,tn=e=>(e.toolKind===`read`||e.toolKind===`search`)&&e.status===`completed`,nn=(e,t,n)=>`${e} ${e===1?t:n}`;function rn(e,t){let n=[];return e>0&&n.push(nn(e,`file`,`files`)),t>0&&n.push(nn(t,`search`,`searches`)),`Explored ${n.join(` · `)}`}function an(e){return`${e} earlier tool call${e===1?``:`s`}`}var on=[`Web search`,`Ran`,`Edit`,`Write`,`Read`,`Search`,`Fetch`,`Task:`];function sn(e){for(let t of on)if(e.startsWith(`${t} `)&&e.length>t.length+1)return{verb:t===`Task:`?`Task`:t,detail:e.slice(t.length+1)};return{verb:e}}function cn(e){let t=e.filter(e=>!(e.kind===`tool`&&e.toolKind===`plan`)&&!(e.kind===`reasoning`&&e.text.trim()===``)),n=new Set(t.filter($t).map(e=>e.id)),r=new Map,i=[];for(let e of t){let t=(e.kind===`message`||e.kind===`reasoning`||e.kind===`tool`)&&e.parentItemId!==void 0&&e.parentItemId!==e.id&&n.has(e.parentItemId)?e.parentItemId:void 0;if(t===void 0)i.push(e);else{let n=r.get(t);n?n.push(e):r.set(t,[e])}}let a=[],o=[],s=()=>{if(o.length>=2){let e=o.filter(e=>e.toolKind===`read`).length;a.push({kind:`context-group`,id:`group:${o[0].id}`,tools:o,files:e,searches:o.length-e,label:rn(e,o.length-e)})}else for(let e of o)a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]});o=[]},c=[],l=()=>{if(c.length!==0){for(let e of ln(c).batches)a.push({kind:`worker-conversation`,id:`worker:${e.messages[0].id}`,batches:[e]});c=[]}};for(let e of i){if(en(e)){s(),c.push(e);continue}l(),$t(e)&&tn(e)&&!r.has(e.id)?o.push(e):(s(),$t(e)?a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]}):a.push({kind:`entry`,id:e.id,entry:e}))}s(),l();let u=e=>e.kind===`context-group`||e.kind===`tool-card`&&e.item.status===`completed`,d=e=>e.kind===`context-group`?e.tools.length:1,f=[],p=[],m=()=>{if(p.length>3){let e=p.slice(0,p.length-3);f.push({kind:`streak`,id:`streak:${e[0].id}`,count:e.reduce((e,t)=>e+d(t),0),blocks:e}),f.push(...p.slice(p.length-3))}else f.push(...p);p=[]};for(let e of a)u(e)?p.push(e):(m(),f.push(e));return m(),f}function ln(e){let t=[];for(let n of e){let e=t.at(-1);n.messageKind===`request`&&e?.kind===`request`&&e.senderRunId===n.senderRunId&&e.text===n.text&&!e.messages.some(e=>e.recipientRunId===n.recipientRunId)?e.messages.push(n):t.push({id:`worker-batch:${n.messageId}`,kind:n.messageKind,text:n.text,senderRunId:n.senderRunId,messages:[n]})}return{kind:`worker-conversation`,id:`worker:${e[0].id}`,batches:t}}var un=new Map,dn=(0,Y.createContext)(null);function fn(){return(0,Y.useContext)(dn)}function pn({runId:e,children:t}){let n=(0,Y.useMemo)(()=>({get:t=>un.get(e)?.get(t),set:(t,n)=>{let r=un.get(e)??new Map;r.set(t,n),un.set(e,r)}}),[e]);return(0,X.jsx)(dn.Provider,{value:n,children:t})}var mn=(0,Y.createContext)({targets:new Map,replies:new Map,navigate:()=>{}});function hn(e){return e.scrollTop<Math.max(600,e.clientHeight)}function gn(e,t){let n=t.find(({bottom:t})=>t>e);return n===void 0?void 0:{key:n.key,offset:n.top-e}}function _n(e,t,n,r,i){if(n===void 0)return i;let a=r.find(({key:e})=>e===n.key);return a===void 0?i:e+(a.top-t-n.offset)}function vn(e,t=24){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function yn(e,t){let n=new URLSearchParams(e).get(`thread`);return n===`flat`||n===`virtual`?n:t>300?`virtual`:`flat`}var bn=new Map;function xn(e,t){bn.set(e,t)}function Sn(e){return bn.get(e)}var Cn=new Map;function wn(e,t){Cn.set(e,t)}function Tn(e,t){let n=Cn.get(e);return n!==void 0&&n.rows===t?n.cache:void 0}function En(e,t){let n={[e.id]:k(e)};for(let e of t??[])n[e.id]=k(e);return n}function Z(e,t){return t?.[e]??`Task`}function Dn(e,t){return e.senderRunId===t?`outbound`:`inbound`}function On(e){switch(e){case`request`:return`Request`;case`progress`:return`Progress`;case`follow-up`:return`Follow-up`;case`reply`:return`Reply`;default:return e}}function kn(e){switch(e){case`pending`:return`Pending`;case`replied`:return`Replied`;case`timed-out`:return`Timed out`;case`cancelled`:return`Cancelled`;case`completed-without-reply`:return`Completed without reply`;case`failed`:return`Failed`;case`destroyed`:return`Destroyed`;case`sender-closed`:return`Sender closed`;case`human-fallback`:return`Sent to a human`;default:return e}}function An(e){if(e.outcome)return kn(e.outcome.status);if(e.delivery===`not-delivered`)return jn(`not-delivered`)}function jn(e){switch(e){case`queued`:return`Queued`;case`delivered`:return`Delivered`;case`consumed`:return`Read`;case`not-delivered`:return`Not delivered`;default:return e}}var Mn={user:{label:`YOUR MESSAGE`,speaker:`Your message`,classes:`border-message-user-border bg-message-user-bg`,accent:`text-message-user-accent`,body:`max-md:text-[12px]`},agent:{label:`AGENT RESPONSE`,speaker:`Agent response`,classes:`border-message-agent-border bg-message-agent-bg`,accent:`text-message-agent-accent`,body:`max-w-[65ch] text-[15px] md:text-[14px]`}};function Nn({role:e,children:t,className:n,...r}){let i=Mn[e];return(0,X.jsxs)(`article`,{...r,"data-role":e,"aria-label":i.speaker,className:U(`flex w-full min-w-0 flex-col gap-2 self-stretch rounded-[8px] border p-3 md:px-4 md:py-[14px]`,i.classes,n),children:[(0,X.jsxs)(`p`,{className:U(`m-0 flex items-center gap-2 text-[11px] leading-[1.2] font-semibold tracking-[0.6px] uppercase`,i.accent),children:[(0,X.jsx)(mt,{"aria-hidden":`true`,className:`size-4 shrink-0`}),i.label]}),(0,X.jsx)(`div`,{className:U(`min-w-0 break-words text-[14px] text-foreground select-text [overflow-wrap:anywhere]`,i.body,`leading-[1.6]`),children:t})]})}function Pn({text:e,imageCount:t=0,images:n=[],onEdit:r,onRemove:i,editLabel:a=`Edit message`,removeLabel:o=`Remove message`}){let s=t-n.length,[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(e),[f,p]=(0,Y.useState)(!1),[m,g]=(0,Y.useState)(),_=()=>{d(e),g(void 0),l(!0)},v=async()=>{let t=u.trim();if(!t||t===e){l(!1);return}p(!0),g(void 0);try{await r?.(t),l(!1)}catch(e){g(e instanceof Error?e.message:`Could not save the message`)}finally{p(!1)}},y=async()=>{p(!0),g(void 0);try{await i?.()}catch(e){g(e instanceof Error?e.message:`Could not remove the message`)}finally{p(!1)}};return c?(0,X.jsxs)(Nn,{role:`user`,"data-slot":`user-bubble`,"data-editing":`true`,children:[(0,X.jsx)(`textarea`,{autoFocus:!0,"aria-label":`Edit the message`,value:u,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.stopPropagation(),l(!1)):e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),v())},className:`block max-h-[220px] min-h-[60px] w-full resize-none rounded-md bg-background px-2 py-1.5 text-[14px] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}),(0,X.jsxs)(`span`,{className:`mt-1.5 flex justify-end gap-1.5`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>l(!1),disabled:f,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm px-2 text-xs font-medium text-muted-foreground hover:bg-background hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:`Cancel`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void v(),disabled:f,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm bg-action px-2 text-xs font-semibold text-action-foreground hover:brightness-[0.96] focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:f?(0,X.jsx)(pt,{className:`size-3.5 animate-spin`}):`Save`})]}),m?(0,X.jsx)(`p`,{role:`alert`,className:`mt-1.5 text-xs text-danger`,children:m}):null]}):(0,X.jsxs)(Nn,{role:`user`,"data-slot":`user-bubble`,className:`group`,children:[r||i?(0,X.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`mb-1 flex justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100`,children:[r?(0,X.jsx)(`button`,{type:`button`,"aria-label":a,onClick:_,disabled:f,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,X.jsx)(Ut,{className:`size-3.5`})}):null,i?(0,X.jsx)(`button`,{type:`button`,"aria-label":o,onClick:()=>void y(),disabled:f,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-danger focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,X.jsx)(h,{className:`size-3.5`})}):null]}):null,m?(0,X.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:m}):null,(0,X.jsx)(_t,{breaks:!0,children:e}),n.length>0?(0,X.jsx)(`span`,{"data-slot":`user-images`,className:`mt-2 flex flex-wrap items-center justify-end gap-1.5`,children:n.map(e=>De(e.split(`/`).pop()??``)?(0,X.jsx)(Dt,{src:e,alt:`attached`,className:`max-h-40 max-w-[220px] rounded-md border border-border object-contain`},e):(0,X.jsxs)(`a`,{href:xe(e),download:!0,"data-slot":`user-file`,className:`inline-flex min-h-11 min-w-11 max-w-[220px] items-center gap-1.5 rounded-md border border-border bg-background/60 px-2 py-1 text-xs text-muted-foreground hover:text-foreground`,children:[(0,X.jsx)(b,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,X.jsx)(`span`,{className:`truncate`,children:e.split(`/`).pop()})]},e))}):null,s>0?(0,X.jsxs)(`span`,{className:`mt-1 block text-xs text-soft-foreground`,children:[s,` image`,s>1?`s`:``,` attached`]}):null]})}function Fn({text:e}){return(0,X.jsx)(Nn,{role:`agent`,"data-slot":`assistant-message`,children:(0,X.jsx)(_t,{children:e})})}var In={outbound:{classes:`border-message-outbound-border bg-message-outbound-bg`,accent:`text-message-outbound-accent`},inbound:{classes:`border-message-inbound-border bg-message-inbound-bg`,accent:`text-message-inbound-accent`}},Ln=`inline-flex min-h-11 max-w-full items-center break-words underline underline-offset-4 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`;function Rn({block:e,runId:t,taskTitles:n}){return(0,X.jsx)(`div`,{"data-slot":`worker-conversation`,className:`flex min-w-0 flex-col gap-2`,children:e.batches.map(e=>(0,X.jsx)(zn,{batch:e,runId:t,taskTitles:n},e.id))})}function zn({batch:e,runId:t,taskTitles:n}){let r=Dn(e.messages[0]??{senderRunId:e.senderRunId},t),i=In[r],a=Un(e.messages.map(e=>r===`outbound`?e.recipientRunId:e.senderRunId)),o=r===`outbound`?`SENT to`:`RECEIVED from`,s=`${o} ${a.map(e=>Z(e,n)).join(`, `)}`,c=e.messages[0],l=c?An(c):void 0;return(0,X.jsxs)(`article`,{"data-slot":`worker-conversation-card`,"data-direction":r,"data-kind":e.kind,className:U(`flex w-full min-w-0 flex-col gap-2 rounded-[8px] border p-3 md:px-4 md:py-[14px]`,i.classes),children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`p`,{className:U(`m-0 flex min-w-0 flex-wrap items-center gap-x-2 text-[11px] leading-[1.2] font-semibold tracking-[0.6px] uppercase`,i.accent),children:[(0,X.jsx)(`span`,{children:o}),a.map((e,t)=>(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-x-2 normal-case tracking-normal`,children:[t>0?(0,X.jsx)(`span`,{"aria-hidden":!0,children:`,`}):null,(0,X.jsx)(K,{className:Ln,to:`/tasks/${e}`,"aria-label":`${o} ${Z(e,n)}`,children:Z(e,n)})]},e))]}),(0,X.jsx)(`span`,{"data-slot":`conversation-kind`,className:`rounded-full bg-background/60 px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-foreground uppercase`,children:On(e.kind)}),e.messages.length===1&&l?(0,X.jsx)(`span`,{"data-slot":`conversation-outcome`,className:`text-xs font-medium text-muted-foreground`,children:l}):null]}),(0,X.jsx)(`div`,{className:`min-w-0 break-words text-[14px] leading-[1.6] text-foreground select-text [overflow-wrap:anywhere]`,children:(0,X.jsx)(_t,{breaks:!0,children:e.text})}),[...new Set(e.messages.map(e=>e.instruction??(e.delivery===`queued`?`Queued for the next safe turn. Pending messages are delivered together within the batch size limit; human questions and scheduler capacity can delay delivery.`:e.state===`continuation-required`?`Not delivered. The recipient needs a new instruction to resume. A parent can resume its owned worker with --resume; workers cannot resume parents.`:e.state===`destroyed`?`Not delivered. This worker was destroyed.`:void 0)))].map(e=>e?(0,X.jsx)(`p`,{"data-slot":`conversation-delivery-explanation`,className:`min-w-0 text-xs leading-relaxed text-muted-foreground [overflow-wrap:anywhere]`,children:e},e):null),e.kind===`request`&&e.messages.length>1?(0,X.jsx)(`ul`,{className:`grid min-w-0 gap-1 text-xs text-muted-foreground`,children:e.messages.map(e=>{let r=An(e);return(0,X.jsxs)(`li`,{className:`flex min-h-11 min-w-0 flex-wrap items-center gap-2`,children:[(0,X.jsx)(K,{className:Ln,to:`/tasks/${e.recipientRunId}`,"aria-label":`${Z(e.recipientRunId,n)}${r?` — ${r}`:``}`,children:Z(e.recipientRunId,n)}),r?(0,X.jsx)(`span`,{"data-slot":`conversation-outcome`,children:r}):null,(0,X.jsx)(Bn,{message:e,runId:t,taskTitles:n})]},e.id)})}):null,e.messages.length===1&&c?(0,X.jsx)(Bn,{message:c,runId:t,taskTitles:n}):null,(0,X.jsx)(Vn,{batch:e,heading:s})]})}function Bn({message:e,runId:t,taskTitles:n}){let{targets:r,replies:i,navigate:a}=(0,Y.useContext)(mn),o=e.requestId?r.get(e.requestId):void 0,s=e.requestId?o?[o]:[]:i.get(e.messageId)??[],c=e.requestId?`request`:`reply`;return s.length===0?e.requestId||e.outcome?.replyId?(0,X.jsxs)(`p`,{"data-slot":`conversation-connector`,className:`text-xs text-muted-foreground`,children:[`Linked `,c,` is outside loaded history.`]}):null:s.map(e=>{let r=Dn(e.message,t)===`outbound`,i=r?e.message.recipientRunId:e.message.senderRunId;return(0,X.jsxs)(`button`,{type:`button`,"data-slot":`conversation-connector`,className:U(Ln,`w-fit gap-1.5 text-xs text-muted-foreground`),onClick:()=>a(e),children:[(0,X.jsx)(`span`,{"aria-hidden":!0,children:`↗`}),`View `,c,` `,r?`to`:`from`,` `,Z(i,n)]},e.message.messageId)})}function Vn({batch:e,heading:t}){return(0,X.jsxs)(Oe,{"data-slot":`conversation-details`,className:`group/details`,children:[(0,X.jsxs)(G,{type:`button`,className:`inline-flex min-h-11 min-w-11 items-center gap-1.5 rounded-md px-2 text-left text-xs font-medium text-muted-foreground hover:bg-background/40 hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:[(0,X.jsx)(j,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/details:rotate-90`}),`Details`]}),(0,X.jsx)(W,{children:(0,X.jsxs)(`dl`,{className:`grid min-w-0 gap-1 break-all px-2 pb-1 font-mono text-[11px] text-muted-foreground`,children:[(0,X.jsx)(`div`,{className:`sr-only`,children:t}),e.messages.flatMap(e=>Hn(e)).map((e,t)=>(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`dt`,{className:`inline font-sans font-medium text-soft-foreground`,children:[e.label,`: `]}),(0,X.jsx)(`dd`,{className:`inline`,children:e.value})]},`${e.label}:${e.value}:${t}`))]})})]})}function Hn(e){let t=[{label:`Message`,value:e.messageId},{label:`Sender`,value:e.senderRunId},{label:`Recipient`,value:e.recipientRunId},{label:`Delivery`,value:jn(e.delivery)}];return e.requestId&&t.push({label:`Request`,value:e.requestId}),e.outcome?.replyId&&t.push({label:`Reply`,value:e.outcome.replyId}),e.state&&t.push({label:`State`,value:e.state}),e.createdAt&&t.push({label:`Created`,value:e.createdAt}),e.deliveredAt&&t.push({label:e.resumed?`Opening turn completed`:`Delivery acknowledged`,value:e.deliveredAt}),e.recordedAt&&t.push({label:`Event recorded`,value:e.recordedAt}),e.resumed&&t.push({label:`Continuation`,value:`Requested by parent with this instruction`}),e.deadline&&t.push({label:`Deadline`,value:e.deadline}),e.requestHash&&t.push({label:`Hash`,value:e.requestHash}),t}function Un(e){let t=new Set,n=[];for(let r of e)t.has(r)||(t.add(r),n.push(r));return n}function Wn({note:e}){return(0,X.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,className:U(`px-0.5 text-xs`,e.tone===`danger`?`text-danger [.light_&]:text-red-700`:`text-soft-foreground`),children:[e.tone===`danger`?`✗ `:`· `,e.text]})}var Gn={claude:`Claude Code`,codex:`Codex`,opencode:`OpenCode`,pi:`pi`,cursor:`Cursor`};function Kn({incident:e}){let t=Gn[e.provider];return(0,X.jsxs)(`div`,{role:`alert`,"data-slot":`provider-auth-required`,className:`rounded-md border border-danger/30 bg-danger/5 px-3.5 py-3`,children:[(0,X.jsxs)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:[`This run needed `,t,` authorization`]}),(0,X.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Review `,t,` settings before retrying.`]}),(0,X.jsx)(K,{to:`/settings/agents#providers`,className:`mt-2 inline-flex text-xs font-medium text-foreground underline-offset-2 hover:underline`,children:`Open provider settings`})]})}function qn({text:e}){let t=(0,Y.useId)();if(e.trim()===``)return null;let n=e.split(`
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Ba as r,Bi as i,Ca as a,Dt as o,Et as s,Fa as c,Fn as l,Ga as u,H as d,Ha as f,Ia as p,J as m,Jt as h,La as g,Ln as _,Lr as v,Na as y,Pt as b,Q as x,Rr as S,Rt as C,Vi as w,Vn as T,Wa as E,X as D,Xn as O,Xr as k,Y as A,Z as j,at as M,bi as N,d as P,dr as F,en as I,et as L,ga as R,hi as z,ht as B,in as V,it as ee,ja as te,jn as ne,ki as re,mi as ie,mn as ae,mr as oe,n as se,nt as ce,qt as H,si as le,t as ue,ti as de,tr as fe,ur as pe,vn as me,wi as he,xa as ge,xt as _e}from"./centered-state-DXxIJA15.js";import{C as ve,S as ye,T as be,c as xe,i as Se,n as Ce,s as we,t as U,w as Te,x as Ee,y as De}from"./utils-DKheTxGD.js";import{n as W,r as G,t as Oe}from"./collapsible-D3Lh_nlG.js";import{n as ke,s as Ae,t as je}from"./agent-accounts-tNk0wiKj.js";import{t as Me}from"./textarea-BOXhPgVD.js";import{t as Ne}from"./createLucideIcon-BHp8sXmF.js";import{D as Pe,_ as Fe,d as Ie,h as Le,j as Re,k as ze,l as Be,m as Ve,s as He,u as Ue,x as We}from"./pill-BU5y1CTd.js";import{t as Ge}from"./external-link-BE6y205O.js";import{I as Ke,S as qe,_ as Je,b as Ye,c as Xe,g as Ze,l as Qe,v as $e,x as et}from"./prompt-templates-D8lCwJds.js";import{a as tt,c as nt,d as rt,i as it,l as at,n as ot,o as st,r as ct,s as lt,t as ut,u as dt}from"./run-header-DYiqx0qE.js";import{s as ft,t as K,u as pt}from"./project-router-EEnXzYjj.js";import{t as mt}from"./message-square-B-MD-8rD.js";import{t as ht}from"./search-x-I9Q8pgUa.js";import{t as gt}from"./square-terminal-B6RYYieR.js";import{t as _t}from"./markdown-0VE-LMFx.js";import{c as vt,i as yt,l as bt,n as xt,o as St,s as Ct,t as wt}from"./thread-loading-D9dDLmql.js";import{t as Tt}from"./use-submit-shortcut-KWJsC906.js";import{t as Et}from"./lib-BQXq3kEf.js";import{t as Dt}from"./zoomable-image-YW3Qdrr_.js";import{t as Ot}from"./run-diff-C-Ij6Y04.js";import{t as kt}from"./use-desktop-BaYgO7YW.js";var At=120;function jt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Mt(e){let t=e.replace(/\s+/g,` `).trim();return t.length>At?`${t.slice(0,At-1)}…`:t}function q(e,...t){if(jt(e))for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim()!==``)return Mt(t)}}function Nt(e){if(!jt(e))return;let t=e.command;if(typeof t==`string`&&t.trim()!==``)return Mt(t);if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return Mt(e.join(` `))}}function Pt(e){if(!jt(e)||!Array.isArray(e.changes))return[];let t=[];for(let n of e.changes)jt(n)&&typeof n.path==`string`&&n.path.trim()!==``&&t.push(n.path);return t}function Ft(e){return q(e,`description`,`query`,`url`,`filePath`,`file_path`,`path`,`pattern`,`name`)}function J(e,t){return t?`${e} ${t}`:e}function It(e,t){let n=typeof e==`string`?e.toLowerCase():``;switch(n){case`bash`:case`commandexecution`:return{toolKind:`execute`,title:J(`Ran`,Nt(t)),subtitle:q(t,`description`)};case`edit`:case`multiedit`:return{toolKind:`edit`,title:J(`Edit`,q(t,`file_path`,`filePath`,`path`))};case`write`:return{toolKind:`edit`,title:J(`Write`,q(t,`file_path`,`filePath`,`path`))};case`notebookedit`:return{toolKind:`edit`,title:J(`Edit`,q(t,`notebook_path`,`notebookPath`,`file_path`,`filePath`,`path`))};case`filechange`:{let e=Pt(t);return{toolKind:`edit`,title:J(`Edit`,e.length===1?e[0]:e.length>1?`${e.length} files`:void 0)}}case`read`:return{toolKind:`read`,title:J(`Read`,q(t,`file_path`,`filePath`,`path`))};case`imageview`:return{toolKind:`read`,title:J(`View image`,q(t,`path`))};case`glob`:case`grep`:return{toolKind:`search`,title:J(`Search`,q(t,`pattern`,`query`)),subtitle:q(t,`path`)};case`webfetch`:return{toolKind:`fetch`,title:J(`Fetch`,q(t,`url`))};case`websearch`:return{toolKind:`fetch`,title:J(`Web search`,q(t,`query`))};case`task`:case`agent`:{let e=n===`agent`?`Agent`:`Task`,r=q(t,`subagent_type`,`subagentType`),i=q(t,`description`,`prompt`)??r;return{toolKind:`task`,title:i?`${e}: ${i}`:e,subtitle:i===r?void 0:r}}case`skill`:{let e=q(t,`skill`,`name`,`command`);return{toolKind:`task`,title:e?`Skill: ${e}`:`Skill`,subtitle:q(t,`args`,`description`)}}case`todowrite`:case`todolist`:case`plan`:case`taskcreate`:case`taskupdate`:case`tasklist`:return{toolKind:`plan`,title:`Update plan`};case`contextcompaction`:return{toolKind:`other`,title:`Compacted context`};case`mcptoolcall`:{let e=q(t,`server`),n=q(t,`tool`);return e&&n?{toolKind:`other`,title:`${e}.${n}`}:{toolKind:`other`,title:`MCP tool`,subtitle:Ft(t)}}}if(n.startsWith(`mcp__`)){let t=e.split(`__`).filter(e=>e!==``);if(t.length>=3)return{toolKind:`other`,title:`${t[1]}.${t.slice(2).join(`__`)}`}}return{toolKind:`other`,title:typeof e==`string`&&e.trim()!==``?Mt(e):`Tool`,subtitle:Ft(t)}}var Lt=class extends f{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,d=i&&c===`forward`,f=o&&c===`backward`,p=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:E(t,n.data),hasPreviousPage:u(t,n.data),isFetchNextPageError:l,isFetchingNextPage:d,isFetchPreviousPageError:f,isFetchingPreviousPage:p,isRefetchError:s&&!l&&!f,isRefetching:a&&!d&&!p}}};function Rt(e,t){return g(e,Lt,t)}var zt=Ne(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),Bt=Ne(`corner-up-left`,[[`path`,{d:`M20 20v-7a4 4 0 0 0-4-4H4`,key:`1nkjon`}],[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}]]),Vt=Ne(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),Ht=Ne(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),Ut=Ne(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),Y=e(t(),1),Wt=[`run-event`,`ui-event`];function Gt(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!=`object`||!t||Array.isArray(t))return null;let{seq:n,type:r}=t;return typeof n!=`number`||typeof r!=`string`||r===``?null:t}function Kt(e,t={}){let[n,r]=(0,Y.useState)([]),{cursor:i,afterSeq:a=0,maxEvents:o,compactAt:s,onCompact:c}=t;return(0,Y.useEffect)(()=>{if(r([]),!e)return;let t=globalThis.EventSource;if(typeof t!=`function`)return;let n=a,l=null,u,d=!1,f=!1,p=Date.now(),m,h=e=>{p=Date.now();let t=Gt(e.data);!t||!(t.seq>n)||(n=t.seq,r(e=>{let n=[...e,t];return!f&&s!==void 0&&n.length>=s&&(f=!0,queueMicrotask(()=>{d||c?.()})),o===void 0||n.length<=o?n:n.slice(-o)}))},g=()=>{p=Date.now()},_=()=>{d||u!==void 0||(u=setTimeout(()=>{u=void 0,d||v()},1500))},v=()=>{l?.close(),p=Date.now();let r=new URLSearchParams;i!==void 0&&r.set(`cursor`,i),(i!==void 0||a>0)&&r.set(`afterSeq`,String(n));let o=r.size>0?`?${r.toString()}`:``;l=new t(Se(`/runs/${encodeURIComponent(e)}/events${o}`),{withCredentials:!0});for(let e of Wt)l.addEventListener(e,h);l.addEventListener(`ping`,g),l.addEventListener(`error`,()=>{l?.readyState===2&&_()})},y=()=>{document.visibilityState===`visible`&&(!l||l.readyState===2)&&(clearTimeout(u),u=void 0,v())},b=()=>{clearTimeout(u),u=void 0,l?.close()},x=e=>{e.persisted&&v()};return m=setInterval(()=>{d||document.visibilityState!==`visible`||Date.now()-p<=4e4||(clearTimeout(u),u=void 0,v())},1e4),document.addEventListener(`visibilitychange`,y),window.addEventListener(`pagehide`,b),window.addEventListener(`pageshow`,x),v(),()=>{d=!0,clearTimeout(u),clearInterval(m),document.removeEventListener(`visibilitychange`,y),window.removeEventListener(`pagehide`,b),window.removeEventListener(`pageshow`,x),l?.close()}},[e,i,a,o,s,c]),n}var qt=5,Jt=200,Yt=5e3;function Xt(...e){let t=new Map;for(let n of e)for(let e of n)t.set(e.seq,e);return[...t.values()].sort((e,t)=>e.seq-t.seq)}function Zt(e){let t=we(),n=r(),a=[`run-history`,t,e],o=[`run-history-context`,t,e],s=Rt({queryKey:a,enabled:e!==void 0,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>i(e,t,{signal:n}),getPreviousPageParam:e=>e.olderCursor,getNextPageParam:e=>e.newerCursor,maxPages:qt,retry:1}),c=p({queryKey:o,enabled:e!==void 0,queryFn:({signal:t})=>w(e,{signal:t}),retry:1}),l=s.isError||c.isError,u=Kt(l?e:void 0),d=s.data?.pages??[],f=d.reduce((e,t)=>t.newerCursor===void 0?t:e??t,void 0),m=(0,Y.useRef)(!1),h=(0,Y.useCallback)(()=>{e===void 0||m.current||(m.current=!0,i(e,void 0).then(r=>{n.setQueryData([`run-history`,t,e],e=>{if(!e)return{pages:[r],pageParams:[void 0]};let t=[...e.pages],n=[...e.pageParams],i=-1;for(let e=0;e<t.length;e+=1)(i===-1||t[e].asOfSeq>t[i].asOfSeq)&&(i=e);for(i>=0&&t[i].newerCursor===void 0?(t[i]=r,n[i]=void 0):(t.push(r),n.push(void 0));t.length>qt;)t.shift(),n.shift();return{pages:t,pageParams:n}})}).catch(()=>{}).finally(()=>{m.current=!1}))},[n,e,t]),g=Kt(!l&&f?e:void 0,{cursor:f?.liveCursor,afterSeq:f?.asOfSeq,maxEvents:Yt,compactAt:Jt,onCompact:h}),_=(0,Y.useMemo)(()=>Xt(...d.map(e=>e.events)),[d]),v=(0,Y.useMemo)(()=>l?u:Xt(_,g),[l,u,_,g]),y=(0,Y.useMemo)(()=>{if(l)return u;let e=c.data?.contextEvents??[],t=c.data?.asOfSeq??0;return Xt(e,v.filter(({seq:e})=>e>t))},[c.data,l,u,v]),b=(0,Y.useCallback)(async()=>{await s.fetchPreviousPage()},[s.fetchPreviousPage]),x=(0,Y.useCallback)(async()=>{l||await n.resetQueries({queryKey:a,exact:!0})},[l,a,n]);return{visibleEvents:v,currentEvents:y,isPending:!l&&s.isPending,contextPending:!l&&c.isPending,fallback:l,hasOlder:!l&&!!s.hasPreviousPage,isFetchingOlder:s.isFetchingPreviousPage,olderError:s.isFetchPreviousPageError?s.error instanceof Error?s.error.message:`Could not load earlier items`:void 0,loadOlder:b,jumpToLatest:x,retainedPages:d.length}}var X=n();function Qt({run:e}){let t=r(),n=c({mutationFn:()=>ie(e.id),onSuccess:()=>{t.invalidateQueries({queryKey:V.runs.detail(e.id)}),t.invalidateQueries({queryKey:V.runs.list()}),R(`This task will not resume itself`)},onError:e=>R(e.message,{tone:`danger`})});if(e.status!==`failed`||!e.autoResumeAt)return null;let i=new Date(e.autoResumeAt);if(!Number.isFinite(i.getTime()))return null;let o=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(i);return(0,X.jsxs)(`div`,{"data-slot":`auto-resume-hint`,role:`status`,className:`flex flex-wrap items-center gap-x-2 gap-y-1 px-1 text-xs text-muted-foreground`,children:[(0,X.jsx)(ze,{tone:`pending`,pulse:!0}),(0,X.jsxs)(`span`,{children:[`Usage limit reached — this task resumes automatically at`,` `,(0,X.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:o})]}),(0,X.jsx)(`button`,{type:`button`,"data-action":`auto-resume-cancel`,disabled:n.isPending,onClick:()=>n.mutate(),className:`font-medium text-foreground underline decoration-border underline-offset-2 hover:decoration-foreground disabled:opacity-50`,children:`Don’t resume`}),(0,X.jsx)(a,{to:`/settings/global/resources`,"data-slot":`auto-resume-settings-link`,className:`font-medium text-foreground underline decoration-border underline-offset-2 hover:decoration-foreground`,children:`Auto-resume settings`})]})}var $t=e=>e.kind===`tool`,en=e=>e.kind===`conversation`,tn=e=>(e.toolKind===`read`||e.toolKind===`search`)&&e.status===`completed`,nn=(e,t,n)=>`${e} ${e===1?t:n}`;function rn(e,t){let n=[];return e>0&&n.push(nn(e,`file`,`files`)),t>0&&n.push(nn(t,`search`,`searches`)),`Explored ${n.join(` · `)}`}function an(e){return`${e} earlier tool call${e===1?``:`s`}`}var on=[`Web search`,`Ran`,`Edit`,`Write`,`Read`,`Search`,`Fetch`,`Task:`];function sn(e){for(let t of on)if(e.startsWith(`${t} `)&&e.length>t.length+1)return{verb:t===`Task:`?`Task`:t,detail:e.slice(t.length+1)};return{verb:e}}function cn(e){let t=e.filter(e=>!(e.kind===`tool`&&e.toolKind===`plan`)&&!(e.kind===`reasoning`&&e.text.trim()===``)),n=new Set(t.filter($t).map(e=>e.id)),r=new Map,i=[];for(let e of t){let t=(e.kind===`message`||e.kind===`reasoning`||e.kind===`tool`)&&e.parentItemId!==void 0&&e.parentItemId!==e.id&&n.has(e.parentItemId)?e.parentItemId:void 0;if(t===void 0)i.push(e);else{let n=r.get(t);n?n.push(e):r.set(t,[e])}}let a=[],o=[],s=()=>{if(o.length>=2){let e=o.filter(e=>e.toolKind===`read`).length;a.push({kind:`context-group`,id:`group:${o[0].id}`,tools:o,files:e,searches:o.length-e,label:rn(e,o.length-e)})}else for(let e of o)a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]});o=[]},c=[],l=()=>{if(c.length!==0){for(let e of ln(c).batches)a.push({kind:`worker-conversation`,id:`worker:${e.messages[0].id}`,batches:[e]});c=[]}};for(let e of i){if(en(e)){s(),c.push(e);continue}l(),$t(e)&&tn(e)&&!r.has(e.id)?o.push(e):(s(),$t(e)?a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]}):a.push({kind:`entry`,id:e.id,entry:e}))}s(),l();let u=e=>e.kind===`context-group`||e.kind===`tool-card`&&e.item.status===`completed`,d=e=>e.kind===`context-group`?e.tools.length:1,f=[],p=[],m=()=>{if(p.length>3){let e=p.slice(0,p.length-3);f.push({kind:`streak`,id:`streak:${e[0].id}`,count:e.reduce((e,t)=>e+d(t),0),blocks:e}),f.push(...p.slice(p.length-3))}else f.push(...p);p=[]};for(let e of a)u(e)?p.push(e):(m(),f.push(e));return m(),f}function ln(e){let t=[];for(let n of e){let e=t.at(-1);n.messageKind===`request`&&e?.kind===`request`&&e.senderRunId===n.senderRunId&&e.text===n.text&&!e.messages.some(e=>e.recipientRunId===n.recipientRunId)?e.messages.push(n):t.push({id:`worker-batch:${n.messageId}`,kind:n.messageKind,text:n.text,senderRunId:n.senderRunId,messages:[n]})}return{kind:`worker-conversation`,id:`worker:${e[0].id}`,batches:t}}var un=new Map,dn=(0,Y.createContext)(null);function fn(){return(0,Y.useContext)(dn)}function pn({runId:e,children:t}){let n=(0,Y.useMemo)(()=>({get:t=>un.get(e)?.get(t),set:(t,n)=>{let r=un.get(e)??new Map;r.set(t,n),un.set(e,r)}}),[e]);return(0,X.jsx)(dn.Provider,{value:n,children:t})}var mn=(0,Y.createContext)({targets:new Map,replies:new Map,navigate:()=>{}});function hn(e){return e.scrollTop<Math.max(600,e.clientHeight)}function gn(e,t){let n=t.find(({bottom:t})=>t>e);return n===void 0?void 0:{key:n.key,offset:n.top-e}}function _n(e,t,n,r,i){if(n===void 0)return i;let a=r.find(({key:e})=>e===n.key);return a===void 0?i:e+(a.top-t-n.offset)}function vn(e,t=24){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function yn(e,t){let n=new URLSearchParams(e).get(`thread`);return n===`flat`||n===`virtual`?n:t>300?`virtual`:`flat`}var bn=new Map;function xn(e,t){bn.set(e,t)}function Sn(e){return bn.get(e)}var Cn=new Map;function wn(e,t){Cn.set(e,t)}function Tn(e,t){let n=Cn.get(e);return n!==void 0&&n.rows===t?n.cache:void 0}function En(e,t){let n={[e.id]:k(e)};for(let e of t??[])n[e.id]=k(e);return n}function Z(e,t){return t?.[e]??`Task`}function Dn(e,t){return e.senderRunId===t?`outbound`:`inbound`}function On(e){switch(e){case`request`:return`Request`;case`progress`:return`Progress`;case`follow-up`:return`Follow-up`;case`reply`:return`Reply`;default:return e}}function kn(e){switch(e){case`pending`:return`Pending`;case`replied`:return`Replied`;case`timed-out`:return`Timed out`;case`cancelled`:return`Cancelled`;case`completed-without-reply`:return`Completed without reply`;case`failed`:return`Failed`;case`destroyed`:return`Destroyed`;case`sender-closed`:return`Sender closed`;case`human-fallback`:return`Sent to a human`;default:return e}}function An(e){if(e.outcome)return kn(e.outcome.status);if(e.delivery===`not-delivered`)return jn(`not-delivered`)}function jn(e){switch(e){case`queued`:return`Queued`;case`delivered`:return`Delivered`;case`consumed`:return`Read`;case`not-delivered`:return`Not delivered`;default:return e}}var Mn={user:{label:`YOUR MESSAGE`,speaker:`Your message`,classes:`border-message-user-border bg-message-user-bg`,accent:`text-message-user-accent`,body:`max-md:text-[12px]`},agent:{label:`AGENT RESPONSE`,speaker:`Agent response`,classes:`border-message-agent-border bg-message-agent-bg`,accent:`text-message-agent-accent`,body:`max-w-[65ch] text-[15px] md:text-[14px]`}};function Nn({role:e,children:t,className:n,...r}){let i=Mn[e];return(0,X.jsxs)(`article`,{...r,"data-role":e,"aria-label":i.speaker,className:U(`flex w-full min-w-0 flex-col gap-2 self-stretch rounded-[8px] border p-3 md:px-4 md:py-[14px]`,i.classes,n),children:[(0,X.jsxs)(`p`,{className:U(`m-0 flex items-center gap-2 text-[11px] leading-[1.2] font-semibold tracking-[0.6px] uppercase`,i.accent),children:[(0,X.jsx)(mt,{"aria-hidden":`true`,className:`size-4 shrink-0`}),i.label]}),(0,X.jsx)(`div`,{className:U(`min-w-0 break-words text-[14px] text-foreground select-text [overflow-wrap:anywhere]`,i.body,`leading-[1.6]`),children:t})]})}function Pn({text:e,imageCount:t=0,images:n=[],onEdit:r,onRemove:i,editLabel:a=`Edit message`,removeLabel:o=`Remove message`}){let s=t-n.length,[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(e),[f,p]=(0,Y.useState)(!1),[m,g]=(0,Y.useState)(),_=()=>{d(e),g(void 0),l(!0)},v=async()=>{let t=u.trim();if(!t||t===e){l(!1);return}p(!0),g(void 0);try{await r?.(t),l(!1)}catch(e){g(e instanceof Error?e.message:`Could not save the message`)}finally{p(!1)}},y=async()=>{p(!0),g(void 0);try{await i?.()}catch(e){g(e instanceof Error?e.message:`Could not remove the message`)}finally{p(!1)}};return c?(0,X.jsxs)(Nn,{role:`user`,"data-slot":`user-bubble`,"data-editing":`true`,children:[(0,X.jsx)(`textarea`,{autoFocus:!0,"aria-label":`Edit the message`,value:u,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.stopPropagation(),l(!1)):e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),v())},className:`block max-h-[220px] min-h-[60px] w-full resize-none rounded-md bg-background px-2 py-1.5 text-[14px] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}),(0,X.jsxs)(`span`,{className:`mt-1.5 flex justify-end gap-1.5`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>l(!1),disabled:f,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm px-2 text-xs font-medium text-muted-foreground hover:bg-background hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:`Cancel`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void v(),disabled:f,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm bg-action px-2 text-xs font-semibold text-action-foreground hover:brightness-[0.96] focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:f?(0,X.jsx)(pt,{className:`size-3.5 animate-spin`}):`Save`})]}),m?(0,X.jsx)(`p`,{role:`alert`,className:`mt-1.5 text-xs text-danger`,children:m}):null]}):(0,X.jsxs)(Nn,{role:`user`,"data-slot":`user-bubble`,className:`group`,children:[r||i?(0,X.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`mb-1 flex justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100`,children:[r?(0,X.jsx)(`button`,{type:`button`,"aria-label":a,onClick:_,disabled:f,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,X.jsx)(Ut,{className:`size-3.5`})}):null,i?(0,X.jsx)(`button`,{type:`button`,"aria-label":o,onClick:()=>void y(),disabled:f,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-danger focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,X.jsx)(h,{className:`size-3.5`})}):null]}):null,m?(0,X.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:m}):null,(0,X.jsx)(_t,{breaks:!0,children:e}),n.length>0?(0,X.jsx)(`span`,{"data-slot":`user-images`,className:`mt-2 flex flex-wrap items-center justify-end gap-1.5`,children:n.map(e=>De(e.split(`/`).pop()??``)?(0,X.jsx)(Dt,{src:e,alt:`attached`,className:`max-h-40 max-w-[220px] rounded-md border border-border object-contain`},e):(0,X.jsxs)(`a`,{href:xe(e),download:!0,"data-slot":`user-file`,className:`inline-flex min-h-11 min-w-11 max-w-[220px] items-center gap-1.5 rounded-md border border-border bg-background/60 px-2 py-1 text-xs text-muted-foreground hover:text-foreground`,children:[(0,X.jsx)(b,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,X.jsx)(`span`,{className:`truncate`,children:e.split(`/`).pop()})]},e))}):null,s>0?(0,X.jsxs)(`span`,{className:`mt-1 block text-xs text-soft-foreground`,children:[s,` image`,s>1?`s`:``,` attached`]}):null]})}function Fn({text:e}){return(0,X.jsx)(Nn,{role:`agent`,"data-slot":`assistant-message`,children:(0,X.jsx)(_t,{children:e})})}var In={outbound:{classes:`border-message-outbound-border bg-message-outbound-bg`,accent:`text-message-outbound-accent`},inbound:{classes:`border-message-inbound-border bg-message-inbound-bg`,accent:`text-message-inbound-accent`}},Ln=`inline-flex min-h-11 max-w-full items-center break-words underline underline-offset-4 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`;function Rn({block:e,runId:t,taskTitles:n}){return(0,X.jsx)(`div`,{"data-slot":`worker-conversation`,className:`flex min-w-0 flex-col gap-2`,children:e.batches.map(e=>(0,X.jsx)(zn,{batch:e,runId:t,taskTitles:n},e.id))})}function zn({batch:e,runId:t,taskTitles:n}){let r=Dn(e.messages[0]??{senderRunId:e.senderRunId},t),i=In[r],a=Un(e.messages.map(e=>r===`outbound`?e.recipientRunId:e.senderRunId)),o=r===`outbound`?`SENT to`:`RECEIVED from`,s=`${o} ${a.map(e=>Z(e,n)).join(`, `)}`,c=e.messages[0],l=c?An(c):void 0;return(0,X.jsxs)(`article`,{"data-slot":`worker-conversation-card`,"data-direction":r,"data-kind":e.kind,className:U(`flex w-full min-w-0 flex-col gap-2 rounded-[8px] border p-3 md:px-4 md:py-[14px]`,i.classes),children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`p`,{className:U(`m-0 flex min-w-0 flex-wrap items-center gap-x-2 text-[11px] leading-[1.2] font-semibold tracking-[0.6px] uppercase`,i.accent),children:[(0,X.jsx)(`span`,{children:o}),a.map((e,t)=>(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-x-2 normal-case tracking-normal`,children:[t>0?(0,X.jsx)(`span`,{"aria-hidden":!0,children:`,`}):null,(0,X.jsx)(K,{className:Ln,to:`/tasks/${e}`,"aria-label":`${o} ${Z(e,n)}`,children:Z(e,n)})]},e))]}),(0,X.jsx)(`span`,{"data-slot":`conversation-kind`,className:`rounded-full bg-background/60 px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-foreground uppercase`,children:On(e.kind)}),e.messages.length===1&&l?(0,X.jsx)(`span`,{"data-slot":`conversation-outcome`,className:`text-xs font-medium text-muted-foreground`,children:l}):null]}),(0,X.jsx)(`div`,{className:`min-w-0 break-words text-[14px] leading-[1.6] text-foreground select-text [overflow-wrap:anywhere]`,children:(0,X.jsx)(_t,{breaks:!0,children:e.text})}),[...new Set(e.messages.map(e=>e.instruction??(e.delivery===`queued`?`Queued for the next safe turn. Pending messages are delivered together within the batch size limit; human questions and scheduler capacity can delay delivery.`:e.state===`continuation-required`?`Not delivered. The recipient needs a new instruction to resume. A parent can resume its owned worker with --resume; workers cannot resume parents.`:e.state===`destroyed`?`Not delivered. This worker was destroyed.`:void 0)))].map(e=>e?(0,X.jsx)(`p`,{"data-slot":`conversation-delivery-explanation`,className:`min-w-0 text-xs leading-relaxed text-muted-foreground [overflow-wrap:anywhere]`,children:e},e):null),e.kind===`request`&&e.messages.length>1?(0,X.jsx)(`ul`,{className:`grid min-w-0 gap-1 text-xs text-muted-foreground`,children:e.messages.map(e=>{let r=An(e);return(0,X.jsxs)(`li`,{className:`flex min-h-11 min-w-0 flex-wrap items-center gap-2`,children:[(0,X.jsx)(K,{className:Ln,to:`/tasks/${e.recipientRunId}`,"aria-label":`${Z(e.recipientRunId,n)}${r?` — ${r}`:``}`,children:Z(e.recipientRunId,n)}),r?(0,X.jsx)(`span`,{"data-slot":`conversation-outcome`,children:r}):null,(0,X.jsx)(Bn,{message:e,runId:t,taskTitles:n})]},e.id)})}):null,e.messages.length===1&&c?(0,X.jsx)(Bn,{message:c,runId:t,taskTitles:n}):null,(0,X.jsx)(Vn,{batch:e,heading:s})]})}function Bn({message:e,runId:t,taskTitles:n}){let{targets:r,replies:i,navigate:a}=(0,Y.useContext)(mn),o=e.requestId?r.get(e.requestId):void 0,s=e.requestId?o?[o]:[]:i.get(e.messageId)??[],c=e.requestId?`request`:`reply`;return s.length===0?e.requestId||e.outcome?.replyId?(0,X.jsxs)(`p`,{"data-slot":`conversation-connector`,className:`text-xs text-muted-foreground`,children:[`Linked `,c,` is outside loaded history.`]}):null:s.map(e=>{let r=Dn(e.message,t)===`outbound`,i=r?e.message.recipientRunId:e.message.senderRunId;return(0,X.jsxs)(`button`,{type:`button`,"data-slot":`conversation-connector`,className:U(Ln,`w-fit gap-1.5 text-xs text-muted-foreground`),onClick:()=>a(e),children:[(0,X.jsx)(`span`,{"aria-hidden":!0,children:`↗`}),`View `,c,` `,r?`to`:`from`,` `,Z(i,n)]},e.message.messageId)})}function Vn({batch:e,heading:t}){return(0,X.jsxs)(Oe,{"data-slot":`conversation-details`,className:`group/details`,children:[(0,X.jsxs)(G,{type:`button`,className:`inline-flex min-h-11 min-w-11 items-center gap-1.5 rounded-md px-2 text-left text-xs font-medium text-muted-foreground hover:bg-background/40 hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:[(0,X.jsx)(j,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/details:rotate-90`}),`Details`]}),(0,X.jsx)(W,{children:(0,X.jsxs)(`dl`,{className:`grid min-w-0 gap-1 break-all px-2 pb-1 font-mono text-[11px] text-muted-foreground`,children:[(0,X.jsx)(`div`,{className:`sr-only`,children:t}),e.messages.flatMap(e=>Hn(e)).map((e,t)=>(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`dt`,{className:`inline font-sans font-medium text-soft-foreground`,children:[e.label,`: `]}),(0,X.jsx)(`dd`,{className:`inline`,children:e.value})]},`${e.label}:${e.value}:${t}`))]})})]})}function Hn(e){let t=[{label:`Message`,value:e.messageId},{label:`Sender`,value:e.senderRunId},{label:`Recipient`,value:e.recipientRunId},{label:`Delivery`,value:jn(e.delivery)}];return e.requestId&&t.push({label:`Request`,value:e.requestId}),e.outcome?.replyId&&t.push({label:`Reply`,value:e.outcome.replyId}),e.state&&t.push({label:`State`,value:e.state}),e.createdAt&&t.push({label:`Created`,value:e.createdAt}),e.deliveredAt&&t.push({label:e.resumed?`Opening turn completed`:`Delivery acknowledged`,value:e.deliveredAt}),e.recordedAt&&t.push({label:`Event recorded`,value:e.recordedAt}),e.resumed&&t.push({label:`Continuation`,value:`Requested by parent with this instruction`}),e.deadline&&t.push({label:`Deadline`,value:e.deadline}),e.requestHash&&t.push({label:`Hash`,value:e.requestHash}),t}function Un(e){let t=new Set,n=[];for(let r of e)t.has(r)||(t.add(r),n.push(r));return n}function Wn({note:e}){return(0,X.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,className:U(`px-0.5 text-xs`,e.tone===`danger`?`text-danger [.light_&]:text-red-700`:`text-soft-foreground`),children:[e.tone===`danger`?`✗ `:`· `,e.text]})}var Gn={claude:`Claude Code`,codex:`Codex`,opencode:`OpenCode`,pi:`pi`,cursor:`Cursor`};function Kn({incident:e}){let t=Gn[e.provider];return(0,X.jsxs)(`div`,{role:`alert`,"data-slot":`provider-auth-required`,className:`rounded-md border border-danger/30 bg-danger/5 px-3.5 py-3`,children:[(0,X.jsxs)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:[`This run needed `,t,` authorization`]}),(0,X.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Review `,t,` settings before retrying.`]}),(0,X.jsx)(K,{to:`/settings/agents#providers`,className:`mt-2 inline-flex text-xs font-medium text-foreground underline-offset-2 hover:underline`,children:`Open provider settings`})]})}function qn({text:e}){let t=(0,Y.useId)();if(e.trim()===``)return null;let n=e.split(`
|
|
2
2
|
`,1)[0]??``,r=n.length<e.length;return(0,X.jsxs)(Oe,{"data-slot":`reasoning`,className:`group/reasoning min-w-0`,children:[(0,X.jsxs)(`div`,{id:t,className:`relative flex w-full items-center gap-1.5 rounded-md p-0.5 text-left text-[13px] text-soft-foreground hover:text-muted-foreground`,children:[(0,X.jsx)(j,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/reasoning:rotate-90`}),(0,X.jsx)(`span`,{className:`shrink-0`,children:`Thinking — `}),(0,X.jsx)(`div`,{className:`min-w-0 truncate text-muted-foreground`,children:(0,X.jsx)(_t,{inline:!0,children:n})}),r?(0,X.jsx)(`span`,{"aria-hidden":!0,children:`…`}):null,(0,X.jsx)(G,{"aria-labelledby":t,className:`absolute inset-0 rounded-md focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`})]}),(0,X.jsx)(W,{children:(0,X.jsx)(`div`,{className:`px-6 py-1.5 text-[13px] leading-[1.6] text-soft-foreground`,children:(0,X.jsx)(_t,{children:e})})})]})}function Jn(){return(0,X.jsxs)(`div`,{"data-slot":`working-indicator`,className:`flex items-center gap-2 py-1 text-[13px] text-soft-foreground`,children:[(0,X.jsx)(pt,{role:`status`,"aria-label":`Working`,className:`size-3.5 shrink-0 animate-spin`}),(0,X.jsx)(`span`,{className:`shimmer font-medium`,children:`Working…`})]})}var Yn={read:rt,edit:Ut,delete:h,move:Vt,search:C,execute:gt,think:zt,fetch:Re,task:m,plan:o,other:I},Xn=e=>e.split(`
|
|
3
3
|
`).length;function Zn({text:e,streaming:t}){let[n,r]=(0,Y.useState)(!1),i=(0,Y.useRef)(null),a=(0,Y.useRef)(!0);(0,Y.useEffect)(()=>{let e=i.current;t&&e&&a.current&&(e.scrollTop=e.scrollHeight)},[e,t]);let o=Xn(e),s=!t&&!n&&o>12;return(0,X.jsxs)(`div`,{"data-slot":`tool-output`,"data-clamped":s?`true`:void 0,children:[(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(`div`,{ref:i,onScroll:t?e=>{a.current=vn(e.currentTarget)}:void 0,className:U(`overflow-x-auto`,t&&`max-h-[216px] overflow-y-auto`,s&&`max-h-[216px] overflow-y-hidden`),children:(0,X.jsx)(`pre`,{className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre text-muted-foreground`,children:e})}),s?(0,X.jsx)(`div`,{"data-slot":`tool-output-fade`,"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-0 h-14 bg-gradient-to-b from-transparent to-card-2`}):null]}),!t&&o>12?(0,X.jsx)(`button`,{type:`button`,"data-slot":`tool-output-toggle`,onClick:()=>r(e=>!e),className:`block w-full border-t border-border/50 px-4 py-1.5 text-left text-[11px] font-medium text-soft-foreground hover:text-foreground`,children:n?`Show less`:`Show all ${o} lines`}):null]})}function Qn({diffs:e}){return(0,X.jsx)(X.Fragment,{children:e.map((e,t)=>(0,X.jsxs)(`div`,{"data-slot":`diff-preview`,className:`min-w-0`,children:[(0,X.jsx)(`div`,{className:`border-b border-border/50 px-4 py-1.5 font-mono text-[11px] text-soft-foreground`,children:e.path}),(0,X.jsx)(`pre`,{className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7] whitespace-pre`,children:e.unified===void 0?[...$n(e.oldText).map((e,t)=>(0,X.jsxs)(`span`,{className:`block bg-diff-del px-4 text-muted-foreground`,children:[`- `,e]},`old-${t}`)),...$n(e.newText).map((e,t)=>(0,X.jsxs)(`span`,{className:`block bg-diff-add px-4`,children:[`+ `,e]},`new-${t}`))]:e.unified.split(`
|
|
4
4
|
`).map((e,t)=>(0,X.jsx)(er,{text:e},t))})]},`${e.path}:${t}`))})}function $n(e){return e==null||e===``?[]:e.replace(/\n$/,``).split(`
|
|
5
|
-
`)}function er({text:e}){return(0,X.jsx)(`span`,{className:U(`block px-4`,e.startsWith(`+`)&&`bg-diff-add`,e.startsWith(`-`)&&`bg-diff-del text-muted-foreground`,e.startsWith(`@@`)&&`text-soft-foreground`),children:e})}function tr(e){return e.toolKind===`execute`&&e.status===`running`&&e.output!==void 0}function nr({item:e,nested:t=[],cacheKey:n,renderNested:r}){let i=fn(),[a,o]=(0,Y.useState)(()=>n===void 0?null:i?.get(n)??null),s=e=>{n!==void 0&&i?.set(n,e),o(e)},c=e.status===`running`||e.status===`pending`,l=sn(e.title),{verb:u,detail:d}=e.toolKind===`execute`&&l.detail===void 0?{verb:`Ran`,detail:e.title}:l,f=e.output!==void 0&&e.output!==``||e.error!==void 0&&e.error!==``||e.diffs!==void 0&&e.diffs.length>0||t.length>0,p=d!==void 0||f,m=p&&(a??(f&&tr(e))),h=Yn[e.toolKind]??I;return(0,X.jsxs)(Oe,{"data-slot":`tool-card`,"data-status":e.status,"data-kind":e.toolKind,open:m,onOpenChange:s,className:U(`min-w-0 overflow-hidden rounded-md border bg-card`,e.status===`failed`?`border-danger/25`:`border-border`),children:[(0,X.jsxs)(G,{disabled:!p,className:`group flex min-h-[28px] w-full items-center gap-1.5 px-2.5 py-0.5 text-left text-[13px] enabled:hover:bg-muted`,children:[(0,X.jsx)(j,{"aria-hidden":!0,className:U(`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`,!p&&`invisible`)}),(0,X.jsx)(h,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,X.jsx)(`span`,{className:U(`shrink-0 font-semibold`,c&&`shimmer`,e.status===`declined`&&`text-muted-foreground`),children:u}),d===void 0?null:(0,X.jsx)(`code`,{title:d,className:`block min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground`,children:d}),(0,X.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[c?(0,X.jsx)(pt,{role:`status`,"aria-label":`Running`,className:`size-3.5 animate-spin text-soft-foreground`}):null,e.status===`failed`?(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`failed`}):null,e.status===`declined`?(0,X.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`declined`}):null,e.toolKind===`execute`&&typeof e.exitCode==`number`?(0,X.jsx)(`span`,{"data-slot":`tool-exit`,className:U(`rounded-full px-2 py-px font-mono text-[11px] font-semibold`,e.exitCode===0?`bg-success/10 text-success`:`bg-danger/10 text-danger`),children:e.exitCode}):null]})]}),(0,X.jsx)(W,{children:(0,X.jsxs)(`div`,{className:`border-t border-border bg-card-2`,children:[d===void 0?null:(0,X.jsx)(`pre`,{"data-slot":`tool-command`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:d}),e.error!==void 0&&e.error!==``?(0,X.jsx)(`div`,{"data-slot":`tool-error`,className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre-wrap text-danger`,children:e.error}):null,e.diffs!==void 0&&e.diffs.length>0?(0,X.jsx)(Qn,{diffs:e.diffs}):null,e.output!==void 0&&e.output!==``?(0,X.jsx)(Zn,{text:e.output,streaming:c}):null,t.length>0?(0,X.jsx)(`div`,{"data-slot":`tool-nested`,className:`flex flex-col gap-2 border-l-2 border-border py-2.5 pr-3 pl-3 ml-4 my-2`,children:r?.(t,n??e.id)}):null]})})]})}function rr({group:e,scope:t}){return(0,X.jsxs)(Oe,{"data-slot":`ctx-group`,className:`min-w-0`,children:[(0,X.jsxs)(G,{className:`group flex h-[34px] tabular-nums w-full items-center gap-2 rounded-md px-2 -mx-2 text-left text-[13px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,children:[(0,X.jsx)(j,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`}),e.label]}),(0,X.jsx)(W,{children:(0,X.jsx)(`div`,{className:`flex flex-col gap-1.5 pt-1.5 pl-4`,children:e.tools.map(e=>(0,X.jsx)(nr,{item:e,cacheKey:t===void 0?void 0:`${t}:${e.id}`},e.id))})})]})}function ir({count:e,children:t}){return(0,X.jsxs)(Oe,{"data-slot":`tool-streak`,className:`min-w-0`,children:[(0,X.jsxs)(G,{className:`group flex items-center gap-1.5 rounded-md p-0.5 tabular-nums text-left text-xs text-soft-foreground hover:text-muted-foreground`,children:[(0,X.jsx)(j,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]:rotate-90`}),an(e)]}),(0,X.jsx)(W,{children:(0,X.jsx)(`div`,{className:`flex flex-col gap-2 pt-2`,children:t})})]})}function ar({image:e}){return(0,X.jsx)(Dt,{"data-slot":`thread-image`,src:e.url,alt:e.name??`image from the agent session`,className:`max-h-72 max-w-full self-start rounded-lg border border-border`})}function or(e,t=null){let n=T(),r=ae(),i=Ie(e),a=i&&!e.runner,o=ge(n.data),s=e.runner??(i?r.data?.defaultRunner:void 0)??`claude`,c=qe(t,o,s),l=o.includes(s),u=(i?Ee(e.workflowDef,c):[c]).filter(e=>!o.includes(e)),d=n.isSuccess&&(!a||r.isSuccess)&&u.length===0,f=a&&r.isPending?`Checking task settings…`:a&&r.isError?`Task settings could not be loaded.`:n.isPending?`Checking agent providers…`:n.isError?`Provider authentication could not be verified.`:d?void 0:i?`Connect the required workflow providers (${u.join(`, `)}) to continue.`:`Connect an agent provider to continue.`;return{runners:o,currentRunner:s,runner:c,currentRunnerConnected:l,canContinue:d,providerPending:n.isPending||a&&r.isPending,providerError:n.isError,reason:f,runnerOverride:t!==null||!l?c:void 0}}function sr(e){let t=r(),n=Fe(e).continueRun,i=ae(),[a,o]=(0,Y.useState)(null),[s,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(e.id);m!==e.id&&(h(e.id),o(null),l(null),d(null),p(null));let g=or(e,a),{runners:_,canContinue:v,currentRunner:y,runner:b}=g,x=pe(b,n),S=i.data?.modelsLocked===!0,C=b!==y,w=!S&&!C&&e.model?{...i.data?.defaultModels,[b]:e.model}:i.data?.defaultModels,T=S?null:s,E=$e(b,x.data,[T,w?.[b]]),D=et(T,b,w,x.data),O=Ze(b,D,x.data),k=S?``:u??e.effort??``,A=Ye(k,O),j=!S&&u===null&&k!==``&&A===``,{accounts:P,repoAccount:F}=ke(),I=[...e.steps].reverse().find(e=>e.sessionId),L=I?.profileId??e.agentProfile??`default`,R=C?F:{...F,[y]:L},z=P.some(e=>e.provider===b&&e.id===f)?f:null,ee=c({mutationFn:({text:t,images:n})=>v?N(e.id,{text:t.trim()?t:void 0,images:n.length?n:void 0,runner:g.runnerOverride,model:!S&&s!==null?D:void 0,effort:!S&&u!==null?A:j?``:void 0,agentProfile:z??void 0}):Promise.reject(Error(g.reason??`Connect an agent provider to continue.`)),onSuccess:()=>t.invalidateQueries({queryKey:V.runs.all}),onError:e=>{e instanceof le&&e.status===409&&t.invalidateQueries({queryKey:V.runs.all})}});return{available:n,canContinue:v,startsNewConversation:!!I&&(b!==(I.backend??y)||(z??e.agentProfile??I.profileId??`default`)!==(I.profileId??`default`)),reason:g.reason,providerPending:g.providerPending,pills:(0,X.jsxs)(`div`,{"data-slot":`follow-up-engine`,className:`session-engine-controls`,children:[_.length>1||_.some(e=>je(P,e))?(0,X.jsx)(Qe,{icon:(0,X.jsx)(H,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,runners:_,value:b,accounts:P,account:z,repoAccount:R,onPick:(e,t)=>{p(t),e!==b&&(o(e),l(null))}}):(0,X.jsx)(Xe,{icon:(0,X.jsx)(H,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,readOnly:!0,slot:`session-runner-value`,ariaLabel:`Runner`,label:b,value:b,onPick:()=>{},options:[{value:b,label:b}]}),(0,X.jsx)(Xe,{icon:(0,X.jsx)(M,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`follow-up-model-pill`,ariaLabel:`Model`,label:E.find(e=>e.id===D)?.label??`auto`,value:D,readOnly:S,disabledHint:`Model selection is locked to native coding-agent settings.`,onPick:e=>{l(e);let t=Ze(b,e,x.data);A!==``&&Ye(A,t)===``&&d(``)},options:E.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:Je(b,x.data,x.isError,x.isFetching)}),(0,X.jsx)(Xe,{icon:(0,X.jsx)(B,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`follow-up-effort-pill`,ariaLabel:`Effort`,label:O.find(e=>e.value===A)?.label??`auto`,value:A,readOnly:S,disabledHint:`Effort selection is locked to native coding-agent settings.`,onPick:e=>d(e),options:O.map(e=>({value:e.value,label:e.label,desc:e.desc}))})]}),continueWith:(e,t)=>ee.mutateAsync({text:e,images:t})}}var cr=120,lr=e=>e!==`pending`&&e!==`running`,ur=e=>e.kind===`tool`&&e.toolKind===`task`,Q=e=>ur(e)&&e.parentItemId===void 0,dr=e=>(e.kind===`message`||e.kind===`reasoning`||e.kind===`tool`)&&!(e.kind===`tool`&&e.toolKind===`plan`);function fr(e,t){for(let n=0;n<e.length;n+=1)if(e[n].items.some(e=>Q(e)&&t.has(e.id)))return n;return 0}function pr(e){let t=e.input;if(typeof t!=`object`||!t)return;let n=t;for(let e of[`subagent_type`,`subagentType`,`agent`]){let t=n[e];if(typeof t==`string`&&t.trim()!==``)return t.trim()}}function mr(e){if(e.kind===`tool`)return hr(e.title);if(e.kind===`message`||e.kind===`reasoning`){let t=e.text.split(`
|
|
5
|
+
`)}function er({text:e}){return(0,X.jsx)(`span`,{className:U(`block px-4`,e.startsWith(`+`)&&`bg-diff-add`,e.startsWith(`-`)&&`bg-diff-del text-muted-foreground`,e.startsWith(`@@`)&&`text-soft-foreground`),children:e})}function tr(e){return e.toolKind===`execute`&&e.status===`running`&&e.output!==void 0}function nr({item:e,nested:t=[],cacheKey:n,renderNested:r}){let i=fn(),[a,o]=(0,Y.useState)(()=>n===void 0?null:i?.get(n)??null),s=e=>{n!==void 0&&i?.set(n,e),o(e)},c=e.status===`running`||e.status===`pending`,l=sn(e.title),{verb:u,detail:d}=e.toolKind===`execute`&&l.detail===void 0?{verb:`Ran`,detail:e.title}:l,f=e.output!==void 0&&e.output!==``||e.error!==void 0&&e.error!==``||e.diffs!==void 0&&e.diffs.length>0||t.length>0,p=d!==void 0||f,m=p&&(a??(f&&tr(e))),h=Yn[e.toolKind]??I;return(0,X.jsxs)(Oe,{"data-slot":`tool-card`,"data-status":e.status,"data-kind":e.toolKind,open:m,onOpenChange:s,className:U(`min-w-0 overflow-hidden rounded-md border bg-card`,e.status===`failed`?`border-danger/25`:`border-border`),children:[(0,X.jsxs)(G,{disabled:!p,className:`group flex min-h-[28px] w-full items-center gap-1.5 px-2.5 py-0.5 text-left text-[13px] enabled:hover:bg-muted`,children:[(0,X.jsx)(j,{"aria-hidden":!0,className:U(`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`,!p&&`invisible`)}),(0,X.jsx)(h,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,X.jsx)(`span`,{className:U(`shrink-0 font-semibold`,c&&`shimmer`,e.status===`declined`&&`text-muted-foreground`),children:u}),d===void 0?null:(0,X.jsx)(`code`,{title:d,className:`block min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground`,children:d}),(0,X.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[c?(0,X.jsx)(pt,{role:`status`,"aria-label":`Running`,className:`size-3.5 animate-spin text-soft-foreground`}):null,e.status===`failed`?(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`failed`}):null,e.status===`declined`?(0,X.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`declined`}):null,e.toolKind===`execute`&&typeof e.exitCode==`number`?(0,X.jsx)(`span`,{"data-slot":`tool-exit`,className:U(`rounded-full px-2 py-px font-mono text-[11px] font-semibold`,e.exitCode===0?`bg-success/10 text-success`:`bg-danger/10 text-danger`),children:e.exitCode}):null]})]}),(0,X.jsx)(W,{children:(0,X.jsxs)(`div`,{className:`border-t border-border bg-card-2`,children:[d===void 0?null:(0,X.jsx)(`pre`,{"data-slot":`tool-command`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:d}),e.error!==void 0&&e.error!==``?(0,X.jsx)(`div`,{"data-slot":`tool-error`,className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre-wrap text-danger`,children:e.error}):null,e.diffs!==void 0&&e.diffs.length>0?(0,X.jsx)(Qn,{diffs:e.diffs}):null,e.output!==void 0&&e.output!==``?(0,X.jsx)(Zn,{text:e.output,streaming:c}):null,t.length>0?(0,X.jsx)(`div`,{"data-slot":`tool-nested`,className:`flex flex-col gap-2 border-l-2 border-border py-2.5 pr-3 pl-3 ml-4 my-2`,children:r?.(t,n??e.id)}):null]})})]})}function rr({group:e,scope:t}){return(0,X.jsxs)(Oe,{"data-slot":`ctx-group`,className:`min-w-0`,children:[(0,X.jsxs)(G,{className:`group flex h-[34px] tabular-nums w-full items-center gap-2 rounded-md px-2 -mx-2 text-left text-[13px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,children:[(0,X.jsx)(j,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`}),e.label]}),(0,X.jsx)(W,{children:(0,X.jsx)(`div`,{className:`flex flex-col gap-1.5 pt-1.5 pl-4`,children:e.tools.map(e=>(0,X.jsx)(nr,{item:e,cacheKey:t===void 0?void 0:`${t}:${e.id}`},e.id))})})]})}function ir({count:e,children:t}){return(0,X.jsxs)(Oe,{"data-slot":`tool-streak`,className:`min-w-0`,children:[(0,X.jsxs)(G,{className:`group flex items-center gap-1.5 rounded-md p-0.5 tabular-nums text-left text-xs text-soft-foreground hover:text-muted-foreground`,children:[(0,X.jsx)(j,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]:rotate-90`}),an(e)]}),(0,X.jsx)(W,{children:(0,X.jsx)(`div`,{className:`flex flex-col gap-2 pt-2`,children:t})})]})}function ar({image:e}){return(0,X.jsx)(Dt,{"data-slot":`thread-image`,src:e.url,alt:e.name??`image from the agent session`,className:`max-h-72 max-w-full self-start rounded-lg border border-border`})}function or(e,t=null){let n=T(),r=ae(),i=Ie(e),a=i&&!e.runner,o=ge(n.data),s=e.runner??(i?r.data?.defaultRunner:void 0)??`claude`,c=qe(t,o,s),l=o.includes(s),u=(i?Ee(e.workflowDef,c):[c]).filter(e=>!o.includes(e)),d=n.isSuccess&&(!a||r.isSuccess)&&u.length===0,f=a&&r.isPending?`Checking task settings…`:a&&r.isError?`Task settings could not be loaded.`:n.isPending?`Checking agent providers…`:n.isError?`Provider authentication could not be verified.`:d?void 0:i?`Connect the required workflow providers (${u.join(`, `)}) to continue.`:`Connect an agent provider to continue.`;return{runners:o,currentRunner:s,runner:c,currentRunnerConnected:l,canContinue:d,providerPending:n.isPending||a&&r.isPending,providerError:n.isError,reason:f,runnerOverride:t!==null||!l?c:void 0}}function sr(e){let t=r(),n=Fe(e).continueRun,i=ae(),[a,o]=(0,Y.useState)(null),[s,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(e.id);m!==e.id&&(h(e.id),o(null),l(null),d(null),p(null));let g=or(e,a),{runners:_,canContinue:v,currentRunner:y,runner:b}=g,x=pe(b,n),S=i.data?.modelsLocked===!0,C=b!==y,w=!S&&!C&&e.model?{...i.data?.defaultModels,[b]:e.model}:i.data?.defaultModels,T=S?null:s,E=$e(b,x.data,[T,w?.[b]]),D=et(T,b,w,x.data),O=Ze(b,D,x.data),k=S?``:u??e.effort??``,A=Ye(k,O),j=!S&&u===null&&k!==``&&A===``,{accounts:P,repoAccount:F}=ke(),I=[...e.steps].reverse().find(e=>e.sessionId),L=I?.profileId??e.agentProfile??`default`,R=C?F:{...F,[y]:L},z=P.some(e=>e.provider===b&&e.id===f)?f:null,ee=c({mutationFn:({text:t,images:n})=>v?N(e.id,{text:t.trim()?t:void 0,images:n.length?n:void 0,runner:g.runnerOverride,model:!S&&(s!==null||C)?D:void 0,effort:!S&&(u!==null||C)?A:j?``:void 0,agentProfile:z??void 0}):Promise.reject(Error(g.reason??`Connect an agent provider to continue.`)),onSuccess:()=>t.invalidateQueries({queryKey:V.runs.all}),onError:e=>{e instanceof le&&e.status===409&&t.invalidateQueries({queryKey:V.runs.all})}});return{available:n,canContinue:v,startsNewConversation:!!I&&(b!==(I.backend??y)||(z??e.agentProfile??I.profileId??`default`)!==(I.profileId??`default`)),reason:g.reason,providerPending:g.providerPending,pills:(0,X.jsxs)(`div`,{"data-slot":`follow-up-engine`,className:`session-engine-controls`,children:[_.length>1||_.some(e=>je(P,e))?(0,X.jsx)(Qe,{icon:(0,X.jsx)(H,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,runners:_,value:b,accounts:P,account:z,repoAccount:R,onPick:(e,t)=>{p(t),e!==b&&(o(e),l(null))}}):(0,X.jsx)(Xe,{icon:(0,X.jsx)(H,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,readOnly:!0,slot:`session-runner-value`,ariaLabel:`Runner`,label:b,value:b,onPick:()=>{},options:[{value:b,label:b}]}),(0,X.jsx)(Xe,{icon:(0,X.jsx)(M,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`follow-up-model-pill`,ariaLabel:`Model`,label:E.find(e=>e.id===D)?.label??`auto`,value:D,readOnly:S,disabledHint:`Model selection is locked to native coding-agent settings.`,onPick:e=>{l(e);let t=Ze(b,e,x.data);A!==``&&Ye(A,t)===``&&d(``)},options:E.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:Je(b,x.data,x.isError,x.isFetching)}),(0,X.jsx)(Xe,{icon:(0,X.jsx)(B,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`follow-up-effort-pill`,ariaLabel:`Effort`,label:O.find(e=>e.value===A)?.label??`auto`,value:A,readOnly:S,disabledHint:`Effort selection is locked to native coding-agent settings.`,onPick:e=>d(e),options:O.map(e=>({value:e.value,label:e.label,desc:e.desc}))})]}),continueWith:(e,t)=>ee.mutateAsync({text:e,images:t})}}var cr=120,lr=e=>e!==`pending`&&e!==`running`,ur=e=>e.kind===`tool`&&e.toolKind===`task`,Q=e=>ur(e)&&e.parentItemId===void 0,dr=e=>(e.kind===`message`||e.kind===`reasoning`||e.kind===`tool`)&&!(e.kind===`tool`&&e.toolKind===`plan`);function fr(e,t){for(let n=0;n<e.length;n+=1)if(e[n].items.some(e=>Q(e)&&t.has(e.id)))return n;return 0}function pr(e){let t=e.input;if(typeof t!=`object`||!t)return;let n=t;for(let e of[`subagent_type`,`subagentType`,`agent`]){let t=n[e];if(typeof t==`string`&&t.trim()!==``)return t.trim()}}function mr(e){if(e.kind===`tool`)return hr(e.title);if(e.kind===`message`||e.kind===`reasoning`){let t=e.text.split(`
|
|
6
6
|
`);for(let e=t.length-1;e>=0;--e){let n=t[e].trim();if(n!==``)return hr(n)}}}function hr(e){return e.length>cr?`${e.slice(0,cr-1).trimEnd()}…`:e}function gr(e,t=!1){let n=br(e,e=>e.items.some(Q));if(n===-1)return[];let r=e=>!t&&!lr(e.status),i=[];for(let t=n-1;t>=0;--t){let n=e[t].items.filter(Q);if(n.length!==0){if(!n.some(r))break;i.unshift(...n)}}let a=[...i,...e[n].items.filter(Q)];if(n!==e.length-1&&!a.some(r))return[];let o=new Set(a.map(e=>e.id)),s=i.length>0?fr(e,o):n,c=new Map;for(let t=s;t<e.length;t+=1)for(let n of e[t].items){if(!dr(n))continue;let e=n.parentItemId;if(e===void 0||!o.has(e))continue;let t=c.get(e);t?t.push(n):c.set(e,[n])}return a.map(e=>_r(e,c.get(e.id)??[],t))}function _r(e,t,n){let r={id:e.id,title:sn(e.title).detail??e.title,status:e.status,toolCalls:t.filter(e=>e.kind===`tool`).length},i=pr(e);i!==void 0&&(r.agentType=i),n&&!lr(e.status)&&(r.stalled=!0);for(let e=t.length-1;e>=0;--e){let n=mr(t[e]);if(n!==void 0){r.activity=n;break}}return r}function vr(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.length}}function yr(e){return e.activity??(e.stalled===!0?`never finished`:`starting…`)}function br(e,t){for(let n=e.length-1;n>=0;--n)if(t(e[n]))return n;return-1}function xr(e,t,n=!1){for(let r=e.length-1;r>=0;--r){let i=e[r].items.find(e=>e.id===t&&Q(e));if(i!==void 0)return _r(i,Sr(e,t),n)}}function Sr(e,t){let n=e.findIndex(e=>e.items.some(e=>e.id===t&&Q(e)));if(n===-1)return[];let r=[];for(let i=n;i<e.length;i+=1)for(let n of e[i].items)dr(n)&&n.parentItemId===t&&n.id!==t&&r.push(n);return r}function Cr(e,t={}){let{surface:n=`document`,onLoadOlder:r,onJumpToLatest:i,rowKeys:a=[]}=t,o=(0,Y.useRef)(e);o.current=e;let s=(0,Y.useRef)(null),[c,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(!1),f=(0,Y.useRef)(!0),p=(0,Y.useRef)(0),m=(0,Y.useRef)(null),h=(0,Y.useRef)(null),g=(0,Y.useRef)(null),_=(0,Y.useCallback)(e=>{let t=s.current;if(!t)return;let n=g.current;n?n.scrollTo(e):t.scrollTop=e},[]),v=(0,Y.useCallback)(()=>{let e=s.current;e&&_(e.scrollHeight-e.clientHeight)},[_]),y=(0,Y.useCallback)(()=>{if(s.current){if(h.current!==e){h.current=e;let t=Sn(e);t&&!t.atBottom?(f.current=!1,m.current=t.top):(f.current=!0,m.current=null)}m.current===null?f.current&&v():_(m.current)}},[e,_,v]),b=(0,Y.useCallback)(e=>{l(e),e&&(s.current=e.closest(n===`panel`?`[data-slot="transcript-viewport"]`:`[data-slot="main"]`),y())},[n,y]),x=(0,Y.useCallback)(()=>{f.current&&v()},[v]),S=(0,Y.useRef)(!1),C=(0,Y.useRef)(0),w=(0,Y.useRef)(!1),T=(0,Y.useRef)(void 0),E=(0,Y.useRef)(!1),D=(0,Y.useRef)(!1),O=(0,Y.useRef)(a);O.current=a;let k=(0,Y.useCallback)(e=>[...e.querySelectorAll(`[data-slot="thread-row"][data-row-key]`)].map(e=>{let t=e.getBoundingClientRect();return{key:e.dataset.rowKey,top:t.top,bottom:t.bottom}}),[]),A=(0,Y.useRef)(null),j=(0,Y.useRef)(0),M=(0,Y.useCallback)(()=>{let e=A.current,t=s.current;if(!e||!t)return;A.current=null;let n=e.beforeTop+Math.max(0,t.scrollHeight-e.beforeHeight),r=t.getBoundingClientRect().top,i=e.anchor===void 0?-1:O.current.indexOf(e.anchor.key),a=g.current;a&&i>=0?a.scrollToIndex(i,{align:`start`,offset:-e.anchor.offset}):_(_n(t.scrollTop,r,e.anchor,k(t),n))},[k,_]),N=(0,Y.useCallback)(()=>{let e=s.current;if(!e||!r||S.current)return;m.current=null,f.current=!1,S.current=!0;let t=C.current+1;C.current=t;let n=e.scrollHeight,i=e.scrollTop,a=e.getBoundingClientRect().top,c=gn(a,k(e)),l=c===void 0?-1:O.current.indexOf(c.key),u=o.current,d=j.current;r().then(()=>{o.current===u&&j.current===d&&(A.current={beforeHeight:n,beforeTop:i,anchor:c,anchorIndex:l})},()=>{}).finally(()=>{C.current===t&&(S.current=!1)})},[k,r]);(0,Y.useEffect)(()=>()=>clearTimeout(T.current),[]);let P=(0,Y.useRef)(null);(0,Y.useEffect)(()=>()=>P.current?.disconnect(),[e,c]);let F=(0,Y.useCallback)((t,n)=>{let r=s.current;if(!r||!c)return;m.current=null,j.current+=1,A.current=null,f.current=!1,p.current=0,d(!0),P.current?.disconnect();let i=()=>[...c.querySelectorAll(`[data-row-key]`)].find(e=>e.dataset.rowKey===t),a=()=>{let e=i();return!e||getComputedStyle(e).visibility===`hidden`||(e.tabIndex=-1,e.focus({preventScroll:!0}),document.activeElement!==e)?!1:(P.current?.disconnect(),!0)},o=r.querySelector(`[data-slot="run-header"]`),l=o&&getComputedStyle(o).position===`sticky`?o.getBoundingClientRect().height:0,u=g.current;if(u)u.scrollToIndex(n,{align:`start`,...l>0?{offset:-l}:{}});else{let e=i();e&&_(r.scrollTop+e.getBoundingClientRect().top-r.getBoundingClientRect().top-l)}a()||(P.current=new MutationObserver(()=>{a()}),P.current.observe(c,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`style`,`class`]})),xn(e,{top:r.scrollTop,atBottom:!1})},[c,_,e]),I=(0,Y.useCallback)(()=>{P.current?.disconnect();let t=s.current;if(!t)return;m.current=null,j.current+=1,A.current=null,f.current=!0,xn(e,{top:t.scrollHeight-t.clientHeight,atBottom:!0});let n=()=>{f.current&&v()};(i?.()??Promise.resolve()).finally(()=>{requestAnimationFrame(()=>{n(),requestAnimationFrame(n)})})},[i,e,v]),L=a.at(-1),R=a.length;return(0,Y.useLayoutEffect)(()=>{j.current+=1,A.current=null,S.current=!1},[e]),(0,Y.useLayoutEffect)(()=>{let e=A.current;e?(e.anchor===void 0?-1:O.current.indexOf(e.anchor.key))>e.anchorIndex?M():A.current=null:f.current&&v()},[L,R,M,v]),(0,Y.useLayoutEffect)(()=>{!s.current||!c||y()},[c,y]),(0,Y.useEffect)(()=>{let t=s.current,n=c;if(!t||!n)return;p.current=0;let r=null,i=!1,a=t.scrollTop,o=()=>{P.current?.disconnect(),m.current=null,j.current+=1,A.current=null,f.current=!1,p.current=0},l=()=>{j.current+=1,A.current=null,p.current=Date.now()},u=e=>{if(e.deltaY<0){o();let e=!w.current;w.current=!0,clearTimeout(T.current),T.current=setTimeout(()=>{w.current=!1},180),e&&hn(t)&&N()}else l()},h=e=>{[`ArrowUp`,`PageUp`,`Home`].includes(e.key)?(o(),!e.repeat&&hn(t)&&N()):[`ArrowDown`,`PageDown`,`End`].includes(e.key)&&l()},g=()=>{i=!0,D.current=!1,a=t.scrollTop,vn(t,80)||(o(),l())},y=()=>{i=!1},b=e=>{E.current=!1,r=e.touches[0]?.clientY??null},x=e=>{let n=e.touches[0]?.clientY;n!==void 0&&(r!==null&&n>r+1?(o(),!E.current&&hn(t)&&(E.current=!0,N())):r!==null&&n<r-1&&l(),r=n)},S=()=>{i&&!D.current&&t.scrollTop<a&&hn(t)&&(D.current=!0,N()),a=t.scrollTop;let n=vn(t,80);n&&m.current===null&&(f.current||Date.now()-p.current<2e3)&&(f.current=!0),d(!n),m.current===null&&xn(e,{top:t.scrollTop,atBottom:n})};t.addEventListener(`scroll`,S,{passive:!0}),t.addEventListener(`wheel`,u,{passive:!0}),t.addEventListener(`touchstart`,b,{passive:!0}),t.addEventListener(`touchmove`,x,{passive:!0}),t.addEventListener(`pointerdown`,g,{passive:!0}),window.addEventListener(`pointerup`,y,{passive:!0}),t.addEventListener(`keydown`,h);let C;if(typeof ResizeObserver<`u`){C=new ResizeObserver(()=>{let e=m.current;if(e!==null){let n=t.scrollHeight-t.clientHeight;_(Math.min(e,n)),n>=e&&(m.current=null)}else f.current&&v()}),C.observe(n);let e=n.closest(`[data-route="task-thread"]`),r=e?.querySelector(`[data-slot="run-header"]`),i=e?.querySelector(`[data-slot="thread-dock"]`);r&&C.observe(r),i&&C.observe(i)}return()=>{t.removeEventListener(`scroll`,S),t.removeEventListener(`wheel`,u),t.removeEventListener(`touchstart`,b),t.removeEventListener(`touchmove`,x),t.removeEventListener(`pointerdown`,g),window.removeEventListener(`pointerup`,y),t.removeEventListener(`keydown`,h),C?.disconnect()}},[e,c,N,_,v]),{attachContent:b,scrollElRef:s,virtualizerRef:g,pillVisible:u,jumpToLatest:I,jumpToRow:F,loadOlder:N,restickIfStuck:x}}function wr({runId:e,rows:t,mode:n,controls:r}){return n===`virtual`?(0,X.jsx)(Tr,{runId:e,rows:t,controls:r}):(0,X.jsx)(`div`,{ref:r.attachContent,"data-slot":`thread-rows`,"data-virtualized":`false`,className:`[overflow-anchor:none]`,children:t.map(e=>(0,X.jsx)(`div`,{"data-slot":`thread-row`,"data-row-key":e.key,className:`flex w-full flex-col pb-2.5 [contain-intrinsic-block-size:auto_3rem] [content-visibility:auto]`,children:e.node},e.key))})}function Tr({runId:e,rows:t,controls:n}){return(0,X.jsx)(Er,{runId:e,rows:t,controls:n},e)}function Er({runId:e,rows:t,controls:n}){let r=(0,Y.useRef)(null),i=(0,Y.useRef)(t),a=t[0]?.key,o=i.current[0]?.key,s=a!==o&&(t.some(e=>e.key===o)||i.current.some(e=>e.key===a));(0,Y.useLayoutEffect)(()=>{i.current=t},[t]);let[c]=(0,Y.useState)(()=>Tn(e,t.length)),l=(0,Y.useRef)(t.length);l.current=t.length;let u=(0,Y.useRef)(null),d=(0,Y.useCallback)(t=>{n.virtualizerRef.current=t,t?u.current=t:u.current&&=(wn(e,{rows:l.current,cache:u.current.cache}),null)},[e,n.virtualizerRef]),[f,p]=(0,Y.useState)(0);return(0,Y.useLayoutEffect)(()=>{let e=()=>{let e=r.current,t=n.scrollElRef.current;!e||!t||p(Math.max(0,Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop)))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[n.scrollElRef]),(0,X.jsx)(`div`,{ref:e=>{r.current=e,n.attachContent(e)},"data-slot":`thread-rows`,"data-virtualized":`true`,className:`[overflow-anchor:none]`,children:(0,X.jsx)(Et,{ref:d,scrollRef:n.scrollElRef,startMargin:f,shift:s,...c===void 0?{}:{cache:c},children:t.map(e=>(0,X.jsx)(`div`,{"data-slot":`thread-row`,"data-row-key":e.key,className:`flex w-full flex-col pb-2.5`,children:e.node},e.key))})})}function Dr({onJump:e}){return(0,X.jsxs)(`button`,{type:`button`,"data-slot":`jump-to-latest`,onClick:e,className:`pointer-events-auto inline-flex min-h-11 min-w-11 items-center gap-1.5 rounded-full border border-border bg-background px-3.5 text-xs font-medium text-muted-foreground shadow-modal hover:text-foreground`,children:[(0,X.jsx)(d,{"aria-hidden":!0,className:`size-3.5`}),`Jump to latest`]})}function Or(e,t){let n=[];e.task&&n.push({id:`task`,userMessageKey:`task`,userMessage:{text:e.task,images:e.taskImages??[]},entries:[]});for(let t of e.queuedMessages??[])n.push({id:`queued:${t.id}`,userMessageKey:`queued:${t.id}`,userMessage:{text:t.text,images:t.images??[]},entries:[]});for(let e of t.turns)n.push({id:e.id,userMessageKey:`${e.id}:user`,...e.userMessage===void 0?{}:{userMessage:{text:e.userMessage.text,imageCount:e.userMessage.imageCount,images:e.userMessage.images}},entries:e.items});return n}function kr(e,t){return[{id:`agent:${e}`,entries:t}]}function Ar(e,t){let n=[];for(let t of e){t.userMessage!==void 0&&n.push({key:t.userMessageKey??`${t.id}:user`,scope:t.id,content:{kind:`user-message`,message:t.userMessage}});for(let e of cn([...t.entries]))n.push({key:`${t.id}:${e.id}`,scope:t.id,content:{kind:`block`,block:e}})}return n}function jr({runId:e,viewId:t,sections:n,mode:r,empty:i,renderAsk:a,messageActions:o,scrollControls:s,renderMode:c,taskTitles:l}){let u=(0,Y.useMemo)(()=>Ar(n,e),[n,e]),d=Cr(`${e}:${t}`,{surface:r}),f=s??d,p=(0,Y.useMemo)(()=>{let e=new Map;u.forEach((t,n)=>{if(!(t.content.kind!==`block`||t.content.block.kind!==`worker-conversation`))for(let r of t.content.block.batches)for(let i of r.messages)e.set(i.messageId,{message:i,rowKey:t.key,rowIndex:n})});let t=new Map;for(let n of e.values()){let{message:e}=n;if(e.messageKind!==`reply`||!e.requestId)continue;let r=t.get(e.requestId)??[];r.push(n),t.set(e.requestId,r)}return{targets:e,replies:t,navigate:e=>f.jumpToRow(e.rowKey,e.rowIndex)}},[u,f.jumpToRow]),m=(0,Y.useMemo)(()=>u.map(t=>({key:t.key,node:t.content.kind===`user-message`?(0,X.jsx)(Mr,{message:t.content.message,actions:o?.[t.key]}):(0,X.jsx)(Nr,{block:t.content.block,scope:t.scope,renderAsk:a,runId:e,taskTitles:l})})),[o,a,u,e,l]),h=c??yn(``,m.length),g=m.length===0?i??null:(0,X.jsx)(wr,{runId:`${e}:${t}`,rows:m,mode:h,controls:f});return(0,X.jsx)(at,{runId:e,children:(0,X.jsx)(pn,{runId:e,children:(0,X.jsx)(mn.Provider,{value:p,children:r===`panel`?(0,X.jsxs)(`div`,{"data-slot":`transcript-viewport`,"aria-label":`Agent transcript`,role:`region`,tabIndex:0,className:`relative flex min-h-0 flex-1 flex-col overflow-y-auto [scrollbar-gutter:stable]`,children:[(0,X.jsx)(`div`,{"data-slot":`subagent-stream`,className:`flex flex-col px-5 py-4`,children:g}),f.pillVisible?(0,X.jsx)(`div`,{className:`pointer-events-none sticky inset-x-0 bottom-4 flex justify-center`,children:(0,X.jsx)(Dr,{onJump:f.jumpToLatest})}):null]}):g})})})}function Mr({message:e,actions:t}){return(0,X.jsx)(Pn,{text:e.text,imageCount:e.imageCount,images:e.images,onEdit:t?.onEdit,onRemove:t?.onRemove,editLabel:t?.editLabel,removeLabel:t?.removeLabel})}function Nr({block:e,scope:t,renderAsk:n,runId:r,taskTitles:i}){switch(e.kind){case`entry`:return(0,X.jsx)(Fr,{entry:e.entry,scope:t,renderAsk:n,runId:r,taskTitles:i});case`tool-card`:return(0,X.jsx)(nr,{item:e.item,nested:e.children,cacheKey:`${t}:${e.id}`,renderNested:(e,t)=>(0,X.jsx)(Pr,{entries:e,scope:t,renderAsk:n,runId:r,taskTitles:i})});case`context-group`:return(0,X.jsx)(rr,{group:e,scope:t});case`streak`:return(0,X.jsx)(ir,{count:e.count,children:e.blocks.map(e=>(0,X.jsx)(Nr,{block:e,scope:t,renderAsk:n,runId:r,taskTitles:i},e.id))});case`worker-conversation`:return(0,X.jsx)(Rn,{block:e,runId:r,taskTitles:i});default:return Ir(e)}}function Pr({entries:e,scope:t,renderAsk:n,runId:r,taskTitles:i}){return cn([...e]).map(e=>(0,X.jsx)(Nr,{block:e,scope:t,renderAsk:n,runId:r,taskTitles:i},e.id))}function Fr({entry:e,scope:t,renderAsk:n,runId:r,taskTitles:i}){switch(e.kind){case`message`:return e.role===`assistant`?(0,X.jsx)(Fn,{text:e.text}):(0,X.jsx)(Pn,{text:e.text});case`reasoning`:return(0,X.jsx)(qn,{text:e.text});case`tool`:return(0,X.jsx)(nr,{item:e,cacheKey:`${t}:${e.id}`});case`note`:return e.attribution?(0,X.jsxs)(`div`,{className:`min-w-0 rounded-md border border-border px-4 py-3 text-sm`,children:[(0,X.jsx)(`p`,{className:`mb-2 break-all text-xs text-muted-foreground`,children:e.attribution.source===`agent`?`Agent input from parent ${e.attribution.parentRunId}`:`Worker lifecycle context for parent ${e.attribution.parentRunId}`}),(0,X.jsx)(Wn,{note:e})]}):(0,X.jsx)(Wn,{note:e});case`conversation`:return(0,X.jsx)(Rn,{runId:r,taskTitles:i,block:{kind:`worker-conversation`,id:e.id,batches:[{id:e.id,kind:e.messageKind,text:e.text,senderRunId:e.senderRunId,messages:[e]}]}});case`image`:return(0,X.jsx)(ar,{image:e});case`ask`:return n===void 0?(0,X.jsx)(`div`,{"data-slot":`ask-card`,className:`rounded-lg border border-border bg-card px-4 py-3 text-sm`,children:`The agent asked a question. Open the main session to answer it.`}):n(e);case`provider-auth-required`:return(0,X.jsx)(Kn,{incident:e});default:return Ir(e)}}function Ir(e){throw Error(`Unhandled transcript variant: ${JSON.stringify(e)}`)}function Lr({runId:e,renderAsk:t,agent:n,entries:r,onClose:i,taskTitles:a}){return(0,X.jsx)(yt,{open:n!==void 0,onOpenChange:e=>{e||i()},children:(0,X.jsx)(St,{"data-slot":`subagent-sheet`,side:`right`,className:`flex min-h-0 w-full gap-0 p-0 sm:max-w-xl`,children:n===void 0?null:(0,X.jsx)(Rr,{runId:e,renderAsk:t,agent:n,entries:r,taskTitles:a})})})}function Rr({runId:e,renderAsk:t,agent:n,entries:r,taskTitles:i}){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(vt,{className:`gap-1.5 border-b border-border px-5 py-4`,children:[(0,X.jsxs)(bt,{className:`flex min-w-0 items-center gap-2 pr-8 text-[16px]`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:n.title}),n.agentType===void 0?null:(0,X.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:n.agentType})]}),(0,X.jsxs)(Ct,{"data-slot":`subagent-meta`,className:`flex items-center gap-2 text-xs`,children:[(0,X.jsx)(zr,{status:n.status}),(0,X.jsxs)(`span`,{className:`tabular-nums`,children:[n.toolCalls,` `,n.toolCalls===1?`tool call`:`tool calls`]})]})]}),(0,X.jsx)(jr,{runId:e,viewId:`agent:${n.id}`,sections:kr(n.id,r),mode:`panel`,renderAsk:t,taskTitles:i,empty:(0,X.jsx)(`div`,{"data-slot":`subagent-empty`,className:`py-2 text-[13px] text-muted-foreground`,children:`No attributed output — see the thread card for this agent's result.`})})]})}function zr({status:e}){let t=e===`completed`?`Completed`:e===`failed`?`Failed`:e===`declined`?`Declined`:e===`pending`?`Pending`:`Running`;return(0,X.jsx)(`span`,{"data-slot":`subagent-status`,"data-status":e,className:U(`rounded-full px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] uppercase`,e===`completed`&&`bg-success/15 text-success`,(e===`failed`||e===`declined`)&&`bg-danger/15 text-danger`,(e===`running`||e===`pending`)&&`bg-muted text-muted-foreground`),children:t})}function Br(e){let t=r();return c({mutationFn:()=>re(e),onSuccess:()=>t.invalidateQueries({queryKey:V.runs.all}),onError:e=>R(e.message,{tone:`danger`})})}function Vr({run:e}){return(0,X.jsxs)(`section`,{"data-slot":`review-panel`,"aria-label":`Review the changes`,className:`flex flex-col gap-3`,children:[(0,X.jsxs)(`div`,{"data-slot":`review-banner`,className:`flex items-center gap-2.5 rounded-md border border-accent-strong/30 bg-accent-strong/10 px-3.5 py-2.5`,children:[(0,X.jsx)(Ke,{className:`size-4 shrink-0 text-accent-icon`,"aria-hidden":`true`}),(0,X.jsxs)(`p`,{className:`min-w-0 text-[13px]`,children:[(0,X.jsx)(`span`,{className:`font-semibold`,children:`Review the changes before anything lands.`}),` `,(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:`Read the diff, send notes back, draft a PR — or accept. Nothing merges on its own.`})]})]}),(0,X.jsx)(Ot,{runId:e.id}),(0,X.jsx)(Hr,{run:e})]})}function Hr({run:e}){let t=r(),n=(0,Y.useRef)(null),[i,a]=(0,Y.useState)(``),[o,s]=(0,Y.useState)(null),l=Br(e.id),u=or(e),d=()=>t.invalidateQueries({queryKey:V.runs.all}),f=c({mutationFn:async t=>u.canContinue?N(e.id,{text:`Review feedback:\n${t}`,runner:u.runnerOverride}):null,onSuccess:e=>{e!==null&&(a(``),d())},onError:e=>R(e.message,{tone:`danger`})}),p=c({mutationFn:()=>he(e.id),onSuccess:e=>{R(`Draft PR created — ${e.url}`),d()},onError:e=>{e instanceof le&&e.manual!==void 0&&s(e.manual),R(e.message,{tone:`danger`})}}),m=()=>{let e=i.trim();if(e.length===0){R(`Write what to change first.`),n.current?.focus();return}f.mutate(e)};return(0,X.jsxs)(`div`,{"data-slot":`review-actions`,className:`flex flex-col gap-2`,children:[(0,X.jsx)(Me,{ref:n,"data-slot":`review-notes`,"aria-label":`Notes for the agent`,placeholder:`Notes for the agent — what should change?`,rows:2,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{Tt({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),m())},className:`min-h-[52px] text-[13px]`}),u.canContinue?null:(0,X.jsxs)(`p`,{id:`review-provider-guidance`,className:`flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{children:u.reason}),u.providerPending?null:(0,X.jsx)(K,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(P,{"data-slot":`review-send-back`,variant:`outline`,size:`sm`,title:u.reason??`Send the notes back into the agent's session`,"aria-describedby":u.canContinue?void 0:`review-provider-guidance`,disabled:f.isPending||!u.canContinue,onClick:m,children:[(0,X.jsx)(Bt,{"aria-hidden":`true`}),`Send back`]}),Ce(e.pullRequestUrl)?(0,X.jsx)(P,{asChild:!0,variant:`outline`,size:`sm`,children:(0,X.jsxs)(`a`,{"data-slot":`pr-link`,href:e.pullRequestUrl,target:`_blank`,rel:`noopener noreferrer`,title:`The PR for this task is already open`,children:[(0,X.jsx)(Ge,{"aria-hidden":`true`}),`PR ↗`]})}):(0,X.jsxs)(P,{"data-slot":`review-draft-pr`,variant:`outline`,size:`sm`,title:`Push the branch and open a draft PR`,disabled:p.isPending,onClick:()=>p.mutate(),children:[(0,X.jsx)(_e,{"aria-hidden":`true`}),`Draft PR`]}),e.finishBlocked===null?(0,X.jsxs)(P,{"data-slot":`review-accept`,variant:`primary`,size:`sm`,className:`ml-auto`,title:Be(`review`),disabled:l.isPending,onClick:()=>l.mutate(),children:[(0,X.jsx)(A,{"aria-hidden":`true`}),`Accept`]}):null]}),o===null?null:(0,X.jsx)(Ur,{command:o})]})}function Ur({command:e}){return(0,X.jsxs)(`button`,{type:`button`,"data-slot":`review-manual`,title:`Copy the command`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>R(`Command copied to clipboard.`)).catch(()=>R(`Run manually: ${e}`))},className:`flex w-full min-w-0 items-center gap-1.5 rounded-sm px-1 py-0.5 text-left font-mono text-[11px] text-soft-foreground hover:bg-muted hover:text-foreground`,children:[(0,X.jsx)(ee,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,X.jsxs)(`span`,{className:`truncate`,children:[`manual path: `,e]})]})}function Wr(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}var Gr=1500;function Kr({status:e}){let t=(0,Y.useRef)(e),[n,r]=(0,Y.useState)(!1);return(0,Y.useEffect)(()=>{let n=t.current;if(t.current=e,n!==`review`||e!==`done`||Wr())return;r(!0);let i=setTimeout(()=>r(!1),Gr);return()=>clearTimeout(i)},[e]),n?(0,X.jsxs)(`div`,{"data-slot":`accept-celebration`,"aria-hidden":`true`,className:`pointer-events-none fixed inset-0 isolate z-40`,children:[(0,X.jsx)(se,{}),(0,X.jsx)(`div`,{className:`flex justify-center pt-24`,children:(0,X.jsx)(`span`,{className:`rounded-full border border-accent-strong/30 bg-accent-strong/15 px-4 py-1.5 text-[13px] font-medium text-accent-text shadow-modal`,children:`✓ Changes accepted`})})]}):null}function qr(e){let t=r(),[n,i]=(0,Y.useState)(),a=Ue(e.status);(0,Y.useEffect)(()=>{(!a||n&&n!==e.id)&&i(void 0)},[a,e.id,n]);let o=c({mutationFn:async()=>{i(e.id);try{if(!(await z(e.id)).cancelled)throw Error(`The task changed before Stop was accepted. Check its status and retry.`)}catch(e){throw i(void 0),e}},onSettled:()=>t.invalidateQueries({queryKey:V.runs.all})});return{stopping:!!e.stopping||o.isPending||a&&n===e.id,stop:()=>o.mutateAsync()}}function Jr({agents:e,onSelect:t}){return e.length===0?null:(0,X.jsx)(`ul`,{"data-slot":`agents-list`,className:`flex min-w-0 flex-col gap-[7px]`,children:e.map(e=>(0,X.jsx)(Yr,{agent:e,onSelect:t},e.id))})}function Yr({agent:e,onSelect:t}){let n=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Xr,{status:e.status,stalled:e.stalled===!0}),(0,X.jsx)(`span`,{className:`min-w-0 shrink truncate font-medium`,children:e.title}),e.agentType===void 0?null:(0,X.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:e.agentType}),(0,X.jsx)(`span`,{"data-slot":`agent-activity`,className:`min-w-0 flex-1 truncate text-muted-foreground`,children:yr(e)}),(0,X.jsxs)(`span`,{"data-slot":`agent-tools`,className:`shrink-0 text-muted-foreground tabular-nums`,children:[e.toolCalls,` `,e.toolCalls===1?`tool`:`tools`]})]});return(0,X.jsx)(`li`,{"data-slot":`agent-item`,"data-status":e.status,className:`min-w-0 text-[13px]`,children:t?(0,X.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),"aria-haspopup":`dialog`,className:`flex min-h-5 w-full min-w-0 items-center gap-2.5 rounded-sm text-left hover:bg-muted/50`,children:n}):(0,X.jsx)(`div`,{className:`flex min-h-5 min-w-0 items-center gap-2.5`,children:n})})}function Xr({status:e,stalled:t=!1}){return t?(0,X.jsx)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,"data-stalled":`true`,className:`size-[15px] shrink-0 text-soft-foreground`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeDasharray:`3 2.5`,children:(0,X.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})}):e===`completed`?(0,X.jsxs)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,className:`size-[15px] shrink-0 text-success`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,X.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,X.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`failed`||e===`declined`?(0,X.jsxs)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,className:`size-[15px] shrink-0 text-danger`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,X.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,X.jsx)(`path`,{d:`m9 9 6 6M15 9l-6 6`})]}):(0,X.jsxs)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,className:`size-[15px] shrink-0 animate-pulse motion-reduce:animate-none`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,X.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,X.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]})}function Zr(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.filter(e=>e.status!==`cancelled`).length}}function Qr({entries:e}){return e.length===0?null:(0,X.jsx)(`ul`,{"data-slot":`plan-list`,className:`flex min-w-0 flex-col gap-[7px]`,children:e.map((e,t)=>(0,X.jsx)($r,{entry:e},`${t}:${e.content}`))})}function $r({entry:e}){return(0,X.jsxs)(`li`,{"data-slot":`plan-item`,"data-status":e.status,className:U(`flex min-h-5 min-w-0 items-center gap-2.5 text-[13px]`,e.status===`completed`&&`text-soft-foreground line-through`,e.status===`in_progress`&&`font-medium`,e.status===`pending`&&`text-muted-foreground`,e.status===`cancelled`&&`text-soft-foreground/70 line-through`),children:[(0,X.jsx)(ei,{status:e.status}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e.content}),e.status===`in_progress`?(0,X.jsx)(`span`,{"data-slot":`plan-tag`,className:`ml-auto shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:`in progress`}):null]})}function ei({status:e}){return e===`cancelled`?(0,X.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-soft-foreground/70`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,X.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`,opacity:`.5`}),(0,X.jsx)(`path`,{d:`m8.5 15.5 7-7`})]}):e===`completed`?(0,X.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-success`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,X.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,X.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`in_progress`?(0,X.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 animate-pulse motion-reduce:animate-none`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,X.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,X.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]}):(0,X.jsx)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-soft-foreground`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,X.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})})}var ti={"not-delivered":0,queued:1,delivered:2,consumed:3};function ni(e){for(let t=e.turns.length-1;t>=0;--t){let n=e.turns[t].planEntries;if(n!==void 0)return n}}function ri(e){let t=[];for(let n of e.turns)for(let e of n.items)if(e.kind===`tool`){for(let n of e.locations??[])t.push(n.path);for(let n of e.diffs??[])t.push(n.path)}let n=[];for(let e=t.length-1;e>=0;--e)n.includes(t[e])||n.push(t[e]);return n}function ii(e,t){switch(e){case`waiting`:return{state:`waiting`};case`failed`:return{state:`closed`,tone:`danger`,label:t?`Session failed — ${t}`:`Session failed`};case`review`:return{state:`closed`,tone:`dim`,label:`Session closed — waiting for your review`};case`done`:case`cancelled`:return{state:`closed`,tone:`dim`,label:`Session closed`};default:return null}}function ai(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $(e){return typeof e==`string`?e:void 0}function oi(e){return e===`claude`||e===`codex`||e===`opencode`||e===`pi`||e===`cursor`?e:void 0}function si(e,t){let n=e.replace(/\s*CEZ:DONE\s*$/,``).replace(/\s*CEZ:MONITORING\s*$/,``);return t&&(n=n.replace(/\s*CEZ:ASK[ \t]+[\s\S]*$/,``)),n.includes(`CEZ:`)?n.split(`
|
|
7
7
|
`).filter(e=>!/^CEZ:(?:PR=\d+|ISSUE=\d+|TITLE=.+)\s*$/.test(e)).join(`
|
|
8
8
|
`):n}function ci(e){let t=e=>si(e,!0).replace(/\s+/g,``),n=new Set,r=[];for(let{origin:i,entry:a}of e.entries)if(i===`v2`&&a.kind===`message`){let e=t(a.text);n.add(e),r.push(e)}if(r.length===0)return;n.add(r.join(``));let i=[],a={entries:[],texts:[]},o=()=>{if(a.entries.length>=2&&n.has(t(a.texts.join(``)))){a={entries:[],texts:[]};return}i.push(...a.entries),a={entries:[],texts:[]}};for(let t of e.entries)t.origin===`v1`&&t.entry.kind===`message`?(a.entries.push(t),a.texts.push(t.entry.text)):(o(),i.push(t));o(),e.entries=i}function li(e){if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e)}catch{return String(e)}}var ui=e=>e.kind===`message`||e.kind===`reasoning`||e.kind===`tool`,di=new Set([`pending`,`in_progress`,`completed`,`cancelled`]);function fi(e){if(!ai(e)||!Array.isArray(e.todos))return;let t=[];for(let n of e.todos){if(!ai(n)||typeof n.content!=`string`)return;t.push({content:n.content,status:di.has(n.status)?n.status:`pending`,...typeof n.activeForm==`string`?{activeForm:n.activeForm}:{}})}return t}function pi(e,t={}){let n=[],r=new Map,i,a=0,o,s=e=>{a+=1;let t={id:e===void 0?`turn-fallback-${a}`:`turn-seq-${e}`,entries:[],v2Items:!1};return n.push(t),t},c=()=>n.at(-1)??s(),l=(e,t)=>{let n=$(e.stepId);return n===void 0?t:`${n}:${t}`},u=(e,t,n)=>{let i={...t};if(!e.v2Items){e.v2Items=!0;for(let t of e.entries)t.origin===`v1`&&t.entry.kind===`tool`&&r.delete(t.entry.id);e.entries=e.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`tool`))}let a=r.get(n);if(a&&a.turn===e){a.entry.entry=i,r.set(n,a);return}let o={origin:`v2`,entry:i};e.entries.push(o),r.set(n,{turn:e,entry:o})},d=new Map,f=new Map,p=new Set,m=e=>{if(e.messageKind!==`request`)return;let t=f.get(e.messageId);t&&(e.outcome={status:t.status,...t.replyId===void 0?{}:{replyId:t.replyId},observedAt:t.observedAt})},h=(e,t,n)=>{let r=d.get(e.id);if(r)return(ti[r.delivery]<ti.delivered||ti[t]>ti[r.delivery])&&(r.delivery=t),e.text!==``&&(r.text=e.text),e.state!==void 0&&(r.state=e.state),e.createdAt!==void 0&&(r.createdAt=e.createdAt),e.requestHash!==void 0&&(r.requestHash=e.requestHash),e.deadline!==void 0&&(r.deadline=e.deadline),e.requestId!==void 0&&(r.requestId=e.requestId),e.instruction!==void 0&&(r.instruction=e.instruction),e.resumed!==void 0&&(r.resumed=e.resumed),n?.deliveredAt!==void 0&&(r.deliveredAt=n.deliveredAt),n?.consumedAt!==void 0&&(r.consumedAt=n.consumedAt),n?.recordedAt!==void 0&&(t===`delivered`||r.delivery!==`delivered`)&&(r.recordedAt=n.recordedAt),m(r),r;let i={kind:`conversation`,id:`conversation-message:${e.id}`,messageId:e.id,text:e.text,senderRunId:e.senderRunId,recipientRunId:e.recipientRunId,messageKind:e.kind,delivery:t,...n,...e.instruction===void 0?{}:{instruction:e.instruction},...e.resumed===void 0?{}:{resumed:e.resumed},...e.requestId===void 0?{}:{requestId:e.requestId},...e.state===void 0?{}:{state:e.state},...e.createdAt===void 0?{}:{createdAt:e.createdAt},...e.requestHash===void 0?{}:{requestHash:e.requestHash},...e.deadline===void 0?{}:{deadline:e.deadline}};return m(i),d.set(e.id,i),c().entries.push({origin:`meta`,entry:i}),i};for(let t of e)switch(t.type){case`conversation-message`:{let e=Te.safeParse(t);if(!e.success)break;h(e.data.message,e.data.delivery,{deliveredAt:e.data.deliveredAt,consumedAt:e.data.consumedAt,recordedAt:e.data.ts});break}case`request-outcome`:{let e=be.safeParse(t);if(!e.success||f.has(e.data.outcome.requestId))break;let{outcome:n}=e.data;f.set(n.requestId,n);let r=d.get(n.requestId);r&&m(r);break}case`agent-input`:{let e=ve.safeParse(t);if(!e.success)break;let{input:n}=e.data;if(p.has(n.id))break;if(p.add(n.id),n.conversation){h({id:n.id,text:n.text,createdAt:n.createdAt,...n.conversation},`delivered`,{deliveredAt:n.deliveredAt,recordedAt:e.data.ts});break}c().entries.push({origin:`meta`,entry:{kind:`note`,id:`agent-input:${n.id}`,text:n.text,tone:`dim`,attribution:{source:n.source,parentRunId:n.parentRunId}}});break}case`user-message`:{let e=$(t.text)??``;o&&!o.resolved&&(o.resolved=!0,o.answeredBy=`human`,e!==``&&(o.answer=e),o=void 0);let n=s(t.seq);n.userMessage={text:e,imageCount:typeof t.imageCount==`number`?t.imageCount:0,images:Array.isArray(t.images)?t.images.filter(e=>typeof e==`string`):[]};break}case`turn.started`:{let e=$(t.turnId),r=n.at(-1);r&&r.turnId===void 0&&!r.v2Items?r.turnId=e:s(t.seq).turnId=e;break}case`turn.completed`:{let e=$(t.turnId),r;for(let t=n.length-1;t>=0&&!r;--t)n[t].turnId===e&&(r=n[t]);let i=r??n.at(-1);i&&(i.completed={stopReason:$(t.stopReason)??`end_turn`,...typeof t.costUsd==`number`?{costUsd:t.costUsd}:{}});break}case`item.started`:case`item.updated`:case`item.completed`:{if(!ai(t.item))break;let e=t.item.kind,n=t.item.id;if(e!==`message`&&e!==`reasoning`&&e!==`tool`||typeof n!=`string`||n===``)break;let i=t.item,a=l(t,i.id);u(r.get(a)?.turn??c(),i,a);break}case`item.delta`:{let e=$(t.itemId)??``,n=r.get(l(t,e)),i=$(t.delta)??``;if(!n||i===``||!ui(n.entry.entry))break;let a=n.entry.entry;t.field===`output`&&a.kind===`tool`?a.output=(a.output??``)+i:t.field!==`output`&&a.kind!==`tool`&&(a.text+=i);break}case`text`:{let e=c(),n=$(t.text)??``;if(n===``)break;e.entries.push({origin:`v1`,entry:{kind:`message`,id:`v1:${t.seq}`,role:`assistant`,text:n}});break}case`tool-call`:{let e=c();if(e.v2Items)break;let n=$(t.tool)??`Tool`;if(mi.has(n))break;let i=It(n,t.input);if(i.toolKind===`plan`){let n=fi(t.input);n!==void 0&&(e.planEntries=n)}let a={kind:`tool`,id:$(t.id)??`v1:${t.seq}`,name:n,toolKind:i.toolKind,title:i.title,status:`running`,input:t.input},o={origin:`v1`,entry:a};e.entries.push(o),r.set(a.id,{turn:e,entry:o});break}case`tool-result`:{let e=r.get($(t.toolCallId)??``);if(!e||e.turn.v2Items||e.entry.origin!==`v1`)break;let n=e.entry.entry;if(n.kind!==`tool`)break;n.status=`completed`,n.output=li(t.result);break}case`note`:case`lifecycle`:{let e=$(t.message)??``;if(e===``)break;let n=t.tone===`danger`?`danger`:`dim`;c().entries.push({origin:`meta`,entry:{kind:`note`,id:`v1:${t.seq}`,text:e,tone:n}});break}case`error`:{let e=$(t.message)??``;if(e===``)break;c().entries.push({origin:`meta`,entry:{kind:`note`,id:`v1:${t.seq}`,text:e,tone:`danger`}});break}case`session.error`:{let e=$(t.message)??``;if(e===``)break;c().entries.push({origin:`meta`,entry:{kind:`note`,id:`v2:${t.seq}`,text:e,tone:`danger`}});break}case`step-end`:{if(t.status!==`failed`)break;let e=$(t.error)?` — ${$(t.error)}`:``;c().entries.push({origin:`meta`,entry:{kind:`note`,id:`v1:${t.seq}`,text:`step ${$(t.stepId)??`?`} failed${e}`,tone:`danger`}});break}case`check-output`:{let e=$(t.command)??`check`,n=typeof t.exitCode==`number`?t.exitCode:-1,r={kind:`tool`,id:`v1:${t.seq}`,name:`check`,toolKind:`execute`,title:`Ran ${e}`,status:n===0?`completed`:`failed`,output:$(t.text)??``,exitCode:n};c().entries.push({origin:`meta`,entry:r});break}case`provider-auth-required`:{let e=oi(t.provider),n=$(t.authFailureId);if(e===void 0||n===void 0||n.length<1||n.length>128)break;c().entries.push({origin:`meta`,entry:{kind:`provider-auth-required`,id:`v1:${t.seq}`,provider:e,authFailureId:n}});break}case`image`:{let e=$(t.url);if(e===void 0)break;let n={kind:`image`,id:`v1:${t.seq}`,url:e},r=$(t.name);r!==void 0&&(n.name=r),c().entries.push({origin:`meta`,entry:n});break}case`plan.updated`:Array.isArray(t.entries)&&(c().planEntries=t.entries);break;case`session.ended`:i={reason:$(t.reason)??`end_turn`,...$(t.message)===void 0?{}:{message:$(t.message)}};break;case`ask.requested`:{let e=$(t.requestId);if(e===void 0||!Array.isArray(t.questions))break;let n=t.questions.filter(e=>ai(e)&&typeof e.header==`string`&&Array.isArray(e.options));if(n.length===0)break;let r={kind:`ask`,id:e,questions:n,resolved:!1,askSeq:t.seq};c().entries.push({origin:`meta`,entry:r}),o=r;break}case`worker-question-routed`:if(o&&!o.resolved&&o.askSeq===t.askSeq){o.routedToParent=!0;let e=$(t.parentRunId);e!==void 0&&(o.parentRunId=e)}break;case`worker-question-fallback`:o&&!o.resolved&&o.askSeq===t.askSeq&&(o.routedToParent=!1);break;case`human-input-delivered`:t.source===`parent`&&o&&!o.resolved&&o.askSeq===t.askSeq&&(o.resolved=!0,o.answeredBy=`parent`,o=void 0);break;case`step-start`:case`token-usage`:case`cost`:case`turn-end`:case`done`:case`session`:break;default:break}for(let e of n){if(!e.v2Items)continue;let t=new Set;for(let{origin:n,entry:r}of e.entries)n===`v2`&&r.kind===`message`&&t.add(si(r.text,!0).trim());t.size!==0&&(e.entries=e.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`message`&&t.has(si(e.entry.text,!0).trim()))),ci(e))}for(let e of d.values())e.messageKind!==`request`||e.outcome!==void 0||e.delivery!==`not-delivered`&&(e.state!==void 0&&e.state!==`accepted`||(e.outcome={status:`pending`}));return{turns:n.map((e,r)=>{let i=e.entries.some(({entry:e})=>e.kind===`ask`),a=t.activeTurn===!0&&r===n.length-1;return{id:e.id,...e.turnId===void 0?{}:{turnId:e.turnId},...e.userMessage===void 0?{}:{userMessage:e.userMessage},...e.planEntries===void 0?{}:{planEntries:e.planEntries},...e.completed===void 0?{}:{completed:e.completed},items:e.entries.map(({entry:e})=>e.kind===`message`&&e.role===`assistant`?{...e,text:si(e.text,i||a)}:e)}}),...i===void 0?{}:{sessionEnded:i}}}var mi=new Set([`subAgentActivity`,`collabAgentToolCall`,`collabToolCall`]),hi=new Map,gi=new Map;function _i({run:e,currentThread:t,onOpenWorker:n}){let r=kt(),[i,a]=(0,Y.useState)(()=>hi.get(e.id)??r),[c,l]=(0,Y.useState)({}),u=!(e.status===`running`||e.status===`waiting`)&&e.status!==`queued`,d=e.steps,f=(0,Y.useMemo)(()=>gr(t.turns,u),[t.turns,u]),p=ni(t)??[],h=e.delegation!==void 0&&e.delegation.role!==`invalid`,g=st(e),_=d.length===0||d.every(e=>e.status===`done`||e.status===`skipped`),v=vr(f),y=Zr(p),b=[d.length>0?`workflow`:void 0,f.length>0?`subagents`:void 0,h?`workers`:void 0,p.length>0?`plan`:void 0].filter(e=>e!==void 0);if(b.length===0)return null;let S=t=>c[t]??gi.get(`${e.id}:${t}`)??t===`workers`,C=t=>{let n=!S(t);gi.set(`${e.id}:${t}`,n),l(e=>({...e,[t]:n}))},w=e.status===`done`&&_&&g===`complete`&&v.done===v.total&&y.done===y.total,T=g===`pending`,E=w?`All complete`:e.status===`failed`?`Failed`:e.status===`cancelled`?`Cancelled`:e.status===`running`?`Working`:e.status===`done`?g===`unknown`?`Workers unavailable`:T?`In progress`:`Incomplete`:`In progress`,O=e.status===`failed`||e.status===`cancelled`;return(0,X.jsxs)(`section`,{"data-slot":`run-activity-dock`,"data-state":i?`open`:`collapsed`,className:`min-w-0 overflow-hidden rounded-xl border border-border bg-card shadow-xs`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":i,onClick:()=>{hi.set(e.id,!i),a(!i)},className:`flex min-h-11 w-full min-w-0 items-center gap-2.5 px-3.5 py-2 text-left text-[14px] hover:bg-muted/40`,children:[(0,X.jsx)(s,{"aria-hidden":!0,className:`size-4 shrink-0 text-accent-text`}),(0,X.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Run activity`}),(0,X.jsxs)(`span`,{"data-slot":`run-activity-count`,className:`shrink-0 text-[13px] text-muted-foreground tabular-nums`,children:[`· `,b.length,` `,b.length===1?`section`:`sections`]}),(0,X.jsxs)(`span`,{"data-slot":`run-activity-status`,className:U(`ml-auto flex min-w-0 shrink items-center gap-1.5 truncate text-[13px]`,w?`text-success`:O?`text-danger`:`text-muted-foreground`),children:[w?(0,X.jsx)(x,{"aria-hidden":!0,className:`size-3.5 shrink-0`}):null,(0,X.jsx)(`span`,{className:`truncate`,children:E})]}),(0,X.jsx)(D,{"aria-hidden":!0,className:U(`size-4 shrink-0 text-soft-foreground transition-transform`,i&&`rotate-180`)})]}),i?(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[d.length>0?(0,X.jsx)(lt,{slot:`workflow`,icon:(0,X.jsx)(vi,{steps:d}),title:d[ct(d)].name,meta:nt(ct(d)+1,d.length,r,`step`),open:S(`workflow`),onToggle:()=>C(`workflow`),children:(0,X.jsx)(ot,{steps:d})}):null,f.length>0?(0,X.jsx)(lt,{slot:`subagents`,icon:(0,X.jsx)(m,{className:`size-4`}),title:`Subagents`,meta:nt(v.done,v.total,r),open:S(`subagents`),onToggle:()=>C(`subagents`),children:(0,X.jsx)(Jr,{agents:f,onSelect:n})}):null,h?(0,X.jsx)(tt,{run:e,open:S(`workers`),onToggle:()=>C(`workers`)}):null,p.length>0?(0,X.jsx)(lt,{slot:`plan`,icon:(0,X.jsx)(o,{className:`size-4`}),title:`Plan`,meta:nt(y.done,y.total,r),open:S(`plan`),onToggle:()=>C(`plan`),children:(0,X.jsx)(Qr,{entries:p})}):null]}):null]})}function vi({steps:e}){let t=it(e[ct(e)].status),n=`size-4 shrink-0`;switch(t){case`active`:return(0,X.jsx)(pt,{role:`status`,"aria-label":`Step running`,"data-slot":`workflow-glyph`,"data-visual":t,className:U(n,`animate-spin stroke-pending motion-reduce:animate-none`)});case`failed`:return(0,X.jsx)(ce,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":t,className:U(n,`text-danger`)});case`pending`:return(0,X.jsx)(L,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":t,className:U(n,`text-soft-foreground`)});case`done`:return(0,X.jsx)(x,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":t,className:U(n,`text-success`)})}}function yi(e,t,n){return`${e.header}: ${n?.trim()||t.join(`, `)}`}function bi({ask:e,run:t}){return e.resolved?(0,X.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`true`,className:`rounded-lg border border-border bg-card px-3.5 py-2.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`text-soft-foreground`,children:e.answeredBy===`parent`?`Answered by parent`:`Answered`}),e.answer?(0,X.jsx)(`span`,{className:`ml-1.5 break-words whitespace-pre-line text-foreground`,children:e.answer}):null]}):e.routedToParent?(0,X.jsx)(xi,{ask:e}):(0,X.jsx)(Si,{ask:e,run:t})}function xi({ask:e}){return(0,X.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,"data-routed":`parent`,className:`rounded-lg border border-border bg-card px-4 pt-3.5 pb-3.5`,children:[(0,X.jsx)(`div`,{className:`mb-2.5 flex items-center gap-2`,children:(0,X.jsx)(`span`,{className:`text-xs font-medium text-link-foreground`,children:`The agent is asking its parent`})}),(0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.questions.map((e,t)=>(0,X.jsxs)(`div`,{role:`group`,"aria-label":e.question,children:[(0,X.jsx)(`div`,{className:`mb-0.5 flex items-center gap-2`,children:(0,X.jsx)(`span`,{className:`rounded-md bg-muted px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e.header})}),(0,X.jsx)(`p`,{className:`mb-1.5 break-words text-sm font-semibold text-foreground`,children:e.question}),(0,X.jsx)(`ul`,{className:`flex list-disc flex-col gap-0.5 pl-5 text-[13px] text-muted-foreground`,children:e.options.map(e=>(0,X.jsxs)(`li`,{className:`break-words`,children:[(0,X.jsx)(`span`,{className:`text-foreground`,children:e.label}),e.description?(0,X.jsxs)(`span`,{children:[`: `,e.description]}):null]},e.label))})]},e.id??t))}),(0,X.jsxs)(`p`,{"data-slot":`ask-routed-hint`,className:`mt-3 text-xs text-muted-foreground`,children:[`Routed to parent: answer it in the`,` `,e.parentRunId?(0,X.jsx)(K,{to:`/tasks/${e.parentRunId}`,className:`font-medium text-foreground underline underline-offset-4`,children:`parent task`}):`parent task`,`.`]})]})}function Si({ask:e,run:t}){let n=He(t),r=n.blockedBy!==void 0,i=e.questions,a=i.length===1&&i[0]?.multiSelect!==!0,[o,s]=(0,Y.useState)({}),[c,l]=(0,Y.useState)({}),u=(e,t)=>s(n=>({...n,[e]:t})),d=e=>l(t=>{if(t[e]===void 0)return t;let n={...t};return delete n[e],n}),f=e=>{u(e,[]),l(t=>({...t,[e]:t[e]??``}))},p=i.some((e,t)=>c[t]!==void 0),m=i.every((e,t)=>(o[t]?.length??0)>0||!!c[t]?.trim()),h=()=>void n.send(i.map((e,t)=>yi(e,o[t]??[],c[t])).join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-QTnfLwEv.js";import{i as e,t}from"./react-runtime-CCIEwYL0.js";import{_ as n,d as r,f as i,g as a,h as o,m as s,p as c,tn as l,v as u}from"./centered-state-
|
|
1
|
+
import"./rolldown-runtime-QTnfLwEv.js";import{i as e,t}from"./react-runtime-CCIEwYL0.js";import{_ as n,d as r,f as i,g as a,h as o,m as s,p as c,tn as l,v as u}from"./centered-state-DXxIJA15.js";import{t as d}from"./utils-DKheTxGD.js";e();var f=t();function p({...e}){return(0,f.jsx)(i,{"data-slot":`dialog`,...e})}function m({...e}){return(0,f.jsx)(n,{"data-slot":`dialog-portal`,...e})}function h({className:e,...t}){return(0,f.jsx)(a,{"data-slot":`dialog-overlay`,className:d(`fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function g({className:e,children:t,showCloseButton:n=!0,...r}){return(0,f.jsxs)(m,{"data-slot":`dialog-portal`,children:[(0,f.jsx)(h,{}),(0,f.jsxs)(s,{"data-slot":`dialog-content`,className:d(`fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-card p-6 shadow-modal duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg`,e),...r,children:[t,n&&(0,f.jsxs)(c,{"data-slot":`dialog-close`,className:`absolute top-4 right-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,f.jsx)(l,{}),(0,f.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function _({className:e,...t}){return(0,f.jsx)(`div`,{"data-slot":`dialog-header`,className:d(`flex flex-col gap-2 text-center sm:text-left`,e),...t})}function v({className:e,showCloseButton:t=!1,children:n,...i}){return(0,f.jsxs)(`div`,{"data-slot":`dialog-footer`,className:d(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...i,children:[n,t&&(0,f.jsx)(c,{asChild:!0,children:(0,f.jsx)(r,{variant:`outline`,children:`Close`})})]})}function y({className:e,...t}){return(0,f.jsx)(u,{"data-slot":`dialog-title`,className:d(`text-lg leading-none font-semibold`,e),...t})}function b({className:e,...t}){return(0,f.jsx)(o,{"data-slot":`dialog-description`,className:d(`text-sm text-muted-foreground`,e),...t})}function x({className:e,...t}){return(0,f.jsx)(`textarea`,{"data-slot":`textarea`,className:d(`flex field-sizing-content min-h-16 w-full resize-none rounded-md border border-input bg-[var(--task-brand-bg)] px-3 py-2 text-base shadow-none transition-[color,box-shadow] outline-none placeholder:text-soft-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 md:text-sm`,e),...t})}export{v as a,b as i,p as n,_ as o,g as r,y as s,x as t};
|