@hearsay-tools/squawk 0.19.0-dev.8893 → 0.19.0-dev.8902
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/activity/requests.js +1 -1
- package/dist/activity/requests.js.map +1 -1
- package/dist/activity/text.d.ts +0 -2
- package/dist/activity/text.js +1 -7
- package/dist/activity/text.js.map +1 -1
- package/dist/activity/tool-activity.js +1 -1
- package/dist/activity/tool-activity.js.map +1 -1
- package/dist/activity/wait.js +1 -1
- package/dist/activity/wait.js.map +1 -1
- package/dist/ci-wait/errors.js +2 -2
- package/dist/ci-wait/errors.js.map +1 -1
- package/dist/ci-wait/github.d.ts +22 -30
- package/dist/ci-wait/github.js +27 -9
- package/dist/ci-wait/github.js.map +1 -1
- package/dist/ci-wait/pr-wait-kind.d.ts +2 -2
- package/dist/ci-wait/pr-wait-kind.js +3 -3
- package/dist/ci-wait/pr-wait-kind.js.map +1 -1
- package/dist/ci-wait/pr-wait-port.d.ts +44 -0
- package/dist/ci-wait/pr-wait-port.js +125 -0
- package/dist/ci-wait/pr-wait-port.js.map +1 -0
- package/dist/ci-wait/progress.d.ts +4 -5
- package/dist/ci-wait/progress.js +1 -1
- package/dist/ci-wait/progress.js.map +1 -1
- package/dist/ci-wait/supervisor.d.ts +13 -8
- package/dist/ci-wait/supervisor.js +59 -26
- package/dist/ci-wait/supervisor.js.map +1 -1
- package/dist/ci-wait/tool-catalog.js +1 -1
- package/dist/ci-wait/tool-catalog.js.map +1 -1
- package/dist/core/clamp-text.d.ts +2 -0
- package/dist/core/clamp-text.js +8 -0
- package/dist/core/clamp-text.js.map +1 -0
- package/dist/core/forge-pr-wait.d.ts +99 -0
- package/dist/core/forge-pr-wait.js +20 -0
- package/dist/core/forge-pr-wait.js.map +1 -0
- package/dist/core/forge-registry.d.ts +6 -2
- package/dist/core/forge-registry.js +5 -0
- package/dist/core/forge-registry.js.map +1 -1
- package/dist/features/automations/tools.d.ts +8 -8
- package/dist/plugin/index.d.ts +3 -0
- package/dist/plugin/index.js +2 -0
- package/dist/plugin/index.js.map +1 -1
- package/dist/runs/run-archive.d.ts +72 -72
- package/dist/server/forge/github-forge.js +3 -0
- package/dist/server/forge/github-forge.js.map +1 -1
- package/dist/server/live-routes.d.ts +6 -6
- package/dist/server/runs-routes.d.ts +17 -17
- package/dist/server/server.d.ts +1396 -1396
- package/dist/server/workspace-live-routes.d.ts +6 -6
- package/dist/workflows/input-acknowledgement.d.ts +24 -24
- package/dist/workflows/run/wait-input-descriptors.js +1 -1
- package/dist/workflows/run/wait-input-descriptors.js.map +1 -1
- package/dist/workflows/run/wait-kind-registry.d.ts +3 -2
- package/dist/workflows/run/wait-kind-registry.js.map +1 -1
- package/dist/workflows/run/wait-registration-tool.js +3 -1
- package/dist/workflows/run/wait-registration-tool.js.map +1 -1
- package/package.json +4 -4
- package/web/dist/assets/{accounts-section-DV18K14j.js → accounts-section-CL4_y1Ap.js} +1 -1
- package/web/dist/assets/{activity-motion-U0gkYTm-.js → activity-motion-1nxINCqs.js} +1 -1
- package/web/dist/assets/{activity-route-CKFb-IYI.js → activity-route-yCPzQHRl.js} +1 -1
- package/web/dist/assets/{agent-config-section-X66FRjsE.js → agent-config-section-CO-Bl7d7.js} +1 -1
- package/web/dist/assets/{agent-defaults-section-EEYiGk_Q.js → agent-defaults-section-C90pO0nt.js} +1 -1
- package/web/dist/assets/{appearance-D4I-ANZ_.js → appearance-dgwYTY63.js} +1 -1
- package/web/dist/assets/{archive-on-merge-field-D6y7pCov.js → archive-on-merge-field-DJZVhb_I.js} +1 -1
- package/web/dist/assets/{automations-route-4ahsnx6z.js → automations-route-BhSkU9kZ.js} +2 -2
- package/web/dist/assets/{command-ppU3xBNs.js → command-BMMjB5k9.js} +1 -1
- package/web/dist/assets/{commit-list-Dp0c_x8b.js → commit-list-mYh1t3BD.js} +1 -1
- package/web/dist/assets/{design-icons-CzEoMH9c.js → design-icons-BZt8Kqs9.js} +1 -1
- package/web/dist/assets/{dialog-DXCws12U.js → dialog-CB9ZhEk2.js} +1 -1
- package/web/dist/assets/{diff-n7BcLjSi.js → diff-B4l1BaZJ.js} +2 -2
- package/web/dist/assets/{diff-controls-7hWjGeWp.js → diff-controls-Bs58JOMz.js} +1 -1
- package/web/dist/assets/{diff-view-CJNrRCRI.js → diff-view-BGwOGavy.js} +1 -1
- package/web/dist/assets/{discard-changes-dialog-Bd3w4xOW.js → discard-changes-dialog-Cr1vlcjZ.js} +1 -1
- package/web/dist/assets/dropdown-menu-VFda6KAg.js +1 -0
- package/web/dist/assets/{file-preview-DS5j5uFi.js → file-preview-DqopZwES.js} +1 -1
- package/web/dist/assets/{git-toolbar-D5N_Ucqr.js → git-toolbar-pr68yTY4.js} +1 -1
- package/web/dist/assets/github-BY-X8L5Q.js +1 -0
- package/web/dist/assets/{global-activity-route-DqyHJiZz.js → global-activity-route-XkwjlnaD.js} +1 -1
- package/web/dist/assets/index-BOWGArJd.css +1 -0
- package/web/dist/assets/index-I4_drgNu.js +21 -0
- package/web/dist/assets/{markdown-9FIYg1nH.js → markdown-fuaT5ciN.js} +1 -1
- package/web/dist/assets/{open-in-menu-L5v_AQZt.js → open-in-menu-Uw-sJhbG.js} +1 -1
- package/web/dist/assets/{option-select-CYbw9rk4.js → option-select-_tHcMUWt.js} +1 -1
- package/web/dist/assets/{preferences-section-Do1nZwKg.js → preferences-section-Crh_5QfK.js} +1 -1
- package/web/dist/assets/{preview-pane-connected-o7nx7h4-.js → preview-pane-connected-CLWRxEhI.js} +1 -1
- package/web/dist/assets/{project-location-BFN7mvbZ.js → project-location-DmGO5Dqx.js} +1 -1
- package/web/dist/assets/{projects-section-Bq9DzRDF.js → projects-section-CLPN14JX.js} +1 -1
- package/web/dist/assets/{prompt-templates-section-CNa_K7AU.js → prompt-templates-section-CQHpVrcB.js} +2 -2
- package/web/dist/assets/{reference-chip-O8Bfl1Oi.js → reference-chip-Dk69XD7Q.js} +1 -1
- package/web/dist/assets/{remote-settings-notice-CbCCb3QA.js → remote-settings-notice-C8naX_yp.js} +1 -1
- package/web/dist/assets/{repo-git-Dz3fhj6j.js → repo-git-CTSdvalV.js} +1 -1
- package/web/dist/assets/{report-reader-BfsdCLq-.js → report-reader-DJJixZxy.js} +1 -1
- package/web/dist/assets/{report-selection-cuFCCxDW.js → report-selection-BH0M_8bk.js} +1 -1
- package/web/dist/assets/{reports-Df83TkE3.js → reports-DXfywo34.js} +1 -1
- package/web/dist/assets/{resources-section-CKJGgLWa.js → resources-section-CA-D1Vj2.js} +1 -1
- package/web/dist/assets/review-panel-UI6FQQmp.js +11 -0
- package/web/dist/assets/{run-header-BWNapiIC.js → run-header-DDQU9tCB.js} +2 -2
- package/web/dist/assets/select-QO8XlmjU.js +1 -0
- package/web/dist/assets/{session-context-section-CSDtUgJI.js → session-context-section-CTDQl-i5.js} +1 -1
- package/web/dist/assets/{settings-agent-picker-pMZcMiW4.js → settings-agent-picker-DE5zKJtS.js} +1 -1
- package/web/dist/assets/{settings-list-detail-Ch1KMPjr.js → settings-list-detail-DcRsGkGy.js} +1 -1
- package/web/dist/assets/{settings-save-bar-CFkofH5G.js → settings-save-bar-DM7T22Nr.js} +1 -1
- package/web/dist/assets/{settings-shell-B6-ofejE.js → settings-shell-EOUcgx1J.js} +1 -1
- package/web/dist/assets/{sidebar-section-DwcXrxn2.js → sidebar-section-C69ES3GL.js} +1 -1
- package/web/dist/assets/{skills-DD5hhynR.js → skills-DuaNQ6XW.js} +1 -1
- package/web/dist/assets/task-changes-midIkW0D.js +1 -0
- package/web/dist/assets/{task-commits-D8Pzk4b3.js → task-commits-DAT7-sIh.js} +1 -1
- package/web/dist/assets/{task-file-scope-DPJOeknI.js → task-file-scope-BYAH1Mj8.js} +1 -1
- package/web/dist/assets/{task-files-DJnNyynG.js → task-files-CJaZfp0y.js} +1 -1
- package/web/dist/assets/{task-github-item-Di9HWGn6.js → task-github-item-BnoxG2el.js} +1 -1
- package/web/dist/assets/task-thread-fsRo8vgf.js +2 -0
- package/web/dist/assets/{thread-state-B2dX4psn.js → thread-state-T5A2uz_q.js} +1 -1
- package/web/dist/assets/use-hand-to-agent-state-CqiCI37V.css +1 -0
- package/web/dist/assets/use-hand-to-agent-state-Cy6oaj7k.js +1 -0
- package/web/dist/assets/use-path-bases-x6weDx5i.js +1 -0
- package/web/dist/assets/workflows-CwZ1aiR4.js +7 -0
- package/web/dist/assets/{workspace-tools-6fvZHbrZ.js → workspace-tools-0-Yx7SCS.js} +1 -1
- package/web/dist/assets/{worktrees-section-C1fpzChO.js → worktrees-section-Cn8sFOCC.js} +1 -1
- package/web/dist/index.html +9 -9
- package/web/dist/assets/dropdown-menu-B60L-d_4.js +0 -1
- package/web/dist/assets/github-Bhj0PA8h.js +0 -1
- package/web/dist/assets/index-UMSYsh9P.css +0 -1
- package/web/dist/assets/index-i4Bu7SvU.js +0 -21
- package/web/dist/assets/review-panel-BaUd88ko.js +0 -11
- package/web/dist/assets/select-Cy2NunWj.js +0 -1
- package/web/dist/assets/task-changes-CbWxyOEd.js +0 -1
- package/web/dist/assets/task-thread-gXImKbGN.js +0 -2
- package/web/dist/assets/use-hand-to-agent-state-BHaqyTxa.css +0 -1
- package/web/dist/assets/use-hand-to-agent-state-DhUiLIQg.js +0 -1
- package/web/dist/assets/use-path-bases-BzlzA9bw.js +0 -1
- package/web/dist/assets/workflows-slzqyi2_.js +0 -7
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,r as n,t as r}from"./react-runtime-CCIEwYL0.js";import{o as i,s as a}from"./dist-C_rn70hE.js";import{G as o,J as s,R as c,Ut as l,V as u,Wt as d,Xt as f,Y as p,_ as m,dn as h,dt as g,ln as _,lt as v,nt as y,ot as b,rn as x,rt as S,sn as C,un as w,xt as T,yt as E,z as D}from"./queries-CIeJg62Y.js";import{$r as O,An as k,At as A,Fn as j,Nn as M,Pn as N,Qn as P,Xn as F,Yn as I,Zn as ee,ei as L,hi as R,ii as z,it as B,lt as V,n as H,ot as te,rt as U,tr as ne,vr as W,yr as re}from"./toaster-D0HMoto5.js";import{f as ie,h as ae,n as oe}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{c as se,f as ce,h as le,r as ue,y as de}from"./tasks-table-CvZ2ZyCa.js";import{A as fe,B as pe,V as me,_ as he,at as G,b as ge,c as _e,d as ve,dt as ye,g as be,h as xe,j as Se,m as Ce,n as we,o as Te,p as Ee,st as De,u as Oe}from"./design-icons-BZt8Kqs9.js";import{t as ke}from"./createLucideIcon-BHp8sXmF.js";import{A as Ae,B as je,C as Me,D as Ne,E as Pe,F as Fe,H as Ie,I as Le,L as Re,M as ze,N as Be,O as Ve,P as He,R as Ue,S as We,T as Ge,U as Ke,V as qe,W as Je,_ as Ye,a as Xe,b as Ze,c as Qe,d as $e,f as et,g as tt,h as nt,i as rt,j as it,k as at,l as ot,m as st,n as ct,o as lt,p as ut,r as dt,s as ft,t as pt,u as mt,v as ht,w as gt,x as _t,y as vt,z as yt}from"./review-panel-UI6FQQmp.js";import{a as bt,i as xt,n as St,o as Ct,r as wt,s as Tt,t as Et}from"./run-header-DDQU9tCB.js";import{t as Dt}from"./eye-B8okNWXU.js";import{t as Ot}from"./loader-circle-CPBhhDbB.js";import{a as kt}from"./tool-display-B9NN44oU.js";import{i as At,l as jt,o as Mt,t as Nt}from"./reference-chip-Dk69XD7Q.js";import{a as Pt,i as Ft,n as It,o as Lt,r as Rt,t as zt}from"./thread-state-T5A2uz_q.js";import{t as K}from"./button-C8jUIs8Q.js";import{n as Bt,r as Vt,t as Ht}from"./collapsible-Bx2vViFx.js";import{a as Ut,i as Wt,o as Gt,r as Kt,t as qt}from"./popover-CvL6hQ5c.js";import{s as Jt,t as Yt}from"./project-router-BHFXTx5l.js";import"./attention-V1gJ7gKo.js";import{D as Xt,E as Zt,O as Qt,S as $t,b as en,f as q,u as tn,w as nn,x as rn}from"./task-groups-C9pTQm-2.js";import{t as J}from"./status-dot-BXf-Ubd0.js";import{c as an,i as on,l as sn,o as cn,r as ln,s as un,t as dn}from"./report-selection-BH0M_8bk.js";import{l as fn,m as pn}from"./page-shell-Dky5crRl.js";import{t as mn}from"./centered-state-BgSV4e79.js";import{An as hn,F as gn,I as _n,In as vn,J as yn,K as bn,M as xn,N as Sn,On as Cn,P as wn,Rn as Tn,Tn as En,Z as Dn,_n as On,b as kn,cn as An,en as jn,fn as Mn,gn as Nn,h as Pn,i as Fn,in as In,l as Ln,ln as Rn,m as zn,n as Bn,q as Vn,rn as Hn,s as Un,sn as Wn,un as Gn,v as Kn,yn as qn}from"./index-I4_drgNu.js";import{t as Jn}from"./markdown-fuaT5ciN.js";import{t as Yn}from"./task-file-scope-BYAH1Mj8.js";import{i as Xn}from"./automation-format-DB34jUyF.js";var Zn=ke(`chart-column`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),Y=e(t(),1),X=r();function Qn(e,t,n,r,i,a,o,s,c){let l=Qt(e,In(e)),u=l?l.model:e.model,d=l?l.effort:e.effort,f=!r&&!n&&u?{...i?.defaultModels,[t]:u}:i?.defaultModels,p=r?null:s,m=wn(t,o,a,[p,f?.[t]]),h=_n(p,t,o,f,a),g=Sn(h,a),_=r?``:c??d??``,v=gn(_,g);return{models:m,model:h,effortOptions:g,effort:v,mustClearStoredEffort:!r&&c===null&&_!==``&&v===``}}function $n(e,t,n,r){let i=Zt(e.steps),a=Qt(e,In(e)),o=a?.agentProfile??e.agentProfile??i?.profileId??`default`;return{sessionStep:i,workerStep:a,account:n?r?.[t]??`default`:o}}function er(e,t,n,r,i,a,o,{model:s,effort:c,mustClearStoredEffort:l}){return{text:e.trim()?e:void 0,images:t.length?t:void 0,runner:n,model:!r&&(a!==null||i)?s:void 0,effort:!r&&(o!==null||i)?c:l?``:void 0}}function tr(e,t,n,r){return!!t&&(r!==Xt(t,e)||(n?.agentProfile??e.agentProfile??t.profileId??`default`)!==(t.profileId??`default`))}function nr({models:e,model:t,effortOptions:n,effort:r}){return{modelLabel:e.find(e=>e.id===t)?.label??`Runner default`,effortLabel:n.find(e=>e.value===r)?.label??`Runner default`}}function rr(e){let t=v(),n=Gn(e).continueRun,r=m(),[i,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(null),[c,l]=(0,Y.useState)(null),u=`${e.id}:${Qt(e,In(e))?.id??``}`,[d,p]=(0,Y.useState)(u);d!==u&&(p(u),a(null),s(null),l(null));let g=rt(e,i),{runners:_,canContinue:y,currentRunner:b,runner:S}=g,{sessionStep:T,workerStep:D,account:O}=$n(e,S,S!==b,qn().repoAccount),k=E(),A=k.data?.capabilities?.localHandoff!==!1,M=x(),N=C(S,n&&!k.isPending&&!M.isPending,A?O:null),P=r.data?.modelsLocked===!0,F=S!==b,I=Qn(e,S,F,P,r.data,N.data,M.data,o,c),{models:ee,model:L,effortOptions:R,effort:z}=I,{modelLabel:B,effortLabel:V}=nr(I),H=h({mutationFn:({text:t,images:n})=>y?te(w(e.id),er(t,n,g.runnerOverride,P,F,o,c,I)):Promise.reject(Error(g.reason??`Connect an agent provider to continue.`)),onMutate:()=>w(e.id),onSuccess:(e,n,r)=>t.invalidateAfter(`continue`,r),onError:(e,n,r)=>{e instanceof j&&e.status===409&&r&&t.invalidateAfter(`continue`,r)}}),U=e.delegation?.role===`worker`;return{skillRunner:S,skillAccount:O,available:n,canContinue:y,startsNewConversation:tr(e,T,D,S),reason:g.reason,providerPending:g.providerPending,pills:(0,X.jsx)(ir,{compact:e.status===`review`,summary:`${f(M.data,S)} · ${B} · ${V}`,children:(0,X.jsxs)(Vn,{children:[!U&&(_.length>1||g.signedOut.length>0)?(0,X.jsx)(yn,{icon:(0,X.jsx)(G,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,runners:_,signedOut:g.signedOut,value:S,onPick:e=>{e!==S&&(a(e),s(null))}}):(0,X.jsx)(bn,{icon:(0,X.jsx)(G,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,readOnly:!0,disabledHint:U?`Owned workers keep their runner; change model or effort instead.`:void 0,slot:`session-runner-value`,ariaLabel:`Runner`,label:S,value:S,onPick:()=>{},options:[{value:S,label:S}]}),(0,X.jsx)(bn,{icon:(0,X.jsx)(ge,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`follow-up-model-pill`,ariaLabel:`Model`,label:B,value:L,readOnly:P,disabledHint:`Model selection is locked to native coding-agent settings.`,onPick:e=>{s(e);let t=Sn(e,N.data);z!==``&&gn(z,t)===``&&l(``)},options:ee.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:xn(S,M.data,N)}),(0,X.jsx)(bn,{icon:(0,X.jsx)(fe,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`follow-up-effort-pill`,ariaLabel:`Effort`,label:V,value:z,readOnly:P,disabledHint:`Effort selection is locked to native coding-agent settings.`,onPick:e=>l(e),options:R.map(e=>({value:e.value,label:e.label,desc:e.desc}))})]})},u),continueWith:(e,t)=>H.mutateAsync({text:e,images:t})}}function ir({compact:e,summary:t,children:n}){let[r,i]=(0,Y.useState)(!1),a=(0,Y.useRef)(null),o=e&&!r;return(0,Y.useEffect)(()=>{r&&a.current?.querySelector(`button:not([disabled])`)?.focus()},[r]),(0,X.jsx)(`div`,{ref:a,"data-slot":`follow-up-engine`,"data-folded":o||void 0,className:o?`min-w-0`:`session-engine-controls`,children:o?(0,X.jsxs)(`button`,{type:`button`,"data-slot":`follow-up-engine-summary`,"aria-expanded":!1,"aria-label":`Agent settings: ${t}`,title:`Change the runner, model or effort`,onClick:()=>i(!0),className:`inline-flex min-h-11 max-w-full min-w-0 items-center gap-1.5 rounded-md px-2 text-xs text-muted-foreground transition-colors outline-hidden hover:bg-muted hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50`,children:[(0,X.jsx)(G,{"aria-hidden":`true`,className:`size-4 shrink-0 text-accent-text`}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:t}),(0,X.jsx)(Oe,{"aria-hidden":`true`,className:`size-3.5 shrink-0`})]}):n})}var ar=120,or=e=>e!==`pending`&&e!==`running`,sr=e=>e.kind===`tool`&&e.toolKind===`task`,cr=e=>sr(e)&&e.parentItemId===void 0,lr=e=>Ue(e.kind)&&!(e.kind===`tool`&&e.toolKind===`plan`);function ur(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 dr(e){if(e.kind===`tool`)return fr(e.title);if(e.kind===`hook`)return fr(`${e.event} hook${e.status===`completed`?``:` ${e.status}`}`);if(e.kind===`message`||e.kind===`reasoning`){let t=e.text.split(`
|
|
2
|
+
`);for(let e=t.length-1;e>=0;--e){let n=t[e].trim();if(n!==``)return fr(n)}}}function fr(e){return e.length>ar?`${e.slice(0,ar-1).trimEnd()}…`:e}function pr(e,t=!1,n=e){let r=_r(e,e=>e.items.some(cr));if(r===-1)return[];let i=e=>!t&&!or(e.status),a=e=>i(e)&&e.background===!0,o=[],s=!1;for(let t=r-1;t>=0;--t){let n=e[t].items.filter(cr);n.length!==0&&(!s&&!n.some(i)&&(s=!0),(!s||n.some(a))&&o.unshift(...n))}let c=[...o,...e[r].items.filter(cr)];return r!==e.length-1&&!c.some(i)?[]:c.map(r=>mr(r,xr(n,e,r.id),t))}function mr(e,t,n){let r={id:e.id,title:Re(e.title).detail??e.title,status:e.status,toolCalls:t.filter(e=>e.kind===`tool`).length},i=ur(e);i!==void 0&&(r.agentType=i),n&&!or(e.status)&&(r.stalled=!0);for(let e=t.length-1;e>=0;--e){let n=dr(t[e]);if(n!==void 0){r.activity=n;break}}return r}function hr(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.length}}function gr(e){return e.activity??(e.stalled===!0?`never finished`:`starting…`)}function _r(e,t){for(let n=e.length-1;n>=0;--n)if(t(e[n]))return n;return-1}function vr(e,t,n=!1,r=e){for(let i=e.length-1;i>=0;--i){let a=e[i].items.find(e=>e.id===t&&cr(e));if(a!==void 0)return mr(a,xr(r,e,t),n)}}function yr(e,t){return _r(e,e=>e.items.some(e=>e.id===t&&cr(e)))}function br(e,t,n){let r=[];for(let i=n;i<e.length;i+=1){let n=e[i];for(let e of n.items)lr(e)&&e.parentItemId===t&&e.id!==t&&r.push({entry:e,seqs:n.itemSeqs?.get(e.id)})}return r}function xr(e,t,n){let r=yr(t,n);if(r===-1)return[];let i=br(t,n,r);if(e===t)return i.map(({entry:e})=>e);let a=t[r].itemSeqs?.get(n)?.first,o=e=>a===void 0||e.seqs===void 0||e.seqs.first>a,s=new Map;for(let t of br(e,n,Math.max(yr(e,n),0)))o(t)&&!s.has(t.entry.id)&&s.set(t.entry.id,t);for(let e of i){let t=s.get(e.entry.id);s.set(e.entry.id,t===void 0?e:Sr(t,e))}return[...s.values()].sort(Cr).map(({entry:e})=>e)}function Sr(e,t){return e.seqs===void 0||t.seqs===void 0?e:{entry:(t.seqs.last>e.seqs.last?t:e).entry,seqs:{first:Math.min(e.seqs.first,t.seqs.first),last:Math.max(e.seqs.last,t.seqs.last)}}}function Cr(e,t){return e.seqs===void 0||t.seqs===void 0?0:e.seqs.first-t.seqs.first}function wr(e,t){if(e.kind===`entry`){let n=e.entry;return n.kind===`message`&&n.role===`assistant`?[{messageKey:`${t}:${n.id}`,text:n.text}]:[]}return e.kind===`tool-card`?Le(e.children).flatMap(n=>wr(n,`${t}:${e.id}`)):e.kind===`streak`?e.blocks.flatMap(e=>wr(e,t)):[]}function Tr(e){return e.flatMap((e,t)=>e.content.kind===`block`?wr(e.content.block,e.scope).map(n=>({...n,rowKey:e.key,rowIndex:t})):[])}function Er(e,t,n,r){let i=(0,Y.useContext)(dn),{projectId:a}=ae(),o=(0,Y.useMemo)(()=>Tr(t),[t]);(0,Y.useLayoutEffect)(()=>{if(!i)return;let t=[],s={runId:e,...a?{projectId:a}:{}};for(let e of o){let a=Ie(e.text,s);for(let e of a)t.push(i.register(e.artifactId,e.runId));r===`document`&&a.length>0&&t.push(i.registerOpener(e.messageKey,(t,r)=>{let i=qe(e.messageKey,t);n.jumpToRow(e.rowKey,e.rowIndex,e=>[...e.querySelectorAll(`[id]`)].find(e=>e.id===i)??null,r)}))}return()=>{for(let e of t)e()}},[i,o,e,a,r,n.jumpToRow])}function Dr(e){let t=R();return h({mutationFn:t=>V(e,t),retry:!1,networkMode:`always`,onSettled:()=>{t.invalidateQueries({queryKey:d.runs.all})}})}var Or=e=>(window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}),kr=()=>navigator.onLine;function Ar({permission:e,runId:t,sessionOpen:n=!1}){return e.status!==`pending`||!n?(0,X.jsx)(Mr,{permission:e,state:e.status===`resolved`?`resolved`:`expired`}):(0,X.jsx)(jr,{permission:e,runId:t},e.requestId)}function jr({permission:e,runId:t}){let n=Dr(t),r=(0,Y.useSyncExternalStore)(Or,kr,()=>!1),i=(0,Y.useRef)(!1),[a,o]=(0,Y.useState)(`pending`),[s,c]=(0,Y.useState)(),[l,u]=(0,Y.useState)(),d=async t=>{if(!(i.current||!r||a!==`pending`)){i.current=!0,o(`sending`),u(void 0);try{await n.mutateAsync({requestId:e.requestId,optionId:t}),c(t),o(`resolved`)}catch(e){e instanceof j&&e.status===409?o(`expired`):(u(e instanceof Error?e.message:String(e)),o(`pending`))}finally{i.current=!1}}};return(0,X.jsx)(Mr,{permission:{...e,...s===void 0?{}:{optionId:s}},state:a,offline:!r,error:l,onSelect:e=>{d(e)}})}function Mr({permission:e,state:t,offline:n=!1,error:r,onSelect:i}){let a=(0,Y.useId)(),o=e.options.find(t=>t.id===e.optionId),s=t!==`pending`||n||!i,c=t===`expired`?`Approval expired. This session can no longer accept a decision.`:t===`resolved`?`Decision sent: ${o?.label??`Recorded`}.`:t===`sending`?`Sending decision…`:n?`Offline. Reconnect to send a decision.`:`Choose an option to respond to this permission request.`;return(0,X.jsxs)(`section`,{"data-slot":`permission-card`,"data-request-id":e.requestId,"data-state":n&&t===`pending`?`offline`:t,"aria-labelledby":a,"aria-busy":t===`sending`,className:`flex min-w-0 flex-col gap-3 rounded-lg border border-card-edge bg-card shadow-card p-3.5 text-sm [overflow-wrap:anywhere]`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Permission request`}),(0,X.jsx)(`h3`,{id:a,className:`font-semibold whitespace-pre-wrap`,children:e.title})]}),e.details?(0,X.jsx)(`pre`,{className:`min-w-0 font-mono text-xs leading-relaxed whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.details}):null,(0,X.jsx)(`div`,{role:`group`,"aria-labelledby":a,className:`flex min-w-0 flex-col gap-2`,children:e.options.map(t=>(0,X.jsx)(K,{type:`button`,variant:`outline`,disabled:s,"aria-pressed":e.optionId===t.id,className:`h-auto min-h-11 min-w-0 max-w-full justify-start py-2 text-start whitespace-normal [overflow-wrap:anywhere] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,onClick:()=>i?.(t.id),children:t.label},t.id))}),(0,X.jsxs)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:[c,e.reason?` ${e.reason}`:``]}),r&&t===`pending`?(0,X.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:r}):null]})}var Nr=(0,Y.createContext)({targets:new Map,replies:new Map,navigate:()=>{}});function Pr(e,t){let n={};for(let e of t??[])n[e.id]=e.currentStepBackend??e.runner;return n[e.id]=e.steps.find(t=>t.id===e.currentStepId)?.backend??e.runner,n}function Fr(e,t,n=[]){let r={};for(let e of n)r[e.id]=q(e);for(let e of t??[])r[e.id]=q(e);return r[e.id]=q(e),r}function Ir(e,t){return t?.[e]??`Task`}function Lr(e,t,n){return t?n?.[e]??`peer task`:Ir(e,n)}function Rr(e,t){return e.senderRunId===t?`outbound`:`inbound`}function zr(e){return e?.relationship===`peer`}function Br(e){switch(e){case`request`:return`Request`;case`progress`:return`Progress`;case`follow-up`:return`Follow-up`;case`reply`:return`Reply`}}function Vr(e){switch(e){case`pending`:return`Pending`;case`replied`:return`Replied`;case`replied-late`:return`Replied late`;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`;case`deleted`:return`Recipient deleted`}}function Hr(e){if(e.outcome)return Vr(e.outcome.status);if(e.delivery===`not-delivered`)return Z(`not-delivered`)}function Z(e){switch(e){case`queued`:return`Queued`;case`delivered`:return`Delivered`;case`consumed`:return`Read`;case`not-delivered`:return`Not delivered`}}function Ur(e,t){return e.instruction===void 0?e.delivery===`queued`?`${t?`Queued for delivery. This agent can receive messages during its current turn.`:`Queued for delivery. Timing depends on the recipient agent.`} Pending messages are batched within the size limit; human questions and scheduler capacity can delay delivery.`:e.state===`continuation-required`?zr(e)?`Not delivered. The recipient is not running. Only its human can continue it.`:`Not delivered. The recipient needs a new instruction to resume. A parent can resume its owned worker with ${Nn()} worker resume; workers cannot resume parents.`:e.state===`destroyed`?`Not delivered. This worker was destroyed.`:void 0:e.instruction}function Wr({id:e,peer:t,taskTitles:n,children:r}){return!t||n?.[e]!==void 0?r({title:Ir(e,n),linkable:!0}):(0,X.jsx)(Gr,{id:e,children:r})}function Gr({id:e,children:t}){let n=p(e);return n.data?t({title:q(n.data),linkable:!0}):n.isPending?t({title:`Peer task`,linkable:!1}):t({title:n.error instanceof j&&n.error.status===404?`Deleted task`:`Task unavailable`,linkable:!1})}var Kr={outbound:{classes:`border-message-outbound-border bg-message-outbound-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-outbound-accent`,accent:`text-message-outbound-accent`},inbound:{classes:`border-message-inbound-border bg-message-inbound-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-inbound-accent`,accent:`text-message-inbound-accent`},peer:{classes:`border-message-peer-border bg-message-peer-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-peer-accent`,accent:`text-message-peer-accent`}},qr=`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 Jr({block:e,runId:t,taskTitles:n,recipientBackends:r}){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)(Yr,{batch:e,runId:t,taskTitles:n,recipientBackends:r},e.id))})}function Yr({batch:e,runId:t,taskTitles:n,recipientBackends:r}){let a=Rr(e.messages[0]??{senderRunId:e.senderRunId},t),o=zr(e.messages[0]),s=Kr[o?`peer`:a],c=ii(e.messages.map(e=>a===`outbound`?e.recipientRunId:e.senderRunId)),l=a===`outbound`?`SENT to`:`RECEIVED from`,u=`${l} ${c.map(e=>Lr(e,o,n)).join(`, `)}`,d=e.messages[0],f=d?.createdAt??d?.recordedAt;return(0,X.jsxs)(`article`,{"data-slot":`worker-conversation-card`,"data-direction":a,"data-relationship":o?`peer`:`family`,"data-kind":e.kind,className:i(`flex w-full min-w-0 flex-col gap-2 rounded-[8px] border p-3 md:px-4 md:py-[14px]`,s.classes),children:[(0,X.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-start gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`p`,{className:i(`m-0 flex min-w-0 flex-wrap items-center gap-x-2 text-xs leading-[1.2] font-semibold tracking-[0.6px] uppercase`,s.accent),children:[(0,X.jsx)(`span`,{children:l}),c.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)(Wr,{id:e,peer:o,taskTitles:n,children:t=>(0,X.jsx)(ei,{view:t,to:`/tasks/${e}`,label:`${l} ${t.title}`})})]},e))]}),o?(0,X.jsx)(`span`,{"data-slot":`conversation-relationship`,className:`rounded-full border border-message-peer-border px-2 py-0.5 text-xs font-semibold tracking-[0.05em] text-foreground uppercase`,children:`Peer`}):null,(0,X.jsx)(`span`,{"data-slot":`conversation-kind`,className:`rounded-full bg-background/60 px-2 py-0.5 text-xs font-semibold tracking-[0.05em] text-foreground uppercase`,children:Br(e.kind)}),e.messages.length===1&&d?(0,X.jsx)(Zr,{message:d}):null]}),(0,X.jsx)(Xr,{at:f,className:`flex shrink-0 items-center justify-self-end gap-1 whitespace-nowrap text-xs text-soft-foreground`,children:e.messages.length>1?`First sent`:null})]}),(0,X.jsx)($r,{batch:e},`${t}:${d?.messageId??e.id}`),[...new Set(e.messages.map(e=>Ur(e,r?.[e.recipientRunId])))].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)(Qr,{messages:e.messages,peer:o,runId:t,taskTitles:n}):null,e.messages.length===1&&d?(0,X.jsx)(ti,{message:d,runId:t,taskTitles:n}):null,(0,X.jsx)(ni,{batch:e,heading:u})]})}function Xr({at:e,className:t,children:n}){return e===void 0||We(e)===void 0?null:(0,X.jsxs)(`span`,{className:t,children:[n,(0,X.jsx)(Ze,{ts:e})]})}function Zr({message:e}){let t=Hr(e),n=Z(e.delivery),r=(e.messageKind===`request`||e.messageKind===`reply`)&&n!==t;return(0,X.jsxs)(X.Fragment,{children:[t?(0,X.jsx)(`span`,{"data-slot":`conversation-outcome`,className:`text-xs font-medium text-muted-foreground`,children:t}):null,r?(0,X.jsx)(`span`,{"data-slot":`conversation-delivery`,className:`text-xs text-muted-foreground`,children:n}):null]})}function Qr({messages:e,peer:t,runId:n,taskTitles:r}){return(0,X.jsx)(`ul`,{className:`grid min-w-0 gap-1 text-xs text-muted-foreground`,children:e.map(e=>{let i=Hr(e),a=e.createdAt??e.recordedAt;return(0,X.jsxs)(`li`,{className:`flex min-h-11 min-w-0 flex-wrap items-center gap-2`,children:[(0,X.jsx)(Wr,{id:e.recipientRunId,peer:t,taskTitles:r,children:t=>(0,X.jsx)(ei,{view:t,to:`/tasks/${e.recipientRunId}`,label:`${t.title}${i?` — ${i}`:``}`})}),i?(0,X.jsx)(`span`,{"data-slot":`conversation-outcome`,children:i}):null,Z(e.delivery)===i?null:(0,X.jsx)(`span`,{"data-slot":`conversation-delivery`,children:Z(e.delivery)}),(0,X.jsx)(ti,{message:e,runId:n,taskTitles:r}),(0,X.jsx)(Xr,{at:a,className:`ml-auto whitespace-nowrap`})]},e.id)})})}function $r({batch:e}){let t=Fe(),n=`conversation-body:${e.messages[0]?.messageId??e.id}`,[r,i]=(0,Y.useState)(()=>t?.get(n)??!1),a=(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)(Jn,{breaks:!0,children:e.text})});return e.kind!==`request`&&e.kind!==`reply`?a:(0,X.jsxs)(Ht,{"data-slot":`conversation-body`,open:r,onOpenChange:e=>{t?.set(n,e),i(e)},className:`min-w-0`,children:[(0,X.jsxs)(Vt,{type:`button`,"data-slot":`conversation-body-toggle`,className:`group/body inline-flex min-h-11 min-w-11 items-center gap-1.5 rounded-md px-2 text-start text-xs font-medium text-muted-foreground [@media(hover:hover)_and_(pointer:fine)]:hover:bg-background/40 [@media(hover:hover)_and_(pointer:fine)]:hover:text-foreground active:bg-background/60 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:[(0,X.jsx)(ve,{"aria-hidden":!0,className:`size-3.5 shrink-0 group-data-[state=open]/body:rotate-90`}),r?`Hide message`:`Show message`]}),(0,X.jsx)(Bt,{children:a})]})}function ei({view:e,to:t,label:n}){return e.linkable?(0,X.jsx)(Yt,{className:qr,to:t,"aria-label":n,children:e.title}):(0,X.jsx)(`span`,{"data-slot":`conversation-counterpart`,children:e.title})}function ti({message:e,runId:t,taskTitles:n}){let{targets:r,replies:a,navigate:o}=(0,Y.useContext)(Nr),s=e.requestId?r.get(e.requestId):void 0,c=e.requestId?s?[s]:[]:a.get(e.messageId)??[],l=e.requestId?`request`:`reply`;return c.length===0?e.requestId||e.outcome?.replyId?(0,X.jsxs)(`p`,{"data-slot":`conversation-connector`,className:`text-xs text-muted-foreground`,children:[`Linked `,l,` is outside loaded history.`]}):null:c.map(e=>{let r=Rr(e.message,t)===`outbound`,a=r?e.message.recipientRunId:e.message.senderRunId;return(0,X.jsxs)(`button`,{type:`button`,"data-slot":`conversation-connector`,className:i(qr,`w-fit gap-1.5 text-xs text-muted-foreground`),onClick:()=>o(e),children:[(0,X.jsx)(`span`,{"aria-hidden":!0,children:`↗`}),(0,X.jsx)(Wr,{id:a,peer:zr(e.message),taskTitles:n,children:e=>(0,X.jsxs)(X.Fragment,{children:[`View `,l,` `,r?`to`:`from`,` `,e.title]})})]},e.message.messageId)})}function ni({batch:e,heading:t}){return(0,X.jsxs)(Ht,{"data-slot":`conversation-details`,className:`group/details`,children:[(0,X.jsxs)(Vt,{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)(ve,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/details:rotate-90`}),`Details`]}),(0,X.jsx)(Bt,{children:(0,X.jsxs)(`dl`,{className:`grid min-w-0 gap-1 break-all px-2 pb-1 font-mono text-xs text-muted-foreground`,children:[(0,X.jsx)(`div`,{className:`sr-only`,children:t}),e.messages.flatMap(e=>ri(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 ri(e){let t=[{label:`Message`,value:e.messageId},{label:`Sender`,value:e.senderRunId},{label:`Recipient`,value:e.recipientRunId},...zr(e)?[{label:`Relationship`,value:`peer`}]:[],{label:`Delivery`,value:Z(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 ii(e){let t=new Set,n=[];for(let r of e)t.has(r)||(t.add(r),n.push(r));return n}var ai=e(n(),1),oi=`pending-ask`;function si(e){return e.querySelector(`[data-slot="ask-question"] :is(button, textarea):not(:disabled)`)||(e.tabIndex=-1,e)}function ci(e,t){if(e.dataset.askMode===`reply`){let n=(t??e.closest(`[data-slot="thread-dock"]`)??document).querySelector(`[data-slot="thread-composer-slot"]:not([hidden]) textarea:not(:disabled)`);if(n)return n}return si(e)}function li(e){let t=e.querySelector(`[data-slot="ask-card"][data-pinned="true"]`);return t?ci(t,e):null}function ui(e,t){let n=`${oi}:${e}`;return r=>{if(!t())return!1;let i=[...r.querySelectorAll(`[data-row-key]`)].find(e=>e.dataset.rowKey===n);if(i)return li(i);let a=[...r.querySelectorAll(`[data-slot="ask-card"][data-pinned="true"]`)].find(t=>t.dataset.askId===e);return a?ci(a,r):null}}function di(e){return e<=0?`Jump to latest`:`Jump to latest (${e} ${e===1?`question`:`questions`} pending)`}function fi({onGoToQuestion:e}){return(0,X.jsxs)(`div`,{"data-slot":`ask-origin`,className:`flex flex-wrap items-center gap-x-2 rounded-lg border border-dashed border-accent-strong/40 px-3.5 py-1 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`font-medium text-link-foreground`,children:`Question asked here`}),(0,X.jsx)(K,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-go-to-question`,className:`min-h-11 min-w-11 px-2 text-foreground underline underline-offset-4`,onClick:e,children:`Go to the question`})]})}function pi(){let e=(0,Y.useRef)(null);return(0,Y.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=t.closest(`[data-slot="main"]`),r=t.querySelector(`[data-slot="run-header"]`),i=t.querySelector(`[data-slot="thread-dock"]`);if(!n||!r||!i)return;let a=()=>{let e=r.querySelector(`[data-slot="run-tabs"]`),a=r.getBoundingClientRect(),o=getComputedStyle(document.documentElement),s=document.documentElement.style.getPropertyValue(`--kb`)||(typeof o.getPropertyValue==`function`?o.getPropertyValue(`--kb`):``),c=Number.parseFloat(s)||0;n.clientHeight>0&&n.clientHeight<420?t.dataset.compactViewport=`true`:delete t.dataset.compactViewport,c>0||Ut(window)?t.dataset.keyboardOpen=`true`:delete t.dataset.keyboardOpen,r.style.setProperty(`--run-header-lead`,`${e?Math.max(0,e.getBoundingClientRect().top-a.top):0}px`),n.style.setProperty(`--thread-viewport-height`,`${n.clientHeight}px`),n.style.setProperty(`--thread-header-height`,`${mi(r)}px`),n.style.setProperty(`--thread-footer-height`,`${i.getBoundingClientRect().height}px`)};a();let o=new ResizeObserver(a);return o.observe(r),o.observe(i),o.observe(n),()=>{o.disconnect(),delete t.dataset.compactViewport,delete t.dataset.keyboardOpen,r.style.removeProperty(`--run-header-lead`),n.style.removeProperty(`--thread-header-height`),n.style.removeProperty(`--thread-footer-height`),n.style.removeProperty(`--thread-viewport-height`)}},[]),e}function mi(e){let t=Number.parseFloat(getComputedStyle(e).insetBlockStart)||0;return Math.max(0,e.getBoundingClientRect().height+Math.min(0,t))}var hi={viewKey:void 0,generation:0},gi=600,_i=24;function vi(e,t={}){let{surface:n=`document`,onLoadOlder:r,onJumpToLatest:i,rowKeys:a=[]}=t,o=(0,Y.useRef)(a);o.current=a;let s=(0,Y.useRef)(e);s.current=e;let c=(0,Y.useRef)(null),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(!1),m=(0,Y.useRef)(!0),h=(0,Y.useRef)(!0),g=(0,Y.useRef)(0),_=(0,Y.useRef)(0),v=(0,Y.useRef)(new Set),y=(0,Y.useCallback)(e=>{for(let t of[...v.current])t(e)},[]),b=(0,Y.useCallback)(e=>(v.current.add(e),()=>{v.current.delete(e)}),[]),x=(0,Y.useRef)(null),S=(0,Y.useRef)(null),C=(0,Y.useRef)(null),w=(0,Y.useRef)(null),T=(0,Y.useCallback)(e=>{let t=c.current;if(!t)return;let n=w.current;n?n.scrollTo(e):t.scrollTop=e},[]),E=(0,Y.useCallback)(()=>{let e=c.current;if(!e)return;let t=h.current?o.current.findIndex(e=>e.startsWith(`pending-ask:`)):-1,n=h.current?e.querySelector(`[data-slot="ask-card"][data-pinned="true"][data-resolved="false"]`):null,r=e.querySelector(`[data-slot="run-header"]`),i=r&&getComputedStyle(r).position===`sticky`?mi(r):0;n?T(e.scrollTop+n.getBoundingClientRect().top-e.getBoundingClientRect().top-i-12):t>=0&&w.current?w.current.scrollToIndex(t,{align:`start`,offset:-i-12}):T(e.scrollHeight-e.clientHeight)},[T]),D=(0,Y.useCallback)(()=>{if(c.current){if(C.current!==e){C.current=e,h.current=!0;let t=at(e);t&&!t.atBottom?(m.current=!1,x.current=t.top,S.current=Ne(e)?.rowKeys?{viewKey:e,top:t.top}:null):(m.current=!0,x.current=null,S.current=null)}x.current===null?m.current&&E():T(x.current)}},[e,T,E]),O=(0,Y.useCallback)(e=>S.current?.viewKey===e,[]),k=(0,Y.useCallback)(e=>{let t=S.current;return!t||!O(e)||e!==s.current?!1:(x.current=t.top,m.current=!1,S.current=null,!0)},[O]),A=(0,Y.useCallback)(e=>{d(e),e&&(c.current=e.closest(n===`panel`?`[data-slot="transcript-viewport"]`:`[data-slot="thread-transcript"], [data-slot="main"]`),D())},[n,D]),j=(0,Y.useCallback)(()=>{m.current&&E()},[E]),M=(0,Y.useRef)(!1),N=(0,Y.useRef)(0),P=(0,Y.useRef)(!1),F=(0,Y.useRef)(void 0),I=(0,Y.useRef)(!1),ee=(0,Y.useRef)(!1),L=(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}}),[]),R=(0,Y.useRef)(null),z=(0,Y.useRef)(0);(0,Y.useEffect)(()=>{if(!l())return;let e=e=>{x.current=null,S.current=null,z.current+=1,R.current=null,m.current=!1,h.current=!1,T(e)};return window.__cezThreadScrollTo=e,()=>{window.__cezThreadScrollTo===e&&delete window.__cezThreadScrollTo}},[T]);let B=(0,Y.useCallback)(()=>{let e=R.current,t=c.current;if(!e||!t)return;R.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=w.current;a&&i>=0?a.scrollToIndex(i,{align:`start`,offset:-e.anchor.offset}):T(ze(t.scrollTop,r,e.anchor,L(t),n))},[L,T]),V=(0,Y.useCallback)(()=>{let e=c.current;if(!e||!r||M.current)return;x.current=null,S.current=null,m.current=!1,M.current=!0;let t=N.current+1;N.current=t;let n=e.scrollHeight,i=e.scrollTop,a=e.getBoundingClientRect().top,l=gt(a,L(e)),u=l===void 0?-1:o.current.indexOf(l.key),d=s.current,f=z.current;r().then(()=>{s.current===d&&z.current===f&&(R.current={beforeHeight:n,beforeTop:i,anchor:l,anchorIndex:u})},()=>{}).finally(()=>{N.current===t&&(M.current=!1)})},[L,r]);(0,Y.useEffect)(()=>()=>clearTimeout(F.current),[]);let H=(0,Y.useRef)(null),te=(0,Y.useRef)(0),U=(0,Y.useCallback)(()=>n===`document`?++hi.generation:++te.current,[n]),ne=(0,Y.useCallback)((e,t)=>n===`document`?hi.viewKey===e&&hi.generation===t:s.current===e&&te.current===t,[n]);(0,Y.useEffect)(()=>()=>H.current?.disconnect(),[e,u]);let W=(0,Y.useCallback)((t,n,r,i)=>{let a=c.current;if(!a||!u)return;x.current=null,S.current=null,z.current+=1,R.current=null,m.current=!1,g.current=0,p(!0),U(),H.current?.disconnect();let o=()=>[...u.querySelectorAll(`[data-row-key]`)].find(e=>e.dataset.rowKey===t),s=a.querySelector(`[data-slot="run-header"]`),l=s&&getComputedStyle(s).position===`sticky`?mi(s):0,d=(e,t)=>{let r=a.getBoundingClientRect(),o=t.getBoundingClientRect(),s=w.current;if(s&&i===void 0){let t=o.top-e.getBoundingClientRect().top;l+t+o.height>r.height&&s.scrollToIndex(n,{align:`start`,offset:t-l-12})}else(o.top<r.top+l||o.bottom>r.bottom)&&T(a.scrollTop+o.top-r.top-l-12)},f=()=>{let e=o();if(!e||getComputedStyle(e).visibility===`hidden`)return!1;let t=r?.(e)??e;return t===e?e.tabIndex=-1:d(e,t),t.focus({preventScroll:!0}),document.activeElement===t?(H.current?.disconnect(),!0):!1},h=w.current;if(i!==void 0)T(i);else if(h)h.scrollToIndex(n,{align:`start`,...l>0?{offset:-l}:{}});else{let e=o();e&&T(a.scrollTop+e.getBoundingClientRect().top-a.getBoundingClientRect().top-l)}f()||(H.current=new MutationObserver(()=>{f()}),H.current.observe(u,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`style`,`class`]})),it(e,{top:i??a.scrollTop,atBottom:!1})},[u,T,e,U]),re=(0,Y.useCallback)(t=>{let n=U(),r=s.current;H.current?.disconnect();let a=c.current;if(!a)return;x.current=null,S.current=null,z.current+=1,R.current=null,m.current=!0,h.current=!0,_.current=0,y({direction:`tail`}),it(e,{top:a.scrollHeight-a.clientHeight,atBottom:!0});let o=()=>{m.current&&E()},l=a.closest(`[data-slot="main"]`)??a.closest(`[data-route="task-thread"]`)??a,u=()=>ne(r,n),d=()=>{let e=t?.(l);return e===!1?!0:e?(e.focus({preventScroll:!0}),document.activeElement===e):!1};(i?.()??Promise.resolve()).finally(()=>{requestAnimationFrame(()=>{o(),requestAnimationFrame(()=>{if(o(),!t||!u()||d())return;H.current?.disconnect();let e=new MutationObserver(()=>{u()?d()&&e.disconnect():e.disconnect()});H.current=e,e.observe(l,{childList:!0,subtree:!0})})})})},[i,e,E,U,ne,y]),ie=a.at(-1),ae=a.length;return(0,Y.useLayoutEffect)(()=>{z.current+=1,R.current=null,M.current=!1,n===`document`?hi.viewKey!==e&&(hi.viewKey=e,hi.generation+=1):te.current+=1},[e,n]),(0,Y.useLayoutEffect)(()=>{let e=R.current;e?(e.anchor===void 0?-1:o.current.indexOf(e.anchor.key))>e.anchorIndex?B():R.current=null:m.current&&E()},[ie,ae,B,E]),(0,Y.useLayoutEffect)(()=>{!c.current||!u||D()},[u,D]),(0,Y.useEffect)(()=>{let t=c.current,n=u;if(!t||!n)return;g.current=0;let r=null,i=!1,a=t.scrollTop,o,s=0,l,d=()=>{h.current&&!Ge(t,80)&&(m.current=!1),h.current=!1},f=e=>{_.current=Date.now(),d(),l=e},v=()=>{U(),H.current?.disconnect(),x.current=null,S.current=null,z.current+=1,R.current=null,m.current=!1,g.current=0},b=()=>{x.current=null,S.current=null,z.current+=1,R.current=null,g.current=Date.now()},C=e=>{if(e.deltaY!==0)if(f(e.deltaY<0?`up`:`down`),e.deltaY<0){v();let e=!P.current;P.current=!0,clearTimeout(F.current),F.current=setTimeout(()=>{P.current=!1},180),e&&Pe(t)&&V()}else b()},w=e=>{[`ArrowUp`,`PageUp`,`Home`].includes(e.key)?(f(`up`),v(),!e.repeat&&Pe(t)&&V()):[`ArrowDown`,`PageDown`,`End`].includes(e.key)&&(f(`down`),b())},D=e=>{if(e.target!==t||e.button!==0||e.pointerType===`touch`||e.pointerType===`pen`||t.scrollHeight<=t.clientHeight)return;i=!0,ee.current=!1,a=t.scrollTop;let n=t.getBoundingClientRect(),r=getComputedStyle(t),o=parseFloat(r.borderLeftWidth)||0,s=parseFloat(r.borderRightWidth)||0,c=n.left+t.clientLeft,l=c+t.clientWidth;!(e.clientX>=n.left+o&&e.clientX<c||e.clientX>=l&&e.clientX<n.right-s)||e.clientY<n.top+t.clientTop||e.clientY>=n.top+t.clientTop+t.clientHeight||(h.current=!1,x.current=null,S.current=null,Ge(t,80)||(v(),b()))},k=()=>{i=!1},A=e=>{I.current=!1,r=e.touches[0]?.clientY??null},j=e=>{let n=e.touches[0]?.clientY;n!==void 0&&(r!==null&&n>r+1?(f(`up`),v(),!I.current&&Pe(t)&&(I.current=!0,V())):r!==null&&n<r-1&&(f(`down`),b()),r=n)},M=e=>{if(e===0||!i&&Date.now()-_.current>=gi)return;let n=e<0?`up`:`down`;!i&&n!==l||(n!==o&&(o=n,s=0),s+=Math.abs(e),s>=_i&&(0,ai.flushSync)(()=>y({direction:n,distanceFromBottom:t.scrollHeight-t.clientHeight-t.scrollTop})))},N=()=>{let n=m.current;M(t.scrollTop-a),i&&t.scrollTop!==a&&(d(),t.scrollTop<a?v():b()),i&&!ee.current&&t.scrollTop<a&&Pe(t)&&(ee.current=!0,V()),a=t.scrollTop;let r=Ge(t,80);r&&x.current===null&&(m.current||Date.now()-g.current<2e3)&&(m.current=!0),!n&&m.current&&y({direction:`tail`}),p(!r),x.current===null&&!O(e)&&it(e,{top:t.scrollTop,atBottom:r})};t.addEventListener(`scroll`,N,{passive:!0}),t.addEventListener(`wheel`,C,{passive:!0}),t.addEventListener(`touchstart`,A,{passive:!0}),t.addEventListener(`touchmove`,j,{passive:!0}),t.addEventListener(`pointerdown`,D,{passive:!0}),window.addEventListener(`pointerup`,k,{passive:!0}),window.addEventListener(`pointercancel`,k,{passive:!0}),t.addEventListener(`keydown`,w);let L;if(typeof ResizeObserver<`u`){L=new ResizeObserver(()=>{let e=x.current;if(e!==null){let n=t.scrollHeight-t.clientHeight;T(Math.min(e,n)),n>=e&&(x.current=null)}else m.current&&E()}),L.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&&L.observe(r),i&&L.observe(i)}return()=>{t.removeEventListener(`scroll`,N),t.removeEventListener(`wheel`,C),t.removeEventListener(`touchstart`,A),t.removeEventListener(`touchmove`,j),t.removeEventListener(`pointerdown`,D),window.removeEventListener(`pointerup`,k),window.removeEventListener(`pointercancel`,k),t.removeEventListener(`keydown`,w),L?.disconnect()}},[e,u,V,T,E,O,U,y]),{attachContent:A,scrollElRef:c,virtualizerRef:w,restoreMeasurements:k,ownsMeasurementRestore:O,pillVisible:f,jumpToLatest:re,jumpToRow:W,loadOlder:V,restickIfStuck:j,subscribeReaderScroll:b}}function yi({runId:e,rows:t,mode:n,controls:r}){return n===`virtual`?(0,X.jsx)(bi,{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 bi({runId:e,rows:t,controls:n}){return(0,X.jsx)(xi,{runId:e,rows:t,controls:n},e)}function xi({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)(()=>Ne(e)),[l,u]=(0,Y.useState)(()=>({cache:Ve(e,t.length,t.map(e=>e.key)),generation:0})),d=(0,Y.useRef)(l.cache===void 0&&c?.rowKeys?.length===c?.rows&&c!==void 0);(0,Y.useLayoutEffect)(()=>{let r=c?.rowKeys;if(!d.current){n.restoreMeasurements(e);return}if(!(!c||!r)){if(t.length>c.rows||t.some((e,t)=>e.key!==r[t])){d.current=!1,n.restoreMeasurements(e);return}t.length===c.rows&&(d.current=!1,n.restoreMeasurements(e)&&u({cache:c.cache,generation:1}))}},[c,t,n.restoreMeasurements,e]);let f=(0,Y.useRef)(t.length);f.current=t.length;let p=(0,Y.useRef)(t.map(e=>e.key));p.current=t.map(e=>e.key);let m=(0,Y.useRef)(null),h=(0,Y.useCallback)(t=>{n.virtualizerRef.current=t,t?m.current=t:m.current&&=(d.current&&c?.rowKeys&&f.current<c.rows&&n.ownsMeasurementRestore(e)||Ae(e,{rows:f.current,cache:m.current.cache,rowKeys:p.current}),null)},[e,n.virtualizerRef,n.ownsMeasurementRestore,c]),[g,_]=(0,Y.useState)(0);return(0,Y.useLayoutEffect)(()=>{let e=()=>{let e=r.current,t=n.scrollElRef.current;!e||!t||_(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)(Un,{ref:h,scrollRef:n.scrollElRef,startMargin:g,shift:s,...l.cache===void 0?{}:{cache:l.cache},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))},l.generation)})}function Si({onJump:e,pendingQuestions:t=0}){return(0,X.jsxs)(`button`,{type:`button`,"data-slot":`jump-to-latest`,"data-pending-questions":t>0?t:void 0,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-sm hover:text-foreground`,children:[(0,X.jsx)(we,{"aria-hidden":!0,className:`size-3.5`}),di(t)]})}function Ci(e){return e.consumedAt?`consumed`:e.deliveredAt?`delivered`:`queued`}function wi(e,t){let n=new Map((e.agentInputs??[]).map(e=>[e.id,Ci(e)]));if(n.size===0)return t;let r=!1,i=t.map(e=>{if(e.kind!==`note`||!e.id.startsWith(`agent-input:`))return e;let t=n.get(e.id.slice(12));return!t||e.delivery===t?e:(r=!0,{...e,delivery:t})});return r?i:t}function Ti(e,t,n){return e.kind===`ask`?e.id===t?n===void 0?e:{...e,placement:`origin`}:e.resolved?e:{...e,resolved:!0}:e}var Ei=new WeakMap;function Di(e,t){let n=Ei.get(e);return n?.length===t.length&&t.every((e,t)=>{let r=n[t];return e===r||Object.keys(e).length===Object.keys(r).length&&Object.entries(e).every(([e,t])=>t===r[e])})?n:(Ei.set(e,t),t)}function Oi(e,t){if(t!=null)return e.turns.flatMap(e=>e.items).find(e=>e.kind===`ask`&&e.id===t&&!e.resolved)}function ki(e,t,n=t,r,i){let a=Oi(n,r),o=i?.pinPendingAskInTranscript!==!1,s=new Map(n.turns.flatMap(e=>e.items).filter(e=>e.kind===`permission`).map(e=>[e.requestId,e])),c=new Set,l=new Set(t.turns.map(e=>e.userMessage?.ask?.id)),u=[];e.task&&u.push({id:`task`,userMessageKey:`task`,userMessage:{text:e.task,images:e.taskImages??[],ts:e.createdAt},entries:[]});for(let t of e.queuedMessages??[])u.push({id:`queued:${t.id}`,userMessageKey:`queued:${t.id}`,userMessage:{text:t.text,images:t.images??[],ts:t.createdAt},inDaySequence:!1,entries:[]});let d=t.turns.at(-1);for(let n of t.turns){let t=e.status===`review`&&n===d?ji(n.items):n.items;u.push({id:n.id,userMessageKey:`${n.id}:user`,...n.userMessage===void 0?{}:{userMessage:{text:n.userMessage.text,ask:n.userMessage.ask,imageCount:n.userMessage.imageCount,images:n.userMessage.images,...n.userMessage.ts===void 0?{}:{ts:n.userMessage.ts}}},...n.startedAt===void 0?{}:{startedAt:n.startedAt},...n.completed?.ts===void 0?{}:{completedAt:n.completed.ts},entries:Di(n.items,wi(e,t.filter(t=>!e.task||!Pt(t,`opening`)).map(e=>e.kind===`ask`&&l.has(e.id)?{...e,placement:`origin`}:r!==void 0&&e.kind===`ask`?Ti(e,r,a):e.kind===`permission`?(c.add(e.requestId),s.get(e.requestId)??(e.status===`pending`?{...e,status:`expired`}:e)):e)))})}let f=[...s.values()].filter(e=>e.status===`pending`&&!c.has(e.requestId));return f.length>0&&u.push({id:`pending-permissions`,entries:f,inDaySequence:!1}),a!==void 0&&o&&u.push({id:oi,entries:[{...a,placement:`pinned`}],inDaySequence:!1}),u}var Ai=`changes ready for review`;function ji(e){return e.filter(e=>!(e.kind===`note`&&e.tone===`dim`&&e.text.startsWith(Ai)))}function Mi(e,t,n){let r=e.findIndex(({content:e})=>e.kind===`block`&&e.block.kind===`entry`&&e.block.entry.kind===`ask`&&e.block.entry.id===t&&e.block.entry.placement===n);return r<0?void 0:{key:e[r].key,index:r}}function Ni(e,t){return[{id:`agent:${e}`,entries:t}]}function Pi(e){if(e.inDaySequence!==!1)return e.userMessage?.ts??e.startedAt??e.completedAt}function Fi(e,t){let n=[],r;for(let t of e){let e=Pi(t),i=Me(e);i!==void 0&&e!==void 0&&(r===void 0||i>r)&&(r!==void 0&&n.push({key:`${t.id}:day-separator`,scope:t.id,content:{kind:`day-separator`,ts:e}}),r=i),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 Le(t.entries))n.push({key:`${t.id}:${e.id}`,scope:t.id,content:{kind:`block`,block:e}});t.completedAt!==void 0&&n.push({key:`${t.id}:turn-time`,scope:t.id,content:{kind:`turn-time`,completedAt:t.completedAt,...t.startedAt===void 0?{}:{startedAt:t.startedAt}}})}return n}function Ii({runId:e,viewId:t,sections:n,mode:r,empty:i,renderAsk:a,renderPermission:o,messageActions:s,scrollControls:c,renderMode:l,taskTitles:u,recipientBackends:d}){let f=(0,Y.useMemo)(()=>Fi(n,e),[n,e]),p=vi(`${e}:${t}`,{surface:r}),m=c??p;Er(e,f,m,r);let h=(0,Y.useMemo)(()=>{let e=new Map;f.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=>m.jumpToRow(e.rowKey,e.rowIndex)}},[f,m.jumpToRow]),g=(0,Y.useMemo)(()=>f.map(t=>({key:t.key,node:Li(t,s?.[t.key],a,o,e,u,d)})),[s,a,o,f,e,u,d]),_=l??Be(``,g.length),v=g.length===0?i??null:(0,X.jsx)(yi,{runId:`${e}:${t}`,rows:g,mode:_,controls:m});return(0,X.jsx)(Yn,{runId:e,children:(0,X.jsx)(He,{runId:e,children:(0,X.jsx)(Nr.Provider,{value:h,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:v}),m.pillVisible?(0,X.jsx)(`div`,{className:`pointer-events-none sticky inset-x-0 bottom-4 flex justify-center`,children:(0,X.jsx)(Si,{onJump:m.jumpToLatest})}):null]}):v})})})}function Li(e,t,n,r,i,a,o){switch(e.content.kind){case`user-message`:return(0,X.jsx)(Ri,{message:e.content.message,actions:t});case`day-separator`:return(0,X.jsx)(vt,{ts:e.content.ts});case`turn-time`:return(0,X.jsx)(_t,{completedAt:e.content.completedAt,...e.content.startedAt===void 0?{}:{startedAt:e.content.startedAt}});case`block`:return(0,X.jsx)(zi,{block:e.content.block,scope:e.scope,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o});default:return Ui(e.content)}}function Ri({message:e,actions:t}){return(0,X.jsx)(tt,{text:e.text,imageCount:e.imageCount,images:e.images,...e.ts===void 0?{}:{ts:e.ts},onEdit:t?.onEdit,onRemove:t?.onRemove,editLabel:t?.editLabel,removeLabel:t?.removeLabel,children:e.ask?(0,X.jsx)(`div`,{"data-slot":`ask-card`,"data-resolved":`true`,children:(0,X.jsx)(Ke,{ask:e.ask})}):void 0})}function zi({block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){switch(e.kind){case`entry`:return(0,X.jsx)(yt.Provider,{value:`${t}:${e.entry.id}`,children:(0,X.jsx)(Vi,{entry:e.entry,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o})});case`tool-card`:return(0,X.jsx)(st,{item:e.item,nested:e.children,cacheKey:`${t}:${e.id}`,renderNested:(e,t)=>(0,X.jsx)(Bi,{entries:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o})});case`context-group`:return(0,X.jsx)(ot,{group:e,scope:t});case`streak`:return(0,X.jsx)(nt,{count:e.count,children:e.blocks.map(e=>(0,X.jsx)(zi,{block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o},e.id))});case`worker-conversation`:return(0,X.jsx)(Jr,{block:e,runId:i,taskTitles:a,recipientBackends:o});default:return Ui(e)}}function Bi({entries:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){return Le(e).map(e=>(0,X.jsx)(zi,{block:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o},e.id))}function Vi({entry:e,scope:t,renderAsk:n,renderPermission:r,runId:i,taskTitles:a,recipientBackends:o}){switch(e.kind){case`message`:return e.role===`assistant`?(0,X.jsx)(Qe,{text:e.text,ts:e.ts}):(0,X.jsx)(tt,{text:e.text,ts:e.ts});case`reasoning`:return(0,X.jsx)(ut,{text:e.text});case`tool`:return(0,X.jsx)(st,{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.jsxs)(`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}`,e.delivery?` · ${Z(e.delivery)}`:``]}),(0,X.jsx)(ht,{note:e})]}):(0,X.jsx)(ht,{note:e});case`conversation`:return(0,X.jsx)(Jr,{runId:i,taskTitles:a,recipientBackends:o,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)($e,{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`permission`:return r?r(e):(0,X.jsx)(Ar,{permission:e,runId:i});case`provider-auth-required`:return(0,X.jsx)(et,{incident:e});case`preview-server`:return(0,X.jsx)(Hi,{entry:e});case`hook`:return(0,X.jsx)(mt,{item:e,cacheKey:`${t}:${e.id}`});default:return Ui(e)}}function Hi({entry:e}){let t=zn(),n=E().data?.capabilities?.preview===!0;return(0,X.jsx)(Lt,{entry:t?.worktreeRemoved?{kind:`preview-server`,id:e.id,server:e.server,state:`unavailable`}:e,inPreview:t!==null&&t.open&&t.port===e.server.port,onOpen:t!==null&&n?t.openPane:void 0})}function Ui(e){throw Error(`Unhandled transcript variant: ${JSON.stringify(e)}`)}function Wi({runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,onClose:a,onBeforeOpenReport:o,onRestoreAgentFocus:s,taskTitles:c,recipientBackends:l}){let u=(0,Y.useContext)(dn),d=(0,Y.useRef)(void 0),f=(0,Y.useRef)(!1);return(0,Y.useEffect)(()=>()=>{d.current?.()},[u,e]),(0,X.jsx)(on,{open:r!==void 0,onOpenChange:e=>{e||a()},children:(0,X.jsx)(cn,{"data-slot":`subagent-sheet`,side:`right`,onCloseAutoFocus:e=>{f.current&&=(e.preventDefault(),!1)},className:`flex min-h-0 w-full gap-0 p-0 sm:max-w-xl`,children:r===void 0?null:(0,X.jsx)(je.Provider,{value:e=>{let t=r?.id,n=[...document.querySelectorAll(`[data-agent-id]`)].find(e=>e.dataset.agentId===t);d.current?.(),d.current=u?.registerOpener(e,()=>{if(t&&s){s(t);return}n?.focus({preventScroll:!0})}),f.current=!0,o?.(),a()},children:(0,X.jsx)(Gi,{runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,taskTitles:c,recipientBackends:l})})})})}function Gi({runId:e,renderAsk:t,renderPermission:n,agent:r,entries:i,taskTitles:a,recipientBackends:o}){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(an,{className:`gap-1.5 border-b border-border px-5 py-4`,children:[(0,X.jsxs)(sn,{className:`flex min-w-0 items-center gap-2 pr-8 text-[16px]`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:r.title}),r.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-xs font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:r.agentType})]}),(0,X.jsxs)(un,{"data-slot":`subagent-meta`,className:`flex items-center gap-2 text-xs`,children:[(0,X.jsx)(Ki,{status:r.status}),(0,X.jsxs)(`span`,{className:`tabular-nums`,children:[r.toolCalls,` `,r.toolCalls===1?`tool call`:`tool calls`]})]})]}),(0,X.jsx)(Ii,{runId:e,viewId:`agent:${r.id}`,sections:Ni(r.id,i),mode:`panel`,renderAsk:t,renderPermission:n,taskTitles:a,recipientBackends:o,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 Ki({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:i(`rounded-full px-2 py-0.5 text-xs 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 qi(e){let t=R(),[n,r]=(0,Y.useState)(),i=en(e);(0,Y.useEffect)(()=>{(!i||n&&n!==e.id)&&r(void 0)},[i,e.id,n]);let a=h({mutationFn:async()=>{r(e.id);try{if(!(await B(e.id)).cancelled)throw Error(`The task changed before Stop was accepted. Check its status and retry.`)}catch(e){throw r(void 0),e}},onSettled:()=>t.invalidateQueries({queryKey:d.runs.all})});return{stopping:!!e.stopping||a.isPending||i&&n===e.id,stop:()=>a.mutateAsync()}}function Ji({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)(Yi,{agent:e,onSelect:t},e.id))})}function Yi({agent:e,onSelect:t}){let n=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Xi,{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-xs 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:gr(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`,"data-agent-id":e.id,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 Xi({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 Zi(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.filter(e=>e.status!==`cancelled`).length}}function Qi({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)($i,{entry:e},`${t}:${e.content}`))})}function $i({entry:e}){return(0,X.jsxs)(`li`,{"data-slot":`plan-item`,"data-status":e.status,className:i(`flex min-h-5 min-w-0 flex-wrap items-start gap-x-2.5 gap-y-1 text-[13px] [&>svg]:mt-[3px]`,e.status===`completed`&&`text-soft-foreground line-through`,e.status===`in_progress`&&`font-medium`,e.status===`pending`&&`text-muted-foreground`,e.status===`cancelled`&&`text-disabled-foreground line-through`),children:[(0,X.jsx)(ea,{status:e.status}),(0,X.jsx)(`span`,{"data-slot":`plan-text`,className:`min-w-0 flex-1 basis-40 break-words`,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-xs font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:`in progress`}):null]})}function ea({status:e}){return e===`cancelled`?(0,X.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-disabled-foreground`,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`})})}function ta(e){switch(e){case`done`:return`done`;case`running`:case`waiting`:case`review`:return`active`;case`failed`:case`cancelled`:return`failed`;case`pending`:case`skipped`:return`pending`}}function na(e,t){let n=ta(e);return n===`active`&&t===`waiting`?`paused`:n}function ra(e){return e===`active`?`running`:e}function ia(e){if(e.length===0)return 0;let t=new Set([`done`,`failed`,`cancelled`,`skipped`]),n=new Set([`running`,`waiting`,`review`]),r=0;for(let i of e)t.has(i.status)?r+=1:n.has(i.status)&&(r+=.5);return r/e.length}function aa({steps:e,runStatus:t=`running`}){if(e.length===0)return null;let n=ia(e)*100;return(0,X.jsxs)(`div`,{"data-slot":`step-rail`,className:`flex min-w-0 flex-col gap-1`,children:[e.map((n,r)=>(0,X.jsxs)(`div`,{"data-slot":`step-row`,"data-visual":na(n.status,t),className:`flex min-h-[22px] min-w-0 flex-wrap items-start gap-x-2 gap-y-0.5 text-[13px] text-muted-foreground [&>svg]:mt-[3px]`,children:[(0,X.jsx)(oa,{visual:na(n.status,t)}),(0,X.jsx)(`span`,{"data-slot":`step-name`,className:`min-w-0 flex-1 basis-32 break-words font-medium text-foreground`,children:n.name}),n.iterations>1?(0,X.jsxs)(`span`,{"data-slot":`step-iterations`,className:`shrink-0 text-xs text-soft-foreground tabular-nums`,children:[`×`,n.iterations]}):null,(0,X.jsxs)(`span`,{"data-slot":`step-meta`,className:`ml-auto max-w-full min-w-0 pl-2 text-right text-xs leading-5 break-words text-soft-foreground tabular-nums`,children:[n.pluginKind??n.kind,` · step `,r+1,` of `,e.length]})]},n.id)),(0,X.jsx)(`div`,{"data-slot":`step-progress`,className:`mt-1 h-0.5 overflow-hidden rounded-full bg-muted`,children:(0,X.jsx)(`div`,{className:`h-full rounded-full bg-pending`,style:{width:`${n}%`}})})]})}function oa({visual:e}){let t=`size-[13px] shrink-0`;switch(e){case`done`:return(0,X.jsx)(Ee,{"aria-hidden":!0,className:i(t,`text-success`)});case`active`:return(0,X.jsx)(Ot,{role:`status`,"aria-label":`Step running`,className:i(t,`animate-spin stroke-pending motion-reduce:animate-none [html.light_&]:stroke-pending-strong`)});case`paused`:return(0,X.jsx)(Ce,{role:`img`,"aria-label":`Step paused`,className:i(t,sa)});case`failed`:return(0,X.jsx)(he,{"aria-hidden":!0,className:i(t,`text-danger`)});case`pending`:return(0,X.jsx)(xe,{"aria-hidden":!0,className:i(t,`text-soft-foreground`)})}}var sa=`stroke-pending [html.light_&]:stroke-pending-strong`,ca={done:`done`,failed:`failed`,cancelled:`cancelled`};function la(e){let t=ca[e.status];return t?e.steps.map(e=>ta(e.status)===`active`?{...e,status:t}:e.status===`pending`?{...e,status:`skipped`}:e):ua(e)}function ua(e){let t=da(e.currentStepId,e.steps);return e.steps.some((e,n)=>n!==t&&e.status===`waiting`)?e.steps.map((e,n)=>n!==t&&e.status===`waiting`?{...e,status:`done`}:e):e.steps}function da(e,t){let n=t.findIndex(t=>t.id===e);if(n>=0)return n;let r=t.reduce((e,t,n)=>ta(t.status)===`active`?n:e,-1);if(r>=0)return r;let i=t.findIndex(e=>e.status===`pending`);return i>=0?i:t.reduce((e,t,n)=>t.status===`skipped`?e:n,0)}function fa(e,t,n,r){return n?r===`step`?`Step ${e} of ${t}`:`${e} of ${t} complete`:`${e} / ${t}`}function pa(e){return typeof e==`object`&&!!e&&!(0,Y.isValidElement)(e)&&`keep`in e}function Q({slot:e,icon:t,title:n,meta:r,summary:a,aside:o,open:s,onToggle:c,className:l,children:u}){let d=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`flex size-4 shrink-0 items-center justify-center text-accent-text`,children:t}),(0,X.jsx)(`span`,{className:i(`truncate text-[14px] font-semibold text-foreground`,typeof n==`string`?`shrink-0`:`min-w-0 shrink`),children:n}),a??(pa(r)?(0,X.jsxs)(`span`,{"data-slot":`run-activity-meta`,className:`contents text-[13px] text-muted-foreground tabular-nums`,children:[r.drop===void 0?null:(0,X.jsxs)(`span`,{className:`flex h-[1lh] min-w-0 shrink-[2] flex-wrap overflow-hidden`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`h-[1lh] w-0`}),(0,X.jsxs)(`span`,{"data-slot":`run-activity-meta-drop`,className:`whitespace-nowrap`,children:[r.drop,(0,X.jsx)(`span`,{className:`text-soft-foreground`,children:` ·`})]})]}),` `,(0,X.jsx)(`span`,{"data-slot":`run-activity-meta-keep`,className:`shrink-0 whitespace-nowrap`,children:r.keep})]}):r===void 0?null:(0,X.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`min-w-0 shrink-[2] truncate text-[13px] text-muted-foreground tabular-nums`,children:r}))]}),f=c!==void 0;return(0,X.jsxs)(`div`,{"data-slot":`run-activity-${e}`,"data-state":f&&s?`open`:`collapsed`,className:i(`min-w-0 border-t border-border first:border-t-0`,l),children:[f?(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":s,onClick:c,className:`flex min-h-11 w-full min-w-0 items-center gap-2.5 px-3.5 py-2 text-start hover:bg-muted/40 active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-ring`,children:[d,o,(0,X.jsx)(Oe,{"aria-hidden":!0,className:i(`size-4 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,!o&&`ms-auto`,s&&`rotate-180`)})]}):(0,X.jsxs)(`div`,{className:`flex min-h-11 w-full min-w-0 items-center gap-2.5 px-3.5 py-2`,children:[d,o]}),f&&s?(0,X.jsx)(`div`,{"data-slot":`run-activity-body`,className:`min-w-0 border-t border-border/60 bg-muted/30 px-3.5 py-2.5`,children:u}):null]})}function ma(e){return W(e.delegation)}function ha(e,t){let n=e?.role===`root`?e.receipts.map(e=>e.workerId).reverse():[];return[...new Set([...n,...(t?.workers??[]).map(e=>e.workerId)])]}function ga(e){let t=e.delegation,n=ma(e),r=y(e.id,{enabled:n});if(!n||!t)return`complete`;if(!r.isSuccess)return r.isError||r.fetchStatus===`paused`?`unknown`:`pending`;let i=new Map(r.data.workers.map(e=>[e.workerId,e])),a=ha(t,r.data).map(e=>{let t=i.get(e)?.status;return t===`done`||t===`cancelled`?`complete`:t===void 0||t===`failed`?`issue`:`pending`});return a.includes(`pending`)?`pending`:a.includes(`issue`)?`issue`:`complete`}function _a(e){let t=y(e.id,{enabled:e.delegation?.role===`root`});return t.isSuccess&&t.data.workers.some(e=>rn(e.status))}function va({run:e,open:t,onToggle:n}){let r=y(e.id),a=S(),o=pn(),s=e.delegation,c=new Map(r.data?.workers.map(e=>[e.workerId,e])),l=ha(s,r.data),u=I(e)??F(e),d=u?ya(e,u):void 0,f=e=>a.data?.find(t=>t.id===e)??r.data?.titles?.find(t=>t.id===e),p=e=>{let t=f(e);return t?q(t):`worker ${e.slice(0,8)}`};return(0,X.jsx)(Q,{slot:`workers`,icon:(0,X.jsx)(Se,{className:`size-4`}),title:`Workers`,meta:ba({ids:l,workers:c,desktop:o,query:r}),aside:r.data?.capacity?(0,X.jsx)(Da,{capacity:r.data.capacity}):void 0,open:t,onToggle:n,children:(0,X.jsxs)(`div`,{"aria-label":`Task relationships`,className:`min-w-0 text-[13px] text-muted-foreground`,role:`group`,children:[r.data?.capacity&&r.data.capacity.outstanding>=r.data.capacity.limit?(0,X.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`All worker slots are in use. Clean up finished workers to free a slot.`}):null,u?(0,X.jsx)(wa,{wait:u,dependencyLabel:d}):null,l.length>0?(0,X.jsx)(`ul`,{className:`grid max-h-64 min-w-0 gap-0.5 overflow-y-auto`,children:l.map(t=>{let n=c.get(t),a=f(t),o=n?Sa(n.status):r.isSuccess?`Record unavailable or deleted`:`Status unavailable`;return(0,X.jsxs)(`li`,{"data-slot":`worker-item`,"data-status":n?.status,className:`min-w-0`,children:[(0,X.jsxs)(Yt,{to:`/tasks/${t}`,"aria-label":`Worker task ${t}`,className:`group flex min-h-11 min-w-0 items-center gap-2.5 rounded-md px-1 text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,X.jsx)(xa,{status:n?.status}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block truncate`,children:a?q(a):`Worker ${t.slice(0,8)}`}),n?.supervisorRunId&&n.supervisorRunId!==e.id?(0,X.jsxs)(`span`,{"data-slot":`worker-supervisor`,className:`block truncate text-xs text-muted-foreground`,children:[`Started by `,p(n.supervisorRunId)]}):null]}),(0,X.jsx)(`span`,{className:i(`max-w-[45%] shrink-0 truncate text-xs`,Ca(n?.status)),children:o}),(0,X.jsx)(Te,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground`})]}),n?(0,X.jsx)(ka,{parentRunId:e.id,worker:n}):null,n?.destroy?(0,X.jsx)(Na,{state:n.destroy}):null]},t)})}):ma(e)&&r.isSuccess?(0,X.jsx)(`p`,{className:`px-1 py-1`,children:`No workers`}):null,r.fetchStatus===`paused`?(0,X.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`Offline — relationship details will refresh when connected.`}):r.isPending?(0,X.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`Loading relationships…`}):null,r.isError?(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-1 py-1`,children:[(0,X.jsx)(`p`,{role:`status`,children:`Could not load relationships. Known task links are retained.`}),(0,X.jsx)(K,{variant:`outline`,className:`min-h-11`,onClick:()=>void r.refetch(),children:`Retry relationships`})]}):null]})})}function ya(e,t){let n=e.delegation;if(!(!n||n.role===`invalid`))return N(e)??M(n.role,t,`requestIds`in t&&P(n,t.requestIds))}function ba({ids:e,workers:t,desktop:n,query:r}){if(e.length===0)return r.isError?`Unavailable`:r.isPending?`Linking…`:`No workers`;let i=`${e.length} linked`;if(!n)return i;let a=new Map;for(let n of e){let e=t.get(n)?.status;e!==void 0&&a.set(e,(a.get(e)??0)+1)}return[i,...[...a.entries()].map(([e,t])=>`${t} ${e}`)].join(` · `)}function xa({status:e}){let t=`size-[15px] shrink-0`;return e===`done`?(0,X.jsx)(Ee,{"aria-hidden":!0,className:i(t,`text-semantic-green`)}):e===`failed`?(0,X.jsx)(he,{"aria-hidden":!0,className:i(t,`text-semantic-red`)}):e===`cancelled`?(0,X.jsx)(be,{"aria-hidden":!0,className:i(t,`text-soft-foreground`)}):e===`review`?(0,X.jsx)(Dt,{"aria-hidden":!0,className:i(t,`text-semantic-info`)}):e===`waiting`?(0,X.jsx)(Ce,{"aria-hidden":!0,className:i(t,`text-semantic-amber`)}):e===`running`?(0,X.jsx)(Ot,{role:`status`,"aria-label":`Worker running`,className:i(t,`animate-spin stroke-status-running motion-reduce:animate-none`)}):(0,X.jsx)(xe,{"aria-hidden":!0,className:i(t,`text-soft-foreground`)})}function Sa(e){return Cn(e)}function Ca(e){return e===`done`?`text-semantic-green`:e===`failed`?`text-semantic-red`:e===`review`?`text-semantic-info`:e===`waiting`?`text-semantic-amber`:`text-muted-foreground`}function wa({wait:e,dependencyLabel:t}){return(0,X.jsxs)(`p`,{className:`px-2 break-words`,children:[e.phase===`parked`&&t?En(`waiting-on-workers`,t):`requestIds`in e&&e.requestIds?e.phase===`parked`?`Waiting for request replies`:e.phase===`wake-pending`?`Conversation update queued for this task`:`Request wait registered — the agent is finishing its turn`:e.phase===`parked`?`Waiting for workers`:e.phase===`wake-pending`?`Worker update queued for the parent`:`Worker wait registered — the agent is finishing its turn`,`.`,`deadline`in e?(0,X.jsxs)(X.Fragment,{children:[` `,`Deadline: `,(0,X.jsx)(`time`,{dateTime:e.deadline,children:e.deadline})]}):` No deadline: Squawk wakes this task when they have all settled.`]})}function Ta(e){return e.delegation?.role===`worker`&&F(e)?.phase===`wake-pending`}function Ea({run:e}){let t=F(e);return e.delegation?.role===`worker`&&t?.phase===`wake-pending`?(0,X.jsx)(wa,{wait:t,dependencyLabel:M(`worker`,t)}):null}function Da({capacity:e}){return(0,X.jsxs)(`span`,{"data-slot":`worker-capacity`,role:`status`,"aria-label":`Worker capacity: ${e.outstanding} of ${e.limit} in use`,className:`ms-auto shrink-0 whitespace-nowrap text-[13px] font-normal text-muted-foreground tabular-nums`,children:[e.outstanding,` of `,e.limit,` in use`]})}var Oa=new Set([`review`,`done`,`failed`,`cancelled`]);function ka({parentRunId:e,worker:t}){let n=c(e),[r,i]=(0,Y.useState)(!1);if(!Oa.has(t.status)||t.destroy?.phase===`complete`&&t.destroy.remaining.length===0)return null;let a=t.workerId.slice(0,8),o=!!t.destroy&&t.destroy.phase!==`complete`,s=n.error instanceof j?n.error.work:void 0;return(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 px-1`,children:[r?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`break-words text-xs`,children:re(t.workspace)?`Removes this worker's worktree and branch. Its result is saved first.`:`Stops this worker and frees its slot. It runs in this task's worktree, so no worktree or branch is removed. Its result is saved first.`}),(0,X.jsx)(K,{variant:`danger-ghost`,size:`sm`,className:`min-h-11`,"aria-label":`Confirm clean up of worker ${a}`,onClick:()=>{i(!1),n.mutate({workerId:t.workerId})},children:`Clean up`}),(0,X.jsx)(K,{variant:`outline`,size:`sm`,className:`min-h-11`,onClick:()=>i(!1),children:`Cancel`})]}):(0,X.jsx)(K,{variant:`outline`,size:`sm`,className:`min-h-11`,"aria-label":o?`Retry clean up of worker ${a}`:`Clean up worker ${a}`,disabled:n.isPending,onClick:()=>i(!0),children:n.isPending?`Cleaning up…`:o?`Retry clean up`:`Clean up`}),n.isError&&!r?(0,X.jsx)(`span`,{role:`status`,className:`break-words text-xs`,children:s?`Cleanup stopped: this worker holds ${ja(s)}. Land or commit what you need first, or discard it.`:`Cleanup did not finish: ${n.error.message}`}):null,s&&!r&&!n.isPending?(0,X.jsx)(K,{variant:`danger-ghost`,size:`sm`,className:`min-h-11`,"aria-label":`Discard work and clean up worker ${a}`,onClick:()=>n.mutate({workerId:t.workerId,discardWork:!0}),children:`Discard work and clean up`}):null]})}var Aa=(e,t,n)=>`${e} ${e===1?t:n}`;function ja(e){return[...e.uncommittedFiles?[Aa(e.uncommittedFiles,`uncommitted file`,`uncommitted files`)]:[],...e.commits?[`${Aa(e.commits,`commit`,`commits`)} no other branch reaches`]:[]].join(` and `)}function Ma(e){return e!==void 0&&(e.phase!==`complete`||e.remaining.length>0||e.error!==void 0)}function Na({state:e}){if(!Ma(e))return null;let t=e.phase===`complete`?void 0:e.retry,n=t&&(0,X.jsx)(Pa,{at:t.nextAt});return(0,X.jsxs)(`p`,{className:`px-2 pb-2 break-words`,children:[t?.needsAttention?`Cleanup needs attention`:e.phase===`incomplete`?`Cleanup incomplete`:e.phase===`complete`?`Cleanup complete`:`Cleanup ${e.phase}`,e.remaining.length?` — remaining: ${e.remaining.join(`, `)}`:``,e.error?` — ${t?e.error.replace(/\.$/,``):e.error}`:``,t?.needsAttention?(0,X.jsxs)(X.Fragment,{children:[`. Nothing changed after `,t.attempts,` automatic attempts; checking hourly, next check `,n,`. Retry clean up to try now.`]}):t?(0,X.jsxs)(X.Fragment,{children:[`. Retrying automatically, next attempt `,n,`.`]}):null]})}function Pa({at:e}){let t=ln(3e4);return(0,X.jsx)(`time`,{dateTime:e,title:new Date(e).toLocaleString(),children:Xn(t,Date.parse(e))})}function Fa({items:e,lead:t=0}){let n=(0,Y.useRef)(null),[r,i]=(0,Y.useState)(-1/0);return(0,Y.useLayoutEffect)(()=>{let r=n.current;if(!r)return;let a=()=>{let n=r.getBoundingClientRect().width;if(!n&&r.getClientRects().length===0)return;let a=getComputedStyle(r),o=Number.parseFloat(a.width),s=o>0?n/o:1,c=(Number.parseFloat(a.columnGap)||0)*s,l=Array.from(r.children,e=>e.getBoundingClientRect().width),u=e.map((e,t)=>({...e,width:l[t]??0})),d=-1/0,f=()=>u.reduce((e,t)=>e+t.width,0)+Math.max(0,u.length-1)*c+(u.length>0?t*s:0);for(let t of[...new Set(e.map(e=>e.priority))].sort((e,t)=>e-t)){if(f()<=n)break;d=t,u=u.filter(e=>e.priority>t)}i(e=>e===d?e:d)};if(a(),typeof ResizeObserver>`u`)return;let o=new ResizeObserver(a);o.observe(r);for(let e of r.children)o.observe(e);return()=>o.disconnect()},[e,t]),(0,X.jsx)(`span`,{ref:n,"data-slot":`activity-summary`,className:`relative flex h-[max(1.5em,22px)] min-w-0 flex-1 items-center gap-2.5 overflow-clip whitespace-nowrap text-[13px] font-normal text-muted-foreground tabular-nums`,children:e.map(n=>{let i=n.priority<=r,a=n===e.find(e=>e.priority>r);return(0,X.jsxs)(`span`,{"data-summary-item":n.id,"data-hidden":i,"aria-hidden":i||void 0,inert:i||void 0,style:a&&t?{marginInlineStart:t}:void 0,className:`inline-flex w-max shrink-0 items-center gap-1.5 data-[hidden=true]:invisible data-[hidden=true]:absolute`,children:[!a||t>0?(0,X.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`activity-separator`,className:`before:content-['·']`}):null,n.content]},n.id)})})}function Ia({run:e,references:t}){return(0,X.jsx)(`span`,{className:`inline-flex items-center gap-1.5`,children:t.map(t=>(0,X.jsx)(Nt,{reference:t,taskTitle:q(e),inert:!0},se(t)))})}function La(e){return e.accountId===void 0||e.profilesPending?void 0:e.profilesError?e.accountId:e.accountId==="default"?On(e.accounts,e.accountBackend)?`default`:void 0:e.known?On(e.accounts,e.accountBackend)?e.known.label:void 0:`${e.accountId} (removed)`}function Ra(e){let t=x(),n=m(),r=g(),{accounts:i}=qn(),a=e.runner??n.data?.defaultRunner??`claude`,o=e.model??`auto`,s=e.effort||`auto`,c=[...e.steps].reverse().find(e=>e.profileId),l=c?.profileId,u=c?.backend??a,d=r.data?.profiles.find(e=>e.id===l&&e.provider===u),p=La({accountId:l,profilesPending:r.isPending,profilesError:r.isError,known:d,accounts:i,accountBackend:u}),h=e.modelIdentity&&e.modelIdentity!==o?e.modelIdentity:void 0;return{runner:e.removedRunner===void 0?f(t.data,a):O(e.removedRunner),...p?{account:p}:{},model:o,effort:s,...h?{identity:h}:{}}}var za=[`running`,`queued`,`waiting`];function Ba(e){return Array.isArray(e)?e.filter(e=>e?.kind===`pr`||e?.kind===`timer`||e?.kind===`worker`||e?.kind===`process`||e?.kind===`peer`||e?.kind===`subagent`||e?.kind===`plugin`):[]}function $(e){let t=e?new Date(e):void 0;return t&&Number.isFinite(t.getTime())?new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(t):void 0}function Va(e,t){return`${e} — ${t.status===`failed`?`not delivered; Continue delivers it, Stop discards it`:t.status===`running`?`current turn still working`:`waiting for capacity`}`}function Ha(e){return e.kind!==`worker`&&e.kind!==`peer`&&e.kind!==`subagent`}function Ua(e){let t=Ba(e.waits),n=za.includes(e.status),r=t.filter(t=>t.phase===`open`?n:t.phase===`resolved`&&Ha(t)&&(n||e.status===`failed`)),i=r.some(e=>e.kind===`pr`),a=[...Ba(e.lastWaits),...t.filter(e=>!r.includes(e)&&e.phase!==`open`)],o=i?void 0:a.filter(e=>e.kind===`pr`).at(-1),s=i?void 0:e.lastWaitsError,c=r.some(e=>e.kind===`process`)?void 0:a.filter(e=>e.kind===`process`).at(-1);return r.length||o||s||c?{open:r,lastCi:o,error:s,lastProcess:c}:void 0}function Wa(e){return Ua(e)!==void 0}function Ga(e){return(Ua(e)?.open??[]).filter(e=>e.kind===`pr`).map(e=>({kind:`PR`,number:e.prNumber,url:e.prUrl}))}function Ka({run:e}){let t=Ua(e);if(!t)return null;let{open:n,lastCi:r,error:i,lastProcess:a}=t;return(0,X.jsxs)(`div`,{"data-slot":`open-waits`,className:`flex min-w-0 flex-col gap-1`,children:[n.map(t=>t.kind===`pr`?(0,X.jsx)(Ja,{run:e,wait:t},t.id):t.kind===`worker`?(0,X.jsx)(Ya,{wait:t},t.id):t.kind===`process`?(0,X.jsx)(to,{run:e,wait:t},t.id):t.kind===`peer`?(0,X.jsx)(Xa,{wait:t},t.id):t.kind===`subagent`?(0,X.jsx)(Za,{wait:t},t.id):t.kind===`plugin`?(0,X.jsx)(Qa,{run:e,wait:t},t.id):(0,X.jsx)($a,{run:e,wait:t},t.id)),i?(0,X.jsx)(`div`,{"data-slot":`ci-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:i}):r?(0,X.jsx)(Ja,{run:e,wait:r,settled:!0}):null,a?(0,X.jsx)(to,{run:e,wait:a,settled:!0}):null]})}function qa(e,t,n){let r=t.result,i=t.until!==`checks`,a={passed:`CI checks passed — observed checks only; not merge approval`,stuck:`CI checks stuck in queue — inspect the PR checks`,failed:`CI checks failed — inspect the PR checks`,conflicting:i?`PR has merge conflicts — inspect the PR; not merged`:`PR has merge conflicts — inspect the PR; not merge approval`,cancelled:i?`Merge wait cancelled`:`CI wait cancelled`,skipped:`CI checks skipped — inspect the PR checks`,no_checks:`No CI checks found — inspect the PR workflows`,startup_failure:`CI workflow never started — inspect the PR workflows`,deadline:i?`Merge wait timed out — merge not confirmed`:`CI wait timed out — inspect the PR checks`,error:i?`Merge wait unavailable — inspect access and the PR`:`CI wait unavailable — inspect access and the PR checks`,head_changed:`CI head changed — ${r?.headSha?vn(r.headSha):`unknown`} → ${r?.observedHeadSha?vn(r.observedHeadSha):`unknown`}`,merged:`PR merged`,closed:`PR closed without merge — inspect the PR`,blocked:`Initiated merge blocked — inspect the PR; not merged`},o=i?`Merge`:`CI`,s=n&&t.phase===`cancelled`;return n?s?`${o} wait cancelled`:r?a[r.outcome]:`${o} wait unavailable`:t.phase===`resolved`?Va(`${o} result ready`,e):t.until===`merge_or_blocked`?`Waiting for merge or blockage`:i?`Waiting for merge`:`Waiting for CI`}function Ja({run:e,wait:t,settled:n=!1}){let r=t.result,i=t.until===`checks`?`CI`:`Merge`,o=n&&t.phase===`cancelled`,s=qa(e,t,n),c=n?o?t.cancelledAt:r?.observedAt:t.deadline,l=$(c),u=`${t.repository}#${t.prNumber}`;return(0,X.jsx)(`div`,{"data-slot":`ci-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-[13px] text-muted-foreground [overflow-wrap:anywhere]`,children:(0,X.jsxs)(`dl`,{className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-baseline gap-x-3 gap-y-1`,children:[(0,X.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Status`}),(0,X.jsx)(`dd`,{children:s}),(0,X.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Pull request`}),(0,X.jsx)(`dd`,{className:`min-w-0`,children:a(t.prUrl)?(0,X.jsx)(`a`,{href:t.prUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex min-h-11 min-w-11 max-w-full items-center rounded-sm px-1 font-medium text-foreground underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring active:bg-muted`,children:u}):(0,X.jsx)(`span`,{children:u})}),l?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-foreground`,children:n?o?`Cancelled`:`Observed`:`Deadline`}),(0,X.jsx)(`dd`,{children:(0,X.jsx)(`time`,{dateTime:c,children:l})})]}):n?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Deadline`}),(0,X.jsxs)(`dd`,{children:[i,` deadline unavailable`]})]})]})})}function Ya({wait:e}){let t=e.workerIds!==void 0,n=new Set((t?e.outcomes:e.requestOutcomes)?.map(e=>`workerId`in e?e.workerId:e.requestId)),r=(e.workerIds??e.requestIds??[]).filter(e=>!n.has(e)).length,i=t?r===1?`worker`:`workers`:r===1?`request reply`:`request replies`,a=$(e.deadline);return(0,X.jsxs)(`div`,{"data-slot":`worker-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,X.jsxs)(`p`,{children:[`Waiting for `,r,` `,i]}),a?(0,X.jsxs)(`p`,{children:[`Deadline`,` `,(0,X.jsx)(`time`,{dateTime:e.deadline,children:a})]}):(0,X.jsx)(`p`,{children:`Worker wait deadline unavailable`})]})}function Xa({wait:e}){let t=e.peerIds.length,n=$(e.deadline);return(0,X.jsxs)(`div`,{"data-slot":`peer-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,X.jsxs)(`p`,{children:[`Waiting for `,t,` `,t===1?`task`:`tasks`]}),n?(0,X.jsxs)(`p`,{children:[`Deadline`,` `,(0,X.jsx)(`time`,{dateTime:e.deadline,children:n})]}):(0,X.jsx)(`p`,{children:`Peer wait deadline unavailable`})]})}function Za({wait:e}){let t=(Array.isArray(e.children)?e.children:[]).filter(e=>e?.status===`running`).length,n=$(e.deadline);return(0,X.jsxs)(`div`,{"data-slot":`subagent-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,X.jsxs)(`p`,{children:[`Waiting for `,t,` `,t===1?`subagent`:`subagents`]}),n?(0,X.jsxs)(`p`,{children:[`Check by`,` `,(0,X.jsx)(`time`,{dateTime:e.deadline,children:n})]}):(0,X.jsx)(`p`,{children:`Subagent wait deadline unavailable`})]})}function Qa({run:e,wait:t}){let n=t.phase===`open`?$(t.deadline):void 0;return(0,X.jsxs)(`div`,{"data-slot":`plugin-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,X.jsx)(`p`,{children:t.phase===`resolved`?Va(t.summary,e):t.summary}),n?(0,X.jsxs)(`p`,{children:[`Deadline`,` `,(0,X.jsx)(`time`,{dateTime:t.deadline,children:n})]}):null]})}function $a({run:e,wait:t}){let n=$(t.deadline);return(0,X.jsxs)(`div`,{"data-slot":`monitoring-schedule`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[t.phase===`resolved`?(0,X.jsx)(`p`,{children:Va(`Automatic check due`,e)}):n?(0,X.jsxs)(`p`,{children:[`Next automatic check`,` `,(0,X.jsx)(`time`,{dateTime:t.deadline,className:`font-medium text-foreground`,children:n})]}):(0,X.jsx)(`p`,{children:`Automatic check time unavailable`}),t.note?(0,X.jsx)(`p`,{children:t.note}):null]})}function eo(e){let t=e.result;return t?t.outcome===`exit_file`?t.exitCode===void 0?`PID ${e.pid} wrote an exit file that is not an exit code`:`PID ${e.pid} exited with code ${t.exitCode}`:t.outcome===`exited`?e.startToken===void 0&&t.observedAt===e.registeredAt?`PID ${e.pid} was not running when the wait was registered`:`PID ${e.pid} exited, code unknown`:t.outcome===`deadline`?`PID ${e.pid} still running at the deadline`:`PID ${e.pid} could not be checked`:`PID ${e.pid} still running at the deadline`}function to({run:e,wait:t,settled:n=!1}){let r=n&&t.phase===`cancelled`?`Process wait on PID ${t.pid} cancelled`:n?eo(t):t.phase===`resolved`?Va(eo(t),e):`Waiting for PID ${t.pid}${t.note?` — ${t.note}`:``}`,i=!n&&t.phase===`open`?$(t.deadline):void 0;return(0,X.jsxs)(`div`,{"data-slot":`process-wait-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,X.jsx)(`p`,{children:r}),i?(0,X.jsxs)(`p`,{children:[`Until`,` `,(0,X.jsx)(`time`,{dateTime:t.deadline,children:i})]}):null]})}var no=new Map,ro=new Map;function io(e){let{referenceProjectId:t,repoBase:n,references:r,requests:i}=Ct(e.run);return(0,X.jsx)(At,{projectId:t,repoBase:n,requests:i,children:(0,X.jsx)(ao,{...e,references:r,prNumbers:i.filter(e=>e.kind===`PR`).map(e=>e.number),hasReferences:r.length>0||!!le(e.run)||!!ce(e.run,n)})})}function ao({run:e,thread:t,currentThread:n,currentComplete:r=!0,pendingAsk:i=!1,onOpenWorker:a,readerScroll:o,presentation:s=`card`,prNumbers:c,hasReferences:l,references:u}){let d=pn(),f=Ra(e),[p,m]=(0,Y.useState)(()=>i?!1:no.get(e.id)??!1),h=Co(o,p),g=s===`panel`||h.open,[_,v]=(0,Y.useState)({}),y=so(e,t??n,n,r,c),b=bt(e),x=t=>_[t]??ro.get(`${e.id}:${t}`)??t===`workers`,S=t=>{let n=!x(t);ro.set(`${e.id}:${t}`,n),v(e=>({...e,[t]:n}))},C=e=>({open:x(e),onToggle:()=>S(e)}),w=(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col border-t border-border`,children:[(0,X.jsx)(go,{run:e,activity:y,...C(`status`)}),(0,X.jsx)(_o,{run:e,desktop:d,automations:y.automations,...C(`workflow`)}),(0,X.jsx)(vo,{activity:y,desktop:d,onOpenWorker:a,...C(`subagents`)}),(0,X.jsx)(yo,{run:e,...C(`workers`)}),(0,X.jsx)(bo,{activity:y,desktop:d,...C(`plan`)}),(0,X.jsx)(xo,{run:e,identity:f,activity:y,...C(`usage`)}),(0,X.jsx)(So,{run:e,references:u,conflicts:y.conflicts,hasReferences:l,onResume:()=>b.mutate(),...C(`workspace`)})]});return s===`panel`?(0,X.jsxs)(`section`,{"data-slot":`run-activity-dock`,"data-presentation":`panel`,"data-state":`open`,"aria-label":`Session activity`,className:`flex min-w-0 flex-col bg-card`,children:[(0,X.jsxs)(`div`,{className:`sticky inset-bs-0 z-10 flex items-center gap-2 bg-card px-3.5 py-2.5 text-[13px]`,children:[(0,X.jsx)(pe,{"aria-hidden":!0,className:`size-4 shrink-0 text-accent-text`}),(0,X.jsx)(`span`,{className:`font-semibold text-foreground`,children:`Session activity`}),y.cost?(0,X.jsx)(`span`,{"data-slot":`run-activity-cost`,className:`ms-auto shrink-0 font-mono text-[12px] text-muted-foreground tabular-nums`,children:y.cost}):null]}),w]}):(0,X.jsxs)(`section`,{"data-slot":`run-activity-dock`,ref:h.ref,"data-state":g?`open`:`collapsed`,className:`min-w-0 overflow-hidden rounded-xl border border-border bg-card shadow-xs`,children:[(0,X.jsx)(po,{run:e,identity:f,activity:y,references:u,open:g,onToggle:()=>{no.set(e.id,!g),m(!g),h.chose(!g)}}),g?w:null]})}function oo(e,t,n,r){let i=E(),a=Bn(i.data),o=S(),s=Tt(e,{queuePosition:e.status===`queued`?tn(o.data??[]).get(e.id):void 0}),c=!$t(e)&&e.status!==`queued`,l=(0,Y.useMemo)(()=>r?pr(n.turns,c,t.turns):[],[r,n.turns,c,t.turns]),u=zt(n)??[],d=ga(e),f=hr(l),p=Zi(u);return{health:i,line:s,...co(e,s,d,r?f:void 0,p),...lo(e,a),agents:l,agentCounts:f,planEntries:u,planCounts:p}}function so(e,t,n,r,i){let a=oo(e,t,n,r),o=Mt(i);return{...a,conflicts:o,waitReferences:Ga(e),automations:Tn(a.health.data)}}function co(e,t,n,r,i){let a=e.steps.every(e=>e.status===`done`||e.status===`skipped`),o=e.status===`done`&&a&&n===`complete`&&r!==void 0&&r.done===r.total&&i.done===i.total;return{allComplete:o,statusText:o?`All complete`:e.status!==`done`||r===void 0?t.label:n===`unknown`?`Workers unavailable`:n===`pending`?`In progress`:`Incomplete`,failed:t.attention.tone===`danger`,glyph:o?(0,X.jsx)(Ee,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-success`}):(0,X.jsx)(J,{tone:t.attention.tone,shape:t.attention.shape,pulse:t.attention.pulse})}}function lo(e,t){return{cost:t.cost&&e.costUsd!==void 0?ue(e.costUsd):void 0,tokens:t.tokens&&(e.inputTokens!==void 0||e.outputTokens!==void 0)?(0,X.jsx)(Fn,{inputTokens:e.inputTokens,outputTokens:e.outputTokens}):void 0}}function uo(e){return e.allComplete?`text-semantic-green`:e.failed&&`text-semantic-red`}function fo(e){let t=la(e),n=da(e.currentStepId,t);return t.length>0?{steps:t,index:n,step:t[n]}:void 0}function po({run:e,identity:t,activity:n,references:r,open:a,onToggle:o}){let{cost:s}=n,c=[...new Map([...r,...n.waitReferences].map(e=>[se(e),e])).values()];return(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":a,"aria-label":mo(e,t,n,c,a),onClick:o,className:i(`flex min-h-11 w-full min-w-0 items-center px-3.5 py-2 text-start text-[14px] hover:bg-muted/40 active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-ring`,a?`gap-2.5`:`gap-2`),children:[(0,X.jsx)(pe,{"aria-hidden":!0,className:`size-4 shrink-0 text-accent-text`}),(0,X.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Activity`}),a?null:(0,X.jsx)(ho,{run:e,identity:t,activity:n,summaryReferences:c}),a&&s?(0,X.jsx)(`span`,{"data-slot":`run-activity-cost`,className:`ms-auto shrink-0 text-[13px] text-muted-foreground tabular-nums`,children:s}):null,(0,X.jsx)(Oe,{"aria-hidden":!0,className:i(`size-4 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,a&&!s&&`ms-auto`,a&&`rotate-180`)})]})}function mo(e,t,n,r,i){let{statusText:a,conflicts:o,cost:s}=n,c=`Session activity: ${a}${o.length?`; pull request conflicts`:``}${s?`; cost ${s}`:``}`;if(i)return c;let l=fo(e)?.step,u=l?`; step ${l.name}, ${ra(na(l.status,e.status))}`:``,d=r.length?`; ${r.map(e=>`${e.kind} #${e.number}`).join(`; `)}`:``;return`${c}${u}; runner ${t.runner}; model ${t.model}; effort ${t.effort}${d}`}function ho({run:e,identity:t,activity:n,summaryReferences:r}){let{statusText:a,cost:o,conflicts:s}=n,c=fo(e)?.step,l=[{id:`runner`,priority:2,content:t.runner},{id:`model`,priority:4,content:t.model},{id:`effort`,priority:3,content:t.effort},...o?[{id:`cost`,priority:1,content:(0,X.jsx)(`span`,{"data-slot":`run-activity-cost`,children:o})}]:[],...r.length||s.length?[{id:`chips`,priority:0,content:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ia,{run:e,references:r}),s.length>0?(0,X.jsxs)(`span`,{"data-slot":`run-activity-conflict`,className:`inline-flex items-center gap-1 font-medium text-conflict`,children:[(0,X.jsx)(De,{"aria-hidden":!0,className:`size-3.5`}),`Conflicts`]}):null]})}]:[]];return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{"data-slot":`run-activity-status`,title:a,className:i(`inline-flex min-w-[calc(0.875rem+3ch)] flex-[0_1_auto] items-center gap-1.5 text-[13px] whitespace-nowrap text-muted-foreground`,uo(n)),children:[n.glyph,(0,X.jsx)(`span`,{"data-slot":`run-activity-status-label`,className:`min-w-0 truncate`,children:a})]}),c?(0,X.jsxs)(`span`,{"data-slot":`run-activity-step`,className:i(`flex max-w-max min-w-[calc(1.375rem+2ch)] flex-[1000_1_0] items-center gap-1.5 text-[13px] text-muted-foreground`,e.status===`waiting`&&`max-md:hidden`),children:[(0,X.jsx)(Do,{step:c,runStatus:e.status,decorative:!0}),(0,X.jsx)(`span`,{"data-slot":`run-activity-step-name`,title:c.name,className:`min-w-0 truncate`,children:c.name})]}):null,(0,X.jsx)(`span`,{className:`-ms-2 flex min-w-0 flex-[1_1_0]`,children:(0,X.jsx)(Fa,{items:l,lead:8})})]})}function go({run:e,activity:t,open:n,onToggle:r}){let{line:a,waitReferences:o}=t,s=Ta(e);return(0,X.jsxs)(Q,{slot:`status-row`,icon:t.glyph,title:(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,X.jsx)(`span`,{"data-slot":`run-activity-status`,className:i(`truncate`,uo(t)),children:t.statusText}),a.nextCheck?(0,X.jsxs)(`span`,{"data-slot":`run-activity-next-check`,className:`whitespace-normal text-[13px] font-normal text-muted-foreground`,children:[`Next check `,(0,X.jsx)(`time`,{dateTime:a.nextCheck.at,children:a.nextCheck.text})]}):null]}),summary:!n&&o.length>0?(0,X.jsx)(Fa,{items:[{id:`chips`,priority:0,content:(0,X.jsx)(Ia,{run:e,references:o})}]}):void 0,open:n,onToggle:Wa(e)||s?r:void 0,children:[(0,X.jsx)(Ka,{run:e}),s?(0,X.jsx)(Ea,{run:e}):null]})}function _o({run:e,desktop:t,automations:n,open:r,onToggle:i}){let a=de(e),o=fo(e);return!a&&!o?null:(0,X.jsxs)(Q,{slot:`workflow`,icon:o?(0,X.jsx)(Do,{step:o.step,runStatus:e.status}):(0,X.jsx)(ye,{className:`size-4`}),title:(0,X.jsxs)(X.Fragment,{children:[`Workflow`,a?(0,X.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[` · `,a]}):null]}),meta:o?{drop:o.step.name,keep:fa(o.index+1,o.steps.length,t,`step`)}:void 0,open:r,onToggle:i,children:[o?(0,X.jsx)(aa,{steps:o.steps,runStatus:e.status}):null,(0,X.jsx)(Eo,{run:e,available:n})]})}function vo({activity:e,desktop:t,onOpenWorker:n,open:r,onToggle:i}){let{agents:a,agentCounts:o}=e;return a.length===0?null:(0,X.jsx)(Q,{slot:`subagents`,icon:(0,X.jsx)(_e,{className:`size-4`}),title:`Subagents`,meta:fa(o.done,o.total,t),open:r,onToggle:i,children:(0,X.jsx)(Ji,{agents:a,onSelect:n})})}function yo({run:e,open:t,onToggle:n}){return ma(e)?(0,X.jsx)(va,{run:e,open:t,onToggle:n}):null}function bo({activity:e,desktop:t,open:n,onToggle:r}){let{planEntries:i,planCounts:a}=e;return i.length===0?null:(0,X.jsx)(Q,{slot:`plan`,icon:(0,X.jsx)(me,{className:`size-4`}),title:`Plan`,meta:fa(a.done,a.total,t),open:n,onToggle:r,children:(0,X.jsx)(Qi,{entries:i})})}function xo({run:e,identity:t,activity:n,open:r,onToggle:i}){let{cost:a,tokens:o}=n,s=e.modelIdentity?.includes(`/`)?e.modelIdentity.split(`/`)[0]:void 0,c=[...s?[{id:`provider`,priority:2,content:s}]:[],{id:`model`,priority:4,content:t.model},{id:`effort`,priority:3,content:t.effort},...a?[{id:`cost`,priority:1,content:a}]:[],...o?[{id:`tokens`,priority:0,content:o}]:[]];return(0,X.jsx)(Q,{slot:`usage`,icon:(0,X.jsx)(Zn,{className:`size-4`}),title:`Usage & agent`,summary:(0,X.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`contents`,children:(0,X.jsx)(Fa,{items:c})}),open:r,onToggle:i,children:(0,X.jsx)(To,{run:e,tokens:o,cost:a})})}function So({run:e,references:t,conflicts:n,hasReferences:r,onResume:i,open:a,onToggle:o}){let s=e.delegation?.role===`worker`?e.delegation.destroy:void 0;if(!(e.branch||e.worktreePath||r||Rn(e)||Ma(s)))return null;let c=n.length===1?`PR #${n[0]} conflicts`:`${n.length} PRs conflict`;return(0,X.jsx)(Q,{slot:`workspace`,icon:(0,X.jsx)(Se,{className:`size-4`}),title:`Workspace`,summary:!a&&t.length>0?(0,X.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`contents`,children:(0,X.jsx)(Fa,{items:[...e.branch?[{id:`branch`,priority:0,content:(0,X.jsx)(`span`,{className:`font-mono text-[12px]`,children:e.branch})}]:[],{id:`chips`,priority:1,content:(0,X.jsx)(Ia,{run:e,references:t})},...n.length>0?[{id:`conflicts`,priority:2,content:(0,X.jsx)(`span`,{className:`font-medium text-conflict`,children:c})}]:[]]})}):void 0,meta:n.length>0?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-medium text-conflict`,children:[(0,X.jsx)(De,{"aria-hidden":!0,className:`size-3.5`}),c]}):e.branch?(0,X.jsx)(`span`,{className:`font-mono text-[12px]`,children:e.branch}):void 0,open:a,onToggle:o,children:(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 text-[13px] text-muted-foreground`,children:[s?(0,X.jsx)(Na,{state:s}):null,(0,X.jsx)(wt,{run:e}),e.branch?(0,X.jsx)(wo,{label:`Branch`,children:(0,X.jsx)(St,{branch:e.branch})}):null,e.worktreePath?(0,X.jsx)(wo,{label:`Worktree`,children:(0,X.jsx)(`span`,{className:`min-w-0 break-all font-mono text-[12px] text-foreground`,children:e.worktreePath})}):null,(0,X.jsx)(xt,{run:e,canResume:Gn(e).terminal,onResume:i})]})})}function Co(e,t){let n=(0,Y.useRef)(null),[r,i]=(0,Y.useState)(!1),a=(0,Y.useRef)(t);a.current=t;let o=(0,Y.useRef)({active:!1,override:!1});return(0,Y.useEffect)(()=>e?.(e=>{if(e.direction===`tail`){o.current={active:!1,override:!1},i(!1);return}if(e.direction===`down`){i(!1);return}if(o.current.active=!0,o.current.override||!a.current)return;let t=n.current?.closest(`[data-slot="thread-dock"]`);!t||getComputedStyle(t).position!==`sticky`||e.distanceFromBottom<=t.getBoundingClientRect().height||i(!0)}),[e]),{ref:n,open:t&&!r,chose:e=>{i(!1),e&&o.current.active&&(o.current.override=!0)}}}function wo({label:e,children:t}){return(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,X.jsx)(`span`,{className:`w-20 shrink-0 font-medium text-foreground`,children:e}),t]})}function To({run:e,tokens:t,cost:n}){let{runner:r,account:i,model:a,effort:o,identity:s}=Ra(e);return(0,X.jsxs)(`dl`,{"data-slot":`agent-details`,className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 text-[13px]`,children:[t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Tokens`}),(0,X.jsx)(`dd`,{className:`min-w-0 text-[12px]`,children:t})]}):null,n?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Cost`}),(0,X.jsx)(`dd`,{className:`min-w-0 font-mono text-[12px] tabular-nums`,children:n})]}):null,(0,X.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Runner`}),(0,X.jsx)(`dd`,{className:`min-w-0 break-all font-mono text-[12px]`,children:r}),i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Account`}),(0,X.jsx)(`dd`,{"data-slot":`agent-badge-account`,className:`min-w-0 break-all font-mono text-[12px]`,children:i})]}):null,(0,X.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Model`}),(0,X.jsx)(`dd`,{className:`min-w-0 break-all font-mono text-[12px]`,children:a}),(0,X.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Effort`}),(0,X.jsx)(`dd`,{"data-slot":`agent-badge-effort`,className:`min-w-0 break-all font-mono text-[12px]`,children:o}),s?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Identity`}),(0,X.jsx)(`dd`,{"data-slot":`agent-badge-identity`,className:`min-w-0 break-all font-mono text-[12px]`,children:s})]}):null]})}function Eo({run:e,available:t}){if(!e.automation)return null;let n=`inline-flex min-h-11 items-center rounded-sm text-[13px] font-medium md:min-h-8`;return(0,X.jsxs)(`p`,{className:`mt-2 text-[13px] text-muted-foreground`,children:[`Launched by`,` `,t?(0,X.jsx)(Yt,{to:`/automations/${encodeURIComponent(e.automation.automationId)}/log`,className:i(n,`text-foreground underline underline-offset-2`),children:`Automation`}):(0,X.jsx)(`span`,{"data-slot":`automation-origin`,title:`Automations are off on this server (CEZ_AUTOMATIONS)`,className:n,children:`Automation`})]})}function Do({step:e,runStatus:t,decorative:n=!1}){let r=na(e.status,t),a=`size-4 shrink-0`;switch(r){case`active`:return(0,X.jsx)(Ot,{...n?{"aria-hidden":!0}:{role:`status`,"aria-label":`Step running`},"data-slot":`workflow-glyph`,"data-visual":r,className:i(a,`animate-spin stroke-pending motion-reduce:animate-none [html.light_&]:stroke-pending-strong`)});case`paused`:return(0,X.jsx)(Ce,{...n?{"aria-hidden":!0}:{role:`img`,"aria-label":`Step paused`},"data-slot":`workflow-glyph`,"data-visual":r,className:i(a,sa)});case`failed`:return(0,X.jsx)(he,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":r,className:i(a,`text-danger`)});case`pending`:return(0,X.jsx)(xe,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":r,className:i(a,`text-soft-foreground`)});case`done`:return(0,X.jsx)(Ee,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":r,className:i(a,`text-success`)})}}function Oo(e,t,n,r){let i=oo(e,t,n,r),a=ma(e),o=y(e.id,{enabled:a}),s=(0,Y.useMemo)(()=>{let t=e.delegation?.role===`root`?e.delegation.receipts.map(e=>e.workerId):[],n=o.data?.workers.map(e=>e.workerId)??[];return new Set([...t,...n]).size},[e.delegation,o.data?.workers]),c=la(e),l=c.length>0?c[da(e.currentStepId,c)]:void 0;return{statusText:i.statusText,glyph:i.glyph,allComplete:i.allComplete,failed:i.failed,activeStepName:l?.name,workerCount:s,agentCounts:i.agentCounts,cost:i.cost,nextCheckText:i.line.nextCheck?.text}}function ko(e,t){let n=[`Session activity: ${e.statusText}`];return e.nextCheckText&&n.push(`Next check ${e.nextCheckText}`),e.activeStepName&&n.push(`step ${e.activeStepName}`),e.workerCount>0&&n.push(`${e.workerCount} ${e.workerCount===1?`worker`:`workers`}`),e.agentCounts.total>0&&n.push(`${e.agentCounts.done}/${e.agentCounts.total} subagents`),e.cost&&n.push(`cost ${e.cost}`),t===`sidebar`&&n.push(`toggle activity sidebar`),n.join(`; `)}function Ao({props:e,align:t,sideOffset:n,contentClassName:r,children:i}){let{run:a,thread:o,currentThread:s,currentComplete:c,onOpenWorker:l,open:u,onOpenChange:d,keepOpen:f=!1,onOpenAutoFocus:p}=e,m=e=>{f&&e.preventDefault()};return(0,X.jsxs)(qt,{open:u,onOpenChange:e=>{!e&&f||d(e)},children:[(0,X.jsx)(Wt,{asChild:!0,children:i}),(0,X.jsx)(Kt,{align:t,sideOffset:n,"data-slot":`run-activity-popover`,className:r,onOpenAutoFocus:p,onInteractOutside:m,onPointerDownOutside:m,onFocusOutside:m,onEscapeKeyDown:m,children:(0,X.jsx)(io,{presentation:`panel`,run:a,thread:o,currentThread:s,currentComplete:c,onOpenWorker:l})})]})}function jo(e){let{run:t,thread:n,currentThread:r,currentComplete:a,mode:o,open:s,onOpenChange:c}=e,l=Oo(t,n,r,a),u=ko(l,o),d=l.allComplete?`text-semantic-green`:l.failed?`text-semantic-red`:`text-foreground`,f=(0,X.jsxs)(`button`,{type:`button`,"data-slot":`run-activity-trigger`,"data-activity-mode":o,"aria-expanded":s,"aria-label":u,onClick:o===`sidebar`?()=>c(!s):void 0,className:i(`hidden min-h-9 min-w-0 max-w-full shrink items-center gap-2 rounded-full border border-border bg-card px-3 py-1 text-[12px] font-medium text-foreground shadow-xs transition-colors md:inline-flex`,`pointer-hover:bg-muted/60 active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,s&&`border-accent-strong/60`),children:[(0,X.jsxs)(`span`,{"data-slot":`pill`,className:`inline-flex min-w-0 items-center gap-1.5`,children:[l.glyph,(0,X.jsx)(`span`,{"data-slot":`run-activity-status`,className:i(`truncate`,d),children:(0,X.jsx)(`span`,{"data-slot":`run-activity-status-label`,children:l.statusText})})]}),l.activeStepName?(0,X.jsxs)(`span`,{className:`hidden max-w-[140px] truncate text-muted-foreground @min-[1120px]:inline`,children:[`· `,l.activeStepName]}):null,l.workerCount>0?(0,X.jsxs)(`span`,{"data-slot":`activity-workers-badge`,className:`rounded-full bg-muted px-2 py-0.5 text-xs text-foreground tabular-nums`,children:[l.workerCount,` `,l.workerCount===1?`worker`:`workers`]}):null,l.agentCounts.total>0?(0,X.jsxs)(`span`,{"data-slot":`activity-subagents-badge`,className:`rounded-full bg-muted px-2 py-0.5 text-xs text-foreground tabular-nums`,children:[l.agentCounts.done,`/`,l.agentCounts.total,` agents`]}):null,l.cost?(0,X.jsx)(`span`,{"data-slot":`run-activity-cost`,className:`font-mono text-xs text-muted-foreground tabular-nums`,children:l.cost}):null,(0,X.jsx)(Oe,{"aria-hidden":`true`,className:i(`size-3.5 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,s&&`rotate-180`)})]});return o===`sidebar`?f:(0,X.jsx)(Ao,{props:e,align:`end`,sideOffset:6,contentClassName:`w-[380px] max-w-[calc(100vw-2rem)] max-h-[min(70dvh,540px)] overflow-y-auto overscroll-contain p-0`,children:f})}function Mo(e){let{run:t,thread:n,currentThread:r,currentComplete:a,open:o}=e,s=Oo(t,n,r,a),c=ko(s,`popover`),l=s.allComplete?`text-semantic-green`:s.failed?`text-semantic-red`:`text-muted-foreground`;return(0,X.jsx)(Ao,{props:e,align:`center`,sideOffset:4,contentClassName:`w-[calc(100vw-1.5rem)] max-w-[420px] max-h-[min(65dvh,460px)] overflow-y-auto overscroll-contain p-0`,children:(0,X.jsxs)(`button`,{type:`button`,"data-slot":`run-activity-trigger-mobile`,"aria-expanded":o,"aria-label":c,className:i(`flex min-h-11 min-w-0 flex-1 items-center gap-2 border-t border-border bg-background px-1 text-start text-[13px] text-foreground md:hidden`,`active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-ring`),children:[(0,X.jsx)(pe,{"aria-hidden":`true`,className:`size-4 shrink-0 text-accent-text`}),(0,X.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Activity`}),(0,X.jsxs)(`span`,{"data-slot":`run-activity-status`,className:i(`inline-flex min-w-0 items-center gap-1.5 truncate`,l),children:[s.glyph,(0,X.jsx)(`span`,{"data-slot":`run-activity-status-label`,className:`truncate`,children:s.statusText})]}),s.workerCount>0?(0,X.jsxs)(`span`,{className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-xs font-medium text-foreground tabular-nums`,children:[s.workerCount,`w`]}):null,s.agentCounts.total>0?(0,X.jsxs)(`span`,{className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-xs font-medium text-foreground tabular-nums`,children:[s.agentCounts.done,`/`,s.agentCounts.total]}):null,s.cost?(0,X.jsx)(`span`,{className:`ms-auto shrink-0 font-mono text-xs text-muted-foreground tabular-nums`,children:s.cost}):null,(0,X.jsx)(Oe,{"aria-hidden":`true`,className:i(`size-4 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,!s.cost&&`ms-auto`,o&&`rotate-180`)})]})})}var No=2e3;function Po(e){let t=0,n=0;for(let r of e)typeof r.seq==`number`&&(r.type===`session.ended`&&r.seq>t&&(t=r.seq),(r.type===`session.started`||r.type===`step-start`&&r.kind===`agent`)&&r.seq>n&&(n=r.seq));return t>n?t:0}function Fo(e){let t=0,n=0;for(let r of e)typeof r.seq==`number`&&(r.type===`turn-end`&&r.seq>t&&(t=r.seq),(r.type===`turn.started`||r.type===`session.started`||r.type===`user-message`||r.type===`step-start`&&r.kind===`agent`)&&r.seq>n&&(n=r.seq));return t>n?t:0}function Io(e,t){let n=R(),r=(0,Y.useMemo)(()=>Po(t),[t]),i=(0,Y.useMemo)(()=>Fo(t),[t]),a=e?.id,o=e?.status;(0,Y.useEffect)(()=>{if(!(r!==0&&(o===`running`||o===`waiting`))&&!(i!==0&&o===`running`)||a===void 0)return;let e=setTimeout(()=>{n.invalidateQueries({queryKey:d.runs.detail(a)}),n.invalidateQueries({queryKey:d.runs.list()})},No);return()=>clearTimeout(e)},[r,i,a,o,n])}function Lo(e){let t=e.querySelector(`[data-slot="ask-origin"]`);return t&&(t.tabIndex=-1),t}function Ro({pendingAskId:e,askSeq:t,rows:n,history:r,jumpToRow:i}){let[a,o]=(0,Y.useState)(void 0),s=(0,Y.useCallback)(()=>o(e),[e]),c=r?.visibleEvents,l=t!==void 0&&(c?.some(({seq:e})=>e===t)??!1),u=r?.hasOlder??!1,d=r?.isFetchingOlder??!1,f=r?.olderError,p=r?.loadOlder;return(0,Y.useEffect)(()=>{if(a===void 0)return;if(a!==e){o(void 0);return}let r=Mi(n,a,`origin`);if(r){o(void 0),i(r.key,r.index,Lo);return}if(!(p!==void 0&&u&&f===void 0&&t!==void 0&&!l)){o(void 0);return}d||p().catch(()=>{})},[a,e,n,c,l,u,d,f,p,t,i]),{reveal:s,seeking:a!==void 0&&a===e}}var zo=12;function Bo({run:e}){let t=R(),n=h({mutationFn:()=>U(e.id),onSuccess:()=>{t.invalidateQueries({queryKey:d.runs.detail(e.id)}),t.invalidateQueries({queryKey:d.runs.list()}),H(`This task will not resume itself`)},onError:e=>H(e.message,{tone:`danger`})});if(!ne(e))return null;let r=new Date(e.autoResumeAt);if(!Number.isFinite(r.getTime()))return null;let i=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(r);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)(J,{tone:`neutral`,shape:`ring`}),e.autoResumeReason===`provider-error`?(0,X.jsxs)(`span`,{title:e.error,children:[`Provider error — this task retries automatically at`,` `,(0,X.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:i}),` `,`(attempt `,(e.autoResumeAttempts??0)+1,` of `,zo,`)`]}):(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:i})]}),(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)(oe,{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`})]})}function Vo({pinnedAskId:e,runStatus:t,askModeState:n,replyPending:r,composerPending:i}){let a=e!==void 0,o=!a&&t===`review`,s=n.askId===e?n.mode:`options`;return{hasPendingAsk:a,isReviewGate:o,askMode:s,decisionMode:a?`ask`:o?`review`:`composer`,unifiedReplyActive:a&&s===`reply`,composerHidden:o||a&&s===`options`,optionDeliveryPending:a&&r&&!i}}function Ho(e){let{run:t,thread:n,pinnedAsk:r,pendingQuestions:a,scroll:o,onJump:s,onShowOrigin:c,sessionOpen:l,attention:u,queued:d,continuable:f,continueAction:p,stopAction:m,finishAction:h,needsAnswer:g,sendMessage:_,reply:v,providerBlocked:y,providerReason:b,removedRunnerNotice:x}=e,S=Gn(t,_a(t)).cancel,[C,w]=(0,Y.useState)({askId:r?.id,mode:`options`}),[T,E]=(0,Y.useState)(!1),D=e=>w({askId:r?.id,mode:e}),{hasPendingAsk:O,isReviewGate:k,askMode:A,decisionMode:j,unifiedReplyActive:M,composerHidden:N,optionDeliveryPending:P}=Vo({pinnedAskId:r?.id,runStatus:t.status,askModeState:C,replyPending:v.isPending,composerPending:T});return(0,X.jsxs)(`div`,{"data-slot":`thread-dock`,"data-pending-ask":g||void 0,"data-decision-mode":j,className:`relative z-10 shrink-0 bg-background py-1.5 md:pt-2.5 md:pb-4`,children:[o.pillVisible?(0,X.jsx)(`div`,{"data-slot":`thread-jump`,className:`pointer-events-none z-30 flex justify-center`,children:(0,X.jsx)(Si,{pendingQuestions:a,onJump:s})}):null,(0,X.jsxs)(`div`,{"data-slot":`thread-footer-content`,className:i(`mx-auto flex w-full min-w-0 max-w-[var(--measure)] flex-col px-[14px] md:px-16`,M?`gap-0`:`gap-1.5 md:gap-2`),children:[k?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Bo,{run:t}),(0,X.jsx)(Uo,{run:t,sessionOpen:l,attention:u,queued:d,continuable:f,startsNewConversation:p.startsNewConversation,removedRunnerNotice:x})]}),r===void 0?k?(0,X.jsx)(ct,{run:t,showDiff:!1}):null:(0,X.jsx)(lt,{ask:{...r,placement:`pinned`},run:t,surface:`decision-zone`,mode:A,onModeChange:D,hideReplyBody:!0,delivery:v,onShowOrigin:c,onStop:S?m.stop:void 0,stopping:m.stopping,onFinish:Wn(t)?()=>h.mutateAsync():void 0,finishing:h.isPending},r.id),(0,X.jsx)(`div`,{"data-slot":`thread-composer-slot`,hidden:N,className:i(`min-w-0 w-full`,N&&`hidden`,M&&`rounded-b-xl border border-t-0 border-accent-strong/30 bg-accent-strong/[0.04] p-2.5 [html:not(.light)_&]:bg-card`),children:(0,X.jsx)(Ko,{run:t,thread:n,canStop:S,hasPendingAsk:O,composerHidden:N,optionDeliveryPending:P,onComposerPendingChange:E,stopAction:m,finishAction:h,attention:u,needsAnswer:g,continuable:f,continueAction:p,queued:d,sendMessage:_,reply:v,providerBlocked:y,providerReason:b,sessionOpen:l})})]})]})}function Uo({run:e,sessionOpen:t,attention:n,queued:r,continuable:i,startsNewConversation:a,removedRunnerNotice:o}){if(e.status===`waiting`&&t)return(0,X.jsxs)(`div`,{"data-slot":`paused-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,X.jsx)(J,{tone:n.tone,shape:n.shape,pulse:n.pulse}),n.bucket===`permission`?`Choose an approval option above to continue`:n.bucket===`waiting`?`The agent is paused, waiting for your reply`:`${hn(e,n).label} — you can send a message to resume`]});if(e.status===`running`){let t=Tt(e,{}),n=la(e),r=n.length>0?n[da(e.currentStepId,n)]:void 0;return(0,X.jsxs)(`div`,{"data-slot":`running-hint`,className:`flex min-w-0 items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,X.jsx)(J,{tone:t.attention.tone,shape:t.attention.shape,pulse:t.attention.pulse}),(0,X.jsxs)(`span`,{className:`truncate`,children:[t.label,r?` · ${r.name}`:``]})]})}return r?(0,X.jsxs)(`div`,{"data-slot":`queued-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,X.jsx)(J,{tone:`neutral`,shape:`ring`}),`Messages you add now are folded into the prompt before the run starts.`]}):o===void 0?i&&a?(0,X.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,role:`status`,children:`Starts a new agent conversation.`}):null:(0,X.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,role:`status`,children:o})}function Wo(e,t,n){if(t)return{skillRunner:n.skillRunner,skillAccount:n.skillAccount};let r=e.steps.find(t=>t.id===e.currentStepId),i=e.workflowDef?.steps.find(t=>t.id===e.currentStepId);return{skillRunner:r?.backend??i?.runner??e.runner,skillAccount:r?.profileId??i?.agentProfile??e.agentProfile}}function Go(e){let{run:t,hasPendingAsk:n,optionDeliveryPending:r,continuable:i,continueAction:a,queued:o,sendMessage:s,reply:c,providerBlocked:l,providerReason:u,sessionOpen:d}=e,f=async(e,t)=>{let n=await c.send(e,t);if(n!==void 0)throw Error(n)};return n?{onSubmit:f,pendingLabel:c.mode===`resume`?`Continuing…`:`Sending…`,disabled:l||c.blockedBy!==void 0||r,disabledReason:l?u:r?`Sending your answer…`:c.reason,placeholder:`Reply — / for skills, @ for files…`}:{onSubmit:i?(e,t)=>a.continueWith(e,t??[]):o?(e,t)=>s.mutateAsync({text:e,images:t}):f,pendingLabel:i?`Continuing…`:`Sending…`,disabled:l||!d&&!o&&!i,disabledReason:l?u:`Session closed — no session to resume.`,placeholder:Jo(t,o,i)}}function Ko(e){let{run:t,thread:n,canStop:r,hasPendingAsk:i,composerHidden:a,onComposerPendingChange:o,stopAction:s,finishAction:c,attention:l,needsAnswer:u,continuable:d,continueAction:f,providerBlocked:p}=e,m=Go(e),h=!i&&d&&!u;return(0,X.jsx)(Dn,{...Wo(t,d,f),onPendingChange:o,onStop:r?s.stop:void 0,onFinish:Wn(t)?()=>c.mutateAsync().catch(()=>void 0):void 0,finishing:c.isPending,stopOnEmpty:!i&&qo(t,l,u),stopping:s.stopping,retainDraftUntilSuccess:!0,compactFeedback:!0,pendingLabel:m.pendingLabel,failureHint:`Your draft is kept. Check the task status and connection, then retry.`,sessionControls:!i&&d?f.pills:void 0,onSubmit:m.onSubmit,disabled:m.disabled,disabledReason:m.disabledReason,footerEnd:p&&!f.providerPending?(0,X.jsx)(Yt,{to:`/settings/agent-defaults#providers`,className:`text-xs font-medium text-foreground underline underline-offset-4`,children:`Configure providers`}):void 0,allowEmptySubmit:h,emptySubmitVariant:t.status===`review`?`outline`:`primary`,emptySubmitLabel:h?`Continue`:void 0,placeholder:m.placeholder,autocompleteSkills:!0,quickReplies:!a,getMentionCandidates:()=>Rt(n)})}function qo(e,t,n){return e.status===`queued`||e.status===`running`||e.status===`waiting`&&t.bucket===`none`&&!n}function Jo(e,t,n){return t?`Add to the prompt — sent when the run starts…`:n?`Continue — add a prompt, or send to just reopen the session…`:e.status===`waiting`?`Reply — / for skills, @ for files…`:`Message the agent — / for skills, @ for files…`}function Yo(){let{id:e}=ae(),t=p(e),n=Ln(e),r=t.data?.status,i=(0,Y.useMemo)(()=>It(n.visibleEvents,{activeTurn:r===`running`}),[n.visibleEvents,r]),a=(0,Y.useMemo)(()=>It(n.currentEvents,{activeTurn:r===`running`}),[n.currentEvents,r]),o=(0,Y.useRef)(void 0),s=(0,Y.useCallback)(e=>{o.current=e},[]),{mutate:c}=u();if((0,Y.useEffect)(()=>{t.data&&o.current!==t.data.id&&nn(t.data)&&c(t.data.id)},[c,t.data?.id,t.data?.status,t.data?.finishedAt,t.data?.seenAt,t.data?.archived]),Io(t.data,n.visibleEvents),t.isPending)return(0,X.jsx)(kn,{});if(t.isError){let e=t.error instanceof j&&t.error.status===404;return(0,X.jsx)(fn,{route:`task-thread`,density:`empty`,flushPadding:!0,children:(0,X.jsx)(mn,{icon:e?(0,X.jsx)(jt,{}):(0,X.jsx)(Je,{}),tone:e?`neutral`:`danger`,title:e?`Task not found`:`Could not load this task`,subtitle:e?`No run has this id. It may have been deleted, or the link is from another machine.`:t.error.message,actions:(0,X.jsx)(K,{asChild:!0,variant:`outline`,children:(0,X.jsx)(Yt,{to:`/`,children:`Back to tasks`})})})})}return n.isPending?(0,X.jsx)(kn,{}):(0,X.jsx)(Zo,{run:t.data,thread:i,currentThread:a,history:n,onMarkedUnread:s})}var Xo=e=>({titles:Object.fromEntries(e.map(e=>[e.id,q(e)])),backends:Object.fromEntries(e.map(e=>[e.id,e.currentStepBackend??e.runner]))});function Zo({run:e,thread:t,currentThread:n=t,history:r,onMarkedUnread:i}){Jt();let a=z({queryKey:d.runs.list(),queryFn:({signal:e})=>A(_(),{signal:e}),select:Xo}),{pendingAsk:o,transcriptAsk:s,pendingAskId:c,historyLoading:l}=ns(r,n),u=k(e),f=Ft(e.status,e.error,t),p=Hn(e),m=!p&&e.status!==`queued`,h=e.status===`queued`,g=rr(e),v=qi(e),y=dt(e.id),x=s||ee(e),{hasContinuation:S,continuable:C}=rs(p,h,g),{openAgentId:w,setOpenAgentId:E,activityMode:D,activityOpen:O,setActivityOpen:j,showActivitySidebar:M,closeActivityPopover:N}=es(e.id),P=(0,Y.useRef)(void 0),F=(0,Y.useCallback)(e=>{let t=[...document.querySelectorAll(`[data-agent-id]`)].find(t=>t.dataset.agentId===e);if(t){t.focus({preventScroll:!0});return}P.current=e,j(!0)},[j]),I=(0,Y.useCallback)(e=>{let t=P.current;if(!t)return;P.current=void 0;let n=[...document.querySelectorAll(`[data-agent-id]`)].find(e=>e.dataset.agentId===t);n&&(e.preventDefault(),n.focus({preventScroll:!0}))},[]),{openAgent:R,openAgentChildren:B}=Qo(w,n,t,m),V=b(e.id),H=jn(e),{providerBlocked:te,providerReason:U}=is(p,Mn(e),S,g),ne=ts(e,h),W=l?void 0:c??null,re=(0,Y.useMemo)(()=>Oi(n,W),[n,W]),ae=re?.questions.length??0,oe=(0,Y.useMemo)(()=>ki(e,t,n,W,{pinPendingAskInTranscript:!1}),[e,t,n,W]),se=(0,Y.useMemo)(()=>Fi(oe,e.id),[oe,e.id]),{taskTitles:le,recipientBackends:ue}=$o(e,a.data),de=(0,Y.useCallback)(t=>(0,X.jsx)(Ar,{permission:t,runId:e.id,sessionOpen:p}),[e.id,p]),fe=C&&e.removedRunner!==void 0?L(e.removedRunner):void 0,pe=ce(e,T()),{search:me}=ie(),he=Be(me,se.length),G=vi(`${e.id}:main`,{onLoadOlder:r?.hasOlder?r.loadOlder:void 0,onJumpToLatest:r?.jumpToLatest,rowKeys:se.map(({key:e})=>e)}),ge=Ro({pendingAskId:c,askSeq:r?o?.seq:void 0,rows:se,history:r,jumpToRow:G.jumpToRow}),_e=(0,Y.useRef)(c);l||(_e.current=c);let ve=pi(),ye=(0,Y.useRef)({reveal:ge.reveal});ye.current={reveal:ge.reveal};let be=(0,Y.useCallback)(()=>{li(ve.current??document.body)?.focus({preventScroll:!0})},[ve]),xe=(0,Y.useCallback)(t=>t.placement===`origin`?(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[t.context?(0,X.jsx)(ft,{text:t.context}):null,t.resolved?null:(0,X.jsx)(fi,{onGoToQuestion:be})]}):(0,X.jsx)(lt,{ask:t,run:e,onShowOrigin:()=>ye.current.reveal()}),[e,be]);Gt(G.restickIfStuck);let Se=r?.currentComplete??!0,Ce={run:e,thread:t,currentThread:n,currentComplete:Se,onOpenWorker:E,mode:D,open:O,onOpenChange:j,keepOpen:w!==void 0,onOpenAutoFocus:I};return(0,X.jsxs)(fn,{route:`task-thread`,density:t.turns.length===0?`empty`:`full`,fillHeight:!0,flushPadding:!0,rootRef:ve,rootProps:{"data-run-id":e.id},className:`overflow-clip`,children:[(0,X.jsx)(Et,{run:e,onMarkedUnread:()=>i?.(e.id),desktopActivitySlot:(0,X.jsx)(jo,{...Ce}),mobileActivitySlot:(0,X.jsx)(Mo,{...Ce})}),(0,X.jsxs)(`div`,{"data-slot":`thread-workspace`,children:[(0,X.jsxs)(`div`,{"data-slot":`thread-main`,children:[(0,X.jsx)(`div`,{"data-slot":`thread-transcript`,role:`region`,"aria-label":`Session transcript`,tabIndex:0,children:(0,X.jsx)(as,{run:e,thread:t,history:r,footer:f,issueUrl:pe,sections:oe,renderAsk:xe,renderPermission:de,messageActions:ne,scroll:G,mode:he,taskTitles:le,recipientBackends:ue})}),(0,X.jsx)(Ho,{run:e,thread:t,pinnedAsk:re,pendingQuestions:ae,scroll:G,onJump:()=>{let e=ae>0?re?.id:void 0;G.jumpToLatest(e===void 0?void 0:ui(e,()=>_e.current===e))},onShowOrigin:()=>ye.current.reveal(),sessionOpen:p,attention:u,queued:h,continuable:C,continueAction:g,stopAction:v,finishAction:y,needsAnswer:x,sendMessage:V,reply:H,providerBlocked:te,providerReason:U,removedRunnerNotice:fe})]}),M?(0,X.jsx)(`aside`,{"data-slot":`thread-activity-sidebar`,"aria-label":`Session activity`,children:(0,X.jsx)(io,{presentation:`panel`,run:e,thread:t,currentThread:n,currentComplete:Se,onOpenWorker:E})}):null]}),(0,X.jsx)(pt,{status:e.status}),(0,X.jsx)(Wi,{runId:e.id,renderAsk:xe,renderPermission:de,agent:R,entries:B,taskTitles:le,recipientBackends:ue,onBeforeOpenReport:N,onRestoreAgentFocus:F,onClose:()=>E(void 0)})]})}function Qo(e,t,n,r){return{openAgent:(0,Y.useMemo)(()=>e===void 0?void 0:vr(t.turns,e,r,n.turns),[t.turns,e,r,n.turns]),openAgentChildren:(0,Y.useMemo)(()=>e===void 0?[]:xr(n.turns,t.turns,e),[n.turns,t.turns,e])}}function $o(e,t){let n=e.delegation?.role===`root`||e.delegation?.role===`worker`,r=y(e.id,{enabled:n});return{taskTitles:(0,Y.useMemo)(()=>({...Fr(e,void 0,r.data?.titles),...t?.titles,[e.id]:q(e)}),[e,t,r.data]),recipientBackends:(0,Y.useMemo)(()=>({...t?.backends,...Pr(e,void 0)}),[e,t])}}function es(e){let[t,n]=(0,Y.useState)(void 0),[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(!0),[s,c]=(0,Y.useState)(e);s!==e&&(c(e),n(void 0),i(!1));let l=zn(),u=Pn()||l?.open===!0,d=Kn(`(min-width: 1600px)`,!1)&&!u?`sidebar`:`popover`;return{openAgentId:t,setOpenAgentId:n,activityMode:d,activityOpen:d===`sidebar`?a:r,setActivityOpen:d===`sidebar`?o:i,showActivitySidebar:d===`sidebar`&&a,closeActivityPopover:(0,Y.useCallback)(()=>i(!1),[])}}function ts(e,t){let{mutateAsync:n}=o(e.id),{mutateAsync:r}=D(e.id),{mutateAsync:i}=s(e.id);return(0,Y.useMemo)(()=>{if(!t)return;let a={task:{onEdit:async e=>{await n({task:e})},editLabel:`Edit the prompt`}};for(let t of e.queuedMessages??[])a[`queued:${t.id}`]={onEdit:e=>r({msgId:t.id,message:{text:e}}).then(()=>void 0),onRemove:()=>i(t.id).then(()=>void 0)};return a},[t,e.queuedMessages,n,r,i])}function ns(e,t){let n=e?kt(e.currentEvents):void 0;return{pendingAsk:n,transcriptAsk:e?n!==void 0:t.turns.some(e=>e.items.some(e=>e.kind===`ask`&&!e.resolved)),pendingAskId:e?n?.requestId:t.turns.flatMap(e=>e.items).reverse().find(e=>e.kind===`ask`&&!e.resolved)?.id,historyLoading:e!==void 0&&(e.isPending||e.contextPending)}}function rs(e,t,n){let r=!e&&!t&&n.available;return{hasContinuation:r,continuable:r&&n.canContinue}}function is(e,t,n,r){let i=e&&!t.usable,a=n&&!r.canContinue;return{providerBlocked:i||a,providerReason:i?t.reason:r.reason}}function as({run:e,thread:t,history:n,footer:r,issueUrl:o,sections:s,renderAsk:c,renderPermission:l,messageActions:u,scroll:d,mode:f,taskTitles:p,recipientBackends:m}){return(0,X.jsxs)(`div`,{"data-slot":`session-conversation`,className:`mx-auto flex w-full max-w-[var(--measure)] flex-1 flex-col gap-2.5 px-[18px] py-3 [padding-block-end:12px] md:gap-3.5 md:px-16 md:py-5 md:[padding-block-end:24px]`,children:[n?(0,X.jsx)(os,{hasOlder:n.hasOlder,loading:n.isFetchingOlder,error:n.olderError,fallback:n.fallback,retainedPages:n.retainedPages,onLoad:d.loadOlder}):null,(0,X.jsx)(Ii,{runId:e.id,viewId:`main`,sections:s,mode:`document`,renderAsk:c,renderPermission:l,messageActions:u,scrollControls:d,renderMode:f,taskTitles:p,recipientBackends:m}),t.turns.length===0?e.status===`queued`?(0,X.jsx)(ss,{run:e}):(0,X.jsx)(`p`,{"data-slot":`thread-empty`,className:`py-6 text-center text-xs text-soft-foreground`,children:`No session events yet.`}):null,e.status===`running`?(0,X.jsx)(Ye,{}):null,r&&r.state===`closed`?(0,X.jsxs)(`div`,{"data-slot":`thread-footer`,"data-state":r.state,className:i(`mt-auto flex items-center gap-2 border-t border-border pt-3 text-xs`,r.tone===`danger`?`text-semantic-red`:`text-soft-foreground`),children:[r.label,a(le(e))?(0,X.jsx)(`a`,{"data-slot":`pr-link`,href:le(e),target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline-offset-2 hover:underline`,children:`PR ↗`}):null,a(o)?(0,X.jsx)(`a`,{"data-slot":`issue-link`,href:o,target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline-offset-2 hover:underline`,children:`Issue ↗`}):null]}):null,e.status===`review`?(0,X.jsx)(Xe,{runId:e.id}):null]})}function os({hasOlder:e,loading:t,error:n,fallback:r,retainedPages:i,onLoad:a}){return r?(0,X.jsx)(`p`,{"data-slot":`history-fallback`,className:`text-center text-xs text-soft-foreground`,role:`status`,children:`Progressive history is unavailable; showing the complete session.`}):!e&&!n?(0,X.jsxs)(`div`,{"data-slot":`history-start`,className:`flex items-center gap-3 text-xs text-soft-foreground`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),`Start of session`,(0,X.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]}):(0,X.jsxs)(`div`,{"data-slot":`history-boundary`,"data-retained-pages":i,"aria-busy":t,className:`flex min-h-8 items-center justify-center text-xs text-muted-foreground`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:a,disabled:t,className:`rounded-md px-3 py-1.5 font-medium hover:bg-muted disabled:cursor-wait`,children:t?`Loading 100 earlier items…`:n?`Couldn’t load earlier items · Retry`:`Load 100 earlier items`}),(0,X.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:t?`Loading earlier session history`:n||``})]})}function ss({run:e}){let t=An(S().data??[],e.id);return(0,X.jsxs)(`div`,{"data-slot":`queued-state`,className:`flex flex-col items-center gap-1.5 py-10 text-center`,children:[(0,X.jsx)(J,{tone:`neutral`,shape:`ring`}),(0,X.jsxs)(`p`,{className:`text-[13px] font-medium`,children:[`Waiting for a free agent slot`,t===void 0?``:` — #${t} in queue`]}),(0,X.jsxs)(`p`,{className:`text-xs text-soft-foreground`,children:[e.workflow,` · starts automatically when a slot frees up`]})]})}export{Yo as TaskThreadRoute};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./react-runtime-CCIEwYL0.js";import{o as t}from"./dist-C_rn70hE.js";import{gr as n,hr as r,ti as i}from"./toaster-D0HMoto5.js";import{h as a,p as o,v as s}from"./live-protocol-DMhTnCmf.js";import{t as c}from"./createLucideIcon-BHp8sXmF.js";import{t as l}from"./app-window-CSHwDX9N.js";import{t as u}from"./play-CmVAj_fu.js";import{i as d,n as ee,o as te,r as ne}from"./tool-display-B9NN44oU.js";import{t as re}from"./square-terminal-B6RYYieR.js";import{t as ie}from"./button-C8jUIs8Q.js";import{t as ae}from"./status-dot-BXf-Ubd0.js";import{a as oe,o as se}from"./format-BU7D3IfE.js";import{f as ce,lr as f,p}from"./index-i4Bu7SvU.js";var m=c(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),h=e(),g={registered:e=>e.server.answeredAtRegistration?{label:`Open`,run:!1}:{label:`Run and open`,run:!0},adopted:()=>({label:`Open`,run:!1}),starting:()=>({label:`Open`,run:!1}),up:()=>({label:`Open`,run:!1}),stalled:()=>({label:`View`,run:!1}),exited:()=>({label:`Start again`,run:!0}),stopped:()=>({label:`Start again`,run:!0}),unavailable:()=>void 0};function _(e){let{text:t,...n}=p(e),r={...n,status:t},i=g[e.state](e);return i?{...r,action:i}:r}var v={"Run and open":u,Open:l,View:f,"Start again":te};function y({entry:e,inPreview:n,onOpen:r}){let{server:i}=e,a=_(e),o=e.state===`unavailable`,s=r?a.action:void 0,c=ce(i.command),l=oe(i.registeredAt);return(0,h.jsxs)(`div`,{"data-slot":`preview-server-card`,"data-state":e.state,className:t(`min-w-0 rounded-lg border border-border bg-card px-3.5 py-3 text-sm`,o&&`text-muted-foreground`),children:[(0,h.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2 text-xs text-soft-foreground`,children:[(0,h.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 font-mono`,children:[(0,h.jsx)(m,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`truncate`,children:`cezar_preview_serve`})]}),o?(0,h.jsx)(`span`,{children:`worktree removed`}):l?(0,h.jsx)(`span`,{children:se(l)}):null]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-2`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,h.jsx)(ae,{tone:a.tone,shape:a.ring?`ring`:`filled`,pulse:a.pulse===!0,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`font-semibold text-foreground`,children:i.label}),(0,h.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,i.port]}),(0,h.jsx)(`span`,{className:`text-muted-foreground`,children:a.status})]}),(0,h.jsx)(le,{entry:e,inPreview:n,action:s,onOpen:r})]}),(0,h.jsxs)(`div`,{className:`mt-2.5 min-w-0 rounded-md bg-muted px-3 py-2 font-mono text-xs`,children:[(0,h.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-foreground`,children:i.command}),i.cwd?(0,h.jsxs)(`p`,{className:`mt-1 flex gap-3 text-soft-foreground`,children:[(0,h.jsx)(`span`,{children:`cwd`}),(0,h.jsx)(`span`,{className:`break-all`,children:i.cwd})]}):null]}),s?.run?(0,h.jsx)(b,{icon:(0,h.jsx)(re,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),children:`${s.label===`Start again`?`Starting again`:`Opening`} runs ${c} in this task's worktree, on the host.`}):null,o?(0,h.jsx)(b,{children:`The worktree this server ran in is gone. Register it again from a new task.`}):null]})}function le({entry:e,inPreview:t,action:n,onOpen:r}){let{server:i}=e,a=t&&n!==void 0&&!n.run,o=a?`In preview`:n?.label,s=a?l:n?v[n.label]:null;return n&&o&&s?(0,h.jsxs)(ie,{variant:a||n.label===`View`||n.label===`Open`&&e.state===`starting`?`outline`:`contrast`,size:`sm`,className:`max-md:h-11 max-md:px-3.5`,onClick:()=>r?.({port:i.port,run:n.run}),children:[(0,h.jsx)(s,{"aria-hidden":`true`}),o]}):null}function b({icon:e,children:t}){return(0,h.jsxs)(`p`,{className:`mt-2.5 flex items-start gap-2 text-xs text-muted-foreground`,children:[e,(0,h.jsx)(`span`,{children:t})]})}function x(e,t){return e.kind===`message`&&e.role===`user`&&e.skillInput?.source===t&&typeof e.skillInput.id==`string`&&e.skillInput.id!==``}function ue(){return{turns:[],itemsById:new Map,turnSeq:0,eventSeq:0,permissions:new Map,conversationEntries:new Map,outcomesByRequest:new Map,seenInputs:new Set,previewByPort:new Map,handedOff:!1}}function S(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function C(e){return typeof e==`string`?e:void 0}function w(e){let t=typeof e==`string`?new Date(e):void 0;return!t||Number.isNaN(t.getTime())?``:` · ${t.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`})}`}function T(e){if(!(typeof e!=`string`||e===``))return Number.isFinite(new Date(e).getTime())?e:void 0}function de(e){return i.safeParse(e).data}function E(e,t){e.turnSeq+=1;let n={id:t===void 0?`turn-fallback-${e.turnSeq}`:`turn-seq-${t}`,entries:[],v2Items:!1};return e.turns.push(n),n}function D(e){return e.turns.at(-1)??E(e)}function O(e,t){let n={origin:`meta`,entry:t,firstSeq:e.eventSeq,lastSeq:e.eventSeq};return D(e).entries.push(n),n}var k=[/^run failed\s+[—-]\s+/,/^continue failed(?:\s+[—-]\s+|:\s+)/,/^step\s+"[^"]+"\s+failed:\s+/,/^step\s+\S+\s+failed\s+[—-]\s+/],A=/^(?:run failed\s+[—-]\s+|continue failed(?:\s+[—-]\s+|:\s+))/;function j(e){return e.trim().replace(/\s+/g,` `)}function M(e){let t=e.trim(),n=!0;for(;n;){n=!1;for(let e of k){let r=t.replace(e,``).trim();r!==t&&r!==``&&(t=r,n=!0)}}return j(t)}function N(e,t,n){if(t===e.primarySource&&n===e.primaryText||e.draft.entry.kind!==`note`)return;let r=e.draft.entry;r.details?.some(e=>e.source===t&&e.text===n)||(r.details=[...r.details??[],{source:t,text:n}])}function P(e,t,n){let r=e.failures;if(r)for(let e=r.length-1;e>=0;--e){let i=r[e];if(t!==``&&i.cause===t||t===``&&i.fatal&&(n===void 0||i.stepId===void 0||i.stepId===n))return i}}function F(e,t,n){let r=D(e),i=P(r,n.cause,n.stepId);if(i){i.draft.lastSeq=Math.max(i.draft.lastSeq,t.seq),n.fatal&&(i.fatal=!0),n.stepId!==void 0&&i.stepId===void 0&&(i.stepId=n.stepId),N(i,n.source,n.text);return}let a={draft:O(e,{kind:`note`,id:n.id,text:n.text,tone:`danger`}),cause:n.cause,primarySource:n.source,primaryText:n.text,...n.stepId===void 0?{}:{stepId:n.stepId},fatal:n.fatal};r.failures=[...r.failures??[],a]}function I(e,t,n){if(!A.test(n))return!1;let r=e.turns.at(-1);if(!r)return!1;let i=M(n);if(i===``)return!1;let a=P(r,i,C(t.stepId));return a?(a.draft.lastSeq=Math.max(a.draft.lastSeq,t.seq),a.fatal=!0,N(a,`lifecycle`,n),!0):!1}function L(e,t,n){let r=e.turns.at(-1);if(!r)return;let i=P(r,n?M(n):``,C(t.stepId));i&&(i.fatal=!0)}function R(e){for(let t of e.permissions.values())t.status===`pending`&&(t.status=`expired`)}function z(e,t){let n=C(e.stepId);return n===void 0?t:`${n}:${t}`}function B(e,t){t.v2Items=!0;for(let n of t.entries)n.origin===`v1`&&n.entry.kind===`tool`&&e.itemsById.delete(n.entry.id);t.entries=t.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`tool`))}function V(e,t,n,r,i,a=!1){let o=n.kind===`message`&&i!==void 0?{...n,ts:i}:{...n};!t.v2Items&&o.kind!==`hook`&&B(e,t);let s=e.itemsById.get(r);if(s&&s.turn===t){s.entry.entry=o,s.entry.lastSeq=e.eventSeq,s.entry.streaming=a;return}let c={origin:`v2`,entry:o,firstSeq:e.eventSeq,lastSeq:e.eventSeq,streaming:a};t.entries.push(c),e.itemsById.set(r,{turn:t,entry:c})}var H={"not-delivered":0,queued:1,delivered:2,consumed:3},fe=[`instruction`,`resumed`,`requestId`,`relationship`,`state`,`createdAt`,`requestHash`,`deadline`];function U(e){let t={};for(let n of fe)e[n]!==void 0&&Object.assign(t,{[n]:e[n]});return t}function W(e,t){if(t.messageKind!==`request`)return;let n=e.outcomesByRequest.get(t.messageId);n&&(t.outcome={status:n.status,...n.replyId===void 0?{}:{replyId:n.replyId},observedAt:n.observedAt})}function pe(e,t){let n=e.conversationEntries.get(t);n&&W(e,n)}function me(e,t,n,r){(H[e.delivery]<H.delivered||H[n]>H[e.delivery])&&(e.delivery=n),t.text!==``&&(e.text=t.text),Object.assign(e,U(t)),r.deliveredAt!==void 0&&(e.deliveredAt=r.deliveredAt),r.consumedAt!==void 0&&(e.consumedAt=r.consumedAt),r.recordedAt!==void 0&&(n===`delivered`||e.delivery!==`delivered`)&&(e.recordedAt=r.recordedAt)}function G(e,t,n,r){let i=e.conversationEntries.get(t.id);if(i){me(i,t,n,r),W(e,i);return}let a={kind:`conversation`,id:`conversation-message:${t.id}`,messageId:t.id,text:t.text,senderRunId:t.senderRunId,recipientRunId:t.recipientRunId,messageKind:t.kind,delivery:n,...r,...U(t)};W(e,a),e.conversationEntries.set(t.id,a),O(e,a)}function he(e,t){let n=w(t.ts),r=C(t.message),i=t.notify===!1?`Stopped notifying the webhook${n}`:`${e.handedOff?`Note sent to webhook`:`Handed off to webhook`}${n}${r?` — ${r}`:``}`;e.handedOff=t.notify!==!1,O(e,{kind:`note`,id:`v1:${t.seq}`,text:i,tone:`dim`,icon:`handoff`})}function ge(e,t){let n=typeof t.attempts==`number`?t.attempts:void 0,r=C(t.webhookName),i=`${r?`Delivery to ${r} failed`:`Webhook delivery failed`}${C(t.event)?` (${C(t.event)})`:``}${n?` after ${n} attempt${n===1?``:`s`}`:``}: ${C(t.error)??`unknown error`}`;O(e,{kind:`note`,id:`v1:${t.seq}`,text:i,tone:`danger`})}function _e(e,t){let n=C(t.webhookName)??`webhook`,r=C(t.title),i=`v1:${t.seq}`;if(t.ok===!1){O(e,{kind:`note`,id:i,text:`Report to ${n} failed: ${C(t.error)??`unknown error`}`,tone:`danger`});return}let a=`${t.dryRun===!0?`Report to ${n} (dry run, nothing sent)`:`Sent report to ${n}`}${w(t.ts)}${r?` — ${r}`:``}`;O(e,t.dryRun===!0?{kind:`note`,id:i,text:a,tone:`dim`}:{kind:`note`,id:i,text:a,tone:`dim`,icon:`handoff`})}function ve(e,t){let n=t.payload??{},r=`Webhook (dry run, nothing sent): ${C(t.event)??`delivery`}${C(n.status)?` · ${C(n.status)}`:``}`;O(e,{kind:`note`,id:`v1:${t.seq}`,text:r,tone:`dim`})}function ye(e,t){let n=r.safeParse(t.server);if(!n.success)return;let i=e.previewByPort.get(n.data.port);i&&(i.turn.entries=i.turn.entries.filter(e=>e!==i.draft));let a=D(e),o={origin:`meta`,firstSeq:t.seq,lastSeq:t.seq,entry:{kind:`preview-server`,id:`preview-server:${n.data.port}`,server:n.data,state:`registered`,stateAt:t.ts}};a.entries.push(o),e.previewByPort.set(n.data.port,{turn:a,draft:o})}function be(e,t){let r=n.safeParse(t.state),i=typeof t.port==`number`?e.previewByPort.get(t.port):void 0;if(!r.success||!i||i.draft.entry.kind!==`preview-server`)return;let{server:a,id:o}=i.draft.entry;i.draft.lastSeq=t.seq,i.draft.entry={kind:`preview-server`,id:o,server:a,state:r.data,stateAt:t.ts,...typeof t.exitCode==`number`?{exitCode:t.exitCode}:{},...t.reason===`user`||t.reason===`idle`?{reason:t.reason}:{}}}function xe(e,t){let n=a.safeParse(t);if(!n.success)return;let{message:r,delivery:i,deliveredAt:o,consumedAt:s,ts:c}=n.data;G(e,r,i,{deliveredAt:o,consumedAt:s,recordedAt:c})}function Se(e,t){let n=s.safeParse(t);if(!n.success)return;let{outcome:r}=n.data,i=e.outcomesByRequest.get(r.requestId);i&&!(i.status===`timed-out`&&r.status===`replied-late`)||(e.outcomesByRequest.set(r.requestId,r),pe(e,r.requestId))}function Ce(e,t){let n=o.safeParse(t);if(!n.success)return;let{input:r}=n.data;if(!e.seenInputs.has(r.id)){if(e.seenInputs.add(r.id),r.conversation){G(e,{id:r.id,text:r.text,createdAt:r.createdAt,...r.conversation},`delivered`,{deliveredAt:r.deliveredAt,recordedAt:n.data.ts});return}O(e,{kind:`note`,id:`agent-input:${r.id}`,text:r.text,tone:`dim`,attribution:{source:r.source,parentRunId:r.parentRunId}})}}function we(e,t){let n=C(t.text)??``,r=e.pendingAsk;e.pendingAsk&&!e.pendingAsk.resolved&&(e.pendingAsk.resolved=!0,e.pendingAsk.answeredBy=`human`,n!==``&&(e.pendingAsk.answer=n),e.pendingAsk=void 0);let i=E(e,t.seq),a=T(t.ts);i.userMessage={text:n,ask:r,imageCount:typeof t.imageCount==`number`?t.imageCount:0,images:Array.isArray(t.images)?t.images.filter(e=>typeof e==`string`):[],...a===void 0?{}:{ts:a}},a!==void 0&&(i.startedAt=a)}function Te(e,t){let n=e.turns.at(-1),r=n&&n.turnId===void 0&&!n.v2Items?n:E(e,t.seq);r.turnId=C(t.turnId),r.startedAt??=T(t.ts)}function Ee(e,t){for(let n=e.turns.length-1;n>=0;--n)if(e.turns[n].turnId===t)return e.turns[n];return e.turns.at(-1)}function De(e,t){R(e);let n=Ee(e,C(t.turnId));if(!n)return;let r=T(t.ts);n.completed={stopReason:C(t.stopReason)??`end_turn`,...typeof t.costUsd==`number`?{costUsd:t.costUsd}:{},...r===void 0?{}:{ts:r}}}var K=new Set([`message`,`reasoning`,`tool`,`hook`]),Oe=e=>K.has(e.kind);function ke(e){if(!(!S(e)||!K.has(e.kind)))return typeof e.id==`string`&&e.id!==``?e:void 0}function q(e,t){let n=ke(t.item);if(!n)return;let r=z(t,n.id),i=e.itemsById.get(r),a=t.type===`item.completed`,o=!a&&(n.kind===`message`||n.kind===`reasoning`);V(e,i?.turn??D(e),n,r,a?T(t.ts):void 0,o)}function Ae(e,t){let n=e.itemsById.get(z(t,C(t.itemId)??``)),r=C(t.delta)??``;if(!n||r===``||!Oe(n.entry.entry))return;let i=n.entry.entry;n.entry.lastSeq=t.seq,t.field===`output`&&i.kind===`tool`?i.output=(i.output??``)+r:t.field!==`output`&&(i.kind===`message`||i.kind===`reasoning`)&&(i.text+=r)}function je(e,t){let n=D(e),r=C(t.text)??``;if(r===``)return;let i=T(t.ts);n.entries.push({origin:`v1`,firstSeq:t.seq,lastSeq:t.seq,entry:{kind:`message`,id:`v1:${t.seq}`,role:`assistant`,text:r,...i===void 0?{}:{ts:i}}})}var Me=new Set([`pending`,`in_progress`,`completed`,`cancelled`]);function Ne(e){if(!S(e)||!Array.isArray(e.todos))return;let t=[];for(let n of e.todos){if(!S(n)||typeof n.content!=`string`)return;t.push({content:n.content,status:Me.has(n.status)?n.status:`pending`,...typeof n.activeForm==`string`?{activeForm:n.activeForm}:{}})}return t}var Pe=new Set([`subAgentActivity`,`collabAgentToolCall`,`collabToolCall`]);function Fe(e,t){let n=D(e),r=C(t.tool)??`Tool`;if(n.v2Items||Pe.has(r))return;let i=ee(r,t.input),a=i.toolKind===`plan`?Ne(t.input):void 0;a!==void 0&&(n.planEntries=a);let o={kind:`tool`,id:C(t.id)??`v1:${t.seq}`,name:r,toolKind:i.toolKind,title:i.title,status:`running`,input:t.input},s={origin:`v1`,entry:o,firstSeq:t.seq,lastSeq:t.seq};n.entries.push(s),e.itemsById.set(o.id,{turn:n,entry:s})}function Ie(e){if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e)}catch{return String(e)}}function Le(e,t){let n=e.itemsById.get(C(t.toolCallId)??``);if(!n||n.turn.v2Items||n.entry.origin!==`v1`)return;let r=n.entry.entry;r.kind===`tool`&&(n.entry.lastSeq=t.seq,r.status=`completed`,r.output=Ie(t.result))}function Re(e,t,n,r){let i=C(t.message)??``;i!==``&&O(e,{kind:`note`,id:n,text:i,tone:r})}function J(e,t){let n=C(t.message)??``;t.type===`lifecycle`&&n!==``&&I(e,t,n)||Re(e,t,`v1:${t.seq}`,t.tone===`danger`?`danger`:`dim`)}function ze(e,t){let n=C(t.message)??``;n!==``&&F(e,t,{id:`v1:${t.seq}`,source:`error`,text:n,cause:M(n),stepId:C(t.stepId),fatal:!1})}function Be(e,t){let n=C(t.message)??``;n!==``&&F(e,t,{id:`v2:${t.seq}`,source:`session.error`,text:n,cause:M(n),stepId:C(t.stepId),fatal:t.fatal===!0})}function Ve(e,t){if(t.status!==`failed`)return;let n=C(t.stepId),r=C(t.error),i=r?` — ${r}`:``;F(e,t,{id:`v1:${t.seq}`,source:`step-end`,text:`step ${n??`?`} failed${i}`,cause:r?M(r):``,stepId:n,fatal:!0})}function He(e,t){let n=C(t.command)??`check`,r=typeof t.exitCode==`number`?t.exitCode:-1;O(e,{kind:`tool`,id:`v1:${t.seq}`,name:`check`,toolKind:`execute`,title:`Ran ${n}`,status:r===0?`completed`:`failed`,output:C(t.text)??``,exitCode:r})}function Ue(e,t){let n=de(t.provider),r=C(t.authFailureId)??``;n===void 0||r.length<1||r.length>128||O(e,{kind:`provider-auth-required`,id:`v1:${t.seq}`,provider:n,authFailureId:r})}function We(e,t){let n=C(t.url);if(n===void 0)return;let r={kind:`image`,id:`v1:${t.seq}`,url:n},i=C(t.name);i!==void 0&&(r.name=i),O(e,r)}function Ge(e,t){Array.isArray(t.entries)&&(D(e).planEntries=t.entries)}function Ke(e,t){R(e);let n=C(t.reason)??`end_turn`,r=C(t.message);n===`error`&&L(e,t,r),e.sessionEnded={reason:n,...r===void 0?{}:{message:r}}}var qe=new Set([`allow_once`,`allow_always`,`reject_once`,`reject_always`]);function Je(e){return S(e)&&typeof e.id==`string`&&e.id!==``&&typeof e.label==`string`&&e.label!==``&&qe.has(e.kind)}function Ye(e){if(!(!Array.isArray(e)||e.length===0||!e.every(Je)))return new Set(e.map(e=>e.id)).size===e.length?e:void 0}function Xe(e,t){let n=C(t.requestId),r=C(t.title),i=Ye(t.options);if(!n||!r||e.permissions.has(n)||!i)return;let a=C(t.itemId),o=C(t.details),s={kind:`permission`,id:`permission:${n}`,requestId:n,title:r,options:i.map(e=>({...e})),status:`pending`,...a===void 0?{}:{itemId:a},...o===void 0?{}:{details:o}};e.permissions.set(n,s),O(e,s)}function Ze(e,t){let n=e.permissions.get(C(t.requestId)??``);if(!n||n.status!==`pending`)return;let r=C(t.optionId);r!==void 0&&n.options.some(e=>e.id===r)?(n.status=`resolved`,n.optionId=r):n.status=`expired`;let i=C(t.reason);i!==void 0&&(n.reason=i)}function Qe(e,t){let n=d(t),r=n&&ne(n);if(!r)return;let i={kind:`ask`,...r,questions:r.questions,resolved:!1};O(e,i),e.pendingAsk=i}function Y(e,t){let n=e.pendingAsk;return n&&!n.resolved&&n.askSeq===t.askSeq?n:void 0}function $e(e,t){let n=Y(e,t);if(!n)return;n.routedToParent=!0;let r=C(t.parentRunId);r!==void 0&&(n.parentRunId=r)}function et(e,t){let n=Y(e,t);n&&(n.routedToParent=!1)}function tt(e,t){let n=Y(e,t);n&&X(e,n,`undeliverable`)}var nt=new Set([`finish`,`superseded`,`parent-stopped`,`worker-stopped`,`undeliverable`]);function rt(e,t){let n=Y(e,t);n&&nt.has(t.reason)&&X(e,n,t.reason)}function X(e,t,n){t.resolved=!0,t.closed=n,e.pendingAsk=void 0}function it(e,t){let n=Y(e,t);if(n){if(t.source===`cezar`){X(e,n,`undeliverable`);return}t.source===`parent`&&(n.resolved=!0,n.answeredBy=`parent`,e.pendingAsk=void 0)}}var Z=()=>{},at=new Map([[`handoff`,he],[`webhook.failed`,ge],[`webhook.dry-run`,ve],[`webhook.report`,_e],[`preview.server-registered`,ye],[`preview.server-state`,be],[`conversation-message`,xe],[`request-outcome`,Se],[`agent-input`,Ce],[`user-message`,we],[`turn.started`,Te],[`turn.completed`,De],[`item.started`,q],[`item.updated`,q],[`item.completed`,q],[`item.delta`,Ae],[`text`,je],[`tool-call`,Fe],[`tool-result`,Le],[`note`,J],[`lifecycle`,J],[`error`,ze],[`session.error`,Be],[`step-end`,Ve],[`check-output`,He],[`provider-auth-required`,Ue],[`image`,We],[`plan.updated`,Ge],[`session.started`,e=>R(e)],[`session.ended`,Ke],[`permission.requested`,Xe],[`permission.resolved`,Ze],[`ask.requested`,Qe],[`worker-question-routed`,$e],[`worker-question-fallback`,et],[`worker-question-undelivered`,tt],[`human-ask-closed`,rt],[`human-input-delivered`,it],[`step-start`,Z],[`token-usage`,Z],[`cost`,Z],[`turn-end`,Z],[`done`,Z],[`session`,Z]]);function ot(e,t){e.eventSeq=t.seq,at.get(t.type)?.(e,t)}function st(e){for(let t=e.turns.length-1;t>=0;--t){let n=e.turns[t].planEntries;if(n!==void 0)return n}}function ct(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=new Set;for(let e=t.length-1;e>=0;--e)n.add(t[e]);return[...n]}function lt(e,t){let n=e?.turns.at(-1);if(!n)return!1;let r=M(t);return r!==``&&n.items.some(e=>e.kind===`note`&&e.tone===`danger`&&M(e.text)===r)}function ut(e,t,n){switch(e){case`waiting`:return{state:`waiting`};case`failed`:return{state:`closed`,tone:`danger`,label:t!==void 0&&t!==``&&!lt(n,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 Q(e,t){let n=e.replace(/\s*CEZ:DONE\s*$/,``).replace(/\s*CEZ:MONITORING\s*$/,``);if(t){let e=n.trimEnd(),t=e.lastIndexOf(`
|
|
1
|
+
import{t as e}from"./react-runtime-CCIEwYL0.js";import{o as t}from"./dist-C_rn70hE.js";import{gr as n,hr as r,ti as i}from"./toaster-D0HMoto5.js";import{h as a,p as o,v as s}from"./live-protocol-DMhTnCmf.js";import{t as c}from"./createLucideIcon-BHp8sXmF.js";import{t as l}from"./app-window-CSHwDX9N.js";import{t as u}from"./play-CmVAj_fu.js";import{i as d,n as ee,o as te,r as ne}from"./tool-display-B9NN44oU.js";import{t as re}from"./square-terminal-B6RYYieR.js";import{t as ie}from"./button-C8jUIs8Q.js";import{t as ae}from"./status-dot-BXf-Ubd0.js";import{a as oe,o as se}from"./format-BU7D3IfE.js";import{f as ce,lr as f,p}from"./index-I4_drgNu.js";var m=c(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),h=e(),g={registered:e=>e.server.answeredAtRegistration?{label:`Open`,run:!1}:{label:`Run and open`,run:!0},adopted:()=>({label:`Open`,run:!1}),starting:()=>({label:`Open`,run:!1}),up:()=>({label:`Open`,run:!1}),stalled:()=>({label:`View`,run:!1}),exited:()=>({label:`Start again`,run:!0}),stopped:()=>({label:`Start again`,run:!0}),unavailable:()=>void 0};function _(e){let{text:t,...n}=p(e),r={...n,status:t},i=g[e.state](e);return i?{...r,action:i}:r}var v={"Run and open":u,Open:l,View:f,"Start again":te};function y({entry:e,inPreview:n,onOpen:r}){let{server:i}=e,a=_(e),o=e.state===`unavailable`,s=r?a.action:void 0,c=ce(i.command),l=oe(i.registeredAt);return(0,h.jsxs)(`div`,{"data-slot":`preview-server-card`,"data-state":e.state,className:t(`min-w-0 rounded-lg border border-border bg-card px-3.5 py-3 text-sm`,o&&`text-muted-foreground`),children:[(0,h.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2 text-xs text-soft-foreground`,children:[(0,h.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 font-mono`,children:[(0,h.jsx)(m,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`truncate`,children:`cezar_preview_serve`})]}),o?(0,h.jsx)(`span`,{children:`worktree removed`}):l?(0,h.jsx)(`span`,{children:se(l)}):null]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-2`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,h.jsx)(ae,{tone:a.tone,shape:a.ring?`ring`:`filled`,pulse:a.pulse===!0,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`font-semibold text-foreground`,children:i.label}),(0,h.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,i.port]}),(0,h.jsx)(`span`,{className:`text-muted-foreground`,children:a.status})]}),(0,h.jsx)(le,{entry:e,inPreview:n,action:s,onOpen:r})]}),(0,h.jsxs)(`div`,{className:`mt-2.5 min-w-0 rounded-md bg-muted px-3 py-2 font-mono text-xs`,children:[(0,h.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-foreground`,children:i.command}),i.cwd?(0,h.jsxs)(`p`,{className:`mt-1 flex gap-3 text-soft-foreground`,children:[(0,h.jsx)(`span`,{children:`cwd`}),(0,h.jsx)(`span`,{className:`break-all`,children:i.cwd})]}):null]}),s?.run?(0,h.jsx)(b,{icon:(0,h.jsx)(re,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),children:`${s.label===`Start again`?`Starting again`:`Opening`} runs ${c} in this task's worktree, on the host.`}):null,o?(0,h.jsx)(b,{children:`The worktree this server ran in is gone. Register it again from a new task.`}):null]})}function le({entry:e,inPreview:t,action:n,onOpen:r}){let{server:i}=e,a=t&&n!==void 0&&!n.run,o=a?`In preview`:n?.label,s=a?l:n?v[n.label]:null;return n&&o&&s?(0,h.jsxs)(ie,{variant:a||n.label===`View`||n.label===`Open`&&e.state===`starting`?`outline`:`contrast`,size:`sm`,className:`max-md:h-11 max-md:px-3.5`,onClick:()=>r?.({port:i.port,run:n.run}),children:[(0,h.jsx)(s,{"aria-hidden":`true`}),o]}):null}function b({icon:e,children:t}){return(0,h.jsxs)(`p`,{className:`mt-2.5 flex items-start gap-2 text-xs text-muted-foreground`,children:[e,(0,h.jsx)(`span`,{children:t})]})}function x(e,t){return e.kind===`message`&&e.role===`user`&&e.skillInput?.source===t&&typeof e.skillInput.id==`string`&&e.skillInput.id!==``}function ue(){return{turns:[],itemsById:new Map,turnSeq:0,eventSeq:0,permissions:new Map,conversationEntries:new Map,outcomesByRequest:new Map,seenInputs:new Set,previewByPort:new Map,handedOff:!1}}function S(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function C(e){return typeof e==`string`?e:void 0}function w(e){let t=typeof e==`string`?new Date(e):void 0;return!t||Number.isNaN(t.getTime())?``:` · ${t.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`})}`}function T(e){if(!(typeof e!=`string`||e===``))return Number.isFinite(new Date(e).getTime())?e:void 0}function de(e){return i.safeParse(e).data}function E(e,t){e.turnSeq+=1;let n={id:t===void 0?`turn-fallback-${e.turnSeq}`:`turn-seq-${t}`,entries:[],v2Items:!1};return e.turns.push(n),n}function D(e){return e.turns.at(-1)??E(e)}function O(e,t){let n={origin:`meta`,entry:t,firstSeq:e.eventSeq,lastSeq:e.eventSeq};return D(e).entries.push(n),n}var k=[/^run failed\s+[—-]\s+/,/^continue failed(?:\s+[—-]\s+|:\s+)/,/^step\s+"[^"]+"\s+failed:\s+/,/^step\s+\S+\s+failed\s+[—-]\s+/],A=/^(?:run failed\s+[—-]\s+|continue failed(?:\s+[—-]\s+|:\s+))/;function j(e){return e.trim().replace(/\s+/g,` `)}function M(e){let t=e.trim(),n=!0;for(;n;){n=!1;for(let e of k){let r=t.replace(e,``).trim();r!==t&&r!==``&&(t=r,n=!0)}}return j(t)}function N(e,t,n){if(t===e.primarySource&&n===e.primaryText||e.draft.entry.kind!==`note`)return;let r=e.draft.entry;r.details?.some(e=>e.source===t&&e.text===n)||(r.details=[...r.details??[],{source:t,text:n}])}function P(e,t,n){let r=e.failures;if(r)for(let e=r.length-1;e>=0;--e){let i=r[e];if(t!==``&&i.cause===t||t===``&&i.fatal&&(n===void 0||i.stepId===void 0||i.stepId===n))return i}}function F(e,t,n){let r=D(e),i=P(r,n.cause,n.stepId);if(i){i.draft.lastSeq=Math.max(i.draft.lastSeq,t.seq),n.fatal&&(i.fatal=!0),n.stepId!==void 0&&i.stepId===void 0&&(i.stepId=n.stepId),N(i,n.source,n.text);return}let a={draft:O(e,{kind:`note`,id:n.id,text:n.text,tone:`danger`}),cause:n.cause,primarySource:n.source,primaryText:n.text,...n.stepId===void 0?{}:{stepId:n.stepId},fatal:n.fatal};r.failures=[...r.failures??[],a]}function I(e,t,n){if(!A.test(n))return!1;let r=e.turns.at(-1);if(!r)return!1;let i=M(n);if(i===``)return!1;let a=P(r,i,C(t.stepId));return a?(a.draft.lastSeq=Math.max(a.draft.lastSeq,t.seq),a.fatal=!0,N(a,`lifecycle`,n),!0):!1}function L(e,t,n){let r=e.turns.at(-1);if(!r)return;let i=P(r,n?M(n):``,C(t.stepId));i&&(i.fatal=!0)}function R(e){for(let t of e.permissions.values())t.status===`pending`&&(t.status=`expired`)}function z(e,t){let n=C(e.stepId);return n===void 0?t:`${n}:${t}`}function B(e,t){t.v2Items=!0;for(let n of t.entries)n.origin===`v1`&&n.entry.kind===`tool`&&e.itemsById.delete(n.entry.id);t.entries=t.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`tool`))}function V(e,t,n,r,i,a=!1){let o=n.kind===`message`&&i!==void 0?{...n,ts:i}:{...n};!t.v2Items&&o.kind!==`hook`&&B(e,t);let s=e.itemsById.get(r);if(s&&s.turn===t){s.entry.entry=o,s.entry.lastSeq=e.eventSeq,s.entry.streaming=a;return}let c={origin:`v2`,entry:o,firstSeq:e.eventSeq,lastSeq:e.eventSeq,streaming:a};t.entries.push(c),e.itemsById.set(r,{turn:t,entry:c})}var H={"not-delivered":0,queued:1,delivered:2,consumed:3},fe=[`instruction`,`resumed`,`requestId`,`relationship`,`state`,`createdAt`,`requestHash`,`deadline`];function U(e){let t={};for(let n of fe)e[n]!==void 0&&Object.assign(t,{[n]:e[n]});return t}function W(e,t){if(t.messageKind!==`request`)return;let n=e.outcomesByRequest.get(t.messageId);n&&(t.outcome={status:n.status,...n.replyId===void 0?{}:{replyId:n.replyId},observedAt:n.observedAt})}function pe(e,t){let n=e.conversationEntries.get(t);n&&W(e,n)}function me(e,t,n,r){(H[e.delivery]<H.delivered||H[n]>H[e.delivery])&&(e.delivery=n),t.text!==``&&(e.text=t.text),Object.assign(e,U(t)),r.deliveredAt!==void 0&&(e.deliveredAt=r.deliveredAt),r.consumedAt!==void 0&&(e.consumedAt=r.consumedAt),r.recordedAt!==void 0&&(n===`delivered`||e.delivery!==`delivered`)&&(e.recordedAt=r.recordedAt)}function G(e,t,n,r){let i=e.conversationEntries.get(t.id);if(i){me(i,t,n,r),W(e,i);return}let a={kind:`conversation`,id:`conversation-message:${t.id}`,messageId:t.id,text:t.text,senderRunId:t.senderRunId,recipientRunId:t.recipientRunId,messageKind:t.kind,delivery:n,...r,...U(t)};W(e,a),e.conversationEntries.set(t.id,a),O(e,a)}function he(e,t){let n=w(t.ts),r=C(t.message),i=t.notify===!1?`Stopped notifying the webhook${n}`:`${e.handedOff?`Note sent to webhook`:`Handed off to webhook`}${n}${r?` — ${r}`:``}`;e.handedOff=t.notify!==!1,O(e,{kind:`note`,id:`v1:${t.seq}`,text:i,tone:`dim`,icon:`handoff`})}function ge(e,t){let n=typeof t.attempts==`number`?t.attempts:void 0,r=C(t.webhookName),i=`${r?`Delivery to ${r} failed`:`Webhook delivery failed`}${C(t.event)?` (${C(t.event)})`:``}${n?` after ${n} attempt${n===1?``:`s`}`:``}: ${C(t.error)??`unknown error`}`;O(e,{kind:`note`,id:`v1:${t.seq}`,text:i,tone:`danger`})}function _e(e,t){let n=C(t.webhookName)??`webhook`,r=C(t.title),i=`v1:${t.seq}`;if(t.ok===!1){O(e,{kind:`note`,id:i,text:`Report to ${n} failed: ${C(t.error)??`unknown error`}`,tone:`danger`});return}let a=`${t.dryRun===!0?`Report to ${n} (dry run, nothing sent)`:`Sent report to ${n}`}${w(t.ts)}${r?` — ${r}`:``}`;O(e,t.dryRun===!0?{kind:`note`,id:i,text:a,tone:`dim`}:{kind:`note`,id:i,text:a,tone:`dim`,icon:`handoff`})}function ve(e,t){let n=t.payload??{},r=`Webhook (dry run, nothing sent): ${C(t.event)??`delivery`}${C(n.status)?` · ${C(n.status)}`:``}`;O(e,{kind:`note`,id:`v1:${t.seq}`,text:r,tone:`dim`})}function ye(e,t){let n=r.safeParse(t.server);if(!n.success)return;let i=e.previewByPort.get(n.data.port);i&&(i.turn.entries=i.turn.entries.filter(e=>e!==i.draft));let a=D(e),o={origin:`meta`,firstSeq:t.seq,lastSeq:t.seq,entry:{kind:`preview-server`,id:`preview-server:${n.data.port}`,server:n.data,state:`registered`,stateAt:t.ts}};a.entries.push(o),e.previewByPort.set(n.data.port,{turn:a,draft:o})}function be(e,t){let r=n.safeParse(t.state),i=typeof t.port==`number`?e.previewByPort.get(t.port):void 0;if(!r.success||!i||i.draft.entry.kind!==`preview-server`)return;let{server:a,id:o}=i.draft.entry;i.draft.lastSeq=t.seq,i.draft.entry={kind:`preview-server`,id:o,server:a,state:r.data,stateAt:t.ts,...typeof t.exitCode==`number`?{exitCode:t.exitCode}:{},...t.reason===`user`||t.reason===`idle`?{reason:t.reason}:{}}}function xe(e,t){let n=a.safeParse(t);if(!n.success)return;let{message:r,delivery:i,deliveredAt:o,consumedAt:s,ts:c}=n.data;G(e,r,i,{deliveredAt:o,consumedAt:s,recordedAt:c})}function Se(e,t){let n=s.safeParse(t);if(!n.success)return;let{outcome:r}=n.data,i=e.outcomesByRequest.get(r.requestId);i&&!(i.status===`timed-out`&&r.status===`replied-late`)||(e.outcomesByRequest.set(r.requestId,r),pe(e,r.requestId))}function Ce(e,t){let n=o.safeParse(t);if(!n.success)return;let{input:r}=n.data;if(!e.seenInputs.has(r.id)){if(e.seenInputs.add(r.id),r.conversation){G(e,{id:r.id,text:r.text,createdAt:r.createdAt,...r.conversation},`delivered`,{deliveredAt:r.deliveredAt,recordedAt:n.data.ts});return}O(e,{kind:`note`,id:`agent-input:${r.id}`,text:r.text,tone:`dim`,attribution:{source:r.source,parentRunId:r.parentRunId}})}}function we(e,t){let n=C(t.text)??``,r=e.pendingAsk;e.pendingAsk&&!e.pendingAsk.resolved&&(e.pendingAsk.resolved=!0,e.pendingAsk.answeredBy=`human`,n!==``&&(e.pendingAsk.answer=n),e.pendingAsk=void 0);let i=E(e,t.seq),a=T(t.ts);i.userMessage={text:n,ask:r,imageCount:typeof t.imageCount==`number`?t.imageCount:0,images:Array.isArray(t.images)?t.images.filter(e=>typeof e==`string`):[],...a===void 0?{}:{ts:a}},a!==void 0&&(i.startedAt=a)}function Te(e,t){let n=e.turns.at(-1),r=n&&n.turnId===void 0&&!n.v2Items?n:E(e,t.seq);r.turnId=C(t.turnId),r.startedAt??=T(t.ts)}function Ee(e,t){for(let n=e.turns.length-1;n>=0;--n)if(e.turns[n].turnId===t)return e.turns[n];return e.turns.at(-1)}function De(e,t){R(e);let n=Ee(e,C(t.turnId));if(!n)return;let r=T(t.ts);n.completed={stopReason:C(t.stopReason)??`end_turn`,...typeof t.costUsd==`number`?{costUsd:t.costUsd}:{},...r===void 0?{}:{ts:r}}}var K=new Set([`message`,`reasoning`,`tool`,`hook`]),Oe=e=>K.has(e.kind);function ke(e){if(!(!S(e)||!K.has(e.kind)))return typeof e.id==`string`&&e.id!==``?e:void 0}function q(e,t){let n=ke(t.item);if(!n)return;let r=z(t,n.id),i=e.itemsById.get(r),a=t.type===`item.completed`,o=!a&&(n.kind===`message`||n.kind===`reasoning`);V(e,i?.turn??D(e),n,r,a?T(t.ts):void 0,o)}function Ae(e,t){let n=e.itemsById.get(z(t,C(t.itemId)??``)),r=C(t.delta)??``;if(!n||r===``||!Oe(n.entry.entry))return;let i=n.entry.entry;n.entry.lastSeq=t.seq,t.field===`output`&&i.kind===`tool`?i.output=(i.output??``)+r:t.field!==`output`&&(i.kind===`message`||i.kind===`reasoning`)&&(i.text+=r)}function je(e,t){let n=D(e),r=C(t.text)??``;if(r===``)return;let i=T(t.ts);n.entries.push({origin:`v1`,firstSeq:t.seq,lastSeq:t.seq,entry:{kind:`message`,id:`v1:${t.seq}`,role:`assistant`,text:r,...i===void 0?{}:{ts:i}}})}var Me=new Set([`pending`,`in_progress`,`completed`,`cancelled`]);function Ne(e){if(!S(e)||!Array.isArray(e.todos))return;let t=[];for(let n of e.todos){if(!S(n)||typeof n.content!=`string`)return;t.push({content:n.content,status:Me.has(n.status)?n.status:`pending`,...typeof n.activeForm==`string`?{activeForm:n.activeForm}:{}})}return t}var Pe=new Set([`subAgentActivity`,`collabAgentToolCall`,`collabToolCall`]);function Fe(e,t){let n=D(e),r=C(t.tool)??`Tool`;if(n.v2Items||Pe.has(r))return;let i=ee(r,t.input),a=i.toolKind===`plan`?Ne(t.input):void 0;a!==void 0&&(n.planEntries=a);let o={kind:`tool`,id:C(t.id)??`v1:${t.seq}`,name:r,toolKind:i.toolKind,title:i.title,status:`running`,input:t.input},s={origin:`v1`,entry:o,firstSeq:t.seq,lastSeq:t.seq};n.entries.push(s),e.itemsById.set(o.id,{turn:n,entry:s})}function Ie(e){if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e)}catch{return String(e)}}function Le(e,t){let n=e.itemsById.get(C(t.toolCallId)??``);if(!n||n.turn.v2Items||n.entry.origin!==`v1`)return;let r=n.entry.entry;r.kind===`tool`&&(n.entry.lastSeq=t.seq,r.status=`completed`,r.output=Ie(t.result))}function Re(e,t,n,r){let i=C(t.message)??``;i!==``&&O(e,{kind:`note`,id:n,text:i,tone:r})}function J(e,t){let n=C(t.message)??``;t.type===`lifecycle`&&n!==``&&I(e,t,n)||Re(e,t,`v1:${t.seq}`,t.tone===`danger`?`danger`:`dim`)}function ze(e,t){let n=C(t.message)??``;n!==``&&F(e,t,{id:`v1:${t.seq}`,source:`error`,text:n,cause:M(n),stepId:C(t.stepId),fatal:!1})}function Be(e,t){let n=C(t.message)??``;n!==``&&F(e,t,{id:`v2:${t.seq}`,source:`session.error`,text:n,cause:M(n),stepId:C(t.stepId),fatal:t.fatal===!0})}function Ve(e,t){if(t.status!==`failed`)return;let n=C(t.stepId),r=C(t.error),i=r?` — ${r}`:``;F(e,t,{id:`v1:${t.seq}`,source:`step-end`,text:`step ${n??`?`} failed${i}`,cause:r?M(r):``,stepId:n,fatal:!0})}function He(e,t){let n=C(t.command)??`check`,r=typeof t.exitCode==`number`?t.exitCode:-1;O(e,{kind:`tool`,id:`v1:${t.seq}`,name:`check`,toolKind:`execute`,title:`Ran ${n}`,status:r===0?`completed`:`failed`,output:C(t.text)??``,exitCode:r})}function Ue(e,t){let n=de(t.provider),r=C(t.authFailureId)??``;n===void 0||r.length<1||r.length>128||O(e,{kind:`provider-auth-required`,id:`v1:${t.seq}`,provider:n,authFailureId:r})}function We(e,t){let n=C(t.url);if(n===void 0)return;let r={kind:`image`,id:`v1:${t.seq}`,url:n},i=C(t.name);i!==void 0&&(r.name=i),O(e,r)}function Ge(e,t){Array.isArray(t.entries)&&(D(e).planEntries=t.entries)}function Ke(e,t){R(e);let n=C(t.reason)??`end_turn`,r=C(t.message);n===`error`&&L(e,t,r),e.sessionEnded={reason:n,...r===void 0?{}:{message:r}}}var qe=new Set([`allow_once`,`allow_always`,`reject_once`,`reject_always`]);function Je(e){return S(e)&&typeof e.id==`string`&&e.id!==``&&typeof e.label==`string`&&e.label!==``&&qe.has(e.kind)}function Ye(e){if(!(!Array.isArray(e)||e.length===0||!e.every(Je)))return new Set(e.map(e=>e.id)).size===e.length?e:void 0}function Xe(e,t){let n=C(t.requestId),r=C(t.title),i=Ye(t.options);if(!n||!r||e.permissions.has(n)||!i)return;let a=C(t.itemId),o=C(t.details),s={kind:`permission`,id:`permission:${n}`,requestId:n,title:r,options:i.map(e=>({...e})),status:`pending`,...a===void 0?{}:{itemId:a},...o===void 0?{}:{details:o}};e.permissions.set(n,s),O(e,s)}function Ze(e,t){let n=e.permissions.get(C(t.requestId)??``);if(!n||n.status!==`pending`)return;let r=C(t.optionId);r!==void 0&&n.options.some(e=>e.id===r)?(n.status=`resolved`,n.optionId=r):n.status=`expired`;let i=C(t.reason);i!==void 0&&(n.reason=i)}function Qe(e,t){let n=d(t),r=n&&ne(n);if(!r)return;let i={kind:`ask`,...r,questions:r.questions,resolved:!1};O(e,i),e.pendingAsk=i}function Y(e,t){let n=e.pendingAsk;return n&&!n.resolved&&n.askSeq===t.askSeq?n:void 0}function $e(e,t){let n=Y(e,t);if(!n)return;n.routedToParent=!0;let r=C(t.parentRunId);r!==void 0&&(n.parentRunId=r)}function et(e,t){let n=Y(e,t);n&&(n.routedToParent=!1)}function tt(e,t){let n=Y(e,t);n&&X(e,n,`undeliverable`)}var nt=new Set([`finish`,`superseded`,`parent-stopped`,`worker-stopped`,`undeliverable`]);function rt(e,t){let n=Y(e,t);n&&nt.has(t.reason)&&X(e,n,t.reason)}function X(e,t,n){t.resolved=!0,t.closed=n,e.pendingAsk=void 0}function it(e,t){let n=Y(e,t);if(n){if(t.source===`cezar`){X(e,n,`undeliverable`);return}t.source===`parent`&&(n.resolved=!0,n.answeredBy=`parent`,e.pendingAsk=void 0)}}var Z=()=>{},at=new Map([[`handoff`,he],[`webhook.failed`,ge],[`webhook.dry-run`,ve],[`webhook.report`,_e],[`preview.server-registered`,ye],[`preview.server-state`,be],[`conversation-message`,xe],[`request-outcome`,Se],[`agent-input`,Ce],[`user-message`,we],[`turn.started`,Te],[`turn.completed`,De],[`item.started`,q],[`item.updated`,q],[`item.completed`,q],[`item.delta`,Ae],[`text`,je],[`tool-call`,Fe],[`tool-result`,Le],[`note`,J],[`lifecycle`,J],[`error`,ze],[`session.error`,Be],[`step-end`,Ve],[`check-output`,He],[`provider-auth-required`,Ue],[`image`,We],[`plan.updated`,Ge],[`session.started`,e=>R(e)],[`session.ended`,Ke],[`permission.requested`,Xe],[`permission.resolved`,Ze],[`ask.requested`,Qe],[`worker-question-routed`,$e],[`worker-question-fallback`,et],[`worker-question-undelivered`,tt],[`human-ask-closed`,rt],[`human-input-delivered`,it],[`step-start`,Z],[`token-usage`,Z],[`cost`,Z],[`turn-end`,Z],[`done`,Z],[`session`,Z]]);function ot(e,t){e.eventSeq=t.seq,at.get(t.type)?.(e,t)}function st(e){for(let t=e.turns.length-1;t>=0;--t){let n=e.turns[t].planEntries;if(n!==void 0)return n}}function ct(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=new Set;for(let e=t.length-1;e>=0;--e)n.add(t[e]);return[...n]}function lt(e,t){let n=e?.turns.at(-1);if(!n)return!1;let r=M(t);return r!==``&&n.items.some(e=>e.kind===`note`&&e.tone===`danger`&&M(e.text)===r)}function ut(e,t,n){switch(e){case`waiting`:return{state:`waiting`};case`failed`:return{state:`closed`,tone:`danger`,label:t!==void 0&&t!==``&&!lt(n,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 Q(e,t){let n=e.replace(/\s*CEZ:DONE\s*$/,``).replace(/\s*CEZ:MONITORING\s*$/,``);if(t){let e=n.trimEnd(),t=e.lastIndexOf(`
|
|
2
2
|
`)+1;/^CEZ:ASK[ \t]+.+$/.test(e.slice(t))&&(n=e.slice(0,t).trimEnd())}return n.includes(`CEZ:`)?n.split(`
|
|
3
3
|
`).filter(e=>!/^CEZ:(?:PR=\d+|ISSUE=\d+|TITLE=.+)\s*$/.test(e)).join(`
|
|
4
4
|
`):n}var dt=/\s*(?:^|\n)C(?:E(?:Z(?::.*)?)?)?$/,ft=/[ \t]+CEZ(?::[A-Z]*)?$/;function $(e){return e.replace(dt,``).replace(ft,``)}function pt(e,t,n){return t!==``&&e.some(e=>e.norm===``?n>e.firstSeq:e.norm.startsWith(t)||t.startsWith(e.norm))}function mt(e,t){let n=e=>Q(e,!0).replace(/\s+/g,``),r=new Set,i=[],a=[];for(let{origin:o,entry:s,firstSeq:c,streaming:l}of e.entries)if(o===`v2`&&s.kind===`message`){let e=n(s.text);r.add(e),i.push(e),t&&l===!0&&a.push({norm:e,firstSeq:c})}if(i.length===0)return;r.add(i.join(``));let o=[],s={entries:[],texts:[]},c=()=>{let e=n(s.texts.join(``)),t=s.entries[0],i=s.entries.length>=2&&r.has(e);if(t&&(i||pt(a,e,t.firstSeq))){s={entries:[],texts:[]};return}o.push(...s.entries),s={entries:[],texts:[]}};for(let t of e.entries)t.origin===`v1`&&t.entry.kind===`message`?(s.entries.push(t),s.texts.push(t.entry.text)):(c(),o.push(t));c(),e.entries=o}function ht(e,t){let n=new Set;for(let{origin:t,entry:r}of e.entries)t===`v2`&&r.kind===`message`&&n.add(Q(r.text,!0).trim());n.size!==0&&(e.entries=e.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`message`&&n.has(Q(e.entry.text,!0).trim()))),mt(e,t))}function gt(e){let t=e.failures?.filter(e=>e.fatal&&e.cause!==``);if(!t||t.length===0)return;let n=new Map;for(let e of t)n.set(e.cause,e);e.entries=e.entries.filter(e=>{if(e.entry.kind!==`message`||e.entry.role!==`assistant`)return!0;let t=Q(e.entry.text,!0).trim();if(t===``)return!0;let r=n.get(j(t));return r?(r.draft.firstSeq=Math.min(r.draft.firstSeq,e.firstSeq),r.draft.lastSeq=Math.max(r.draft.lastSeq,e.lastSeq),N(r,`assistant`,t),!1):!0})}function _t(e){e.userMessage&&(e.entries=e.entries.filter(({entry:e})=>!x(e,`human`)))}function vt(e){for(let t of e.conversationEntries.values())t.messageKind!==`request`||t.outcome!==void 0||t.delivery!==`not-delivered`&&(t.state!==void 0&&t.state!==`accepted`||(t.outcome={status:`pending`}))}function yt(e,t,n){let{entry:r}=e;if(r.kind!==`message`||r.role!==`assistant`)return r;let i=Q(r.text,t);return n&&e.streaming===!0?{...r,text:$(i),streaming:!0}:{...r,text:i}}function bt(e,t){let n=t||e.entries.some(({entry:e})=>e.kind===`ask`);return{id:e.id,...e.turnId===void 0?{}:{turnId:e.turnId},...e.userMessage===void 0?{}:{userMessage:e.userMessage},...e.startedAt===void 0?{}:{startedAt:e.startedAt},...e.planEntries===void 0?{}:{planEntries:e.planEntries},...e.completed===void 0?{}:{completed:e.completed},items:e.entries.map(e=>yt(e,n,t)),itemSeqs:xt(e.entries)}}function xt(e){let t=new Map;for(let{entry:n,firstSeq:r,lastSeq:i}of e)t.has(n.id)||t.set(n.id,{first:r,last:i});return t}function St(e,t={}){let n=ue();for(let t of e)ot(n,t);let r=n.turns.length-1;for(let[e,i]of n.turns.entries())i.v2Items&&ht(i,t.activeTurn===!0&&e===r),gt(i),_t(i);return vt(n),{turns:n.turns.map((e,n)=>bt(e,t.activeTurn===!0&&n===r)),...n.sessionEnded===void 0?{}:{sessionEnded:n.sessionEnded}}}export{x as a,ut as i,St as n,y as o,ct as r,m as s,st as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[data-route=github]{width:100%}[data-slot=gh-hand]{border-color:color-mix(in oklch, var(--accent-strong) 24%, var(--border));background:var(--background);border-radius:12px;flex-direction:column;gap:16px;padding:20px;display:flex}[data-slot=gh-hand]>h3{margin:0}.gh-handoff-settings{flex-direction:column;gap:16px;display:flex}.gh-field{flex-direction:column;gap:6px;min-width:0;display:flex}.gh-field>span{color:var(--muted-foreground);font-size:12px}.gh-field>button,.gh-field>select{border:1px solid var(--border);background:var(--card);width:100%;min-height:44px;color:var(--foreground);text-align:start;border-radius:8px;padding-block:0;padding-inline:12px;font-size:12px}.gh-field>button>svg:last-child{margin-inline-start:auto}[data-slot=gh-custom-prompt]{min-height:150px;margin-block-start:0;padding:16px;font-size:14px}[data-slot=gh-merge-box]{border-radius:12px;margin-block:22px;padding:24px}[data-slot=gh-merge-box] select{flex:none;min-height:44px}@media (width<=767px){[data-slot=gh-hand],[data-slot=gh-merge-box]{padding:16px}}[data-slot=gh-hand]>[data-slot=prompt-template-trigger]{border-radius:8px;align-self:flex-start;min-height:44px;padding-block:0;padding-inline:12px}[data-slot=gh-merge-box]>div>svg{display:none}[data-slot=gh-merge-box] h3{font-size:18px;font-weight:400}[data-slot=gh-merge-box] ul{margin-block-start:20px;font-size:13px}[data-slot=gh-merge-box] ul>li+li{margin-block-start:16px}[data-route=github] [data-slot=gh-tabs]{border-block-end:1px solid var(--border);flex-flow:wrap;gap:20px}[data-route=github] [data-slot=gh-tabs]>a{border:none;min-height:44px;color:var(--muted-foreground);background:0 0;border-block-end:2px solid #0000;border-radius:0;align-items:center;gap:6px;margin-block-end:-1px;padding-block:8px;padding-inline:0;font-size:13px;font-weight:500;display:inline-flex}[data-route=github] [data-slot=gh-tabs]>a[aria-current=page]{color:var(--foreground);border-color:var(--accent-text);font-weight:500}[data-slot=gh-merge-box]:not([data-eligibility=ready]) h3{color:var(--pending-strong)}[data-slot=gh-header]>div:first-child{row-gap:8px}[data-slot=gh-search]{border-radius:8px;padding-inline-start:34px;font-size:13px}[data-slot=gh-rows]{gap:0}[data-slot=gh-row-item][data-divided]{border-block-start:1px solid var(--border)}[data-slot=gh-row]{border-radius:8px;padding-block:14px;padding-inline:12px}[data-slot=gh-row][data-kind=issue] [data-slot=gh-row-icon]{display:none}[data-slot=gh-row][data-kind=issue]>span{padding-inline-start:0}[data-slot=gh-row]>span:first-child>span{white-space:normal;font-weight:400}[data-slot=gh-row]>span:nth-child(2){font-family:inherit;font-size:12px}[data-slot=gh-detail-inner]{padding:24px}[data-slot=gh-hand]{border-color:color-mix(in oklch, var(--accent-strong) 24%, var(--border))}.gh-prompt-field{gap:8px}.gh-prompt-field [data-slot=gh-custom-prompt]{border:1px solid var(--border);background:var(--card);border-radius:8px;min-height:96px;padding:12px}.gh-field [data-slot=account-pill]{width:100%}@media (width<=767px){[data-slot=gh-detail-inner]{padding:16px}}[data-slot=gh-row][data-kind=issue]>span:first-child{color:var(--foreground)}[data-slot=gh-row-labels]{order:1}[data-slot=gh-row-labels]>span+span:before{content:"·";margin-inline-end:4px}[data-slot=gh-row]>span:nth-child(2){order:2}[data-slot=gh-merge-box][data-conflicting=true] h3{color:var(--conflict)}[data-slot=gh-bypass-warning]{color:var(--pending-strong)}@media (width<=767px){[data-route=github] [data-slot=gh-tabs]{gap:12px}[data-route=github] [data-slot=gh-filter-toolbar]>div:first-child{flex-basis:auto;width:100%}}@media (width>=768px){[data-route=github] [data-slot=gh-tabs]{gap:24px;min-height:0}[data-route=github] [data-slot=gh-tabs]>a{min-height:44px;padding-block:0;padding-inline:0}[data-route=github] [data-slot=gh-filter-toolbar]{gap:10px}[data-route=github] [data-slot=gh-filter-toolbar] :is(input,button){border-radius:7px;height:36px;min-height:36px;padding-block:0;font-size:12.5px}[data-route=github] [data-slot=gh-filter-toolbar] [data-slot=gh-search]{color:var(--foreground);padding-inline-start:32px}[data-route=github] [data-slot=gh-filter-toolbar] [data-slot=gh-assigned-me]{border-radius:999px}}[data-slot=engine-row-box]{width:100%;min-width:0;container:engine-row/inline-size}.engine-row{grid-template-columns:max-content minmax(0,1fr) max-content;gap:10px;display:grid}.engine-row>:is([data-slot$=pill],:has(>[data-slot$=pill])){min-width:0}.engine-row [data-slot$=pill]{border-color:var(--border);border-radius:9px;width:100%;min-width:0;min-height:44px}.engine-row [data-slot=model-pill]{justify-content:flex-start}.engine-row [data-slot$=pill]>svg:last-child{margin-inline-start:auto}@container engine-row (width>=550px){.engine-row:not(:has([data-slot=runner-pill])){grid-template-columns:minmax(0,1fr) max-content}}@container engine-row (width<=549.99px){.engine-row{grid-template-columns:max-content minmax(0,1fr)}.engine-row>:is([data-slot=model-pill],:has(>[data-slot=model-pill])){grid-area:2/1/auto/-1}.engine-row>:is([data-slot=effort-pill],:has(>[data-slot=effort-pill])){grid-area:1/2}.engine-row:not(:has([data-slot=runner-pill]))>:is([data-slot=effort-pill],:has(>[data-slot=effort-pill])){grid-column:1/-1}.engine-row :is([data-slot=runner-pill],[data-slot=effort-pill])>svg:first-child{display:none}}@media (width<=767px){.engine-row{grid-template-columns:max-content minmax(0,1fr)}.engine-row>:is([data-slot=model-pill],:has(>[data-slot=model-pill])){grid-area:2/1/auto/-1}.engine-row>:is([data-slot=effort-pill],:has(>[data-slot=effort-pill])){grid-area:1/2}.engine-row:not(:has([data-slot=runner-pill]))>:is([data-slot=effort-pill],:has(>[data-slot=effort-pill])){grid-column:1/-1}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{o as r,s as i}from"./dist-C_rn70hE.js";import{A as a,Ct as o,Jt as s,Wt as c,_ as l,a as u,c as d,dn as f,f as p,k as m,rn as h,sn as g}from"./queries-CIeJg62Y.js";import{$ as _,I as v,J as y,Pr as b,Y as x,a as S,hi as C,ii as w,n as T,st as E}from"./toaster-D0HMoto5.js";import{A as D,X as O,_ as k,at as A,b as j,d as M,dt as ee,h as N,l as P,lt as F,nt as I,pt as L,r as te,st as R,u as ne}from"./design-icons-BZt8Kqs9.js";import{t as z}from"./external-link-BE6y205O.js";import{t as re}from"./eye-B8okNWXU.js";import{t as ie}from"./loader-circle-CPBhhDbB.js";import{t as ae}from"./message-square-B-MD-8rD.js";import{t as oe}from"./play-CmVAj_fu.js";import{t as B}from"./button-C8jUIs8Q.js";import{i as se,r as ce,t as le}from"./popover-CvL6hQ5c.js";import{a as ue,i as de,o as fe,r as pe,s as me,t as he}from"./dialog-CB9ZhEk2.js";import{t as V}from"./project-router-BHFXTx5l.js";import{a as ge,i as H,o as U,r as _e,s as ve,t as ye}from"./command-BMMjB5k9.js";import{d as be,f as W,i as xe,o as Se,p as Ce,s as we,t as Te,u as Ee}from"./skills-pM_PouEs.js";import{$ as De,Ct as G,F as Oe,Fn as ke,G as Ae,I as je,In as Me,J as Ne,K,L as Pe,M as Fe,N as Ie,P as Le,Pn as q,Q as Re,Qn as J,R as ze,W as Be,X as Ve,_n as He,at as Ue,bn as We,hr as Ge,it as Ke,nt as qe,ot as Je,q as Ye,tt as Xe}from"./index-I4_drgNu.js";import{t as Ze}from"./markdown-fuaT5ciN.js";import{t as Qe}from"./textarea-vEsJAUAV.js";import{t as $e}from"./diff-B4l1BaZJ.js";import{t as Y}from"./change-counts-wqSYI3W8.js";import{t as et}from"./option-select-_tHcMUWt.js";import{t as tt}from"./tab-link-BYYXdpLn.js";var X=e(t(),1),Z=n(),nt={squash:`Squash and merge`,merge:`Create a merge commit`,rebase:`Rebase and merge`};function Q({state:e}){let t=`size-4 shrink-0`;return e===`passing`?(0,Z.jsx)(P,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-passing`,className:r(t,`text-semantic-green`)}):e===`failing`?(0,Z.jsx)(k,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-failing`,className:r(t,`text-semantic-red`)}):e===`pending`?(0,Z.jsx)(ie,{"aria-hidden":`true`,"data-slot":`gh-merge-status-pending`,className:r(t,`animate-spin text-semantic-amber motion-reduce:animate-none`)}):e===`review`?(0,Z.jsx)(N,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-review`,className:r(t,`text-semantic-info`)}):e===`conflict`?(0,Z.jsx)(R,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-conflict`,className:r(t,`text-semantic-conflict`)}):(0,Z.jsx)(N,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-unknown`,className:r(t,`text-soft-foreground`)})}function rt(e){return e?.available?e.mergeState:null}function it(e,t){return e&&t?.methods.includes(e)?e:t?.defaultMethod??t?.methods[0]??null}function at(e){return e.state===`merged`?`Merged`:e.state===`closed`?`Closed`:e.isDraft?`Draft`:e.mergeable===`conflicting`?`Conflicts must be resolved`:e.canMerge?`Ready to merge`:e.eligibility===`unknown`?`Merge blocked · Requirements unknown`:`Merge blocked`}function ot(e){return e===`approved`||e===`not-required`?`passing`:e===`review-required`?`review`:e===`unknown`?`unknown`:`failing`}function st(e){switch(e){case`approved`:return`Approved`;case`not-required`:return`Not required`;case`review-required`:return`Waiting for review`;case`changes-requested`:return`Changes requested`;case`unknown`:return`Unknown`}}function ct(e){return e===`mergeable`?`passing`:e===`conflicting`?`conflict`:`unknown`}function lt(e){return e===`conflicting`?`present`:e===`mergeable`?`none`:`unknown`}function ut(e){return e===!0?` · required`:e===null?` · requiredness unknown`:``}function dt(e){return e?.available===!1?e.reason:`GitHub could not load merge requirements.`}function ft(e,t,n){return!!(e&&(t.canMerge||t.canOverride&&n))}function $(e){return e?nt[e]:`Merge`}function pt(e){return e===`conflicting`?`true`:void 0}function mt({check:e}){return(0,Z.jsxs)(`li`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(Q,{state:e.state}),(0,Z.jsxs)(`span`,{children:[e.name,` · `,e.state,ut(e.required)]})]}),e.url&&i(e.url)?(0,Z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-muted-foreground underline`,children:`details`}):null]})}function ht({reason:e}){return(0,Z.jsxs)(`section`,{"data-slot":`gh-merge-unavailable`,className:`mt-6 rounded-lg border border-border bg-card p-4 text-sm`,children:[(0,Z.jsx)(`p`,{className:`font-medium`,children:`Merge status unavailable`}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-soft-foreground`,children:e})]})}function gt({state:e,selectedMethod:t,overrideRules:n,mergeEnabled:i,refreshPending:a,onRefresh:o,onRunAgent:s,onConfirm:c,onMethodChange:l,onOverrideChange:u}){let d=at(e),f=ot(e.reviewDecision),p=ct(e.mergeable);return(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[e.canMerge?(0,Z.jsx)(P,{size:16,"aria-hidden":`true`,className:`mt-0.5 size-5 shrink-0 text-semantic-green`}):(0,Z.jsx)(R,{size:16,"aria-hidden":`true`,className:r(`mt-0.5 size-5 shrink-0`,e.mergeable===`conflicting`?`text-semantic-conflict`:`text-semantic-amber`)}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(`h3`,{className:`font-semibold`,children:d}),(0,Z.jsxs)(B,{type:`button`,variant:`ghost`,size:`sm`,disabled:a,onClick:o,children:[(0,Z.jsx)(O,{size:16,"aria-hidden":`true`,className:r(`size-3.5`,a&&`animate-spin`)}),`Refresh`]})]}),(0,Z.jsxs)(`p`,{className:`mt-1 font-mono text-xs text-soft-foreground`,children:[e.headRef,` (`,Me(e.headSha),`) → `,e.baseRef]}),(0,Z.jsxs)(`ul`,{className:`mt-3 space-y-2 text-xs`,children:[(0,Z.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Q,{state:f}),(0,Z.jsxs)(`span`,{children:[`Reviews: `,st(e.reviewDecision)]})]}),(0,Z.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Q,{state:p}),(0,Z.jsxs)(`span`,{children:[`Conflicts: `,lt(e.mergeable)]})]}),e.checks.length===0?(0,Z.jsx)(`li`,{children:`No checks configured`}):e.checks.map(e=>(0,Z.jsx)(mt,{check:e},e.name)),e.blockers.map(e=>(0,Z.jsx)(`li`,{className:`text-soft-foreground`,children:e.message},e.code))]}),e.mergeable===`conflicting`&&s?(0,Z.jsx)(B,{className:`mt-4`,onClick:s,children:`Run agent on this PR`}):null,e.canOverride?(0,Z.jsxs)(`label`,{className:`mt-4 flex cursor-pointer items-start gap-2 rounded-md border border-pending-strong/40 bg-pending/10 p-3 text-xs`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>u(e.target.checked),className:`mt-0.5 size-4 accent-accent-strong`}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`block font-medium`,children:`Merge without waiting for requirements`}),(0,Z.jsx)(`span`,{className:`mt-0.5 block text-soft-foreground`,children:`GitHub will allow this only if your permissions can bypass the repository rules.`})]})]}):null,e.eligibility===`unknown`?(0,Z.jsx)(`p`,{className:`mt-4 text-xs text-muted-foreground`,children:`GitHub could not confirm review and branch-protection requirements. Passing checks do not establish merge readiness.`}):null,e.state===`open`&&e.methods.length>0?(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-col flex-wrap gap-2 sm:flex-row`,children:[(0,Z.jsx)(et,{"aria-label":`Merge method`,value:t??``,onValueChange:e=>l(e),options:e.methods.map(e=>({value:e,label:nt[e]})),className:`w-full min-w-0 flex-1 bg-background sm:w-auto`}),(0,Z.jsx)(B,{disabled:!i,onClick:c,children:$(t)})]}):null]})]})}function _t({number:e,state:t,selectedMethod:n,confirming:r,overrideRules:i,mergePending:a,mergeError:o,onOpenChange:s,onMerge:c}){return(0,Z.jsx)(he,{open:r,onOpenChange:s,children:(0,Z.jsxs)(pe,{"data-slot":`gh-merge-confirm`,showCloseButton:!1,children:[(0,Z.jsxs)(fe,{children:[(0,Z.jsxs)(me,{children:[$(n),` pull request #`,e,`?`]}),(0,Z.jsx)(de,{asChild:!0,children:(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`p`,{children:[`This will merge “`,t.title,`” into `,t.baseRef,`. GitHub will re-check the exact reviewed head before changing the repository.`]}),i&&t.canOverride?(0,Z.jsx)(`p`,{"data-slot":`gh-bypass-warning`,className:`mt-4 text-sm text-semantic-amber`,children:`You are asking GitHub to bypass unmet repository requirements; GitHub may refuse if your permissions do not allow it.`}):null]})})]}),o?(0,Z.jsx)(`p`,{className:`text-sm text-danger`,children:o.message}):null,(0,Z.jsxs)(ue,{children:[(0,Z.jsx)(B,{variant:`outline`,disabled:a,onClick:()=>s(!1),children:`Cancel`}),(0,Z.jsx)(B,{disabled:a,onClick:c,children:a?`Merging…`:$(n)})]})]})})}function vt({number:e,onRunAgent:t}){let n=C(),r=p(),i=w({queryKey:c.githubMergeState(e),queryFn:({signal:t})=>x(e,{},{signal:t}),retry:!1}),a=rt(i.data),[o,s]=(0,X.useState)(null),[l,u]=(0,X.useState)(!1),[d,m]=(0,X.useState)(!1),h=f({mutationFn:t=>x(e,{refresh:!0}),onSuccess:(e,t)=>n.setQueryData(t,e),onError:e=>T(e instanceof Error?e.message:String(e),{tone:`danger`})}),g=it(o,a),v=()=>({mergeState:c.githubMergeState(e),list:c.githubPages(50),comments:c.githubComments(`pr`,e),item:c.githubItem(`pr`,e),refStatus:r===void 0?void 0:c.githubRefStatusOf(r)}),y=f({mutationFn:t=>{if(!a||!g)throw Error(`No merge method is available.`);return _(e,{method:g,expectedHeadSha:a.headSha,...d&&a.canOverride?{overrideRules:!0}:{}})},onSuccess:(t,r)=>{u(!1),T(`Pull request #${e} merged`),n.invalidateQueries({queryKey:r.mergeState}),n.invalidateQueries({queryKey:r.list}),n.invalidateQueries({queryKey:r.comments}),n.invalidateQueries({queryKey:r.item}),r.refStatus&&n.invalidateQueries({queryKey:r.refStatus})},onError:(e,t)=>{T(e instanceof Error?e.message:String(e),{tone:`danger`}),n.invalidateQueries({queryKey:t.mergeState})}});return i.isPending?(0,Z.jsx)(J,{"data-slot":`gh-merge-loading`,className:`mt-6 h-32 w-full`}):a?(0,Z.jsxs)(`section`,{"data-slot":`gh-merge-box`,"data-eligibility":a.eligibility,"data-conflicting":pt(a.mergeable),"aria-live":`polite`,className:`mt-6 rounded-lg border border-card-edge bg-card p-4 shadow-card`,children:[(0,Z.jsx)(gt,{state:a,selectedMethod:g,overrideRules:d,mergeEnabled:ft(g,a,d),refreshPending:h.isPending,onRefresh:()=>h.mutate(c.githubMergeState(e)),onRunAgent:t,onConfirm:()=>u(!0),onMethodChange:s,onOverrideChange:m}),(0,Z.jsx)(_t,{number:e,state:a,selectedMethod:g,confirming:l,overrideRules:d,mergePending:y.isPending,mergeError:y.error,onOpenChange:u,onMerge:()=>y.mutate(v())})]}):(0,Z.jsx)(ht,{reason:dt(i.data)})}function yt(e){let t=new Set;for(let n of e)for(let e of n.labels)t.add(e);return[...t].sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase()))}function bt(e,t={}){let n=(t.query??``).trim().toLowerCase(),r=t.labels??[],i=n.replace(/^#/,``),a=i!==``&&/^\d+$/.test(i);return e.filter(e=>r.length>0&&!r.every(t=>e.labels.includes(t))||t.assignees?.length&&!e.assignees?.some(e=>t.assignees.some(t=>t.toLowerCase()===e.toLowerCase()))||t.author!==void 0&&e.author.toLowerCase()!==t.author.toLowerCase()||t.includeNumbers&&!t.includeNumbers.has(e.number)||t.excludeNumbers?.has(e.number)||t.projectId&&e.projectIds!==void 0&&!e.projectIds.includes(t.projectId)?!1:n===``?!0:a?String(e.number).includes(i):`#${e.number} ${e.title} ${e.author} ${e.body??``}`.toLowerCase().includes(n))}function xt(e,t){let n=e.trim();if(n===``)return!1;let r=n.replace(/^#/,``);return/^\d+$/.test(r)?!t.some(e=>e.number===Number(r)):t.length===0}function St(e){if(!e||!/^[0-9a-fA-F]{6}$/.test(e))return{borderColor:`var(--border)`,color:`var(--muted-foreground)`};let t=`#${e}`;return{backgroundColor:`${t}22`,borderColor:`${t}66`,color:`color-mix(in srgb, ${t} 50%, var(--foreground))`}}function Ct({label:e,color:t,plain:n=!1}){return(0,Z.jsx)(`span`,{"data-slot":`gh-label`,"data-label":e,style:n?void 0:St(t),className:n?`text-xs font-normal text-muted-foreground`:`rounded-full border px-1.5 py-px text-[12px] font-medium`,children:e})}function wt(e){return e===`pr`?`pull request`:`issue`}function Tt(e,t,n){return e===`pr`&&!!(t||n)}function Et({backLink:e}){return e?(0,Z.jsxs)(V,{to:e.to,"data-slot":`gh-back`,className:`mb-3 inline-flex min-h-11 items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-foreground`,children:[(0,Z.jsx)(te,{size:16,"aria-hidden":`true`,className:`size-3.5`}),`Back to the list`]}):null}var Dt=r(`text-sm`,`[&_[data-streamdown="code-block"]]:relative [&_[data-streamdown="code-block"]]:my-2.5 [&_[data-streamdown="code-block"]]:gap-0 [&_[data-streamdown="code-block"]]:overflow-hidden [&_[data-streamdown="code-block"]]:rounded-lg [&_[data-streamdown="code-block"]]:border [&_[data-streamdown="code-block"]]:border-border [&_[data-streamdown="code-block"]]:bg-background [&_[data-streamdown="code-block"]]:p-0 [&_[data-streamdown="code-block"]]:![content-visibility:visible] [&_[data-streamdown="code-block"]]:![contain-intrinsic-size:auto]`,`[&_[data-streamdown="code-block-header"]]:h-7 [&_[data-streamdown="code-block-header"]]:border-b [&_[data-streamdown="code-block-header"]]:border-border [&_[data-streamdown="code-block-header"]]:bg-muted/40 [&_[data-streamdown="code-block-header"]]:px-3 [&_[data-streamdown="code-block-header"]]:text-xs`,`[&_[data-streamdown="code-block-header"][data-language=""]]:hidden [&_[data-streamdown="code-block-header"]:not([data-language])]:hidden [&_[data-streamdown="code-block-header"]:has(>span:empty)]:hidden`,`[&_[data-streamdown="code-block"]>*:has([data-streamdown="code-block-actions"])]:absolute [&_[data-streamdown="code-block"]>*:has([data-streamdown="code-block-actions"])]:top-1 [&_[data-streamdown="code-block"]>*:has([data-streamdown="code-block-actions"])]:right-1.5 [&_[data-streamdown="code-block"]>*:has([data-streamdown="code-block-actions"])]:mt-0 [&_[data-streamdown="code-block"]>*:has([data-streamdown="code-block-actions"])]:h-auto`,`[&_[data-streamdown="code-block-actions"]]:border-0 [&_[data-streamdown="code-block-actions"]]:bg-transparent [&_[data-streamdown="code-block-actions"]]:p-0 [&_[data-streamdown="code-block-actions"]]:backdrop-blur-none`,`[&_[data-streamdown="image-fallback"]]:inline-flex [&_[data-streamdown="image-fallback"]]:rounded-md [&_[data-streamdown="image-fallback"]]:border [&_[data-streamdown="image-fallback"]]:border-dashed [&_[data-streamdown="image-fallback"]]:border-border [&_[data-streamdown="image-fallback"]]:bg-muted/40 [&_[data-streamdown="image-fallback"]]:px-3 [&_[data-streamdown="image-fallback"]]:py-2 [&_[data-streamdown="image-fallback"]]:not-italic [&_[data-streamdown="image-fallback"]]:after:content-["_—_open_on_GitHub_to_view"]`,`[&_[data-streamdown="code-block-body"]]:rounded-none [&_[data-streamdown="code-block-body"]]:border-0 [&_[data-streamdown="code-block-body"]]:bg-transparent [&_[data-streamdown="code-block-body"]]:px-3.5 [&_[data-streamdown="code-block-body"]]:py-2.5 [&_[data-streamdown="code-block-body"]]:pr-10`);function Ot(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function kt({item:e,kindWord:t,commentCount:n,hasDiffStat:r,additions:a,deletions:o}){return(0,Z.jsxs)(`p`,{"data-slot":`gh-meta`,className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 text-xs text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{className:`tabular-nums`,children:[`#`,e.number]}),`·`,(0,Z.jsx)(`span`,{children:t}),`·`,(0,Z.jsxs)(`span`,{children:[`opened by `,e.author]}),`·`,(0,Z.jsx)(q,{iso:e.createdAt,title:Ot(e.createdAt)}),n?(0,Z.jsxs)(Z.Fragment,{children:[`·`,(0,Z.jsx)(tn,{count:n})]}):null,r?(0,Z.jsxs)(Z.Fragment,{children:[`·`,(0,Z.jsx)(`span`,{"data-slot":`gh-diffstat`,children:(0,Z.jsx)(Y,{adds:a??0,dels:o??0})})]}):null,`·`,i(e.url)?(0,Z.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-open-link`,className:`inline-flex items-center gap-0.5 text-muted-foreground hover:text-foreground hover:underline`,children:[`open on GitHub`,(0,Z.jsx)(z,{"aria-hidden":`true`,className:`size-2.5`})]}):(0,Z.jsx)(`span`,{"data-slot":`gh-open-link`,className:`text-muted-foreground`,children:`open on GitHub`})]})}function At({item:e,subNav:t,changes:n}){return e.kind===`pr`?t?(0,Z.jsxs)(`nav`,{"aria-label":`Pull request detail`,className:`mt-4 flex border-b border-border`,children:[(0,Z.jsx)(tt,{to:G(`prs`,t.filter,e.number),active:!n,children:`Conversation`}),(0,Z.jsx)(tt,{to:G(`prs`,t.filter,e.number,`/changes`),active:n,children:`Changes`})]}):(0,Z.jsx)(V,{to:G(`prs`,null,e.number,`/changes`),"data-slot":`gh-files-changed`,className:`mt-3 inline-flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground hover:underline`,children:`Files changed`}):null}function jt({item:e,colors:t,checks:n}){return e.labels.length>0||n?(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5`,children:[e.labels.map(e=>(0,Z.jsx)(Ct,{label:e,color:t[e]},e)),n?(0,Z.jsx)(nn,{checks:n,url:e.url}):null]}):null}function Mt({item:e,colors:t,body:n}){return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{"data-slot":`gh-body`,className:r(`mt-5`,Dt),children:n?(0,Z.jsx)(Ze,{children:n}):(0,Z.jsx)(`p`,{className:`text-muted-foreground`,children:`(no description)`})}),(0,Z.jsx)(It,{item:e,colors:t})]})}function Nt({item:e,colors:t,checks:n,comments:r,backLink:i,subNav:a,onRunAgent:o,afterHeading:s,headerAction:c,children:l}){let d=a?.changes??!1,f=wt(e.kind),p=u(e.kind,e.number,!d).data?.detail,m=p?.body??e.body,h=p?.additions??e.additions,g=p?.deletions??e.deletions,_=Tt(e.kind,h,g),v=r??e.comments;return(0,Z.jsxs)(`article`,{"data-slot":`gh-detail-inner`,className:`min-w-0 px-4 py-4 md:px-7 md:py-5`,children:[(0,Z.jsx)(Et,{backLink:i}),(0,Z.jsxs)(`div`,{"data-slot":`gh-description-card`,className:e.kind===`pr`?`rounded-xl border border-border bg-card p-6`:void 0,children:[e.kind===`pr`?(0,Z.jsx)(Pt,{action:c,className:`mb-4`,children:(0,Z.jsxs)(`h2`,{className:`min-w-0 text-[22px] leading-snug font-semibold tracking-tight`,children:[`#`,e.number,` `,e.title]})}):null,(0,Z.jsx)(Pt,{action:e.kind===`pr`?void 0:c,children:(0,Z.jsx)(kt,{item:e,kindWord:f,commentCount:v,hasDiffStat:_,additions:h,deletions:g})}),e.kind===`pr`?null:(0,Z.jsx)(`h2`,{className:`mt-2 text-[22px] leading-snug font-semibold tracking-tight`,children:e.title}),s,(0,Z.jsx)(At,{item:e,subNav:a,changes:d}),(0,Z.jsx)(jt,{item:e,colors:t,checks:n}),d&&e.kind===`pr`?(0,Z.jsx)(Ft,{item:e}):(0,Z.jsx)(Mt,{item:e,colors:t,body:m})]}),e.kind===`pr`?(0,Z.jsx)(vt,{number:e.number,onRunAgent:o}):null,l]})}function Pt({action:e,className:t,children:n}){return e?(0,Z.jsxs)(`div`,{"data-slot":`gh-header-row`,className:r(`flex flex-wrap items-center gap-x-3 gap-y-2`,t),children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:n}),(0,Z.jsx)(`div`,{"data-slot":`gh-header-action`,className:`flex shrink-0 items-center gap-2`,children:e})]}):t?(0,Z.jsx)(`div`,{className:t,children:n}):(0,Z.jsx)(Z.Fragment,{children:n})}function Ft({item:e}){let t=C(),n=d(e.number),[a,o]=(0,X.useState)(``),[s,l]=(0,X.useState)(null),u=n.data,f=e=>u?.available?u.files.filter(t=>t.path.toLowerCase().includes(e.toLowerCase())):[],p=f(a),m=p.some(e=>e.path===s)?s:p[0]?.path??null,h=p.findIndex(e=>e.path===m),g=e=>{o(e);let t=f(e),n=m??s,r=t.some(e=>e.path===n)?n:t[0]?.path??n;r!==s&&l(r)},_=async()=>{let n=u?.available?u.headSha:null,r=c.githubPrChanges(e.number),i=await y(e.number,{refresh:!0});t.setQueryData(r,i),i.available&&n&&n!==i.headSha&&(l(i.files[0]?.path??null),T(`The reviewed revision changed.`))};if(n.isPending)return(0,Z.jsx)(`p`,{"aria-live":`polite`,className:`mt-6 text-sm text-muted-foreground`,children:`Loading changed files…`});if(n.isError||!u)return(0,Z.jsx)(`p`,{className:`mt-6 text-sm text-danger`,children:`Changed files could not be loaded.`});if(!u.available)return(0,Z.jsx)(`p`,{className:`mt-6 text-sm text-muted-foreground`,children:u.reason});let v=p.map(e=>({path:e.path,...e.previousPath?{oldPath:e.previousPath}:{},status:e.status===`removed`?`deleted`:e.status===`changed`?`modified`:e.status,adds:e.additions,dels:e.deletions,binary:e.patchUnavailableReason===`binary`,patch:e.patch??``})),b=i(e.url)?`${e.url}/files`:null,x=p.find(e=>e.path===m);return(0,Z.jsxs)(`section`,{"data-slot":`gh-pr-changes`,className:`mt-5 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,Z.jsxs)(`strong`,{children:[u.files.length,` changed files`]}),(0,Z.jsx)(Y,{adds:u.additions,dels:u.deletions}),(0,Z.jsx)(ke,{sha:u.headSha,variant:`inline`,prefix:`head `,className:`text-muted-foreground`}),(0,Z.jsx)(B,{type:`button`,variant:`outline`,size:`sm`,className:`ml-auto min-h-11`,onClick:()=>void _(),children:`Refresh`})]}),u.truncated?(0,Z.jsxs)(`p`,{role:`status`,className:`mt-3 rounded-md border border-pending-strong/40 bg-pending/10 p-3 text-xs`,children:[u.reason??`This response is incomplete.`,` `,b?(0,Z.jsx)(`a`,{href:b,target:`_blank`,rel:`noopener noreferrer`,className:`underline`,children:`Open all files on GitHub`}):null]}):null,(0,Z.jsxs)(`div`,{className:`mt-4 grid min-w-0 gap-4 lg:grid-cols-[240px_minmax(0,1fr)]`,children:[(0,Z.jsxs)(`aside`,{className:`min-w-0`,children:[(0,Z.jsx)(`input`,{"aria-label":`Filter changed files`,value:a,onChange:e=>g(e.target.value),placeholder:`Filter files…`,className:`min-h-11 w-full rounded-md border border-input bg-background px-3 text-sm`}),(0,Z.jsx)(et,{"aria-label":`Select changed file`,value:m??``,onValueChange:l,options:p.map(e=>({value:e.path,label:e.path})),className:`mt-2 w-full min-w-0 bg-background lg:hidden`,contentClassName:`max-w-[calc(100vw-2rem)]`}),(0,Z.jsx)(`ul`,{className:`mt-2 hidden max-h-[60vh] overflow-auto lg:block`,children:p.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>l(e.path),className:r(`min-h-11 w-full truncate rounded px-2 text-left text-xs`,m===e.path&&`bg-muted font-medium`),title:e.path,children:[e.status,` · `,e.path,` `,(0,Z.jsx)(Y,{adds:e.additions,dels:e.deletions})]})},e.path))})]}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex justify-end gap-1`,children:[(0,Z.jsx)(B,{"aria-label":`Previous file`,variant:`outline`,size:`icon`,className:`min-h-11 min-w-11`,disabled:h<=0,onClick:()=>l(p[h-1]?.path??null),children:(0,Z.jsx)(Ge,{})}),(0,Z.jsx)(B,{"aria-label":`Next file`,variant:`outline`,size:`icon`,className:`min-h-11 min-w-11`,disabled:h<0||h>=p.length-1,onClick:()=>l(p[h+1]?.path??null),children:(0,Z.jsx)(M,{size:16})})]}),p.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No changed files match this filter.`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($e,{files:v.filter(e=>e.path===m),wrap:!0,className:`min-w-0`}),x&&!x.patch?(0,Z.jsxs)(`p`,{className:`rounded-b border border-border p-3 text-xs text-muted-foreground`,children:[`Patch unavailable: `,x.patchUnavailableReason??`not-provided`,`.`]}):null]})]})]})]})}function It({item:e,colors:t}){let n=u(e.kind,e.number),r=n.data,i=(0,X.useMemo)(()=>{let e=[...(r?.comments??[]).map(e=>({row:`comment`,comment:e})),...(r?.events??[]).map(e=>({row:`event`,event:e}))],t=e=>{let t=Date.parse(Lt(e));return Number.isNaN(t)?-1/0:t};return e.sort((e,n)=>t(e)-t(n))},[r?.comments,r?.events]);return n.isPending?(0,Z.jsxs)(`section`,{"data-slot":`gh-thread-loading`,className:`mt-6 border-t border-border pt-5`,children:[(0,Z.jsx)(J,{className:`mb-3 h-3 w-24`}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(J,{className:`h-14 w-full`}),(0,Z.jsx)(J,{className:`h-14 w-full`})]})]}):!r||!r.available?(0,Z.jsxs)(`section`,{"data-slot":`gh-thread-error`,className:`mt-6 border-t border-border pt-5 text-xs text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{children:[`Couldn’t load comments — `,r?.reason??(n.error instanceof Error?n.error.message:`could not load comments`),`. `]}),(0,Z.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-0.5 text-muted-foreground hover:text-foreground hover:underline`,children:[`open on GitHub`,(0,Z.jsx)(z,{"aria-hidden":`true`,className:`size-2.5`})]})]}):i.length===0?null:(0,Z.jsxs)(`section`,{"data-slot":`gh-thread`,className:`mt-6 border-t border-border pt-5`,children:[(0,Z.jsxs)(`h3`,{"data-slot":`gh-thread-header`,className:`mb-4 text-xs font-semibold tracking-wide text-muted-foreground uppercase`,children:[`Activity · `,r.comments.length,` comment`,r.comments.length===1?``:`s`]}),(0,Z.jsx)(`ul`,{className:`flex flex-col gap-5`,children:Rt(i).map(e=>e.group===`commits`?(0,Z.jsx)(zt,{commits:e.commits,colors:t},e.commits[0].id):e.entry.row===`comment`?(0,Z.jsx)(Xt,{comment:e.entry.comment},`${e.entry.comment.kind}-${e.entry.comment.id}`):(0,Z.jsx)(Vt,{event:e.entry.event,colors:t},e.entry.event.id))}),r.truncated?(0,Z.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-thread-truncated`,className:`mt-4 inline-flex items-center gap-0.5 text-xs text-muted-foreground hover:text-foreground hover:underline`,children:[`thread truncated — open on GitHub`,(0,Z.jsx)(z,{"aria-hidden":`true`,className:`size-2.5`})]}):null]})}var Lt=e=>e.row===`comment`?e.comment.createdAt:e.event.createdAt;function Rt(e){let t=[],n=[],r=()=>{n.length!==0&&(n.length===1?t.push({group:`single`,entry:{row:`event`,event:n[0]}}):t.push({group:`commits`,commits:n}),n=[])};for(let i of e){if(i.row===`event`&&i.event.kind===`committed`&&i.row===`event`){let e=n[n.length-1];e&&e.actor!==i.event.actor&&r(),n.push(i.event);continue}r(),t.push({group:`single`,entry:i})}return r(),t}function zt({commits:e,colors:t}){let[n,r]=(0,X.useState)(!1),i=e[0]?.actor??`?`;return n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`li`,{"data-slot":`gh-commit-group`,"data-open":`true`,className:`min-w-0`,children:(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":!0,onClick:()=>r(!1),className:`flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground`,children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:Bt.committed}),(0,Z.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:i}),(0,Z.jsxs)(`span`,{children:[`added `,e.length,` commits`]})]})}),e.map(e=>(0,Z.jsx)(Vt,{event:e,colors:t},e.id))]}):(0,Z.jsx)(`li`,{"data-slot":`gh-commit-group`,"data-open":`false`,className:`min-w-0`,children:(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":!1,onClick:()=>r(!0),className:`flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground`,children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:Bt.committed}),(0,Z.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:i}),(0,Z.jsxs)(`span`,{children:[`added `,e.length,` commits`]}),(0,Z.jsx)(q,{iso:e[e.length-1].createdAt,className:`shrink-0`})]})})}var Bt={committed:`⚙`,labeled:`◆`,unlabeled:`◇`,assigned:`◍`,unassigned:`◌`,merged:`⑃`,closed:`⊘`,reopened:`⊙`,head_ref_force_pushed:`↻`,"cross-referenced":`↗`,renamed:`✎`};function Vt({event:e,colors:t}){return(0,Z.jsxs)(`li`,{"data-slot":`gh-event-row`,"data-kind":e.kind,className:r(`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,e.kind===`merged`&&`text-accent-foreground`),children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:Bt[e.kind]}),(0,Z.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:e.actor}),(0,Z.jsx)(qt,{event:e,colors:t}),(0,Z.jsx)(q,{iso:e.createdAt,className:`shrink-0`}),e.url?(0,Z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`open ${e.kind} on GitHub`,className:`ml-auto shrink-0 text-muted-foreground hover:text-foreground`,children:(0,Z.jsx)(z,{"aria-hidden":`true`,className:`size-2.5`})}):null]})}function Ht({event:e}){return(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`shrink-0`,children:`committed`}),e.sha?(0,Z.jsx)(ke,{sha:e.sha,variant:`inline`,className:`shrink-0 text-xs text-muted-foreground`}):null,e.message?(0,Z.jsx)(`span`,{className:`truncate font-sans text-foreground`,children:e.message}):null,(0,Z.jsx)(Jt,{checks:e.checks})]})}function Ut({event:e,colors:t}){return(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`shrink-0`,children:e.kind===`labeled`?`added the`:`removed the`}),e.label?(0,Z.jsx)(`span`,{"data-slot":`gh-event-label`,style:St(e.label.color??t[e.label.name]),className:`max-w-[12rem] truncate rounded-full border px-1.5 py-px font-sans text-[12px]`,children:e.label.name}):null,(0,Z.jsx)(`span`,{className:`shrink-0`,children:`label`})]})}function Wt({event:e}){return(0,Z.jsxs)(`span`,{className:`truncate`,children:[e.kind===`assigned`?`assigned`:`unassigned`,` `,e.subject??`someone`]})}function Gt({event:e}){return(0,Z.jsxs)(`span`,{className:`truncate`,children:[`referenced this in `,e.refNumber?`#${e.refNumber}`:`another thread`,e.refTitle?` ${e.refTitle}`:``]})}var Kt={committed:e=>(0,Z.jsx)(Ht,{event:e}),labeled:(e,t)=>(0,Z.jsx)(Ut,{event:e,colors:t}),unlabeled:(e,t)=>(0,Z.jsx)(Ut,{event:e,colors:t}),assigned:e=>(0,Z.jsx)(Wt,{event:e}),unassigned:e=>(0,Z.jsx)(Wt,{event:e}),merged:()=>(0,Z.jsx)(`span`,{children:`merged this`}),closed:()=>(0,Z.jsx)(`span`,{children:`closed this`}),reopened:()=>(0,Z.jsx)(`span`,{children:`reopened this`}),head_ref_force_pushed:()=>(0,Z.jsx)(`span`,{children:`force-pushed`}),renamed:e=>(0,Z.jsxs)(`span`,{className:`truncate`,children:[`renamed this to `,e.subject??`—`]}),"cross-referenced":e=>(0,Z.jsx)(Gt,{event:e})};function qt({event:e,colors:t}){return Kt[e.kind]?.(e,t)??null}function Jt({checks:e}){return e?(0,Z.jsx)(`span`,{"data-slot":`gh-commit-checks`,"data-checks":e,"aria-label":`checks ${e}`,className:r(`shrink-0`,$t[e]),children:Qt[e]}):null}var Yt={approved:{label:`Approved`,tone:`border-success/40 text-semantic-green`},changes_requested:{label:`Changes requested`,tone:`border-danger/40 text-semantic-red`},commented:{label:`Commented`,tone:`border-border text-muted-foreground`},dismissed:{label:`Dismissed`,tone:`border-border text-muted-foreground`}};function Xt({comment:e}){let t=e.reviewState?Yt[e.reviewState]:null;return(0,Z.jsxs)(`li`,{"data-slot":`gh-thread-entry`,"data-kind":e.kind,className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(Zt,{url:e.avatarUrl,login:e.author}),(0,Z.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:e.author}),(0,Z.jsx)(q,{iso:e.createdAt}),t?(0,Z.jsx)(`span`,{"data-slot":`gh-review-chip`,"data-review-state":e.reviewState,className:r(`rounded-full border px-1.5 py-px font-sans text-[12px] font-medium`,t.tone),children:t.label}):null,(0,Z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`open comment on GitHub`,className:`ml-auto shrink-0 text-muted-foreground hover:text-foreground`,children:(0,Z.jsx)(z,{"aria-hidden":`true`,className:`size-2.5`})})]}),(0,Z.jsx)(`div`,{"data-slot":`gh-thread-body`,className:Dt,children:e.body?(0,Z.jsx)(Ze,{children:e.body}):(0,Z.jsx)(`p`,{className:`text-muted-foreground`,children:`(no body)`})})]})}function Zt({url:e,login:t}){let[n,r]=(0,X.useState)(!1);return e&&!n?(0,Z.jsx)(`img`,{src:e,alt:``,width:20,height:20,loading:`lazy`,onError:()=>r(!0),"data-slot":`gh-avatar`,className:`size-5 shrink-0 rounded-full`}):(0,Z.jsx)(`span`,{"data-slot":`gh-avatar-fallback`,"aria-hidden":`true`,className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-muted text-xs font-semibold text-muted-foreground uppercase`,children:t.slice(0,1)||`?`})}var Qt={passing:`✓`,failing:`✗`,pending:`○`},$t={passing:`text-semantic-green`,failing:`text-semantic-red`,pending:`text-semantic-amber`},en={passing:`Checks passing`,failing:`Checks failing`,pending:`Checks pending`};function tn({count:e}){return e?(0,Z.jsxs)(`span`,{"data-slot":`gh-comment-count`,"data-count":e,"aria-label":`${e} comment${e===1?``:`s`}`,className:`inline-flex shrink-0 items-center gap-0.5`,children:[(0,Z.jsx)(ae,{"aria-hidden":`true`,className:`size-3`}),e]}):null}function nn({checks:e,url:t}){let n=r(`text-xs font-medium`,$t[e],t&&`hover:underline`),i=`${Qt[e]} ${en[e]}`;return t?(0,Z.jsx)(`a`,{href:`${t}/checks`,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-checks`,"data-checks":e,className:n,children:i}):(0,Z.jsx)(`span`,{"data-slot":`gh-checks`,"data-checks":e,className:n,children:i})}function rn({checks:e}){return(0,Z.jsx)(`span`,{"data-slot":`gh-row-checks`,"data-checks":e,title:en[e],"aria-label":en[e],className:r(`shrink-0 font-sans text-xs font-semibold`,$t[e]),children:Qt[e]})}function an(e){return`${e.kind===`pr`?`Address GitHub pull request`:`Fix GitHub issue`} #${e.number}: ${e.title}\n\n${e.url}`}function on(e,t=[]){let n=an(e);return e.body?.trim()&&(n+=`\n\n---\n\n${e.body.trim()}`),t.length&&(n+=sn(t)),n}function sn(e){return`\n\nUse these skills where relevant: ${e.join(`, `)}.`}function cn(e,t){return e.replace(/\{\{\s*number\s*\}\}/gi,()=>`#${t.number}`).replace(/\{\{\s*title\s*\}\}/gi,()=>t.title).replace(/\{\{\s*url\s*\}\}/gi,()=>t.url)}function ln(e,t){if(e.includes(t.url))return!0;let n=t.kind===`pr`?String.raw`(?:pull\s+request|pr)`:String.raw`issue`;return new RegExp(String.raw`\b${n}\s*#?\s*${t.number}\b`,`i`).test(e)}function un(e,t,n){let r=(n??``).trim();if(!r)return on(e,t);let i=an(e),a=r.startsWith(i)?i+cn(r.slice(i.length),e):cn(r,e),o=ln(a,e)?a:`${i}\n\n${a}`;return t.length?o+sn(t):o}function dn(e){let t=[];for(let n of e.slice(0,8)){let e=new Set(t.map(e=>e.id)),r=n;for(let t=2;e.has(r);t++)r=`${n}-${t}`;t.push({id:r,name:n,skill:n,prompt:`{{task}}`})}return t}function fn(e,t,n,r,i={}){return t?{...i,workflow:t,task:un(e,n.map(e=>e.id),r)}:n.length?{...i,steps:dn(n.map(e=>e.id)).map((e,t)=>({...e,...n[t]?.path===void 0?{}:{skillPath:n[t].path}})),task:un(e,[],r)}:{...i,workflow:`quick-task`,task:un(e,[],r)}}function pn(e){let t=o(),n=l(),r=h(),{runners:i,uninstalled:a,signedOut:s,accounts:c,repoAccount:u,accountFor:d}=We(),f=n.data?.defaultRunner,p=Pe(e.runner,i,f??i[0]??`claude`),m=n.data?.modelsLocked===!0,_=d(p,e.account),v=g(p,!0,_??u?.[p]),y=je(m?null:e.model,p,r.data,n.data?.defaultModels,v.data),b=Ie(y,v.data);return{runner:p,runnerExplicit:e.runner!==null,model:y,effort:m?``:Oe(e.effort,b),effortOptions:b,runners:i,uninstalled:a,signedOut:s,defaultRunner:f,canRun:t.isSuccess&&i.length>0,modelsLocked:m,providerPending:t.isPending,providerError:t.isError,accounts:c,account:_,repoAccount:u}}function mn(e){return{runner:ze(e.runner,e.defaultRunner,e.runnerExplicit),model:e.modelsLocked?void 0:e.model||void 0,effort:e.modelsLocked?void 0:e.effort||void 0}}function hn(e){return{...mn(e),...e.account?{agentProfile:e.account}:{}}}function gn(e,t){return e.find(e=>e.id===t)?.label??(t===``?`Runner default`:t)}function _n(e,t){let{runners:n,uninstalled:r,signedOut:i}=e;return n.length>1||r.length>0||i.length>0||n.some(e=>He(t,e))}function vn({pick:e,onChange:t,disabled:n=!1,accounts:r=!1,layout:i}){let a=(0,X.useRef)(null),o=(0,X.useRef)(null),[s,c]=(0,X.useState)(()=>typeof window<`u`&&window.innerWidth<=767);(0,X.useLayoutEffect)(()=>{let e=a.current;if(i!==`row`||!e)return;let t=()=>{let t=window.innerWidth<=767||e.getBoundingClientRect().width<550,n=document.activeElement;o.current=n instanceof HTMLElement&&e.contains(n)?n:null,c(t)};t();let n=typeof ResizeObserver>`u`?null:new ResizeObserver(t);return n?.observe(e),window.addEventListener(`resize`,t),()=>{n?.disconnect(),window.removeEventListener(`resize`,t)}},[i]),(0,X.useLayoutEffect)(()=>{let e=o.current;o.current=null,e&&e.isConnected&&document.activeElement!==e&&e.focus()},[s]);let u=pn(e),{runner:d,model:f,effort:p,effortOptions:m,runners:_,canRun:v,modelsLocked:y}=u,b=l(),x=h(),S=g(d,!0,u.account??u.repoAccount?.[d]),C=Le(d,x.data,S.data,[e.model,b.data?.defaultModels?.[d]]),w=n||!v,T=r?u.accounts:[],E=_n(u,T)?(0,Z.jsx)(Ne,{icon:(0,Z.jsx)(A,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,runners:_,uninstalled:u.uninstalled,signedOut:u.signedOut,value:d,accounts:T,account:r?u.account:null,repoAccount:r?u.repoAccount:void 0,disabled:w,onPick:(n,i)=>t(r?{runner:n,account:i,model:n===d?e.model:null,effort:e.effort}:{runner:n,account:null,model:null,effort:e.effort})},`runner`):null,O=(0,Z.jsx)(K,{icon:(0,Z.jsx)(j,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`model-pill`,ariaLabel:`Model`,label:gn(C,f),value:f,disabled:w,readOnly:y===!0,disabledHint:y?`Model selection is locked to native coding-agent settings.`:void 0,onPick:n=>{let r=Ie(n,S.data);t({...e,model:n,effort:e.effort===null?null:Oe(e.effort,r)})},options:C.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:Fe(d,x.data,S)},`model`),k=(0,Z.jsx)(K,{icon:(0,Z.jsx)(D,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`effort-pill`,ariaLabel:`Effort`,label:m.find(e=>e.value===p)?.label??`Runner default`,value:p,disabled:w,readOnly:y===!0,disabledHint:y?`Effort selection is locked to native coding-agent settings.`:void 0,onPick:n=>t({...e,effort:n}),options:m.map(e=>({value:e.value,label:e.label,desc:e.desc}))},`effort`);return i===`row`?(0,Z.jsx)(`div`,{ref:a,"data-slot":`engine-row-box`,children:(0,Z.jsx)(`div`,{"data-slot":`engine-row`,className:`engine-row`,role:`group`,"aria-label":`Agent settings`,children:(0,Z.jsx)(Ye,{fill:`model-pill`,children:s?[E,k,O]:[E,O,k]})})}):(0,Z.jsxs)(Ye,{children:[E,O,k]})}var yn={workflow:null,skills:[]},bn=`cez-followup-selection`;function xn(e){let t=e&&typeof e==`object`?e:{};return{workflow:typeof t.workflow==`string`?t.workflow:null,skills:Array.isArray(t.skills)?t.skills.flatMap(e=>typeof e==`string`?[{id:e}]:!e||typeof e!=`object`||typeof e.id!=`string`?[]:[{id:e.id,...typeof e.path==`string`?{path:e.path}:{}}]):[]}}function Sn(){try{let e=localStorage.getItem(bn);return e?xn(JSON.parse(e)):{...yn}}catch{return{...yn}}}function Cn(e){try{localStorage.setItem(bn,JSON.stringify(e))}catch{}}var wn=`cez-followup-prompt:`;function Tn(e){try{return localStorage.getItem(wn+e)??``}catch{return``}}function En(e,t){try{t===``?localStorage.removeItem(wn+e):localStorage.setItem(wn+e,t)}catch{}}function Dn({item:e,workflows:t,skills:n,workflow:r,onWorkflowChange:a,selectedSkills:o,onSkillsChange:l,engine:u,onEngineChange:d,queuedRunId:p,onQueued:h}){let g=C(),_=m(),y=e.kind===`pr`?`PR`:`issue`,b=pn(u),x=s(b.runner,b.account),S=o.filter(e=>x.unchecked||e.path===void 0||n.some(t=>t.id===e.id&&(e.path===void 0||t.path===e.path))),w=S.length!==o.length,[D]=(0,X.useState)(()=>an(e)),[O,k]=(0,X.useState)(()=>Tn(e.url)||D),A=(0,X.useRef)(null),j=(0,X.useRef)(null);(0,X.useEffect)(()=>{En(e.url,O===D?``:O)},[e.url,O,D]);let M=(0,X.useMemo)(()=>Ke(_.data?.promptTemplates),[_.data?.promptTemplates]),ee=e=>{let t=A.current,n=Je({prompt:O,base:D,selectionStart:t?.selectionStart??null,focused:document.activeElement===t,remembered:j.current}),r=qe(O,n,e);k(r.text),j.current=r.caret,requestAnimationFrame(()=>{A.current?.focus(),A.current?.setSelectionRange(r.caret,r.caret)})},N=Xe(M,S.map(e=>e.id)),F=(0,X.useRef)(O);F.current=O;let I=(0,X.useRef)(``);(0,X.useEffect)(()=>{let e=Ue(F.current,I.current,N,D);I.current=e.applied,e.text!==F.current&&k(e.text)},[N,D]);let L=f({mutationFn:async()=>!b.canRun||w?null:E(fn(e,r,S,O,hn(b))),onSuccess:t=>{if(t===null)return;let n=t;n&&h(e.url,n.id),T(`Added to the queue — ${y} #${e.number}`),S.length>0&&_.data!==void 0&&v({skillUsage:S.reduce((e,t)=>Te(e,t.id),_.data.skillUsage)}).then(()=>g.invalidateQueries({queryKey:c.uiState})).catch(()=>{}),En(e.url,``),k(D),I.current=``,g.invalidateQueries({queryKey:c.runs.all})},onError:e=>T(e.message,{tone:`danger`})}),te=e=>{Re({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(),!L.isPending&&b.canRun&&L.mutate())},R=e=>l(o.some(t=>W(t)===W(e))?o.filter(t=>W(t)!==W(e)):[...o,we(e)]);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`section`,{"data-slot":`gh-hand`,className:`mt-7 rounded-lg border border-border bg-card p-4`,children:[(0,Z.jsx)(`h3`,{className:`text-xl font-normal text-foreground`,children:`Hand this to the agent`}),(0,Z.jsxs)(`label`,{className:`gh-field gh-prompt-field`,children:[(0,Z.jsx)(`span`,{children:`Instructions for the agent`}),(0,Z.jsx)(Qe,{ref:A,"data-slot":`gh-custom-prompt`,"aria-label":`Custom prompt`,"aria-keyshortcuts":`Control+Enter Meta+Enter`,value:O,onChange:e=>k(e.target.value),onSelect:e=>{j.current=e.currentTarget.selectionStart},onKeyDown:te,placeholder:`Instructions for the agent… (#${e.number} and its link are always sent)`,className:`mt-3 min-h-20 text-[13px]`})]}),(0,Z.jsx)(Ae,{templates:M,onInsert:ee}),(0,Z.jsxs)(`div`,{className:`gh-handoff-settings`,children:[(0,Z.jsxs)(`div`,{className:`gh-field`,children:[(0,Z.jsx)(`span`,{children:`Workflow`}),(0,Z.jsx)(kn,{workflows:t,value:r,onChange:a})]}),(0,Z.jsxs)(`div`,{className:`gh-field`,children:[(0,Z.jsx)(`span`,{children:`Skills · select one or more`}),(0,Z.jsx)(jn,{skills:n,skillUsage:_.data?.skillUsage,selected:o,onToggle:R})]}),o.length>0?(0,Z.jsx)(`div`,{"data-slot":`gh-skill-chips`,className:`mt-2.5 flex flex-wrap gap-1.5`,children:o.map(e=>(0,Z.jsx)(On,{skill:e,skills:n,unchecked:x.unchecked,onRemove:()=>R(e)},W(e)))}):null,w?(0,Z.jsx)(`p`,{role:`alert`,children:`A selected skill path is unavailable. Remove it or choose a current copy before starting.`}):null,(0,Z.jsx)(vn,{layout:`row`,pick:u,onChange:d,disabled:L.isPending||!b.canRun,accounts:!0}),(0,Z.jsxs)(`div`,{className:`gh-field`,children:[(0,Z.jsx)(`span`,{children:`Account`}),(0,Z.jsx)(An,{resolved:b,disabled:L.isPending||!b.canRun,onPick:e=>d({...u,account:e})})]}),!b.providerPending&&!b.canRun?(0,Z.jsxs)(`span`,{"data-slot":`gh-provider-gate`,className:`inline-flex flex-wrap items-center gap-1 text-xs text-muted-foreground`,children:[b.providerError?`Provider authentication could not be verified.`:`Connect an agent provider to run this item.`,(0,Z.jsx)(V,{to:`/settings/agent-defaults#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}):null]}),(0,Z.jsxs)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:[e.kind===`pr`?`PR`:`Issue`,` number and link remain attached to the task. Edit the prompt before starting. Cmd/Ctrl+Enter submits; Enter adds a new line.`]})]}),(0,Z.jsxs)(`div`,{"data-slot":`gh-handoff-actions`,className:`mt-[22px] flex flex-wrap items-center gap-2.5`,children:[i(e.url)?(0,Z.jsx)(B,{asChild:!0,variant:`outline`,children:(0,Z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:`Open in GitHub`})}):null,(0,Z.jsxs)(B,{variant:`primary`,"data-action":`gh-run`,disabled:L.isPending||!b.canRun||w,onClick:()=>L.mutate(),children:[(0,Z.jsx)(oe,{"aria-hidden":`true`,className:`size-3.5`}),`Run agent on this `,y]}),(0,Z.jsx)(`kbd`,{"aria-hidden":`true`,className:`rounded-[5px] border border-b-2 border-border bg-card px-[5px] py-px font-mono text-xs font-medium text-muted-foreground`,children:De()}),p?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`span`,{"data-slot":`gh-queued`,className:`flex items-center gap-1 text-xs font-medium text-success`,children:[(0,Z.jsx)(P,{size:16,"aria-hidden":`true`,className:`size-3.5`}),`queued`]}),(0,Z.jsx)(V,{to:`/tasks/${p}`,"data-slot":`gh-view-run`,className:`text-xs font-semibold text-accent-text hover:underline`,children:`View task →`})]}):null]})]})}function On({skill:e,skills:t,unchecked:n,onRemove:r}){let i=t.find(t=>t.id===e.id&&(e.path===void 0||t.path===e.path)),a=[i?.name??e.id,e.path].filter(Boolean).join(` · `),o=!n&&e.path!==void 0&&!i?` (unavailable)`:n||!i?` (unchecked)`:``;return(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`gh-skill-chip`,"data-skill":e.id,onClick:r,title:`Remove skill ${a}`,"aria-label":`Remove skill ${a}`,className:`inline-flex min-h-11 items-center gap-2 rounded-lg border border-border bg-card px-3 text-xs font-medium text-foreground transition-colors hover:bg-danger/10 hover:text-danger`,children:[a,o,(0,Z.jsx)(L,{size:16,"aria-hidden":`true`,className:`size-3`})]})}function kn({workflows:e,value:t,onChange:n}){let[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(``),c=(0,X.useRef)(null),l=be(e,o);return(0,Z.jsxs)(le,{open:i,onOpenChange:e=>{a(e),e||s(``)},children:[(0,Z.jsx)(se,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`gh-workflow-trigger`,"aria-label":`Choose a workflow`,className:r(Ve,t&&`border-foreground/60 font-mono text-xs font-semibold text-foreground`),children:[(0,Z.jsx)(ee,{size:16,"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),(0,Z.jsx)(`span`,{className:`min-w-0 max-w-44 truncate`,children:t??`workflow`}),(0,Z.jsx)(ne,{size:16,"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,Z.jsx)(ce,{align:`start`,sideOffset:8,className:`w-[320px] max-w-[calc(100vw-2rem)] p-0`,children:(0,Z.jsxs)(ye,{shouldFilter:!1,children:[(0,Z.jsx)(ge,{placeholder:`Search workflows…`,value:o,onValueChange:s,onInput:()=>c.current?.scrollTo(0,0)}),(0,Z.jsxs)(ve,{ref:c,"data-slot":`gh-workflow-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[l.length===0?(0,Z.jsx)(_e,{children:`Nothing matches.`}):null,(0,Z.jsx)(H,{children:l.map(e=>{let r=t===e.name;return(0,Z.jsxs)(U,{value:`workflow ${e.name}`,keywords:Ce(e.name,e.description),"data-slot":`gh-workflow-option`,"data-workflow":e.name,onSelect:()=>{n(r?null:e.name),a(!1)},children:[(0,Z.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),e.description?(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,r?(0,Z.jsx)(P,{size:16,"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]},e.name)})})]})]})})]})}function An({resolved:e,disabled:t,onPick:n}){let r=e.accounts.filter(t=>t.provider===e.runner),i=[...r.some(e=>e.id==="default")?[]:[{value:b,label:`Default`}],...r.map(e=>({value:e.id,label:e.label,...e.configDir?{desc:e.configDir}:{}}))],a=e.account??e.repoAccount?.[e.runner]??`default`;return(0,Z.jsx)(K,{icon:(0,Z.jsx)(F,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),slot:`account-pill`,ariaLabel:`Account`,label:i.find(e=>e.value===a)?.label??`Default`,value:a,options:i,disabled:t,onPick:n})}function jn({skills:e,skillUsage:t,selected:n,onToggle:i}){let[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(``),[l,u]=(0,X.useState)(null),d=(0,X.useRef)(null),{mostUsed:f,project:p,global:m,ranked:h}=Ee(e,s,t),g=(e,t)=>{let a=n.some(t=>W(t)===W(e));return(0,Z.jsxs)(U,{value:W(e),keywords:Ce(e.name,e.description),"data-slot":`gh-skill-option`,"data-skill":e.id,"data-selected":a?`true`:void 0,onSelect:()=>i(we(e)),children:[(0,Z.jsx)(`span`,{className:r(`shrink-0 font-mono text-xs`,t&&`font-semibold`),children:e.name}),e.path?(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-xs`,children:e.path}):null,e.description?(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,(0,Z.jsx)(`button`,{type:`button`,"data-slot":`gh-skill-view`,"aria-label":`View skill ${e.name}`,title:`View skill`,onClick:t=>{t.preventDefault(),t.stopPropagation(),u(e)},className:`ml-auto shrink-0 rounded-sm p-0.5 text-soft-foreground transition-colors hover:text-foreground`,children:(0,Z.jsx)(re,{"aria-hidden":`true`,className:`size-3.5`})}),a?(0,Z.jsx)(P,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-link-foreground`}):null]},W(e))};return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Be,{skill:l,onClose:()=>u(null)}),(0,Z.jsxs)(le,{open:a,onOpenChange:e=>{o(e),e||c(``)},children:[(0,Z.jsx)(se,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`gh-skills-trigger`,"aria-label":`Choose skills`,className:r(Ve,n.length>0&&`border-foreground/60 font-semibold text-foreground`),children:[(0,Z.jsx)(I,{size:16,"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),`skills`,n.length>0?` · ${n.length}`:``,(0,Z.jsx)(ne,{size:16,"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,Z.jsx)(ce,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,Z.jsxs)(ye,{shouldFilter:!1,children:[(0,Z.jsx)(ge,{placeholder:`Search skills…`,value:s,onValueChange:c,onInput:()=>d.current?.scrollTo(0,0)}),(0,Z.jsxs)(ve,{ref:d,"data-slot":`gh-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[s.trim()&&!e.some(e=>e.id===s.trim())?(0,Z.jsx)(H,{children:(0,Z.jsxs)(U,{value:`typed-skill`,onSelect:()=>i({id:s.trim()}),children:[`Use skill id “`,s.trim(),`” (unchecked)`]})}):null,(h?h.length===0:f.length===0&&p.length===0&&m.length===0)?(0,Z.jsx)(_e,{children:`Nothing matches.`}):null,h?h.length>0?(0,Z.jsx)(H,{children:h.map(e=>g(e,xe(e)))}):null:(0,Z.jsxs)(Z.Fragment,{children:[f.length>0?(0,Z.jsx)(H,{heading:`Most used`,children:f.map(e=>g(e,xe(e)))}):null,p.length>0?(0,Z.jsx)(H,{heading:`Project skills`,children:p.map(e=>g(e,!0))}):null,m.length>0?(0,Z.jsx)(H,{heading:`Global`,children:m.map(e=>g(e,!1))}):null]})]})]})})]})]})}var Mn=new WeakMap;function Nn(){let e=Sn(),t={workflow:e.workflow,selectedSkills:e.skills,engine:{runner:null,model:null,effort:null,account:null},queued:new Map},n=new Set;return{snapshot:()=>t,subscribe:e=>(n.add(e),()=>{n.delete(e)}),update:e=>{t={...t,...e},(e.workflow!==void 0||e.selectedSkills!==void 0)&&Cn({workflow:t.workflow,skills:[...t.selectedSkills]}),n.forEach(e=>e())}}}function Pn(){let e=C(),{projectId:t}=S(),n=Mn.get(e);n||Mn.set(e,n=new Map);let r=n.get(t);r||n.set(t,r=Nn());let{snapshot:i,subscribe:o,update:c}=r,l=(0,X.useSyncExternalStore)(o,i,i),u=a(),d=pn(l.engine),f=s(d.runner,d.account),p=m(),h=u.data?.workflows;(0,X.useEffect)(()=>{h&&l.workflow!==null&&!h.some(e=>e.name===l.workflow)&&c({workflow:null})},[c,h,l.workflow]);let g=(0,X.useMemo)(()=>Se(f.data??[],p.data?.skillUsage),[f.data,p.data?.skillUsage]);return{...l,workflows:u,skillList:g,skillsUnchecked:f.unchecked,setWorkflow:e=>c({workflow:e}),setSelectedSkills:e=>c({selectedSkills:e}),setEngine:e=>c({engine:e}),onQueued:(e,t)=>c({queued:new Map(i().queued).set(e,t)})}}export{rn as a,Nt as c,yt as d,bt as f,nn as i,Ct as l,xt as m,Dn as n,tn as o,St as p,on as r,Et as s,Pn as t,Rt as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{It as e}from"./queries-CIeJg62Y.js";import{n as t}from"./project-location-DmGO5Dqx.js";function n(){return{home:e().data?.homeDir??null,root:t()}}export{n as t};
|