import{d as m,c as x,u as b,r as y,e as v,f as s,C as l,B as f,n as C,K as B,a7 as h,ab as k}from"./index-a0da86f0.js";import{_ as E}from"./_plugin-vue_export-helper-c27b6911.js";const F=["title"],S=["title"],I=["title","disabled"],M=["title"],N=["title"],O=m({__name:"local_ai_agent_list_actions",props:{context:{}},setup(p){const o=p,w=x(()=>(o.context.viewMode||"list")==="card"?"actions-container card-actions":"actions-container col-actions"),i=b(),r=y(!1);async function _(){var e;try{r.value=!0;const t=o.context.row.name,n=o.context.row.agent_name||"",c=await(await fetch("/jingrow/agents/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent_id:t,agent_name:n,session_cookie:(e=document.cookie.split("; ").find(a=>a.startsWith("sid=")))==null?void 0:e.split("=")[1]})})).json();c.success?i.success(o.context.t("Agent execution started successfully")):i.error(c.message||o.context.t("Execution failed"))}catch(t){i.error((t==null?void 0:t.message)||o.context.t("Execution failed"))}finally{r.value=!1}}async function g(){var e;try{const t=o.context.row.name;let n={};if(o.context.row.agent_flow!==void 0&&o.context.row.agent_flow!==null){const a=o.context.row.agent_flow;if(n=a,typeof a=="string")try{n=JSON.parse(a)}catch{n={}}}else try{const d=(((e=(await B.get(`/api/data/${encodeURIComponent(o.context.entity)}/${encodeURIComponent(t)}`,{headers:h(),withCredentials:!0})).data)==null?void 0:e.data)||{}).agent_flow??{};if(n=d,typeof d=="string")try{n=JSON.parse(d)}catch{n={}}}catch(a){console.error("获取智能体数据失败:",a),i.error(o.context.t("Failed to load agent data"));return}const{useFlowBuilderStore:u}=await k(()=>import("./flowBuilder-c7c3e16b.js"),["assets/flowBuilder-c7c3e16b.js","assets/index-a0da86f0.js","assets/index-1c27c26c.css"]);u().activateFlowBuilder(n,t),o.context.router.push({name:"FlowBuilder",query:{agentId:t}})}catch(t){console.error("打开流程编排失败:",t),i.error((t==null?void 0:t.message)||o.context.t("Failed to open flow builder"))}}return(e,t)=>(C(),v("div",{class:f(w.value)},[s("button",{class:"action-btn",onClick:t[0]||(t[0]=l(n=>e.context.openDetail(e.context.row.name),["stop"])),title:e.context.t("View")},[...t[3]||(t[3]=[s("i",{class:"fa fa-eye"},null,-1)])],8,F),s("button",{class:"action-btn",onClick:t[1]||(t[1]=l(n=>e.context.editRecord(e.context.row),["stop"])),title:e.context.t("Edit")},[...t[4]||(t[4]=[s("i",{class:"fa fa-edit"},null,-1)])],8,S),s("button",{class:"action-btn execute-btn",onClick:l(_,["stop"]),title:e.context.t("Execute"),disabled:r.value},[s("i",{class:f(r.value?"fa fa-spinner fa-spin":"fa fa-play")},null,2)],8,I),s("button",{class:"action-btn flow-builder-btn",onClick:l(g,["stop"]),title:e.context.t("Flow Builder")},[...t[5]||(t[5]=[s("i",{class:"fa fa-sitemap"},null,-1)])],8,M),s("button",{class:"action-btn delete-btn",onClick:t[2]||(t[2]=l(n=>e.context.deleteRecord(e.context.row.name),["stop"])),title:e.context.t("Delete")},[...t[6]||(t[6]=[s("i",{class:"fa fa-trash"},null,-1)])],8,N)],2))}});const j=E(O,[["__scopeId","data-v-8a1e46b7"]]);export{j as default};
