@useorgx/openclaw-plugin 0.7.3 → 0.7.5

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 (123) hide show
  1. package/dashboard/dist/assets/{CZaT3ob_.js → 77gGFBt6.js} +1 -1
  2. package/dashboard/dist/assets/77gGFBt6.js.br +0 -0
  3. package/dashboard/dist/assets/77gGFBt6.js.gz +0 -0
  4. package/dashboard/dist/assets/BBpTN_SR.js +1 -0
  5. package/dashboard/dist/assets/BBpTN_SR.js.br +0 -0
  6. package/dashboard/dist/assets/BBpTN_SR.js.gz +0 -0
  7. package/dashboard/dist/assets/BTAEErUY.js +1 -0
  8. package/dashboard/dist/assets/BTAEErUY.js.br +0 -0
  9. package/dashboard/dist/assets/BTAEErUY.js.gz +0 -0
  10. package/dashboard/dist/assets/BVShoyjA.js +1 -0
  11. package/dashboard/dist/assets/BVShoyjA.js.br +0 -0
  12. package/dashboard/dist/assets/BVShoyjA.js.gz +0 -0
  13. package/dashboard/dist/assets/{CC63EwFD.js → BgcAY5rE.js} +1 -1
  14. package/dashboard/dist/assets/BgcAY5rE.js.br +0 -0
  15. package/dashboard/dist/assets/BgcAY5rE.js.gz +0 -0
  16. package/dashboard/dist/assets/{rttbDbEx.js → C-PAoJF-.js} +1 -1
  17. package/dashboard/dist/assets/C-PAoJF-.js.br +0 -0
  18. package/dashboard/dist/assets/C-PAoJF-.js.gz +0 -0
  19. package/dashboard/dist/assets/C0nA-iUG.js +1 -0
  20. package/dashboard/dist/assets/C0nA-iUG.js.br +0 -0
  21. package/dashboard/dist/assets/C0nA-iUG.js.gz +0 -0
  22. package/dashboard/dist/assets/C6GO-FKy.js +1 -0
  23. package/dashboard/dist/assets/C6GO-FKy.js.br +0 -0
  24. package/dashboard/dist/assets/C6GO-FKy.js.gz +0 -0
  25. package/dashboard/dist/assets/CFwPph5U.js +1 -0
  26. package/dashboard/dist/assets/CFwPph5U.js.br +0 -0
  27. package/dashboard/dist/assets/CFwPph5U.js.gz +0 -0
  28. package/dashboard/dist/assets/CPjsbbgZ.js +212 -0
  29. package/dashboard/dist/assets/CPjsbbgZ.js.br +0 -0
  30. package/dashboard/dist/assets/CPjsbbgZ.js.gz +0 -0
  31. package/dashboard/dist/assets/{IUexzymk.js → CSr2ZnTV.js} +1 -1
  32. package/dashboard/dist/assets/CSr2ZnTV.js.br +0 -0
  33. package/dashboard/dist/assets/CSr2ZnTV.js.gz +0 -0
  34. package/dashboard/dist/assets/CgQDT6yL.js +1 -0
  35. package/dashboard/dist/assets/CgQDT6yL.js.br +0 -0
  36. package/dashboard/dist/assets/CgQDT6yL.js.gz +0 -0
  37. package/dashboard/dist/assets/{B6wPWJ35.js → CnitK1MX.js} +1 -1
  38. package/dashboard/dist/assets/CnitK1MX.js.br +0 -0
  39. package/dashboard/dist/assets/CnitK1MX.js.gz +0 -0
  40. package/dashboard/dist/assets/{CgaottFX.js → D7DHFX0D.js} +1 -1
  41. package/dashboard/dist/assets/D7DHFX0D.js.br +0 -0
  42. package/dashboard/dist/assets/D7DHFX0D.js.gz +0 -0
  43. package/dashboard/dist/assets/DEip7uko.js +1 -0
  44. package/dashboard/dist/assets/DEip7uko.js.br +0 -0
  45. package/dashboard/dist/assets/DEip7uko.js.gz +0 -0
  46. package/dashboard/dist/assets/DHUSLc01.css +1 -0
  47. package/dashboard/dist/assets/DHUSLc01.css.br +0 -0
  48. package/dashboard/dist/assets/DHUSLc01.css.gz +0 -0
  49. package/dashboard/dist/assets/{B5zYRHc3.js → DOFL9l8s.js} +1 -1
  50. package/dashboard/dist/assets/DOFL9l8s.js.br +0 -0
  51. package/dashboard/dist/assets/DOFL9l8s.js.gz +0 -0
  52. package/dashboard/dist/assets/{8dksYiq4.js → DpuQm1oF.js} +1 -1
  53. package/dashboard/dist/assets/DpuQm1oF.js.br +0 -0
  54. package/dashboard/dist/assets/DpuQm1oF.js.gz +0 -0
  55. package/dashboard/dist/assets/{D8JNX8kq.js → DxKG5zy8.js} +2 -2
  56. package/dashboard/dist/assets/DxKG5zy8.js.br +0 -0
  57. package/dashboard/dist/assets/DxKG5zy8.js.gz +0 -0
  58. package/dashboard/dist/assets/tcEHYcbW.js +1 -0
  59. package/dashboard/dist/assets/tcEHYcbW.js.br +0 -0
  60. package/dashboard/dist/assets/tcEHYcbW.js.gz +0 -0
  61. package/dashboard/dist/index.html +2 -2
  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.js +29 -11
  65. package/dist/http/helpers/autopilot-slice-utils.js +7 -10
  66. package/dist/http/helpers/openclaw-cli.js +2 -2
  67. package/dist/http/index.js +161 -4
  68. package/dist/http/routes/live-legacy.d.ts +2 -0
  69. package/dist/http/routes/live-legacy.js +186 -3
  70. package/dist/http/routes/live-misc.d.ts +1 -0
  71. package/dist/http/routes/live-misc.js +76 -0
  72. package/dist/http/routes/mission-control-read.d.ts +4 -0
  73. package/dist/http/routes/mission-control-read.js +114 -63
  74. package/dist/http/routes/usage.js +15 -3
  75. package/dist/json-utils.js +5 -1
  76. package/dist/openclaw-settings.js +3 -2
  77. package/dist/sync/outbox-replay.js +17 -8
  78. package/package.json +6 -1
  79. package/dashboard/dist/assets/6mILZQ2a.js +0 -1
  80. package/dashboard/dist/assets/6mILZQ2a.js.br +0 -0
  81. package/dashboard/dist/assets/6mILZQ2a.js.gz +0 -0
  82. package/dashboard/dist/assets/8dksYiq4.js.br +0 -0
  83. package/dashboard/dist/assets/8dksYiq4.js.gz +0 -0
  84. package/dashboard/dist/assets/B5zYRHc3.js.br +0 -0
  85. package/dashboard/dist/assets/B5zYRHc3.js.gz +0 -0
  86. package/dashboard/dist/assets/B6wPWJ35.js.br +0 -0
  87. package/dashboard/dist/assets/B6wPWJ35.js.gz +0 -0
  88. package/dashboard/dist/assets/BWEwjt1W.js +0 -1
  89. package/dashboard/dist/assets/BWEwjt1W.js.br +0 -0
  90. package/dashboard/dist/assets/BWEwjt1W.js.gz +0 -0
  91. package/dashboard/dist/assets/BzRbDCAD.css +0 -1
  92. package/dashboard/dist/assets/BzRbDCAD.css.br +0 -0
  93. package/dashboard/dist/assets/BzRbDCAD.css.gz +0 -0
  94. package/dashboard/dist/assets/C8uM3AX8.js +0 -1
  95. package/dashboard/dist/assets/C8uM3AX8.js.br +0 -0
  96. package/dashboard/dist/assets/C8uM3AX8.js.gz +0 -0
  97. package/dashboard/dist/assets/C9jy61eu.js +0 -212
  98. package/dashboard/dist/assets/C9jy61eu.js.br +0 -0
  99. package/dashboard/dist/assets/C9jy61eu.js.gz +0 -0
  100. package/dashboard/dist/assets/CC63EwFD.js.br +0 -0
  101. package/dashboard/dist/assets/CC63EwFD.js.gz +0 -0
  102. package/dashboard/dist/assets/CZaT3ob_.js.br +0 -0
  103. package/dashboard/dist/assets/CZaT3ob_.js.gz +0 -0
  104. package/dashboard/dist/assets/CgaottFX.js.br +0 -0
  105. package/dashboard/dist/assets/CgaottFX.js.gz +0 -0
  106. package/dashboard/dist/assets/CzCxAZlW.js +0 -1
  107. package/dashboard/dist/assets/CzCxAZlW.js.br +0 -0
  108. package/dashboard/dist/assets/CzCxAZlW.js.gz +0 -0
  109. package/dashboard/dist/assets/D3iMTYEj.js +0 -1
  110. package/dashboard/dist/assets/D3iMTYEj.js.br +0 -0
  111. package/dashboard/dist/assets/D3iMTYEj.js.gz +0 -0
  112. package/dashboard/dist/assets/D8JNX8kq.js.br +0 -0
  113. package/dashboard/dist/assets/D8JNX8kq.js.gz +0 -0
  114. package/dashboard/dist/assets/DnA8dpj6.js +0 -1
  115. package/dashboard/dist/assets/DnA8dpj6.js.br +0 -0
  116. package/dashboard/dist/assets/DnA8dpj6.js.gz +0 -0
  117. package/dashboard/dist/assets/IUexzymk.js.br +0 -0
  118. package/dashboard/dist/assets/IUexzymk.js.gz +0 -0
  119. package/dashboard/dist/assets/ic2FaMnh.js +0 -1
  120. package/dashboard/dist/assets/ic2FaMnh.js.br +0 -0
  121. package/dashboard/dist/assets/ic2FaMnh.js.gz +0 -0
  122. package/dashboard/dist/assets/rttbDbEx.js.br +0 -0
  123. package/dashboard/dist/assets/rttbDbEx.js.gz +0 -0
@@ -1 +1 @@
1
- import{r as w,j as e}from"./cNrhgGc1.js";import{y as T,z as N,F as ye,P as we,w as S,G as qe,d as Z,H as ze,J as je,K as q,L as Pe,x as Fe,M as Oe}from"./C9jy61eu.js";import{u as Ve}from"./B6wPWJ35.js";import"./C-KIc3Wc.js";import"./BJgZIVUQ.js";import"./CxQ08qFN.js";const Ge=/^[0-9a-f-]{20,}$/i,Ke=new Set(["running","active","queued","pending","in_progress","working","planning","handoff","review"]),He=new Set(["agent execution failed","execution failed","run failed","failed"]);function y(n){return typeof n=="string"&&n.trim().length>0}function le(n){return(n??"").trim().toLowerCase()}function Je(n){return(n??"").trim().replace(/\s+/g," ").toLowerCase()}function Xe(n){return He.has(Je(n))}function z(n,t=3){return n.length<=t?n.join(", "):`${n.slice(0,t).join(", ")} +${n.length-t} more`}function P(n,t){const b=[],o=m=>{if(typeof m!="string")return;const j=m.trim();j&&(b.some(L=>L.toLowerCase()===j.toLowerCase())||b.push(j))};if(Array.isArray(n))for(const m of n)o(m);return o(t??null),b}function Qe(n){if(n.runId&&n.runId.trim().length>0)return n.runId.trim();const t=n.metadata;if(!t)return null;const b=["slice_run_id","sliceRunId","runId","run_id","correlation_id","correlationId","sessionId","session_id","agentRunId"];for(const o of b){const m=t[o];if(typeof m=="string"&&m.trim().length>0)return m.trim()}return null}function Ye(n){const t=le(n.status);if(t==="blocked"||t==="failed"||t==="completed"||t==="cancelled")return t;const b=le(n.phase);if(b==="blocked")return"blocked";if(b==="handoff")return"handoff";if(b==="completed")return"completed";if(b==="review")return"review";const o=le(n.state);return o==="error"?"failed":o==="stopped"?"paused":o==="stale"?"queued":Ke.has(t)?t:n.blockers.length>0?"blocked":t||"unknown"}function Ze(n,t,b){var m;const o=[((m=n.blockerDiagnostics)==null?void 0:m.reason)??null,n.blockerReason??null,...n.blockers,t==="blocked"||t==="failed"||t==="handoff"?b:null].map(j=>typeof j=="string"?j.trim():"").filter(j=>j.length>0);return o.length>0?o.find(L=>!Xe(L))??o[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 De(n){return n==="completed"?"border-lime/25 bg-lime/[0.08] text-lime":n==="needs_attention"?"border-amber-400/30 bg-amber-400/10 text-amber-200":n==="failed"?"border-red-400/30 bg-red-500/10 text-red-200":n==="in_progress"?"border-teal-400/30 bg-teal-400/10 text-teal-200":"border-strong bg-white/[0.04] text-secondary"}const dt=w.memo(function({session:t,activity:b,initiatives:o=[],sliceRuns:m=[],onOpenActivityItem:j,onContinueHighestPriority:L,onDispatchSession:F,onPauseSession:O,onResumeSession:V,onCancelSession:G,onCreateCheckpoint:K,onRollbackSession:H,onStartInitiative:et,onStartWorkstream:tt,initialInterventionDraft:k=null,onSubmitIntervention:ie}){var he,be,ge;const[x,de]=w.useState(null),[J,A]=w.useState(null),[M,oe]=w.useState(!1),[D,W]=w.useState(""),{enqueue:ce,ToastRenderer:ve}=Ve();w.useEffect(()=>{if(!t){W("");return}if(k!=null&&k.text){W(k.text);return}W("")},[k==null?void 0:k.text,t==null?void 0:t.id]);const B=w.useMemo(()=>{var d,g,f,i,u;if(!t)return new Set;const r=new Set;return(d=t.runId)!=null&&d.trim()&&r.add(t.runId.trim()),(g=t.id)!=null&&g.trim()&&r.add(t.id.trim()),(u=(i=(f=t.blockerDiagnostics)==null?void 0:f.context)==null?void 0:i.sliceRunId)!=null&&u.trim()&&r.add(t.blockerDiagnostics.context.sliceRunId.trim()),r},[t]),C=w.useMemo(()=>t?B.size===0?[]:b.filter(r=>{const d=Qe(r);return!!(d&&B.has(d))}).sort((r,d)=>Date.parse(d.timestamp)-Date.parse(r.timestamp)).slice(0,12):[],[b,t,B]),s=w.useMemo(()=>{var f,i;if(!t||!Array.isArray(m)||m.length===0)return null;const r=((f=t.initiativeId)==null?void 0:f.trim())??"",d=((i=t.workstreamId)==null?void 0:i.trim())??"",g=m.filter(u=>{var ne,fe;const I=((ne=u.sliceRunId)==null?void 0:ne.trim())??"",E=((fe=u.runId)==null?void 0:fe.trim())??"";if(I&&B.has(I)||E&&B.has(E))return!0;if(!d||!P(u.workstreamIds,u.workstreamId).includes(d))return!1;if(!r)return!0;const Y=P(u.initiativeIds,u.initiativeId);return!(Y.length>0&&!Y.includes(r))});return g.length===0?null:[...g].sort((u,I)=>{const E=Date.parse(u.updatedAt??u.lastEventAt??u.startedAt??""),ae=Date.parse(I.updatedAt??I.lastEventAt??I.startedAt??""),Y=Number.isFinite(E)?E:0;return(Number.isFinite(ae)?ae:0)-Y})[0]},[t,B,m]),ee=w.useMemo(()=>{var f;if(!t)return[];const r=[],d=t.initiativeId??t.groupId;if(d){const i=o.find(u=>u.id===d);i?r.push({label:"Initiative",value:i.name}):t.groupLabel&&t.groupLabel.trim().length>0?r.push({label:"Initiative",value:t.groupLabel}):T(d)&&r.push({label:"Initiative",value:N(d)})}if(t.workstreamId){let i=null;for(const u of o){const I=(f=u.workstreams)==null?void 0:f.find(E=>E.id===t.workstreamId);if(I){i=I.name;break}}!i&&T(t.workstreamId)?i=N(t.workstreamId):!i&&!Ge.test(t.workstreamId)&&(i=t.workstreamId),i&&r.push({label:"Workstream",value:i})}const g=t.phase??null;if(g){const i=String(g);r.push({label:"Milestone",value:T(i)?N(i):i})}return t.title&&r.push({label:"Task",value:t.title}),r},[o,t]),R=w.useMemo(()=>{var f,i;if(!t)return null;const r=((f=C[0])==null?void 0:f.summary)??((i=C[0])==null?void 0:i.description)??null,g=t.lastEventSummary??r??null;return g&&g.trim().length>0?g.trim():null},[C,t]),ue=w.useMemo(()=>{var r;return t?ye(t.agentName,t.title,t.lastEventSummary,R,(r=C[0])==null?void 0:r.metadata):ye()},[C,t,R]),_=async(r,d,g)=>{if(!(!g||x)){de(r),A(null);try{await g(),A(`${d} requested.`)}catch(f){A(f instanceof Error?f.message:`${d} failed.`)}finally{de(null)}}};if(!t)return e.jsxs(we,{className:"flex h-full min-h-0 flex-col overflow-hidden card-enter",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-subtle px-4 py-3.5",children:[e.jsx("h2",{className:"text-heading font-semibold text-white",children:"Session Detail"}),e.jsx("button",{onClick:()=>oe(r=>!r),className:"text-muted transition-colors hover:text-primary","aria-label":M?"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:S("transition-transform",M?"-rotate-90":"rotate-0"),children:e.jsx("path",{d:"m6 9 6 6 6-6"})})})]}),e.jsx("div",{className:S("transition-all",M?"max-h-0 overflow-hidden":"min-h-0 flex-1"),children:e.jsxs("div",{className:"h-full min-h-0 space-y-2 overflow-y-auto p-4 text-body text-secondary",children:[e.jsx("p",{children:"Select a session to inspect summary, breadcrumbs, blockers, and recent messages."}),e.jsx("button",{onClick:()=>_("continue-priority","Continue highest priority",L),disabled:!L||!!x,className:"rounded-md border border-strong bg-white/[0.04] px-3 py-1.5 text-caption text-primary transition-colors hover:bg-white/[0.08] disabled:opacity-45",children:x==="continue-priority"?"Dispatching…":"Continue highest priority"}),J&&e.jsx("p",{className:"text-caption text-secondary",children:J})]})})]});const U=t.progress===null?null:Math.round(t.progress),v=Ye(t),p=C[0]??null,te=(s==null?void 0:s.blockingDecisionCount)??0,Ne=Math.max(0,((s==null?void 0:s.decisionCount)??0)-te),c=qe({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??((he=t.blockerDiagnostics)==null?void 0:he.reason)??((s==null?void 0:s.status)==="failed"?"error":null),decisionRequired:((p==null?void 0:p.decisionRequired)??!1)||te>0,blockingDecisionCount:te,nonBlockingDecisionCount:Ne,blockerCount:t.blockers.length,blockerReason:t.blockerReason??((be=t.blockerDiagnostics)==null?void 0:be.reason)??null}),re=Ze(t,v,R),ke=v==="handoff"?"Handoff":v==="blocked"?"Blocker reason":v==="failed"?"Failure reason":"Status note",Ie=c.status==="in_progress"&&["running","active","queued","pending","working","in_progress","planning","review"].includes(v),Ae=c.status==="needs_attention"&&["paused","blocked","queued","pending"].includes(v),Ce=!["completed","archived","cancelled"].includes(v),Re=!["archived","cancelled"].includes(v),Te=c.label,Se=De(c.status),me=["running","active","working","in_progress","planning","review"].includes(v),_e=c.status!=="in_progress"&&!me,Ee=c.tone==="critical"?Z.red:c.tone==="warning"?Z.amber:c.tone==="positive"?Z.lime:Z.teal,Le=U!==null&&U>=100&&c.status!=="completed"?"Terminal state":"Progress",Me=c.tone==="critical"?"border-red-400/25 bg-red-500/10":c.tone==="warning"?"border-amber-400/25 bg-amber-500/10":c.tone==="positive"?"border-lime/22 bg-lime/[0.08]":"border-subtle bg-white/[0.02]",a=t.blockerDiagnostics??null,l=(a==null?void 0:a.context)??null,se=[y(a==null?void 0:a.source)?`Source: ${a.source.trim()}`:null,y(a==null?void 0:a.errorCode)?`Code: ${a.errorCode.trim()}`:null,y(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),h=[];l&&(Array.isArray(l.initiativeIds)&&l.initiativeIds.length>0?h.push({label:"Initiatives",value:z(l.initiativeIds.map(r=>T(r)?N(r):r),4)}):y(l.initiativeId)&&h.push({label:"Initiative",value:ze("Initiative",l.initiativeId.trim())}),y(l.workstreamTitle)?h.push({label:"Workstream",value:l.workstreamTitle.trim()}):Array.isArray(l.workstreamIds)&&l.workstreamIds.length>0?h.push({label:"Workstreams",value:z(l.workstreamIds,4)}):y(l.workstreamId)&&h.push({label:"Workstream",value:l.workstreamId.trim()}),y(l.sliceRunId)&&h.push({label:"Slice run",value:N(l.sliceRunId.trim())}),y(l.parallelMode)&&h.push({label:"Mode",value:l.parallelMode.trim().toUpperCase()}),Array.isArray(l.taskIds)&&l.taskIds.length>0&&h.push({label:"Tasks",value:z(l.taskIds.map(r=>T(r)?N(r):r))}),Array.isArray(l.milestoneIds)&&l.milestoneIds.length>0&&h.push({label:"Milestones",value:z(l.milestoneIds.map(r=>T(r)?N(r):r))}),Array.isArray(l.iwmtIds)&&l.iwmtIds.length>0?h.push({label:"Scope IDs",value:z(l.iwmtIds.map(r=>T(r)?N(r):r),4)}):y(l.iwmtId)&&h.push({label:"Scope ID",value:T(l.iwmtId.trim())?N(l.iwmtId.trim()):l.iwmtId.trim()}),y(l.logPath)&&h.push({label:"Log path",value:je(l.logPath.trim())}),y(l.outputPath)&&h.push({label:"Output path",value:je(l.outputPath.trim())}));const xe=(v==="blocked"||v==="failed")&&!!(a&&(y(a.reason)||se.length>0||h.length>0||Array.isArray(a.suggestedActions)&&a.suggestedActions.length>0)),X=y(re)?re:null,Be=X!==null&&!(R&&(X===R||R.includes(X)))&&!xe,Ue=w.useCallback(()=>{!G||!t||(A("Session will be cancelled…"),ce({message:`Cancelled "${t.title}"`,onCommit:async()=>{try{await G(t),A("Session cancelled.")}catch(r){A(r instanceof Error?r.message:"Cancel failed.")}},onUndo:()=>{A(null)}}))},[G,t,ce]),We=[{label:"Started",value:t.startedAt?q(t.startedAt):"—"},{label:"Updated",value:t.updatedAt?q(t.updatedAt):"—"},...t.eta?[{label:"ETA",value:t.eta}]:[],...t.checkpointCount?[{label:"Checkpoints",value:String(t.checkpointCount)}]:[]],pe=s?s.status.replace(/_/g," "):null,$=P(s==null?void 0:s.initiativeIds,(s==null?void 0:s.initiativeId)??null),Q=P(s==null?void 0:s.workstreamIds,(s==null?void 0:s.workstreamId)??null);P(s==null?void 0:s.iwmtIds,(s==null?void 0:s.iwmtId)??null);const $e=$[0]?((ge=o.find(r=>r.id===$[0]))==null?void 0:ge.name)??$[0]:null;return e.jsxs(we,{className:"flex h-full min-h-0 flex-col overflow-hidden card-enter",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-subtle px-4 py-3.5",children:[e.jsx("h2",{className:"text-heading font-semibold text-white",children:"Session Detail"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:S("chip text-caption uppercase tracking-[0.14em]",Se),children:Te}),e.jsx("button",{onClick:()=>oe(r=>!r),className:"text-muted transition-colors hover:text-primary","aria-label":M?"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:S("transition-transform",M?"-rotate-90":"rotate-0"),children:e.jsx("path",{d:"m6 9 6 6 6-6"})})})]})]}),e.jsx("div",{className:S("transition-all",M?"max-h-0 overflow-hidden":"min-h-0 flex-1"),children:e.jsxs("div",{className:"h-full min-h-0 space-y-4 overflow-y-auto p-4",children:[e.jsxs("div",{className:"rounded-xl border border-subtle bg-white/[0.02] p-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Pe,{provider:ue.id,size:"sm"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-body font-semibold text-white",children:Fe(t.title)}),e.jsxs("p",{className:"mt-1 text-caption text-secondary",children:[t.agentName??"OrgX"," · ",ue.label]})]})]}),ee.length>0&&e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"mb-1 text-micro uppercase tracking-[0.16em] text-muted",children:"Context"}),e.jsx("div",{className:"flex flex-wrap items-center gap-1.5 text-caption",children:ee.map((r,d)=>e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"rounded-full border border-strong bg-white/[0.02] px-2 py-0.5 text-secondary",children:r.value}),d<ee.length-1&&e.jsx("span",{className:"text-caption text-muted",children:"›"})]},`${r.label}-${r.value}`))})]}),R&&e.jsxs("div",{className:"mt-3 rounded-lg border border-subtle bg-white/[0.02] px-3 py-2",children:[e.jsx("p",{className:"mb-1 text-micro uppercase tracking-[0.16em] text-muted",children:"Summary"}),e.jsx(Oe,{text:R,mode:"block"})]}),e.jsxs("div",{className:S("mt-3 rounded-lg border px-3 py-2",Me),children:[e.jsx("p",{className:"mb-1 text-micro uppercase tracking-[0.16em] text-muted",children:c.label}),e.jsx("p",{className:"text-body text-secondary",children:c.sentence}),c.nextAction&&e.jsxs("p",{className:"mt-1 text-caption text-secondary",children:["Next: ",c.nextAction]})]}),Be&&e.jsxs("div",{className:"mt-3 rounded-lg border border-subtle bg-white/[0.02] px-3 py-2",children:[e.jsx("p",{className:"mb-1 text-micro uppercase tracking-[0.16em] text-muted",children:ke}),e.jsx("p",{className:"text-body text-secondary",children:X})]}),xe&&e.jsxs("div",{className:"mt-3 rounded-lg border border-red-500/25 bg-red-500/10 px-3 py-2.5",children:[e.jsx("p",{className:"mb-1 text-micro uppercase tracking-[0.16em] text-red-200/75",children:"Why blocked"}),e.jsx("p",{className:"text-body text-red-100/90",children:(a==null?void 0:a.reason)??re??"Runtime marked this run as blocked without details."}),se.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:se.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))}),h.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:h.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))})]}),y(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()," ·"," ",q(a.eventTimestamp)]})]})]}),s&&e.jsxs("div",{className:"rounded-xl border border-subtle bg-white/[0.02] p-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("h3",{className:"text-caption uppercase tracking-[0.12em] text-secondary",children:"Slice scope"}),pe?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:pe}):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:$e??"—"})]}),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??(Q[0]?N(Q[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?q(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]}),$.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:["+",$.length-1," initiatives"]}):null,Q.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:["+",Q.length-1," workstreams"]}):null]}),s.taskIds.length>0?e.jsxs("p",{className:"mt-2 text-micro text-secondary",children:["Tasks: ",s.taskIds.length]}):null]}),e.jsxs("div",{className:"rounded-xl border border-subtle bg-white/[0.02] p-3",children:[U!==null&&e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between text-caption text-secondary",children:[e.jsx("span",{children:Le}),e.jsxs("span",{className:"text-primary",children:[U,"%"]})]}),e.jsx("div",{className:"h-2 rounded-full bg-white/[0.08]",children:e.jsx("div",{className:S("h-2 rounded-full transition-all duration-500",me&&"live-pulse"),style:{width:`${U}%`,background:Ee}})})]}),e.jsx("dl",{className:S("grid grid-cols-2 gap-3 text-caption text-secondary",U!==null?"mt-3":""),children:We.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))})]}),e.jsxs("div",{className:"rounded-xl border border-subtle bg-white/[0.02] p-3",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{onClick:()=>_("dispatch-session","Session started",()=>F==null?void 0:F(t)),disabled:!F||!!x||!_e,className:"rounded-md border border-lime/25 bg-lime/10 px-3 py-2 text-caption font-semibold text-lime transition-colors hover:bg-lime/20 disabled:opacity-45",children:x==="dispatch-session"?"Starting…":c.status==="completed"?"Restart":"Start"}),Ie&&e.jsx("button",{onClick:()=>_("pause-session","Session paused",()=>O==null?void 0:O(t)),disabled:!O||!!x,className:"rounded-md border border-strong bg-white/[0.02] px-3 py-2 text-caption text-secondary transition-colors hover:bg-white/[0.06] hover:text-white disabled:opacity-45",children:x==="pause-session"?"Pausing…":"Pause"}),Ae&&e.jsx("button",{onClick:()=>_("resume-session","Session resumed",()=>V==null?void 0:V(t)),disabled:!V||!!x,className:"rounded-md border border-strong bg-white/[0.02] px-3 py-2 text-caption text-secondary transition-colors hover:bg-white/[0.06] hover:text-white disabled:opacity-45",children:x==="resume-session"?"Resuming…":"Resume"}),e.jsx("button",{onClick:()=>_("checkpoint-session","Progress saved",()=>K==null?void 0:K(t)),disabled:!K||!!x,className:"rounded-md border border-strong bg-white/[0.02] px-3 py-2 text-caption text-secondary transition-colors hover:bg-white/[0.06] hover:text-white disabled:opacity-45",children:x==="checkpoint-session"?"Saving…":"Save progress"}),Re&&e.jsx("button",{onClick:()=>_("rollback-session","Undo requested",()=>H==null?void 0:H(t)),disabled:!H||!!x,className:"rounded-md border border-strong bg-white/[0.02] px-3 py-2 text-caption text-secondary transition-colors hover:bg-white/[0.06] hover:text-white disabled:opacity-45",children:x==="rollback-session"?"Undoing…":"Undo last step"})]}),ie&&e.jsxs("div",{className:"mt-3 rounded-lg border border-white/[0.08] bg-black/[0.18] px-3 py-2.5",children:[e.jsx("p",{className:"mb-2 text-micro uppercase tracking-[0.16em] text-muted",children:"Intervene"}),e.jsx("textarea",{value:D,onChange:r=>W(r.target.value),placeholder:"Share guidance for this run...",className:"min-h-[84px] w-full resize-y 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:"mt-2 flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-micro text-secondary",children:"Visible to agents and collaborators."}),e.jsx("button",{type:"button",onClick:()=>{const r=D.trim();if(!r){A("Intervention note cannot be empty.");return}_("intervene-note","Intervention sent",async()=>{await ie({session:t,workstreamId:(k==null?void 0:k.workstreamId)??t.workstreamId??null,text:r}),W("")})},disabled:!!x||D.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:x==="intervene-note"?"Sending…":"Send intervention"})]})]}),Ce&&G&&e.jsx("div",{className:"mt-3 border-t border-subtle pt-3",children:e.jsx("button",{onClick:Ue,disabled:!!x,className:"text-caption text-secondary transition-colors hover:text-red-300 disabled:opacity-45",children:"Cancel session…"})})]}),J&&e.jsx("p",{className:"rounded-md border border-white/[0.08] bg-white/[0.02] px-2.5 py-1.5 text-caption text-secondary",children:J}),t.blockers.length>0&&e.jsxs("div",{className:"rounded-xl border border-red-500/30 bg-red-500/10 p-3",children:[e.jsx("h3",{className:"mb-1 text-caption uppercase tracking-[0.12em] 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.jsxs("div",{children:[e.jsx("h3",{className:"mb-2 text-caption uppercase tracking-[0.16em] text-secondary",children:"Recent Messages"}),C.length===0&&e.jsx("p",{className:"text-body text-secondary",children:"No recent messages for this run."}),e.jsx("div",{className:"space-y-2",children:C.map(r=>e.jsxs("article",{className:"rounded-lg border border-subtle bg-white/[0.02] px-2.5 py-2",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}),j&&e.jsx("button",{type:"button",onClick:()=>j(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 transition-colors 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()," · ",q(r.timestamp)]})]},r.id))})]})]})}),e.jsx(ve,{})]})});export{dt as SessionInspector};
1
+ import{r as w,j as e}from"./cNrhgGc1.js";import{B as T,C as N,J as ye,P as we,y as S,K as qe,d as Z,L as ze,N as je,o as q,O as Pe,z as Fe,M as Oe}from"./CPjsbbgZ.js";import{u as Ve}from"./CnitK1MX.js";import"./C-KIc3Wc.js";import"./BJgZIVUQ.js";import"./CxQ08qFN.js";const Ge=/^[0-9a-f-]{20,}$/i,Ke=new Set(["running","active","queued","pending","in_progress","working","planning","handoff","review"]),Je=new Set(["agent execution failed","execution failed","run failed","failed"]);function y(n){return typeof n=="string"&&n.trim().length>0}function le(n){return(n??"").trim().toLowerCase()}function Xe(n){return(n??"").trim().replace(/\s+/g," ").toLowerCase()}function He(n){return Je.has(Xe(n))}function z(n,t=3){return n.length<=t?n.join(", "):`${n.slice(0,t).join(", ")} +${n.length-t} more`}function P(n,t){const b=[],o=m=>{if(typeof m!="string")return;const j=m.trim();j&&(b.some(L=>L.toLowerCase()===j.toLowerCase())||b.push(j))};if(Array.isArray(n))for(const m of n)o(m);return o(t??null),b}function Qe(n){if(n.runId&&n.runId.trim().length>0)return n.runId.trim();const t=n.metadata;if(!t)return null;const b=["slice_run_id","sliceRunId","runId","run_id","correlation_id","correlationId","sessionId","session_id","agentRunId"];for(const o of b){const m=t[o];if(typeof m=="string"&&m.trim().length>0)return m.trim()}return null}function Ye(n){const t=le(n.status);if(t==="blocked"||t==="failed"||t==="completed"||t==="cancelled")return t;const b=le(n.phase);if(b==="blocked")return"blocked";if(b==="handoff")return"handoff";if(b==="completed")return"completed";if(b==="review")return"review";const o=le(n.state);return o==="error"?"failed":o==="stopped"?"paused":o==="stale"?"queued":Ke.has(t)?t:n.blockers.length>0?"blocked":t||"unknown"}function Ze(n,t,b){var m;const o=[((m=n.blockerDiagnostics)==null?void 0:m.reason)??null,n.blockerReason??null,...n.blockers,t==="blocked"||t==="failed"||t==="handoff"?b:null].map(j=>typeof j=="string"?j.trim():"").filter(j=>j.length>0);return o.length>0?o.find(L=>!He(L))??o[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 De(n){return n==="completed"?"border-lime/25 bg-lime/[0.08] text-lime":n==="needs_attention"?"border-amber-400/30 bg-amber-400/10 text-amber-200":n==="failed"?"border-red-400/30 bg-red-500/10 text-red-200":n==="in_progress"?"border-teal-400/30 bg-teal-400/10 text-teal-200":"border-strong bg-white/[0.04] text-secondary"}const dt=w.memo(function({session:t,activity:b,initiatives:o=[],sliceRuns:m=[],onOpenActivityItem:j,onContinueHighestPriority:L,onDispatchSession:F,onPauseSession:O,onResumeSession:V,onCancelSession:G,onCreateCheckpoint:K,onRollbackSession:J,onStartInitiative:et,onStartWorkstream:tt,initialInterventionDraft:k=null,onSubmitIntervention:ie}){var he,be,ge;const[x,de]=w.useState(null),[X,C]=w.useState(null),[B,oe]=w.useState(!1),[D,W]=w.useState(""),{enqueue:ce,ToastRenderer:ve}=Ve();w.useEffect(()=>{if(!t){W("");return}if(k!=null&&k.text){W(k.text);return}W("")},[k==null?void 0:k.text,t==null?void 0:t.id]);const M=w.useMemo(()=>{var d,g,f,i,u;if(!t)return new Set;const r=new Set;return(d=t.runId)!=null&&d.trim()&&r.add(t.runId.trim()),(g=t.id)!=null&&g.trim()&&r.add(t.id.trim()),(u=(i=(f=t.blockerDiagnostics)==null?void 0:f.context)==null?void 0:i.sliceRunId)!=null&&u.trim()&&r.add(t.blockerDiagnostics.context.sliceRunId.trim()),r},[t]),A=w.useMemo(()=>t?M.size===0?[]:b.filter(r=>{const d=Qe(r);return!!(d&&M.has(d))}).sort((r,d)=>Date.parse(d.timestamp)-Date.parse(r.timestamp)).slice(0,12):[],[b,t,M]),s=w.useMemo(()=>{var f,i;if(!t||!Array.isArray(m)||m.length===0)return null;const r=((f=t.initiativeId)==null?void 0:f.trim())??"",d=((i=t.workstreamId)==null?void 0:i.trim())??"",g=m.filter(u=>{var ne,fe;const I=((ne=u.sliceRunId)==null?void 0:ne.trim())??"",E=((fe=u.runId)==null?void 0:fe.trim())??"";if(I&&M.has(I)||E&&M.has(E))return!0;if(!d||!P(u.workstreamIds,u.workstreamId).includes(d))return!1;if(!r)return!0;const Y=P(u.initiativeIds,u.initiativeId);return!(Y.length>0&&!Y.includes(r))});return g.length===0?null:[...g].sort((u,I)=>{const E=Date.parse(u.updatedAt??u.lastEventAt??u.startedAt??""),ae=Date.parse(I.updatedAt??I.lastEventAt??I.startedAt??""),Y=Number.isFinite(E)?E:0;return(Number.isFinite(ae)?ae:0)-Y})[0]},[t,M,m]),ee=w.useMemo(()=>{var f;if(!t)return[];const r=[],d=t.initiativeId??t.groupId;if(d){const i=o.find(u=>u.id===d);i?r.push({label:"Initiative",value:i.name}):t.groupLabel&&t.groupLabel.trim().length>0?r.push({label:"Initiative",value:t.groupLabel}):T(d)&&r.push({label:"Initiative",value:N(d)})}if(t.workstreamId){let i=null;for(const u of o){const I=(f=u.workstreams)==null?void 0:f.find(E=>E.id===t.workstreamId);if(I){i=I.name;break}}!i&&T(t.workstreamId)?i=N(t.workstreamId):!i&&!Ge.test(t.workstreamId)&&(i=t.workstreamId),i&&r.push({label:"Workstream",value:i})}const g=t.phase??null;if(g){const i=String(g);r.push({label:"Milestone",value:T(i)?N(i):i})}return t.title&&r.push({label:"Task",value:t.title}),r},[o,t]),R=w.useMemo(()=>{var f,i;if(!t)return null;const r=((f=A[0])==null?void 0:f.summary)??((i=A[0])==null?void 0:i.description)??null,g=t.lastEventSummary??r??null;return g&&g.trim().length>0?g.trim():null},[A,t]),ue=w.useMemo(()=>{var r;return t?ye(t.agentName,t.title,t.lastEventSummary,R,(r=A[0])==null?void 0:r.metadata):ye()},[A,t,R]),_=async(r,d,g)=>{if(!(!g||x)){de(r),C(null);try{await g(),C(`${d} requested.`)}catch(f){C(f instanceof Error?f.message:`${d} failed.`)}finally{de(null)}}};if(!t)return e.jsxs(we,{className:"flex h-full min-h-0 flex-col overflow-hidden card-enter",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-subtle px-4 py-3.5",children:[e.jsx("h2",{className:"text-heading font-semibold text-white",children:"Session Detail"}),e.jsx("button",{onClick:()=>oe(r=>!r),className:"text-muted transition-colors hover:text-primary","aria-label":B?"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:S("transition-transform",B?"-rotate-90":"rotate-0"),children:e.jsx("path",{d:"m6 9 6 6 6-6"})})})]}),e.jsx("div",{className:S("transition-all",B?"max-h-0 overflow-hidden":"min-h-0 flex-1"),children:e.jsxs("div",{className:"h-full min-h-0 space-y-2 overflow-y-auto p-4 text-body text-secondary",children:[e.jsx("p",{children:"Select a session to inspect summary, breadcrumbs, blockers, and recent messages."}),e.jsx("button",{onClick:()=>_("continue-priority","Continue highest priority",L),disabled:!L||!!x,className:"rounded-md border border-strong bg-white/[0.04] px-3 py-1.5 text-caption text-primary transition-colors hover:bg-white/[0.08] disabled:opacity-45",children:x==="continue-priority"?"Dispatching…":"Continue highest priority"}),X&&e.jsx("p",{className:"text-caption text-secondary",children:X})]})})]});const U=t.progress===null?null:Math.round(t.progress),v=Ye(t),p=A[0]??null,te=(s==null?void 0:s.blockingDecisionCount)??0,Ne=Math.max(0,((s==null?void 0:s.decisionCount)??0)-te),c=qe({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??((he=t.blockerDiagnostics)==null?void 0:he.reason)??((s==null?void 0:s.status)==="failed"?"error":null),decisionRequired:((p==null?void 0:p.decisionRequired)??!1)||te>0,blockingDecisionCount:te,nonBlockingDecisionCount:Ne,blockerCount:t.blockers.length,blockerReason:t.blockerReason??((be=t.blockerDiagnostics)==null?void 0:be.reason)??null}),re=Ze(t,v,R),ke=v==="handoff"?"Handoff":v==="blocked"?"Blocker reason":v==="failed"?"Failure reason":"Status note",Ie=c.status==="in_progress"&&["running","active","queued","pending","working","in_progress","planning","review"].includes(v),Ce=c.status==="needs_attention"&&["paused","blocked","queued","pending"].includes(v),Ae=!["completed","archived","cancelled"].includes(v),Re=!["archived","cancelled"].includes(v),Te=c.label,Se=De(c.status),me=["running","active","working","in_progress","planning","review"].includes(v),_e=c.status!=="in_progress"&&!me,Ee=c.tone==="critical"?Z.red:c.tone==="warning"?Z.amber:c.tone==="positive"?Z.lime:Z.teal,Le=U!==null&&U>=100&&c.status!=="completed"?"Terminal state":"Progress",Be=c.tone==="critical"?"border-red-400/25 bg-red-500/10":c.tone==="warning"?"border-amber-400/25 bg-amber-500/10":c.tone==="positive"?"border-lime/22 bg-lime/[0.08]":"border-subtle bg-white/[0.02]",a=t.blockerDiagnostics??null,l=(a==null?void 0:a.context)??null,se=[y(a==null?void 0:a.source)?`Source: ${a.source.trim()}`:null,y(a==null?void 0:a.errorCode)?`Code: ${a.errorCode.trim()}`:null,y(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),h=[];l&&(Array.isArray(l.initiativeIds)&&l.initiativeIds.length>0?h.push({label:"Initiatives",value:z(l.initiativeIds.map(r=>T(r)?N(r):r),4)}):y(l.initiativeId)&&h.push({label:"Initiative",value:ze("Initiative",l.initiativeId.trim())}),y(l.workstreamTitle)?h.push({label:"Workstream",value:l.workstreamTitle.trim()}):Array.isArray(l.workstreamIds)&&l.workstreamIds.length>0?h.push({label:"Workstreams",value:z(l.workstreamIds,4)}):y(l.workstreamId)&&h.push({label:"Workstream",value:l.workstreamId.trim()}),y(l.sliceRunId)&&h.push({label:"Slice run",value:N(l.sliceRunId.trim())}),y(l.parallelMode)&&h.push({label:"Mode",value:l.parallelMode.trim().toUpperCase()}),Array.isArray(l.taskIds)&&l.taskIds.length>0&&h.push({label:"Tasks",value:z(l.taskIds.map(r=>T(r)?N(r):r))}),Array.isArray(l.milestoneIds)&&l.milestoneIds.length>0&&h.push({label:"Milestones",value:z(l.milestoneIds.map(r=>T(r)?N(r):r))}),Array.isArray(l.iwmtIds)&&l.iwmtIds.length>0?h.push({label:"Scope IDs",value:z(l.iwmtIds.map(r=>T(r)?N(r):r),4)}):y(l.iwmtId)&&h.push({label:"Scope ID",value:T(l.iwmtId.trim())?N(l.iwmtId.trim()):l.iwmtId.trim()}),y(l.logPath)&&h.push({label:"Log path",value:je(l.logPath.trim())}),y(l.outputPath)&&h.push({label:"Output path",value:je(l.outputPath.trim())}));const xe=(v==="blocked"||v==="failed")&&!!(a&&(y(a.reason)||se.length>0||h.length>0||Array.isArray(a.suggestedActions)&&a.suggestedActions.length>0)),H=y(re)?re:null,Me=H!==null&&!(R&&(H===R||R.includes(H)))&&!xe,Ue=w.useCallback(()=>{!G||!t||(C("Session will be cancelled…"),ce({message:`Cancelled "${t.title}"`,onCommit:async()=>{try{await G(t),C("Session cancelled.")}catch(r){C(r instanceof Error?r.message:"Cancel failed.")}},onUndo:()=>{C(null)}}))},[G,t,ce]),We=[{label:"Started",value:t.startedAt?q(t.startedAt):"—"},{label:"Updated",value:t.updatedAt?q(t.updatedAt):"—"},...t.eta?[{label:"ETA",value:t.eta}]:[],...t.checkpointCount?[{label:"Checkpoints",value:String(t.checkpointCount)}]:[]],pe=s?s.status.replace(/_/g," "):null,$=P(s==null?void 0:s.initiativeIds,(s==null?void 0:s.initiativeId)??null),Q=P(s==null?void 0:s.workstreamIds,(s==null?void 0:s.workstreamId)??null);P(s==null?void 0:s.iwmtIds,(s==null?void 0:s.iwmtId)??null);const $e=$[0]?((ge=o.find(r=>r.id===$[0]))==null?void 0:ge.name)??$[0]:null;return e.jsxs(we,{className:"flex h-full min-h-0 flex-col overflow-hidden card-enter",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-subtle px-4 py-3.5",children:[e.jsx("h2",{className:"text-heading font-semibold text-white",children:"Session Detail"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:S("chip text-caption uppercase tracking-[0.14em]",Se),children:Te}),e.jsx("button",{onClick:()=>oe(r=>!r),className:"text-muted transition-colors hover:text-primary","aria-label":B?"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:S("transition-transform",B?"-rotate-90":"rotate-0"),children:e.jsx("path",{d:"m6 9 6 6 6-6"})})})]})]}),e.jsx("div",{className:S("transition-all",B?"max-h-0 overflow-hidden":"min-h-0 flex-1"),children:e.jsxs("div",{className:"h-full min-h-0 space-y-4 overflow-y-auto p-4",children:[e.jsxs("div",{className:"rounded-xl border border-subtle bg-white/[0.02] p-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Pe,{provider:ue.id,size:"sm"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-body font-semibold text-white",children:Fe(t.title)}),e.jsxs("p",{className:"mt-1 text-caption text-secondary",children:[t.agentName??"OrgX"," · ",ue.label]})]})]}),ee.length>0&&e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"mb-1 text-micro uppercase tracking-[0.16em] text-muted",children:"Context"}),e.jsx("div",{className:"flex flex-wrap items-center gap-1.5 text-caption",children:ee.map((r,d)=>e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"rounded-full border border-strong bg-white/[0.02] px-2 py-0.5 text-secondary",children:r.value}),d<ee.length-1&&e.jsx("span",{className:"text-caption text-muted",children:"›"})]},`${r.label}-${r.value}`))})]}),R&&e.jsxs("div",{className:"mt-3 rounded-lg border border-subtle bg-white/[0.02] px-3 py-2",children:[e.jsx("p",{className:"mb-1 text-micro uppercase tracking-[0.16em] text-muted",children:"Summary"}),e.jsx(Oe,{text:R,mode:"block"})]}),e.jsxs("div",{className:S("mt-3 rounded-lg border px-3 py-2",Be),children:[e.jsx("p",{className:"mb-1 text-micro uppercase tracking-[0.16em] text-muted",children:c.label}),e.jsx("p",{className:"text-body text-secondary",children:c.sentence}),c.nextAction&&e.jsxs("p",{className:"mt-1 text-caption text-secondary",children:["Next: ",c.nextAction]})]}),Me&&e.jsxs("div",{className:"mt-3 rounded-lg border border-subtle bg-white/[0.02] px-3 py-2",children:[e.jsx("p",{className:"mb-1 text-micro uppercase tracking-[0.16em] text-muted",children:ke}),e.jsx("p",{className:"text-body text-secondary",children:H})]}),xe&&e.jsxs("div",{className:"mt-3 rounded-lg border border-red-500/25 bg-red-500/10 px-3 py-2.5",children:[e.jsx("p",{className:"mb-1 text-micro uppercase tracking-[0.16em] text-red-200/75",children:"Why blocked"}),e.jsx("p",{className:"text-body text-red-100/90",children:(a==null?void 0:a.reason)??re??"Runtime marked this run as blocked without details."}),se.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:se.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))}),h.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:h.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))})]}),y(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()," ·"," ",q(a.eventTimestamp)]})]})]}),s&&e.jsxs("div",{className:"rounded-xl border border-subtle bg-white/[0.02] p-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("h3",{className:"text-caption uppercase tracking-[0.12em] text-secondary",children:"Slice scope"}),pe?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:pe}):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:$e??"—"})]}),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??(Q[0]?N(Q[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?q(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]}),$.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:["+",$.length-1," initiatives"]}):null,Q.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:["+",Q.length-1," workstreams"]}):null]}),s.taskIds.length>0?e.jsxs("p",{className:"mt-2 text-micro text-secondary",children:["Tasks: ",s.taskIds.length]}):null]}),e.jsxs("div",{className:"rounded-xl border border-subtle bg-white/[0.02] p-3",children:[U!==null&&e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between text-caption text-secondary",children:[e.jsx("span",{children:Le}),e.jsxs("span",{className:"text-primary",children:[U,"%"]})]}),e.jsx("div",{className:"h-2 rounded-full bg-white/[0.08]",children:e.jsx("div",{className:S("h-2 rounded-full transition-all duration-500",me&&"live-pulse"),style:{width:`${U}%`,background:Ee}})})]}),e.jsx("dl",{className:S("grid grid-cols-2 gap-3 text-caption text-secondary",U!==null?"mt-3":""),children:We.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))})]}),e.jsxs("div",{className:"rounded-xl border border-subtle bg-white/[0.02] p-3",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{onClick:()=>_("dispatch-session","Session started",()=>F==null?void 0:F(t)),disabled:!F||!!x||!_e,className:"rounded-md border border-lime/25 bg-lime/10 px-3 py-2 text-caption font-semibold text-lime transition-colors hover:bg-lime/20 disabled:opacity-45",children:x==="dispatch-session"?"Starting…":c.status==="completed"?"Restart":"Start"}),Ie&&e.jsx("button",{onClick:()=>_("pause-session","Session paused",()=>O==null?void 0:O(t)),disabled:!O||!!x,className:"rounded-md border border-strong bg-white/[0.02] px-3 py-2 text-caption text-secondary transition-colors hover:bg-white/[0.06] hover:text-white disabled:opacity-45",children:x==="pause-session"?"Pausing…":"Pause"}),Ce&&e.jsx("button",{onClick:()=>_("resume-session","Session resumed",()=>V==null?void 0:V(t)),disabled:!V||!!x,className:"rounded-md border border-strong bg-white/[0.02] px-3 py-2 text-caption text-secondary transition-colors hover:bg-white/[0.06] hover:text-white disabled:opacity-45",children:x==="resume-session"?"Resuming…":"Resume"}),e.jsx("button",{onClick:()=>_("checkpoint-session","Progress saved",()=>K==null?void 0:K(t)),disabled:!K||!!x,className:"rounded-md border border-strong bg-white/[0.02] px-3 py-2 text-caption text-secondary transition-colors hover:bg-white/[0.06] hover:text-white disabled:opacity-45",children:x==="checkpoint-session"?"Saving…":"Save progress"}),Re&&e.jsx("button",{onClick:()=>_("rollback-session","Undo requested",()=>J==null?void 0:J(t)),disabled:!J||!!x,className:"rounded-md border border-strong bg-white/[0.02] px-3 py-2 text-caption text-secondary transition-colors hover:bg-white/[0.06] hover:text-white disabled:opacity-45",children:x==="rollback-session"?"Undoing…":"Undo last step"})]}),ie&&e.jsxs("div",{className:"mt-3 rounded-lg border border-white/[0.08] bg-black/[0.18] px-3 py-2.5",children:[e.jsx("p",{className:"mb-2 text-micro uppercase tracking-[0.16em] text-muted",children:"Intervene"}),e.jsx("textarea",{value:D,onChange:r=>W(r.target.value),placeholder:"Share guidance for this run...",className:"min-h-[84px] w-full resize-y 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:"mt-2 flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-micro text-secondary",children:"Visible to agents and collaborators."}),e.jsx("button",{type:"button",onClick:()=>{const r=D.trim();if(!r){C("Intervention note cannot be empty.");return}_("intervene-note","Intervention sent",async()=>{await ie({session:t,workstreamId:(k==null?void 0:k.workstreamId)??t.workstreamId??null,text:r}),W("")})},disabled:!!x||D.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:x==="intervene-note"?"Sending…":"Send intervention"})]})]}),Ae&&G&&e.jsx("div",{className:"mt-3 border-t border-subtle pt-3",children:e.jsx("button",{onClick:Ue,disabled:!!x,className:"text-caption text-secondary transition-colors hover:text-red-300 disabled:opacity-45",children:"Cancel session…"})})]}),X&&e.jsx("p",{className:"rounded-md border border-white/[0.08] bg-white/[0.02] px-2.5 py-1.5 text-caption text-secondary",children:X}),t.blockers.length>0&&e.jsxs("div",{className:"rounded-xl border border-red-500/30 bg-red-500/10 p-3",children:[e.jsx("h3",{className:"mb-1 text-caption uppercase tracking-[0.12em] 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.jsxs("div",{children:[e.jsx("h3",{className:"mb-2 text-caption uppercase tracking-[0.16em] text-secondary",children:"Recent Messages"}),A.length===0&&e.jsx("p",{className:"text-body text-secondary",children:"No recent messages for this run."}),e.jsx("div",{className:"space-y-2",children:A.map(r=>e.jsxs("article",{className:"rounded-lg border border-subtle bg-white/[0.02] px-2.5 py-2",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}),j&&e.jsx("button",{type:"button",onClick:()=>j(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 transition-colors 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()," · ",q(r.timestamp)]})]},r.id))})]})]})}),e.jsx(ve,{})]})});export{dt as SessionInspector};
@@ -0,0 +1 @@
1
+ import{r as o,j as t}from"./cNrhgGc1.js";import{i as L,b as C,R,a5 as M}from"./CPjsbbgZ.js";function A(c){const i=Date.parse(c);if(!Number.isFinite(i))return null;const s=Date.now()-i,r=s<0,a=Math.abs(s),l=Math.round(a/6e4);if(l<1)return r?"soon":"just now";if(l<60)return r?`in ${l}m`:`${l}m ago`;const u=Math.round(a/36e5);if(u<48)return r?`in ${u}h`:`${u}h ago`;const p=Math.round(a/864e5);return p<30?r?`in ${p}d`:`${p}d ago`:new Date(i).toLocaleDateString()}async function T(c,i){const s=await fetch(c,i);if(!s.ok){const r=await s.json().catch(()=>null),a=typeof(r==null?void 0:r.error)=="string"&&r.error||typeof(r==null?void 0:r.message)=="string"&&r.message||`Request failed (${s.status})`;throw new Error(a)}return await s.json()}function J(c){const{entityType:i,entityId:s,authToken:r,embedMode:a,className:l,variant:u="default"}=c,[p,b]=o.useState(!0),[j,v]=o.useState(!1),[N,x]=o.useState(null),[E,S]=o.useState([]),[h,g]=o.useState(""),m=L(),y=o.useMemo(()=>{const e=encodeURIComponent(i),n=encodeURIComponent(s);return`/orgx/api/entities/${e}/${n}/comments`},[i,s]),f=o.useCallback(async()=>{if(m){S([]),x(null),b(!1);return}b(!0),x(null);try{const e=await T(y,{method:"GET",headers:C({authToken:r,embedMode:a})});S(Array.isArray(e.comments)?e.comments:[])}catch(e){x(e instanceof Error?e.message:String(e))}finally{b(!1)}},[r,m,a,y]);o.useEffect(()=>{f()},[f]);const w=o.useCallback(async()=>{if(m){g("");return}const e=h.trim();if(e){v(!0),x(null);try{await T(y,{method:"POST",headers:C({authToken:r,embedMode:a,contentTypeJson:!0}),body:JSON.stringify({body:e,commentType:"note",severity:"info",tags:[]})}),g(""),await f()}catch(n){x(n instanceof Error?n.message:String(n))}finally{v(!1)}}},[r,h,m,a,y,f]),_=o.useCallback(e=>{e.key==="Enter"&&(!e.metaKey&&!e.ctrlKey||(e.preventDefault(),w()))},[w]),d=u==="inline";return t.jsxs("div",{className:l,children:[t.jsxs("div",{className:d?"space-y-1":"space-y-2",children:[t.jsx("textarea",{value:h,onChange:e=>g(e.target.value),onKeyDown:_,placeholder:"Leave a note for humans or agents...",className:d?"min-h-[60px] w-full resize-y border-b border-white/[0.06] bg-transparent px-0 py-2 text-body text-bright outline-none placeholder:text-faint focus:border-white/15 transition-colors":"min-h-[96px] w-full resize-y rounded-xl border border-white/[0.10] bg-white/[0.03] px-4 py-3 text-body text-bright outline-none placeholder:text-faint focus:border-white/20 focus:bg-white/[0.05] transition-colors"}),t.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 ${d?"opacity-70":""}`,children:[t.jsx("p",{className:"text-caption text-muted",children:"Cmd/Ctrl+Enter to post. Visible to agents and collaborators."}),t.jsx("button",{type:"button",onClick:w,disabled:j||h.trim().length===0,className:d?"text-caption font-semibold text-primary hover:text-white transition-colors disabled:opacity-50":"inline-flex items-center justify-center rounded-full border border-strong bg-white/[0.05] px-3.5 py-1.5 text-caption font-semibold tracking-wide text-primary transition-colors hover:bg-white/[0.09] disabled:opacity-50 disabled:hover:bg-white/[0.05]",children:j?"Saving…":"Post note"})]})]}),N?t.jsx("div",{className:`mt-2 text-caption text-red-200 ${d?"":"rounded-xl border border-red-500/20 bg-red-500/10 px-3.5 py-2"}`,children:N}):null,p?t.jsx("div",{className:"mt-2 text-body text-muted",children:"Loading notes…"}):E.length===0?t.jsx(R,{icon:"inbox",headline:"No notes yet",description:m?"Notes are unavailable in demo mode.":"Add a note to keep context for your team and agents.",className:"py-6"}):t.jsx("div",{className:`mt-2 space-y-2 ${d?"divide-y divide-white/[0.06]":"space-y-3"}`,children:E.map(e=>{const n=e.created_at?A(e.created_at):null,k=e.author_name??(e.author_type==="agent"?e.author_id:"Unknown");if(d)return t.jsxs("div",{className:"pt-2 first:pt-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-micro text-muted",children:[t.jsx("span",{className:"font-medium text-secondary",children:k}),n?t.jsx("span",{title:M(e.created_at),children:n}):null]}),t.jsx("p",{className:"mt-0.5 whitespace-pre-wrap text-body leading-relaxed text-primary",children:e.body})]},e.id);const D=e.comment_type??"note",$=typeof e.severity=="string"?e.severity:"info";return t.jsxs("div",{className:"rounded-2xl border border-white/[0.10] bg-white/[0.02] px-4 py-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-body font-semibold text-bright",children:k}),t.jsx("span",{className:"rounded-full border border-strong bg-white/[0.06] px-2 py-0.5 text-micro uppercase tracking-[0.08em] text-secondary",children:e.author_type}),t.jsx("span",{className:"rounded-full border border-strong px-2 py-0.5 text-micro uppercase tracking-[0.08em] text-secondary",children:D}),$!=="info"?t.jsx("span",{className:"rounded-full border border-strong px-2 py-0.5 text-micro uppercase tracking-[0.08em] text-secondary",children:$}):null]}),n?t.jsx("span",{className:"text-caption text-muted",title:M(e.created_at),children:n}):null]}),t.jsx("p",{className:"mt-2 whitespace-pre-wrap text-body leading-relaxed text-primary",children:e.body})]},e.id)})})]})}export{J as E};
@@ -1 +1 @@
1
- import{r as a,j as e}from"./cNrhgGc1.js";import{d as i}from"./C9jy61eu.js";import{A as m,m as x}from"./CxQ08qFN.js";function f({message:l,durationMs:s=5e3,onUndo:d,onExpire:r}){const[t,c]=a.useState(!0),o=a.useRef();a.useEffect(()=>(o.current=setTimeout(()=>{c(!1),r()},s),()=>clearTimeout(o.current)),[s,r]);const n=()=>{clearTimeout(o.current),c(!1),d()};return e.jsx(m,{children:t&&e.jsx(x.div,{initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.95},transition:{duration:.22,ease:[.22,1,.36,1]},className:"fixed bottom-6 left-1/2 z-50 -translate-x-1/2",children:e.jsxs("div",{className:"flex items-center gap-3 rounded-xl px-4 py-2.5 shadow-lg",style:{backgroundColor:i.cardBgElevated,border:`1px solid ${i.cardBorderStrong}`},children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:i.lime,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6 9 17l-5-5"})}),e.jsx("span",{className:"text-body text-primary",children:l}),e.jsx("button",{onClick:n,className:"ml-1 rounded-md px-2.5 py-1 text-caption font-semibold transition-colors hover:bg-white/[0.08]",style:{color:i.lime},children:"Undo"}),e.jsx("div",{className:"absolute bottom-0 left-3 right-3 h-0.5 overflow-hidden rounded-full",children:e.jsx("div",{className:"h-full origin-left rounded-full",style:{backgroundColor:i.lime,opacity:.4,animation:`undoCountdown ${s}ms linear forwards`}})})]})})})}function y(){const[l,s]=a.useState([]),d=o=>{const n=`undo-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;return s(u=>[...u,{...o,id:n}]),n},r=o=>{s(n=>n.filter(u=>u.id!==o))},t=l[0]??null;return{enqueue:d,ToastRenderer:()=>t?e.jsx(f,{message:t.message,onUndo:()=>{t.onUndo(),r(t.id)},onExpire:()=>{t.onCommit(),r(t.id)}},t.id):null}}export{y as u};
1
+ import{r as a,j as e}from"./cNrhgGc1.js";import{d as i}from"./CPjsbbgZ.js";import{A as m,m as x}from"./CxQ08qFN.js";function f({message:l,durationMs:s=5e3,onUndo:d,onExpire:r}){const[t,c]=a.useState(!0),o=a.useRef();a.useEffect(()=>(o.current=setTimeout(()=>{c(!1),r()},s),()=>clearTimeout(o.current)),[s,r]);const n=()=>{clearTimeout(o.current),c(!1),d()};return e.jsx(m,{children:t&&e.jsx(x.div,{initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.95},transition:{duration:.22,ease:[.22,1,.36,1]},className:"fixed bottom-6 left-1/2 z-50 -translate-x-1/2",children:e.jsxs("div",{className:"flex items-center gap-3 rounded-xl px-4 py-2.5 shadow-lg",style:{backgroundColor:i.cardBgElevated,border:`1px solid ${i.cardBorderStrong}`},children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:i.lime,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6 9 17l-5-5"})}),e.jsx("span",{className:"text-body text-primary",children:l}),e.jsx("button",{onClick:n,className:"ml-1 rounded-md px-2.5 py-1 text-caption font-semibold transition-colors hover:bg-white/[0.08]",style:{color:i.lime},children:"Undo"}),e.jsx("div",{className:"absolute bottom-0 left-3 right-3 h-0.5 overflow-hidden rounded-full",children:e.jsx("div",{className:"h-full origin-left rounded-full",style:{backgroundColor:i.lime,opacity:.4,animation:`undoCountdown ${s}ms linear forwards`}})})]})})})}function y(){const[l,s]=a.useState([]),d=o=>{const n=`undo-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;return s(u=>[...u,{...o,id:n}]),n},r=o=>{s(n=>n.filter(u=>u.id!==o))},t=l[0]??null;return{enqueue:d,ToastRenderer:()=>t?e.jsx(f,{message:t.message,onUndo:()=>{t.onUndo(),r(t.id)},onExpire:()=>{t.onCommit(),r(t.id)}},t.id):null}}export{y as u};
@@ -1 +1 @@
1
- import{r as l,j as e}from"./cNrhgGc1.js";import{d as r,r as u,E as j,K as f}from"./C9jy61eu.js";import"./C-KIc3Wc.js";import"./BJgZIVUQ.js";import"./CxQ08qFN.js";function c(a){if(!a)return"unknown";try{return f(a)}catch{return"unknown"}}function k({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,y)=>y[1]-s[1]),[t.pendingByQueue]),n=l.useMemo(()=>t.replayStatus==="error"?r.red:t.pendingTotal>0?r.amber:r.textMuted,[t.pendingTotal,t.replayStatus]),b=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:`${n}30`,backgroundColor:`${n}14`,color:n},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:n},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:b,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(([i,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:i}),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})]},i))}),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{k as BulkOutboxModal};
1
+ import{r as l,j as e}from"./cNrhgGc1.js";import{d as r,w as u,E as j,o as f}from"./CPjsbbgZ.js";import"./C-KIc3Wc.js";import"./BJgZIVUQ.js";import"./CxQ08qFN.js";function c(a){if(!a)return"unknown";try{return f(a)}catch{return"unknown"}}function k({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,y)=>y[1]-s[1]),[t.pendingByQueue]),n=l.useMemo(()=>t.replayStatus==="error"?r.red:t.pendingTotal>0?r.amber:r.textMuted,[t.pendingTotal,t.replayStatus]),b=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:`${n}30`,backgroundColor:`${n}14`,color:n},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:n},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:b,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(([i,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:i}),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})]},i))}),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{k as BulkOutboxModal};