@useorgx/openclaw-plugin 0.7.18 → 0.7.23
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.
- package/dashboard/dist/assets/9gFmK3Kr.js +1 -0
- package/dashboard/dist/assets/9gFmK3Kr.js.br +0 -0
- package/dashboard/dist/assets/9gFmK3Kr.js.gz +0 -0
- package/dashboard/dist/assets/{DS79hzMu.js → BrMXbzQ-.js} +2 -2
- package/dashboard/dist/assets/BrMXbzQ-.js.br +0 -0
- package/dashboard/dist/assets/BrMXbzQ-.js.gz +0 -0
- package/dashboard/dist/assets/By0MIBj_.js +1 -0
- package/dashboard/dist/assets/By0MIBj_.js.br +0 -0
- package/dashboard/dist/assets/By0MIBj_.js.gz +0 -0
- package/dashboard/dist/assets/C1u2SGin.css +1 -0
- package/dashboard/dist/assets/C1u2SGin.css.br +0 -0
- package/dashboard/dist/assets/C1u2SGin.css.gz +0 -0
- package/dashboard/dist/assets/{467jKHFJ.js → CGJiHCIx.js} +1 -1
- package/dashboard/dist/assets/CGJiHCIx.js.br +0 -0
- package/dashboard/dist/assets/CGJiHCIx.js.gz +0 -0
- package/dashboard/dist/assets/CSd4rSuU.js +212 -0
- package/dashboard/dist/assets/CSd4rSuU.js.br +0 -0
- package/dashboard/dist/assets/CSd4rSuU.js.gz +0 -0
- package/dashboard/dist/assets/{5Ihga-4X.js → CZXS5i_5.js} +1 -1
- package/dashboard/dist/assets/CZXS5i_5.js.br +0 -0
- package/dashboard/dist/assets/CZXS5i_5.js.gz +0 -0
- package/dashboard/dist/assets/{a6qcPiWt.js → CbVWL74-.js} +1 -1
- package/dashboard/dist/assets/CbVWL74-.js.br +0 -0
- package/dashboard/dist/assets/CbVWL74-.js.gz +0 -0
- package/dashboard/dist/assets/{qDJ6rqcs.js → D-FuHfT8.js} +1 -1
- package/dashboard/dist/assets/D-FuHfT8.js.br +0 -0
- package/dashboard/dist/assets/D-FuHfT8.js.gz +0 -0
- package/dashboard/dist/assets/{BcJmNILk.js → D0PN5_vY.js} +1 -1
- package/dashboard/dist/assets/D0PN5_vY.js.br +0 -0
- package/dashboard/dist/assets/D0PN5_vY.js.gz +0 -0
- package/dashboard/dist/assets/DDCPrZRt.js +1 -0
- package/dashboard/dist/assets/DDCPrZRt.js.br +0 -0
- package/dashboard/dist/assets/DDCPrZRt.js.gz +0 -0
- package/dashboard/dist/assets/{B71dt9yu.js → DNQ-iFO2.js} +1 -1
- package/dashboard/dist/assets/DNQ-iFO2.js.br +0 -0
- package/dashboard/dist/assets/DNQ-iFO2.js.gz +0 -0
- package/dashboard/dist/assets/{PVi0vr9a.js → DhPuHPK7.js} +1 -1
- package/dashboard/dist/assets/DhPuHPK7.js.br +0 -0
- package/dashboard/dist/assets/DhPuHPK7.js.gz +0 -0
- package/dashboard/dist/assets/Dhz7qPtn.js +1 -0
- package/dashboard/dist/assets/Dhz7qPtn.js.br +0 -0
- package/dashboard/dist/assets/Dhz7qPtn.js.gz +0 -0
- package/dashboard/dist/assets/LOFrVoPD.js +1 -0
- package/dashboard/dist/assets/LOFrVoPD.js.br +0 -0
- package/dashboard/dist/assets/LOFrVoPD.js.gz +0 -0
- package/dashboard/dist/assets/OlLPtzdz.js +1 -0
- package/dashboard/dist/assets/OlLPtzdz.js.br +0 -0
- package/dashboard/dist/assets/OlLPtzdz.js.gz +0 -0
- package/dashboard/dist/assets/{sdoPH_Z1.js → RN4M9u9W.js} +2 -2
- package/dashboard/dist/assets/RN4M9u9W.js.br +0 -0
- package/dashboard/dist/assets/RN4M9u9W.js.gz +0 -0
- package/dashboard/dist/assets/VCHu272d.js +1 -0
- package/dashboard/dist/assets/VCHu272d.js.br +0 -0
- package/dashboard/dist/assets/VCHu272d.js.gz +0 -0
- package/dashboard/dist/assets/m2smti3F.js +1 -0
- package/dashboard/dist/assets/m2smti3F.js.br +0 -0
- package/dashboard/dist/assets/m2smti3F.js.gz +0 -0
- package/dashboard/dist/assets/{C3_j_W9V.js → nra1yvJX.js} +1 -1
- package/dashboard/dist/assets/nra1yvJX.js.br +0 -0
- package/dashboard/dist/assets/nra1yvJX.js.gz +0 -0
- package/dashboard/dist/assets/qLX6NZ-J.js +1 -0
- package/dashboard/dist/assets/qLX6NZ-J.js.br +0 -0
- package/dashboard/dist/assets/qLX6NZ-J.js.gz +0 -0
- package/dashboard/dist/index.html +2 -2
- package/dashboard/dist/index.html.br +0 -0
- package/dashboard/dist/index.html.gz +0 -0
- package/dist/agent-run-store.js +162 -24
- package/dist/cli/orgx.d.ts +3 -0
- package/dist/config/resolution.d.ts +7 -0
- package/dist/config/resolution.js +13 -5
- package/dist/contracts/onboarding-state.d.ts +2 -0
- package/dist/contracts/onboarding-state.js +23 -0
- package/dist/contracts/shared-types.d.ts +17 -0
- package/dist/http/helpers/auto-continue-engine.d.ts +62 -0
- package/dist/http/helpers/auto-continue-engine.js +329 -53
- package/dist/http/helpers/autopilot-runtime.js +5 -1
- package/dist/http/helpers/autopilot-slice-utils.js +25 -1
- package/dist/http/helpers/decision-mapper.d.ts +1 -0
- package/dist/http/helpers/decision-mapper.js +19 -2
- package/dist/http/helpers/dispatch-lifecycle.js +3 -0
- package/dist/http/helpers/mission-control.d.ts +1 -0
- package/dist/http/helpers/mission-control.js +5 -2
- package/dist/http/helpers/slice-run-projections.d.ts +27 -0
- package/dist/http/helpers/slice-run-projections.js +198 -10
- package/dist/http/helpers/triage-mapper.js +220 -6
- package/dist/http/index.d.ts +1 -0
- package/dist/http/index.js +94 -46
- package/dist/http/router.js +64 -9
- package/dist/http/routes/live-legacy.d.ts +19 -2
- package/dist/http/routes/live-legacy.js +110 -27
- package/dist/http/routes/live-snapshot.d.ts +16 -2
- package/dist/http/routes/live-snapshot.js +169 -25
- package/dist/http/routes/mission-control-actions.js +28 -0
- package/dist/http/routes/mission-control-read.d.ts +18 -0
- package/dist/http/routes/mission-control-read.js +130 -218
- package/dist/http/routes/onboarding.d.ts +1 -0
- package/dist/http/routes/onboarding.js +17 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +199 -123
- package/dist/outbox.d.ts +0 -2
- package/dist/outbox.js +268 -150
- package/dist/reporting/rollups.js +18 -11
- package/dist/runtime-instance-store.js +212 -58
- package/dist/stores/materialized-snapshot-store.d.ts +18 -0
- package/dist/stores/materialized-snapshot-store.js +91 -0
- package/dist/stores/sqlite-state.d.ts +6 -0
- package/dist/stores/sqlite-state.js +179 -0
- package/package.json +6 -1
- package/dashboard/dist/assets/467jKHFJ.js.br +0 -0
- package/dashboard/dist/assets/467jKHFJ.js.gz +0 -0
- package/dashboard/dist/assets/5Ihga-4X.js.br +0 -0
- package/dashboard/dist/assets/5Ihga-4X.js.gz +0 -0
- package/dashboard/dist/assets/B71dt9yu.js.br +0 -0
- package/dashboard/dist/assets/B71dt9yu.js.gz +0 -0
- package/dashboard/dist/assets/BCudUvwg.js +0 -1
- package/dashboard/dist/assets/BCudUvwg.js.br +0 -0
- package/dashboard/dist/assets/BCudUvwg.js.gz +0 -0
- package/dashboard/dist/assets/BEnI6kNR.js +0 -1
- package/dashboard/dist/assets/BEnI6kNR.js.br +0 -0
- package/dashboard/dist/assets/BEnI6kNR.js.gz +0 -0
- package/dashboard/dist/assets/BcJmNILk.js.br +0 -0
- package/dashboard/dist/assets/BcJmNILk.js.gz +0 -0
- package/dashboard/dist/assets/C-MOJWHs.js +0 -1
- package/dashboard/dist/assets/C-MOJWHs.js.br +0 -0
- package/dashboard/dist/assets/C-MOJWHs.js.gz +0 -0
- package/dashboard/dist/assets/C-XuWXGi.js +0 -1
- package/dashboard/dist/assets/C-XuWXGi.js.br +0 -0
- package/dashboard/dist/assets/C-XuWXGi.js.gz +0 -0
- package/dashboard/dist/assets/C3_j_W9V.js.br +0 -0
- package/dashboard/dist/assets/C3_j_W9V.js.gz +0 -0
- package/dashboard/dist/assets/C9-UYhBb.js +0 -1
- package/dashboard/dist/assets/C9-UYhBb.js.br +0 -0
- package/dashboard/dist/assets/C9-UYhBb.js.gz +0 -0
- package/dashboard/dist/assets/C9yV06GS.js +0 -1
- package/dashboard/dist/assets/C9yV06GS.js.br +0 -0
- package/dashboard/dist/assets/C9yV06GS.js.gz +0 -0
- package/dashboard/dist/assets/CReugbyT.js +0 -1
- package/dashboard/dist/assets/CReugbyT.js.br +0 -0
- package/dashboard/dist/assets/CReugbyT.js.gz +0 -0
- package/dashboard/dist/assets/CSDhTbKy.js +0 -1
- package/dashboard/dist/assets/CSDhTbKy.js.br +0 -0
- package/dashboard/dist/assets/CSDhTbKy.js.gz +0 -0
- package/dashboard/dist/assets/CfMS9yIf.js +0 -1
- package/dashboard/dist/assets/CfMS9yIf.js.br +0 -0
- package/dashboard/dist/assets/CfMS9yIf.js.gz +0 -0
- package/dashboard/dist/assets/D2Kqcmv9.js +0 -212
- package/dashboard/dist/assets/D2Kqcmv9.js.br +0 -0
- package/dashboard/dist/assets/D2Kqcmv9.js.gz +0 -0
- package/dashboard/dist/assets/DS79hzMu.js.br +0 -0
- package/dashboard/dist/assets/DS79hzMu.js.gz +0 -0
- package/dashboard/dist/assets/PVi0vr9a.js.br +0 -0
- package/dashboard/dist/assets/PVi0vr9a.js.gz +0 -0
- package/dashboard/dist/assets/RZkbqlJk.css +0 -1
- package/dashboard/dist/assets/RZkbqlJk.css.br +0 -0
- package/dashboard/dist/assets/RZkbqlJk.css.gz +0 -0
- package/dashboard/dist/assets/a6qcPiWt.js.br +0 -0
- package/dashboard/dist/assets/a6qcPiWt.js.gz +0 -0
- package/dashboard/dist/assets/qDJ6rqcs.js.br +0 -0
- package/dashboard/dist/assets/qDJ6rqcs.js.gz +0 -0
- package/dashboard/dist/assets/sdoPH_Z1.js.br +0 -0
- package/dashboard/dist/assets/sdoPH_Z1.js.gz +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as c,j as e}from"./Dj2k1r16.js";import{E as ae,f as P,z as Pe,a4 as ee,w as Re,a5 as Ue,a6 as Oe,M as ze,h as We,P as Ge,C as ue}from"./CSd4rSuU.js";import{E as Ke}from"./DhPuHPK7.js";import{A as De,m as V,u as Xe}from"./eeHXe_OQ.js";import{u as Je}from"./CGJiHCIx.js";import"./DMKyYAtD.js";import"./cX2e-TLi.js";import"./BjK42gtU.js";import"./BV0BcV1u.js";const Ve={pr:"⎋",file:"◇",artifact:"▪",log:"▸",decision:"◈"};function Ze(a){return a>=.8?"#BFFF00":a>=.5?"#F5B700":"#FF6B88"}function Qe(a){const t=a.match(/https?:\/\/\S+/);return t?t[0]:null}function Ye({evidenceType:a,title:t,summary:u,sourceUrl:m,confidence:y,payload:k,icon:j,label:v,onOpenTerminal:C}){const[o,W]=c.useState(!1),B=t??v??null,_=a??(j?j.toUpperCase():null),T=j?Ve[j]:null,S=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:()=>W(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}):S?e.jsx("a",{href:S,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 ${o?"":"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 ${o?"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:o&&e.jsx(V.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:a}){return a.length===0?null:e.jsx("nav",{className:"flex items-center gap-1.5 min-w-0 text-caption text-secondary",children:a.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(ae,{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 ve={label:"Retry this workstream",description:"Re-run with the same configuration. Recommended if this was a transient issue.",impliedStatus:"approved"},J={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:(a,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:[ve,{label:"Retry with more resources",description:"Increase token budget before re-running.",impliedStatus:"approved"},J],extractDetails:(a,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:(a,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:[ve,{label:"Check MCP server",description:"Investigate the tool server connection before retrying.",impliedStatus:"approved"},J],extractDetails:(a,t)=>({server:t[1]||void 0})},{test:/(?:Slice|Autopilot slice) timed out after (\d+)/i,headline:"Agent ran out of time",explain:(a,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"},J],extractDetails:(a,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:[ve,{label:"Review logs",description:"Check the session logs to understand why the agent stalled.",impliedStatus:"approved"},J]},{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"},J]},{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"},J]},{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"},J]},{test:/code=(\d+)/i,headline:"Agent encountered an error",explain:(a,t)=>`The agent process exited with error code ${t[1]}. Reviewing the session logs will show what operation failed.`,severity:"critical",options:[ve,{label:"Review error logs",description:"Check session logs to understand the error before retrying.",impliedStatus:"approved"},J],extractDetails:(a,t)=>({exitCode:t[1]})}];function tt(a){var u;const t=a.context||a.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 a.decisionType==="autopilot_failure"?{headline:"Agent work needs attention",explanation:t||"An issue occurred during autopilot execution that requires review.",structuredDetails:{},suggestedOptions:[ve,J],severity:"warning"}:{headline:a.title||"Decision needed",explanation:t||"Review the details and choose an action.",structuredDetails:{},suggestedOptions:[],severity:"info"}}function st(a){return a.map((t,u)=>({id:`suggested-${u}`,label:t.label,description:t.description,impliedStatus:t.impliedStatus,actionType:null,requiresNote:!1}))}function rt(a,t){var v;if(!t||!a.workstreamId||!t.nodes.find(C=>C.id===a.workstreamId&&C.entityType==="workstream"))return null;const m=new Set(t.edges.filter(C=>C.source===a.workstreamId).map(C=>C.target)),y=[];for(const C of m){const o=t.nodes.find(W=>W.id===C);o&&y.push({id:o.id,title:o.title,taskCount:((v=o.children)==null?void 0:v.length)??0,status:o.status})}if(y.length===0)return null;const k=y.reduce((C,o)=>C+o.taskCount,0),j=y.some(C=>t.edges.some(o=>o.source===C.id));return{blockedWorkstreams:y,totalBlockedTasks:k,criticalPath:j}}function nt(a){const t=a.blockedWorkstreams.length,u=a.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(a){try{return JSON.stringify(a,null,2)}catch{return null}}function pe(a){return!a||typeof a!="object"||Array.isArray(a)?null:a}function at(a){if(!a)return[];const t=pe(a.result),u=[a,t].filter(j=>!!j),m=[],y=new Set,k=(j,v)=>{if(Array.isArray(v))for(const C of v){const o=pe(C);if(!o)continue;const W=typeof o.task_id=="string"&&o.task_id.trim()||typeof o.taskId=="string"&&o.taskId.trim()||typeof o.milestone_id=="string"&&o.milestone_id.trim()||typeof o.milestoneId=="string"&&o.milestoneId.trim()||null,B=typeof o.task_title=="string"&&o.task_title.trim()||typeof o.taskTitle=="string"&&o.taskTitle.trim()||typeof o.milestone_title=="string"&&o.milestone_title.trim()||typeof o.milestoneTitle=="string"&&o.milestoneTitle.trim()||typeof o.title=="string"&&o.title.trim()||W||j,_=typeof o.status=="string"&&o.status.trim()||typeof o.state=="string"&&o.state.trim()||null,T=typeof o.reason=="string"&&o.reason.trim()||typeof o.summary=="string"&&o.summary.trim()||typeof o.note=="string"&&o.note.trim()||null,S=`${j}|${B.toLowerCase()}|${(_??"").toLowerCase()}|${(T??"").toLowerCase()}`;y.has(S)||(y.add(S),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 Le(a){if(typeof a!="string")return null;const t=a.trim().toLowerCase();return t==="rejected"?"declined":t==="approved"||t==="declined"||t==="cancelled"?t:null}function Ae(a,t){return!a||a.trim().length===0?t:We(a.trim())||t}function lt(a){switch(a){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 a.replace(/[_-]/g," ").replace(/\b\w/g,t=>t.toUpperCase())}}function ot(a){const t=a.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 ct({open:a,decision:t,onClose:u,onApprove:m,onReject:y,initiativeTitle:k,workstreamTitle:j,onNavigate:v,currentIndex:C,totalCount:o,onFocusRunId:W,graph:B}){const[_,T]=c.useState("idle"),[S,N]=c.useState(null),[U,O]=c.useState(null),[I,Z]=c.useState(""),[ke,te]=c.useState(!1),[me,Ne]=c.useState(!1),Q=c.useRef(null),le=c.useRef(),xe=c.useRef(u);xe.current=u,c.useEffect(()=>{if(a){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);O(s),Z(""),te(!1),Ne(!1)}return()=>{le.current&&clearTimeout(le.current)}},[a,t==null?void 0:t.id]);const F=t==null?void 0:t.metadata,G=c.useMemo(()=>{if(!F)return[];const s=F,l=s.decision_options??s.options??s.actions??null;if(!Array.isArray(l))return[];const x=[],z=new Set;for(let R=0;R<l.length;R+=1){const L=l[R];if(typeof L=="string"){const r=L.trim();if(!r)continue;const i=`option-${R+1}`;if(z.has(i))continue;z.add(i),x.push({id:i,label:r,description:null,consequences:null,impliedStatus:null,actionType:null,requiresNote:!1});continue}if(!L||typeof L!="object")continue;const h=L,X=typeof h.id=="string"&&h.id.trim()||typeof h.option_id=="string"&&h.option_id.trim()||typeof h.action_id=="string"&&h.action_id.trim()||`option-${R+1}`;if(z.has(X))continue;const n=typeof h.label=="string"&&h.label.trim()||typeof h.title=="string"&&h.title.trim()||typeof h.name=="string"&&h.name.trim()||typeof h.action=="string"&&h.action.trim()||null;n&&(z.add(X),x.push({id:X,label:n,description:typeof h.description=="string"?h.description:null,consequences:typeof h.consequences=="string"&&h.consequences||typeof h.impact=="string"&&h.impact||null,impliedStatus:Le(h.implied_status)??Le(h.status),actionType:typeof h.action_type=="string"&&h.action_type||typeof h.type=="string"&&h.type||null,requiresNote:h.requires_note===!0||h.requiresNote===!0||h.note_required===!0}))}return x.slice(0,12)},[F]),w=c.useMemo(()=>t?tt(t):null,[t==null?void 0:t.context,t==null?void 0:t.title,t==null?void 0:t.decisionType]),se=c.useMemo(()=>t?rt(t,B??null):null,[t==null?void 0:t.workstreamId,t==null?void 0:t.initiativeId,B]),oe=((t==null?void 0:t.waitingMinutes)??0)>1440,E=c.useMemo(()=>t!=null&&t.options&&t.options.length>0?t.options:G.length>0?G:w&&w.suggestedOptions.length>0?st(w.suggestedOptions):[],[t==null?void 0:t.options,G,w]),g=c.useMemo(()=>E.find(s=>s.id===U)??null,[E,U]),he=(g==null?void 0:g.requiresNote)===!0,b=c.useMemo(()=>{const s=((t==null?void 0:t.context)??"").trim();if(s)return s;if(!F)return"";const l=F,x=(typeof l.summary=="string"?l.summary:null)??(typeof l.description=="string"?l.description:null)??"";return String(x??"").trim()},[t==null?void 0:t.context,F]),A=c.useMemo(()=>{var X,n,r;const s=F&&typeof F=="object"?F:void 0,l=at(s),x=pe(s==null?void 0:s.outcomes),z=typeof(s==null?void 0:s.status_updates_applied)=="number"&&Number.isFinite(s.status_updates_applied)?s.status_updates_applied:typeof((X=pe(s==null?void 0:s.result))==null?void 0:X.status_updates_applied)=="number"&&Number.isFinite((n=pe(s==null?void 0:s.result))==null?void 0:n.status_updates_applied)?(r=pe(s==null?void 0:s.result))==null?void 0:r.status_updates_applied:null,R=Array.isArray(s==null?void 0:s.artifacts)?s.artifacts.length:typeof(x==null?void 0:x.artifacts)=="number"?x.artifacts:null,L=(s==null?void 0:s.status_updates_buffered)??(s==null?void 0:s.statusUpdatesBuffered),h=L===!0||typeof L=="number"&&L>0||typeof L=="string"&&["true","1","yes"].includes(L.trim().toLowerCase());return{rows:l,statusUpdatesApplied:z,artifactCount:typeof R=="number"?R:null,buffered:h,hasPr:typeof(x==null?void 0:x.pr_url)=="string"||typeof(x==null?void 0:x.commit_sha)=="string"}},[F]),q=c.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]),ce=c.useCallback(async()=>{if(!t)return;const s=it({decision:t,metadata:F});if(s)try{await navigator.clipboard.writeText(s),te(!0),setTimeout(()=>te(!1),2e3)}catch{}},[t,F]),re=c.useCallback(()=>{const s=I.trim(),l=g==null?void 0:g.id;if(!(!s&&!l))return{note:s.length>0?s:void 0,optionId:l??void 0}},[I,g]),de=c.useCallback(async()=>{if(!t||!m)return;if(E.length>0&&!g){N("Select an option before approving this decision.");return}if(g!=null&&g.requiresNote&&I.trim().length===0){N("A note is required for the selected option."),requestAnimationFrame(()=>{var l;return(l=Q.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,re());l.failed>0?(T("error"),N(Ae(l.firstError,"Approval failed. Please try again."))):(T("success"),le.current=setTimeout(()=>xe.current(),800))}catch(l){T("error");const x=l instanceof Error?l.message:"";N(Ae(x,"Approval failed."))}}},[re,t,I,m,E.length,g]),Y=c.useCallback(async()=>{if(!t||!y)return;if(E.length>0&&!g){N("Select an option before rejecting this decision.");return}if(g!=null&&g.requiresNote&&I.trim().length===0){N("A note is required for the selected option."),requestAnimationFrame(()=>{var l;return(l=Q.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,re());l.failed>0?(T("error"),N(Ae(l.firstError,"Rejection failed. Please try again."))):(T("rejected"),le.current=setTimeout(()=>xe.current(),800))}catch(l){T("error");const x=l instanceof Error?l.message:"";N(Ae(x,"Rejection failed."))}}},[re,t,I,y,E.length,g]);if(c.useEffect(()=>{if(!a)return;const s=l=>{var z,R;if((l.metaKey||l.ctrlKey)&&l.key==="Enter"){l.preventDefault(),de();return}const x=(z=l.target)==null?void 0:z.tagName;if(!(x==="INPUT"||x==="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(),de();break;case"r":l.preventDefault(),Y();break;case"n":l.preventDefault(),(R=Q.current)==null||R.focus();break}};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[a,de,Y,v]),!a||!t)return null;const fe=_==="approving"||_==="rejecting",$e=_==="success"||_==="rejected",ne=(t.status??"pending").toLowerCase(),ge=!ne.includes("approved")&&!ne.includes("resolved")&&!ne.includes("rejected")&&!ne.includes("declined")&&!ne.includes("cancelled"),_e=E.length>0&&!g,be=(g==null?void 0:g.requiresNote)===!0&&I.trim().length===0,M=fe||_e||be,Ce=t.evidenceRefs??[],Te=Ce.length>0,ye=t.recommendedAction??null,Se=t.decisionType??null,we=t.priority??null,D=t.occurrenceCount??null,je=t.sourceRunId??null,ie=[];k&&ie.push({label:k,icon:"initiative"}),j&&ie.push({label:j,icon:"workstream"});const K=[["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:a,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:a,onClose:u,maxWidth:"max-w-xl",children:e.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col",style:oe?{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&&o!=null&&e.jsxs("span",{className:"text-micro text-muted tabular-nums",children:[C+1," of ",o,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"})})})]}),ie.length>0&&e.jsx("div",{className:"px-6 pt-2",children:e.jsx(He,{segments:ie})}),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(ae,{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:oe?"font-semibold text-red-300":"",children:ee(t.waitingMinutes).text}),Se&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-white/[0.15]",children:"|"}),e.jsx("span",{className:"text-primary",children:lt(Se)})]}),we&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-white/[0.15]",children:"|"}),e.jsx("span",{className:"font-medium",style:{color:ot(we)},children:we})]})]}),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(Ue,{nodes:Oe({initiativeId:t.initiativeId,initiativeTitle:k,workstreamId:t.workstreamId,workstreamTitle:j,agentName:t.agentName,agentId:t.agentId}),activeId:t.workstreamId,compact:!0})}),ye&&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:ye})]}),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:Ce.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))})]}),oe&&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:ee(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(/^./,x=>x.toUpperCase()),": ",l]},s))})]}):b?e.jsx("div",{className:"rounded-xl border border-white/[0.06] bg-white/[0.02] px-4 py-3",children:e.jsx(ze,{text:b,mode:"block"})}):e.jsx("p",{className:"px-1 text-body text-muted italic",children:"No additional context provided."}),(A.rows.length>0||(A.statusUpdatesApplied??0)>0||A.buffered||(A.artifactCount??0)>0||A.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:A.buffered?"Updates being applied":"Expected updates"}),(A.statusUpdatesApplied??0)>0&&e.jsxs("p",{className:"text-caption text-primary",children:[A.statusUpdatesApplied," status update",A.statusUpdatesApplied===1?"":"s",A.buffered?" queued for sync":" planned","."]}),(A.artifactCount??0)>0&&e.jsxs("p",{className:"text-caption text-primary",children:[A.artifactCount," artifact",A.artifactCount===1?"":"s"," expected from this decision path."]}),A.rows.length>0&&e.jsx("ul",{className:"mt-2 space-y-1 pl-4",children:A.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}`))})]}),E.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:E.map(s=>{const l=U===s.id;return e.jsxs("button",{type:"button",onClick:()=>{O(l?null:s.id),s.requiresNote&&requestAnimationFrame(()=>{var x;return(x=Q.current)==null?void 0:x.focus()})},disabled:fe,className:"group relative flex w-full items-start gap-4 px-4 py-4 text-left focus:outline-none",children:[l&&e.jsx(V.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(V.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)})})]}),ge&&he&&e.jsxs("div",{className:"mt-4",children:[e.jsx("textarea",{ref:Q,value:I,onChange:s=>Z(s.target.value),disabled:fe,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]"}),I.trim().length===0&&e.jsx("p",{className:"mt-2 text-caption text-amber-300",children:"This option requires a note before submission."})]}),se&&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(se)}),se.blockedWorkstreams.length>0&&e.jsx("ul",{className:"mt-2 space-y-1 text-caption text-secondary",children:se.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))})]}),je&&W&&e.jsx("div",{className:"mt-4",children:e.jsxs("button",{type:"button",onClick:()=>W(je),className:"inline-flex items-center gap-1.5 text-caption text-[#D8FFA1] transition-colors hover:text-white",children:[e.jsx(ae,{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})}),K.length>0&&e.jsxs("div",{className:"mt-4 border-t border-white/[0.06] pt-2",children:[e.jsxs("button",{type:"button",onClick:()=>Ne(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 ${me?"rotate-180":""}`,children:e.jsx("path",{d:"m6 9 6 6 6-6"})})]}),me&&e.jsx("div",{className:"mt-2 space-y-0.5",children:K.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"})]})]}),S&&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:S})]}),ge&&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(V.button,{whileTap:{scale:.97},type:"button",onClick:Y,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:ce,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:ke?"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(V.button,{whileTap:!m||M?void 0:{scale:.97},type:"button",onClick:de,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(a,t){return!a||a.trim().length===0?t:We(a.trim())||t}function Ee(a,t,u){const m=a==="approve"?`Approval failed for ${t} decision${t===1?"":"s"}.`:`Rejection failed for ${t} decision${t===1?"":"s"}.`;return Me(u,m)}function qe(a){return a>=1440?"overdue":a>=60?"urgent":"normal"}function dt(a){return a.length>=32?a.slice(0,8):a}function Be({group:a}){const t=qe(a.worstWaitingMinutes),u=a.decisions.length;return e.jsxs(V.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:a.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 ut(a,t){return`${a}_${t}`}const jt=c.memo(function({decisions:t,focusDecisionId:u=null,onFocusDecisionHandled:m,onApproveDecision:y,onRejectDecision:k,onApproveAll:j,onBulkDecisionAction:v,mutationState:C,showHeader:o=!0,panelStyle:W="card",className:B,initiativeNames:_}){var X;const T=Xe(),[S,N]=c.useState(!1),[U,O]=c.useState(new Set),[I,Z]=c.useState(new Set),[ke,te]=c.useState(new Set),{enqueue:me,ToastRenderer:Ne}=Je(),[Q,le]=c.useState("approve_selected"),[xe,F]=c.useState(""),[G,w]=c.useState(null),[se,oe]=c.useState(Ie),[E,g]=c.useState(null),he=c.useRef(null),b=c.useMemo(()=>{const n=new Set;return[...t].filter(r=>n.has(r.id)?!1:(n.add(r.id),!0)).sort((r,i)=>{if(r.waitingMinutes!==i.waitingMinutes)return i.waitingMinutes-r.waitingMinutes;const d=Date.parse(r.requestedAt??r.updatedAt??""),p=Date.parse(i.requestedAt??i.updatedAt??""),f=Number.isFinite(d)?d:0;return(Number.isFinite(p)?p:0)-f})},[t]);c.useEffect(()=>{Z(n=>{const r=new Set(b.map(d=>d.id)),i=new Set;for(const d of n)r.has(d)&&i.add(d);return i})},[b]);const A=I.size,q=c.useMemo(()=>b.filter(n=>!ke.has(n.id)).slice(0,se),[b,se,ke]),ce=c.useMemo(()=>{const n=new Map,r=[];for(const d of q){const p=d.initiativeId??"_unscoped";let f=n.get(p);f||(f=[],n.set(p,f),r.push(p)),f.push(d)}const i=r.map(d=>{const p=n.get(d),f=Math.max(0,...p.map(H=>H.waitingMinutes)),$=d==="_unscoped"?"General":(_==null?void 0:_[d])??dt(d);return{initiativeId:d,label:$,decisions:p,worstWaitingMinutes:f}});return i.sort((d,p)=>p.worstWaitingMinutes-d.worstWaitingMinutes),i},[q,_]),re=c.useMemo(()=>{if(q.length===0)return!1;for(const n of q)if(!I.has(n.id))return!1;return!0},[I,q]),de=c.useMemo(()=>E?b.find(n=>n.id===E)??null:null,[E,b]),Y=c.useMemo(()=>E?b.findIndex(n=>n.id===E):-1,[E,b]),fe=c.useCallback(n=>{const r=Y+n;r>=0&&r<b.length&&g(b[r].id)},[Y,b]),$e=async(n,r)=>{w(null),O(d=>{const p=new Set(d);return p.add(n),p});const i=await y(n,r);return i.failed>0?w(Ee("approve",i.failed,i.firstError)):i.updated>0&&w("Decision approved. Changes synced."),O(d=>{const p=new Set(d);return p.delete(n),p}),i},ne=k?async(n,r)=>{w(null),O(d=>{const p=new Set(d);return p.add(n),p});const i=await k(n,r);return i.failed>0?w(Ee("reject",i.failed,i.firstError)):i.updated>0&&w("Decision rejected. Changes synced."),O(d=>{const p=new Set(d);return p.delete(n),p}),i}:void 0;c.useEffect(()=>{oe(n=>b.length===0?0:Math.min(Math.max(Ie,n),b.length))},[b.length]),c.useEffect(()=>{const n=(u??"").trim();if(!n){he.current=null;return}he.current===n||!b.some(i=>i.id===n)||(he.current=n,g(n),m==null||m(n))},[u,m,b]);const ge=n=>{Z(r=>{const i=new Set(r);return i.has(n)?i.delete(n):i.add(n),i})},_e=()=>{Z(n=>{if(q.length===0)return n;const r=new Set(n),i=re;for(const d of q)i?r.delete(d.id):r.add(d.id);return r})},be=c.useMemo(()=>{const n=b.map(i=>i.id).filter(i=>I.has(i)),r=q.map(i=>i.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(i=>!i.hidden)},[k,I,b,q]),M=c.useMemo(()=>be.find(n=>n.id===Q)??be[0]??null,[Q,be]),Ce=async(n,r,i)=>{if(n.length===0)return{updated:0,failed:0};if(r==="approve"&&n.length===b.length&&!i)return j();let d=0,p=0,f;for(const $ of n)try{const H=r==="approve"?await y($,i?{note:i}:void 0):k?await k($,i?{note:i}:void 0):{updated:0,failed:1};d+=H.updated,p+=H.failed,!f&&H.firstError&&(f=H.firstError)}catch{p+=1}return{updated:d,failed:p,firstError:f}},Te=async()=>{if(!M||S)return;const n=M.ids;if(n.length===0){w("No decisions selected for this action.");return}w(null),N(!0),O(new Set(n));const r=xe.trim();try{const i=v?await v(n,M.action,r.length>0?r:void 0):await Ce(n,M.action,r.length>0?r:void 0),d=M.action==="approve"?"Approved":"Rejected";if(i.failed>0){const p=`${d} ${i.updated}; ${i.failed} failed.`,f=Me(i.firstError,p);w(f===p?p:`${p} ${f}`)}else i.updated>0?w(`${d} ${i.updated} decision${i.updated===1?"":"s"}.`):w("No decisions were updated.");Z(new Set)}catch(i){const d=i instanceof Error?i.message:"";w(Me(d,"Bulk decision action failed."))}finally{N(!1),O(new Set)}},ye=async n=>{if(!(U.has(n)||S)){w(null),O(r=>{const i=new Set(r);return i.add(n),i});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 i=r instanceof Error?r.message:"";w(Me(i,"Decision approval failed."))}finally{O(r=>{const i=new Set(r);return i.delete(n),i}),Z(r=>{if(!r.has(n))return r;const i=new Set(r);return i.delete(n),i})}}},Se=c.useCallback(n=>{U.has(n.id)||S||(te(r=>new Set(r).add(n.id)),me({message:`Approved '${n.title.length>40?n.title.slice(0,40)+"…":n.title}'`,onUndo:()=>{te(r=>{const i=new Set(r);return i.delete(n.id),i})},onCommit:()=>{te(r=>{const i=new Set(r);return i.delete(n.id),i}),y(n.id).catch(()=>{w("Approval failed. Try again from the decision panel.")})}}))},[U,S,me,y]);c.useEffect(()=>{if(!G)return;const n=window.setTimeout(()=>w(null),5200);return()=>window.clearTimeout(n)},[G]);const we=G!==null&&!G.toLowerCase().includes("fail"),D=S||U.size>0,je=Math.max(U.size,S?A:0),ie=D?`Applying ${je} decision action${je===1?"":"s"}…`:G??null,K=D?"processing":G?we?"success":"warning":"idle",s=!T&&q.length<=32,l=M!==null&&M.ids.length>0&&!S,x=b.length;(X=b[0])==null||X.waitingMinutes;const z=M!=null&&M.id.includes("visible")?"visible":"selected",R=(M==null?void 0:M.action)??"approve",L=ie!==null||K!=="idle",h=W==="card"?Ge:"div";return e.jsxs(h,{className:ue("flex h-full min-h-0 flex-col",W==="card"&&"card-enter",B),children:[e.jsx(ct,{open:E!==null,decision:de,onClose:()=>g(null),onApprove:$e,onReject:ne,onNavigate:fe,currentIndex:Y>=0?Y:void 0,totalCount:b.length}),o?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(ae,{type:"decision",size:14}),"Decisions"]}),e.jsx("p",{className:"mt-0.5 text-caption text-secondary",children:x>0?`${x} decision${x===1?"":"s"} need${x===1?"s":""} your input`:"All clear — no decisions pending"})]})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[b.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:re?"Clear all":"Select all"}),A>0&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:Te,disabled:!l||D,"data-state":l?"active":"idle",className:"control-pill h-8 flex-shrink-0 px-3 text-caption font-semibold disabled:opacity-45",children:S?"Approving…":`Approve ${A} selected`}),k&&e.jsx("button",{type:"button",onClick:()=>le(ut("reject",z)),disabled:D,"data-state":R==="reject"?"active":"idle",className:ue("control-pill h-8 px-2.5 text-caption font-semibold disabled:opacity-45",R==="reject"&&"border-amber-300/35 bg-amber-400/[0.12] text-amber-100"),children:"Reject"})]})]}),L?e.jsxs(V.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:ue("flex min-h-[32px] items-center gap-2 rounded-lg border px-2.5 py-1.5 text-caption transition-colors overflow-hidden",K==="processing"?"border-amber-300/25 bg-amber-400/[0.08] text-amber-100":K==="success"?"border-lime/30 bg-lime/10 text-lime":K==="warning"?"border-red-400/25 bg-red-500/[0.08] text-red-100":"border-strong bg-white/[0.02] text-secondary"),children:[K==="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"}):K==="success"?e.jsx(ae,{type:"decision",size:12,className:"opacity-90"}):K==="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:ie})]}):null]}):null,e.jsxs("div",{className:ue("min-h-0 flex-1 space-y-2 overflow-y-auto",o?"p-3":"p-0"),children:[b.length===0&&e.jsx(V.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."})]})}),s?e.jsx(De,{mode:"popLayout",children:ce.map(n=>e.jsxs("div",{children:[ce.length>1&&e.jsx(Be,{group:n}),n.decisions.map((r,i)=>{const d=U.has(r.id),p=I.has(r.id),f=qe(r.waitingMinutes);return e.jsx(V.article,{role:"button",tabIndex:0,onClick:()=>g(r.id),onKeyDown:$=>{($.key==="Enter"||$.key===" ")&&($.preventDefault(),g(r.id))},drag:!D&&!d?"x":!1,dragConstraints:{left:0,right:0},dragElastic:.3,onDragEnd:($,H)=>{H.offset.x>120&&Se(r)},initial:S?{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],...S?{delay:i*.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:()=>ge(r.id),disabled:d||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:[f!=="normal"&&e.jsx("span",{"aria-label":f==="overdue"?"Overdue":"Urgent",className:ue("mt-[5px] h-2 w-2 flex-shrink-0 rounded-full",f==="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(ae,{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 $=ee(r.waitingMinutes);return $.tone==="urgent"?"text-red-400":$.tone==="attention"?"text-amber-400":"text-muted"})()}`,title:`${r.agentName??"OrgX Autopilot"} · ${ee(r.waitingMinutes).text}`,children:[r.agentName??"OrgX Autopilot"," · ",ee(r.waitingMinutes).text]}),e.jsx("button",{onClick:$=>{$.stopPropagation(),ye(r.id)},disabled:d||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:d?"Approving…":"Approve"}),k&&e.jsx("button",{onClick:$=>{$.stopPropagation(),g(r.id)},disabled:d||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:ce.map(n=>e.jsxs("div",{children:[ce.length>1&&e.jsx(Be,{group:n}),n.decisions.map(r=>{const i=U.has(r.id),d=I.has(r.id),p=qe(r.waitingMinutes);return e.jsx("article",{role:"button",tabIndex:0,onClick:()=>g(r.id),onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),g(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:d?`${P.lime}50`:"rgba(255, 255, 255, 0.1)",boxShadow:d?"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:d,onChange:()=>ge(r.id),disabled:i||D,onClick:f=>f.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:ue("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(ae,{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 f=ee(r.waitingMinutes);return f.tone==="urgent"?"text-red-400":f.tone==="attention"?"text-amber-400":"text-muted"})()}`,title:`${r.agentName??"OrgX Autopilot"} · ${ee(r.waitingMinutes).text}`,children:[r.agentName??"OrgX Autopilot"," · ",ee(r.waitingMinutes).text]}),e.jsx("button",{onClick:f=>{f.stopPropagation(),ye(r.id)},disabled:i||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:i?"Approving…":"Approve"}),k&&e.jsx("button",{onClick:f=>{f.stopPropagation(),g(r.id)},disabled:i||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<b.length&&e.jsxs("button",{onClick:()=>oe(n=>Math.min(b.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 (",b.length-q.length," remaining)"]})]}),e.jsx(Ne,{})]})});export{jt as DecisionQueue};
|
|
Binary file
|
|
Binary file
|
|
@@ -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/
|
|
13
|
+
<script type="module" crossorigin src="/orgx/live/assets/CSd4rSuU.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/
|
|
21
|
+
<link rel="stylesheet" crossorigin href="/orgx/live/assets/C1u2SGin.css">
|
|
22
22
|
</head>
|
|
23
23
|
<body class="bg-[#080808] text-white antialiased">
|
|
24
24
|
<div id="root"></div>
|
|
Binary file
|
|
Binary file
|
package/dist/agent-run-store.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { existsSync, readFileSync, } from "node:fs";
|
|
2
2
|
import { getOrgxPluginConfigDir, getOrgxPluginConfigPath } from "./paths.js";
|
|
3
|
-
import { backupCorruptFileSync
|
|
3
|
+
import { backupCorruptFileSync } from "./fs-utils.js";
|
|
4
4
|
import { clearStoreFileSync, ensureStoreDirSync, parseJsonSafe, } from "./stores/json-store.js";
|
|
5
|
+
import { getStateDb, readStateMeta, writeStateMeta, } from "./stores/sqlite-state.js";
|
|
5
6
|
const MAX_RUNS = 240;
|
|
7
|
+
const AGENT_RUN_IMPORT_META_KEY = "agent_runs_imported_v1";
|
|
6
8
|
function runDir() {
|
|
7
9
|
return getOrgxPluginConfigDir();
|
|
8
10
|
}
|
|
@@ -52,7 +54,7 @@ function normalizeRecord(input) {
|
|
|
52
54
|
status: input.status === "stopped" ? "stopped" : "running",
|
|
53
55
|
};
|
|
54
56
|
}
|
|
55
|
-
|
|
57
|
+
function legacyReadAgentRuns() {
|
|
56
58
|
const file = runFile();
|
|
57
59
|
try {
|
|
58
60
|
if (!existsSync(file)) {
|
|
@@ -98,13 +100,157 @@ export function readAgentRuns() {
|
|
|
98
100
|
return { updatedAt: new Date().toISOString(), runs: {} };
|
|
99
101
|
}
|
|
100
102
|
}
|
|
103
|
+
function rowToRecord(row) {
|
|
104
|
+
return normalizeRecord({
|
|
105
|
+
runId: row.run_id,
|
|
106
|
+
agentId: row.agent_id,
|
|
107
|
+
pid: typeof row.pid === "number" ? row.pid : null,
|
|
108
|
+
message: row.message,
|
|
109
|
+
provider: row.provider,
|
|
110
|
+
model: row.model,
|
|
111
|
+
initiativeId: row.initiative_id,
|
|
112
|
+
initiativeTitle: row.initiative_title,
|
|
113
|
+
workstreamId: row.workstream_id,
|
|
114
|
+
taskId: row.task_id,
|
|
115
|
+
startedAt: row.started_at,
|
|
116
|
+
stoppedAt: row.stopped_at,
|
|
117
|
+
status: row.status === "stopped" ? "stopped" : "running",
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
function writeAgentRunRecord(record) {
|
|
121
|
+
const normalized = normalizeRecord(record);
|
|
122
|
+
getStateDb()
|
|
123
|
+
.prepare(`INSERT INTO agent_runs (
|
|
124
|
+
run_id,
|
|
125
|
+
agent_id,
|
|
126
|
+
pid,
|
|
127
|
+
message,
|
|
128
|
+
provider,
|
|
129
|
+
model,
|
|
130
|
+
initiative_id,
|
|
131
|
+
initiative_title,
|
|
132
|
+
workstream_id,
|
|
133
|
+
task_id,
|
|
134
|
+
started_at,
|
|
135
|
+
stopped_at,
|
|
136
|
+
status,
|
|
137
|
+
updated_at
|
|
138
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
139
|
+
ON CONFLICT(run_id) DO UPDATE SET
|
|
140
|
+
agent_id = excluded.agent_id,
|
|
141
|
+
pid = excluded.pid,
|
|
142
|
+
message = excluded.message,
|
|
143
|
+
provider = excluded.provider,
|
|
144
|
+
model = excluded.model,
|
|
145
|
+
initiative_id = excluded.initiative_id,
|
|
146
|
+
initiative_title = excluded.initiative_title,
|
|
147
|
+
workstream_id = excluded.workstream_id,
|
|
148
|
+
task_id = excluded.task_id,
|
|
149
|
+
started_at = excluded.started_at,
|
|
150
|
+
stopped_at = excluded.stopped_at,
|
|
151
|
+
status = excluded.status,
|
|
152
|
+
updated_at = excluded.updated_at`)
|
|
153
|
+
.run(normalized.runId, normalized.agentId, normalized.pid, normalized.message, normalized.provider, normalized.model, normalized.initiativeId, normalized.initiativeTitle, normalized.workstreamId, normalized.taskId, normalized.startedAt, normalized.stoppedAt, normalized.status, new Date().toISOString());
|
|
154
|
+
}
|
|
155
|
+
function pruneAgentRuns() {
|
|
156
|
+
getStateDb()
|
|
157
|
+
.prepare(`DELETE FROM agent_runs
|
|
158
|
+
WHERE run_id NOT IN (
|
|
159
|
+
SELECT run_id
|
|
160
|
+
FROM agent_runs
|
|
161
|
+
ORDER BY started_at DESC, updated_at DESC
|
|
162
|
+
LIMIT ?
|
|
163
|
+
)`)
|
|
164
|
+
.run(MAX_RUNS);
|
|
165
|
+
}
|
|
166
|
+
function ensureAgentRunStoreMigrated() {
|
|
167
|
+
const migrated = readStateMeta(AGENT_RUN_IMPORT_META_KEY);
|
|
168
|
+
if (migrated)
|
|
169
|
+
return;
|
|
170
|
+
const countRow = getStateDb()
|
|
171
|
+
.prepare("SELECT COUNT(*) AS count FROM agent_runs")
|
|
172
|
+
.get();
|
|
173
|
+
if ((countRow?.count ?? 0) > 0) {
|
|
174
|
+
writeStateMeta(AGENT_RUN_IMPORT_META_KEY, true);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
const legacy = legacyReadAgentRuns();
|
|
178
|
+
const records = Object.values(legacy.runs)
|
|
179
|
+
.map((record) => normalizeRecord(record))
|
|
180
|
+
.filter((record) => Boolean(record.runId) && Boolean(record.agentId));
|
|
181
|
+
const transaction = getStateDb().transaction((items) => {
|
|
182
|
+
for (const item of items) {
|
|
183
|
+
writeAgentRunRecord(item);
|
|
184
|
+
}
|
|
185
|
+
pruneAgentRuns();
|
|
186
|
+
writeStateMeta(AGENT_RUN_IMPORT_META_KEY, true);
|
|
187
|
+
});
|
|
188
|
+
transaction(records);
|
|
189
|
+
}
|
|
190
|
+
function readAgentRunRows(limit = MAX_RUNS) {
|
|
191
|
+
ensureAgentRunStoreMigrated();
|
|
192
|
+
return getStateDb()
|
|
193
|
+
.prepare(`SELECT
|
|
194
|
+
run_id,
|
|
195
|
+
agent_id,
|
|
196
|
+
pid,
|
|
197
|
+
message,
|
|
198
|
+
provider,
|
|
199
|
+
model,
|
|
200
|
+
initiative_id,
|
|
201
|
+
initiative_title,
|
|
202
|
+
workstream_id,
|
|
203
|
+
task_id,
|
|
204
|
+
started_at,
|
|
205
|
+
stopped_at,
|
|
206
|
+
status,
|
|
207
|
+
updated_at
|
|
208
|
+
FROM agent_runs
|
|
209
|
+
ORDER BY started_at DESC, updated_at DESC
|
|
210
|
+
LIMIT ?`)
|
|
211
|
+
.all(Math.max(1, limit));
|
|
212
|
+
}
|
|
213
|
+
export function readAgentRuns() {
|
|
214
|
+
const rows = readAgentRunRows();
|
|
215
|
+
const runs = {};
|
|
216
|
+
let updatedAt = new Date(0).toISOString();
|
|
217
|
+
for (const row of rows) {
|
|
218
|
+
const record = rowToRecord(row);
|
|
219
|
+
runs[record.runId] = record;
|
|
220
|
+
if (Date.parse(row.updated_at) > Date.parse(updatedAt)) {
|
|
221
|
+
updatedAt = row.updated_at;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return {
|
|
225
|
+
updatedAt: rows.length > 0 ? updatedAt : new Date().toISOString(),
|
|
226
|
+
runs,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
101
229
|
export function getAgentRun(runId) {
|
|
102
230
|
const id = runId.trim();
|
|
103
231
|
if (!id)
|
|
104
232
|
return null;
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
|
|
233
|
+
ensureAgentRunStoreMigrated();
|
|
234
|
+
const row = getStateDb()
|
|
235
|
+
.prepare(`SELECT
|
|
236
|
+
run_id,
|
|
237
|
+
agent_id,
|
|
238
|
+
pid,
|
|
239
|
+
message,
|
|
240
|
+
provider,
|
|
241
|
+
model,
|
|
242
|
+
initiative_id,
|
|
243
|
+
initiative_title,
|
|
244
|
+
workstream_id,
|
|
245
|
+
task_id,
|
|
246
|
+
started_at,
|
|
247
|
+
stopped_at,
|
|
248
|
+
status,
|
|
249
|
+
updated_at
|
|
250
|
+
FROM agent_runs
|
|
251
|
+
WHERE run_id = ?`)
|
|
252
|
+
.get(id);
|
|
253
|
+
return row ? rowToRecord(row) : null;
|
|
108
254
|
}
|
|
109
255
|
export function upsertAgentRun(input) {
|
|
110
256
|
const runId = input.runId.trim();
|
|
@@ -113,12 +259,12 @@ export function upsertAgentRun(input) {
|
|
|
113
259
|
return readAgentRuns();
|
|
114
260
|
}
|
|
115
261
|
ensureRunDir();
|
|
116
|
-
|
|
117
|
-
const existing =
|
|
262
|
+
ensureAgentRunStoreMigrated();
|
|
263
|
+
const existing = getAgentRun(runId);
|
|
118
264
|
const startedAt = typeof input.startedAt === "string" && input.startedAt.trim().length > 0
|
|
119
265
|
? input.startedAt
|
|
120
266
|
: existing?.startedAt ?? new Date().toISOString();
|
|
121
|
-
|
|
267
|
+
const record = normalizeRecord({
|
|
122
268
|
runId,
|
|
123
269
|
agentId,
|
|
124
270
|
pid: input.pid ?? null,
|
|
@@ -133,27 +279,18 @@ export function upsertAgentRun(input) {
|
|
|
133
279
|
stoppedAt: input.stoppedAt ?? existing?.stoppedAt ?? null,
|
|
134
280
|
status: input.status ?? existing?.status ?? "running",
|
|
135
281
|
});
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
if (!keep.has(key)) {
|
|
143
|
-
delete next.runs[key];
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
const file = runFile();
|
|
148
|
-
writeJsonFileAtomicSync(file, next, 0o600);
|
|
149
|
-
return next;
|
|
282
|
+
const transaction = getStateDb().transaction((item) => {
|
|
283
|
+
writeAgentRunRecord(item);
|
|
284
|
+
pruneAgentRuns();
|
|
285
|
+
});
|
|
286
|
+
transaction(record);
|
|
287
|
+
return readAgentRuns();
|
|
150
288
|
}
|
|
151
289
|
export function markAgentRunStopped(runId) {
|
|
152
290
|
const id = runId.trim();
|
|
153
291
|
if (!id)
|
|
154
292
|
return null;
|
|
155
|
-
const
|
|
156
|
-
const existing = store.runs[id];
|
|
293
|
+
const existing = getAgentRun(id);
|
|
157
294
|
if (!existing)
|
|
158
295
|
return null;
|
|
159
296
|
const next = upsertAgentRun({
|
|
@@ -175,5 +312,6 @@ export function markAgentRunStopped(runId) {
|
|
|
175
312
|
return updated ? normalizeRecord(updated) : null;
|
|
176
313
|
}
|
|
177
314
|
export function clearAgentRuns() {
|
|
315
|
+
getStateDb().prepare("DELETE FROM agent_runs").run();
|
|
178
316
|
clearStoreFileSync(runFile());
|
|
179
317
|
}
|
package/dist/cli/orgx.d.ts
CHANGED
|
@@ -29,7 +29,10 @@ export interface HealthReport {
|
|
|
29
29
|
sync: {
|
|
30
30
|
serviceRunning: boolean;
|
|
31
31
|
inFlight: boolean;
|
|
32
|
+
backgroundInFlight: boolean;
|
|
32
33
|
lastSnapshotAt: string | null;
|
|
34
|
+
lastBackgroundSyncAt: string | null;
|
|
35
|
+
lastBackgroundSyncError: string | null;
|
|
33
36
|
};
|
|
34
37
|
outbox: {
|
|
35
38
|
pendingTotal: number;
|
|
@@ -15,6 +15,11 @@ export interface PluginApiLike {
|
|
|
15
15
|
dashboardEnabled: boolean;
|
|
16
16
|
}>;
|
|
17
17
|
};
|
|
18
|
+
"openclaw-plugin"?: {
|
|
19
|
+
config?: Partial<OrgXConfig & {
|
|
20
|
+
dashboardEnabled: boolean;
|
|
21
|
+
}>;
|
|
22
|
+
};
|
|
18
23
|
};
|
|
19
24
|
};
|
|
20
25
|
};
|
|
@@ -27,6 +32,8 @@ export declare function readOpenClawOrgxConfig(): {
|
|
|
27
32
|
apiKey: string;
|
|
28
33
|
userId: string;
|
|
29
34
|
baseUrl: string;
|
|
35
|
+
enabled?: boolean;
|
|
36
|
+
dashboardEnabled?: boolean;
|
|
30
37
|
};
|
|
31
38
|
export declare function resolvePluginVersion(): string;
|
|
32
39
|
export declare function resolveDocsUrl(baseUrl: string): string;
|
|
@@ -88,16 +88,22 @@ export function readOpenClawOrgxConfig() {
|
|
|
88
88
|
const entries = plugins.entries && typeof plugins.entries === "object"
|
|
89
89
|
? plugins.entries
|
|
90
90
|
: {};
|
|
91
|
-
const
|
|
91
|
+
const orgxEntry = entries.orgx && typeof entries.orgx === "object"
|
|
92
92
|
? entries.orgx
|
|
93
93
|
: {};
|
|
94
|
+
const openclawPluginEntry = entries["openclaw-plugin"] && typeof entries["openclaw-plugin"] === "object"
|
|
95
|
+
? entries["openclaw-plugin"]
|
|
96
|
+
: {};
|
|
97
|
+
const orgx = Object.keys(orgxEntry).length > 0 ? orgxEntry : openclawPluginEntry;
|
|
94
98
|
const config = orgx.config && typeof orgx.config === "object"
|
|
95
99
|
? orgx.config
|
|
96
100
|
: {};
|
|
97
101
|
const apiKey = typeof config.apiKey === "string" ? config.apiKey.trim() : "";
|
|
98
102
|
const userId = typeof config.userId === "string" ? config.userId.trim() : "";
|
|
99
103
|
const baseUrl = typeof config.baseUrl === "string" ? config.baseUrl.trim() : "";
|
|
100
|
-
|
|
104
|
+
const enabled = typeof orgx.enabled === "boolean" ? orgx.enabled : undefined;
|
|
105
|
+
const dashboardEnabled = typeof config.dashboardEnabled === "boolean" ? config.dashboardEnabled : undefined;
|
|
106
|
+
return { apiKey, userId, baseUrl, enabled, dashboardEnabled };
|
|
101
107
|
}
|
|
102
108
|
catch {
|
|
103
109
|
return { apiKey: "", userId: "", baseUrl: "" };
|
|
@@ -150,7 +156,9 @@ export function resolveDocsUrl(baseUrl) {
|
|
|
150
156
|
return DEFAULT_DOCS_URL;
|
|
151
157
|
}
|
|
152
158
|
export function resolveConfig(api, input) {
|
|
153
|
-
const pluginConf = api.config?.plugins?.entries?.orgx?.config ??
|
|
159
|
+
const pluginConf = api.config?.plugins?.entries?.orgx?.config ??
|
|
160
|
+
api.config?.plugins?.entries?.["openclaw-plugin"]?.config ??
|
|
161
|
+
{};
|
|
154
162
|
const openclaw = readOpenClawOrgxConfig();
|
|
155
163
|
const apiKeyResolution = resolveApiKey(pluginConf, input.persistedApiKey);
|
|
156
164
|
const apiKey = apiKeyResolution.value;
|
|
@@ -167,9 +175,9 @@ export function resolveConfig(api, input) {
|
|
|
167
175
|
userId,
|
|
168
176
|
baseUrl,
|
|
169
177
|
syncIntervalMs: pluginConf.syncIntervalMs ?? 300_000,
|
|
170
|
-
enabled: pluginConf.enabled ?? true,
|
|
178
|
+
enabled: pluginConf.enabled ?? openclaw.enabled ?? true,
|
|
171
179
|
autoInstallAgentSuiteOnConnect: pluginConf.autoInstallAgentSuiteOnConnect ?? true,
|
|
172
|
-
dashboardEnabled: pluginConf.dashboardEnabled ?? true,
|
|
180
|
+
dashboardEnabled: pluginConf.dashboardEnabled ?? openclaw.dashboardEnabled ?? true,
|
|
173
181
|
installationId: input.installationId,
|
|
174
182
|
pluginVersion: resolvePluginVersion(),
|
|
175
183
|
docsUrl: resolveDocsUrl(baseUrl),
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function mergeOnboardingState(previous, next) {
|
|
2
|
+
const preserveVerifiedContext = previous.hasApiKey && previous.connectionVerified;
|
|
3
|
+
const merged = {
|
|
4
|
+
...previous,
|
|
5
|
+
...next,
|
|
6
|
+
};
|
|
7
|
+
if (preserveVerifiedContext &&
|
|
8
|
+
(next.status === "pairing" || next.status === "awaiting_browser_auth")) {
|
|
9
|
+
merged.hasApiKey = true;
|
|
10
|
+
merged.connectionVerified = true;
|
|
11
|
+
merged.workspaceName = previous.workspaceName ?? next.workspaceName ?? null;
|
|
12
|
+
}
|
|
13
|
+
else if (!next.workspaceName && previous.workspaceName) {
|
|
14
|
+
merged.workspaceName = previous.workspaceName;
|
|
15
|
+
}
|
|
16
|
+
if ((!next.installationId || next.installationId.trim().length === 0) && previous.installationId) {
|
|
17
|
+
merged.installationId = previous.installationId;
|
|
18
|
+
}
|
|
19
|
+
if ((next.keySource === "none" || !next.keySource) && previous.keySource && previous.keySource !== "none") {
|
|
20
|
+
merged.keySource = previous.keySource;
|
|
21
|
+
}
|
|
22
|
+
return merged;
|
|
23
|
+
}
|
|
@@ -93,6 +93,7 @@ export interface LiveDecisionOption {
|
|
|
93
93
|
id: string;
|
|
94
94
|
label: string;
|
|
95
95
|
description: string | null;
|
|
96
|
+
consequences?: string | null;
|
|
96
97
|
impliedStatus: LiveDecisionOptionStatus | null;
|
|
97
98
|
actionType: DecisionActionType | null;
|
|
98
99
|
requiresNote: boolean;
|
|
@@ -241,6 +242,7 @@ export interface TriageAction {
|
|
|
241
242
|
consequences: string;
|
|
242
243
|
requiresNote: boolean;
|
|
243
244
|
available: boolean;
|
|
245
|
+
optionId?: string | null;
|
|
244
246
|
}
|
|
245
247
|
export interface ProofBundle {
|
|
246
248
|
artifactRefs: string[];
|
|
@@ -254,6 +256,20 @@ export interface TriageImpact {
|
|
|
254
256
|
workstreamCount: number;
|
|
255
257
|
downstreamBlockedCount: number;
|
|
256
258
|
}
|
|
259
|
+
export interface TriageInterventionContext {
|
|
260
|
+
blockerReason?: string | null;
|
|
261
|
+
waitingOn?: string | null;
|
|
262
|
+
requiredAction?: string | null;
|
|
263
|
+
requiredActor?: string | null;
|
|
264
|
+
retryable?: boolean | null;
|
|
265
|
+
errorCode?: string | null;
|
|
266
|
+
errorCategory?: string | null;
|
|
267
|
+
suggestedActions?: string[];
|
|
268
|
+
nextActions?: string[];
|
|
269
|
+
decisionIds?: string[];
|
|
270
|
+
taskUpdateCount?: number;
|
|
271
|
+
milestoneUpdateCount?: number;
|
|
272
|
+
}
|
|
257
273
|
export interface LiveTriageItem {
|
|
258
274
|
id: string;
|
|
259
275
|
kind: TriageItemKind;
|
|
@@ -274,6 +290,7 @@ export interface LiveTriageItem {
|
|
|
274
290
|
blocking: boolean;
|
|
275
291
|
recommendedAction: string | null;
|
|
276
292
|
agentId: string | null;
|
|
293
|
+
intervention?: TriageInterventionContext | null;
|
|
277
294
|
impact: TriageImpact;
|
|
278
295
|
proofBundle: ProofBundle;
|
|
279
296
|
actionContract: TriageAction[];
|