1import{a as e,p as s,A as a,z as t}from"./chunk-6CSD65Y2-xYubHBmU.js";import{G as l,H as r}from"./voiceStore-D_K9cjIr.js";import{s as n,f as d,t as i}from"./formatExecutionDate-B2Fx7Ep5.js";import{A as c}from"./AccountSelector-BUcIR6dl.js";import{O as o,Q as m,V as x,X as u,b as h,Y as j,J as p,aj as f,ak as g,al as v,am as N,an as w,br as b,Z as y,_,$ as k,G as C,A as S,I as D,B as E,R as L,co as A,cp as O,cq as R,cr as $,cs as z,ct as I,q as F,bM as P,cu as T,g as U,l as M,m as W,n as V,o as B,p as X}from"./CoreLayout-V9PVLCM0.js";import{L as q}from"./loader-circle-Mux4UJzI.js";import{U as G,P as J}from"./USTALogo-P-ie0qNe.js";import{W as Y}from"./WorkspaceMenu-DuxeUjKB.js";import{C as H,a as K,b as Q,c as Z}from"./card-C2UeeBp1.js";import{X as ee}from"./overlayFocus-BmDVzTk_.js";import{a as se}from"./index-BcwKVuK3.js";import"./index-BfJR_dAR.js";import"./createLucideIcon-B7UGDY3i.js";import"./command-C0bc47YX.js";import"./index-ATyz5JdO.js";import"./user-BccZgP0Q.js";import"./AdminRoute-YaPmKRZJ.js";import"./AuthContextDefinition-CrUuQ85U.js";const ae="all",te=[{value:ae,label:"Everything"},{value:"7",label:"Older than 7 days"},{value:"30",label:"Older than 30 days"},{value:"90",label:"Older than 90 days"}];function le({open:a,onOpenChange:t,onDeleted:r}){const[n,d]=e.useState(!1),[i,c]=e.useState(ae),[S,D]=e.useState(!1),[E,L]=e.useState(null);e.useEffect(()=>{a&&(d(!1),c(ae),L(null))},[a]);const A=te.find(e=>e.value===i)?.label.toLowerCase()??"everything";return s.jsx(o,{open:a,onOpenChange:t,children:s.jsxs(m,{children:[s.jsxs(x,{children:[s.jsxs(u,{className:"flex items-center gap-2",children:[s.jsx(h,{className:"w-5 h-5 text-destructive","aria-hidden":"true"}),"Delete execution data"]}),s.jsx(j,{children:"This permanently deletes execution history for this account, including the inputs and outputs recorded for every node. Downloaded logs are unaffected. This cannot be undone."})]}),s.jsxs("div",{className:"flex flex-col gap-4 py-2",children:[s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(p,{htmlFor:"purge-scope",children:"What to delete"}),s.jsxs(f,{value:i,onValueChange:c,disabled:S,children:[s.jsx(g,{id:"purge-scope",children:s.jsx(v,{placeholder:"Everything"})}),s.jsx(N,{children:te.map(e=>s.jsx(w,{value:e.value,children:e.label},e.value))})]})]}),s.jsxs("div",{className:"flex items-start gap-3 rounded-md border border-destructive/40 bg-destructive/5 p-3",children:[s.jsx(b,{id:"purge-acknowledge",checked:n,onCheckedChange:e=>d(!0===e),disabled:S,className:"mt-0.5"}),s.jsxs(p,{htmlFor:"purge-acknowledge",className:"text-sm font-normal leading-snug cursor-pointer",children:["I understand this permanently deletes ",A," and cannot be undone."]})]}),E&&s.jsx("p",{role:"alert",className:"text-sm text-destructive",children:E})]}),s.jsxs(y,{children:[s.jsx(_,{disabled:S,children:"Cancel"}),s.jsx(k,{onClick:e=>{e.preventDefault(),(async()=>{D(!0),L(null);try{const e=await l.delete("/executions/data",{data:{confirm:"DELETE",...i===ae?{}:{olderThanDays:Number(i)}}});r?.(e),t(!1)}catch(e){L(e?.response?.data?.error?.message||e?.message||"Could not delete execution data. Try again.")}finally{D(!1)}})()},disabled:!n||S,variant:"destructive",children:S?s.jsxs(s.Fragment,{children:[s.jsx(q,{className:"w-4 h-4 mr-2 animate-spin","aria-hidden":"true"}),"Deletingâ¦"]}):s.jsxs(s.Fragment,{children:[s.jsx(C,{className:"w-4 h-4 mr-2","aria-hidden":"true"}),"Delete data"]})})]})]})})}function re({type:e}){const a=i[e??"manual"]??i.manual;return s.jsxs(F,{variant:a.variant,className:"gap-1",children:[a.icon,a.label]})}function ne(){const i=a(),[o,m]=t(),[x,u]=e.useState([]),[h,j]=e.useState([]),[p,b]=e.useState({page:1,limit:20,total:0,pages:0}),[y,_]=e.useState(!0),[k,ae]=e.useState(!1),[te,ne]=e.useState(null),[de,ie]=e.useState(!1),[ce,oe]=e.useState(!1),[me,xe]=e.useState(""),[ue,he]=e.useState(o.get("status")||"all"),[je,pe]=e.useState(o.get("workflow")||"all"),[fe,ge]=e.useState(o.get("start_date")||""),[ve,Ne]=e.useState(o.get("end_date")||""),{currentAccountId:we}=r(),be=e.useCallback(async()=>{try{const e={};we&&(e["X-Account-ID"]=we);const s=await l.get("/workflows",void 0,{headers:e}),a=s.data||s.workflows||[];j(a.map(e=>({id:e.id,name:e.name})))}catch(e){}},[we]),ye=e.useCallback(async(e=1)=>{_(!0);try{const s={page:e,limit:p.limit,sort:"started_at",order:"desc"};ue&&"all"!==ue&&(s.status=ue),je&&"all"!==je&&(s.workflow_id=je),fe&&(s.start_date=new Date(fe).toISOString()),ve&&(s.end_date=new Date(ve).toISOString());const a={};we&&(a["X-Account-ID"]=we);const t=await l.get("/executions",s,{headers:a});u(t.executions||[]),b(t.pagination||{page:1,limit:20,total:0,pages:0})}catch(s){u([])}finally{_(!1),ae(!1)}},[ue,je,fe,ve,p.limit,we]);e.useEffect(()=>{be()},[be]),e.useEffect(()=>{ye(1)},[ye,we]),e.useEffect(()=>{const e=new URLSearchParams;ue&&"all"!==ue&&e.set("status",ue),je&&"all"!==je&&e.set("workflow",je),fe&&e.set("start_date",fe),ve&&e.set("end_date",ve),m(e,{replace:!0})},[ue,je,fe,ve,m]);const _e=e=>{ye(e)},ke=e=>{const s={id:e.id,workflow:e.workflow_name,status:e.status,started_at:e.started_at,completed_at:e.completed_at,duration_ms:e.duration_ms,inputs:e.inputs,outputs:e.outputs,error:e.error_message},a=new Blob([JSON.stringify(s,null,2)],{type:"application/json"}),t=URL.createObjectURL(a),l=document.createElement("a");l.href=t,l.download=`execution-${e.id}.json`,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(t)},Ce=e=>{i(`/core/flow/${e}`)},Se=e=>{if(!e)return"-";const s=Math.floor(e/1e3),a=Math.floor(s/60),t=Math.floor(a/60);return t>0?`${t}h ${a%60}m`:a>0?`${a}m ${s%60}s`:`${s}s`},De=x.filter(e=>""===me||e.workflow_name?.toLowerCase().includes(me.toLowerCase())||e.id.toLowerCase().includes(me.toLowerCase())),Ee="all"!==ue||"all"!==je||fe||ve;return s.jsxs("div",{className:"h-screen flex flex-col bg-[hsl(var(--background))] [--placeholder-foreground:var(--muted-foreground)]",children:[s.jsx("div",{className:"border-b bg-[hsl(var(--muted))] shrink-0",children:s.jsx("div",{className:"max-w-[1400px] mx-auto px-4 py-3 sm:px-6 sm:py-4",children:s.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2 sm:flex sm:gap-3",children:[s.jsx(G,{size:"md"}),s.jsx("div",{className:"min-w-0 [&_button]:h-11 sm:[&_button]:h-9",children:s.jsx(Y,{currentPage:"executions"})}),s.jsx("div",{className:"order-last col-span-3 min-w-0 sm:order-none",children:s.jsx(c,{className:"h-11 w-full sm:h-9 sm:w-auto"})}),s.jsx("div",{className:"justify-self-end sm:ml-auto [&_button]:h-11 [&_button]:w-11 sm:[&_button]:h-9 sm:[&_button]:w-9",children:s.jsx(J,{})})]})})}),s.jsx("div",{className:"flex-1 overflow-auto",children:s.jsxs("div",{className:"max-w-[1400px] mx-auto px-6 py-6",children:[s.jsxs("div",{className:"mb-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[s.jsx(S,{className:"w-6 h-6 text-primary"}),s.jsx("h1",{className:"text-2xl font-semibold text-foreground",children:"Execution Logs"})]}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Monitor and review workflow execution history"})]}),s.jsx(H,{className:"mb-6",children:s.jsx(K,{className:"pt-6",children:s.jsxs("div",{className:"flex flex-wrap gap-4 items-end",children:[s.jsxs("div",{className:"flex-1 min-w-[200px]",children:[s.jsx("label",{className:"text-sm font-medium text-foreground mb-1.5 block",children:"Search"}),s.jsx("div",{className:"relative",children:s.jsx(D,{icon:"Search",placeholder:"Search by workflow name or ID...",value:me,onChange:e=>xe(e.target.value)})})]}),s.jsxs("div",{className:"w-[200px]",children:[s.jsx("label",{className:"text-sm font-medium text-foreground mb-1.5 block",children:"Workflow"}),s.jsxs(f,{value:je,onValueChange:pe,children:[s.jsx(g,{children:s.jsx(v,{placeholder:"All workflows"})}),s.jsxs(N,{children:[s.jsx(w,{value:"all",children:"All workflows"}),h.map(e=>s.jsx(w,{value:e.id,children:e.name},e.id))]})]})]}),s.jsxs("div",{className:"w-[160px]",children:[s.jsx("label",{className:"text-sm font-medium text-foreground mb-1.5 block",children:"Status"}),s.jsxs(f,{value:ue,onValueChange:he,children:[s.jsx(g,{children:s.jsx(v,{placeholder:"All statuses"})}),s.jsxs(N,{children:[s.jsx(w,{value:"all",children:"All statuses"}),s.jsx(w,{value:"pending",children:"Pending"}),s.jsx(w,{value:"running",children:"Running"}),s.jsx(w,{value:"completed",children:"Completed"}),s.jsx(w,{value:"partial",children:"Partial"}),s.jsx(w,{value:"failed",children:"Failed"}),s.jsx(w,{value:"cancelled",children:"Cancelled"})]})]})]}),s.jsxs("div",{className:"w-[160px]",children:[s.jsx("label",{className:"text-sm font-medium text-foreground mb-1.5 block",children:"Start Date"}),s.jsx(D,{type:"date",value:fe,onChange:e=>ge(e.target.value)})]}),s.jsxs("div",{className:"w-[160px]",children:[s.jsx("label",{className:"text-sm font-medium text-foreground mb-1.5 block",children:"End Date"}),s.jsx(D,{type:"date",value:ve,onChange:e=>Ne(e.target.value)})]}),s.jsxs("div",{className:"flex flex-wrap gap-2 [--ui-control-shadow:0_1px_2px_rgb(0_0_0_/_0.06)]",children:[Ee&&s.jsxs(E,{variant:"outline",size:"sm",className:"h-10 border-[hsl(var(--muted-foreground))] bg-[hsl(var(--card))] text-sm",onClick:()=>{he("all"),pe("all"),ge(""),Ne(""),xe("")},children:[s.jsx(ee,{className:"w-4 h-4 mr-1"}),"Clear"]}),s.jsxs(E,{variant:"outline",size:"sm",className:"h-10 border-[hsl(var(--muted-foreground))] bg-[hsl(var(--card))] text-sm",onClick:()=>{ae(!0),ye(p.page)},disabled:k,children:[s.jsx(L,{className:"w-4 h-4 mr-1 "+(k?"animate-spin":"")}),"Refresh"]}),s.jsxs(E,{variant:"outline",size:"sm",onClick:()=>oe(!0),className:"h-10 border-red-700 bg-[hsl(var(--card))] text-sm text-red-700 hover:bg-red-50 hover:text-red-700 dark:border-red-300 dark:text-red-300 dark:hover:bg-red-950 dark:hover:text-red-300",children:[s.jsx(C,{className:"w-4 h-4 mr-1"}),"Delete Data"]})]})]})})}
1),s.jsxs(H,{children:[s.jsx(Q,{className:"pb-3",children:s.jsx("div",{className:"flex justify-between items-center",children:s.jsxs(Z,{className:"text-lg",children:["Executions",p.total>0&&s.jsxs("span",{className:"text-sm font-normal text-muted-foreground ml-2",children:["(",p.total," total)"]})]})})}),s.jsx(K,{children:y?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(q,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):0===De.length?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[s.jsx(S,{className:"w-12 h-12 text-muted-foreground/50 mb-4"}),s.jsx("h3",{className:"text-lg font-medium text-foreground mb-1",children:"No executions found"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:Ee?"Try adjusting your filters":"Run a workflow to see execution logs here"})]}):s.jsxs(s.Fragment,{children:[s.jsxs(A,{children:[s.jsx(O,{className:"bg-muted/30",children:s.jsxs(R,{children:[s.jsx($,{children:"Workflow"}),s.jsx($,{children:"Status"}),s.jsx($,{children:"Source"}),s.jsx($,{children:"Started"}),s.jsx($,{children:"Duration"}),s.jsx($,{children:"Nodes"}),s.jsx($,{children:"Cost"}),s.jsx($,{className:"text-right",children:"Actions"})]})}),s.jsx(z,{children:De.map(e=>{const a=n[e.status]||n.pending;return s.jsxs(R,{className:"hover:bg-accent/5",children:[s.jsxs(I,{children:[s.jsxs("button",{onClick:()=>Ce(e.workflow_id),className:"text-left hover:underline",children:[s.jsx("div",{className:"font-medium",children:e.workflow_name}),s.jsxs("div",{className:"text-xs text-muted-foreground",children:[e.id.slice(0,8),"..."]})]}),e.dry_run&&s.jsx(F,{variant:"outline",className:"text-[9px] text-yellow-600 dark:text-yellow-400 border-yellow-500/40 mt-1",children:"Dry Run"})]}),s.jsx(I,{children:s.jsxs(F,{variant:a.variant,className:"gap-1",children:[a.icon,a.label]})}),s.jsx(I,{children:s.jsx(re,{type:e.trigger_type})}),s.jsx(I,{children:s.jsx("div",{className:"text-sm",children:d(e.started_at)})}),s.jsx(I,{children:s.jsx("div",{className:"text-sm",children:Se(e.duration_ms)})}),s.jsx(I,{children:s.jsxs("div",{className:"text-sm",children:[e.nodes_completed||0,"/",e.node_count||0,(e.nodes_failed||0)>0&&s.jsxs("span",{className:"text-red-600 ml-1",children:["(",e.nodes_failed," failed)"]})]})}),s.jsx(I,{children:s.jsx("div",{className:"text-sm",children:null!=e.cost_usd?`$${Number(e.cost_usd).toFixed(4)}`:"-"})}),s.jsx(I,{className:"text-right",children:s.jsxs("div",{className:"flex justify-end gap-1",children:[s.jsx(E,{variant:"ghost",size:"sm",onClick:()=>(async e=>{try{const s=await l.get(`/executions/${e.id}`),a=s?.data||s;a&&(ne(a),ie(!0))}catch(s){}})(e),className:"h-8 w-8 p-0",children:s.jsx(se,{className:"w-4 h-4"})}),s.jsx(E,{variant:"ghost",size:"sm",onClick:()=>ke(e),className:"h-8 w-8 p-0",children:s.jsx(P,{className:"w-4 h-4"})})]})})]},e.id)})})]}),p.pages>1&&s.jsxs("div",{className:"flex items-center justify-between mt-4 pt-4 border-t",children:[s.jsxs("div",{className:"text-sm text-muted-foreground",children:["Page ",p.page," of ",p.pages]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(E,{variant:"outline",size:"sm",onClick:()=>_e(p.page-1),disabled:p.page<=1,children:[s.jsx(T,{className:"w-4 h-4"}),"Previous"]}),s.jsxs(E,{variant:"outline",size:"sm",onClick:()=>_e(p.page+1),disabled:p.page>=p.pages,children:["Next",s.jsx(U,{className:"w-4 h-4"})]})]})]})]})})]})]})}),s.jsx(M,{open:de,onOpenChange:ie,children:s.jsxs(W,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[s.jsxs(V,{children:[s.jsx(B,{children:"Execution Details"}),s.jsxs(X,{children:[te?.workflow_name," - ",te?.id.slice(0,8),"..."]})]}),te&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:"Status"}),s.jsx("div",{className:"mt-1",children:s.jsxs(F,{variant:n[te.status]?.variant||"secondary",children:[n[te.status]?.icon,s.jsx("span",{className:"ml-1",children:n[te.status]?.label})]})})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:"Source"}),s.jsx("div",{className:"mt-1",children:s.jsx(re,{type:te.trigger_type})})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:"Duration"}),s.jsx("div",{className:"mt-1 text-sm",children:Se(te.duration_ms)})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:"Started"}),s.jsx("div",{className:"mt-1 text-sm",children:d(te.started_at)})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:"Completed"}),s.jsx("div",{className:"mt-1 text-sm",children:te.completed_at?d(te.completed_at):"-"})]})]}),te.error_message&&s.jsxs("div",{children:[s.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:"Error"}),s.jsx("div",{className:"mt-1 p-3 bg-destructive/10 text-destructive rounded-md text-sm",children:te.error_message})]}),te.node_summary&&te.node_summary.length>0&&s.jsxs("div",{children:[s.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:"Node Executions"}),s.jsx("div",{className:"mt-2 space-y-2",children:te.node_summary.map((e,a)=>s.jsxs("div",{className:"flex items-center justify-between p-2 bg-muted rounded-md",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium",children:e.node_id}),s.jsx("div",{className:"text-xs text-muted-foreground",children:e.node_type})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:Se(e.duration_ms)}),s.jsx(F,{variant:"completed"===e.status?"outline":"failed"===e.status?"destructive":"secondary",className:"text-xs",children:e.status})]})]},a))})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[s.jsxs(E,{variant:"outline",onClick:()=>ke(te),children:[s.jsx(P,{className:"w-4 h-4 mr-2"}),"Download Log"]}),s.jsx(E,{onClick:()=>Ce(te.workflow_id),children:"Open Workflow"})]})]})]})}),s.jsx(le,{open:ce,onOpenChange:oe,onDeleted:()=>ye(1)})]})}export{ne as ExecutionLogsPage,ne as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.