@aheart-ui/ai 1.1.0 → 1.2.0

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),v=require("aheart-ui"),ne=require("@aheart-ui/dnd/sortable"),J=require("./safe-markdown.js"),se={class:"aheart-ai-workbench__execution-content"},ce={key:0,class:"aheart-ai-workbench__mobile-priority",role:"region","aria-label":"移动端优先处理"},ie={class:"aheart-ai-workbench__priority-heading"},de={class:"aheart-ai-workbench__eyebrow"},pe={key:0},ue={key:1},ke={key:0,class:"aheart-ai-workbench__priority-approval"},me={key:0},ve={class:"aheart-ai-workbench__priority-actions"},_e={key:1,class:"aheart-ai-workbench__approval-result"},ye=["aria-label"],he={key:0},be=["aria-label"],ge={key:0},Be=["aria-labelledby"],Ne={class:"aheart-ai-workbench__section-heading"},Ve=["id"],Ee={class:"aheart-ai-workbench__timeline"},fe=["data-task-id"],Ce={class:"aheart-ai-workbench__task-body"},we={class:"aheart-ai-workbench__task-summary"},Se={key:0,class:"aheart-ai-workbench__tool-name"},De={class:"aheart-ai-workbench__task-status"},$e={key:0,class:"aheart-ai-workbench__task-detail"},xe={key:1,class:"aheart-ai-workbench__tool-call","aria-label":"工具调用摘要"},je={key:0},Ae={key:1},Te={key:2},Me={key:2,class:"aheart-ai-workbench__task-lock-reason",role:"status"},Ie={key:3,class:"aheart-ai-workbench__task-lock-reason",role:"status"},ze={key:4,class:"aheart-ai-workbench__task-lock-reason",role:"status"},Ke={key:5,class:"aheart-ai-workbench__task-progress"},Re=["aria-valuenow"],Le={key:6,class:"aheart-ai-workbench__task-time"},Fe={key:0},qe={key:1},Ue={key:7,class:"aheart-ai-workbench__task-error"},He={class:"aheart-ai-workbench__task-actions"},Pe={key:8,class:"aheart-ai-workbench__operation-status",role:"status"},Oe=["data-approval-id"],We={key:0},Ze={key:1,class:"aheart-ai-workbench__approval-result"},Ge={key:0,class:"aheart-ai-workbench__empty"},Je=["aria-labelledby"],Qe={class:"aheart-ai-workbench__section-heading"},Xe=["id"],Ye={key:0,class:"aheart-ai-workbench__artifact-list"},et=["data-artifact-id"],tt=["aria-pressed","onClick"],at={key:0},ot={key:1,class:"aheart-ai-workbench__empty"},lt={key:2,class:"aheart-ai-workbench__artifact-preview","aria-label":"产物预览"},rt={class:"aheart-ai-workbench__artifact-preview-header"},nt=["href"],st={key:0},ct=e.defineComponent({name:"AIAgentWorkbenchExecution",__name:"agent-execution",props:{tasks:{default:()=>[]},artifacts:{default:()=>[]},activeArtifact:{default:void 0},disabled:{type:Boolean,default:!1},reorderable:{type:Boolean,default:!0},tasksRevision:{},scopeKey:{default:"default"},actionDisabled:{type:Function,default:()=>!1},operationMessages:{default:()=>({})},validateCandidate:{type:Function,default:()=>{}}},emits:["update:tasks","approve","reject","cancel","retry","move-task","move-task-reject","select-artifact"],setup(i,{emit:Q}){const r=i,C=e.computed(()=>`aheart-agent-execution-${String(r.scopeKey??"default").replace(/[^a-zA-Z0-9_-]/g,"-")}`),w=e.computed(()=>`${C.value}-tasks`),S=e.computed(()=>`${C.value}-artifacts`),d=Q,X={pending:"等待执行",running:"执行中","waiting-approval":"等待审批",complete:"已完成",error:"执行失败",cancelled:"已取消"},Y=e.computed(()=>r.tasks.map((o,l)=>({...o,__sortableKey:`${o.id}::${l}`}))),n=e.computed(()=>r.artifacts.find(o=>o.id===r.activeArtifact)??r.artifacts[0]),s=e.computed(()=>r.tasks.find(o=>o.approval&&(!o.approval.status||o.approval.status==="pending"))??r.tasks.find(o=>o.approval)),_=e.computed(()=>r.artifacts.find(o=>{var l,c;return o.id===((c=(l=s.value)==null?void 0:l.approval)==null?void 0:c.artifactId)})??n.value),ee=e.computed(()=>{var o;return(o=s.value)!=null&&o.approval&&(!s.value.approval.status||s.value.approval.status==="pending")?"等待审批":s.value?"审批结果":"当前产物"}),a=o=>o,p=o=>o.toolCall,N=o=>{var l;return`${o.id}:${String(o.revision??"")}:${((l=o.approval)==null?void 0:l.id)??""}`},te=o=>{d("move-task-reject",{"stale-revision":"任务版本已变化,排序已拒绝","source-missing":"源任务已不存在,排序已拒绝","target-missing":"目标位置已不存在,排序已拒绝","duplicate-key":"任务标识重复,无法排序","group-mismatch":"任务不属于当前排序分组",disabled:"任务当前不可排序,排序已拒绝","invalid-position":"目标位置无效,排序已拒绝","parent-rejected":"任务版本已变化,排序已拒绝","rollback-rejected":"排序回滚失败,请刷新后重试",unmounted:"排序目标已卸载",cancelled:"排序已取消"}[o.reason??""]??"任务当前不可排序,排序已拒绝")},ae=o=>X[o],oe=o=>o.status,le=o=>ae(o.status),V=o=>Math.min(100,Math.max(0,Math.round(o??0))),re=o=>{var l;if(!r.disabled&&r.reorderable){const c=o.map(({__sortableKey:b,...h})=>h),k=(l=r.validateCandidate)==null?void 0:l.call(r,c);if(k){d("move-task-reject",k);return}d("update:tasks",c)}},D=(o,l)=>{var h;if(E(r.tasks[o],o,l))return;const c=[...r.tasks],[k]=c.splice(o,1);c.splice(o+l,0,k);const b=(h=r.validateCandidate)==null?void 0:h.call(r,c);if(b){d("move-task-reject",b);return}d("update:tasks",c),d("move-task",k.id,l<0?"up":"down")},y=(o,l)=>{var c;return r.disabled||!!((c=r.actionDisabled)!=null&&c.call(r,o,l))},E=(o,l,c)=>!!(r.disabled||!r.reorderable||l+c<0||l+c>=r.tasks.length||(o==null?void 0:o.reorderable)===!1||o!=null&&o.lockedReason||(o==null?void 0:o.status)==="running"||(o==null?void 0:o.status)==="waiting-approval");return(o,l)=>{var c,k,b,h,$,x;return e.openBlock(),e.createElementBlock("div",se,[s.value||n.value?(e.openBlock(),e.createElementBlock("section",ce,[e.createElementVNode("div",ie,[e.createElementVNode("span",de,e.toDisplayString(ee.value),1),s.value?(e.openBlock(),e.createElementBlock("strong",pe,e.toDisplayString((c=s.value.approval)==null?void 0:c.title),1)):(e.openBlock(),e.createElementBlock("strong",ue,"查看当前产物"))]),s.value?(e.openBlock(),e.createElementBlock("div",ke,[(k=s.value.approval)!=null&&k.description?(e.openBlock(),e.createElementBlock("p",me,e.toDisplayString(s.value.approval.description),1)):e.createCommentVNode("",!0),e.createElementVNode("div",ve,[!((b=s.value.approval)!=null&&b.status)||s.value.approval.status==="pending"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(e.unref(v.Button),{"data-action":"approve",type:"primary",disabled:y(s.value,"approve"),onClick:l[0]||(l[0]=t=>d("approve",s.value))},{default:e.withCtx(()=>[...l[4]||(l[4]=[e.createTextVNode("批准",-1)])]),_:1},8,["disabled"]),e.createVNode(e.unref(v.Button),{"data-action":"reject",danger:"",disabled:y(s.value,"reject"),onClick:l[1]||(l[1]=t=>d("reject",s.value))},{default:e.withCtx(()=>[...l[5]||(l[5]=[e.createTextVNode("拒绝",-1)])]),_:1},8,["disabled"])],64)):(e.openBlock(),e.createElementBlock("span",_e,e.toDisplayString(s.value.approval.status==="approved"?"已批准":"已拒绝"),1))])])):e.createCommentVNode("",!0),_.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"aheart-ai-workbench__priority-artifact","data-artifact-role":"approval","aria-label":_.value.title,onClick:l[2]||(l[2]=t=>d("select-artifact",_.value))},[e.createElementVNode("span",null,e.toDisplayString(($=(h=s.value)==null?void 0:h.approval)!=null&&$.artifactId?"审批对象":"当前产物"),1),e.createElementVNode("strong",null,e.toDisplayString(_.value.title),1),_.value.description?(e.openBlock(),e.createElementBlock("small",he,e.toDisplayString(_.value.description),1)):e.createCommentVNode("",!0)],8,ye)):e.createCommentVNode("",!0),n.value&&n.value.id!==((x=_.value)==null?void 0:x.id)?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:"aheart-ai-workbench__priority-artifact","data-artifact-role":"current","aria-label":n.value.title,onClick:l[3]||(l[3]=t=>d("select-artifact",n.value))},[l[6]||(l[6]=e.createElementVNode("span",null,"当前产物",-1)),e.createElementVNode("strong",null,e.toDisplayString(n.value.title),1),n.value.description?(e.openBlock(),e.createElementBlock("small",ge,e.toDisplayString(n.value.description),1)):e.createCommentVNode("",!0)],8,be)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createElementVNode("section",{class:"aheart-ai-workbench__tasks","aria-labelledby":w.value},[e.createElementVNode("div",Ne,[e.createElementVNode("div",null,[l[7]||(l[7]=e.createElementVNode("span",{class:"aheart-ai-workbench__eyebrow"},"执行流程",-1)),e.createElementVNode("h2",{id:w.value},"执行时间线",8,Ve)]),e.createElementVNode("span",null,e.toDisplayString(i.tasks.length)+" 项",1)]),e.createElementVNode("div",Ee,[e.createVNode(e.unref(ne.SortableList),{items:Y.value,"item-key":"__sortableKey",disabled:i.disabled||!i.reorderable,revision:i.tasksRevision,group:`agent-tasks-${i.scopeKey}`,"onUpdate:items":re,onMoveReject:te},{item:e.withCtx(({item:t,index:m})=>[e.renderSlot(o.$slots,"task",{task:a(t),index:m},()=>{var g,f,j,A,T,M,I,z,K,R,L,F,q,U,H,P,O,W,Z,G;return[e.createElementVNode("article",{"data-task-id":a(t).id,class:e.normalizeClass(["aheart-ai-workbench__timeline-item",[`is-${oe(a(t))}`,{"has-approval-summary":!!a(t).approval}]])},[l[15]||(l[15]=e.createElementVNode("span",{class:"aheart-ai-workbench__timeline-marker","aria-hidden":"true"},null,-1)),e.createElementVNode("div",Ce,[e.createElementVNode("header",we,[e.createElementVNode("div",null,[e.createElementVNode("strong",null,e.toDisplayString(a(t).label),1),a(t).toolName?(e.openBlock(),e.createElementBlock("span",Se,e.toDisplayString(a(t).toolName),1)):e.createCommentVNode("",!0)]),e.createElementVNode("span",De,e.toDisplayString(le(a(t))),1)]),a(t).detail&&!p(a(t))?(e.openBlock(),e.createElementBlock("p",$e,e.toDisplayString(a(t).detail),1)):e.createCommentVNode("",!0),p(a(t))?(e.openBlock(),e.createElementBlock("section",xe,[e.createElementVNode("strong",null,e.toDisplayString((g=p(a(t)))==null?void 0:g.name),1),e.createElementVNode("span",null,e.toDisplayString((f=p(a(t)))==null?void 0:f.summary),1),(j=p(a(t)))!=null&&j.inputSummary?(e.openBlock(),e.createElementBlock("small",je,e.toDisplayString((A=p(a(t)))==null?void 0:A.inputSummary),1)):e.createCommentVNode("",!0),(T=p(a(t)))!=null&&T.resultSummary?(e.openBlock(),e.createElementBlock("small",Ae,e.toDisplayString((M=p(a(t)))==null?void 0:M.resultSummary),1)):e.createCommentVNode("",!0),(I=p(a(t)))!=null&&I.error?(e.openBlock(),e.createElementBlock("small",Te,e.toDisplayString((z=p(a(t)))==null?void 0:z.error),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),a(t).lockedReason||((K=i.operationMessages)==null?void 0:K[N(a(t))])===""?(e.openBlock(),e.createElementBlock("p",Me,e.toDisplayString(a(t).lockedReason),1)):e.createCommentVNode("",!0),a(t).revision===void 0&&y(a(t),"approve")?(e.openBlock(),e.createElementBlock("p",Ie,"缺少任务版本")):e.createCommentVNode("",!0),(R=a(t).approval)!=null&&R.artifactId&&(!i.artifacts.some(u=>{var B;return u.id===((B=a(t).approval)==null?void 0:B.artifactId)})||i.artifacts.some(u=>{var B;return u.id===((B=a(t).approval)==null?void 0:B.artifactId)&&u.revision===void 0}))?(e.openBlock(),e.createElementBlock("p",ze,"缺少产物版本")):e.createCommentVNode("",!0),a(t).progress!==void 0?(e.openBlock(),e.createElementBlock("div",Ke,[e.createElementVNode("div",{role:"progressbar","aria-label":"任务进度","aria-valuemin":"0","aria-valuemax":"100","aria-valuenow":V(a(t).progress)},[e.createElementVNode("span",{style:e.normalizeStyle({inlineSize:`${V(a(t).progress)}%`})},null,4)],8,Re),e.createElementVNode("small",null,e.toDisplayString(V(a(t).progress))+"%",1)])):e.createCommentVNode("",!0),a(t).startedAt||a(t).completedAt?(e.openBlock(),e.createElementBlock("div",Le,[a(t).startedAt?(e.openBlock(),e.createElementBlock("span",Fe,"开始 "+e.toDisplayString(a(t).startedAt),1)):e.createCommentVNode("",!0),a(t).completedAt?(e.openBlock(),e.createElementBlock("span",qe,"完成 "+e.toDisplayString(a(t).completedAt),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),a(t).error?(e.openBlock(),e.createElementBlock("details",Ue,[l[8]||(l[8]=e.createElementVNode("summary",null,"查看错误详情",-1)),e.createElementVNode("p",null,e.toDisplayString(a(t).error),1)])):e.createCommentVNode("",!0),e.createElementVNode("div",He,[a(t).status==="running"?(e.openBlock(),e.createBlock(e.unref(v.Button),{key:0,"data-action":"cancel",type:"text",disabled:y(a(t),"cancel"),onClick:u=>d("cancel",a(t))},{default:e.withCtx(()=>[...l[9]||(l[9]=[e.createTextVNode("取消",-1)])]),_:1},8,["disabled","onClick"])):e.createCommentVNode("",!0),a(t).status==="error"||(L=i.operationMessages)!=null&&L[N(a(t))]?(e.openBlock(),e.createBlock(e.unref(v.Button),{key:1,"data-action":"retry",type:"text",disabled:y(a(t),"retry"),onClick:u=>d("retry",a(t))},{default:e.withCtx(()=>[...l[10]||(l[10]=[e.createTextVNode("重试",-1)])]),_:1},8,["disabled","onClick"])):e.createCommentVNode("",!0),e.createVNode(e.unref(v.Button),{"data-action":"move-up",type:"text",disabled:E(a(t),m,-1),onClick:u=>D(m,-1)},{default:e.withCtx(()=>[...l[11]||(l[11]=[e.createTextVNode("上移",-1)])]),_:1},8,["disabled","onClick"]),e.createVNode(e.unref(v.Button),{"data-action":"move-down",type:"text",disabled:E(a(t),m,1),onClick:u=>D(m,1)},{default:e.withCtx(()=>[...l[12]||(l[12]=[e.createTextVNode("下移",-1)])]),_:1},8,["disabled","onClick"])]),(F=i.operationMessages)!=null&&F[N(a(t))]?(e.openBlock(),e.createElementBlock("p",Pe,e.toDisplayString(i.operationMessages[N(a(t))]),1)):e.createCommentVNode("",!0),a(t).approval?(e.openBlock(),e.createElementBlock("div",{key:9,"data-approval-id":(q=a(t).approval)==null?void 0:q.id,class:e.normalizeClass(["aheart-ai-workbench__approval",`is-${((U=a(t).approval)==null?void 0:U.status)??"pending"}`])},[e.createElementVNode("div",null,[e.createElementVNode("strong",null,e.toDisplayString((H=a(t).approval)==null?void 0:H.title),1),(P=a(t).approval)!=null&&P.description?(e.openBlock(),e.createElementBlock("p",We,e.toDisplayString((O=a(t).approval)==null?void 0:O.description),1)):e.createCommentVNode("",!0)]),!((W=a(t).approval)!=null&&W.status)||((Z=a(t).approval)==null?void 0:Z.status)==="pending"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(e.unref(v.Button),{"data-action":"approve",type:"primary",disabled:y(a(t),"approve"),onClick:u=>d("approve",a(t))},{default:e.withCtx(()=>[...l[13]||(l[13]=[e.createTextVNode("批准",-1)])]),_:1},8,["disabled","onClick"]),e.createVNode(e.unref(v.Button),{"data-action":"reject",danger:"",disabled:y(a(t),"reject"),onClick:u=>d("reject",a(t))},{default:e.withCtx(()=>[...l[14]||(l[14]=[e.createTextVNode("拒绝",-1)])]),_:1},8,["disabled","onClick"])],64)):(e.openBlock(),e.createElementBlock("span",Ze,e.toDisplayString(((G=a(t).approval)==null?void 0:G.status)==="approved"?"已批准":"已拒绝"),1))],10,Oe)):e.createCommentVNode("",!0)])],10,fe)]})]),_:3},8,["items","disabled","revision","group"])]),i.tasks.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("p",Ge,"尚无执行任务。"))],8,Be),e.createElementVNode("section",{class:"aheart-ai-workbench__artifacts","aria-labelledby":S.value},[e.createElementVNode("div",Qe,[e.createElementVNode("div",null,[l[16]||(l[16]=e.createElementVNode("span",{class:"aheart-ai-workbench__eyebrow"},"产物输出",-1)),e.createElementVNode("h2",{id:S.value},"产物",8,Xe)]),e.createElementVNode("span",null,e.toDisplayString(i.artifacts.length)+" 项",1)]),i.artifacts.length?(e.openBlock(),e.createElementBlock("ul",Ye,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.artifacts,t=>{var m,g;return e.openBlock(),e.createElementBlock("li",{key:t.id,"data-artifact-id":t.id,class:e.normalizeClass({"is-active":t.id===((m=n.value)==null?void 0:m.id)})},[e.createElementVNode("button",{type:"button","aria-pressed":t.id===((g=n.value)==null?void 0:g.id),onClick:f=>d("select-artifact",t)},[e.renderSlot(o.$slots,"artifact",{artifact:t},()=>[e.createElementVNode("span",null,e.toDisplayString(t.title),1),t.description?(e.openBlock(),e.createElementBlock("small",at,e.toDisplayString(t.description),1)):e.createCommentVNode("",!0)])],8,tt)],10,et)}),128))])):(e.openBlock(),e.createElementBlock("p",ot,"任务完成后,产物会出现在这里。")),n.value?(e.openBlock(),e.createElementBlock("section",lt,[e.renderSlot(o.$slots,"artifact-preview",{artifact:n.value},()=>[e.createElementVNode("div",rt,[e.createElementVNode("div",null,[e.createElementVNode("span",null,e.toDisplayString(n.value.type??"文件"),1),e.createElementVNode("h3",null,e.toDisplayString(n.value.title),1)]),e.unref(J.getSafeUrl)(n.value.url)?(e.openBlock(),e.createElementBlock("a",{key:0,href:e.unref(J.getSafeUrl)(n.value.url),target:"_blank",rel:"noreferrer"},"打开产物",8,nt)):e.createCommentVNode("",!0)]),e.createElementVNode("p",null,e.toDisplayString(n.value.description??"业务层可通过 artifact-preview 插槽提供自定义预览。"),1),n.value.updatedAt?(e.openBlock(),e.createElementBlock("small",st,"更新于 "+e.toDisplayString(n.value.updatedAt),1)):e.createCommentVNode("",!0)])])):e.createCommentVNode("",!0)],8,Je)])}}});exports.default=ct;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),v=require("aheart-ui/button"),ne=require("@aheart-ui/dnd/sortable"),J=require("./safe-markdown.js"),se={class:"aheart-ai-workbench__execution-content"},ce={key:0,class:"aheart-ai-workbench__mobile-priority",role:"region","aria-label":"移动端优先处理"},ie={class:"aheart-ai-workbench__priority-heading"},de={class:"aheart-ai-workbench__eyebrow"},pe={key:0},ue={key:1},ke={key:0,class:"aheart-ai-workbench__priority-approval"},me={key:0},ve={class:"aheart-ai-workbench__priority-actions"},_e={key:1,class:"aheart-ai-workbench__approval-result"},ye=["aria-label"],he={key:0},be=["aria-label"],ge={key:0},Be=["aria-labelledby"],Ne={class:"aheart-ai-workbench__section-heading"},Ve=["id"],Ee={class:"aheart-ai-workbench__timeline"},fe=["data-task-id"],Ce={class:"aheart-ai-workbench__task-body"},we={class:"aheart-ai-workbench__task-summary"},Se={key:0,class:"aheart-ai-workbench__tool-name"},De={class:"aheart-ai-workbench__task-status"},$e={key:0,class:"aheart-ai-workbench__task-detail"},xe={key:1,class:"aheart-ai-workbench__tool-call","aria-label":"工具调用摘要"},je={key:0},Ae={key:1},Te={key:2},Me={key:2,class:"aheart-ai-workbench__task-lock-reason",role:"status"},Ie={key:3,class:"aheart-ai-workbench__task-lock-reason",role:"status"},ze={key:4,class:"aheart-ai-workbench__task-lock-reason",role:"status"},Ke={key:5,class:"aheart-ai-workbench__task-progress"},Re=["aria-valuenow"],Le={key:6,class:"aheart-ai-workbench__task-time"},Fe={key:0},qe={key:1},Ue={key:7,class:"aheart-ai-workbench__task-error"},He={class:"aheart-ai-workbench__task-actions"},Pe={key:8,class:"aheart-ai-workbench__operation-status",role:"status"},Oe=["data-approval-id"],We={key:0},Ze={key:1,class:"aheart-ai-workbench__approval-result"},Ge={key:0,class:"aheart-ai-workbench__empty"},Je=["aria-labelledby"],Qe={class:"aheart-ai-workbench__section-heading"},Xe=["id"],Ye={key:0,class:"aheart-ai-workbench__artifact-list"},et=["data-artifact-id"],tt=["aria-pressed","onClick"],at={key:0},ot={key:1,class:"aheart-ai-workbench__empty"},lt={key:2,class:"aheart-ai-workbench__artifact-preview","aria-label":"产物预览"},rt={class:"aheart-ai-workbench__artifact-preview-header"},nt=["href"],st={key:0},ct=e.defineComponent({name:"AIAgentWorkbenchExecution",__name:"agent-execution",props:{tasks:{default:()=>[]},artifacts:{default:()=>[]},activeArtifact:{default:void 0},disabled:{type:Boolean,default:!1},reorderable:{type:Boolean,default:!0},tasksRevision:{},scopeKey:{default:"default"},actionDisabled:{type:Function,default:()=>!1},operationMessages:{default:()=>({})},validateCandidate:{type:Function,default:()=>{}}},emits:["update:tasks","approve","reject","cancel","retry","move-task","move-task-reject","select-artifact"],setup(i,{emit:Q}){const r=i,C=e.computed(()=>`aheart-agent-execution-${String(r.scopeKey??"default").replace(/[^a-zA-Z0-9_-]/g,"-")}`),w=e.computed(()=>`${C.value}-tasks`),S=e.computed(()=>`${C.value}-artifacts`),d=Q,X={pending:"等待执行",running:"执行中","waiting-approval":"等待审批",complete:"已完成",error:"执行失败",cancelled:"已取消"},Y=e.computed(()=>r.tasks.map((o,l)=>({...o,__sortableKey:`${o.id}::${l}`}))),n=e.computed(()=>r.artifacts.find(o=>o.id===r.activeArtifact)??r.artifacts[0]),s=e.computed(()=>r.tasks.find(o=>o.approval&&(!o.approval.status||o.approval.status==="pending"))??r.tasks.find(o=>o.approval)),_=e.computed(()=>r.artifacts.find(o=>{var l,c;return o.id===((c=(l=s.value)==null?void 0:l.approval)==null?void 0:c.artifactId)})??n.value),ee=e.computed(()=>{var o;return(o=s.value)!=null&&o.approval&&(!s.value.approval.status||s.value.approval.status==="pending")?"等待审批":s.value?"审批结果":"当前产物"}),a=o=>o,p=o=>o.toolCall,N=o=>{var l;return`${o.id}:${String(o.revision??"")}:${((l=o.approval)==null?void 0:l.id)??""}`},te=o=>{d("move-task-reject",{"stale-revision":"任务版本已变化,排序已拒绝","source-missing":"源任务已不存在,排序已拒绝","target-missing":"目标位置已不存在,排序已拒绝","duplicate-key":"任务标识重复,无法排序","group-mismatch":"任务不属于当前排序分组",disabled:"任务当前不可排序,排序已拒绝","invalid-position":"目标位置无效,排序已拒绝","parent-rejected":"任务版本已变化,排序已拒绝","rollback-rejected":"排序回滚失败,请刷新后重试",unmounted:"排序目标已卸载",cancelled:"排序已取消"}[o.reason??""]??"任务当前不可排序,排序已拒绝")},ae=o=>X[o],oe=o=>o.status,le=o=>ae(o.status),V=o=>Math.min(100,Math.max(0,Math.round(o??0))),re=o=>{var l;if(!r.disabled&&r.reorderable){const c=o.map(({__sortableKey:b,...h})=>h),k=(l=r.validateCandidate)==null?void 0:l.call(r,c);if(k){d("move-task-reject",k);return}d("update:tasks",c)}},D=(o,l)=>{var h;if(E(r.tasks[o],o,l))return;const c=[...r.tasks],[k]=c.splice(o,1);c.splice(o+l,0,k);const b=(h=r.validateCandidate)==null?void 0:h.call(r,c);if(b){d("move-task-reject",b);return}d("update:tasks",c),d("move-task",k.id,l<0?"up":"down")},y=(o,l)=>{var c;return r.disabled||!!((c=r.actionDisabled)!=null&&c.call(r,o,l))},E=(o,l,c)=>!!(r.disabled||!r.reorderable||l+c<0||l+c>=r.tasks.length||(o==null?void 0:o.reorderable)===!1||o!=null&&o.lockedReason||(o==null?void 0:o.status)==="running"||(o==null?void 0:o.status)==="waiting-approval");return(o,l)=>{var c,k,b,h,$,x;return e.openBlock(),e.createElementBlock("div",se,[s.value||n.value?(e.openBlock(),e.createElementBlock("section",ce,[e.createElementVNode("div",ie,[e.createElementVNode("span",de,e.toDisplayString(ee.value),1),s.value?(e.openBlock(),e.createElementBlock("strong",pe,e.toDisplayString((c=s.value.approval)==null?void 0:c.title),1)):(e.openBlock(),e.createElementBlock("strong",ue,"查看当前产物"))]),s.value?(e.openBlock(),e.createElementBlock("div",ke,[(k=s.value.approval)!=null&&k.description?(e.openBlock(),e.createElementBlock("p",me,e.toDisplayString(s.value.approval.description),1)):e.createCommentVNode("",!0),e.createElementVNode("div",ve,[!((b=s.value.approval)!=null&&b.status)||s.value.approval.status==="pending"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(e.unref(v.Button),{"data-action":"approve",type:"primary",disabled:y(s.value,"approve"),onClick:l[0]||(l[0]=t=>d("approve",s.value))},{default:e.withCtx(()=>[...l[4]||(l[4]=[e.createTextVNode("批准",-1)])]),_:1},8,["disabled"]),e.createVNode(e.unref(v.Button),{"data-action":"reject",danger:"",disabled:y(s.value,"reject"),onClick:l[1]||(l[1]=t=>d("reject",s.value))},{default:e.withCtx(()=>[...l[5]||(l[5]=[e.createTextVNode("拒绝",-1)])]),_:1},8,["disabled"])],64)):(e.openBlock(),e.createElementBlock("span",_e,e.toDisplayString(s.value.approval.status==="approved"?"已批准":"已拒绝"),1))])])):e.createCommentVNode("",!0),_.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"aheart-ai-workbench__priority-artifact","data-artifact-role":"approval","aria-label":_.value.title,onClick:l[2]||(l[2]=t=>d("select-artifact",_.value))},[e.createElementVNode("span",null,e.toDisplayString(($=(h=s.value)==null?void 0:h.approval)!=null&&$.artifactId?"审批对象":"当前产物"),1),e.createElementVNode("strong",null,e.toDisplayString(_.value.title),1),_.value.description?(e.openBlock(),e.createElementBlock("small",he,e.toDisplayString(_.value.description),1)):e.createCommentVNode("",!0)],8,ye)):e.createCommentVNode("",!0),n.value&&n.value.id!==((x=_.value)==null?void 0:x.id)?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:"aheart-ai-workbench__priority-artifact","data-artifact-role":"current","aria-label":n.value.title,onClick:l[3]||(l[3]=t=>d("select-artifact",n.value))},[l[6]||(l[6]=e.createElementVNode("span",null,"当前产物",-1)),e.createElementVNode("strong",null,e.toDisplayString(n.value.title),1),n.value.description?(e.openBlock(),e.createElementBlock("small",ge,e.toDisplayString(n.value.description),1)):e.createCommentVNode("",!0)],8,be)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createElementVNode("section",{class:"aheart-ai-workbench__tasks","aria-labelledby":w.value},[e.createElementVNode("div",Ne,[e.createElementVNode("div",null,[l[7]||(l[7]=e.createElementVNode("span",{class:"aheart-ai-workbench__eyebrow"},"执行流程",-1)),e.createElementVNode("h2",{id:w.value},"执行时间线",8,Ve)]),e.createElementVNode("span",null,e.toDisplayString(i.tasks.length)+" 项",1)]),e.createElementVNode("div",Ee,[e.createVNode(e.unref(ne.SortableList),{items:Y.value,"item-key":"__sortableKey",disabled:i.disabled||!i.reorderable,revision:i.tasksRevision,group:`agent-tasks-${i.scopeKey}`,"onUpdate:items":re,onMoveReject:te},{item:e.withCtx(({item:t,index:m})=>[e.renderSlot(o.$slots,"task",{task:a(t),index:m},()=>{var g,f,j,A,T,M,I,z,K,R,L,F,q,U,H,P,O,W,Z,G;return[e.createElementVNode("article",{"data-task-id":a(t).id,class:e.normalizeClass(["aheart-ai-workbench__timeline-item",[`is-${oe(a(t))}`,{"has-approval-summary":!!a(t).approval}]])},[l[15]||(l[15]=e.createElementVNode("span",{class:"aheart-ai-workbench__timeline-marker","aria-hidden":"true"},null,-1)),e.createElementVNode("div",Ce,[e.createElementVNode("header",we,[e.createElementVNode("div",null,[e.createElementVNode("strong",null,e.toDisplayString(a(t).label),1),a(t).toolName?(e.openBlock(),e.createElementBlock("span",Se,e.toDisplayString(a(t).toolName),1)):e.createCommentVNode("",!0)]),e.createElementVNode("span",De,e.toDisplayString(le(a(t))),1)]),a(t).detail&&!p(a(t))?(e.openBlock(),e.createElementBlock("p",$e,e.toDisplayString(a(t).detail),1)):e.createCommentVNode("",!0),p(a(t))?(e.openBlock(),e.createElementBlock("section",xe,[e.createElementVNode("strong",null,e.toDisplayString((g=p(a(t)))==null?void 0:g.name),1),e.createElementVNode("span",null,e.toDisplayString((f=p(a(t)))==null?void 0:f.summary),1),(j=p(a(t)))!=null&&j.inputSummary?(e.openBlock(),e.createElementBlock("small",je,e.toDisplayString((A=p(a(t)))==null?void 0:A.inputSummary),1)):e.createCommentVNode("",!0),(T=p(a(t)))!=null&&T.resultSummary?(e.openBlock(),e.createElementBlock("small",Ae,e.toDisplayString((M=p(a(t)))==null?void 0:M.resultSummary),1)):e.createCommentVNode("",!0),(I=p(a(t)))!=null&&I.error?(e.openBlock(),e.createElementBlock("small",Te,e.toDisplayString((z=p(a(t)))==null?void 0:z.error),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),a(t).lockedReason||((K=i.operationMessages)==null?void 0:K[N(a(t))])===""?(e.openBlock(),e.createElementBlock("p",Me,e.toDisplayString(a(t).lockedReason),1)):e.createCommentVNode("",!0),a(t).revision===void 0&&y(a(t),"approve")?(e.openBlock(),e.createElementBlock("p",Ie,"缺少任务版本")):e.createCommentVNode("",!0),(R=a(t).approval)!=null&&R.artifactId&&(!i.artifacts.some(u=>{var B;return u.id===((B=a(t).approval)==null?void 0:B.artifactId)})||i.artifacts.some(u=>{var B;return u.id===((B=a(t).approval)==null?void 0:B.artifactId)&&u.revision===void 0}))?(e.openBlock(),e.createElementBlock("p",ze,"缺少产物版本")):e.createCommentVNode("",!0),a(t).progress!==void 0?(e.openBlock(),e.createElementBlock("div",Ke,[e.createElementVNode("div",{role:"progressbar","aria-label":"任务进度","aria-valuemin":"0","aria-valuemax":"100","aria-valuenow":V(a(t).progress)},[e.createElementVNode("span",{style:e.normalizeStyle({inlineSize:`${V(a(t).progress)}%`})},null,4)],8,Re),e.createElementVNode("small",null,e.toDisplayString(V(a(t).progress))+"%",1)])):e.createCommentVNode("",!0),a(t).startedAt||a(t).completedAt?(e.openBlock(),e.createElementBlock("div",Le,[a(t).startedAt?(e.openBlock(),e.createElementBlock("span",Fe,"开始 "+e.toDisplayString(a(t).startedAt),1)):e.createCommentVNode("",!0),a(t).completedAt?(e.openBlock(),e.createElementBlock("span",qe,"完成 "+e.toDisplayString(a(t).completedAt),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),a(t).error?(e.openBlock(),e.createElementBlock("details",Ue,[l[8]||(l[8]=e.createElementVNode("summary",null,"查看错误详情",-1)),e.createElementVNode("p",null,e.toDisplayString(a(t).error),1)])):e.createCommentVNode("",!0),e.createElementVNode("div",He,[a(t).status==="running"?(e.openBlock(),e.createBlock(e.unref(v.Button),{key:0,"data-action":"cancel",type:"text",disabled:y(a(t),"cancel"),onClick:u=>d("cancel",a(t))},{default:e.withCtx(()=>[...l[9]||(l[9]=[e.createTextVNode("取消",-1)])]),_:1},8,["disabled","onClick"])):e.createCommentVNode("",!0),a(t).status==="error"||(L=i.operationMessages)!=null&&L[N(a(t))]?(e.openBlock(),e.createBlock(e.unref(v.Button),{key:1,"data-action":"retry",type:"text",disabled:y(a(t),"retry"),onClick:u=>d("retry",a(t))},{default:e.withCtx(()=>[...l[10]||(l[10]=[e.createTextVNode("重试",-1)])]),_:1},8,["disabled","onClick"])):e.createCommentVNode("",!0),e.createVNode(e.unref(v.Button),{"data-action":"move-up",type:"text",disabled:E(a(t),m,-1),onClick:u=>D(m,-1)},{default:e.withCtx(()=>[...l[11]||(l[11]=[e.createTextVNode("上移",-1)])]),_:1},8,["disabled","onClick"]),e.createVNode(e.unref(v.Button),{"data-action":"move-down",type:"text",disabled:E(a(t),m,1),onClick:u=>D(m,1)},{default:e.withCtx(()=>[...l[12]||(l[12]=[e.createTextVNode("下移",-1)])]),_:1},8,["disabled","onClick"])]),(F=i.operationMessages)!=null&&F[N(a(t))]?(e.openBlock(),e.createElementBlock("p",Pe,e.toDisplayString(i.operationMessages[N(a(t))]),1)):e.createCommentVNode("",!0),a(t).approval?(e.openBlock(),e.createElementBlock("div",{key:9,"data-approval-id":(q=a(t).approval)==null?void 0:q.id,class:e.normalizeClass(["aheart-ai-workbench__approval",`is-${((U=a(t).approval)==null?void 0:U.status)??"pending"}`])},[e.createElementVNode("div",null,[e.createElementVNode("strong",null,e.toDisplayString((H=a(t).approval)==null?void 0:H.title),1),(P=a(t).approval)!=null&&P.description?(e.openBlock(),e.createElementBlock("p",We,e.toDisplayString((O=a(t).approval)==null?void 0:O.description),1)):e.createCommentVNode("",!0)]),!((W=a(t).approval)!=null&&W.status)||((Z=a(t).approval)==null?void 0:Z.status)==="pending"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(e.unref(v.Button),{"data-action":"approve",type:"primary",disabled:y(a(t),"approve"),onClick:u=>d("approve",a(t))},{default:e.withCtx(()=>[...l[13]||(l[13]=[e.createTextVNode("批准",-1)])]),_:1},8,["disabled","onClick"]),e.createVNode(e.unref(v.Button),{"data-action":"reject",danger:"",disabled:y(a(t),"reject"),onClick:u=>d("reject",a(t))},{default:e.withCtx(()=>[...l[14]||(l[14]=[e.createTextVNode("拒绝",-1)])]),_:1},8,["disabled","onClick"])],64)):(e.openBlock(),e.createElementBlock("span",Ze,e.toDisplayString(((G=a(t).approval)==null?void 0:G.status)==="approved"?"已批准":"已拒绝"),1))],10,Oe)):e.createCommentVNode("",!0)])],10,fe)]})]),_:3},8,["items","disabled","revision","group"])]),i.tasks.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("p",Ge,"尚无执行任务。"))],8,Be),e.createElementVNode("section",{class:"aheart-ai-workbench__artifacts","aria-labelledby":S.value},[e.createElementVNode("div",Qe,[e.createElementVNode("div",null,[l[16]||(l[16]=e.createElementVNode("span",{class:"aheart-ai-workbench__eyebrow"},"产物输出",-1)),e.createElementVNode("h2",{id:S.value},"产物",8,Xe)]),e.createElementVNode("span",null,e.toDisplayString(i.artifacts.length)+" 项",1)]),i.artifacts.length?(e.openBlock(),e.createElementBlock("ul",Ye,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.artifacts,t=>{var m,g;return e.openBlock(),e.createElementBlock("li",{key:t.id,"data-artifact-id":t.id,class:e.normalizeClass({"is-active":t.id===((m=n.value)==null?void 0:m.id)})},[e.createElementVNode("button",{type:"button","aria-pressed":t.id===((g=n.value)==null?void 0:g.id),onClick:f=>d("select-artifact",t)},[e.renderSlot(o.$slots,"artifact",{artifact:t},()=>[e.createElementVNode("span",null,e.toDisplayString(t.title),1),t.description?(e.openBlock(),e.createElementBlock("small",at,e.toDisplayString(t.description),1)):e.createCommentVNode("",!0)])],8,tt)],10,et)}),128))])):(e.openBlock(),e.createElementBlock("p",ot,"任务完成后,产物会出现在这里。")),n.value?(e.openBlock(),e.createElementBlock("section",lt,[e.renderSlot(o.$slots,"artifact-preview",{artifact:n.value},()=>[e.createElementVNode("div",rt,[e.createElementVNode("div",null,[e.createElementVNode("span",null,e.toDisplayString(n.value.type??"文件"),1),e.createElementVNode("h3",null,e.toDisplayString(n.value.title),1)]),e.unref(J.getSafeUrl)(n.value.url)?(e.openBlock(),e.createElementBlock("a",{key:0,href:e.unref(J.getSafeUrl)(n.value.url),target:"_blank",rel:"noreferrer"},"打开产物",8,nt)):e.createCommentVNode("",!0)]),e.createElementVNode("p",null,e.toDisplayString(n.value.description??"业务层可通过 artifact-preview 插槽提供自定义预览。"),1),n.value.updatedAt?(e.openBlock(),e.createElementBlock("small",st,"更新于 "+e.toDisplayString(n.value.updatedAt),1)):e.createCommentVNode("",!0)])])):e.createCommentVNode("",!0)],8,Je)])}}});exports.default=ct;