@useorgx/openclaw-plugin 0.7.15 → 0.7.17

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 (126) hide show
  1. package/dashboard/dist/assets/{CFZ4Swr5.js → 05zHA1Am.js} +1 -1
  2. package/dashboard/dist/assets/05zHA1Am.js.br +0 -0
  3. package/dashboard/dist/assets/05zHA1Am.js.gz +0 -0
  4. package/dashboard/dist/assets/0uYJrBLl.js +1 -0
  5. package/dashboard/dist/assets/0uYJrBLl.js.br +0 -0
  6. package/dashboard/dist/assets/0uYJrBLl.js.gz +0 -0
  7. package/dashboard/dist/assets/8nr6IqT4.js +1 -0
  8. package/dashboard/dist/assets/8nr6IqT4.js.br +0 -0
  9. package/dashboard/dist/assets/8nr6IqT4.js.gz +0 -0
  10. package/dashboard/dist/assets/{3VwNyxUf.js → B7kFLPiD.js} +1 -1
  11. package/dashboard/dist/assets/B7kFLPiD.js.br +0 -0
  12. package/dashboard/dist/assets/B7kFLPiD.js.gz +0 -0
  13. package/dashboard/dist/assets/{3TtV4moZ.js → B8NuBCcY.js} +1 -1
  14. package/dashboard/dist/assets/B8NuBCcY.js.br +0 -0
  15. package/dashboard/dist/assets/B8NuBCcY.js.gz +0 -0
  16. package/dashboard/dist/assets/{CnPC783_.js → BDlKSbsp.js} +1 -1
  17. package/dashboard/dist/assets/BDlKSbsp.js.br +0 -0
  18. package/dashboard/dist/assets/BDlKSbsp.js.gz +0 -0
  19. package/dashboard/dist/assets/C8AYbjlq.js +212 -0
  20. package/dashboard/dist/assets/C8AYbjlq.js.br +0 -0
  21. package/dashboard/dist/assets/C8AYbjlq.js.gz +0 -0
  22. package/dashboard/dist/assets/CMir7ekf.js +1 -0
  23. package/dashboard/dist/assets/CMir7ekf.js.br +0 -0
  24. package/dashboard/dist/assets/CMir7ekf.js.gz +0 -0
  25. package/dashboard/dist/assets/{CKrH5fYO.js → CWXk6UZl.js} +1 -1
  26. package/dashboard/dist/assets/CWXk6UZl.js.br +0 -0
  27. package/dashboard/dist/assets/CWXk6UZl.js.gz +0 -0
  28. package/dashboard/dist/assets/{Ctw95IkC.js → CoDun8X6.js} +1 -1
  29. package/dashboard/dist/assets/CoDun8X6.js.br +0 -0
  30. package/dashboard/dist/assets/CoDun8X6.js.gz +0 -0
  31. package/dashboard/dist/assets/{7DhYqBrM.js → Crj3jKHE.js} +1 -1
  32. package/dashboard/dist/assets/Crj3jKHE.js.br +0 -0
  33. package/dashboard/dist/assets/Crj3jKHE.js.gz +0 -0
  34. package/dashboard/dist/assets/{T2NFtzAv.js → CyUpNSKv.js} +1 -1
  35. package/dashboard/dist/assets/CyUpNSKv.js.br +0 -0
  36. package/dashboard/dist/assets/CyUpNSKv.js.gz +0 -0
  37. package/dashboard/dist/assets/{C9fvfXmS.js → D8mvKY2h.js} +1 -1
  38. package/dashboard/dist/assets/D8mvKY2h.js.br +0 -0
  39. package/dashboard/dist/assets/D8mvKY2h.js.gz +0 -0
  40. package/dashboard/dist/assets/{C91KLKit.js → DBRLnKWw.js} +1 -1
  41. package/dashboard/dist/assets/DBRLnKWw.js.br +0 -0
  42. package/dashboard/dist/assets/DBRLnKWw.js.gz +0 -0
  43. package/dashboard/dist/assets/DBct8HLW.js +1 -0
  44. package/dashboard/dist/assets/DBct8HLW.js.br +0 -0
  45. package/dashboard/dist/assets/DBct8HLW.js.gz +0 -0
  46. package/dashboard/dist/assets/{gZr_xKlA.js → DLNTxNX-.js} +1 -1
  47. package/dashboard/dist/assets/DLNTxNX-.js.br +0 -0
  48. package/dashboard/dist/assets/DLNTxNX-.js.gz +0 -0
  49. package/dashboard/dist/assets/DMKyYAtD.js +1 -0
  50. package/dashboard/dist/assets/DMKyYAtD.js.br +0 -0
  51. package/dashboard/dist/assets/DMKyYAtD.js.gz +0 -0
  52. package/dashboard/dist/assets/{CJjEAGFN.js → DdYkuATV.js} +1 -1
  53. package/dashboard/dist/assets/DdYkuATV.js.br +0 -0
  54. package/dashboard/dist/assets/DdYkuATV.js.gz +0 -0
  55. package/dashboard/dist/assets/{CGj8kRhg.js → DvFumX8R.js} +1 -1
  56. package/dashboard/dist/assets/DvFumX8R.js.br +0 -0
  57. package/dashboard/dist/assets/DvFumX8R.js.gz +0 -0
  58. package/dashboard/dist/assets/RZkbqlJk.css +1 -0
  59. package/dashboard/dist/assets/RZkbqlJk.css.br +0 -0
  60. package/dashboard/dist/assets/RZkbqlJk.css.gz +0 -0
  61. package/dashboard/dist/index.html +3 -3
  62. package/dashboard/dist/index.html.br +0 -0
  63. package/dashboard/dist/index.html.gz +0 -0
  64. package/dist/http/helpers/auto-continue-engine.d.ts +15 -0
  65. package/dist/http/helpers/auto-continue-engine.js +165 -0
  66. package/dist/http/helpers/mission-control.d.ts +3 -0
  67. package/dist/http/helpers/mission-control.js +38 -7
  68. package/dist/http/helpers/value-utils.d.ts +1 -1
  69. package/dist/http/helpers/value-utils.js +5 -2
  70. package/dist/http/index.js +3 -1
  71. package/dist/http/routes/chat.d.ts +1 -1
  72. package/dist/http/routes/chat.js +2 -2
  73. package/dist/http/routes/entities.js +60 -2
  74. package/dist/http/routes/entity-dynamic.js +49 -9
  75. package/dist/http/routes/live-snapshot.d.ts +10 -1
  76. package/dist/http/routes/live-snapshot.js +11 -3
  77. package/dist/http/routes/mission-control-actions.d.ts +6 -0
  78. package/dist/http/routes/mission-control-actions.js +33 -0
  79. package/package.json +1 -1
  80. package/dashboard/dist/assets/0RUEVzJa.js +0 -1
  81. package/dashboard/dist/assets/0RUEVzJa.js.br +0 -0
  82. package/dashboard/dist/assets/0RUEVzJa.js.gz +0 -0
  83. package/dashboard/dist/assets/3TtV4moZ.js.br +0 -0
  84. package/dashboard/dist/assets/3TtV4moZ.js.gz +0 -0
  85. package/dashboard/dist/assets/3VwNyxUf.js.br +0 -0
  86. package/dashboard/dist/assets/3VwNyxUf.js.gz +0 -0
  87. package/dashboard/dist/assets/7DhYqBrM.js.br +0 -0
  88. package/dashboard/dist/assets/7DhYqBrM.js.gz +0 -0
  89. package/dashboard/dist/assets/BVvffj0x.js +0 -1
  90. package/dashboard/dist/assets/BVvffj0x.js.br +0 -0
  91. package/dashboard/dist/assets/BVvffj0x.js.gz +0 -0
  92. package/dashboard/dist/assets/BiOgVMED.js +0 -1
  93. package/dashboard/dist/assets/BiOgVMED.js.br +0 -0
  94. package/dashboard/dist/assets/BiOgVMED.js.gz +0 -0
  95. package/dashboard/dist/assets/C91KLKit.js.br +0 -0
  96. package/dashboard/dist/assets/C91KLKit.js.gz +0 -0
  97. package/dashboard/dist/assets/C9fvfXmS.js.br +0 -0
  98. package/dashboard/dist/assets/C9fvfXmS.js.gz +0 -0
  99. package/dashboard/dist/assets/CFZ4Swr5.js.br +0 -0
  100. package/dashboard/dist/assets/CFZ4Swr5.js.gz +0 -0
  101. package/dashboard/dist/assets/CGj8kRhg.js.br +0 -0
  102. package/dashboard/dist/assets/CGj8kRhg.js.gz +0 -0
  103. package/dashboard/dist/assets/CJjEAGFN.js.br +0 -0
  104. package/dashboard/dist/assets/CJjEAGFN.js.gz +0 -0
  105. package/dashboard/dist/assets/CKrH5fYO.js.br +0 -0
  106. package/dashboard/dist/assets/CKrH5fYO.js.gz +0 -0
  107. package/dashboard/dist/assets/CMTTPXch.js +0 -1
  108. package/dashboard/dist/assets/CMTTPXch.js.br +0 -0
  109. package/dashboard/dist/assets/CMTTPXch.js.gz +0 -0
  110. package/dashboard/dist/assets/CnPC783_.js.br +0 -0
  111. package/dashboard/dist/assets/CnPC783_.js.gz +0 -0
  112. package/dashboard/dist/assets/Ctw95IkC.js.br +0 -0
  113. package/dashboard/dist/assets/Ctw95IkC.js.gz +0 -0
  114. package/dashboard/dist/assets/DHz-aQPw.js +0 -1
  115. package/dashboard/dist/assets/DHz-aQPw.js.br +0 -0
  116. package/dashboard/dist/assets/DHz-aQPw.js.gz +0 -0
  117. package/dashboard/dist/assets/DNX2foSJ.css +0 -1
  118. package/dashboard/dist/assets/DNX2foSJ.css.br +0 -0
  119. package/dashboard/dist/assets/DNX2foSJ.css.gz +0 -0
  120. package/dashboard/dist/assets/DxUw4FMR.js +0 -212
  121. package/dashboard/dist/assets/DxUw4FMR.js.br +0 -0
  122. package/dashboard/dist/assets/DxUw4FMR.js.gz +0 -0
  123. package/dashboard/dist/assets/T2NFtzAv.js.br +0 -0
  124. package/dashboard/dist/assets/T2NFtzAv.js.gz +0 -0
  125. package/dashboard/dist/assets/gZr_xKlA.js.br +0 -0
  126. package/dashboard/dist/assets/gZr_xKlA.js.gz +0 -0
@@ -0,0 +1 @@
1
+ import{j as e,r as f}from"./Dj2k1r16.js";import{a3 as pe,e as u,O as he,a4 as fe,y as ge,a5 as be,A as ke,m as ve,C as T,a6 as ye,a7 as je,a1 as we,v as B,E as te,S as Ne}from"./C8AYbjlq.js";import{E as Ie}from"./DBRLnKWw.js";import{m as g,A as Ce}from"./eeHXe_OQ.js";import{M as Te}from"./BCudUvwg.js";import{f as Fe,g as ie,w as se}from"./B7kFLPiD.js";import"./DMKyYAtD.js";import"./cX2e-TLi.js";import"./BjK42gtU.js";import"./BV0BcV1u.js";function Se(n){if(!n)return{label:"artifact",color:"rgba(255,255,255,0.4)"};const s=n.toLowerCase();return s.includes("code")||s.includes("pr")||s.includes("pull_request")||s.includes("commit")?{label:"code",color:u.lime}:s.includes("doc")||s.includes("spec")||s.includes("document")||s.includes("proposal")?{label:"doc",color:u.teal}:s.includes("design")||s.includes("a11y")||s.includes("accessibility")?{label:"design",color:u.iris}:s.includes("test")||s.includes("experiment")?{label:"test",color:u.cyan}:s.includes("config")||s.includes("decision")||s.includes("routing")||s.includes("runbook")||s.includes("incident")?{label:"config",color:u.amber}:s.includes("marketing")||s.includes("qualification")||s.includes("sales")?{label:s.includes("marketing")?"marketing":"sales",color:u.teal}:{label:n.slice(0,12),color:"rgba(255,255,255,0.5)"}}function Ae({artifacts:n,onOpenArtifact:s,className:l}){return n.length===0?null:e.jsxs("div",{className:l,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:"section-kicker font-semibold",children:"Artifacts"}),e.jsx("span",{className:"chip text-micro",children:n.length})]}),e.jsx(g.div,{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",initial:"hidden",animate:"visible",variants:{visible:{transition:{staggerChildren:.04}}},children:n.map((d,k)=>{const x=Se(d.type);return e.jsxs(g.button,{type:"button",onClick:()=>s==null?void 0:s(d),className:"subsection-shell rounded-xl px-3.5 py-3 text-left hover-lift",variants:pe,custom:k,children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"rounded-full px-1.5 py-0.5 text-[9px] font-semibold uppercase tracking-widest",style:{color:x.color,backgroundColor:`${x.color}18`,border:`1px solid ${x.color}30`},children:x.label})}),e.jsx("p",{className:"mt-1.5 text-body font-medium text-white truncate",children:d.title})]},d.id??`artifact-${k}`)})})]})}function M(n){return n.toLowerCase().trim().replace(/\.\s*$/,"").replace(/\s+/g," ")}function Ee(n){var j,w,N;const s=new Set,l=((j=n.statusExplainer)==null?void 0:j.trim())||null;l&&s.add(M(l));const d=((w=n.summary)==null?void 0:w.trim())||null,k=d!=null&&!s.has(M(d));d&&s.add(M(d));const x=((N=n.lastEventSummary)==null?void 0:N.trim())||null,F=x!=null&&!s.has(M(x));return{outcome:l,whatHappened:k?d:null,lastActivity:F?x:null}}function Be(n){const s=[];if(n.lifecycleState==="completed"&&n.artifactCount===0)s.push("Completed but produced no artifacts."),s.push("This may indicate the agent finished analysis without outputting structured results."),n.statusExplainer&&s.push(n.statusExplainer);else if(n.lifecycleState==="completed"&&n.artifactCount>0){s.push(`Completed with ${n.artifactCount} artifact${n.artifactCount>1?"s":""}.`);const l=n.artifacts??[];for(const d of l.slice(0,3))s.push(`· ${d.title} (${d.type})`);l.length>3&&s.push(`· and ${l.length-3} more`)}else n.lifecycleState==="failed"?(s.push("Failed during execution."),n.statusExplainer&&s.push(n.statusExplainer)):n.lifecycleState==="awaiting_input"&&(s.push("Waiting for input before continuing."),n.statusExplainer&&s.push(n.statusExplainer));return s.length>0?s.join(" "):null}function D(n){return n===0?u.red:n===1?u.amber:n===2?u.iris:"rgba(255,255,255,0.5)"}function L(n){return n===0?"P0":n===1?"P1":n===2?"P2":n===3?"P3":""}function De(n){switch(n){case"high":return{filled:5,color:u.lime};case"medium":return{filled:3,color:u.amber};case"low":return{filled:1,color:u.red};default:return{filled:0,color:u.iris}}}async function Re(n){const s={};if(n.runId&&(s.runId=n.runId),n.sliceRunId&&(s.sliceRunId=n.sliceRunId),n.sessionId&&(s.sessionId=n.sessionId),Object.keys(s).length===0)throw new Error("No run identifier available for terminal open.");const l=await fetch("/orgx/api/live/terminal/open",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!l.ok){const d=await l.json().catch(()=>({}));throw new Error(d.error??`Terminal open failed (${l.status})`)}}const $e={hidden:{opacity:0,y:-4},visible:n=>({opacity:1,y:0,transition:{duration:.28,delay:n*.04,ease:[.16,1,.3,1]}}),exit:{opacity:0,transition:{duration:.18}}},y={hidden:{opacity:0,y:8},visible:n=>({opacity:1,y:0,transition:{duration:.22,delay:n*.04,ease:ve.easingStandard}}),exit:{opacity:0,transition:{duration:.18}}};function ne(n){var d,k,x,F,j,w,N,S;if(n.source==="queue"){const{item:r,linkedSliceRun:c}=n;return{initiativeId:r.initiativeId,initiativeTitle:T(r.initiativeTitle),initiativeStatus:r.initiativeStatus,workstreamId:r.workstreamId,workstreamTitle:T(r.workstreamTitle),workstreamStatus:r.workstreamStatus,nextTaskTitle:r.nextTaskTitle?T(r.nextTaskTitle):null,nextTaskPriority:r.nextTaskPriority,nextTaskDueAt:r.nextTaskDueAt,agentId:r.runnerAgentId,agentName:r.runnerAgentName,agentSource:r.runnerSource,queueState:r.queueState,blockReason:r.blockReason?T(r.blockReason):null,sliceScope:r.sliceScope??null,sliceTaskCount:typeof r.sliceTaskCount=="number"&&Number.isFinite(r.sliceTaskCount)?Math.max(0,Math.floor(r.sliceTaskCount)):((d=r.sliceTaskIds)==null?void 0:d.length)??null,autoContinue:r.autoContinue,sliceRun:c,sessionId:null,runId:(c==null?void 0:c.runId)??null}}if(n.source==="in_progress"){const{row:r,sliceRun:c}=n;return{initiativeId:r.initiativeId,initiativeTitle:r.initiativeTitle?T(r.initiativeTitle):null,initiativeStatus:null,workstreamId:r.workstreamId,workstreamTitle:r.workstreamTitle?T(r.workstreamTitle):r.title,workstreamStatus:r.status,nextTaskTitle:null,nextTaskPriority:null,nextTaskDueAt:null,agentId:((k=r.session)==null?void 0:k.agentId)??null,agentName:((x=r.session)==null?void 0:x.agentName)??"OrgX",agentSource:null,queueState:r.status==="running"?"running":"queued",blockReason:null,sliceScope:(c==null?void 0:c.scope)??null,sliceTaskCount:typeof((F=c==null?void 0:c.scopeProgress)==null?void 0:F.totalTasks)=="number"?Math.max(0,Math.floor(c.scopeProgress.totalTasks-c.scopeProgress.completedTasks)):((j=c==null?void 0:c.taskIds)==null?void 0:j.length)??null,autoContinue:null,sliceRun:c,sessionId:((w=r.session)==null?void 0:w.id)??null,runId:r.runId}}const{sliceRun:s}=n,l=s.sourceClient?s.sourceClient.charAt(0).toUpperCase()+s.sourceClient.slice(1):"OrgX";return{initiativeId:s.initiativeId,initiativeTitle:null,initiativeStatus:null,workstreamId:s.workstreamId,workstreamTitle:s.workstreamTitle?T(s.workstreamTitle):"Work slice",workstreamStatus:s.status,nextTaskTitle:null,nextTaskPriority:null,nextTaskDueAt:null,agentId:null,agentName:l,agentSource:s.sourceClient,queueState:s.status==="needs_review"?"completed":"blocked",blockReason:s.status==="failed"&&s.statusExplainer||null,sliceScope:s.scope??null,sliceTaskCount:typeof((N=s.scopeProgress)==null?void 0:N.totalTasks)=="number"?Math.max(0,Math.floor(s.scopeProgress.totalTasks-s.scopeProgress.completedTasks)):((S=s.taskIds)==null?void 0:S.length)??null,autoContinue:null,sliceRun:s,sessionId:null,runId:s.runId}}function C(){return e.jsx("div",{className:"h-px bg-gradient-to-r from-transparent via-white/[0.06] to-transparent"})}function Je({target:n,onClose:s,onPlayWorkstream:l,onStartAutoContinue:d,onMoveWorkstream:k,onRemoveFromQueue:x,onOpenSession:F,onFocusRunId:j,onOpenInitiative:w,onReviewActivity:N,onOpenDecisions:S,onAcceptSlice:r,onRejectSlice:c,initiatives:J=[]}){var Q,ee;const R=n!==null,[ae,z]=f.useState(!1),[_e,O]=f.useState(null),[p,A]=f.useState(null),[$,_]=f.useState(""),[q,I]=f.useState(null),X=f.useRef(null),K=f.useCallback(a=>{if(n&&(a.metaKey||a.ctrlKey)&&a.key==="Enter"){a.preventDefault();const o=ne(n);o.initiativeId&&o.workstreamId&&(l==null||l(o.initiativeId,o.workstreamId,o.agentId??void 0))}},[n,l]);f.useEffect(()=>{if(R)return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},[R,K]),f.useEffect(()=>{R||(O(null),z(!1),A(null),_(""),I(null))},[R]),f.useEffect(()=>{p&&requestAnimationFrame(()=>{var a;(a=X.current)==null||a.focus()})},[p]);const re=f.useMemo(()=>{const a=new Map;for(const o of J)o.id&&a.set(o.id,o.name??o.id);return a},[J]);if(!n)return null;const i=ne(n);!i.initiativeTitle&&i.initiativeId&&(i.initiativeTitle=re.get(i.initiativeId)??null);const t=i.sliceRun,b=he({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}),oe=b.status==="completed"?"text-lime border-lime/30 bg-lime/[0.12]":b.status==="failed"?"text-red-200 border-red-400/30 bg-red-500/[0.12]":b.status==="needs_attention"?"text-amber-200 border-amber-400/30 bg-amber-500/[0.12]":b.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]",le=b.tone==="critical"?"border-red-400/24 bg-red-500/[0.08]":b.tone==="warning"?"border-amber-400/24 bg-amber-500/[0.08]":b.tone==="positive"?"border-lime/24 bg-lime/[0.08]":"border-subtle bg-white/[0.02]",ce=[...i.initiativeTitle?[{label:i.initiativeTitle,onClick:i.initiativeId?()=>w==null?void 0:w(i.initiativeId):void 0}]:[],{label:i.workstreamTitle}],Z=b.status==="in_progress",de=!!(i.initiativeId&&i.workstreamId&&!Z),G=b.nextAction??(n.source==="needs_input"&&t?t.primaryAction==="resolve_decision"?"Resolve decision":t.primaryAction==="open_artifact"?"Open result":"Review activity":null),H=(()=>{const a=(t==null?void 0:t.primaryAction)??null;return!a||a==="none"?null:a==="resolve_decision"?"resolve_decision":a==="open_artifact"||a==="review_output"?"review":a==="retry_slice"?"start":null})(),W="ring-1 ring-[#BFFF00]/40 shadow-[0_0_8px_rgba(191,255,0,0.15)]",ue=f.useCallback(async a=>{try{O(null),z(!0),await Re(a)}catch(o){O(o instanceof Error?o.message:"Unable to open terminal")}finally{z(!1)}},[]),Y=f.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]),me=Y!==null,U=f.useMemo(()=>fe({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]),P=n.source==="needs_input"&&(t==null?void 0:t.status)==="needs_review",V=f.useCallback(async()=>{if(!t||!p)return;const a=$.trim(),o=t.runId??t.sliceRunId;if(p==="accept")try{I("Accepting…");const m=a?`Accepted: ${a}`:"Accepted from dashboard",h=await fetch(`/orgx/api/runs/${encodeURIComponent(o)}/actions/complete`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:m})});if(!h.ok){const E=await h.json().catch(()=>null);I(`Error: ${(E==null?void 0:E.error)??(E==null?void 0:E.message)??h.status}`);return}I("Accepted!");try{r==null||r(t,a||void 0)}catch{}setTimeout(()=>s(),600)}catch(m){I(`Failed: ${m instanceof Error?m.message:"network error"}`)}else if(p==="reject"&&a)try{I("Sending feedback…");const m=await fetch(`/orgx/api/entities/run/${encodeURIComponent(o)}/comments`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:a,commentType:"review_feedback",severity:"warn",tags:["changes_requested"]})});if(!m.ok){const h=await m.json().catch(()=>null);I(`Error: ${(h==null?void 0:h.error)??(h==null?void 0:h.message)??m.status}`);return}I("Feedback sent!");try{c==null||c(t,a)}catch{}A(null),_("")}catch(m){I(`Failed: ${m instanceof Error?m.message:"network error"}`)}},[t,p,$,r,c,s]),xe=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(Ce,{children:p&&e.jsx(g.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:X,value:$,onChange:a=>_(a.target.value),onKeyDown:a=>{(a.metaKey||a.ctrlKey)&&a.key==="Enter"&&(a.preventDefault(),V()),a.key==="Escape"&&(a.preventDefault(),A(null),_(""))},placeholder:p==="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),_("")},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:p==="reject"&&!$.trim()?"Note required":"⌘Enter to confirm"}),e.jsx("button",{type:"button",onClick:V,disabled:p==="reject"&&!$.trim(),className:`inline-flex h-7 items-center gap-1 rounded-md px-3 text-[11px] font-semibold transition-colors disabled:opacity-30 ${p==="accept"?"bg-[#BFFF00]/12 text-[#BFFF00] hover:bg-[#BFFF00]/20":"bg-[#FF6B88]/12 text-[#FF6B88] hover:bg-[#FF6B88]/20"}`,children:p==="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:[n.source==="queue"&&i.initiativeId&&i.workstreamId&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>{x==null||x(i.initiativeId,i.workstreamId),s()},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:()=>k==null?void 0:k(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"})]}),n.source==="in_progress"&&i.sessionId&&e.jsx("button",{type:"button",onClick:()=>{F==null||F(i.sessionId),s()},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"}),n.source==="needs_input"&&t&&t.primaryAction==="resolve_decision"&&e.jsx("button",{type:"button",onClick:()=>{S==null||S(),s()},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] ${H==="resolve_decision"?W:""}`,children:"Resolve decision"}),n.source==="needs_input"&&t&&e.jsx("button",{type:"button",onClick:()=>{N==null||N(t),s()},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 ${H==="review"?W:""}`,children:"Review"}),i.runId&&e.jsx("button",{type:"button",onClick:()=>{j==null||j(i.runId),s()},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:[P&&c&&e.jsx("button",{type:"button",onClick:()=>A(p==="reject"?null:"reject"),className:`rounded-md px-2.5 py-1.5 text-[12px] font-medium transition-colors ${p==="reject"?"bg-[#FF6B88]/12 text-[#FF6B88]":"text-white/35 hover:bg-white/[0.04] hover:text-white/60"}`,children:"Request changes"}),P&&r&&e.jsxs("button",{type:"button",onClick:()=>{p==="accept"?V():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"]}),de&&e.jsxs("button",{type:"button","data-modal-autofocus":"true",onClick:()=>{l==null||l(i.initiativeId,i.workstreamId,i.agentId??void 0),s()},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 ${H==="start"?"ring-1 ring-[#BFFF00]/50 shadow-[0_0_10px_rgba(191,255,0,0.2)]":""}`,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"})}),b.status==="completed"?"Restart":b.status==="needs_attention"?"Retry":"Start"]}),me&&e.jsx("button",{type:"button",onClick:()=>void ue(Y),disabled:ae,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 v=0;return e.jsx(ge,{open:R,onClose:s,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:Fe(i.queueState),"aria-hidden":!0}),e.jsx(be,{breadcrumbs:ce,onClose:s,footer:xe,children:e.jsxs("div",{className:"px-6 py-5 space-y-5",children:[e.jsxs(g.div,{variants:$e,initial:"hidden",animate:"visible",exit:"exit",custom:v++,className:"flex items-start gap-3",children:[e.jsx(ke,{name:i.agentName??"OrgX",hint:i.agentSource??i.agentId,size:"md"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"text-[28px] font-medium leading-none text-white truncate",children:i.workstreamTitle}),i.initiativeTitle&&e.jsx("p",{className:"mt-1 text-[10px] uppercase tracking-[0.1em] text-muted",children:i.initiativeTitle}),e.jsxs("div",{className:"mt-2 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-widest ${oe}`,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:ie(i.queueState)}}),Z&&e.jsx(g.span,{className:"absolute inset-0 rounded-full",style:{backgroundColor:ie(i.queueState)},animate:{opacity:[1,.3,1],scale:[1,1.6,1]},transition:{duration:2,repeat:1/0,ease:"easeInOut"}})]}),b.label]}),(t==null?void 0:t.confidence)&&e.jsx("span",{className:`chip text-[9px] font-semibold ${t.confidence==="high"?"border-[#BFFF00]/30 bg-[#BFFF00]/[0.12] text-[#d8ffa1]":t.confidence==="medium"?"border-[#F5B700]/30 bg-[#F5B700]/[0.12] text-[#FFE7A8]":"border-white/[0.12] bg-white/[0.05] text-white/60"}`,children:t.confidence})]}),(t==null?void 0:t.statusExplainer)&&n.source!=="needs_input"&&e.jsx("p",{className:"mt-2 text-body text-secondary",children:t.statusExplainer})]})]}),t&&e.jsx(Te,{metrics:[...t.startedAt?[{label:"Duration",value:(()=>{const a=t.completedAt??t.failedAt??t.updatedAt??new Date().toISOString(),o=Date.parse(a)-Date.parse(t.startedAt);return o<6e4?`${Math.round(o/1e3)}s`:o<36e5?`${Math.round(o/6e4)}m`:`${(o/36e5).toFixed(1)}h`})()}]:[],...t.artifactCount>0?[{label:"Artifacts",value:t.artifactCount,color:u.teal}]:[],...t.decisionCount>0?[{label:"Decisions",value:t.decisionCount,color:u.amber}]:[]],className:"pb-4 border-b border-white/[0.04]"}),t&&t.artifacts.length>0&&e.jsx(Ae,{artifacts:t.artifacts}),e.jsx(C,{}),n.source==="needs_input"&&t?(()=>{const a=Ee({statusExplainer:t.statusExplainer,summary:i.blockReason,lastEventSummary:t.lastEventSummary}),m=Be({lifecycleState:t.status,artifactCount:t.artifactCount,artifacts:t.artifacts.map(h=>({title:h.title,type:h.type??"unknown"})),statusExplainer:t.statusExplainer,confidence:t.confidence})??a.outcome;return e.jsxs(e.Fragment,{children:[e.jsxs(g.div,{variants:y,initial:"hidden",animate:"visible",exit:"exit",custom:v++,className:`rounded-xl border px-4 py-3 ${le}`,children:[e.jsx("p",{className:"section-kicker",children:"What to do now"}),e.jsx("p",{className:"mt-1 text-body text-primary",children:b.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,G?e.jsxs("p",{className:"mt-1 text-caption text-[#BFFF00]/70 flex items-center gap-1",children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:"flex-shrink-0",children:e.jsx("polyline",{points:"9 18 15 12 9 6"})}),"Recommended action: ",G]}):null]}),m&&e.jsxs(g.div,{variants:y,initial:"hidden",animate:"visible",exit:"exit",custom:v++,children:[e.jsx("p",{className:"section-kicker",children:"Outcome"}),e.jsx("p",{className:"mt-1 text-body text-secondary leading-relaxed",children:T(m)})]}),a.lastActivity&&e.jsxs(g.div,{variants:y,initial:"hidden",animate:"visible",exit:"exit",custom:v++,children:[e.jsx("p",{className:"section-kicker",children:"Last activity"}),e.jsx("p",{className:"mt-1 text-caption text-white/50 leading-relaxed",children:T(a.lastActivity)})]}),e.jsx(C,{})]})})():null,(i.blockReason||i.autoContinue||i.agentSource&&i.agentSource!=="assigned")&&e.jsxs(g.div,{variants:y,initial:"hidden",animate:"visible",exit:"exit",custom:v++,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:[" · ",ye(i.autoContinue.laneState)]})]})]}),((Q=i.autoContinue)==null?void 0:Q.laneBlockedReason)&&e.jsx("p",{className:"text-micro text-red-100/75",children:i.autoContinue.laneBlockedReason}),((ee=i.autoContinue)==null?void 0:ee.stopReason)&&e.jsx("p",{className:"text-micro text-amber-100/75",children:je(i.autoContinue.stopReason)})]}),U.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(C,{}),e.jsxs(g.div,{variants:y,initial:"hidden",animate:"visible",exit:"exit",custom:v++,className:"space-y-2",children:[e.jsx("p",{className:"section-kicker",children:se(i.queueState,P)}),e.jsx(we,{nodes:U,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:D(i.nextTaskPriority),borderColor:`${D(i.nextTaskPriority)}33`,backgroundColor:`${D(i.nextTaskPriority)}14`},children:L(i.nextTaskPriority)}),i.nextTaskDueAt&&e.jsxs("span",{className:"text-micro text-secondary",children:["Due ",B(i.nextTaskDueAt)]})]})]})]}),U.length===0&&(i.nextTaskTitle||i.sliceTaskCount!==null||i.sliceScope)&&e.jsxs(e.Fragment,{children:[e.jsx(C,{}),e.jsxs(g.div,{variants:y,initial:"hidden",animate:"visible",exit:"exit",custom:v++,className:"space-y-2",children:[e.jsx("p",{className:"section-kicker",children:se(i.queueState,P)}),i.nextTaskTitle&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(te,{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:D(i.nextTaskPriority),borderColor:`${D(i.nextTaskPriority)}33`,backgroundColor:`${D(i.nextTaskPriority)}14`},children:L(i.nextTaskPriority)}),i.nextTaskDueAt&&e.jsxs("span",{className:"text-micro text-secondary",children:["Due ",B(i.nextTaskDueAt)]})]})]})]}),t&&(t.startedAt||t.updatedAt||t.completedAt||t.failedAt)&&e.jsxs(e.Fragment,{children:[e.jsx(C,{}),e.jsxs(g.div,{variants:y,initial:"hidden",animate:"visible",exit:"exit",custom:v++,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(Ne,{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},(a,o)=>{const{filled:m,color:h}=De(t.confidence);return e.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full",style:{backgroundColor:o<m?h:"rgba(255,255,255,0.1)"}},o)})})]}),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:B(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:B(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:B(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:B(t.updatedAt)})]}):null]})]})]}),t&&t.artifactCount>0&&t.artifacts.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(C,{}),e.jsxs(g.div,{variants:y,initial:"hidden",animate:"visible",exit:"exit",custom:v++,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((a,o)=>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(te,{type:a.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:a.title}),a.url&&e.jsx("a",{href:a.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"})]})})]},a.id??o))})]})]}),t&&t.decisionCount>0&&e.jsxs(e.Fragment,{children:[e.jsx(C,{}),e.jsxs(g.div,{variants:y,initial:"hidden",animate:"visible",exit:"exit",custom:v++,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:u.red,borderColor:`${u.red}33`,backgroundColor:`${u.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(a=>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:a.label}),a.description&&e.jsx("p",{className:"mt-0.5 text-micro leading-snug text-secondary",children:a.description})]},a.id))})]})]}),t&&(t.sliceRunId||t.runId)&&e.jsxs(e.Fragment,{children:[e.jsx(C,{}),e.jsxs(g.div,{variants:y,initial:"hidden",animate:"visible",exit:"exit",custom:v++,children:[e.jsx("p",{className:"section-kicker mb-2",children:"Notes"}),e.jsx(Ie,{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(C,{}),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{Je as SliceDetailModal};
@@ -1 +1 @@
1
- import{e as t}from"./DxUw4FMR.js";const e={QUEUED:"queued",RUNNING:"running",BLOCKED:"blocked",IDLE:"idle",COMPLETED:"completed"};function n(r){switch(r){case e.RUNNING:return"border-teal-300/35 bg-teal-400/[0.12] text-teal-100";case e.BLOCKED:return"border-amber-300/35 bg-amber-400/[0.12] text-amber-100";case e.IDLE:return"border-strong bg-white/[0.05] text-secondary";default:return"border-[#BFFF00]/30 bg-[#BFFF00]/12 text-[#E1FFB2]"}}function c(r){switch(r){case e.RUNNING:return"Running";case e.BLOCKED:return"Needs input";case e.IDLE:return"Idle";case e.COMPLETED:return"Completed";case e.QUEUED:return"Queued";default:return r.replace(/_/g," ")}}function o(r){switch(r){case e.QUEUED:case e.IDLE:return 0;case e.BLOCKED:return 1;case e.RUNNING:return 2;case e.COMPLETED:return 3;default:return 4}}function i(r){switch(r){case e.RUNNING:return"from-teal-300/0 via-teal-300/60 to-teal-300/0";case e.BLOCKED:return"from-amber-300/0 via-amber-300/55 to-amber-300/0";case e.IDLE:return"from-white/0 via-white/35 to-white/0";default:return"from-[#BFFF00]/0 via-[#BFFF00]/70 to-[#BFFF00]/0"}}function s(r){switch(r){case e.RUNNING:return"Current";case e.BLOCKED:return"Blocked on";default:return"Next"}}function E(r){switch(r){case e.RUNNING:return t.lime;case e.BLOCKED:return t.red;case e.IDLE:return t.iris;case e.QUEUED:return t.teal;default:return t.amber}}function d(r){switch(r){case e.RUNNING:return{background:`linear-gradient(to right, ${t.lime}, ${t.teal})`};case e.BLOCKED:return{background:`linear-gradient(to right, ${t.red}, ${t.amber})`};case e.IDLE:return{background:`linear-gradient(to right, ${t.iris}99, transparent)`};default:return{background:`linear-gradient(to right, ${t.lime}B3, ${t.teal}66)`}}}function l(r,a){if(a)return"Scope Under Review";switch(r){case e.COMPLETED:return"Completed Scope";case e.RUNNING:return"Current Work";case e.BLOCKED:return"Blocked Work";default:return"Next Work"}}function N(r){return r.some(a=>a.queueState===e.RUNNING)?e.RUNNING:r.some(a=>a.queueState===e.BLOCKED)?e.BLOCKED:r.some(a=>a.queueState===e.QUEUED)?e.QUEUED:r.some(a=>a.queueState===e.IDLE)?e.IDLE:e.COMPLETED}export{e as Q,c as a,n as b,i as c,N as d,s as e,d as f,E as g,o as q,l as w};
1
+ import{e as t}from"./C8AYbjlq.js";const e={QUEUED:"queued",RUNNING:"running",BLOCKED:"blocked",IDLE:"idle",COMPLETED:"completed"};function n(r){switch(r){case e.RUNNING:return"border-teal-300/35 bg-teal-400/[0.12] text-teal-100";case e.BLOCKED:return"border-amber-300/35 bg-amber-400/[0.12] text-amber-100";case e.IDLE:return"border-strong bg-white/[0.05] text-secondary";default:return"border-[#BFFF00]/30 bg-[#BFFF00]/12 text-[#E1FFB2]"}}function c(r){switch(r){case e.RUNNING:return"Running";case e.BLOCKED:return"Needs input";case e.IDLE:return"Idle";case e.COMPLETED:return"Completed";case e.QUEUED:return"Queued";default:return r.replace(/_/g," ")}}function o(r){switch(r){case e.QUEUED:case e.IDLE:return 0;case e.BLOCKED:return 1;case e.RUNNING:return 2;case e.COMPLETED:return 3;default:return 4}}function i(r){switch(r){case e.RUNNING:return"from-teal-300/0 via-teal-300/60 to-teal-300/0";case e.BLOCKED:return"from-amber-300/0 via-amber-300/55 to-amber-300/0";case e.IDLE:return"from-white/0 via-white/35 to-white/0";default:return"from-[#BFFF00]/0 via-[#BFFF00]/70 to-[#BFFF00]/0"}}function s(r){switch(r){case e.RUNNING:return"Current";case e.BLOCKED:return"Blocked on";default:return"Next"}}function E(r){switch(r){case e.RUNNING:return t.lime;case e.BLOCKED:return t.red;case e.IDLE:return t.iris;case e.QUEUED:return t.teal;default:return t.amber}}function d(r){switch(r){case e.RUNNING:return{background:`linear-gradient(to right, ${t.lime}, ${t.teal})`};case e.BLOCKED:return{background:`linear-gradient(to right, ${t.red}, ${t.amber})`};case e.IDLE:return{background:`linear-gradient(to right, ${t.iris}99, transparent)`};default:return{background:`linear-gradient(to right, ${t.lime}B3, ${t.teal}66)`}}}function l(r,a){if(a)return"Scope Under Review";switch(r){case e.COMPLETED:return"Completed Scope";case e.RUNNING:return"Current Work";case e.BLOCKED:return"Blocked Work";default:return"Next Work"}}function N(r){return r.some(a=>a.queueState===e.RUNNING)?e.RUNNING:r.some(a=>a.queueState===e.BLOCKED)?e.BLOCKED:r.some(a=>a.queueState===e.QUEUED)?e.QUEUED:r.some(a=>a.queueState===e.IDLE)?e.IDLE:e.COMPLETED}export{e as Q,c as a,n as b,i as c,N as d,s as e,d as f,E as g,o as q,l as w};
@@ -1 +1 @@
1
- import{r as j,j as e}from"./Dj2k1r16.js";import{D as B,F as N,N as ke,e as x,B as M,O as Ve,Q as Ge,R as Ne,r as O,j as Ie,A as Xe,C as Ke,S as Qe,M as He,m as Je}from"./DxUw4FMR.js";import{u as Ye}from"./C9fvfXmS.js";import{A as Ze,m as I}from"./eeHXe_OQ.js";import"./BiOgVMED.js";import"./cX2e-TLi.js";import"./BjK42gtU.js";import"./BV0BcV1u.js";const De=/^[0-9a-f-]{20,}$/i,et=new Set(["running","active","queued","pending","in_progress","working","planning","handoff","review"]),tt=new Set(["agent execution failed","execution failed","run failed","failed"]);function v(i){return typeof i=="string"&&i.trim().length>0}function ce(i){return(i??"").trim().toLowerCase()}function rt(i){return(i??"").trim().replace(/\s+/g," ").toLowerCase()}function st(i){return tt.has(rt(i))}function V(i,t=3){return i.length<=t?i.join(", "):`${i.slice(0,t).join(", ")} +${i.length-t} more`}function G(i,t){const f=[],c=h=>{if(typeof h!="string")return;const w=h.trim();w&&(f.some(W=>W.toLowerCase()===w.toLowerCase())||f.push(w))};if(Array.isArray(i))for(const h of i)c(h);return c(t??null),f}function it(i){if(i.runId&&i.runId.trim().length>0)return i.runId.trim();const t=i.metadata;if(!t)return null;const f=["slice_run_id","sliceRunId","runId","run_id","correlation_id","correlationId","sessionId","session_id","agentRunId"];for(const c of f){const h=t[c];if(typeof h=="string"&&h.trim().length>0)return h.trim()}return null}function at(i){const t=ce(i.status);if(t==="blocked"||t==="failed"||t==="completed"||t==="cancelled")return t;const f=ce(i.phase);if(f==="blocked")return"blocked";if(f==="handoff")return"handoff";if(f==="completed")return"completed";if(f==="review")return"review";const c=ce(i.state);return c==="error"?"failed":c==="stopped"?"paused":c==="stale"?"queued":et.has(t)?t:i.blockers.length>0?"blocked":t||"unknown"}function nt(i,t,f){var h;const c=[((h=i.blockerDiagnostics)==null?void 0:h.reason)??null,i.blockerReason??null,...i.blockers,t==="blocked"||t==="failed"||t==="handoff"?f:null].map(w=>typeof w=="string"?w.trim():"").filter(w=>w.length>0);return c.length>0?c.find(W=>!st(W))??c[0]:t==="handoff"?"Waiting for handoff acceptance by the next agent.":t==="blocked"?"Blocked without an explicit reason from runtime.":t==="failed"?"Run failed without explicit error details.":null}function lt(i){return i==="completed"?"border-lime/25 bg-lime/[0.08] text-lime":i==="needs_attention"?"border-amber-400/30 bg-amber-400/10 text-amber-200":i==="failed"?"border-red-400/30 bg-red-500/10 text-red-200":i==="in_progress"?"border-teal-400/30 bg-teal-400/10 text-teal-200":"border-strong bg-white/[0.04] text-secondary"}const dt={hidden:{opacity:0,y:-4},visible:i=>({opacity:1,y:0,transition:{duration:.28,delay:i*.04,ease:[.16,1,.3,1]}}),exit:{opacity:0,transition:{duration:.18}}},R={hidden:{opacity:0,y:8},visible:i=>({opacity:1,y:0,transition:{duration:.22,delay:i*.04,ease:[.22,1,.36,1]}}),exit:{opacity:0,transition:{duration:.18}}};function ue(){return e.jsx("div",{className:"h-px bg-gradient-to-r from-transparent via-white/[0.06] to-transparent"})}function ot(i){return i==="in_progress"?{background:`linear-gradient(90deg, ${x.lime}, ${x.teal})`}:i==="needs_attention"?{background:`linear-gradient(90deg, ${x.red}, ${x.amber})`}:i==="completed"?{background:`linear-gradient(90deg, ${x.teal}, ${x.cyan})`}:i==="failed"?{background:`linear-gradient(90deg, ${x.red}, ${x.red}80)`}:{background:`linear-gradient(90deg, ${x.iris}, ${x.iris}80)`}}const vt=j.memo(function({session:t,activity:f,initiatives:c=[],sliceRuns:h=[],onOpenActivityItem:w,onContinueHighestPriority:W,onDispatchSession:X,onPauseSession:K,onResumeSession:Q,onCancelSession:H,onCreateCheckpoint:J,onRollbackSession:Y,onStartInitiative:ct,onStartWorkstream:ut,initialInterventionDraft:C=null,onSubmitIntervention:te,onClose:me}){var ye,ve,je;const[u,xe]=j.useState(null),[L,T]=j.useState(null),[U,he]=j.useState(!1),[re,z]=j.useState(""),{enqueue:pe,ToastRenderer:Ce}=Ye();j.useEffect(()=>{if(!t){z("");return}if(C!=null&&C.text){z(C.text);return}z("")},[C==null?void 0:C.text,t==null?void 0:t.id]);const q=j.useMemo(()=>{var l,g,y,d,m;if(!t)return new Set;const r=new Set;return(l=t.runId)!=null&&l.trim()&&r.add(t.runId.trim()),(g=t.id)!=null&&g.trim()&&r.add(t.id.trim()),(m=(d=(y=t.blockerDiagnostics)==null?void 0:y.context)==null?void 0:d.sliceRunId)!=null&&m.trim()&&r.add(t.blockerDiagnostics.context.sliceRunId.trim()),r},[t]),$=j.useMemo(()=>t?q.size===0?[]:f.filter(r=>{const l=it(r);return!!(l&&q.has(l))}).sort((r,l)=>Date.parse(l.timestamp)-Date.parse(r.timestamp)).slice(0,12):[],[f,t,q]),s=j.useMemo(()=>{var y,d;if(!t||!Array.isArray(h)||h.length===0)return null;const r=((y=t.initiativeId)==null?void 0:y.trim())??"",l=((d=t.workstreamId)==null?void 0:d.trim())??"",g=h.filter(m=>{var oe,we;const A=((oe=m.sliceRunId)==null?void 0:oe.trim())??"",E=((we=m.runId)==null?void 0:we.trim())??"";if(A&&q.has(A)||E&&q.has(E))return!0;if(!l||!G(m.workstreamIds,m.workstreamId).includes(l))return!1;if(!r)return!0;const ee=G(m.initiativeIds,m.initiativeId);return!(ee.length>0&&!ee.includes(r))});return g.length===0?null:[...g].sort((m,A)=>{const E=Date.parse(m.updatedAt??m.lastEventAt??m.startedAt??""),de=Date.parse(A.updatedAt??A.lastEventAt??A.startedAt??""),ee=Number.isFinite(E)?E:0;return(Number.isFinite(de)?de:0)-ee})[0]},[t,q,h]),se=j.useMemo(()=>{var y;if(!t)return[];const r=[],l=t.initiativeId??t.groupId;if(l){const d=c.find(m=>m.id===l);d?r.push({label:"Initiative",value:d.name}):t.groupLabel&&t.groupLabel.trim().length>0?r.push({label:"Initiative",value:t.groupLabel}):B(l)&&r.push({label:"Initiative",value:N(l)})}if(t.workstreamId){let d=null;for(const m of c){const A=(y=m.workstreams)==null?void 0:y.find(E=>E.id===t.workstreamId);if(A){d=A.name;break}}!d&&B(t.workstreamId)?d=N(t.workstreamId):!d&&!De.test(t.workstreamId)&&(d=t.workstreamId),d&&r.push({label:"Workstream",value:d})}const g=t.phase??null;if(g){const d=String(g);r.push({label:"Milestone",value:B(d)?N(d):d})}return t.title&&r.push({label:"Task",value:t.title}),r},[c,t]),S=j.useMemo(()=>{var y,d;if(!t)return null;const r=((y=$[0])==null?void 0:y.summary)??((d=$[0])==null?void 0:d.description)??null,g=t.lastEventSummary??r??null;return g&&g.trim().length>0?g.trim():null},[$,t]),Ae=j.useMemo(()=>{var r;return t?ke(t.agentName,t.title,t.lastEventSummary,S,(r=$[0])==null?void 0:r.metadata):ke()},[$,t,S]),_=async(r,l,g)=>{if(!(!g||u)){xe(r),T(null);try{await g(),T(`${l} requested.`)}catch(y){T(y instanceof Error?y.message:`${l} failed.`)}finally{xe(null)}}};if(!t)return e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[e.jsx("div",{className:"h-[2px] flex-shrink-0",style:{background:`linear-gradient(90deg, ${x.iris}, ${x.iris}80)`}}),e.jsxs("div",{className:"flex items-center justify-between px-5 py-3",children:[e.jsx("p",{className:"section-kicker",children:"Session Detail"}),e.jsx("button",{onClick:()=>he(r=>!r),className:"text-muted transition-colors hover:text-primary","aria-label":U?"Expand session detail":"Collapse session detail",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:M("transition-transform",U?"-rotate-90":"rotate-0"),children:e.jsx("path",{d:"m6 9 6 6 6-6"})})})]}),e.jsx("div",{className:M("transition-all",U?"max-h-0 overflow-hidden":"min-h-0 flex-1"),children:e.jsxs("div",{className:"flex h-full min-h-0 flex-col items-center justify-center gap-4 px-5 py-8",children:[e.jsx("div",{className:"flex h-14 w-14 items-center justify-center rounded-2xl border border-white/[0.08] bg-white/[0.03]",children:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-muted",children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),e.jsx("path",{d:"M8 21h8M12 17v4"})]})}),e.jsx("p",{className:"text-body text-secondary text-center",children:"No session selected"}),e.jsx("p",{className:"text-caption text-muted text-center max-w-[240px]",children:"Select a session to inspect summary, breadcrumbs, blockers, and recent messages."}),e.jsx("button",{onClick:()=>_("continue-priority","Continue highest priority",W),disabled:!W||!!u,className:"mt-2 h-8 rounded-lg border border-lime/25 bg-lime/10 px-4 text-caption font-semibold text-lime transition-colors hover:bg-lime/20 disabled:opacity-45",children:u==="continue-priority"?"Dispatching...":"Continue highest priority"}),L&&e.jsx("p",{className:"text-caption text-secondary",children:L})]})})]});const P=t.progress===null?null:Math.round(t.progress),k=at(t),p=$[0]??null,ie=(s==null?void 0:s.blockingDecisionCount)??0,Re=Math.max(0,((s==null?void 0:s.decisionCount)??0)-ie),o=Ve({sessionStatus:t.status,sessionPhase:t.phase??null,sessionState:t.state??null,sliceStatus:(s==null?void 0:s.status)??null,activityType:(p==null?void 0:p.type)??null,activityStatus:(typeof(p==null?void 0:p.state)=="string"&&p.state.trim().length>0?p.state:null)??(typeof(p==null?void 0:p.phase)=="string"&&p.phase.trim().length>0?p.phase:null)??(s==null?void 0:s.runtimeState)??null,stopReason:t.blockerReason??((ye=t.blockerDiagnostics)==null?void 0:ye.reason)??((s==null?void 0:s.status)==="failed"?"error":null),decisionRequired:((p==null?void 0:p.decisionRequired)??!1)||ie>0,blockingDecisionCount:ie,nonBlockingDecisionCount:Re,blockerCount:t.blockers.length,blockerReason:t.blockerReason??((ve=t.blockerDiagnostics)==null?void 0:ve.reason)??null}),ae=nt(t,k,S),Te=k==="handoff"?"Handoff":k==="blocked"?"Blocker reason":k==="failed"?"Failure reason":"Status note",$e=o.status==="in_progress"&&["running","active","queued","pending","working","in_progress","planning","review"].includes(k),Se=o.status==="needs_attention"&&["paused","blocked","queued","pending"].includes(k),Be=!["completed","archived","cancelled"].includes(k),Me=!["archived","cancelled"].includes(k),Le=o.label,_e=lt(o.status),ne=["running","active","working","in_progress","planning","review"].includes(k),Ee=o.status!=="in_progress"&&!ne,We=o.tone==="critical"?x.red:o.tone==="warning"?x.amber:o.tone==="positive"?x.lime:x.teal,Ue=P!==null&&P>=100&&o.status!=="completed"?"Terminal state":"Progress",qe=o.tone==="critical"?"border-red-400/25 bg-red-500/10":o.tone==="warning"?"border-amber-400/25 bg-amber-500/10":o.tone==="positive"?"border-lime/22 bg-lime/[0.08]":"border-subtle bg-white/[0.02]",a=t.blockerDiagnostics??null,n=(a==null?void 0:a.context)??null,le=[v(a==null?void 0:a.source)?`Source: ${a.source.trim()}`:null,v(a==null?void 0:a.errorCode)?`Code: ${a.errorCode.trim()}`:null,v(a==null?void 0:a.errorCategory)?`Category: ${a.errorCategory.trim()}`:null,(a==null?void 0:a.retryable)===!0?"Retryable: yes":(a==null?void 0:a.retryable)===!1?"Retryable: no":null].filter(r=>!!r),b=[];n&&(Array.isArray(n.initiativeIds)&&n.initiativeIds.length>0?b.push({label:"Initiatives",value:V(n.initiativeIds.map(r=>B(r)?N(r):r),4)}):v(n.initiativeId)&&b.push({label:"Initiative",value:Ge("Initiative",n.initiativeId.trim())}),v(n.workstreamTitle)?b.push({label:"Workstream",value:n.workstreamTitle.trim()}):Array.isArray(n.workstreamIds)&&n.workstreamIds.length>0?b.push({label:"Workstreams",value:V(n.workstreamIds,4)}):v(n.workstreamId)&&b.push({label:"Workstream",value:n.workstreamId.trim()}),v(n.sliceRunId)&&b.push({label:"Slice run",value:N(n.sliceRunId.trim())}),v(n.parallelMode)&&b.push({label:"Mode",value:n.parallelMode.trim().toUpperCase()}),Array.isArray(n.taskIds)&&n.taskIds.length>0&&b.push({label:"Tasks",value:V(n.taskIds.map(r=>B(r)?N(r):r))}),Array.isArray(n.milestoneIds)&&n.milestoneIds.length>0&&b.push({label:"Milestones",value:V(n.milestoneIds.map(r=>B(r)?N(r):r))}),Array.isArray(n.iwmtIds)&&n.iwmtIds.length>0?b.push({label:"Scope IDs",value:V(n.iwmtIds.map(r=>B(r)?N(r):r),4)}):v(n.iwmtId)&&b.push({label:"Scope ID",value:B(n.iwmtId.trim())?N(n.iwmtId.trim()):n.iwmtId.trim()}),v(n.logPath)&&b.push({label:"Log path",value:Ne(n.logPath.trim())}),v(n.outputPath)&&b.push({label:"Output path",value:Ne(n.outputPath.trim())}));const be=(k==="blocked"||k==="failed")&&!!(a&&(v(a.reason)||le.length>0||b.length>0||Array.isArray(a.suggestedActions)&&a.suggestedActions.length>0)),Z=v(ae)?ae:null,ze=Z!==null&&!(S&&(Z===S||S.includes(Z)))&&!be,Pe=j.useCallback(()=>{!H||!t||(T("Session will be cancelled..."),pe({message:`Cancelled "${t.title}"`,onCommit:async()=>{try{await H(t),T("Session cancelled.")}catch(r){T(r instanceof Error?r.message:"Cancel failed.")}},onUndo:()=>{T(null)}}))},[H,t,pe]),Fe=[{label:"Started",value:t.startedAt?O(t.startedAt):"—"},{label:"Updated",value:t.updatedAt?O(t.updatedAt):"—"},...t.eta?[{label:"ETA",value:t.eta}]:[],...t.checkpointCount?[{label:"Checkpoints",value:String(t.checkpointCount)}]:[]],fe=s?s.status.replace(/_/g," "):null,F=G(s==null?void 0:s.initiativeIds,(s==null?void 0:s.initiativeId)??null),D=G(s==null?void 0:s.workstreamIds,(s==null?void 0:s.workstreamId)??null);G(s==null?void 0:s.iwmtIds,(s==null?void 0:s.iwmtId)??null);const Oe=F[0]?((je=c.find(r=>r.id===F[0]))==null?void 0:je.name)??F[0]:null,ge=L?L.toLowerCase().includes("fail")||L.toLowerCase().includes("error")?"error":u?"pending":"success":null;return e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[e.jsx("div",{className:"h-[2px] flex-shrink-0",style:ot(o.status)}),e.jsxs("div",{className:"flex items-center justify-between px-5 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("p",{className:"section-kicker",children:"Session Detail"}),e.jsxs("span",{className:M("inline-flex items-center gap-1.5 rounded-full border px-2 py-[1px] text-micro font-semibold uppercase tracking-widest",_e),children:[ne&&e.jsx("span",{className:"h-1.5 w-1.5 rounded-full pulse-soft",style:{backgroundColor:Ie(k)}}),Le]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{onClick:()=>he(r=>!r),className:"text-muted transition-colors hover:text-primary","aria-label":U?"Expand session detail":"Collapse session detail",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:M("transition-transform",U?"-rotate-90":"rotate-0"),children:e.jsx("path",{d:"m6 9 6 6 6-6"})})}),me&&e.jsx("button",{type:"button",onClick:me,"aria-label":"Close session inspector",className:"inline-flex h-8 w-8 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:"14",height:"14",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.jsxs("div",{className:M("transition-all flex flex-col min-h-0",U?"max-h-0 overflow-hidden":"flex-1"),children:[e.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto px-5 py-5 space-y-5",children:[e.jsx(Ze,{mode:"wait",children:e.jsxs(I.div,{variants:dt,initial:"hidden",animate:"visible",exit:"exit",custom:0,children:[e.jsxs("div",{className:"flex items-start gap-3.5",children:[e.jsx(Xe,{name:t.agentName??"OrgX",size:"md",hint:t.agentName}),e.jsxs("div",{className:"min-w-0 flex-1 pt-0.5",children:[e.jsx("h2",{className:"text-[28px] font-medium leading-tight text-white truncate",children:Ke(t.title)}),e.jsxs("p",{className:"mt-1 text-micro uppercase tracking-[0.12em] text-muted",children:[t.agentName??"OrgX"," · ",Ae.label]})]})]}),se.length>0&&e.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-1.5",children:se.map((r,l)=>e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(Qe,{tone:"muted",children:r.value}),l<se.length-1&&e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"flex-shrink-0 text-faint",children:e.jsx("path",{d:"m9 18 6-6-6-6"})})]},`${r.label}-${r.value}`))})]},t.id)}),e.jsx(ue,{}),S&&e.jsxs(I.div,{variants:R,initial:"hidden",animate:"visible",custom:1,children:[e.jsx("p",{className:"section-kicker mb-2",children:"Summary"}),e.jsx(He,{text:S,mode:"block"})]}),e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:2,children:e.jsxs("div",{className:M("rounded-xl border px-4 py-3",qe),children:[e.jsx("p",{className:"section-kicker mb-1.5",children:o.label}),e.jsx("p",{className:"text-body text-secondary",children:o.sentence}),o.nextAction&&e.jsxs("p",{className:"mt-1.5 flex items-center gap-1 text-caption text-secondary",children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:x.lime,strokeWidth:"2.5",className:"flex-shrink-0",children:e.jsx("path",{d:"m9 18 6-6-6-6"})}),"Next: ",o.nextAction]})]})}),ze&&e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:3,children:e.jsxs("div",{className:"rounded-xl border border-subtle bg-white/[0.02] px-4 py-3",children:[e.jsx("p",{className:"section-kicker mb-1.5",children:Te}),e.jsx("p",{className:"text-body text-secondary",children:Z})]})}),be&&e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:3,children:e.jsxs("div",{className:"rounded-xl border border-red-500/25 bg-red-500/10 px-4 py-3",children:[e.jsx("p",{className:"section-kicker mb-1.5 text-red-200/75",children:"Why blocked"}),e.jsx("p",{className:"text-body text-red-100/90",children:(a==null?void 0:a.reason)??ae??"Runtime marked this run as blocked without details."}),le.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:le.map(r=>e.jsx("span",{className:"rounded-full border border-red-300/25 bg-red-500/10 px-2 py-0.5 text-micro text-red-100/85",children:r},r))}),b.length>0&&e.jsxs("div",{className:"mt-2 rounded-md border border-red-300/20 bg-black/15 p-2.5",children:[e.jsx("p",{className:"mb-1 text-micro uppercase tracking-[0.14em] text-red-200/65",children:"Associated context"}),e.jsx("dl",{className:"grid grid-cols-1 gap-1.5 text-caption text-red-100/85",children:b.map(r=>e.jsxs("div",{className:"grid grid-cols-[86px_1fr] gap-2",children:[e.jsx("dt",{className:"text-red-200/70",children:r.label}),e.jsx("dd",{className:"break-all text-red-50/95",children:r.value})]},r.label))})]}),Array.isArray(a==null?void 0:a.suggestedActions)&&a.suggestedActions.length>0&&e.jsxs("div",{className:"mt-2",children:[e.jsx("p",{className:"mb-1 text-micro uppercase tracking-[0.14em] text-red-200/65",children:"Suggested actions"}),e.jsx("ul",{className:"space-y-1 text-caption text-red-100/85",children:a.suggestedActions.map(r=>e.jsxs("li",{children:["• ",r]},r))})]}),v(a==null?void 0:a.eventTimestamp)&&e.jsxs("p",{className:"mt-2 text-micro text-red-200/60",children:["Last blocker event: ",new Date(a.eventTimestamp).toLocaleString()," ·"," ",O(a.eventTimestamp)]})]})}),e.jsx(ue,{}),e.jsxs(I.div,{variants:R,initial:"hidden",animate:"visible",custom:4,children:[P!==null&&e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between text-caption text-secondary",children:[e.jsx("span",{children:Ue}),e.jsxs("span",{className:"text-primary",children:[P,"%"]})]}),e.jsx("div",{className:"h-[3px] rounded-full bg-white/[0.08]",children:e.jsx(I.div,{className:M("h-[3px] rounded-full",ne&&"live-pulse"),style:{background:We},initial:{width:0},animate:{width:`${P}%`},transition:{duration:.5,ease:Je.easingStandard}})})]}),e.jsx("dl",{className:"grid grid-cols-2 gap-3 text-caption text-secondary",children:Fe.map(r=>e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:r.label}),e.jsx("dd",{className:"text-body font-semibold text-white",children:r.value})]},r.label))})]}),s&&e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:5,children:e.jsxs("div",{className:"rounded-xl border border-subtle bg-white/[0.02] px-4 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"section-kicker",children:"Slice scope"}),fe?e.jsx("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-micro font-semibold uppercase tracking-[0.08em] text-secondary",children:fe}):null]}),s.statusExplainer?e.jsx("p",{className:"mt-2 text-caption text-secondary",children:s.statusExplainer}):null,e.jsxs("dl",{className:"mt-2 grid grid-cols-2 gap-2 text-caption text-secondary",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:"Initiative"}),e.jsx("dd",{className:"text-body font-semibold text-white",children:Oe??"—"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:"Workstream"}),e.jsx("dd",{className:"text-body font-semibold text-white",children:s.workstreamTitle??(D[0]?N(D[0]):"—")})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:"Run"}),e.jsx("dd",{className:"break-all text-body font-semibold text-white",children:N(s.runId??s.sliceRunId)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:"Updated"}),e.jsx("dd",{className:"text-body font-semibold text-white",children:s.updatedAt?O(s.updatedAt):"—"})]})]}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5 text-micro",children:[e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["Tasks ",s.taskIds.length]}),e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["Milestones ",s.milestoneIds.length]}),e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["Artifacts ",s.artifactCount]}),e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["Needs input ",s.blockingDecisionCount]}),F.length>1?e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["+",F.length-1," initiatives"]}):null,D.length>1?e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["+",D.length-1," workstreams"]}):null]}),s.taskIds.length>0?e.jsxs("p",{className:"mt-2 text-micro text-secondary",children:["Tasks: ",s.taskIds.length]}):null]})}),t.blockers.length>0&&e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:6,children:e.jsxs("div",{className:"rounded-xl border border-red-500/30 bg-red-500/10 px-4 py-3",children:[e.jsx("p",{className:"section-kicker mb-2 text-red-200/70",children:"Blockers"}),e.jsx("ul",{className:"space-y-1 text-body text-red-100/90",children:t.blockers.map(r=>e.jsxs("li",{children:["• ",r]},r))})]})}),e.jsx(ue,{}),e.jsxs(I.div,{variants:R,initial:"hidden",animate:"visible",custom:7,children:[e.jsx("p",{className:"section-kicker mb-4",children:"Recent Messages"}),$.length===0&&e.jsx("p",{className:"text-body text-secondary",children:"No recent messages for this run."}),e.jsx("div",{className:"relative border-l border-white/[0.06] pl-6 ml-1 space-y-3",children:$.map((r,l)=>e.jsxs(I.div,{className:"relative group",variants:R,initial:"hidden",animate:"visible",custom:l,children:[e.jsx("div",{className:"absolute -left-[27px] top-1.5 h-2 w-2 rounded-full border border-black ring-4 ring-black",style:{backgroundColor:Ie(r.type??r.state??"unknown")}}),e.jsxs("article",{className:"rounded-lg border border-subtle bg-white/[0.02] px-3 py-2.5 transition-colors hover:bg-white/[0.04]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("p",{className:"min-w-0 flex-1 text-caption text-bright",children:r.title}),w&&e.jsx("button",{type:"button",onClick:()=>w(r),className:"flex-shrink-0 rounded-full border border-strong bg-white/[0.03] px-2.5 py-0.5 text-micro font-semibold text-secondary opacity-0 transition-all group-hover:opacity-100 hover:bg-white/[0.08] hover:text-primary",children:"Open"})]}),(r.summary||r.description)&&e.jsx("p",{className:"mt-0.5 line-clamp-2 text-caption text-secondary",children:r.summary??r.description}),e.jsxs("p",{className:"mt-1 text-micro text-muted",children:[new Date(r.timestamp).toLocaleString()," · ",O(r.timestamp)]})]})]},r.id))})]})]}),e.jsxs("div",{className:"flex-shrink-0 border-t border-subtle px-5 py-3 space-y-3",children:[L&&e.jsx("p",{className:M("rounded-md border px-2.5 py-1.5 text-caption",ge==="error"?"border-red-400/30 bg-red-500/10 text-red-200":ge==="pending"?"border-white/[0.08] bg-white/[0.02] text-secondary pulse-soft":"border-lime/25 bg-lime/[0.08] text-lime"),children:L}),te&&e.jsx("div",{children:e.jsx("textarea",{value:re,onChange:r=>z(r.target.value),placeholder:"Share guidance for this run...",rows:2,className:"w-full resize-none rounded-lg border border-white/[0.10] bg-white/[0.03] px-3 py-2 text-body text-bright outline-none placeholder:text-faint focus:border-white/20"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[$e&&e.jsx("button",{onClick:()=>_("pause-session","Session paused",()=>K==null?void 0:K(t)),disabled:!K||!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-secondary hover:bg-white/[0.04] hover:text-white disabled:opacity-45 transition-colors",children:u==="pause-session"?"Pausing...":"Pause"}),Se&&e.jsx("button",{onClick:()=>_("resume-session","Session resumed",()=>Q==null?void 0:Q(t)),disabled:!Q||!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-secondary hover:bg-white/[0.04] hover:text-white disabled:opacity-45 transition-colors",children:u==="resume-session"?"Resuming...":"Resume"}),e.jsx("button",{onClick:()=>_("checkpoint-session","Progress saved",()=>J==null?void 0:J(t)),disabled:!J||!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-secondary hover:bg-white/[0.04] hover:text-white disabled:opacity-45 transition-colors",children:u==="checkpoint-session"?"Saving...":"Save"}),Me&&e.jsx("button",{onClick:()=>_("rollback-session","Undo requested",()=>Y==null?void 0:Y(t)),disabled:!Y||!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-secondary hover:bg-white/[0.04] hover:text-white disabled:opacity-45 transition-colors",children:u==="rollback-session"?"Undoing...":"Undo"}),Be&&H&&e.jsx("button",{onClick:Pe,disabled:!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-red-400/70 hover:bg-red-500/[0.08] hover:text-red-300 disabled:opacity-45 transition-colors",children:"Cancel"})]}),e.jsx("div",{className:"flex-1"}),te&&e.jsx("button",{type:"button",onClick:()=>{const r=re.trim();if(!r){T("Intervention note cannot be empty.");return}_("intervene-note","Intervention sent",async()=>{await te({session:t,workstreamId:(C==null?void 0:C.workstreamId)??t.workstreamId??null,text:r}),z("")})},disabled:!!u||re.trim().length===0,className:"rounded-md border border-strong bg-white/[0.03] px-3 py-1.5 text-caption font-semibold text-primary transition-colors hover:bg-white/[0.08] disabled:opacity-45",children:u==="intervene-note"?"Sending...":"Intervene"}),e.jsxs("button",{onClick:()=>_("dispatch-session","Session started",()=>X==null?void 0:X(t)),disabled:!X||!!u||!Ee,className:"inline-flex h-8 items-center gap-1.5 rounded-lg border border-lime/25 bg-lime/10 px-4 text-caption font-semibold text-lime transition-colors hover:bg-lime/20 disabled:opacity-45",children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",className:"flex-shrink-0",children:e.jsx("path",{d:"M8 5v14l11-7z"})}),u==="dispatch-session"?"Starting...":o.status==="completed"?"Restart":"Start"]})]})]})]}),e.jsx(Ce,{})]})});export{vt as SessionInspector};
1
+ import{r as j,j as e}from"./Dj2k1r16.js";import{D as B,F as N,N as ke,e as x,B as M,O as Ve,Q as Ge,R as Ne,v as O,j as Ie,A as Xe,C as Ke,S as Qe,M as He,m as Je}from"./C8AYbjlq.js";import{u as Ye}from"./D8mvKY2h.js";import{A as Ze,m as I}from"./eeHXe_OQ.js";import"./DMKyYAtD.js";import"./cX2e-TLi.js";import"./BjK42gtU.js";import"./BV0BcV1u.js";const De=/^[0-9a-f-]{20,}$/i,et=new Set(["running","active","queued","pending","in_progress","working","planning","handoff","review"]),tt=new Set(["agent execution failed","execution failed","run failed","failed"]);function v(i){return typeof i=="string"&&i.trim().length>0}function ce(i){return(i??"").trim().toLowerCase()}function rt(i){return(i??"").trim().replace(/\s+/g," ").toLowerCase()}function st(i){return tt.has(rt(i))}function V(i,t=3){return i.length<=t?i.join(", "):`${i.slice(0,t).join(", ")} +${i.length-t} more`}function G(i,t){const f=[],c=h=>{if(typeof h!="string")return;const w=h.trim();w&&(f.some(W=>W.toLowerCase()===w.toLowerCase())||f.push(w))};if(Array.isArray(i))for(const h of i)c(h);return c(t??null),f}function it(i){if(i.runId&&i.runId.trim().length>0)return i.runId.trim();const t=i.metadata;if(!t)return null;const f=["slice_run_id","sliceRunId","runId","run_id","correlation_id","correlationId","sessionId","session_id","agentRunId"];for(const c of f){const h=t[c];if(typeof h=="string"&&h.trim().length>0)return h.trim()}return null}function at(i){const t=ce(i.status);if(t==="blocked"||t==="failed"||t==="completed"||t==="cancelled")return t;const f=ce(i.phase);if(f==="blocked")return"blocked";if(f==="handoff")return"handoff";if(f==="completed")return"completed";if(f==="review")return"review";const c=ce(i.state);return c==="error"?"failed":c==="stopped"?"paused":c==="stale"?"queued":et.has(t)?t:i.blockers.length>0?"blocked":t||"unknown"}function nt(i,t,f){var h;const c=[((h=i.blockerDiagnostics)==null?void 0:h.reason)??null,i.blockerReason??null,...i.blockers,t==="blocked"||t==="failed"||t==="handoff"?f:null].map(w=>typeof w=="string"?w.trim():"").filter(w=>w.length>0);return c.length>0?c.find(W=>!st(W))??c[0]:t==="handoff"?"Waiting for handoff acceptance by the next agent.":t==="blocked"?"Blocked without an explicit reason from runtime.":t==="failed"?"Run failed without explicit error details.":null}function lt(i){return i==="completed"?"border-lime/25 bg-lime/[0.08] text-lime":i==="needs_attention"?"border-amber-400/30 bg-amber-400/10 text-amber-200":i==="failed"?"border-red-400/30 bg-red-500/10 text-red-200":i==="in_progress"?"border-teal-400/30 bg-teal-400/10 text-teal-200":"border-strong bg-white/[0.04] text-secondary"}const dt={hidden:{opacity:0,y:-4},visible:i=>({opacity:1,y:0,transition:{duration:.28,delay:i*.04,ease:[.16,1,.3,1]}}),exit:{opacity:0,transition:{duration:.18}}},R={hidden:{opacity:0,y:8},visible:i=>({opacity:1,y:0,transition:{duration:.22,delay:i*.04,ease:[.22,1,.36,1]}}),exit:{opacity:0,transition:{duration:.18}}};function ue(){return e.jsx("div",{className:"h-px bg-gradient-to-r from-transparent via-white/[0.06] to-transparent"})}function ot(i){return i==="in_progress"?{background:`linear-gradient(90deg, ${x.lime}, ${x.teal})`}:i==="needs_attention"?{background:`linear-gradient(90deg, ${x.red}, ${x.amber})`}:i==="completed"?{background:`linear-gradient(90deg, ${x.teal}, ${x.cyan})`}:i==="failed"?{background:`linear-gradient(90deg, ${x.red}, ${x.red}80)`}:{background:`linear-gradient(90deg, ${x.iris}, ${x.iris}80)`}}const vt=j.memo(function({session:t,activity:f,initiatives:c=[],sliceRuns:h=[],onOpenActivityItem:w,onContinueHighestPriority:W,onDispatchSession:X,onPauseSession:K,onResumeSession:Q,onCancelSession:H,onCreateCheckpoint:J,onRollbackSession:Y,onStartInitiative:ct,onStartWorkstream:ut,initialInterventionDraft:C=null,onSubmitIntervention:te,onClose:me}){var ye,ve,je;const[u,xe]=j.useState(null),[L,T]=j.useState(null),[U,he]=j.useState(!1),[re,z]=j.useState(""),{enqueue:pe,ToastRenderer:Ce}=Ye();j.useEffect(()=>{if(!t){z("");return}if(C!=null&&C.text){z(C.text);return}z("")},[C==null?void 0:C.text,t==null?void 0:t.id]);const q=j.useMemo(()=>{var l,g,y,d,m;if(!t)return new Set;const r=new Set;return(l=t.runId)!=null&&l.trim()&&r.add(t.runId.trim()),(g=t.id)!=null&&g.trim()&&r.add(t.id.trim()),(m=(d=(y=t.blockerDiagnostics)==null?void 0:y.context)==null?void 0:d.sliceRunId)!=null&&m.trim()&&r.add(t.blockerDiagnostics.context.sliceRunId.trim()),r},[t]),$=j.useMemo(()=>t?q.size===0?[]:f.filter(r=>{const l=it(r);return!!(l&&q.has(l))}).sort((r,l)=>Date.parse(l.timestamp)-Date.parse(r.timestamp)).slice(0,12):[],[f,t,q]),s=j.useMemo(()=>{var y,d;if(!t||!Array.isArray(h)||h.length===0)return null;const r=((y=t.initiativeId)==null?void 0:y.trim())??"",l=((d=t.workstreamId)==null?void 0:d.trim())??"",g=h.filter(m=>{var oe,we;const A=((oe=m.sliceRunId)==null?void 0:oe.trim())??"",E=((we=m.runId)==null?void 0:we.trim())??"";if(A&&q.has(A)||E&&q.has(E))return!0;if(!l||!G(m.workstreamIds,m.workstreamId).includes(l))return!1;if(!r)return!0;const ee=G(m.initiativeIds,m.initiativeId);return!(ee.length>0&&!ee.includes(r))});return g.length===0?null:[...g].sort((m,A)=>{const E=Date.parse(m.updatedAt??m.lastEventAt??m.startedAt??""),de=Date.parse(A.updatedAt??A.lastEventAt??A.startedAt??""),ee=Number.isFinite(E)?E:0;return(Number.isFinite(de)?de:0)-ee})[0]},[t,q,h]),se=j.useMemo(()=>{var y;if(!t)return[];const r=[],l=t.initiativeId??t.groupId;if(l){const d=c.find(m=>m.id===l);d?r.push({label:"Initiative",value:d.name}):t.groupLabel&&t.groupLabel.trim().length>0?r.push({label:"Initiative",value:t.groupLabel}):B(l)&&r.push({label:"Initiative",value:N(l)})}if(t.workstreamId){let d=null;for(const m of c){const A=(y=m.workstreams)==null?void 0:y.find(E=>E.id===t.workstreamId);if(A){d=A.name;break}}!d&&B(t.workstreamId)?d=N(t.workstreamId):!d&&!De.test(t.workstreamId)&&(d=t.workstreamId),d&&r.push({label:"Workstream",value:d})}const g=t.phase??null;if(g){const d=String(g);r.push({label:"Milestone",value:B(d)?N(d):d})}return t.title&&r.push({label:"Task",value:t.title}),r},[c,t]),S=j.useMemo(()=>{var y,d;if(!t)return null;const r=((y=$[0])==null?void 0:y.summary)??((d=$[0])==null?void 0:d.description)??null,g=t.lastEventSummary??r??null;return g&&g.trim().length>0?g.trim():null},[$,t]),Ae=j.useMemo(()=>{var r;return t?ke(t.agentName,t.title,t.lastEventSummary,S,(r=$[0])==null?void 0:r.metadata):ke()},[$,t,S]),_=async(r,l,g)=>{if(!(!g||u)){xe(r),T(null);try{await g(),T(`${l} requested.`)}catch(y){T(y instanceof Error?y.message:`${l} failed.`)}finally{xe(null)}}};if(!t)return e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[e.jsx("div",{className:"h-[2px] flex-shrink-0",style:{background:`linear-gradient(90deg, ${x.iris}, ${x.iris}80)`}}),e.jsxs("div",{className:"flex items-center justify-between px-5 py-3",children:[e.jsx("p",{className:"section-kicker",children:"Session Detail"}),e.jsx("button",{onClick:()=>he(r=>!r),className:"text-muted transition-colors hover:text-primary","aria-label":U?"Expand session detail":"Collapse session detail",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:M("transition-transform",U?"-rotate-90":"rotate-0"),children:e.jsx("path",{d:"m6 9 6 6 6-6"})})})]}),e.jsx("div",{className:M("transition-all",U?"max-h-0 overflow-hidden":"min-h-0 flex-1"),children:e.jsxs("div",{className:"flex h-full min-h-0 flex-col items-center justify-center gap-4 px-5 py-8",children:[e.jsx("div",{className:"flex h-14 w-14 items-center justify-center rounded-2xl border border-white/[0.08] bg-white/[0.03]",children:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-muted",children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),e.jsx("path",{d:"M8 21h8M12 17v4"})]})}),e.jsx("p",{className:"text-body text-secondary text-center",children:"No session selected"}),e.jsx("p",{className:"text-caption text-muted text-center max-w-[240px]",children:"Select a session to inspect summary, breadcrumbs, blockers, and recent messages."}),e.jsx("button",{onClick:()=>_("continue-priority","Continue highest priority",W),disabled:!W||!!u,className:"mt-2 h-8 rounded-lg border border-lime/25 bg-lime/10 px-4 text-caption font-semibold text-lime transition-colors hover:bg-lime/20 disabled:opacity-45",children:u==="continue-priority"?"Dispatching...":"Continue highest priority"}),L&&e.jsx("p",{className:"text-caption text-secondary",children:L})]})})]});const P=t.progress===null?null:Math.round(t.progress),k=at(t),p=$[0]??null,ie=(s==null?void 0:s.blockingDecisionCount)??0,Re=Math.max(0,((s==null?void 0:s.decisionCount)??0)-ie),o=Ve({sessionStatus:t.status,sessionPhase:t.phase??null,sessionState:t.state??null,sliceStatus:(s==null?void 0:s.status)??null,activityType:(p==null?void 0:p.type)??null,activityStatus:(typeof(p==null?void 0:p.state)=="string"&&p.state.trim().length>0?p.state:null)??(typeof(p==null?void 0:p.phase)=="string"&&p.phase.trim().length>0?p.phase:null)??(s==null?void 0:s.runtimeState)??null,stopReason:t.blockerReason??((ye=t.blockerDiagnostics)==null?void 0:ye.reason)??((s==null?void 0:s.status)==="failed"?"error":null),decisionRequired:((p==null?void 0:p.decisionRequired)??!1)||ie>0,blockingDecisionCount:ie,nonBlockingDecisionCount:Re,blockerCount:t.blockers.length,blockerReason:t.blockerReason??((ve=t.blockerDiagnostics)==null?void 0:ve.reason)??null}),ae=nt(t,k,S),Te=k==="handoff"?"Handoff":k==="blocked"?"Blocker reason":k==="failed"?"Failure reason":"Status note",$e=o.status==="in_progress"&&["running","active","queued","pending","working","in_progress","planning","review"].includes(k),Se=o.status==="needs_attention"&&["paused","blocked","queued","pending"].includes(k),Be=!["completed","archived","cancelled"].includes(k),Me=!["archived","cancelled"].includes(k),Le=o.label,_e=lt(o.status),ne=["running","active","working","in_progress","planning","review"].includes(k),Ee=o.status!=="in_progress"&&!ne,We=o.tone==="critical"?x.red:o.tone==="warning"?x.amber:o.tone==="positive"?x.lime:x.teal,Ue=P!==null&&P>=100&&o.status!=="completed"?"Terminal state":"Progress",qe=o.tone==="critical"?"border-red-400/25 bg-red-500/10":o.tone==="warning"?"border-amber-400/25 bg-amber-500/10":o.tone==="positive"?"border-lime/22 bg-lime/[0.08]":"border-subtle bg-white/[0.02]",a=t.blockerDiagnostics??null,n=(a==null?void 0:a.context)??null,le=[v(a==null?void 0:a.source)?`Source: ${a.source.trim()}`:null,v(a==null?void 0:a.errorCode)?`Code: ${a.errorCode.trim()}`:null,v(a==null?void 0:a.errorCategory)?`Category: ${a.errorCategory.trim()}`:null,(a==null?void 0:a.retryable)===!0?"Retryable: yes":(a==null?void 0:a.retryable)===!1?"Retryable: no":null].filter(r=>!!r),b=[];n&&(Array.isArray(n.initiativeIds)&&n.initiativeIds.length>0?b.push({label:"Initiatives",value:V(n.initiativeIds.map(r=>B(r)?N(r):r),4)}):v(n.initiativeId)&&b.push({label:"Initiative",value:Ge("Initiative",n.initiativeId.trim())}),v(n.workstreamTitle)?b.push({label:"Workstream",value:n.workstreamTitle.trim()}):Array.isArray(n.workstreamIds)&&n.workstreamIds.length>0?b.push({label:"Workstreams",value:V(n.workstreamIds,4)}):v(n.workstreamId)&&b.push({label:"Workstream",value:n.workstreamId.trim()}),v(n.sliceRunId)&&b.push({label:"Slice run",value:N(n.sliceRunId.trim())}),v(n.parallelMode)&&b.push({label:"Mode",value:n.parallelMode.trim().toUpperCase()}),Array.isArray(n.taskIds)&&n.taskIds.length>0&&b.push({label:"Tasks",value:V(n.taskIds.map(r=>B(r)?N(r):r))}),Array.isArray(n.milestoneIds)&&n.milestoneIds.length>0&&b.push({label:"Milestones",value:V(n.milestoneIds.map(r=>B(r)?N(r):r))}),Array.isArray(n.iwmtIds)&&n.iwmtIds.length>0?b.push({label:"Scope IDs",value:V(n.iwmtIds.map(r=>B(r)?N(r):r),4)}):v(n.iwmtId)&&b.push({label:"Scope ID",value:B(n.iwmtId.trim())?N(n.iwmtId.trim()):n.iwmtId.trim()}),v(n.logPath)&&b.push({label:"Log path",value:Ne(n.logPath.trim())}),v(n.outputPath)&&b.push({label:"Output path",value:Ne(n.outputPath.trim())}));const be=(k==="blocked"||k==="failed")&&!!(a&&(v(a.reason)||le.length>0||b.length>0||Array.isArray(a.suggestedActions)&&a.suggestedActions.length>0)),Z=v(ae)?ae:null,ze=Z!==null&&!(S&&(Z===S||S.includes(Z)))&&!be,Pe=j.useCallback(()=>{!H||!t||(T("Session will be cancelled..."),pe({message:`Cancelled "${t.title}"`,onCommit:async()=>{try{await H(t),T("Session cancelled.")}catch(r){T(r instanceof Error?r.message:"Cancel failed.")}},onUndo:()=>{T(null)}}))},[H,t,pe]),Fe=[{label:"Started",value:t.startedAt?O(t.startedAt):"—"},{label:"Updated",value:t.updatedAt?O(t.updatedAt):"—"},...t.eta?[{label:"ETA",value:t.eta}]:[],...t.checkpointCount?[{label:"Checkpoints",value:String(t.checkpointCount)}]:[]],fe=s?s.status.replace(/_/g," "):null,F=G(s==null?void 0:s.initiativeIds,(s==null?void 0:s.initiativeId)??null),D=G(s==null?void 0:s.workstreamIds,(s==null?void 0:s.workstreamId)??null);G(s==null?void 0:s.iwmtIds,(s==null?void 0:s.iwmtId)??null);const Oe=F[0]?((je=c.find(r=>r.id===F[0]))==null?void 0:je.name)??F[0]:null,ge=L?L.toLowerCase().includes("fail")||L.toLowerCase().includes("error")?"error":u?"pending":"success":null;return e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[e.jsx("div",{className:"h-[2px] flex-shrink-0",style:ot(o.status)}),e.jsxs("div",{className:"flex items-center justify-between px-5 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("p",{className:"section-kicker",children:"Session Detail"}),e.jsxs("span",{className:M("inline-flex items-center gap-1.5 rounded-full border px-2 py-[1px] text-micro font-semibold uppercase tracking-widest",_e),children:[ne&&e.jsx("span",{className:"h-1.5 w-1.5 rounded-full pulse-soft",style:{backgroundColor:Ie(k)}}),Le]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{onClick:()=>he(r=>!r),className:"text-muted transition-colors hover:text-primary","aria-label":U?"Expand session detail":"Collapse session detail",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:M("transition-transform",U?"-rotate-90":"rotate-0"),children:e.jsx("path",{d:"m6 9 6 6 6-6"})})}),me&&e.jsx("button",{type:"button",onClick:me,"aria-label":"Close session inspector",className:"inline-flex h-8 w-8 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:"14",height:"14",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.jsxs("div",{className:M("transition-all flex flex-col min-h-0",U?"max-h-0 overflow-hidden":"flex-1"),children:[e.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto px-5 py-5 space-y-5",children:[e.jsx(Ze,{mode:"wait",children:e.jsxs(I.div,{variants:dt,initial:"hidden",animate:"visible",exit:"exit",custom:0,children:[e.jsxs("div",{className:"flex items-start gap-3.5",children:[e.jsx(Xe,{name:t.agentName??"OrgX",size:"md",hint:t.agentName}),e.jsxs("div",{className:"min-w-0 flex-1 pt-0.5",children:[e.jsx("h2",{className:"text-[28px] font-medium leading-tight text-white truncate",children:Ke(t.title)}),e.jsxs("p",{className:"mt-1 text-micro uppercase tracking-[0.12em] text-muted",children:[t.agentName??"OrgX"," · ",Ae.label]})]})]}),se.length>0&&e.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-1.5",children:se.map((r,l)=>e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(Qe,{tone:"muted",children:r.value}),l<se.length-1&&e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"flex-shrink-0 text-faint",children:e.jsx("path",{d:"m9 18 6-6-6-6"})})]},`${r.label}-${r.value}`))})]},t.id)}),e.jsx(ue,{}),S&&e.jsxs(I.div,{variants:R,initial:"hidden",animate:"visible",custom:1,children:[e.jsx("p",{className:"section-kicker mb-2",children:"Summary"}),e.jsx(He,{text:S,mode:"block"})]}),e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:2,children:e.jsxs("div",{className:M("rounded-xl border px-4 py-3",qe),children:[e.jsx("p",{className:"section-kicker mb-1.5",children:o.label}),e.jsx("p",{className:"text-body text-secondary",children:o.sentence}),o.nextAction&&e.jsxs("p",{className:"mt-1.5 flex items-center gap-1 text-caption text-secondary",children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:x.lime,strokeWidth:"2.5",className:"flex-shrink-0",children:e.jsx("path",{d:"m9 18 6-6-6-6"})}),"Next: ",o.nextAction]})]})}),ze&&e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:3,children:e.jsxs("div",{className:"rounded-xl border border-subtle bg-white/[0.02] px-4 py-3",children:[e.jsx("p",{className:"section-kicker mb-1.5",children:Te}),e.jsx("p",{className:"text-body text-secondary",children:Z})]})}),be&&e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:3,children:e.jsxs("div",{className:"rounded-xl border border-red-500/25 bg-red-500/10 px-4 py-3",children:[e.jsx("p",{className:"section-kicker mb-1.5 text-red-200/75",children:"Why blocked"}),e.jsx("p",{className:"text-body text-red-100/90",children:(a==null?void 0:a.reason)??ae??"Runtime marked this run as blocked without details."}),le.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:le.map(r=>e.jsx("span",{className:"rounded-full border border-red-300/25 bg-red-500/10 px-2 py-0.5 text-micro text-red-100/85",children:r},r))}),b.length>0&&e.jsxs("div",{className:"mt-2 rounded-md border border-red-300/20 bg-black/15 p-2.5",children:[e.jsx("p",{className:"mb-1 text-micro uppercase tracking-[0.14em] text-red-200/65",children:"Associated context"}),e.jsx("dl",{className:"grid grid-cols-1 gap-1.5 text-caption text-red-100/85",children:b.map(r=>e.jsxs("div",{className:"grid grid-cols-[86px_1fr] gap-2",children:[e.jsx("dt",{className:"text-red-200/70",children:r.label}),e.jsx("dd",{className:"break-all text-red-50/95",children:r.value})]},r.label))})]}),Array.isArray(a==null?void 0:a.suggestedActions)&&a.suggestedActions.length>0&&e.jsxs("div",{className:"mt-2",children:[e.jsx("p",{className:"mb-1 text-micro uppercase tracking-[0.14em] text-red-200/65",children:"Suggested actions"}),e.jsx("ul",{className:"space-y-1 text-caption text-red-100/85",children:a.suggestedActions.map(r=>e.jsxs("li",{children:["• ",r]},r))})]}),v(a==null?void 0:a.eventTimestamp)&&e.jsxs("p",{className:"mt-2 text-micro text-red-200/60",children:["Last blocker event: ",new Date(a.eventTimestamp).toLocaleString()," ·"," ",O(a.eventTimestamp)]})]})}),e.jsx(ue,{}),e.jsxs(I.div,{variants:R,initial:"hidden",animate:"visible",custom:4,children:[P!==null&&e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between text-caption text-secondary",children:[e.jsx("span",{children:Ue}),e.jsxs("span",{className:"text-primary",children:[P,"%"]})]}),e.jsx("div",{className:"h-[3px] rounded-full bg-white/[0.08]",children:e.jsx(I.div,{className:M("h-[3px] rounded-full",ne&&"live-pulse"),style:{background:We},initial:{width:0},animate:{width:`${P}%`},transition:{duration:.5,ease:Je.easingStandard}})})]}),e.jsx("dl",{className:"grid grid-cols-2 gap-3 text-caption text-secondary",children:Fe.map(r=>e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:r.label}),e.jsx("dd",{className:"text-body font-semibold text-white",children:r.value})]},r.label))})]}),s&&e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:5,children:e.jsxs("div",{className:"rounded-xl border border-subtle bg-white/[0.02] px-4 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"section-kicker",children:"Slice scope"}),fe?e.jsx("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-micro font-semibold uppercase tracking-[0.08em] text-secondary",children:fe}):null]}),s.statusExplainer?e.jsx("p",{className:"mt-2 text-caption text-secondary",children:s.statusExplainer}):null,e.jsxs("dl",{className:"mt-2 grid grid-cols-2 gap-2 text-caption text-secondary",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:"Initiative"}),e.jsx("dd",{className:"text-body font-semibold text-white",children:Oe??"—"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:"Workstream"}),e.jsx("dd",{className:"text-body font-semibold text-white",children:s.workstreamTitle??(D[0]?N(D[0]):"—")})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:"Run"}),e.jsx("dd",{className:"break-all text-body font-semibold text-white",children:N(s.runId??s.sliceRunId)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:"Updated"}),e.jsx("dd",{className:"text-body font-semibold text-white",children:s.updatedAt?O(s.updatedAt):"—"})]})]}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5 text-micro",children:[e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["Tasks ",s.taskIds.length]}),e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["Milestones ",s.milestoneIds.length]}),e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["Artifacts ",s.artifactCount]}),e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["Needs input ",s.blockingDecisionCount]}),F.length>1?e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["+",F.length-1," initiatives"]}):null,D.length>1?e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["+",D.length-1," workstreams"]}):null]}),s.taskIds.length>0?e.jsxs("p",{className:"mt-2 text-micro text-secondary",children:["Tasks: ",s.taskIds.length]}):null]})}),t.blockers.length>0&&e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:6,children:e.jsxs("div",{className:"rounded-xl border border-red-500/30 bg-red-500/10 px-4 py-3",children:[e.jsx("p",{className:"section-kicker mb-2 text-red-200/70",children:"Blockers"}),e.jsx("ul",{className:"space-y-1 text-body text-red-100/90",children:t.blockers.map(r=>e.jsxs("li",{children:["• ",r]},r))})]})}),e.jsx(ue,{}),e.jsxs(I.div,{variants:R,initial:"hidden",animate:"visible",custom:7,children:[e.jsx("p",{className:"section-kicker mb-4",children:"Recent Messages"}),$.length===0&&e.jsx("p",{className:"text-body text-secondary",children:"No recent messages for this run."}),e.jsx("div",{className:"relative border-l border-white/[0.06] pl-6 ml-1 space-y-3",children:$.map((r,l)=>e.jsxs(I.div,{className:"relative group",variants:R,initial:"hidden",animate:"visible",custom:l,children:[e.jsx("div",{className:"absolute -left-[27px] top-1.5 h-2 w-2 rounded-full border border-black ring-4 ring-black",style:{backgroundColor:Ie(r.type??r.state??"unknown")}}),e.jsxs("article",{className:"rounded-lg border border-subtle bg-white/[0.02] px-3 py-2.5 transition-colors hover:bg-white/[0.04]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("p",{className:"min-w-0 flex-1 text-caption text-bright",children:r.title}),w&&e.jsx("button",{type:"button",onClick:()=>w(r),className:"flex-shrink-0 rounded-full border border-strong bg-white/[0.03] px-2.5 py-0.5 text-micro font-semibold text-secondary opacity-0 transition-all group-hover:opacity-100 hover:bg-white/[0.08] hover:text-primary",children:"Open"})]}),(r.summary||r.description)&&e.jsx("p",{className:"mt-0.5 line-clamp-2 text-caption text-secondary",children:r.summary??r.description}),e.jsxs("p",{className:"mt-1 text-micro text-muted",children:[new Date(r.timestamp).toLocaleString()," · ",O(r.timestamp)]})]})]},r.id))})]})]}),e.jsxs("div",{className:"flex-shrink-0 border-t border-subtle px-5 py-3 space-y-3",children:[L&&e.jsx("p",{className:M("rounded-md border px-2.5 py-1.5 text-caption",ge==="error"?"border-red-400/30 bg-red-500/10 text-red-200":ge==="pending"?"border-white/[0.08] bg-white/[0.02] text-secondary pulse-soft":"border-lime/25 bg-lime/[0.08] text-lime"),children:L}),te&&e.jsx("div",{children:e.jsx("textarea",{value:re,onChange:r=>z(r.target.value),placeholder:"Share guidance for this run...",rows:2,className:"w-full resize-none rounded-lg border border-white/[0.10] bg-white/[0.03] px-3 py-2 text-body text-bright outline-none placeholder:text-faint focus:border-white/20"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[$e&&e.jsx("button",{onClick:()=>_("pause-session","Session paused",()=>K==null?void 0:K(t)),disabled:!K||!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-secondary hover:bg-white/[0.04] hover:text-white disabled:opacity-45 transition-colors",children:u==="pause-session"?"Pausing...":"Pause"}),Se&&e.jsx("button",{onClick:()=>_("resume-session","Session resumed",()=>Q==null?void 0:Q(t)),disabled:!Q||!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-secondary hover:bg-white/[0.04] hover:text-white disabled:opacity-45 transition-colors",children:u==="resume-session"?"Resuming...":"Resume"}),e.jsx("button",{onClick:()=>_("checkpoint-session","Progress saved",()=>J==null?void 0:J(t)),disabled:!J||!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-secondary hover:bg-white/[0.04] hover:text-white disabled:opacity-45 transition-colors",children:u==="checkpoint-session"?"Saving...":"Save"}),Me&&e.jsx("button",{onClick:()=>_("rollback-session","Undo requested",()=>Y==null?void 0:Y(t)),disabled:!Y||!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-secondary hover:bg-white/[0.04] hover:text-white disabled:opacity-45 transition-colors",children:u==="rollback-session"?"Undoing...":"Undo"}),Be&&H&&e.jsx("button",{onClick:Pe,disabled:!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-red-400/70 hover:bg-red-500/[0.08] hover:text-red-300 disabled:opacity-45 transition-colors",children:"Cancel"})]}),e.jsx("div",{className:"flex-1"}),te&&e.jsx("button",{type:"button",onClick:()=>{const r=re.trim();if(!r){T("Intervention note cannot be empty.");return}_("intervene-note","Intervention sent",async()=>{await te({session:t,workstreamId:(C==null?void 0:C.workstreamId)??t.workstreamId??null,text:r}),z("")})},disabled:!!u||re.trim().length===0,className:"rounded-md border border-strong bg-white/[0.03] px-3 py-1.5 text-caption font-semibold text-primary transition-colors hover:bg-white/[0.08] disabled:opacity-45",children:u==="intervene-note"?"Sending...":"Intervene"}),e.jsxs("button",{onClick:()=>_("dispatch-session","Session started",()=>X==null?void 0:X(t)),disabled:!X||!!u||!Ee,className:"inline-flex h-8 items-center gap-1.5 rounded-lg border border-lime/25 bg-lime/10 px-4 text-caption font-semibold text-lime transition-colors hover:bg-lime/20 disabled:opacity-45",children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",className:"flex-shrink-0",children:e.jsx("path",{d:"M8 5v14l11-7z"})}),u==="dispatch-session"?"Starting...":o.status==="completed"?"Restart":"Start"]})]})]})]}),e.jsx(Ce,{})]})});export{vt as SessionInspector};
@@ -1 +1 @@
1
- import{r as l,j as e}from"./Dj2k1r16.js";import{e as r,y as u,E as j,r as f}from"./DxUw4FMR.js";import"./BiOgVMED.js";import"./eeHXe_OQ.js";import"./cX2e-TLi.js";import"./BjK42gtU.js";import"./BV0BcV1u.js";function c(a){if(!a)return"unknown";try{return f(a)}catch{return"unknown"}}function E({open:a,onClose:o,outbox:t,onOpenSettings:p,onRefresh:m}){const[x,d]=l.useState(!1),h=l.useMemo(()=>Object.entries(t.pendingByQueue??{}).filter(([,s])=>typeof s=="number"&&s>0).sort((s,b)=>b[1]-s[1]),[t.pendingByQueue]),i=l.useMemo(()=>t.replayStatus==="error"?r.red:t.pendingTotal>0?r.amber:r.textMuted,[t.pendingTotal,t.replayStatus]),y=async()=>{try{await navigator.clipboard.writeText(JSON.stringify(t,null,2)),d(!0),setTimeout(()=>d(!1),1200)}catch{}};return e.jsx(u,{open:a,onClose:o,maxWidth:"max-w-3xl",fitContent:!0,children:e.jsxs("div",{className:"flex w-full flex-col",children:[e.jsxs("div",{className:"border-b border-subtle px-5 pt-5 pb-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h3",{className:"inline-flex items-center gap-2 text-heading font-semibold text-white",children:[e.jsx(j,{type:"outbox",size:14}),e.jsx("span",{className:"truncate",children:"Outbox"}),e.jsx("span",{className:"rounded-full border px-2 py-0.5 text-caption font-semibold",style:{borderColor:`${i}30`,backgroundColor:`${i}14`,color:i},children:t.pendingTotal})]}),e.jsx("p",{className:"mt-1 text-body leading-relaxed text-secondary",children:"Buffered updates queued for replay to OrgX when connectivity is healthy."})]}),e.jsx("button",{type:"button",onClick:o,className:"rounded-md border border-strong bg-white/[0.03] px-2.5 py-1.5 text-caption text-primary transition-colors hover:bg-white/[0.08]","aria-label":"Close outbox modal",children:"Close"})]}),e.jsxs("div",{className:"mt-3 grid grid-cols-1 gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-xl border border-white/[0.08] bg-white/[0.02] px-3 py-2",children:[e.jsx("p",{className:"text-micro uppercase tracking-[0.12em] text-secondary",children:"Replay status"}),e.jsx("p",{className:"mt-1 text-body font-semibold",style:{color:i},children:t.replayStatus}),t.lastReplayError&&t.replayStatus==="error"&&e.jsx("p",{className:"mt-1 line-clamp-2 text-caption text-red-200/75",children:t.lastReplayError})]}),e.jsxs("div",{className:"rounded-xl border border-white/[0.08] bg-white/[0.02] px-3 py-2",children:[e.jsx("p",{className:"text-micro uppercase tracking-[0.12em] text-secondary",children:"Window"}),e.jsxs("p",{className:"mt-1 text-caption text-primary",children:["Oldest: ",e.jsx("span",{className:"font-semibold text-white",children:c(t.oldestEventAt)})]}),e.jsxs("p",{className:"mt-0.5 text-caption text-primary",children:["Newest: ",e.jsx("span",{className:"font-semibold text-white",children:c(t.newestEventAt)})]})]})]})]}),e.jsx("div",{className:"px-5 py-4",children:t.pendingTotal===0?e.jsx("div",{className:"rounded-xl border border-subtle bg-white/[0.02] p-4 text-body text-secondary",children:"Outbox is empty."}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-caption font-semibold uppercase tracking-[0.12em] text-secondary",children:"Queues"}),e.jsx("button",{type:"button",onClick:y,className:"rounded-md border border-strong bg-white/[0.03] px-2.5 py-1.5 text-caption text-secondary transition-colors hover:bg-white/[0.08]",children:x?"Copied":"Copy JSON"})]}),e.jsx("div",{className:"space-y-1.5",children:h.map(([n,s])=>e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-white/[0.08] bg-white/[0.02] px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-body font-medium text-white",children:n}),e.jsxs("p",{className:"mt-0.5 text-micro text-secondary",children:[s," event",s===1?"":"s"]})]}),e.jsx("span",{className:"rounded-full border px-2 py-0.5 text-caption font-semibold",style:{borderColor:`${r.amber}30`,backgroundColor:`${r.amber}14`,color:r.amber},children:s})]},n))}),e.jsx("div",{className:"rounded-xl border border-subtle bg-white/[0.02] px-3 py-2 text-caption text-secondary",children:"Replay is handled automatically by the OrgX sync service. If events stay queued, check Settings for API key and last replay errors."})]})}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-subtle px-5 py-3",children:[e.jsx("button",{type:"button",onClick:m,className:"rounded-md border border-strong bg-white/[0.03] px-3 py-1.5 text-caption text-primary transition-colors hover:bg-white/[0.08]",children:"Refresh"}),e.jsx("button",{type:"button",onClick:p,className:"rounded-md border border-lime/25 bg-lime/10 px-3 py-1.5 text-caption font-semibold text-lime transition-colors hover:bg-lime/20",children:"Open settings"})]})]})})}export{E as BulkOutboxModal};
1
+ import{r as l,j as e}from"./Dj2k1r16.js";import{e as r,y as u,E as j,v as f}from"./C8AYbjlq.js";import"./DMKyYAtD.js";import"./eeHXe_OQ.js";import"./cX2e-TLi.js";import"./BjK42gtU.js";import"./BV0BcV1u.js";function c(a){if(!a)return"unknown";try{return f(a)}catch{return"unknown"}}function E({open:a,onClose:o,outbox:t,onOpenSettings:p,onRefresh:m}){const[x,d]=l.useState(!1),h=l.useMemo(()=>Object.entries(t.pendingByQueue??{}).filter(([,s])=>typeof s=="number"&&s>0).sort((s,b)=>b[1]-s[1]),[t.pendingByQueue]),i=l.useMemo(()=>t.replayStatus==="error"?r.red:t.pendingTotal>0?r.amber:r.textMuted,[t.pendingTotal,t.replayStatus]),y=async()=>{try{await navigator.clipboard.writeText(JSON.stringify(t,null,2)),d(!0),setTimeout(()=>d(!1),1200)}catch{}};return e.jsx(u,{open:a,onClose:o,maxWidth:"max-w-3xl",fitContent:!0,children:e.jsxs("div",{className:"flex w-full flex-col",children:[e.jsxs("div",{className:"border-b border-subtle px-5 pt-5 pb-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h3",{className:"inline-flex items-center gap-2 text-heading font-semibold text-white",children:[e.jsx(j,{type:"outbox",size:14}),e.jsx("span",{className:"truncate",children:"Outbox"}),e.jsx("span",{className:"rounded-full border px-2 py-0.5 text-caption font-semibold",style:{borderColor:`${i}30`,backgroundColor:`${i}14`,color:i},children:t.pendingTotal})]}),e.jsx("p",{className:"mt-1 text-body leading-relaxed text-secondary",children:"Buffered updates queued for replay to OrgX when connectivity is healthy."})]}),e.jsx("button",{type:"button",onClick:o,className:"rounded-md border border-strong bg-white/[0.03] px-2.5 py-1.5 text-caption text-primary transition-colors hover:bg-white/[0.08]","aria-label":"Close outbox modal",children:"Close"})]}),e.jsxs("div",{className:"mt-3 grid grid-cols-1 gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-xl border border-white/[0.08] bg-white/[0.02] px-3 py-2",children:[e.jsx("p",{className:"text-micro uppercase tracking-[0.12em] text-secondary",children:"Replay status"}),e.jsx("p",{className:"mt-1 text-body font-semibold",style:{color:i},children:t.replayStatus}),t.lastReplayError&&t.replayStatus==="error"&&e.jsx("p",{className:"mt-1 line-clamp-2 text-caption text-red-200/75",children:t.lastReplayError})]}),e.jsxs("div",{className:"rounded-xl border border-white/[0.08] bg-white/[0.02] px-3 py-2",children:[e.jsx("p",{className:"text-micro uppercase tracking-[0.12em] text-secondary",children:"Window"}),e.jsxs("p",{className:"mt-1 text-caption text-primary",children:["Oldest: ",e.jsx("span",{className:"font-semibold text-white",children:c(t.oldestEventAt)})]}),e.jsxs("p",{className:"mt-0.5 text-caption text-primary",children:["Newest: ",e.jsx("span",{className:"font-semibold text-white",children:c(t.newestEventAt)})]})]})]})]}),e.jsx("div",{className:"px-5 py-4",children:t.pendingTotal===0?e.jsx("div",{className:"rounded-xl border border-subtle bg-white/[0.02] p-4 text-body text-secondary",children:"Outbox is empty."}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-caption font-semibold uppercase tracking-[0.12em] text-secondary",children:"Queues"}),e.jsx("button",{type:"button",onClick:y,className:"rounded-md border border-strong bg-white/[0.03] px-2.5 py-1.5 text-caption text-secondary transition-colors hover:bg-white/[0.08]",children:x?"Copied":"Copy JSON"})]}),e.jsx("div",{className:"space-y-1.5",children:h.map(([n,s])=>e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-white/[0.08] bg-white/[0.02] px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-body font-medium text-white",children:n}),e.jsxs("p",{className:"mt-0.5 text-micro text-secondary",children:[s," event",s===1?"":"s"]})]}),e.jsx("span",{className:"rounded-full border px-2 py-0.5 text-caption font-semibold",style:{borderColor:`${r.amber}30`,backgroundColor:`${r.amber}14`,color:r.amber},children:s})]},n))}),e.jsx("div",{className:"rounded-xl border border-subtle bg-white/[0.02] px-3 py-2 text-caption text-secondary",children:"Replay is handled automatically by the OrgX sync service. If events stay queued, check Settings for API key and last replay errors."})]})}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-subtle px-5 py-3",children:[e.jsx("button",{type:"button",onClick:m,className:"rounded-md border border-strong bg-white/[0.03] px-3 py-1.5 text-caption text-primary transition-colors hover:bg-white/[0.08]",children:"Refresh"}),e.jsx("button",{type:"button",onClick:p,className:"rounded-md border border-lime/25 bg-lime/10 px-3 py-1.5 text-caption font-semibold text-lime transition-colors hover:bg-lime/20",children:"Open settings"})]})]})})}export{E as BulkOutboxModal};