@raytrace-cli/cli 0.17.0 → 0.17.2
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/dist/dashboard/assets/{index-BnYr54S5.js → index-CNN5OJ-7.js} +1 -1
- package/dist/dashboard/index.html +1 -1
- package/package.json +1 -1
- package/proxy/evidence-store.mjs +12 -1
- package/proxy/evidence-store.test.mjs +24 -0
- package/proxy/gvisor-forwarder.mjs +6 -0
- package/proxy/gvisor-forwarder.test.mjs +8 -0
- package/proxy/tool-metadata.mjs +9 -0
- package/proxy/tool-metadata.test.mjs +11 -1
- package/worker/sandbox/engine.py +32 -7
- package/worker/sandbox/test_capture.py +28 -0
|
@@ -22,7 +22,7 @@ Error generating stack: `+e.message+`
|
|
|
22
22
|
`,`
|
|
23
23
|
+`).split(`
|
|
24
24
|
`));return[t,t.reduce((e,t)=>e.concat(...t),[])]}return[[],[]]},[e]);return(0,_.useEffect)(()=>{let n=t?.target??KN,c=t?.actInsideInputWithModifier??!0;if(e!==null){let e=e=>{if(i.current=e.ctrlKey||e.metaKey||e.shiftKey||e.altKey,(!i.current||i.current&&!c)&&Tj(e))return!1;let n=YN(e.code,s);if(a.current.add(e[n]),JN(o,a.current,!1)){let n=e.composedPath?.()?.[0]||e.target,a=n?.nodeName===`BUTTON`||n?.nodeName===`A`;t.preventDefault!==!1&&(i.current||!a)&&e.preventDefault(),r(!0)}},l=e=>{let t=YN(e.code,s);JN(o,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(e[t]),e.key===`Meta`&&a.current.clear(),i.current=!1},u=()=>{a.current.clear(),r(!1)};return n?.addEventListener(`keydown`,e),n?.addEventListener(`keyup`,l),window.addEventListener(`blur`,u),window.addEventListener(`contextmenu`,u),()=>{n?.removeEventListener(`keydown`,e),n?.removeEventListener(`keyup`,l),window.removeEventListener(`blur`,u),window.removeEventListener(`contextmenu`,u)}}},[e,r]),n}function JN(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function YN(e,t){return t.includes(e)?`code`:`key`}var XN=()=>{let e=yN();return(0,_.useMemo)(()=>({zoomIn:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{let{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{let{transform:[r,i,a],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??a},n),!0):!1},getViewport:()=>{let[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{let{width:r,height:i,minZoom:a,maxZoom:o,panZoom:s}=e.getState(),c=dj(t,r,i,a,o,n?.padding??.1);return s?(await s.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{let{transform:r,snapGrid:i,snapToGrid:a,domNode:o}=e.getState();if(!o)return t;let{x:s,y:c}=o.getBoundingClientRect(),l={x:t.x-s,y:t.y-c},u=n.snapGrid??i;return oj(l,r,n.snapToGrid??a,u)},flowToScreenPosition:t=>{let{transform:n,domNode:r}=e.getState();if(!r)return t;let{x:i,y:a}=r.getBoundingClientRect(),o=sj(t,n);return{x:o.x+i,y:o.y+a}}}),[])};function ZN(e,t){let n=[],r=new Map,i=[];for(let t of e)if(t.type===`add`){i.push(t);continue}else if(t.type===`remove`||t.type===`replace`)r.set(t.id,[t]);else{let e=r.get(t.id);e?e.push(t):r.set(t.id,[t])}for(let e of t){let t=r.get(e.id);if(!t){n.push(e);continue}if(t[0].type===`remove`)continue;if(t[0].type===`replace`){n.push({...t[0].item});continue}let i={...e};for(let e of t)QN(e,i);n.push(i)}return i.length&&i.forEach(e=>{e.index===void 0?n.push({...e.item}):n.splice(e.index,0,{...e.item})}),n}function QN(e,t){switch(e.type){case`select`:t.selected=e.selected;break;case`position`:e.position!==void 0&&(t.position=e.position),e.dragging!==void 0&&(t.dragging=e.dragging);break;case`dimensions`:e.dimensions!==void 0&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes===`width`)&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes===`height`)&&(t.height=e.dimensions.height))),typeof e.resizing==`boolean`&&(t.resizing=e.resizing)}}function $N(e,t){return ZN(e,t)}function eP(e,t){return ZN(e,t)}function tP(e,t){return{id:e,type:`select`,selected:t}}function nP(e,t=new Set,n=!1){let r=[];for(let[i,a]of e){let e=t.has(i);(a.selected!==void 0||e)&&a.selected!==e&&(n&&(a.selected=e),r.push(tP(a.id,e)))}return r}function rP({items:e=[],lookup:t}){let n=[],r=new Map(e.map(e=>[e.id,e]));for(let[r,i]of e.entries()){let e=t.get(i.id),a=e?.internals?.userNode??e;a!==void 0&&a!==i&&n.push({id:i.id,item:i,type:`replace`}),a===void 0&&n.push({item:i,type:`add`,index:r})}for(let[e]of t)r.get(e)===void 0&&n.push({id:e,type:`remove`});return n}function iP(e){return{id:e.id,type:`remove`}}var aP=ij(`React Flow`,`https://reactflow.dev/`);function oP(e,t,n={}){return Rj(e,t,{...n,onError:n.onError??aP})}var sP=e=>MA(e),cP=e=>jA(e);function lP(e){return(0,_.forwardRef)(e)}var uP=typeof window<`u`?_.useLayoutEffect:_.useEffect;function dP(e){let[t,n]=(0,_.useState)(BigInt(0)),[r]=(0,_.useState)(()=>fP(()=>n(e=>e+BigInt(1))));return uP(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}function fP(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var pP=(0,_.createContext)(null);function mP({children:e}){let t=yN(),n=dP((0,_.useCallback)(e=>{let{nodes:n=[],setNodes:r,hasDefaultNodes:i,onNodesChange:a,nodeLookup:o,fitViewQueued:s,onNodesChangeMiddlewareMap:c}=t.getState(),l=n;for(let t of e)l=typeof t==`function`?t(l):t;let u=rP({items:l,lookup:o});for(let e of c.values())u=e(u);i&&r(l),u.length>0?a?.(u):s&&window.requestAnimationFrame(()=>{let{fitViewQueued:e,nodes:n,setNodes:r}=t.getState();e&&r(n)})},[])),r=dP((0,_.useCallback)(e=>{let{edges:n=[],setEdges:r,hasDefaultEdges:i,onEdgesChange:a,edgeLookup:o}=t.getState(),s=n;for(let t of e)s=typeof t==`function`?t(s):t;i?r(s):a&&a(rP({items:s,lookup:o}))},[])),i=(0,_.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,G.jsx)(pP.Provider,{value:i,children:e})}function hP(){let e=(0,_.useContext)(pP);if(!e)throw Error(`useBatchContext must be used within a BatchProvider`);return e}var gP=e=>!!e.panZoom;function _P(){let e=XN(),t=yN(),n=hP(),r=vN(gP),i=(0,_.useMemo)(()=>{let e=e=>t.getState().nodeLookup.get(e),r=e=>{n.nodeQueue.push(e)},i=e=>{n.edgeQueue.push(e)},a=e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState(),i=sP(e)?e:n.get(e.id),a=i.parentId?gj(i.position,i.measured,i.parentId,n,r):i.position;return ZA({...i,position:a,width:i.measured?.width??i.width,height:i.measured?.height??i.height})},o=(e,t,n={replace:!1})=>{r(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&sP(e)?e:{...r,...e}}return r}))},s=(e,t,n={replace:!1})=>{i(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&cP(e)?e:{...r,...e}}return r}))};return{getNodes:()=>t.getState().nodes.map(e=>({...e})),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{let{edges:e=[]}=t.getState();return e.map(e=>({...e}))},getEdge:e=>t.getState().edgeLookup.get(e),setNodes:r,setEdges:i,addNodes:e=>{let t=Array.isArray(e)?e:[e];n.nodeQueue.push(e=>[...e,...t])},addEdges:e=>{let t=Array.isArray(e)?e:[e];n.edgeQueue.push(e=>[...e,...t])},toObject:()=>{let{nodes:e=[],edges:n=[],transform:r}=t.getState(),[i,a,o]=r;return{nodes:e.map(e=>({...e})),edges:n.map(e=>({...e})),viewport:{x:i,y:a,zoom:o}}},deleteElements:async({nodes:e=[],edges:n=[]})=>{let{nodes:r,edges:i,onNodesDelete:a,onEdgesDelete:o,triggerNodeChanges:s,triggerEdgeChanges:c,onDelete:l,onBeforeDelete:u}=t.getState(),{nodes:d,edges:f}=await HA({nodesToRemove:e,edgesToRemove:n,nodes:r,edges:i,onBeforeDelete:u}),p=f.length>0,m=d.length>0;if(p){let e=f.map(iP);o?.(f),c(e)}if(m){let e=d.map(iP);a?.(d),s(e)}return(m||p)&&l?.({nodes:d,edges:f}),{deletedNodes:d,deletedEdges:f}},getIntersectingNodes:(e,n=!0,r)=>{let i=nj(e),o=i?e:a(e),s=r!==void 0;return o?(r||t.getState().nodes).filter(r=>{let a=t.getState().nodeLookup.get(r.id);if(a&&!i&&(r.id===e.id||!a.internals.positionAbsolute))return!1;let c=ZA(s?r:a),l=tj(c,o);return n&&l>0||l>=c.width*c.height||l>=o.width*o.height}):[]},isNodeIntersecting:(e,t,n=!0)=>{let r=nj(e)?e:a(e);if(!r)return!1;let i=tj(r,t);return n&&i>0||i>=t.width*t.height||i>=r.width*r.height},updateNode:o,updateNodeData:(e,t,n={replace:!1})=>{o(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},updateEdge:s,updateEdgeData:(e,t,n={replace:!1})=>{s(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},getNodesBounds:e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState();return FA(e,{nodeLookup:n,nodeOrigin:r})},getHandleConnections:({type:e,id:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}-${e}${n?`-${n}`:``}`)?.values()??[]),getNodeConnections:({type:e,handleId:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}${e?n?`-${e}-${n}`:`-${e}`:``}`)?.values()??[]),fitView:async e=>{let r=t.getState().fitViewResolver??vj();return t.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:r}),n.nodeQueue.push(e=>[...e]),r.promise}}},[]);return(0,_.useMemo)(()=>({...i,...e,viewportInitialized:r}),[r])}var vP=e=>e.selected,yP=typeof window<`u`?window:void 0;function bP({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=yN(),{deleteElements:r}=_P(),i=qN(e,{actInsideInputWithModifier:!1}),a=qN(t,{target:yP});(0,_.useEffect)(()=>{if(i){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter(vP),edges:e.filter(vP)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,_.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])}function xP(e){let t=yN();(0,_.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let n=Sj(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,bA.error004()),t.setState({width:n.width||500,height:n.height||500})};if(e.current){n(),window.addEventListener(`resize`,n);let t=new ResizeObserver(()=>n());return t.observe(e.current),()=>{window.removeEventListener(`resize`,n),t&&e.current&&t.unobserve(e.current)}}},[])}var SP={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},CP=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function wP({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panActivationKeyPressed:i,panOnScrollSpeed:a=.5,panOnScrollMode:o=TA.Free,zoomOnDoubleClick:s=!0,panOnDrag:c=!0,defaultViewport:l,translateExtent:u,minZoom:d,maxZoom:f,zoomActivationKeyCode:p,preventScrolling:m=!0,children:h,noWheelClassName:g,noPanClassName:v,onViewportChange:y,isControlledViewport:b,paneClickDistance:x,selectionOnDrag:S}){let C=yN(),w=(0,_.useRef)(null),{userSelectionActive:T,lib:E,connectionInProgress:D}=vN(CP,mN),O=qN(p),k=(0,_.useRef)();xP(w);let A=(0,_.useCallback)(e=>{y?.({x:e[0],y:e[1],zoom:e[2]}),b||C.setState({transform:e})},[y,b]);return(0,_.useEffect)(()=>{if(w.current){k.current=qM({domNode:w.current,minZoom:d,maxZoom:f,translateExtent:u,viewport:l,onDraggingChange:e=>C.setState(t=>t.paneDragging===e?t:{paneDragging:e}),onPanZoomStart:(e,t)=>{let{onViewportChangeStart:n,onMoveStart:r}=C.getState();r?.(e,t),n?.(t)},onPanZoom:(e,t)=>{let{onViewportChange:n,onMove:r}=C.getState();r?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{let{onViewportChangeEnd:n,onMoveEnd:r}=C.getState();r?.(e,t),n?.(t)}});let{x:e,y:t,zoom:n}=k.current.getViewport();return C.setState({panZoom:k.current,transform:[e,t,n],domNode:w.current.closest(`.react-flow`)}),()=>{k.current?.destroy()}}},[]),(0,_.useEffect)(()=>{k.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panActivationKeyPressed:i,panOnScrollSpeed:a,panOnScrollMode:o,zoomOnDoubleClick:s,panOnDrag:c,zoomActivationKeyPressed:O,preventScrolling:m,noPanClassName:v,userSelectionActive:T,noWheelClassName:g,lib:E,onTransformChange:A,connectionInProgress:D,selectionOnDrag:S,paneClickDistance:x})},[e,t,n,r,i,a,o,s,c,O,m,v,T,g,E,A,D,S,x]),(0,G.jsx)(`div`,{className:`react-flow__renderer`,ref:w,style:SP,children:h})}var TP=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function EP(){let{userSelectionActive:e,userSelectionRect:t}=vN(TP,mN);return e&&t?(0,G.jsx)(`div`,{className:`react-flow__selection react-flow__container`,style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}var DP=(e,t)=>n=>{n.target===t.current&&e?.(n)},OP=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function kP({isSelecting:e,selectionKeyPressed:t,selectionMode:n=EA.Full,panOnDrag:r,autoPanOnSelection:i,paneClickDistance:a,selectionOnDrag:o,onSelectionStart:s,onSelectionEnd:c,onPaneClick:l,onPaneContextMenu:u,onPaneScroll:d,onPaneMouseEnter:f,onPaneMouseMove:p,onPaneMouseLeave:m,children:h}){let g=(0,_.useRef)(0),v=yN(),{userSelectionActive:y,elementsSelectable:b,dragging:x,panBy:S,autoPanSpeed:C}=vN(OP,mN),w=b&&(e||y),T=(0,_.useRef)(null),E=(0,_.useRef)(),D=(0,_.useRef)(new Set),O=(0,_.useRef)(new Set),k=(0,_.useRef)(!1),A=(0,_.useRef)(!1),j=(0,_.useRef)({x:0,y:0}),M=(0,_.useRef)(!1),N=e=>{if(A.current||k.current||v.getState().connection.inProgress){A.current=!1,k.current=!1;return}l?.(e),v.getState().resetSelectedElements(),v.setState({nodesSelectionActive:!1})},P=e=>{if(Array.isArray(r)&&r?.includes(2)){e.preventDefault();return}u?.(e)},F=d?e=>d(e):void 0,I=e=>{A.current&&=(e.stopPropagation(),!1)},L=n=>{if(n.pointerType===`touch`&&r!==!1&&!t)return;let{domNode:i,transform:a}=v.getState();if(E.current=i?.getBoundingClientRect(),!E.current)return;let s=n.target===T.current;if(!s&&n.target.closest(`.nokey`)||!e||!(o&&s||t)||n.button!==0||!n.isPrimary)return;n.target?.setPointerCapture?.(n.pointerId),A.current=!1;let{x:c,y:l}=Dj(n.nativeEvent,E.current),u=oj({x:c,y:l},a);v.setState({userSelectionRect:{width:0,height:0,startX:u.x,startY:u.y,x:c,y:l}}),s||(n.stopPropagation(),n.preventDefault())};function R(e,t){let{userSelectionRect:r}=v.getState();if(!r)return;let{transform:i,nodeLookup:a,edgeLookup:o,connectionLookup:s,triggerNodeChanges:c,triggerEdgeChanges:l,defaultEdgeOptions:u}=v.getState(),d={x:r.startX,y:r.startY},{x:f,y:p}=sj(d,i),m={startX:d.x,startY:d.y,x:e<f?e:f,y:t<p?t:p,width:Math.abs(e-f),height:Math.abs(t-p)},h=D.current,g=O.current;D.current=new Set(LA(a,m,i,n===EA.Partial,!0).map(e=>e.id)),O.current=new Set;let _=u?.selectable??!0;for(let e of D.current){let t=s.get(e);if(t)for(let{edgeId:e}of t.values()){let t=o.get(e);t&&(t.selectable??_)&&O.current.add(e)}}_j(h,D.current)||c(nP(a,D.current,!0)),_j(g,O.current)||l(nP(o,O.current)),v.setState({userSelectionRect:m,userSelectionActive:!0,nodesSelectionActive:!1})}function z(){if(!i||!E.current)return;let[e,t]=qA(j.current,E.current,C);S({x:e,y:t}).then(e=>{if(!A.current||!e){g.current=requestAnimationFrame(z);return}let{x:t,y:n}=j.current;R(t,n),g.current=requestAnimationFrame(z)})}let B=()=>{cancelAnimationFrame(g.current),g.current=0,M.current=!1};(0,_.useEffect)(()=>()=>B(),[]);let V=e=>{let{userSelectionRect:n,transform:r,resetSelectedElements:i}=v.getState();if(!E.current||!n)return;let{x:o,y:c}=Dj(e.nativeEvent,E.current);j.current={x:o,y:c};let l=sj({x:n.startX,y:n.startY},r);if(!A.current){let n=t?0:a;if(Math.hypot(o-l.x,c-l.y)<=n)return;i(),s?.(e)}A.current=!0,M.current||=(z(),!0),R(o,c)},H=e=>{if(!w){e.target===T.current&&v.getState().connection.inProgress&&(k.current=!0);return}e.button===0&&(e.target?.releasePointerCapture?.(e.pointerId),!y&&e.target===T.current&&v.getState().userSelectionRect&&N?.(e),v.setState({userSelectionActive:!1,userSelectionRect:null}),A.current&&(c?.(e),v.setState({nodesSelectionActive:D.current.size>0})),B())},U=e=>{e.target?.releasePointerCapture?.(e.pointerId),B()},ee=r===!0||Array.isArray(r)&&r.includes(0);return(0,G.jsxs)(`div`,{className:Lw([`react-flow__pane`,{draggable:ee,dragging:x,selection:e}]),onClick:w?void 0:DP(N,T),onContextMenu:DP(P,T),onWheel:DP(F,T),onPointerEnter:w?void 0:f,onPointerMove:w?V:p,onPointerUp:H,onPointerCancel:w?U:void 0,onPointerDownCapture:w?L:void 0,onClickCapture:w?I:void 0,onPointerLeave:m,ref:T,style:SP,children:[h,(0,G.jsx)(EP,{})]})}function AP({id:e,store:t,unselect:n=!1,nodeRef:r}){let{addSelectedNodes:i,unselectNodesAndEdges:a,multiSelectionActive:o,nodeLookup:s,onError:c}=t.getState(),l=s.get(e);if(!l){c?.(`012`,bA.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function jP({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,nodeClickDistance:o}){let s=yN(),[c,l]=(0,_.useState)(!1),u=(0,_.useRef)();return(0,_.useEffect)(()=>{if(!t)return u.current=SM({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{AP({id:t,store:s,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}}),()=>{u.current?.destroy(),u.current=void 0}},[t,s,e]),(0,_.useEffect)(()=>{!t&&e.current&&u.current&&u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:i,nodeClickDistance:o})},[n,r,t,a,e,i,o]),c}var MP=e=>t=>t.selected&&(t.draggable||e&&t.draggable===void 0);function NP(){let e=yN();return(0,_.useCallback)(t=>{let{nodeExtent:n,snapToGrid:r,snapGrid:i,nodesDraggable:a,onError:o,updateNodePositions:s,nodeLookup:c,nodeOrigin:l}=e.getState(),u=new Map,d=MP(a),f=r?i[0]:5,p=r?i[1]:5,m=t.direction.x*f*t.factor,h=t.direction.y*p*t.factor;for(let[,e]of c){if(!d(e))continue;let t={x:e.internals.positionAbsolute.x+m,y:e.internals.positionAbsolute.y+h};r&&(t=aj(t,i));let{position:a,positionAbsolute:s}=VA({nodeId:e.id,nextPosition:t,nodeLookup:c,nodeExtent:n,nodeOrigin:l,onError:o});e.position=a,e.internals.positionAbsolute=s,u.set(e.id,e)}s(u)},[])}var PP=(0,_.createContext)(null),FP=PP.Provider;PP.Consumer;var IP=()=>(0,_.useContext)(PP),LP=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),RP=(0,_.createContext)(null);function zP({children:e}){let t=vN(LP,mN);return(0,G.jsx)(RP.Provider,{value:t,children:e})}function BP(){let e=(0,_.useContext)(RP);if(!e)throw Error(`useHandleConfig must be used within a HandleConfigProvider`);return e}var VP={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},HP=(e,t,n)=>r=>{let{connectionClickStartHandle:i,connectionMode:a,connection:o}=r,{fromHandle:s,toHandle:c,isValid:l}=o;if(!s&&!i)return VP;let u=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:s?.nodeId===e&&s?.id===t&&s?.type===n,connectingTo:u,clickConnecting:i?.nodeId===e&&i?.id===t&&i?.type===n,isPossibleEndHandle:a===wA.Strict?s?.type!==n:e!==s?.nodeId||t!==s?.id,connectionInProcess:!!s,clickConnectionInProcess:!!i,valid:u&&l}};function UP({type:e=`source`,position:t=$.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:a=!0,id:o,onConnect:s,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},p){let m=o||null,h=e===`target`,g=yN(),_=IP(),{connectOnClick:v,noPanClassName:y,rfId:b}=BP(),{connectingFrom:x,connectingTo:S,clickConnecting:C,isPossibleEndHandle:w,connectionInProcess:T,clickConnectionInProcess:E,valid:D}=vN(HP(_,m,e),mN);_||g.getState().onError?.(`010`,bA.error010());let O=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=g.getState(),i={...t,...e};if(r){let{edges:e,setEdges:t,onError:n}=g.getState();t(oP(i,e,{onError:n}))}n?.(i),s?.(i)},k=e=>{if(!_)return;let t=Ej(e.nativeEvent);if(i&&(t&&e.button===0||!t)){let t=g.getState();MM.onPointerDown(e.nativeEvent,{handleDomNode:e.currentTarget,autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNode:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:h,handleId:m,nodeId:_,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:(...e)=>g.getState().onConnectEnd?.(...e),updateConnection:t.updateConnection,onConnect:O,isValidConnection:n||((...e)=>g.getState().isValidConnection?.(...e)??!0),getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,autoPanSpeed:t.autoPanSpeed,dragThreshold:t.connectionDragThreshold})}t?u?.(e):d?.(e)};return(0,G.jsx)(`div`,{"data-handleid":m,"data-nodeid":_,"data-handlepos":t,"data-id":`${b}-${_}-${m}-${e}`,className:Lw([`react-flow__handle`,`react-flow__handle-${t}`,`nodrag`,y,l,{source:!h,target:h,connectable:r,connectablestart:i,connectableend:a,clickconnecting:C,connectingfrom:x,connectingto:S,valid:D,connectionindicator:r&&(!T||w)&&(T||E?a:i)}]),onMouseDown:k,onTouchStart:k,onClick:v?t=>{let{onClickConnectStart:r,onClickConnectEnd:a,connectionClickStartHandle:o,connectionMode:s,isValidConnection:c,lib:l,rfId:u,nodeLookup:d,connection:f}=g.getState();if(!_||!o&&!i)return;if(!o){r?.(t.nativeEvent,{nodeId:_,handleId:m,handleType:e}),g.setState({connectionClickStartHandle:{nodeId:_,type:e,id:m}});return}let p=Cj(t.target),h=n||c,{connection:v,isValid:y}=MM.isValid(t.nativeEvent,{handle:{nodeId:_,id:m,type:e},connectionMode:s,fromNodeId:o.nodeId,fromHandleId:o.id||null,fromType:o.type,isValidConnection:h,flowId:u,doc:p,lib:l,nodeLookup:d});y&&v&&O(v);let b=structuredClone(f);delete b.inProgress,b.toPosition=b.toHandle?b.toHandle.position:null,a?.(t,b),g.setState({connectionClickStartHandle:null})}:void 0,ref:p,...f,children:c})}var WP=(0,_.memo)(lP(UP));function GP({data:e,isConnectable:t,sourcePosition:n=$.Bottom}){return(0,G.jsxs)(G.Fragment,{children:[e?.label,(0,G.jsx)(WP,{type:`source`,position:n,isConnectable:t})]})}function KP({data:e,isConnectable:t,targetPosition:n=$.Top,sourcePosition:r=$.Bottom}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(WP,{type:`target`,position:n,isConnectable:t}),e?.label,(0,G.jsx)(WP,{type:`source`,position:r,isConnectable:t})]})}function qP(){return null}function JP({data:e,isConnectable:t,targetPosition:n=$.Top}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(WP,{type:`target`,position:n,isConnectable:t}),e?.label]})}var YP={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},XP={input:GP,default:KP,output:JP,group:qP};function ZP(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}var QP=e=>{let{width:t,height:n,x:r,y:i}=IA(e.nodeLookup,{filter:e=>!!e.selected});return{width:rj(t)?t:null,height:rj(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${i}px)`}};function $P({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=yN(),{width:i,height:a,transformString:o,userSelectionActive:s}=vN(QP,mN),c=NP(),l=(0,_.useRef)(null);(0,_.useEffect)(()=>{n||l.current?.focus({preventScroll:!0})},[n]);let u=!s&&i!==null&&a!==null;if(jP({nodeRef:l,disabled:!u}),!u)return null;let d=e?t=>{e(t,r.getState().nodes.filter(e=>e.selected))}:void 0;return(0,G.jsx)(`div`,{className:Lw([`react-flow__nodesselection`,`react-flow__container`,t]),style:{transform:o},children:(0,G.jsx)(`div`,{ref:l,className:`react-flow__nodesselection-rect`,onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(YP,e.key)&&(e.preventDefault(),c({direction:YP[e.key],factor:e.shiftKey?4:1}))},style:{width:i,height:a}})})}var eF=typeof window<`u`?window:void 0,tF=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function nF({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,paneClickDistance:s,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:d,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:h,zoomActivationKeyCode:g,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:b,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:w,autoPanOnSelection:T,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,preventScrolling:A,onSelectionContextMenu:j,noWheelClassName:M,noPanClassName:N,disableKeyboardA11y:P,onViewportChange:F,isControlledViewport:I}){let{nodesSelectionActive:L,userSelectionActive:R}=vN(tF,mN),z=qN(l,{target:eF}),B=qN(h,{target:eF}),V=B||w,H=B||b,U=u&&V!==!0,ee=z||R||U;return bP({deleteKeyCode:c,multiSelectionKeyCode:m}),(0,G.jsx)(wP,{onPaneContextMenu:a,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:H,panActivationKeyPressed:B,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!z&&V,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,zoomActivationKeyCode:g,preventScrolling:A,noWheelClassName:M,noPanClassName:N,onViewportChange:F,isControlledViewport:I,paneClickDistance:s,selectionOnDrag:U,children:(0,G.jsxs)(kP,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:V,autoPanOnSelection:T,isSelecting:!!ee,selectionMode:d,selectionKeyPressed:z,paneClickDistance:s,selectionOnDrag:U,children:[e,L&&(0,G.jsx)($P,{onSelectionContextMenu:j,noPanClassName:N,disableKeyboardA11y:P})]})})}nF.displayName=`FlowRenderer`;var rF=(0,_.memo)(nF),iF=e=>t=>e?LA(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(e=>e.id):Array.from(t.nodeLookup.keys());function aF(e){return vN((0,_.useCallback)(iF(e),[e]),mN)}var oF=e=>e.updateNodeInternals;function sF(){let e=vN(oF),[t]=(0,_.useState)(()=>typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{let n=new Map;t.forEach(e=>{let t=e.target.getAttribute(`data-id`);n.set(t,{id:t,nodeElement:e.target,force:!0})}),e(n)}));return(0,_.useEffect)(()=>()=>{t?.disconnect()},[t]),t}function cF({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let i=yN(),a=(0,_.useRef)(null),o=(0,_.useRef)(null),s=(0,_.useRef)(e.sourcePosition),c=(0,_.useRef)(e.targetPosition),l=(0,_.useRef)(t),u=n&&!!e.internals.handleBounds;return(0,_.useEffect)(()=>{a.current&&!e.hidden&&(!u||o.current!==a.current)&&(o.current&&r?.unobserve(o.current),r?.observe(a.current),o.current=a.current)},[u,e.hidden]),(0,_.useEffect)(()=>()=>{o.current&&=(r?.unobserve(o.current),null)},[]),(0,_.useEffect)(()=>{if(a.current){let n=l.current!==t,r=s.current!==e.sourcePosition,o=c.current!==e.targetPosition;(n||r||o)&&(l.current=t,s.current=e.sourcePosition,c.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function lF({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:i,onContextMenu:a,onDoubleClick:o,nodesDraggable:s,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:d,noDragClassName:f,noPanClassName:p,disableKeyboardA11y:m,rfId:h,nodeTypes:g,nodeClickDistance:_,onError:v}){let{node:y,internals:b,isParent:x}=vN(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},mN),S=y.type||`default`,C=g?.[S]||XP[S];C===void 0&&(v?.(`003`,bA.error003(S)),S=`default`,C=g?.default||XP.default);let w=!!(y.draggable||s&&y.draggable===void 0),T=!!(y.selectable||c&&y.selectable===void 0),E=!!(y.connectable||l&&y.connectable===void 0),D=!!(y.focusable||u&&y.focusable===void 0),O=yN(),k=hj(y),A=cF({node:y,nodeType:S,hasDimensions:k,resizeObserver:d}),j=jP({nodeRef:A,disabled:y.hidden||!w,noDragClassName:f,handleSelector:y.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:_}),M=NP();if(y.hidden)return null;let N=mj(y),P=ZP(y),F=T||w||t||n||r||i,I=n?e=>n(e,{...b.userNode}):void 0,L=r?e=>r(e,{...b.userNode}):void 0,R=i?e=>i(e,{...b.userNode}):void 0,z=a?e=>a(e,{...b.userNode}):void 0,B=o?e=>o(e,{...b.userNode}):void 0,V=n=>{let{selectNodesOnDrag:r,nodeDragThreshold:i}=O.getState();T&&(!r||!w||i>0)&&AP({id:e,store:O,nodeRef:A}),t&&t(n,{...b.userNode})},H=t=>{if(!(Tj(t.nativeEvent)||m)){if(SA.includes(t.key)&&T){let n=t.key===`Escape`;AP({id:e,store:O,unselect:n,nodeRef:A})}else if(w&&y.selected&&Object.prototype.hasOwnProperty.call(YP,t.key)){t.preventDefault();let{ariaLabelConfig:e}=O.getState();O.setState({ariaLiveMessage:e[`node.a11yDescription.ariaLiveMessage`]({direction:t.key.replace(`Arrow`,``).toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),M({direction:YP[t.key],factor:t.shiftKey?4:1})}}},U=()=>{if(m||!A.current?.matches(`:focus-visible`))return;let{transform:t,width:n,height:r,autoPanOnNodeFocus:i,setCenter:a}=O.getState();i&&(LA(new Map([[e,y]]),{x:0,y:0,width:n,height:r},t,!0).length>0||a(y.position.x+N.width/2,y.position.y+N.height/2,{zoom:t[2]}))};return(0,G.jsx)(`div`,{className:Lw([`react-flow__node`,`react-flow__node-${S}`,{[p]:w},y.className,{selected:y.selected,selectable:T,parent:x,draggable:w,dragging:j}]),ref:A,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:F?`all`:`none`,visibility:k?`visible`:`hidden`,...y.style,...P},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:I,onMouseMove:L,onMouseLeave:R,onContextMenu:z,onClick:V,onDoubleClick:B,onKeyDown:D?H:void 0,tabIndex:D?0:void 0,onFocus:D?U:void 0,role:y.ariaRole??(D?`group`:void 0),"aria-roledescription":`node`,"aria-describedby":m?void 0:`${SN}-${h}`,"aria-label":y.ariaLabel,...y.domAttributes,children:(0,G.jsx)(FP,{value:e,children:(0,G.jsx)(C,{id:e,data:y.data,type:S,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:y.selected??!1,selectable:T,draggable:w,deletable:y.deletable??!0,isConnectable:E,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:j,dragHandle:y.dragHandle,zIndex:b.z,parentId:y.parentId,...N})})})}var uF=(0,_.memo)(lF),dF=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function fF(e){let{nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,onError:i}=vN(dF,mN),a=aF(e.onlyRenderVisibleElements),o=sF();return(0,G.jsx)(`div`,{className:`react-flow__nodes`,style:SP,children:a.map(a=>(0,G.jsx)(uF,{id:a,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:o,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:i},a))})}fF.displayName=`NodeRenderer`;var pF=(0,_.memo)(fF);function mF(e){return vN((0,_.useCallback)(t=>{if(!e)return t.edges.map(e=>e.id);let n=[];if(t.width&&t.height)for(let e of t.edges){let r=t.nodeLookup.get(e.source),i=t.nodeLookup.get(e.target);r&&i&&Fj({sourceNode:r,targetNode:i,width:t.width,height:t.height,transform:t.transform})&&n.push(e.id)}return n},[e]),mN)}var hF=({color:e=`none`,strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e}};return(0,G.jsx)(`polyline`,{className:`arrow`,style:n,strokeLinecap:`round`,fill:`none`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4`})},gF=({color:e=`none`,strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e,fill:e}};return(0,G.jsx)(`polyline`,{className:`arrowclosed`,style:n,strokeLinecap:`round`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4 -5,-4`})},_F={[kA.Arrow]:hF,[kA.ArrowClosed]:gF};function vF(e){let t=yN();return(0,_.useMemo)(()=>Object.prototype.hasOwnProperty.call(_F,e)?_F[e]:(t.getState().onError?.(`009`,bA.error009(e)),null),[e])}var yF=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:a=`strokeWidth`,strokeWidth:o,orient:s=`auto-start-reverse`})=>{let c=vF(t);return c?(0,G.jsx)(`marker`,{className:`react-flow__arrowhead`,id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:`-10 -10 20 20`,markerUnits:a,orient:s,refX:`0`,refY:`0`,children:(0,G.jsx)(c,{color:n,strokeWidth:o})}):null},bF=({defaultColor:e,rfId:t})=>{let n=vN(e=>e.edges),r=vN(e=>e.defaultEdgeOptions),i=(0,_.useMemo)(()=>Qj(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return i.length?(0,G.jsx)(`svg`,{className:`react-flow__marker`,"aria-hidden":`true`,children:(0,G.jsx)(`defs`,{children:i.map(e=>(0,G.jsx)(yF,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id))})}):null};bF.displayName=`MarkerDefinitions`;var xF=(0,_.memo)(bF);function SF({x:e,y:t,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:a,labelBgPadding:o=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...u}){let[d,f]=(0,_.useState)({x:1,y:0,width:0,height:0}),p=Lw([`react-flow__edge-textwrapper`,l]),m=(0,_.useRef)(null);return(0,_.useEffect)(()=>{if(m.current){let e=m.current.getBBox();f({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),n?(0,G.jsxs)(`g`,{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:p,visibility:d.width?`visible`:`hidden`,...u,children:[i&&(0,G.jsx)(`rect`,{width:d.width+2*o[0],x:-o[0],y:-o[1],height:d.height+2*o[1],className:`react-flow__edge-textbg`,style:a,rx:s,ry:s}),(0,G.jsx)(`text`,{className:`react-flow__edge-text`,y:d.height/2,dy:`0.3em`,ref:m,style:r,children:n}),c]}):null}SF.displayName=`EdgeText`;var CF=(0,_.memo)(SF);function wF({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`path`,{...u,d:e,fill:`none`,className:Lw([`react-flow__edge-path`,u.className])}),l?(0,G.jsx)(`path`,{d:e,fill:`none`,strokeOpacity:0,strokeWidth:l,className:`react-flow__edge-interaction`}):null,r&&rj(t)&&rj(n)?(0,G.jsx)(CF,{x:t,y:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function TF({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===$.Left||e===$.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function EF({sourceX:e,sourceY:t,sourcePosition:n=$.Bottom,targetX:r,targetY:i,targetPosition:a=$.Top}){let[o,s]=TF({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=TF({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=kj({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:o,sourceControlY:s,targetControlX:c,targetControlY:l});return[`M${e},${t} C${o},${s} ${c},${l} ${r},${i}`,u,d,f,p]}function DF(e){return(0,_.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o,targetPosition:s,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})=>{let[v,y,b]=EF({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s}),x=e.isInternal?void 0:t;return(0,G.jsx)(wF,{id:x,path:v,labelX:y,labelY:b,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})})}var OF=DF({isInternal:!1}),kF=DF({isInternal:!0});OF.displayName=`SimpleBezierEdge`,kF.displayName=`SimpleBezierEdgeInternal`;function AF(e){return(0,_.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,sourcePosition:p=$.Bottom,targetPosition:m=$.Top,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=Gj({sourceX:n,sourceY:r,sourcePosition:p,targetX:i,targetY:a,targetPosition:m,borderRadius:_?.borderRadius,offset:_?.offset,stepPosition:_?.stepPosition}),S=e.isInternal?void 0:t;return(0,G.jsx)(wF,{id:S,path:y,labelX:b,labelY:x,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})})}var jF=AF({isInternal:!1}),MF=AF({isInternal:!0});jF.displayName=`SmoothStepEdge`,MF.displayName=`SmoothStepEdgeInternal`;function NF(e){return(0,_.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,G.jsx)(jF,{...n,id:r,pathOptions:(0,_.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var PF=NF({isInternal:!1}),FF=NF({isInternal:!0});PF.displayName=`StepEdge`,FF.displayName=`StepEdgeInternal`;function IF(e){return(0,_.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})=>{let[g,_,v]=zj({sourceX:n,sourceY:r,targetX:i,targetY:a}),y=e.isInternal?void 0:t;return(0,G.jsx)(wF,{id:y,path:g,labelX:_,labelY:v,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})})}var LF=IF({isInternal:!1}),RF=IF({isInternal:!0});LF.displayName=`StraightEdge`,RF.displayName=`StraightEdgeInternal`;function zF(e){return(0,_.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o=$.Bottom,targetPosition:s=$.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=Mj({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s,curvature:_?.curvature}),S=e.isInternal?void 0:t;return(0,G.jsx)(wF,{id:S,path:y,labelX:b,labelY:x,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:v})})}var BF=zF({isInternal:!1}),VF=zF({isInternal:!0});BF.displayName=`BezierEdge`,VF.displayName=`BezierEdgeInternal`;var HF={default:VF,straight:RF,step:FF,smoothstep:MF,simplebezier:kF},UF={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},WF=(e,t,n)=>n===$.Left?e-t:n===$.Right?e+t:e,GF=(e,t,n)=>n===$.Top?e-t:n===$.Bottom?e+t:e,KF=`react-flow__edgeupdater`;function qF({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s}){return(0,G.jsx)(`circle`,{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:Lw([KF,`${KF}-${s}`]),cx:WF(t,r,e),cy:GF(n,r,e),r,stroke:`transparent`,fill:`transparent`})}function JF({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:i,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:d,setReconnecting:f,setUpdateHover:p}){let m=yN(),h=(e,t)=>{if(e.button!==0)return;let{autoPanOnConnect:r,domNode:i,connectionMode:a,connectionRadius:o,lib:s,onConnectStart:c,cancelConnection:p,nodeLookup:h,rfId:g,panBy:_,updateConnection:v}=m.getState(),y=t.type===`target`;MM.onPointerDown(e.nativeEvent,{autoPanOnConnect:r,connectionMode:a,connectionRadius:o,domNode:i,handleId:t.id,nodeId:t.nodeId,nodeLookup:h,isTarget:y,edgeUpdaterType:t.type,lib:s,flowId:g,cancelConnection:p,panBy:_,isValidConnection:(...e)=>m.getState().isValidConnection?.(...e)??!0,onConnect:e=>l?.(n,e),onConnectStart:(r,i)=>{f(!0),u?.(e,n,t.type),c?.(r,i)},onConnectEnd:(...e)=>m.getState().onConnectEnd?.(...e),onReconnectEnd:(e,r)=>{f(!1),d?.(e,n,t.type,r)},updateConnection:v,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:e.currentTarget})},g=e=>h(e,{nodeId:n.target,id:n.targetHandle??null,type:`target`}),_=e=>h(e,{nodeId:n.source,id:n.sourceHandle??null,type:`source`}),v=()=>p(!0),y=()=>p(!1);return(0,G.jsxs)(G.Fragment,{children:[(e===!0||e===`source`)&&(0,G.jsx)(qF,{position:s,centerX:r,centerY:i,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:y,type:`source`}),(e===!0||e===`target`)&&(0,G.jsx)(qF,{position:c,centerX:a,centerY:o,radius:t,onMouseDown:_,onMouseEnter:v,onMouseOut:y,type:`target`})]})}function YF({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:i,onDoubleClick:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,rfId:m,edgeTypes:h,noPanClassName:g,onError:v,disableKeyboardA11y:y}){let b=vN(t=>t.edgeLookup.get(e)),x=vN(e=>e.defaultEdgeOptions);b=x?{...x,...b}:b;let S=b.type||`default`,C=h?.[S]||HF[S];C===void 0&&(v?.(`011`,bA.error011(S)),S=`default`,C=h?.default||HF.default);let w=!!(b.focusable||t&&b.focusable===void 0),T=d!==void 0&&(b.reconnectable||n&&b.reconnectable===void 0),E=!!(b.selectable||r&&b.selectable===void 0),D=(0,_.useRef)(null),[O,k]=(0,_.useState)(!1),[A,j]=(0,_.useState)(!1),M=yN(),{zIndex:N=b.zIndex,sourceX:P,sourceY:F,targetX:I,targetY:L,sourcePosition:R,targetPosition:z}=vN((0,_.useCallback)(t=>{let n=t.nodeLookup.get(b.source),r=t.nodeLookup.get(b.target);if(!n||!r)return UF;let i=qj({id:e,sourceNode:n,targetNode:r,sourceHandle:b.sourceHandle||null,targetHandle:b.targetHandle||null,connectionMode:t.connectionMode,onError:v}),a=Pj({selected:b.selected,zIndex:b.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode});return{...i||UF,zIndex:a}},[b.source,b.target,b.sourceHandle,b.targetHandle,b.selected,b.zIndex,v]),mN),B=(0,_.useMemo)(()=>b.markerStart?`url('#${Zj(b.markerStart,m)}')`:void 0,[b.markerStart,m]),V=(0,_.useMemo)(()=>b.markerEnd?`url('#${Zj(b.markerEnd,m)}')`:void 0,[b.markerEnd,m]);if(b.hidden||P===null||F===null||I===null||L===null)return null;let H=t=>{let{addSelectedEdges:n,unselectNodesAndEdges:r,multiSelectionActive:a}=M.getState();E&&(M.setState({nodesSelectionActive:!1}),b.selected&&a?(r({nodes:[],edges:[b]}),D.current?.blur()):n([e])),i&&i(t,b)},U=a?e=>{a(e,{...b})}:void 0,ee=o?e=>{o(e,{...b})}:void 0,W=s?e=>{s(e,{...b})}:void 0,te=c?e=>{c(e,{...b})}:void 0,ne=l?e=>{l(e,{...b})}:void 0;return(0,G.jsx)(`svg`,{style:{zIndex:N},children:(0,G.jsxs)(`g`,{className:Lw([`react-flow__edge`,`react-flow__edge-${S}`,b.className,g,{selected:b.selected,animated:b.animated,inactive:!E&&!i,updating:O,selectable:E}]),onClick:H,onDoubleClick:U,onContextMenu:ee,onMouseEnter:W,onMouseMove:te,onMouseLeave:ne,onKeyDown:w?t=>{if(!y&&SA.includes(t.key)&&E){let{unselectNodesAndEdges:n,addSelectedEdges:r}=M.getState();t.key===`Escape`?(D.current?.blur(),n({edges:[b]})):r([e])}}:void 0,tabIndex:w?0:void 0,role:b.ariaRole??(w?`group`:`img`),"aria-roledescription":`edge`,"data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":b.ariaLabel===null?void 0:b.ariaLabel||`Edge from ${b.source} to ${b.target}`,"aria-describedby":w?`${CN}-${m}`:void 0,ref:D,...b.domAttributes,children:[!A&&(0,G.jsx)(C,{id:e,source:b.source,target:b.target,type:b.type,selected:b.selected,animated:b.animated,selectable:E,deletable:b.deletable??!0,label:b.label,labelStyle:b.labelStyle,labelShowBg:b.labelShowBg,labelBgStyle:b.labelBgStyle,labelBgPadding:b.labelBgPadding,labelBgBorderRadius:b.labelBgBorderRadius,sourceX:P,sourceY:F,targetX:I,targetY:L,sourcePosition:R,targetPosition:z,data:b.data,style:b.style,sourceHandleId:b.sourceHandle,targetHandleId:b.targetHandle,markerStart:B,markerEnd:V,pathOptions:`pathOptions`in b?b.pathOptions:void 0,interactionWidth:b.interactionWidth}),T&&(0,G.jsx)(JF,{edge:b,isReconnectable:T,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,sourceX:P,sourceY:F,targetX:I,targetY:L,sourcePosition:R,targetPosition:z,setUpdateHover:k,setReconnecting:j})]})})}var XF=(0,_.memo)(YF),ZF=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function QF({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:i,onReconnect:a,onEdgeContextMenu:o,onEdgeMouseEnter:s,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:d,onEdgeDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:h}){let{edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,onError:y}=vN(ZF,mN),b=mF(t);return(0,G.jsxs)(`div`,{className:`react-flow__edges`,children:[(0,G.jsx)(xF,{defaultColor:e,rfId:n}),b.map(e=>(0,G.jsx)(XF,{id:e,edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,noPanClassName:i,onReconnect:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:d,onDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,rfId:n,onError:y,edgeTypes:r,disableKeyboardA11y:h},e))]})}QF.displayName=`EdgeRenderer`;var $F=(0,_.memo)(QF),eI=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function tI({children:e}){let t=yN(),n=(0,_.useRef)(null),[r]=(0,_.useState)(()=>t.getState().transform);return uP(()=>{let e=null,r=()=>{let r=t.getState().transform;e&&r[0]===e[0]&&r[1]===e[1]&&r[2]===e[2]||(e=r,n.current&&(n.current.style.transform=eI(r)))};return r(),t.subscribe(r)},[t]),(0,G.jsx)(`div`,{ref:n,className:`react-flow__viewport xyflow__viewport react-flow__container`,style:{transform:eI(r)},children:e})}function nI(e){let t=_P(),n=(0,_.useRef)(!1);(0,_.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var rI=e=>e.panZoom?.syncViewport;function iI(e){let t=vN(rI),n=yN();return(0,_.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function aI(e){return e.connection.inProgress?{...e.connection,to:oj(e.connection.to,e.transform)}:{...e.connection}}function oI(e){return e?t=>e(aI(t)):aI}function sI(e){return vN(oI(e),mN)}var cI=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function lI({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:i,width:a,height:o,isValid:s,inProgress:c}=vN(cI,mN);return a&&i&&c?(0,G.jsx)(`svg`,{style:e,width:a,height:o,className:`react-flow__connectionline react-flow__container`,children:(0,G.jsx)(`g`,{className:Lw([`react-flow__connection`,bj(s)]),children:(0,G.jsx)(uI,{style:t,type:n,CustomComponent:r,isValid:s})})}):null}var uI=({style:e,type:t=OA.Bezier,CustomComponent:n,isValid:r})=>{let{inProgress:i,from:a,fromNode:o,fromHandle:s,fromPosition:c,to:l,toNode:u,toHandle:d,toPosition:f,pointer:p}=sI();if(!i)return;if(n)return(0,G.jsx)(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:s,fromX:a.x,fromY:a.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:bj(r),toNode:u,toHandle:d,pointer:p});let m=``,h={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case OA.Bezier:[m]=Mj(h);break;case OA.SimpleBezier:[m]=EF(h);break;case OA.Step:[m]=Gj({...h,borderRadius:0});break;case OA.SmoothStep:[m]=Gj(h);break;default:[m]=zj(h)}return(0,G.jsx)(`path`,{d:m,fill:`none`,className:`react-flow__connection-path`,style:e})};uI.displayName=`ConnectionLine`;var dI={};function fI(e=dI){(0,_.useRef)(e),yN(),(0,_.useEffect)(()=>{},[e])}function pI(){yN(),(0,_.useRef)(!1),(0,_.useEffect)(()=>{},[])}function mI({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:a,onEdgeDoubleClick:o,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:h,connectionLineComponent:g,connectionLineContainerStyle:_,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,deleteKeyCode:w,onlyRenderVisibleElements:T,elementsSelectable:E,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,preventScrolling:j,defaultMarkerColor:M,zoomOnScroll:N,zoomOnPinch:P,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,zoomOnDoubleClick:R,panOnDrag:z,autoPanOnSelection:B,onPaneClick:V,onPaneMouseEnter:H,onPaneMouseMove:U,onPaneMouseLeave:ee,onPaneScroll:W,onPaneContextMenu:te,paneClickDistance:ne,nodeClickDistance:re,onEdgeContextMenu:ie,onEdgeMouseEnter:ae,onEdgeMouseMove:oe,onEdgeMouseLeave:se,reconnectRadius:ce,onReconnect:le,onReconnectStart:ue,onReconnectEnd:de,noDragClassName:fe,noWheelClassName:pe,noPanClassName:me,disableKeyboardA11y:he,nodeExtent:ge,rfId:_e,viewport:ve,onViewportChange:ye,nodesDraggable:be}){return fI(e),fI(t),pI(),nI(n),iI(ve),(0,G.jsx)(rF,{onPaneClick:V,onPaneMouseEnter:H,onPaneMouseMove:U,onPaneMouseLeave:ee,onPaneContextMenu:te,onPaneScroll:W,paneClickDistance:ne,deleteKeyCode:w,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,elementsSelectable:E,zoomOnScroll:N,zoomOnPinch:P,zoomOnDoubleClick:R,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,panOnDrag:z,autoPanOnSelection:B,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,onSelectionContextMenu:d,preventScrolling:j,noDragClassName:fe,noWheelClassName:pe,noPanClassName:me,disableKeyboardA11y:he,onViewportChange:ye,isControlledViewport:!!ve,children:(0,G.jsxs)(tI,{children:[(0,G.jsx)($F,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:le,onReconnectStart:ue,onReconnectEnd:de,onlyRenderVisibleElements:T,onEdgeContextMenu:ie,onEdgeMouseEnter:ae,onEdgeMouseMove:oe,onEdgeMouseLeave:se,reconnectRadius:ce,defaultMarkerColor:M,noPanClassName:me,disableKeyboardA11y:he,rfId:_e}),(0,G.jsx)(lI,{style:h,type:m,component:g,containerStyle:_}),(0,G.jsx)(`div`,{className:`react-flow__edgelabel-renderer`}),(0,G.jsx)(pF,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:re,onlyRenderVisibleElements:T,noPanClassName:me,noDragClassName:fe,disableKeyboardA11y:he,nodeExtent:ge,rfId:_e,nodesDraggable:be}),(0,G.jsx)(`div`,{className:`react-flow__viewport-portal`})]})})}mI.displayName=`GraphView`;var hI=(0,_.memo)(mI),gI=ij(`React Flow`,`https://reactflow.dev/`),_I=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c=.5,maxZoom:l=2,nodeOrigin:u,nodeExtent:d,zIndexMode:f=`basic`}={})=>{let p=new Map,m=new Map,h=new Map,g=new Map,_=r??t??[],v=n??e??[],y=u??[0,0],b=d??xA;gM(h,g,_);let{nodesInitialized:x}=sM(v,p,m,{nodeOrigin:y,nodeExtent:b,zIndexMode:f}),S=[0,0,1];if(o&&i&&a){let{x:e,y:t,zoom:n}=dj(IA(p,{filter:e=>!(!e.width&&!e.initialWidth||!e.height&&!e.initialHeight)}),i,a,c,l,s?.padding??.1);S=[e,t,n]}return{rfId:`1`,width:i??0,height:a??0,transform:S,nodes:v,nodesInitialized:x,nodeLookup:p,parentLookup:m,edges:_,edgeLookup:g,connectionLookup:h,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:xA,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:wA.Strict,domNode:null,paneDragging:!1,noPanClassName:`nopan`,nodeOrigin:y,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:o??!1,fitViewOptions:s,fitViewResolver:null,connection:{...DA},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:gI,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:`react`,debug:!1,ariaLabelConfig:CA,zIndexMode:f,defaultEdgeOptions:void 0,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map,onNodesDelete:void 0,onEdgesDelete:void 0,onDelete:void 0,onBeforeDelete:void 0,onViewportChangeStart:void 0,onViewportChange:void 0,onViewportChangeEnd:void 0,onNodeDragStart:void 0,onNodeDrag:void 0,onNodeDragStop:void 0,onSelectionDragStart:void 0,onSelectionDrag:void 0,onSelectionDragStop:void 0,onMoveStart:void 0,onMove:void 0,onMoveEnd:void 0,onConnect:void 0,onConnectStart:void 0,onConnectEnd:void 0,onClickConnectStart:void 0,onClickConnectEnd:void 0}},vI=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f})=>pN((p,m)=>{async function h(){let{nodeLookup:e,panZoom:t,fitViewOptions:n,fitViewResolver:r,width:i,height:a,minZoom:o,maxZoom:s}=m();t&&(await BA({nodes:e,width:i,height:a,panZoom:t,minZoom:o,maxZoom:s},n),r?.resolve(!0),p({fitViewResolver:null}))}return{..._I({nodes:e,edges:t,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:e=>{let{nodeLookup:t,parentLookup:n,nodeOrigin:r,nodeExtent:i,elevateNodesOnSelect:a,fitViewQueued:o,zIndexMode:s,nodesSelectionActive:c}=m(),{nodesInitialized:l,hasSelectedNodes:u}=sM(e,t,n,{nodeOrigin:r,nodeExtent:i,elevateNodesOnSelect:a,checkEquality:!0,zIndexMode:s}),d=c&&u;o&&l?(h(),p({nodes:e,nodesInitialized:l,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:d})):p({nodes:e,nodesInitialized:l,nodesSelectionActive:d})},setEdges:e=>{let{connectionLookup:t,edgeLookup:n}=m();gM(t,n,e),p({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){let{setNodes:t}=m();t(e),p({hasDefaultNodes:!0})}if(t){let{setEdges:e}=m();e(t),p({hasDefaultEdges:!0})}},updateNodeInternals:e=>{let{triggerNodeChanges:t,nodeLookup:n,parentLookup:r,domNode:i,nodeOrigin:a,nodeExtent:o,debug:s,fitViewQueued:c,zIndexMode:l}=m(),{changes:u,updatedInternals:d}=pM(e,n,r,i,a,o,l);d&&(iM(n,r,{nodeOrigin:a,nodeExtent:o,zIndexMode:l}),c?(h(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),u?.length>0&&(s&&console.log(`React Flow: trigger node changes`,u),t?.(u)))},updateNodePositions:(e,t=!1)=>{let n=[],r=[],{nodeLookup:i,triggerNodeChanges:a,connection:o,updateConnection:s,onNodesChangeMiddlewareMap:c}=m();for(let[a,c]of e){let e=i.get(a),l=!!(e?.expandParent&&e?.parentId&&c?.position),u={id:a,type:`position`,position:l?{x:Math.max(0,c.position.x),y:Math.max(0,c.position.y)}:c.position,dragging:t};if(e&&o.inProgress&&o.fromNode.id===e.id){let t=Yj(e,o.fromHandle,$.Left,!0);s({...o,from:t})}l&&e.parentId&&n.push({id:a,parentId:e.parentId,rect:{...c.internals.positionAbsolute,width:c.measured.width??0,height:c.measured.height??0}}),r.push(u)}if(n.length>0){let{parentLookup:e,nodeOrigin:t}=m(),a=fM(n,i,e,t);r.push(...a)}for(let e of c.values())r=e(r);a(r)},triggerNodeChanges:e=>{let{onNodesChange:t,setNodes:n,nodes:r,hasDefaultNodes:i,debug:a}=m();e?.length&&(i&&n($N(e,r)),a&&console.log(`React Flow: trigger node changes`,e),t?.(e))},triggerEdgeChanges:e=>{let{onEdgesChange:t,setEdges:n,edges:r,hasDefaultEdges:i,debug:a}=m();e?.length&&(i&&n(eP(e,r)),a&&console.log(`React Flow: trigger edge changes`,e),t?.(e))},addSelectedNodes:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){i(e.map(e=>tP(e,!0)));return}i(nP(r,new Set([...e]),!0)),a(nP(n))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){a(e.map(e=>tP(e,!0)));return}a(nP(n,new Set([...e]))),i(nP(r,new Set,!0))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{let{edges:n,nodes:r,nodeLookup:i,triggerNodeChanges:a,triggerEdgeChanges:o}=m(),s=e||r,c=t||n,l=[];for(let e of s){if(!e.selected)continue;let t=i.get(e.id);t&&(t.selected=!1),l.push(tP(e.id,!1))}let u=[];for(let e of c)e.selected&&u.push(tP(e.id,!1));a(l),o(u)},setMinZoom:e=>{let{panZoom:t,maxZoom:n}=m();t?.setScaleExtent([e,n]),p({minZoom:e})},setMaxZoom:e=>{let{panZoom:t,minZoom:n}=m();t?.setScaleExtent([n,e]),p({maxZoom:e})},setTranslateExtent:e=>{m().panZoom?.setTranslateExtent(e),p({translateExtent:e})},resetSelectedElements:()=>{let{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:r,elementsSelectable:i}=m();if(!i)return;let a=t.reduce((e,t)=>t.selected?[...e,tP(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,tP(t.id,!1)]:e,[]);n(a),r(o)},setNodeExtent:e=>{let{nodes:t,nodeLookup:n,parentLookup:r,nodeOrigin:i,elevateNodesOnSelect:a,nodeExtent:o,zIndexMode:s}=m();(e[0][0]!==o[0][0]||e[0][1]!==o[0][1]||e[1][0]!==o[1][0]||e[1][1]!==o[1][1])&&(sM(t,n,r,{nodeOrigin:i,nodeExtent:e,elevateNodesOnSelect:a,checkEquality:!1,zIndexMode:s}),p({nodeExtent:e}))},panBy:e=>{let{transform:t,width:n,height:r,panZoom:i,translateExtent:a}=m();return mM({delta:e,panZoom:i,transform:t,translateExtent:a,width:n,height:r})},setCenter:async(e,t,n)=>{let{width:r,height:i,maxZoom:a,panZoom:o}=m();if(!o)return!1;let s=n?.zoom===void 0?a:n.zoom;return await o.setViewport({x:r/2-e*s,y:i/2-t*s,zoom:s},{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0},cancelConnection:()=>{p({connection:{...DA}})},updateConnection:e=>{p({connection:e})},reset:()=>p({..._I()})}},Object.is);function yI({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:a,initialMinZoom:o,initialMaxZoom:s,initialFitViewOptions:c,fitView:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f,children:p}){let[m]=(0,_.useState)(()=>vI({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:l,minZoom:o,maxZoom:s,fitViewOptions:c,nodeOrigin:u,nodeExtent:d,zIndexMode:f}));return(0,G.jsx)(gN,{value:m,children:(0,G.jsx)(mP,{children:(0,G.jsx)(zP,{children:p})})})}function bI({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:i,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p}){return(0,_.useContext)(hN)?(0,G.jsx)(G.Fragment,{children:e}):(0,G.jsx)(yI,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:i,initialWidth:a,initialHeight:o,fitView:s,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p,children:e})}var xI={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0};function SI({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:a,edgeTypes:o,onNodeClick:s,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:v,onNodeMouseEnter:y,onNodeMouseMove:b,onNodeMouseLeave:x,onNodeContextMenu:S,onNodeDoubleClick:C,onNodeDragStart:w,onNodeDrag:T,onNodeDragStop:E,onNodesDelete:D,onEdgesDelete:O,onDelete:k,onSelectionChange:A,onSelectionDragStart:j,onSelectionDrag:M,onSelectionDragStop:N,onSelectionContextMenu:P,onSelectionStart:F,onSelectionEnd:I,onBeforeDelete:L,connectionMode:R,connectionLineType:z=OA.Bezier,connectionLineStyle:B,connectionLineComponent:V,connectionLineContainerStyle:H,deleteKeyCode:U=`Backspace`,selectionKeyCode:ee=`Shift`,selectionOnDrag:W=!1,selectionMode:te=EA.Full,panActivationKeyCode:ne=`Space`,multiSelectionKeyCode:re=fj()?`Meta`:`Control`,zoomActivationKeyCode:ie=fj()?`Meta`:`Control`,snapToGrid:ae,snapGrid:oe,onlyRenderVisibleElements:se=!1,selectNodesOnDrag:ce,nodesDraggable:le,autoPanOnNodeFocus:ue,nodesConnectable:de,nodesFocusable:fe,nodeOrigin:pe=RN,edgesFocusable:me,edgesReconnectable:he,elementsSelectable:ge=!0,defaultViewport:_e=zN,minZoom:ve=.5,maxZoom:ye=2,translateExtent:be=xA,preventScrolling:xe=!0,nodeExtent:Se,defaultMarkerColor:Ce=`#b1b1b7`,zoomOnScroll:we=!0,zoomOnPinch:Te=!0,panOnScroll:Ee=!1,panOnScrollSpeed:De=.5,panOnScrollMode:Oe=TA.Free,zoomOnDoubleClick:ke=!0,panOnDrag:Ae=!0,onPaneClick:je,onPaneMouseEnter:Me,onPaneMouseMove:Ne,onPaneMouseLeave:Pe,onPaneScroll:Fe,onPaneContextMenu:Ie,paneClickDistance:Le=1,nodeClickDistance:Re=0,children:ze,onReconnect:Be,onReconnectStart:Ve,onReconnectEnd:He,onEdgeContextMenu:Ue,onEdgeDoubleClick:We,onEdgeMouseEnter:Ge,onEdgeMouseMove:Ke,onEdgeMouseLeave:qe,reconnectRadius:Je=10,onNodesChange:Ye,onEdgesChange:Xe,noDragClassName:Ze=`nodrag`,noWheelClassName:Qe=`nowheel`,noPanClassName:$e=`nopan`,fitView:et,fitViewOptions:tt,connectOnClick:nt,attributionPosition:rt,proOptions:it,defaultEdgeOptions:at,elevateNodesOnSelect:ot=!0,elevateEdgesOnSelect:st=!1,disableKeyboardA11y:ct=!1,autoPanOnConnect:lt,autoPanOnNodeDrag:ut,autoPanOnSelection:dt=!0,autoPanSpeed:ft,connectionRadius:pt,isValidConnection:mt,onError:ht,style:gt,id:_t,nodeDragThreshold:vt,connectionDragThreshold:yt,viewport:bt,onViewportChange:xt,width:St,height:Ct,colorMode:wt=`light`,debug:Tt,onScroll:Et,ariaLabelConfig:Dt,zIndexMode:Ot=`basic`,...kt},At){let jt=_t||`1`,Mt=GN(wt),Nt=(0,_.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:`instant`}),Et?.(e)},[Et]);return(0,G.jsx)(`div`,{"data-testid":`rf__wrapper`,...kt,onScroll:Nt,style:{...gt,...xI},ref:At,className:Lw([`react-flow`,i,Mt]),id:_t,role:`application`,children:(0,G.jsxs)(bI,{nodes:e,edges:t,width:St,height:Ct,fitView:et,fitViewOptions:tt,minZoom:ve,maxZoom:ye,nodeOrigin:pe,nodeExtent:Se,zIndexMode:Ot,children:[(0,G.jsx)(UN,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:v,nodesDraggable:le,autoPanOnNodeFocus:ue,nodesConnectable:de,nodesFocusable:fe,edgesFocusable:me,edgesReconnectable:he,elementsSelectable:ge,elevateNodesOnSelect:ot,elevateEdgesOnSelect:st,minZoom:ve,maxZoom:ye,nodeExtent:Se,onNodesChange:Ye,onEdgesChange:Xe,snapToGrid:ae,snapGrid:oe,connectionMode:R,translateExtent:be,connectOnClick:nt,defaultEdgeOptions:at,fitView:et,fitViewOptions:tt,onNodesDelete:D,onEdgesDelete:O,onDelete:k,onNodeDragStart:w,onNodeDrag:T,onNodeDragStop:E,onSelectionDrag:M,onSelectionDragStart:j,onSelectionDragStop:N,onMove:u,onMoveStart:d,onMoveEnd:f,noPanClassName:$e,nodeOrigin:pe,rfId:jt,autoPanOnConnect:lt,autoPanOnNodeDrag:ut,autoPanSpeed:ft,onError:ht,connectionRadius:pt,isValidConnection:mt,selectNodesOnDrag:ce,nodeDragThreshold:vt,connectionDragThreshold:yt,onBeforeDelete:L,debug:Tt,ariaLabelConfig:Dt,zIndexMode:Ot}),(0,G.jsx)(hI,{onInit:l,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:y,onNodeMouseMove:b,onNodeMouseLeave:x,onNodeContextMenu:S,onNodeDoubleClick:C,nodeTypes:a,edgeTypes:o,connectionLineType:z,connectionLineStyle:B,connectionLineComponent:V,connectionLineContainerStyle:H,selectionKeyCode:ee,selectionOnDrag:W,selectionMode:te,deleteKeyCode:U,multiSelectionKeyCode:re,panActivationKeyCode:ne,zoomActivationKeyCode:ie,onlyRenderVisibleElements:se,defaultViewport:_e,translateExtent:be,minZoom:ve,maxZoom:ye,preventScrolling:xe,zoomOnScroll:we,zoomOnPinch:Te,zoomOnDoubleClick:ke,panOnScroll:Ee,panOnScrollSpeed:De,panOnScrollMode:Oe,panOnDrag:Ae,autoPanOnSelection:dt,onPaneClick:je,onPaneMouseEnter:Me,onPaneMouseMove:Ne,onPaneMouseLeave:Pe,onPaneScroll:Fe,onPaneContextMenu:Ie,paneClickDistance:Le,nodeClickDistance:Re,onSelectionContextMenu:P,onSelectionStart:F,onSelectionEnd:I,onReconnect:Be,onReconnectStart:Ve,onReconnectEnd:He,onEdgeContextMenu:Ue,onEdgeDoubleClick:We,onEdgeMouseEnter:Ge,onEdgeMouseMove:Ke,onEdgeMouseLeave:qe,reconnectRadius:Je,defaultMarkerColor:Ce,noDragClassName:Ze,noWheelClassName:Qe,noPanClassName:$e,rfId:jt,disableKeyboardA11y:ct,nodeExtent:Se,viewport:bt,onViewportChange:xt,nodesDraggable:le}),(0,G.jsx)(LN,{onSelectionChange:A}),ze,(0,G.jsx)(jN,{proOptions:it,position:rt}),(0,G.jsx)(ON,{rfId:jt,disableKeyboardA11y:ct})]})})}var CI=lP(SI);bA.error014();function wI({dimensions:e,lineWidth:t,variant:n,className:r}){return(0,G.jsx)(`path`,{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Lw([`react-flow__background-pattern`,n,r])})}function TI({radius:e,className:t}){return(0,G.jsx)(`circle`,{cx:e,cy:e,r:e,className:Lw([`react-flow__background-pattern`,`dots`,t])})}var EI;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(EI||={});var DI={[EI.Dots]:1,[EI.Lines]:1,[EI.Cross]:6},OI=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function kI({id:e,variant:t=EI.Dots,gap:n=20,size:r,lineWidth:i=1,offset:a=0,color:o,bgColor:s,style:c,className:l,patternClassName:u}){let d=(0,_.useRef)(null),{transform:f,patternId:p}=vN(OI,mN),m=r||DI[t],h=t===EI.Dots,g=t===EI.Cross,v=Array.isArray(n)?n:[n,n],y=[v[0]*f[2]||1,v[1]*f[2]||1],b=m*f[2],x=Array.isArray(a)?a:[a,a],S=g?[b,b]:y,C=[x[0]*f[2]+S[0]/2,x[1]*f[2]+S[1]/2],w=`${p}${e||``}`;return(0,G.jsxs)(`svg`,{className:Lw([`react-flow__background`,l]),style:{...c,...SP,"--xy-background-color-props":s,"--xy-background-pattern-color-props":o},ref:d,"data-testid":`rf__background`,children:[(0,G.jsx)(`pattern`,{id:w,x:f[0]%y[0],y:f[1]%y[1],width:y[0],height:y[1],patternUnits:`userSpaceOnUse`,patternTransform:`translate(-${C[0]},-${C[1]})`,children:h?(0,G.jsx)(TI,{radius:b/2,className:u}):(0,G.jsx)(wI,{dimensions:S,lineWidth:i,variant:t,className:u})}),(0,G.jsx)(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${w})`})]})}kI.displayName=`Background`;var AI=(0,_.memo)(kI);function jI(){return(0,G.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,children:(0,G.jsx)(`path`,{d:`M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z`})})}function MI(){return(0,G.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 5`,children:(0,G.jsx)(`path`,{d:`M0 0h32v4.2H0z`})})}function NI(){return(0,G.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 30`,children:(0,G.jsx)(`path`,{d:`M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z`})})}function PI(){return(0,G.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,G.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z`})})}function FI(){return(0,G.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,G.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z`})})}function II({children:e,className:t,...n}){return(0,G.jsx)(`button`,{type:`button`,className:Lw([`react-flow__controls-button`,t]),...n,children:e})}var LI=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function RI({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:a,onZoomOut:o,onFitView:s,onInteractiveChange:c,className:l,children:u,position:d=`bottom-left`,orientation:f=`vertical`,"aria-label":p}){let m=yN(),{isInteractive:h,minZoomReached:g,maxZoomReached:_,ariaLabelConfig:v}=vN(LI,mN),{zoomIn:y,zoomOut:b,fitView:x}=_P();return(0,G.jsxs)(kN,{className:Lw([`react-flow__controls`,f===`horizontal`?`horizontal`:`vertical`,l]),position:d,style:e,"data-testid":`rf__controls`,"aria-label":p??v[`controls.ariaLabel`],children:[t&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(II,{onClick:()=>{y(),a?.()},className:`react-flow__controls-zoomin`,title:v[`controls.zoomIn.ariaLabel`],"aria-label":v[`controls.zoomIn.ariaLabel`],disabled:_,children:(0,G.jsx)(jI,{})}),(0,G.jsx)(II,{onClick:()=>{b(),o?.()},className:`react-flow__controls-zoomout`,title:v[`controls.zoomOut.ariaLabel`],"aria-label":v[`controls.zoomOut.ariaLabel`],disabled:g,children:(0,G.jsx)(MI,{})})]}),n&&(0,G.jsx)(II,{className:`react-flow__controls-fitview`,onClick:()=>{x(i),s?.()},title:v[`controls.fitView.ariaLabel`],"aria-label":v[`controls.fitView.ariaLabel`],children:(0,G.jsx)(NI,{})}),r&&(0,G.jsx)(II,{className:`react-flow__controls-interactive`,onClick:()=>{m.setState({nodesDraggable:!h,nodesConnectable:!h,elementsSelectable:!h}),c?.(!h)},title:v[`controls.interactive.ariaLabel`],"aria-label":v[`controls.interactive.ariaLabel`],children:h?(0,G.jsx)(FI,{}):(0,G.jsx)(PI,{})}),u]})}RI.displayName=`Controls`;var zI=(0,_.memo)(RI);function BI({id:e,x:t,y:n,width:r,height:i,style:a,color:o,strokeColor:s,strokeWidth:c,className:l,borderRadius:u,shapeRendering:d,selected:f,onClick:p}){let{background:m,backgroundColor:h}=a||{},g=o||m||h;return(0,G.jsx)(`rect`,{className:Lw([`react-flow__minimap-node`,{selected:f},l]),x:t,y:n,rx:u,ry:u,width:r,height:i,style:{fill:g,stroke:s,strokeWidth:c},shapeRendering:d,onClick:p?t=>p(t,e):void 0})}var VI=(0,_.memo)(BI),HI=e=>e.nodes.map(e=>e.id),UI=e=>e instanceof Function?e:()=>e;function WI({nodeStrokeColor:e,nodeColor:t,nodeClassName:n=``,nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=VI,onClick:o}){let s=vN(HI,mN),c=UI(t),l=UI(e),u=UI(n),d=typeof window>`u`||window.chrome?`crispEdges`:`geometricPrecision`;return(0,G.jsx)(G.Fragment,{children:s.map(e=>(0,G.jsx)(KI,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:o,shapeRendering:d},e))})}function GI({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:a,shapeRendering:o,NodeComponent:s,onClick:c}){let{node:l,x:u,y:d,width:f,height:p}=vN(t=>{let n=t.nodeLookup.get(e);if(!n)return{node:void 0,x:0,y:0,width:0,height:0};let r=n.internals.userNode,{x:i,y:a}=n.internals.positionAbsolute,{width:o,height:s}=mj(r);return{node:r,x:i,y:a,width:o,height:s}},mN);return!l||l.hidden||!hj(l)?null:(0,G.jsx)(s,{x:u,y:d,width:f,height:p,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:i,strokeColor:n(l),strokeWidth:a,shapeRendering:o,onClick:c,id:l.id})}var KI=(0,_.memo)(GI),qI=(0,_.memo)(WI),JI=200,YI=150,XI=e=>!e.hidden,ZI=e=>{let t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]},n=!1;for(let t of e.nodeLookup.values())if(!t.hidden){n=!0;break}return{viewBB:t,boundingRect:n?$A(IA(e.nodeLookup,{filter:XI}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},QI=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,$I=(e,t)=>QI(e.viewBB,t.viewBB)&&QI(e.boundingRect,t.boundingRect)&&e.rfId===t.rfId&&e.panZoom===t.panZoom&&e.translateExtent===t.translateExtent&&e.flowWidth===t.flowWidth&&e.flowHeight===t.flowHeight&&e.ariaLabelConfig===t.ariaLabelConfig,eL=`react-flow__minimap-desc`;function tL({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:i=``,nodeBorderRadius:a=5,nodeStrokeWidth:o,nodeComponent:s,bgColor:c,maskColor:l,maskStrokeColor:u,maskStrokeWidth:d,position:f=`bottom-right`,onClick:p,onNodeClick:m,pannable:h=!1,zoomable:g=!1,ariaLabel:v,inversePan:y,zoomStep:b=1,offsetScale:x=5}){let S=yN(),C=(0,_.useRef)(null),{boundingRect:w,panZoom:T,viewBB:E,rfId:D,translateExtent:O,flowWidth:k,flowHeight:A,ariaLabelConfig:j}=vN(ZI,$I),M=e?.width??JI,N=e?.height??YI,P=w.width/M,F=w.height/N,I=Math.max(P,F),L=I*M,R=I*N,z=x*I,B=w.x-(L-w.width)/2-z,V=w.y-(R-w.height)/2-z,H=L+z*2,U=R+z*2,ee=`${eL}-${D}`,W=(0,_.useRef)(0),te=(0,_.useRef)();W.current=I,(0,_.useEffect)(()=>{let e=S.getState().panZoom;if(C.current&&e)return te.current=NM({domNode:C.current,panZoom:e,getTransform:()=>S.getState().transform,getViewScale:()=>W.current}),()=>{te.current?.destroy()}},[T]),(0,_.useEffect)(()=>{te.current?.update({translateExtent:O,width:k,height:A,inversePan:y,pannable:h,zoomStep:b,zoomable:g})},[h,g,y,b,O,k,A]);let ne=p?e=>{let[t,n]=te.current?.pointer(e)||[0,0];p(e,{x:t,y:n})}:void 0,re=(0,_.useCallback)((e,t)=>{let n=S.getState().nodeLookup.get(t).internals.userNode;m?.(e,n)},[m]),ie=m?re:void 0,ae=v??j[`minimap.ariaLabel`];return(0,G.jsx)(kN,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c==`string`?c:void 0,"--xy-minimap-mask-background-color-props":typeof l==`string`?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof u==`string`?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof d==`number`?d*I:void 0,"--xy-minimap-node-background-color-props":typeof r==`string`?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n==`string`?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o==`number`?o:void 0},className:Lw([`react-flow__minimap`,t]),"data-testid":`rf__minimap`,children:(0,G.jsxs)(`svg`,{width:M,height:N,viewBox:`${B} ${V} ${H} ${U}`,className:`react-flow__minimap-svg`,role:`img`,"aria-labelledby":ee,ref:C,onClick:ne,children:[ae&&(0,G.jsx)(`title`,{id:ee,children:ae}),(0,G.jsx)(qI,{onClick:ie,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:s}),(0,G.jsx)(`path`,{className:`react-flow__minimap-mask`,d:`M${B-z},${V-z}h${H+z*2}v${U+z*2}h${-H-z*2}z
|
|
25
|
-
M${E.x},${E.y}h${E.width}v${E.height}h${-E.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}tL.displayName=`MiniMap`;var nL=(0,_.memo)(tL),rL=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,iL={[JM.Line]:`right`,[JM.Handle]:`bottom-right`};function aL({nodeId:e,position:t,variant:n=JM.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:h,onResize:g,onResizeEnd:v}){let y=IP(),b=typeof e==`string`?e:y,x=yN(),S=(0,_.useRef)(null),C=n===JM.Handle,w=vN((0,_.useCallback)(rL(C&&p),[C,p]),mN),T=(0,_.useRef)(null),E=t??iL[n];(0,_.useEffect)(()=>{if(S.current&&b)return T.current||=aN({domNode:S.current,nodeId:b,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=x.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=x.getState(),o=[],s={x:e.x,y:e.y},c=r.get(b);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=fM([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...gj({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:b,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:b,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:b,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};x.getState().triggerNodeChanges([n])}}),T.current.update({controlPosition:E,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:v,shouldResize:m}),()=>{T.current?.destroy()}},[E,s,c,l,u,d,h,g,v,m]);let D=E.split(`-`);return(0,G.jsx)(`div`,{className:Lw([`react-flow__resize-control`,`nodrag`,...D,n,r]),ref:S,style:{...i,scale:w,...o&&{[C?`backgroundColor`:`borderColor`]:o}},children:a})}(0,_.memo)(aL);var oL=3,sL=60,cL=140,lL=e=>e.replace(/\s+/g,` `).trim();function uL(e){let t=lL(e.description||e.proposed||e.name||`Tool call`);return t.length>sL?`${t.slice(0,59)}…`:t}function dL(e,t){if(t?.status===`ready`&&t.text)return t.text;if(e.length){let t=[...new Set(e.map(uL))],n=t.slice(0,oL),r=n.join(` · `)+(t.length>n.length?` · +${t.length-n.length} more`:``);return r.length>cL?`${r.slice(0,139)}…`:r}return t?.status===`loading`?`Summarizing…`:t?.status===`error`?`Summary unavailable.`:`No tool calls in this request.`}var fL=236,pL=300;function mL({data:e}){let t=e.failed===null?``:e.failed?`graph-node-fail`:`graph-node-ok`;return(0,G.jsxs)(`button`,{type:`button`,className:`graph-node ${t}`,onClick:e.onClick,children:[(0,G.jsx)(WP,{type:`target`,position:$.Left,style:{opacity:0}}),(0,G.jsx)(WP,{type:`source`,position:$.Right,style:{opacity:0}}),(0,G.jsxs)(`div`,{className:`graph-node-head`,children:[(0,G.jsxs)(`span`,{className:`graph-node-num`,children:[`Request #`,e.number]}),e.failed!==null&&(0,G.jsx)(`span`,{className:`graph-node-status ${e.failed?`fail`:`ok`}`,children:e.failed?`Failed`:`OK`})]}),(0,G.jsx)(`p`,{className:`graph-node-summary`,children:e.summaryText}),(0,G.jsxs)(`div`,{className:`graph-node-meta`,children:[(0,G.jsx)(`span`,{children:zC(e.cost,e.costEstimated)}),(0,G.jsx)(`span`,{children:BC(e.durationMs)}),e.totalCalls>0&&(0,G.jsxs)(`span`,{className:e.verifiedCount===e.totalCalls?`graph-node-verified-all`:`graph-node-verified-partial`,children:[e.verifiedCount,`/`,e.totalCalls,` verified`]})]})]})}var hL={request:mL};function gL({trace:e,blocks:t,summaries:n,onSelectStep:r}){let i=np(),{nodes:a,edges:o}=(0,_.useMemo)(()=>{let i=new Map((e.requests||[]).map(e=>[e.id,e])),a=new Map;for(let t of e.callVerifications||[]){let e=a.get(t.exchange_id)||[];e.push(t),a.set(t.exchange_id,e)}let o=t.map((e,t)=>{let o=i.get(e.exchangeId),s=n[e.exchangeId],c=a.get(e.exchangeId)||[],l=e.completion?ap(e.completion):null;return{id:e.exchangeId,type:`request`,position:{x:t*pL,y:0},data:{number:e.number,summaryText:dL(c,s),failed:l,cost:o?.cost??null,costEstimated:o?.costEstimated??!1,durationMs:o?.durationMs??null,verifiedCount:c.filter(e=>e.verified).length,totalCalls:c.length,onClick:()=>r(e.items[0]?.index??0)},style:{width:fL}}}),s=[];for(let e=0;e<t.length-1;e++){let n=t[e],r=t[e+1],i=a.get(n.exchangeId)||[],o=i.filter(e=>e.verified).length,c=i.length>0&&o===i.length,l=o>0&&o<i.length,u=i.length?`${o}/${i.length} verified`:void 0;s.push({id:`seq-${n.exchangeId}-${r.exchangeId}`,source:n.exchangeId,target:r.exchangeId,label:u,style:{stroke:c?`#3d7a5e`:l?`#8a7233`:i.length?`#7a3d45`:`var(--line)`},labelStyle:{fill:`var(--muted)`,fontSize:10},labelBgStyle:{fill:`var(--deep)`}})}return{nodes:o,edges:s}},[e,t,n,r]);return t.length?(0,G.jsx)(`div`,{className:`graph-canvas`,children:(0,G.jsxs)(CI,{nodes:a,edges:o,nodeTypes:hL,fitView:!0,proOptions:{hideAttribution:!0},colorMode:i,children:[(0,G.jsx)(AI,{color:i===`dark`?`#31362c`:`#d3dbcb`,gap:24}),(0,G.jsx)(zI,{showInteractive:!1}),(0,G.jsx)(nL,{pannable:!0,zoomable:!0,style:{background:`var(--deep)`},maskColor:i===`dark`?`rgba(17,19,21,0.75)`:`rgba(255,255,255,0.75)`,nodeColor:i===`dark`?`#31362c`:`#d3dbcb`})]})}):(0,G.jsx)(`div`,{className:`graph-empty`,children:`No model requests captured for this trace yet.`})}var _L=[``,`Minimal`,`Low`,`Moderate`,`High`,`Critical`],vL=[``,`Ignore`,`Routine`,`Watch`,`Review carefully`,`Lock down`],yL={"content-type":`application/json`,"x-raytace-experiment":`1`};async function bL(e,t){let n=await e.json().catch(()=>({}));if(!e.ok)throw Error(n.error||t);return n}var xL=async e=>bL(await x().fetch(`/raytace/sandboxes/${e}/files`,{cache:`no-store`}),`The initial scan could not be loaded.`),SL=async(e,t)=>bL(await x().fetch(`/raytace/sandboxes/${e}/files`,{method:`POST`,headers:yL,body:JSON.stringify({updates:t})}),`That change could not be saved.`),CL=async(e,t,n,r)=>bL(await x().fetch(`/raytace/sandboxes/${e}/activity${t||n?`?${t?`since=${Math.floor(t)}`:``}${t&&n?`&`:``}${n?`until=${Math.ceil(n)}`:``}`:``}`,{cache:`no-store`,signal:r}),`Sandbox activity could not be loaded.`),wL=async e=>bL(await x().fetch(`/raytace/alerts${e?`?sandbox=${e}`:``}`,{cache:`no-store`}),`Alerts could not be loaded.`);async function TL(){try{let e=await x().fetch(`/raytace/me`,{cache:`no-store`});if(!e.ok)return null;let t=await e.json();return typeof t.notify_email==`boolean`?t.notify_email:null}catch{return null}}var EL=async e=>bL(await x().fetch(`/raytace/me`,{method:`POST`,headers:yL,body:JSON.stringify({notify_email:e})}),`That setting could not be saved.`),DL=async e=>bL(await x().fetch(`/raytace/alerts/seen`,{method:`POST`,headers:yL,body:JSON.stringify({ids:e})}),`Alerts could not be marked seen.`),OL=new Map;function kL(e){let[t,n]=(0,_.useState)(new Map);return(0,_.useEffect)(()=>{if(!e)return;let t=!1;return OL.has(e)||OL.set(e,xL(e).then(e=>new Map(e.files.map(e=>[e.path,e])),()=>(OL.delete(e),new Map))),OL.get(e).then(e=>{t||n(e)}),()=>{t=!0}},[e]),t}var AL=e=>{OL.delete(e)},jL={read:`Read`,created:`Created`,changed:`Changed`,emptied:`Emptied`,appended:`Appended to`,deleted:`Deleted`,renamed:`Renamed`,permissions_changed:`Permissions changed`,attempted:`Refused`,opened_for_writing:`Opened for writing,
|
|
25
|
+
M${E.x},${E.y}h${E.width}v${E.height}h${-E.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}tL.displayName=`MiniMap`;var nL=(0,_.memo)(tL),rL=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,iL={[JM.Line]:`right`,[JM.Handle]:`bottom-right`};function aL({nodeId:e,position:t,variant:n=JM.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:h,onResize:g,onResizeEnd:v}){let y=IP(),b=typeof e==`string`?e:y,x=yN(),S=(0,_.useRef)(null),C=n===JM.Handle,w=vN((0,_.useCallback)(rL(C&&p),[C,p]),mN),T=(0,_.useRef)(null),E=t??iL[n];(0,_.useEffect)(()=>{if(S.current&&b)return T.current||=aN({domNode:S.current,nodeId:b,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=x.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=x.getState(),o=[],s={x:e.x,y:e.y},c=r.get(b);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=fM([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...gj({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:b,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:b,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:b,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};x.getState().triggerNodeChanges([n])}}),T.current.update({controlPosition:E,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:v,shouldResize:m}),()=>{T.current?.destroy()}},[E,s,c,l,u,d,h,g,v,m]);let D=E.split(`-`);return(0,G.jsx)(`div`,{className:Lw([`react-flow__resize-control`,`nodrag`,...D,n,r]),ref:S,style:{...i,scale:w,...o&&{[C?`backgroundColor`:`borderColor`]:o}},children:a})}(0,_.memo)(aL);var oL=3,sL=60,cL=140,lL=e=>e.replace(/\s+/g,` `).trim();function uL(e){let t=lL(e.description||e.proposed||e.name||`Tool call`);return t.length>sL?`${t.slice(0,59)}…`:t}function dL(e,t){if(t?.status===`ready`&&t.text)return t.text;if(e.length){let t=[...new Set(e.map(uL))],n=t.slice(0,oL),r=n.join(` · `)+(t.length>n.length?` · +${t.length-n.length} more`:``);return r.length>cL?`${r.slice(0,139)}…`:r}return t?.status===`loading`?`Summarizing…`:t?.status===`error`?`Summary unavailable.`:`No tool calls in this request.`}var fL=236,pL=300;function mL({data:e}){let t=e.failed===null?``:e.failed?`graph-node-fail`:`graph-node-ok`;return(0,G.jsxs)(`button`,{type:`button`,className:`graph-node ${t}`,onClick:e.onClick,children:[(0,G.jsx)(WP,{type:`target`,position:$.Left,style:{opacity:0}}),(0,G.jsx)(WP,{type:`source`,position:$.Right,style:{opacity:0}}),(0,G.jsxs)(`div`,{className:`graph-node-head`,children:[(0,G.jsxs)(`span`,{className:`graph-node-num`,children:[`Request #`,e.number]}),e.failed!==null&&(0,G.jsx)(`span`,{className:`graph-node-status ${e.failed?`fail`:`ok`}`,children:e.failed?`Failed`:`OK`})]}),(0,G.jsx)(`p`,{className:`graph-node-summary`,children:e.summaryText}),(0,G.jsxs)(`div`,{className:`graph-node-meta`,children:[(0,G.jsx)(`span`,{children:zC(e.cost,e.costEstimated)}),(0,G.jsx)(`span`,{children:BC(e.durationMs)}),e.totalCalls>0&&(0,G.jsxs)(`span`,{className:e.verifiedCount===e.totalCalls?`graph-node-verified-all`:`graph-node-verified-partial`,children:[e.verifiedCount,`/`,e.totalCalls,` verified`]})]})]})}var hL={request:mL};function gL({trace:e,blocks:t,summaries:n,onSelectStep:r}){let i=np(),{nodes:a,edges:o}=(0,_.useMemo)(()=>{let i=new Map((e.requests||[]).map(e=>[e.id,e])),a=new Map;for(let t of e.callVerifications||[]){let e=a.get(t.exchange_id)||[];e.push(t),a.set(t.exchange_id,e)}let o=t.map((e,t)=>{let o=i.get(e.exchangeId),s=n[e.exchangeId],c=a.get(e.exchangeId)||[],l=e.completion?ap(e.completion):null;return{id:e.exchangeId,type:`request`,position:{x:t*pL,y:0},data:{number:e.number,summaryText:dL(c,s),failed:l,cost:o?.cost??null,costEstimated:o?.costEstimated??!1,durationMs:o?.durationMs??null,verifiedCount:c.filter(e=>e.verified).length,totalCalls:c.length,onClick:()=>r(e.items[0]?.index??0)},style:{width:fL}}}),s=[];for(let e=0;e<t.length-1;e++){let n=t[e],r=t[e+1],i=a.get(n.exchangeId)||[],o=i.filter(e=>e.verified).length,c=i.length>0&&o===i.length,l=o>0&&o<i.length,u=i.length?`${o}/${i.length} verified`:void 0;s.push({id:`seq-${n.exchangeId}-${r.exchangeId}`,source:n.exchangeId,target:r.exchangeId,label:u,style:{stroke:c?`#3d7a5e`:l?`#8a7233`:i.length?`#7a3d45`:`var(--line)`},labelStyle:{fill:`var(--muted)`,fontSize:10},labelBgStyle:{fill:`var(--deep)`}})}return{nodes:o,edges:s}},[e,t,n,r]);return t.length?(0,G.jsx)(`div`,{className:`graph-canvas`,children:(0,G.jsxs)(CI,{nodes:a,edges:o,nodeTypes:hL,fitView:!0,proOptions:{hideAttribution:!0},colorMode:i,children:[(0,G.jsx)(AI,{color:i===`dark`?`#31362c`:`#d3dbcb`,gap:24}),(0,G.jsx)(zI,{showInteractive:!1}),(0,G.jsx)(nL,{pannable:!0,zoomable:!0,style:{background:`var(--deep)`},maskColor:i===`dark`?`rgba(17,19,21,0.75)`:`rgba(255,255,255,0.75)`,nodeColor:i===`dark`?`#31362c`:`#d3dbcb`})]})}):(0,G.jsx)(`div`,{className:`graph-empty`,children:`No model requests captured for this trace yet.`})}var _L=[``,`Minimal`,`Low`,`Moderate`,`High`,`Critical`],vL=[``,`Ignore`,`Routine`,`Watch`,`Review carefully`,`Lock down`],yL={"content-type":`application/json`,"x-raytace-experiment":`1`};async function bL(e,t){let n=await e.json().catch(()=>({}));if(!e.ok)throw Error(n.error||t);return n}var xL=async e=>bL(await x().fetch(`/raytace/sandboxes/${e}/files`,{cache:`no-store`}),`The initial scan could not be loaded.`),SL=async(e,t)=>bL(await x().fetch(`/raytace/sandboxes/${e}/files`,{method:`POST`,headers:yL,body:JSON.stringify({updates:t})}),`That change could not be saved.`),CL=async(e,t,n,r)=>bL(await x().fetch(`/raytace/sandboxes/${e}/activity${t||n?`?${t?`since=${Math.floor(t)}`:``}${t&&n?`&`:``}${n?`until=${Math.ceil(n)}`:``}`:``}`,{cache:`no-store`,signal:r}),`Sandbox activity could not be loaded.`),wL=async e=>bL(await x().fetch(`/raytace/alerts${e?`?sandbox=${e}`:``}`,{cache:`no-store`}),`Alerts could not be loaded.`);async function TL(){try{let e=await x().fetch(`/raytace/me`,{cache:`no-store`});if(!e.ok)return null;let t=await e.json();return typeof t.notify_email==`boolean`?t.notify_email:null}catch{return null}}var EL=async e=>bL(await x().fetch(`/raytace/me`,{method:`POST`,headers:yL,body:JSON.stringify({notify_email:e})}),`That setting could not be saved.`),DL=async e=>bL(await x().fetch(`/raytace/alerts/seen`,{method:`POST`,headers:yL,body:JSON.stringify({ids:e})}),`Alerts could not be marked seen.`),OL=new Map;function kL(e){let[t,n]=(0,_.useState)(new Map);return(0,_.useEffect)(()=>{if(!e)return;let t=!1;return OL.has(e)||OL.set(e,xL(e).then(e=>new Map(e.files.map(e=>[e.path,e])),()=>(OL.delete(e),new Map))),OL.get(e).then(e=>{t||n(e)}),()=>{t=!0}},[e]),t}var AL=e=>{OL.delete(e)},jL={read:`Read`,created:`Created`,changed:`Changed`,emptied:`Emptied`,appended:`Appended to`,deleted:`Deleted`,renamed:`Renamed`,permissions_changed:`Permissions changed`,attempted:`Refused`,opened_for_writing:`Opened for writing, same content`,created_and_deleted:`Created and deleted`,rewritten:`Written, same content`},ML={read:`a read`,write:`a write`,delete:`a delete`,rename:`a rename`,permissions:`a permission change`},NL={confirmed:[`confirmed`,`The kernel saw the call, and the file shows its effect.`],attempted:[`refused`,`The kernel refused the call. Nothing changed.`],possible:[`possible`,`The file was opened for writing and is as it was.`],one_of:[`one of several`,`More than one process made such a call at that moment; this is the likeliest.`],unattributed:[`no call seen`,`The file changed on disk and the kernel reported no call for it: events may have been lost, or it was changed another way.`]},PL={connected:[`connected`,`The connection was made.`],attempted:[`attempted`,`The program did not wait for the result, so the call says only that it tried.`],refused_by_policy:[`refused by the firewall`,`A private address: the sandbox firewall rejects it, whatever the call returned.`],failed:[`failed`,`The connection was not made.`],listening:[`listening`,`The program accepts connections here. Nothing outside the sandbox network is routed to it.`]},FL=e=>new Date(e*1e3).toLocaleString(void 0,{day:`numeric`,month:`short`,hour:`numeric`,minute:`2-digit`,second:`2-digit`}),IL=e=>e>1?` ×${e.toLocaleString()}`:``,LL=e=>e?e.slice(0,8):null;function RL(e){let t=e.basis??{},n=LL(t.before?.sha256),r=LL(t.after?.sha256);return[t.syscall&&`Call: ${t.syscall}${t.errno?` (${t.errno})`:``}`,t.watcher?.length&&`Seen on disk: ${t.watcher.join(`, `)}`,n&&r&&n!==r&&`SHA-256 ${n}… → ${r}…`,t.path_from&&{argv:`The file is named in the program's own arguments.`,argv_folder:`A folder in the program's arguments holds the file.`,argv_text:`The file's name appears in the program's arguments.`}[t.path_from],t.candidates?.length&&`Also at that moment: ${t.candidates.map(e=>e.process??`pid ${e.pid}`).join(`, `)}`,t.note].filter(Boolean).join(`
|
|
26
26
|
`)}function zL({fact:e,step:t,onOpenCall:n}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`td`,{title:e.command??void 0,children:e.process??(0,G.jsx)(`span`,{className:`rt-muted`,children:`–`})}),(0,G.jsx)(`td`,{className:`rt-scan-open`,children:t&&(0,G.jsxs)(`button`,{type:`button`,className:`link-button`,onClick:()=>n(t.trace,t.call),children:[`Open the step `,(0,G.jsx)(P,{size:11})]})})]})}function BL({fact:e}){return(0,G.jsxs)(G.Fragment,{children:[Object.entries(e.outcomes).map(([e,t],n)=>(0,G.jsxs)(`span`,{title:PL[e]?.[1],className:e===`refused_by_policy`||e===`failed`?`exec-fail`:void 0,children:[n?` · `:``,PL[e]?.[0]??e,IL(t)]},e)),e.errno&&(0,G.jsxs)(`span`,{className:`rt-muted`,children:[` (`,e.errno,`)`]})]})}function VL({fact:e}){let[t,n]=(0,_.useState)(!1),r=t?e.packages:e.packages.slice(0,12);return(0,G.jsxs)(G.Fragment,{children:[r.map(e=>(0,G.jsxs)(`code`,{title:e.source,className:`rt-package`,children:[e.name,`@`,e.version]},`${e.name}@${e.version}`)),e.packages.length>r.length&&(0,G.jsxs)(`button`,{type:`button`,className:`link-button`,onClick:()=>n(!0),children:[`and `,(e.total-r.length).toLocaleString(),` more`]}),t&&e.total>e.packages.length&&(0,G.jsxs)(`span`,{className:`rt-muted`,children:[` and `,(e.total-e.packages.length).toLocaleString(),` not listed`]})]})}function HL({box:e,stepFor:t,onOpenCall:n}){let[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(null);if((0,_.useEffect)(()=>{i(null),o(null);let t=!1,n,r=async()=>{try{let n=await CL(e);t||(i(n),o(null))}catch(e){t||o(e instanceof Error?e.message:`Sandbox activity could not be loaded.`)}t||(n=setTimeout(r,1e4))};return r(),()=>{t=!0,clearTimeout(n)}},[e]),a&&!r)return(0,G.jsx)(`p`,{role:`alert`,className:`rt-problem`,children:a});if(!r)return(0,G.jsx)(rp,{label:`Loading sandbox activity…`});let s=new Set(r.network.map(e=>e.host).filter(Boolean)),c=r.lookups.filter(e=>!s.has(e.name)),l=!r.network.length&&!r.packages.length&&!r.files.length&&!r.lookups.length&&!r.bulk.length&&!r.identity.length,u=[...r.network,...r.files,...r.packages].some(e=>e.coverage===`gaps`);return l?(0,G.jsx)(`p`,{className:`rt-empty`,children:`Nothing recorded yet. The kernel layer of the sandbox reports every connection the agent makes, the packages it installs, and what happens to the project's files. A sandbox started before this was turned on reports once it is stopped and started again.`}):(0,G.jsxs)(G.Fragment,{children:[u&&(0,G.jsxs)(`p`,{className:`rt-problem`,children:[`Some events were lost while these were recorded, so a row marked `,(0,G.jsx)(`em`,{children:`gaps`}),` may not be all that happened.`]}),(0,G.jsxs)(`div`,{className:`rt-list-head`,children:[(0,G.jsx)(`span`,{children:`NETWORK`}),(0,G.jsxs)(`small`,{children:[r.network.length,` destination`,r.network.length===1?``:`s`,r.more.includes(`network`)?`, newest shown`:``]})]}),r.network.length?(0,G.jsx)(`div`,{className:`rt-table-wrap`,children:(0,G.jsxs)(`table`,{className:`rt-table rt-scan`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{children:`Last`}),(0,G.jsx)(`th`,{children:`Destination`}),(0,G.jsx)(`th`,{children:`Result`}),(0,G.jsx)(`th`,{children:`Program`}),(0,G.jsx)(`th`,{children:`Step`})]})}),(0,G.jsx)(`tbody`,{children:r.network.map(e=>(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`td`,{children:(0,G.jsx)(`time`,{children:FL(e.at)})}),(0,G.jsxs)(`td`,{children:[(0,G.jsxs)(`code`,{children:[e.host??e.ip,`:`,e.port]}),e.host&&(0,G.jsxs)(`span`,{className:`rt-muted`,title:`The address${(e.addresses?.length??1)>1?`es`:``} the program connected to. The name is the lookup that answered with ${(e.addresses?.length??1)>1?`them`:`it`}.\n${(e.addresses??[e.ip]).join(`
|
|
27
27
|
`)}`,children:[` `,e.ip,(e.addresses?.length??1)>1?` and ${e.addresses.length-1} more`:``]}),e.coverage===`gaps`&&(0,G.jsx)(`span`,{className:`rt-flag`,title:`Events were lost about then.`,children:`gaps`})]}),(0,G.jsx)(`td`,{children:(0,G.jsx)(BL,{fact:e})}),(0,G.jsx)(zL,{fact:e,step:t(e.call_id),onOpenCall:n})]},e.id))})]})}):(0,G.jsx)(`p`,{className:`rt-empty`,children:`No connection left the sandbox.`}),c.length>0&&(0,G.jsxs)(`p`,{className:`rt-foot`,children:[`Looked up, with no connection seen: `,c.slice(0,40).map((e,t)=>(0,G.jsxs)(`span`,{title:e.failed?`The lookup failed: ${e.failed}`:e.addresses.join(`, `),children:[t?`, `:``,(0,G.jsx)(`code`,{children:e.name}),e.failed?` (${e.failed})`:``]},e.id)),c.length>40?` and ${c.length-40} more`:``,`.`]}),(0,G.jsx)(`div`,{className:`rt-list-head`,children:(0,G.jsx)(`span`,{children:`PACKAGES INSTALLED`})}),r.packages.length?(0,G.jsx)(`div`,{className:`rt-table-wrap`,children:(0,G.jsxs)(`table`,{className:`rt-table rt-scan`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{children:`When`}),(0,G.jsx)(`th`,{children:`Manager`}),(0,G.jsx)(`th`,{children:`Packages`}),(0,G.jsx)(`th`,{children:`Basis`}),(0,G.jsx)(`th`,{children:`Program`}),(0,G.jsx)(`th`,{children:`Step`})]})}),(0,G.jsx)(`tbody`,{children:r.packages.map(e=>(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`td`,{children:(0,G.jsx)(`time`,{children:FL(e.at)})}),(0,G.jsxs)(`td`,{children:[e.manager,` `,(0,G.jsxs)(`span`,{className:`rt-muted`,children:[`· `,e.total.toLocaleString()]})]}),(0,G.jsx)(`td`,{className:`rt-scan-why`,children:(0,G.jsx)(VL,{fact:e})}),(0,G.jsx)(`td`,{title:e.certainty===`corroborated`?`Read from the package manager's own records in the sandbox, and a package registry was reached about then.`:`Read from the package manager's own records in the sandbox, which the agent can write. No registry connection was seen with it.`,children:e.certainty===`corroborated`?`records, registry reached`:`records only`}),(0,G.jsx)(zL,{fact:e,step:t(e.call_id),onOpenCall:n})]},e.id))})]})}):(0,G.jsx)(`p`,{className:`rt-empty`,children:`No package manager left anything new.`}),(0,G.jsxs)(`div`,{className:`rt-list-head`,children:[(0,G.jsx)(`span`,{children:`FILES, AS THE KERNEL SAW THEM`}),(0,G.jsx)(`small`,{children:`every project file; reads only of sensitive, Report and Restrict files`})]}),r.files.length?(0,G.jsx)(`div`,{className:`rt-table-wrap`,children:(0,G.jsxs)(`table`,{className:`rt-table rt-scan`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{children:`When`}),(0,G.jsx)(`th`,{children:`File`}),(0,G.jsx)(`th`,{children:`What happened`}),(0,G.jsx)(`th`,{children:`How sure`}),(0,G.jsx)(`th`,{children:`Program`}),(0,G.jsx)(`th`,{children:`Step`})]})}),(0,G.jsx)(`tbody`,{children:r.files.map(e=>(0,G.jsxs)(`tr`,{className:e.effect===`attempted`?`rt-fact-refused`:void 0,title:RL(e),children:[(0,G.jsx)(`td`,{children:(0,G.jsx)(`time`,{children:FL(e.at)})}),(0,G.jsxs)(`td`,{children:[e.path?(0,G.jsx)(`code`,{children:e.path}):(0,G.jsx)(`span`,{className:`rt-muted`,title:`gVisor reports this call by number, without its path.`,children:`file not reported`}),e.guard&&e.guard!==`project`&&(0,G.jsx)(`span`,{className:`rt-flag`,children:e.guard})]}),(0,G.jsxs)(`td`,{children:[jL[e.effect]??e.effect,e.effect===`attempted`&&e.intent?`: ${ML[e.intent]??e.intent}`:``,e.to?(0,G.jsxs)(G.Fragment,{children:[` to `,(0,G.jsx)(`code`,{children:e.to})]}):null,IL(e.count),e.basis?.errno&&(0,G.jsxs)(`span`,{className:`rt-muted`,children:[` (`,e.basis.errno,`)`]})]}),(0,G.jsx)(`td`,{title:NL[e.certainty]?.[1],children:NL[e.certainty]?.[0]??e.certainty}),(0,G.jsx)(zL,{fact:e,step:t(e.call_id),onOpenCall:n})]},e.id))})]})}):(0,G.jsx)(`p`,{className:`rt-empty`,children:`Nothing happened to a project file.`}),r.bulk.length>0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`rt-list-head`,children:[(0,G.jsx)(`span`,{children:`BULK FILE ACCESS`}),(0,G.jsx)(`small`,{children:`counted, not kept`})]}),(0,G.jsx)(`ul`,{className:`rt-foot rt-bulk`,children:r.bulk.slice(0,20).map(e=>{let r=t(e.call_id);return(0,G.jsxs)(`li`,{children:[FL(e.at),`: `,e.process??`a step`,` opened `,e.opens.toLocaleString(),` files (`,Object.entries(e.folders).map(([e,t])=>`${t.toLocaleString()} under ${e}`).join(`, `),`)`,` `,r&&(0,G.jsxs)(`button`,{type:`button`,className:`link-button`,onClick:()=>n(r.trace,r.call),children:[`Open the step `,(0,G.jsx)(P,{size:11})]})]},e.id)})})]}),r.identity.length>0&&(0,G.jsxs)(`p`,{className:`rt-problem`,children:[`A program asked to change its user or group id: `,r.identity.map(e=>`${e.basis?.syscall??`setid`}(${e.ids.join(`, `)}) by ${e.process??`a process`}, ${e.effect===`changed`?`allowed`:`refused${e.basis?.errno?` (${e.basis.errno})`:``}`}`).join(`; `),`.`]}),(0,G.jsx)(`p`,{className:`rt-foot`,children:`Seen by the kernel layer of the sandbox and its host, not reported by the agent. An address is what a program connected to; the name beside it is the lookup that answered with it. HTTPS contents are not read. A file that was read is one opened for reading. Reads of ordinary project files are counted, not listed, and so is everything under folders like node_modules.`})]})}function UL(e){let t=new Map,n=new Map,r=(e,r)=>{if(e.call_id&&t.set(e.call_id,[...t.get(e.call_id)??[],r]),e.pid!=null){let t=`${e.pid}:${e.process_start_ns??``}`;n.set(t,[...n.get(t)??[],r])}};if(!e)return{byCall:t,byProcess:n};for(let t of e.network){let e=!!t.outcomes.refused_by_policy;r(t,{key:t.id,fail:e,text:`${e?`refused `:t.effect===`listen`?`listens on `:`→ `}${t.host??t.ip}:${t.port}${IL(t.count)}`,title:Object.entries(t.outcomes).map(([e,t])=>`${PL[e]?.[0]??e}${IL(t)}`).join(`, `)})}for(let t of e.packages)r(t,{key:t.id,text:`${t.manager}: ${t.total.toLocaleString()} package${t.total===1?``:`s`}`,title:t.packages.slice(0,20).map(e=>`${e.name}@${e.version}`).join(`, `)});for(let t of e.files)t.path&&r(t,{key:t.id,fail:t.effect===`attempted`,text:`${t.path.split(`/`).pop()} ${(jL[t.effect]??t.effect).toLowerCase()}`,title:`${t.path}\n${NL[t.certainty]?.[1]??``}\n${RL(t)}`});return{byCall:t,byProcess:n}}var WL=200,GL={untested:[`no test`,`No test file is named after this file.`],unreferenced:[`not imported`,`No other file imports this one, and nothing was found that starts it.`],large:[`large`,`Over 800 lines.`],created:[`new`,`Appeared after the initial scan, so it is scored by its path alone.`]},KL={watched_changed:`Watched file changed`,restricted_changed:`Restricted file changed`,new_sensitive:`Sensitive file created`,restricted_blocked:`Change to a restricted file blocked`,restricted_read:`Restricted file read`,restricted_named:`Restricted file named in a command`,watched_read:`Watched file read`,network_refused:`Connection to a private address refused`},qL={restricted_blocked:`The agent tried to change this file and was refused.`,restricted_named:`The command mentions this file. What it does is not known: it may only read it.`,network_refused:`The sandbox firewall rejects private addresses: the VM's own services and the cloud metadata server are there.`},JL={A:`added`,M:`edited`,D:`deleted`,R:`renamed`,T:`type changed`},YL={kernel:`Seen by the sandbox's kernel layer and its host: every program, whatever started it, and nothing the agent could write.`,hook:`Reported by the sandbox's Claude Code hook: the agent's own tool said so.`};function XL(e){let t=[];for(let n of e){let e=n.at??n.created,r=t.find(t=>t.path===n.path&&t.kind===n.kind&&!t.sources.includes(n.source)&&(t.call_id&&n.call_id?t.call_id===n.call_id:Math.abs((t.at??t.created)-e)<=20));if(!r){t.push({...n,ids:[n.id],sources:[n.source],tool:n.source===`hook`?n.tool:null,by:n.source===`kernel`?n.tool:null});continue}r.ids.push(n.id),r.sources.push(n.source),r.seen=r.seen&&n.seen,r.call_id??=n.call_id,n.source===`kernel`?r.by=n.tool:(r.tool=n.tool,r.status??=n.status,r.added??=n.added,r.removed??=n.removed,r.commit??=n.commit)}return t}var ZL=e=>new Date(typeof e==`number`?e*1e3:e).toLocaleString(void 0,{day:`numeric`,month:`short`,hour:`numeric`,minute:`2-digit`});function QL({level:e,title:t}){return(0,G.jsx)(`span`,{className:`rt-level level-${e}`,title:t??`Level ${e} of 5: ${_L[e]}`,children:e})}function $L({onSelect:e}){let[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(null);return(0,_.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await x().fetch(`/raytace/sandboxes`,{cache:`no-store`}),r=await t.json();if(!t.ok)throw Error(r.error||`Sandbox list unavailable`);e||n((r.sandboxes??[]).filter(e=>e.status!==`deleted`))}catch(t){e||i(t instanceof Error?t.message:`Sandbox list unavailable`)}})(),()=>{e=!0}},[]),r?(0,G.jsx)(`p`,{className:`rt-empty`,children:r}):t?t.length?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`rt-list-head`,children:(0,G.jsx)(`span`,{children:`CHOOSE A SANDBOX`})}),(0,G.jsx)(`ol`,{className:`rt-prompts`,children:t.map(t=>(0,G.jsx)(`li`,{className:`rt-prompt`,children:(0,G.jsxs)(`button`,{type:`button`,className:`rt-prompt-row`,onClick:()=>e(t.id),children:[(0,G.jsx)(`time`,{children:ZL(t.created)}),(0,G.jsx)(`strong`,{children:t.name}),(0,G.jsxs)(`small`,{children:[t.id.slice(0,12),`…`]})]})},t.id))})]}):(0,G.jsx)(`p`,{className:`rt-empty`,children:`No sandboxes yet. A project is scanned when its sandbox is created.`}):(0,G.jsx)(rp,{label:`Loading the initial scan…`})}function eR({box:e,traces:t,onSelect:n,onOpenCall:r,onAlertsSeen:i}){let[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(null),[d,f]=(0,_.useState)(`files`),[p,m]=(0,_.useState)(null),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(``),[b,x]=(0,_.useState)(()=>new Set([5,4,3,2,1])),[S,C]=(0,_.useState)(WL),[w,T]=(0,_.useState)([]),[E,D]=(0,_.useState)(null);(0,_.useEffect)(()=>{let e=!1;return TL().then(t=>{e||D(t)}),()=>{e=!0}},[]),(0,_.useEffect)(()=>{if(o(null),c(null),u(null),C(WL),x(new Set([5,4,3,2,1])),!e)return;let t=!1;return xL(e).then(e=>{t||o(e)},e=>{t||c(e.message)}),()=>{t=!0}},[e]),(0,_.useEffect)(()=>{if(T([]),!e)return;let t=!1,n,r=async()=>{try{let n=await wL(e);t||T(n.alerts)}catch{}t||(n=setTimeout(r,1e4))};return r(),()=>{t=!0,clearTimeout(n)}},[e]);let O=(0,_.useCallback)(async(t,n)=>{u(null),o(e=>e&&{...e,files:e.files.map(e=>e.path===t.path?{...e,...n}:e)});try{let n=await SL(e,[t]),r=new Map(n.files.map(e=>[e.path,e]));o(e=>e&&{...e,guardrails:n.guardrails??e.guardrails,files:e.files.map(e=>r.get(e.path)??e)}),AL(e)}catch(t){u(t instanceof Error?t.message:`That change could not be saved.`),xL(e).then(o,()=>void 0)}},[e]),k=(0,_.useMemo)(()=>a?.files??[],[a]),A=(0,_.useMemo)(()=>{let e=[0,0,0,0,0,0],t=0,n=0;for(let r of k)e[r.level]+=1,r.restricted&&(t+=1),r.notify&&(n+=1);return{byLevel:e,restricted:t,notify:n}},[k]),j=(0,_.useMemo)(()=>{let e=v.trim().toLowerCase();return k.filter(t=>(p==null||t.level===p)&&(h!==`restricted`||t.restricted)&&(h!==`notify`||t.notify)&&(!e||t.path.toLowerCase().includes(e))).sort((e,t)=>t.level-e.level||(t.reach?.score??t.reach?.dependents??0)-(e.reach?.score??e.reach?.dependents??0)||(t.reach?.dependents??0)-(e.reach?.dependents??0)||e.path.localeCompare(t.path))},[k,p,h,v]),M=!!(v.trim()||p!=null||h),N=j.slice(0,S),L=[5,4,3,2,1].map(e=>({level:e,total:j.filter(t=>t.level===e).length,files:N.filter(t=>t.level===e),closed:!M&&b.has(e)})).filter(e=>e.total>0),R=e=>{let t=(e.hazard?.level??0)>=4,n=(e.reach?.level??0)>=4;return t&&n?`Sensitive · Widely used`:t?`Sensitive`:n?`Widely used`:null},z=(0,_.useMemo)(()=>new Set(a?.guardrails?.read_only??[]),[a]),H=w.filter(e=>!e.seen),U=(0,_.useMemo)(()=>XL(w),[w]),ee=n=>{if(!n)return null;let r=t.find(t=>t.sandboxId===e&&!t.forkId&&t.callVerifications?.some(e=>e.call_id===n));return r?{trace:r.id,call:n}:null},W=async e=>{D(e),u(null);try{await EL(e)}catch(t){D(!e),u(t instanceof Error?t.message:`That setting could not be saved.`)}},te=async e=>{T(t=>t.map(t=>e.includes(t.id)?{...t,seen:!0}:t));try{await DL(e)}catch{}i()},ne=a?.scan;return(0,G.jsxs)(`section`,{className:`rt-view`,children:[(0,G.jsxs)(`header`,{className:`rt-view-head`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`eyebrow`,children:`INITIAL SCAN`}),(0,G.jsx)(`h1`,{children:a?.name?`How risky each file of ${a.name} is to change`:`How risky each file is to change`})]}),e&&(0,G.jsx)(`div`,{className:`rt-actions`,children:(0,G.jsx)(`button`,{type:`button`,className:`rt-button`,onClick:()=>n(``),children:`Another sandbox`})})]}),!e&&(0,G.jsx)($L,{onSelect:n}),e&&s&&(0,G.jsx)(`p`,{role:`alert`,className:`verify-error`,children:s}),e&&!s&&!a&&(0,G.jsx)(rp,{label:`Loading the initial scan…`}),a&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`dl`,{className:`rt-stats`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Files`}),(0,G.jsx)(`dd`,{children:k.length.toLocaleString()})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Level`}),(0,G.jsx)(`dd`,{className:`rt-sev-counts`,children:[5,4,3,2,1].map(e=>(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":p===e,className:`rt-level level-${e}${p===e?` rt-sev-on`:``}${p!=null&&p!==e?` rt-sev-off`:``}`,title:p===e?`Show every level`:`Show only level ${e} (${vL[e].toLowerCase()})`,onClick:()=>{m(t=>t===e?null:e),C(WL)},children:[e,` · `,A.byLevel[e]]},e))})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Reported when changed`}),(0,G.jsx)(`dd`,{children:(0,G.jsxs)(`button`,{type:`button`,className:`rt-pick${h===`notify`?` on`:``}`,"aria-pressed":h===`notify`,onClick:()=>{g(e=>e===`notify`?null:`notify`),C(WL)},children:[(0,G.jsx)(I,{size:13}),` `,A.notify]})})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Restricted`}),(0,G.jsx)(`dd`,{children:(0,G.jsxs)(`button`,{type:`button`,className:`rt-pick${h===`restricted`?` on`:``}`,"aria-pressed":h===`restricted`,onClick:()=>{g(e=>e===`restricted`?null:`restricted`),C(WL)},children:[(0,G.jsx)(se,{size:13}),` `,A.restricted]})})]})]}),(0,G.jsxs)(`div`,{className:`rt-tabs`,role:`tablist`,children:[(0,G.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":d===`files`,className:d===`files`?`on`:``,onClick:()=>f(`files`),children:`Files`}),(0,G.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":d===`alerts`,className:d===`alerts`?`on`:``,onClick:()=>f(`alerts`),children:[`Alerts`,H.length>0&&(0,G.jsx)(`span`,{className:`rt-count`,children:H.length})]}),(0,G.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":d===`activity`,className:d===`activity`?`on`:``,onClick:()=>f(`activity`),children:`Activity`})]}),l&&(0,G.jsx)(`p`,{role:`alert`,className:`rt-problem`,children:l}),d===`files`&&(0,G.jsxs)(G.Fragment,{children:[ne&&`error`in ne&&(0,G.jsxs)(`p`,{className:`rt-problem`,children:[ne.error,`. Files the agent changes are still scored by their path.`]}),!k.length&&!(ne&&`error`in ne)&&(0,G.jsx)(`p`,{className:`rt-empty`,children:`This sandbox was created before RayTrace scanned projects, so it has no scan.`}),k.length>0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`input`,{className:`rt-search`,type:`search`,value:v,placeholder:`Filter by path`,"aria-label":`Filter files by path`,onChange:e=>{y(e.target.value),C(WL)}}),(0,G.jsx)(`div`,{className:`rt-table-wrap`,children:(0,G.jsxs)(`table`,{className:`rt-table rt-scan`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{children:`Level`}),(0,G.jsx)(`th`,{children:`File`}),(0,G.jsx)(`th`,{children:`Why`}),(0,G.jsx)(`th`,{title:`Report it when the agent changes this file`,children:`Report`}),(0,G.jsx)(`th`,{title:`The agent may not change this file`,children:`Restrict`})]})}),L.map(e=>(0,G.jsxs)(`tbody`,{children:[(0,G.jsx)(`tr`,{className:`rt-scan-group`,children:(0,G.jsx)(`td`,{colSpan:5,children:(0,G.jsxs)(`button`,{type:`button`,"aria-expanded":!e.closed,onClick:()=>x(t=>{let n=new Set(t);return n.has(e.level)?n.delete(e.level):n.add(e.level),n}),children:[e.closed?(0,G.jsx)(V,{size:13}):(0,G.jsx)(B,{size:13}),(0,G.jsx)(`span`,{className:`rt-level level-${e.level}`,children:e.level}),vL[e.level],(0,G.jsxs)(`span`,{className:`rt-muted`,children:[e.total.toLocaleString(),` file`,e.total===1?``:`s`]})]})})}),!e.closed&&e.files.map(e=>(0,G.jsxs)(`tr`,{children:[(0,G.jsxs)(`td`,{className:`rt-scan-level`,children:[(0,G.jsx)(`select`,{className:`rt-level level-${e.level}`,value:e.level,"aria-label":`Level of ${e.path}`,onChange:t=>{let n=Number(t.target.value);O({path:e.path,level:n===e.scanned_level?null:n},{level:n,edited:n!==e.scanned_level,...e.notify_set?{}:{notify:n>=4}})},children:[5,4,3,2,1].map(t=>(0,G.jsxs)(`option`,{value:t,children:[t,` `,vL[t],t===e.scanned_level?` (scanned)`:``]},t))}),e.edited&&(0,G.jsx)(`button`,{type:`button`,className:`rt-undo`,title:`Back to the scanned level, ${e.scanned_level}`,"aria-label":`Put ${e.path} back to its scanned level`,onClick:()=>void O({path:e.path,level:null},{level:e.scanned_level,edited:!1,...e.notify_set?{}:{notify:e.scanned_level>=4}}),children:(0,G.jsx)(he,{size:11})})]}),(0,G.jsx)(`td`,{children:(0,G.jsx)(`code`,{children:e.path})}),(0,G.jsxs)(`td`,{className:`rt-scan-why`,children:[e.reasons.join(` · `)||(0,G.jsx)(`span`,{className:`rt-muted`,children:`Nothing imports it, and its name marks nothing`}),R(e)&&(0,G.jsx)(`span`,{className:`rt-flag rt-driver`,title:`What put this file at its level: sensitivity of the code, weighted blast radius, or both`,children:R(e)}),e.flags.map(e=>(0,G.jsx)(`span`,{className:`rt-flag`,title:GL[e]?.[1],children:GL[e]?.[0]??e},e)),e.restricted&&(0,G.jsx)(`small`,{className:`rt-scan-lock`,children:z.has(e.path)?`Read-only in the sandbox, for every tool.`:`Claude Code edits are refused now. Read-only for every tool after the sandbox is next stopped and started.`})]}),(0,G.jsx)(`td`,{children:(0,G.jsx)(`input`,{type:`checkbox`,checked:e.notify,"aria-label":`Report changes to ${e.path}`,onChange:t=>void O({path:e.path,notify:t.target.checked},{notify:t.target.checked,notify_set:!0})})}),(0,G.jsx)(`td`,{children:(0,G.jsx)(`input`,{type:`checkbox`,checked:e.restricted,"aria-label":`Restrict ${e.path}`,onChange:t=>void O({path:e.path,restricted:t.target.checked},{restricted:t.target.checked})})})]},e.path))]},e.level))]})}),!j.length&&(0,G.jsx)(`p`,{className:`rt-empty`,children:`No files match.`}),j.length>S&&(0,G.jsxs)(`p`,{className:`rt-foot`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`rt-button`,onClick:()=>C(e=>e+WL),children:[`Show `,Math.min(WL,j.length-S),` more`]}),` `,S.toLocaleString(),` of `,j.length.toLocaleString(),` shown`]}),ne&&!(`error`in ne)&&(0,G.jsxs)(`p`,{className:`rt-foot`,children:[ne.version===`scan-v2`?`Level is the higher of weighted blast radius and sensitivity. Direct and startup dependents count most, then each extra hop decays; reach is banded by percentile in this project, while secret, destructive, credential, payment and deploy code can be sensitive at any reach.`:`Level is the higher of how much of the project imports a file and what kind of file it is.`,` `,ne.edges.toLocaleString(),` imports followed in JavaScript, TypeScript and Python; other files are scored by path. Secrets left out of the upload are scored when the agent creates them.`]})]})]}),d===`alerts`&&(0,G.jsxs)(G.Fragment,{children:[E!==null&&(0,G.jsxs)(`label`,{className:`rt-foot rt-email`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:E,onChange:e=>void W(e.target.checked)}),` Email me about alerts`,(0,G.jsx)(`span`,{className:`rt-muted`,children:` · batched, at most one message every 30 seconds per project`})]}),!w.length&&(0,G.jsx)(`p`,{className:`rt-empty`,children:`No alerts. One is raised when the agent changes, tries to change or reads a file marked Report or Restrict, creates a sensitive one, or tries to reach a private address.`}),w.length>0&&(0,G.jsxs)(G.Fragment,{children:[H.length>0&&(0,G.jsx)(`p`,{className:`rt-foot`,children:(0,G.jsx)(`button`,{type:`button`,className:`rt-button`,onClick:()=>void te(H.map(e=>e.id)),children:`Mark all seen`})}),(0,G.jsx)(`div`,{className:`rt-table-wrap`,children:(0,G.jsxs)(`table`,{className:`rt-table rt-scan`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{children:`When`}),(0,G.jsx)(`th`,{children:`Level`}),(0,G.jsx)(`th`,{children:`File or destination`}),(0,G.jsx)(`th`,{children:`What happened`}),(0,G.jsx)(`th`,{title:`Who saw it: the sandbox's kernel layer, or the agent's own tool through the sandbox's hook`,children:`Seen by`}),(0,G.jsx)(`th`,{title:`The agent's tool, and the program the kernel saw do it`,children:`Tool`}),(0,G.jsx)(`th`,{children:`Step`})]})}),(0,G.jsx)(`tbody`,{children:U.map(e=>{let t=ee(e.call_id);return(0,G.jsxs)(`tr`,{className:`${e.seen?`rt-seen`:``}${e.kind===`restricted_blocked`||e.kind===`network_refused`?` rt-alert-blocked`:``}`,children:[(0,G.jsx)(`td`,{children:(0,G.jsx)(`time`,{title:e.at?`Seen at ${new Date(e.at*1e3).toISOString()}`:void 0,children:ZL(e.at??e.created)})}),(0,G.jsx)(`td`,{children:(0,G.jsx)(QL,{level:e.level})}),(0,G.jsx)(`td`,{children:(0,G.jsx)(`code`,{children:e.path})}),(0,G.jsxs)(`td`,{title:qL[e.kind],children:[(e.kind===`restricted_blocked`||e.kind===`network_refused`)&&(0,G.jsx)(F,{size:12,"aria-hidden":`true`}),` `,KL[e.kind]??e.kind,e.status&&JL[e.status]?(0,G.jsxs)(`span`,{className:`rt-muted`,children:[` · `,JL[e.status]]}):null,e.added!=null&&(0,G.jsxs)(`span`,{className:`rt-muted`,children:[` · +`,e.added,` −`,e.removed??0]})]}),(0,G.jsx)(`td`,{children:[...e.sources].sort().reverse().map(e=>(0,G.jsx)(`span`,{className:`rt-flag rt-source-${e}`,title:YL[e],children:e},e))}),(0,G.jsx)(`td`,{children:e.tool||e.by?(0,G.jsxs)(G.Fragment,{children:[e.tool,e.tool&&e.by?` · `:``,e.by&&(0,G.jsx)(`span`,{title:`The program the kernel saw do it`,children:e.by})]}):(0,G.jsx)(`span`,{className:`rt-muted`,children:`–`})}),(0,G.jsx)(`td`,{className:`rt-scan-open`,children:t&&(0,G.jsxs)(`button`,{type:`button`,className:`link-button`,onClick:()=>{te(e.ids),r(t.trace,t.call)},children:[`Open the step `,(0,G.jsx)(P,{size:11})]})})]},e.id)})})]})})]})]}),d===`activity`&&(0,G.jsx)(HL,{box:e,stepFor:ee,onOpenCall:r})]})]})}function tR(e){let t=e.callVerifications??[],n=new Map,r=[],i=t.flatMap(e=>e.snapshot?[e.snapshot]:[]),a=new Set;t.forEach((e,t)=>{let i=e.snapshot;if(i){for(let e of i.too_big??[])a.add(e);i.changed&&i.changes.length&&r.push({call:e,number:t+1});for(let e of i.changes){let r=n.get(e.path)??{path:e.path,status:e.status,added:0,removed:0,calls:[]};r.status=e.status,e.added==null||r.added==null?(r.added=null,r.removed=null):(r.added+=e.added,r.removed=(r.removed??0)+(e.removed??0)),r.calls.includes(t+1)||r.calls.push(t+1),n.set(e.path,r)}}});let o=[...n.values()];return{files:o,steps:r,base:i.length?i[0].parent??`4b825dc642cb6eb9a060e54bf8d69288fbee4904`:null,final:i.at(-1)?.commit??null,hasSnapshots:i.length>0,tooBig:[...a],added:o.reduce((e,t)=>e+(t.added??0),0),removed:o.reduce((e,t)=>e+(t.removed??0),0)}}function nR(e){return/CalledProcessError|Command \[|docker|snapshot failed|exec:/i.test(e)?`The sandbox holding these snapshots could not be reached to read them. Check it under Sandboxes, then try again.`:e}var rR=(e,t)=>`raytrace-${e.id.slice(0,8)}${t?`-${t.split(`/`).at(-1)}`:``}.patch`,iR=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function aR(e){let t={hunks:[],additions:0,deletions:0,binary:!1},n=null,r=0,i=0,a=[],o=[],s=()=>{if(n){for(let e=0;e<Math.max(a.length,o.length);e+=1)n.rows.push({oldNo:a[e]?.no??null,oldText:a[e]?.text??null,newNo:o[e]?.no??null,newText:o[e]?.text??null});a=[],o=[]}},c=String(e??``).split(`
|
|
28
28
|
`);return c.forEach((e,l)=>{if(/^Binary files .* differ$/.test(e)||e===`GIT binary patch`){t.binary=!0;return}let u=iR.exec(e);if(u){s(),n={header:e.trim(),rows:[]},t.hunks.push(n),r=Number(u[1]),i=Number(u[2]);return}if(!n)return;if(e.startsWith(`\\`)){s(),n.rows.push({oldNo:null,oldText:null,newNo:null,newText:null,note:e.slice(1).trim()});return}if(e.startsWith(`-`)){a.push({no:r,text:e.slice(1)}),r+=1,t.deletions+=1;return}if(e.startsWith(`+`)){o.push({no:i,text:e.slice(1)}),i+=1,t.additions+=1;return}if(e===``&&l===c.length-1)return;s();let d=e.startsWith(` `)?e.slice(1):e;n.rows.push({oldNo:r,oldText:d,newNo:i,newText:d}),r+=1,i+=1}),s(),t}var oR=e=>/^[0-9a-f]{40}$/.test(e)||e.startsWith(`refs/forks/`);async function sR(e,t,n,r){if(!oR(t)||!oR(n))throw Error(`This snapshot cannot be diffed.`);let i=new URLSearchParams({commit:t,to:n,...r?{path:r}:{}}),a=await x().fetch(`/raytace/snapshots/${e}/diff?${i}`),o=await a.json().catch(()=>({}));if(!a.ok)throw Error(nR(o.error??`HTTP ${a.status}`));return{diff:o.diff??``,truncated:!!o.truncated}}function cR(e,t){let n=URL.createObjectURL(new Blob([t],{type:`text/plain;charset=utf-8`})),r=document.createElement(`a`);r.href=n,r.download=e,document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(n)}var lR=e=>e.startsWith(`+`)&&!e.startsWith(`+++`)?`add`:e.startsWith(`-`)&&!e.startsWith(`---`)?`del`:e.startsWith(`@@`)?`hunk`:``,uR=`raytace.diff-view`;function dR(){let[e,t]=(0,_.useState)(`split`);return(0,_.useEffect)(()=>{try{localStorage.getItem(uR)===`unified`&&t(`unified`)}catch{}},[]),[e,e=>{t(e);try{localStorage.setItem(uR,e)}catch{}}]}function fR({diff:e}){let t=(0,_.useMemo)(()=>aR(e),[e]),[n,r]=dR();return t.binary?(0,G.jsx)(`p`,{className:`rt-files-note`,children:`A binary file: it changed, but there are no lines to show.`}):t.hunks.length?(0,G.jsxs)(`div`,{className:`rt-diff-wrap`,children:[(0,G.jsxs)(`div`,{className:`rt-diff-bar`,children:[(0,G.jsxs)(`span`,{children:[(0,G.jsxs)(`b`,{className:`rt-diff-add-n`,children:[`+`,t.additions]}),` `,(0,G.jsxs)(`b`,{className:`rt-diff-del-n`,children:[`−`,t.deletions]})]}),(0,G.jsxs)(`span`,{className:`rt-diff-mode`,children:[(0,G.jsx)(`button`,{type:`button`,"aria-pressed":n===`split`,className:n===`split`?`on`:``,onClick:()=>r(`split`),children:`Split`}),(0,G.jsx)(`button`,{type:`button`,"aria-pressed":n===`unified`,className:n===`unified`?`on`:``,onClick:()=>r(`unified`),children:`Unified`})]})]}),n===`unified`?(0,G.jsx)(`pre`,{className:`rt-diff`,children:e.split(`
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<title>RayTrace — Agent trace forensics</title>
|
|
7
7
|
<meta name="description" content="Evidence-backed traces and live counterfactual forks for coding agents." />
|
|
8
8
|
<link rel="icon" href="/favicon.svg?v=raytrace-box-1" type="image/svg+xml" />
|
|
9
|
-
<script type="module" crossorigin src="/assets/index-
|
|
9
|
+
<script type="module" crossorigin src="/assets/index-CNN5OJ-7.js"></script>
|
|
10
10
|
<link rel="stylesheet" crossorigin href="/assets/index-B5ndFs_A.css">
|
|
11
11
|
</head>
|
|
12
12
|
<body class="antialiased">
|
package/package.json
CHANGED
package/proxy/evidence-store.mjs
CHANGED
|
@@ -557,6 +557,10 @@ export function openEvidenceStore(file, { readOnly = false } = {}) {
|
|
|
557
557
|
insertAttribution.run(randomUUID(), toolCallId, eventId, method, confidence,
|
|
558
558
|
JSON.stringify({ method, score, window_start_ms: windowStartMs, window_end_ms: windowEndMs }), ATTRIBUTOR_VERSION, Date.now(),
|
|
559
559
|
score ?? null, windowStartMs ?? null, windowEndMs ?? null);
|
|
560
|
+
// The process may have exited and the call been answered before the two
|
|
561
|
+
// were tied (a transcript that arrives after its commands ran): neither
|
|
562
|
+
// arrival will come again to set the check.
|
|
563
|
+
checkReported({ toolCallId });
|
|
560
564
|
indexGuarded(() => indexCall(toolCallId));
|
|
561
565
|
return true;
|
|
562
566
|
},
|
|
@@ -983,7 +987,14 @@ export function openEvidenceStore(file, { readOnly = false } = {}) {
|
|
|
983
987
|
for (const row of rows) {
|
|
984
988
|
if (!row.reported_result_sha || row.exited_at_ns == null || row.exit_code == null) continue;
|
|
985
989
|
const reported = toolResultFacts(getPayload(row.reported_result_sha));
|
|
986
|
-
if (reported.exitCode === null)
|
|
990
|
+
if (reported.exitCode === null) {
|
|
991
|
+
// No code reported and no error: the agent took it as having worked,
|
|
992
|
+
// which agrees with an observed exit 0. With any other exit it stays
|
|
993
|
+
// unchecked: a command left running in the background also reports
|
|
994
|
+
// no error, and a false "differs" costs more trust than it earns.
|
|
995
|
+
if (reported.impliedSuccess && row.exit_code === 0) q('UPDATE runtime_attributions SET reported_check = ? WHERE id = ?').run('agrees', row.id);
|
|
996
|
+
continue;
|
|
997
|
+
}
|
|
987
998
|
let verdict = reported.exitCode === row.exit_code ? 'agrees' : 'exit_code_differs';
|
|
988
999
|
const observedMs = Number.isFinite(row.first_seen_ms) && Number.isFinite(row.exited_at_ms) ? row.exited_at_ms - row.first_seen_ms : null;
|
|
989
1000
|
if (verdict === 'agrees' && reported.wallMs !== null && observedMs !== null && observedMs >= 0) {
|
|
@@ -194,6 +194,30 @@ test('reported_check records disagreement whichever side arrives first', () => w
|
|
|
194
194
|
assert.equal(row.reported_check, 'exit_code_differs');
|
|
195
195
|
}));
|
|
196
196
|
|
|
197
|
+
test('a result with no code and no error agrees with an observed exit 0, and is left unchecked otherwise', () => {
|
|
198
|
+
withStore((store) => {
|
|
199
|
+
captureDemo(store, { reported: '1 passing' });
|
|
200
|
+
observeDemo(store);
|
|
201
|
+
assert.equal(store.divergence(['e1'])[0].reported_check, 'agrees');
|
|
202
|
+
});
|
|
203
|
+
withStore((store) => {
|
|
204
|
+
// Nothing reported and the sandbox saw exit 1: perhaps left running in the background. Not called a disagreement.
|
|
205
|
+
captureDemo(store, { reported: '1 passing' });
|
|
206
|
+
observeDemo(store, { exitCode: 1 });
|
|
207
|
+
assert.equal(store.divergence(['e1'])[0].reported_check, null);
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
test('reported_check is set when a process is tied to its call after both have finished', () => withStore((store) => {
|
|
212
|
+
// The command ran and exited before its call was recorded, as a transcript that arrives late leaves it.
|
|
213
|
+
const top = store.recordProcessStart({ containerId: CONTAINER, projectId: SESSION, raw: exec(1, 108, 10, ['/bin/bash', '-c', 'ls /nope'], '1000', 1_790_000_000_500), startedMs: 1_790_000_000_500 });
|
|
214
|
+
store.recordProcessExit({ containerId: CONTAINER, raw: exit(2, 108, '1000', 2, 1_790_000_000_600), endedMs: 1_790_000_000_600, exit_code: 2 });
|
|
215
|
+
captureDemo(store, { reported: HEADER(2, 0.1) });
|
|
216
|
+
const [candidate] = store.candidatesInWindow(0, Number.MAX_SAFE_INTEGER, { sessionId: SESSION });
|
|
217
|
+
store.attribute({ toolCallId: candidate.call_id, eventId: top.eventId, method: 'marker', confidence: 'exact', score: 1 });
|
|
218
|
+
assert.equal(one(store, "SELECT reported_check FROM runtime_attributions WHERE method = 'marker'").reported_check, 'agrees');
|
|
219
|
+
}));
|
|
220
|
+
|
|
197
221
|
test('attributionsForProcesses marks own, inherited and unattributed processes by pid + start time', () => withStore((store) => {
|
|
198
222
|
captureDemo(store);
|
|
199
223
|
observeDemo(store);
|
|
@@ -86,6 +86,12 @@ export function toExecutionEvent(event, clock = UNMEASURED_CLOCK) {
|
|
|
86
86
|
const pid = Number(event.pid);
|
|
87
87
|
const eventId = Number(event.event_id);
|
|
88
88
|
if (!command || timestamp == null || !Number.isFinite(pid) || !Number.isFinite(eventId)) return null;
|
|
89
|
+
// The hook announcing a file tool's call to the sandbox's recorder
|
|
90
|
+
// (worker/sandbox/claude-hook.mjs announce()): /bin/true, carrying the call
|
|
91
|
+
// id. It is not a process the call ran, and recording it would tie every
|
|
92
|
+
// Read, Write and Edit to a `true` that exited 0. Only the real `true` is
|
|
93
|
+
// left out: any other program given these arguments is recorded as usual.
|
|
94
|
+
if (argv[1] === 'raytrace-tool' && /^(?:\/usr)?\/bin\/true$/.test(String(event.executable ?? ''))) return null;
|
|
89
95
|
// `markers` is the collector's allowlisted RAYTRACE_* env (see
|
|
90
96
|
// worker/gvisor/collector.py MARKER_KEYS). When RAYTRACE_CALL_ID is present
|
|
91
97
|
// it IS the answer -- the call id travelled with the process -- and the
|
|
@@ -433,3 +433,11 @@ test('a source checkpoint failure does not reject the background poll and retrie
|
|
|
433
433
|
const forwarder=startGvisorForwarder({ingest:async()=>new Map(),finish:()=>{},fetchImpl,log:()=>{},saveProgress:async()=>{if(fail)throw Error('disk full');saved++;},pollMs:60000,discoverMs:60000});
|
|
434
434
|
try{await forwarder.discover();await assert.doesNotReject(forwarder.poll());fail=false;await forwarder.poll();assert.equal(saved,1);}finally{forwarder.stop();}
|
|
435
435
|
});
|
|
436
|
+
|
|
437
|
+
test('the hook announcing a file tool call is not a process of that call', () => {
|
|
438
|
+
const announce = { ...exec(7, 300, 299, ['true', 'raytrace-tool', 'begin', 'Read', 'src/app.js']), executable: '/usr/bin/true', markers: { RAYTRACE_CALL_ID: 'toolu_1' } };
|
|
439
|
+
assert.equal(toExecutionEvent(announce), null);
|
|
440
|
+
// Any other program given the same arguments is a process like any other.
|
|
441
|
+
assert.equal(toExecutionEvent({ ...announce, executable: '/workspace/true' }).call_marker, 'toolu_1');
|
|
442
|
+
assert.equal(toExecutionEvent({ ...announce, argv: ['true', 'something-else'] }).call_marker, 'toolu_1');
|
|
443
|
+
});
|
package/proxy/tool-metadata.mjs
CHANGED
|
@@ -27,6 +27,15 @@ export function toolResultFacts(item) {
|
|
|
27
27
|
if (metadata && typeof metadata.exit_code === 'number') {
|
|
28
28
|
facts.exitCode = metadata.exit_code;
|
|
29
29
|
if (typeof metadata.duration_seconds === 'number') facts.wallMs = Math.round(metadata.duration_seconds * 1000);
|
|
30
|
+
return facts;
|
|
31
|
+
}
|
|
32
|
+
// Claude Code's Bash tool: a failed command's result is an error that
|
|
33
|
+
// begins "Exit code N"; a command that worked says nothing about its code.
|
|
34
|
+
// Only an error is read for the code: the same words can be a command's own output.
|
|
35
|
+
if (typeof output === 'string' || Array.isArray(output)) {
|
|
36
|
+
const exit = item?.is_error === true ? text.match(/^Exit code (-?\d+)\s*(?:\n|$)/) : null;
|
|
37
|
+
if (exit) facts.exitCode = Number(exit[1]);
|
|
38
|
+
else if (item?.is_error !== true) facts.impliedSuccess = true;
|
|
30
39
|
}
|
|
31
40
|
return facts;
|
|
32
41
|
}
|
|
@@ -31,8 +31,18 @@ test('toolResultFacts reads exit code and wall time from the runner header only'
|
|
|
31
31
|
// Still running: the wall time is how long Codex waited, not a run time.
|
|
32
32
|
assert.deepEqual(toolResultFacts({ output: 'Wall time: 10.0 seconds\nProcess running with session ID 7\nOutput:\n' }), { exitCode: null, wallMs: null });
|
|
33
33
|
// File contents that look like a header are not a header.
|
|
34
|
-
assert.deepEqual(toolResultFacts({ output: 'a file containing\nProcess exited with code 1' }), { exitCode: null, wallMs: null });
|
|
34
|
+
assert.deepEqual(toolResultFacts({ output: 'a file containing\nProcess exited with code 1' }), { exitCode: null, wallMs: null, impliedSuccess: true });
|
|
35
35
|
// The older shell tool's JSON metadata.
|
|
36
36
|
assert.deepEqual(toolResultFacts({ output: JSON.stringify({ output: 'ok', metadata: { exit_code: 2, duration_seconds: 0.25 } }) }), { exitCode: 2, wallMs: 250 });
|
|
37
37
|
assert.deepEqual(toolResultFacts(undefined), { exitCode: null, wallMs: null });
|
|
38
38
|
});
|
|
39
|
+
|
|
40
|
+
test('toolResultFacts reads Claude Code\'s Bash result: a code only from an error, success only implied', async () => {
|
|
41
|
+
const { toolResultFacts } = await import('./tool-metadata.mjs');
|
|
42
|
+
assert.deepEqual(toolResultFacts({ output: 'Exit code 127\nbash: nope: command not found', is_error: true }), { exitCode: 127, wallMs: null });
|
|
43
|
+
// The same words printed by a command that worked are its output, not its code.
|
|
44
|
+
assert.deepEqual(toolResultFacts({ output: 'Exit code 3\nfrom a log file' }), { exitCode: null, wallMs: null, impliedSuccess: true });
|
|
45
|
+
assert.deepEqual(toolResultFacts({ output: '(Bash completed with no output)' }), { exitCode: null, wallMs: null, impliedSuccess: true });
|
|
46
|
+
// An error with no code (a refused tool, a timeout) says nothing either way.
|
|
47
|
+
assert.deepEqual(toolResultFacts({ output: '<tool_use_error>refused</tool_use_error>', is_error: true }), { exitCode: null, wallMs: null });
|
|
48
|
+
});
|
package/worker/sandbox/engine.py
CHANGED
|
@@ -685,6 +685,9 @@ class Engine(threading.Thread):
|
|
|
685
685
|
"""The fact these say, begun or added to: one fact for the same thing
|
|
686
686
|
done by the same step, with a count, not one for each time."""
|
|
687
687
|
step = who.get('call_id') or (f"{who.get('pid')}:{who.get('start_ns')}" if who.get('pid') else '')
|
|
688
|
+
if not step and kind == 'file':
|
|
689
|
+
# Nobody to name: the same thing ten minutes later is another event, not one more of this one.
|
|
690
|
+
step = f'@{int(at_ns) // 60_000_000_000}'
|
|
688
691
|
fact_id = hashlib.sha256('\0'.join([box.container, kind, step, *map(str, key)]).encode()).hexdigest()[:32]
|
|
689
692
|
fact = self.facts.get(fact_id)
|
|
690
693
|
if fact is None:
|
|
@@ -957,22 +960,41 @@ class Engine(threading.Thread):
|
|
|
957
960
|
for writer in writers:
|
|
958
961
|
flags |= writer['flags']
|
|
959
962
|
effect = change(before, after, cause['events'], flags)
|
|
963
|
+
note = None
|
|
964
|
+
if effect is None and before is None and after is None and 'delete' in cause['events']:
|
|
965
|
+
# Not there at the last look and not there now, but the watcher saw
|
|
966
|
+
# it come and go in between. (A temporary file that was renamed
|
|
967
|
+
# away has no delete: it is the file it became.)
|
|
968
|
+
made = 'create' in cause['events'] or bool(flags & O_CREAT)
|
|
969
|
+
if made or 'moved_to' in cause['events']:
|
|
970
|
+
effect = 'created_and_deleted' if made else 'deleted'
|
|
971
|
+
note = ('created and deleted again before it was looked at: what it held was never seen' if made
|
|
972
|
+
else 'moved to this name and deleted before it was looked at')
|
|
973
|
+
elif effect is None and before is not None and after is not None and 'modify' in cause['events']:
|
|
974
|
+
effect = 'rewritten'
|
|
975
|
+
note = 'written to; it holds the same bytes as before. Whether they were changed and put back is not known'
|
|
960
976
|
if effect:
|
|
961
977
|
box.photos[path] = after
|
|
962
978
|
if after is None and box.known is not None:
|
|
963
979
|
box.known.discard(path)
|
|
964
980
|
via = None
|
|
981
|
+
opened, seen = [], set()
|
|
982
|
+
for writer in reversed(writers): # the latest to open it first
|
|
983
|
+
key = (writer['who']['pid'], writer['who']['start_ns'])
|
|
984
|
+
if key not in seen:
|
|
985
|
+
seen.add(key)
|
|
986
|
+
opened.append((writer['who'], writer['syscall']))
|
|
965
987
|
if effect in ('deleted', 'renamed'):
|
|
966
988
|
found = self.actors(box, 'remove' if effect == 'deleted' else 'rename', cause['at_ns'], path)
|
|
989
|
+
elif effect == 'created_and_deleted':
|
|
990
|
+
# Whoever deleted it; failing that, whoever made it.
|
|
991
|
+
found = self.actors(box, 'remove', cause['at_ns'], path) or opened
|
|
992
|
+
for writer in writers:
|
|
993
|
+
writer['credited'] = True
|
|
967
994
|
elif effect == 'permissions_changed':
|
|
968
995
|
found = self.actors(box, 'metadata', cause['at_ns'], path)
|
|
969
996
|
else:
|
|
970
|
-
|
|
971
|
-
for writer in reversed(writers): # the latest to open it first
|
|
972
|
-
key = (writer['who']['pid'], writer['who']['start_ns'])
|
|
973
|
-
if key not in seen:
|
|
974
|
-
seen.add(key)
|
|
975
|
-
opened.append((writer['who'], writer['syscall']))
|
|
997
|
+
for writer in writers:
|
|
976
998
|
writer['credited'] = True
|
|
977
999
|
found = None
|
|
978
1000
|
if 'moved_to' in cause['events']:
|
|
@@ -992,6 +1014,8 @@ class Engine(threading.Thread):
|
|
|
992
1014
|
who = self.called(box, who, path, cause['at_ns'])
|
|
993
1015
|
certainty = 'unattributed' if not found else 'confirmed' if len(found) == 1 else 'one_of'
|
|
994
1016
|
basis = {'syscall': call, 'watcher': sorted(cause['events']), 'before': before, 'after': after, 'resolution': 'lexical'}
|
|
1017
|
+
if note:
|
|
1018
|
+
basis['note'] = note
|
|
995
1019
|
if via:
|
|
996
1020
|
basis.update(resolution='link', via=via, note='opened under another name that is a link to this file')
|
|
997
1021
|
if len(found) > 1:
|
|
@@ -1010,7 +1034,8 @@ class Engine(threading.Thread):
|
|
|
1010
1034
|
self.fact(box, 'file', (path, 'opened_for_writing'), writer['who'],
|
|
1011
1035
|
{'path': path, 'guard': guard, 'effect': 'opened_for_writing', 'certainty': 'possible',
|
|
1012
1036
|
'basis': {'syscall': writer['syscall'], 'flags': writer['flags'], 'before': before, 'after': after,
|
|
1013
|
-
'resolution': 'lexical',
|
|
1037
|
+
'resolution': 'lexical',
|
|
1038
|
+
'note': 'opened for writing; the file holds the same bytes as before. A write that was put back would look the same'}}, writer['at_ns'])
|
|
1014
1039
|
for writer in writers:
|
|
1015
1040
|
if writer.get('gone'):
|
|
1016
1041
|
writer['settled'] = True
|
|
@@ -387,6 +387,34 @@ class EveryProjectFile(unittest.TestCase):
|
|
|
387
387
|
'argv': ['true', engine.TOOL_MARK, 'begin', 'Read', 'config/payment-keys.js'],
|
|
388
388
|
'timestamp_ns': str(time.time_ns()), 'markers': {'RAYTRACE_CALL_ID': 'made_up'}})
|
|
389
389
|
self.assertEqual(len(self.box.tools), 0)
|
|
390
|
+
def test_a_file_that_came_and_went_between_two_looks_is_a_line(self):
|
|
391
|
+
self.engine.refresh(self.box)
|
|
392
|
+
self.opened('src/scratch.txt', flags=engine.O_CREAT | 1)
|
|
393
|
+
self.assertEqual(self.looked('src/scratch.txt', 'create', 'modify', 'close_write', 'delete'),
|
|
394
|
+
[('src/scratch.txt', 'created_and_deleted', 'project', 'call_10')])
|
|
395
|
+
self.assertNotIn('src/scratch.txt', self.box.guarded)
|
|
396
|
+
self.assertEqual(len(self.looked('src/scratch.txt', final=True)), 1)
|
|
397
|
+
|
|
398
|
+
def test_a_file_written_with_the_same_bytes_is_said_to_be_written(self):
|
|
399
|
+
self.engine.refresh(self.box)
|
|
400
|
+
self.opened('src/app.js')
|
|
401
|
+
self.write('src/app.js', 'one') # what it already held
|
|
402
|
+
self.assertEqual(self.looked('src/app.js', 'modify', 'close_write'), [('src/app.js', 'rewritten', 'project', 'call_10')])
|
|
403
|
+
# Opened for writing and never written: still only "possible", at the last look.
|
|
404
|
+
self.engine.facts.clear()
|
|
405
|
+
self.opened('config/payment-keys.js', flags=1)
|
|
406
|
+
self.assertEqual(self.looked('config/payment-keys.js'), [])
|
|
407
|
+
self.assertEqual(self.looked('config/payment-keys.js', final=True), [('config/payment-keys.js', 'opened_for_writing', 'sensitive', 'call_10')])
|
|
408
|
+
|
|
409
|
+
def test_two_deletes_nobody_can_be_named_for_are_two_lines_when_minutes_apart(self):
|
|
410
|
+
self.engine.refresh(self.box)
|
|
411
|
+
body = {'path': 'src/app.js', 'effect': 'deleted', 'certainty': 'unattributed', 'basis': {}}
|
|
412
|
+
key = ('src/app.js', 'deleted', 'unattributed')
|
|
413
|
+
now = time.time_ns() // 60_000_000_000 * 60_000_000_000 + 1_000_000_000 # a second into a minute
|
|
414
|
+
self.engine.fact(self.box, 'file', key, {}, dict(body), now)
|
|
415
|
+
self.engine.fact(self.box, 'file', key, {}, dict(body), now + 1_000_000)
|
|
416
|
+
self.engine.fact(self.box, 'file', key, {}, dict(body), now + 600_000_000_000)
|
|
417
|
+
self.assertEqual(sorted(fact['count'] for fact in self.engine.facts.values()), [1, 2])
|
|
390
418
|
|
|
391
419
|
def test_a_write_through_a_link_is_still_the_writers(self):
|
|
392
420
|
os.symlink('app.js', Path(self.folder.name) / 'src/alias.js')
|