feat(webui): add WebMCP task actions
This commit is contained in:
1 parent
32b73c3a28
commit
7cd62232ef
3 files changed
+68
-17
No files matched your search
Vendored
+1
-1
@@ -322,4 +322,4 @@ Edge: ${e}`,EDGE_NOT_FOUND:e=>`Edge not found
|
||||
Edge: ${e}`,USEVUEFLOW_OPTIONS:()=>`The options parameter is deprecated and will be removed in the next major version. Please use the id parameter instead`},y7=class extends Error{constructor(e,...t){super(v7[e]?.call(v7,...t)),this.name=`VueFlowError`,this.code=e,this.args=t}};function b7(e){return`clientX`in e}function Boe(e){return`sourceEvent`in e}function x7(e,t){let n=b7(e),r,i;return n?(r=e.clientX,i=e.clientY):`touches`in e&&e.touches.length>0?(r=e.touches[0].clientX,i=e.touches[0].clientY):`changedTouches`in e&&e.changedTouches.length>0?(r=e.changedTouches[0].clientX,i=e.changedTouches[0].clientY):(r=0,i=0),{x:r-(t?.left??0),y:i-(t?.top??0)}}var S7=()=>typeof navigator<`u`&&(navigator==null?void 0:navigator.userAgent)?.indexOf(`Mac`)>=0;function Voe(e){return{width:e.dimensions?.width??e.width??0,height:e.dimensions?.height??e.height??0}}function C7(e,t=[1,1]){return{x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}}var Hoe=()=>!0;function w7(e){e?.classList.remove(`valid`,`connecting`,`vue-flow__handle-valid`,`vue-flow__handle-connecting`)}function Uoe(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())j5(i,A5(e))>0&&r.push(e);return r}var Woe=250;function Goe(e,t,n,r){let i=[],a=1/0,o=Uoe(e,n,t+Woe);for(let n of o){let o=[...n.handleBounds?.source??[],...n.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=h7(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l<a?(i=[{...s,x:o,y:c}],a=l):l===a&&i.push({...s,x:o,y:c}))}}if(!i.length)return null;if(i.length>1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function T7(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=Hoe},u,d,f,p){let m=a===`target`,h=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:g,y:_}=x7(e),v=o.elementFromPoint(g,_),y=v?.classList.contains(`${s}-flow__handle`)?v:h,b={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){let e=E7(void 0,y),t=y.getAttribute(`data-nodeid`),a=y.getAttribute(`data-handleid`),o=y.classList.contains(`connectable`),s=y.classList.contains(`connectableend`);if(!t||!e)return b;let c={source:m?t:r,sourceHandle:m?a:i,target:m?r:t,targetHandle:m?i:a};b.connection=c,b.isValid=o&&s&&(n===b5.Strict?m&&e===`source`||!m&&e===`target`:t!==r||a!==i)&&l(c,{nodes:d,edges:u,sourceNode:f(c.source),targetNode:f(c.target)}),b.toHandle=D7(t,e,a,p,n,!0)}return b}function E7(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function Koe(e,t){let n=null;return t?n=`valid`:e&&!t&&(n=`invalid`),n}function qoe(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}function D7(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===b5.Strict?o.handleBounds?.[t]:[...o.handleBounds?.source??[],...o.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...h7(o,c,c.position,!0)}:c}var O7={[_5.Left]:_5.Right,[_5.Right]:_5.Left,[_5.Top]:_5.Bottom,[_5.Bottom]:_5.Top},Joe=[`production`,`prod`];function k7(e,...t){A7()&&console.warn(`[Vue Flow]: ${e}`,...t)}function A7(){return!Joe.includes(`production`)}function j7(e,t,n,r,i){let a=t.querySelectorAll(`.vue-flow__handle.${e}`);return a?.length?Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...M5(t)}}):null}function M7(e,t,n,r,i,a=!1,o){i.value=!1,e.selected?(a||e.selected&&t)&&(r([e]),We(()=>{o.blur()})):n([e])}function N7(e){return V(e)!==void 0}function Yoe(e,t,n,r){if(!e||!e.source||!e.target)return n(new y7(_7.EDGE_INVALID,e?.id??`[ID UNKNOWN]`)),!1;let i;return i=I5(e)?e:{...e,id:H5(e)},i=B5(i,void 0,r),!Ooe(i,t)&&i}function Xoe(e,t,n,r,i){if(!t.source||!t.target)return i(new y7(_7.EDGE_INVALID,e.id)),!1;if(!n)return i(new y7(_7.EDGE_NOT_FOUND,e.id)),!1;let{id:a,...o}=e;return{...o,id:r?H5(t):a,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle}}function P7(e,t,n){let r={},i=[];for(let a=0;a<e.length;++a){let o=e[a];if(!L5(o)){n(new y7(_7.NODE_INVALID,o?.id));continue}let s=Toe(o,t(o.id),o.parentNode);o.parentNode&&(r[o.parentNode]=!0),i[a]=s}for(let e of i){let a=t(e.parentNode)||i.find(t=>t.id===e.parentNode);e.parentNode&&!a&&n(new y7(_7.NODE_MISSING_PARENT,e.id,e.parentNode)),(e.parentNode||r[e.id])&&(r[e.id]&&(e.isParent=!0),a&&(a.isParent=!0))}return i}function F7(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function I7(e,t,n){e.clear();for(let t of n){let{source:n,target:r,sourceHandle:i=null,targetHandle:a=null}=t,o={edgeId:t.id,source:n,target:r,sourceHandle:i,targetHandle:a},s=`${n}-${i}--${r}-${a}`;F7(`sourcLine truncated
|
||||
`)},B(e.data.summary||e.data.detail),9,Rce)):F(``,!0),e.data.when||e.data.retry||e.data.continues?(L(),j(`div`,zce,[e.data.when?(L(),j(`span`,{key:0,class:`flex max-w-full min-w-0 items-center gap-0.5 rounded bg-secondary px-1 font-mono`,title:`Runs only when ${e.data.when}`},[A(V(hu),{class:`size-3 shrink-0`,"aria-hidden":`true`}),R(`span`,Vce,B(e.data.when),1)],8,Bce)):F(``,!0),e.data.retry?(L(),j(`span`,{key:1,class:`flex items-center gap-0.5 rounded bg-secondary px-1`,title:`Up to ${e.data.retry} attempts`},[A(V(ute),{class:`size-3`,"aria-hidden":`true`}),H(`×`+B(e.data.retry),1)],8,Hce)):F(``,!0),e.data.continues?(L(),j(`span`,Uce,[A(V(_te),{class:`size-3`,"aria-hidden":`true`}),r[10]||=H(`continues`,-1)])):F(``,!0)])):F(``,!0),e.data.run?.error?(L(),j(`p`,{key:4,class:`mt-1 line-clamp-2 text-caption text-danger`,title:e.data.run.error},B(e.data.run.error),9,Wce)):F(``,!0)],64))]),A(ut,{"enter-from-class":`opacity-0 -translate-y-1`,"enter-active-class":`transition duration-200`,"leave-to-class":`opacity-0`,"leave-active-class":`transition duration-100`},{default:I(()=>[e.data.expanded?(L(),j(`div`,{key:0,class:`nodrag nopan nowheel cursor-auto border-t border-border`,onClick:r[6]||=pt(()=>{},[`stop`])},[K(t.$slots,`default`)])):F(``,!0)]),_:3}),A(V(Q7),{type:`source`,position:V(_5).Bottom},null,8,[`position`]),A(V(Q7),{id:`data-out`,type:`source`,position:V(_5).Right,class:`!opacity-0`},null,8,[`position`]),e.data.type===`switch`?(L(),q(V(Q7),{key:1,id:`otherwise`,type:`source`,position:V(_5).Right,class:`!opacity-0`},null,8,[`position`])):F(``,!0)],2))}}),Kce={class:`pointer-events-none size-full rounded-xl border border-dashed border-border bg-muted/30`},qce={class:`flex items-center gap-1 px-2.5 pt-1.5 text-caption text-fg-subtle`},Jce={key:0},Yce={key:1,class:`font-mono`},Xce=P({__name:`LaneNode`,props:{data:{}},setup(e){return(t,n)=>(L(),j(`div`,Kce,[R(`div`,qce,[e.data.lane===`switch`?(L(),j(U,{key:0},[A(V(Au),{class:`size-3`,"aria-hidden":`true`}),e.data.title==="default"?(L(),j(`span`,Jce,`otherwise`)):(L(),j(`span`,Yce,`= `+B(e.data.title),1))],64)):(L(),j(U,{key:1},[A(V(_u),{class:`size-3`,"aria-hidden":`true`}),H(B(e.data.title),1)],64))])]))}}),Zce={class:`flex shrink-0 items-center justify-center gap-1 border-t border-border bg-card p-1`},S9=240,Qce=416,C9=-140,$ce=72,ele=.9,w9=P({__name:`WorkflowCanvas`,props:{yaml:{},stages:{},open:{},triggers:{},types:{},readonly:{type:Boolean},restartable:{type:Boolean},marks:{},problems:{},title:{},summary:{}},emits:[`toggle`,`insert`,`duplicate`,`move`,`remove`,`rename`,`restart`],setup(e,{emit:t}){let n=e,r=t,i=Y(()=>!!n.types?.length&&!n.readonly),a=Y(()=>[...n.types??[],`parallel`,`switch`]),o=Y(()=>a.value.filter(e=>[`agent.run`,`workflow.call`].includes(e))),s=e=>e&&r1(e)?o.value:a.value,c=e=>e.kind===`step`?JSON.stringify(e.path??null):e.kind,l=J(null),u=J(null),d=Et(`(max-width: 767px)`),f=Y(()=>{let e=S1(N1(n.yaml),n.stages??[]);return n.types?.length?{nodes:[{id:`workflow`,type:`step`,position:{x:0,y:C9},data:{kind:`workflow`,key:`workflow`,title:n.title||`Workflow`,type:``,detail:n.summary??``}},...e.nodes],edges:[{id:`flow-workflow-start`,source:`workflow`,target:`start`,kind:`flow`},...e.edges]}:e}),p=Y(()=>f.value.nodes.filter(e=>e.data.path?.length===2).length),m=J({}),h=J({}),g=Y(()=>f.value.nodes.find(e=>e.type===`step`&&c(e.data)===n.open));function _(e,t){m.value={...m.value,[e]:t},g.value?.id!==e&&(h.value={...h.value,[e]:t})}let v=Y(()=>{let e=d.value?void 0:g.value?.id;return e&&m.value[e]?Math.max(0,m.value[e]-(h.value[e]??m.value[e])):0}),y=Mt(),b=wt(v,{duration:Y(()=>y.value===`reduce`?0:200)}),x=Y(()=>{let e=new Map;for(let t of f.value.nodes){if(t.type!==`step`)continue;let n=(t.id===g.value?.id?h.value[t.id]:void 0)??m.value[t.id];n!==void 0&&e.set(t.position.y,Math.max(e.get(t.position.y)??-72,n-$ce))}return[...e]}),S=e=>x.value.reduce((t,[n,r])=>n<e?t+r:t,0);function C(e){let t=e.data,a=c(t),o=t.path,s={triggers:t.kind===`start`?n.triggers??[]:t.triggers,expanded:!d.value&&a===n.open,editable:i.value,problem:o?n.problems?.[a]:void 0,onResize:t=>_(e.id,t)};return n.types?.length&&(s.onToggle=()=>r(`toggle`,a)),i.value&&o&&(s.onRename=e=>r(`rename`,o,e),s.onDuplicate=()=>r(`duplicate`,o),s.onRemove=()=>r(`remove`,o)),{...e,data:{...t,...s}}}let w=e=>{let t=g.value;return d.value||!t||!e.style?.width?!1:e.position.x<=t.position.x&&e.position.x+parseFloat(String(e.style.width))>=t.position.x+S9};function T(e){let t=g.value;if(d.value||!t)return 0;if(e.id===t.id||w(e))return-88;let n=t.position.x+S9/2,r=e.style?.width?parseFloat(String(e.style.width)):e.type===`step`?S9:32,i=e.position.x+r/2;return Math.abs(i-n)<S9/2?0:i<n?-88:88}let ee=Y(()=>{let e=g.value;return f.value.nodes.map(t=>{let a=t;t.type===`add`?t={...t,data:{...t.data,types:s(t.data.insertAfter),editable:i.value,onInsert:e=>r(`insert`,t.data.insertAfter,e)}}:t.type===`step`&&(t=C(t));let o=n.marks?.[t.id];o&&(t={...t,data:{...t.data,mark:o}});let c=t.position.x
Line truncated
|
||||
`),r=t.split(`
|
||||
`),i=Array.from({length:n.length+1},()=>Array(r.length+1).fill(0));for(let e=n.length-1;e>=0;e--)for(let t=r.length-1;t>=0;t--)i[e][t]=n[e]===r[t]?i[e+1][t+1]+1:Math.max(i[e+1][t],i[e][t+1]);let a=[],o=0,s=0;for(;o<n.length&&s<r.length;)n[o]===r[s]?(a.push({kind:`same`,text:n[o++]}),s++):i[o+1][s]>=i[o][s+1]?a.push({kind:`del`,text:n[o++]}):a.push({kind:`add`,text:r[s++]});for(;o<n.length;)a.push({kind:`del`,text:n[o++]});for(;s<r.length;)a.push({kind:`add`,text:r[s++]});return a}function T9(e){let t=Z$(e).toJS(),n=new Map;for(let r of N1(e).nodes){let{kind:e,path:i,stage:a,occurrence:o}=r.data;if(r.type!==`step`||e!==`step`||!i||a===void 0)continue;let s=t;for(let e of i)s=s?.[e];n.set(`${a}#${o??0}`,{node:r.id,signature:JSON.stringify(s??null)})}return n}function E9(e,t,n){let r=T9(e),i=T9(t),a={};for(let[e,t]of r){let r=i.get(e);r?r.signature!==t.signature&&(a[t.node]=`changed`):a[t.node]=n}return a}var ale={class:`flex flex-col gap-3 md:grid md:h-[calc(100dvh-17rem)] md:min-h-[26rem] md:grid-cols-[18rem_1fr]`},ole=[`aria-current`,`onClick`],sle={class:`flex items-center gap-2 text-sm`},cle={class:`font-mono text-xs text-fg-subtle`},lle=[`title`],ule={key:0,class:`px-3 py-2 text-sm text-fg-muted`},dle={key:1,class:`flex min-h-0 flex-col gap-2`},fle={class:`flex items-center gap-2 max-md:flex-wrap`},ple={key:0,class:`rounded-lg border border-border p-4 text-sm text-fg-muted`},mle={key:1,class:`min-h-0 flex-1 overflow-auto rounded-lg border border-border pt-2 pb-[calc(0.5rem+var(--code-overscroll))] font-mono text-label leading-6`},hle={class:`inline-block w-4 select-none text-fg-subtle`},gle={key:2,class:`grid min-h-0 flex-1 gap-3 max-md:flex-none md:grid-cols-2`},_le={class:`flex min-h-0 flex-col gap-1`},vle={class:`text-caption font-medium uppercase text-fg-muted`},yle={class:`min-h-0 flex-1 max-md:h-72 max-md:flex-none`},ble={class:`flex min-h-0 flex-col gap-1`},xle={class:`min-h-0 flex-1 max-md:h-72 max-md:flex-none`},Sle=P({__name:`WorkflowHistory`,props:Ye({revisions:{},current:{},error:{}},{selected:{default:0},selectedModifiers:{},mode:{default:`yaml`},modeModifiers:{}}),emits:Ye([`restore`],[`update:selected`,`update:mode`]),setup(e,{emit:t}){let n=e,r=t,i=ke(e,`selected`),a=ke(e,`mode`);N(()=>n.revisions,e=>{e.some(e=>e.version===i.value)||(i.value=(e.find(e=>e.yaml!==n.current)??e[0])?.version??0)},{immediate:!0});let o=Y(()=>n.revisions.find(e=>e.version===i.value)),s=Y(()=>o.value?.yaml??null),c=Y(()=>s.value===null?[]:ile(s.value,n.current)),l=Y(()=>s.value!==null&&s.value===n.current),u=Y(()=>s.value===null?{}:E9(s.value,n.current,`removed`)),d=Y(()=>s.value===null?{}:E9(n.current,s.value,`added`)),f={added:`default`,edited:`secondary`,removed:`destructive`};return(t,n)=>(L(),j(`div`,ale,[R(`ol`,{class:z(V(W)(`min-h-0 divide-y divide-border overflow-y-auto rounded-lg border border-border`,e.revisions.length&&`max-md:hidden`)),"aria-label":`Revisions`},[(L(!0),j(U,null,M(e.revisions,e=>(L(),j(`li`,{key:e.version},[R(`button`,{type:`button`,class:z([`block w-full px-3 py-2 text-left hover:bg-secondary`,e.version===i.value&&`bg-secondary`]),"aria-current":e.version===i.value,onClick:t=>i.value=e.version},[R(`span`,sle,[R(`span`,cle,`v`+B(e.version),1),A(V(k),{variant:f[e.change]},{default:I(()=>[H(B(e.change),1)]),_:2},1032,[`variant`])]),R(`span`,{class:`mt-0.5 block truncate text-xs text-fg-muted`,title:e.at},[H(B(e.actor||`unknown`)+` · `+B(e.source||`unknown`)+` · `,1),A(V(dw),{at:e.at},null,8,[`at`])],8,lle)],10,ole)]))),128)),e.revisions.length?F(``,!0):(L(),j(`li`,ule,B(e.error||`No recorded changes`),1))],2),e.revisions.length?(L(),q(V(Vu),{key:0,"model-value":String(i.value),"onUpdate:modelValue":n[0]||=e=>i.value=Number(e)},{default:I(()=>[A(V(Gu),{class:`w-full md:hidden`,"aria-label":`Revision`},{default:I(()=>[A(V(Ku))]),_:1}),A(V(Hu),null,{default:I(()=>[(L(!0),j(U,null,M(e.revisions,e=>(L(),q(V(Wu),{key:e.version,value:String(e.version)},{default:I(()=>[H(`v`+B(e.version)+` · `+B(e.change)+` · `+B(e.actor||`unknown`)+` · `+B(V(lw)(e.at)),1)]),_:2},1032,[`value`]))),128))]),_:1})]),_:1},8,[`model-value`])):F(``,!0),o.value?(L(),j(`div`,dle,[R(`div`,fle,[A(V(FO),{modelValue:a.value,"onUpdate:modelValue":n[1]||=e=>a.value=e},{default:I(()=>[A(V(LO),null,{default:I(()=>[A(V(RO),{value:`yaml`},{default:I(()=>[...n[3]||=[H(`YAML`,-1)]]),_:1}),A(V(RO),{value:`canvas`},{default:I(()=>[...n[4]||=[H(`Canvas`,-1)]]),_:1})]),_:1})]),_:1},8,[`modelValue`]),A(V(X),{type:`button`,size:`sm`,variant:`outline`,class:`ml-auto`,disabled:s.value===null||l.value,title:s.value===null?`Workflow removed`:void 0,onClick:n[2]||=e=>r(`restore`,s.value)},{default:I(()=>[A(V(Du),{"data-icon":`inline-start`}),n[5]||=H(` Restore this version`,-1)]),_:1},8,[`disabled`,`title`])]),s.value===null?(L(),j(`p`,ple,`Workflow removed in this revision.`)):a.value===`yaml`?(L(),j(`pre`,mle,[R(`code`,null,[(L(!0),j(U,null,M(c.value,(e,t)=>(L(),j(`span`,{key:t,class:z([`block min-h-6 px-3 whitespace-pre-wrap`,{"bg-o
Line truncated
|
||||
`),i=Array.from({length:n.length+1},()=>Array(r.length+1).fill(0));for(let e=n.length-1;e>=0;e--)for(let t=r.length-1;t>=0;t--)i[e][t]=n[e]===r[t]?i[e+1][t+1]+1:Math.max(i[e+1][t],i[e][t+1]);let a=[],o=0,s=0;for(;o<n.length&&s<r.length;)n[o]===r[s]?(a.push({kind:`same`,text:n[o++]}),s++):i[o+1][s]>=i[o][s+1]?a.push({kind:`del`,text:n[o++]}):a.push({kind:`add`,text:r[s++]});for(;o<n.length;)a.push({kind:`del`,text:n[o++]});for(;s<r.length;)a.push({kind:`add`,text:r[s++]});return a}function T9(e){let t=Z$(e).toJS(),n=new Map;for(let r of N1(e).nodes){let{kind:e,path:i,stage:a,occurrence:o}=r.data;if(r.type!==`step`||e!==`step`||!i||a===void 0)continue;let s=t;for(let e of i)s=s?.[e];n.set(`${a}#${o??0}`,{node:r.id,signature:JSON.stringify(s??null)})}return n}function E9(e,t,n){let r=T9(e),i=T9(t),a={};for(let[e,t]of r){let r=i.get(e);r?r.signature!==t.signature&&(a[t.node]=`changed`):a[t.node]=n}return a}var ale={class:`flex flex-col gap-3 md:grid md:h-[calc(100dvh-17rem)] md:min-h-[26rem] md:grid-cols-[18rem_1fr]`},ole=[`aria-current`,`onClick`],sle={class:`flex items-center gap-2 text-sm`},cle={class:`font-mono text-xs text-fg-subtle`},lle=[`title`],ule={key:0,class:`px-3 py-2 text-sm text-fg-muted`},dle={key:1,class:`flex min-h-0 flex-col gap-2`},fle={class:`flex items-center gap-2 max-md:flex-wrap`},ple={key:0,class:`rounded-lg border border-border p-4 text-sm text-fg-muted`},mle={key:1,class:`min-h-0 flex-1 overflow-auto rounded-lg border border-border pt-2 pb-[calc(0.5rem+var(--code-overscroll))] font-mono text-label leading-6`},hle={class:`inline-block w-4 select-none text-fg-subtle`},gle={key:2,class:`grid min-h-0 flex-1 gap-3 max-md:flex-none md:grid-cols-2`},_le={class:`flex min-h-0 flex-col gap-1`},vle={class:`text-caption font-medium uppercase text-fg-muted`},yle={class:`min-h-0 flex-1 max-md:h-72 max-md:flex-none`},ble={class:`flex min-h-0 flex-col gap-1`},xle={class:`min-h-0 flex-1 max-md:h-72 max-md:flex-none`},Sle=P({__name:`WorkflowHistory`,props:Ye({revisions:{},current:{},error:{}},{selected:{default:0},selectedModifiers:{},mode:{default:`yaml`},modeModifiers:{}}),emits:Ye([`restore`],[`update:selected`,`update:mode`]),setup(e,{emit:t}){let n=e,r=t,i=ke(e,`selected`),a=ke(e,`mode`);N(()=>n.revisions,e=>{e.some(e=>e.version===i.value)||(i.value=(e.find(e=>e.yaml!==n.current)??e[0])?.version??0)},{immediate:!0});let o=Y(()=>n.revisions.find(e=>e.version===i.value)),s=Y(()=>o.value?.yaml??null),c=Y(()=>s.value===null?[]:ile(s.value,n.current)),l=Y(()=>s.value!==null&&s.value===n.current),u=Y(()=>s.value===null?{}:E9(s.value,n.current,`removed`)),d=Y(()=>s.value===null?{}:E9(n.current,s.value,`added`)),f={added:`default`,edited:`secondary`,removed:`destructive`};return(t,n)=>(L(),j(`div`,ale,[R(`ol`,{class:z(V(W)(`min-h-0 divide-y divide-border overflow-y-auto rounded-lg border border-border`,e.revisions.length&&`max-md:hidden`)),"aria-label":`Revisions`},[(L(!0),j(U,null,M(e.revisions,e=>(L(),j(`li`,{key:e.version},[R(`button`,{type:`button`,class:z([`block w-full px-3 py-2 text-left hover:bg-secondary`,e.version===i.value&&`bg-secondary`]),"aria-current":e.version===i.value,onClick:t=>i.value=e.version},[R(`span`,sle,[R(`span`,cle,`v`+B(e.version),1),A(V(k),{variant:f[e.change]},{default:I(()=>[H(B(e.change),1)]),_:2},1032,[`variant`])]),R(`span`,{class:`mt-0.5 block truncate text-xs text-fg-muted`,title:e.at},[H(B(e.actor||`unknown`)+` · `+B(e.source||`unknown`)+` · `,1),A(V(dw),{at:e.at},null,8,[`at`])],8,lle)],10,ole)]))),128)),e.revisions.length?F(``,!0):(L(),j(`li`,ule,B(e.error||`No recorded changes`),1))],2),e.revisions.length?(L(),q(V(Vu),{key:0,"model-value":String(i.value),"onUpdate:modelValue":n[0]||=e=>i.value=Number(e)},{default:I(()=>[A(V(Gu),{class:`w-full md:hidden`,"aria-label":`Revision`},{default:I(()=>[A(V(Ku))]),_:1}),A(V(Hu),null,{default:I(()=>[(L(!0),j(U,null,M(e.revisions,e=>(L(),q(V(Wu),{key:e.version,value:String(e.version)},{default:I(()=>[H(`v`+B(e.version)+` · `+B(e.change)+` · `+B(e.actor||`unknown`)+` · `+B(V(lw)(e.at)),1)]),_:2},1032,[`value`]))),128))]),_:1})]),_:1},8,[`model-value`])):F(``,!0),o.value?(L(),j(`div`,dle,[R(`div`,fle,[A(V(FO),{modelValue:a.value,"onUpdate:modelValue":n[1]||=e=>a.value=e},{default:I(()=>[A(V(LO),null,{default:I(()=>[A(V(RO),{value:`yaml`},{default:I(()=>[...n[3]||=[H(`YAML`,-1)]]),_:1}),A(V(RO),{value:`canvas`},{default:I(()=>[...n[4]||=[H(`Canvas`,-1)]]),_:1})]),_:1})]),_:1},8,[`modelValue`]),A(V(X),{type:`button`,size:`sm`,variant:`outline`,class:`ml-auto`,disabled:s.value===null||l.value,title:s.value===null?`Workflow removed`:void 0,onClick:n[2]||=e=>r(`restore`,s.value)},{default:I(()=>[A(V(Du),{"data-icon":`inline-start`}),n[5]||=H(` Restore this version`,-1)]),_:1},8,[`disabled`,`title`])]),s.value===null?(L(),j(`p`,ple,`Workflow removed in this revision.`)):a.value===`yaml`?(L(),j(`pre`,mle,[R(`code`,null,[(L(!0),j(U,null,M(c.value,(e,t)=>(L(),j(`span`,{key:t,class:z([`block min-h-6 px-3 whitespace-pre-wrap`,{"bg-o
Line truncated
|
||||
+34
-11
@@ -3,9 +3,8 @@
|
||||
// The API client is a parameter rather than a module import, so this list is
|
||||
// host-agnostic and unit-testable; `archie-webmcp.ts` is the one place that
|
||||
// binds it to the dashboard's own client. Scope is deliberate: read-only
|
||||
// inspection, plus the three recovery actions (retry, stop, cancel). The human
|
||||
// review gate -- approve and reject -- is deliberately not exposed, because an
|
||||
// agent that can approve its own work defeats the design.
|
||||
// inspection and consequential task actions. The authenticated operator's
|
||||
// session authorizes every mutation.
|
||||
//
|
||||
// Security model: these tools run in the signed-in operator's own browser
|
||||
// session, so they inherit exactly what that operator can already do and can
|
||||
@@ -69,9 +68,9 @@ const taskIDSchema = {
|
||||
additionalProperties: false,
|
||||
} as const;
|
||||
|
||||
// A recovery tool's schema. `confirm` is required and must be true: a
|
||||
// A task action's schema. `confirm` is required and must be true: a
|
||||
// deliberate-action signal, not a security control (see the module header).
|
||||
const recoverySchema = {
|
||||
const taskActionSchema = {
|
||||
type: "object",
|
||||
properties: {
|
||||
task_id: {
|
||||
@@ -88,8 +87,8 @@ const recoverySchema = {
|
||||
additionalProperties: false,
|
||||
} as const;
|
||||
|
||||
/** One recovery action, published under its own name so the agent chooses by intent. */
|
||||
function recoveryTool(
|
||||
/** One task action, published under its own name so the agent chooses by intent. */
|
||||
function taskActionTool(
|
||||
client: DashboardApi,
|
||||
name: string,
|
||||
action: string,
|
||||
@@ -98,7 +97,7 @@ function recoveryTool(
|
||||
return {
|
||||
name,
|
||||
description,
|
||||
inputSchema: recoverySchema,
|
||||
inputSchema: taskActionSchema,
|
||||
annotations: { readOnlyHint: false, consequentialHint: true },
|
||||
execute: async (input) => {
|
||||
const id = taskID(input);
|
||||
@@ -170,23 +169,47 @@ export function archieWebMcpTools(client: DashboardApi): WebMcpTool[] {
|
||||
annotations: { readOnlyHint: true, untrustedContentHint: false },
|
||||
execute: async () => jsonEnvelope(await client.health()),
|
||||
},
|
||||
recoveryTool(
|
||||
taskActionTool(
|
||||
client,
|
||||
"retry_task",
|
||||
"retry",
|
||||
"Requeue a task that is stuck or parked so the workflow runs it again; keeps the task, its history, and its pull request. This recovers stalled work -- it is not how a review is approved.",
|
||||
),
|
||||
recoveryTool(
|
||||
taskActionTool(
|
||||
client,
|
||||
"stop_task",
|
||||
"stop",
|
||||
"Stop a running task recoverably: it moves to parked and can be retried later. Does not close the issue or discard the branch. Use this to pause work; use cancel_task to end it.",
|
||||
),
|
||||
recoveryTool(
|
||||
taskActionTool(
|
||||
client,
|
||||
"cancel_task",
|
||||
"cancel",
|
||||
"End a parked task archie should not continue; the forge issue stays open. stop_task parks a running task recoverably instead.",
|
||||
),
|
||||
taskActionTool(
|
||||
client,
|
||||
"approve_task",
|
||||
"approve",
|
||||
"Approve a task waiting for approval so its workflow can continue.",
|
||||
),
|
||||
taskActionTool(
|
||||
client,
|
||||
"reject_task",
|
||||
"reject",
|
||||
"Reject a task Archie should not continue. This ends the task and may close its forge issue or pull request.",
|
||||
),
|
||||
taskActionTool(
|
||||
client,
|
||||
"abandon_task",
|
||||
"abandon",
|
||||
"Abandon a parked task without closing its forge issue.",
|
||||
),
|
||||
taskActionTool(
|
||||
client,
|
||||
"archive_task",
|
||||
"archive",
|
||||
"Archive a terminal task, removing its local task record and worktree.",
|
||||
),
|
||||
];
|
||||
}
|
||||
+33
-5
@@ -116,7 +116,7 @@ test("registration passes each tool's schema and annotations, and disposes via t
|
||||
}
|
||||
});
|
||||
|
||||
test("read-only tools are read-only; recovery tools are consequential", () => {
|
||||
test("read-only tools are read-only; task actions are consequential", () => {
|
||||
const annotations = new Map(
|
||||
archieWebMcpTools(fakeClient().client).map((tool) => [
|
||||
tool.name,
|
||||
@@ -141,7 +141,15 @@ test("read-only tools are read-only; recovery tools are consequential", () => {
|
||||
`${name} must not be consequential`,
|
||||
);
|
||||
}
|
||||
for (const name of ["retry_task", "stop_task", "cancel_task"]) {
|
||||
for (const name of [
|
||||
"retry_task",
|
||||
"stop_task",
|
||||
"cancel_task",
|
||||
"approve_task",
|
||||
"reject_task",
|
||||
"abandon_task",
|
||||
"archive_task",
|
||||
]) {
|
||||
assert.equal(
|
||||
annotations.get(name)?.consequentialHint,
|
||||
true,
|
||||
@@ -173,7 +181,7 @@ test("tools returning agent, operator or inbound content carry untrustedContentH
|
||||
assert.equal(annotations.get("list_tasks")?.consequentialHint, undefined);
|
||||
});
|
||||
|
||||
test("recovery tools post the dashboard's own action verbs", async () => {
|
||||
test("task action tools post the dashboard's own action verbs", async () => {
|
||||
const { calls, client } = fakeClient();
|
||||
await toolNamed(client, "retry_task").execute({
|
||||
task_id: "9",
|
||||
@@ -184,15 +192,35 @@ test("recovery tools post the dashboard's own action verbs", async () => {
|
||||
task_id: "9",
|
||||
confirm: true,
|
||||
});
|
||||
await toolNamed(client, "approve_task").execute({
|
||||
task_id: "9",
|
||||
confirm: true,
|
||||
});
|
||||
await toolNamed(client, "reject_task").execute({
|
||||
task_id: "9",
|
||||
confirm: true,
|
||||
});
|
||||
await toolNamed(client, "abandon_task").execute({
|
||||
task_id: "9",
|
||||
confirm: true,
|
||||
});
|
||||
await toolNamed(client, "archive_task").execute({
|
||||
task_id: "9",
|
||||
confirm: true,
|
||||
});
|
||||
|
||||
assert.deepEqual(calls, [
|
||||
{ method: "taskAction", args: ["9", "retry"] },
|
||||
{ method: "taskAction", args: ["9", "stop"] },
|
||||
{ method: "taskAction", args: ["9", "cancel"] },
|
||||
{ method: "taskAction", args: ["9", "approve"] },
|
||||
{ method: "taskAction", args: ["9", "reject"] },
|
||||
{ method: "taskAction", args: ["9", "abandon"] },
|
||||
{ method: "taskAction", args: ["9", "archive"] },
|
||||
]);
|
||||
});
|
||||
|
||||
test("recovery tools require an explicit confirm flag before touching the API", async () => {
|
||||
test("task action tools require an explicit confirm flag before touching the API", async () => {
|
||||
const { calls, client } = fakeClient();
|
||||
const retry = toolNamed(client, "retry_task");
|
||||
|
||||
@@ -210,7 +238,7 @@ test("recovery tools require an explicit confirm flag before touching the API",
|
||||
assert.deepEqual(calls, [{ method: "taskAction", args: ["9", "retry"] }]);
|
||||
});
|
||||
|
||||
test("the recovery schema requires both task_id and confirm", () => {
|
||||
test("the task action schema requires both task_id and confirm", () => {
|
||||
const schema = archieWebMcpTools(fakeClient().client).find(
|
||||
(tool) => tool.name === "stop_task",
|
||||
)!.inputSchema as {
|
||||
|
||||
Reference in new issue
Block a user