@action-llama/action-llama 0.26.6 → 0.26.7
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/build-info.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"gitSha":"
|
|
1
|
+
{"gitSha":"abc6143f"}
|
|
@@ -13,4 +13,4 @@ Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}
|
|
|
13
13
|
font-weight: bold;
|
|
14
14
|
color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i}return o.updateDeps=e=>{r=e},o}function xi(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var Si=(e,t)=>Math.abs(e-t)<1.01,Ci=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},wi=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},Ti=e=>e,Ei=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},Di=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(wi(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(wi(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},Oi={passive:!0},ki=typeof window>`u`?!0:`onscrollend`in window,Ai=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&ki?()=>void 0:Ci(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,Oi);let l=e.options.useScrollendEvent&&ki;return l&&n.addEventListener(`scrollend`,c,Oi),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},ji=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},Mi=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},Ni=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Ti,rangeExtractor:Ei,onChange:()=>{},measureElement:ji,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...e}},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=bi(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=bi(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(e,t,n,r,i,a)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a}),{key:!1}),this.getMeasurements=bi(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a},o)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let s=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let c=this.measurementsCache.slice(0,s),l=Array(a).fill(void 0);for(let e=0;e<s;e++){let t=c[e];t&&(l[t.lane]=e)}for(let i=s;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,u;if(a!==void 0&&this.options.lanes>1){s=a;let e=l[s],r=e===void 0?void 0:c[e];u=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?c[i-1]:this.getFurthestMeasurement(c,i);u=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(i,s)}let d=o.get(e),f=typeof d==`number`?d:this.options.estimateSize(i),p=u+f;c[i]={index:i,start:u,size:f,end:p,key:e,lane:s},l[s]=i}return this.measurementsCache=c,c},{key:!1,debug:()=>this.options.debug}),this.calculateRange=bi(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?Fi({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=bi(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{let n=this.measurementsCache[e];if(!n)return;let r=t-(this.itemSizeCache.get(n.key)??n.size);r!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?n.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,t)),this.notify(!1))},this.getVirtualItems=bi(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return xi(t[Pi(0,t.length-1,e=>xi(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t);this.scrollState={index:null,align:t,behavior:n,startedAt:this.now(),lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e;this.scrollState={index:null,align:`start`,behavior:t,startedAt:this.now(),lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=e[e.length-1]?.end??0;else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&Si(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior=`auto`,this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}));this.scheduleScrollReconcile()}},Pi=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function Fi({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=Pi(0,i,a,n),s=o;if(r===1)for(;s<i&&e[s].end<n+t;)s++;else if(r>1){let a=Array(r).fill(0);for(;s<i&&a.some(e=>e<n+t);){let t=e[s];a[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var Ii=typeof document<`u`?x.useLayoutEffect:x.useEffect;function Li({useFlushSync:e=!0,...t}){let n=x.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,yi.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=x.useState(()=>new Ni(r));return i.setOptions(r),Ii(()=>i._didMount(),[]),Ii(()=>i._willUpdate()),i}function F(e){return Li({observeElementRect:Di,observeElementOffset:Ai,scrollToFn:Mi,...e})}function I(e){if(e<1e3)return`${e}ms`;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${t%60}s`:`${Math.floor(n/60)}h ${n%60}m`}function Ri(e){return!e||e===0?`$0.00`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function zi(e){return!e||e===0?`0`:e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function Bi(e){return e.length<=9?e:`${e.slice(0,4)}\u2026${e.slice(-4)}`}function Vi(e){return new Date(e).toLocaleString()}function Hi(e){let t=Date.now()-new Date(e).getTime();if(t<0)return``;let n=Math.floor(t/36e5);return n<1?`last ${Math.floor(t/6e4)}m`:n<24?`last ${n}h`:`last ${Math.floor(n/24)}d`}function Ui(e,t=6){let n=Date.now()-new Date(e).getTime();if(n<0||n>=t*36e5)return new Date(e).toLocaleString();let r=Math.floor(n/1e3);if(r<60)return`${r}s ago`;let i=Math.floor(r/60);return i<60?`${i} min ago`:`${Math.floor(i/60)}h ago`}var Wi={pending:`bg-amber-400`,running:`bg-blue-500 animate-pulse`,completed:`bg-green-500`,error:`bg-red-500`,"dead-letter":`bg-red-300 dark:bg-red-800`,rerun:`bg-green-500`},Gi={pending:`Pending`,running:`Running`,completed:`Completed`,error:`Error`,"dead-letter":`Dead Letter`,rerun:`Rerun`},Ki={pending:`border-l-2 border-l-amber-400 dark:border-l-amber-500 bg-amber-50/40 dark:bg-amber-950/20`,running:`border-l-2 border-l-blue-500 dark:border-l-blue-400 bg-blue-50/40 dark:bg-blue-950/20`,completed:`border-l-2 border-l-green-500 dark:border-l-green-400`,error:`border-l-2 border-l-red-500 dark:border-l-red-400 bg-red-50/30 dark:bg-red-950/20`,"dead-letter":`border-l-2 border-l-red-300 dark:border-l-red-700 bg-red-50/20 dark:bg-red-950/10`,rerun:`border-l-2 border-l-green-500 dark:border-l-green-400`};function qi(e){return e.triggerType===`webhook`&&e.triggerSource?e.eventSummary&&e.eventSummary!==e.triggerSource?`${e.triggerSource} ${e.eventSummary}`:e.triggerSource:e.triggerType}function Ji(e){return!!(e.agentName&&e.instanceId)&&e.result!==`pending`&&e.result!==`running`&&e.result!==`dead-letter`}(0,x.memo)(function({row:e,index:t,agentNames:n}){let[r,i]=(0,x.useState)(!1),[a,o]=(0,x.useState)(null),[s,c]=(0,x.useState)(null),[l,u]=(0,x.useState)(!1),[d,f]=(0,x.useState)(!1),p=e.result===`dead-letter`,m=qi(e),h=e.instanceId??``,g=h?a??e.summary??null:null,_=!l,v=d,y=Ji(e),b=async()=>{if(!(!e.agentName||!h)){i(!0),c(null);try{let t=await yr(e.agentName,h);t.summary&&o(t.summary)}catch(e){c(e instanceof Error?e.message:`Failed to generate summary`)}finally{i(!1)}}},S=()=>{u(e=>!e)},C=()=>{f(e=>!e)},w=e.instanceId?`/dashboard/triggers/${encodeURIComponent(e.instanceId)}`:e.webhookReceiptId?`/dashboard/webhooks/${encodeURIComponent(e.webhookReceiptId)}`:null,T=w?(0,N.jsxs)(M,{to:w,className:`inline-flex items-center gap-1 hover:underline`,children:[(0,N.jsx)(ri,{label:m}),e.triggerType!==`webhook`&&e.triggerSource&&(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:e.triggerSource})]}):(0,N.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,N.jsx)(ri,{label:m}),e.triggerType!==`webhook`&&e.triggerSource&&(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:e.triggerSource})]}),E=!p&&e.agentName&&e.instanceId?(0,N.jsx)(M,{to:`/dashboard/agents/${encodeURIComponent(e.agentName)}/instances/${encodeURIComponent(e.instanceId)}`,className:`font-medium hover:underline truncate block`,children:(0,N.jsx)(`span`,{className:`agent-color-text truncate text-sm md:text-base`,style:P(e.agentName,n),children:e.instanceId})}):!p&&e.agentName?(0,N.jsx)(M,{to:`/dashboard/agents/${encodeURIComponent(e.agentName)}`,className:`font-medium hover:underline truncate block`,children:(0,N.jsx)(`span`,{className:`agent-color-text truncate text-sm md:text-base`,style:P(e.agentName,n),children:e.agentName})}):null,ee=(0,N.jsx)(`td`,{className:`pl-0 pr-2 py-2.5 hidden md:table-cell align-top`,children:r?(0,N.jsx)(`span`,{className:`text-xs text-slate-400 dark:text-slate-500 animate-pulse`,children:`Generating…`}):s?(0,N.jsxs)(`span`,{className:`text-xs text-red-500 dark:text-red-400`,title:s,children:[`Failed to generate — `,s]}):g?(0,N.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,N.jsx)(`button`,{onClick:()=>S(),className:`text-xs text-slate-600 dark:text-slate-300 text-left hover:text-slate-900 dark:hover:text-white transition-colors`,title:_?`Collapse`:`Click to expand`,children:_?(0,N.jsx)(`span`,{children:g}):(0,N.jsx)(`span`,{className:`line-clamp-2`,children:g})}),y&&(0,N.jsx)(`button`,{onClick:()=>b(),className:`shrink-0 text-slate-400 hover:text-slate-600 dark:text-slate-500 dark:hover:text-slate-300 transition-colors`,title:`Regenerate summary`,children:`↻`})]}):y?(0,N.jsx)(`button`,{onClick:()=>b(),className:`text-xs text-blue-500 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 transition-colors`,children:`Generate`}):(0,N.jsx)(`span`,{className:`text-xs text-slate-300 dark:text-slate-600`,children:`—`})});return(0,N.jsxs)(`tr`,{className:`border-b border-slate-100 dark:border-slate-800/50 last:border-b-0 hover:bg-slate-100/60 dark:hover:bg-slate-800/40 transition-colors ${Ki[e.result]??``}`,children:[(0,N.jsx)(`td`,{className:`pl-4 pr-1 py-2.5 text-slate-600 dark:text-slate-400 text-xs whitespace-nowrap align-top w-[1%]`,title:new Date(e.ts).toLocaleString(),children:(0,N.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,N.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${Wi[e.result]??`bg-slate-400`}`,title:Gi[e.result]??e.result}),Ui(e.ts)]})}),(0,N.jsx)(`td`,{className:`pl-2 pr-2 py-2.5 whitespace-nowrap max-w-[200px]`,children:(0,N.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[E,(0,N.jsx)(`div`,{className:`mt-0.5`,children:T}),p&&e.deadLetterReason&&(0,N.jsx)(`span`,{className:`text-xs text-red-500 dark:text-red-400`,children:e.deadLetterReason.replace(/_/g,` `)}),y&&(0,N.jsx)(`div`,{className:`md:hidden mt-1`,children:r?(0,N.jsx)(`span`,{className:`text-xs text-slate-400 dark:text-slate-500 animate-pulse`,children:`Generating…`}):s?(0,N.jsx)(`span`,{className:`text-xs text-red-500 dark:text-red-400`,title:s,children:`Failed to generate`}):g?(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`button`,{onClick:()=>C(),className:`text-xs text-slate-500 dark:text-slate-400 text-left hover:text-slate-700 dark:hover:text-slate-200 transition-colors`,children:v?(0,N.jsx)(`span`,{children:g}):(0,N.jsx)(`span`,{children:g.length>60?`${g.slice(0,60)}…`:g})}),v&&(0,N.jsx)(`button`,{onClick:()=>b(),className:`ml-2 text-xs text-slate-400 hover:text-slate-600 dark:text-slate-500 dark:hover:text-slate-300 transition-colors`,title:`Regenerate summary`,children:`↻ Regenerate`})]}):(0,N.jsx)(`button`,{onClick:()=>b(),className:`text-xs text-blue-500 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 transition-colors`,children:`Generate summary`})})]})}),ee]},`${e.ts}-${t}`)});var Yi=(0,x.memo)(function({row:e,agentNames:t}){let[n,r]=(0,x.useState)(!1),[i,a]=(0,x.useState)(null),[o,s]=(0,x.useState)(null),[c,l]=(0,x.useState)(!1),[u,d]=(0,x.useState)(!1),f=e.instanceId??``,p=e.result===`dead-letter`,m=qi(e),h=i??e.summary??null,g=Ji(e),_=!c,v=(0,x.useCallback)(async()=>{if(!(!e.agentName||!f)){r(!0),s(null);try{let t=await yr(e.agentName,f);t.summary&&a(t.summary)}catch(e){s(e instanceof Error?e.message:`Failed to generate summary`)}finally{r(!1)}}},[e.agentName,f]),y=(0,x.useCallback)(()=>l(e=>!e),[]),b=(0,x.useCallback)(()=>d(e=>!e),[]),S=e.instanceId?`/dashboard/triggers/${encodeURIComponent(e.instanceId)}`:e.webhookReceiptId?`/dashboard/webhooks/${encodeURIComponent(e.webhookReceiptId)}`:null,C=S?(0,N.jsxs)(M,{to:S,className:`inline-flex items-center gap-1 hover:underline`,children:[(0,N.jsx)(ri,{label:m}),e.triggerType!==`webhook`&&e.triggerSource&&(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:e.triggerSource})]}):(0,N.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,N.jsx)(ri,{label:m}),e.triggerType!==`webhook`&&e.triggerSource&&(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:e.triggerSource})]}),w=!p&&e.agentName&&e.instanceId?(0,N.jsx)(M,{to:`/dashboard/agents/${encodeURIComponent(e.agentName)}/instances/${encodeURIComponent(e.instanceId)}`,className:`font-medium hover:underline truncate block`,children:(0,N.jsx)(`span`,{className:`agent-color-text truncate text-sm md:text-base`,style:P(e.agentName,t),children:e.instanceId})}):!p&&e.agentName?(0,N.jsx)(M,{to:`/dashboard/agents/${encodeURIComponent(e.agentName)}`,className:`font-medium hover:underline truncate block`,children:(0,N.jsx)(`span`,{className:`agent-color-text truncate text-sm md:text-base`,style:P(e.agentName,t),children:e.agentName})}):null;return(0,N.jsxs)(`div`,{className:`flex border-b border-slate-100 dark:border-slate-800/50 last:border-b-0 hover:bg-slate-100/60 dark:hover:bg-slate-800/40 transition-colors ${Ki[e.result]??``}`,children:[(0,N.jsx)(`div`,{className:`pl-4 pr-1 py-2.5 text-slate-600 dark:text-slate-400 text-xs whitespace-nowrap flex-none w-[100px]`,title:new Date(e.ts).toLocaleString(),children:(0,N.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,N.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${Wi[e.result]??`bg-slate-400`}`,title:Gi[e.result]??e.result}),Ui(e.ts)]})}),(0,N.jsx)(`div`,{className:`pl-2 pr-2 py-2.5 whitespace-nowrap max-w-[200px] flex-none`,children:(0,N.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[w,(0,N.jsx)(`div`,{className:`mt-0.5`,children:C}),p&&e.deadLetterReason&&(0,N.jsx)(`span`,{className:`text-xs text-red-500 dark:text-red-400`,children:e.deadLetterReason.replace(/_/g,` `)}),g&&(0,N.jsx)(`div`,{className:`md:hidden mt-1`,children:n?(0,N.jsx)(`span`,{className:`text-xs text-slate-400 dark:text-slate-500 animate-pulse`,children:`Generating…`}):o?(0,N.jsx)(`span`,{className:`text-xs text-red-500 dark:text-red-400`,title:o,children:`Failed to generate`}):h?(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`button`,{onClick:b,className:`text-xs text-slate-500 dark:text-slate-400 text-left hover:text-slate-700 dark:hover:text-slate-200 transition-colors`,children:u?(0,N.jsx)(`span`,{children:h}):(0,N.jsx)(`span`,{children:h.length>60?`${h.slice(0,60)}…`:h})}),u&&(0,N.jsx)(`button`,{onClick:v,className:`ml-2 text-xs text-slate-400 hover:text-slate-600 dark:text-slate-500 dark:hover:text-slate-300 transition-colors`,title:`Regenerate summary`,children:`↻ Regenerate`})]}):(0,N.jsx)(`button`,{onClick:v,className:`text-xs text-blue-500 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 transition-colors`,children:`Generate summary`})})]})}),(0,N.jsx)(`div`,{className:`pl-0 pr-2 py-2.5 hidden md:block flex-1 min-w-0`,children:n?(0,N.jsx)(`span`,{className:`text-xs text-slate-400 dark:text-slate-500 animate-pulse`,children:`Generating…`}):o?(0,N.jsxs)(`span`,{className:`text-xs text-red-500 dark:text-red-400`,title:o,children:[`Failed to generate — `,o]}):h?(0,N.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,N.jsx)(`button`,{onClick:y,className:`text-xs text-slate-600 dark:text-slate-300 text-left hover:text-slate-900 dark:hover:text-white transition-colors`,title:_?`Collapse`:`Click to expand`,children:_?(0,N.jsx)(`span`,{children:h}):(0,N.jsx)(`span`,{className:`line-clamp-2`,children:h})}),g&&(0,N.jsx)(`button`,{onClick:v,className:`shrink-0 text-slate-400 hover:text-slate-600 dark:text-slate-500 dark:hover:text-slate-300 transition-colors`,title:`Regenerate summary`,children:`↻`})]}):g?(0,N.jsx)(`button`,{onClick:v,className:`text-xs text-blue-500 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 transition-colors`,children:`Generate`}):(0,N.jsx)(`span`,{className:`text-xs text-slate-300 dark:text-slate-600`,children:`—`})})]})});function Xi({rows:e,agentNames:t,loading:n=!1,emptyMessage:r=`No activity found`}){let i=(0,x.useRef)(null),a=F({count:e.length,getScrollElement:()=>i.current,estimateSize:()=>60,overscan:10});return e.length===0?(0,N.jsx)(`div`,{className:`px-4 py-8 text-center text-slate-500 dark:text-slate-400`,children:n?`Loading...`:r}):(0,N.jsxs)(`div`,{className:`w-full text-sm`,children:[(0,N.jsxs)(`div`,{className:`flex border-b border-slate-200 dark:border-slate-800 sticky top-0 bg-slate-50 dark:bg-slate-900 z-10`,children:[(0,N.jsx)(`div`,{className:`pl-6 pr-1 py-2.5 text-xs font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wide flex-none w-[100px]`,children:`Time`}),(0,N.jsx)(`div`,{className:`pl-2 pr-2 py-2.5 text-xs font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wide flex-none max-w-[200px]`,children:`Instance`}),(0,N.jsx)(`div`,{className:`pl-0 pr-2 py-2.5 text-xs font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wide hidden md:block flex-1`,children:`Summary`})]}),(0,N.jsx)(`div`,{ref:i,className:`overflow-auto`,style:{maxHeight:`calc(100vh - 280px)`},children:(0,N.jsx)(`div`,{style:{height:`${a.getTotalSize()}px`,width:`100%`,position:`relative`},children:a.getVirtualItems().map(n=>(0,N.jsx)(`div`,{"data-index":n.index,ref:a.measureElement,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${n.start}px)`},children:(0,N.jsx)(Yi,{row:e[n.index],index:n.index,agentNames:t})},e[n.index].instanceId??`${e[n.index].ts}-${n.index}`))})})]})}function Zi(){let{name:e}=dt(),t=Nr(),n=t.find(t=>t.name===e)??null,r=t.map(e=>e.name),{data:i}=ni({key:`agent-activity:${e}`,fetcher:t=>rr(5,0,e,void 0,void 0,t),invalidateOn:[`runs`],invalidateAgent:e,enabled:!!e}),a=i?.rows??[];return e?(0,N.jsx)(`div`,{className:`space-y-6`,children:(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Activity`}),n&&(0,N.jsxs)(`span`,{id:`agent-state`,className:`text-sm ${n.runningCount>0?`text-blue-600 dark:text-blue-400`:`text-slate-500 dark:text-slate-400`}`,children:[(0,N.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full mr-1.5 ${n.runningCount>0?`bg-blue-500`:`bg-slate-400`}`}),n.runningCount>0?n.scale>1?`running ${n.runningCount}/${n.scale}`:`running`:`idle`,n.scale>1&&n.runningCount===0&&(0,N.jsxs)(`span`,{className:`text-xs text-slate-400 ml-1`,children:[`×`,n.scale]})]}),(n?.queuedWebhooks??0)>0&&(0,N.jsxs)(`span`,{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-400`,children:[n.queuedWebhooks,` pending`]})]}),(0,N.jsx)(M,{to:`/activity?agent=${encodeURIComponent(e)}`,className:`text-xs text-blue-600 dark:text-blue-400 hover:underline`,children:`View all`})]}),(0,N.jsx)(`div`,{className:`overflow-x-auto`,children:(0,N.jsx)(Xi,{rows:a,agentNames:r,emptyMessage:`No activity yet`})})]})}):null}function Qi(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function $i(e){let t=Qi(e);return t=t.replace(/`([^`]+)`/g,`<code class="bg-slate-200 dark:bg-slate-800 px-1 py-0.5 rounded text-sm font-mono">$1</code>`),t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,`<a href="$2" class="text-blue-600 dark:text-blue-400 hover:underline" target="_blank" rel="noopener noreferrer">$1</a>`),t=t.replace(/\*\*([^*]+)\*\*/g,`<strong class="font-semibold">$1</strong>`),t=t.replace(/\*([^*]+)\*/g,`<em class="italic">$1</em>`),t}function ea(e){if(!e)return``;let t=e.split(`
|
|
15
15
|
`),n=[],r=!1,i=``,a=null;function o(){if(a){let e=a.type===`ul`?`list-disc list-inside mb-4 space-y-1`:`list-decimal list-inside mb-4 space-y-1`;n.push(`<${a.type} class="${e}">`);for(let e of a.items)n.push(`<li class="ml-2">${$i(e)}</li>`);n.push(`</${a.type}>`),a=null}}for(let e=0;e<t.length;e++){let s=t[e],c=s.trim();if(c.startsWith("```")){if(r)n.push(`</code></pre>`),r=!1,i=``;else{o(),i=c.slice(3).trim();let e=i?` language-${Qi(i)}`:``;n.push(`<pre class="bg-slate-100 dark:bg-slate-900 rounded-lg p-4 overflow-x-auto text-sm"><code${e?` class="${e}"`:``}>`),r=!0}continue}if(r){n.push(Qi(s));continue}if(!c){o(),n.push(`<br>`);continue}if(c.startsWith(`#`)){o();let e=c.match(/^(#+)\s+(.+)$/);if(e){let t=Math.min(e[1].length,6),r=e[2],i=t===1?`text-2xl`:t===2?`text-xl`:t===3?`text-lg`:`text-base`;n.push(`<h${t} class="${i} font-bold text-slate-900 dark:text-white mt-6 mb-3">${$i(r)}</h${t}>`)}continue}let l=c.match(/^[-*+]\s+(.+)$/),u=c.match(/^\d+\.\s+(.+)$/);if(l){(!a||a.type!==`ul`)&&(o(),a={type:`ul`,items:[]}),a.items.push(l[1]);continue}if(u){(!a||a.type!==`ol`)&&(o(),a={type:`ol`,items:[]}),a.items.push(u[1]);continue}o(),c&&n.push(`<p class="mb-4 leading-relaxed">${$i(c)}</p>`)}return r&&n.push(`</code></pre>`),o(),n.join(`
|
|
16
|
-
`)}function ta(){let{name:e}=dt(),{agents:t}=Br(),[n,r]=(0,x.useState)(null),[i,a]=(0,x.useState)(``),[o,s]=(0,x.useState)(null),[c,l]=(0,x.useState)(null),[u,d]=(0,x.useState)(null),[f,p]=(0,x.useState)(null),m=t.find(t=>t.name===e)??n?.agent??null,h=(0,x.useCallback)(()=>{e&&Qn(e).then(e=>{r(e),e.agent&&a(String(e.agent.scale))}).catch(()=>{})},[e]);(0,x.useEffect)(()=>{h()},[h]),(0,x.useEffect)(()=>{m&&a(String(m.scale))},[m?.scale]),(0,x.useEffect)(()=>{e&&$n(e).then(e=>{s(e.body),l(e.agentConfig)}).catch(e=>d(e instanceof Error?e.message:`Failed to load skill`))},[e]);let g=(0,x.useCallback)(async e=>{p(null);try{await e()}catch(e){p(e instanceof Error?e.message:`Action failed`)}},[]),_=(0,x.useCallback)(()=>{if(!e)return;let t=parseInt(i,10);isNaN(t)||t<1||g(()=>gr(e,t))},[e,i,g]);return e?(0,N.jsxs)(`div`,{className:`space-y-6`,children:[f&&(0,N.jsx)(`div`,{className:`bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3 text-sm text-red-700 dark:text-red-400`,children:f}),(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Controls`})}),(0,N.jsxs)(`div`,{className:`p-4 flex items-center gap-4 flex-wrap`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Scale:`}),(0,N.jsx)(`input`,{id:`agent-scale-input`,type:`number`,min:1,value:i,onChange:e=>a(e.target.value),className:`w-16 px-2 py-1 bg-white dark:bg-slate-950 border border-slate-300 dark:border-slate-700 rounded text-base text-slate-900 dark:text-slate-200`}),(0,N.jsx)(`button`,{id:`update-agent-scale-btn`,onClick:_,className:`px-2 py-1.5 text-xs font-medium rounded-md bg-blue-600 hover:bg-blue-700 text-white transition-colors`,children:`Set`})]}),m&&(0,N.jsx)(`button`,{id:`toggle-btn`,onClick:()=>g(()=>m.enabled?fr(e):dr(e)),className:`px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${m.enabled?`bg-slate-200 dark:bg-slate-700 text-slate-700 dark:text-slate-300 hover:bg-slate-300 dark:hover:bg-slate-600`:`bg-blue-600 hover:bg-blue-700 text-white`}`,children:m.enabled?`Disable`:`Enable`})]})]}),c&&(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Configuration`})}),(0,N.jsxs)(`div`,{className:`p-4 space-y-4 text-sm`,children:[c.description&&(0,N.jsx)(`p`,{className:`text-slate-700 dark:text-slate-300`,children:c.description}),(0,N.jsxs)(`dl`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-3`,children:[c.schedule&&(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`dt`,{className:`text-xs text-slate-500 dark:text-slate-400 uppercase tracking-wide`,children:`Schedule`}),(0,N.jsx)(`dd`,{className:`mt-0.5`,children:(0,N.jsx)(`code`,{className:`text-xs bg-slate-200 dark:bg-slate-800 px-1.5 py-0.5 rounded font-mono`,children:c.schedule})})]}),c.models&&c.models.length>0&&(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`dt`,{className:`text-xs text-slate-500 dark:text-slate-400 uppercase tracking-wide`,children:`Models`}),(0,N.jsx)(`dd`,{className:`mt-0.5 space-y-0.5`,children:c.models.map((e,t)=>(0,N.jsxs)(`div`,{className:`text-xs text-slate-700 dark:text-slate-300`,children:[e.provider,`/`,e.model,e.thinkingLevel?` (${e.thinkingLevel})`:``,(0,N.jsxs)(`span`,{className:`text-slate-400 dark:text-slate-500 ml-1`,children:[`[`,e.authType,`]`]})]},t))})]}),c.credentials&&c.credentials.length>0&&(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`dt`,{className:`text-xs text-slate-500 dark:text-slate-400 uppercase tracking-wide`,children:`Credentials`}),(0,N.jsx)(`dd`,{className:`mt-0.5 flex flex-wrap gap-1`,children:c.credentials.map(e=>(0,N.jsx)(`span`,{className:`px-1.5 py-0.5 text-xs bg-slate-200 dark:bg-slate-800 rounded font-mono`,children:e},e))})]}),c.hooks&&(c.hooks.pre?.length||c.hooks.post?.length)&&(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`dt`,{className:`text-xs text-slate-500 dark:text-slate-400 uppercase tracking-wide`,children:`Hooks`}),(0,N.jsxs)(`dd`,{className:`mt-0.5 text-xs text-slate-700 dark:text-slate-300`,children:[c.hooks.pre&&c.hooks.pre.length>0&&(0,N.jsxs)(`div`,{children:[`Pre: `,c.hooks.pre.join(`, `)]}),c.hooks.post&&c.hooks.post.length>0&&(0,N.jsxs)(`div`,{children:[`Post: `,c.hooks.post.join(`, `)]})]})]}),c.params&&Object.keys(c.params).length>0&&(0,N.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,N.jsx)(`dt`,{className:`text-xs text-slate-500 dark:text-slate-400 uppercase tracking-wide`,children:`Params`}),(0,N.jsx)(`dd`,{className:`mt-0.5`,children:(0,N.jsx)(`pre`,{className:`text-xs bg-slate-200 dark:bg-slate-800 p-2 rounded overflow-x-auto`,children:JSON.stringify(c.params,null,2)})})]})]}),c.webhooks&&c.webhooks.length>0&&(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h3`,{className:`text-xs text-slate-500 dark:text-slate-400 uppercase tracking-wide mb-2`,children:`Webhook Filters`}),(0,N.jsx)(`div`,{className:`space-y-3`,children:c.webhooks.map((e,t)=>(0,N.jsxs)(`div`,{className:`bg-slate-100 dark:bg-slate-800 rounded p-3 text-xs space-y-1`,children:[(0,N.jsx)(`div`,{className:`font-medium text-slate-700 dark:text-slate-300`,children:e.source??`unknown`}),e.events&&e.events.length>0&&(0,N.jsxs)(`div`,{className:`text-slate-600 dark:text-slate-400`,children:[(0,N.jsx)(`span`,{className:`text-slate-500`,children:`events:`}),` `,e.events.map(e=>(0,N.jsx)(`span`,{className:`inline-block mr-1 px-1.5 py-0.5 bg-slate-200 dark:bg-slate-700 rounded font-mono`,children:e},e))]}),e.actions&&e.actions.length>0&&(0,N.jsxs)(`div`,{className:`text-slate-600 dark:text-slate-400`,children:[(0,N.jsx)(`span`,{className:`text-slate-500`,children:`actions:`}),` `,e.actions.join(`, `)]}),e.repos&&e.repos.length>0&&(0,N.jsxs)(`div`,{className:`text-slate-600 dark:text-slate-400`,children:[(0,N.jsx)(`span`,{className:`text-slate-500`,children:`repos:`}),` `,e.repos.join(`, `)]}),(e.org||e.orgs&&e.orgs.length>0)&&(0,N.jsxs)(`div`,{className:`text-slate-600 dark:text-slate-400`,children:[(0,N.jsx)(`span`,{className:`text-slate-500`,children:`orgs:`}),` `,e.org??e.orgs?.join(`, `)]}),e.branches&&e.branches.length>0&&(0,N.jsxs)(`div`,{className:`text-slate-600 dark:text-slate-400`,children:[(0,N.jsx)(`span`,{className:`text-slate-500`,children:`branches:`}),` `,e.branches.join(`, `)]}),e.labels&&e.labels.length>0&&(0,N.jsxs)(`div`,{className:`text-slate-600 dark:text-slate-400`,children:[(0,N.jsx)(`span`,{className:`text-slate-500`,children:`labels:`}),` `,e.labels.join(`, `)]}),e.assignee&&(0,N.jsxs)(`div`,{className:`text-slate-600 dark:text-slate-400`,children:[(0,N.jsx)(`span`,{className:`text-slate-500`,children:`assignee:`}),` `,e.assignee]}),e.author&&(0,N.jsxs)(`div`,{className:`text-slate-600 dark:text-slate-400`,children:[(0,N.jsx)(`span`,{className:`text-slate-500`,children:`author:`}),` `,e.author]})]},t))})]})]})]}),u?(0,N.jsx)(`div`,{className:`bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 text-sm text-red-700 dark:text-red-400`,children:u}):o===null?(0,N.jsx)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 p-8 text-center text-slate-500 dark:text-slate-400`,children:`Loading...`}):(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Skill`})}),(0,N.jsx)(`div`,{className:`p-6`,children:(0,N.jsx)(`div`,{className:`prose prose-slate dark:prose-invert max-w-none text-sm text-slate-700 dark:text-slate-300`,dangerouslySetInnerHTML:{__html:ea(o)}})})]})]}):null}function na(e,t,n=[]){let r=(0,x.useRef)(e);r.current=e;let{intervalMs:i,enabled:a=!0}=t;(0,x.useEffect)(()=>{if(!a)return;let e=new AbortController,t=!1,n=()=>{t||(t=!0,r.current(e.signal).catch(()=>{}).finally(()=>{t=!1}))};n();let o=setInterval(n,i);return()=>{clearInterval(o),e.abort()}},[i,a,...n])}function ra(e){let t=e.msg||``;return e.text&&(t.includes(`assistant`)||t.includes(`response`))?{text:`${t}: ${e.text}`,className:`text-white font-bold`}:e.cmd||t.includes(`bash`)||t.includes(`command`)?{text:e.cmd?`$ ${e.cmd}`:t,className:`text-cyan-400`}:e.tool||t.includes(`tool`)?{text:e.tool?`[tool] ${e.tool}: ${e.result??``}`:t,className:`text-blue-400`}:e.level>=50||e.err?{text:t,className:`text-red-400`}:e.level>=40?{text:t,className:`text-yellow-400`}:{text:t,className:`text-slate-300`}}function ia(){let e=(0,x.useContext)(si),[t,n]=(0,x.useState)([]),[r,i]=(0,x.useState)(!0),[a,o]=(0,x.useState)(!1),s=(0,x.useRef)(null),c=(0,x.useRef)(null),l=(0,x.useRef)(null),u=e?.name??``,d=e?.id??``,f=e?.isRunning??!1,[p,m]=(0,x.useState)(!1),[h,g]=(0,x.useState)(!0),[_,v]=(0,x.useState)(!1),y=(0,x.useRef)(!1),[b,S]=(0,x.useState)(null),[C,w]=(0,x.useState)(!1),[T,E]=(0,x.useState)(null),{data:ee}=ni({key:`instance-locks:${d}`,fetcher:e=>or(e),pollIntervalMs:5e3,enabled:f&&!!e}),D=(ee?.locks??[]).filter(e=>e.holder===d||!e.holder&&e.agentName===u);na(async e=>{if(!u||!d)return;let t={lines:`100`};s.current&&(t.cursor=s.current);try{let r=await sr(u,d,t,e);o(!0),r.entries.length>0&&(n(e=>[...e,...r.entries]),r.cursor&&(s.current=r.cursor)),!s.current&&r.backCursor&&(c.current=r.backCursor)}catch{throw o(!1),void 0}},{intervalMs:f?3e3:1e4,enabled:!!u&&!!d&&!!e},[u,d,f]),(0,x.useEffect)(()=>{r&&l.current&&(l.current.scrollTop=l.current.scrollHeight)},[t,r]);let te=(0,x.useCallback)(async()=>{if(!(!u||!d)){w(!0),E(null);try{let e=await yr(u,d);e.error?E(e.error):S(e.summary)}catch(e){E(e instanceof Error?e.message:`Failed to summarize`)}finally{w(!1)}}},[u,d]),ne=(0,x.useCallback)(async()=>{if(!(!u||!d||p||!h||t.length===0||_)){if(!c.current){g(!1);return}m(!0);try{let e=await sr(u,d,{lines:`100`,back_cursor:c.current});if(e.entries.length>0){let t=l.current,r=t?.scrollHeight??0,i=t?.scrollTop??0;n(t=>[...e.entries,...t]),requestAnimationFrame(()=>{t&&(t.scrollTop=i+(t.scrollHeight-r))})}c.current=e.backCursor,(!e.backCursor||e.entries.length<100)&&g(!1)}catch{}finally{m(!1)}}},[u,d,p,h,t,_]);(0,x.useEffect)(()=>{if(f||!u||!d||!h||y.current||t.length===0)return;if(!c.current){g(!1);return}y.current=!0,v(!0);let e=!1;return(async()=>{try{for(;!e&&c.current;){let t=await sr(u,d,{lines:`100`,back_cursor:c.current});if(e)break;if(t.entries.length===0){g(!1);break}let r=l.current,i=r?.scrollHeight??0,a=r?.scrollTop??0;if(n(e=>[...t.entries,...e]),requestAnimationFrame(()=>{r&&(r.scrollTop=a+(r.scrollHeight-i))}),c.current=t.backCursor,!t.backCursor||t.entries.length<100){g(!1);break}}}catch{}finally{e||(v(!1),y.current=!1)}})(),()=>{e=!0,v(!1),y.current=!1}},[f,u,d,t.length>0]);let re=(0,x.useCallback)(()=>{if(!l.current)return;let e=l.current;i(e.scrollHeight-e.scrollTop-e.clientHeight<40),e.scrollTop<100&&h&&!p&&!_&&t.length>0&&ne()},[h,p,_,t.length,ne]);return e?(0,N.jsxs)(`div`,{className:`space-y-4`,children:[D.length>0&&(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsxs)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:[`Resource Locks (`,D.length,`)`]})}),(0,N.jsx)(`div`,{className:`divide-y divide-slate-100 dark:divide-slate-800/50`,children:D.map(e=>(0,N.jsxs)(`div`,{className:`px-4 py-2.5 flex items-center justify-between`,children:[(0,N.jsx)(`span`,{className:`text-sm font-mono text-slate-700 dark:text-slate-300`,children:e.resourceKey}),e.heldSince&&(0,N.jsxs)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:[`since `,new Date(e.heldSince).toLocaleTimeString()]})]},e.resourceKey))})]}),(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:[(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Logs`}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsxs)(`span`,{className:`hidden sm:inline text-xs text-slate-500 dark:text-slate-400`,children:[t.length,` lines`]}),(0,N.jsx)(`span`,{className:`text-xs ${a?`text-green-500`:`text-red-500`}`,children:a?`Connected`:`Disconnected`}),(0,N.jsx)(`button`,{onClick:te,disabled:C||t.length===0,className:`px-2 py-1 text-xs rounded bg-purple-600 hover:bg-purple-700 disabled:opacity-40 disabled:cursor-not-allowed text-white transition-colors`,children:C?(0,N.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,N.jsxs)(`svg`,{className:`w-3 h-3 animate-spin`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,N.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,N.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z`})]}),`Summarizing…`]}):`Summarize`}),(0,N.jsx)(`button`,{onClick:()=>i(e=>!e),className:`px-2 py-1 text-xs rounded transition-colors ${r?`bg-blue-600 text-white`:`bg-slate-200 dark:bg-slate-800 text-slate-700 dark:text-slate-300`}`,children:`Follow`}),(0,N.jsx)(`button`,{onClick:()=>{n([]),s.current=null,c.current=null,g(!0)},className:`px-2 py-1 text-xs rounded bg-slate-200 dark:bg-slate-800 text-slate-700 dark:text-slate-300 hover:bg-slate-300 dark:hover:bg-slate-700 transition-colors`,children:`Clear`})]})]}),(0,N.jsxs)(`div`,{className:`relative`,children:[(b||T)&&(0,N.jsx)(`div`,{className:`absolute inset-x-0 top-0 z-10 p-3 pointer-events-none`,children:(0,N.jsxs)(`div`,{className:`pointer-events-auto`,children:[b&&(0,N.jsx)(`div`,{className:`bg-purple-900/95 border border-purple-700 rounded-lg p-4 text-sm text-purple-100 shadow-lg backdrop-blur-sm`,children:(0,N.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`div`,{className:`text-xs font-medium text-purple-300 mb-1`,children:`Summary`}),(0,N.jsx)(`p`,{className:`leading-relaxed`,children:b})]}),(0,N.jsx)(`button`,{onClick:()=>S(null),className:`text-purple-400 hover:text-purple-200 flex-shrink-0`,children:(0,N.jsx)(`svg`,{className:`w-4 h-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,N.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M6 18L18 6M6 6l12 12`})})})]})}),T&&(0,N.jsxs)(`div`,{className:`mt-2 bg-red-900/95 border border-red-700 rounded-lg p-3 text-sm text-red-200 flex items-center justify-between shadow-lg backdrop-blur-sm`,children:[(0,N.jsx)(`span`,{children:T}),(0,N.jsx)(`button`,{onClick:()=>E(null),className:`text-red-400 hover:text-red-200 ml-2`,children:(0,N.jsx)(`svg`,{className:`w-4 h-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,N.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M6 18L18 6M6 6l12 12`})})})]})]})}),(0,N.jsxs)(`div`,{ref:l,onScroll:re,className:`min-h-[32rem] max-h-[calc(100vh-16rem)] overflow-y-auto scrollbar-thin bg-slate-950 p-3`,children:[(p||_)&&(0,N.jsx)(`div`,{className:`text-xs text-slate-500 text-center py-2`,children:(0,N.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,N.jsxs)(`svg`,{className:`w-3 h-3 animate-spin`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,N.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,N.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z`})]}),_?`Loading full history…`:`Loading older logs…`]})}),!h&&t.length>0&&(0,N.jsx)(`div`,{className:`text-xs text-slate-600 text-center py-2 border-b border-slate-800 mb-2`,children:`— Beginning of logs —`}),h&&!p&&t.length>0&&(0,N.jsx)(`button`,{className:`w-full text-xs text-blue-400 hover:text-blue-300 text-center py-2 border-b border-slate-800 mb-2 transition-colors`,onClick:ne,children:`↑ Load older logs`}),t.length>0?t.map((e,t)=>{let{text:n,className:r}=ra(e);return(0,N.jsxs)(`div`,{className:`text-xs font-mono leading-5`,children:[(0,N.jsx)(`span`,{className:`text-slate-600`,children:new Date(e.time).toLocaleTimeString()}),` `,(0,N.jsx)(`span`,{className:r,children:n})]},t)}):(0,N.jsx)(`div`,{className:`text-xs text-slate-500 text-center py-4`,children:`No log entries`})]})]})]})]}):null}function aa(e){if(e)try{let t=JSON.parse(e);return t[`content-type`]??t[`Content-Type`]}catch{return}}function oa(e,t){if(!e)return null;let n=aa(t)?.toLowerCase()??``;if(n.includes(`application/x-www-form-urlencoded`))try{let t=new URLSearchParams(e),n={};for(let[e,r]of t.entries())try{n[e]=JSON.parse(r)}catch{n[e]=r}return{label:`Decoded Body (form-urlencoded)`,content:JSON.stringify(n,null,2)}}catch{}if(n.includes(`application/json`))return null;try{return JSON.parse(e),null}catch{if(/^[A-Za-z0-9+/\n\r]+=*$/.test(e.trim())&&e.trim().length>20)try{let t=atob(e.trim().replace(/\s/g,``));if(/^[\x20-\x7E\t\n\r]*$/.test(t))try{let e=JSON.parse(t);return{label:`Decoded Body (base64)`,content:JSON.stringify(e,null,2)}}catch{return{label:`Decoded Body (base64)`,content:t}}}catch{}}return null}function sa(e){if(!e)return`—`;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function ca(){let e=(0,x.useContext)(si),{agents:t}=Br(),n=t.map(e=>e.name),[r,i]=(0,x.useState)(void 0),a=e?.id,o=e?.detail;if((0,x.useEffect)(()=>{a&&ir(a).then(e=>i(e.trigger)).catch(()=>i(null))},[a]),!e)return null;if(r===void 0)return(0,N.jsx)(`div`,{className:`text-center py-12 text-slate-500 dark:text-slate-400`,children:`Loading...`});if(r===null){let e=o?.run;return e?(0,N.jsx)(`div`,{className:`space-y-4`,children:(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Overview`})}),(0,N.jsxs)(`div`,{className:`divide-y divide-slate-100 dark:divide-slate-800/50 max-w-2xl`,children:[(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Trigger Type`}),(0,N.jsx)(ai,{type:e.trigger_type})]}),e.trigger_source&&(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Source`}),(0,N.jsx)(`span`,{className:`text-xs text-slate-700 dark:text-slate-300`,children:e.trigger_source})]})]})]})}):(0,N.jsx)(`div`,{className:`text-center py-12 text-slate-500 dark:text-slate-400`,children:`Trigger details not available.`})}return(0,N.jsxs)(`div`,{className:`space-y-4`,children:[(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Overview`})}),(0,N.jsxs)(`div`,{className:`divide-y divide-slate-100 dark:divide-slate-800/50 max-w-2xl`,children:[(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Trigger Type`}),(0,N.jsx)(ai,{type:r.triggerType})]}),(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Agent`}),(0,N.jsx)(M,{to:`/dashboard/agents/${encodeURIComponent(r.agentName)}`,className:`hover:underline text-xs flex items-center gap-1.5`,children:(0,N.jsx)(`span`,{className:`agent-color-text`,style:P(r.agentName,n),children:r.agentName})})]}),(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Instance`}),(0,N.jsx)(`span`,{className:`font-mono text-xs text-slate-700 dark:text-slate-300`,children:r.instanceId})]}),(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Time`}),(0,N.jsx)(`span`,{className:`text-xs text-slate-700 dark:text-slate-300`,children:Vi(r.startedAt)})]}),r.triggerSource&&(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Source`}),(0,N.jsx)(`span`,{className:`text-xs text-slate-700 dark:text-slate-300`,children:r.triggerSource})]})]})]}),r.triggerType===`webhook`&&r.webhook&&(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Webhook Details`})}),(0,N.jsxs)(`div`,{className:`divide-y divide-slate-100 dark:divide-slate-800/50 max-w-2xl`,children:[(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Receipt ID`}),(0,N.jsx)(M,{to:`/dashboard/webhooks/${encodeURIComponent(r.webhook.receiptId)}`,className:`font-mono text-xs text-blue-600 dark:text-blue-400 hover:underline`,children:Bi(r.webhook.receiptId)})]}),(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Source`}),(0,N.jsx)(`span`,{className:`text-xs text-slate-700 dark:text-slate-300`,children:r.webhook.source})]}),r.webhook.eventSummary&&(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Event`}),(0,N.jsx)(`span`,{className:`text-xs text-slate-700 dark:text-slate-300`,children:r.webhook.eventSummary})]}),r.webhook.deliveryId&&(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Delivery ID`}),(0,N.jsx)(`span`,{className:`font-mono text-xs text-slate-700 dark:text-slate-300`,children:r.webhook.deliveryId})]}),(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Status`}),(0,N.jsx)(oi,{result:r.webhook.status===`processed`?`completed`:`dead-letter`})]}),(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Matched Agents`}),(0,N.jsx)(`span`,{className:`text-xs text-slate-700 dark:text-slate-300`,children:r.webhook.matchedAgents})]})]}),r.webhook.headers&&(0,N.jsxs)(`div`,{className:`border-t border-slate-200 dark:border-slate-800`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-100 dark:border-slate-800/50`,children:(0,N.jsx)(`h3`,{className:`text-xs font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wide`,children:`Headers`})}),(0,N.jsx)(`pre`,{className:`px-4 py-3 text-xs font-mono text-slate-700 dark:text-slate-300 overflow-x-auto whitespace-pre-wrap break-all`,children:sa(r.webhook.headers)})]}),(()=>{let e=oa(r.webhook.body,r.webhook.headers);return(0,N.jsxs)(N.Fragment,{children:[e&&(0,N.jsxs)(`div`,{className:`border-t border-slate-200 dark:border-slate-800`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-100 dark:border-slate-800/50`,children:(0,N.jsx)(`h3`,{className:`text-xs font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wide`,children:e.label})}),(0,N.jsx)(`pre`,{className:`px-4 py-3 text-xs font-mono text-slate-700 dark:text-slate-300 overflow-x-auto whitespace-pre-wrap break-all max-h-96 overflow-y-auto`,children:e.content})]}),r.webhook.body&&(0,N.jsxs)(`div`,{className:`border-t border-slate-200 dark:border-slate-800`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-100 dark:border-slate-800/50`,children:(0,N.jsx)(`h3`,{className:`text-xs font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wide`,children:e?`Raw Body`:`Body`})}),(0,N.jsx)(`pre`,{className:`px-4 py-3 text-xs font-mono text-slate-700 dark:text-slate-300 overflow-x-auto whitespace-pre-wrap break-all`,children:sa(r.webhook.body)})]})]})})()]}),r.triggerType===`agent`&&(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Agent Trigger Details`})}),(0,N.jsx)(`div`,{className:`divide-y divide-slate-100 dark:divide-slate-800/50 max-w-2xl`,children:r.callerAgent?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Called by`}),(0,N.jsx)(M,{to:`/dashboard/agents/${encodeURIComponent(r.callerAgent)}`,className:`hover:underline text-xs flex items-center gap-1.5`,children:(0,N.jsx)(`span`,{className:`agent-color-text`,style:P(r.callerAgent,n),children:r.callerAgent})})]}),r.callerInstance&&(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Caller Instance`}),(0,N.jsx)(M,{to:`/dashboard/agents/${encodeURIComponent(r.callerAgent)}/instances/${encodeURIComponent(r.callerInstance)}`,className:`font-mono text-xs text-blue-600 dark:text-blue-400 hover:underline`,children:Bi(r.callerInstance)})]}),r.callDepth!==void 0&&(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Call Depth`}),(0,N.jsx)(`span`,{className:`text-xs text-slate-700 dark:text-slate-300`,children:r.callDepth})]})]}):(0,N.jsx)(`div`,{className:`px-4 py-3`,children:(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Caller information not available`})})}),r.triggerContext&&(0,N.jsxs)(`div`,{className:`border-t border-slate-200 dark:border-slate-800`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-100 dark:border-slate-800/50`,children:(0,N.jsx)(`h3`,{className:`text-xs font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wide`,children:`Trigger Context`})}),(0,N.jsx)(`pre`,{className:`px-4 py-3 text-xs font-mono text-slate-700 dark:text-slate-300 overflow-x-auto whitespace-pre-wrap break-all`,children:r.triggerContext})]})]}),r.triggerType===`manual`&&(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Manual Trigger Details`})}),r.triggerContext?(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-100 dark:border-slate-800/50`,children:(0,N.jsx)(`h3`,{className:`text-xs font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wide`,children:`Prompt`})}),(0,N.jsx)(`pre`,{className:`px-4 py-3 text-xs font-mono text-slate-700 dark:text-slate-300 overflow-x-auto whitespace-pre-wrap break-all`,children:r.triggerContext})]}):(0,N.jsx)(`div`,{className:`px-4 py-3`,children:(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Prompt not available (run predates context tracking)`})})]}),r.triggerType===`schedule`&&(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Schedule Trigger Details`})}),(0,N.jsx)(`div`,{className:`px-4 py-3`,children:(0,N.jsxs)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:[`Scheduled run at `,Vi(r.startedAt)]})})]})]})}function la(){let e=(0,x.useContext)(si);if(!e)return null;let{detail:t,isRunning:n}=e,r=t?.run;return!r&&n?(0,N.jsx)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 p-6 text-center`,children:(0,N.jsx)(`p`,{className:`text-sm text-slate-500 dark:text-slate-400`,children:`Instance is currently running. Telemetry data will be available once the run completes.`})}):r?(0,N.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 p-4`,children:[(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white mb-3`,children:`Run Info`}),(0,N.jsxs)(`dl`,{className:`space-y-2 text-sm`,children:[(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Status`}),(0,N.jsx)(`dd`,{children:(0,N.jsx)(oi,{result:r.result})})]}),r.exit_code!=null&&(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Exit Code`}),(0,N.jsx)(`dd`,{className:r.exit_code===0?`text-green-600 dark:text-green-400`:`text-red-600 dark:text-red-400`,children:r.exit_code})]}),(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Started`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300`,children:Vi(r.started_at)})]}),(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Ended`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300`,children:Vi(r.started_at+r.duration_ms)})]}),(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Duration`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300`,children:I(r.duration_ms)})]}),(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Turns`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300`,children:r.turn_count})]}),r.error_message&&(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400 mb-1`,children:`Error`}),(0,N.jsx)(`dd`,{className:`text-red-600 dark:text-red-400 text-xs bg-red-50 dark:bg-red-900/20 rounded p-2 font-mono break-all`,children:r.error_message})]})]})]}),(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 p-4`,children:[(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white mb-3`,children:`Token Usage`}),(0,N.jsxs)(`dl`,{className:`space-y-2 text-sm`,children:[(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Input`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300`,children:zi(r.input_tokens)})]}),(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Output`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300`,children:zi(r.output_tokens)})]}),(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Cache Read`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300`,children:zi(r.cache_read_tokens)})]}),(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Cache Write`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300`,children:zi(r.cache_write_tokens)})]}),(0,N.jsxs)(`div`,{className:`flex justify-between border-t border-slate-200 dark:border-slate-800 pt-2 mt-2`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400 font-medium`,children:`Total`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300 font-medium`,children:zi(r.total_tokens)})]}),(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400 font-medium`,children:`Cost`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300 font-medium`,children:Ri(r.cost_usd)})]})]})]})]}):null}function L({options:e,value:t,onChange:n,placeholder:r}){let[i,a]=(0,x.useState)(!1),o=(0,x.useRef)(null);return(0,x.useEffect)(()=>{let e=e=>{o.current&&!o.current.contains(e.target)&&a(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,N.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>a(!i),className:`inline-flex items-center gap-1.5 text-sm rounded-lg border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-800 text-slate-700 dark:text-slate-200 pl-3 pr-2 py-1.5 hover:border-slate-300 dark:hover:border-slate-600 transition-colors shadow-sm`,children:[(0,N.jsx)(`span`,{children:e.find(e=>e.value===t)?.label||r}),(0,N.jsx)(da,{})]}),i&&(0,N.jsx)(`div`,{className:`absolute z-50 mt-1 min-w-[160px] rounded-lg border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-800 shadow-lg py-1 max-h-64 overflow-y-auto`,children:e.map(e=>(0,N.jsx)(`button`,{type:`button`,onClick:()=>{n(e.value),a(!1)},className:`w-full text-left px-3 py-1.5 text-sm transition-colors ${e.value===t?`bg-blue-50 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 font-medium`:`text-slate-700 dark:text-slate-300 hover:bg-slate-50 dark:hover:bg-slate-700/50`}`,children:e.label},e.value))})]})}function ua({options:e,selected:t,onChange:n,label:r}){let[i,a]=(0,x.useState)(!1),o=(0,x.useRef)(null);(0,x.useEffect)(()=>{let e=e=>{o.current&&!o.current.contains(e.target)&&a(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let s=t.length===e.length,c=t.length===0,l=e=>{t.includes(e)?n(t.filter(t=>t!==e)):n([...t,e])},u=()=>{n(s?[]:e.map(e=>e.value))},d=s||c?r:t.length===1?e.find(e=>e.value===t[0])?.label??r:`${t.length} selected`;return(0,N.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>a(!i),className:`inline-flex items-center gap-1.5 text-sm rounded-lg border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-800 text-slate-700 dark:text-slate-200 pl-3 pr-2 py-1.5 hover:border-slate-300 dark:hover:border-slate-600 transition-colors shadow-sm`,children:[!s&&!c&&(0,N.jsx)(`span`,{className:`inline-flex items-center justify-center w-4 h-4 rounded-full bg-blue-600 text-white text-[10px] font-bold leading-none`,children:t.length}),(0,N.jsx)(`span`,{children:d}),(0,N.jsx)(da,{})]}),i&&(0,N.jsxs)(`div`,{className:`absolute z-50 mt-1 min-w-[180px] rounded-lg border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-800 shadow-lg py-1 max-h-64 overflow-y-auto`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:u,className:`w-full text-left px-3 py-1.5 text-xs font-medium text-slate-500 dark:text-slate-400 hover:bg-slate-50 dark:hover:bg-slate-700/50 transition-colors border-b border-slate-100 dark:border-slate-700`,children:s?`Deselect all`:`Select all`}),e.map(e=>{let n=t.includes(e.value);return(0,N.jsxs)(`button`,{type:`button`,onClick:()=>l(e.value),className:`w-full text-left px-3 py-1.5 text-sm flex items-center gap-2 transition-colors ${n?`text-slate-900 dark:text-white`:`text-slate-500 dark:text-slate-400 hover:bg-slate-50 dark:hover:bg-slate-700/50`}`,children:[(0,N.jsx)(`span`,{className:`flex items-center justify-center w-3.5 h-3.5 rounded border transition-colors ${n?`bg-blue-600 border-blue-600`:`border-slate-300 dark:border-slate-600`}`,children:n&&(0,N.jsx)(`svg`,{className:`w-2.5 h-2.5 text-white`,viewBox:`0 0 12 12`,fill:`none`,children:(0,N.jsx)(`path`,{d:`M2 6l3 3 5-5`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}),e.dot&&(0,N.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${e.dot}`}),(0,N.jsx)(`span`,{children:e.label})]},e.value)})]})]})}function da(){return(0,N.jsx)(`svg`,{className:`w-4 h-4 text-slate-400`,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,N.jsx)(`path`,{fillRule:`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,clipRule:`evenodd`})})}var fa=50,pa=[`pending`,`running`,`completed`],ma=[{value:`pending`,label:`Pending`,dot:`bg-amber-400`},{value:`running`,label:`Running`,dot:`bg-blue-500`},{value:`completed`,label:`Completed`,dot:`bg-green-500`},{value:`error`,label:`Error`,dot:`bg-red-500`},{value:`dead-letter`,label:`Dead Letter`,dot:`bg-red-300 dark:bg-red-800`}],ha=[{value:``,label:`All Types`},{value:`schedule`,label:`Schedule`},{value:`webhook`,label:`Webhook`},{value:`manual`,label:`Manual`},{value:`agent`,label:`Agent`}];function ga(e){if(!e)return pa;let t=e.split(`,`).filter(Boolean);return t.length>0?t:pa}function _a(){let[e,t]=Ln(),n=e.get(`agent`)||void 0,r=e.get(`type`)||void 0,i=e.get(`status`),a=(0,x.useMemo)(()=>ga(i),[i]),[o,s]=(0,x.useState)(0),c=Nr(),l=c.map(e=>e.name),u=a.join(`,`),d=a.length===ma.length?void 0:a,{data:f,isLoading:p}=ni({key:`activity:${o}:${n??``}:${r??``}:${u}`,fetcher:e=>rr(fa,o,n,r,d,e),invalidateOn:[`runs`,`triggers`],keyChangeDebounceMs:150}),m=f?.rows??[],h=f?.total??0,g=f?.pendingCount??0;(0,x.useEffect)(()=>{s(0)},[n,r,u]);let _=(0,x.useCallback)((e,n)=>{t(t=>{let r=new URLSearchParams(t);return n?r.set(e,n):r.delete(e),r.delete(`offset`),r})},[t]),v=(0,x.useCallback)(e=>{t(t=>{let n=new URLSearchParams(t);return e.length===0||e.length===ma.length?n.delete(`status`):n.set(`status`,e.join(`,`)),n.delete(`offset`),n})},[t]),y=Math.floor(o/fa)+1,b=Math.max(1,Math.ceil(h/fa)),S=[{value:``,label:`All Agents`},...c.map(e=>({value:e.name,label:e.name}))];return(0,N.jsxs)(`div`,{className:`space-y-6`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between flex-wrap gap-3`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsx)(`h1`,{className:`text-xl font-bold text-slate-900 dark:text-white`,children:`Activity`}),g>0&&(0,N.jsxs)(`span`,{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-400`,children:[g,` pending`]})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,N.jsx)(L,{options:S,value:n||``,onChange:e=>_(`agent`,e||void 0),placeholder:`All Agents`}),(0,N.jsx)(L,{options:ha,value:r||``,onChange:e=>_(`type`,e||void 0),placeholder:`All Types`}),(0,N.jsx)(ua,{options:ma,selected:a,onChange:v,label:`All Statuses`})]})]}),(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(Xi,{rows:m,agentNames:l,loading:p&&m.length===0}),b>1&&(0,N.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2.5 border-t border-slate-200 dark:border-slate-800`,children:[(0,N.jsx)(`button`,{onClick:()=>s(Math.max(0,o-fa)),disabled:o===0,className:`px-3 py-1 text-xs rounded bg-slate-200 dark:bg-slate-800 text-slate-700 dark:text-slate-300 hover:bg-slate-300 dark:hover:bg-slate-700 disabled:opacity-40 transition-colors`,children:`Previous`}),(0,N.jsxs)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:[`Page `,y,` of `,b,` (`,h,` total)`]}),(0,N.jsx)(`button`,{onClick:()=>s(o+fa),disabled:o+fa>=h,className:`px-3 py-1 text-xs rounded bg-slate-200 dark:bg-slate-800 text-slate-700 dark:text-slate-300 hover:bg-slate-300 dark:hover:bg-slate-700 disabled:opacity-40 transition-colors`,children:`Next`})]})]})]})}function va(e){if(!e)return`—`;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function ya(){let{instanceId:e}=dt(),{agents:t}=Br(),n=t.map(e=>e.name),[r,i]=(0,x.useState)(void 0),[a,o]=(0,x.useState)(null),[s,c]=(0,x.useState)(null),[l,u]=(0,x.useState)(!1);(0,x.useEffect)(()=>{e&&ir(e).then(e=>i(e.trigger)).catch(()=>i(null))},[e]);let d=(0,x.useCallback)(async()=>{if(r?.webhook?.receiptId){o(null),c(null),u(!0);try{let e=await nr(r.webhook.receiptId);o(`Replayed: ${e.matched} matched, ${e.skipped} skipped`)}catch(e){c(e instanceof Error?e.message:`Replay failed`)}finally{u(!1)}}},[r]);if(!e)return null;if(r===void 0)return(0,N.jsx)(`div`,{className:`text-center py-12 text-slate-500 dark:text-slate-400`,children:`Loading...`});if(r===null)return(0,N.jsx)(`div`,{className:`space-y-6`,children:(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsx)(M,{to:`/jobs`,className:`text-slate-500 hover:text-slate-700 dark:hover:text-slate-300`,children:(0,N.jsx)(`svg`,{className:`w-5 h-5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,N.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M15 19l-7-7 7-7`})})}),(0,N.jsx)(`h1`,{className:`text-xl font-bold text-slate-900 dark:text-white`,children:`Trigger not found`})]})});let f=!!(r.webhook?.receiptId&&(r.webhook.headers||r.webhook.body));return(0,N.jsxs)(`div`,{className:`space-y-6`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between flex-wrap gap-3`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsx)(M,{to:`/jobs`,className:`text-slate-500 hover:text-slate-700 dark:hover:text-slate-300`,children:(0,N.jsx)(`svg`,{className:`w-5 h-5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,N.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M15 19l-7-7 7-7`})})}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h1`,{className:`text-xl font-bold text-slate-900 dark:text-white font-mono`,children:r.instanceId}),(0,N.jsx)(`div`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Trigger Detail`})]}),(0,N.jsx)(ai,{type:r.triggerType})]}),r.triggerType===`webhook`&&f&&(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a&&(0,N.jsx)(`span`,{className:`text-xs text-green-600 dark:text-green-400`,children:a}),s&&(0,N.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,children:s}),(0,N.jsx)(`button`,{onClick:d,disabled:l,className:`px-3 py-1.5 text-xs font-medium rounded-md bg-blue-600 hover:bg-blue-700 disabled:opacity-40 text-white transition-colors`,children:l?`Replaying...`:`Replay`})]})]}),(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Overview`})}),(0,N.jsxs)(`div`,{className:`divide-y divide-slate-100 dark:divide-slate-800/50 max-w-2xl`,children:[(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Trigger Type`}),(0,N.jsx)(ai,{type:r.triggerType})]}),(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Agent`}),(0,N.jsx)(M,{to:`/dashboard/agents/${encodeURIComponent(r.agentName)}`,className:`hover:underline text-xs flex items-center gap-1.5`,children:(0,N.jsx)(`span`,{className:`agent-color-text`,style:P(r.agentName,n),children:r.agentName})})]}),(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Instance`}),(0,N.jsx)(M,{to:`/dashboard/agents/${encodeURIComponent(r.agentName)}/instances/${encodeURIComponent(r.instanceId)}`,className:`font-mono text-xs text-blue-600 dark:text-blue-400 hover:underline`,children:r.instanceId})]}),(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Time`}),(0,N.jsx)(`span`,{className:`text-xs text-slate-700 dark:text-slate-300`,children:Vi(r.startedAt)})]}),r.triggerSource&&(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Source`}),(0,N.jsx)(`span`,{className:`text-xs text-slate-700 dark:text-slate-300`,children:r.triggerSource})]})]})]}),r.triggerType===`webhook`&&r.webhook&&(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Webhook Details`})}),(0,N.jsxs)(`div`,{className:`divide-y divide-slate-100 dark:divide-slate-800/50 max-w-2xl`,children:[(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Receipt ID`}),(0,N.jsx)(M,{to:`/dashboard/webhooks/${encodeURIComponent(r.webhook.receiptId)}`,className:`font-mono text-xs text-blue-600 dark:text-blue-400 hover:underline`,children:Bi(r.webhook.receiptId)})]}),(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Source`}),(0,N.jsx)(`span`,{className:`text-xs text-slate-700 dark:text-slate-300`,children:r.webhook.source})]}),r.webhook.eventSummary&&(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Event`}),(0,N.jsx)(`span`,{className:`text-xs text-slate-700 dark:text-slate-300`,children:r.webhook.eventSummary})]}),r.webhook.deliveryId&&(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Delivery ID`}),(0,N.jsx)(`span`,{className:`font-mono text-xs text-slate-700 dark:text-slate-300`,children:r.webhook.deliveryId})]}),(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Status`}),(0,N.jsx)(oi,{result:r.webhook.status===`processed`?`completed`:`dead-letter`})]}),(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Matched Agents`}),(0,N.jsx)(`span`,{className:`text-xs text-slate-700 dark:text-slate-300`,children:r.webhook.matchedAgents})]})]}),r.webhook.headers&&(0,N.jsxs)(`div`,{className:`border-t border-slate-200 dark:border-slate-800`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-100 dark:border-slate-800/50`,children:(0,N.jsx)(`h3`,{className:`text-xs font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wide`,children:`Headers`})}),(0,N.jsx)(`pre`,{className:`px-4 py-3 text-xs font-mono text-slate-700 dark:text-slate-300 overflow-x-auto whitespace-pre-wrap break-all`,children:va(r.webhook.headers)})]}),(()=>{let e=oa(r.webhook.body,r.webhook.headers);return(0,N.jsxs)(N.Fragment,{children:[e&&(0,N.jsxs)(`div`,{className:`border-t border-slate-200 dark:border-slate-800`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-100 dark:border-slate-800/50`,children:(0,N.jsx)(`h3`,{className:`text-xs font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wide`,children:e.label})}),(0,N.jsx)(`pre`,{className:`px-4 py-3 text-xs font-mono text-slate-700 dark:text-slate-300 overflow-x-auto whitespace-pre-wrap break-all max-h-96 overflow-y-auto`,children:e.content})]}),r.webhook.body&&(0,N.jsxs)(`div`,{className:`border-t border-slate-200 dark:border-slate-800`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-100 dark:border-slate-800/50`,children:(0,N.jsx)(`h3`,{className:`text-xs font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wide`,children:e?`Raw Body`:`Body`})}),(0,N.jsx)(`pre`,{className:`px-4 py-3 text-xs font-mono text-slate-700 dark:text-slate-300 overflow-x-auto whitespace-pre-wrap break-all`,children:va(r.webhook.body)})]})]})})()]}),r.triggerType===`agent`&&(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Agent Trigger Details`})}),(0,N.jsx)(`div`,{className:`divide-y divide-slate-100 dark:divide-slate-800/50 max-w-2xl`,children:r.callerAgent?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Called by`}),(0,N.jsx)(M,{to:`/dashboard/agents/${encodeURIComponent(r.callerAgent)}`,className:`hover:underline text-xs flex items-center gap-1.5`,children:(0,N.jsx)(`span`,{className:`agent-color-text`,style:P(r.callerAgent,n),children:r.callerAgent})})]}),r.callerInstance&&(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Caller Instance`}),(0,N.jsx)(M,{to:`/dashboard/agents/${encodeURIComponent(r.callerAgent)}/instances/${encodeURIComponent(r.callerInstance)}`,className:`font-mono text-xs text-blue-600 dark:text-blue-400 hover:underline`,children:Bi(r.callerInstance)})]}),r.callDepth!==void 0&&(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Call Depth`}),(0,N.jsx)(`span`,{className:`text-xs text-slate-700 dark:text-slate-300`,children:r.callDepth})]})]}):(0,N.jsx)(`div`,{className:`px-4 py-3`,children:(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Caller information not available`})})}),r.triggerContext&&(0,N.jsxs)(`div`,{className:`border-t border-slate-200 dark:border-slate-800`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-100 dark:border-slate-800/50`,children:(0,N.jsx)(`h3`,{className:`text-xs font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wide`,children:`Trigger Context`})}),(0,N.jsx)(`pre`,{className:`px-4 py-3 text-xs font-mono text-slate-700 dark:text-slate-300 overflow-x-auto whitespace-pre-wrap break-all`,children:r.triggerContext})]})]}),r.triggerType===`manual`&&(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Manual Trigger Details`})}),r.triggerContext?(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-100 dark:border-slate-800/50`,children:(0,N.jsx)(`h3`,{className:`text-xs font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wide`,children:`Prompt`})}),(0,N.jsx)(`pre`,{className:`px-4 py-3 text-xs font-mono text-slate-700 dark:text-slate-300 overflow-x-auto whitespace-pre-wrap break-all`,children:r.triggerContext})]}):(0,N.jsx)(`div`,{className:`px-4 py-3`,children:(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Prompt not available (run predates context tracking)`})})]}),r.triggerType===`schedule`&&(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Schedule Trigger Details`})}),(0,N.jsx)(`div`,{className:`px-4 py-3`,children:(0,N.jsxs)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:[`Scheduled run at `,Vi(r.startedAt)]})})]}),(0,N.jsx)(`div`,{className:`flex justify-end`,children:(0,N.jsx)(M,{to:`/dashboard/agents/${encodeURIComponent(r.agentName)}/instances/${encodeURIComponent(r.instanceId)}`,className:`text-sm text-blue-600 dark:text-blue-400 hover:underline`,children:`View run details →`})})]})}function ba(){let e=Pr(),{data:t}=ni({key:`project-config`,fetcher:e=>er(e),invalidateOn:[`config`]}),[n,r]=(0,x.useState)(``),[i,a]=(0,x.useState)(null),[o,s]=(0,x.useState)(null);(0,x.useEffect)(()=>{t&&r(String(t.projectScale))},[t]);let c=(0,x.useCallback)(async(e,t)=>{a(null),s(null);try{await e(),t&&s(t)}catch(e){a(e instanceof Error?e.message:`Action failed`)}},[]),l=(0,x.useCallback)(()=>{let e=parseInt(n,10);isNaN(e)||e<1||c(()=>hr(e),`Scale updated`)},[n,c]);return(0,N.jsxs)(`div`,{className:`space-y-6`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsx)(M,{to:`/dashboard`,className:`text-slate-500 hover:text-slate-700 dark:hover:text-slate-300`,children:(0,N.jsx)(`svg`,{className:`w-5 h-5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,N.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M15 19l-7-7 7-7`})})}),(0,N.jsx)(`h1`,{className:`text-xl font-bold text-slate-900 dark:text-white`,children:`Project Configuration`})]}),i&&(0,N.jsx)(`div`,{className:`bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3 text-sm text-red-700 dark:text-red-400`,children:i}),o&&(0,N.jsx)(`div`,{className:`bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-3 text-sm text-green-700 dark:text-green-400`,children:o}),(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 p-4`,children:[(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white mb-3`,children:`Project Scale`}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsx)(`label`,{htmlFor:`project-scale`,className:`text-sm text-slate-500 dark:text-slate-400`,children:`Default scale:`}),(0,N.jsx)(`input`,{id:`project-scale`,type:`number`,min:1,value:n,onChange:e=>r(e.target.value),className:`w-20 px-2 py-1.5 bg-white dark:bg-slate-950 border border-slate-300 dark:border-slate-700 rounded text-base text-slate-900 dark:text-slate-200`}),(0,N.jsx)(`button`,{onClick:l,className:`px-3 py-1.5 text-xs font-medium rounded-md bg-blue-600 hover:bg-blue-700 text-white transition-colors`,children:`Update`})]}),(0,N.jsx)(`p`,{className:`text-xs text-slate-500 dark:text-slate-400 mt-2`,children:`The default number of concurrent instances per agent. Individual agents can override this in their SKILL.md config.`})]}),(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 p-4`,children:[(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white mb-3`,children:`Gateway Status`}),t?(0,N.jsxs)(`dl`,{className:`space-y-2 text-sm`,children:[t.projectName&&(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Project`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300`,children:t.projectName})]}),t.gatewayPort!=null&&(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Port`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300 font-mono`,children:t.gatewayPort})]}),(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Webhooks`}),(0,N.jsx)(`dd`,{children:t.webhooksActive?(0,N.jsx)(`span`,{className:`text-green-600 dark:text-green-400 text-xs font-medium`,children:`Active`}):(0,N.jsx)(`span`,{className:`text-slate-500 text-xs`,children:`Inactive`})})]})]}):(0,N.jsx)(`p`,{className:`text-sm text-slate-500 dark:text-slate-400`,children:`Loading...`})]}),(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 p-4`,children:[(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white mb-3`,children:`Scheduler Control`}),e?(0,N.jsxs)(`div`,{className:`space-y-3`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,N.jsx)(`span`,{className:`text-slate-500 dark:text-slate-400`,children:`Status:`}),e.paused?(0,N.jsx)(`span`,{className:`text-yellow-600 dark:text-yellow-400 font-medium`,children:`Paused`}):(0,N.jsx)(`span`,{className:`text-green-600 dark:text-green-400 font-medium`,children:`Running`})]}),(0,N.jsx)(`div`,{className:`flex items-center gap-2`,children:e.paused?(0,N.jsx)(`button`,{onClick:()=>c(mr,`Scheduler resumed`),className:`px-4 py-2 text-sm font-medium rounded-md bg-green-600 hover:bg-green-700 text-white transition-colors`,children:`Resume All`}):(0,N.jsx)(`button`,{onClick:()=>c(pr,`Scheduler paused`),className:`px-4 py-2 text-sm font-medium rounded-md bg-yellow-600 hover:bg-yellow-700 text-white transition-colors`,children:`Pause All`})}),(0,N.jsx)(`p`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Pausing prevents new scheduled and webhook-triggered runs from starting. Running instances are not affected.`})]}):(0,N.jsx)(`p`,{className:`text-sm text-slate-500 dark:text-slate-400`,children:`Connecting to scheduler...`})]})]})}function xa({label:e,value:t,id:n}){return(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 p-3 sm:p-4`,children:[(0,N.jsx)(`div`,{className:`text-xs text-slate-500 dark:text-slate-400 uppercase tracking-wide mb-1`,children:e}),(0,N.jsx)(`div`,{className:`text-lg sm:text-xl font-semibold text-slate-900 dark:text-white`,id:n,children:t})]})}function Sa(){let{name:e}=dt(),{data:t}=ni({key:`agent-stats:${e}`,fetcher:t=>Qn(e,t),invalidateOn:[`stats`],invalidateAgent:e,enabled:!!e});if(!e)return null;let n=t?.summary;return(0,N.jsx)(`div`,{className:`space-y-6`,children:n&&(0,N.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-3`,children:[(0,N.jsx)(xa,{label:`Total Runs`,value:`${n.totalRuns}`}),(0,N.jsx)(xa,{label:`Success`,value:`${n.okRuns}`}),(0,N.jsx)(xa,{label:`Errors`,value:`${n.errorRuns}`}),(0,N.jsx)(xa,{label:`Avg Duration`,value:n.avgDurationMs?I(n.avgDurationMs):`—`}),(0,N.jsx)(xa,{label:`Total Tokens`,value:zi(n.totalTokens)}),(0,N.jsx)(xa,{label:`Total Cost`,value:Ri(n.totalCost)})]})})}function Ca(){let{agents:e,schedulerInfo:t}=Br(),n=e.map(e=>e.name),r=e.reduce((e,t)=>e+(t.cumulativeUsage?.totalTokens??0),0),i=e.filter(e=>(e.cumulativeUsage?.totalTokens??0)>0).sort((e,t)=>(t.cumulativeUsage?.totalTokens??0)-(e.cumulativeUsage?.totalTokens??0));return(0,N.jsxs)(`div`,{className:`space-y-6`,children:[(0,N.jsx)(`div`,{className:`flex items-center justify-between flex-wrap gap-3`,children:(0,N.jsx)(`h1`,{className:`text-xl font-bold text-slate-900 dark:text-white`,children:`Stats`})}),(0,N.jsx)(`div`,{className:`flex gap-6 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`span`,{className:`pb-2 text-sm font-medium text-blue-600 dark:text-blue-400 border-b-2 border-blue-600 dark:border-blue-400`,children:`Token Usage`})}),t?.startedAt&&(0,N.jsxs)(`div`,{className:`text-sm text-slate-500 dark:text-slate-400`,children:[`Session: `,Hi(t.startedAt)]}),(0,N.jsx)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800`,children:r===0?(0,N.jsx)(`div`,{className:`px-4 py-8 text-center text-slate-500 dark:text-slate-400`,children:`No token usage recorded yet`}):i.map(e=>{let t=e.cumulativeUsage?.totalTokens??0,i=t/r*100;return(0,N.jsxs)(`div`,{className:`px-4 py-3 border-b border-slate-100 dark:border-slate-800/50 last:border-0`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,N.jsx)(M,{to:`/dashboard/agents/${encodeURIComponent(e.name)}`,className:`agent-color-text text-sm font-medium hover:underline`,style:P(e.name,n),children:e.name}),(0,N.jsxs)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:[zi(t),` (`,i.toFixed(1),`%)`]})]}),(0,N.jsx)(`div`,{className:`h-2 rounded-full overflow-hidden bg-slate-200 dark:bg-slate-800`,children:(0,N.jsx)(`div`,{className:`h-full rounded-full agent-color-bg transition-all`,style:{width:`${i}%`,...P(e.name,n)}})})]},e.name)})})]})}var wa=``;async function Ta(e,t){let n=await fetch(`${wa}${e}`,{credentials:`same-origin`,...t});if(n.status===401)throw window.location.href=`/login`,Error(`Unauthorized`);if(!n.ok){let e=await n.text();throw Error(e||`HTTP ${n.status}`)}return n.json()}function Ea(e){return Ta(`/api/chat/sessions`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({agentName:e})})}function Da(e){return Ta(`/api/chat/sessions/${encodeURIComponent(e)}/clear`,{method:`POST`})}function Oa(e){return Ta(`/api/chat/sessions/${encodeURIComponent(e)}`,{method:`DELETE`})}var ka=0;function Aa(){return`msg-${++ka}-${Date.now()}`}function ja(e){let t=(0,x.useRef)(null),[n,r]=(0,x.useState)([]),[i,a]=(0,x.useState)(!1),[o,s]=(0,x.useState)(!1),c=(0,x.useRef)(!1);return(0,x.useEffect)(()=>{if(!e)return;let n=`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}/chat/ws/${e}`,i=new WebSocket(n);return t.current=i,i.onopen=()=>{a(!0)},i.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}switch(t.type){case`assistant_message`:t.done?(c.current=!1,r(e=>{let t=e[e.length-1];return t?.role===`assistant`&&!t.done?[...e.slice(0,-1),{...t,done:!0}]:e})):(o||s(!0),c.current=!0,r(e=>{let n=e[e.length-1];return n?.role===`assistant`&&!n.done?[...e.slice(0,-1),{...n,text:n.text+(t.text||``)}]:[...e,{id:Aa(),role:`assistant`,text:t.text||``,done:!1}]}));break;case`tool_start`:o||s(!0),r(e=>[...e,{id:Aa(),role:`tool_start`,text:t.input||``,toolName:t.tool,toolCallId:t.toolCallId}]);break;case`tool_result`:r(e=>[...e,{id:Aa(),role:`tool_result`,text:t.output||``,toolName:t.tool,toolCallId:t.toolCallId,error:!!t.error}]);break;case`error`:r(e=>[...e,{id:Aa(),role:`error`,text:t.message||`Unknown error`}]),c.current=!1;break;case`heartbeat`:break}},i.onclose=()=>{a(!1)},i.onerror=()=>{a(!1)},()=>{i.close(),t.current=null}},[e]),{messages:n,connected:i,containerReady:o,sendMessage:(0,x.useCallback)(e=>{if(!t.current||t.current.readyState!==WebSocket.OPEN)return;let n={id:Aa(),role:`user`,text:e,done:!0};r(e=>[...e,n]),t.current.send(JSON.stringify({type:`user_message`,text:e}))},[]),cancel:(0,x.useCallback)(()=>{!t.current||t.current.readyState!==WebSocket.OPEN||t.current.send(JSON.stringify({type:`cancel`}))},[]),resetMessages:(0,x.useCallback)(()=>{r([]),c.current=!1},[])}}function Ma({message:e}){return e.role===`user`?(0,N.jsx)(`div`,{className:`flex justify-end mb-3`,children:(0,N.jsx)(`div`,{className:`max-w-[80%] bg-blue-600 text-white rounded-2xl rounded-br-sm px-4 py-2 text-sm whitespace-pre-wrap`,children:e.text})}):e.role===`assistant`?(0,N.jsx)(`div`,{className:`flex justify-start mb-3`,children:(0,N.jsxs)(`div`,{className:`max-w-[80%] bg-slate-700 text-slate-100 rounded-2xl rounded-bl-sm px-4 py-2 text-sm whitespace-pre-wrap`,children:[e.text,!e.done&&(0,N.jsx)(`span`,{className:`inline-block w-2 h-4 bg-slate-400 animate-pulse ml-0.5 align-text-bottom`})]})}):e.role===`error`?(0,N.jsx)(`div`,{className:`flex justify-start mb-3`,children:(0,N.jsx)(`div`,{className:`max-w-[80%] bg-red-900/50 border border-red-700 text-red-200 rounded-lg px-4 py-2 text-sm`,children:e.text})}):null}function Na({message:e}){let[t,n]=(0,x.useState)(!1),r=e.role===`tool_result`,i=e.error;return(0,N.jsxs)(`div`,{className:`mb-2 ml-2`,children:[(0,N.jsxs)(`button`,{onClick:()=>n(!t),className:`flex items-center gap-2 text-xs font-mono px-3 py-1.5 rounded-md w-full text-left transition-colors ${i?`bg-red-900/30 border border-red-800 text-red-300 hover:bg-red-900/50`:`bg-slate-800 border border-slate-700 text-slate-400 hover:bg-slate-750`}`,children:[(0,N.jsx)(`span`,{className:`transition-transform ${t?`rotate-90`:``}`,children:`▸`}),(0,N.jsx)(`span`,{className:`font-semibold text-slate-300`,children:e.toolName||`tool`}),(0,N.jsx)(`span`,{className:`text-slate-500`,children:r?i?`error`:`done`:`running...`})]}),t&&(0,N.jsx)(`pre`,{className:`mt-1 ml-5 p-2 bg-slate-900 border border-slate-800 rounded text-xs text-slate-400 overflow-x-auto max-h-60 overflow-y-auto whitespace-pre-wrap`,children:e.text.slice(0,5e3)})]})}function Pa(){let{agent:e}=dt(),t=st(),[n,r]=(0,x.useState)(null),[i,a]=(0,x.useState)(null),[o,s]=(0,x.useState)(``),c=(0,x.useRef)(null),l=(0,x.useRef)(null),{messages:u,connected:d,containerReady:f,sendMessage:p,cancel:m,resetMessages:h}=ja(n);(0,x.useEffect)(()=>{if(!e)return;let t=!1;return Ea(e).then(({sessionId:e})=>{t||r(e)}).catch(e=>{t||a(e.message)}),()=>{t=!0}},[e]),(0,x.useEffect)(()=>{c.current?.scrollIntoView({behavior:`smooth`})},[u]),(0,x.useEffect)(()=>{l.current&&(l.current.style.height=`auto`,l.current.style.height=`${Math.min(l.current.scrollHeight,150)}px`)},[o]);let g=(0,x.useCallback)(()=>{let e=o.trim();e&&(p(e),s(``))},[o,p]),_=(0,x.useCallback)(e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),g())},[g]),v=(0,x.useCallback)(async()=>{if(n)try{let{sessionId:e}=await Da(n);h(),r(e)}catch(e){a(e.message)}},[n,h]),y=(0,x.useCallback)(async()=>{if(n)try{await Oa(n),t(`/dashboard/agents/${encodeURIComponent(e||``)}`)}catch(e){a(e.message)}},[n,e,t]),b=u.some(e=>e.role===`assistant`&&!e.done);return i?(0,N.jsx)(`div`,{className:`min-h-screen bg-slate-900 text-white flex items-center justify-center`,children:(0,N.jsxs)(`div`,{className:`text-center`,children:[(0,N.jsx)(`p`,{className:`text-red-400 mb-4`,children:i}),(0,N.jsx)(M,{to:`/dashboard`,className:`text-blue-400 hover:underline`,children:`Back to Dashboard`})]})}):(0,N.jsxs)(`div`,{className:`flex flex-col h-screen bg-slate-900 text-white`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-slate-700 bg-slate-800`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsx)(M,{to:`/dashboard/agents/${encodeURIComponent(e||``)}`,className:`text-slate-400 hover:text-white transition-colors`,children:`←`}),(0,N.jsxs)(`h1`,{className:`text-lg font-semibold`,children:[`Chat: `,e]})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full ${d?f?`bg-green-400`:`bg-yellow-400`:`bg-red-400`}`}),(0,N.jsx)(`span`,{className:`text-xs text-slate-400`,children:d?f?`Connected`:`Waiting for agent...`:`Disconnected`}),(0,N.jsx)(`button`,{onClick:v,disabled:!n,className:`px-3 py-1.5 text-xs font-medium rounded-md bg-yellow-600 hover:bg-yellow-700 disabled:opacity-40 text-white transition-colors`,children:`Clear Context`}),(0,N.jsx)(`button`,{onClick:y,disabled:!n,className:`px-3 py-1.5 text-xs font-medium rounded-md bg-red-600 hover:bg-red-700 disabled:opacity-40 text-white transition-colors`,children:`Shutdown`})]})]}),(0,N.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-4 py-4`,children:[u.length===0&&!b&&(0,N.jsx)(`div`,{className:`text-center text-slate-500 mt-20`,children:f?`Send a message to start chatting.`:`Waiting for agent container to start...`}),u.map(e=>e.role===`tool_start`||e.role===`tool_result`?(0,N.jsx)(Na,{message:e},e.id):(0,N.jsx)(Ma,{message:e},e.id)),(0,N.jsx)(`div`,{ref:c})]}),(0,N.jsxs)(`div`,{className:`border-t border-slate-700 bg-slate-800 px-4 py-3`,children:[(0,N.jsxs)(`div`,{className:`flex items-end gap-2 max-w-4xl mx-auto`,children:[(0,N.jsx)(`textarea`,{ref:l,value:o,onChange:e=>s(e.target.value),onKeyDown:_,placeholder:b?`Agent is responding...`:`Type a message...`,disabled:!d,rows:1,className:`flex-1 bg-slate-700 border border-slate-600 rounded-lg px-3 py-2 text-base text-white placeholder-slate-400 resize-none focus:outline-none focus:border-blue-500 disabled:opacity-50`}),b?(0,N.jsx)(`button`,{onClick:m,className:`px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-sm font-medium transition-colors`,children:`Cancel`}):(0,N.jsx)(`button`,{onClick:g,disabled:!o.trim()||!d,className:`px-4 py-2 bg-blue-600 hover:bg-blue-700 disabled:bg-slate-600 disabled:cursor-not-allowed text-white rounded-lg text-sm font-medium transition-colors`,children:`Send`})]}),(0,N.jsx)(`p`,{className:`text-xs text-slate-500 mt-1 text-center`,children:`Enter to send, Shift+Enter for newline`})]})]})}function Fa(e){if(!e)return`—`;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function Ia(){let{receiptId:e}=dt(),[t,n]=(0,x.useState)(void 0),[r,i]=(0,x.useState)(null),[a,o]=(0,x.useState)(null),[s,c]=(0,x.useState)(!1);(0,x.useEffect)(()=>{e&&tr(e).then(e=>n(e.receipt)).catch(()=>n(null))},[e]);let l=(0,x.useCallback)(async()=>{if(e){i(null),o(null),c(!0);try{let t=await nr(e);i(`Replayed: ${t.matched} matched, ${t.skipped} skipped`)}catch(e){o(e instanceof Error?e.message:`Replay failed`)}finally{c(!1)}}},[e]);if(!e)return null;if(t===void 0)return(0,N.jsx)(`div`,{className:`text-center py-12 text-slate-500 dark:text-slate-400`,children:`Loading...`});if(t===null)return(0,N.jsx)(`div`,{className:`space-y-6`,children:(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsx)(M,{to:`/dashboard/triggers`,className:`text-slate-500 hover:text-slate-700 dark:hover:text-slate-300`,children:(0,N.jsx)(`svg`,{className:`w-5 h-5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,N.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M15 19l-7-7 7-7`})})}),(0,N.jsx)(`h1`,{className:`text-xl font-bold text-slate-900 dark:text-white`,children:`Receipt not found`})]})});let u=!!(t.headers||t.body),d=t.status===`processed`?`completed`:`dead-letter`,f=oa(t.body,t.headers);return(0,N.jsxs)(`div`,{className:`space-y-6`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between flex-wrap gap-3`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsx)(M,{to:`/dashboard/triggers`,className:`text-slate-500 hover:text-slate-700 dark:hover:text-slate-300`,children:(0,N.jsx)(`svg`,{className:`w-5 h-5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,N.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M15 19l-7-7 7-7`})})}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h1`,{className:`text-xl font-bold text-slate-900 dark:text-white font-mono`,children:Bi(t.id)}),(0,N.jsx)(`div`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Webhook Receipt`})]}),(0,N.jsx)(oi,{result:d})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r&&(0,N.jsx)(`span`,{className:`text-xs text-green-600 dark:text-green-400`,children:r}),a&&(0,N.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,children:a}),(0,N.jsx)(`button`,{onClick:l,disabled:!u||s,className:`px-3 py-1.5 text-xs font-medium rounded-md bg-blue-600 hover:bg-blue-700 disabled:opacity-40 text-white transition-colors`,children:s?`Replaying...`:`Replay`})]})]}),(0,N.jsx)(`div`,{className:`max-w-2xl`,children:(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 p-4`,children:[(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white mb-3`,children:`Receipt Info`}),(0,N.jsxs)(`dl`,{className:`text-sm`,children:[(0,N.jsxs)(`div`,{className:`grid grid-cols-[8rem_1fr] gap-x-4 py-1 items-center`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Source`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300`,children:t.source})]}),t.eventSummary&&(0,N.jsxs)(`div`,{className:`grid grid-cols-[8rem_1fr] gap-x-4 py-1 items-center`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Event`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300`,children:t.eventSummary})]}),t.deliveryId&&(0,N.jsxs)(`div`,{className:`grid grid-cols-[8rem_1fr] gap-x-4 py-1 items-center`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Delivery ID`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300 font-mono text-xs`,children:t.deliveryId})]}),(0,N.jsxs)(`div`,{className:`grid grid-cols-[8rem_1fr] gap-x-4 py-1 items-center`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Timestamp`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300`,children:Vi(t.timestamp)})]}),(0,N.jsxs)(`div`,{className:`grid grid-cols-[8rem_1fr] gap-x-4 py-1 items-center`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Status`}),(0,N.jsx)(`dd`,{children:(0,N.jsx)(oi,{result:d})})]}),(0,N.jsxs)(`div`,{className:`grid grid-cols-[8rem_1fr] gap-x-4 py-1 items-center`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Matched Agents`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300`,children:t.matchedAgents})]}),t.deadLetterReason&&(0,N.jsxs)(`div`,{className:`grid grid-cols-[8rem_1fr] gap-x-4 py-1 items-center`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Dead Letter Reason`}),(0,N.jsx)(`dd`,{className:`text-red-600 dark:text-red-400 text-xs`,children:t.deadLetterReason})]}),(0,N.jsxs)(`div`,{className:`grid grid-cols-[8rem_1fr] gap-x-4 py-1 items-start pt-2 mt-1 border-t border-slate-200 dark:border-slate-800`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Receipt ID`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300 font-mono text-xs break-all`,children:t.id})]})]})]})}),(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Headers`})}),(0,N.jsx)(`div`,{className:`p-3 bg-slate-950`,children:(0,N.jsx)(`pre`,{className:`text-xs font-mono text-slate-300 whitespace-pre-wrap break-all`,children:t.headers?Fa(t.headers):`—`})})]}),f&&(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:f.label})}),(0,N.jsx)(`div`,{className:`bg-slate-950 p-3 max-h-96 overflow-y-auto`,children:(0,N.jsx)(`pre`,{className:`text-xs font-mono text-slate-300 whitespace-pre-wrap break-all`,children:f.content})})]}),(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:f?`Raw Body`:`Body`})}),(0,N.jsx)(`div`,{className:`bg-slate-950 p-3 max-h-96 overflow-y-auto`,children:(0,N.jsx)(`pre`,{className:`text-xs font-mono text-slate-300 whitespace-pre-wrap break-all`,children:t.body?Fa(t.body):`—`})})]})]})}function La(){let{name:e}=dt();return(0,N.jsx)(Ft,{to:`/activity?agent=${encodeURIComponent(e??``)}`,replace:!0})}function Ra(){let{name:e}=dt();return(0,N.jsx)(Ft,{to:`/dashboard/agents/${encodeURIComponent(e??``)}/settings`,replace:!0})}function za(){return(0,N.jsxs)(Rt,{children:[(0,N.jsx)(j,{path:`/login`,element:(0,N.jsx)(li,{})}),(0,N.jsx)(j,{path:`/chat/:agent`,element:(0,N.jsx)(Pa,{})}),(0,N.jsxs)(j,{element:(0,N.jsx)(Wr,{}),children:[(0,N.jsx)(j,{path:`/dashboard`,element:(0,N.jsx)(vi,{})}),(0,N.jsxs)(j,{path:`/dashboard/agents/:name`,element:(0,N.jsx)(qr,{}),children:[(0,N.jsx)(j,{index:!0,element:(0,N.jsx)(Zi,{})}),(0,N.jsx)(j,{path:`stats`,element:(0,N.jsx)(Sa,{})}),(0,N.jsx)(j,{path:`settings`,element:(0,N.jsx)(ta,{})}),(0,N.jsx)(j,{path:`admin`,element:(0,N.jsx)(Ft,{to:`settings`,replace:!0})}),(0,N.jsx)(j,{path:`skill`,element:(0,N.jsx)(Ra,{})}),(0,N.jsx)(j,{path:`triggers`,element:(0,N.jsx)(La,{})})]}),(0,N.jsxs)(j,{path:`/dashboard/agents/:name/instances/:id`,element:(0,N.jsx)(ci,{}),children:[(0,N.jsx)(j,{index:!0,element:(0,N.jsx)(ia,{})}),(0,N.jsx)(j,{path:`trigger`,element:(0,N.jsx)(ca,{})}),(0,N.jsx)(j,{path:`telemetry`,element:(0,N.jsx)(la,{})})]}),(0,N.jsx)(j,{path:`/dashboard/triggers`,element:(0,N.jsx)(Ft,{to:`/activity`,replace:!0})}),(0,N.jsx)(j,{path:`/activity`,element:(0,N.jsx)(_a,{})}),(0,N.jsx)(j,{path:`/stats`,element:(0,N.jsx)(Ca,{})}),(0,N.jsx)(j,{path:`/triggers`,element:(0,N.jsx)(Ft,{to:`/activity`,replace:!0})}),(0,N.jsx)(j,{path:`/jobs`,element:(0,N.jsx)(Ft,{to:`/activity`,replace:!0})}),(0,N.jsx)(j,{path:`/dashboard/triggers/:instanceId`,element:(0,N.jsx)(ya,{})}),(0,N.jsx)(j,{path:`/dashboard/webhooks/:receiptId`,element:(0,N.jsx)(Ia,{})}),(0,N.jsx)(j,{path:`/dashboard/config`,element:(0,N.jsx)(ba,{})})]}),(0,N.jsx)(j,{path:`/`,element:(0,N.jsx)(Ft,{to:`/dashboard`,replace:!0})})]})}var Ba=localStorage.getItem(`al-theme`)||`dark`;document.documentElement.classList.toggle(`dark`,Ba===`dark`),(0,Jn.createRoot)(document.getElementById(`root`)).render((0,N.jsx)(x.StrictMode,{children:(0,N.jsx)(Dn,{children:(0,N.jsx)(za,{})})}));
|
|
16
|
+
`)}function ta(){let{name:e}=dt(),{agents:t}=Br(),[n,r]=(0,x.useState)(null),[i,a]=(0,x.useState)(``),[o,s]=(0,x.useState)(null),[c,l]=(0,x.useState)(null),[u,d]=(0,x.useState)(null),[f,p]=(0,x.useState)(null),m=t.find(t=>t.name===e)??n?.agent??null,h=(0,x.useCallback)(()=>{e&&Qn(e).then(e=>{r(e),e.agent&&a(String(e.agent.scale))}).catch(()=>{})},[e]);(0,x.useEffect)(()=>{h()},[h]),(0,x.useEffect)(()=>{m&&a(String(m.scale))},[m?.scale]),(0,x.useEffect)(()=>{e&&$n(e).then(e=>{s(e.body),l(e.agentConfig)}).catch(e=>d(e instanceof Error?e.message:`Failed to load skill`))},[e]);let g=(0,x.useCallback)(async e=>{p(null);try{await e()}catch(e){p(e instanceof Error?e.message:`Action failed`)}},[]),_=(0,x.useCallback)(()=>{if(!e)return;let t=parseInt(i,10);isNaN(t)||t<1||g(()=>gr(e,t))},[e,i,g]);return e?(0,N.jsxs)(`div`,{className:`space-y-6`,children:[f&&(0,N.jsx)(`div`,{className:`bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3 text-sm text-red-700 dark:text-red-400`,children:f}),(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Controls`})}),(0,N.jsxs)(`div`,{className:`p-4 flex items-center gap-4 flex-wrap`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Scale:`}),(0,N.jsx)(`input`,{id:`agent-scale-input`,type:`number`,min:1,value:i,onChange:e=>a(e.target.value),className:`w-16 px-2 py-1 bg-white dark:bg-slate-950 border border-slate-300 dark:border-slate-700 rounded text-base text-slate-900 dark:text-slate-200`}),(0,N.jsx)(`button`,{id:`update-agent-scale-btn`,onClick:_,className:`px-2 py-1.5 text-xs font-medium rounded-md bg-blue-600 hover:bg-blue-700 text-white transition-colors`,children:`Set`})]}),m&&(0,N.jsx)(`button`,{id:`toggle-btn`,onClick:()=>g(()=>m.enabled?fr(e):dr(e)),className:`px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${m.enabled?`bg-slate-200 dark:bg-slate-700 text-slate-700 dark:text-slate-300 hover:bg-slate-300 dark:hover:bg-slate-600`:`bg-blue-600 hover:bg-blue-700 text-white`}`,children:m.enabled?`Disable`:`Enable`})]})]}),c&&(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Configuration`})}),(0,N.jsxs)(`div`,{className:`p-4 space-y-4 text-sm`,children:[c.description&&(0,N.jsx)(`p`,{className:`text-slate-700 dark:text-slate-300`,children:c.description}),(0,N.jsxs)(`dl`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-3`,children:[c.schedule&&(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`dt`,{className:`text-xs text-slate-500 dark:text-slate-400 uppercase tracking-wide`,children:`Schedule`}),(0,N.jsx)(`dd`,{className:`mt-0.5`,children:(0,N.jsx)(`code`,{className:`text-xs bg-slate-200 dark:bg-slate-800 px-1.5 py-0.5 rounded font-mono`,children:c.schedule})})]}),c.models&&c.models.length>0&&(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`dt`,{className:`text-xs text-slate-500 dark:text-slate-400 uppercase tracking-wide`,children:`Models`}),(0,N.jsx)(`dd`,{className:`mt-0.5 space-y-0.5`,children:c.models.map((e,t)=>(0,N.jsxs)(`div`,{className:`text-xs text-slate-700 dark:text-slate-300`,children:[e.provider,`/`,e.model,e.thinkingLevel?` (${e.thinkingLevel})`:``,(0,N.jsxs)(`span`,{className:`text-slate-400 dark:text-slate-500 ml-1`,children:[`[`,e.authType,`]`]})]},t))})]}),c.credentials&&c.credentials.length>0&&(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`dt`,{className:`text-xs text-slate-500 dark:text-slate-400 uppercase tracking-wide`,children:`Credentials`}),(0,N.jsx)(`dd`,{className:`mt-0.5 flex flex-wrap gap-1`,children:c.credentials.map(e=>(0,N.jsx)(`span`,{className:`px-1.5 py-0.5 text-xs bg-slate-200 dark:bg-slate-800 rounded font-mono`,children:e},e))})]}),c.hooks&&(c.hooks.pre?.length||c.hooks.post?.length)&&(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`dt`,{className:`text-xs text-slate-500 dark:text-slate-400 uppercase tracking-wide`,children:`Hooks`}),(0,N.jsxs)(`dd`,{className:`mt-0.5 text-xs text-slate-700 dark:text-slate-300`,children:[c.hooks.pre&&c.hooks.pre.length>0&&(0,N.jsxs)(`div`,{children:[`Pre: `,c.hooks.pre.join(`, `)]}),c.hooks.post&&c.hooks.post.length>0&&(0,N.jsxs)(`div`,{children:[`Post: `,c.hooks.post.join(`, `)]})]})]}),c.params&&Object.keys(c.params).length>0&&(0,N.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,N.jsx)(`dt`,{className:`text-xs text-slate-500 dark:text-slate-400 uppercase tracking-wide`,children:`Params`}),(0,N.jsx)(`dd`,{className:`mt-0.5`,children:(0,N.jsx)(`pre`,{className:`text-xs bg-slate-200 dark:bg-slate-800 p-2 rounded overflow-x-auto`,children:JSON.stringify(c.params,null,2)})})]})]}),c.webhooks&&c.webhooks.length>0&&(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h3`,{className:`text-xs text-slate-500 dark:text-slate-400 uppercase tracking-wide mb-2`,children:`Webhook Filters`}),(0,N.jsx)(`div`,{className:`space-y-3`,children:c.webhooks.map((e,t)=>(0,N.jsxs)(`div`,{className:`bg-slate-100 dark:bg-slate-800 rounded p-3 text-xs space-y-1`,children:[(0,N.jsx)(`div`,{className:`font-medium text-slate-700 dark:text-slate-300`,children:e.source??`unknown`}),e.events&&e.events.length>0&&(0,N.jsxs)(`div`,{className:`text-slate-600 dark:text-slate-400`,children:[(0,N.jsx)(`span`,{className:`text-slate-500`,children:`events:`}),` `,e.events.map(e=>(0,N.jsx)(`span`,{className:`inline-block mr-1 px-1.5 py-0.5 bg-slate-200 dark:bg-slate-700 rounded font-mono`,children:e},e))]}),e.actions&&e.actions.length>0&&(0,N.jsxs)(`div`,{className:`text-slate-600 dark:text-slate-400`,children:[(0,N.jsx)(`span`,{className:`text-slate-500`,children:`actions:`}),` `,e.actions.join(`, `)]}),e.repos&&e.repos.length>0&&(0,N.jsxs)(`div`,{className:`text-slate-600 dark:text-slate-400`,children:[(0,N.jsx)(`span`,{className:`text-slate-500`,children:`repos:`}),` `,e.repos.join(`, `)]}),(e.org||e.orgs&&e.orgs.length>0)&&(0,N.jsxs)(`div`,{className:`text-slate-600 dark:text-slate-400`,children:[(0,N.jsx)(`span`,{className:`text-slate-500`,children:`orgs:`}),` `,e.org??e.orgs?.join(`, `)]}),e.branches&&e.branches.length>0&&(0,N.jsxs)(`div`,{className:`text-slate-600 dark:text-slate-400`,children:[(0,N.jsx)(`span`,{className:`text-slate-500`,children:`branches:`}),` `,e.branches.join(`, `)]}),e.labels&&e.labels.length>0&&(0,N.jsxs)(`div`,{className:`text-slate-600 dark:text-slate-400`,children:[(0,N.jsx)(`span`,{className:`text-slate-500`,children:`labels:`}),` `,e.labels.join(`, `)]}),e.assignee&&(0,N.jsxs)(`div`,{className:`text-slate-600 dark:text-slate-400`,children:[(0,N.jsx)(`span`,{className:`text-slate-500`,children:`assignee:`}),` `,e.assignee]}),e.author&&(0,N.jsxs)(`div`,{className:`text-slate-600 dark:text-slate-400`,children:[(0,N.jsx)(`span`,{className:`text-slate-500`,children:`author:`}),` `,e.author]})]},t))})]})]})]}),u?(0,N.jsx)(`div`,{className:`bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 text-sm text-red-700 dark:text-red-400`,children:u}):o===null?(0,N.jsx)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 p-8 text-center text-slate-500 dark:text-slate-400`,children:`Loading...`}):(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Skill`})}),(0,N.jsx)(`div`,{className:`p-6`,children:(0,N.jsx)(`div`,{className:`prose prose-slate dark:prose-invert max-w-none text-sm text-slate-700 dark:text-slate-300`,dangerouslySetInnerHTML:{__html:ea(o)}})})]})]}):null}function na(e,t,n=[]){let r=(0,x.useRef)(e);r.current=e;let{intervalMs:i,enabled:a=!0}=t;(0,x.useEffect)(()=>{if(!a)return;let e=new AbortController,t=!1,n=()=>{t||(t=!0,r.current(e.signal).catch(()=>{}).finally(()=>{t=!1}))};n();let o=setInterval(n,i);return()=>{clearInterval(o),e.abort()}},[i,a,...n])}function ra(e){let t=e.msg||``;return e.text&&(t.includes(`assistant`)||t.includes(`response`))?{text:`${t}: ${e.text}`,className:`text-white font-bold`}:e.cmd||t.includes(`bash`)||t.includes(`command`)?{text:e.cmd?`$ ${e.cmd}`:t,className:`text-cyan-400`}:e.tool||t.includes(`tool`)?{text:e.tool?`[tool] ${e.tool}: ${e.result??``}`:t,className:`text-blue-400`}:e.level>=50||e.err?{text:t,className:`text-red-400`}:e.level>=40?{text:t,className:`text-yellow-400`}:{text:t,className:`text-slate-300`}}function ia(){let e=(0,x.useContext)(si),[t,n]=(0,x.useState)([]),[r,i]=(0,x.useState)(!0),[a,o]=(0,x.useState)(!1),s=(0,x.useRef)(null),c=(0,x.useRef)(null),l=(0,x.useRef)(null),u=e?.name??``,d=e?.id??``,f=e?.isRunning??!1,[p,m]=(0,x.useState)(!1),[h,g]=(0,x.useState)(!0),[_,v]=(0,x.useState)(!1),y=(0,x.useRef)(!1),[b,S]=(0,x.useState)(null),[C,w]=(0,x.useState)(!1),[T,E]=(0,x.useState)(null),{data:ee}=ni({key:`instance-locks:${d}`,fetcher:e=>or(e),pollIntervalMs:5e3,enabled:f&&!!e}),D=(ee?.locks??[]).filter(e=>e.holder===d||!e.holder&&e.agentName===u);na(async e=>{if(!u||!d)return;let t={lines:`200`};s.current&&(t.cursor=s.current);try{let r=await sr(u,d,t,e);o(!0),r.entries.length>0&&(!s.current&&r.backCursor&&(c.current=r.backCursor),n(e=>[...e,...r.entries]),r.cursor&&(s.current=r.cursor))}catch{throw o(!1),void 0}},{intervalMs:f?3e3:1e4,enabled:!!u&&!!d&&!!e},[u,d,f]),(0,x.useEffect)(()=>{r&&l.current&&(l.current.scrollTop=l.current.scrollHeight)},[t,r]);let te=(0,x.useCallback)(async()=>{if(!(!u||!d)){w(!0),E(null);try{let e=await yr(u,d);e.error?E(e.error):S(e.summary)}catch(e){E(e instanceof Error?e.message:`Failed to summarize`)}finally{w(!1)}}},[u,d]),ne=(0,x.useCallback)(async()=>{if(!(!u||!d||p||!h||t.length===0||_)){if(!c.current){g(!1);return}m(!0);try{let e=await sr(u,d,{lines:`100`,back_cursor:c.current});if(e.entries.length>0){let t=l.current,r=t?.scrollHeight??0,i=t?.scrollTop??0;n(t=>[...e.entries,...t]),requestAnimationFrame(()=>{t&&(t.scrollTop=i+(t.scrollHeight-r))})}c.current=e.backCursor,(!e.backCursor||e.entries.length<100)&&g(!1)}catch{}finally{m(!1)}}},[u,d,p,h,t,_]);(0,x.useEffect)(()=>{if(f||!u||!d||!h||y.current||t.length===0)return;if(!c.current){g(!1);return}y.current=!0,v(!0);let e=!1;return(async()=>{try{for(;!e&&c.current;){let t=await sr(u,d,{lines:`100`,back_cursor:c.current});if(e)break;if(t.entries.length===0){g(!1);break}let r=l.current,i=r?.scrollHeight??0,a=r?.scrollTop??0;if(n(e=>[...t.entries,...e]),requestAnimationFrame(()=>{r&&(r.scrollTop=a+(r.scrollHeight-i))}),c.current=t.backCursor,!t.backCursor||t.entries.length<100){g(!1);break}}}catch{}finally{e||(v(!1),y.current=!1)}})(),()=>{e=!0,v(!1),y.current=!1}},[f,u,d,t.length>0]);let re=(0,x.useCallback)(()=>{if(!l.current)return;let e=l.current;i(e.scrollHeight-e.scrollTop-e.clientHeight<40),e.scrollTop<100&&h&&!p&&!_&&t.length>0&&ne()},[h,p,_,t.length,ne]);return e?(0,N.jsxs)(`div`,{className:`space-y-4`,children:[D.length>0&&(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsxs)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:[`Resource Locks (`,D.length,`)`]})}),(0,N.jsx)(`div`,{className:`divide-y divide-slate-100 dark:divide-slate-800/50`,children:D.map(e=>(0,N.jsxs)(`div`,{className:`px-4 py-2.5 flex items-center justify-between`,children:[(0,N.jsx)(`span`,{className:`text-sm font-mono text-slate-700 dark:text-slate-300`,children:e.resourceKey}),e.heldSince&&(0,N.jsxs)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:[`since `,new Date(e.heldSince).toLocaleTimeString()]})]},e.resourceKey))})]}),(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:[(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Logs`}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsxs)(`span`,{className:`hidden sm:inline text-xs text-slate-500 dark:text-slate-400`,children:[t.length,` lines`]}),(0,N.jsx)(`span`,{className:`text-xs ${a?`text-green-500`:`text-red-500`}`,children:a?`Connected`:`Disconnected`}),(0,N.jsx)(`button`,{onClick:te,disabled:C||t.length===0,className:`px-2 py-1 text-xs rounded bg-purple-600 hover:bg-purple-700 disabled:opacity-40 disabled:cursor-not-allowed text-white transition-colors`,children:C?(0,N.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,N.jsxs)(`svg`,{className:`w-3 h-3 animate-spin`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,N.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,N.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z`})]}),`Summarizing…`]}):`Summarize`}),(0,N.jsx)(`button`,{onClick:()=>i(e=>!e),className:`px-2 py-1 text-xs rounded transition-colors ${r?`bg-blue-600 text-white`:`bg-slate-200 dark:bg-slate-800 text-slate-700 dark:text-slate-300`}`,children:`Follow`}),(0,N.jsx)(`button`,{onClick:()=>{n([]),s.current=null,c.current=null,g(!0)},className:`px-2 py-1 text-xs rounded bg-slate-200 dark:bg-slate-800 text-slate-700 dark:text-slate-300 hover:bg-slate-300 dark:hover:bg-slate-700 transition-colors`,children:`Clear`})]})]}),(0,N.jsxs)(`div`,{className:`relative`,children:[(b||T)&&(0,N.jsx)(`div`,{className:`absolute inset-x-0 top-0 z-10 p-3 pointer-events-none`,children:(0,N.jsxs)(`div`,{className:`pointer-events-auto`,children:[b&&(0,N.jsx)(`div`,{className:`bg-purple-900/95 border border-purple-700 rounded-lg p-4 text-sm text-purple-100 shadow-lg backdrop-blur-sm`,children:(0,N.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`div`,{className:`text-xs font-medium text-purple-300 mb-1`,children:`Summary`}),(0,N.jsx)(`p`,{className:`leading-relaxed`,children:b})]}),(0,N.jsx)(`button`,{onClick:()=>S(null),className:`text-purple-400 hover:text-purple-200 flex-shrink-0`,children:(0,N.jsx)(`svg`,{className:`w-4 h-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,N.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M6 18L18 6M6 6l12 12`})})})]})}),T&&(0,N.jsxs)(`div`,{className:`mt-2 bg-red-900/95 border border-red-700 rounded-lg p-3 text-sm text-red-200 flex items-center justify-between shadow-lg backdrop-blur-sm`,children:[(0,N.jsx)(`span`,{children:T}),(0,N.jsx)(`button`,{onClick:()=>E(null),className:`text-red-400 hover:text-red-200 ml-2`,children:(0,N.jsx)(`svg`,{className:`w-4 h-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,N.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M6 18L18 6M6 6l12 12`})})})]})]})}),(0,N.jsxs)(`div`,{ref:l,onScroll:re,className:`min-h-[32rem] max-h-[calc(100vh-16rem)] overflow-y-auto scrollbar-thin bg-slate-950 p-3`,children:[(p||_)&&(0,N.jsx)(`div`,{className:`text-xs text-slate-500 text-center py-2`,children:(0,N.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,N.jsxs)(`svg`,{className:`w-3 h-3 animate-spin`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,N.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,N.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z`})]}),_?`Loading full history…`:`Loading older logs…`]})}),!h&&t.length>0&&(0,N.jsx)(`div`,{className:`text-xs text-slate-600 text-center py-2 border-b border-slate-800 mb-2`,children:`— Beginning of logs —`}),h&&!p&&t.length>0&&(0,N.jsx)(`button`,{className:`w-full text-xs text-blue-400 hover:text-blue-300 text-center py-2 border-b border-slate-800 mb-2 transition-colors`,onClick:ne,children:`↑ Load older logs`}),t.length>0?t.map((e,t)=>{let{text:n,className:r}=ra(e);return(0,N.jsxs)(`div`,{className:`text-xs font-mono leading-5`,children:[(0,N.jsx)(`span`,{className:`text-slate-600`,children:new Date(e.time).toLocaleTimeString()}),` `,(0,N.jsx)(`span`,{className:r,children:n})]},t)}):(0,N.jsx)(`div`,{className:`text-xs text-slate-500 text-center py-4`,children:`No log entries`})]})]})]})]}):null}function aa(e){if(e)try{let t=JSON.parse(e);return t[`content-type`]??t[`Content-Type`]}catch{return}}function oa(e,t){if(!e)return null;let n=aa(t)?.toLowerCase()??``;if(n.includes(`application/x-www-form-urlencoded`))try{let t=new URLSearchParams(e),n={};for(let[e,r]of t.entries())try{n[e]=JSON.parse(r)}catch{n[e]=r}return{label:`Decoded Body (form-urlencoded)`,content:JSON.stringify(n,null,2)}}catch{}if(n.includes(`application/json`))return null;try{return JSON.parse(e),null}catch{if(/^[A-Za-z0-9+/\n\r]+=*$/.test(e.trim())&&e.trim().length>20)try{let t=atob(e.trim().replace(/\s/g,``));if(/^[\x20-\x7E\t\n\r]*$/.test(t))try{let e=JSON.parse(t);return{label:`Decoded Body (base64)`,content:JSON.stringify(e,null,2)}}catch{return{label:`Decoded Body (base64)`,content:t}}}catch{}}return null}function sa(e){if(!e)return`—`;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function ca(){let e=(0,x.useContext)(si),{agents:t}=Br(),n=t.map(e=>e.name),[r,i]=(0,x.useState)(void 0),a=e?.id,o=e?.detail;if((0,x.useEffect)(()=>{a&&ir(a).then(e=>i(e.trigger)).catch(()=>i(null))},[a]),!e)return null;if(r===void 0)return(0,N.jsx)(`div`,{className:`text-center py-12 text-slate-500 dark:text-slate-400`,children:`Loading...`});if(r===null){let e=o?.run;return e?(0,N.jsx)(`div`,{className:`space-y-4`,children:(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Overview`})}),(0,N.jsxs)(`div`,{className:`divide-y divide-slate-100 dark:divide-slate-800/50 max-w-2xl`,children:[(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Trigger Type`}),(0,N.jsx)(ai,{type:e.trigger_type})]}),e.trigger_source&&(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Source`}),(0,N.jsx)(`span`,{className:`text-xs text-slate-700 dark:text-slate-300`,children:e.trigger_source})]})]})]})}):(0,N.jsx)(`div`,{className:`text-center py-12 text-slate-500 dark:text-slate-400`,children:`Trigger details not available.`})}return(0,N.jsxs)(`div`,{className:`space-y-4`,children:[(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Overview`})}),(0,N.jsxs)(`div`,{className:`divide-y divide-slate-100 dark:divide-slate-800/50 max-w-2xl`,children:[(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Trigger Type`}),(0,N.jsx)(ai,{type:r.triggerType})]}),(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Agent`}),(0,N.jsx)(M,{to:`/dashboard/agents/${encodeURIComponent(r.agentName)}`,className:`hover:underline text-xs flex items-center gap-1.5`,children:(0,N.jsx)(`span`,{className:`agent-color-text`,style:P(r.agentName,n),children:r.agentName})})]}),(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Instance`}),(0,N.jsx)(`span`,{className:`font-mono text-xs text-slate-700 dark:text-slate-300`,children:r.instanceId})]}),(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Time`}),(0,N.jsx)(`span`,{className:`text-xs text-slate-700 dark:text-slate-300`,children:Vi(r.startedAt)})]}),r.triggerSource&&(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Source`}),(0,N.jsx)(`span`,{className:`text-xs text-slate-700 dark:text-slate-300`,children:r.triggerSource})]})]})]}),r.triggerType===`webhook`&&r.webhook&&(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Webhook Details`})}),(0,N.jsxs)(`div`,{className:`divide-y divide-slate-100 dark:divide-slate-800/50 max-w-2xl`,children:[(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Receipt ID`}),(0,N.jsx)(M,{to:`/dashboard/webhooks/${encodeURIComponent(r.webhook.receiptId)}`,className:`font-mono text-xs text-blue-600 dark:text-blue-400 hover:underline`,children:Bi(r.webhook.receiptId)})]}),(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Source`}),(0,N.jsx)(`span`,{className:`text-xs text-slate-700 dark:text-slate-300`,children:r.webhook.source})]}),r.webhook.eventSummary&&(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Event`}),(0,N.jsx)(`span`,{className:`text-xs text-slate-700 dark:text-slate-300`,children:r.webhook.eventSummary})]}),r.webhook.deliveryId&&(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Delivery ID`}),(0,N.jsx)(`span`,{className:`font-mono text-xs text-slate-700 dark:text-slate-300`,children:r.webhook.deliveryId})]}),(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Status`}),(0,N.jsx)(oi,{result:r.webhook.status===`processed`?`completed`:`dead-letter`})]}),(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Matched Agents`}),(0,N.jsx)(`span`,{className:`text-xs text-slate-700 dark:text-slate-300`,children:r.webhook.matchedAgents})]})]}),r.webhook.headers&&(0,N.jsxs)(`div`,{className:`border-t border-slate-200 dark:border-slate-800`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-100 dark:border-slate-800/50`,children:(0,N.jsx)(`h3`,{className:`text-xs font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wide`,children:`Headers`})}),(0,N.jsx)(`pre`,{className:`px-4 py-3 text-xs font-mono text-slate-700 dark:text-slate-300 overflow-x-auto whitespace-pre-wrap break-all`,children:sa(r.webhook.headers)})]}),(()=>{let e=oa(r.webhook.body,r.webhook.headers);return(0,N.jsxs)(N.Fragment,{children:[e&&(0,N.jsxs)(`div`,{className:`border-t border-slate-200 dark:border-slate-800`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-100 dark:border-slate-800/50`,children:(0,N.jsx)(`h3`,{className:`text-xs font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wide`,children:e.label})}),(0,N.jsx)(`pre`,{className:`px-4 py-3 text-xs font-mono text-slate-700 dark:text-slate-300 overflow-x-auto whitespace-pre-wrap break-all max-h-96 overflow-y-auto`,children:e.content})]}),r.webhook.body&&(0,N.jsxs)(`div`,{className:`border-t border-slate-200 dark:border-slate-800`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-100 dark:border-slate-800/50`,children:(0,N.jsx)(`h3`,{className:`text-xs font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wide`,children:e?`Raw Body`:`Body`})}),(0,N.jsx)(`pre`,{className:`px-4 py-3 text-xs font-mono text-slate-700 dark:text-slate-300 overflow-x-auto whitespace-pre-wrap break-all`,children:sa(r.webhook.body)})]})]})})()]}),r.triggerType===`agent`&&(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Agent Trigger Details`})}),(0,N.jsx)(`div`,{className:`divide-y divide-slate-100 dark:divide-slate-800/50 max-w-2xl`,children:r.callerAgent?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Called by`}),(0,N.jsx)(M,{to:`/dashboard/agents/${encodeURIComponent(r.callerAgent)}`,className:`hover:underline text-xs flex items-center gap-1.5`,children:(0,N.jsx)(`span`,{className:`agent-color-text`,style:P(r.callerAgent,n),children:r.callerAgent})})]}),r.callerInstance&&(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Caller Instance`}),(0,N.jsx)(M,{to:`/dashboard/agents/${encodeURIComponent(r.callerAgent)}/instances/${encodeURIComponent(r.callerInstance)}`,className:`font-mono text-xs text-blue-600 dark:text-blue-400 hover:underline`,children:Bi(r.callerInstance)})]}),r.callDepth!==void 0&&(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Call Depth`}),(0,N.jsx)(`span`,{className:`text-xs text-slate-700 dark:text-slate-300`,children:r.callDepth})]})]}):(0,N.jsx)(`div`,{className:`px-4 py-3`,children:(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Caller information not available`})})}),r.triggerContext&&(0,N.jsxs)(`div`,{className:`border-t border-slate-200 dark:border-slate-800`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-100 dark:border-slate-800/50`,children:(0,N.jsx)(`h3`,{className:`text-xs font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wide`,children:`Trigger Context`})}),(0,N.jsx)(`pre`,{className:`px-4 py-3 text-xs font-mono text-slate-700 dark:text-slate-300 overflow-x-auto whitespace-pre-wrap break-all`,children:r.triggerContext})]})]}),r.triggerType===`manual`&&(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Manual Trigger Details`})}),r.triggerContext?(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-100 dark:border-slate-800/50`,children:(0,N.jsx)(`h3`,{className:`text-xs font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wide`,children:`Prompt`})}),(0,N.jsx)(`pre`,{className:`px-4 py-3 text-xs font-mono text-slate-700 dark:text-slate-300 overflow-x-auto whitespace-pre-wrap break-all`,children:r.triggerContext})]}):(0,N.jsx)(`div`,{className:`px-4 py-3`,children:(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Prompt not available (run predates context tracking)`})})]}),r.triggerType===`schedule`&&(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Schedule Trigger Details`})}),(0,N.jsx)(`div`,{className:`px-4 py-3`,children:(0,N.jsxs)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:[`Scheduled run at `,Vi(r.startedAt)]})})]})]})}function la(){let e=(0,x.useContext)(si);if(!e)return null;let{detail:t,isRunning:n}=e,r=t?.run;return!r&&n?(0,N.jsx)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 p-6 text-center`,children:(0,N.jsx)(`p`,{className:`text-sm text-slate-500 dark:text-slate-400`,children:`Instance is currently running. Telemetry data will be available once the run completes.`})}):r?(0,N.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 p-4`,children:[(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white mb-3`,children:`Run Info`}),(0,N.jsxs)(`dl`,{className:`space-y-2 text-sm`,children:[(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Status`}),(0,N.jsx)(`dd`,{children:(0,N.jsx)(oi,{result:r.result})})]}),r.exit_code!=null&&(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Exit Code`}),(0,N.jsx)(`dd`,{className:r.exit_code===0?`text-green-600 dark:text-green-400`:`text-red-600 dark:text-red-400`,children:r.exit_code})]}),(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Started`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300`,children:Vi(r.started_at)})]}),(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Ended`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300`,children:Vi(r.started_at+r.duration_ms)})]}),(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Duration`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300`,children:I(r.duration_ms)})]}),(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Turns`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300`,children:r.turn_count})]}),r.error_message&&(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400 mb-1`,children:`Error`}),(0,N.jsx)(`dd`,{className:`text-red-600 dark:text-red-400 text-xs bg-red-50 dark:bg-red-900/20 rounded p-2 font-mono break-all`,children:r.error_message})]})]})]}),(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 p-4`,children:[(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white mb-3`,children:`Token Usage`}),(0,N.jsxs)(`dl`,{className:`space-y-2 text-sm`,children:[(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Input`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300`,children:zi(r.input_tokens)})]}),(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Output`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300`,children:zi(r.output_tokens)})]}),(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Cache Read`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300`,children:zi(r.cache_read_tokens)})]}),(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Cache Write`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300`,children:zi(r.cache_write_tokens)})]}),(0,N.jsxs)(`div`,{className:`flex justify-between border-t border-slate-200 dark:border-slate-800 pt-2 mt-2`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400 font-medium`,children:`Total`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300 font-medium`,children:zi(r.total_tokens)})]}),(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400 font-medium`,children:`Cost`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300 font-medium`,children:Ri(r.cost_usd)})]})]})]})]}):null}function L({options:e,value:t,onChange:n,placeholder:r}){let[i,a]=(0,x.useState)(!1),o=(0,x.useRef)(null);return(0,x.useEffect)(()=>{let e=e=>{o.current&&!o.current.contains(e.target)&&a(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,N.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>a(!i),className:`inline-flex items-center gap-1.5 text-sm rounded-lg border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-800 text-slate-700 dark:text-slate-200 pl-3 pr-2 py-1.5 hover:border-slate-300 dark:hover:border-slate-600 transition-colors shadow-sm`,children:[(0,N.jsx)(`span`,{children:e.find(e=>e.value===t)?.label||r}),(0,N.jsx)(da,{})]}),i&&(0,N.jsx)(`div`,{className:`absolute z-50 mt-1 min-w-[160px] rounded-lg border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-800 shadow-lg py-1 max-h-64 overflow-y-auto`,children:e.map(e=>(0,N.jsx)(`button`,{type:`button`,onClick:()=>{n(e.value),a(!1)},className:`w-full text-left px-3 py-1.5 text-sm transition-colors ${e.value===t?`bg-blue-50 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 font-medium`:`text-slate-700 dark:text-slate-300 hover:bg-slate-50 dark:hover:bg-slate-700/50`}`,children:e.label},e.value))})]})}function ua({options:e,selected:t,onChange:n,label:r}){let[i,a]=(0,x.useState)(!1),o=(0,x.useRef)(null);(0,x.useEffect)(()=>{let e=e=>{o.current&&!o.current.contains(e.target)&&a(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let s=t.length===e.length,c=t.length===0,l=e=>{t.includes(e)?n(t.filter(t=>t!==e)):n([...t,e])},u=()=>{n(s?[]:e.map(e=>e.value))},d=s||c?r:t.length===1?e.find(e=>e.value===t[0])?.label??r:`${t.length} selected`;return(0,N.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>a(!i),className:`inline-flex items-center gap-1.5 text-sm rounded-lg border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-800 text-slate-700 dark:text-slate-200 pl-3 pr-2 py-1.5 hover:border-slate-300 dark:hover:border-slate-600 transition-colors shadow-sm`,children:[!s&&!c&&(0,N.jsx)(`span`,{className:`inline-flex items-center justify-center w-4 h-4 rounded-full bg-blue-600 text-white text-[10px] font-bold leading-none`,children:t.length}),(0,N.jsx)(`span`,{children:d}),(0,N.jsx)(da,{})]}),i&&(0,N.jsxs)(`div`,{className:`absolute z-50 mt-1 min-w-[180px] rounded-lg border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-800 shadow-lg py-1 max-h-64 overflow-y-auto`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:u,className:`w-full text-left px-3 py-1.5 text-xs font-medium text-slate-500 dark:text-slate-400 hover:bg-slate-50 dark:hover:bg-slate-700/50 transition-colors border-b border-slate-100 dark:border-slate-700`,children:s?`Deselect all`:`Select all`}),e.map(e=>{let n=t.includes(e.value);return(0,N.jsxs)(`button`,{type:`button`,onClick:()=>l(e.value),className:`w-full text-left px-3 py-1.5 text-sm flex items-center gap-2 transition-colors ${n?`text-slate-900 dark:text-white`:`text-slate-500 dark:text-slate-400 hover:bg-slate-50 dark:hover:bg-slate-700/50`}`,children:[(0,N.jsx)(`span`,{className:`flex items-center justify-center w-3.5 h-3.5 rounded border transition-colors ${n?`bg-blue-600 border-blue-600`:`border-slate-300 dark:border-slate-600`}`,children:n&&(0,N.jsx)(`svg`,{className:`w-2.5 h-2.5 text-white`,viewBox:`0 0 12 12`,fill:`none`,children:(0,N.jsx)(`path`,{d:`M2 6l3 3 5-5`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}),e.dot&&(0,N.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${e.dot}`}),(0,N.jsx)(`span`,{children:e.label})]},e.value)})]})]})}function da(){return(0,N.jsx)(`svg`,{className:`w-4 h-4 text-slate-400`,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,N.jsx)(`path`,{fillRule:`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,clipRule:`evenodd`})})}var fa=50,pa=[`pending`,`running`,`completed`],ma=[{value:`pending`,label:`Pending`,dot:`bg-amber-400`},{value:`running`,label:`Running`,dot:`bg-blue-500`},{value:`completed`,label:`Completed`,dot:`bg-green-500`},{value:`error`,label:`Error`,dot:`bg-red-500`},{value:`dead-letter`,label:`Dead Letter`,dot:`bg-red-300 dark:bg-red-800`}],ha=[{value:``,label:`All Types`},{value:`schedule`,label:`Schedule`},{value:`webhook`,label:`Webhook`},{value:`manual`,label:`Manual`},{value:`agent`,label:`Agent`}];function ga(e){if(!e)return pa;let t=e.split(`,`).filter(Boolean);return t.length>0?t:pa}function _a(){let[e,t]=Ln(),n=e.get(`agent`)||void 0,r=e.get(`type`)||void 0,i=e.get(`status`),a=(0,x.useMemo)(()=>ga(i),[i]),[o,s]=(0,x.useState)(0),c=Nr(),l=c.map(e=>e.name),u=a.join(`,`),d=a.length===ma.length?void 0:a,{data:f,isLoading:p}=ni({key:`activity:${o}:${n??``}:${r??``}:${u}`,fetcher:e=>rr(fa,o,n,r,d,e),invalidateOn:[`runs`,`triggers`],keyChangeDebounceMs:150}),m=f?.rows??[],h=f?.total??0,g=f?.pendingCount??0;(0,x.useEffect)(()=>{s(0)},[n,r,u]);let _=(0,x.useCallback)((e,n)=>{t(t=>{let r=new URLSearchParams(t);return n?r.set(e,n):r.delete(e),r.delete(`offset`),r})},[t]),v=(0,x.useCallback)(e=>{t(t=>{let n=new URLSearchParams(t);return e.length===0||e.length===ma.length?n.delete(`status`):n.set(`status`,e.join(`,`)),n.delete(`offset`),n})},[t]),y=Math.floor(o/fa)+1,b=Math.max(1,Math.ceil(h/fa)),S=[{value:``,label:`All Agents`},...c.map(e=>({value:e.name,label:e.name}))];return(0,N.jsxs)(`div`,{className:`space-y-6`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between flex-wrap gap-3`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsx)(`h1`,{className:`text-xl font-bold text-slate-900 dark:text-white`,children:`Activity`}),g>0&&(0,N.jsxs)(`span`,{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-400`,children:[g,` pending`]})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,N.jsx)(L,{options:S,value:n||``,onChange:e=>_(`agent`,e||void 0),placeholder:`All Agents`}),(0,N.jsx)(L,{options:ha,value:r||``,onChange:e=>_(`type`,e||void 0),placeholder:`All Types`}),(0,N.jsx)(ua,{options:ma,selected:a,onChange:v,label:`All Statuses`})]})]}),(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(Xi,{rows:m,agentNames:l,loading:p&&m.length===0}),b>1&&(0,N.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2.5 border-t border-slate-200 dark:border-slate-800`,children:[(0,N.jsx)(`button`,{onClick:()=>s(Math.max(0,o-fa)),disabled:o===0,className:`px-3 py-1 text-xs rounded bg-slate-200 dark:bg-slate-800 text-slate-700 dark:text-slate-300 hover:bg-slate-300 dark:hover:bg-slate-700 disabled:opacity-40 transition-colors`,children:`Previous`}),(0,N.jsxs)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:[`Page `,y,` of `,b,` (`,h,` total)`]}),(0,N.jsx)(`button`,{onClick:()=>s(o+fa),disabled:o+fa>=h,className:`px-3 py-1 text-xs rounded bg-slate-200 dark:bg-slate-800 text-slate-700 dark:text-slate-300 hover:bg-slate-300 dark:hover:bg-slate-700 disabled:opacity-40 transition-colors`,children:`Next`})]})]})]})}function va(e){if(!e)return`—`;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function ya(){let{instanceId:e}=dt(),{agents:t}=Br(),n=t.map(e=>e.name),[r,i]=(0,x.useState)(void 0),[a,o]=(0,x.useState)(null),[s,c]=(0,x.useState)(null),[l,u]=(0,x.useState)(!1);(0,x.useEffect)(()=>{e&&ir(e).then(e=>i(e.trigger)).catch(()=>i(null))},[e]);let d=(0,x.useCallback)(async()=>{if(r?.webhook?.receiptId){o(null),c(null),u(!0);try{let e=await nr(r.webhook.receiptId);o(`Replayed: ${e.matched} matched, ${e.skipped} skipped`)}catch(e){c(e instanceof Error?e.message:`Replay failed`)}finally{u(!1)}}},[r]);if(!e)return null;if(r===void 0)return(0,N.jsx)(`div`,{className:`text-center py-12 text-slate-500 dark:text-slate-400`,children:`Loading...`});if(r===null)return(0,N.jsx)(`div`,{className:`space-y-6`,children:(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsx)(M,{to:`/jobs`,className:`text-slate-500 hover:text-slate-700 dark:hover:text-slate-300`,children:(0,N.jsx)(`svg`,{className:`w-5 h-5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,N.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M15 19l-7-7 7-7`})})}),(0,N.jsx)(`h1`,{className:`text-xl font-bold text-slate-900 dark:text-white`,children:`Trigger not found`})]})});let f=!!(r.webhook?.receiptId&&(r.webhook.headers||r.webhook.body));return(0,N.jsxs)(`div`,{className:`space-y-6`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between flex-wrap gap-3`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsx)(M,{to:`/jobs`,className:`text-slate-500 hover:text-slate-700 dark:hover:text-slate-300`,children:(0,N.jsx)(`svg`,{className:`w-5 h-5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,N.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M15 19l-7-7 7-7`})})}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h1`,{className:`text-xl font-bold text-slate-900 dark:text-white font-mono`,children:r.instanceId}),(0,N.jsx)(`div`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Trigger Detail`})]}),(0,N.jsx)(ai,{type:r.triggerType})]}),r.triggerType===`webhook`&&f&&(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a&&(0,N.jsx)(`span`,{className:`text-xs text-green-600 dark:text-green-400`,children:a}),s&&(0,N.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,children:s}),(0,N.jsx)(`button`,{onClick:d,disabled:l,className:`px-3 py-1.5 text-xs font-medium rounded-md bg-blue-600 hover:bg-blue-700 disabled:opacity-40 text-white transition-colors`,children:l?`Replaying...`:`Replay`})]})]}),(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Overview`})}),(0,N.jsxs)(`div`,{className:`divide-y divide-slate-100 dark:divide-slate-800/50 max-w-2xl`,children:[(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Trigger Type`}),(0,N.jsx)(ai,{type:r.triggerType})]}),(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Agent`}),(0,N.jsx)(M,{to:`/dashboard/agents/${encodeURIComponent(r.agentName)}`,className:`hover:underline text-xs flex items-center gap-1.5`,children:(0,N.jsx)(`span`,{className:`agent-color-text`,style:P(r.agentName,n),children:r.agentName})})]}),(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Instance`}),(0,N.jsx)(M,{to:`/dashboard/agents/${encodeURIComponent(r.agentName)}/instances/${encodeURIComponent(r.instanceId)}`,className:`font-mono text-xs text-blue-600 dark:text-blue-400 hover:underline`,children:r.instanceId})]}),(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Time`}),(0,N.jsx)(`span`,{className:`text-xs text-slate-700 dark:text-slate-300`,children:Vi(r.startedAt)})]}),r.triggerSource&&(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Source`}),(0,N.jsx)(`span`,{className:`text-xs text-slate-700 dark:text-slate-300`,children:r.triggerSource})]})]})]}),r.triggerType===`webhook`&&r.webhook&&(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Webhook Details`})}),(0,N.jsxs)(`div`,{className:`divide-y divide-slate-100 dark:divide-slate-800/50 max-w-2xl`,children:[(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Receipt ID`}),(0,N.jsx)(M,{to:`/dashboard/webhooks/${encodeURIComponent(r.webhook.receiptId)}`,className:`font-mono text-xs text-blue-600 dark:text-blue-400 hover:underline`,children:Bi(r.webhook.receiptId)})]}),(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Source`}),(0,N.jsx)(`span`,{className:`text-xs text-slate-700 dark:text-slate-300`,children:r.webhook.source})]}),r.webhook.eventSummary&&(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Event`}),(0,N.jsx)(`span`,{className:`text-xs text-slate-700 dark:text-slate-300`,children:r.webhook.eventSummary})]}),r.webhook.deliveryId&&(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Delivery ID`}),(0,N.jsx)(`span`,{className:`font-mono text-xs text-slate-700 dark:text-slate-300`,children:r.webhook.deliveryId})]}),(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Status`}),(0,N.jsx)(oi,{result:r.webhook.status===`processed`?`completed`:`dead-letter`})]}),(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Matched Agents`}),(0,N.jsx)(`span`,{className:`text-xs text-slate-700 dark:text-slate-300`,children:r.webhook.matchedAgents})]})]}),r.webhook.headers&&(0,N.jsxs)(`div`,{className:`border-t border-slate-200 dark:border-slate-800`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-100 dark:border-slate-800/50`,children:(0,N.jsx)(`h3`,{className:`text-xs font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wide`,children:`Headers`})}),(0,N.jsx)(`pre`,{className:`px-4 py-3 text-xs font-mono text-slate-700 dark:text-slate-300 overflow-x-auto whitespace-pre-wrap break-all`,children:va(r.webhook.headers)})]}),(()=>{let e=oa(r.webhook.body,r.webhook.headers);return(0,N.jsxs)(N.Fragment,{children:[e&&(0,N.jsxs)(`div`,{className:`border-t border-slate-200 dark:border-slate-800`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-100 dark:border-slate-800/50`,children:(0,N.jsx)(`h3`,{className:`text-xs font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wide`,children:e.label})}),(0,N.jsx)(`pre`,{className:`px-4 py-3 text-xs font-mono text-slate-700 dark:text-slate-300 overflow-x-auto whitespace-pre-wrap break-all max-h-96 overflow-y-auto`,children:e.content})]}),r.webhook.body&&(0,N.jsxs)(`div`,{className:`border-t border-slate-200 dark:border-slate-800`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-100 dark:border-slate-800/50`,children:(0,N.jsx)(`h3`,{className:`text-xs font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wide`,children:e?`Raw Body`:`Body`})}),(0,N.jsx)(`pre`,{className:`px-4 py-3 text-xs font-mono text-slate-700 dark:text-slate-300 overflow-x-auto whitespace-pre-wrap break-all`,children:va(r.webhook.body)})]})]})})()]}),r.triggerType===`agent`&&(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Agent Trigger Details`})}),(0,N.jsx)(`div`,{className:`divide-y divide-slate-100 dark:divide-slate-800/50 max-w-2xl`,children:r.callerAgent?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Called by`}),(0,N.jsx)(M,{to:`/dashboard/agents/${encodeURIComponent(r.callerAgent)}`,className:`hover:underline text-xs flex items-center gap-1.5`,children:(0,N.jsx)(`span`,{className:`agent-color-text`,style:P(r.callerAgent,n),children:r.callerAgent})})]}),r.callerInstance&&(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Caller Instance`}),(0,N.jsx)(M,{to:`/dashboard/agents/${encodeURIComponent(r.callerAgent)}/instances/${encodeURIComponent(r.callerInstance)}`,className:`font-mono text-xs text-blue-600 dark:text-blue-400 hover:underline`,children:Bi(r.callerInstance)})]}),r.callDepth!==void 0&&(0,N.jsxs)(`div`,{className:`px-4 py-3 grid grid-cols-[8rem_1fr] gap-x-4 items-center`,children:[(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Call Depth`}),(0,N.jsx)(`span`,{className:`text-xs text-slate-700 dark:text-slate-300`,children:r.callDepth})]})]}):(0,N.jsx)(`div`,{className:`px-4 py-3`,children:(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Caller information not available`})})}),r.triggerContext&&(0,N.jsxs)(`div`,{className:`border-t border-slate-200 dark:border-slate-800`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-100 dark:border-slate-800/50`,children:(0,N.jsx)(`h3`,{className:`text-xs font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wide`,children:`Trigger Context`})}),(0,N.jsx)(`pre`,{className:`px-4 py-3 text-xs font-mono text-slate-700 dark:text-slate-300 overflow-x-auto whitespace-pre-wrap break-all`,children:r.triggerContext})]})]}),r.triggerType===`manual`&&(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Manual Trigger Details`})}),r.triggerContext?(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-100 dark:border-slate-800/50`,children:(0,N.jsx)(`h3`,{className:`text-xs font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wide`,children:`Prompt`})}),(0,N.jsx)(`pre`,{className:`px-4 py-3 text-xs font-mono text-slate-700 dark:text-slate-300 overflow-x-auto whitespace-pre-wrap break-all`,children:r.triggerContext})]}):(0,N.jsx)(`div`,{className:`px-4 py-3`,children:(0,N.jsx)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Prompt not available (run predates context tracking)`})})]}),r.triggerType===`schedule`&&(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Schedule Trigger Details`})}),(0,N.jsx)(`div`,{className:`px-4 py-3`,children:(0,N.jsxs)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:[`Scheduled run at `,Vi(r.startedAt)]})})]}),(0,N.jsx)(`div`,{className:`flex justify-end`,children:(0,N.jsx)(M,{to:`/dashboard/agents/${encodeURIComponent(r.agentName)}/instances/${encodeURIComponent(r.instanceId)}`,className:`text-sm text-blue-600 dark:text-blue-400 hover:underline`,children:`View run details →`})})]})}function ba(){let e=Pr(),{data:t}=ni({key:`project-config`,fetcher:e=>er(e),invalidateOn:[`config`]}),[n,r]=(0,x.useState)(``),[i,a]=(0,x.useState)(null),[o,s]=(0,x.useState)(null);(0,x.useEffect)(()=>{t&&r(String(t.projectScale))},[t]);let c=(0,x.useCallback)(async(e,t)=>{a(null),s(null);try{await e(),t&&s(t)}catch(e){a(e instanceof Error?e.message:`Action failed`)}},[]),l=(0,x.useCallback)(()=>{let e=parseInt(n,10);isNaN(e)||e<1||c(()=>hr(e),`Scale updated`)},[n,c]);return(0,N.jsxs)(`div`,{className:`space-y-6`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsx)(M,{to:`/dashboard`,className:`text-slate-500 hover:text-slate-700 dark:hover:text-slate-300`,children:(0,N.jsx)(`svg`,{className:`w-5 h-5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,N.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M15 19l-7-7 7-7`})})}),(0,N.jsx)(`h1`,{className:`text-xl font-bold text-slate-900 dark:text-white`,children:`Project Configuration`})]}),i&&(0,N.jsx)(`div`,{className:`bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3 text-sm text-red-700 dark:text-red-400`,children:i}),o&&(0,N.jsx)(`div`,{className:`bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-3 text-sm text-green-700 dark:text-green-400`,children:o}),(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 p-4`,children:[(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white mb-3`,children:`Project Scale`}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsx)(`label`,{htmlFor:`project-scale`,className:`text-sm text-slate-500 dark:text-slate-400`,children:`Default scale:`}),(0,N.jsx)(`input`,{id:`project-scale`,type:`number`,min:1,value:n,onChange:e=>r(e.target.value),className:`w-20 px-2 py-1.5 bg-white dark:bg-slate-950 border border-slate-300 dark:border-slate-700 rounded text-base text-slate-900 dark:text-slate-200`}),(0,N.jsx)(`button`,{onClick:l,className:`px-3 py-1.5 text-xs font-medium rounded-md bg-blue-600 hover:bg-blue-700 text-white transition-colors`,children:`Update`})]}),(0,N.jsx)(`p`,{className:`text-xs text-slate-500 dark:text-slate-400 mt-2`,children:`The default number of concurrent instances per agent. Individual agents can override this in their SKILL.md config.`})]}),(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 p-4`,children:[(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white mb-3`,children:`Gateway Status`}),t?(0,N.jsxs)(`dl`,{className:`space-y-2 text-sm`,children:[t.projectName&&(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Project`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300`,children:t.projectName})]}),t.gatewayPort!=null&&(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Port`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300 font-mono`,children:t.gatewayPort})]}),(0,N.jsxs)(`div`,{className:`flex justify-between`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Webhooks`}),(0,N.jsx)(`dd`,{children:t.webhooksActive?(0,N.jsx)(`span`,{className:`text-green-600 dark:text-green-400 text-xs font-medium`,children:`Active`}):(0,N.jsx)(`span`,{className:`text-slate-500 text-xs`,children:`Inactive`})})]})]}):(0,N.jsx)(`p`,{className:`text-sm text-slate-500 dark:text-slate-400`,children:`Loading...`})]}),(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 p-4`,children:[(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white mb-3`,children:`Scheduler Control`}),e?(0,N.jsxs)(`div`,{className:`space-y-3`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,N.jsx)(`span`,{className:`text-slate-500 dark:text-slate-400`,children:`Status:`}),e.paused?(0,N.jsx)(`span`,{className:`text-yellow-600 dark:text-yellow-400 font-medium`,children:`Paused`}):(0,N.jsx)(`span`,{className:`text-green-600 dark:text-green-400 font-medium`,children:`Running`})]}),(0,N.jsx)(`div`,{className:`flex items-center gap-2`,children:e.paused?(0,N.jsx)(`button`,{onClick:()=>c(mr,`Scheduler resumed`),className:`px-4 py-2 text-sm font-medium rounded-md bg-green-600 hover:bg-green-700 text-white transition-colors`,children:`Resume All`}):(0,N.jsx)(`button`,{onClick:()=>c(pr,`Scheduler paused`),className:`px-4 py-2 text-sm font-medium rounded-md bg-yellow-600 hover:bg-yellow-700 text-white transition-colors`,children:`Pause All`})}),(0,N.jsx)(`p`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Pausing prevents new scheduled and webhook-triggered runs from starting. Running instances are not affected.`})]}):(0,N.jsx)(`p`,{className:`text-sm text-slate-500 dark:text-slate-400`,children:`Connecting to scheduler...`})]})]})}function xa({label:e,value:t,id:n}){return(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 p-3 sm:p-4`,children:[(0,N.jsx)(`div`,{className:`text-xs text-slate-500 dark:text-slate-400 uppercase tracking-wide mb-1`,children:e}),(0,N.jsx)(`div`,{className:`text-lg sm:text-xl font-semibold text-slate-900 dark:text-white`,id:n,children:t})]})}function Sa(){let{name:e}=dt(),{data:t}=ni({key:`agent-stats:${e}`,fetcher:t=>Qn(e,t),invalidateOn:[`stats`],invalidateAgent:e,enabled:!!e});if(!e)return null;let n=t?.summary;return(0,N.jsx)(`div`,{className:`space-y-6`,children:n&&(0,N.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-3`,children:[(0,N.jsx)(xa,{label:`Total Runs`,value:`${n.totalRuns}`}),(0,N.jsx)(xa,{label:`Success`,value:`${n.okRuns}`}),(0,N.jsx)(xa,{label:`Errors`,value:`${n.errorRuns}`}),(0,N.jsx)(xa,{label:`Avg Duration`,value:n.avgDurationMs?I(n.avgDurationMs):`—`}),(0,N.jsx)(xa,{label:`Total Tokens`,value:zi(n.totalTokens)}),(0,N.jsx)(xa,{label:`Total Cost`,value:Ri(n.totalCost)})]})})}function Ca(){let{agents:e,schedulerInfo:t}=Br(),n=e.map(e=>e.name),r=e.reduce((e,t)=>e+(t.cumulativeUsage?.totalTokens??0),0),i=e.filter(e=>(e.cumulativeUsage?.totalTokens??0)>0).sort((e,t)=>(t.cumulativeUsage?.totalTokens??0)-(e.cumulativeUsage?.totalTokens??0));return(0,N.jsxs)(`div`,{className:`space-y-6`,children:[(0,N.jsx)(`div`,{className:`flex items-center justify-between flex-wrap gap-3`,children:(0,N.jsx)(`h1`,{className:`text-xl font-bold text-slate-900 dark:text-white`,children:`Stats`})}),(0,N.jsx)(`div`,{className:`flex gap-6 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`span`,{className:`pb-2 text-sm font-medium text-blue-600 dark:text-blue-400 border-b-2 border-blue-600 dark:border-blue-400`,children:`Token Usage`})}),t?.startedAt&&(0,N.jsxs)(`div`,{className:`text-sm text-slate-500 dark:text-slate-400`,children:[`Session: `,Hi(t.startedAt)]}),(0,N.jsx)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800`,children:r===0?(0,N.jsx)(`div`,{className:`px-4 py-8 text-center text-slate-500 dark:text-slate-400`,children:`No token usage recorded yet`}):i.map(e=>{let t=e.cumulativeUsage?.totalTokens??0,i=t/r*100;return(0,N.jsxs)(`div`,{className:`px-4 py-3 border-b border-slate-100 dark:border-slate-800/50 last:border-0`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,N.jsx)(M,{to:`/dashboard/agents/${encodeURIComponent(e.name)}`,className:`agent-color-text text-sm font-medium hover:underline`,style:P(e.name,n),children:e.name}),(0,N.jsxs)(`span`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:[zi(t),` (`,i.toFixed(1),`%)`]})]}),(0,N.jsx)(`div`,{className:`h-2 rounded-full overflow-hidden bg-slate-200 dark:bg-slate-800`,children:(0,N.jsx)(`div`,{className:`h-full rounded-full agent-color-bg transition-all`,style:{width:`${i}%`,...P(e.name,n)}})})]},e.name)})})]})}var wa=``;async function Ta(e,t){let n=await fetch(`${wa}${e}`,{credentials:`same-origin`,...t});if(n.status===401)throw window.location.href=`/login`,Error(`Unauthorized`);if(!n.ok){let e=await n.text();throw Error(e||`HTTP ${n.status}`)}return n.json()}function Ea(e){return Ta(`/api/chat/sessions`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({agentName:e})})}function Da(e){return Ta(`/api/chat/sessions/${encodeURIComponent(e)}/clear`,{method:`POST`})}function Oa(e){return Ta(`/api/chat/sessions/${encodeURIComponent(e)}`,{method:`DELETE`})}var ka=0;function Aa(){return`msg-${++ka}-${Date.now()}`}function ja(e){let t=(0,x.useRef)(null),[n,r]=(0,x.useState)([]),[i,a]=(0,x.useState)(!1),[o,s]=(0,x.useState)(!1),c=(0,x.useRef)(!1);return(0,x.useEffect)(()=>{if(!e)return;let n=`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}/chat/ws/${e}`,i=new WebSocket(n);return t.current=i,i.onopen=()=>{a(!0)},i.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}switch(t.type){case`assistant_message`:t.done?(c.current=!1,r(e=>{let t=e[e.length-1];return t?.role===`assistant`&&!t.done?[...e.slice(0,-1),{...t,done:!0}]:e})):(o||s(!0),c.current=!0,r(e=>{let n=e[e.length-1];return n?.role===`assistant`&&!n.done?[...e.slice(0,-1),{...n,text:n.text+(t.text||``)}]:[...e,{id:Aa(),role:`assistant`,text:t.text||``,done:!1}]}));break;case`tool_start`:o||s(!0),r(e=>[...e,{id:Aa(),role:`tool_start`,text:t.input||``,toolName:t.tool,toolCallId:t.toolCallId}]);break;case`tool_result`:r(e=>[...e,{id:Aa(),role:`tool_result`,text:t.output||``,toolName:t.tool,toolCallId:t.toolCallId,error:!!t.error}]);break;case`error`:r(e=>[...e,{id:Aa(),role:`error`,text:t.message||`Unknown error`}]),c.current=!1;break;case`heartbeat`:break}},i.onclose=()=>{a(!1)},i.onerror=()=>{a(!1)},()=>{i.close(),t.current=null}},[e]),{messages:n,connected:i,containerReady:o,sendMessage:(0,x.useCallback)(e=>{if(!t.current||t.current.readyState!==WebSocket.OPEN)return;let n={id:Aa(),role:`user`,text:e,done:!0};r(e=>[...e,n]),t.current.send(JSON.stringify({type:`user_message`,text:e}))},[]),cancel:(0,x.useCallback)(()=>{!t.current||t.current.readyState!==WebSocket.OPEN||t.current.send(JSON.stringify({type:`cancel`}))},[]),resetMessages:(0,x.useCallback)(()=>{r([]),c.current=!1},[])}}function Ma({message:e}){return e.role===`user`?(0,N.jsx)(`div`,{className:`flex justify-end mb-3`,children:(0,N.jsx)(`div`,{className:`max-w-[80%] bg-blue-600 text-white rounded-2xl rounded-br-sm px-4 py-2 text-sm whitespace-pre-wrap`,children:e.text})}):e.role===`assistant`?(0,N.jsx)(`div`,{className:`flex justify-start mb-3`,children:(0,N.jsxs)(`div`,{className:`max-w-[80%] bg-slate-700 text-slate-100 rounded-2xl rounded-bl-sm px-4 py-2 text-sm whitespace-pre-wrap`,children:[e.text,!e.done&&(0,N.jsx)(`span`,{className:`inline-block w-2 h-4 bg-slate-400 animate-pulse ml-0.5 align-text-bottom`})]})}):e.role===`error`?(0,N.jsx)(`div`,{className:`flex justify-start mb-3`,children:(0,N.jsx)(`div`,{className:`max-w-[80%] bg-red-900/50 border border-red-700 text-red-200 rounded-lg px-4 py-2 text-sm`,children:e.text})}):null}function Na({message:e}){let[t,n]=(0,x.useState)(!1),r=e.role===`tool_result`,i=e.error;return(0,N.jsxs)(`div`,{className:`mb-2 ml-2`,children:[(0,N.jsxs)(`button`,{onClick:()=>n(!t),className:`flex items-center gap-2 text-xs font-mono px-3 py-1.5 rounded-md w-full text-left transition-colors ${i?`bg-red-900/30 border border-red-800 text-red-300 hover:bg-red-900/50`:`bg-slate-800 border border-slate-700 text-slate-400 hover:bg-slate-750`}`,children:[(0,N.jsx)(`span`,{className:`transition-transform ${t?`rotate-90`:``}`,children:`▸`}),(0,N.jsx)(`span`,{className:`font-semibold text-slate-300`,children:e.toolName||`tool`}),(0,N.jsx)(`span`,{className:`text-slate-500`,children:r?i?`error`:`done`:`running...`})]}),t&&(0,N.jsx)(`pre`,{className:`mt-1 ml-5 p-2 bg-slate-900 border border-slate-800 rounded text-xs text-slate-400 overflow-x-auto max-h-60 overflow-y-auto whitespace-pre-wrap`,children:e.text.slice(0,5e3)})]})}function Pa(){let{agent:e}=dt(),t=st(),[n,r]=(0,x.useState)(null),[i,a]=(0,x.useState)(null),[o,s]=(0,x.useState)(``),c=(0,x.useRef)(null),l=(0,x.useRef)(null),{messages:u,connected:d,containerReady:f,sendMessage:p,cancel:m,resetMessages:h}=ja(n);(0,x.useEffect)(()=>{if(!e)return;let t=!1;return Ea(e).then(({sessionId:e})=>{t||r(e)}).catch(e=>{t||a(e.message)}),()=>{t=!0}},[e]),(0,x.useEffect)(()=>{c.current?.scrollIntoView({behavior:`smooth`})},[u]),(0,x.useEffect)(()=>{l.current&&(l.current.style.height=`auto`,l.current.style.height=`${Math.min(l.current.scrollHeight,150)}px`)},[o]);let g=(0,x.useCallback)(()=>{let e=o.trim();e&&(p(e),s(``))},[o,p]),_=(0,x.useCallback)(e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),g())},[g]),v=(0,x.useCallback)(async()=>{if(n)try{let{sessionId:e}=await Da(n);h(),r(e)}catch(e){a(e.message)}},[n,h]),y=(0,x.useCallback)(async()=>{if(n)try{await Oa(n),t(`/dashboard/agents/${encodeURIComponent(e||``)}`)}catch(e){a(e.message)}},[n,e,t]),b=u.some(e=>e.role===`assistant`&&!e.done);return i?(0,N.jsx)(`div`,{className:`min-h-screen bg-slate-900 text-white flex items-center justify-center`,children:(0,N.jsxs)(`div`,{className:`text-center`,children:[(0,N.jsx)(`p`,{className:`text-red-400 mb-4`,children:i}),(0,N.jsx)(M,{to:`/dashboard`,className:`text-blue-400 hover:underline`,children:`Back to Dashboard`})]})}):(0,N.jsxs)(`div`,{className:`flex flex-col h-screen bg-slate-900 text-white`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-slate-700 bg-slate-800`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsx)(M,{to:`/dashboard/agents/${encodeURIComponent(e||``)}`,className:`text-slate-400 hover:text-white transition-colors`,children:`←`}),(0,N.jsxs)(`h1`,{className:`text-lg font-semibold`,children:[`Chat: `,e]})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full ${d?f?`bg-green-400`:`bg-yellow-400`:`bg-red-400`}`}),(0,N.jsx)(`span`,{className:`text-xs text-slate-400`,children:d?f?`Connected`:`Waiting for agent...`:`Disconnected`}),(0,N.jsx)(`button`,{onClick:v,disabled:!n,className:`px-3 py-1.5 text-xs font-medium rounded-md bg-yellow-600 hover:bg-yellow-700 disabled:opacity-40 text-white transition-colors`,children:`Clear Context`}),(0,N.jsx)(`button`,{onClick:y,disabled:!n,className:`px-3 py-1.5 text-xs font-medium rounded-md bg-red-600 hover:bg-red-700 disabled:opacity-40 text-white transition-colors`,children:`Shutdown`})]})]}),(0,N.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-4 py-4`,children:[u.length===0&&!b&&(0,N.jsx)(`div`,{className:`text-center text-slate-500 mt-20`,children:f?`Send a message to start chatting.`:`Waiting for agent container to start...`}),u.map(e=>e.role===`tool_start`||e.role===`tool_result`?(0,N.jsx)(Na,{message:e},e.id):(0,N.jsx)(Ma,{message:e},e.id)),(0,N.jsx)(`div`,{ref:c})]}),(0,N.jsxs)(`div`,{className:`border-t border-slate-700 bg-slate-800 px-4 py-3`,children:[(0,N.jsxs)(`div`,{className:`flex items-end gap-2 max-w-4xl mx-auto`,children:[(0,N.jsx)(`textarea`,{ref:l,value:o,onChange:e=>s(e.target.value),onKeyDown:_,placeholder:b?`Agent is responding...`:`Type a message...`,disabled:!d,rows:1,className:`flex-1 bg-slate-700 border border-slate-600 rounded-lg px-3 py-2 text-base text-white placeholder-slate-400 resize-none focus:outline-none focus:border-blue-500 disabled:opacity-50`}),b?(0,N.jsx)(`button`,{onClick:m,className:`px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-sm font-medium transition-colors`,children:`Cancel`}):(0,N.jsx)(`button`,{onClick:g,disabled:!o.trim()||!d,className:`px-4 py-2 bg-blue-600 hover:bg-blue-700 disabled:bg-slate-600 disabled:cursor-not-allowed text-white rounded-lg text-sm font-medium transition-colors`,children:`Send`})]}),(0,N.jsx)(`p`,{className:`text-xs text-slate-500 mt-1 text-center`,children:`Enter to send, Shift+Enter for newline`})]})]})}function Fa(e){if(!e)return`—`;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function Ia(){let{receiptId:e}=dt(),[t,n]=(0,x.useState)(void 0),[r,i]=(0,x.useState)(null),[a,o]=(0,x.useState)(null),[s,c]=(0,x.useState)(!1);(0,x.useEffect)(()=>{e&&tr(e).then(e=>n(e.receipt)).catch(()=>n(null))},[e]);let l=(0,x.useCallback)(async()=>{if(e){i(null),o(null),c(!0);try{let t=await nr(e);i(`Replayed: ${t.matched} matched, ${t.skipped} skipped`)}catch(e){o(e instanceof Error?e.message:`Replay failed`)}finally{c(!1)}}},[e]);if(!e)return null;if(t===void 0)return(0,N.jsx)(`div`,{className:`text-center py-12 text-slate-500 dark:text-slate-400`,children:`Loading...`});if(t===null)return(0,N.jsx)(`div`,{className:`space-y-6`,children:(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsx)(M,{to:`/dashboard/triggers`,className:`text-slate-500 hover:text-slate-700 dark:hover:text-slate-300`,children:(0,N.jsx)(`svg`,{className:`w-5 h-5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,N.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M15 19l-7-7 7-7`})})}),(0,N.jsx)(`h1`,{className:`text-xl font-bold text-slate-900 dark:text-white`,children:`Receipt not found`})]})});let u=!!(t.headers||t.body),d=t.status===`processed`?`completed`:`dead-letter`,f=oa(t.body,t.headers);return(0,N.jsxs)(`div`,{className:`space-y-6`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between flex-wrap gap-3`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsx)(M,{to:`/dashboard/triggers`,className:`text-slate-500 hover:text-slate-700 dark:hover:text-slate-300`,children:(0,N.jsx)(`svg`,{className:`w-5 h-5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,N.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M15 19l-7-7 7-7`})})}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h1`,{className:`text-xl font-bold text-slate-900 dark:text-white font-mono`,children:Bi(t.id)}),(0,N.jsx)(`div`,{className:`text-xs text-slate-500 dark:text-slate-400`,children:`Webhook Receipt`})]}),(0,N.jsx)(oi,{result:d})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r&&(0,N.jsx)(`span`,{className:`text-xs text-green-600 dark:text-green-400`,children:r}),a&&(0,N.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,children:a}),(0,N.jsx)(`button`,{onClick:l,disabled:!u||s,className:`px-3 py-1.5 text-xs font-medium rounded-md bg-blue-600 hover:bg-blue-700 disabled:opacity-40 text-white transition-colors`,children:s?`Replaying...`:`Replay`})]})]}),(0,N.jsx)(`div`,{className:`max-w-2xl`,children:(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 p-4`,children:[(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white mb-3`,children:`Receipt Info`}),(0,N.jsxs)(`dl`,{className:`text-sm`,children:[(0,N.jsxs)(`div`,{className:`grid grid-cols-[8rem_1fr] gap-x-4 py-1 items-center`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Source`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300`,children:t.source})]}),t.eventSummary&&(0,N.jsxs)(`div`,{className:`grid grid-cols-[8rem_1fr] gap-x-4 py-1 items-center`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Event`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300`,children:t.eventSummary})]}),t.deliveryId&&(0,N.jsxs)(`div`,{className:`grid grid-cols-[8rem_1fr] gap-x-4 py-1 items-center`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Delivery ID`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300 font-mono text-xs`,children:t.deliveryId})]}),(0,N.jsxs)(`div`,{className:`grid grid-cols-[8rem_1fr] gap-x-4 py-1 items-center`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Timestamp`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300`,children:Vi(t.timestamp)})]}),(0,N.jsxs)(`div`,{className:`grid grid-cols-[8rem_1fr] gap-x-4 py-1 items-center`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Status`}),(0,N.jsx)(`dd`,{children:(0,N.jsx)(oi,{result:d})})]}),(0,N.jsxs)(`div`,{className:`grid grid-cols-[8rem_1fr] gap-x-4 py-1 items-center`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Matched Agents`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300`,children:t.matchedAgents})]}),t.deadLetterReason&&(0,N.jsxs)(`div`,{className:`grid grid-cols-[8rem_1fr] gap-x-4 py-1 items-center`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Dead Letter Reason`}),(0,N.jsx)(`dd`,{className:`text-red-600 dark:text-red-400 text-xs`,children:t.deadLetterReason})]}),(0,N.jsxs)(`div`,{className:`grid grid-cols-[8rem_1fr] gap-x-4 py-1 items-start pt-2 mt-1 border-t border-slate-200 dark:border-slate-800`,children:[(0,N.jsx)(`dt`,{className:`text-slate-500 dark:text-slate-400`,children:`Receipt ID`}),(0,N.jsx)(`dd`,{className:`text-slate-700 dark:text-slate-300 font-mono text-xs break-all`,children:t.id})]})]})]})}),(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:`Headers`})}),(0,N.jsx)(`div`,{className:`p-3 bg-slate-950`,children:(0,N.jsx)(`pre`,{className:`text-xs font-mono text-slate-300 whitespace-pre-wrap break-all`,children:t.headers?Fa(t.headers):`—`})})]}),f&&(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:f.label})}),(0,N.jsx)(`div`,{className:`bg-slate-950 p-3 max-h-96 overflow-y-auto`,children:(0,N.jsx)(`pre`,{className:`text-xs font-mono text-slate-300 whitespace-pre-wrap break-all`,children:f.content})})]}),(0,N.jsxs)(`div`,{className:`bg-slate-50 dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-4 py-2.5 border-b border-slate-200 dark:border-slate-800`,children:(0,N.jsx)(`h2`,{className:`text-sm font-medium text-slate-900 dark:text-white`,children:f?`Raw Body`:`Body`})}),(0,N.jsx)(`div`,{className:`bg-slate-950 p-3 max-h-96 overflow-y-auto`,children:(0,N.jsx)(`pre`,{className:`text-xs font-mono text-slate-300 whitespace-pre-wrap break-all`,children:t.body?Fa(t.body):`—`})})]})]})}function La(){let{name:e}=dt();return(0,N.jsx)(Ft,{to:`/activity?agent=${encodeURIComponent(e??``)}`,replace:!0})}function Ra(){let{name:e}=dt();return(0,N.jsx)(Ft,{to:`/dashboard/agents/${encodeURIComponent(e??``)}/settings`,replace:!0})}function za(){return(0,N.jsxs)(Rt,{children:[(0,N.jsx)(j,{path:`/login`,element:(0,N.jsx)(li,{})}),(0,N.jsx)(j,{path:`/chat/:agent`,element:(0,N.jsx)(Pa,{})}),(0,N.jsxs)(j,{element:(0,N.jsx)(Wr,{}),children:[(0,N.jsx)(j,{path:`/dashboard`,element:(0,N.jsx)(vi,{})}),(0,N.jsxs)(j,{path:`/dashboard/agents/:name`,element:(0,N.jsx)(qr,{}),children:[(0,N.jsx)(j,{index:!0,element:(0,N.jsx)(Zi,{})}),(0,N.jsx)(j,{path:`stats`,element:(0,N.jsx)(Sa,{})}),(0,N.jsx)(j,{path:`settings`,element:(0,N.jsx)(ta,{})}),(0,N.jsx)(j,{path:`admin`,element:(0,N.jsx)(Ft,{to:`settings`,replace:!0})}),(0,N.jsx)(j,{path:`skill`,element:(0,N.jsx)(Ra,{})}),(0,N.jsx)(j,{path:`triggers`,element:(0,N.jsx)(La,{})})]}),(0,N.jsxs)(j,{path:`/dashboard/agents/:name/instances/:id`,element:(0,N.jsx)(ci,{}),children:[(0,N.jsx)(j,{index:!0,element:(0,N.jsx)(ia,{})}),(0,N.jsx)(j,{path:`trigger`,element:(0,N.jsx)(ca,{})}),(0,N.jsx)(j,{path:`telemetry`,element:(0,N.jsx)(la,{})})]}),(0,N.jsx)(j,{path:`/dashboard/triggers`,element:(0,N.jsx)(Ft,{to:`/activity`,replace:!0})}),(0,N.jsx)(j,{path:`/activity`,element:(0,N.jsx)(_a,{})}),(0,N.jsx)(j,{path:`/stats`,element:(0,N.jsx)(Ca,{})}),(0,N.jsx)(j,{path:`/triggers`,element:(0,N.jsx)(Ft,{to:`/activity`,replace:!0})}),(0,N.jsx)(j,{path:`/jobs`,element:(0,N.jsx)(Ft,{to:`/activity`,replace:!0})}),(0,N.jsx)(j,{path:`/dashboard/triggers/:instanceId`,element:(0,N.jsx)(ya,{})}),(0,N.jsx)(j,{path:`/dashboard/webhooks/:receiptId`,element:(0,N.jsx)(Ia,{})}),(0,N.jsx)(j,{path:`/dashboard/config`,element:(0,N.jsx)(ba,{})})]}),(0,N.jsx)(j,{path:`/`,element:(0,N.jsx)(Ft,{to:`/dashboard`,replace:!0})})]})}var Ba=localStorage.getItem(`al-theme`)||`dark`;document.documentElement.classList.toggle(`dark`,Ba===`dark`),(0,Jn.createRoot)(document.getElementById(`root`)).render((0,N.jsx)(x.StrictMode,{children:(0,N.jsx)(Dn,{children:(0,N.jsx)(za,{})})}));
|