cezarion 0.18.0-dev.8572 → 0.18.0-dev.8582

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/package.json +3 -3
  2. package/web/dist/assets/{accounts-section-VLKEYGPj.js → accounts-section-COizLyTO.js} +1 -1
  3. package/web/dist/assets/{activity-motion-IiyiWtXq.js → activity-motion-DfI5xoMG.js} +1 -1
  4. package/web/dist/assets/{activity-route-QCPCR9kZ.js → activity-route-BQs2vBeo.js} +1 -1
  5. package/web/dist/assets/{agent-config-section-BK0gs0uc.js → agent-config-section-BwBo-HRw.js} +1 -1
  6. package/web/dist/assets/{agent-defaults-section-BoluhHkE.js → agent-defaults-section-h-Gjb_gh.js} +1 -1
  7. package/web/dist/assets/{appearance-CEFPwlnq.js → appearance-Bcl2amXv.js} +1 -1
  8. package/web/dist/assets/{archive-on-merge-field-BEt4jVZt.js → archive-on-merge-field-Bm8miJjt.js} +1 -1
  9. package/web/dist/assets/attention-8bNiiAFt.js +1 -0
  10. package/web/dist/assets/{automations-route-F58YdVbC.js → automations-route-rSezHxBp.js} +1 -1
  11. package/web/dist/assets/{commit-list-BZ6wfGPz.js → commit-list-DtEqtn9o.js} +1 -1
  12. package/web/dist/assets/{diff-BbD04q_C.js → diff-BK789dS0.js} +2 -2
  13. package/web/dist/assets/{diff-controls-CW1hOWET.js → diff-controls-BFqQNxRu.js} +1 -1
  14. package/web/dist/assets/{diff-view-C3XewBZ4.js → diff-view-BEgQ7jZV.js} +1 -1
  15. package/web/dist/assets/{file-preview-B3r8zavn.js → file-preview-CDWTFZ4P.js} +1 -1
  16. package/web/dist/assets/{folder-browser-6LK4AIPp.js → folder-browser-BfclRPcX.js} +1 -1
  17. package/web/dist/assets/{git-toolbar-CCZtGd6H.js → git-toolbar-Pugtjt-9.js} +1 -1
  18. package/web/dist/assets/{github-CzZZ-wwm.js → github-CvpaGHe6.js} +1 -1
  19. package/web/dist/assets/{global-activity-route-BNyhS-a8.js → global-activity-route-Di_ICsRI.js} +1 -1
  20. package/web/dist/assets/{image-preview-CMk53HOX.js → image-preview-Dx2w5oIn.js} +1 -1
  21. package/web/dist/assets/{index-DaJ5iats.js → index-CJFT0IZP.js} +5 -5
  22. package/web/dist/assets/{label-YDZzSz0S.js → label-DEH7fJN4.js} +1 -1
  23. package/web/dist/assets/{live-reads-CR3-q01w.js → live-reads-BJ9eDISf.js} +1 -1
  24. package/web/dist/assets/{live-refetch-1_o4J83F.js → live-refetch-VoLPvzhe.js} +1 -1
  25. package/web/dist/assets/{markdown-q0pVKAO0.js → markdown-Dv0r75AX.js} +1 -1
  26. package/web/dist/assets/{notifications-section-n3Xb47pL.js → notifications-section-DCiqPl3M.js} +1 -1
  27. package/web/dist/assets/{open-in-menu-D4ACqxcC.js → open-in-menu-HM5l7Bwk.js} +1 -1
  28. package/web/dist/assets/{preview-pane-connected-VmfC04wB.js → preview-pane-connected-WV9oolnn.js} +1 -1
  29. package/web/dist/assets/{project-location-GPzDWXuH.js → project-location-CfJLc6aJ.js} +1 -1
  30. package/web/dist/assets/{project-router-DucFIl_x.js → project-router-Bii3ofOk.js} +1 -1
  31. package/web/dist/assets/{project-scope-context-C912rTJP.js → project-scope-context-BdqKyBHa.js} +3 -3
  32. package/web/dist/assets/{projects-section-BotQxpQ6.js → projects-section-D2cACaaG.js} +1 -1
  33. package/web/dist/assets/{prompt-templates-section-B8pr6Ue3.js → prompt-templates-section-toLPd5u2.js} +1 -1
  34. package/web/dist/assets/{queries-DDhFFTvR.js → queries-C7VNk-nW.js} +1 -1
  35. package/web/dist/assets/{reference-chip-90x9Bq44.js → reference-chip-rylFalfg.js} +1 -1
  36. package/web/dist/assets/{remote-settings-notice-F_onp6Yr.js → remote-settings-notice-N9vtBTIK.js} +1 -1
  37. package/web/dist/assets/{repo-git-B5Bse6ld.js → repo-git-DJym0aRY.js} +1 -1
  38. package/web/dist/assets/{report-reader-B_kyYgIY.js → report-reader-CjskGtxS.js} +1 -1
  39. package/web/dist/assets/{reports-D0E8DWXQ.js → reports-B-G9HA48.js} +1 -1
  40. package/web/dist/assets/{resources-section-DcfHTNpN.js → resources-section-B88h1y0Q.js} +1 -1
  41. package/web/dist/assets/{run-header-OhEYfuQX.js → run-header-B-olCSdg.js} +1 -1
  42. package/web/dist/assets/{select-r1KS5cjs.js → select-BaydzE-I.js} +1 -1
  43. package/web/dist/assets/{session-context-section-PCOCiOTV.js → session-context-section-BJKRXbss.js} +1 -1
  44. package/web/dist/assets/{settings-agent-picker-D0UKjmOj.js → settings-agent-picker-6xZMIC_D.js} +1 -1
  45. package/web/dist/assets/{settings-shell-BiPh5fg6.js → settings-shell-BkTgs1S9.js} +1 -1
  46. package/web/dist/assets/{sidebar-section-DmOlTUs8.js → sidebar-section-B57HIEgv.js} +1 -1
  47. package/web/dist/assets/{skills-CSLg7E0x.js → skills-pBrfwrKF.js} +1 -1
  48. package/web/dist/assets/{tab-link-Bh6CcIR7.js → tab-link-B1CULYRs.js} +1 -1
  49. package/web/dist/assets/{task-changes-DuOb61QV.js → task-changes-CXldTh93.js} +1 -1
  50. package/web/dist/assets/{task-commits-CiGYJpqo.js → task-commits-BZ3B_GPB.js} +1 -1
  51. package/web/dist/assets/{task-files-fJSQ4Abg.js → task-files-BSfmCkJc.js} +1 -1
  52. package/web/dist/assets/{task-github-item-CRxN82Yw.js → task-github-item-v2bygvdO.js} +1 -1
  53. package/web/dist/assets/{task-groups-B3Z2qfE6.js → task-groups-BbnYlkYj.js} +1 -1
  54. package/web/dist/assets/{task-thread-CqjKwRuV.js → task-thread-BPWnJ7Qx.js} +1 -1
  55. package/web/dist/assets/{tasks-table-Cm6YZBUB.js → tasks-table-Cx7AM7lZ.js} +1 -1
  56. package/web/dist/assets/{thread-state-DcHyKcQ-.js → thread-state-R0MTvwlo.js} +1 -1
  57. package/web/dist/assets/{use-hand-to-agent-state-DuefXU2m.js → use-hand-to-agent-state-BckHuhr8.js} +1 -1
  58. package/web/dist/assets/{useInfiniteQuery-CPEWc6dl.js → useInfiniteQuery--iQKfpUQ.js} +1 -1
  59. package/web/dist/assets/useQuery-BSyhc3l3.js +1 -0
  60. package/web/dist/assets/{workflows-CC3TZmBS.js → workflows-BBc2PFDB.js} +1 -1
  61. package/web/dist/assets/{workspace-tools-kscvD6KC.js → workspace-tools-CiTG-ArW.js} +1 -1
  62. package/web/dist/assets/{worktrees-section-CoKimDBt.js → worktrees-section-C07tNayi.js} +1 -1
  63. package/web/dist/index.html +15 -15
  64. package/web/dist/assets/attention-BFUaj1mU.js +0 -1
  65. package/web/dist/assets/useQuery-BOEhMTCg.js +0 -1
@@ -1 +1 @@
1
- import{Bn as e,Cn as t,Ir as n,On as r,Qn as i,kn as a}from"./project-scope-context-C912rTJP.js";import"./queries-DDhFFTvR.js";import"./attention-BFUaj1mU.js";function o(e,t){let n;for(let r of e)!r.sessionId||r.id===t||(!n||!r.startedAt||!n.startedAt||r.startedAt>=n.startedAt)&&(n=r);return n}function s(e,t){return e?.backend??t?.runner??`claude`}function c(e,t){let n;for(let r of e)r.removedBackend===void 0&&(t===void 0||r.sessionId!==t)||(!n||!r.startedAt||!n.startedAt||r.startedAt>=n.startedAt)&&(n=r);return n?.removedBackend===void 0?void 0:n}function l(e){let t=o(e.steps),n=c(e.steps,t?.sessionId)?void 0:t;return{sessionId:n?.sessionId,backend:s(n,e),profileId:n?.profileId}}function u(e){return e.command===void 0&&e.kind!==`plugin`}function d(e){let t=e.workflowCursor?.mode===`resume`?e.workflowCursor.stepId:void 0;if(t&&e.steps.find(e=>e.id===t)?.status===`failed`)return t;let n=o(e.steps);if(n)return n.synthetic===`continuation`&&n.continuesStepId!==void 0?n.continuesStepId:e.steps.find(e=>e.sessionId===n.sessionId)?.id??n.id}function f(e,t=!1){if(e.delegation?.role!==`worker`)return;let n=e.workflowDef?.steps;if(!n?.length)return;if(t)return n.find(u);let r=d(e);return(r?n.find(e=>e.id===r&&u(e)):void 0)??[...n].reverse().find(u)}var p=new Set([`queued`,`running`,`waiting`]);function m(e){return p.has(e)}function h(e){return i(e)?!1:e.status===`queued`||e.status===`running`||e.status===`waiting`}function g(e){return h(e)&&e.status!==`queued`}function _(t,n,r){return t.archived||!(t.status===`done`||t.status===`failed`||t.status===`cancelled`)||t.delegation?.role===`worker`||r!==void 0&&e(t)!==r?!1:n===`unpinned`?!t.pinned:n!==`pinned`||t.pinned===!0}var v=[`done`,`failed`];function y(e){return e.archived||i(e)||!v.includes(e.status)?!1:e.finishedAt!==void 0}function b(e){let t=e.finishedAt;return t===void 0||!y(e)?!1:e.seenAt===void 0||e.seenAt<t}var x=[`Needs you`,`Finished`,`Working`,`Archived`],S={waiting:0,review:1,running:2,queued:4,done:5,failed:6,cancelled:7},C=3,w=e=>i(e)?C:S[e.status]??9;function T(e){let n=e=>t[r(e).bucket];return[...e].sort((e,t)=>n(e)-n(t)||w(e)-w(t))[0]}function E(e,t){return t===`archived`?`Archived`:a(e)?`Needs you`:e.status===`waiting`||e.status===`running`||e.status===`queued`?`Working`:`Finished`}function D(e){let t=e.titleSummary;return t===void 0||!(e.titleOrigin===`user`||e.titleOrigin===`marker`)&&/[.!?][A-Z]/.test(t)?e.title:t}function O(e){let t=/^(\d{1,9}): (.+)$/.exec(e),n=t?.[1],r=t?.[2];return n===void 0||r===void 0?{ref:null,rest:e}:{ref:Number(n),rest:r}}function k(e,t){return t!==void 0&&O(e).ref===t}function A(e){let t=e.filter(e=>!e.archived&&e.status===`queued`).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));return new Map(t.map((e,t)=>[e.id,t+1]))}function j(e,t){return e.filter(e=>t===`archived`?e.archived:!e.archived).sort((e,n)=>{if(t!==`archived`){let t=Number(!!n.pinned)-Number(!!e.pinned);if(t!==0)return t}let r=w(e)-w(n);if(r!==0)return r;if(i(e)&&i(n)){let t=e.autoResumeAt.localeCompare(n.autoResumeAt);if(t!==0)return t}return e.status===`queued`&&n.status===`queued`?e.createdAt.localeCompare(n.createdAt):n.createdAt.localeCompare(e.createdAt)})}function M(e){return e.delegation?.role===`worker`}function N(e,t){if(e==null)return null;let n=t.find(t=>t.id===e);return!n||!M(n)?e:n.delegation?.parentRunId??e}function P(e,t,n=A(e)){let r=j(e,t).filter(e=>!M(e)),i=new Map,a=(e,t)=>{let n=i.get(e);n?n.push(t):i.set(e,[t])};for(let e of r)a(E(e,t),{kind:`run`,run:e,queuePosition:n.get(e.id)??null});return x.filter(e=>i.has(e)).map(e=>({label:e,rows:i.get(e)}))}function F(e,t={}){let r=typeof t==`number`?{overall:t}:n(t),i={"Needs you":`needsYou`,Finished:`finished`,Working:`working`},a=[],o=r.overall===void 0?10:r.overall??1/0;for(let t of e){let e=t.label===`Archived`?1/0:r[i[t.label]]??1/0,n=t.rows.filter(n=>{let r=n.run.pinned;return t.label!==`Archived`&&r?!0:o<=0||e<=0?!1:(--o,--e,!0)});n.length&&a.push({label:t.label,rows:n})}return a}function I(e,t){if(t.length===0)return[...e];let n=new Set(e.map(e=>e.id)),r=new Set,i=t.filter(e=>n.has(e.id)||r.has(e.id)?!1:(r.add(e.id),!0));return[...e,...i]}function L(e){let t=0,n=0,r=0;for(let i of e)if(!M(i)){if(i.archived){n+=1;continue}t+=1,a(i)&&(r+=1)}return{active:t,archived:n,waiting:r}}function R(t,n,r){return t.filter(t=>!t.archived&&(!r||e(t)===(n===`automations`)))}var z={"Needs you":`needs-you`,Finished:`finished`,Working:`working`},B=Object.keys(z),V=`section`;function H(e,t,n){let r=`${V}=${z[e]}`;return n?`/?origin=${t===`automations`?`automations`:`direct`}&${r}`:`/?${r}`}function U(e){return B.find(t=>z[t]===e)??null}function W(t,n){let r={active:0,automations:0,activeWaiting:0,automationsWaiting:0};for(let i of t){if(M(i)||i.archived)continue;let t=+!!a(i);n&&e(i)?(r.automations+=1,r.automationsWaiting+=t):(r.active+=1,r.activeWaiting+=t)}return r}export{_ as C,s as D,o as E,f as O,g as S,l as T,O as _,P as a,h as b,T as c,k as d,D as f,R as g,W as h,F as i,U as l,N as m,V as n,M as o,H as p,B as r,L as s,x as t,A as u,I as v,b as w,m as x,y};
1
+ import{Bn as e,Cn as t,Ir as n,On as r,Qn as i,kn as a}from"./project-scope-context-BdqKyBHa.js";import"./queries-C7VNk-nW.js";import"./attention-8bNiiAFt.js";function o(e,t){let n;for(let r of e)!r.sessionId||r.id===t||(!n||!r.startedAt||!n.startedAt||r.startedAt>=n.startedAt)&&(n=r);return n}function s(e,t){return e?.backend??t?.runner??`claude`}function c(e,t){let n;for(let r of e)r.removedBackend===void 0&&(t===void 0||r.sessionId!==t)||(!n||!r.startedAt||!n.startedAt||r.startedAt>=n.startedAt)&&(n=r);return n?.removedBackend===void 0?void 0:n}function l(e){let t=o(e.steps),n=c(e.steps,t?.sessionId)?void 0:t;return{sessionId:n?.sessionId,backend:s(n,e),profileId:n?.profileId}}function u(e){return e.command===void 0&&e.kind!==`plugin`}function d(e){let t=e.workflowCursor?.mode===`resume`?e.workflowCursor.stepId:void 0;if(t&&e.steps.find(e=>e.id===t)?.status===`failed`)return t;let n=o(e.steps);if(n)return n.synthetic===`continuation`&&n.continuesStepId!==void 0?n.continuesStepId:e.steps.find(e=>e.sessionId===n.sessionId)?.id??n.id}function f(e,t=!1){if(e.delegation?.role!==`worker`)return;let n=e.workflowDef?.steps;if(!n?.length)return;if(t)return n.find(u);let r=d(e);return(r?n.find(e=>e.id===r&&u(e)):void 0)??[...n].reverse().find(u)}var p=new Set([`queued`,`running`,`waiting`]);function m(e){return p.has(e)}function h(e){return i(e)?!1:e.status===`queued`||e.status===`running`||e.status===`waiting`}function g(e){return h(e)&&e.status!==`queued`}function _(t,n,r){return t.archived||!(t.status===`done`||t.status===`failed`||t.status===`cancelled`)||t.delegation?.role===`worker`||r!==void 0&&e(t)!==r?!1:n===`unpinned`?!t.pinned:n!==`pinned`||t.pinned===!0}var v=[`done`,`failed`];function y(e){return e.archived||i(e)||!v.includes(e.status)?!1:e.finishedAt!==void 0}function b(e){let t=e.finishedAt;return t===void 0||!y(e)?!1:e.seenAt===void 0||e.seenAt<t}var x=[`Needs you`,`Finished`,`Working`,`Archived`],S={waiting:0,review:1,running:2,queued:4,done:5,failed:6,cancelled:7},C=3,w=e=>i(e)?C:S[e.status]??9;function T(e){let n=e=>t[r(e).bucket];return[...e].sort((e,t)=>n(e)-n(t)||w(e)-w(t))[0]}function E(e,t){return t===`archived`?`Archived`:a(e)?`Needs you`:e.status===`waiting`||e.status===`running`||e.status===`queued`?`Working`:`Finished`}function D(e){let t=e.titleSummary;return t===void 0||!(e.titleOrigin===`user`||e.titleOrigin===`marker`)&&/[.!?][A-Z]/.test(t)?e.title:t}function O(e){let t=/^(\d{1,9}): (.+)$/.exec(e),n=t?.[1],r=t?.[2];return n===void 0||r===void 0?{ref:null,rest:e}:{ref:Number(n),rest:r}}function k(e,t){return t!==void 0&&O(e).ref===t}function A(e){let t=e.filter(e=>!e.archived&&e.status===`queued`).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));return new Map(t.map((e,t)=>[e.id,t+1]))}function j(e,t){return e.filter(e=>t===`archived`?e.archived:!e.archived).sort((e,n)=>{if(t!==`archived`){let t=Number(!!n.pinned)-Number(!!e.pinned);if(t!==0)return t}let r=w(e)-w(n);if(r!==0)return r;if(i(e)&&i(n)){let t=e.autoResumeAt.localeCompare(n.autoResumeAt);if(t!==0)return t}return e.status===`queued`&&n.status===`queued`?e.createdAt.localeCompare(n.createdAt):n.createdAt.localeCompare(e.createdAt)})}function M(e){return e.delegation?.role===`worker`}function N(e,t){if(e==null)return null;let n=t.find(t=>t.id===e);return!n||!M(n)?e:n.delegation?.parentRunId??e}function P(e,t,n=A(e)){let r=j(e,t).filter(e=>!M(e)),i=new Map,a=(e,t)=>{let n=i.get(e);n?n.push(t):i.set(e,[t])};for(let e of r)a(E(e,t),{kind:`run`,run:e,queuePosition:n.get(e.id)??null});return x.filter(e=>i.has(e)).map(e=>({label:e,rows:i.get(e)}))}function F(e,t={}){let r=typeof t==`number`?{overall:t}:n(t),i={"Needs you":`needsYou`,Finished:`finished`,Working:`working`},a=[],o=r.overall===void 0?10:r.overall??1/0;for(let t of e){let e=t.label===`Archived`?1/0:r[i[t.label]]??1/0,n=t.rows.filter(n=>{let r=n.run.pinned;return t.label!==`Archived`&&r?!0:o<=0||e<=0?!1:(--o,--e,!0)});n.length&&a.push({label:t.label,rows:n})}return a}function I(e,t){if(t.length===0)return[...e];let n=new Set(e.map(e=>e.id)),r=new Set,i=t.filter(e=>n.has(e.id)||r.has(e.id)?!1:(r.add(e.id),!0));return[...e,...i]}function L(e){let t=0,n=0,r=0;for(let i of e)if(!M(i)){if(i.archived){n+=1;continue}t+=1,a(i)&&(r+=1)}return{active:t,archived:n,waiting:r}}function R(t,n,r){return t.filter(t=>!t.archived&&(!r||e(t)===(n===`automations`)))}var z={"Needs you":`needs-you`,Finished:`finished`,Working:`working`},B=Object.keys(z),V=`section`;function H(e,t,n){let r=`${V}=${z[e]}`;return n?`/?origin=${t===`automations`?`automations`:`direct`}&${r}`:`/?${r}`}function U(e){return B.find(t=>z[t]===e)??null}function W(t,n){let r={active:0,automations:0,activeWaiting:0,automationsWaiting:0};for(let i of t){if(M(i)||i.archived)continue;let t=+!!a(i);n&&e(i)?(r.automations+=1,r.automationsWaiting+=t):(r.active+=1,r.activeWaiting+=t)}return r}export{_ as C,s as D,o as E,f as O,g as S,l as T,O as _,P as a,h as b,T as c,k as d,D as f,R as g,W as h,F as i,U as l,N as m,V as n,M as o,H as p,B as r,L as s,x as t,A as u,I as v,b as w,m as x,y};
@@ -1,4 +1,4 @@
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{l as i,n as a,t as o}from"./utils-DSMR_WLb.js";import{d as s,i as c,n as l,r as u,s as d}from"./live-refetch-1_o4J83F.js";import{Jn as f,Mn as p,Nn as m,On as h,Ot as g,Qn as _,Qr as v,Xn as y,Yn as b,Zr as x,_r as S,di as C,dt as w,gr as T,it as E,jn as D,lr as O,nt as k,ot as ee,qn as A,st as j,tr as M,tt as te}from"./project-scope-context-C912rTJP.js";import{$ as N,Bt as P,G as ne,J as F,Jt as I,P as L,Qt as R,R as z,St as B,V as re,Xt as ie,Y as ae,Zt as V,_ as oe,bt as se,ct as ce,nt as le,ot as ue,rt as de,ut as fe,vt as pe,z as me}from"./queries-DDhFFTvR.js";import{t as he}from"./useQuery-BOEhMTCg.js";import{f as ge,h as _e,n as H,p as ve}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{d as ye,m as be,r as xe,s as Se,v as Ce}from"./tasks-table-Cm6YZBUB.js";import{n as U}from"./toaster-Bo5vCbz-.js";import{A as we,B as Te,F as Ee,K as De,X as Oe,a as ke,at as Ae,c as je,dt as Me,f as Ne,g as Pe,h as Fe,it as Ie,k as Le,l as Re,m as ze,n as Be,ot as Ve,p as He,s as Ue,u as W,ut as We,v as Ge,y as Ke,z as qe}from"./design-icons-CzEoMH9c.js";import{t as G}from"./createLucideIcon-BHp8sXmF.js";import{a as Je,c as Ye,i as Xe,n as Ze,o as Qe,r as $e,s as et,t as tt}from"./run-header-OhEYfuQX.js";import{t as nt}from"./chevron-right-BENZ-1ZN.js";import{t as rt}from"./external-link-BE6y205O.js";import{t as it}from"./eye-B8okNWXU.js";import{n as at}from"./smartphone-Lr8Ug2z_.js";import{t as ot}from"./loader-circle-CPBhhDbB.js";import{t as st}from"./message-square-B-MD-8rD.js";import{a as ct,c as lt,i as ut,l as dt,n as ft,o as pt,r as mt,s as ht,t as gt}from"./thread-state-DcHyKcQ-.js";import{i as _t,o as vt,t as yt,u as bt}from"./reference-chip-90x9Bq44.js";import{t as xt}from"./square-terminal-B6RYYieR.js";import{t as K}from"./button-B7MKxYjT.js";import{n as q,r as J,t as Y}from"./collapsible-BEV4FO-1.js";import{a as St}from"./popover-BPgUYFyu.js";import{s as Ct,t as X}from"./project-router-DucFIl_x.js";import"./attention-BFUaj1mU.js";import{D as wt,E as Tt,O as Et,S as Dt,b as Ot,f as Z,u as kt,w as At,x as jt}from"./task-groups-B3Z2qfE6.js";import{t as Mt}from"./status-dot-BRzVlF2X.js";import{n as Nt,t as Pt}from"./centered-state-V15AR_qo.js";import{$n as Ft,$t as It,Cn as Lt,F as Rt,Fn as zt,G as Bt,I as Vt,In as Ht,Jn as Ut,K as Wt,Ln as Gt,M as Kt,N as qt,P as Jt,Pn as Yt,Rn as Xt,W as Zt,X as Qt,Y as $t,_n as en,an as tn,bn as nn,dn as rn,en as an,fn as on,i as sn,in as cn,j as ln,l as un,ln as dn,m as fn,mn as pn,n as mn,nn as hn,on as gn,pn as _n,s as vn,un as yn,vn as bn,x as xn,xn as Sn,y as Cn}from"./index-DaJ5iats.js";import{i as wn,r as Tn}from"./highlighter-DvLzHjjY.js";import{t as En}from"./zoomable-image-CIQl1Wpe.js";import{i as Dn,r as On,s as kn,t as An}from"./markdown-q0pVKAO0.js";import{i as jn}from"./automation-format-DB34jUyF.js";import{t as Mn}from"./textarea-vJt9undk.js";import{t as Nn}from"./report-title-D4Mbu2Er.js";var Pn=G(`anchor`,[[`path`,{d:`M12 6v16`,key:`nqf5sj`}],[`path`,{d:`m19 13 2-1a9 9 0 0 1-18 0l2 1`,key:`y7qv08`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}]]),Fn=G(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),In=G(`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`}]]),Ln=G(`corner-up-left`,[[`path`,{d:`M20 20v-7a4 4 0 0 0-4-4H4`,key:`1nkjon`}],[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}]]),Rn=G(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),zn=G(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),Bn=G(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),Q=e(t(),1),$=r(),Vn=12;function Hn({run:e}){let t=C(),n=R({mutationFn:()=>te(e.id),onSuccess:()=>{t.invalidateQueries({queryKey:P.runs.detail(e.id)}),t.invalidateQueries({queryKey:P.runs.list()}),U(`This task will not resume itself`)},onError:e=>U(e.message,{tone:`danger`})});if(!_(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,$.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,$.jsx)(Mt,{tone:`neutral`,shape:`ring`}),e.autoResumeReason===`provider-error`?(0,$.jsxs)(`span`,{title:e.error,children:[`Provider error — this task retries automatically at`,` `,(0,$.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:i}),` `,`(attempt `,(e.autoResumeAttempts??0)+1,` of `,Vn,`)`]}):(0,$.jsxs)(`span`,{children:[`Usage limit reached — this task resumes automatically at`,` `,(0,$.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:i})]}),(0,$.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,$.jsx)(H,{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 Un(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Wn=/^[A-Za-z0-9_./:=+,@%-]+$/;function Gn(e){return e.replaceAll(`'`,`'\\''`)}function Kn(e){return e===``?`''`:Wn.test(e)?e:`\u0027${Gn(e)}\u0027`}function qn(e){if(!Un(e))return;let t=e.command;if(typeof t==`string`&&t!==``)return t;if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return e.map(Kn).join(` `)}}function Jn(e){let t="`".repeat(3),n=`~`.repeat(3);return e.split(t).filter((e,t)=>t%2==0).join(` `).split(n).filter((e,t)=>t%2==0).join(` `).split("`").filter((e,t)=>t%2==0).join(` `)}function Yn(e){return e.replace(/!\[(?:\\.|[^\]\\])*\]\([^)\s]*(?:\s+"[^"]*")?\)/g,` `)}function Xn(e){return e.replace(/(?<!\\)(?:\*\*|\*|__|~~|`)/g,``).replace(/\\([!"#$%&'()*+,\-./:;<=>?@[\]\\^_`{|}~])/g,`$1`)}function Zn(e){let t=e.trim();return t===``||t.startsWith(`#`)||/^(https?:|mailto:)/i.test(t)?!0:!/^[a-z][a-z0-9+.-]*:/i.test(t)}function Qn(e){let t=Jn(Yn(e)),n=new Map;for(let e of t.matchAll(/^\s*\[([^\]]+)\]:\s*(\S+)/gm))Zn(e[2])&&n.set(e[1].toLowerCase(),e[2]);let r=t.replace(/^\s*\[[^\]]+\]:\s*\S+.*$/gm,` `),i=[];for(let e of r.matchAll(/(?<!!)\[((?:\\.|[^\]\\])+)\](?:\(((?:[^()\s]|\([^)]*\))+)(?:\s+"[^"]*")?\)|\[([^\]]*)\])|<(https?:\/\/[^>\s]+)>|(https?:\/\/[^\s<]+)/g)){if(e[2]){Zn(e[2])&&i.push({label:Xn(e[1]),href:e[2]});continue}if(e[1]!==void 0&&e[3]!==void 0){let t=(e[3].length>0?e[3]:e[1]).toLowerCase(),r=n.get(t);r&&i.push({label:Xn(e[1]),href:r});continue}let t=(e[4]??e[5])?.replace(/[.,;:!?]+$/,``);t&&Zn(t)&&i.push({label:t,href:t})}return i}var $n=(0,Q.createContext)(void 0),er=(0,Q.createContext)(void 0);function tr(e,t){let n=new Map;for(let r of Qn(e)){let e=Dn(r.href,t);if(!e)continue;let i=new URL(e,`https://cockpit.invalid`),a=/^\/p\/([^/]+)\/tasks\/([^/]+)\/report$/.exec(i.pathname),o=/^\/tasks\/([^/]+)\/report$/.exec(i.pathname),s=i.searchParams.get(`artifact`);if(!s||(a?decodeURIComponent(a[1])!==t.projectId:!o))continue;let c=decodeURIComponent(a?a[2]:o[1]),l=`${c}:${s}`;n.has(l)||n.set(l,{runId:c,artifactId:s,label:r.label,href:e})}return[...n.values()]}function nr(e,t){return`report-card-${encodeURIComponent(e)}-${t}`}function rr({text:e,messageKey:t}){let n=(0,Q.useContext)(On),r=(0,Q.useContext)(er),i=t??r;if(!n||i===void 0)return null;let a=tr(e,n);return a.length===0?null:(0,$.jsx)(`div`,{"data-slot":`report-cards`,className:`flex flex-col gap-3 [margin-block-start:1rem]`,children:a.map(e=>(0,$.jsx)(ir,{reference:e,messageKey:i},`${e.runId}:${e.artifactId}`))})}function ir({reference:e,messageKey:t}){let{artifactId:n,runId:r,label:i,href:a}=e,o=(0,Q.useContext)($n),s=(0,Q.useContext)(Cn);(0,Q.useLayoutEffect)(()=>s?.register(n,r),[s,n,r]);let c=L(r,n),l=ge(),u=ve();if(c.isError)return(0,$.jsx)(H,{id:nr(t,n),"data-slot":`report-card-fallback`,to:a,state:{readerFrom:l.pathname+l.search},children:i});let d=c.data?.artifact;if(d&&!kn(d.name))return null;let f=new URLSearchParams(l.search);f.set(`report`,n),f.set(`card`,t);let p=new URLSearchParams(l.search).has(`report`)?l.state:null,m=new URLSearchParams(l.search);m.delete(`report`),m.delete(`card`);let h=`${l.pathname}${m.size?`?${m}`:``}`,g=window.navigation,_={reportCardEntry:!0,reportReturnTo:p?.reportReturnTo??h,reportReturnKey:p?.reportReturnKey??g?.currentEntry?.key,reportScrollTop:p?.reportScrollTop},v={pathname:l.pathname,search:`?${f}`,hash:new URL(a,`https://cockpit.invalid`).hash};return(0,$.jsxs)(`section`,{"data-slot":`report-card`,"data-artifact-id":n,"data-report-run-id":r,"aria-busy":c.isPending,className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-card p-3 text-foreground`,children:[(0,$.jsx)(`h3`,{className:`break-words text-sm font-medium`,children:d?Nn(d):i}),(0,$.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`HTML report`}),(0,$.jsx)(H,{id:nr(t,n),to:v,state:_,onClick:e=>{if(e.button!==0||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault(),o?.(t);let n=_.reportScrollTop??document.querySelector(`[data-slot="main"]`)?.scrollTop;u(v,{state:{..._,reportScrollTop:n}})},className:`inline-flex min-h-11 min-w-11 items-center self-start rounded-md border border-border px-3 text-sm active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring ${c.isPending?`text-soft-foreground`:`text-accent-text`}`,children:`Read report`})]})}var ar={message:!0,reasoning:!0,tool:!0,hook:!0};function or(e){return Object.hasOwn(ar,e)&&ar[e]}var sr=e=>e.kind===`tool`,cr=e=>e.kind===`conversation`,lr=e=>(e.toolKind===`read`||e.toolKind===`search`)&&e.status===`completed`,ur=(e,t,n)=>`${e} ${e===1?t:n}`;function dr(e,t){let n=[];return e>0&&n.push(ur(e,`file`,`files`)),t>0&&n.push(ur(t,`search`,`searches`)),`Explored ${n.join(` · `)}`}function fr(e){return`${e} earlier tool call${e===1?``:`s`}`}var pr=[`Web search`,`Ran`,`Edit`,`Write`,`Read`,`Search`,`Fetch`,`Task:`];function mr(e){for(let t of pr)if(e.startsWith(`${t} `)&&e.length>t.length+1)return{verb:t===`Task:`?`Task`:t,detail:e.slice(t.length+1)};return{verb:e}}var hr=new WeakMap;function gr(e){let t=hr.get(e);if(t)return t;let n=_r(e);return hr.set(e,n),n}function _r(e){let t=e.filter(e=>!(e.kind===`tool`&&e.toolKind===`plan`)&&!((e.kind===`reasoning`||e.kind===`message`)&&e.text.trim()===``)),n=new Set(t.filter(sr).map(e=>e.id)),r=new Map,i=[];for(let e of t){let t=or(e.kind)&&`parentItemId`in e&&e.parentItemId!==void 0&&e.parentItemId!==e.id&&n.has(e.parentItemId)?e.parentItemId:void 0;if(t===void 0)i.push(e);else{let n=r.get(t);n?n.push(e):r.set(t,[e])}}let a=[],o=[],s=()=>{if(o.length>=2){let e=o.filter(e=>e.toolKind===`read`).length;a.push({kind:`context-group`,id:`group:${o[0].id}`,tools:o,files:e,searches:o.length-e,label:dr(e,o.length-e)})}else for(let e of o)a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]});o=[]},c=[],l=()=>{if(c.length!==0){for(let e of vr(c).batches)a.push({kind:`worker-conversation`,id:`worker:${e.messages[0].id}`,batches:[e]});c=[]}};for(let e of i){if(cr(e)){s(),c.push(e);continue}l(),sr(e)&&lr(e)&&!r.has(e.id)?o.push(e):(s(),sr(e)?a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]}):a.push({kind:`entry`,id:e.id,entry:e}))}s(),l();let u=e=>e.kind===`context-group`||e.kind===`tool-card`&&e.item.status===`completed`,d=e=>e.kind===`context-group`?e.tools.length:1,f=[],p=[],m=()=>{if(p.length>3){let e=p.slice(0,p.length-3);f.push({kind:`streak`,id:`streak:${e[0].id}`,count:e.reduce((e,t)=>e+d(t),0),blocks:e}),f.push(...p.slice(p.length-3))}else f.push(...p);p=[]};for(let e of a)u(e)?p.push(e):(m(),f.push(e));return m(),f}function vr(e){let t=[];for(let n of e){let e=t.at(-1);n.messageKind===`request`&&e?.kind===`request`&&e.senderRunId===n.senderRunId&&e.text===n.text&&e.messages[0].relationship===`peer`==(n.relationship===`peer`)&&!e.messages.some(e=>e.recipientRunId===n.recipientRunId)?e.messages.push(n):t.push({id:`worker-batch:${n.messageId}`,kind:n.messageKind,text:n.text,senderRunId:n.senderRunId,messages:[n]})}return{kind:`worker-conversation`,id:`worker:${e[0].id}`,batches:t}}var yr=new Map,br=(0,Q.createContext)(null);function xr(){return(0,Q.useContext)(br)}function Sr({runId:e,children:t}){let n=(0,Q.useMemo)(()=>({get:t=>yr.get(e)?.get(t),set:(t,n)=>{let r=yr.get(e)??new Map;r.set(t,n),yr.set(e,r)}}),[e]);return(0,$.jsx)(br.Provider,{value:n,children:t})}function Cr(e){return e.scrollTop<Math.max(600,e.clientHeight)}function wr(e,t){let n=t.find(({bottom:t})=>t>e);return n===void 0?void 0:{key:n.key,offset:n.top-e}}function Tr(e,t,n,r,i){if(n===void 0)return i;let a=r.find(({key:e})=>e===n.key);return a===void 0?i:e+(a.top-t-n.offset)}function Er(e,t=24){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function Dr(e,t){let n=new URLSearchParams(e).get(`thread`);return n===`flat`||n===`virtual`?n:t>300?`virtual`:`flat`}var Or=new Map;function kr(e,t){Or.set(e,t)}function Ar(e){return Or.get(e)}var jr=new Map;function Mr(e,t){jr.set(e,{...t,...t.rowKeys?{rowKeys:[...t.rowKeys]}:{}})}function Nr(e){return jr.get(e)}function Pr(e,t,n){let r=jr.get(e);if(!r||r.rows!==t)return;let i=r.rowKeys;if(!(n&&i&&(n.length!==t||i.length!==t||!n.every((e,t)=>e===i[t]))))return r.cache}var Fr=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),Ir=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`medium`}),Lr=new Intl.DateTimeFormat(void 0,{weekday:`short`,month:`short`,day:`numeric`}),Rr=new Intl.DateTimeFormat(void 0,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`}),zr=new Intl.DateTimeFormat(void 0,{dateStyle:`full`});function Br(e){if(typeof e!=`string`||e===``)return;let t=new Date(e);return Number.isFinite(t.getTime())?t:void 0}function Vr(e){let t=Br(e);return t===void 0?void 0:Fr.format(t)}function Hr(e){let t=Br(e);return t===void 0?void 0:Ir.format(t)}var Ur=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;function Wr(e){let t=Br(e);return t===void 0?void 0:Ur(t)}function Gr(e,t=new Date){let n=Br(e);if(n===void 0)return;let r=Ur(n);return r===Ur(t)?`Today`:r===Ur(new Date(t.getFullYear(),t.getMonth(),t.getDate()-1))?`Yesterday`:(n.getFullYear()===t.getFullYear()?Lr:Rr).format(n)}function Kr(e,t){let n=Br(e),r=Br(t);if(n===void 0||r===void 0)return;let i=Math.round((r.getTime()-n.getTime())/1e3);if(i<0)return;if(i<60)return`${i}s`;let a=Math.floor(i/60);return a<60?`${a}m ${String(i%60).padStart(2,`0`)}s`:`${Math.floor(a/60)}h ${String(a%60).padStart(2,`0`)}m`}function qr({ts:e}){let t=Vr(e);return t===void 0?null:(0,$.jsx)(`time`,{"data-slot":`message-time`,dateTime:e,title:Hr(e),className:`text-[11px] leading-none text-soft-foreground`,children:t})}function Jr({startedAt:e,completedAt:t}){let n=Vr(t);if(n===void 0)return null;let r=Kr(e,t);return(0,$.jsxs)(`div`,{"data-slot":`turn-time`,className:`flex items-center gap-1.5 px-0.5 text-[11px] leading-none text-soft-foreground`,children:[(0,$.jsx)(`time`,{dateTime:t,title:Hr(t),children:n}),r===void 0?null:(0,$.jsxs)(`span`,{title:`Replied in ${r}`,children:[`· `,r]})]})}function Yr({ts:e}){let t=Gr(e),n=Br(e);if(t===void 0||n===void 0)return null;let r=zr.format(n);return(0,$.jsxs)(`div`,{"data-slot":`day-separator`,role:`separator`,"aria-label":t===`Today`||t===`Yesterday`?`${t}, ${r}`:r,className:`flex items-center gap-3 py-1 text-[11px] font-medium text-soft-foreground`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),(0,$.jsx)(`time`,{dateTime:Wr(e),title:r,children:t}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]})}var Xr={assistant:`Agent message`,error:`Runner error`,"session.error":`Session error`,"step-end":`Step status`,lifecycle:`Run status`};function Zr({note:e}){return e.icon===`handoff`?(0,$.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,"data-icon":`handoff`,className:`flex items-start gap-2 px-0.5 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`mt-[-1px] flex size-5 shrink-0 items-center justify-center rounded-full border border-border text-success`,children:(0,$.jsx)(Ut,{className:`size-3`})}),(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:e.text})]}):e.details&&e.details.length>0?(0,$.jsxs)(Y,{"data-slot":`note-line`,"data-tone":e.tone,className:`group/failure min-w-0 px-0.5 text-xs`,children:[(0,$.jsxs)(`div`,{className:o(`flex items-start gap-2`,e.tone===`danger`?`text-danger [.light_&]:text-red-700`:`text-soft-foreground`),children:[(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap wrap-anywhere`,children:[e.tone===`danger`?`✗ `:null,e.text]}),(0,$.jsxs)(J,{"data-slot":`note-details-toggle`,className:`inline-flex shrink-0 items-center gap-1 rounded-sm px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground hover:bg-muted/50 hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11 max-md:min-w-11 max-md:justify-center pointer-coarse:min-h-11 pointer-coarse:min-w-11 pointer-coarse:justify-center`,children:[(0,$.jsx)(W,{"aria-hidden":`true`,className:`size-3 shrink-0 motion-safe:transition-transform group-data-[state=open]/failure:rotate-90`}),`Details`]})]}),(0,$.jsx)(q,{children:(0,$.jsx)(`ul`,{"data-slot":`note-details`,className:`mbs-1.5 flex flex-col gap-1 border-s border-border ps-3 font-mono text-[11px] text-muted-foreground`,children:e.details.map((e,t)=>(0,$.jsxs)(`li`,{className:`min-w-0 whitespace-pre-wrap wrap-anywhere`,children:[(0,$.jsxs)(`span`,{className:`font-sans font-medium text-foreground/80`,children:[Xr[e.source],`:`,` `]}),e.text]},`${e.source}:${t}`))})})]}):(0,$.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,className:o(`px-0.5 text-xs`,e.tone===`danger`?`text-danger [.light_&]:text-red-700`:`text-soft-foreground`),children:[e.tone===`danger`?`✗ `:null,e.text]})}var Qr={user:{label:`YOUR MESSAGE`,speaker:`Your message`,classes:`border-message-user-border bg-message-user-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-user-accent`,accent:`text-message-user-accent`,body:`max-md:text-[12px]`},agent:{label:`AGENT RESPONSE`,speaker:`Agent response`,classes:`border-message-agent-border bg-message-agent-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-agent-accent`,accent:`text-message-agent-accent`,body:`text-[15px] md:text-[14px]`}};function $r({role:e,children:t,className:n,ts:r,headerActions:i,...a}){let s=Qr[e],c=r===void 0?void 0:Vr(r);return(0,$.jsxs)(`article`,{...a,"data-role":e,"aria-label":s.speaker,className:o(`flex w-full min-w-0 flex-col gap-2 self-stretch rounded-[8px] border p-3 md:px-4 md:py-[14px]`,s.classes,n),children:[(0,$.jsxs)(`p`,{className:o(`m-0 flex w-full min-w-0 items-start gap-2 text-[11px] leading-[1.2] font-semibold tracking-[0.6px] uppercase`,s.accent),children:[(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1 normal-case tracking-normal`,children:[(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2 uppercase tracking-[0.6px]`,children:[(0,$.jsx)(st,{"aria-hidden":`true`,className:`size-4 shrink-0`}),s.label]}),i]}),c===void 0?null:(0,$.jsx)(`span`,{className:`shrink-0 font-normal tracking-normal normal-case`,children:(0,$.jsx)(qr,{ts:r})})]}),(0,$.jsx)(`div`,{className:o(`min-w-0 break-words text-[14px] text-foreground select-text [overflow-wrap:anywhere]`,s.body,`leading-[1.6]`),children:t})]})}var ei=[],ti=(0,Q.memo)(function({text:e,imageCount:t=0,images:n=ei,ts:r,onEdit:a,onRemove:o,editLabel:s=`Edit message`,removeLabel:c=`Remove message`,children:l}){let u=t-n.length,[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(e),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(),y=()=>{m(e),v(void 0),f(!0)},b=async()=>{let t=p.trim();if(!t||t===e){f(!1);return}g(!0),v(void 0);try{await a?.(t),f(!1)}catch(e){v(e instanceof Error?e.message:`Could not save the message`)}finally{g(!1)}},x=async()=>{g(!0),v(void 0);try{await o?.()}catch(e){v(e instanceof Error?e.message:`Could not remove the message`)}finally{g(!1)}};return d?(0,$.jsxs)($r,{role:`user`,ts:r,"data-slot":`user-bubble`,"data-editing":`true`,children:[(0,$.jsx)(`textarea`,{autoFocus:!0,"aria-label":`Edit the message`,value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.stopPropagation(),f(!1)):e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),b())},className:`block max-h-[220px] min-h-[60px] w-full resize-none rounded-md bg-background px-2 py-1.5 text-[14px] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}),(0,$.jsxs)(`span`,{className:`mt-1.5 flex justify-end gap-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>f(!1),disabled:h,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm px-2 text-xs font-medium text-muted-foreground hover:bg-background hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:`Cancel`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void b(),disabled:h,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm bg-action px-2 text-xs font-semibold text-action-foreground hover:brightness-[0.96] focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:h?(0,$.jsx)(ot,{className:`size-3.5 animate-spin`}):`Save`})]}),_?(0,$.jsx)(`p`,{role:`alert`,className:`mt-1.5 text-xs text-danger`,children:_}):null]}):(0,$.jsxs)($r,{role:`user`,ts:r,"data-slot":`user-bubble`,className:`group`,children:[a||o?(0,$.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`mb-1 flex justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100`,children:[a?(0,$.jsx)(`button`,{type:`button`,"aria-label":s,onClick:y,disabled:h,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,$.jsx)(Bn,{className:`size-3.5`})}):null,o?(0,$.jsx)(`button`,{type:`button`,"aria-label":c,onClick:()=>void x(),disabled:h,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-danger focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,$.jsx)(Ae,{className:`size-3.5`})}):null]}):null,_?(0,$.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:_}):null,l??(0,$.jsx)(An,{breaks:!0,children:e}),n.length>0?(0,$.jsx)(`span`,{"data-slot":`user-images`,className:`mt-2 flex flex-wrap items-center justify-end gap-1.5`,children:n.map(e=>O(e.split(`/`).pop()??``)?(0,$.jsx)(En,{src:e,alt:`attached`,className:`max-h-40 max-w-[220px] rounded-md border border-border object-contain`},e):(0,$.jsxs)(`a`,{href:i(e),download:!0,"data-slot":`user-file`,className:`inline-flex min-h-11 min-w-11 max-w-[220px] items-center gap-1.5 rounded-md border border-border bg-background/60 px-2 py-1 text-xs text-muted-foreground hover:text-foreground`,children:[(0,$.jsx)(De,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.split(`/`).pop()})]},e))}):null,u>0?(0,$.jsxs)(`span`,{className:`mt-1 block text-xs text-soft-foreground`,children:[u,` image`,u>1?`s`:``,` attached`]}):null]})}),ni=`inline-flex h-11 min-w-11 items-center justify-center gap-1 rounded-sm px-2 text-xs font-medium text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,ri=[`[data-streamdown="code-block-actions"]`,`[data-streamdown="code-copy-button"]`,`[data-streamdown="code-block-copy-button"]`,`[data-streamdown="code-block-header"]`].join(`,`);function ii(e,t){let n=e.cloneNode(!0);n.querySelectorAll(ri).forEach(e=>e.remove());let r=Qn(t);return[...n.querySelectorAll(`button[data-streamdown="link"]`)].forEach(e=>{let t=e.textContent??``,i=r.findIndex(e=>e.label===t);if(i<0)return;let a=r.splice(i,1)[0];if(!a||!Zn(a.href))return;let o=n.ownerDocument.createElement(`a`);o.setAttribute(`href`,a.href),o.setAttribute(`data-streamdown`,`link`),o.textContent=e.textContent,e.replaceWith(o)}),n.innerHTML}async function ai(e,t,n){if(e===`markdown`){if(!navigator.clipboard?.writeText)throw Error(`Clipboard unavailable`);await navigator.clipboard.writeText(t);return}if(!navigator.clipboard?.write||typeof ClipboardItem>`u`||!n)throw Error(`Clipboard unavailable`);let r=ii(n,t);await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([r],{type:`text/html`}),"text/plain":new Blob([t],{type:`text/plain`})})])}var oi=(0,Q.memo)(function({text:e,ts:t,messageKey:n}){let r=(0,Q.useRef)(null),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(null),c=(0,Q.useRef)(null);(0,Q.useEffect)(()=>()=>{c.current!==null&&clearTimeout(c.current)},[]);let l=async t=>{c.current!==null&&clearTimeout(c.current),a(null),s(null);try{await ai(t,e,r.current),a(t),c.current=setTimeout(()=>a(null),2e3)}catch{s(`Couldn't copy to the clipboard`)}};return(0,$.jsxs)($r,{role:`agent`,ts:t,"data-slot":`assistant-message`,headerActions:(0,$.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`flex items-center gap-0.5`,children:[(0,$.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply`,onClick:()=>void l(`html`),className:ni,children:[(0,$.jsx)(Ge,{className:`size-3.5`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{"aria-live":`polite`,children:i===`html`?`Copied`:`Copy`})]}),(0,$.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply as markdown`,onClick:()=>void l(`markdown`),className:ni,children:[(0,$.jsx)(Ft,{className:`size-3.5`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{"aria-live":`polite`,children:i===`markdown`?`Copied`:`Copy markdown`})]})]}),children:[o?(0,$.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:o}):null,(0,$.jsx)(`div`,{ref:r,children:(0,$.jsx)(An,{breaks:!0,children:e})}),(0,$.jsx)(rr,{text:e,messageKey:n})]})});function si({incident:e}){let t=s().data;if(!t)return null;let n=c(t,e.provider);return(0,$.jsxs)(`div`,{role:`alert`,"data-slot":`provider-auth-required`,className:`rounded-md border border-danger/30 bg-danger/5 px-3.5 py-3`,children:[(0,$.jsxs)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:[`This run needed `,n,` authorization`]}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Review `,n,` settings before retrying.`]}),(0,$.jsx)(X,{to:`/settings/agent-defaults#providers`,className:`mt-2 inline-flex text-xs font-medium text-foreground underline-offset-2 hover:underline`,children:`Open provider settings`})]})}var ci=(0,Q.memo)(function({text:e}){let t=(0,Q.useId)();if(e.trim()===``)return null;let n=e.split(`
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{l as i,n as a,t as o}from"./utils-DSMR_WLb.js";import{d as s,i as c,n as l,r as u,s as d}from"./live-refetch-VoLPvzhe.js";import{Jn as f,Mn as p,Nn as m,On as h,Ot as g,Qn as _,Qr as v,Xn as y,Yn as b,Zr as x,_r as S,di as C,dt as w,gr as T,it as E,jn as D,lr as O,nt as k,ot as ee,qn as A,st as j,tr as M,tt as te}from"./project-scope-context-BdqKyBHa.js";import{$ as N,Bt as P,G as ne,J as F,Jt as I,P as L,Qt as R,R as z,St as B,V as re,Xt as ie,Y as ae,Zt as V,_ as oe,bt as se,ct as ce,nt as le,ot as ue,rt as de,ut as fe,vt as pe,z as me}from"./queries-C7VNk-nW.js";import{t as he}from"./useQuery-BSyhc3l3.js";import{f as ge,h as _e,n as H,p as ve}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{d as ye,m as be,r as xe,s as Se,v as Ce}from"./tasks-table-Cx7AM7lZ.js";import{n as U}from"./toaster-Bo5vCbz-.js";import{A as we,B as Te,F as Ee,K as De,X as Oe,a as ke,at as Ae,c as je,dt as Me,f as Ne,g as Pe,h as Fe,it as Ie,k as Le,l as Re,m as ze,n as Be,ot as Ve,p as He,s as Ue,u as W,ut as We,v as Ge,y as Ke,z as qe}from"./design-icons-CzEoMH9c.js";import{t as G}from"./createLucideIcon-BHp8sXmF.js";import{a as Je,c as Ye,i as Xe,n as Ze,o as Qe,r as $e,s as et,t as tt}from"./run-header-B-olCSdg.js";import{t as nt}from"./chevron-right-BENZ-1ZN.js";import{t as rt}from"./external-link-BE6y205O.js";import{t as it}from"./eye-B8okNWXU.js";import{n as at}from"./smartphone-Lr8Ug2z_.js";import{t as ot}from"./loader-circle-CPBhhDbB.js";import{t as st}from"./message-square-B-MD-8rD.js";import{a as ct,c as lt,i as ut,l as dt,n as ft,o as pt,r as mt,s as ht,t as gt}from"./thread-state-R0MTvwlo.js";import{i as _t,o as vt,t as yt,u as bt}from"./reference-chip-rylFalfg.js";import{t as xt}from"./square-terminal-B6RYYieR.js";import{t as K}from"./button-B7MKxYjT.js";import{n as q,r as J,t as Y}from"./collapsible-BEV4FO-1.js";import{a as St}from"./popover-BPgUYFyu.js";import{s as Ct,t as X}from"./project-router-Bii3ofOk.js";import"./attention-8bNiiAFt.js";import{D as wt,E as Tt,O as Et,S as Dt,b as Ot,f as Z,u as kt,w as At,x as jt}from"./task-groups-BbnYlkYj.js";import{t as Mt}from"./status-dot-BRzVlF2X.js";import{n as Nt,t as Pt}from"./centered-state-V15AR_qo.js";import{$n as Ft,$t as It,Cn as Lt,F as Rt,Fn as zt,G as Bt,I as Vt,In as Ht,Jn as Ut,K as Wt,Ln as Gt,M as Kt,N as qt,P as Jt,Pn as Yt,Rn as Xt,W as Zt,X as Qt,Y as $t,_n as en,an as tn,bn as nn,dn as rn,en as an,fn as on,i as sn,in as cn,j as ln,l as un,ln as dn,m as fn,mn as pn,n as mn,nn as hn,on as gn,pn as _n,s as vn,un as yn,vn as bn,x as xn,xn as Sn,y as Cn}from"./index-CJFT0IZP.js";import{i as wn,r as Tn}from"./highlighter-DvLzHjjY.js";import{t as En}from"./zoomable-image-CIQl1Wpe.js";import{i as Dn,r as On,s as kn,t as An}from"./markdown-Dv0r75AX.js";import{i as jn}from"./automation-format-DB34jUyF.js";import{t as Mn}from"./textarea-vJt9undk.js";import{t as Nn}from"./report-title-D4Mbu2Er.js";var Pn=G(`anchor`,[[`path`,{d:`M12 6v16`,key:`nqf5sj`}],[`path`,{d:`m19 13 2-1a9 9 0 0 1-18 0l2 1`,key:`y7qv08`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}]]),Fn=G(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),In=G(`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`}]]),Ln=G(`corner-up-left`,[[`path`,{d:`M20 20v-7a4 4 0 0 0-4-4H4`,key:`1nkjon`}],[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}]]),Rn=G(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),zn=G(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),Bn=G(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),Q=e(t(),1),$=r(),Vn=12;function Hn({run:e}){let t=C(),n=R({mutationFn:()=>te(e.id),onSuccess:()=>{t.invalidateQueries({queryKey:P.runs.detail(e.id)}),t.invalidateQueries({queryKey:P.runs.list()}),U(`This task will not resume itself`)},onError:e=>U(e.message,{tone:`danger`})});if(!_(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,$.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,$.jsx)(Mt,{tone:`neutral`,shape:`ring`}),e.autoResumeReason===`provider-error`?(0,$.jsxs)(`span`,{title:e.error,children:[`Provider error — this task retries automatically at`,` `,(0,$.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:i}),` `,`(attempt `,(e.autoResumeAttempts??0)+1,` of `,Vn,`)`]}):(0,$.jsxs)(`span`,{children:[`Usage limit reached — this task resumes automatically at`,` `,(0,$.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:i})]}),(0,$.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,$.jsx)(H,{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 Un(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Wn=/^[A-Za-z0-9_./:=+,@%-]+$/;function Gn(e){return e.replaceAll(`'`,`'\\''`)}function Kn(e){return e===``?`''`:Wn.test(e)?e:`\u0027${Gn(e)}\u0027`}function qn(e){if(!Un(e))return;let t=e.command;if(typeof t==`string`&&t!==``)return t;if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return e.map(Kn).join(` `)}}function Jn(e){let t="`".repeat(3),n=`~`.repeat(3);return e.split(t).filter((e,t)=>t%2==0).join(` `).split(n).filter((e,t)=>t%2==0).join(` `).split("`").filter((e,t)=>t%2==0).join(` `)}function Yn(e){return e.replace(/!\[(?:\\.|[^\]\\])*\]\([^)\s]*(?:\s+"[^"]*")?\)/g,` `)}function Xn(e){return e.replace(/(?<!\\)(?:\*\*|\*|__|~~|`)/g,``).replace(/\\([!"#$%&'()*+,\-./:;<=>?@[\]\\^_`{|}~])/g,`$1`)}function Zn(e){let t=e.trim();return t===``||t.startsWith(`#`)||/^(https?:|mailto:)/i.test(t)?!0:!/^[a-z][a-z0-9+.-]*:/i.test(t)}function Qn(e){let t=Jn(Yn(e)),n=new Map;for(let e of t.matchAll(/^\s*\[([^\]]+)\]:\s*(\S+)/gm))Zn(e[2])&&n.set(e[1].toLowerCase(),e[2]);let r=t.replace(/^\s*\[[^\]]+\]:\s*\S+.*$/gm,` `),i=[];for(let e of r.matchAll(/(?<!!)\[((?:\\.|[^\]\\])+)\](?:\(((?:[^()\s]|\([^)]*\))+)(?:\s+"[^"]*")?\)|\[([^\]]*)\])|<(https?:\/\/[^>\s]+)>|(https?:\/\/[^\s<]+)/g)){if(e[2]){Zn(e[2])&&i.push({label:Xn(e[1]),href:e[2]});continue}if(e[1]!==void 0&&e[3]!==void 0){let t=(e[3].length>0?e[3]:e[1]).toLowerCase(),r=n.get(t);r&&i.push({label:Xn(e[1]),href:r});continue}let t=(e[4]??e[5])?.replace(/[.,;:!?]+$/,``);t&&Zn(t)&&i.push({label:t,href:t})}return i}var $n=(0,Q.createContext)(void 0),er=(0,Q.createContext)(void 0);function tr(e,t){let n=new Map;for(let r of Qn(e)){let e=Dn(r.href,t);if(!e)continue;let i=new URL(e,`https://cockpit.invalid`),a=/^\/p\/([^/]+)\/tasks\/([^/]+)\/report$/.exec(i.pathname),o=/^\/tasks\/([^/]+)\/report$/.exec(i.pathname),s=i.searchParams.get(`artifact`);if(!s||(a?decodeURIComponent(a[1])!==t.projectId:!o))continue;let c=decodeURIComponent(a?a[2]:o[1]),l=`${c}:${s}`;n.has(l)||n.set(l,{runId:c,artifactId:s,label:r.label,href:e})}return[...n.values()]}function nr(e,t){return`report-card-${encodeURIComponent(e)}-${t}`}function rr({text:e,messageKey:t}){let n=(0,Q.useContext)(On),r=(0,Q.useContext)(er),i=t??r;if(!n||i===void 0)return null;let a=tr(e,n);return a.length===0?null:(0,$.jsx)(`div`,{"data-slot":`report-cards`,className:`flex flex-col gap-3 [margin-block-start:1rem]`,children:a.map(e=>(0,$.jsx)(ir,{reference:e,messageKey:i},`${e.runId}:${e.artifactId}`))})}function ir({reference:e,messageKey:t}){let{artifactId:n,runId:r,label:i,href:a}=e,o=(0,Q.useContext)($n),s=(0,Q.useContext)(Cn);(0,Q.useLayoutEffect)(()=>s?.register(n,r),[s,n,r]);let c=L(r,n),l=ge(),u=ve();if(c.isError)return(0,$.jsx)(H,{id:nr(t,n),"data-slot":`report-card-fallback`,to:a,state:{readerFrom:l.pathname+l.search},children:i});let d=c.data?.artifact;if(d&&!kn(d.name))return null;let f=new URLSearchParams(l.search);f.set(`report`,n),f.set(`card`,t);let p=new URLSearchParams(l.search).has(`report`)?l.state:null,m=new URLSearchParams(l.search);m.delete(`report`),m.delete(`card`);let h=`${l.pathname}${m.size?`?${m}`:``}`,g=window.navigation,_={reportCardEntry:!0,reportReturnTo:p?.reportReturnTo??h,reportReturnKey:p?.reportReturnKey??g?.currentEntry?.key,reportScrollTop:p?.reportScrollTop},v={pathname:l.pathname,search:`?${f}`,hash:new URL(a,`https://cockpit.invalid`).hash};return(0,$.jsxs)(`section`,{"data-slot":`report-card`,"data-artifact-id":n,"data-report-run-id":r,"aria-busy":c.isPending,className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-card p-3 text-foreground`,children:[(0,$.jsx)(`h3`,{className:`break-words text-sm font-medium`,children:d?Nn(d):i}),(0,$.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`HTML report`}),(0,$.jsx)(H,{id:nr(t,n),to:v,state:_,onClick:e=>{if(e.button!==0||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault(),o?.(t);let n=_.reportScrollTop??document.querySelector(`[data-slot="main"]`)?.scrollTop;u(v,{state:{..._,reportScrollTop:n}})},className:`inline-flex min-h-11 min-w-11 items-center self-start rounded-md border border-border px-3 text-sm active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring ${c.isPending?`text-soft-foreground`:`text-accent-text`}`,children:`Read report`})]})}var ar={message:!0,reasoning:!0,tool:!0,hook:!0};function or(e){return Object.hasOwn(ar,e)&&ar[e]}var sr=e=>e.kind===`tool`,cr=e=>e.kind===`conversation`,lr=e=>(e.toolKind===`read`||e.toolKind===`search`)&&e.status===`completed`,ur=(e,t,n)=>`${e} ${e===1?t:n}`;function dr(e,t){let n=[];return e>0&&n.push(ur(e,`file`,`files`)),t>0&&n.push(ur(t,`search`,`searches`)),`Explored ${n.join(` · `)}`}function fr(e){return`${e} earlier tool call${e===1?``:`s`}`}var pr=[`Web search`,`Ran`,`Edit`,`Write`,`Read`,`Search`,`Fetch`,`Task:`];function mr(e){for(let t of pr)if(e.startsWith(`${t} `)&&e.length>t.length+1)return{verb:t===`Task:`?`Task`:t,detail:e.slice(t.length+1)};return{verb:e}}var hr=new WeakMap;function gr(e){let t=hr.get(e);if(t)return t;let n=_r(e);return hr.set(e,n),n}function _r(e){let t=e.filter(e=>!(e.kind===`tool`&&e.toolKind===`plan`)&&!((e.kind===`reasoning`||e.kind===`message`)&&e.text.trim()===``)),n=new Set(t.filter(sr).map(e=>e.id)),r=new Map,i=[];for(let e of t){let t=or(e.kind)&&`parentItemId`in e&&e.parentItemId!==void 0&&e.parentItemId!==e.id&&n.has(e.parentItemId)?e.parentItemId:void 0;if(t===void 0)i.push(e);else{let n=r.get(t);n?n.push(e):r.set(t,[e])}}let a=[],o=[],s=()=>{if(o.length>=2){let e=o.filter(e=>e.toolKind===`read`).length;a.push({kind:`context-group`,id:`group:${o[0].id}`,tools:o,files:e,searches:o.length-e,label:dr(e,o.length-e)})}else for(let e of o)a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]});o=[]},c=[],l=()=>{if(c.length!==0){for(let e of vr(c).batches)a.push({kind:`worker-conversation`,id:`worker:${e.messages[0].id}`,batches:[e]});c=[]}};for(let e of i){if(cr(e)){s(),c.push(e);continue}l(),sr(e)&&lr(e)&&!r.has(e.id)?o.push(e):(s(),sr(e)?a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]}):a.push({kind:`entry`,id:e.id,entry:e}))}s(),l();let u=e=>e.kind===`context-group`||e.kind===`tool-card`&&e.item.status===`completed`,d=e=>e.kind===`context-group`?e.tools.length:1,f=[],p=[],m=()=>{if(p.length>3){let e=p.slice(0,p.length-3);f.push({kind:`streak`,id:`streak:${e[0].id}`,count:e.reduce((e,t)=>e+d(t),0),blocks:e}),f.push(...p.slice(p.length-3))}else f.push(...p);p=[]};for(let e of a)u(e)?p.push(e):(m(),f.push(e));return m(),f}function vr(e){let t=[];for(let n of e){let e=t.at(-1);n.messageKind===`request`&&e?.kind===`request`&&e.senderRunId===n.senderRunId&&e.text===n.text&&e.messages[0].relationship===`peer`==(n.relationship===`peer`)&&!e.messages.some(e=>e.recipientRunId===n.recipientRunId)?e.messages.push(n):t.push({id:`worker-batch:${n.messageId}`,kind:n.messageKind,text:n.text,senderRunId:n.senderRunId,messages:[n]})}return{kind:`worker-conversation`,id:`worker:${e[0].id}`,batches:t}}var yr=new Map,br=(0,Q.createContext)(null);function xr(){return(0,Q.useContext)(br)}function Sr({runId:e,children:t}){let n=(0,Q.useMemo)(()=>({get:t=>yr.get(e)?.get(t),set:(t,n)=>{let r=yr.get(e)??new Map;r.set(t,n),yr.set(e,r)}}),[e]);return(0,$.jsx)(br.Provider,{value:n,children:t})}function Cr(e){return e.scrollTop<Math.max(600,e.clientHeight)}function wr(e,t){let n=t.find(({bottom:t})=>t>e);return n===void 0?void 0:{key:n.key,offset:n.top-e}}function Tr(e,t,n,r,i){if(n===void 0)return i;let a=r.find(({key:e})=>e===n.key);return a===void 0?i:e+(a.top-t-n.offset)}function Er(e,t=24){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function Dr(e,t){let n=new URLSearchParams(e).get(`thread`);return n===`flat`||n===`virtual`?n:t>300?`virtual`:`flat`}var Or=new Map;function kr(e,t){Or.set(e,t)}function Ar(e){return Or.get(e)}var jr=new Map;function Mr(e,t){jr.set(e,{...t,...t.rowKeys?{rowKeys:[...t.rowKeys]}:{}})}function Nr(e){return jr.get(e)}function Pr(e,t,n){let r=jr.get(e);if(!r||r.rows!==t)return;let i=r.rowKeys;if(!(n&&i&&(n.length!==t||i.length!==t||!n.every((e,t)=>e===i[t]))))return r.cache}var Fr=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),Ir=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`medium`}),Lr=new Intl.DateTimeFormat(void 0,{weekday:`short`,month:`short`,day:`numeric`}),Rr=new Intl.DateTimeFormat(void 0,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`}),zr=new Intl.DateTimeFormat(void 0,{dateStyle:`full`});function Br(e){if(typeof e!=`string`||e===``)return;let t=new Date(e);return Number.isFinite(t.getTime())?t:void 0}function Vr(e){let t=Br(e);return t===void 0?void 0:Fr.format(t)}function Hr(e){let t=Br(e);return t===void 0?void 0:Ir.format(t)}var Ur=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;function Wr(e){let t=Br(e);return t===void 0?void 0:Ur(t)}function Gr(e,t=new Date){let n=Br(e);if(n===void 0)return;let r=Ur(n);return r===Ur(t)?`Today`:r===Ur(new Date(t.getFullYear(),t.getMonth(),t.getDate()-1))?`Yesterday`:(n.getFullYear()===t.getFullYear()?Lr:Rr).format(n)}function Kr(e,t){let n=Br(e),r=Br(t);if(n===void 0||r===void 0)return;let i=Math.round((r.getTime()-n.getTime())/1e3);if(i<0)return;if(i<60)return`${i}s`;let a=Math.floor(i/60);return a<60?`${a}m ${String(i%60).padStart(2,`0`)}s`:`${Math.floor(a/60)}h ${String(a%60).padStart(2,`0`)}m`}function qr({ts:e}){let t=Vr(e);return t===void 0?null:(0,$.jsx)(`time`,{"data-slot":`message-time`,dateTime:e,title:Hr(e),className:`text-[11px] leading-none text-soft-foreground`,children:t})}function Jr({startedAt:e,completedAt:t}){let n=Vr(t);if(n===void 0)return null;let r=Kr(e,t);return(0,$.jsxs)(`div`,{"data-slot":`turn-time`,className:`flex items-center gap-1.5 px-0.5 text-[11px] leading-none text-soft-foreground`,children:[(0,$.jsx)(`time`,{dateTime:t,title:Hr(t),children:n}),r===void 0?null:(0,$.jsxs)(`span`,{title:`Replied in ${r}`,children:[`· `,r]})]})}function Yr({ts:e}){let t=Gr(e),n=Br(e);if(t===void 0||n===void 0)return null;let r=zr.format(n);return(0,$.jsxs)(`div`,{"data-slot":`day-separator`,role:`separator`,"aria-label":t===`Today`||t===`Yesterday`?`${t}, ${r}`:r,className:`flex items-center gap-3 py-1 text-[11px] font-medium text-soft-foreground`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),(0,$.jsx)(`time`,{dateTime:Wr(e),title:r,children:t}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]})}var Xr={assistant:`Agent message`,error:`Runner error`,"session.error":`Session error`,"step-end":`Step status`,lifecycle:`Run status`};function Zr({note:e}){return e.icon===`handoff`?(0,$.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,"data-icon":`handoff`,className:`flex items-start gap-2 px-0.5 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`mt-[-1px] flex size-5 shrink-0 items-center justify-center rounded-full border border-border text-success`,children:(0,$.jsx)(Ut,{className:`size-3`})}),(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:e.text})]}):e.details&&e.details.length>0?(0,$.jsxs)(Y,{"data-slot":`note-line`,"data-tone":e.tone,className:`group/failure min-w-0 px-0.5 text-xs`,children:[(0,$.jsxs)(`div`,{className:o(`flex items-start gap-2`,e.tone===`danger`?`text-danger [.light_&]:text-red-700`:`text-soft-foreground`),children:[(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap wrap-anywhere`,children:[e.tone===`danger`?`✗ `:null,e.text]}),(0,$.jsxs)(J,{"data-slot":`note-details-toggle`,className:`inline-flex shrink-0 items-center gap-1 rounded-sm px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground hover:bg-muted/50 hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11 max-md:min-w-11 max-md:justify-center pointer-coarse:min-h-11 pointer-coarse:min-w-11 pointer-coarse:justify-center`,children:[(0,$.jsx)(W,{"aria-hidden":`true`,className:`size-3 shrink-0 motion-safe:transition-transform group-data-[state=open]/failure:rotate-90`}),`Details`]})]}),(0,$.jsx)(q,{children:(0,$.jsx)(`ul`,{"data-slot":`note-details`,className:`mbs-1.5 flex flex-col gap-1 border-s border-border ps-3 font-mono text-[11px] text-muted-foreground`,children:e.details.map((e,t)=>(0,$.jsxs)(`li`,{className:`min-w-0 whitespace-pre-wrap wrap-anywhere`,children:[(0,$.jsxs)(`span`,{className:`font-sans font-medium text-foreground/80`,children:[Xr[e.source],`:`,` `]}),e.text]},`${e.source}:${t}`))})})]}):(0,$.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,className:o(`px-0.5 text-xs`,e.tone===`danger`?`text-danger [.light_&]:text-red-700`:`text-soft-foreground`),children:[e.tone===`danger`?`✗ `:null,e.text]})}var Qr={user:{label:`YOUR MESSAGE`,speaker:`Your message`,classes:`border-message-user-border bg-message-user-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-user-accent`,accent:`text-message-user-accent`,body:`max-md:text-[12px]`},agent:{label:`AGENT RESPONSE`,speaker:`Agent response`,classes:`border-message-agent-border bg-message-agent-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-agent-accent`,accent:`text-message-agent-accent`,body:`text-[15px] md:text-[14px]`}};function $r({role:e,children:t,className:n,ts:r,headerActions:i,...a}){let s=Qr[e],c=r===void 0?void 0:Vr(r);return(0,$.jsxs)(`article`,{...a,"data-role":e,"aria-label":s.speaker,className:o(`flex w-full min-w-0 flex-col gap-2 self-stretch rounded-[8px] border p-3 md:px-4 md:py-[14px]`,s.classes,n),children:[(0,$.jsxs)(`p`,{className:o(`m-0 flex w-full min-w-0 items-start gap-2 text-[11px] leading-[1.2] font-semibold tracking-[0.6px] uppercase`,s.accent),children:[(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1 normal-case tracking-normal`,children:[(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2 uppercase tracking-[0.6px]`,children:[(0,$.jsx)(st,{"aria-hidden":`true`,className:`size-4 shrink-0`}),s.label]}),i]}),c===void 0?null:(0,$.jsx)(`span`,{className:`shrink-0 font-normal tracking-normal normal-case`,children:(0,$.jsx)(qr,{ts:r})})]}),(0,$.jsx)(`div`,{className:o(`min-w-0 break-words text-[14px] text-foreground select-text [overflow-wrap:anywhere]`,s.body,`leading-[1.6]`),children:t})]})}var ei=[],ti=(0,Q.memo)(function({text:e,imageCount:t=0,images:n=ei,ts:r,onEdit:a,onRemove:o,editLabel:s=`Edit message`,removeLabel:c=`Remove message`,children:l}){let u=t-n.length,[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(e),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(),y=()=>{m(e),v(void 0),f(!0)},b=async()=>{let t=p.trim();if(!t||t===e){f(!1);return}g(!0),v(void 0);try{await a?.(t),f(!1)}catch(e){v(e instanceof Error?e.message:`Could not save the message`)}finally{g(!1)}},x=async()=>{g(!0),v(void 0);try{await o?.()}catch(e){v(e instanceof Error?e.message:`Could not remove the message`)}finally{g(!1)}};return d?(0,$.jsxs)($r,{role:`user`,ts:r,"data-slot":`user-bubble`,"data-editing":`true`,children:[(0,$.jsx)(`textarea`,{autoFocus:!0,"aria-label":`Edit the message`,value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.stopPropagation(),f(!1)):e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),b())},className:`block max-h-[220px] min-h-[60px] w-full resize-none rounded-md bg-background px-2 py-1.5 text-[14px] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}),(0,$.jsxs)(`span`,{className:`mt-1.5 flex justify-end gap-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>f(!1),disabled:h,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm px-2 text-xs font-medium text-muted-foreground hover:bg-background hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:`Cancel`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void b(),disabled:h,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm bg-action px-2 text-xs font-semibold text-action-foreground hover:brightness-[0.96] focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:h?(0,$.jsx)(ot,{className:`size-3.5 animate-spin`}):`Save`})]}),_?(0,$.jsx)(`p`,{role:`alert`,className:`mt-1.5 text-xs text-danger`,children:_}):null]}):(0,$.jsxs)($r,{role:`user`,ts:r,"data-slot":`user-bubble`,className:`group`,children:[a||o?(0,$.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`mb-1 flex justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100`,children:[a?(0,$.jsx)(`button`,{type:`button`,"aria-label":s,onClick:y,disabled:h,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,$.jsx)(Bn,{className:`size-3.5`})}):null,o?(0,$.jsx)(`button`,{type:`button`,"aria-label":c,onClick:()=>void x(),disabled:h,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-danger focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,$.jsx)(Ae,{className:`size-3.5`})}):null]}):null,_?(0,$.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:_}):null,l??(0,$.jsx)(An,{breaks:!0,children:e}),n.length>0?(0,$.jsx)(`span`,{"data-slot":`user-images`,className:`mt-2 flex flex-wrap items-center justify-end gap-1.5`,children:n.map(e=>O(e.split(`/`).pop()??``)?(0,$.jsx)(En,{src:e,alt:`attached`,className:`max-h-40 max-w-[220px] rounded-md border border-border object-contain`},e):(0,$.jsxs)(`a`,{href:i(e),download:!0,"data-slot":`user-file`,className:`inline-flex min-h-11 min-w-11 max-w-[220px] items-center gap-1.5 rounded-md border border-border bg-background/60 px-2 py-1 text-xs text-muted-foreground hover:text-foreground`,children:[(0,$.jsx)(De,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.split(`/`).pop()})]},e))}):null,u>0?(0,$.jsxs)(`span`,{className:`mt-1 block text-xs text-soft-foreground`,children:[u,` image`,u>1?`s`:``,` attached`]}):null]})}),ni=`inline-flex h-11 min-w-11 items-center justify-center gap-1 rounded-sm px-2 text-xs font-medium text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,ri=[`[data-streamdown="code-block-actions"]`,`[data-streamdown="code-copy-button"]`,`[data-streamdown="code-block-copy-button"]`,`[data-streamdown="code-block-header"]`].join(`,`);function ii(e,t){let n=e.cloneNode(!0);n.querySelectorAll(ri).forEach(e=>e.remove());let r=Qn(t);return[...n.querySelectorAll(`button[data-streamdown="link"]`)].forEach(e=>{let t=e.textContent??``,i=r.findIndex(e=>e.label===t);if(i<0)return;let a=r.splice(i,1)[0];if(!a||!Zn(a.href))return;let o=n.ownerDocument.createElement(`a`);o.setAttribute(`href`,a.href),o.setAttribute(`data-streamdown`,`link`),o.textContent=e.textContent,e.replaceWith(o)}),n.innerHTML}async function ai(e,t,n){if(e===`markdown`){if(!navigator.clipboard?.writeText)throw Error(`Clipboard unavailable`);await navigator.clipboard.writeText(t);return}if(!navigator.clipboard?.write||typeof ClipboardItem>`u`||!n)throw Error(`Clipboard unavailable`);let r=ii(n,t);await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([r],{type:`text/html`}),"text/plain":new Blob([t],{type:`text/plain`})})])}var oi=(0,Q.memo)(function({text:e,ts:t,messageKey:n}){let r=(0,Q.useRef)(null),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(null),c=(0,Q.useRef)(null);(0,Q.useEffect)(()=>()=>{c.current!==null&&clearTimeout(c.current)},[]);let l=async t=>{c.current!==null&&clearTimeout(c.current),a(null),s(null);try{await ai(t,e,r.current),a(t),c.current=setTimeout(()=>a(null),2e3)}catch{s(`Couldn't copy to the clipboard`)}};return(0,$.jsxs)($r,{role:`agent`,ts:t,"data-slot":`assistant-message`,headerActions:(0,$.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`flex items-center gap-0.5`,children:[(0,$.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply`,onClick:()=>void l(`html`),className:ni,children:[(0,$.jsx)(Ge,{className:`size-3.5`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{"aria-live":`polite`,children:i===`html`?`Copied`:`Copy`})]}),(0,$.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply as markdown`,onClick:()=>void l(`markdown`),className:ni,children:[(0,$.jsx)(Ft,{className:`size-3.5`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{"aria-live":`polite`,children:i===`markdown`?`Copied`:`Copy markdown`})]})]}),children:[o?(0,$.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:o}):null,(0,$.jsx)(`div`,{ref:r,children:(0,$.jsx)(An,{breaks:!0,children:e})}),(0,$.jsx)(rr,{text:e,messageKey:n})]})});function si({incident:e}){let t=s().data;if(!t)return null;let n=c(t,e.provider);return(0,$.jsxs)(`div`,{role:`alert`,"data-slot":`provider-auth-required`,className:`rounded-md border border-danger/30 bg-danger/5 px-3.5 py-3`,children:[(0,$.jsxs)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:[`This run needed `,n,` authorization`]}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Review `,n,` settings before retrying.`]}),(0,$.jsx)(X,{to:`/settings/agent-defaults#providers`,className:`mt-2 inline-flex text-xs font-medium text-foreground underline-offset-2 hover:underline`,children:`Open provider settings`})]})}var ci=(0,Q.memo)(function({text:e}){let t=(0,Q.useId)();if(e.trim()===``)return null;let n=e.split(`
2
2
  `,1)[0]??``,r=n.length<e.length;return(0,$.jsxs)(Y,{"data-slot":`reasoning`,className:`group/reasoning min-w-0`,children:[(0,$.jsxs)(`div`,{id:t,className:`relative flex w-full items-center gap-1.5 rounded-md p-0.5 text-left text-[13px] text-soft-foreground hover:text-muted-foreground`,children:[(0,$.jsx)(W,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/reasoning:rotate-90`}),(0,$.jsx)(`span`,{className:`shrink-0`,children:`Thinking — `}),(0,$.jsx)(`div`,{className:`min-w-0 truncate text-muted-foreground`,children:(0,$.jsx)(An,{inline:!0,children:n})}),r?(0,$.jsx)(`span`,{"aria-hidden":!0,children:`…`}):null,(0,$.jsx)(J,{"aria-labelledby":t,className:`absolute inset-0 rounded-md focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`})]}),(0,$.jsx)(q,{children:(0,$.jsx)(`div`,{className:`px-6 py-1.5 text-[13px] leading-[1.6] text-soft-foreground`,children:(0,$.jsx)(An,{children:e})})})]})});function li(){return(0,$.jsxs)(`div`,{"data-slot":`working-indicator`,className:`flex items-center gap-2 py-1 text-[13px] text-soft-foreground`,children:[(0,$.jsx)(ot,{role:`status`,"aria-label":`Working`,className:`size-3.5 shrink-0 animate-spin`}),(0,$.jsx)(`span`,{className:`shimmer font-medium`,children:`Working…`})]})}var ui={read:Ft,edit:Bn,delete:Ae,move:Rn,search:Oe,execute:xt,think:Fn,fetch:at,task:Ue,plan:Te,other:Me},di=e=>e.split(`
3
3
  `).length;function fi({text:e,streaming:t}){let[n,r]=(0,Q.useState)(!1),i=(0,Q.useRef)(null),a=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{let e=i.current;t&&e&&a.current&&(e.scrollTop=e.scrollHeight)},[e,t]);let s=di(e),c=!t&&!n&&s>12;return(0,$.jsxs)(`div`,{"data-slot":`tool-output`,"data-clamped":c?`true`:void 0,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`div`,{ref:i,onScroll:t?e=>{a.current=Er(e.currentTarget)}:void 0,className:o(`overflow-x-auto`,t&&`max-h-[216px] overflow-y-auto`,c&&`max-h-[216px] overflow-y-hidden`),children:(0,$.jsx)(`pre`,{className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre text-muted-foreground`,children:e})}),c?(0,$.jsx)(`div`,{"data-slot":`tool-output-fade`,"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-0 h-14 bg-gradient-to-b from-transparent to-card-2`}):null]}),!t&&s>12?(0,$.jsx)(`button`,{type:`button`,"data-slot":`tool-output-toggle`,onClick:()=>r(e=>!e),className:`block w-full border-t border-border/50 px-4 py-1.5 text-left text-[11px] font-medium text-soft-foreground hover:text-foreground`,children:n?`Show less`:`Show all ${s} lines`}):null]})}function pi({diffs:e}){return(0,$.jsx)($.Fragment,{children:e.map((e,t)=>(0,$.jsxs)(`div`,{"data-slot":`diff-preview`,className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`border-b border-border/50 px-4 py-1.5 font-mono text-[11px] wrap-anywhere text-muted-foreground`,children:e.path}),(0,$.jsx)(`pre`,{className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7] whitespace-pre`,children:e.unified===void 0?[...mi(e.oldText).map((e,t)=>(0,$.jsxs)(`span`,{className:`block bg-diff-del px-4 text-muted-foreground`,children:[`- `,e]},`old-${t}`)),...mi(e.newText).map((e,t)=>(0,$.jsxs)(`span`,{className:`block bg-diff-add px-4`,children:[`+ `,e]},`new-${t}`))]:e.unified.split(`
4
4
  `).map((e,t)=>(0,$.jsx)(hi,{text:e},t))})]},`${e.path}:${t}`))})}function mi(e){return e==null||e===``?[]:e.replace(/\n$/,``).split(`
@@ -1 +1 @@
1
- import{Qn as e}from"./project-scope-context-C912rTJP.js";import{C as t,f as n,o as r}from"./task-groups-B3Z2qfE6.js";function i(e){if(e.workflow===`(planned)`||e.workflow===`(inbox)`){let t=(e.steps??[]).find(e=>e.kind===`agent`);if(t?.name)return t.name}return e.workflow}function a(e){let t=/\/(\d+)\/?$/.exec(e.trim()),n=t?Number(t[1]):NaN;return Number.isInteger(n)&&n>0?n:null}function o(e){let t=new Set;for(let n of[e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl]){let e=n?a(n):null;e!==null&&t.add(e)}for(let n of[e.prNumber,e.issueNumber,e.markerRefs?.pr,e.markerRefs?.issue])typeof n==`number`&&Number.isInteger(n)&&n>0&&t.add(n);for(let n of e.pullRequests??[])t.add(n.number);return[...t]}var s=[{id:`title`,kind:`text`,scopes:[`stored`],source:`summary`,texts:e=>[e.title]},{id:`titleSummary`,kind:`text`,scopes:[`stored`],source:`summary`,texts:e=>[e.titleSummary]},{id:`displayTitle`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>[t.displayTitle]},{id:`branch`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.branch]},{id:`workflow`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.workflow]},{id:`workflowLabel`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.workflowLabel]},{id:`automation`,kind:`text`,scopes:[`stored`,`shown`],source:`reader`,texts:(e,t)=>[t.automation],universe:e=>[...e.automationNames?.values()??[]]},{id:`projectName`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>[t.projectName]},{id:`tags`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>t.tags??[]},{id:`id`,kind:`identifier`,scopes:[`stored`],source:`summary`,texts:e=>[e.id]},{id:`urls`,kind:`link`,scopes:[`stored`],source:`summary`,texts:e=>[e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl,...(e.pullRequests??[]).map(e=>e.url)]},{id:`heldReferences`,kind:`reference`,scopes:[`stored`],source:`summary`,numbers:o},{id:`shownReferences`,kind:`reference`,scopes:[`shown`],source:`reader`,numbers:(e,t)=>t.references?.()??[]}];function c(e){return e.trim().toLowerCase().split(/\s+/).filter(e=>e!==``)}function l(e,t){return t&&e.automationId!==void 0?t.get(e.automationId)??e.automationId:void 0}function u(e,t){let n=t.scope??`stored`,r=t.scope===`shown`?t.extras:{automation:l(e,t.automationNames)},i=[],a=[],o=[],c={text:i,identifier:a,link:o},u=[];for(let t of s)if(t.scopes.includes(n)){if(t.kind===`reference`){u.push(()=>t.numbers(e,r));continue}for(let n of t.texts(e,r))typeof n==`string`&&c[t.kind].push(n.toLowerCase())}let d;return{prose:i,ids:a,links:o,references:()=>d??=new Set(u.flatMap(e=>e().map(String)))}}function d(e,t,n={}){let r=c(t);if(r.length===0)return!1;let{prose:i,ids:a,links:o,references:s}=u(e,n);return r.every(e=>{if(i.some(t=>t.includes(e)))return!0;let t=e.replace(/^#/,``);return/^\d+$/.test(t)?s().has(String(Number(t)))||a.some(e=>e.startsWith(t)):a.some(t=>t.includes(e))||o.some(t=>t.includes(e))})}var f=new Set([`running`,`waiting`]);function p(e){return e?e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${Math.round(e/1024**2)} MB`:`${Math.round(e/1024)} kB`:``}function m(e){return e===void 0?``:`$${e>=10?e.toFixed(0):e.toFixed(2)}`}function h(t,n=new Date){if(!e(t))return;let r=new Date(t.autoResumeAt);if(!Number.isFinite(r.getTime()))return;let i=r.toDateString()===n.toDateString(),a=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}).format(r);return{label:i?a:`${new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(r)} ${a}`,title:`Resumes automatically at ${new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(r)}`}}function g(e){return e.steps?i({workflow:e.workflow,steps:e.steps}):e.workflowLabel??e.workflow}function _(e,t,i=()=>``){let a=e.filter(e=>!r(e));return t.trim()?a.filter(e=>d(e,t,{scope:`shown`,extras:{displayTitle:n(e),automation:i(e),references:()=>v(e)}})):[...a]}function v(e){return T(e).map(e=>e.number)}function y(e,n){return e.filter(e=>t(e,n)).length}function b(e){return y(e)}function x(e){return S(e)[0]??e.pullRequests?.find(e=>e.url)?.url}function S(e){let t=[];return e.pullRequestUrl&&t.push(e.pullRequestUrl),!(e.markerRefs?.issue!==void 0&&e.markerRefs?.pr===void 0)&&e.referencedPullRequestUrl&&t.push(e.referencedPullRequestUrl),t}function C(e,t){if(e.referencedIssueUrl)return e.referencedIssueUrl;let n=e.issueNumber??e.markerRefs?.issue;if(!(!n||!t))return`${t}/issues/${n}`}function w(e){let t=`${e.kind}#${e.number}`;if(!e.url)return`${t}@project:${e.projectId??`default`}`;try{let n=new URL(e.url),r=n.pathname.split(`/`).filter(Boolean).slice(0,2).join(`/`);return`${t}@${n.host.toLowerCase()}/${r.toLowerCase()}`}catch{return`${t}@${e.url}`}}function T(e,t,n=e.projectId){let r=S(e),i=e.markerRefs?.pr,a=[...i===void 0||[...r,...(e.pullRequests??[]).flatMap(e=>e.url?[e.url]:[])].some(e=>M(e)===String(i))?[]:[{kind:`PR`,number:i}],...r.map(e=>({kind:`PR`,url:e})),{kind:`PR`,number:e.prNumber},...(e.pullRequests??[]).map(e=>({kind:`PR`,number:e.number,...e.url?{url:e.url}:{},authoritative:!0})),{kind:`Issue`,url:C(e,t)},{kind:`Issue`,number:e.issueNumber}],o=new Set,s=[];for(let e of a){let r=e.url?Number(M(e.url)):e.number;if(!r||!Number.isInteger(r)||!e.url&&!e.authoritative&&s.some(t=>t.url&&t.kind===e.kind&&t.number===r))continue;let i=e.url??E(e.kind,r,t),a={kind:e.kind,number:r,...i?{url:i}:n===void 0?{}:{projectId:n}},c=w(a);o.has(c)||(o.add(c),s.push(a))}return s}function E(e,t,n){if(n)return`${n}/${e===`PR`?`pull`:`issues`}/${t}`}function D(e){return T(e)[0]}function O(e,t){if(!e.url)return!0;if(!t)return!1;let n=k(t);return n!==void 0&&k(e.url)===n}function k(e){try{let t=new URL(e),[n,r]=t.pathname.split(`/`).filter(Boolean);return n&&r?`${t.host}/${n}/${r}`.toLowerCase():void 0}catch{return}}function A(e,t){let n=[];for(let r of T(e,t)){if(!O(r,t))continue;let e=r.kind===`PR`?`pr`:`issue`;n.some(t=>t.kind===e&&t.number===r.number)||n.push({kind:e,number:r.number})}return n}function j(e,t,n,r){if(O(n,r))return`/p/${e}/tasks/${t}/${n.kind===`PR`?`pr`:`issue`}/${n.number}`}function M(e){return/\/(\d+)\/?(?:[?#].*)?$/.exec(e)?.[1]??null}function N(e,t){let n=f.has(e.status)?t:void 0;if(n)return{cpu:{text:`${n.cpuPct.toFixed(0)}%`,kind:`live`},mem:{text:p(n.rssBytes),kind:`live`}};let r=p(e.peakRssBytes);return{cpu:{text:``,kind:`none`},mem:r?{text:`peak ${r}`,kind:`peak`,title:`peak — run finished${e.peakProcCount?` · ${e.peakProcCount} procs`:``}`}:{text:``,kind:`none`}}}export{N as _,O as a,h as c,C as d,j as f,T as g,D as h,p as i,v as l,x as m,b as n,M as o,A as p,m as r,w as s,_ as t,y as u,g as v,d as y};
1
+ import{Qn as e}from"./project-scope-context-BdqKyBHa.js";import{C as t,f as n,o as r}from"./task-groups-BbnYlkYj.js";function i(e){if(e.workflow===`(planned)`||e.workflow===`(inbox)`){let t=(e.steps??[]).find(e=>e.kind===`agent`);if(t?.name)return t.name}return e.workflow}function a(e){let t=/\/(\d+)\/?$/.exec(e.trim()),n=t?Number(t[1]):NaN;return Number.isInteger(n)&&n>0?n:null}function o(e){let t=new Set;for(let n of[e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl]){let e=n?a(n):null;e!==null&&t.add(e)}for(let n of[e.prNumber,e.issueNumber,e.markerRefs?.pr,e.markerRefs?.issue])typeof n==`number`&&Number.isInteger(n)&&n>0&&t.add(n);for(let n of e.pullRequests??[])t.add(n.number);return[...t]}var s=[{id:`title`,kind:`text`,scopes:[`stored`],source:`summary`,texts:e=>[e.title]},{id:`titleSummary`,kind:`text`,scopes:[`stored`],source:`summary`,texts:e=>[e.titleSummary]},{id:`displayTitle`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>[t.displayTitle]},{id:`branch`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.branch]},{id:`workflow`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.workflow]},{id:`workflowLabel`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.workflowLabel]},{id:`automation`,kind:`text`,scopes:[`stored`,`shown`],source:`reader`,texts:(e,t)=>[t.automation],universe:e=>[...e.automationNames?.values()??[]]},{id:`projectName`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>[t.projectName]},{id:`tags`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>t.tags??[]},{id:`id`,kind:`identifier`,scopes:[`stored`],source:`summary`,texts:e=>[e.id]},{id:`urls`,kind:`link`,scopes:[`stored`],source:`summary`,texts:e=>[e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl,...(e.pullRequests??[]).map(e=>e.url)]},{id:`heldReferences`,kind:`reference`,scopes:[`stored`],source:`summary`,numbers:o},{id:`shownReferences`,kind:`reference`,scopes:[`shown`],source:`reader`,numbers:(e,t)=>t.references?.()??[]}];function c(e){return e.trim().toLowerCase().split(/\s+/).filter(e=>e!==``)}function l(e,t){return t&&e.automationId!==void 0?t.get(e.automationId)??e.automationId:void 0}function u(e,t){let n=t.scope??`stored`,r=t.scope===`shown`?t.extras:{automation:l(e,t.automationNames)},i=[],a=[],o=[],c={text:i,identifier:a,link:o},u=[];for(let t of s)if(t.scopes.includes(n)){if(t.kind===`reference`){u.push(()=>t.numbers(e,r));continue}for(let n of t.texts(e,r))typeof n==`string`&&c[t.kind].push(n.toLowerCase())}let d;return{prose:i,ids:a,links:o,references:()=>d??=new Set(u.flatMap(e=>e().map(String)))}}function d(e,t,n={}){let r=c(t);if(r.length===0)return!1;let{prose:i,ids:a,links:o,references:s}=u(e,n);return r.every(e=>{if(i.some(t=>t.includes(e)))return!0;let t=e.replace(/^#/,``);return/^\d+$/.test(t)?s().has(String(Number(t)))||a.some(e=>e.startsWith(t)):a.some(t=>t.includes(e))||o.some(t=>t.includes(e))})}var f=new Set([`running`,`waiting`]);function p(e){return e?e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${Math.round(e/1024**2)} MB`:`${Math.round(e/1024)} kB`:``}function m(e){return e===void 0?``:`$${e>=10?e.toFixed(0):e.toFixed(2)}`}function h(t,n=new Date){if(!e(t))return;let r=new Date(t.autoResumeAt);if(!Number.isFinite(r.getTime()))return;let i=r.toDateString()===n.toDateString(),a=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}).format(r);return{label:i?a:`${new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(r)} ${a}`,title:`Resumes automatically at ${new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(r)}`}}function g(e){return e.steps?i({workflow:e.workflow,steps:e.steps}):e.workflowLabel??e.workflow}function _(e,t,i=()=>``){let a=e.filter(e=>!r(e));return t.trim()?a.filter(e=>d(e,t,{scope:`shown`,extras:{displayTitle:n(e),automation:i(e),references:()=>v(e)}})):[...a]}function v(e){return T(e).map(e=>e.number)}function y(e,n){return e.filter(e=>t(e,n)).length}function b(e){return y(e)}function x(e){return S(e)[0]??e.pullRequests?.find(e=>e.url)?.url}function S(e){let t=[];return e.pullRequestUrl&&t.push(e.pullRequestUrl),!(e.markerRefs?.issue!==void 0&&e.markerRefs?.pr===void 0)&&e.referencedPullRequestUrl&&t.push(e.referencedPullRequestUrl),t}function C(e,t){if(e.referencedIssueUrl)return e.referencedIssueUrl;let n=e.issueNumber??e.markerRefs?.issue;if(!(!n||!t))return`${t}/issues/${n}`}function w(e){let t=`${e.kind}#${e.number}`;if(!e.url)return`${t}@project:${e.projectId??`default`}`;try{let n=new URL(e.url),r=n.pathname.split(`/`).filter(Boolean).slice(0,2).join(`/`);return`${t}@${n.host.toLowerCase()}/${r.toLowerCase()}`}catch{return`${t}@${e.url}`}}function T(e,t,n=e.projectId){let r=S(e),i=e.markerRefs?.pr,a=[...i===void 0||[...r,...(e.pullRequests??[]).flatMap(e=>e.url?[e.url]:[])].some(e=>M(e)===String(i))?[]:[{kind:`PR`,number:i}],...r.map(e=>({kind:`PR`,url:e})),{kind:`PR`,number:e.prNumber},...(e.pullRequests??[]).map(e=>({kind:`PR`,number:e.number,...e.url?{url:e.url}:{},authoritative:!0})),{kind:`Issue`,url:C(e,t)},{kind:`Issue`,number:e.issueNumber}],o=new Set,s=[];for(let e of a){let r=e.url?Number(M(e.url)):e.number;if(!r||!Number.isInteger(r)||!e.url&&!e.authoritative&&s.some(t=>t.url&&t.kind===e.kind&&t.number===r))continue;let i=e.url??E(e.kind,r,t),a={kind:e.kind,number:r,...i?{url:i}:n===void 0?{}:{projectId:n}},c=w(a);o.has(c)||(o.add(c),s.push(a))}return s}function E(e,t,n){if(n)return`${n}/${e===`PR`?`pull`:`issues`}/${t}`}function D(e){return T(e)[0]}function O(e,t){if(!e.url)return!0;if(!t)return!1;let n=k(t);return n!==void 0&&k(e.url)===n}function k(e){try{let t=new URL(e),[n,r]=t.pathname.split(`/`).filter(Boolean);return n&&r?`${t.host}/${n}/${r}`.toLowerCase():void 0}catch{return}}function A(e,t){let n=[];for(let r of T(e,t)){if(!O(r,t))continue;let e=r.kind===`PR`?`pr`:`issue`;n.some(t=>t.kind===e&&t.number===r.number)||n.push({kind:e,number:r.number})}return n}function j(e,t,n,r){if(O(n,r))return`/p/${e}/tasks/${t}/${n.kind===`PR`?`pr`:`issue`}/${n.number}`}function M(e){return/\/(\d+)\/?(?:[?#].*)?$/.exec(e)?.[1]??null}function N(e,t){let n=f.has(e.status)?t:void 0;if(n)return{cpu:{text:`${n.cpuPct.toFixed(0)}%`,kind:`live`},mem:{text:p(n.rssBytes),kind:`live`}};let r=p(e.peakRssBytes);return{cpu:{text:``,kind:`none`},mem:r?{text:`peak ${r}`,kind:`peak`,title:`peak — run finished${e.peakProcCount?` · ${e.peakProcCount} procs`:``}`}:{text:``,kind:`none`}}}export{N as _,O as a,h as c,C as d,j as f,T as g,D as h,p as i,v as l,x as m,b as n,M as o,A as p,m as r,w as s,_ as t,y as u,g as v,d as y};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./react-runtime-CCIEwYL0.js";import{t}from"./utils-DSMR_WLb.js";import{$r as n,mr as r,pr as i}from"./project-scope-context-C912rTJP.js";import{_ as a,g as o,h as s,k as c,p as l,v as ee}from"./live-protocol-DMhTnCmf.js";import{t as te}from"./createLucideIcon-BHp8sXmF.js";import{t as ne}from"./app-window-CSHwDX9N.js";import{t as re}from"./play-CmVAj_fu.js";import{t as ie}from"./square-terminal-B6RYYieR.js";import{t as ae}from"./button-B7MKxYjT.js";import{t as oe}from"./status-dot-BRzVlF2X.js";import{a as se,o as ce}from"./format-BU7D3IfE.js";import{$n as le,f as ue,p as de}from"./index-DaJ5iats.js";var fe=te(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),pe=te(`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`}]]),u=e(),me={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 he(e){let{text:t,...n}=de(e),r={...n,status:t},i=me[e.state](e);return i?{...r,action:i}:r}var ge={"Run and open":re,Open:ne,View:le,"Start again":fe};function _e({entry:e,inPreview:n,onOpen:r}){let{server:i}=e,a=he(e),o=e.state===`unavailable`,s=r?a.action:void 0,c=ue(i.command),l=se(i.registeredAt);return(0,u.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,u.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2 text-xs text-soft-foreground`,children:[(0,u.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 font-mono`,children:[(0,u.jsx)(pe,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,u.jsx)(`span`,{className:`truncate`,children:`cezar_preview_serve`})]}),o?(0,u.jsx)(`span`,{children:`worktree removed`}):l?(0,u.jsx)(`span`,{children:ce(l)}):null]}),(0,u.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-2`,children:[(0,u.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,u.jsx)(oe,{tone:a.tone,shape:a.ring?`ring`:`filled`,pulse:a.pulse===!0,"aria-hidden":`true`}),(0,u.jsx)(`span`,{className:`font-semibold text-foreground`,children:i.label}),(0,u.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,i.port]}),(0,u.jsx)(`span`,{className:`text-muted-foreground`,children:a.status})]}),(0,u.jsx)(ve,{entry:e,inPreview:n,action:s,onOpen:r})]}),(0,u.jsxs)(`div`,{className:`mt-2.5 min-w-0 rounded-md bg-muted px-3 py-2 font-mono text-xs`,children:[(0,u.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-foreground`,children:i.command}),i.cwd?(0,u.jsxs)(`p`,{className:`mt-1 flex gap-3 text-soft-foreground`,children:[(0,u.jsx)(`span`,{children:`cwd`}),(0,u.jsx)(`span`,{className:`break-all`,children:i.cwd})]}):null]}),s?.run?(0,u.jsx)(d,{icon:(0,u.jsx)(ie,{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,u.jsx)(d,{children:`The worktree this server ran in is gone. Register it again from a new task.`}):null]})}function ve({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?ne:n?ge[n.label]:null;return n&&o&&s?(0,u.jsxs)(ae,{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,u.jsx)(s,{"aria-hidden":`true`}),o]}):null}function d({icon:e,children:t}){return(0,u.jsxs)(`p`,{className:`mt-2.5 flex items-start gap-2 text-xs text-muted-foreground`,children:[e,(0,u.jsx)(`span`,{children:t})]})}function f(e,t){return e.kind===`message`&&e.role===`user`&&e.skillInput?.source===t&&typeof e.skillInput.id==`string`&&e.skillInput.id!==``}var p=120;function m(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function h(e){let t=e.replace(/\s+/g,` `).trim();return t.length>p?`${t.slice(0,p-1)}…`:t}var g=e=>e===void 0?void 0:h(e);function _(e,...t){if(m(e))for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim()!==``)return t}}function v(e,...t){return g(_(e,...t))}function ye(e){if(!m(e))return;let t=e.command;if(typeof t==`string`&&t.trim()!==``)return t;if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return e.join(` `)}}function y(e){if(!m(e)||!Array.isArray(e.changes))return[];let t=[];for(let n of e.changes)m(n)&&typeof n.path==`string`&&n.path.trim()!==``&&t.push(n.path);return t}function b(e){return v(e,`description`,`query`,`url`,`filePath`,`file_path`,`path`,`pattern`,`name`)}function x(e,t){return t?`${e} ${t}`:e}var S=new Map([[`bash`,`execute`],[`commandexecution`,`execute`],[`edit`,`edit`],[`multiedit`,`edit`],[`write`,`edit`],[`notebookedit`,`edit`],[`filechange`,`edit`],[`read`,`read`],[`imageview`,`read`],[`glob`,`search`],[`grep`,`search`],[`webfetch`,`fetch`],[`websearch`,`fetch`],[`task`,`task`],[`agent`,`task`],[`skill`,`task`],[`spawnagent`,`task`],[`subtask`,`task`],[`todowrite`,`plan`],[`todolist`,`plan`],[`plan`,`plan`],[`taskcreate`,`plan`],[`taskupdate`,`plan`],[`tasklist`,`plan`],[`contextcompaction`,`other`],[`mcptoolcall`,`other`]]);function C(e,t){switch(e){case`notebookedit`:return _(t,`notebook_path`,`notebookPath`,`file_path`,`filePath`,`path`);case`filechange`:{let e=y(t);return e.length===1?e[0]:void 0}default:return _(t,`file_path`,`filePath`,`path`)}}function be(e,t){let n=e===`write`?`Write`:`Edit`;if(e!==`filechange`)return{toolKind:`edit`,title:x(n,g(C(e,t)))};let r=y(t);return{toolKind:`edit`,title:x(n,r.length>1?`${r.length} files`:r[0])}}function w(e,t){return e===`imageview`?_(t,`path`):_(t,`file_path`,`filePath`,`path`)}function xe(e,t){return{toolKind:`read`,title:x(e===`imageview`?`View image`:`Read`,g(w(e,t)))}}function T(e){return _(e,`pattern`,`query`)}function E(e,t){return e===`webfetch`?_(t,`url`):_(t,`query`)}function Se(e,t){return{toolKind:`fetch`,title:x(e===`webfetch`?`Fetch`:`Web search`,g(E(e,t)))}}var D=e=>_(e,`skill`,`name`,`command`),O=e=>_(e,`subagent_type`,`subagentType`);function Ce(e,t){return e===`skill`?D(t):_(t,`prompt`,`task`,`description`)??O(t)}function we(e,t){if(e===`skill`){let e=g(D(t));return{toolKind:`task`,title:e?`Skill: ${e}`:`Skill`,subtitle:v(t,`args`,`description`)}}let n=e===`agent`?`Agent`:`Task`,r=g(O(t)),i=v(t,`description`,`prompt`)??r;return{toolKind:`task`,title:i?`${n}: ${i}`:n,subtitle:i===r?void 0:r}}function Te(e,t,n){if(t===`contextcompaction`)return{toolKind:`other`,title:`Compacted context`};if(t===`mcptoolcall`){let e=v(n,`server`),t=v(n,`tool`);return e&&t?{toolKind:`other`,title:`${e}.${t}`}:{toolKind:`other`,title:`MCP tool`,subtitle:b(n)}}if(t.startsWith(`mcp__`)){let t=e.split(`__`).filter(e=>e!==``);if(t.length>=3)return{toolKind:`other`,title:`${t[1]}.${t.slice(2).join(`__`)}`}}return{toolKind:`other`,title:typeof e==`string`&&e.trim()!==``?h(e):`Tool`,subtitle:b(n)}}function k(e,t){let n=typeof e==`string`?e.toLowerCase():``;switch(S.get(n)){case`execute`:return{toolKind:`execute`,title:x(`Ran`,g(ye(t))),subtitle:v(t,`description`)};case`edit`:return be(n,t);case`read`:return xe(n,t);case`search`:return{toolKind:`search`,title:x(`Search`,g(T(t))),subtitle:v(t,`path`)};case`fetch`:return Se(n,t);case`task`:return we(n,t);case`plan`:return{toolKind:`plan`,title:`Update plan`};default:return Te(e,n,t)}}function Ee(e,t){let n=typeof e==`string`?e.toLowerCase():``;switch(S.get(n)){case`execute`:return ye(t);case`edit`:return C(n,t);case`read`:return w(n,t);case`search`:return T(t);case`fetch`:return E(n,t);case`task`:return Ce(n,t);default:return}}function De(e,t){if(t.type===`ask.requested`&&typeof t.requestId==`string`&&c.safeParse({questions:t.questions}).success)return t;if(t.type===`human-input-delivered`||t.type===`human-ask-closed`){let n=(t.type===`human-input-delivered`?a:o).safeParse(t);if(n.success&&n.data.askSeq===e?.seq)return}return e}function Oe(e){if(!(e.type!==`ask.requested`||typeof e.requestId!=`string`))return{requestId:e.requestId,questions:e.questions,...e.context===void 0?{}:{context:e.context}}}function ke(e){let t=Oe(e);return t&&{seq:e.seq,...t}}function Ae(e,t){let n=De(e&&{type:`ask.requested`,seq:e.seq,ts:``},t);return n===t?ke(t):n===void 0?void 0:e}function je(e){let t;for(let n of e)t=Ae(t,n);return t}function Me(e){let t=Array.isArray(e.questions)?e.questions.filter(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e.header==`string`&&(e.options===void 0||Array.isArray(e.options))):[];if(t.length===0)return;let n=typeof e.context==`string`&&e.context!==``?e.context:void 0;return{id:e.requestId,questions:t,...n===void 0?{}:{context:n},askSeq:e.seq}}function Ne(){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 A(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function j(e){return typeof e==`string`?e:void 0}function M(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 N(e){if(!(typeof e!=`string`||e===``))return Number.isFinite(new Date(e).getTime())?e:void 0}function Pe(e){return n.safeParse(e).data}function P(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 F(e){return e.turns.at(-1)??P(e)}function I(e,t){let n={origin:`meta`,entry:t,firstSeq:e.eventSeq,lastSeq:e.eventSeq};return F(e).entries.push(n),n}var Fe=[/^run failed\s+[—-]\s+/,/^continue failed(?:\s+[—-]\s+|:\s+)/,/^step\s+"[^"]+"\s+failed:\s+/,/^step\s+\S+\s+failed\s+[—-]\s+/],Ie=/^(?:run failed\s+[—-]\s+|continue failed(?:\s+[—-]\s+|:\s+))/;function L(e){return e.trim().replace(/\s+/g,` `)}function R(e){let t=e.trim(),n=!0;for(;n;){n=!1;for(let e of Fe){let r=t.replace(e,``).trim();r!==t&&r!==``&&(t=r,n=!0)}}return L(t)}function z(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 B(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 V(e,t,n){let r=F(e),i=B(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),z(i,n.source,n.text);return}let a={draft:I(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 Le(e,t,n){if(!Ie.test(n))return!1;let r=e.turns.at(-1);if(!r)return!1;let i=R(n);if(i===``)return!1;let a=B(r,i,j(t.stepId));return a?(a.draft.lastSeq=Math.max(a.draft.lastSeq,t.seq),a.fatal=!0,z(a,`lifecycle`,n),!0):!1}function Re(e,t,n){let r=e.turns.at(-1);if(!r)return;let i=B(r,n?R(n):``,j(t.stepId));i&&(i.fatal=!0)}function H(e){for(let t of e.permissions.values())t.status===`pending`&&(t.status=`expired`)}function U(e,t){let n=j(e.stepId);return n===void 0?t:`${n}:${t}`}function ze(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 Be(e,t,n,r,i,a=!1){let o=n.kind===`message`&&i!==void 0?{...n,ts:i}:{...n};!t.v2Items&&o.kind!==`hook`&&ze(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 W={"not-delivered":0,queued:1,delivered:2,consumed:3},Ve=[`instruction`,`resumed`,`requestId`,`relationship`,`state`,`createdAt`,`requestHash`,`deadline`];function G(e){let t={};for(let n of Ve)e[n]!==void 0&&Object.assign(t,{[n]:e[n]});return t}function K(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 He(e,t){let n=e.conversationEntries.get(t);n&&K(e,n)}function Ue(e,t,n,r){(W[e.delivery]<W.delivered||W[n]>W[e.delivery])&&(e.delivery=n),t.text!==``&&(e.text=t.text),Object.assign(e,G(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 q(e,t,n,r){let i=e.conversationEntries.get(t.id);if(i){Ue(i,t,n,r),K(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,...G(t)};K(e,a),e.conversationEntries.set(t.id,a),I(e,a)}function We(e,t){let n=M(t.ts),r=j(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,I(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=j(t.webhookName),i=`${r?`Delivery to ${r} failed`:`Webhook delivery failed`}${j(t.event)?` (${j(t.event)})`:``}${n?` after ${n} attempt${n===1?``:`s`}`:``}: ${j(t.error)??`unknown error`}`;I(e,{kind:`note`,id:`v1:${t.seq}`,text:i,tone:`danger`})}function Ke(e,t){let n=j(t.webhookName)??`webhook`,r=j(t.title),i=`v1:${t.seq}`;if(t.ok===!1){I(e,{kind:`note`,id:i,text:`Report to ${n} failed: ${j(t.error)??`unknown error`}`,tone:`danger`});return}let a=`${t.dryRun===!0?`Report to ${n} (dry run, nothing sent)`:`Sent report to ${n}`}${M(t.ts)}${r?` — ${r}`:``}`;I(e,t.dryRun===!0?{kind:`note`,id:i,text:a,tone:`dim`}:{kind:`note`,id:i,text:a,tone:`dim`,icon:`handoff`})}function qe(e,t){let n=t.payload??{},r=`Webhook (dry run, nothing sent): ${j(t.event)??`delivery`}${j(n.status)?` · ${j(n.status)}`:``}`;I(e,{kind:`note`,id:`v1:${t.seq}`,text:r,tone:`dim`})}function Je(e,t){let n=i.safeParse(t.server);if(!n.success)return;let r=e.previewByPort.get(n.data.port);r&&(r.turn.entries=r.turn.entries.filter(e=>e!==r.draft));let a=F(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 Ye(e,t){let n=r.safeParse(t.state),i=typeof t.port==`number`?e.previewByPort.get(t.port):void 0;if(!n.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:n.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=s.safeParse(t);if(!n.success)return;let{message:r,delivery:i,deliveredAt:a,consumedAt:o,ts:c}=n.data;q(e,r,i,{deliveredAt:a,consumedAt:o,recordedAt:c})}function Ze(e,t){let n=ee.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),He(e,r.requestId))}function Qe(e,t){let n=l.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){q(e,{id:r.id,text:r.text,createdAt:r.createdAt,...r.conversation},`delivered`,{deliveredAt:r.deliveredAt,recordedAt:n.data.ts});return}I(e,{kind:`note`,id:`agent-input:${r.id}`,text:r.text,tone:`dim`,attribution:{source:r.source,parentRunId:r.parentRunId}})}}function $e(e,t){let n=j(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=P(e,t.seq),a=N(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 et(e,t){let n=e.turns.at(-1),r=n&&n.turnId===void 0&&!n.v2Items?n:P(e,t.seq);r.turnId=j(t.turnId),r.startedAt??=N(t.ts)}function tt(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 nt(e,t){H(e);let n=tt(e,j(t.turnId));if(!n)return;let r=N(t.ts);n.completed={stopReason:j(t.stopReason)??`end_turn`,...typeof t.costUsd==`number`?{costUsd:t.costUsd}:{},...r===void 0?{}:{ts:r}}}var J=new Set([`message`,`reasoning`,`tool`,`hook`]),rt=e=>J.has(e.kind);function it(e){if(!(!A(e)||!J.has(e.kind)))return typeof e.id==`string`&&e.id!==``?e:void 0}function Y(e,t){let n=it(t.item);if(!n)return;let r=U(t,n.id),i=e.itemsById.get(r),a=t.type===`item.completed`,o=!a&&(n.kind===`message`||n.kind===`reasoning`);Be(e,i?.turn??F(e),n,r,a?N(t.ts):void 0,o)}function at(e,t){let n=e.itemsById.get(U(t,j(t.itemId)??``)),r=j(t.delta)??``;if(!n||r===``||!rt(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 ot(e,t){let n=F(e),r=j(t.text)??``;if(r===``)return;let i=N(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 st=new Set([`pending`,`in_progress`,`completed`,`cancelled`]);function ct(e){if(!A(e)||!Array.isArray(e.todos))return;let t=[];for(let n of e.todos){if(!A(n)||typeof n.content!=`string`)return;t.push({content:n.content,status:st.has(n.status)?n.status:`pending`,...typeof n.activeForm==`string`?{activeForm:n.activeForm}:{}})}return t}var lt=new Set([`subAgentActivity`,`collabAgentToolCall`,`collabToolCall`]);function ut(e,t){let n=F(e),r=j(t.tool)??`Tool`;if(n.v2Items||lt.has(r))return;let i=k(r,t.input),a=i.toolKind===`plan`?ct(t.input):void 0;a!==void 0&&(n.planEntries=a);let o={kind:`tool`,id:j(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 dt(e){if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e)}catch{return String(e)}}function ft(e,t){let n=e.itemsById.get(j(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=dt(t.result))}function pt(e,t,n,r){let i=j(t.message)??``;i!==``&&I(e,{kind:`note`,id:n,text:i,tone:r})}function mt(e,t){let n=j(t.message)??``;t.type===`lifecycle`&&n!==``&&Le(e,t,n)||pt(e,t,`v1:${t.seq}`,t.tone===`danger`?`danger`:`dim`)}function ht(e,t){let n=j(t.message)??``;n!==``&&V(e,t,{id:`v1:${t.seq}`,source:`error`,text:n,cause:R(n),stepId:j(t.stepId),fatal:!1})}function gt(e,t){let n=j(t.message)??``;n!==``&&V(e,t,{id:`v2:${t.seq}`,source:`session.error`,text:n,cause:R(n),stepId:j(t.stepId),fatal:t.fatal===!0})}function _t(e,t){if(t.status!==`failed`)return;let n=j(t.stepId),r=j(t.error),i=r?` — ${r}`:``;V(e,t,{id:`v1:${t.seq}`,source:`step-end`,text:`step ${n??`?`} failed${i}`,cause:r?R(r):``,stepId:n,fatal:!0})}function vt(e,t){let n=j(t.command)??`check`,r=typeof t.exitCode==`number`?t.exitCode:-1;I(e,{kind:`tool`,id:`v1:${t.seq}`,name:`check`,toolKind:`execute`,title:`Ran ${n}`,status:r===0?`completed`:`failed`,output:j(t.text)??``,exitCode:r})}function yt(e,t){let n=Pe(t.provider),r=j(t.authFailureId)??``;n===void 0||r.length<1||r.length>128||I(e,{kind:`provider-auth-required`,id:`v1:${t.seq}`,provider:n,authFailureId:r})}function bt(e,t){let n=j(t.url);if(n===void 0)return;let r={kind:`image`,id:`v1:${t.seq}`,url:n},i=j(t.name);i!==void 0&&(r.name=i),I(e,r)}function xt(e,t){Array.isArray(t.entries)&&(F(e).planEntries=t.entries)}function St(e,t){H(e);let n=j(t.reason)??`end_turn`,r=j(t.message);n===`error`&&Re(e,t,r),e.sessionEnded={reason:n,...r===void 0?{}:{message:r}}}var Ct=new Set([`allow_once`,`allow_always`,`reject_once`,`reject_always`]);function wt(e){return A(e)&&typeof e.id==`string`&&e.id!==``&&typeof e.label==`string`&&e.label!==``&&Ct.has(e.kind)}function Tt(e){if(!(!Array.isArray(e)||e.length===0||!e.every(wt)))return new Set(e.map(e=>e.id)).size===e.length?e:void 0}function Et(e,t){let n=j(t.requestId),r=j(t.title),i=Tt(t.options);if(!n||!r||e.permissions.has(n)||!i)return;let a=j(t.itemId),o=j(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),I(e,s)}function Dt(e,t){let n=e.permissions.get(j(t.requestId)??``);if(!n||n.status!==`pending`)return;let r=j(t.optionId);r!==void 0&&n.options.some(e=>e.id===r)?(n.status=`resolved`,n.optionId=r):n.status=`expired`;let i=j(t.reason);i!==void 0&&(n.reason=i)}function Ot(e,t){let n=ke(t),r=n&&Me(n);if(!r)return;let i={kind:`ask`,...r,questions:r.questions,resolved:!1};I(e,i),e.pendingAsk=i}function X(e,t){let n=e.pendingAsk;return n&&!n.resolved&&n.askSeq===t.askSeq?n:void 0}function kt(e,t){let n=X(e,t);if(!n)return;n.routedToParent=!0;let r=j(t.parentRunId);r!==void 0&&(n.parentRunId=r)}function At(e,t){let n=X(e,t);n&&(n.routedToParent=!1)}function jt(e,t){let n=X(e,t);n&&Z(e,n,`undeliverable`)}var Mt=new Set([`finish`,`superseded`,`parent-stopped`,`worker-stopped`,`undeliverable`]);function Nt(e,t){let n=X(e,t);n&&Mt.has(t.reason)&&Z(e,n,t.reason)}function Z(e,t,n){t.resolved=!0,t.closed=n,e.pendingAsk=void 0}function Pt(e,t){let n=X(e,t);if(n){if(t.source===`cezar`){Z(e,n,`undeliverable`);return}t.source===`parent`&&(n.resolved=!0,n.answeredBy=`parent`,e.pendingAsk=void 0)}}var Q=()=>{},Ft=new Map([[`handoff`,We],[`webhook.failed`,Ge],[`webhook.dry-run`,qe],[`webhook.report`,Ke],[`preview.server-registered`,Je],[`preview.server-state`,Ye],[`conversation-message`,Xe],[`request-outcome`,Ze],[`agent-input`,Qe],[`user-message`,$e],[`turn.started`,et],[`turn.completed`,nt],[`item.started`,Y],[`item.updated`,Y],[`item.completed`,Y],[`item.delta`,at],[`text`,ot],[`tool-call`,ut],[`tool-result`,ft],[`note`,mt],[`lifecycle`,mt],[`error`,ht],[`session.error`,gt],[`step-end`,_t],[`check-output`,vt],[`provider-auth-required`,yt],[`image`,bt],[`plan.updated`,xt],[`session.started`,e=>H(e)],[`session.ended`,St],[`permission.requested`,Et],[`permission.resolved`,Dt],[`ask.requested`,Ot],[`worker-question-routed`,kt],[`worker-question-fallback`,At],[`worker-question-undelivered`,jt],[`human-ask-closed`,Nt],[`human-input-delivered`,Pt],[`step-start`,Q],[`token-usage`,Q],[`cost`,Q],[`turn-end`,Q],[`done`,Q],[`session`,Q]]);function It(e,t){e.eventSeq=t.seq,Ft.get(t.type)?.(e,t)}function Lt(e){for(let t=e.turns.length-1;t>=0;--t){let n=e.turns[t].planEntries;if(n!==void 0)return n}}function Rt(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 zt(e,t){let n=e?.turns.at(-1);if(!n)return!1;let r=R(t);return r!==``&&n.items.some(e=>e.kind===`note`&&e.tone===`danger`&&R(e.text)===r)}function Bt(e,t,n){switch(e){case`waiting`:return{state:`waiting`};case`failed`:return{state:`closed`,tone:`danger`,label:t!==void 0&&t!==``&&!zt(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 $(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{t}from"./utils-DSMR_WLb.js";import{$r as n,mr as r,pr as i}from"./project-scope-context-BdqKyBHa.js";import{_ as a,g as o,h as s,k as c,p as l,v as ee}from"./live-protocol-DMhTnCmf.js";import{t as te}from"./createLucideIcon-BHp8sXmF.js";import{t as ne}from"./app-window-CSHwDX9N.js";import{t as re}from"./play-CmVAj_fu.js";import{t as ie}from"./square-terminal-B6RYYieR.js";import{t as ae}from"./button-B7MKxYjT.js";import{t as oe}from"./status-dot-BRzVlF2X.js";import{a as se,o as ce}from"./format-BU7D3IfE.js";import{$n as le,f as ue,p as de}from"./index-CJFT0IZP.js";var fe=te(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),pe=te(`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`}]]),u=e(),me={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 he(e){let{text:t,...n}=de(e),r={...n,status:t},i=me[e.state](e);return i?{...r,action:i}:r}var ge={"Run and open":re,Open:ne,View:le,"Start again":fe};function _e({entry:e,inPreview:n,onOpen:r}){let{server:i}=e,a=he(e),o=e.state===`unavailable`,s=r?a.action:void 0,c=ue(i.command),l=se(i.registeredAt);return(0,u.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,u.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2 text-xs text-soft-foreground`,children:[(0,u.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 font-mono`,children:[(0,u.jsx)(pe,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,u.jsx)(`span`,{className:`truncate`,children:`cezar_preview_serve`})]}),o?(0,u.jsx)(`span`,{children:`worktree removed`}):l?(0,u.jsx)(`span`,{children:ce(l)}):null]}),(0,u.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-2`,children:[(0,u.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,u.jsx)(oe,{tone:a.tone,shape:a.ring?`ring`:`filled`,pulse:a.pulse===!0,"aria-hidden":`true`}),(0,u.jsx)(`span`,{className:`font-semibold text-foreground`,children:i.label}),(0,u.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,i.port]}),(0,u.jsx)(`span`,{className:`text-muted-foreground`,children:a.status})]}),(0,u.jsx)(ve,{entry:e,inPreview:n,action:s,onOpen:r})]}),(0,u.jsxs)(`div`,{className:`mt-2.5 min-w-0 rounded-md bg-muted px-3 py-2 font-mono text-xs`,children:[(0,u.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-foreground`,children:i.command}),i.cwd?(0,u.jsxs)(`p`,{className:`mt-1 flex gap-3 text-soft-foreground`,children:[(0,u.jsx)(`span`,{children:`cwd`}),(0,u.jsx)(`span`,{className:`break-all`,children:i.cwd})]}):null]}),s?.run?(0,u.jsx)(d,{icon:(0,u.jsx)(ie,{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,u.jsx)(d,{children:`The worktree this server ran in is gone. Register it again from a new task.`}):null]})}function ve({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?ne:n?ge[n.label]:null;return n&&o&&s?(0,u.jsxs)(ae,{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,u.jsx)(s,{"aria-hidden":`true`}),o]}):null}function d({icon:e,children:t}){return(0,u.jsxs)(`p`,{className:`mt-2.5 flex items-start gap-2 text-xs text-muted-foreground`,children:[e,(0,u.jsx)(`span`,{children:t})]})}function f(e,t){return e.kind===`message`&&e.role===`user`&&e.skillInput?.source===t&&typeof e.skillInput.id==`string`&&e.skillInput.id!==``}var p=120;function m(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function h(e){let t=e.replace(/\s+/g,` `).trim();return t.length>p?`${t.slice(0,p-1)}…`:t}var g=e=>e===void 0?void 0:h(e);function _(e,...t){if(m(e))for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim()!==``)return t}}function v(e,...t){return g(_(e,...t))}function ye(e){if(!m(e))return;let t=e.command;if(typeof t==`string`&&t.trim()!==``)return t;if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return e.join(` `)}}function y(e){if(!m(e)||!Array.isArray(e.changes))return[];let t=[];for(let n of e.changes)m(n)&&typeof n.path==`string`&&n.path.trim()!==``&&t.push(n.path);return t}function b(e){return v(e,`description`,`query`,`url`,`filePath`,`file_path`,`path`,`pattern`,`name`)}function x(e,t){return t?`${e} ${t}`:e}var S=new Map([[`bash`,`execute`],[`commandexecution`,`execute`],[`edit`,`edit`],[`multiedit`,`edit`],[`write`,`edit`],[`notebookedit`,`edit`],[`filechange`,`edit`],[`read`,`read`],[`imageview`,`read`],[`glob`,`search`],[`grep`,`search`],[`webfetch`,`fetch`],[`websearch`,`fetch`],[`task`,`task`],[`agent`,`task`],[`skill`,`task`],[`spawnagent`,`task`],[`subtask`,`task`],[`todowrite`,`plan`],[`todolist`,`plan`],[`plan`,`plan`],[`taskcreate`,`plan`],[`taskupdate`,`plan`],[`tasklist`,`plan`],[`contextcompaction`,`other`],[`mcptoolcall`,`other`]]);function C(e,t){switch(e){case`notebookedit`:return _(t,`notebook_path`,`notebookPath`,`file_path`,`filePath`,`path`);case`filechange`:{let e=y(t);return e.length===1?e[0]:void 0}default:return _(t,`file_path`,`filePath`,`path`)}}function be(e,t){let n=e===`write`?`Write`:`Edit`;if(e!==`filechange`)return{toolKind:`edit`,title:x(n,g(C(e,t)))};let r=y(t);return{toolKind:`edit`,title:x(n,r.length>1?`${r.length} files`:r[0])}}function w(e,t){return e===`imageview`?_(t,`path`):_(t,`file_path`,`filePath`,`path`)}function xe(e,t){return{toolKind:`read`,title:x(e===`imageview`?`View image`:`Read`,g(w(e,t)))}}function T(e){return _(e,`pattern`,`query`)}function E(e,t){return e===`webfetch`?_(t,`url`):_(t,`query`)}function Se(e,t){return{toolKind:`fetch`,title:x(e===`webfetch`?`Fetch`:`Web search`,g(E(e,t)))}}var D=e=>_(e,`skill`,`name`,`command`),O=e=>_(e,`subagent_type`,`subagentType`);function Ce(e,t){return e===`skill`?D(t):_(t,`prompt`,`task`,`description`)??O(t)}function we(e,t){if(e===`skill`){let e=g(D(t));return{toolKind:`task`,title:e?`Skill: ${e}`:`Skill`,subtitle:v(t,`args`,`description`)}}let n=e===`agent`?`Agent`:`Task`,r=g(O(t)),i=v(t,`description`,`prompt`)??r;return{toolKind:`task`,title:i?`${n}: ${i}`:n,subtitle:i===r?void 0:r}}function Te(e,t,n){if(t===`contextcompaction`)return{toolKind:`other`,title:`Compacted context`};if(t===`mcptoolcall`){let e=v(n,`server`),t=v(n,`tool`);return e&&t?{toolKind:`other`,title:`${e}.${t}`}:{toolKind:`other`,title:`MCP tool`,subtitle:b(n)}}if(t.startsWith(`mcp__`)){let t=e.split(`__`).filter(e=>e!==``);if(t.length>=3)return{toolKind:`other`,title:`${t[1]}.${t.slice(2).join(`__`)}`}}return{toolKind:`other`,title:typeof e==`string`&&e.trim()!==``?h(e):`Tool`,subtitle:b(n)}}function k(e,t){let n=typeof e==`string`?e.toLowerCase():``;switch(S.get(n)){case`execute`:return{toolKind:`execute`,title:x(`Ran`,g(ye(t))),subtitle:v(t,`description`)};case`edit`:return be(n,t);case`read`:return xe(n,t);case`search`:return{toolKind:`search`,title:x(`Search`,g(T(t))),subtitle:v(t,`path`)};case`fetch`:return Se(n,t);case`task`:return we(n,t);case`plan`:return{toolKind:`plan`,title:`Update plan`};default:return Te(e,n,t)}}function Ee(e,t){let n=typeof e==`string`?e.toLowerCase():``;switch(S.get(n)){case`execute`:return ye(t);case`edit`:return C(n,t);case`read`:return w(n,t);case`search`:return T(t);case`fetch`:return E(n,t);case`task`:return Ce(n,t);default:return}}function De(e,t){if(t.type===`ask.requested`&&typeof t.requestId==`string`&&c.safeParse({questions:t.questions}).success)return t;if(t.type===`human-input-delivered`||t.type===`human-ask-closed`){let n=(t.type===`human-input-delivered`?a:o).safeParse(t);if(n.success&&n.data.askSeq===e?.seq)return}return e}function Oe(e){if(!(e.type!==`ask.requested`||typeof e.requestId!=`string`))return{requestId:e.requestId,questions:e.questions,...e.context===void 0?{}:{context:e.context}}}function ke(e){let t=Oe(e);return t&&{seq:e.seq,...t}}function Ae(e,t){let n=De(e&&{type:`ask.requested`,seq:e.seq,ts:``},t);return n===t?ke(t):n===void 0?void 0:e}function je(e){let t;for(let n of e)t=Ae(t,n);return t}function Me(e){let t=Array.isArray(e.questions)?e.questions.filter(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e.header==`string`&&(e.options===void 0||Array.isArray(e.options))):[];if(t.length===0)return;let n=typeof e.context==`string`&&e.context!==``?e.context:void 0;return{id:e.requestId,questions:t,...n===void 0?{}:{context:n},askSeq:e.seq}}function Ne(){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 A(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function j(e){return typeof e==`string`?e:void 0}function M(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 N(e){if(!(typeof e!=`string`||e===``))return Number.isFinite(new Date(e).getTime())?e:void 0}function Pe(e){return n.safeParse(e).data}function P(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 F(e){return e.turns.at(-1)??P(e)}function I(e,t){let n={origin:`meta`,entry:t,firstSeq:e.eventSeq,lastSeq:e.eventSeq};return F(e).entries.push(n),n}var Fe=[/^run failed\s+[—-]\s+/,/^continue failed(?:\s+[—-]\s+|:\s+)/,/^step\s+"[^"]+"\s+failed:\s+/,/^step\s+\S+\s+failed\s+[—-]\s+/],Ie=/^(?:run failed\s+[—-]\s+|continue failed(?:\s+[—-]\s+|:\s+))/;function L(e){return e.trim().replace(/\s+/g,` `)}function R(e){let t=e.trim(),n=!0;for(;n;){n=!1;for(let e of Fe){let r=t.replace(e,``).trim();r!==t&&r!==``&&(t=r,n=!0)}}return L(t)}function z(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 B(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 V(e,t,n){let r=F(e),i=B(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),z(i,n.source,n.text);return}let a={draft:I(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 Le(e,t,n){if(!Ie.test(n))return!1;let r=e.turns.at(-1);if(!r)return!1;let i=R(n);if(i===``)return!1;let a=B(r,i,j(t.stepId));return a?(a.draft.lastSeq=Math.max(a.draft.lastSeq,t.seq),a.fatal=!0,z(a,`lifecycle`,n),!0):!1}function Re(e,t,n){let r=e.turns.at(-1);if(!r)return;let i=B(r,n?R(n):``,j(t.stepId));i&&(i.fatal=!0)}function H(e){for(let t of e.permissions.values())t.status===`pending`&&(t.status=`expired`)}function U(e,t){let n=j(e.stepId);return n===void 0?t:`${n}:${t}`}function ze(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 Be(e,t,n,r,i,a=!1){let o=n.kind===`message`&&i!==void 0?{...n,ts:i}:{...n};!t.v2Items&&o.kind!==`hook`&&ze(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 W={"not-delivered":0,queued:1,delivered:2,consumed:3},Ve=[`instruction`,`resumed`,`requestId`,`relationship`,`state`,`createdAt`,`requestHash`,`deadline`];function G(e){let t={};for(let n of Ve)e[n]!==void 0&&Object.assign(t,{[n]:e[n]});return t}function K(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 He(e,t){let n=e.conversationEntries.get(t);n&&K(e,n)}function Ue(e,t,n,r){(W[e.delivery]<W.delivered||W[n]>W[e.delivery])&&(e.delivery=n),t.text!==``&&(e.text=t.text),Object.assign(e,G(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 q(e,t,n,r){let i=e.conversationEntries.get(t.id);if(i){Ue(i,t,n,r),K(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,...G(t)};K(e,a),e.conversationEntries.set(t.id,a),I(e,a)}function We(e,t){let n=M(t.ts),r=j(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,I(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=j(t.webhookName),i=`${r?`Delivery to ${r} failed`:`Webhook delivery failed`}${j(t.event)?` (${j(t.event)})`:``}${n?` after ${n} attempt${n===1?``:`s`}`:``}: ${j(t.error)??`unknown error`}`;I(e,{kind:`note`,id:`v1:${t.seq}`,text:i,tone:`danger`})}function Ke(e,t){let n=j(t.webhookName)??`webhook`,r=j(t.title),i=`v1:${t.seq}`;if(t.ok===!1){I(e,{kind:`note`,id:i,text:`Report to ${n} failed: ${j(t.error)??`unknown error`}`,tone:`danger`});return}let a=`${t.dryRun===!0?`Report to ${n} (dry run, nothing sent)`:`Sent report to ${n}`}${M(t.ts)}${r?` — ${r}`:``}`;I(e,t.dryRun===!0?{kind:`note`,id:i,text:a,tone:`dim`}:{kind:`note`,id:i,text:a,tone:`dim`,icon:`handoff`})}function qe(e,t){let n=t.payload??{},r=`Webhook (dry run, nothing sent): ${j(t.event)??`delivery`}${j(n.status)?` · ${j(n.status)}`:``}`;I(e,{kind:`note`,id:`v1:${t.seq}`,text:r,tone:`dim`})}function Je(e,t){let n=i.safeParse(t.server);if(!n.success)return;let r=e.previewByPort.get(n.data.port);r&&(r.turn.entries=r.turn.entries.filter(e=>e!==r.draft));let a=F(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 Ye(e,t){let n=r.safeParse(t.state),i=typeof t.port==`number`?e.previewByPort.get(t.port):void 0;if(!n.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:n.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=s.safeParse(t);if(!n.success)return;let{message:r,delivery:i,deliveredAt:a,consumedAt:o,ts:c}=n.data;q(e,r,i,{deliveredAt:a,consumedAt:o,recordedAt:c})}function Ze(e,t){let n=ee.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),He(e,r.requestId))}function Qe(e,t){let n=l.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){q(e,{id:r.id,text:r.text,createdAt:r.createdAt,...r.conversation},`delivered`,{deliveredAt:r.deliveredAt,recordedAt:n.data.ts});return}I(e,{kind:`note`,id:`agent-input:${r.id}`,text:r.text,tone:`dim`,attribution:{source:r.source,parentRunId:r.parentRunId}})}}function $e(e,t){let n=j(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=P(e,t.seq),a=N(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 et(e,t){let n=e.turns.at(-1),r=n&&n.turnId===void 0&&!n.v2Items?n:P(e,t.seq);r.turnId=j(t.turnId),r.startedAt??=N(t.ts)}function tt(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 nt(e,t){H(e);let n=tt(e,j(t.turnId));if(!n)return;let r=N(t.ts);n.completed={stopReason:j(t.stopReason)??`end_turn`,...typeof t.costUsd==`number`?{costUsd:t.costUsd}:{},...r===void 0?{}:{ts:r}}}var J=new Set([`message`,`reasoning`,`tool`,`hook`]),rt=e=>J.has(e.kind);function it(e){if(!(!A(e)||!J.has(e.kind)))return typeof e.id==`string`&&e.id!==``?e:void 0}function Y(e,t){let n=it(t.item);if(!n)return;let r=U(t,n.id),i=e.itemsById.get(r),a=t.type===`item.completed`,o=!a&&(n.kind===`message`||n.kind===`reasoning`);Be(e,i?.turn??F(e),n,r,a?N(t.ts):void 0,o)}function at(e,t){let n=e.itemsById.get(U(t,j(t.itemId)??``)),r=j(t.delta)??``;if(!n||r===``||!rt(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 ot(e,t){let n=F(e),r=j(t.text)??``;if(r===``)return;let i=N(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 st=new Set([`pending`,`in_progress`,`completed`,`cancelled`]);function ct(e){if(!A(e)||!Array.isArray(e.todos))return;let t=[];for(let n of e.todos){if(!A(n)||typeof n.content!=`string`)return;t.push({content:n.content,status:st.has(n.status)?n.status:`pending`,...typeof n.activeForm==`string`?{activeForm:n.activeForm}:{}})}return t}var lt=new Set([`subAgentActivity`,`collabAgentToolCall`,`collabToolCall`]);function ut(e,t){let n=F(e),r=j(t.tool)??`Tool`;if(n.v2Items||lt.has(r))return;let i=k(r,t.input),a=i.toolKind===`plan`?ct(t.input):void 0;a!==void 0&&(n.planEntries=a);let o={kind:`tool`,id:j(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 dt(e){if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e)}catch{return String(e)}}function ft(e,t){let n=e.itemsById.get(j(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=dt(t.result))}function pt(e,t,n,r){let i=j(t.message)??``;i!==``&&I(e,{kind:`note`,id:n,text:i,tone:r})}function mt(e,t){let n=j(t.message)??``;t.type===`lifecycle`&&n!==``&&Le(e,t,n)||pt(e,t,`v1:${t.seq}`,t.tone===`danger`?`danger`:`dim`)}function ht(e,t){let n=j(t.message)??``;n!==``&&V(e,t,{id:`v1:${t.seq}`,source:`error`,text:n,cause:R(n),stepId:j(t.stepId),fatal:!1})}function gt(e,t){let n=j(t.message)??``;n!==``&&V(e,t,{id:`v2:${t.seq}`,source:`session.error`,text:n,cause:R(n),stepId:j(t.stepId),fatal:t.fatal===!0})}function _t(e,t){if(t.status!==`failed`)return;let n=j(t.stepId),r=j(t.error),i=r?` — ${r}`:``;V(e,t,{id:`v1:${t.seq}`,source:`step-end`,text:`step ${n??`?`} failed${i}`,cause:r?R(r):``,stepId:n,fatal:!0})}function vt(e,t){let n=j(t.command)??`check`,r=typeof t.exitCode==`number`?t.exitCode:-1;I(e,{kind:`tool`,id:`v1:${t.seq}`,name:`check`,toolKind:`execute`,title:`Ran ${n}`,status:r===0?`completed`:`failed`,output:j(t.text)??``,exitCode:r})}function yt(e,t){let n=Pe(t.provider),r=j(t.authFailureId)??``;n===void 0||r.length<1||r.length>128||I(e,{kind:`provider-auth-required`,id:`v1:${t.seq}`,provider:n,authFailureId:r})}function bt(e,t){let n=j(t.url);if(n===void 0)return;let r={kind:`image`,id:`v1:${t.seq}`,url:n},i=j(t.name);i!==void 0&&(r.name=i),I(e,r)}function xt(e,t){Array.isArray(t.entries)&&(F(e).planEntries=t.entries)}function St(e,t){H(e);let n=j(t.reason)??`end_turn`,r=j(t.message);n===`error`&&Re(e,t,r),e.sessionEnded={reason:n,...r===void 0?{}:{message:r}}}var Ct=new Set([`allow_once`,`allow_always`,`reject_once`,`reject_always`]);function wt(e){return A(e)&&typeof e.id==`string`&&e.id!==``&&typeof e.label==`string`&&e.label!==``&&Ct.has(e.kind)}function Tt(e){if(!(!Array.isArray(e)||e.length===0||!e.every(wt)))return new Set(e.map(e=>e.id)).size===e.length?e:void 0}function Et(e,t){let n=j(t.requestId),r=j(t.title),i=Tt(t.options);if(!n||!r||e.permissions.has(n)||!i)return;let a=j(t.itemId),o=j(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),I(e,s)}function Dt(e,t){let n=e.permissions.get(j(t.requestId)??``);if(!n||n.status!==`pending`)return;let r=j(t.optionId);r!==void 0&&n.options.some(e=>e.id===r)?(n.status=`resolved`,n.optionId=r):n.status=`expired`;let i=j(t.reason);i!==void 0&&(n.reason=i)}function Ot(e,t){let n=ke(t),r=n&&Me(n);if(!r)return;let i={kind:`ask`,...r,questions:r.questions,resolved:!1};I(e,i),e.pendingAsk=i}function X(e,t){let n=e.pendingAsk;return n&&!n.resolved&&n.askSeq===t.askSeq?n:void 0}function kt(e,t){let n=X(e,t);if(!n)return;n.routedToParent=!0;let r=j(t.parentRunId);r!==void 0&&(n.parentRunId=r)}function At(e,t){let n=X(e,t);n&&(n.routedToParent=!1)}function jt(e,t){let n=X(e,t);n&&Z(e,n,`undeliverable`)}var Mt=new Set([`finish`,`superseded`,`parent-stopped`,`worker-stopped`,`undeliverable`]);function Nt(e,t){let n=X(e,t);n&&Mt.has(t.reason)&&Z(e,n,t.reason)}function Z(e,t,n){t.resolved=!0,t.closed=n,e.pendingAsk=void 0}function Pt(e,t){let n=X(e,t);if(n){if(t.source===`cezar`){Z(e,n,`undeliverable`);return}t.source===`parent`&&(n.resolved=!0,n.answeredBy=`parent`,e.pendingAsk=void 0)}}var Q=()=>{},Ft=new Map([[`handoff`,We],[`webhook.failed`,Ge],[`webhook.dry-run`,qe],[`webhook.report`,Ke],[`preview.server-registered`,Je],[`preview.server-state`,Ye],[`conversation-message`,Xe],[`request-outcome`,Ze],[`agent-input`,Qe],[`user-message`,$e],[`turn.started`,et],[`turn.completed`,nt],[`item.started`,Y],[`item.updated`,Y],[`item.completed`,Y],[`item.delta`,at],[`text`,ot],[`tool-call`,ut],[`tool-result`,ft],[`note`,mt],[`lifecycle`,mt],[`error`,ht],[`session.error`,gt],[`step-end`,_t],[`check-output`,vt],[`provider-auth-required`,yt],[`image`,bt],[`plan.updated`,xt],[`session.started`,e=>H(e)],[`session.ended`,St],[`permission.requested`,Et],[`permission.resolved`,Dt],[`ask.requested`,Ot],[`worker-question-routed`,kt],[`worker-question-fallback`,At],[`worker-question-undelivered`,jt],[`human-ask-closed`,Nt],[`human-input-delivered`,Pt],[`step-start`,Q],[`token-usage`,Q],[`cost`,Q],[`turn-end`,Q],[`done`,Q],[`session`,Q]]);function It(e,t){e.eventSeq=t.seq,Ft.get(t.type)?.(e,t)}function Lt(e){for(let t=e.turns.length-1;t>=0;--t){let n=e.turns[t].planEntries;if(n!==void 0)return n}}function Rt(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 zt(e,t){let n=e?.turns.at(-1);if(!n)return!1;let r=R(t);return r!==``&&n.items.some(e=>e.kind===`note`&&e.tone===`danger`&&R(e.text)===r)}function Bt(e,t,n){switch(e){case`waiting`:return{state:`waiting`};case`failed`:return{state:`closed`,tone:`danger`,label:t!==void 0&&t!==``&&!zt(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 $(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 Vt=/\s*(?:^|\n)C(?:E(?:Z(?::.*)?)?)?$/,Ht=/[ \t]+CEZ(?::[A-Z]*)?$/;function Ut(e){return e.replace(Vt,``).replace(Ht,``)}function Wt(e,t,n){return t!==``&&e.some(e=>e.norm===``?n>e.firstSeq:e.norm.startsWith(t)||t.startsWith(e.norm))}function Gt(e,t){let n=e=>$(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||Wt(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 Kt(e,t){let n=new Set;for(let{origin:t,entry:r}of e.entries)t===`v2`&&r.kind===`message`&&n.add($(r.text,!0).trim());n.size!==0&&(e.entries=e.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`message`&&n.has($(e.entry.text,!0).trim()))),Gt(e,t))}function qt(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=$(e.entry.text,!0).trim();if(t===``)return!0;let r=n.get(L(t));return r?(r.draft.firstSeq=Math.min(r.draft.firstSeq,e.firstSeq),r.draft.lastSeq=Math.max(r.draft.lastSeq,e.lastSeq),z(r,`assistant`,t),!1):!0})}function Jt(e){e.userMessage&&(e.entries=e.entries.filter(({entry:e})=>!f(e,`human`)))}function Yt(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 Xt(e,t,n){let{entry:r}=e;if(r.kind!==`message`||r.role!==`assistant`)return r;let i=$(r.text,t);return n&&e.streaming===!0?{...r,text:Ut(i),streaming:!0}:{...r,text:i}}function Zt(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=>Xt(e,n,t)),itemSeqs:Qt(e.entries)}}function Qt(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 $t(e,t={}){let n=Ne();for(let t of e)It(n,t);let r=n.turns.length-1;for(let[e,i]of n.turns.entries())i.v2Items&&Kt(i,t.activeTurn===!0&&e===r),qt(i),Jt(i);return Yt(n),{turns:n.turns.map((e,n)=>Zt(e,t.activeTurn===!0&&n===r)),...n.sessionEnded===void 0?{}:{sessionEnded:n.sessionEnded}}}export{je as a,f as c,fe as d,Bt as i,_e as l,$t as n,Ee as o,Rt as r,k as s,Lt as t,pe as u};