@useorgx/openclaw-plugin 0.7.2 → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/dashboard/dist/assets/{CgaottFX.js → B1mDqDdy.js} +1 -1
  2. package/dashboard/dist/assets/B1mDqDdy.js.br +0 -0
  3. package/dashboard/dist/assets/B1mDqDdy.js.gz +0 -0
  4. package/dashboard/dist/assets/BDMstdfu.js +1 -0
  5. package/dashboard/dist/assets/BDMstdfu.js.br +0 -0
  6. package/dashboard/dist/assets/BDMstdfu.js.gz +0 -0
  7. package/dashboard/dist/assets/BTAEErUY.js +1 -0
  8. package/dashboard/dist/assets/BTAEErUY.js.br +0 -0
  9. package/dashboard/dist/assets/BTAEErUY.js.gz +0 -0
  10. package/dashboard/dist/assets/{8dksYiq4.js → BXapfumA.js} +1 -1
  11. package/dashboard/dist/assets/BXapfumA.js.br +0 -0
  12. package/dashboard/dist/assets/BXapfumA.js.gz +0 -0
  13. package/dashboard/dist/assets/BZZKPNDb.css +1 -0
  14. package/dashboard/dist/assets/BZZKPNDb.css.br +0 -0
  15. package/dashboard/dist/assets/BZZKPNDb.css.gz +0 -0
  16. package/dashboard/dist/assets/{rttbDbEx.js → BdusVDcP.js} +1 -1
  17. package/dashboard/dist/assets/BdusVDcP.js.br +0 -0
  18. package/dashboard/dist/assets/BdusVDcP.js.gz +0 -0
  19. package/dashboard/dist/assets/{D8JNX8kq.js → BwkNYH6r.js} +1 -1
  20. package/dashboard/dist/assets/BwkNYH6r.js.br +0 -0
  21. package/dashboard/dist/assets/BwkNYH6r.js.gz +0 -0
  22. package/dashboard/dist/assets/{CzCxAZlW.js → CRhvoVeH.js} +1 -1
  23. package/dashboard/dist/assets/CRhvoVeH.js.br +0 -0
  24. package/dashboard/dist/assets/CRhvoVeH.js.gz +0 -0
  25. package/dashboard/dist/assets/{B6wPWJ35.js → CYchPSem.js} +1 -1
  26. package/dashboard/dist/assets/CYchPSem.js.br +0 -0
  27. package/dashboard/dist/assets/CYchPSem.js.gz +0 -0
  28. package/dashboard/dist/assets/Cn07669c.js +212 -0
  29. package/dashboard/dist/assets/Cn07669c.js.br +0 -0
  30. package/dashboard/dist/assets/Cn07669c.js.gz +0 -0
  31. package/dashboard/dist/assets/{C8uM3AX8.js → DBG89Wsz.js} +1 -1
  32. package/dashboard/dist/assets/DBG89Wsz.js.br +0 -0
  33. package/dashboard/dist/assets/DBG89Wsz.js.gz +0 -0
  34. package/dashboard/dist/assets/{CZaT3ob_.js → DHoYGJ9i.js} +1 -1
  35. package/dashboard/dist/assets/DHoYGJ9i.js.br +0 -0
  36. package/dashboard/dist/assets/DHoYGJ9i.js.gz +0 -0
  37. package/dashboard/dist/assets/DHtZPEKd.js +1 -0
  38. package/dashboard/dist/assets/DHtZPEKd.js.br +0 -0
  39. package/dashboard/dist/assets/DHtZPEKd.js.gz +0 -0
  40. package/dashboard/dist/assets/{B5zYRHc3.js → DUaqjbT7.js} +1 -1
  41. package/dashboard/dist/assets/DUaqjbT7.js.br +0 -0
  42. package/dashboard/dist/assets/DUaqjbT7.js.gz +0 -0
  43. package/dashboard/dist/assets/{IUexzymk.js → Dlz0Cm_E.js} +1 -1
  44. package/dashboard/dist/assets/Dlz0Cm_E.js.br +0 -0
  45. package/dashboard/dist/assets/Dlz0Cm_E.js.gz +0 -0
  46. package/dashboard/dist/assets/{CC63EwFD.js → E8q3xNGK.js} +1 -1
  47. package/dashboard/dist/assets/E8q3xNGK.js.br +0 -0
  48. package/dashboard/dist/assets/E8q3xNGK.js.gz +0 -0
  49. package/dashboard/dist/assets/VH0fzk6I.js +1 -0
  50. package/dashboard/dist/assets/VH0fzk6I.js.br +0 -0
  51. package/dashboard/dist/assets/VH0fzk6I.js.gz +0 -0
  52. package/dashboard/dist/assets/bxgRC96y.js +1 -0
  53. package/dashboard/dist/assets/bxgRC96y.js.br +0 -0
  54. package/dashboard/dist/assets/bxgRC96y.js.gz +0 -0
  55. package/dashboard/dist/index.html +2 -2
  56. package/dashboard/dist/index.html.br +0 -0
  57. package/dashboard/dist/index.html.gz +0 -0
  58. package/dist/http/helpers/auto-continue-engine.js +29 -11
  59. package/dist/http/helpers/autopilot-slice-utils.js +7 -10
  60. package/dist/http/helpers/openclaw-cli.js +2 -2
  61. package/dist/http/index.js +160 -4
  62. package/dist/http/routes/live-legacy.d.ts +2 -0
  63. package/dist/http/routes/live-legacy.js +97 -0
  64. package/dist/http/routes/mission-control-read.js +106 -63
  65. package/dist/openclaw-settings.js +3 -2
  66. package/dist/openclaw.plugin.json +1 -1
  67. package/dist/sync/outbox-replay.js +17 -8
  68. package/openclaw.plugin.json +1 -1
  69. package/package.json +1 -1
  70. package/dashboard/dist/assets/6mILZQ2a.js +0 -1
  71. package/dashboard/dist/assets/6mILZQ2a.js.br +0 -0
  72. package/dashboard/dist/assets/6mILZQ2a.js.gz +0 -0
  73. package/dashboard/dist/assets/8dksYiq4.js.br +0 -0
  74. package/dashboard/dist/assets/8dksYiq4.js.gz +0 -0
  75. package/dashboard/dist/assets/B5zYRHc3.js.br +0 -0
  76. package/dashboard/dist/assets/B5zYRHc3.js.gz +0 -0
  77. package/dashboard/dist/assets/B6wPWJ35.js.br +0 -0
  78. package/dashboard/dist/assets/B6wPWJ35.js.gz +0 -0
  79. package/dashboard/dist/assets/BWEwjt1W.js +0 -1
  80. package/dashboard/dist/assets/BWEwjt1W.js.br +0 -0
  81. package/dashboard/dist/assets/BWEwjt1W.js.gz +0 -0
  82. package/dashboard/dist/assets/BzRbDCAD.css +0 -1
  83. package/dashboard/dist/assets/BzRbDCAD.css.br +0 -0
  84. package/dashboard/dist/assets/BzRbDCAD.css.gz +0 -0
  85. package/dashboard/dist/assets/C8uM3AX8.js.br +0 -0
  86. package/dashboard/dist/assets/C8uM3AX8.js.gz +0 -0
  87. package/dashboard/dist/assets/C9jy61eu.js +0 -212
  88. package/dashboard/dist/assets/C9jy61eu.js.br +0 -0
  89. package/dashboard/dist/assets/C9jy61eu.js.gz +0 -0
  90. package/dashboard/dist/assets/CC63EwFD.js.br +0 -0
  91. package/dashboard/dist/assets/CC63EwFD.js.gz +0 -0
  92. package/dashboard/dist/assets/CZaT3ob_.js.br +0 -0
  93. package/dashboard/dist/assets/CZaT3ob_.js.gz +0 -0
  94. package/dashboard/dist/assets/CgaottFX.js.br +0 -0
  95. package/dashboard/dist/assets/CgaottFX.js.gz +0 -0
  96. package/dashboard/dist/assets/CzCxAZlW.js.br +0 -0
  97. package/dashboard/dist/assets/CzCxAZlW.js.gz +0 -0
  98. package/dashboard/dist/assets/D3iMTYEj.js +0 -1
  99. package/dashboard/dist/assets/D3iMTYEj.js.br +0 -0
  100. package/dashboard/dist/assets/D3iMTYEj.js.gz +0 -0
  101. package/dashboard/dist/assets/D8JNX8kq.js.br +0 -0
  102. package/dashboard/dist/assets/D8JNX8kq.js.gz +0 -0
  103. package/dashboard/dist/assets/DnA8dpj6.js +0 -1
  104. package/dashboard/dist/assets/DnA8dpj6.js.br +0 -0
  105. package/dashboard/dist/assets/DnA8dpj6.js.gz +0 -0
  106. package/dashboard/dist/assets/IUexzymk.js.br +0 -0
  107. package/dashboard/dist/assets/IUexzymk.js.gz +0 -0
  108. package/dashboard/dist/assets/ic2FaMnh.js +0 -1
  109. package/dashboard/dist/assets/ic2FaMnh.js.br +0 -0
  110. package/dashboard/dist/assets/ic2FaMnh.js.gz +0 -0
  111. package/dashboard/dist/assets/rttbDbEx.js.br +0 -0
  112. package/dashboard/dist/assets/rttbDbEx.js.gz +0 -0
@@ -0,0 +1 @@
1
+ import{j as e,r as x}from"./cNrhgGc1.js";import{E as W,G as ce,$ as de,r as ue,A as xe,R as me,x as w,a0 as pe,a1 as he,Y as ke,K as D,_ as be,d as l}from"./Cn07669c.js";import{E as ge}from"./DBG89Wsz.js";import{A as fe,m as h}from"./CxQ08qFN.js";import"./C-KIc3Wc.js";import"./BJgZIVUQ.js";function je({breadcrumbs:s,typeBadge:n,onClose:d,footer:N,children:I}){return e.jsxs("div",{className:"flex h-full w-full min-h-0 flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-subtle px-5 py-3 sm:px-6",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 text-body text-secondary",children:[s.map((b,g)=>e.jsxs("span",{className:"flex items-center gap-1.5 min-w-0",children:[g>0&&e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"flex-shrink-0 text-faint",children:e.jsx("path",{d:"m9 18 6-6-6-6"})}),b.onClick?e.jsx("button",{type:"button",onClick:b.onClick,className:`truncate transition-colors hover:text-primary ${g===s.length-1?"text-primary font-medium":""}`,children:b.label}):e.jsx("span",{className:`truncate ${g===s.length-1?"text-primary font-medium":""}`,children:b.label})]},g)),n&&e.jsxs("span",{className:"ml-1 inline-flex items-center gap-1 rounded-full border border-white/[0.1] bg-white/[0.04] px-2 py-0.5 text-micro uppercase tracking-[0.06em] text-secondary",children:[n.icon&&e.jsx(W,{type:n.icon,size:11,className:"opacity-90"}),n.label]})]}),e.jsx("button",{type:"button",onClick:d,"aria-label":"Close detail",className:"inline-flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-full border border-strong bg-white/[0.03] text-primary transition-colors hover:bg-white/[0.08] hover:text-white",children:e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 6L6 18"}),e.jsx("path",{d:"M6 6l12 12"})]})})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:I}),N&&e.jsx("div",{className:"flex-shrink-0 border-t border-subtle px-5 py-3 sm:px-6",children:N})]})}function ve(s){switch(s){case"running":return{background:`linear-gradient(to right, ${l.lime}, ${l.teal})`};case"blocked":return{background:`linear-gradient(to right, ${l.red}, ${l.amber})`};case"idle":return{background:`linear-gradient(to right, ${l.iris}99, transparent)`};default:return{background:`linear-gradient(to right, ${l.lime}B3, ${l.teal}66)`}}}function Y(s){switch(s){case"running":return l.lime;case"blocked":return l.red;case"idle":return l.iris;case"queued":return l.teal;default:return l.amber}}function Q(s,n){return n?"Scope Under Review":s==="completed"?"Completed Scope":s==="running"?"Current Work":s==="blocked"?"Blocked Work":"Next Work"}function B(s){return s===0?l.red:s===1?l.amber:s===2?l.iris:"rgba(255,255,255,0.5)"}function L(s){return s===0?"P0":s===1?"P1":s===2?"P2":s===3?"P3":""}function ye(s){switch(s){case"high":return{filled:5,color:l.lime};case"medium":return{filled:3,color:l.amber};case"low":return{filled:1,color:l.red};default:return{filled:0,color:l.iris}}}async function we(s){const n={};if(s.runId&&(n.runId=s.runId),s.sliceRunId&&(n.sliceRunId=s.sliceRunId),s.sessionId&&(n.sessionId=s.sessionId),Object.keys(n).length===0)throw new Error("No run identifier available for terminal open.");const d=await fetch("/orgx/api/live/terminal/open",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!d.ok){const N=await d.json().catch(()=>({}));throw new Error(N.error??`Terminal open failed (${d.status})`)}}const Ne={hidden:{opacity:0,y:-4},visible:s=>({opacity:1,y:0,transition:{duration:.28,delay:s*.04,ease:[.16,1,.3,1]}}),exit:{opacity:0,transition:{duration:.18}}},j={hidden:{opacity:0,y:8},visible:s=>({opacity:1,y:0,transition:{duration:.22,delay:s*.04,ease:me.easingStandard}}),exit:{opacity:0,transition:{duration:.18}}};function ee(s){var N,I,b,g,C,T,F,S;if(s.source==="queue"){const{item:a,linkedSliceRun:o}=s;return{initiativeId:a.initiativeId,initiativeTitle:w(a.initiativeTitle),initiativeStatus:a.initiativeStatus,workstreamId:a.workstreamId,workstreamTitle:w(a.workstreamTitle),workstreamStatus:a.workstreamStatus,nextTaskTitle:a.nextTaskTitle?w(a.nextTaskTitle):null,nextTaskPriority:a.nextTaskPriority,nextTaskDueAt:a.nextTaskDueAt,agentId:a.runnerAgentId,agentName:a.runnerAgentName,agentSource:a.runnerSource,queueState:a.queueState,blockReason:a.blockReason?w(a.blockReason):null,sliceScope:a.sliceScope??null,sliceTaskCount:typeof a.sliceTaskCount=="number"&&Number.isFinite(a.sliceTaskCount)?Math.max(0,Math.floor(a.sliceTaskCount)):((N=a.sliceTaskIds)==null?void 0:N.length)??null,autoContinue:a.autoContinue,sliceRun:o,sessionId:null,runId:(o==null?void 0:o.runId)??null}}if(s.source==="in_progress"){const{row:a,sliceRun:o}=s;return{initiativeId:a.initiativeId,initiativeTitle:a.initiativeTitle?w(a.initiativeTitle):null,initiativeStatus:null,workstreamId:a.workstreamId,workstreamTitle:a.workstreamTitle?w(a.workstreamTitle):a.title,workstreamStatus:a.status,nextTaskTitle:null,nextTaskPriority:null,nextTaskDueAt:null,agentId:((I=a.session)==null?void 0:I.agentId)??null,agentName:((b=a.session)==null?void 0:b.agentName)??"OrgX",agentSource:null,queueState:a.status==="running"?"running":"queued",blockReason:null,sliceScope:(o==null?void 0:o.scope)??null,sliceTaskCount:typeof((g=o==null?void 0:o.scopeProgress)==null?void 0:g.totalTasks)=="number"?Math.max(0,Math.floor(o.scopeProgress.totalTasks-o.scopeProgress.completedTasks)):((C=o==null?void 0:o.taskIds)==null?void 0:C.length)??null,autoContinue:null,sliceRun:o,sessionId:((T=a.session)==null?void 0:T.id)??null,runId:a.runId}}const{sliceRun:n}=s,d=n.sourceClient?n.sourceClient.charAt(0).toUpperCase()+n.sourceClient.slice(1):"OrgX";return{initiativeId:n.initiativeId,initiativeTitle:null,initiativeStatus:null,workstreamId:n.workstreamId,workstreamTitle:n.workstreamTitle?w(n.workstreamTitle):"Work slice",workstreamStatus:n.status,nextTaskTitle:null,nextTaskPriority:null,nextTaskDueAt:null,agentId:null,agentName:d,agentSource:n.sourceClient,queueState:n.status==="needs_review"?"completed":"blocked",blockReason:n.status==="failed"&&n.statusExplainer||null,sliceScope:n.scope??null,sliceTaskCount:typeof((F=n.scopeProgress)==null?void 0:F.totalTasks)=="number"?Math.max(0,Math.floor(n.scopeProgress.totalTasks-n.scopeProgress.completedTasks)):((S=n.taskIds)==null?void 0:S.length)??null,autoContinue:null,sliceRun:n,sessionId:null,runId:n.runId}}function y(){return e.jsx("div",{className:"h-px bg-gradient-to-r from-transparent via-white/[0.06] to-transparent"})}function De({target:s,onClose:n,onPlayWorkstream:d,onStartAutoContinue:N,onMoveWorkstream:I,onRemoveFromQueue:b,onOpenSession:g,onFocusRunId:C,onOpenInitiative:T,onReviewActivity:F,onOpenDecisions:S,onAcceptSlice:a,onRejectSlice:o}){var Z,G;const E=s!==null,[te,M]=x.useState(!1),[Ie,z]=x.useState(null),[u,A]=x.useState(null),[$,P]=x.useState(""),[q,v]=x.useState(null),J=x.useRef(null),O=x.useCallback(r=>{if(s&&(r.metaKey||r.ctrlKey)&&r.key==="Enter"){r.preventDefault();const c=ee(s);c.initiativeId&&c.workstreamId&&(d==null||d(c.initiativeId,c.workstreamId,c.agentId??void 0))}},[s,d]);if(x.useEffect(()=>{if(E)return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[E,O]),x.useEffect(()=>{E||(z(null),M(!1),A(null),P(""),v(null))},[E]),x.useEffect(()=>{u&&requestAnimationFrame(()=>{var r;(r=J.current)==null||r.focus()})},[u]),!s)return null;const i=ee(s),t=i.sliceRun,m=ce({sessionStatus:i.queueState,sessionPhase:i.workstreamStatus,sliceStatus:(t==null?void 0:t.status)??i.workstreamStatus,activityStatus:(t==null?void 0:t.runtimeState)??i.workstreamStatus??i.queueState,stopReason:i.queueState==="blocked"?"blocked":null,decisionRequired:((t==null?void 0:t.blockingDecisionCount)??0)>0,blockingDecisionCount:(t==null?void 0:t.blockingDecisionCount)??0,nonBlockingDecisionCount:Math.max(0,((t==null?void 0:t.decisionCount)??0)-((t==null?void 0:t.blockingDecisionCount)??0)),blockerCount:i.blockReason?1:0,blockerReason:i.blockReason}),ie=m.status==="completed"?"text-lime border-lime/30 bg-lime/[0.12]":m.status==="failed"?"text-red-200 border-red-400/30 bg-red-500/[0.12]":m.status==="needs_attention"?"text-amber-200 border-amber-400/30 bg-amber-500/[0.12]":m.status==="in_progress"?"text-teal-200 border-teal-400/30 bg-teal-500/[0.12]":"text-secondary border-white/[0.14] bg-white/[0.04]",se=m.tone==="critical"?"border-red-400/24 bg-red-500/[0.08]":m.tone==="warning"?"border-amber-400/24 bg-amber-500/[0.08]":m.tone==="positive"?"border-lime/24 bg-lime/[0.08]":"border-subtle bg-white/[0.02]",ne=[...i.initiativeTitle?[{label:i.initiativeTitle,onClick:i.initiativeId?()=>T==null?void 0:T(i.initiativeId):void 0}]:[],{label:i.workstreamTitle}],V=m.status==="in_progress",ae=!!(i.initiativeId&&i.workstreamId&&!V),X=m.nextAction??(s.source==="needs_input"&&t?t.primaryAction==="resolve_decision"?"Resolve decision":t.primaryAction==="open_artifact"?"Open result":"Review activity":null),re=x.useCallback(async r=>{try{z(null),M(!0),await we(r)}catch(c){z(c instanceof Error?c.message:"Unable to open terminal")}finally{M(!1)}},[]),H=x.useMemo(()=>i.sessionId?{sessionId:i.sessionId,runId:i.runId,sliceRunId:(t==null?void 0:t.sliceRunId)??null}:t!=null&&t.runId||t!=null&&t.sliceRunId?{runId:t.runId??null,sliceRunId:t.sliceRunId??null}:i.runId?{runId:i.runId,sliceRunId:(t==null?void 0:t.sliceRunId)??null}:null,[i.sessionId,i.runId,t]),oe=H!==null,K=x.useMemo(()=>de({initiativeId:i.initiativeId,initiativeTitle:i.initiativeTitle,workstreamId:i.workstreamId,workstreamTitle:i.workstreamTitle,taskIds:t==null?void 0:t.taskIds,milestoneIds:t==null?void 0:t.milestoneIds,scopeProgress:(t==null?void 0:t.scopeProgress)??null,status:(t==null?void 0:t.status)??i.queueState,agentName:i.agentName,agentId:i.agentId}),[i.initiativeId,i.initiativeTitle,i.workstreamId,i.workstreamTitle,t,i.queueState,i.agentName,i.agentId]),_=s.source==="needs_input"&&(t==null?void 0:t.status)==="needs_review",U=x.useCallback(async()=>{if(!t||!u)return;const r=$.trim(),c=t.runId??t.sliceRunId;if(u==="accept")try{v("Accepting…");const p=r?`Accepted: ${r}`:"Accepted from dashboard",k=await fetch(`/orgx/api/runs/${encodeURIComponent(c)}/actions/complete`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:p})});if(!k.ok){const R=await k.json().catch(()=>null);v(`Error: ${(R==null?void 0:R.error)??(R==null?void 0:R.message)??k.status}`);return}v("Accepted!");try{a==null||a(t,r||void 0)}catch{}setTimeout(()=>n(),600)}catch(p){v(`Failed: ${p instanceof Error?p.message:"network error"}`)}else if(u==="reject"&&r)try{v("Sending feedback…");const p=await fetch(`/orgx/api/entities/run/${encodeURIComponent(c)}/comments`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:r,commentType:"review_feedback",severity:"warn",tags:["changes_requested"]})});if(!p.ok){const k=await p.json().catch(()=>null);v(`Error: ${(k==null?void 0:k.error)??(k==null?void 0:k.message)??p.status}`);return}v("Feedback sent!");try{o==null||o(t,r)}catch{}A(null),P("")}catch(p){v(`Failed: ${p instanceof Error?p.message:"network error"}`)}},[t,u,$,a,o,n]),le=e.jsxs("div",{className:"space-y-2",children:[q&&e.jsx("div",{className:`flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-[11px] font-medium ${q.startsWith("Error")||q.startsWith("Failed")?"bg-[#FF6B88]/10 text-[#FF6B88]":q.includes("…")?"bg-white/[0.04] text-white/60 animate-pulse":"bg-[#BFFF00]/10 text-[#BFFF00]"}`,children:q}),e.jsx(fe,{children:u&&e.jsx(h.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},className:"overflow-hidden",children:e.jsxs("div",{className:"pb-2",children:[e.jsx("textarea",{ref:J,value:$,onChange:r=>P(r.target.value),onKeyDown:r=>{(r.metaKey||r.ctrlKey)&&r.key==="Enter"&&(r.preventDefault(),U()),r.key==="Escape"&&(r.preventDefault(),A(null),P(""))},placeholder:u==="accept"?"Optional note...":"What needs to change?",className:"w-full resize-none rounded-lg border border-white/[0.08] bg-white/[0.03] px-3 py-2 text-[13px] text-white/80 outline-none placeholder:text-white/25 focus:border-white/15 transition-colors",rows:2}),e.jsxs("div",{className:"mt-1.5 flex items-center justify-between",children:[e.jsx("button",{type:"button",onClick:()=>{A(null),P("")},className:"text-[11px] text-white/30 transition-colors hover:text-white/50",children:"Cancel"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] text-white/20",children:u==="reject"&&!$.trim()?"Note required":"⌘Enter to confirm"}),e.jsx("button",{type:"button",onClick:U,disabled:u==="reject"&&!$.trim(),className:`inline-flex h-7 items-center gap-1 rounded-md px-3 text-[11px] font-semibold transition-colors disabled:opacity-30 ${u==="accept"?"bg-[#BFFF00]/12 text-[#BFFF00] hover:bg-[#BFFF00]/20":"bg-[#FF6B88]/12 text-[#FF6B88] hover:bg-[#FF6B88]/20"}`,children:u==="accept"?"Confirm accept":"Request changes"})]})]})]})})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[s.source==="queue"&&i.initiativeId&&i.workstreamId&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>{b==null||b(i.initiativeId,i.workstreamId),n()},className:"rounded-md px-2.5 py-1.5 text-[12px] font-medium text-[#FF6B88]/70 transition-colors hover:bg-[#FF6B88]/[0.08] hover:text-[#FF6B88]",children:"Remove"}),e.jsx("button",{type:"button",onClick:()=>I==null?void 0:I(i.initiativeId,i.workstreamId,"top"),className:"rounded-md px-2.5 py-1.5 text-[12px] font-medium text-white/35 transition-colors hover:bg-white/[0.04] hover:text-white/60",children:"Move top"})]}),s.source==="in_progress"&&i.sessionId&&e.jsx("button",{type:"button",onClick:()=>{g==null||g(i.sessionId),n()},className:"rounded-md px-2.5 py-1.5 text-[12px] font-medium text-white/35 transition-colors hover:bg-white/[0.04] hover:text-white/60",children:"Open session"}),s.source==="needs_input"&&t&&t.primaryAction==="resolve_decision"&&e.jsx("button",{type:"button",onClick:()=>{S==null||S(),n()},className:"rounded-md px-2.5 py-1.5 text-[12px] font-medium text-[#0AD4C4]/70 transition-colors hover:bg-[#0AD4C4]/[0.08] hover:text-[#0AD4C4]",children:"Resolve decision"}),s.source==="needs_input"&&t&&e.jsx("button",{type:"button",onClick:()=>{F==null||F(t),n()},className:"rounded-md px-2.5 py-1.5 text-[12px] font-medium text-white/35 transition-colors hover:bg-white/[0.04] hover:text-white/60",children:"Review"}),i.runId&&e.jsx("button",{type:"button",onClick:()=>{C==null||C(i.runId),n()},className:"rounded-md px-2.5 py-1.5 text-[12px] font-medium text-white/35 transition-colors hover:bg-white/[0.04] hover:text-white/60",children:"Timeline"})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[_&&o&&e.jsx("button",{type:"button",onClick:()=>A(u==="reject"?null:"reject"),className:`rounded-md px-2.5 py-1.5 text-[12px] font-medium transition-colors ${u==="reject"?"bg-[#FF6B88]/12 text-[#FF6B88]":"text-white/35 hover:bg-white/[0.04] hover:text-white/60"}`,children:"Request changes"}),_&&a&&e.jsxs("button",{type:"button",onClick:()=>{u==="accept"?U():A("accept")},className:"inline-flex h-8 items-center gap-1.5 rounded-lg bg-[#BFFF00]/12 px-4 text-[12px] font-semibold text-[#BFFF00] transition-colors hover:bg-[#BFFF00]/20",children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Accept"]}),ae&&e.jsxs("button",{type:"button","data-modal-autofocus":"true",onClick:()=>{d==null||d(i.initiativeId,i.workstreamId,i.agentId??void 0),n()},className:"inline-flex h-8 items-center gap-1.5 rounded-lg border border-[#BFFF00]/25 bg-[#BFFF00]/10 px-4 text-[12px] font-semibold text-[#E1FFB2] transition-colors hover:bg-[#BFFF00]/20",title:"Start (⌘ Enter)",children:[e.jsx("svg",{viewBox:"0 0 20 20",fill:"none","aria-hidden":!0,className:"h-3.5 w-3.5",children:e.jsx("path",{d:"M7 5.4v9.2c0 .7.75 1.15 1.38.83l7.6-4.6a.95.95 0 0 0 0-1.62l-7.6-4.64A.95.95 0 0 0 7 5.4Z",fill:"currentColor"})}),m.status==="completed"?"Restart":m.status==="needs_attention"?"Retry":"Start"]}),oe&&e.jsx("button",{type:"button",onClick:()=>void re(H),disabled:te,className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-white/30 transition-colors hover:bg-white/[0.04] hover:text-white/50 disabled:opacity-40",title:"Open in terminal",children:e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"4 17 10 11 4 5"}),e.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})})]})]})]});let f=0;return e.jsx(ue,{open:E,onClose:n,maxWidth:"max-w-xl",children:e.jsxs("div",{className:"relative flex h-full min-h-0 flex-col",children:[e.jsx("div",{className:"h-[2px] flex-shrink-0 rounded-t-2xl",style:ve(i.queueState),"aria-hidden":!0}),e.jsx(je,{breadcrumbs:ne,onClose:n,footer:le,children:e.jsxs("div",{className:"px-6 py-5 space-y-5",children:[e.jsxs(h.div,{variants:Ne,initial:"hidden",animate:"visible",exit:"exit",custom:f++,className:"flex items-start gap-3",children:[e.jsx(xe,{name:i.agentName??"OrgX",hint:i.agentSource??i.agentId,size:"md"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-[20px] font-semibold leading-snug text-white",children:i.workstreamTitle}),i.initiativeTitle&&e.jsx("p",{className:"mt-0.5 text-[10px] uppercase tracking-[0.1em] text-muted",children:i.initiativeTitle}),e.jsx("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:e.jsxs("span",{className:`inline-flex items-center rounded-full border px-2 py-[1px] text-micro font-semibold uppercase tracking-[0.06em] ${ie}`,children:[e.jsxs("span",{className:"relative mr-1.5 inline-block h-1.5 w-1.5",children:[e.jsx("span",{className:"absolute inset-0 rounded-full",style:{backgroundColor:Y(i.queueState)}}),V&&e.jsx(h.span,{className:"absolute inset-0 rounded-full",style:{backgroundColor:Y(i.queueState)},animate:{opacity:[1,.3,1],scale:[1,1.6,1]},transition:{duration:2,repeat:1/0,ease:"easeInOut"}})]}),m.label]})})]})]}),e.jsx(y,{}),s.source==="needs_input"&&t?e.jsxs(e.Fragment,{children:[e.jsxs(h.div,{variants:j,initial:"hidden",animate:"visible",exit:"exit",custom:f++,className:`rounded-xl border px-4 py-3 ${se}`,children:[e.jsx("p",{className:"section-kicker",children:"What to do now"}),e.jsx("p",{className:"mt-1 text-body text-primary",children:m.sentence}),t.artifactCount>0?e.jsxs("p",{className:"mt-1 text-caption text-secondary",children:[t.artifactCount," artifact",t.artifactCount===1?"":"s"," ready for review."]}):null,t.blockingDecisionCount>0?e.jsxs("p",{className:"mt-1 text-caption text-secondary",children:[t.blockingDecisionCount," blocking decision",t.blockingDecisionCount===1?"":"s"," waiting."]}):null,X?e.jsxs("p",{className:"mt-1 text-caption text-secondary",children:["Recommended action: ",X]}):null]}),t.statusExplainer&&t.statusExplainer!==i.blockReason&&e.jsxs(h.div,{variants:j,initial:"hidden",animate:"visible",exit:"exit",custom:f++,children:[e.jsx("p",{className:"section-kicker",children:"What happened"}),e.jsx("p",{className:"mt-1 text-body text-secondary leading-relaxed",children:w(t.statusExplainer)})]}),t.lastEventSummary&&e.jsxs(h.div,{variants:j,initial:"hidden",animate:"visible",exit:"exit",custom:f++,children:[e.jsx("p",{className:"section-kicker",children:"Last activity"}),e.jsx("p",{className:"mt-1 text-caption text-white/50 leading-relaxed",children:w(t.lastEventSummary)})]}),e.jsx(y,{})]}):null,(i.blockReason||i.autoContinue||i.agentSource&&i.agentSource!=="assigned")&&e.jsxs(h.div,{variants:j,initial:"hidden",animate:"visible",exit:"exit",custom:f++,className:"space-y-2",children:[i.blockReason&&e.jsxs("div",{className:"rounded-lg border border-red-400/24 bg-red-500/[0.08] px-2.5 py-1.5 text-caption text-red-100/85",children:[e.jsx("p",{className:"mb-0.5 text-micro font-semibold uppercase tracking-[0.08em] text-red-200/70",children:"Why blocked"}),i.blockReason]}),i.autoContinue&&e.jsxs("div",{className:"flex items-center gap-2 text-caption text-secondary",children:[e.jsx("svg",{viewBox:"0 0 20 20",fill:"none","aria-hidden":!0,className:"h-3.5 w-3.5 flex-shrink-0 text-[#0AD4C4]",children:e.jsx("path",{d:"M6.1 13.25C4.25 13.25 2.8 11.8 2.8 10s1.45-3.25 3.3-3.25c3.15 0 4.35 6.5 8.05 6.5 1.85 0 3.3-1.45 3.3-3.25s-1.45-3.25-3.3-3.25c-3.7 0-4.9 6.5-8.05 6.5Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),e.jsxs("span",{children:["Auto-continue: ",e.jsx("span",{className:"text-primary capitalize",children:i.autoContinue.status}),i.autoContinue.laneState&&e.jsxs("span",{className:"text-muted",children:[" · ",pe(i.autoContinue.laneState)]})]})]}),((Z=i.autoContinue)==null?void 0:Z.laneBlockedReason)&&e.jsx("p",{className:"text-micro text-red-100/75",children:i.autoContinue.laneBlockedReason}),((G=i.autoContinue)==null?void 0:G.stopReason)&&e.jsx("p",{className:"text-micro text-amber-100/75",children:he(i.autoContinue.stopReason)})]}),K.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(y,{}),e.jsxs(h.div,{variants:j,initial:"hidden",animate:"visible",exit:"exit",custom:f++,className:"space-y-2",children:[e.jsx("p",{className:"section-kicker",children:Q(i.queueState,_)}),e.jsx(ke,{nodes:K,activeId:i.workstreamId}),e.jsxs("div",{className:"flex items-center gap-2",children:[i.nextTaskPriority!==null&&L(i.nextTaskPriority)&&e.jsx("span",{className:"inline-flex rounded-full border px-2 py-[1px] text-micro font-semibold",style:{color:B(i.nextTaskPriority),borderColor:`${B(i.nextTaskPriority)}33`,backgroundColor:`${B(i.nextTaskPriority)}14`},children:L(i.nextTaskPriority)}),i.nextTaskDueAt&&e.jsxs("span",{className:"text-micro text-secondary",children:["Due ",D(i.nextTaskDueAt)]})]})]})]}),K.length===0&&(i.nextTaskTitle||i.sliceTaskCount!==null||i.sliceScope)&&e.jsxs(e.Fragment,{children:[e.jsx(y,{}),e.jsxs(h.div,{variants:j,initial:"hidden",animate:"visible",exit:"exit",custom:f++,className:"space-y-2",children:[e.jsx("p",{className:"section-kicker",children:Q(i.queueState,_)}),i.nextTaskTitle&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(W,{type:"task",size:14,className:"mt-[2px] flex-shrink-0 opacity-80"}),e.jsx("p",{className:"text-body font-semibold leading-snug text-white",children:i.nextTaskTitle})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[i.sliceScope?e.jsxs("span",{className:"inline-flex rounded-full border border-strong bg-white/[0.03] px-2 py-[1px] text-micro uppercase tracking-[0.08em] text-secondary",children:[i.sliceScope," slice"]}):null,typeof i.sliceTaskCount=="number"?e.jsxs("span",{className:"inline-flex rounded-full border border-strong bg-white/[0.03] px-2 py-[1px] text-micro text-secondary",children:[i.sliceTaskCount," ",i.sliceTaskCount===1?"task":"tasks"," in scope"]}):null,i.nextTaskPriority!==null&&L(i.nextTaskPriority)&&e.jsx("span",{className:"inline-flex rounded-full border px-2 py-[1px] text-micro font-semibold",style:{color:B(i.nextTaskPriority),borderColor:`${B(i.nextTaskPriority)}33`,backgroundColor:`${B(i.nextTaskPriority)}14`},children:L(i.nextTaskPriority)}),i.nextTaskDueAt&&e.jsxs("span",{className:"text-micro text-secondary",children:["Due ",D(i.nextTaskDueAt)]})]})]})]}),t&&(t.startedAt||t.updatedAt||t.completedAt||t.failedAt)&&e.jsxs(e.Fragment,{children:[e.jsx(y,{}),e.jsxs(h.div,{variants:j,initial:"hidden",animate:"visible",exit:"exit",custom:f++,className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"section-kicker",children:"Timeline"}),t.scope&&t.scope!=="task"&&e.jsx(be,{tone:t.scope==="milestone"?"cyan":"lime",children:t.scope}),t.confidence&&e.jsx("div",{className:"flex items-center gap-1 ml-auto",title:`Confidence: ${t.confidence}`,children:Array.from({length:5},(r,c)=>{const{filled:p,color:k}=ye(t.confidence);return e.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full",style:{backgroundColor:c<p?k:"rgba(255,255,255,0.1)"}},c)})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[t.startedAt&&e.jsxs("div",{children:[e.jsx("p",{className:"text-micro uppercase tracking-[0.08em] text-muted",children:"Started"}),e.jsx("p",{className:"mt-0.5 text-caption text-primary",children:D(t.startedAt)})]}),t.completedAt?e.jsxs("div",{children:[e.jsx("p",{className:"text-micro uppercase tracking-[0.08em] text-muted",children:"Completed"}),e.jsx("p",{className:"mt-0.5 text-caption text-primary",children:D(t.completedAt)})]}):t.failedAt?e.jsxs("div",{children:[e.jsx("p",{className:"text-micro uppercase tracking-[0.08em] text-muted",children:"Failed"}),e.jsx("p",{className:"mt-0.5 text-caption text-red-100",children:D(t.failedAt)})]}):t.updatedAt&&t.updatedAt!==t.startedAt?e.jsxs("div",{children:[e.jsx("p",{className:"text-micro uppercase tracking-[0.08em] text-muted",children:"Updated"}),e.jsx("p",{className:"mt-0.5 text-caption text-primary",children:D(t.updatedAt)})]}):null]})]})]}),t&&t.artifactCount>0&&t.artifacts.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(y,{}),e.jsxs(h.div,{variants:j,initial:"hidden",animate:"visible",exit:"exit",custom:f++,className:"space-y-2",children:[e.jsxs("p",{className:"section-kicker",children:["Artifacts ",e.jsx("span",{className:"text-muted tabular-nums",children:t.artifactCount})]}),e.jsx("div",{className:"space-y-1",children:t.artifacts.map((r,c)=>e.jsxs("div",{className:"flex items-center gap-2 rounded-lg px-2 py-1.5 transition-colors hover:bg-white/[0.04]",children:[e.jsx(W,{type:r.type==="pull_request"?"session":"workstream",size:13,className:"flex-shrink-0 opacity-75"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-caption text-primary",children:r.title}),r.url&&e.jsx("a",{href:r.url,target:"_blank",rel:"noopener noreferrer",className:"flex-shrink-0 text-micro text-secondary transition-colors hover:text-white",title:"Open artifact",children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})})]},r.id??c))})]})]}),t&&t.decisionCount>0&&e.jsxs(e.Fragment,{children:[e.jsx(y,{}),e.jsxs(h.div,{variants:j,initial:"hidden",animate:"visible",exit:"exit",custom:f++,className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("p",{className:"section-kicker",children:["Decisions ",e.jsx("span",{className:"text-muted tabular-nums",children:t.decisionCount})]}),t.blockingDecisionCount>0&&e.jsxs("span",{className:"inline-flex rounded-full border px-1.5 py-[0.5px] text-micro font-semibold tabular-nums",style:{color:l.red,borderColor:`${l.red}33`,backgroundColor:`${l.red}14`},children:[t.blockingDecisionCount," blocking"]})]}),t.decisionOptions.length>0&&e.jsx("div",{className:"space-y-1.5",children:t.decisionOptions.slice(0,4).map(r=>e.jsxs("div",{className:"rounded-lg border border-white/[0.06] bg-white/[0.02] px-3 py-2",children:[e.jsx("p",{className:"text-caption font-semibold text-primary",children:r.label}),r.description&&e.jsx("p",{className:"mt-0.5 text-micro leading-snug text-secondary",children:r.description})]},r.id))})]})]}),t&&(t.sliceRunId||t.runId)&&e.jsxs(e.Fragment,{children:[e.jsx(y,{}),e.jsxs(h.div,{variants:j,initial:"hidden",animate:"visible",exit:"exit",custom:f++,children:[e.jsx("p",{className:"section-kicker mb-2",children:"Notes"}),e.jsx(ge,{entityType:"run",entityId:t.runId??t.sliceRunId,variant:"inline"})]})]}),t&&(t.sourceClient||t.runtimeState||t.correlationId||t.runId)&&e.jsxs(e.Fragment,{children:[e.jsx(y,{}),e.jsxs("details",{className:"group",children:[e.jsxs("summary",{className:"flex cursor-pointer select-none items-center gap-1.5 py-1 text-micro uppercase tracking-[0.08em] text-muted transition-colors hover:text-secondary",children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"transition-transform group-open:rotate-90",children:e.jsx("path",{d:"m9 18 6-6-6-6"})}),"Technical details"]}),e.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-x-4 gap-y-2",children:[t.sourceClient&&e.jsxs("div",{children:[e.jsx("p",{className:"text-micro uppercase tracking-[0.08em] text-muted",children:"Source"}),e.jsx("p",{className:"mt-0.5 font-mono text-caption text-primary",children:t.sourceClient})]}),t.runtimeState&&e.jsxs("div",{children:[e.jsx("p",{className:"text-micro uppercase tracking-[0.08em] text-muted",children:"Runtime State"}),e.jsx("p",{className:"mt-0.5 font-mono text-caption text-primary",children:t.runtimeState})]}),t.runId&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("p",{className:"text-micro uppercase tracking-[0.08em] text-muted",children:"Run ID"}),e.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(t.runId)},className:"mt-0.5 font-mono text-caption text-primary transition-colors hover:text-white",title:"Click to copy",children:t.runId})]}),t.correlationId&&t.correlationId!==t.runId&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("p",{className:"text-micro uppercase tracking-[0.08em] text-muted",children:"Correlation ID"}),e.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(t.correlationId)},className:"mt-0.5 font-mono text-caption text-primary transition-colors hover:text-white",title:"Click to copy",children:t.correlationId})]})]})]})]})]})})]})})}export{De as SliceDetailModal};
@@ -0,0 +1 @@
1
+ import{u as _t,r as d,a as zt,b as ze,j as e}from"./cNrhgGc1.js";import{i as Kt,q as Ke,b as Me,N as ot,B as Qt,u as Ut,P as Dt,w as O,C as lt,x as R,K as xt,A as pt,E as Ne,h as We,y as ct,z as Wt,U as Vt}from"./Cn07669c.js";import{S as W}from"./DHoYGJ9i.js";import{A as je,m as ee,R as Ht,b as Gt,a as Jt}from"./CxQ08qFN.js";function Zt({initiativeId:n=null,authToken:s=null,embedMode:l=!1,enabled:i=!0}){var L,z,te;const f=_t(),b=Kt(),N=d.useMemo(()=>Ke.autoContinueStatus({initiativeId:n??"__global__",authToken:s,embedMode:l}),[n,s,l]),g=zt({queryKey:N,enabled:i&&(!!n||n===null),queryFn:async()=>{if(b)return{ok:!0,initiativeId:n,run:null,defaults:{tokenBudget:null,tickMs:0}};const m=new URLSearchParams;n&&m.set("initiative_id",n);const x=await fetch(`/orgx/api/mission-control/auto-continue/status?${m.toString()}`,{headers:Me({authToken:s,embedMode:l})}),u=await x.json().catch(()=>null);if(!x.ok){const c=typeof(u==null?void 0:u.error)=="string"&&u.error||typeof(u==null?void 0:u.message)=="string"&&u.message||`Failed to load auto-continue status (${x.status})`;return{ok:!1,initiativeId:n,run:null,defaults:{tokenBudget:null,tickMs:0},error:c}}return u},refetchInterval:m=>{var T,p;const x=m.state.data;if((x==null?void 0:x.ok)===!1)return!1;const u=((T=x==null?void 0:x.error)==null?void 0:T.toLowerCase())??"";if(u.includes("404")||u.includes("400")||u.includes("not found")||u.includes("bad request"))return!1;const y=((p=x==null?void 0:x.run)==null?void 0:p.status)??null;return y==="running"||y==="stopping"?2500:12e3}}),$=async()=>{await f.invalidateQueries({queryKey:N}),await f.invalidateQueries({queryKey:Ke.missionControlGraph({initiativeId:n,authToken:s,embedMode:l})}),await f.invalidateQueries({queryKey:Ke.liveData({authToken:s,embedMode:l})})},A=ze({mutationFn:async m=>{if(b){const y=g.data??null;return{ok:!0,initiativeId:n,run:(y==null?void 0:y.run)??null,defaults:(y==null?void 0:y.defaults)??{tokenBudget:null,tickMs:0}}}const x={};n&&(x.initiativeId=n),x.ignoreSpawnGuardRateLimit=!0,m&&typeof m=="object"&&(typeof m.tokenBudgetTokens=="number"&&(x.tokenBudgetTokens=m.tokenBudgetTokens),typeof m.agentId=="string"&&m.agentId.trim().length>0&&(x.agentId=m.agentId.trim()),typeof m.maxParallelSlices=="number"&&Number.isFinite(m.maxParallelSlices)&&(x.maxParallelSlices=m.maxParallelSlices),m.parallelMode==="iwmt"&&(x.parallelMode=m.parallelMode));const u=await fetch("/orgx/api/mission-control/auto-continue/start",{method:"POST",headers:Me({authToken:s,embedMode:l,contentTypeJson:!0}),body:JSON.stringify(x)}),c=await u.json().catch(()=>null);if(!u.ok){const y=ot(c);if(y)throw y;const T=typeof(c==null?void 0:c.error)=="string"&&c.error||typeof(c==null?void 0:c.message)=="string"&&c.message||`Failed to start auto-continue (${u.status})`;throw new Error(T)}if(c&&typeof c=="object"&&"run"in c){const y=g.data??null;return{ok:!0,initiativeId:n,run:c.run??null,defaults:(y==null?void 0:y.defaults)??{tokenBudget:null,tickMs:0}}}return c},onSuccess:()=>{$()}}),J=ze({mutationFn:async()=>{if(b){const c=g.data??null;return{ok:!0,initiativeId:n,run:null,defaults:(c==null?void 0:c.defaults)??{tokenBudget:null,tickMs:0}}}const m={};n&&(m.initiativeId=n);const x=await fetch("/orgx/api/mission-control/auto-continue/stop",{method:"POST",headers:Me({authToken:s,embedMode:l,contentTypeJson:!0}),body:JSON.stringify(m)}),u=await x.json().catch(()=>null);if(!x.ok){const c=typeof(u==null?void 0:u.error)=="string"&&u.error||typeof(u==null?void 0:u.message)=="string"&&u.message||`Failed to stop auto-continue (${x.status})`;throw new Error(c)}if(u&&typeof u=="object"&&"run"in u){const c=g.data??null;return{ok:!0,initiativeId:n,run:u.run??null,defaults:(c==null?void 0:c.defaults)??{tokenBudget:null,tickMs:0}}}return u},onSuccess:()=>{$()}}),q=ze({mutationFn:async m=>{var y;if(b)return{ok:!0,dispatched:((y=m.workstreamIds)==null?void 0:y.length)??1};const x={initiativeId:m.initiativeId};m.workstreamIds&&m.workstreamIds.length>0&&(x.workstreamIds=m.workstreamIds),m.agentId&&(x.agentId=m.agentId),m.scope&&(x.scope=m.scope),x.ignoreSpawnGuardRateLimit=!0;const u=await fetch("/orgx/api/mission-control/next-up/launch",{method:"POST",headers:Me({authToken:s,embedMode:l,contentTypeJson:!0}),body:JSON.stringify(x)}),c=await u.json().catch(()=>null);if(!u.ok){const T=ot(c);if(T)throw T;const p=typeof(c==null?void 0:c.error)=="string"&&c.error||typeof(c==null?void 0:c.message)=="string"&&c.message||`Failed to launch (${u.status})`;throw new Error(p)}return c??{ok:!0,dispatched:0}},onSuccess:()=>{$()}}),C=((L=g.data)==null?void 0:L.run)??null,_=(C==null?void 0:C.status)==="running"||(C==null?void 0:C.status)==="stopping";return{status:g.data??null,run:C,isRunning:_,isLoading:g.isLoading,error:((z=g.data)==null?void 0:z.error)??((te=g.error)==null?void 0:te.message)??null,start:A.mutateAsync,stop:J.mutateAsync,launchSingle:q.mutateAsync,isStarting:A.isPending,isStopping:J.isPending,isLaunching:q.isPending,refetch:g.refetch}}async function ht(n,s){var b;const i=await(await fetch(n,s)).json().catch(()=>null),f=((b=i==null?void 0:i.data)==null?void 0:b.url)??(i==null?void 0:i.url)??null;if(typeof f=="string"&&f.trim())return f.trim();throw new Error((i==null?void 0:i.error)??"Billing link unavailable")}async function Xt(n){var f;const s=((f=n==null?void 0:n.actions)==null?void 0:f.checkout)??"/orgx/api/billing/checkout",l=((n==null?void 0:n.requiredPlan)??"starter").trim().toLowerCase()||"starter",i=await ht(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({planId:l})});window.open(i,"_blank","noopener,noreferrer")}async function Yt(n){var i;const s=((i=n==null?void 0:n.actions)==null?void 0:i.portal)??"/orgx/api/billing/portal",l=await ht(s,{method:"POST"});window.open(l,"_blank","noopener,noreferrer")}function Ot(n){return n==="success"?"border-emerald-400/30 bg-[#0A1210]/95 text-emerald-100":n==="warning"?"border-amber-300/30 bg-[#12100A]/95 text-amber-100":n==="error"?"border-red-400/32 bg-[#120A0A]/95 text-red-100":n==="info"?"border-cyan-300/28 bg-[#0A1012]/95 text-cyan-100":"border-strong bg-[#0B0F16]/95 text-primary"}function en({open:n,tone:s="neutral",title:l,message:i=null,className:f,primaryAction:b=null,secondaryAction:N=null,onDismiss:g=null,autoDismissMs:$=null}){return d.useEffect(()=>{if(!n||!g||!$)return;const A=window.setTimeout(()=>g(),$);return()=>window.clearTimeout(A)},[$,g,n,l,i]),e.jsx(je,{initial:!1,children:n?e.jsx(ee.div,{initial:{opacity:0,y:-8,scale:.985},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.985},transition:{duration:.2,ease:[.22,1,.36,1]},className:`pointer-events-none ${f??""}`,children:e.jsxs("div",{className:`pointer-events-none min-w-[220px] max-w-[420px] rounded-xl border px-3 py-2 shadow-[0_16px_36px_rgba(0,0,0,0.42)] backdrop-blur ${Ot(s)}`,children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-caption font-semibold",children:l}),i?e.jsx("p",{className:"mt-0.5 text-caption opacity-85",children:i}):null]}),g?e.jsx("button",{type:"button",onClick:g,className:"pointer-events-auto inline-flex h-6 w-6 items-center justify-center rounded-md text-current/70 transition-colors hover:bg-white/[0.08] hover:text-current","aria-label":"Dismiss toast",title:"Dismiss",children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 6 6 18"}),e.jsx("path",{d:"m6 6 12 12"})]})}):null]}),b||N?e.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[N?e.jsx("button",{type:"button",onClick:N.onClick,className:"pointer-events-auto h-7 rounded-md border border-strong bg-white/[0.06] px-2.5 text-micro font-semibold text-current transition-colors hover:bg-white/[0.12]",children:N.label}):null,b?e.jsx("button",{type:"button",onClick:b.onClick,className:"pointer-events-auto h-7 rounded-md border border-white/25 bg-white/[0.14] px-2.5 text-micro font-semibold text-current transition-colors hover:bg-white/[0.2]",children:b.label}):null]}):null]})}):null})}function ft({className:n=""}){return e.jsx("svg",{viewBox:"0 0 20 20",fill:"none","aria-hidden":!0,className:n,children:e.jsx("path",{d:"M7 5.4v9.2c0 .7.75 1.15 1.38.83l7.6-4.6a.95.95 0 0 0 0-1.62l-7.6-4.64A.95.95 0 0 0 7 5.4Z",fill:"currentColor"})})}function tn({className:n=""}){return e.jsxs("svg",{viewBox:"0 0 20 20",fill:"none","aria-hidden":!0,className:n,children:[e.jsx("path",{d:"M6.2 9.4V6.7c0-.7.5-1.2 1.1-1.2s1.1.5 1.1 1.2v2.2",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),e.jsx("path",{d:"M8.4 8.9V5.8c0-.7.5-1.3 1.1-1.3s1.1.6 1.1 1.3v3",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),e.jsx("path",{d:"M10.6 8.9V6.2c0-.7.5-1.3 1.1-1.3s1.1.6 1.1 1.3v3.2",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),e.jsx("path",{d:"M12.8 9.6V7.2c0-.7.5-1.2 1.1-1.2s1.1.5 1.1 1.2v4.2c0 2.7-1.9 4.6-4.6 4.6H9.2c-2.1 0-3.7-1-4.6-2.8l-.9-1.7c-.3-.6 0-1.4.6-1.7.6-.3 1.3 0 1.6.6l.7 1.4",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]})}function nn({className:n=""}){return e.jsxs("svg",{viewBox:"0 0 20 20",fill:"none","aria-hidden":!0,className:n,children:[e.jsx("path",{d:"M6.4 9.2V7.4c0-.7.5-1.2 1.1-1.2s1.1.5 1.1 1.2v1.3",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),e.jsx("path",{d:"M8.6 8.9V7c0-.7.5-1.2 1.1-1.2s1.1.5 1.1 1.2v2",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),e.jsx("path",{d:"M10.8 9.2V7.3c0-.7.5-1.2 1.1-1.2s1.1.5 1.1 1.2v2.6",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),e.jsx("path",{d:"M13 9.8V8.2c0-.7.5-1.2 1.1-1.2s1.1.5 1.1 1.2v3.6c0 2.4-1.7 4-4.1 4H9.7c-2 0-3.4-.9-4.2-2.5l-.8-1.4c-.3-.6 0-1.3.5-1.6.6-.3 1.2-.1 1.6.5l.6 1",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]})}function ut(n){return n==="running"?"border-teal-300/35 bg-teal-400/[0.12] text-teal-100":n==="blocked"?"border-amber-300/35 bg-amber-400/[0.12] text-amber-100":n==="idle"?"border-strong bg-white/[0.05] text-secondary":"border-[#BFFF00]/30 bg-[#BFFF00]/12 text-[#E1FFB2]"}function dt(n){return n==="running"?"Running":n==="blocked"?"Needs input":n==="idle"?"Idle":"Queued"}function Be(n){return n==="queued"||n==="idle"?0:n==="blocked"?1:n==="running"?2:n==="completed"?3:4}function bt(n){return n==="running"?"from-teal-300/0 via-teal-300/60 to-teal-300/0":n==="blocked"?"from-amber-300/0 via-amber-300/55 to-amber-300/0":n==="idle"?"from-white/0 via-white/35 to-white/0":"from-[#BFFF00]/0 via-[#BFFF00]/70 to-[#BFFF00]/0"}function Qe(n){return n==="running"?"Current":n==="blocked"?"Blocked on":"Next"}function Ue(n){const s=typeof n.sliceTaskCount=="number"&&Number.isFinite(n.sliceTaskCount)?Math.max(0,Math.floor(n.sliceTaskCount)):null,l=n.sliceScope==="task"?"task":n.sliceScope==="milestone"?"milestone slice":"workstream slice",i=s&&s>0?`${s} ${s===1?"task":"tasks"}`:null;return n.queueState==="running"?i?`Executing ${i} in ${l}.`:"Execution in progress. Task detail will appear as the scheduler advances.":n.queueState==="blocked"?n.blockReason?"Blocked while waiting for dependency resolution.":"Blocked. Waiting for dependency or review.":n.queueState==="queued"?i?`Queued with ${i} in ${l}.`:"Queued at workstream scope. Task detail will populate after dispatch.":n.queueState==="completed"?"Completed. No queued tasks remain.":"Idle. Ready to dispatch when started."}function gt(n){const s=typeof n.initiativePriority=="string"?n.initiativePriority.trim().toLowerCase():"",l=typeof n.initiativePriorityNum=="number"&&Number.isFinite(n.initiativePriorityNum)?Math.max(1,Math.min(100,Math.round(n.initiativePriorityNum))):null,i=s==="urgent"||s==="high"||s==="medium"||s==="low"?s:l!==null?l<=12?"urgent":l<=30?"high":l<=60?"medium":"low":null;if(!i)return null;const f=i==="urgent"?"P1":i==="high"?"P2":i==="medium"?"P3":"P4",b=i==="urgent"?"Urgent":i==="high"?"High":i==="medium"?"Medium":"Low",N=i==="urgent"?"border-red-300/35 bg-red-500/[0.14] text-red-100":i==="high"?"border-amber-300/35 bg-amber-500/[0.14] text-amber-100":i==="medium"?"border-[#BFFF00]/35 bg-[#BFFF00]/14 text-[#E1FFB2]":"border-white/[0.2] bg-white/[0.08] text-white/70";return{shortLabel:`${f} ${b}`,longLabel:`Initiative priority ${b} (${f})`,toneClass:N}}function sn(n){const s=n.trim().toLowerCase();if(s.includes("timed out")||s.includes("timeout")||s.includes("request cancelled")||s.includes("signal is aborted"))return"Next Up is still syncing. Keep this panel open and it will repopulate automatically.";if(s.includes("unauthorized")||s.includes("forbidden")||s.includes("api key")||s.includes("auth"))return"Next Up is unavailable until OrgX authentication is reconnected in Settings.";if(s.includes("unknown api endpoint")||s.includes("route is unavailable"))return"This runtime is missing queue routes. Restart and update the plugin build.";const l=n.split("|").map(i=>i.trim()).filter(Boolean).map(i=>i.replace(/^[^:]+:\s*/,"").trim()).filter(Boolean).slice(0,2).join(" ");return We(l||n)||"Next Up is temporarily unavailable."}function rn(n){const s=n.trim().toLowerCase();return s.includes("timed out")||s.includes("timeout")||s.includes("request cancelled")||s.includes("signal is aborted")?"Signal is delayed right now. Queue data will appear as soon as sync catches up.":s.includes("fallback")?"Showing fallback queue data while full signal refreshes.":s.includes("unknown api endpoint")||s.includes("route is unavailable")?"Some queue controls are unavailable in this plugin build. Update and restart to restore full controls.":We(n.trim())}function Ce(n,s,l){const i=typeof n=="string"?n.trim():"";if(i&&!ct(i))return R(i);const f=typeof s=="string"?s.trim():"";return f?ct(f)?`${l} ${Wt(f)}`:R(f):l}function yt(n){const s=typeof n.runnerAgentName=="string"?n.runnerAgentName.trim():"";if(!s)return"Unassigned";const l=s.toLowerCase();return l==="undefined"||l==="null"||l==="main"&&(n.runnerAgentId==="unassigned"||n.runnerSource==="fallback")?"Unassigned":s}function wt(n){return n.runnerSource==="inferred"?"inferred":null}function kt(n,s){const l=n.runnerSource==="assigned"?"assigned":n.runnerSource==="inferred"?"inferred":"fallback";return s==="Unassigned"?`Runner ${l}`:`${s} · ${l}`}function me(n,s){return!n||n.trim().length===0?s:We(n.trim())||s}function mt(n){return!n||typeof n!="object"||Array.isArray(n)?null:n}function De(n,s){const l=R(n.workstreamTitle),i=mt(s),f=i&&typeof i.dispatchMode=="string"?i.dispatchMode:null,b=mt(i==null?void 0:i.run);return(b&&typeof b.stopReason=="string"?b.stopReason:b&&typeof b.stop_reason=="string"?b.stop_reason:null)==="budget_exhausted"?`Dispatch acknowledged for ${l}, but autopilot stopped: budget exhausted.`:f==="pending"?`Dispatching ${l}; waiting for slice start…`:f==="fallback"?`Dispatched ${l} using fallback runner.`:`Dispatched ${l}.`}function vt({className:n=""}){return e.jsxs("svg",{viewBox:"0 0 20 20",fill:"none","aria-hidden":!0,className:n,children:[e.jsx("circle",{cx:"4.5",cy:"10",r:"1.4",fill:"currentColor"}),e.jsx("circle",{cx:"10",cy:"10",r:"1.4",fill:"currentColor"}),e.jsx("circle",{cx:"15.5",cy:"10",r:"1.4",fill:"currentColor"})]})}function an({compact:n}){const s=n?3:6;return e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2 px-1 pt-1 text-micro uppercase tracking-[0.12em] text-muted",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[#BFFF00]/70 status-breathe"}),e.jsx("span",{children:"Calibrating queue"})]}),Array.from({length:s}).map((l,i)=>e.jsxs("div",{className:"nextup-skeleton-card rounded-2xl border border-white/[0.08] bg-white/[0.02] px-3 py-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2.5",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-2.5",children:[e.jsx(W,{className:"h-8 w-8 rounded-full"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(W,{className:"h-3 w-40 rounded-md"}),e.jsx(W,{className:"mt-2 h-4 w-56 rounded-md"})]})]}),e.jsx(W,{className:"h-5 w-16 rounded-full"})]}),e.jsxs("div",{className:"mt-3 rounded-lg border border-white/[0.07] bg-black/[0.18] px-2.5 py-2",children:[e.jsx(W,{className:"h-3 w-14 rounded"}),e.jsx(W,{className:"mt-2 h-3 w-full rounded"}),e.jsx(W,{className:"mt-2 h-3 w-3/5 rounded"})]}),e.jsxs("div",{className:"mt-2.5 flex flex-wrap gap-1.5",children:[e.jsx(W,{className:"h-8 w-24 rounded-full"}),e.jsx(W,{className:"h-8 w-20 rounded-full"}),e.jsx(W,{className:"h-8 w-24 rounded-full"})]})]},`nextup-skeleton-${i}`))]})}function on({initiativeId:n=null,projectId:s=null,authToken:l=null,embedMode:i=!1,title:f="Next Up",showHeader:b=!0,compact:N=!1,className:g,disableEnterAnimation:$=!1,allowCompactToggle:A=!1,onToggleCompact:J,onOpenInitiative:q,onOpenSettings:C,onUpgradeGate:_,onOpenSliceDetail:L,selectionEnabled:z=!0,panelStyle:te="card",showQueueSettings:m=!0,queueModel:x,queueActions:u,snapshotVersion:c=null}){var at;const[y,T]=d.useState(N);d.useEffect(()=>T(N),[N]);const p=A&&!J?y:N,F=t=>{J?J(t):T(t)},[V,k]=d.useState(null),[S,xe]=d.useState("workstream"),[oe,pe]=d.useState(null),he="bottom",[M,ne]=d.useState(null),[Q,w]=d.useState(null),[le,se]=d.useState(null),[Z,ce]=d.useState(new Set),[Se,ue]=d.useState(null),[fe,be]=d.useState(!1),[jt,Ie]=d.useState(!1),Ve=d.useRef(null),Nt=Qt({initiativeId:n,projectId:s,authToken:l,embedMode:i,enabled:!x,snapshotVersion:c,zoomLevel:S}),Ct=x??Nt,{items:ge,degraded:re,isLoading:K,isFetching:He,error:$e,refetch:St,playWorkstream:Re,startWorkstreamAutoContinue:Ge,initiativeGroups:Je,milestoneGroups:Ze}=Ct;Zt({initiativeId:n,authToken:l,embedMode:i});const It=Ut({authToken:l,embedMode:i}),H=u??It,U=t=>`${t.initiativeId}:${t.workstreamId}`,X=S==="workstream",ye=d.useMemo(()=>ge.filter(t=>t.queueState==="running").length,[ge]),D=d.useMemo(()=>{const t=ge.filter(o=>o.queueState!=="running");return t.length>0?t:ge},[ge]),Xe=d.useMemo(()=>D.length===0?"empty":D.some(t=>t.queueState!=="running"&&t.queueState!=="blocked")?"queued":D.some(t=>t.queueState==="blocked")?"blocked":D.some(t=>t.queueState==="running")?"running":"queued",[D]),we=d.useMemo(()=>[...Je].sort((t,o)=>{const a=Be(t.queueState)-Be(o.queueState);return a!==0?a:t.initiativeTitle.localeCompare(o.initiativeTitle)}),[Je]),ke=d.useMemo(()=>[...Ze].sort((t,o)=>{const a=Be(t.queueState)-Be(o.queueState);if(a!==0)return a;const r=t.initiativeTitle.localeCompare(o.initiativeTitle);if(r!==0)return r;const h=t.workstreamTitle.localeCompare(o.workstreamTitle);return h!==0?h:t.milestoneTitle.localeCompare(o.milestoneTitle)}),[Ze]),Le=d.useMemo(()=>p?we.slice(0,5):we,[p,we]),Pe=d.useMemo(()=>p?ke.slice(0,5):ke,[p,ke]),Ye=d.useMemo(()=>S==="initiative"?we.length:S==="milestone"?ke.length:D.length,[D.length,we.length,ke.length,S]),$t=[{value:"initiative",label:"Initiative"},{value:"workstream",label:"Workstream"},{value:"milestone",label:"Milestone"}],B=d.useMemo(()=>X?p?D.slice(0,5):D:[],[p,X,D]),qt=d.useMemo(()=>B.filter(t=>Z.has(U(t))),[Z,B]),[de,Oe]=d.useState([]),Ee=d.useRef([]),et=d.useMemo(()=>{const t=new Map;for(const o of B)t.set(U(o),o);return t},[B]),P=d.useMemo(()=>B.map(U),[B]),Tt=d.useMemo(()=>P.join("|"),[P]);d.useEffect(()=>{Oe(t=>{if(p)return[];const o=[],a=new Set(P);for(const r of t)a.has(r)&&o.push(r);for(const r of P)o.includes(r)||o.push(r);return o})},[p,Tt]),d.useEffect(()=>{Ee.current=de},[de]),d.useEffect(()=>{Se&&(P.includes(Se)||ue(null))},[Se,P]),d.useEffect(()=>{ce(t=>{if(t.size===0)return t;const o=new Set(B.map(U)),a=new Set;for(const r of t)o.has(r)&&a.add(r);return a.size===t.size?t:a})},[B]),d.useEffect(()=>{if(!le)return;B.some(o=>U(o)===le)||se(null)},[le,B]),d.useEffect(()=>{if(re.length===0){Ie(!1);return}Ie(!1)},[re]),d.useEffect(()=>{z&&!p&&Z.size>0&&be(!1)},[p,Z.size,z]),d.useEffect(()=>{if(!fe)return;const t=a=>{var h;const r=a.target;r&&((h=Ve.current)!=null&&h.contains(r)||be(!1))},o=a=>{a.key==="Escape"&&be(!1)};return document.addEventListener("mousedown",t),document.addEventListener("touchstart",t),document.addEventListener("keydown",o),()=>{document.removeEventListener("mousedown",t),document.removeEventListener("touchstart",t),document.removeEventListener("keydown",o)}},[fe]);const tt=async t=>{const o=U(t),a=R(t.workstreamTitle);try{await H.remove({initiativeId:t.initiativeId,workstreamId:t.workstreamId}),ce(r=>{if(!r.has(o))return r;const h=new Set(r);return h.delete(o),h}),ue(r=>r===o?null:r),k(`Removed ${a} from queue.`)}catch(r){const h=r instanceof Error?r.message:"";k(me(h,"Failed to remove from queue"))}},Ft=(t,o,a)=>{const r=p?P:de.length>0?de:P;ce(h=>{const v=new Set(h),E=Se;if(a&&E&&r.includes(E)){const j=r.indexOf(t),Y=r.indexOf(E);if(j>=0&&Y>=0){const[Te,Fe]=j<Y?[j,Y]:[Y,j];for(const ve of r.slice(Te,Fe+1))o?v.add(ve):v.delete(ve)}else o?v.add(t):v.delete(t)}else o?v.add(t):v.delete(t);return v}),ue(t)},Mt=()=>{ce(new Set(P)),ue(P.length>0?P[P.length-1]:null)},Bt=()=>{ce(new Set),ue(null)},Ae=async t=>{if(Z.size===0){k("Select one or more queue items first.");return}const o=B.map(a=>({key:U(a),item:a})).filter(a=>Z.has(a.key));if(o.length===0){k("Selected queue items are no longer visible.");return}w(`bulk:${t}`),k(null);try{const a=o.map(({item:j})=>({initiativeId:j.initiativeId,workstreamId:j.workstreamId})),r=await H.bulk({action:t,items:a}),h=typeof(r==null?void 0:r.updated)=="number"?r.updated??0:0,v=typeof(r==null?void 0:r.failed)=="number"?r.failed??0:0,E=Array.isArray(r==null?void 0:r.errors)?r.errors.filter(j=>typeof j=="string").map(j=>j.trim()).filter(Boolean):[],I=t==="remove"?"removed":t==="move_top"?"moved to top":"moved to bottom";h===0&&v>0&&E.length>0?k(me(E[0],`${v} queue action${v===1?"":"s"} failed.`)):k(v>0?`${h} item${h===1?"":"s"} ${I}; ${v} failed.`:`${h} item${h===1?"":"s"} ${I}.`),ce(new Set),ue(null)}catch(a){const r=a instanceof Error?a.message:"";k(me(r,"Bulk queue action failed"))}finally{w(null)}},Rt=async()=>{const t=Ee.current.map(o=>et.get(o)).filter(Boolean).map(o=>({initiativeId:o.initiativeId,workstreamId:o.workstreamId}));t.length!==0&&await H.reorder({order:t})},ie=async(t,o,a)=>{k(null),ne(null),_==null||_(null),w(t);try{const r=await o();k(typeof a=="function"?a(r):a)}catch(r){if(r instanceof Vt)ne(r),_==null||_(r);else{const h=r instanceof Error?r.message:"";k(me(h,"Action failed"))}}finally{w(null)}},nt=async t=>await Re({initiativeId:t.initiativeId,workstreamId:t.workstreamId,agentId:t.runnerAgentId}),qe=M?"upgrade":$e?"error":V?"notice":null,st=$e?sn($e):null,_e=re.length>0?rn(re[0]):null,Lt=qe!==null,Pt=re.length>0&&!jt&&le===null&&!fe,ae=qt.length,Et=d.useMemo(()=>S==="initiative"?Le.length>0:S==="milestone"?Pe.length>0:B.length>0,[Le.length,B.length,Pe.length,S]),rt=z&&X&&!p&&ae>0,At=S==="initiative"?"No initiatives in the queue right now.":S==="milestone"?"No milestone slices in the queue right now.":ye>0?`No queued workstreams yet. ${ye} running item${ye===1?"":"s"} still in-flight.`:re.length>0?"Queue signal is delayed right now.":"No queued workstreams right now.",it=e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:Mt,className:"control-pill h-8 px-2.5 text-caption font-semibold",children:"Select all"}),e.jsx("button",{type:"button",onClick:Bt,disabled:Z.size===0,className:"control-pill h-8 px-2.5 text-caption font-semibold disabled:opacity-45",children:"Clear"}),e.jsx("button",{type:"button",disabled:ae===0||Q==="bulk:move_top",onClick:()=>void Ae("move_top"),className:"control-pill h-8 px-2.5 text-caption font-semibold disabled:opacity-45",children:"Move top"}),e.jsx("button",{type:"button",disabled:ae===0||Q==="bulk:move_bottom",onClick:()=>void Ae("move_bottom"),className:"control-pill h-8 px-2.5 text-caption font-semibold disabled:opacity-45",children:"Move bottom"}),e.jsx("button",{type:"button",disabled:ae===0||Q==="bulk:remove",onClick:()=>void Ae("remove"),className:"control-pill h-8 px-2.5 text-caption font-semibold disabled:opacity-45",children:"Remove"})]});return e.jsxs(Dt,{surface:te==="card",className:`flex h-full min-h-0 flex-col overflow-hidden ${$?"":"card-enter"} ${te==="flat"?"!rounded-none !border-none !bg-transparent !shadow-none":""} ${g??""}`,children:[b?e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-subtle px-4 py-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("h2",{className:"truncate text-heading font-semibold text-white",children:f}),e.jsx("span",{className:"chip inline-flex min-w-[52px] justify-center text-micro tabular-nums",children:K?e.jsx("span",{"aria-hidden":!0,className:"h-2.5 w-5 rounded bg-white/15 animate-pulse"}):Ye}),e.jsx("span",{className:O("chip inline-flex min-w-[148px] justify-center text-micro tabular-nums transition-opacity",!K&&ye>0&&X?"text-secondary opacity-100":"pointer-events-none opacity-0"),children:`${ye} active elsewhere`}),e.jsx("span",{className:O("inline-flex min-w-[92px] justify-end text-micro text-muted transition-opacity",He&&!K?"opacity-100":"opacity-0"),"aria-live":"polite",children:"refreshing…"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"inline-flex items-center rounded-xl border border-white/[0.1] bg-white/[0.03] p-1",role:"tablist","aria-label":"Next Up scope",children:$t.map(t=>{const o=S===t.value;return e.jsx("button",{type:"button",role:"tab","aria-selected":o,onClick:()=>xe(t.value),className:O("h-7 rounded-lg px-2.5 text-caption font-semibold transition-colors",o?"border border-[#BFFF00]/35 bg-[#BFFF00]/16 text-[#E8FFD0]":"text-secondary hover:text-white"),title:`Show ${t.label.toLowerCase()} queue`,children:t.label},t.value)})}),A?e.jsx("button",{type:"button",onClick:()=>F(!p),className:"control-pill h-8 flex-shrink-0 whitespace-nowrap px-3 text-caption font-semibold",title:p?"Switch to expanded cards":"Switch to compact list","aria-label":p?"Expand Next Up queue":"Compact Next Up queue",children:p?"Expand":"Compact"}):null]})]}):null,Lt&&e.jsx("div",{className:"px-3 pt-2",children:e.jsx(je,{initial:!1,mode:"wait",children:qe==="upgrade"&&M?e.jsx(ee.div,{initial:{opacity:0,y:-4,scale:.99},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.99},transition:{duration:.18,ease:[.22,1,.36,1]},className:"rounded-xl border border-amber-200/25 bg-amber-200/10 px-3 py-2 text-caption text-amber-100",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"rounded-full border border-amber-200/25 bg-amber-200/10 px-2 py-0.5 text-micro font-semibold uppercase tracking-[0.08em] text-amber-100/90",children:"Upgrade required"}),e.jsxs("span",{className:"truncate text-micro text-secondary",children:[lt(M.currentPlan)," →"," ",lt(M.requiredPlan)]})]}),e.jsx("div",{className:"mt-1 line-clamp-2 text-caption leading-snug text-amber-50/90",title:M.message,children:M.message}),V?e.jsx("div",{className:"mt-1 text-micro text-rose-50/85",children:V}):null]}),e.jsxs("div",{className:"flex flex-shrink-0 flex-col items-end gap-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>void Xt({actions:M.actions,requiredPlan:M.requiredPlan}).catch(t=>k(me(t instanceof Error?t.message:"","Checkout failed"))),className:"h-7 rounded-full border border-amber-200/25 bg-amber-200/15 px-3 text-micro font-semibold text-amber-50 transition-colors hover:bg-amber-200/20",children:"Upgrade"}),e.jsx("button",{type:"button",onClick:()=>void Yt({actions:M.actions}).catch(t=>k(me(t instanceof Error?t.message:"","Portal failed"))),className:"h-7 rounded-full border border-strong bg-white/[0.04] px-3 text-micro font-semibold text-primary transition-colors hover:bg-white/[0.08]",children:"Billing"}),C&&e.jsx("button",{type:"button",onClick:C,className:"h-7 rounded-full border border-strong bg-white/[0.04] px-2.5 text-micro font-semibold text-primary transition-colors hover:bg-white/[0.08]",children:"Settings"})]}),(at=M.actions)!=null&&at.pricing?e.jsx("a",{href:M.actions.pricing,target:"_blank",rel:"noopener noreferrer",className:"text-micro text-secondary underline decoration-white/20 hover:text-primary",children:"View pricing"}):null]})]})},"upgrade"):qe==="error"&&st?e.jsx(ee.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.18},className:"rounded-xl border border-red-400/25 bg-red-500/[0.08] px-3 py-2 text-caption text-red-100",children:st},"error"):qe==="notice"&&V?e.jsx(ee.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.18},className:"rounded-xl border border-white/[0.1] bg-white/[0.03] px-3 py-2 text-caption text-primary",children:V},"notice"):null})}),e.jsxs("div",{className:`flex-1 space-y-2.5 overflow-y-auto overscroll-y-contain px-3 pb-3 ${b?"pt-1":"pt-2.5"}`,children:[!K&&Ye>0?e.jsxs("div",{className:"flex flex-col gap-2.5 px-0.5 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-micro uppercase tracking-[0.08em] text-muted",children:S==="initiative"?"Initiatives":S==="milestone"?"Milestone slices":Xe==="blocked"?"Needs attention":Xe==="running"?"Running now":"Queue"}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[ae>0?e.jsxs("span",{className:"chip text-micro",children:[ae," selected"]}):null,e.jsx("span",{className:O("inline-flex min-w-[92px] text-micro text-muted transition-opacity",He&&!K?"opacity-100":"opacity-0"),"aria-live":"polite",children:"refreshing…"}),z&&X&&!p&&ae===0?e.jsx("span",{className:"text-micro text-muted",children:"Shift+select to pick ranges."}):null]})]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5 sm:justify-end",children:[A?e.jsx("button",{type:"button",onClick:()=>F(!p),className:"control-pill h-8 px-2.5 text-caption font-semibold",title:p?"Switch to expanded cards":"Switch to compact list","aria-label":p?"Expand Next Up queue":"Compact Next Up queue",children:p?"Expand":"Compact"}):null,rt?e.jsx("div",{className:"flex flex-wrap justify-end gap-1.5",children:it}):null,!rt&&m&&X?e.jsxs("div",{ref:Ve,className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>be(t=>!t),className:"control-pill h-8 px-2.5 text-caption font-semibold","aria-haspopup":"menu","aria-expanded":fe,title:"Queue settings",children:[e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"opacity-85","aria-hidden":!0,children:[e.jsx("path",{d:"M4 6h16"}),e.jsx("path",{d:"M7 12h10"}),e.jsx("path",{d:"M10 18h4"})]}),e.jsx("span",{children:"Queue"})]}),fe?e.jsx("div",{className:"surface-tier-2 absolute right-0 top-[calc(100%+8px)] z-[280] w-[320px] max-w-[86vw] rounded-xl p-3 shadow-[0_18px_42px_rgba(0,0,0,0.46)] backdrop-blur-xl",children:e.jsxs("div",{className:"space-y-2.5",children:[z&&!p?e.jsxs("div",{children:[e.jsx("p",{className:"section-kicker",children:"Bulk actions"}),e.jsx("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:it})]}):null,C?e.jsx("button",{type:"button",onClick:()=>{be(!1),C()},className:"control-pill h-7 px-2.5 text-micro font-semibold",children:"Open settings"}):null]})}):null]}):null]})]}):null,K?e.jsx(an,{compact:p}):null,!K&&!Et&&!$e&&e.jsxs("div",{className:"rounded-xl border border-white/[0.08] bg-white/[0.02] px-3 py-4 text-center",children:[e.jsx("p",{className:"text-body text-secondary",children:At}),_e?e.jsx("p",{className:"mt-1 text-micro text-muted",children:_e}):null,re.length>0?e.jsx("div",{className:"mt-2.5 flex items-center justify-center gap-1.5",children:e.jsx("button",{type:"button",onClick:()=>{Ie(!1),St()},className:"control-pill h-7 px-2.5 text-micro font-semibold",children:"Retry now"})}):null]}),!K&&S==="initiative"?e.jsx(je,{initial:!1,children:Le.map((t,o)=>{const a=t.items.find(I=>I.queueState!=="running"&&I.queueState!=="completed")??t.items[0]??null,r=Ce(t.initiativeTitle,t.initiativeId,"Initiative"),h=dt(t.queueState),v=ut(t.queueState),E=t.items.reduce((I,j)=>I+(j.sliceTaskCount??0),0);return e.jsxs(ee.article,{layout:!0,initial:{opacity:0,y:8,scale:.99},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.99},transition:{duration:.2,delay:Math.min(o,7)*.02,ease:[.22,1,.36,1]},className:"rounded-2xl border border-white/[0.08] bg-white/[0.02] px-3 py-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-micro uppercase tracking-[0.08em] text-muted",children:"Initiative"}),e.jsx("p",{className:"mt-0.5 truncate text-body font-semibold text-white",title:r,children:r})]}),e.jsx("span",{className:O("inline-flex items-center rounded-full border px-2 py-0.5 text-[10px] font-semibold uppercase tracking-[0.08em]",v),children:h})]}),e.jsxs("p",{className:"mt-1 text-micro text-secondary",children:[t.workstreamCount," workstreams · ",E," tasks"]}),e.jsx("div",{className:"mt-2 space-y-1",children:t.items.slice(0,3).map((I,j)=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-lg border border-white/[0.06] bg-black/[0.18] px-2.5 py-1.5 text-caption",children:[e.jsx("span",{className:"truncate text-white/84",children:R(I.workstreamTitle)}),e.jsxs("span",{className:"text-micro text-secondary",children:[I.sliceTaskCount??0," tasks"]})]},`${I.workstreamId}:${j}`))}),e.jsxs("div",{className:"mt-2.5 flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>q==null?void 0:q(t.initiativeId,t.initiativeTitle),className:"control-pill h-7 px-2.5 text-micro font-semibold",children:"Open"}),e.jsx("button",{type:"button",disabled:!a||Q===`initiative:${t.initiativeId}`,onClick:()=>{a&&ie(`initiative:${t.initiativeId}`,()=>nt(a),`Dispatched ${R(a.workstreamTitle)}.`)},className:"control-pill h-7 px-2.5 text-micro font-semibold disabled:opacity-45",children:"Dispatch"})]})]},`initiative-group:${t.initiativeId}`)})}):null,!K&&S==="milestone"?e.jsx(je,{initial:!1,children:Pe.map((t,o)=>{const a=t.item,r=`milestone:${t.workstreamId}:${t.milestoneId??"none"}`;return e.jsxs(ee.article,{layout:!0,initial:{opacity:0,y:8,scale:.99},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.99},transition:{duration:.2,delay:Math.min(o,7)*.02,ease:[.22,1,.36,1]},className:"rounded-2xl border border-white/[0.08] bg-white/[0.02] px-3 py-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-micro uppercase tracking-[0.08em] text-muted",children:[R(t.initiativeTitle)," · ",R(t.workstreamTitle)]}),e.jsx("p",{className:"mt-0.5 truncate text-body font-semibold text-white",title:t.milestoneTitle,children:R(t.milestoneTitle)})]}),e.jsx("span",{className:O("inline-flex items-center rounded-full border px-2 py-0.5 text-[10px] font-semibold uppercase tracking-[0.08em]",ut(t.queueState)),children:dt(t.queueState)})]}),e.jsxs("p",{className:"mt-1 text-micro text-secondary",children:[t.taskCount," tasks in slice"]}),e.jsxs("div",{className:"mt-2.5 flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>q==null?void 0:q(t.initiativeId,t.initiativeTitle),className:"control-pill h-7 px-2.5 text-micro font-semibold",children:"Open"}),e.jsx("button",{type:"button",disabled:Q===r||t.queueState==="running",onClick:()=>void ie(r,()=>nt(a),h=>De(a,h)),className:"control-pill h-7 px-2.5 text-micro font-semibold disabled:opacity-45",children:t.queueState==="running"?"Running":"Start"})]})]},`${t.initiativeId}:${t.workstreamId}:${t.milestoneId??"none"}`)})}):null,!K&&X&&p?e.jsx(je,{initial:!1,children:B.map((t,o)=>{const a=U(t),r=Q===a,h=t.queueState==="running",v=t.nextTaskDueAt?xt(t.nextTaskDueAt):null,E=Ce(t.initiativeTitle,t.initiativeId,"Initiative"),I=Ce(t.workstreamTitle,t.workstreamId,"Workstream"),j=gt(t),Y=t.nextTaskTitle?R(t.nextTaskTitle):null,Te=t.blockReason?R(t.blockReason):null,Fe=yt(t),ve=wt(t);return e.jsxs(ee.article,{layout:!0,initial:{opacity:0,y:6,scale:.99},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.99},transition:{duration:.22,delay:Math.min(o,7)*.018,ease:[.22,1,.36,1]},className:"group relative overflow-visible rounded-2xl border border-white/[0.08] bg-white/[0.02] px-2.5 py-2 cursor-pointer transition-colors hover:border-white/[0.14]",onClick:()=>L==null?void 0:L(t),role:"button",tabIndex:0,onKeyDown:G=>{(G.key==="Enter"||G.key===" ")&&(G.preventDefault(),L==null||L(t))},children:[e.jsx("div",{className:`pointer-events-none absolute inset-x-2.5 top-0 h-px bg-gradient-to-r ${bt(t.queueState)}`,"aria-hidden":!0}),e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[e.jsx(pt,{name:Fe,hint:kt(t,Fe),size:"xs"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx(Ne,{type:"initiative",size:11,className:"flex-shrink-0 opacity-85"}),e.jsx("button",{type:"button",onClick:()=>q==null?void 0:q(t.initiativeId,t.initiativeTitle),className:"block min-w-0 flex-1 truncate text-left text-micro uppercase tracking-[0.08em] text-muted transition-colors hover:text-white/72",title:E,children:E}),j?e.jsx("span",{className:O("inline-flex flex-shrink-0 items-center rounded-full border px-2 py-0.5 text-[9px] font-semibold uppercase tracking-[0.08em]",j.toneClass),title:j.longLabel,children:j.shortLabel}):null]}),e.jsxs("p",{className:"mt-0.5 flex min-w-0 items-center gap-1.5 text-caption font-semibold leading-snug text-white",title:I,children:[e.jsx(Ne,{type:"workstream",size:12,className:"flex-shrink-0 opacity-95"}),e.jsx("span",{className:"line-clamp-2",children:I})]}),Y?e.jsxs("p",{className:"mt-0.5 line-clamp-2 text-micro leading-snug text-secondary",title:`${Qe(t.queueState)}: ${Y}${v?` · ${v}`:""}`,children:[Qe(t.queueState),": ",Y,v?` · ${v}`:""]}):e.jsx("p",{className:"mt-0.5 line-clamp-2 text-micro leading-snug text-secondary",title:Ue(t),children:Ue(t)}),ve?e.jsxs("p",{className:"mt-0.5 text-micro text-muted",children:["Runner ",ve]}):null]})]}),Te&&e.jsxs("div",{className:"mt-1.5 rounded-lg border border-red-400/24 bg-red-500/[0.08] px-2.5 py-1 text-micro text-red-100/85",children:["Blocked: ",Te]}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",onClick:G=>G.stopPropagation(),children:[e.jsx("button",{type:"button",disabled:r||h,onClick:()=>void ie(a,()=>Re({initiativeId:t.initiativeId,workstreamId:t.workstreamId,agentId:t.runnerAgentId}),G=>De(t,G)),className:"control-pill flex h-7 items-center justify-center px-2.5 text-micro font-semibold disabled:opacity-40",title:h?"Already running":"Start now",children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(ft,{className:"h-3 w-3 opacity-85"}),e.jsx("span",{children:h?"Running":"Start"})]})}),e.jsxs("div",{className:"relative ml-auto",children:[e.jsx("button",{type:"button",disabled:r,onClick:()=>se(G=>G===a?null:a),className:"control-pill flex h-7 items-center justify-center px-2.5 text-micro font-semibold disabled:opacity-40",title:"Queue actions",children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(vt,{className:"h-3 w-3 opacity-85"}),e.jsx("span",{children:"More"})]})}),le===a&&e.jsxs("div",{className:"absolute right-0 top-[calc(100%+6px)] z-[320] min-w-[178px] rounded-xl border border-white/[0.1] bg-[#080d14]/95 p-1.5 shadow-[0_16px_36px_rgba(0,0,0,0.42)] backdrop-blur",children:[e.jsx("button",{type:"button",onClick:()=>{se(null),ie(`${a}:top`,()=>H.move({initiativeId:t.initiativeId,workstreamId:t.workstreamId,placement:"top"}),`Moved ${I} to top of queue.`)},className:"flex h-8 w-full items-center rounded-md px-2.5 text-left text-caption text-primary transition-colors hover:bg-white/[0.08]",children:"Move to top"}),e.jsx("button",{type:"button",onClick:()=>{se(null),ie(`${a}:bottom`,()=>H.move({initiativeId:t.initiativeId,workstreamId:t.workstreamId,placement:"bottom"}),`Moved ${I} to bottom of queue.`)},className:"flex h-8 w-full items-center rounded-md px-2.5 text-left text-caption text-primary transition-colors hover:bg-white/[0.08]",children:"Move to bottom"}),e.jsx("button",{type:"button",onClick:()=>{se(null),ie(`${a}:auto`,async()=>(await H.move({initiativeId:t.initiativeId,workstreamId:t.workstreamId,placement:"top"}),Ge({initiativeId:t.initiativeId,workstreamId:t.workstreamId,agentId:t.runnerAgentId,scope:"initiative"})),`Start+Auto enabled for ${E}.`)},className:"flex h-8 w-full items-center rounded-md px-2.5 text-left text-caption text-primary transition-colors hover:bg-white/[0.08]",children:"Start with auto"}),e.jsx("button",{type:"button",disabled:H.isRemoving,onClick:()=>{se(null),tt(t)},className:"mt-1 flex h-8 w-full items-center rounded-md px-2.5 text-left text-caption text-red-100 transition-colors hover:bg-red-500/[0.12] disabled:opacity-45",children:"Remove from queue"})]})]})]})]},a)})}):!K&&X?e.jsx(Ht,{axis:"y",values:de,onReorder:t=>{Ee.current=t,Oe(t)},className:"space-y-2.5",children:de.map(t=>et.get(t)).filter(Boolean).map((t,o)=>e.jsx(ln,{item:t,index:o,actionKey:Q,setNotice:k,setUpgradeGate:ne,onUpgradeGate:_,onOpenInitiative:q,onOpenSliceDetail:L,selected:Z.has(U(t)),selectionEnabled:z,onToggleSelection:Ft,menuKey:le,setMenuKey:se,playWorkstream:Re,startWorkstreamAutoContinue:Ge,triagePlacement:he,onPauseWorkstream:(a,r)=>H.stopTriage({initiativeId:a.initiativeId,workstreamId:a.workstreamId,placement:r,resetToTodo:!1}),onMoveWorkstream:(a,r)=>H.move({initiativeId:a.initiativeId,workstreamId:a.workstreamId,placement:r}),onCommitReorder:()=>void Rt().catch(()=>null),onDismiss:tt,runAction:ie},U(t)))}):null]}),e.jsx("div",{className:"pointer-events-none absolute bottom-3 right-3 z-[250]",children:e.jsx(en,{open:Pt,tone:"warning",title:"Limited signal",message:_e,autoDismissMs:6e3,onDismiss:()=>Ie(!0)})})]})}function ln({item:n,index:s,actionKey:l,setNotice:i,setUpgradeGate:f,onUpgradeGate:b,onOpenInitiative:N,onOpenSliceDetail:g,selected:$,selectionEnabled:A,onToggleSelection:J,menuKey:q,setMenuKey:C,playWorkstream:_,startWorkstreamAutoContinue:L,triagePlacement:z,onPauseWorkstream:te,onMoveWorkstream:m,onCommitReorder:x,onDismiss:u,runAction:c}){const y=Gt(),[T,p]=d.useState(!1),F=`${n.initiativeId}:${n.workstreamId}`,V=l===F,k=n.queueState==="running",S=n.nextTaskDueAt?xt(n.nextTaskDueAt):null,xe=Ce(n.initiativeTitle,n.initiativeId,"Initiative"),oe=Ce(n.workstreamTitle,n.workstreamId,"Workstream"),pe=gt(n),he=n.nextTaskTitle?R(n.nextTaskTitle):null,M=n.blockReason?R(n.blockReason):null,ne=yt(n),Q=wt(n);return e.jsx(Jt,{value:F,id:F,dragListener:!1,dragControls:y,onDragStart:()=>p(!0),onDragEnd:()=>{p(!1),x()},whileDrag:{scale:1.02,boxShadow:"0 20px 48px rgba(0,0,0,0.5), 0 0 0 1px rgba(191,255,0,0.15)",zIndex:50,cursor:"grabbing"},className:"relative",children:e.jsxs(ee.article,{layout:!0,initial:{opacity:0,y:12,scale:.97},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.98},transition:{duration:.4,ease:[.25,.1,.25,1],delay:Math.min(s,7)*.05,opacity:{duration:.32,ease:[.25,.1,.25,1]}},className:"group relative overflow-visible rounded-2xl border border-white/[0.08] bg-white/[0.02] px-3 py-3 cursor-pointer transition-colors hover:border-white/[0.14]",onClick:()=>g==null?void 0:g(n),role:"button",tabIndex:0,onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),g==null||g(n))},children:[e.jsx("div",{className:`pointer-events-none absolute inset-x-3 top-0 h-px bg-gradient-to-r ${bt(n.queueState)}`,"aria-hidden":!0}),e.jsx("div",{className:"flex items-start justify-between gap-2.5",children:e.jsxs("div",{className:"min-w-0 flex flex-1 items-start gap-2.5",children:[e.jsxs("div",{className:"relative h-8 w-8 flex-shrink-0",children:[e.jsx("div",{className:`absolute inset-0 transition-[opacity,transform] duration-200 ease-out ${A?$?"opacity-0 scale-90":"opacity-100 scale-100 group-hover:opacity-0 group-hover:scale-90 group-focus-within:opacity-0 group-focus-within:scale-90":"opacity-100 scale-100"}`,children:e.jsx(pt,{name:ne,hint:kt(n,ne),size:"sm"})}),A?e.jsx("button",{type:"button",role:"checkbox","aria-checked":$,"aria-label":"Select queue row",title:$?"Selected (Shift+click for range)":"Select (Shift+click for range)",onClick:w=>{w.stopPropagation(),J(F,!$,w.shiftKey)},onMouseDown:w=>w.stopPropagation(),onKeyDown:w=>w.stopPropagation(),className:`absolute inset-0 flex items-center justify-center rounded-full border transition-[opacity,transform,background-color,border-color,color] duration-200 ease-out ${$?"opacity-100 scale-100 border-[#BFFF00]/40 bg-[#BFFF00]/18 text-[#E1FFB2]":"opacity-0 scale-90 border-white/[0.24] bg-black/55 text-white/78 group-hover:opacity-100 group-hover:scale-100 group-focus-within:opacity-100 group-focus-within:scale-100 hover:bg-black/62"}`,children:e.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center rounded-full border border-current/45 bg-black/30",children:$?e.jsx("svg",{viewBox:"0 0 16 16",className:"h-2.5 w-2.5",fill:"none","aria-hidden":!0,children:e.jsx("path",{d:"M3.2 8.3 6.2 11l6.6-6.1",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}):null})}):null]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx(Ne,{type:"initiative",size:11,className:"flex-shrink-0 opacity-85"}),e.jsx("button",{type:"button",onClick:()=>N==null?void 0:N(n.initiativeId,n.initiativeTitle),className:"block min-w-0 flex-1 truncate text-left text-micro uppercase tracking-[0.08em] text-muted transition-colors hover:text-white/72",title:xe,children:xe}),pe?e.jsx("span",{className:O("inline-flex flex-shrink-0 items-center rounded-full border px-2 py-0.5 text-[9px] font-semibold uppercase tracking-[0.08em]",pe.toneClass),title:pe.longLabel,children:pe.shortLabel}):null]}),e.jsxs("div",{className:"mt-0.5 flex min-w-0 items-start gap-1.5",children:[e.jsx(Ne,{type:"workstream",size:12,className:"mt-[3px] flex-shrink-0 opacity-95"}),e.jsx("p",{className:"min-w-0 line-clamp-2 text-body font-semibold leading-snug text-white",title:oe,children:oe})]}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-2 text-micro text-secondary",children:[e.jsx("span",{className:"rounded-full border border-strong bg-white/[0.03] px-2 py-0.5 text-micro uppercase tracking-[0.08em] text-secondary",children:"Runner"}),e.jsxs("span",{className:"truncate text-white/68",children:[ne,Q?` · ${Q}`:""]})]})]})]})}),e.jsx("div",{className:"mt-2 rounded-lg border border-white/[0.07] bg-black/[0.18] px-2.5 py-2 text-caption text-white/68",children:he?e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1 text-micro uppercase tracking-[0.08em] text-white/44",children:[e.jsx(Ne,{type:"task",size:10,className:"flex-shrink-0 opacity-80"}),e.jsx("span",{children:Qe(n.queueState)}),S?e.jsxs("span",{className:"truncate text-micro normal-case tracking-normal text-muted",children:["· ",S]}):null]}),e.jsx("p",{className:"line-clamp-2 break-words text-caption leading-snug text-white/84",title:he,children:he})]}):e.jsx("span",{className:"text-secondary",children:Ue(n)})}),M&&e.jsxs("div",{className:"mt-1.5 rounded-lg border border-red-400/24 bg-red-500/[0.08] px-2.5 py-1 text-micro text-red-100/85",children:["Blocked: ",M]}),e.jsxs("div",{className:"mt-2 flex items-center gap-1.5",onClick:w=>w.stopPropagation(),children:[e.jsx("button",{type:"button",disabled:V||k,onClick:()=>void c(F,()=>_({initiativeId:n.initiativeId,workstreamId:n.workstreamId,agentId:n.runnerAgentId}),w=>De(n,w)),className:"control-pill flex h-7 items-center justify-center px-2.5 text-micro font-semibold disabled:opacity-40",title:k?"Already running":"Start this workstream now",children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(ft,{className:"h-3 w-3 opacity-85"}),e.jsx("span",{children:k?"Running":"Start"})]})}),e.jsxs("button",{type:"button",onPointerDown:w=>y.start(w),"aria-label":"Drag to reorder",title:T?"Reordering":"Drag to reorder",className:`control-pill flex h-7 items-center justify-center gap-1 px-2 text-micro font-semibold transition-colors ${T?"border-[#BFFF00]/35 bg-[#BFFF00]/14 text-[#E1FFB2] cursor-grabbing":"cursor-grab hover:bg-white/[0.08] hover:text-bright"}`,children:[T?e.jsx(nn,{className:"h-3.5 w-3.5 opacity-90"}):e.jsx(tn,{className:"h-3.5 w-3.5 opacity-90"}),e.jsx("span",{children:T?"Reordering":"Drag"})]}),e.jsxs("div",{className:"relative ml-auto",children:[e.jsx("button",{type:"button",disabled:V,onClick:()=>C(w=>w===F?null:F),className:"control-pill flex h-7 items-center justify-center px-2.5 text-micro font-semibold disabled:opacity-40",title:"Queue actions",children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(vt,{className:"h-3 w-3 opacity-85"}),e.jsx("span",{children:"More"})]})}),q===F&&e.jsxs("div",{className:"absolute right-0 top-[calc(100%+6px)] z-[320] min-w-[198px] rounded-xl border border-white/[0.1] bg-[#080d14]/95 p-1.5 shadow-[0_16px_36px_rgba(0,0,0,0.42)] backdrop-blur",children:[e.jsx("button",{type:"button",onClick:()=>{C(null),c(`${F}:top`,()=>m(n,"top"),`Moved ${oe} to top of queue.`)},className:"flex h-8 w-full items-center rounded-md px-2.5 text-left text-caption text-primary transition-colors hover:bg-white/[0.08]",children:"Move to top"}),e.jsx("button",{type:"button",onClick:()=>{C(null),c(`${F}:bottom`,()=>m(n,"bottom"),`Moved ${oe} to bottom of queue.`)},className:"flex h-8 w-full items-center rounded-md px-2.5 text-left text-caption text-primary transition-colors hover:bg-white/[0.08]",children:"Move to bottom"}),e.jsx("button",{type:"button",onClick:()=>{C(null),c(`${F}:auto`,async()=>(await m(n,"top"),L({initiativeId:n.initiativeId,workstreamId:n.workstreamId,agentId:n.runnerAgentId,scope:"initiative"})),`Start+Auto enabled for ${xe}.`)},className:"flex h-8 w-full items-center rounded-md px-2.5 text-left text-caption text-primary transition-colors hover:bg-white/[0.08]",children:"Start with auto"}),k?e.jsx("button",{type:"button",onClick:()=>{C(null),c(`${F}:pause`,()=>te(n,z),`Paused ${oe}.`)},className:"mt-1 flex h-8 w-full items-center rounded-md px-2.5 text-left text-caption text-primary transition-colors hover:bg-white/[0.08]",children:"Pause run"}):null,e.jsx("button",{type:"button",disabled:V||k,onClick:()=>{C(null),u(n)},className:"mt-1 flex h-8 w-full items-center rounded-md px-2.5 text-left text-caption text-red-100 transition-colors hover:bg-red-500/[0.12] disabled:opacity-45",children:"Remove from queue"})]})]})]})]})})}const xn=Object.freeze(Object.defineProperty({__proto__:null,NextUpPanel:on},Symbol.toStringTag,{value:"Module"}));export{en as I,on as N,xn as a,Xt as o,Zt as u};
@@ -10,13 +10,13 @@
10
10
  <meta name="googlebot" content="noindex, nofollow, noarchive, nosnippet, noimageindex" />
11
11
  <meta name="copyright" content="OrgX. All rights reserved." />
12
12
  <title>OrgX Live Dashboard</title>
13
- <script type="module" crossorigin src="/orgx/live/assets/C9jy61eu.js"></script>
13
+ <script type="module" crossorigin src="/orgx/live/assets/Cn07669c.js"></script>
14
14
  <link rel="modulepreload" crossorigin href="/orgx/live/assets/C-KIc3Wc.js">
15
15
  <link rel="modulepreload" crossorigin href="/orgx/live/assets/BJgZIVUQ.js">
16
16
  <link rel="modulepreload" crossorigin href="/orgx/live/assets/cNrhgGc1.js">
17
17
  <link rel="modulepreload" crossorigin href="/orgx/live/assets/CxQ08qFN.js">
18
18
  <link rel="stylesheet" crossorigin href="/orgx/live/assets/qm8xLgv-.css">
19
- <link rel="stylesheet" crossorigin href="/orgx/live/assets/BzRbDCAD.css">
19
+ <link rel="stylesheet" crossorigin href="/orgx/live/assets/BZZKPNDb.css">
20
20
  </head>
21
21
  <body class="bg-[#080808] text-white antialiased">
22
22
  <div id="root"></div>
Binary file
Binary file
@@ -175,6 +175,17 @@ export function createAutoContinueEngine(deps) {
175
175
  pendingQuestionAutoAnswerByScope.delete(key);
176
176
  }
177
177
  };
178
+ const hasPendingQuestionAutoAnswerStateForInitiative = (initiativeId) => {
179
+ const normalizedInitiativeId = (initiativeId ?? "").trim();
180
+ if (!normalizedInitiativeId)
181
+ return false;
182
+ for (const pending of pendingQuestionAutoAnswerByScope.values()) {
183
+ if ((pending.initiativeId ?? "").trim() === normalizedInitiativeId) {
184
+ return true;
185
+ }
186
+ }
187
+ return false;
188
+ };
178
189
  const processQuestionAutoAnswer = async (key, pending) => {
179
190
  pendingQuestionAutoAnswerByScope.delete(key);
180
191
  const note = pending.action === "approve"
@@ -606,6 +617,14 @@ export function createAutoContinueEngine(deps) {
606
617
  const inferredSourceClient = normalizeRuntimeSourceClient(metadataSourceClient ??
607
618
  process.env.ORGX_AUTOPILOT_EXECUTOR ??
608
619
  process.env.ORGX_AUTOPILOT_WORKER_KIND);
620
+ const sourceRefSourceClient = (typeof sourceRefBase.source_client === "string" &&
621
+ sourceRefBase.source_client.trim().length > 0
622
+ ? sourceRefBase.source_client.trim()
623
+ : null) ??
624
+ (typeof sourceRefBase.sourceClient === "string" &&
625
+ sourceRefBase.sourceClient.trim().length > 0
626
+ ? sourceRefBase.sourceClient.trim()
627
+ : null);
609
628
  const normalizedInput = {
610
629
  ...input,
611
630
  sourceRunId: inferredRunId,
@@ -617,26 +636,24 @@ export function createAutoContinueEngine(deps) {
617
636
  session_id: sourceRefBase.session_id ?? inferredSessionId,
618
637
  stream_id: sourceRefBase.stream_id ?? inferredStreamId,
619
638
  workstream_id: sourceRefBase.workstream_id ?? input.workstreamId ?? null,
620
- source_client: sourceRefBase.source_client ??
621
- sourceRefBase.sourceClient ??
622
- inferredSourceClient,
639
+ source_client: sourceRefSourceClient ?? inferredSourceClient,
623
640
  },
624
641
  metadata: {
625
642
  ...metadataBase,
626
643
  source_system: input.sourceSystem ?? null,
627
644
  conflict_source: input.conflictSource ?? null,
628
- source_client: metadataBase.source_client ??
629
- metadataBase.sourceClient ??
630
- inferredSourceClient,
645
+ source_client: metadataSourceClient ?? inferredSourceClient,
631
646
  },
632
647
  };
633
648
  const linkedSlice = inferredRunId ? autoContinueSliceRuns.get(inferredRunId) ?? null : null;
634
- const sourceClientFromInput = typeof normalizedInput.metadata?.source_client === "string"
635
- ? normalizedInput.metadata.source_client
649
+ const sourceClientFromInput = typeof normalizedInput.metadata?.source_client === "string" &&
650
+ normalizedInput.metadata.source_client.trim().length > 0
651
+ ? normalizedInput.metadata.source_client.trim()
636
652
  : null;
637
- const sourceClient = sourceClientFromInput ??
653
+ const sourceClient = normalizeRuntimeSourceClient(sourceClientFromInput ??
638
654
  linkedSlice?.sourceClient ??
639
- "unknown";
655
+ process.env.ORGX_AUTOPILOT_EXECUTOR ??
656
+ process.env.ORGX_AUTOPILOT_WORKER_KIND);
640
657
  const scopedWorkstreamId = ((typeof normalizedInput.workstreamId === "string" &&
641
658
  normalizedInput.workstreamId.trim().length > 0
642
659
  ? normalizedInput.workstreamId.trim()
@@ -1376,7 +1393,8 @@ export function createAutoContinueEngine(deps) {
1376
1393
  .map((entry) => entry.trim())
1377
1394
  .filter(Boolean)
1378
1395
  : [];
1379
- const preserveQuestionAutoAnswerState = input.reason === "blocked" && decisionRequired && decisionIds.length > 0;
1396
+ const preserveQuestionAutoAnswerState = (input.reason === "blocked" && decisionRequired && decisionIds.length > 0) ||
1397
+ hasPendingQuestionAutoAnswerStateForInitiative(input.run.initiativeId);
1380
1398
  const now = new Date().toISOString();
1381
1399
  ensureRunInternals(input.run);
1382
1400
  const activeRunIds = listActiveSliceRunIds(input.run);
@@ -236,10 +236,6 @@ export function parseSliceResult(raw) {
236
236
  }
237
237
  const normalizedStatus = typeof nextRecord.status === "string" ? nextRecord.status : status;
238
238
  if (normalizedStatus === "completed") {
239
- const hasExplicitOutcomeArrays = Array.isArray(record.artifacts) ||
240
- Array.isArray(record.task_updates) ||
241
- Array.isArray(record.milestone_updates) ||
242
- Array.isArray(record.decisions_needed);
243
239
  const artifactsCount = Array.isArray(nextRecord.artifacts) ? nextRecord.artifacts.length : 0;
244
240
  const taskUpdatesCount = Array.isArray(nextRecord.task_updates)
245
241
  ? nextRecord.task_updates.length
@@ -250,7 +246,7 @@ export function parseSliceResult(raw) {
250
246
  const hasOutcomes = artifactsCount > 0 ||
251
247
  taskUpdatesCount > 0 ||
252
248
  milestoneUpdatesCount > 0;
253
- if (hasExplicitOutcomeArrays && !hasOutcomes) {
249
+ if (!hasOutcomes) {
254
250
  changed = true;
255
251
  nextRecord = { ...nextRecord, status: "error" };
256
252
  }
@@ -304,6 +300,9 @@ export function parseSliceResult(raw) {
304
300
  const fromText = parseEmbeddedText(candidateRecord.text);
305
301
  if (fromText)
306
302
  return fromText;
303
+ const fromContent = parseEmbeddedText(candidateRecord.content);
304
+ if (fromContent)
305
+ return fromContent;
307
306
  const fromOutputText = parseEmbeddedText(candidateRecord.output_text);
308
307
  if (fromOutputText)
309
308
  return fromOutputText;
@@ -344,11 +343,9 @@ export function parseSliceResult(raw) {
344
343
  if (parsedResult)
345
344
  return parsedResult;
346
345
  }
347
- if (typeof record.output_text === "string") {
348
- const parsedOutputText = parseSliceJsonText(record.output_text);
349
- if (parsedOutputText)
350
- return parsedOutputText;
351
- }
346
+ const parsedTopLevelOutputText = parseEmbeddedText(record.output_text);
347
+ if (parsedTopLevelOutputText)
348
+ return parsedTopLevelOutputText;
352
349
  // Responses-style envelopes can return text in output/message/content arrays.
353
350
  const output = record.output;
354
351
  if (Array.isArray(output)) {
@@ -117,9 +117,9 @@ export function normalizeOpenClawProvider(value) {
117
117
  return "anthropic";
118
118
  if (raw === "anthropic")
119
119
  return "anthropic";
120
- if (raw === "openrouter" || raw === "open-router")
120
+ if (raw === "openrouter" || raw === "open-router" || raw === "open_router")
121
121
  return "openrouter";
122
- if (raw === "openai")
122
+ if (raw === "openai" || raw === "openai-codex")
123
123
  return "openai";
124
124
  return null;
125
125
  }
@@ -18,10 +18,12 @@
18
18
  * /orgx/api/runs/:id/actions/:action → run control action
19
19
  */
20
20
  import { readFileSync, existsSync, readdirSync, statSync, openSync, readSync, closeSync, } from "node:fs";
21
+ import { execFile } from "node:child_process";
21
22
  import { homedir } from "node:os";
22
23
  import { join, dirname, extname, normalize, resolve, relative, sep } from "node:path";
23
24
  import { fileURLToPath } from "node:url";
24
25
  import { randomUUID } from "node:crypto";
26
+ import { promisify } from "node:util";
25
27
  import { readNextUpQueuePins, removeNextUpQueuePin, setNextUpQueuePinOrder, suppressNextUpQueueItem, upsertNextUpQueuePin, } from "../next-up-queue-store.js";
26
28
  import { formatStatus, formatAgents, formatActivity, formatInitiatives, getOnboardingState, } from "../dashboard-api.js";
27
29
  import { loadLocalOpenClawSnapshot, loadLocalTurnDetail, toLocalLiveActivity, toLocalLiveAgents, toLocalLiveInitiatives, toLocalSessionTree, } from "../local-openclaw.js";
@@ -1219,6 +1221,8 @@ const IMMUTABLE_FILE_CACHE = new Map();
1219
1221
  const IMMUTABLE_FILE_CACHE_MAX = 128;
1220
1222
  const FILE_PREVIEW_MAX_BYTES = 1_000_000;
1221
1223
  const FILE_PREVIEW_MAX_DIR_ENTRIES = 300;
1224
+ const AUTOPILOT_LOGS_DIR = join(homedir(), ".config", "useorgx", "openclaw-plugin", "autopilot-logs");
1225
+ const execFileAsync = promisify(execFile);
1222
1226
  function sendJson(res, status, data) {
1223
1227
  const body = JSON.stringify(data);
1224
1228
  res.writeHead(status, {
@@ -1270,6 +1274,50 @@ function resolveFilesystemOpenPath(rawPath) {
1270
1274
  }
1271
1275
  return resolve(process.cwd(), value);
1272
1276
  }
1277
+ function resolveAutopilotLogCandidates(runId) {
1278
+ const sanitizedRunId = runId.trim().replaceAll(/[\\/]/g, "");
1279
+ if (!sanitizedRunId)
1280
+ return [];
1281
+ const directCandidates = [
1282
+ join(AUTOPILOT_LOGS_DIR, `${sanitizedRunId}.log`),
1283
+ join(AUTOPILOT_LOGS_DIR, `${sanitizedRunId}.output.json`),
1284
+ ];
1285
+ if (!existsSync(AUTOPILOT_LOGS_DIR)) {
1286
+ return directCandidates;
1287
+ }
1288
+ const discovered = readdirSync(AUTOPILOT_LOGS_DIR)
1289
+ .filter((entry) => entry.startsWith(`${sanitizedRunId}.`))
1290
+ .map((entry) => join(AUTOPILOT_LOGS_DIR, entry))
1291
+ .filter((entry) => entry.endsWith(".log") || entry.endsWith(".output.json"));
1292
+ return dedupeStrings([...directCandidates, ...discovered]);
1293
+ }
1294
+ async function openPathInTerminal(pathname) {
1295
+ const resolvedPath = resolve(pathname);
1296
+ if (process.platform === "darwin") {
1297
+ const escapedPath = resolvedPath
1298
+ .replaceAll("\\", "\\\\")
1299
+ .replaceAll('"', '\\"');
1300
+ await execFileAsync("osascript", [
1301
+ "-e",
1302
+ 'tell application "Terminal" to activate',
1303
+ "-e",
1304
+ `tell application "Terminal" to do script "tail -f \\"${escapedPath}\\""`,
1305
+ ]);
1306
+ return;
1307
+ }
1308
+ if (process.platform === "win32") {
1309
+ await execFileAsync("cmd", ["/c", "start", "", resolvedPath]);
1310
+ return;
1311
+ }
1312
+ try {
1313
+ await execFileAsync("gnome-terminal", ["--", "tail", "-f", resolvedPath]);
1314
+ return;
1315
+ }
1316
+ catch {
1317
+ // Fallback to generic opener when no terminal app is available.
1318
+ }
1319
+ await execFileAsync("xdg-open", [resolvedPath]);
1320
+ }
1273
1321
  function readFilePreview(pathname, totalBytes) {
1274
1322
  if (totalBytes <= 0) {
1275
1323
  return { previewBuffer: Buffer.alloc(0), truncated: false };
@@ -3369,6 +3417,8 @@ export function createHttpHandler(config, client, getSnapshot, onboarding, diagn
3369
3417
  readFilePreview,
3370
3418
  filePreviewMaxBytes: FILE_PREVIEW_MAX_BYTES,
3371
3419
  filePreviewMaxDirEntries: FILE_PREVIEW_MAX_DIR_ENTRIES,
3420
+ resolveAutopilotLogCandidates,
3421
+ openPathInTerminal,
3372
3422
  securityHeaders: SECURITY_HEADERS,
3373
3423
  corsHeaders: CORS_HEADERS,
3374
3424
  config: {
@@ -3509,10 +3559,116 @@ export function createHttpHandler(config, client, getSnapshot, onboarding, diagn
3509
3559
  }
3510
3560
  return [];
3511
3561
  },
3512
- getBlockerEvents: () => {
3513
- // Extract blocker events from recent activity
3514
- // In future, this will read from a dedicated blocker store
3515
- return [];
3562
+ getBlockerEvents: (workspaceId) => {
3563
+ const normalizedWorkspaceId = (workspaceId ?? "").trim();
3564
+ const scopedKeys = normalizedWorkspaceId
3565
+ ? [
3566
+ `live-snapshot:${normalizedWorkspaceId}`,
3567
+ `live-snapshot-v2:${normalizedWorkspaceId}`,
3568
+ `dashboard-bundle:${normalizedWorkspaceId}`,
3569
+ ]
3570
+ : [];
3571
+ const fallbackKeys = ["live-snapshot", "dashboard-bundle", "live-snapshot-v2"];
3572
+ const keys = [...scopedKeys, ...fallbackKeys];
3573
+ const seen = new Set();
3574
+ const mapped = [];
3575
+ const deriveFailureType = (eventNameRaw, actionTypeRaw) => {
3576
+ const eventName = (eventNameRaw ?? "").trim().toLowerCase();
3577
+ const actionType = (actionTypeRaw ?? "").trim().toLowerCase();
3578
+ const signature = `${eventName} ${actionType}`;
3579
+ if (!signature.trim())
3580
+ return null;
3581
+ if (signature.includes("status_updates_buffered"))
3582
+ return "status_updates_buffered";
3583
+ if (signature.includes("question_answer_failed"))
3584
+ return "question_answer_failed";
3585
+ if (signature.includes("spawn_guard_rate_limited"))
3586
+ return "spawn_guard_rate_limited";
3587
+ if (signature.includes("spawn_guard_blocked"))
3588
+ return "spawn_guard_blocked";
3589
+ if (signature.includes("mcp_handshake_failure") || signature.includes("mcp_handshake")) {
3590
+ return "mcp_handshake_failure";
3591
+ }
3592
+ if (signature.includes("worker_exit_no_output") ||
3593
+ signature.includes("worker_exit_without_structured_output") ||
3594
+ signature.includes("no_structured_output")) {
3595
+ return "worker_exit_no_output";
3596
+ }
3597
+ if (signature.includes("workspace_conflict"))
3598
+ return "workspace_conflict";
3599
+ if (signature.includes("budget_exhausted"))
3600
+ return "budget_exhausted";
3601
+ if (signature.includes("stale_blocked_workstream"))
3602
+ return "stale_blocked_workstream";
3603
+ return null;
3604
+ };
3605
+ try {
3606
+ for (const key of keys) {
3607
+ const cached = readSnapshotResponseCache(key);
3608
+ if (!cached || typeof cached !== "object")
3609
+ continue;
3610
+ const activityRaw = cached.activity;
3611
+ if (!Array.isArray(activityRaw))
3612
+ continue;
3613
+ for (const entry of activityRaw) {
3614
+ if (!entry || typeof entry !== "object")
3615
+ continue;
3616
+ const activityRecord = entry;
3617
+ const metadataRecord = activityRecord.metadata && typeof activityRecord.metadata === "object"
3618
+ ? activityRecord.metadata
3619
+ : {};
3620
+ const failureType = deriveFailureType(pickString(metadataRecord, ["event", "event_name"]), pickString(metadataRecord, ["action_type", "actionType"]));
3621
+ if (!failureType)
3622
+ continue;
3623
+ const runId = pickString(metadataRecord, ["run_id", "source_run_id"]) ?? pickString(activityRecord, ["runId"]);
3624
+ const workstreamId = pickString(metadataRecord, ["workstream_id", "source_stream_id"]) ??
3625
+ pickString(activityRecord, ["workstreamId"]);
3626
+ const taskId = pickString(metadataRecord, ["task_id"]) ?? pickString(activityRecord, ["taskId"]);
3627
+ const initiativeId = pickString(metadataRecord, ["initiative_id"]) ??
3628
+ pickString(activityRecord, ["initiativeId"]);
3629
+ const timestamp = pickString(activityRecord, ["timestamp"]) ??
3630
+ pickString(metadataRecord, ["timestamp", "created_at"]);
3631
+ const dedupeId = pickString(activityRecord, ["id"]) ??
3632
+ `${failureType}:${initiativeId ?? "unknown"}:${workstreamId ?? "unknown"}:${runId ?? "unknown"}:${timestamp ?? "unknown"}`;
3633
+ if (seen.has(dedupeId))
3634
+ continue;
3635
+ seen.add(dedupeId);
3636
+ mapped.push({
3637
+ id: dedupeId,
3638
+ failureType,
3639
+ reason: pickString(metadataRecord, ["error", "reason", "message"]) ??
3640
+ pickString(activityRecord, ["description", "summary", "title"]),
3641
+ provider: pickString(metadataRecord, ["provider"]),
3642
+ initiativeId,
3643
+ initiativeTitle: pickString(metadataRecord, ["initiative_title"]) ??
3644
+ pickString(activityRecord, ["initiativeTitle"]),
3645
+ workstreamId,
3646
+ workstreamTitle: pickString(metadataRecord, ["workstream_title"]) ??
3647
+ pickString(activityRecord, ["workstreamTitle"]),
3648
+ taskId,
3649
+ taskTitle: pickString(metadataRecord, ["task_title"]) ?? pickString(activityRecord, ["taskTitle"]),
3650
+ agentId: pickString(metadataRecord, ["agent_id", "executor_agent_id"]) ??
3651
+ pickString(activityRecord, ["executorAgentId", "agentId"]),
3652
+ domain: pickString(metadataRecord, ["domain", "executor_domain"]),
3653
+ sourceSystem: pickString(metadataRecord, ["source_system", "source"]) ?? "openclaw",
3654
+ runId,
3655
+ logPath: pickString(metadataRecord, ["log_path"]),
3656
+ outputPath: pickString(metadataRecord, ["output_path"]),
3657
+ metadata: metadataRecord,
3658
+ timestamp: timestamp ?? undefined,
3659
+ });
3660
+ }
3661
+ }
3662
+ }
3663
+ catch {
3664
+ // best effort
3665
+ }
3666
+ mapped.sort((a, b) => {
3667
+ const aTs = Date.parse(String(a.timestamp ?? "")) || 0;
3668
+ const bTs = Date.parse(String(b.timestamp ?? "")) || 0;
3669
+ return bTs - aTs;
3670
+ });
3671
+ return mapped;
3516
3672
  },
3517
3673
  resolveDecisionAction: async (decisionId, action, note, optionId) => {
3518
3674
  try {
@@ -101,6 +101,8 @@ type RegisterLiveLegacyRoutesDeps<TRes extends RouteResLike> = {
101
101
  };
102
102
  filePreviewMaxBytes: number;
103
103
  filePreviewMaxDirEntries: number;
104
+ resolveAutopilotLogCandidates?: (runId: string) => string[];
105
+ openPathInTerminal?: (path: string) => Promise<void>;
104
106
  securityHeaders: Record<string, string>;
105
107
  corsHeaders: Record<string, string>;
106
108
  config: {