@useorgx/openclaw-plugin 0.7.23 → 0.7.25

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 (125) hide show
  1. package/dashboard/dist/assets/{m2smti3F.js → B6VftyY6.js} +1 -1
  2. package/dashboard/dist/assets/B6VftyY6.js.br +0 -0
  3. package/dashboard/dist/assets/B6VftyY6.js.gz +0 -0
  4. package/dashboard/dist/assets/{D-FuHfT8.js → BANQdlC4.js} +1 -1
  5. package/dashboard/dist/assets/BANQdlC4.js.br +0 -0
  6. package/dashboard/dist/assets/BANQdlC4.js.gz +0 -0
  7. package/dashboard/dist/assets/{DDCPrZRt.js → BPL4CL3c.js} +1 -1
  8. package/dashboard/dist/assets/BPL4CL3c.js.br +0 -0
  9. package/dashboard/dist/assets/BPL4CL3c.js.gz +0 -0
  10. package/dashboard/dist/assets/{D0PN5_vY.js → BZCkOZ20.js} +1 -1
  11. package/dashboard/dist/assets/BZCkOZ20.js.br +0 -0
  12. package/dashboard/dist/assets/BZCkOZ20.js.gz +0 -0
  13. package/dashboard/dist/assets/{DNQ-iFO2.js → B_LdOJUa.js} +1 -1
  14. package/dashboard/dist/assets/B_LdOJUa.js.br +0 -0
  15. package/dashboard/dist/assets/B_LdOJUa.js.gz +0 -0
  16. package/dashboard/dist/assets/Bfp-wdwb.css +1 -0
  17. package/dashboard/dist/assets/Bfp-wdwb.css.br +0 -0
  18. package/dashboard/dist/assets/{C1u2SGin.css.gz → Bfp-wdwb.css.gz} +0 -0
  19. package/dashboard/dist/assets/{CZXS5i_5.js → BvFcH_Iy.js} +1 -1
  20. package/dashboard/dist/assets/BvFcH_Iy.js.br +0 -0
  21. package/dashboard/dist/assets/BvFcH_Iy.js.gz +0 -0
  22. package/dashboard/dist/assets/C0i7ABUU.js +212 -0
  23. package/dashboard/dist/assets/C0i7ABUU.js.br +0 -0
  24. package/dashboard/dist/assets/C0i7ABUU.js.gz +0 -0
  25. package/dashboard/dist/assets/CFB0MM7j.js +1 -0
  26. package/dashboard/dist/assets/CFB0MM7j.js.br +0 -0
  27. package/dashboard/dist/assets/CFB0MM7j.js.gz +0 -0
  28. package/dashboard/dist/assets/{OlLPtzdz.js → CQSRb1yu.js} +1 -1
  29. package/dashboard/dist/assets/CQSRb1yu.js.br +0 -0
  30. package/dashboard/dist/assets/CQSRb1yu.js.gz +0 -0
  31. package/dashboard/dist/assets/{CbVWL74-.js → CUoQoSm-.js} +1 -1
  32. package/dashboard/dist/assets/CUoQoSm-.js.br +0 -0
  33. package/dashboard/dist/assets/CUoQoSm-.js.gz +0 -0
  34. package/dashboard/dist/assets/Ckd1R1iE.js +1 -0
  35. package/dashboard/dist/assets/Ckd1R1iE.js.br +0 -0
  36. package/dashboard/dist/assets/Ckd1R1iE.js.gz +0 -0
  37. package/dashboard/dist/assets/{DhPuHPK7.js → CqRNb2EL.js} +1 -1
  38. package/dashboard/dist/assets/CqRNb2EL.js.br +0 -0
  39. package/dashboard/dist/assets/CqRNb2EL.js.gz +0 -0
  40. package/dashboard/dist/assets/{CGJiHCIx.js → DClUc9rw.js} +1 -1
  41. package/dashboard/dist/assets/DClUc9rw.js.br +0 -0
  42. package/dashboard/dist/assets/DClUc9rw.js.gz +0 -0
  43. package/dashboard/dist/assets/DF2PMTwT.js +1 -0
  44. package/dashboard/dist/assets/DF2PMTwT.js.br +0 -0
  45. package/dashboard/dist/assets/DF2PMTwT.js.gz +0 -0
  46. package/dashboard/dist/assets/{RN4M9u9W.js → DJYl7gyA.js} +1 -1
  47. package/dashboard/dist/assets/DJYl7gyA.js.br +0 -0
  48. package/dashboard/dist/assets/DJYl7gyA.js.gz +0 -0
  49. package/dashboard/dist/assets/{BrMXbzQ-.js → DZtNMX0t.js} +1 -1
  50. package/dashboard/dist/assets/DZtNMX0t.js.br +0 -0
  51. package/dashboard/dist/assets/DZtNMX0t.js.gz +0 -0
  52. package/dashboard/dist/assets/{LOFrVoPD.js → DlEa8PI0.js} +1 -1
  53. package/dashboard/dist/assets/DlEa8PI0.js.br +0 -0
  54. package/dashboard/dist/assets/DlEa8PI0.js.gz +0 -0
  55. package/dashboard/dist/assets/M4QxcXjh.js +1 -0
  56. package/dashboard/dist/assets/M4QxcXjh.js.br +0 -0
  57. package/dashboard/dist/assets/M4QxcXjh.js.gz +0 -0
  58. package/dashboard/dist/assets/{nra1yvJX.js → MrW1ixGx.js} +1 -1
  59. package/dashboard/dist/assets/MrW1ixGx.js.br +0 -0
  60. package/dashboard/dist/assets/MrW1ixGx.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/activity-store.js +68 -8
  65. package/dist/contracts/shared-types.d.ts +28 -0
  66. package/dist/http/helpers/auto-continue-engine.js +235 -32
  67. package/dist/http/helpers/triage-mapper.js +285 -6
  68. package/dist/http/helpers/value-utils.d.ts +1 -0
  69. package/dist/http/helpers/value-utils.js +17 -0
  70. package/dist/http/index.js +89 -3
  71. package/dist/http/routes/live-triage.js +6 -1
  72. package/dist/http/routes/mission-control-actions.d.ts +9 -0
  73. package/dist/http/routes/mission-control-actions.js +157 -7
  74. package/dist/http/routes/mission-control-read.d.ts +9 -0
  75. package/dist/http/routes/mission-control-read.js +33 -0
  76. package/dist/openclaw.plugin.json +1 -1
  77. package/dist/stores/sqlite-state.d.ts +1 -1
  78. package/dist/stores/sqlite-state.js +153 -2
  79. package/openclaw.plugin.json +1 -1
  80. package/package.json +1 -1
  81. package/dashboard/dist/assets/9gFmK3Kr.js +0 -1
  82. package/dashboard/dist/assets/9gFmK3Kr.js.br +0 -0
  83. package/dashboard/dist/assets/9gFmK3Kr.js.gz +0 -0
  84. package/dashboard/dist/assets/BrMXbzQ-.js.br +0 -0
  85. package/dashboard/dist/assets/BrMXbzQ-.js.gz +0 -0
  86. package/dashboard/dist/assets/C1u2SGin.css +0 -1
  87. package/dashboard/dist/assets/C1u2SGin.css.br +0 -0
  88. package/dashboard/dist/assets/CGJiHCIx.js.br +0 -0
  89. package/dashboard/dist/assets/CGJiHCIx.js.gz +0 -0
  90. package/dashboard/dist/assets/CSd4rSuU.js +0 -212
  91. package/dashboard/dist/assets/CSd4rSuU.js.br +0 -0
  92. package/dashboard/dist/assets/CSd4rSuU.js.gz +0 -0
  93. package/dashboard/dist/assets/CZXS5i_5.js.br +0 -0
  94. package/dashboard/dist/assets/CZXS5i_5.js.gz +0 -0
  95. package/dashboard/dist/assets/CbVWL74-.js.br +0 -0
  96. package/dashboard/dist/assets/CbVWL74-.js.gz +0 -0
  97. package/dashboard/dist/assets/D-FuHfT8.js.br +0 -0
  98. package/dashboard/dist/assets/D-FuHfT8.js.gz +0 -0
  99. package/dashboard/dist/assets/D0PN5_vY.js.br +0 -0
  100. package/dashboard/dist/assets/D0PN5_vY.js.gz +0 -0
  101. package/dashboard/dist/assets/DDCPrZRt.js.br +0 -0
  102. package/dashboard/dist/assets/DDCPrZRt.js.gz +0 -0
  103. package/dashboard/dist/assets/DNQ-iFO2.js.br +0 -0
  104. package/dashboard/dist/assets/DNQ-iFO2.js.gz +0 -0
  105. package/dashboard/dist/assets/DhPuHPK7.js.br +0 -0
  106. package/dashboard/dist/assets/DhPuHPK7.js.gz +0 -0
  107. package/dashboard/dist/assets/Dhz7qPtn.js +0 -1
  108. package/dashboard/dist/assets/Dhz7qPtn.js.br +0 -0
  109. package/dashboard/dist/assets/Dhz7qPtn.js.gz +0 -0
  110. package/dashboard/dist/assets/LOFrVoPD.js.br +0 -0
  111. package/dashboard/dist/assets/LOFrVoPD.js.gz +0 -0
  112. package/dashboard/dist/assets/OlLPtzdz.js.br +0 -0
  113. package/dashboard/dist/assets/OlLPtzdz.js.gz +0 -0
  114. package/dashboard/dist/assets/RN4M9u9W.js.br +0 -0
  115. package/dashboard/dist/assets/RN4M9u9W.js.gz +0 -0
  116. package/dashboard/dist/assets/VCHu272d.js +0 -1
  117. package/dashboard/dist/assets/VCHu272d.js.br +0 -0
  118. package/dashboard/dist/assets/VCHu272d.js.gz +0 -0
  119. package/dashboard/dist/assets/m2smti3F.js.br +0 -0
  120. package/dashboard/dist/assets/m2smti3F.js.gz +0 -0
  121. package/dashboard/dist/assets/nra1yvJX.js.br +0 -0
  122. package/dashboard/dist/assets/nra1yvJX.js.gz +0 -0
  123. package/dashboard/dist/assets/qLX6NZ-J.js +0 -1
  124. package/dashboard/dist/assets/qLX6NZ-J.js.br +0 -0
  125. package/dashboard/dist/assets/qLX6NZ-J.js.gz +0 -0
@@ -0,0 +1 @@
1
+ import{r as d,j as e}from"./Dj2k1r16.js";import{E as ne,f as P,z as Pe,a4 as H,w as Re,a5 as We,a6 as Oe,M as ze,h as Ue,P as Ge,C as de}from"./C0i7ABUU.js";import{E as Ke}from"./CqRNb2EL.js";import{A as De,m as J,u as Xe}from"./eeHXe_OQ.js";import{u as Je}from"./DClUc9rw.js";import"./DMKyYAtD.js";import"./cX2e-TLi.js";import"./BjK42gtU.js";import"./BV0BcV1u.js";const Ve={pr:"⎋",file:"◇",artifact:"▪",log:"▸",decision:"◈"};function Ze(i){return i>=.8?"#BFFF00":i>=.5?"#F5B700":"#FF6B88"}function Qe(i){const t=i.match(/https?:\/\/\S+/);return t?t[0]:null}function Ye({evidenceType:i,title:t,summary:u,sourceUrl:m,confidence:y,payload:k,icon:j,label:v,onOpenTerminal:C}){const[c,O]=d.useState(!1),B=t??v??null,_=i??(j?j.toUpperCase():null),T=j?Ve[j]:null,A=j==="pr"&&v?Qe(v):null;return e.jsxs("div",{className:"rounded-xl border border-white/[0.06] bg-white/[0.02] px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-start gap-2.5 cursor-pointer",onClick:()=>O(N=>!N),children:[(_||T)&&e.jsxs("span",{className:"mt-0.5 flex-shrink-0 rounded bg-white/[0.06] px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wider text-secondary",children:[T?e.jsx("span",{className:"mr-1",children:T}):null,_]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[B&&e.jsx("p",{className:"text-body font-medium text-primary",children:m?e.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"text-[#D8FFA1] hover:underline",onClick:N=>N.stopPropagation(),children:B}):A?e.jsx("a",{href:A,target:"_blank",rel:"noopener noreferrer",className:"text-[#D8FFA1] hover:underline",onClick:N=>N.stopPropagation(),children:B}):B}),u&&e.jsx("p",{className:`mt-0.5 text-caption text-secondary ${c?"":"line-clamp-2"}`,children:u})]}),e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:`mt-1 flex-shrink-0 text-muted transition-transform ${c?"rotate-180":""}`,children:e.jsx("path",{d:"m6 9 6 6 6-6"})})]}),y!=null&&e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("div",{className:"h-1 flex-1 overflow-hidden rounded-full bg-white/[0.06]",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Math.round(y*100)}%`,backgroundColor:Ze(y)}})}),e.jsxs("span",{className:"text-micro text-muted tabular-nums",children:[Math.round(y*100),"%"]})]}),e.jsx(De,{children:c&&e.jsx(J.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:"overflow-hidden",children:e.jsxs("div",{className:"mt-2 space-y-2",children:[j==="log"&&C&&e.jsxs("button",{type:"button",onClick:N=>{N.stopPropagation(),C()},className:"inline-flex items-center gap-1.5 rounded-lg border border-white/[0.12] bg-white/[0.04] px-3 py-1.5 text-caption font-semibold text-primary transition-colors hover:bg-white/[0.08]",children:[e.jsx("span",{className:"font-mono text-micro",children:">_"}),"Open in terminal"]}),k&&Object.keys(k).length>0&&e.jsx("pre",{className:"max-h-40 overflow-auto rounded-lg bg-black/40 p-2.5 text-micro text-secondary font-mono",children:JSON.stringify(k,null,2)})]})})})]})}function He({segments:i}){return i.length===0?null:e.jsx("nav",{className:"flex items-center gap-1.5 min-w-0 text-caption text-secondary",children:i.map((t,u)=>e.jsxs("span",{className:"flex items-center gap-1.5 min-w-0",children:[u>0&&e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"flex-shrink-0 text-faint",children:e.jsx("path",{d:"m9 18 6-6-6-6"})}),t.icon&&e.jsx(ne,{type:t.icon,size:11,className:"flex-shrink-0 opacity-80"}),t.onClick?e.jsx("button",{type:"button",onClick:t.onClick,className:"truncate transition-colors hover:text-primary",children:t.label}):e.jsx("span",{className:"truncate",children:t.label})]},u))})}const je={label:"Retry this workstream",description:"Re-run with the same configuration. Recommended if this was a transient issue.",impliedStatus:"approved"},X={label:"Skip and continue",description:"Mark as accepted and move to the next workstream.",impliedStatus:"approved"},et=[{test:/Worker exited without structured output.*?code=(\S+?),\s*signal=(\S+?)\)/i,headline:"Agent work stopped unexpectedly",explain:(i,t)=>{const u=t[1]==="null"?"none":t[1],m=t[2]==="null"?"none":t[2];return`The agent process exited before producing results. Exit code: ${u}. Signal: ${m}. This usually means the worker was terminated externally or ran out of resources.`},severity:"critical",options:[je,{label:"Retry with more resources",description:"Increase token budget before re-running.",impliedStatus:"approved"},X],extractDetails:(i,t)=>({exitCode:t[1]==="null"?void 0:t[1],signal:t[2]==="null"?void 0:t[2]})},{test:/MCP handshake failed(?:\s+for\s+(\S+))?/i,headline:"Agent couldn't connect to tools",explain:(i,t)=>`The agent failed to connect to its tool server${t[1]?` (${t[1]})`:""}. This typically means the MCP server is unreachable or took too long to respond.`,severity:"critical",options:[je,{label:"Check MCP server",description:"Investigate the tool server connection before retrying.",impliedStatus:"approved"},X],extractDetails:(i,t)=>({server:t[1]||void 0})},{test:/(?:Slice|Autopilot slice) timed out after (\d+)/i,headline:"Agent ran out of time",explain:(i,t)=>{const u=Math.round(parseInt(t[1],10)/6e4);return`The agent exceeded its ${u>0?`${u}-minute`:`${t[1]}ms`} time limit. Consider breaking the work into smaller steps or increasing the time budget.`},severity:"warning",options:[{label:"Retry with more time",description:"Increase the timeout before re-running.",impliedStatus:"approved"},{label:"Break into smaller tasks",description:"Split the workstream into smaller pieces that fit the time budget.",impliedStatus:"approved"},X],extractDetails:(i,t)=>({elapsedMs:t[1]})},{test:/(?:Slice|Autopilot slice) stalled/i,headline:"Agent stopped making progress",explain:()=>"The agent stopped producing output. It may be stuck in a loop, waiting on an unresponsive resource, or unable to proceed with the current approach.",severity:"warning",options:[je,{label:"Review logs",description:"Check the session logs to understand why the agent stalled.",impliedStatus:"approved"},X]},{test:/blocked.*?(?:needs|requires?) intervention/i,headline:"Agent needs your help to continue",explain:()=>"The agent reached a point where it cannot proceed without human guidance. This may be a question about requirements, a permission needed, or an ambiguity.",severity:"warning",options:[{label:"Review blocker",description:"Look at what the agent needs and provide guidance.",impliedStatus:"approved"},{label:"Provide guidance",description:"Add a note with instructions for the agent.",impliedStatus:"approved"},X]},{test:/completed.*?(?:without|no) (?:verifiable )?(?:outcomes?|artifacts?)/i,headline:"Agent finished but produced no outputs",explain:()=>"The agent reported completion but produced no artifacts or status updates. The work may have been done informally, or the agent could not find actionable work.",severity:"info",options:[{label:"Accept as-is",description:"The work was done informally or no output was needed.",impliedStatus:"approved"},{label:"Retry with stronger output requirements",description:"Re-run and require the agent to produce structured artifacts.",impliedStatus:"approved"},X]},{test:/Spawn guard denied/i,headline:"Agent dispatch was blocked by safety check",explain:()=>"The system's safety checks prevented this agent from starting. This is typically due to capacity limits or quality gate requirements.",severity:"warning",options:[{label:"Approve exception",description:"Override the safety check and allow dispatch.",impliedStatus:"approved"},{label:"Investigate quality gate",description:"Review what safety check failed before proceeding.",impliedStatus:"approved"},X]},{test:/code=(\d+)/i,headline:"Agent encountered an error",explain:(i,t)=>`The agent process exited with error code ${t[1]}. Reviewing the session logs will show what operation failed.`,severity:"critical",options:[je,{label:"Review error logs",description:"Check session logs to understand the error before retrying.",impliedStatus:"approved"},X],extractDetails:(i,t)=>({exitCode:t[1]})}];function tt(i){var u;const t=i.context||i.title||"";for(const m of et){const y=t.match(m.test);if(y)return{headline:m.headline,explanation:m.explain(t,y),structuredDetails:((u=m.extractDetails)==null?void 0:u.call(m,t,y))??{},suggestedOptions:m.options,severity:m.severity}}return i.decisionType==="autopilot_failure"?{headline:"Agent work needs attention",explanation:t||"An issue occurred during autopilot execution that requires review.",structuredDetails:{},suggestedOptions:[je,X],severity:"warning"}:{headline:i.title||"Decision needed",explanation:t||"Review the details and choose an action.",structuredDetails:{},suggestedOptions:[],severity:"info"}}function st(i){return i.map((t,u)=>({id:`suggested-${u}`,label:t.label,description:t.description,impliedStatus:t.impliedStatus,actionType:null,requiresNote:!1}))}function rt(i,t){var v;if(!t||!i.workstreamId||!t.nodes.find(C=>C.id===i.workstreamId&&C.entityType==="workstream"))return null;const m=new Set(t.edges.filter(C=>C.source===i.workstreamId).map(C=>C.target)),y=[];for(const C of m){const c=t.nodes.find(O=>O.id===C);c&&y.push({id:c.id,title:c.title,taskCount:((v=c.children)==null?void 0:v.length)??0,status:c.status})}if(y.length===0)return null;const k=y.reduce((C,c)=>C+c.taskCount,0),j=y.some(C=>t.edges.some(c=>c.source===C.id));return{blockedWorkstreams:y,totalBlockedTasks:k,criticalPath:j}}function nt(i){const t=i.blockedWorkstreams.length,u=i.blockedWorkstreams.map(m=>m.title);return t===1?`Resolving this unblocks 1 downstream workstream: ${u[0]}.`:t<=3?`Resolving this unblocks ${t} downstream workstreams: ${u.join(", ")}.`:`Resolving this unblocks ${t} downstream workstreams including ${u[0]} and ${u[1]}.`}const Fe=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.userAgent);function it(i){try{return JSON.stringify(i,null,2)}catch{return null}}function ue(i){return!i||typeof i!="object"||Array.isArray(i)?null:i}function at(i){if(!i)return[];const t=ue(i.result),u=[i,t].filter(j=>!!j),m=[],y=new Set,k=(j,v)=>{if(Array.isArray(v))for(const C of v){const c=ue(C);if(!c)continue;const O=typeof c.task_id=="string"&&c.task_id.trim()||typeof c.taskId=="string"&&c.taskId.trim()||typeof c.milestone_id=="string"&&c.milestone_id.trim()||typeof c.milestoneId=="string"&&c.milestoneId.trim()||null,B=typeof c.task_title=="string"&&c.task_title.trim()||typeof c.taskTitle=="string"&&c.taskTitle.trim()||typeof c.milestone_title=="string"&&c.milestone_title.trim()||typeof c.milestoneTitle=="string"&&c.milestoneTitle.trim()||typeof c.title=="string"&&c.title.trim()||O||j,_=typeof c.status=="string"&&c.status.trim()||typeof c.state=="string"&&c.state.trim()||null,T=typeof c.reason=="string"&&c.reason.trim()||typeof c.summary=="string"&&c.summary.trim()||typeof c.note=="string"&&c.note.trim()||null,A=`${j}|${B.toLowerCase()}|${(_??"").toLowerCase()}|${(T??"").toLowerCase()}`;y.has(A)||(y.add(A),m.push({scope:j,label:B,status:_,note:T}))}};for(const j of u)k("Task",j.task_updates??j.taskUpdates),k("Milestone",j.milestone_updates??j.milestoneUpdates);return m.slice(0,8)}function lt(i){const t=new Set;return i.context.trim().length===0&&t.add("Decision context"),i.options.length===0&&t.add("Decision options"),i.recommendedAction||t.add("Recommended action"),i.evidenceCount===0&&t.add("Supporting evidence"),i.updateCount===0&&t.add("Expected downstream updates"),Array.from(t)}function ot({missing:i}){return i.length===0?null:e.jsxs("div",{className:"mb-4 rounded-xl border border-amber-300/20 bg-amber-300/[0.08] px-4 py-3",children:[e.jsx("p",{className:"text-micro font-semibold uppercase tracking-wider text-amber-100",children:"Signal incomplete"}),e.jsx("p",{className:"mt-1 text-caption text-amber-50/90",children:"This decision is missing some of the context an operator needs to intervene confidently."}),e.jsx("ul",{className:"mt-2 space-y-0.5",children:i.map(t=>e.jsxs("li",{className:"text-caption text-amber-100/85",children:["- ",t]},t))}),e.jsx("p",{className:"mt-2 text-micro text-amber-100/60",children:"Raw diagnostics remain available under Technical details."})]})}function Le(i){if(typeof i!="string")return null;const t=i.trim().toLowerCase();return t==="rejected"?"declined":t==="approved"||t==="declined"||t==="cancelled"?t:null}function Ae(i,t){return!i||i.trim().length===0?t:Ue(i.trim())||t}function ct(i){switch(i){case"spawn_guard_blocked":return"Spawn Guard";case"autopilot_failure":return"Autopilot Failure";case"budget_exceeded":return"Budget Exceeded";case"scope_change":return"Scope Change";case"conflict_resolution":return"Conflict Resolution";case"approval_required":return"Approval Required";case"review_required":return"Review Required";case"permission_request":return"Permission Request";default:return i.replace(/[_-]/g," ").replace(/\b\w/g,t=>t.toUpperCase())}}function dt(i){const t=i.toLowerCase();return t==="critical"||t==="p0"?P.red:t==="high"||t==="p1"?P.amber:t==="medium"||t==="p2"?P.iris:"rgba(255,255,255,0.5)"}function ut({open:i,decision:t,onClose:u,onApprove:m,onReject:y,initiativeTitle:k,workstreamTitle:j,onNavigate:v,currentIndex:C,totalCount:c,onFocusRunId:O,graph:B}){const[_,T]=d.useState("idle"),[A,N]=d.useState(null),[z,G]=d.useState(null),[E,V]=d.useState(""),[ve,ee]=d.useState(!1),[pe,ke]=d.useState(!1),Z=d.useRef(null),ie=d.useRef(),me=d.useRef(u);me.current=u,d.useEffect(()=>{if(i){T("idle"),N(null);const s=(t==null?void 0:t.selectedOptionId)??(t!=null&&t.options&&t.options.length===1?t.options[0].id:null);G(s),V(""),ee(!1),ke(!1)}return()=>{ie.current&&clearTimeout(ie.current)}},[i,t==null?void 0:t.id]);const R=t==null?void 0:t.metadata,K=d.useMemo(()=>{if(!R)return[];const s=R,l=s.decision_options??s.options??s.actions??null;if(!Array.isArray(l))return[];const b=[],W=new Set;for(let F=0;F<l.length;F+=1){const L=l[F];if(typeof L=="string"){const a=L.trim();if(!a)continue;const o=`option-${F+1}`;if(W.has(o))continue;W.add(o),b.push({id:o,label:a,description:null,consequences:null,impliedStatus:null,actionType:null,requiresNote:!1});continue}if(!L||typeof L!="object")continue;const x=L,n=typeof x.id=="string"&&x.id.trim()||typeof x.option_id=="string"&&x.option_id.trim()||typeof x.action_id=="string"&&x.action_id.trim()||`option-${F+1}`;if(W.has(n))continue;const r=typeof x.label=="string"&&x.label.trim()||typeof x.title=="string"&&x.title.trim()||typeof x.name=="string"&&x.name.trim()||typeof x.action=="string"&&x.action.trim()||null;r&&(W.add(n),b.push({id:n,label:r,description:typeof x.description=="string"?x.description:null,consequences:typeof x.consequences=="string"&&x.consequences||typeof x.impact=="string"&&x.impact||null,impliedStatus:Le(x.implied_status)??Le(x.status),actionType:typeof x.action_type=="string"&&x.action_type||typeof x.type=="string"&&x.type||null,requiresNote:x.requires_note===!0||x.requiresNote===!0||x.note_required===!0}))}return b.slice(0,12)},[R]),w=d.useMemo(()=>t?tt(t):null,[t==null?void 0:t.context,t==null?void 0:t.title,t==null?void 0:t.decisionType]),te=d.useMemo(()=>t?rt(t,B??null):null,[t==null?void 0:t.workstreamId,t==null?void 0:t.initiativeId,B]),ae=((t==null?void 0:t.waitingMinutes)??0)>1440,I=d.useMemo(()=>t!=null&&t.options&&t.options.length>0?t.options:K.length>0?K:w&&w.suggestedOptions.length>0?st(w.suggestedOptions):[],[t==null?void 0:t.options,K,w]),f=d.useMemo(()=>I.find(s=>s.id===z)??null,[I,z]),xe=(f==null?void 0:f.requiresNote)===!0,g=d.useMemo(()=>{const s=((t==null?void 0:t.context)??"").trim();if(s)return s;if(!R)return"";const l=R,b=(typeof l.summary=="string"?l.summary:null)??(typeof l.description=="string"?l.description:null)??"";return String(b??"").trim()},[t==null?void 0:t.context,R]),S=d.useMemo(()=>{var n,r,a;const s=R&&typeof R=="object"?R:void 0,l=at(s),b=ue(s==null?void 0:s.outcomes),W=typeof(s==null?void 0:s.status_updates_applied)=="number"&&Number.isFinite(s.status_updates_applied)?s.status_updates_applied:typeof((n=ue(s==null?void 0:s.result))==null?void 0:n.status_updates_applied)=="number"&&Number.isFinite((r=ue(s==null?void 0:s.result))==null?void 0:r.status_updates_applied)?(a=ue(s==null?void 0:s.result))==null?void 0:a.status_updates_applied:null,F=Array.isArray(s==null?void 0:s.artifacts)?s.artifacts.length:typeof(b==null?void 0:b.artifacts)=="number"?b.artifacts:null,L=(s==null?void 0:s.status_updates_buffered)??(s==null?void 0:s.statusUpdatesBuffered),x=L===!0||typeof L=="number"&&L>0||typeof L=="string"&&["true","1","yes"].includes(L.trim().toLowerCase());return{rows:l,statusUpdatesApplied:W,artifactCount:typeof F=="number"?F:null,buffered:x,hasPr:typeof(b==null?void 0:b.pr_url)=="string"||typeof(b==null?void 0:b.commit_sha)=="string"}},[R]),q=d.useMemo(()=>{const s=(t==null?void 0:t.waitingMinutes)??0;return s>=15?P.red:s>=5?P.amber:P.teal},[t==null?void 0:t.waitingMinutes]),le=d.useCallback(async()=>{if(!t)return;const s=it({decision:t,metadata:R});if(s)try{await navigator.clipboard.writeText(s),ee(!0),setTimeout(()=>ee(!1),2e3)}catch{}},[t,R]),se=d.useCallback(()=>{const s=E.trim(),l=f==null?void 0:f.id;if(!(!s&&!l))return{note:s.length>0?s:void 0,optionId:l??void 0}},[E,f]),oe=d.useCallback(async()=>{if(!t||!m)return;if(I.length>0&&!f){N("Select an option before approving this decision.");return}if(f!=null&&f.requiresNote&&E.trim().length===0){N("A note is required for the selected option."),requestAnimationFrame(()=>{var l;return(l=Z.current)==null?void 0:l.focus()});return}let s=!1;if(T(l=>l==="approving"||l==="rejecting"?l:(s=!0,"approving")),!!s){N(null);try{const l=await m(t.id,se());l.failed>0?(T("error"),N(Ae(l.firstError,"Approval failed. Please try again."))):(T("success"),ie.current=setTimeout(()=>me.current(),800))}catch(l){T("error");const b=l instanceof Error?l.message:"";N(Ae(b,"Approval failed."))}}},[se,t,E,m,I.length,f]),Q=d.useCallback(async()=>{if(!t||!y)return;if(I.length>0&&!f){N("Select an option before rejecting this decision.");return}if(f!=null&&f.requiresNote&&E.trim().length===0){N("A note is required for the selected option."),requestAnimationFrame(()=>{var l;return(l=Z.current)==null?void 0:l.focus()});return}let s=!1;if(T(l=>l==="approving"||l==="rejecting"?l:(s=!0,"rejecting")),!!s){N(null);try{const l=await y(t.id,se());l.failed>0?(T("error"),N(Ae(l.firstError,"Rejection failed. Please try again."))):(T("rejected"),ie.current=setTimeout(()=>me.current(),800))}catch(l){T("error");const b=l instanceof Error?l.message:"";N(Ae(b,"Rejection failed."))}}},[se,t,E,y,I.length,f]);if(d.useEffect(()=>{if(!i)return;const s=l=>{var W,F;if((l.metaKey||l.ctrlKey)&&l.key==="Enter"){l.preventDefault(),oe();return}const b=(W=l.target)==null?void 0:W.tagName;if(!(b==="INPUT"||b==="TEXTAREA"))switch(l.key){case"j":l.preventDefault(),v==null||v(1);break;case"k":l.preventDefault(),v==null||v(-1);break;case"a":l.preventDefault(),oe();break;case"r":l.preventDefault(),Q();break;case"n":l.preventDefault(),(F=Z.current)==null||F.focus();break}};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[i,oe,Q,v]),!i||!t)return null;const he=_==="approving"||_==="rejecting",$e=_==="success"||_==="rejected",re=(t.status??"pending").toLowerCase(),fe=!re.includes("approved")&&!re.includes("resolved")&&!re.includes("rejected")&&!re.includes("declined")&&!re.includes("cancelled"),_e=I.length>0&&!f,ge=(f==null?void 0:f.requiresNote)===!0&&E.trim().length===0,M=he||_e||ge,be=t.evidenceRefs??[],Te=be.length>0,ce=t.recommendedAction??null,Ne=t.decisionType??null,ye=t.priority??null,D=t.occurrenceCount??null,we=t.sourceRunId??null,Ce=lt({context:g,recommendedAction:ce,options:I,evidenceCount:be.length,updateCount:S.rows.length+(S.statusUpdatesApplied??0)}),U=[];k&&U.push({label:k,icon:"initiative"}),j&&U.push({label:j,icon:"workstream"});const Se=[["ID",t.id],["Type",t.decisionType],["Dedupe key",t.dedupeKey],["Source system",t.sourceSystem],["Conflict source",t.conflictSource],["Agent ID",t.agentId],["Source run",t.sourceRunId],["Source session",t.sourceSessionId],["Source stream",t.sourceStreamId]].filter(([,s])=>s!=null);if($e){const s=_==="success",l=s?P.lime:P.red;return e.jsx(Pe,{open:i,onClose:u,maxWidth:"max-w-xl",fitContent:!0,children:e.jsxs("div",{className:"flex flex-col items-center justify-center px-8 py-12",children:[e.jsx("div",{className:"mb-4 flex h-16 w-16 items-center justify-center rounded-full",style:{backgroundColor:`${l}18`,border:`1.5px solid ${l}40`},children:s?e.jsx("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:l,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}):e.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:l,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 6L6 18"}),e.jsx("path",{d:"M6 6l12 12"})]})}),e.jsx("p",{className:"text-heading font-semibold text-white",children:s?"Approved":"Rejected"}),e.jsx("p",{className:"mt-1 text-body text-secondary",children:t.title})]})})}return e.jsx(Pe,{open:i,onClose:u,maxWidth:"max-w-xl",children:e.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col",style:ae?{boxShadow:`inset 0 0 0 1px ${P.amber}30`,borderRadius:"inherit"}:void 0,children:[e.jsx("div",{className:"h-[2px] w-full flex-shrink-0",style:{background:`linear-gradient(90deg, ${q}60, ${q}20, transparent)`}}),v&&e.jsxs("div",{className:"flex items-center justify-between px-6 pt-3 pb-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>v(-1),className:"rounded p-1 text-muted hover:text-secondary hover:bg-white/[0.06] transition-colors",title:"Previous (k)",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"m15 18-6-6 6-6"})})}),e.jsx("button",{type:"button",onClick:()=>v(1),className:"rounded p-1 text-muted hover:text-secondary hover:bg-white/[0.06] transition-colors",title:"Next (j)",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"m9 18 6-6-6-6"})})}),C!=null&&c!=null&&e.jsxs("span",{className:"text-micro text-muted tabular-nums",children:[C+1," of ",c,e.jsx("span",{className:"ml-1 hidden sm:inline",children:"· Longest waiting first"})]})]}),e.jsx("button",{type:"button",onClick:u,"aria-label":"Close",className:"rounded p-1 text-muted hover:text-secondary hover:bg-white/[0.06] transition-colors",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M18 6 6 18M6 6l12 12"})})})]}),U.length>0&&e.jsx("div",{className:"px-6 pt-2",children:e.jsx(He,{segments:U})}),e.jsxs("div",{className:"flex items-start justify-between gap-3 px-6 pt-4 pb-4",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg",style:{backgroundColor:`${q}14`,border:`1px solid ${q}30`},children:e.jsx(ne,{type:"decision",size:14})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-title font-medium leading-tight text-white mb-2",children:t.title||"Decision Required"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-body text-secondary",children:[e.jsx("span",{children:t.agentName||"OrgX Autopilot"}),e.jsx("span",{className:"text-white/[0.15]",children:"|"}),e.jsx("span",{className:ae?"font-semibold text-red-300":"",children:H(t.waitingMinutes).text}),Ne&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-white/[0.15]",children:"|"}),e.jsx("span",{className:"text-primary",children:ct(Ne)})]}),ye&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-white/[0.15]",children:"|"}),e.jsx("span",{className:"font-medium",style:{color:dt(ye)},children:ye})]})]}),D!=null&&D>1&&e.jsxs("p",{className:"mt-2 text-caption text-muted",children:["Seen ",D," times",t.firstSeenAt&&e.jsxs(e.Fragment,{children:[" · first ",Re(t.firstSeenAt)]}),t.lastSeenAt&&e.jsxs(e.Fragment,{children:[" · last ",Re(t.lastSeenAt)]})]})]})]})}),!v&&e.jsx("button",{type:"button",onClick:u,"aria-label":"Close",className:"mt-0.5 flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg text-muted transition-colors hover:bg-white/[0.06] 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:"min-h-0 flex-1 overflow-y-auto px-6 pb-4",children:[(t.initiativeId||t.workstreamId)&&e.jsx("div",{className:"mb-4",children:e.jsx(We,{nodes:Oe({initiativeId:t.initiativeId,initiativeTitle:k,workstreamId:t.workstreamId,workstreamTitle:j,agentName:t.agentName,agentId:t.agentId}),activeId:t.workstreamId,compact:!0})}),e.jsx(ot,{missing:Ce}),ce&&e.jsxs("div",{className:"mb-4 rounded-xl border border-cyan-300/[0.28] bg-cyan-500/[0.12] px-4 py-3",children:[e.jsx("p",{className:"text-micro font-semibold uppercase tracking-wider text-cyan-200 mb-1",children:"Recommended"}),e.jsx("p",{className:"text-body text-cyan-100",children:ce})]}),Te&&e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"mb-2 px-1 text-micro font-semibold uppercase tracking-wider text-muted",children:"Evidence"}),e.jsx("div",{className:"space-y-1.5",children:be.map((s,l)=>e.jsx(Ye,{evidenceType:s.evidenceType,title:s.title,summary:s.summary,sourceUrl:s.sourceUrl,confidence:s.confidence,payload:s.payload},l))})]}),ae&&e.jsx("div",{className:"mb-4 rounded-xl border border-amber-400/[0.3] bg-amber-500/[0.08] px-4 py-3",children:e.jsxs("p",{className:"text-body text-amber-200",children:["This decision has been waiting"," ",e.jsx("span",{className:"font-semibold text-amber-100",children:H(t.waitingMinutes).text}),". Downstream work is paused."]})}),w&&w.headline!==t.title?e.jsxs("div",{className:"rounded-xl border border-white/[0.06] bg-white/[0.02] px-4 py-3",children:[e.jsx("p",{className:"text-micro font-semibold uppercase tracking-wider text-muted mb-2",children:"What happened"}),e.jsx("p",{className:"text-body text-primary leading-relaxed",children:w.explanation}),Object.keys(w.structuredDetails).length>0&&e.jsx("div",{className:"mt-3 flex flex-wrap gap-x-4 gap-y-1 text-caption text-secondary",children:Object.entries(w.structuredDetails).filter(([,s])=>s!=null).map(([s,l])=>e.jsxs("span",{children:[s.replace(/([A-Z])/g," $1").replace(/^./,b=>b.toUpperCase()),": ",l]},s))})]}):g?e.jsx("div",{className:"rounded-xl border border-white/[0.06] bg-white/[0.02] px-4 py-3",children:e.jsx(ze,{text:g,mode:"block"})}):e.jsx("p",{className:"px-1 text-body text-muted italic",children:"No additional context provided."}),(S.rows.length>0||(S.statusUpdatesApplied??0)>0||S.buffered||(S.artifactCount??0)>0||S.hasPr)&&e.jsxs("div",{className:"mt-4 rounded-xl border border-[#14B8A6]/20 bg-[#14B8A6]/[0.06] px-4 py-3",children:[e.jsx("p",{className:"text-micro font-semibold uppercase tracking-wider text-[#7ce0d3] mb-1",children:S.buffered?"Updates being applied":"Expected updates"}),(S.statusUpdatesApplied??0)>0&&e.jsxs("p",{className:"text-caption text-primary",children:[S.statusUpdatesApplied," status update",S.statusUpdatesApplied===1?"":"s",S.buffered?" queued for sync":" planned","."]}),(S.artifactCount??0)>0&&e.jsxs("p",{className:"text-caption text-primary",children:[S.artifactCount," artifact",S.artifactCount===1?"":"s"," expected from this decision path."]}),S.rows.length>0&&e.jsx("ul",{className:"mt-2 space-y-1 pl-4",children:S.rows.map((s,l)=>e.jsxs("li",{className:"text-caption text-secondary",children:[e.jsxs("span",{className:"text-primary",children:[s.scope,": ",s.label]}),s.status?` → ${s.status}`:"",s.note?` · ${s.note}`:""]},`${s.scope}-${s.label}-${l}`))})]}),I.length>0&&e.jsxs("div",{className:"mt-8",children:[e.jsx("p",{className:"mb-3 px-1 text-[11px] font-semibold uppercase tracking-[0.08em] text-muted",children:"Options"}),e.jsx("div",{className:"space-y-1 relative",children:I.map(s=>{const l=z===s.id;return e.jsxs("button",{type:"button",onClick:()=>{G(l?null:s.id),s.requiresNote&&requestAnimationFrame(()=>{var b;return(b=Z.current)==null?void 0:b.focus()})},disabled:he,className:"group relative flex w-full items-start gap-4 px-4 py-4 text-left focus:outline-none",children:[l&&e.jsx(J.div,{layoutId:"decision-option-bg",className:"absolute inset-0 rounded-xl",style:{backgroundColor:`${P.lime}12`},transition:{type:"spring",stiffness:400,damping:25}}),!l&&e.jsx("div",{className:"absolute inset-0 rounded-xl opacity-0 transition-opacity group-hover:bg-white/[0.03]"}),e.jsx("div",{className:"relative mt-0.5 flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-full border-[1.5px] transition-colors",style:{borderColor:l?P.lime:"rgba(255,255,255,0.2)"},children:e.jsx(De,{children:l&&e.jsx(J.div,{initial:{scale:0},animate:{scale:1},exit:{scale:0},transition:{type:"spring",stiffness:500,damping:30},className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:P.lime}})})}),e.jsxs("div",{className:"relative min-w-0 flex-1",children:[e.jsx("span",{className:`block text-[15px] ${l?"font-medium text-white":"text-primary"}`,children:s.label}),s.description&&e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-secondary",children:s.description}),s.consequences&&e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-muted",children:s.consequences}),s.requiresNote&&e.jsx("p",{className:"mt-1.5 text-[11px] font-medium uppercase tracking-wider text-amber-400",children:"Note required"})]})]},s.id)})})]}),fe&&xe&&e.jsxs("div",{className:"mt-4",children:[e.jsx("textarea",{ref:Z,value:E,onChange:s=>V(s.target.value),disabled:he,placeholder:"Required: add context for this decision...",rows:3,className:"w-full resize-none rounded-xl border border-white/[0.08] bg-white/[0.03] px-4 py-3 text-body text-primary placeholder-white/30 outline-none transition-colors focus:border-white/[0.16] focus:bg-white/[0.04]"}),E.trim().length===0&&e.jsx("p",{className:"mt-2 text-caption text-amber-300",children:"This option requires a note before submission."})]}),te&&e.jsxs("div",{className:"mt-6 rounded-xl border border-white/[0.06] bg-white/[0.02] px-4 py-3",children:[e.jsx("p",{className:"text-micro font-semibold uppercase tracking-wider text-muted mb-2",children:"Impact"}),e.jsx("p",{className:"text-body text-primary leading-relaxed",children:nt(te)}),te.blockedWorkstreams.length>0&&e.jsx("ul",{className:"mt-2 space-y-1 text-caption text-secondary",children:te.blockedWorkstreams.map(s=>e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-block h-1 w-1 rounded-full bg-amber-400 flex-shrink-0"}),s.title,s.status==="blocked"&&e.jsx("span",{className:"text-amber-400 text-micro",children:"(blocked)"})]},s.id))})]}),we&&O&&e.jsx("div",{className:"mt-4",children:e.jsxs("button",{type:"button",onClick:()=>O(we),className:"inline-flex items-center gap-1.5 text-caption text-[#D8FFA1] transition-colors hover:text-white",children:[e.jsx(ne,{type:"session",size:12}),"View source run"]})}),e.jsx("div",{className:"mt-4 border-t border-white/[0.06] pt-4",children:e.jsx(Ke,{entityType:"decision",entityId:t.id})}),Se.length>0&&e.jsxs("div",{className:"mt-4 border-t border-white/[0.06] pt-2",children:[e.jsxs("button",{type:"button",onClick:()=>ke(s=>!s),className:"flex w-full items-center justify-between text-micro font-semibold uppercase tracking-wider text-muted hover:text-secondary transition-colors",children:[e.jsx("span",{children:"Technical details"}),e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:`transition-transform ${pe?"rotate-180":""}`,children:e.jsx("path",{d:"m6 9 6 6 6-6"})})]}),pe&&e.jsx("div",{className:"mt-2 space-y-0.5",children:Se.map(([s,l])=>e.jsxs("div",{className:"flex gap-2 text-micro",children:[e.jsx("span",{className:"text-muted w-28 flex-shrink-0",children:s}),e.jsx("span",{className:"text-secondary truncate",children:l})]},s))})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-x-3 gap-y-1 text-micro text-muted opacity-60",children:[v&&e.jsx("span",{children:"j/k nav"}),e.jsx("span",{children:"a approve"}),e.jsx("span",{children:"r reject"}),e.jsx("span",{children:"n note"}),e.jsxs("span",{children:[Fe?"⌘":"Ctrl","+Enter approve"]}),e.jsx("span",{children:"esc close"})]})]}),A&&e.jsxs("div",{className:"flex items-center gap-2 border-t border-white/[0.06] px-6 py-3",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:P.red,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),e.jsx("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]}),e.jsx("p",{className:"text-caption text-red-300",children:A})]}),fe&&e.jsx("div",{className:"relative mt-auto border-t border-white/[0.04] bg-black/60 px-6 py-5 backdrop-blur-xl",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[y&&e.jsx(J.button,{whileTap:{scale:.97},type:"button",onClick:Q,disabled:M,className:"rounded-lg px-4 py-2 text-[14px] font-medium text-secondary transition-colors hover:text-red-400 disabled:opacity-40 focus:outline-none",children:_==="rejecting"?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-block h-3 w-3 animate-spin rounded-full border-[1.5px] border-current border-t-transparent"}),"Rejecting"]}):"Reject"}),e.jsx("button",{type:"button",onClick:le,className:"rounded-lg px-2 py-2 text-[13px] text-muted transition-colors hover:text-secondary focus:outline-none",title:"Copy decision as JSON",children:ve?"Copied":"Copy JSON"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{className:"hidden text-[13px] text-muted sm:block",children:[Fe?"⌘":"Ctrl","+Enter"]}),e.jsx(J.button,{whileTap:!m||M?void 0:{scale:.97},type:"button",onClick:oe,disabled:!m||M,"data-modal-autofocus":"true",className:"rounded-lg px-6 py-2.5 text-[14px] font-semibold transition-all focus:outline-none",style:{backgroundColor:!m||M?"rgba(255,255,255,0.06)":P.lime,color:!m||M?"rgba(255,255,255,0.4)":"#000"},children:_==="approving"?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-block h-3 w-3 animate-spin rounded-full border-[1.5px] border-black/40 border-t-black"}),"Approving"]}):"Approve"})]})]})})]})})}const Ie=40;function Me(i,t){return!i||i.trim().length===0?t:Ue(i.trim())||t}function Ee(i,t,u){const m=i==="approve"?`Approval failed for ${t} decision${t===1?"":"s"}.`:`Rejection failed for ${t} decision${t===1?"":"s"}.`;return Me(u,m)}function qe(i){return i>=1440?"overdue":i>=60?"urgent":"normal"}function pt(i){return i.length>=32?i.slice(0,8):i}function Be({group:i}){const t=qe(i.worstWaitingMinutes),u=i.decisions.length;return e.jsxs(J.div,{initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.22,ease:[.22,1,.36,1]},className:"flex items-center gap-2 px-1 pb-1 pt-2.5 first:pt-0",children:[e.jsx("span",{className:"text-caption font-semibold text-white/70 truncate",children:i.label}),e.jsxs("span",{className:"text-micro text-muted whitespace-nowrap",children:["(",u," decision",u===1?"":"s",")"]}),t==="overdue"&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-red-500/[0.12] px-1.5 py-0.5 text-micro font-medium text-red-400",children:[e.jsx("span",{"aria-hidden":!0,className:"h-1.5 w-1.5 rounded-full bg-red-400"}),"overdue"]}),t==="urgent"&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-amber-400/[0.12] px-1.5 py-0.5 text-micro font-medium text-amber-400",children:[e.jsx("span",{"aria-hidden":!0,className:"h-1.5 w-1.5 rounded-full bg-amber-400"}),"urgent"]})]})}function mt(i,t){return`${i}_${t}`}const kt=d.memo(function({decisions:t,focusDecisionId:u=null,onFocusDecisionHandled:m,onApproveDecision:y,onRejectDecision:k,onApproveAll:j,onBulkDecisionAction:v,mutationState:C,showHeader:c=!0,panelStyle:O="card",className:B,initiativeNames:_}){var x;const T=Xe(),[A,N]=d.useState(!1),[z,G]=d.useState(new Set),[E,V]=d.useState(new Set),[ve,ee]=d.useState(new Set),{enqueue:pe,ToastRenderer:ke}=Je(),[Z,ie]=d.useState("approve_selected"),[me,R]=d.useState(""),[K,w]=d.useState(null),[te,ae]=d.useState(Ie),[I,f]=d.useState(null),xe=d.useRef(null),g=d.useMemo(()=>{const n=new Set;return[...t].filter(r=>n.has(r.id)?!1:(n.add(r.id),!0)).sort((r,a)=>{if(r.waitingMinutes!==a.waitingMinutes)return a.waitingMinutes-r.waitingMinutes;const o=Date.parse(r.requestedAt??r.updatedAt??""),p=Date.parse(a.requestedAt??a.updatedAt??""),h=Number.isFinite(o)?o:0;return(Number.isFinite(p)?p:0)-h})},[t]);d.useEffect(()=>{V(n=>{const r=new Set(g.map(o=>o.id)),a=new Set;for(const o of n)r.has(o)&&a.add(o);return a})},[g]);const S=E.size,q=d.useMemo(()=>g.filter(n=>!ve.has(n.id)).slice(0,te),[g,te,ve]),le=d.useMemo(()=>{const n=new Map,r=[];for(const o of q){const p=o.initiativeId??"_unscoped";let h=n.get(p);h||(h=[],n.set(p,h),r.push(p)),h.push(o)}const a=r.map(o=>{const p=n.get(o),h=Math.max(0,...p.map(Y=>Y.waitingMinutes)),$=o==="_unscoped"?"General":(_==null?void 0:_[o])??pt(o);return{initiativeId:o,label:$,decisions:p,worstWaitingMinutes:h}});return a.sort((o,p)=>p.worstWaitingMinutes-o.worstWaitingMinutes),a},[q,_]),se=d.useMemo(()=>{if(q.length===0)return!1;for(const n of q)if(!E.has(n.id))return!1;return!0},[E,q]),oe=d.useMemo(()=>I?g.find(n=>n.id===I)??null:null,[I,g]),Q=d.useMemo(()=>I?g.findIndex(n=>n.id===I):-1,[I,g]),he=d.useCallback(n=>{const r=Q+n;r>=0&&r<g.length&&f(g[r].id)},[Q,g]),$e=async(n,r)=>{w(null),G(o=>{const p=new Set(o);return p.add(n),p});const a=await y(n,r);return a.failed>0?w(Ee("approve",a.failed,a.firstError)):a.updated>0&&w("Decision approved. Changes synced."),G(o=>{const p=new Set(o);return p.delete(n),p}),a},re=k?async(n,r)=>{w(null),G(o=>{const p=new Set(o);return p.add(n),p});const a=await k(n,r);return a.failed>0?w(Ee("reject",a.failed,a.firstError)):a.updated>0&&w("Decision rejected. Changes synced."),G(o=>{const p=new Set(o);return p.delete(n),p}),a}:void 0;d.useEffect(()=>{ae(n=>g.length===0?0:Math.min(Math.max(Ie,n),g.length))},[g.length]),d.useEffect(()=>{const n=(u??"").trim();if(!n){xe.current=null;return}xe.current===n||!g.some(a=>a.id===n)||(xe.current=n,f(n),m==null||m(n))},[u,m,g]);const fe=n=>{V(r=>{const a=new Set(r);return a.has(n)?a.delete(n):a.add(n),a})},_e=()=>{V(n=>{if(q.length===0)return n;const r=new Set(n),a=se;for(const o of q)a?r.delete(o.id):r.add(o.id);return r})},ge=d.useMemo(()=>{const n=g.map(a=>a.id).filter(a=>E.has(a)),r=q.map(a=>a.id);return[{id:"approve_selected",label:`Approve selected (${n.length})`,action:"approve",ids:n},{id:"reject_selected",label:`Reject selected (${n.length})`,action:"reject",ids:n,hidden:!k},{id:"approve_visible",label:`Approve visible (${r.length})`,action:"approve",ids:r},{id:"reject_visible",label:`Reject visible (${r.length})`,action:"reject",ids:r,hidden:!k}].filter(a=>!a.hidden)},[k,E,g,q]),M=d.useMemo(()=>ge.find(n=>n.id===Z)??ge[0]??null,[Z,ge]),be=async(n,r,a)=>{if(n.length===0)return{updated:0,failed:0};if(r==="approve"&&n.length===g.length&&!a)return j();let o=0,p=0,h;for(const $ of n)try{const Y=r==="approve"?await y($,a?{note:a}:void 0):k?await k($,a?{note:a}:void 0):{updated:0,failed:1};o+=Y.updated,p+=Y.failed,!h&&Y.firstError&&(h=Y.firstError)}catch{p+=1}return{updated:o,failed:p,firstError:h}},Te=async()=>{if(!M||A)return;const n=M.ids;if(n.length===0){w("No decisions selected for this action.");return}w(null),N(!0),G(new Set(n));const r=me.trim();try{const a=v?await v(n,M.action,r.length>0?r:void 0):await be(n,M.action,r.length>0?r:void 0),o=M.action==="approve"?"Approved":"Rejected";if(a.failed>0){const p=`${o} ${a.updated}; ${a.failed} failed.`,h=Me(a.firstError,p);w(h===p?p:`${p} ${h}`)}else a.updated>0?w(`${o} ${a.updated} decision${a.updated===1?"":"s"}.`):w("No decisions were updated.");V(new Set)}catch(a){const o=a instanceof Error?a.message:"";w(Me(o,"Bulk decision action failed."))}finally{N(!1),G(new Set)}},ce=async n=>{if(!(z.has(n)||A)){w(null),G(r=>{const a=new Set(r);return a.add(n),a});try{const r=await y(n);r.failed>0?w(Ee("approve",r.failed,r.firstError)):r.updated>0&&w("Decision approved.")}catch(r){const a=r instanceof Error?r.message:"";w(Me(a,"Decision approval failed."))}finally{G(r=>{const a=new Set(r);return a.delete(n),a}),V(r=>{if(!r.has(n))return r;const a=new Set(r);return a.delete(n),a})}}},Ne=d.useCallback(n=>{z.has(n.id)||A||(ee(r=>new Set(r).add(n.id)),pe({message:`Approved '${n.title.length>40?n.title.slice(0,40)+"…":n.title}'`,onUndo:()=>{ee(r=>{const a=new Set(r);return a.delete(n.id),a})},onCommit:()=>{ee(r=>{const a=new Set(r);return a.delete(n.id),a}),y(n.id).catch(()=>{w("Approval failed. Try again from the decision panel.")})}}))},[z,A,pe,y]);d.useEffect(()=>{if(!K)return;const n=window.setTimeout(()=>w(null),5200);return()=>window.clearTimeout(n)},[K]);const ye=K!==null&&!K.toLowerCase().includes("fail"),D=A||z.size>0,we=Math.max(z.size,A?S:0),Ce=D?`Applying ${we} decision action${we===1?"":"s"}…`:K??null,U=D?"processing":K?ye?"success":"warning":"idle",Se=!T&&q.length<=32,s=M!==null&&M.ids.length>0&&!A,l=g.length;(x=g[0])==null||x.waitingMinutes;const b=M!=null&&M.id.includes("visible")?"visible":"selected",W=(M==null?void 0:M.action)??"approve",F=Ce!==null||U!=="idle",L=O==="card"?Ge:"div";return e.jsxs(L,{className:de("flex h-full min-h-0 flex-col",O==="card"&&"card-enter",B),children:[e.jsx(ut,{open:I!==null,decision:oe,onClose:()=>f(null),onApprove:$e,onReject:re,onNavigate:he,currentIndex:Q>=0?Q:void 0,totalCount:g.length}),c?e.jsxs("div",{className:"space-y-2.5 border-b border-subtle px-4 py-3.5",children:[e.jsx("div",{className:"flex items-start justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h2",{className:"inline-flex items-center gap-2 text-heading font-semibold text-white",children:[e.jsx(ne,{type:"decision",size:14}),"Decisions"]}),e.jsx("p",{className:"mt-0.5 text-caption text-secondary",children:l>0?`${l} decision${l===1?"":"s"} need${l===1?"s":""} your input`:"All clear — no decisions pending"})]})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[g.length>0&&e.jsx("button",{onClick:_e,disabled:D,className:"control-pill h-8 flex-shrink-0 px-3 text-caption font-semibold disabled:opacity-45",children:se?"Clear all":"Select all"}),S>0&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:Te,disabled:!s||D,"data-state":s?"active":"idle",className:"control-pill h-8 flex-shrink-0 px-3 text-caption font-semibold disabled:opacity-45",children:A?"Approving…":`Approve ${S} selected`}),k&&e.jsx("button",{type:"button",onClick:()=>ie(mt("reject",b)),disabled:D,"data-state":W==="reject"?"active":"idle",className:de("control-pill h-8 px-2.5 text-caption font-semibold disabled:opacity-45",W==="reject"&&"border-amber-300/35 bg-amber-400/[0.12] text-amber-100"),children:"Reject"})]})]}),F?e.jsxs(J.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.22,ease:[.22,1,.36,1]},"aria-live":"polite",className:de("flex min-h-[32px] items-center gap-2 rounded-lg border px-2.5 py-1.5 text-caption transition-colors overflow-hidden",U==="processing"?"border-amber-300/25 bg-amber-400/[0.08] text-amber-100":U==="success"?"border-lime/30 bg-lime/10 text-lime":U==="warning"?"border-red-400/25 bg-red-500/[0.08] text-red-100":"border-strong bg-white/[0.02] text-secondary"),children:[U==="processing"?e.jsx("span",{"aria-hidden":!0,className:"h-3.5 w-3.5 rounded-full border-2 border-amber-200/45 border-t-transparent animate-spin"}):U==="success"?e.jsx(ne,{type:"decision",size:12,className:"opacity-90"}):U==="warning"?e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"opacity-90",children:[e.jsx("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"}),e.jsx("line",{x1:"12",x2:"12",y1:"9",y2:"13"}),e.jsx("line",{x1:"12",x2:"12.01",y1:"17",y2:"17"})]}):e.jsx("span",{"aria-hidden":!0,className:"h-1.5 w-1.5 rounded-full bg-white/35"}),e.jsx("span",{className:"min-w-0 truncate",children:Ce})]}):null]}):null,e.jsxs("div",{className:de("min-h-0 flex-1 space-y-2 overflow-y-auto",c?"p-3":"p-0"),children:[g.length===0&&e.jsx(J.div,{initial:{opacity:0,scale:.97},animate:{opacity:1,scale:1},transition:{duration:.28,ease:[.22,1,.36,1]},className:"flex flex-col items-center gap-2.5 rounded-xl border border-subtle bg-white/[0.02] p-4 text-center",children:D?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,className:"h-5 w-5 rounded-full border-2 border-amber-200/45 border-t-transparent animate-spin"}),e.jsx("p",{className:"text-body text-secondary",children:"Finalizing decision updates…"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"text-faint",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),e.jsx("p",{className:"text-body text-secondary",children:"No pending decisions. All clear."})]})}),Se?e.jsx(De,{mode:"popLayout",children:le.map(n=>e.jsxs("div",{children:[le.length>1&&e.jsx(Be,{group:n}),n.decisions.map((r,a)=>{const o=z.has(r.id),p=E.has(r.id),h=qe(r.waitingMinutes);return e.jsx(J.article,{role:"button",tabIndex:0,onClick:()=>f(r.id),onKeyDown:$=>{($.key==="Enter"||$.key===" ")&&($.preventDefault(),f(r.id))},drag:!D&&!o?"x":!1,dragConstraints:{left:0,right:0},dragElastic:.3,onDragEnd:($,Y)=>{Y.offset.x>120&&Ne(r)},initial:A?{opacity:0,x:300}:{opacity:0,y:8,scale:.98},animate:{opacity:1,y:0,x:0,scale:1},exit:{opacity:0,x:300,scale:.95,boxShadow:"0 0 12px 4px rgba(191, 255, 0, 0.15)"},transition:{duration:.25,ease:[.22,1,.36,1],...A?{delay:a*.04}:{}},layout:!0,className:"mt-1.5 rounded-xl border bg-white/[0.03] px-3 py-2.5 transition-[border-color,box-shadow] cv-auto",style:{borderColor:p?`${P.lime}50`:"rgba(255, 255, 255, 0.1)",boxShadow:p?"0 0 0 1px rgba(191, 255, 0, 0.14)":"none"},children:e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx("input",{type:"checkbox",checked:p,onChange:()=>fe(r.id),disabled:o||D,onClick:$=>$.stopPropagation(),className:"mt-0.5 h-4 w-4 rounded border-white/20 bg-black/40 text-lime focus:ring-lime/40"}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-1.5",children:[h!=="normal"&&e.jsx("span",{"aria-label":h==="overdue"?"Overdue":"Urgent",className:de("mt-[5px] h-2 w-2 flex-shrink-0 rounded-full",h==="overdue"?"bg-red-400":"bg-amber-400")}),e.jsxs("p",{className:"flex min-w-0 items-start gap-1.5 text-body font-medium text-white",title:r.title,children:[e.jsx(ne,{type:"decision",size:12,className:"mt-[3px] flex-shrink-0 opacity-90"}),e.jsx("span",{className:"line-clamp-2",children:r.title})]})]}),r.context&&e.jsx("p",{className:"mt-1 line-clamp-2 text-caption text-secondary",title:r.context,children:r.context}),e.jsxs("div",{className:"mt-1.5 flex items-center justify-between gap-2",children:[e.jsxs("p",{className:`min-w-0 truncate text-micro ${(()=>{const $=H(r.waitingMinutes);return $.tone==="urgent"?"text-red-400":$.tone==="attention"?"text-amber-400":"text-muted"})()}`,title:`${r.agentName??"OrgX Autopilot"} · ${H(r.waitingMinutes).text}`,children:[r.agentName??"OrgX Autopilot"," · ",H(r.waitingMinutes).text]}),e.jsx("button",{onClick:$=>{$.stopPropagation(),ce(r.id)},disabled:o||D,className:"flex-shrink-0 rounded-md border border-lime/25 bg-lime/10 px-2.5 py-1 text-micro font-semibold text-lime transition-colors hover:bg-lime/20 disabled:cursor-not-allowed disabled:border-white/10 disabled:bg-white/[0.08] disabled:text-secondary",children:o?"Approving…":"Approve"}),k&&e.jsx("button",{onClick:$=>{$.stopPropagation(),f(r.id)},disabled:o||D,className:"flex-shrink-0 rounded-md border border-white/[0.08] bg-white/[0.03] px-2.5 py-1 text-micro font-semibold text-secondary transition-colors hover:border-red-400/30 hover:bg-red-400/[0.08] hover:text-red-300 disabled:cursor-not-allowed disabled:opacity-40",children:"Reject"})]})]})})]})},r.id)})]},n.initiativeId))}):e.jsx(e.Fragment,{children:le.map(n=>e.jsxs("div",{children:[le.length>1&&e.jsx(Be,{group:n}),n.decisions.map(r=>{const a=z.has(r.id),o=E.has(r.id),p=qe(r.waitingMinutes);return e.jsx("article",{role:"button",tabIndex:0,onClick:()=>f(r.id),onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),f(r.id))},className:"mt-1.5 rounded-xl border bg-white/[0.03] px-3 py-2.5 transition-[border-color,box-shadow] cv-auto",style:{borderColor:o?`${P.lime}50`:"rgba(255, 255, 255, 0.1)",boxShadow:o?"0 0 0 1px rgba(191, 255, 0, 0.14)":"none"},children:e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx("input",{type:"checkbox",checked:o,onChange:()=>fe(r.id),disabled:a||D,onClick:h=>h.stopPropagation(),className:"mt-0.5 h-4 w-4 rounded border-white/20 bg-black/40 text-lime focus:ring-lime/40"}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-1.5",children:[p!=="normal"&&e.jsx("span",{"aria-label":p==="overdue"?"Overdue":"Urgent",className:de("mt-[5px] h-2 w-2 flex-shrink-0 rounded-full",p==="overdue"?"bg-red-400":"bg-amber-400")}),e.jsxs("p",{className:"flex min-w-0 items-start gap-1.5 text-body font-medium text-white",title:r.title,children:[e.jsx(ne,{type:"decision",size:12,className:"mt-[3px] flex-shrink-0 opacity-90"}),e.jsx("span",{className:"line-clamp-2",children:r.title})]})]}),r.context&&e.jsx("p",{className:"mt-1 line-clamp-2 text-caption text-secondary",title:r.context,children:r.context}),e.jsxs("div",{className:"mt-1.5 flex items-center justify-between gap-2",children:[e.jsxs("p",{className:`min-w-0 truncate text-micro ${(()=>{const h=H(r.waitingMinutes);return h.tone==="urgent"?"text-red-400":h.tone==="attention"?"text-amber-400":"text-muted"})()}`,title:`${r.agentName??"OrgX Autopilot"} · ${H(r.waitingMinutes).text}`,children:[r.agentName??"OrgX Autopilot"," · ",H(r.waitingMinutes).text]}),e.jsx("button",{onClick:h=>{h.stopPropagation(),ce(r.id)},disabled:a||D,className:"flex-shrink-0 rounded-md border border-lime/25 bg-lime/10 px-2.5 py-1 text-micro font-semibold text-lime transition-colors hover:bg-lime/20 disabled:cursor-not-allowed disabled:border-white/10 disabled:bg-white/[0.08] disabled:text-secondary",children:a?"Approving…":"Approve"}),k&&e.jsx("button",{onClick:h=>{h.stopPropagation(),f(r.id)},disabled:a||D,className:"flex-shrink-0 rounded-md border border-white/[0.08] bg-white/[0.03] px-2.5 py-1 text-micro font-semibold text-secondary transition-colors hover:border-red-400/30 hover:bg-red-400/[0.08] hover:text-red-300 disabled:cursor-not-allowed disabled:opacity-40",children:"Reject"})]})]})})]})},r.id)})]},n.initiativeId))}),q.length<g.length&&e.jsxs("button",{onClick:()=>ae(n=>Math.min(g.length,n+Ie)),className:"w-full rounded-xl border border-white/[0.08] bg-white/[0.02] px-3 py-2 text-caption text-secondary transition-colors hover:bg-white/[0.05]",children:["Load more (",g.length-q.length," remaining)"]})]}),e.jsx(ke,{})]})});export{kt as DecisionQueue};
@@ -1 +1 @@
1
- import{r as l,j as e}from"./Dj2k1r16.js";import{f as r,z as u,E as f,w as j}from"./CSd4rSuU.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 j(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,y)=>y[1]-s[1]),[t.pendingByQueue]),i=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(f,{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: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(([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{f as r,z as u,E as f,w as j}from"./C0i7ABUU.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 j(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,y)=>y[1]-s[1]),[t.pendingByQueue]),i=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(f,{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: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(([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};
@@ -10,7 +10,7 @@
10
10
  <meta name="googlebot" content="noindex, nofollow, noarchive, nosnippet, noimageindex" />
11
11
  <meta name="copyright" content="OrgX. All rights reserved." />
12
12
  <title>OrgX Live Dashboard</title>
13
- <script type="module" crossorigin src="/orgx/live/assets/CSd4rSuU.js"></script>
13
+ <script type="module" crossorigin src="/orgx/live/assets/C0i7ABUU.js"></script>
14
14
  <link rel="modulepreload" crossorigin href="/orgx/live/assets/Dj2k1r16.js">
15
15
  <link rel="modulepreload" crossorigin href="/orgx/live/assets/DMKyYAtD.js">
16
16
  <link rel="modulepreload" crossorigin href="/orgx/live/assets/eeHXe_OQ.js">
@@ -18,7 +18,7 @@
18
18
  <link rel="modulepreload" crossorigin href="/orgx/live/assets/BjK42gtU.js">
19
19
  <link rel="modulepreload" crossorigin href="/orgx/live/assets/BV0BcV1u.js">
20
20
  <link rel="stylesheet" crossorigin href="/orgx/live/assets/qm8xLgv-.css">
21
- <link rel="stylesheet" crossorigin href="/orgx/live/assets/C1u2SGin.css">
21
+ <link rel="stylesheet" crossorigin href="/orgx/live/assets/Bfp-wdwb.css">
22
22
  </head>
23
23
  <body class="bg-[#080808] text-white antialiased">
24
24
  <div id="root"></div>
Binary file
Binary file
@@ -45,10 +45,67 @@ function compareActivity(a, b) {
45
45
  // Deterministic tie-breaker for cursor paging.
46
46
  return String(b.id).localeCompare(String(a.id));
47
47
  }
48
+ function activityString(meta, keys) {
49
+ if (!meta)
50
+ return null;
51
+ for (const key of keys) {
52
+ const value = meta[key];
53
+ if (typeof value !== "string")
54
+ continue;
55
+ const trimmed = value.trim();
56
+ if (trimmed.length > 0)
57
+ return trimmed;
58
+ }
59
+ return null;
60
+ }
61
+ function activityStringArray(meta, keys) {
62
+ if (!meta)
63
+ return [];
64
+ for (const key of keys) {
65
+ const raw = meta[key];
66
+ if (!Array.isArray(raw))
67
+ continue;
68
+ const values = raw
69
+ .filter((entry) => typeof entry === "string")
70
+ .map((entry) => entry.trim())
71
+ .filter(Boolean);
72
+ if (values.length > 0)
73
+ return values;
74
+ }
75
+ return [];
76
+ }
77
+ function activitySemanticKey(item) {
78
+ const meta = item.metadata && typeof item.metadata === "object" && !Array.isArray(item.metadata)
79
+ ? item.metadata
80
+ : null;
81
+ const bucket = Math.floor(toEpoch(item.timestamp) / 60_000);
82
+ const event = activityString(meta, ["event", "event_name", "eventName"]) ??
83
+ item.type ??
84
+ "activity";
85
+ const initiativeId = (typeof item.initiativeId === "string" && item.initiativeId.trim().length > 0
86
+ ? item.initiativeId.trim()
87
+ : null) ?? activityString(meta, ["initiative_id", "initiativeId"]);
88
+ const workstreamId = activityString(meta, ["workstream_id", "workstreamId", "source_stream_id"]);
89
+ const runId = (typeof item.runId === "string" && item.runId.trim().length > 0 ? item.runId.trim() : null) ??
90
+ activityString(meta, ["run_id", "runId", "source_run_id", "session_id", "sessionId"]);
91
+ const decisionIds = activityStringArray(meta, ["decision_ids", "decisionIds"]).slice(0, 3).join(",");
92
+ const title = activityString(meta, ["decision_title", "task_title", "artifact_title", "title"]) ??
93
+ (typeof item.title === "string" ? item.title.trim() : "");
94
+ return [
95
+ event.toLowerCase(),
96
+ initiativeId ?? "",
97
+ workstreamId ?? "",
98
+ runId ?? "",
99
+ decisionIds,
100
+ title.toLowerCase(),
101
+ String(bucket),
102
+ ].join("|");
103
+ }
48
104
  function normalizeItems(source) {
49
105
  const now = Date.now();
50
106
  const cutoffEpoch = now - RETENTION_DAYS * 24 * 60 * 60_000;
51
107
  const byId = new Map();
108
+ const bySemantic = new Map();
52
109
  for (const item of source) {
53
110
  if (!item || typeof item !== "object")
54
111
  continue;
@@ -65,6 +122,15 @@ function normalizeItems(source) {
65
122
  continue;
66
123
  if (shouldHideActivityItem(item))
67
124
  continue;
125
+ const semanticKey = activitySemanticKey(item);
126
+ const existingSemantic = bySemantic.get(semanticKey);
127
+ if (existingSemantic) {
128
+ if (compareActivity(item, existingSemantic) >= 0) {
129
+ continue;
130
+ }
131
+ byId.delete(existingSemantic.id);
132
+ }
133
+ bySemantic.set(semanticKey, item);
68
134
  byId.set(id, item);
69
135
  }
70
136
  return enrichActivityActorFieldsList(Array.from(byId.values()))
@@ -203,14 +269,8 @@ export function appendActivityItems(items) {
203
269
  if (appended === 0 && updated === 0) {
204
270
  return { appended: 0, updated: 0, total: state.items.length };
205
271
  }
206
- // Rebuild sorted list from map, bounded by MAX_ITEMS.
207
- // Skip full normalizeItems (enrichment + dedup) for small batches — items are already validated above.
208
- if (appended + updated > 50) {
209
- state.items = normalizeItems(Array.from(state.byId.values()));
210
- }
211
- else {
212
- state.items = Array.from(state.byId.values()).sort(compareActivity).slice(0, MAX_ITEMS);
213
- }
272
+ // Rebuild via normalizeItems every time so semantic dedupe stays consistent.
273
+ state.items = normalizeItems(Array.from(state.byId.values()));
214
274
  state.byId = new Map(state.items.map((item) => [item.id, item]));
215
275
  state.dirty = true;
216
276
  scheduleFlush(state);
@@ -256,6 +256,24 @@ export interface TriageImpact {
256
256
  workstreamCount: number;
257
257
  downstreamBlockedCount: number;
258
258
  }
259
+ export interface TriageDecisionOptionSummary {
260
+ id?: string | null;
261
+ label: string;
262
+ description?: string | null;
263
+ consequences?: string | null;
264
+ actionType?: string | null;
265
+ impliedStatus?: string | null;
266
+ requiresNote?: boolean;
267
+ recommended?: boolean;
268
+ }
269
+ export interface TriageEvidenceSummary {
270
+ title: string;
271
+ summary?: string | null;
272
+ url?: string | null;
273
+ pointer?: string | null;
274
+ evidenceType?: string | null;
275
+ confidence?: number | null;
276
+ }
259
277
  export interface TriageInterventionContext {
260
278
  blockerReason?: string | null;
261
279
  waitingOn?: string | null;
@@ -269,6 +287,16 @@ export interface TriageInterventionContext {
269
287
  decisionIds?: string[];
270
288
  taskUpdateCount?: number;
271
289
  milestoneUpdateCount?: number;
290
+ decisionPrompt?: string | null;
291
+ decisionSummary?: string | null;
292
+ decisionOptions?: TriageDecisionOptionSummary[];
293
+ recommendedAction?: string | null;
294
+ scopeHierarchy?: string[];
295
+ currentRunState?: string | null;
296
+ impactIfDelayed?: string | null;
297
+ artifacts?: string[];
298
+ evidence?: TriageEvidenceSummary[];
299
+ updatesApplied?: string[];
272
300
  }
273
301
  export interface LiveTriageItem {
274
302
  id: string;