@inspectr/mcplab 1.31.0 → 1.31.1

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.
@@ -161,7 +161,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/alert-
161
161
 
162
162
  Defaulting to \`null\`.`}var e7=q5,Jde=Y5,t7=_.forwardRef(({className:e,value:t,...n},r)=>(0,I.jsx)(e7,{ref:r,className:U(`relative h-4 w-full overflow-hidden rounded-full bg-secondary`,e),...n,children:(0,I.jsx)(Jde,{className:`h-full w-full flex-1 bg-primary transition-all`,style:{transform:`translateX(-${100-(t||0)}%)`}})}));t7.displayName=e7.displayName;function n7(e){let t=e.toLowerCase();return t.includes(`side-effectful prefix`)||t.includes(`destructive behavior`)||t.includes(`destructivehint`)||t.includes(`non-read-only behavior`)||t.includes(`readonlyhint: false`)||t.includes(`additive behavior`)}function r7(e){try{return JSON.stringify(e,null,2)}catch{return`[schema not serializable]`}}function Yde(e){return typeof e.type==`string`?e.type:Array.isArray(e.type)?e.type.join(` | `):e.properties&&typeof e.properties==`object`?`object`:e.items&&typeof e.items==`object`?`array`:`any`}function i7(e,t=new Set){if(!e||typeof e!=`object`||Array.isArray(e))return 0;let n=e;if(t.has(n))return 0;let r=new Set(t);r.add(n);let i=n.properties&&typeof n.properties==`object`&&!Array.isArray(n.properties)?n.properties:void 0,a=i?Object.values(i).reduce((e,t)=>e+i7(t,r),0):0,o=i7(n.items,r),s=[...Array.isArray(n.oneOf)?n.oneOf:[],...Array.isArray(n.anyOf)?n.anyOf:[]].reduce((e,t)=>e+i7(t,r),0);return(i?Object.keys(i).length:0)+a+o+s}function a7({name:e,schema:t,required:n=!1,depth:r=0,seen:i=new Set,expandAll:a=null}){let[o,s]=(0,_.useState)(r===0);if((0,_.useEffect)(()=>{a!==null&&s(a)},[a]),!t||typeof t!=`object`||Array.isArray(t))return(0,I.jsx)(`div`,{className:`text-xs`,children:e});let c=t;if(i.has(c))return(0,I.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[e,` (circular)`]});let l=new Set(i);l.add(c);let u=c.properties&&typeof c.properties==`object`&&!Array.isArray(c.properties)?c.properties:void 0,d=new Set(Array.isArray(c.required)?c.required.filter(e=>typeof e==`string`):[]),f=c.items&&typeof c.items==`object`?c.items:void 0,p=[...Array.isArray(c.oneOf)?c.oneOf:[],...Array.isArray(c.anyOf)?c.anyOf:[]],m=u&&Object.keys(u).length>0||!!f||p.length>0;return(0,I.jsxs)(`div`,{className:`min-w-0 space-y-1`,style:{marginLeft:r*12},children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5 text-xs`,children:[m?(0,I.jsxs)(`button`,{type:`button`,className:`inline-flex min-w-0 max-w-full items-center gap-1 text-left font-medium hover:underline`,"aria-label":`${o?`Collapse`:`Expand`} ${e}`,"aria-expanded":o,onClick:()=>s(e=>!e),children:[o?(0,I.jsx)(on,{className:`h-3 w-3 shrink-0`}):(0,I.jsx)(sn,{className:`h-3 w-3 shrink-0`}),(0,I.jsx)(`span`,{className:`wrap-break-word`,children:e})]}):(0,I.jsx)(`span`,{className:`wrap-break-word font-medium`,children:e}),(0,I.jsx)(Y,{variant:`outline`,className:`text-[10px]`,children:Yde(c)}),n&&(0,I.jsx)(`span`,{className:`text-[10px] text-rose-600`,children:`required`})]}),typeof c.description==`string`&&(0,I.jsx)(`div`,{className:`max-w-full wrap-break-word text-[11px] text-muted-foreground`,children:c.description}),Array.isArray(c.enum)&&(0,I.jsxs)(`div`,{className:`max-w-full wrap-break-word text-[11px] text-muted-foreground`,children:[`Enum: `,c.enum.map(e=>String(e)).join(`, `)]}),c.default!==void 0&&(0,I.jsxs)(`div`,{className:`max-w-full wrap-break-word text-[11px] text-muted-foreground`,children:[`Default: `,r7(c.default)]}),o&&m&&(0,I.jsxs)(`div`,{className:`min-w-0 space-y-2 border-l pl-2`,children:[u&&Object.keys(u).length>0&&(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(`div`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Properties`}),Object.entries(u).map(([e,t])=>(0,I.jsx)(a7,{name:e,schema:t,required:d.has(e),depth:r+1,seen:l,expandAll:a},e))]}),f&&(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(`div`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Items`}),(0,I.jsx)(a7,{name:`item`,schema:f,depth:r+1,seen:l,expandAll:a})]}),p.length>0&&(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(`div`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Variants`}),p.map((e,t)=>(0,I.jsx)(a7,{name:`variant ${t+1}`,schema:e,depth:r+1,seen:l,expandAll:a},t))]})]})]})}function o7({propertyCount:e,onExpandAll:t,onCollapseAll:n}){return(0,I.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1`,children:[(0,I.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[e,` Properties`]}),(0,I.jsx)(`button`,{type:`button`,className:`rounded border px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted hover:text-foreground`,onClick:t,children:`Expand All`}),(0,I.jsx)(`button`,{type:`button`,className:`rounded border px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted hover:text-foreground`,onClick:n,children:`Collapse All`})]})}function s7({title:e,schema:t,explorerControls:n}){let r=e.toLowerCase(),i=async()=>{try{await navigator.clipboard.writeText(r7(t)),O({title:`${e} copied`})}catch(t){O({title:`Could not copy ${e.toLowerCase()}`,description:t instanceof Error?t.message:String(t),variant:`destructive`})}};return(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,I.jsx)(`div`,{className:`text-[11px] font-medium text-muted-foreground`,children:e}),(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-1.5`,children:[n,(0,I.jsxs)(`button`,{type:`button`,className:`inline-flex shrink-0 items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":`Copy ${r} JSON`,title:`Copy ${r} JSON`,onClick:()=>void i(),children:[(0,I.jsx)(vn,{className:`h-3 w-3`}),`Copy JSON`]})]})]})}function c7({inputSchema:e,outputSchema:t,mode:n,onModeChange:r}){let[i,a]=(0,_.useState)(`explorer`),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(null),u=n??i,d=e=>{r?.(e),n||a(e)};return e===void 0&&t===void 0?null:(0,I.jsxs)(`details`,{className:`group/schema min-w-0 max-w-full overflow-hidden rounded border bg-muted/10 p-2`,onClick:e=>e.stopPropagation(),children:[(0,I.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 text-xs font-medium`,children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Schemas`,e!==void 0&&(0,I.jsx)(Y,{variant:`outline`,className:`border-border text-[10px] text-muted-foreground`,children:`input`}),t!==void 0&&(0,I.jsx)(Y,{variant:`outline`,className:`border-border text-[10px] text-muted-foreground`,children:`output`})]}),(0,I.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`inline-flex rounded-md border bg-muted p-0.5`,role:`tablist`,"aria-label":`Schema view mode`,children:[`json`,`explorer`].map(e=>(0,I.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":u===e,className:`rounded px-2 py-0.5 text-[11px] font-medium capitalize data-[active=true]:bg-background data-[active=true]:shadow-xs`,"data-active":u===e,onClick:t=>{t.preventDefault(),t.stopPropagation(),d(e)},children:e.toUpperCase()},e))}),(0,I.jsx)(on,{className:`h-4 w-4 text-muted-foreground transition-transform group-open/schema:rotate-180`})]})]}),(0,I.jsxs)(`div`,{className:`mt-2`,children:[u===`json`&&(0,I.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[e!==void 0&&(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(s7,{title:`Input schema`,schema:e}),(0,I.jsx)(`pre`,{className:`max-h-52 max-w-full overflow-auto whitespace-pre-wrap wrap-break-word rounded border bg-muted/20 p-2 text-[11px]`,children:r7(e)})]}),t!==void 0&&(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(s7,{title:`Output schema`,schema:t}),(0,I.jsx)(`pre`,{className:`max-h-52 max-w-full overflow-auto whitespace-pre-wrap wrap-break-word rounded border bg-muted/20 p-2 text-[11px]`,children:r7(t)})]})]}),u===`explorer`&&(0,I.jsxs)(`div`,{className:`mt-2 min-w-0 space-y-2`,children:[e!==void 0&&(0,I.jsxs)(`div`,{className:`min-w-0 space-y-2 rounded border bg-muted/10 p-2`,children:[(0,I.jsx)(s7,{title:`Input schema`,schema:e,explorerControls:(0,I.jsx)(o7,{propertyCount:i7(e),onExpandAll:()=>s(!0),onCollapseAll:()=>s(!1)})}),(0,I.jsx)(a7,{name:`root`,schema:e,expandAll:o})]}),t!==void 0&&(0,I.jsxs)(`div`,{className:`min-w-0 space-y-2 rounded border bg-muted/10 p-2`,children:[(0,I.jsx)(s7,{title:`Output schema`,schema:t,explorerControls:(0,I.jsx)(o7,{propertyCount:i7(t),onExpandAll:()=>l(!0),onCollapseAll:()=>l(!1)})}),(0,I.jsx)(a7,{name:`root`,schema:t,expandAll:c})]})]})]})]})}function l7(e,t){let n=t??(typeof navigator<`u`?navigator.language:void 0);return e.toLocaleString(n)}function Xde(e,t){let n=0,r=!1;for(let i of e){let e=i.tokenEstimate;if(!e)continue;r=!0;let a=new Set(t[i.serverName]??[]);n+=e.tools.filter(e=>a.has(e.name)).reduce((e,t)=>e+t.total,0)}return r?n:void 0}function u7({total:e,title:t=`Estimated tokens for this tool definition and its schemas`,className:n}){return typeof e==`number`?(0,I.jsxs)(Y,{variant:`outline`,className:U(`bg-background font-mono text-xs font-normal`,n),title:t,children:[`~`,l7(e),`tok`]}):null}var d7=[`critical`,`high`,`medium`,`low`,`info`];function f7(e){switch(e){case`critical`:return`border-red-300 bg-red-100 text-red-900`;case`high`:return`border-orange-300 bg-orange-100 text-orange-900`;case`medium`:return`border-amber-300 bg-amber-100 text-amber-900`;case`low`:return`border-sky-300 bg-sky-100 text-sky-900`;default:return`border-slate-300 bg-slate-100 text-slate-800`}}function Zde(e){switch(e){case`critical`:return`border-red-300 bg-background text-red-900`;case`high`:return`border-orange-300 bg-background text-orange-900`;case`medium`:return`border-amber-300 bg-background text-amber-900`;case`low`:return`border-sky-300 bg-background text-sky-900`;default:return`border-slate-300 bg-background text-slate-800`}}function p7(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`tool`}async function m7(e,t){let n=typeof t==`string`?t:JSON.stringify(t,null,2);try{await navigator.clipboard.writeText(n),O({title:`${e} copied`})}catch(t){O({title:`Could not copy ${e.toLowerCase()}`,description:t instanceof Error?t.message:String(t),variant:`destructive`})}}function h7({text:e}){return(0,I.jsxs)(`div`,{className:`mt-2 rounded-md border px-2.5 py-2 text-[11px] text-slate-800`,children:[(0,I.jsxs)(`div`,{className:`mb-1 inline-flex items-center gap-1 font-medium text-slate-700`,children:[(0,I.jsx)(In,{className:`h-3.5 w-3.5`}),`Suggested improvement`]}),(0,I.jsx)(`p`,{children:e})]})}function Qde({label:e,reason:t,variantClassName:n}){return(0,I.jsx)(gl,{delayDuration:0,children:(0,I.jsxs)(_l,{children:[(0,I.jsx)(vl,{asChild:!0,children:(0,I.jsx)(Y,{variant:`outline`,className:n,children:e})}),(0,I.jsx)(yl,{className:`max-w-sm text-xs`,children:(0,I.jsx)(`p`,{children:t})})]})})}function g7(e){let t=[],n=(e,n)=>{t.push(`#### ${e}`),t.push("```json");try{t.push(JSON.stringify(n,null,2))}catch{t.push(`"[schema not serializable]"`)}t.push("```")};if(t.push(`# MCP Tool Analysis Report`,``),t.push(`- Created: ${e.createdAt}`),t.push(`- Assistant Agent: ${e.assistantAgentName}`),t.push(`- Assistant Model: ${e.assistantAgentModel}`),e.mcpServerVersions&&Object.keys(e.mcpServerVersions).length>0){let n=Object.entries(e.mcpServerVersions).map(([e,t])=>`${e}: ${t??`unknown`}`).join(`, `);t.push(`- MCP Server Versions: ${n}`)}t.push(`- Modes: ${[e.modes.metadataReview?`metadata review`:null,e.modes.deeperAnalysis?`deeper analysis`:null].filter(Boolean).join(` + `)}`),t.push(``,`## Summary`),t.push(`- Servers analyzed: ${e.summary.serversAnalyzed}`),t.push(`- Tools analyzed: ${e.summary.toolsAnalyzed}`),t.push(`- Tools skipped: ${e.summary.toolsSkipped}`,``);for(let r of e.servers){t.push(`## Server: ${r.serverName}`),r.warnings.length>0&&t.push(...r.warnings.map(e=>`- Warning: ${e}`),``);for(let e of r.tools){if(t.push(`### ${e.publicToolName}`),e.title&&t.push(`- Title: ${e.title}`),t.push(`- Safety: ${e.safetyClassification} (${e.classificationReason})`),e.inputSchema!==void 0&&n(`Input schema`,e.inputSchema),e.outputSchema!==void 0&&n(`Output schema`,e.outputSchema),e.metadataReview?.issues.length){t.push(`#### Metadata issues`);for(let n of e.metadataReview.issues)t.push(` - [${n.severity}] ${n.title}: ${n.detail}`)}if(e.deeperAnalysis){if(!e.deeperAnalysis.attempted)t.push(`- Deeper analysis: skipped (${e.deeperAnalysis.skippedReason??`unknown`})`);else{t.push(`- Deeper analysis sample calls: ${e.deeperAnalysis.sampleCalls.length}`);for(let n of e.deeperAnalysis.sampleCalls){t.push(` - Call ${n.callIndex}: ${n.ok?`ok`:`error`}${n.durationMs?` (${n.durationMs}ms)`:``}`),n.error&&t.push(` - Error: ${n.error}`);for(let e of n.observations)t.push(` - ${e}`)}}}if(e.overallRecommendations.length>0){t.push(`#### Recommendations`);for(let n of e.overallRecommendations)t.push(` - ${n}`)}if(e.metadataReview?.evalReadinessNotes.length){t.push(`#### Agent/Eval readiness notes`);for(let n of e.metadataReview.evalReadinessNotes)t.push(` - ${n}`)}t.push(``)}}return`${t.join(`
163
163
  `)}\n`}function _7({report:e,schemaMode:t,onSchemaModeChange:n}){let[r,i]=cp(),[a,o]=(0,_.useState)([...d7]),[s,c]=(0,_.useState)(new Set),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)(`explorer`),h=t??p,g=e=>{n?.(e),t||m(e)},v=r.get(`groupBy`)===`severity`?`severity`:`tool`,y=(0,_.useRef)(null),b=l.trim().toLowerCase(),x=(0,_.useMemo)(()=>new Set(a),[a]),S=e=>{o(t=>{let n=t.includes(e)?t.filter(t=>t!==e):[...t,e];return n.length===0?[...d7]:n})},C=e=>{let t=new URLSearchParams(r);e===`severity`?t.set(`groupBy`,`severity`):t.delete(`groupBy`),i(t,{replace:!0})},w=(0,_.useMemo)(()=>{let t={critical:[],high:[],medium:[],low:[],info:[]};for(let n of e.servers)for(let e of n.tools){let r=`tool-${p7(`${n.serverName}-${e.publicToolName}`)}`,i=`${n.serverName}::${e.publicToolName}`,a=e.publicToolName.split(`::`).pop()??e.publicToolName;for(let n of e.metadataReview?.issues??[]){let e=n.severity;t[e].push({key:`${i}-metadata-${n.id}`,toolAnchorId:r,toolLabel:i,toolDisplayName:a,sourceLabel:`Metadata review`,issue:{id:n.id,title:n.title,detail:n.detail,severity:e,suggestion:n.suggestion}})}for(let n of e.deeperAnalysis?.sampleCalls??[])for(let e of n.issues){let o=e.severity;t[o].push({key:`${i}-call-${n.callIndex}-${e.id}`,toolAnchorId:r,toolLabel:i,toolDisplayName:a,sourceLabel:`Sample call ${n.callIndex}`,issue:{id:e.id,title:e.title,detail:e.detail,severity:o,suggestion:e.suggestion}})}}return t},[e.servers]),T=(0,_.useMemo)(()=>Array.from(new Set(e.servers.flatMap(e=>e.tools.map(e=>e.publicToolName)).map(e=>e.split(`::`).pop()??e))).sort((e,t)=>e.localeCompare(t)),[e.servers]),E=e=>b.length===0||(e.toLowerCase().split(`::`).pop()??e.toLowerCase()).includes(b),D=e=>{y.current&&y.current.querySelectorAll(`details`).forEach(t=>{t.open=e})},O=()=>c(new Set(d7)),k=()=>c(new Set),A=e=>{c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,I.jsx)(K,{children:(0,I.jsxs)(q,{className:`pt-6`,children:[(0,I.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Tools analyzed`}),(0,I.jsx)(`div`,{className:`text-2xl font-semibold`,children:e.summary.toolsAnalyzed})]})}),(0,I.jsx)(K,{children:(0,I.jsxs)(q,{className:`pt-6`,children:[(0,I.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Tools skipped`}),(0,I.jsx)(`div`,{className:`text-2xl font-semibold`,children:e.summary.toolsSkipped})]})}),(0,I.jsx)(K,{children:(0,I.jsxs)(q,{className:`pt-6`,children:[(0,I.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Findings`}),(0,I.jsx)(`div`,{className:`text-2xl font-semibold`,children:e.findings.length})]})})]}),(0,I.jsxs)(K,{children:[(0,I.jsxs)(gv,{className:`pb-3`,children:[(0,I.jsx)(_v,{className:`text-base`,children:`Analysis Overview`}),(0,I.jsx)(vv,{children:`Visual breakdown of findings by severity. Click badges to filter the report.`})]}),(0,I.jsx)(q,{children:(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[d7.filter(t=>e.summary.issueCounts[t]>0).map(t=>{let n=x.has(t);return(0,I.jsx)(`button`,{type:`button`,onClick:()=>S(t),className:`rounded-full`,"aria-pressed":n,children:(0,I.jsxs)(Y,{variant:`outline`,className:`capitalize font-normal ${n?f7(t):Zde(t)} ${n?`ring-1 ring-current`:`opacity-70`}`,children:[t,`: `,e.summary.issueCounts[t]]})},t)}),(0,I.jsx)(W,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>o([...d7]),className:`h-7 px-2 text-xs`,children:`Reset`})]})})]}),(0,I.jsxs)(`div`,{className:`space-y-0`,children:[(0,I.jsx)(CX,{value:v,onValueChange:e=>{(e===`tool`||e===`severity`)&&C(e)},className:`min-w-0 px-3 pt-1`,children:(0,I.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-2 border-b`,children:[(0,I.jsxs)(wX,{className:`h-auto justify-start rounded-none bg-transparent p-0`,children:[(0,I.jsx)(TX,{value:`tool`,className:`-mb-px h-10 rounded-none rounded-t border border-border border-b-border bg-muted/20 px-6 text-sm font-semibold text-muted-foreground data-[state=active]:z-10 data-[state=active]:bg-card data-[state=active]:text-foreground data-[state=active]:border-border data-[state=active]:border-b-card data-[state=active]:shadow-none`,children:`Report by Tool`}),(0,I.jsx)(TX,{value:`severity`,className:`-mb-px h-10 rounded-none rounded-t border border-border border-b-border bg-muted/20 px-6 text-sm font-semibold text-muted-foreground data-[state=active]:z-10 data-[state=active]:bg-card data-[state=active]:text-foreground data-[state=active]:border-border data-[state=active]:border-b-card data-[state=active]:shadow-none`,children:`By Severity`})]}),(0,I.jsxs)(`div`,{className:`mb-2 flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`whitespace-nowrap text-xs text-muted-foreground`,children:`Filter tools`}),(0,I.jsxs)(K8,{open:d,onOpenChange:f,children:[(0,I.jsx)(q8,{asChild:!0,children:(0,I.jsxs)(W,{type:`button`,variant:`outline`,role:`combobox`,"aria-expanded":d,"aria-controls":`tool-filter-command-list`,className:`h-8 w-[320px] max-w-full justify-between text-xs font-normal`,children:[(0,I.jsx)(`span`,{className:`truncate text-left`,children:l||`All tools`}),(0,I.jsx)(on,{className:`ml-2 h-4 w-4 shrink-0 opacity-50`})]})}),(0,I.jsx)(J8,{className:`w-[320px] p-0`,align:`end`,children:(0,I.jsxs)(b5,{children:[(0,I.jsx)(x5,{placeholder:`Search tools...`}),(0,I.jsxs)(S5,{id:`tool-filter-command-list`,children:[(0,I.jsx)(C5,{children:`No tools found.`}),(0,I.jsxs)(w5,{children:[(0,I.jsx)(T5,{value:`all tools`,onSelect:()=>{u(``),f(!1)},children:`All tools`}),T.map(e=>(0,I.jsx)(T5,{value:e,onSelect:()=>{u(e),f(!1)},children:e},e))]})]})]})})]}),v===`severity`&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(W,{type:`button`,variant:`outline`,size:`sm`,className:`h-8 text-xs`,onClick:k,children:`Expand all`}),(0,I.jsx)(W,{type:`button`,variant:`outline`,size:`sm`,className:`h-8 text-xs`,onClick:O,children:`Collapse all`})]}),v===`tool`&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(W,{type:`button`,variant:`outline`,size:`sm`,className:`h-8 text-xs`,onClick:()=>D(!0),children:`Expand all`}),(0,I.jsx)(W,{type:`button`,variant:`outline`,size:`sm`,className:`h-8 text-xs`,onClick:()=>D(!1),children:`Collapse all`})]})]})]})}),v===`severity`?(0,I.jsx)(`div`,{className:`space-y-4`,children:d7.filter(e=>x.has(e)).map(e=>{let t=w[e].filter(e=>E(e.toolLabel));if(t.length===0)return null;let n=s.has(e);return(0,I.jsxs)(K,{children:[(0,I.jsx)(gv,{className:`pb-3`,children:(0,I.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(_v,{className:`text-base capitalize`,children:e}),(0,I.jsxs)(vv,{children:[t.length,` finding(s)`]})]}),(0,I.jsx)(`div`,{className:`flex gap-2`,children:(0,I.jsx)(W,{type:`button`,variant:`outline`,size:`sm`,className:`h-8 text-xs`,onClick:()=>A(e),children:n?`Expand`:`Collapse`})})]})}),!n&&(0,I.jsx)(q,{className:`space-y-2`,children:t.map((e,t)=>(0,I.jsxs)(`div`,{className:`rounded border p-2 text-xs`,children:[(0,I.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`inline-flex h-5 min-w-5 shrink-0 items-center justify-center rounded-full border bg-muted px-1 text-[10px] font-semibold text-muted-foreground`,children:t+1}),(0,I.jsx)(`span`,{className:`min-w-0 font-bold leading-tight`,children:e.issue.title})]}),(0,I.jsx)(Y,{variant:`outline`,className:`shrink-0 text-[10px] ${f7(e.issue.severity)}`,children:e.issue.severity})]}),(0,I.jsxs)(`p`,{children:[(0,I.jsx)(`span`,{className:`font-bold`,children:`Finding:`}),` `,e.issue.detail]}),(0,I.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-[11px]`,children:[(0,I.jsx)(Y,{variant:`secondary`,className:`font-normal`,children:e.sourceLabel}),(0,I.jsx)(W,{type:`button`,variant:`ghost`,size:`sm`,className:`h-6 px-2 font-mono text-[11px]`,title:e.toolLabel,onClick:()=>{C(`tool`),requestAnimationFrame(()=>{document.getElementById(e.toolAnchorId)?.scrollIntoView({behavior:`smooth`,block:`start`})})},children:e.toolDisplayName})]}),e.issue.suggestion&&(0,I.jsx)(h7,{text:e.issue.suggestion})]},e.key))})]},e)})}):(0,I.jsx)(`div`,{ref:y,className:`space-y-4`,children:e.servers.map(e=>{let t=e.tokenEstimate,n=e.tools.filter(t=>{let n=`${e.serverName}::${t.publicToolName}`;if(!E(n))return!1;let r=[...t.metadataReview?.issues??[],...t.deeperAnalysis?.sampleCalls.flatMap(e=>e.issues)??[]];return r.length===0?a.length===d7.length:r.some(e=>x.has(e.severity))});return n.length===0?null:(0,I.jsxs)(K,{children:[(0,I.jsxs)(gv,{className:`pb-3`,children:[(0,I.jsxs)(_v,{className:`flex items-center gap-2 text-base`,children:[e.serverName,(0,I.jsx)(u7,{total:t?.total,title:`Estimated tokens for the analyzed tool definitions and their schemas`})]}),(0,I.jsxs)(vv,{children:[`Discovered `,e.toolCountDiscovered,` · Showing `,n.length,` of`,` `,e.toolCountAnalyzed,` analyzed · Skipped `,e.toolCountSkipped]})]}),(0,I.jsxs)(q,{className:`space-y-3`,children:[e.warnings.length>0&&(0,I.jsxs)(R5,{children:[(0,I.jsx)(z5,{children:`Warnings`}),(0,I.jsx)(B5,{children:(0,I.jsx)(`ul`,{className:`ml-4 list-disc space-y-1`,children:e.warnings.map(t=>(0,I.jsx)(`li`,{children:t},`${e.serverName}-${t}`))})})]}),n.map(n=>{let r=t?.tools.find(e=>e.name===n.toolName),i=n.publicToolName.split(`::`).pop()??n.publicToolName,a=n7(n.classificationReason),o=n.safetyClassification===`read_only`?`read-only`:a?`write/delete`:`unsafe/unknown`,s=n.safetyClassification===`read_only`?`border-emerald-200 bg-emerald-50 text-emerald-700`:a?`border-amber-300 bg-amber-50 text-amber-800`:`border-slate-300 bg-slate-100 text-slate-700`;return(0,I.jsxs)(`details`,{id:`tool-${p7(`${e.serverName}-${n.publicToolName}`)}`,className:`group rounded-md border p-3`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer list-none`,children:(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(`div`,{className:`min-w-0 truncate font-mono text-sm`,title:n.publicToolName,children:i}),(0,I.jsx)(Qde,{label:o,reason:n.classificationReason,variantClassName:s}),(0,I.jsx)(u7,{total:r?.total,className:`text-[10px]`})]}),(0,I.jsx)(on,{className:`h-4 w-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180`})]}),n.title&&(0,I.jsx)(`p`,{className:`text-sm text-foreground/85`,children:n.title}),n.description&&(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n.description})]})}),(0,I.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,I.jsxs)(W,{type:`button`,size:`sm`,variant:`outline`,className:`h-7 px-2 text-[11px]`,onClick:()=>void m7(`Tool info`,{server:e.serverName,name:n.publicToolName,title:n.title,description:n.description}),children:[(0,I.jsx)(vn,{className:`mr-1.5 h-3.5 w-3.5`}),`Copy Tool Info`]}),(0,I.jsxs)(W,{type:`button`,size:`sm`,variant:`outline`,className:`h-7 px-2 text-[11px]`,onClick:()=>void m7(`Schemas`,{server:e.serverName,name:n.publicToolName,inputSchema:n.inputSchema,outputSchema:n.outputSchema}),disabled:n.inputSchema===void 0&&n.outputSchema===void 0,children:[(0,I.jsx)(vn,{className:`mr-1.5 h-3.5 w-3.5`}),`Copy Schemas`]}),(0,I.jsxs)(W,{type:`button`,size:`sm`,variant:`outline`,className:`h-7 px-2 text-[11px]`,onClick:()=>void m7(`Metadata review`,{server:e.serverName,name:n.publicToolName,metadataReview:n.metadataReview}),disabled:!n.metadataReview,children:[(0,I.jsx)(vn,{className:`mr-1.5 h-3.5 w-3.5`}),`Copy Metadata Review`]})]}),(0,I.jsx)(c7,{inputSchema:n.inputSchema,outputSchema:n.outputSchema,mode:h,onModeChange:g}),n.metadataReview&&(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(`div`,{className:`text-xs font-medium`,children:`Metadata review`}),n.metadataReview.issues.filter(e=>x.has(e.severity)).length===0?(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No metadata issues reported.`}):(0,I.jsx)(`div`,{className:`space-y-1`,children:n.metadataReview.issues.filter(e=>x.has(e.severity)).map((e,t)=>(0,I.jsxs)(`div`,{className:`rounded border p-2 text-xs`,children:[(0,I.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`inline-flex h-5 min-w-5 shrink-0 items-center justify-center rounded-full border bg-muted px-1 text-[10px] font-semibold text-muted-foreground`,children:t+1}),(0,I.jsx)(`span`,{className:`min-w-0 font-bold leading-tight`,children:e.title})]}),(0,I.jsx)(Y,{variant:`outline`,className:`shrink-0 text-[10px] ${f7(e.severity)}`,children:e.severity})]}),(0,I.jsxs)(`p`,{children:[(0,I.jsx)(`span`,{className:`font-bold`,children:`Finding:`}),` `,e.detail]}),e.suggestion&&(0,I.jsx)(h7,{text:e.suggestion})]},e.id))})]}),n.deeperAnalysis&&(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(`div`,{className:`text-xs font-medium`,children:`Deeper analysis`}),n.deeperAnalysis.attempted?(0,I.jsx)(`div`,{className:`space-y-2`,children:n.deeperAnalysis.sampleCalls.map(e=>(0,I.jsxs)(`div`,{className:`rounded border p-2 text-xs`,children:[(0,I.jsxs)(`div`,{className:`mb-1 flex items-center gap-2`,children:[(0,I.jsx)(Y,{variant:e.ok?`secondary`:`destructive`,className:`text-[10px]`,children:e.ok?`ok`:`error`}),(0,I.jsxs)(`span`,{children:[`Call `,e.callIndex]}),e.durationMs!==void 0&&(0,I.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.durationMs,`ms`]})]}),e.error&&(0,I.jsx)(`p`,{className:`text-destructive`,children:e.error}),e.observations.length>0&&(0,I.jsxs)(`div`,{className:`mt-2`,children:[(0,I.jsx)(`div`,{className:`mb-1 inline-flex items-center rounded-full border px-2 py-0.5 text-[10px] font-medium text-muted-foreground`,children:`Observations`}),(0,I.jsx)(`ul`,{className:`ml-4 list-disc space-y-1`,children:e.observations.map((t,r)=>(0,I.jsx)(`li`,{children:t},`${n.publicToolName}-obs-${e.callIndex}-${r}`))})]}),e.issues.filter(e=>x.has(e.severity)).length>0&&(0,I.jsx)(`div`,{className:`mt-2 space-y-1`,children:e.issues.filter(e=>x.has(e.severity)).map((t,n)=>(0,I.jsxs)(`div`,{className:`rounded border p-2`,children:[(0,I.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`inline-flex h-5 min-w-5 shrink-0 items-center justify-center rounded-full border bg-muted px-1 text-[10px] font-semibold text-muted-foreground`,children:n+1}),(0,I.jsx)(`span`,{className:`min-w-0 font-bold leading-tight`,children:t.title})]}),(0,I.jsx)(Y,{variant:`outline`,className:`shrink-0 text-[10px] ${f7(t.severity)}`,children:t.severity})]}),(0,I.jsxs)(`p`,{children:[(0,I.jsx)(`span`,{className:`font-bold`,children:`Finding:`}),` `,t.detail]}),t.suggestion&&(0,I.jsx)(h7,{text:t.suggestion})]},`${e.callIndex}-${t.id}`))})]},`${n.publicToolName}-call-${e.callIndex}`))}):(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n.deeperAnalysis.skippedReason??`Skipped`})]})]})]},n.publicToolName)})]})]},e.serverName)})})]})]})}function v7(e){return{reportId:e.reportId,createdAt:e.createdAt,tools:e.report.servers.flatMap(e=>e.tools.map(t=>({server:e.serverName,name:t.publicToolName,title:t.title,description:t.description,inputSchema:t.inputSchema,outputSchema:t.outputSchema})))}}function $de(e){let t=e.selectedToolNames?.length?new Set(e.selectedToolNames):null;return{serverName:e.serverName,tools:e.tools.filter(e=>!t||t.has(e.name)).map(e=>({name:e.name,title:e.title,description:e.description,inputSchema:e.inputSchema,outputSchema:e.outputSchema}))}}function y7(e){return e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/-+/g,`-`).replace(/^-+|-+$/g,``)}function efe(e,t){let n=[`tool-info`,y7(e)],r=t?.trim();return r&&n.push(`v${y7(r)}`),`${n.filter(Boolean).join(`-`)}.json`}function tfe(e){let t=0,n=new Set,r=new Set;for(let i of e){let e=typeof i.payload?.message==`string`?i.payload.message:``;if(!e)continue;let a=e.match(/\((\d+)\s+selected\s+of\s+\d+\s+discovered\)/i);a&&(t=Math.max(t,Number(a[1])||0));let o=e.match(/^Started\s+(.+)$/);o&&n.add(o[1]);let s=e.match(/^Finished\s+(.+)$/);s&&r.add(s[1])}let i=t>0?Math.max(0,Math.min(100,Math.round(r.size/t*100))):0;return{totalTools:t,startedTools:n.size,finishedTools:r.size,percent:i}}var b7=`mcplab.toolAnalysis.activeJobId`;function x7(e,t,n){let r=new Blob([t],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=e,a.click(),URL.revokeObjectURL(i)}async function nfe(e,t){try{await navigator.clipboard.writeText(t),O({title:`${e} copied`})}catch(t){O({title:`Could not copy ${e.toLowerCase()}`,description:t instanceof Error?t.message:String(t),variant:`destructive`})}}function S7({text:e}){return(0,I.jsxs)(_l,{children:[(0,I.jsx)(vl,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,className:`inline-flex h-4 w-4 items-center justify-center rounded text-muted-foreground hover:text-foreground`,onClick:e=>e.preventDefault(),"aria-label":e,children:(0,I.jsx)(fn,{className:`h-3.5 w-3.5`})})}),(0,I.jsx)(yl,{className:`max-w-xs text-xs`,children:(0,I.jsx)(`p`,{children:e})})]})}function rfe(e,t){let n=t.toLowerCase();return n.includes(`failed to load tools`)||n.includes(`failed to connect to mcp server`)?`Could not load tools from '${e}'. Check that the MCP server is running and reachable, then try Refresh Servers / Discover Tools again.`:t}function ife({label:e,reason:t,variantClassName:n}){return(0,I.jsx)(gl,{delayDuration:0,children:(0,I.jsxs)(_l,{children:[(0,I.jsx)(vl,{asChild:!0,children:(0,I.jsx)(Y,{variant:`outline`,className:n,children:e})}),(0,I.jsx)(yl,{className:`max-w-sm text-xs`,children:(0,I.jsx)(`p`,{children:t})})]})})}var afe=()=>{let e=e=>`tool-analysis-${Date.now()}.${e}`,{source:t}=nv(),{servers:n,agents:r,loading:i,reload:a}=hv(),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)([]),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)([]),[m,h]=(0,_.useState)({}),[g,v]=(0,_.useState)(``),[y,b]=(0,_.useState)(!0),[x,S]=(0,_.useState)(!1),[C,w]=(0,_.useState)(2),[T,E]=(0,_.useState)(1),[D,k]=(0,_.useState)(1e4),[A,j]=(0,_.useState)(null),[M,N]=(0,_.useState)([]),[P,F]=(0,_.useState)(null),[L,R]=(0,_.useState)(null),[z,ee]=(0,_.useState)(!1),[te,ne]=(0,_.useState)(`configure`),[re,ie]=(0,_.useState)(`explorer`),[ae,oe]=(0,_.useState)(`idle`),[se,ce]=(0,_.useState)(!1),B=(0,_.useRef)(null),le=(0,_.useRef)(null),ue=o||r[0]?.name||``,de=(0,_.useMemo)(()=>tfe(M),[M]);(0,_.useEffect)(()=>{let e=!0;return t.getWorkspaceSettings().then(t=>{e&&t&&s(t.assistantAgentName??``)}).catch(()=>{e&&s(``)}),()=>{e=!1}},[t]),(0,_.useEffect)(()=>()=>{B.current?.()},[]),(0,_.useEffect)(()=>{let e=le.current;e&&requestAnimationFrame(()=>{e.scrollTop=e.scrollHeight})},[M.length]);let V=()=>{try{sessionStorage.removeItem(b7)}catch{}},fe=e=>{try{sessionStorage.setItem(b7,e)}catch{}},pe=e=>{B.current?.(),B.current=t.subscribeToolAnalysisJob(e,n=>{if(N(e=>[...e,n]),n.type===`completed`)t.getToolAnalysisResult(e).then(e=>{F(e.report),R(e.savedReportId??null)}).catch(e=>O({title:`Could not load analysis report`,description:e instanceof Error?e.message:String(e),variant:`destructive`})).finally(()=>{V(),j(null),ee(!1),oe(`idle`),ne(`run`)});else if(n.type===`error`){let e=String(n.payload?.message??``);V(),oe(e.toLowerCase().includes(`abort`)?`stopped`:`error`),j(null),ee(!1)}})};(0,_.useEffect)(()=>{if(A||P)return;let e=``;try{e=sessionStorage.getItem(b7)??``}catch{e=``}if(e)return ne(`run`),oe(`running`),ee(!0),j(e),N([]),pe(e),()=>{}},[t,A,P]);let me=async()=>{if(c.length===0){p([]),h({});return}let e=c.filter(e=>n.find(t=>t.id===e)?.authType===`oauth2`);try{e.length>0&&(ce(!0),await e6({serverNames:e,source:t,onServerAuthStart:e=>{O({title:`OAuth login required for ${e}`,description:`Complete login in the opened browser tab. Discovery will continue automatically.`})}}))}catch(e){O({title:`OAuth login failed`,description:e instanceof Error?e.message:String(e),variant:`destructive`}),ce(!1);return}finally{ce(!1)}d(!0);try{let e=await t.discoverToolsForAnalysis({serverNames:c});p(e.servers),h(t=>{let n={};for(let r of e.servers){let e=t[r.serverName]??[],i=r.tools.map(e=>e.name),a=e.filter(e=>i.includes(e));n[r.serverName]=a.length>0?a:i}return n})}catch(e){O({title:`Could not discover MCP tools`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{d(!1)}};(0,_.useEffect)(()=>{me()},[c.join(`|`)]);let he=(0,_.useMemo)(()=>{let e=g.trim().toLowerCase();return e?f.map(t=>({...t,tools:t.tools.filter(t=>t.name.toLowerCase().includes(e)||(t.description||``).toLowerCase().includes(e))})).filter(e=>e.tools.length>0):f},[f,g]),ge=(0,_.useMemo)(()=>Object.values(m).reduce((e,t)=>e+t.length,0),[m]),_e=(0,_.useMemo)(()=>Xde(f,m),[f,m]),ve=c[0]??``,ye=async()=>{if(!y&&!x)O({title:`Select at least one mode`,variant:`destructive`});else if(c.length!==1)O({title:`Select exactly one server`,variant:`destructive`});else if(ge===0)O({title:`Select at least one tool`,variant:`destructive`});else{ee(!0),N([]),F(null),R(null),ne(`run`),oe(`running`);try{let e=c[0];n.find(t=>t.id===e)?.authType===`oauth2`&&(ce(!0),await e6({serverNames:[e],source:t,onServerAuthStart:e=>{O({title:`OAuth login required for ${e}`,description:`Complete login in the opened browser tab. Analysis will continue automatically.`})}}));let{jobId:r}=await t.startToolAnalysis({serverNames:c,selectedToolsByServer:m,maxParallelTools:C,modes:{metadataReview:y,deeperAnalysis:x},deeperAnalysisOptions:{autoRunPolicy:`read_only_allowlist`,sampleCallsPerTool:T,toolCallTimeoutMs:D}});j(r),fe(r),pe(r)}catch(e){ee(!1),oe(`error`),ne(`run`),O({title:`Could not start tool analysis`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{ce(!1)}}},be=()=>{let e=c[0],t=f.find(t=>t.serverName===e);if(!e||!t){O({title:`No discovered tool info available`,description:`Select a server and discover tools before downloading tool info.`,variant:`destructive`});return}let n=$de({serverName:t.serverName,tools:t.tools,selectedToolNames:m[t.serverName]});x7(efe(t.serverName,t.mcpServerVersion),`${JSON.stringify(n,null,2)}\n`,`application/json`)},xe=async()=>{if(!A)return;let e=A;try{let n=await t.stopToolAnalysis(e);if(n.status===`completed`){B.current?.(),B.current=null;let n=await t.getToolAnalysisResult(e);F(n.report),R(n.savedReportId??null),V(),j(null),ee(!1),oe(`idle`),ne(`run`),O({title:`Analysis already finished`,description:`Showing the result overview.`});return}if(n.status===`stopped`){B.current?.(),B.current=null,V(),j(null),ee(!1),oe(`stopped`),O({title:`Analysis stopped`});return}if(n.status===`error`){B.current?.(),B.current=null,V(),j(null),ee(!1),oe(`error`),O({title:`Analysis already ended with an error`,description:`Review the progress log and return to Configure Analysis.`});return}O({title:`Stopping analysis...`})}catch(e){O({title:`Could not stop analysis`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}},Se=()=>{ne(`configure`),oe(`idle`),j(null)},Ce=(e,t)=>{l(n=>t?[e]:n.filter(t=>t!==e))},we=(e,t,n)=>{h(r=>{let i=new Set(r[e]??[]);return n?i.add(t):i.delete(t),{...r,[e]:Array.from(i)}})},Te=(e,t)=>{h(n=>({...n,[e]:t}))},Ee=A!==null||M.length>0||ae===`stopped`||ae===`error`,De=!!P,Oe=e=>{e===`configure`?ne(`configure`):e===`run`&&Ee?ne(`run`):e===`report`&&De&&ne(`report`)};return(0,I.jsxs)(`div`,{className:`space-y-6`,children:[(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`h1`,{className:`inline-flex items-center gap-2 text-2xl font-bold`,children:[(0,I.jsx)(Bn,{className:`h-6 w-6`}),`Analyze MCP Tools`]}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Review MCP tools for schema quality, ergonomics, and agent/eval readiness.`})]}),(0,I.jsxs)(`div`,{className:`hidden flex-wrap items-center gap-2 md:flex`,children:[(0,I.jsx)(`button`,{type:`button`,onClick:()=>Oe(`configure`),className:`rounded-full`,"aria-label":`Open Configure Analysis`,children:(0,I.jsx)(Y,{variant:te===`configure`?`default`:`outline-solid`,className:`cursor-pointer`,children:`Configure Analysis`})}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>Oe(`run`),disabled:!Ee,className:`rounded-full disabled:cursor-not-allowed disabled:opacity-60`,"aria-label":`Open Run Analysis`,children:(0,I.jsx)(Y,{variant:te===`run`?`default`:`outline-solid`,className:Ee?`cursor-pointer`:`cursor-not-allowed`,children:`Run Analysis`})}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>Oe(`report`),disabled:!De,className:`rounded-full disabled:cursor-not-allowed disabled:opacity-60`,"aria-label":`Open Report`,children:(0,I.jsx)(Y,{variant:te===`report`?`default`:`outline-solid`,className:De?`cursor-pointer`:`cursor-not-allowed`,children:`Report`})})]})]}),te===`configure`&&(0,I.jsxs)(K,{children:[(0,I.jsxs)(gv,{children:[(0,I.jsx)(_v,{className:`text-base`,children:`Run MCP analysis`}),(0,I.jsx)(vv,{children:`Select servers and tools, choose metadata review and/or deeper sample-call analysis, then run the report.`})]}),(0,I.jsxs)(q,{className:`space-y-5`,children:[!ue&&(0,I.jsxs)(R5,{children:[(0,I.jsx)(z5,{children:`No assistant agent available`}),(0,I.jsxs)(B5,{children:[`Add a library agent in`,` `,(0,I.jsx)(np,{to:`/libraries/agents`,className:`underline`,children:`Agents`}),` `,`and optionally set the default Assistant Agent in`,` `,(0,I.jsx)(np,{to:`/settings`,className:`underline`,children:`Settings`}),`.`]})]}),(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsx)(Q,{className:`text-xs`,children:`Servers`}),(0,I.jsxs)(W,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>void a(),disabled:i||se,children:[(0,I.jsx)(Qn,{className:`mr-2 h-4 w-4`}),`Refresh Servers`]})]}),(0,I.jsx)(`div`,{className:`grid gap-2 rounded-md border p-3 md:grid-cols-2`,children:n.length===0?(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No library servers configured.`}):n.map(e=>{let t=c.includes(e.id);return(0,I.jsxs)(`label`,{className:`flex items-start gap-2 rounded-md border p-2 text-sm`,children:[(0,I.jsx)(KX,{checked:t,onCheckedChange:t=>Ce(e.id,!!t)}),(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`div`,{className:`font-medium`,children:e.name||e.id}),e.url&&(0,I.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.url})]})]},e.id)})}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Select exactly one MCP server for analysis.`})]}),(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(Q,{className:`text-xs`,children:`Filter visible tools`}),(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(er,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,I.jsx)(Op,{className:`h-9 pl-8`,placeholder:`Filter tools by name or description...`,value:g,onChange:e=>v(e.target.value)})]}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Filtering only changes what is shown; selected tools remain selected.`})]}),(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsx)(Q,{className:`text-xs`,children:ve?`Tools for ${ve}`:`Tools`}),(0,I.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,I.jsxs)(W,{type:`button`,size:`sm`,variant:`outline`,onClick:be,disabled:u||se||c.length===0||f.length===0,children:[(0,I.jsx)(yn,{className:`mr-2 h-4 w-4`}),`Download Tool Info`]}),(0,I.jsxs)(W,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>void me(),disabled:u||se||c.length===0,children:[u&&(0,I.jsx)(zn,{className:`mr-2 h-4 w-4 animate-spin`}),`Discover Tools`]})]})]}),(0,I.jsx)(`div`,{className:`space-y-3 rounded-md border p-3`,children:c.length===0?(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Select a server to discover tools.`}):u&&f.length===0?(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading tools...`}):he.length===0&&!u?(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No discovered tools match the current filters.`}):he.map(e=>{let t=new Set(m[e.serverName]??[]);return(0,I.jsxs)(`div`,{className:`rounded-md border p-3`,children:[(0,I.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(`div`,{className:`font-medium`,children:e.serverName}),(0,I.jsx)(u7,{total:e.tokenEstimate?.total,title:`Estimated tokens for all discovered tool definitions and their schemas`})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsxs)(W,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>void nfe(`Tool list`,`${JSON.stringify({server:e.serverName,tools:e.tools.map(e=>({name:e.name,title:e.title,description:e.description}))},null,2)}\n`),children:[(0,I.jsx)(vn,{className:`mr-1.5 h-3.5 w-3.5`}),`Copy`]}),(0,I.jsx)(W,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>Te(e.serverName,e.tools.map(e=>e.name)),children:`Select all`}),(0,I.jsx)(W,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>Te(e.serverName,[]),children:`Clear`})]})]}),e.warnings.length>0&&(0,I.jsx)(`div`,{className:`mb-2 space-y-1`,children:e.warnings.map(t=>(0,I.jsx)(`div`,{className:`text-xs text-amber-700`,children:rfe(e.serverName,t)},`${e.serverName}-${t}`))}),(0,I.jsx)(`div`,{className:`grid gap-2`,children:e.tools.map(n=>{let r=e.tokenEstimate?.tools.find(e=>e.name===n.name),i=n7(n.classificationReason),a=n.safetyClassification===`read_only`?`read-only`:i?`write/delete`:`unsafe/unknown`,o=n.safetyClassification===`read_only`?`border-emerald-200 bg-emerald-50 text-emerald-700`:i?`border-amber-300 bg-amber-50 text-amber-800`:`border-slate-300 bg-slate-100 text-slate-700`;return(0,I.jsxs)(`label`,{className:`flex items-start gap-2 rounded border p-2`,children:[(0,I.jsx)(KX,{checked:t.has(n.name),onCheckedChange:t=>we(e.serverName,n.name,!!t)}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,I.jsx)(`span`,{className:`font-mono text-xs`,children:n.name}),n.title&&(0,I.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.title}),(0,I.jsx)(ife,{label:a,reason:n.classificationReason,variantClassName:o}),n.inputSchema&&(0,I.jsx)(Y,{variant:`outline`,className:`border-border text-[10px] text-muted-foreground`,children:`schema: input`}),n.outputSchema&&(0,I.jsx)(Y,{variant:`outline`,className:`border-border text-[10px] text-muted-foreground`,children:`schema: output`}),(0,I.jsx)(u7,{total:r?.total,className:`text-[10px]`})]}),n.description&&(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground line-clamp-2`,children:n.description}),(0,I.jsx)(c7,{inputSchema:n.inputSchema,outputSchema:n.outputSchema,mode:re,onModeChange:ie})]})]},`${e.serverName}-${n.name}`)})})]},e.serverName)})}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Selected tools: `,ge,_e!==void 0&&` · estimated context: ~${l7(_e)} tokens`]})]}),(0,I.jsxs)(`div`,{className:`space-y-3 rounded-md border p-3`,children:[(0,I.jsx)(`div`,{className:`text-sm font-medium`,children:`Analysis Modes`}),(0,I.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,I.jsx)(KX,{checked:y,onCheckedChange:e=>b(!!e)}),(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[`Metadata / schema review`,(0,I.jsx)(S7,{text:`No tool execution. Reviews tool names, descriptions, and schemas only.`})]})]}),(0,I.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,I.jsx)(KX,{checked:x,onCheckedChange:e=>S(!!e)}),(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[`Deeper analysis`,(0,I.jsx)(S7,{text:`Runs sample MCP tool calls automatically for read-only tools only (based on the safety allowlist).`})]})]}),(0,I.jsxs)(`div`,{className:`grid gap-3 rounded-md border bg-muted/20 p-3 md:grid-cols-3`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(Q,{className:`text-xs`,children:`Max parallel tools`}),(0,I.jsx)(Op,{type:`number`,min:1,max:8,value:C,onChange:e=>w(Math.max(1,Math.min(8,Number(e.target.value)||2))),className:`h-8`})]}),x?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(Q,{className:`text-xs`,children:`Safety profile`}),(0,I.jsx)(`div`,{className:`text-sm`,children:`Read-only allowlist only`})]}),(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(Q,{className:`text-xs`,children:`Sample calls per tool`}),(0,I.jsx)(Op,{type:`number`,min:1,max:5,value:T,onChange:e=>E(Math.max(1,Math.min(5,Number(e.target.value)||1))),className:`h-8`})]}),(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(Q,{className:`text-xs`,children:`Tool call timeout (ms)`}),(0,I.jsx)(Op,{type:`number`,min:1e3,max:6e4,step:500,value:D,onChange:e=>k(Math.max(1e3,Math.min(6e4,Number(e.target.value)||1e4))),className:`h-8`})]}),(0,I.jsx)(`div`,{className:`md:col-span-3 text-xs text-amber-700`,children:`Deeper analysis may execute read-only MCP tools automatically.`})]}):null]})]}),(0,I.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,I.jsxs)(W,{type:`button`,onClick:()=>void ye(),disabled:z||se||!!A,children:[(z||!!A)&&(0,I.jsx)(zn,{className:`mr-2 h-4 w-4 animate-spin`}),`Analyze Tools`]})})]})]}),te===`run`&&(0,I.jsxs)(K,{children:[(0,I.jsx)(gv,{className:`pb-3`,children:(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(_v,{className:`flex items-center gap-2 text-base`,children:(0,I.jsx)(`span`,{children:`Progress`})}),(0,I.jsx)(vv,{children:A?`Live tool-analysis job events:`:P?`Analysis finished. Review the summary below or open the saved report details.`:ae===`stopped`?`Analysis was stopped. You can return to Configure Analysis.`:ae===`error`?`Analysis ended with an error. Review the log and go back to Configure Analysis.`:`Analysis finished.`})]}),A?(0,I.jsx)(W,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>void xe(),children:`Stop Analysis`}):(0,I.jsx)(W,{type:`button`,size:`sm`,variant:`outline`,onClick:Se,children:`Back to Configure Analysis`})]})}),(0,I.jsxs)(q,{className:`space-y-2`,children:[A&&(0,I.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-md border bg-muted/20 px-2.5 py-1 text-xs text-muted-foreground`,children:[(0,I.jsx)(zn,{className:`h-3.5 w-3.5 animate-spin`}),`Analysis is still running...`]}),(de.totalTools>0||A)&&(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,I.jsx)(`span`,{children:de.totalTools>0?`${de.finishedTools}/${de.totalTools} tools finished`:`Preparing analysis...`}),(0,I.jsx)(`span`,{children:de.totalTools>0?`${de.percent}%`:`0%`})]}),(0,I.jsx)(t7,{value:de.totalTools>0?de.percent:0,className:`h-2`})]}),M.length===0?(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:A?`Starting analysis...`:`No progress events captured.`}):(0,I.jsx)(`div`,{ref:le,className:`max-h-64 space-y-1 overflow-auto rounded border bg-muted/20 p-2`,children:M.map((e,t)=>(0,I.jsxs)(`div`,{className:`text-xs`,children:[(0,I.jsx)(`span`,{className:`mr-2 font-mono text-muted-foreground`,children:new Date(e.ts).toLocaleTimeString()}),(0,I.jsx)(Y,{variant:`outline`,className:`mr-2 text-[10px]`,children:e.type}),(0,I.jsx)(`span`,{className:`break-all`,children:typeof e.payload.message==`string`?e.payload.message:JSON.stringify(e.payload)})]},`${e.ts}-${t}`))}),!A&&P&&(0,I.jsx)(K,{className:`mt-2 border-green-200 bg-green-50/40 dark:border-green-900/40 dark:bg-green-950/10`,children:(0,I.jsxs)(q,{className:`pt-4 space-y-3`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`text-sm font-semibold`,children:`Result overview`}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[P.summary.toolsAnalyzed,` tools analyzed, `,P.summary.toolsSkipped,` `,`skipped, across `,P.summary.serversAnalyzed,` server`,P.summary.serversAnalyzed===1?``:`s`,`.`]})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[L&&(0,I.jsx)(W,{asChild:!0,size:`sm`,children:(0,I.jsx)(np,{to:`/tool-analysis-results/${L}`,children:`Open result details`})}),(0,I.jsx)(W,{asChild:!0,size:`sm`,variant:`outline`,children:(0,I.jsx)(np,{to:`/tool-analysis-results`,children:`View all results`})}),(0,I.jsx)(W,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>Oe(`report`),children:`View inline report`})]})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[P.summary.issueCounts.critical>0&&(0,I.jsxs)(Y,{className:`bg-red-600 text-white hover:bg-red-600`,children:[`Critical: `,P.summary.issueCounts.critical]}),P.summary.issueCounts.high>0&&(0,I.jsxs)(Y,{className:`bg-orange-500 text-white hover:bg-orange-500`,children:[`High: `,P.summary.issueCounts.high]}),P.summary.issueCounts.medium>0&&(0,I.jsxs)(Y,{className:`bg-amber-500 text-white hover:bg-amber-500`,children:[`Medium: `,P.summary.issueCounts.medium]}),P.summary.issueCounts.low>0&&(0,I.jsxs)(Y,{className:`bg-blue-500 text-white hover:bg-blue-500`,children:[`Low: `,P.summary.issueCounts.low]}),P.summary.issueCounts.info>0&&(0,I.jsxs)(Y,{variant:`outline`,children:[`Info: `,P.summary.issueCounts.info]}),Object.values(P.summary.issueCounts).every(e=>e===0)&&(0,I.jsx)(Y,{className:`bg-green-600 text-white hover:bg-green-600`,children:`No findings`})]})]})})]})]}),te===`report`&&P&&(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Report`}),(0,I.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[P.summary.toolsAnalyzed,` tools analyzed across`,` `,P.summary.serversAnalyzed,` server`,P.summary.serversAnalyzed===1?``:`s`,`.`]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(W,{type:`button`,size:`sm`,variant:`outline`,onClick:Se,children:`Back to Configure Analysis`}),L&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(W,{asChild:!0,type:`button`,size:`sm`,variant:`outline`,children:(0,I.jsx)(np,{to:`/tool-analysis-results/${L}`,children:`Open saved report`})}),(0,I.jsx)(W,{asChild:!0,type:`button`,size:`sm`,variant:`outline`,children:(0,I.jsx)(np,{to:`/tool-analysis-results`,children:`View all reports`})})]}),(0,I.jsxs)(W,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>x7(e(`json`),`${JSON.stringify(P,null,2)}\n`,`application/json`),children:[(0,I.jsx)(yn,{className:`mr-2 h-4 w-4`}),`Export JSON`]}),(0,I.jsxs)(W,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>x7(e(`md`),g7(P),`text/markdown`),children:[(0,I.jsx)(yn,{className:`mr-2 h-4 w-4`}),`Export Markdown`]})]})]}),(0,I.jsx)(_7,{report:P,schemaMode:re,onSchemaModeChange:ie})]})]})};function C7({versions:e,showPrefix:t=!0,className:n}){let r=Object.entries(e??{}).sort((e,t)=>e[0].localeCompare(t[0])).map(([e,t])=>`${e}@${t??`unknown`}`).join(`, `);return r?(0,I.jsx)(gl,{delayDuration:0,children:(0,I.jsxs)(_l,{children:[(0,I.jsx)(vl,{asChild:!0,children:(0,I.jsxs)(`span`,{tabIndex:0,className:U(`inline-flex max-w-[18rem] min-w-0 items-center rounded-sm border border-border/60 bg-muted/30 px-1.5 py-1 text-[11px] leading-none text-muted-foreground`,n),children:[t?(0,I.jsx)(`span`,{className:`font-medium`,children:`MCP:`}):null,(0,I.jsx)(`span`,{className:U(t?`ml-1`:``,`min-w-0 truncate font-mono`),children:r})]})}),(0,I.jsx)(yl,{className:`max-w-md wrap-break-word text-xs`,children:(0,I.jsx)(`span`,{className:`font-mono`,children:r})})]})}):null}function w7(e){let[t,n]=(0,_.useState)(0),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(0),s=(0,_.useCallback)(()=>{n(t=>Math.max(0,t-e))},[e]),c=(0,_.useCallback)(()=>{n(t=>t+e)},[e]),l=(0,_.useCallback)(()=>n(0),[]),u=(0,_.useCallback)(e=>{i(e.has_more),o(e.total_count)},[]),d=(0,_.useCallback)(e=>a<=0||e<=0?`Showing 0 of 0`:`Showing ${t+1}-${Math.min(t+e,a)} of ${a}`,[t,a]);return(0,_.useMemo)(()=>({limit:e,offset:t,hasMore:r,totalCount:a,setOffset:n,setHasMore:i,setTotalCount:o,prev:s,next:c,reset:l,updateMeta:u,rangeLabel:d}),[r,e,c,t,s,d,l,a,u])}function T7(e,t,n){let r=new Blob([t],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=e,a.click(),URL.revokeObjectURL(i)}function ofe(){let{source:e}=nv(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(`all`),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)([]),h=w7(100),{offset:g,hasMore:v}=h,y=async()=>{i(!0);try{if(e.listToolAnalysisResultsPage){let t=await e.listToolAnalysisResultsPage({limit:100,offset:g,server:l===`all`?void 0:l});n(t.data),h.updateMeta(t)}else n(await e.listToolAnalysisResults({limit:100,offset:g,server:l===`all`?void 0:l}))}catch(e){O({title:`Could not load tool analysis results`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{i(!1)}};(0,_.useEffect)(()=>{y()},[g,l]),(0,_.useEffect)(()=>{e.listToolAnalysisServers&&e.listToolAnalysisServers().then(e=>m(e)).catch(()=>{m([])})},[e]),(0,_.useEffect)(()=>{e.listToolAnalysisServers||m(Array.from(new Set(t.flatMap(e=>e.serverNames))).sort((e,t)=>e.localeCompare(t)))},[t,e]),(0,_.useEffect)(()=>{h.reset()},[h.reset,l]);let b=(0,_.useMemo)(()=>t.find(e=>e.reportId===a)??null,[t,a]),x=async()=>{if(a){c(!0);try{await e.deleteToolAnalysisSavedResult(a),n(e=>e.filter(e=>e.reportId!==a)),O({title:`Tool analysis report deleted`}),o(null)}catch(e){O({title:`Could not delete report`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{c(!1)}}},S=async(t,n)=>{try{let r=await e.getToolAnalysisSavedResult(t);n===`json`?T7(`${t}.json`,`${JSON.stringify(r,null,2)}\n`,`application/json`):n===`tool_schemas`?T7(`${t}-tool-schemas.json`,`${JSON.stringify(v7(r),null,2)}\n`,`application/json`):T7(`${t}.md`,g7(r.report),`text/markdown`)}catch(e){O({title:`Could not export saved report`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}};return(0,I.jsxs)(`div`,{className:`space-y-6`,children:[(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`h1`,{className:`inline-flex items-center gap-2 text-2xl font-bold`,children:[(0,I.jsx)(Hn,{className:`h-6 w-6`}),`Tool Analysis Results`]}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Browse persisted Analyze MCP Tools reports.`})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`MCP server`}),(0,I.jsxs)(K8,{open:d,onOpenChange:f,children:[(0,I.jsx)(q8,{asChild:!0,children:(0,I.jsxs)(W,{type:`button`,variant:`outline`,role:`combobox`,"aria-expanded":d,"aria-controls":`tool-analysis-server-command-list`,className:`h-9 w-[240px] justify-between font-normal ${l===`all`?``:`border-primary/40`}`,children:[(0,I.jsx)(`span`,{className:`truncate text-left`,children:l===`all`?`All servers`:l}),(0,I.jsx)(on,{className:`ml-2 h-4 w-4 shrink-0 opacity-50`})]})}),(0,I.jsx)(J8,{className:`w-[240px] p-0`,align:`start`,children:(0,I.jsxs)(b5,{children:[(0,I.jsx)(x5,{placeholder:`Search MCP servers...`}),(0,I.jsxs)(S5,{id:`tool-analysis-server-command-list`,children:[(0,I.jsx)(C5,{children:`No servers found.`}),(0,I.jsxs)(w5,{children:[(0,I.jsx)(T5,{value:`all servers`,onSelect:()=>{u(`all`),f(!1)},children:`All servers`}),p.map(e=>(0,I.jsx)(T5,{value:e,onSelect:()=>{u(e),f(!1)},children:e},e))]})]})]})})]})]}),(0,I.jsx)(W,{variant:`outline`,onClick:()=>void y(),disabled:r,children:r?`Refreshing...`:`Refresh`}),(0,I.jsx)(W,{variant:`outline`,onClick:h.prev,disabled:r||g===0,children:`Prev`}),(0,I.jsx)(W,{variant:`outline`,onClick:h.next,disabled:r||!v,children:`Next`}),(0,I.jsx)(W,{asChild:!0,variant:`outline`,children:(0,I.jsx)(np,{to:`/tool-analysis`,children:`Analyze MCP Tools`})})]})]}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:h.rangeLabel(t.length)}),(0,I.jsx)(K,{children:(0,I.jsx)(q,{className:`p-0`,children:r?(0,I.jsx)(`p`,{className:`p-6 text-sm text-muted-foreground`,children:`Loading tool analysis results...`}):t.length===0?(0,I.jsx)(`p`,{className:`p-6 text-sm text-muted-foreground`,children:`No saved tool analysis reports yet.`}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`border-b px-4 py-3`,children:(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Showing `,(0,I.jsx)(`span`,{className:`font-medium text-foreground`,children:t.length}),` `,`reports`]})}),t.length===0?(0,I.jsx)(`p`,{className:`p-6 text-sm text-muted-foreground`,children:`No reports for the selected MCP server.`}):(0,I.jsxs)(bv,{children:[(0,I.jsx)(xv,{children:(0,I.jsxs)(wv,{children:[(0,I.jsx)(Tv,{children:`Report ID`}),(0,I.jsx)(Tv,{children:`Evaluated`}),(0,I.jsx)(Tv,{children:`Timestamp`}),(0,I.jsx)(Tv,{children:`Issues`}),(0,I.jsx)(Tv,{children:`Modes`}),(0,I.jsx)(Tv,{className:`w-10`})]})}),(0,I.jsx)(Sv,{children:t.map(e=>(0,I.jsxs)(wv,{children:[(0,I.jsx)(J,{children:(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(np,{to:`/tool-analysis-results/${e.reportId}`,className:`font-mono text-xs text-primary hover:underline`,children:e.reportId}),(0,I.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:e.assistantAgentName})]})}),(0,I.jsx)(J,{className:`text-[11px] text-muted-foreground`,children:(0,I.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,I.jsxs)(`div`,{children:[`Servers:`,` `,(0,I.jsx)(`span`,{className:`font-medium text-foreground`,children:e.serverNames.length}),` `,`· Tools:`,` `,(0,I.jsx)(`span`,{className:`font-medium text-foreground`,children:e.summary.toolsAnalyzed}),` · `,`Skipped:`,` `,(0,I.jsx)(`span`,{className:`font-medium text-foreground`,children:e.summary.toolsSkipped})]}),Object.keys(e.mcpServerVersions??{}).length>0?(0,I.jsx)(C7,{versions:e.mcpServerVersions,showPrefix:!1}):(0,I.jsxs)(`div`,{className:`font-mono text-xs text-foreground/80`,children:[e.serverNames.slice(0,2).join(`, `),e.serverNames.length>2?` +${e.serverNames.length-2}`:``]})]})}),(0,I.jsx)(J,{className:`text-xs text-muted-foreground`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,I.jsx)(_n,{className:`h-3 w-3`}),new Date(e.createdAt).toLocaleString()]})}),(0,I.jsx)(J,{children:(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[[`critical`,`high`,`medium`,`low`,`info`].map(t=>e.summary.issueCounts[t]>0?(0,I.jsxs)(Y,{variant:`outline`,className:`capitalize`,children:[t,`: `,e.summary.issueCounts[t]]},`${e.reportId}-${t}`):null),Object.values(e.summary.issueCounts).every(e=>e===0)&&(0,I.jsx)(Y,{variant:`outline`,children:`No issues`})]})}),(0,I.jsx)(J,{children:(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[e.modes.metadataReview&&(0,I.jsx)(Y,{variant:`outline`,children:`metadata`}),e.modes.deeperAnalysis&&(0,I.jsx)(Y,{variant:`outline`,children:`deeper`})]})}),(0,I.jsx)(J,{children:(0,I.jsxs)(Rq,{children:[(0,I.jsx)(zq,{asChild:!0,children:(0,I.jsx)(W,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,children:(0,I.jsx)(xn,{className:`h-4 w-4`})})}),(0,I.jsxs)(Hq,{align:`end`,children:[(0,I.jsx)(Uq,{asChild:!0,children:(0,I.jsx)(np,{to:`/tool-analysis-results/${e.reportId}`,children:`View`})}),(0,I.jsxs)(Uq,{onSelect:()=>void S(e.reportId,`json`),children:[(0,I.jsx)(yn,{className:`mr-2 h-3.5 w-3.5`}),` Export JSON`]}),(0,I.jsxs)(Uq,{onSelect:()=>void S(e.reportId,`markdown`),children:[(0,I.jsx)(yn,{className:`mr-2 h-3.5 w-3.5`}),` Export Markdown`]}),(0,I.jsxs)(Uq,{className:`text-destructive`,onSelect:t=>{t.preventDefault(),o(e.reportId)},children:[(0,I.jsx)(lr,{className:`mr-2 h-3.5 w-3.5`}),` Delete`]}),(0,I.jsxs)(Uq,{onSelect:()=>void S(e.reportId,`tool_schemas`),children:[(0,I.jsx)(yn,{className:`mr-2 h-3.5 w-3.5`}),` Export MCP Info`]})]})]})})]},e.reportId))})]})]})})}),(0,I.jsx)(X6,{open:!!a,onOpenChange:e=>!e&&o(null),children:(0,I.jsxs)(Q6,{children:[(0,I.jsxs)($6,{children:[(0,I.jsx)(t8,{children:`Delete tool analysis report?`}),(0,I.jsx)(n8,{children:b?`Delete saved report '${b.reportId}' from disk? This cannot be undone.`:`Delete this saved report from disk? This cannot be undone.`})]}),(0,I.jsxs)(e8,{children:[(0,I.jsx)(i8,{disabled:s,children:`Cancel`}),(0,I.jsx)(r8,{onClick:e=>{e.preventDefault(),x()},disabled:s,children:s?`Deleting...`:`Delete`})]})]})})]})}function E7(e,t,n){let r=new Blob([t],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=e,a.click(),URL.revokeObjectURL(i)}function sfe(){let{id:e=``}=Zd(),t=qd(),{source:n}=nv(),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(!0),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(!1);(0,_.useEffect)(()=>{let t=!0;return o(!0),c(!1),n.getToolAnalysisSavedResult(e).then(e=>{t&&i(e)}).catch(e=>{if(!t)return;let n=e instanceof Error?e.message:String(e);n.includes(`(404)`)?(c(!0),i(null)):O({title:`Could not load saved tool analysis report`,description:n,variant:`destructive`})}).finally(()=>{t&&o(!1)}),()=>{t=!1}},[e,n]);let p=async()=>{f(!0);try{await n.deleteToolAnalysisSavedResult(e),O({title:`Tool analysis report deleted`}),t(`/tool-analysis-results`)}catch(e){O({title:`Could not delete report`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{f(!1),u(!1)}};return a?(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading saved tool analysis report...`}):s||!r?(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Tool Analysis Result`}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Saved report not found.`}),(0,I.jsx)(W,{asChild:!0,variant:`outline`,children:(0,I.jsx)(np,{to:`/tool-analysis-results`,children:`Back to Tool Analysis Results`})})]}):(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h1`,{className:`font-mono text-xl font-semibold`,children:r.reportId}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1 align-middle`,children:[(0,I.jsx)(_n,{className:`h-3 w-3 shrink-0`}),new Date(r.createdAt).toLocaleString()]}),` `,`·`,` `,[r.report.assistantAgentProvider?OX(r.report.assistantAgentProvider):null,r.report.assistantAgentModel].filter(Boolean).join(` · `)||r.serverNames.join(`, `)||`—`]})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(C7,{versions:r.report.mcpServerVersions}),(0,I.jsx)(W,{asChild:!0,size:`sm`,variant:`outline`,children:(0,I.jsx)(np,{to:`/tool-analysis-results`,children:`Back to results`})}),(0,I.jsxs)(W,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>E7(`${r.reportId}.json`,`${JSON.stringify(r,null,2)}\n`,`application/json`),children:[(0,I.jsx)(yn,{className:`mr-2 h-4 w-4`}),`Export JSON`]}),(0,I.jsxs)(W,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>E7(`${r.reportId}.md`,g7(r.report),`text/markdown`),children:[(0,I.jsx)(yn,{className:`mr-2 h-4 w-4`}),`Export Markdown`]}),(0,I.jsxs)(W,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>E7(`${r.reportId}-tool-schemas.json`,`${JSON.stringify(v7(r),null,2)}\n`,`application/json`),children:[(0,I.jsx)(yn,{className:`mr-2 h-4 w-4`}),`Export MCP info`]}),(0,I.jsxs)(W,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>u(!0),children:[(0,I.jsx)(lr,{className:`mr-2 h-4 w-4`}),`Delete`]})]})]}),(0,I.jsx)(_7,{report:r.report}),(0,I.jsx)(X6,{open:l,onOpenChange:u,children:(0,I.jsxs)(Q6,{children:[(0,I.jsxs)($6,{children:[(0,I.jsx)(t8,{children:`Delete tool analysis report?`}),(0,I.jsxs)(n8,{children:[`Delete saved report '`,r.reportId,`' from disk? This cannot be undone.`]})]}),(0,I.jsxs)(e8,{children:[(0,I.jsx)(i8,{disabled:d,children:`Cancel`}),(0,I.jsx)(r8,{onClick:e=>{e.preventDefault(),p()},disabled:d,children:d?`Deleting...`:`Delete`})]})]})})]})}var cfe=[{id:`configure`,label:`Configure Debug Session`},{id:`run`,label:`Run / Inspect Flow`},{id:`report`,label:`Report / Export`}],lfe=`resolve_target_metadata`,ufe=`token_exchange`,dfe=`resource_probe`;function D7({text:e}){return(0,I.jsx)(gl,{delayDuration:200,children:(0,I.jsxs)(_l,{children:[(0,I.jsx)(vl,{type:`button`,className:`inline-flex shrink-0 items-center`,onClick:e=>e.preventDefault(),children:(0,I.jsx)(Nn,{className:`h-3.5 w-3.5 text-muted-foreground/50 hover:text-muted-foreground`})}),(0,I.jsx)(yl,{className:`max-w-xs text-xs leading-relaxed`,children:e})]})})}function O7(e){return navigator.clipboard.writeText(e)}function k7(){return typeof window>`u`?``:window.location.port===`8685`?`http://127.0.0.1:8787`:``}function A7(e){if(!e)return`No metadata payload captured.`;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return`Non-JSON response body:\n${e}`}}function ffe(e,t){let n=[];n.push(`# OAuth Debugger Report`),n.push(``),n.push(`- Session ID: ${e.id}`),n.push(`- Status: ${e.status}`),n.push(`- Registration method: ${e.registrationMethod}`),n.push(`- Profile: ${e.profile}`),n.push(``),n.push(`## Steps`);for(let t of e.stepStates)n.push(`- ${t.title}: ${t.status}${t.outcomeSummary?` — ${t.outcomeSummary}`:``}`);if(n.push(``),n.push(`## Validation Findings`),e.validations.length===0)n.push(`- None`);else for(let t of e.validations)n.push(`- [${t.severity}] ${t.title} (${t.stepId})`),n.push(` - ${t.detail}`),t.recommendation&&n.push(` - Recommendation: ${t.recommendation}`);n.push(``),n.push(`## Event Log`);for(let e of t){let t=typeof e.payload.message==`string`?e.payload.message:JSON.stringify(e.payload);n.push(`- ${new Date(e.ts).toLocaleTimeString()} [${e.type}] ${t}`)}return`${n.join(`
164
- `)}\n`}function pfe(){let{source:e}=nv(),{servers:t,reload:n,loading:r}=hv(),[i,a]=(0,_.useState)(`configure`),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(`pre_registered`),[u,d]=(0,_.useState)(`local_callback`),[f,p]=(0,_.useState)(!0),[m,h]=(0,_.useState)(!0),[g,v]=(0,_.useState)(!0),[y,b]=(0,_.useState)(``),[x,S]=(0,_.useState)(``),[C,w]=(0,_.useState)(``),[T,E]=(0,_.useState)(``),[D,k]=(0,_.useState)(`__default__`),[A,j]=(0,_.useState)(`{}`),[M,N]=(0,_.useState)(``),[P,F]=(0,_.useState)(``),[L,R]=(0,_.useState)(``),[z,ee]=(0,_.useState)(``),[te,ne]=(0,_.useState)(``),[re,ie]=(0,_.useState)(``),[ae,oe]=(0,_.useState)(``),[se,ce]=(0,_.useState)(``),[B,le]=(0,_.useState)(null),[ue,de]=(0,_.useState)(null),[V,fe]=(0,_.useState)([]),[pe,me]=(0,_.useState)(!1),[he,ge]=(0,_.useState)(!1),[_e,ve]=(0,_.useState)(!1),[ye,be]=(0,_.useState)(`all`),[xe,Se]=(0,_.useState)(`all`),[Ce,we]=(0,_.useState)(`inspector`),Te=(0,_.useRef)(null),Ee=(0,_.useRef)(null),De=(0,_.useRef)(!1),Oe=(0,_.useRef)(m);(0,_.useEffect)(()=>{Oe.current=m},[m]),(0,_.useEffect)(()=>()=>{Te.current?.(),Te.current=null},[]),(0,_.useEffect)(()=>{Ee.current?.scrollIntoView({behavior:`smooth`,block:`end`})},[V.length]);let ke=(0,_.useMemo)(()=>t.filter(e=>e.authType===`oauth2`).slice().sort((e,t)=>(e.name||e.id).localeCompare(t.name||t.id,void 0,{sensitivity:`base`})),[t]),Ae=ke.find(e=>e.id===o);(0,_.useEffect)(()=>{o&&(ke.some(e=>e.id===o)||s(``))},[ke,o]),(0,_.useEffect)(()=>{Ae&&(Ae.oauthMode===`dcr`?(l(`dcr`),w(``),E(``)):(l(`pre_registered`),w(Ae.oauthClientId??``),E(Ae.oauthClientSecret??``)),b(Ae.oauthScope??``),ee(Ae.oauthAuthorizationUrl??``),ne(Ae.oauthTokenEndpoint??``))},[Ae?.id]);let je=(0,_.useMemo)(()=>{let e=B?.stepStates.length??0,t=B?.stepStates.filter(e=>e.status===`completed`||e.status===`skipped`).length??0,n=B?.stepStates.filter(e=>e.status===`failed`).length??0;return{total:e,completed:t,failed:n,percent:e>0?Math.round((t+n)/e*100):0}},[B]),Me=(0,_.useMemo)(()=>{let e=B?.network??[],t=new Map,n=[],r=e=>`${e.stepId}::${e.label}::${e.url}`;for(let i of e){if(i.phase===`request`){let e=n.length;n.push({key:i.id,stepId:i.stepId,label:i.label,method:i.method,url:i.url,request:i});let a=r(i),o=t.get(a)??[];o.push(e),t.set(a,o);continue}let e=r(i),a=t.get(e),o=a?.shift();typeof o==`number`?(n[o]={...n[o],response:i},a&&a.length>0?t.set(e,a):t.delete(e)):n.push({key:i.id,stepId:i.stepId,label:i.label,method:i.method,url:i.url,response:i})}return n.filter(e=>ye!==`all`&&e.stepId!==ye?!1:xe===`error`?typeof e.response?.status==`number`&&e.response.status>=400:xe!==`ok`||typeof e.response?.status==`number`&&e.response.status<400)},[B?.network,ye,xe]),Ne=!!ue,Pe=!(!B||B.status!==`completed`&&B.status!==`error`&&B.status!==`stopped`),Fe=(0,_.useMemo)(()=>{let e=new Map;return(B?.stepStates??[]).forEach((t,n)=>{e.set(t.id,n+1)}),e},[B?.stepStates]),Ie=(0,_.useMemo)(()=>{let e=(B?.network??[]).filter(e=>e.phase===`response`),t=t=>{let n=e.filter(e=>e.label===t);return[...n].reverse().find(e=>typeof e.status==`number`&&e.status<400)??[...n].reverse()[0]};return{resourceMetadata:t(`Protected Resource Metadata`),authorizationServerMetadata:t(`Authorization Server Metadata`)}},[B?.network]),Le=(0,_.useMemo)(()=>{let e=new Map;for(let t of B?.network??[]){let n=e.get(t.stepId)??{requests:[],responses:[]};t.phase===`request`&&n.requests.push(t),t.phase===`response`&&n.responses.push(t),e.set(t.stepId,n)}return e},[B?.network]),Re=e=>{if(e===`configure`||e===`run`&&Ne||e===`report`&&Pe)return a(e)},ze=()=>{let e;if(c===`dcr`&&A.trim())try{e=JSON.parse(A)}catch{throw Error(`DCR metadata JSON is invalid`)}if(!Ae)throw Error(`Select an MCP server`);return{profile:`latest`,target:{serverName:Ae.id,overrides:{authorizationServerMetadataUrl:L||void 0,authorizationEndpoint:z||void 0,tokenEndpoint:te||void 0,registrationEndpoint:re||void 0,cimdUrl:M||void 0,resourceBaseUrl:ae||void 0}},registrationMethod:c,clientConfig:{preRegistered:c===`pre_registered`?{clientId:C.trim(),clientSecret:T.trim()||void 0,tokenEndpointAuthMethod:D===`__default__`?void 0:D||void 0}:void 0,dcr:c===`dcr`?{metadata:e,tokenEndpointAuthMethod:D===`__default__`?void 0:D||void 0}:void 0,cimd:c===`cimd`?{cimdUrl:M||void 0,expectedClientId:P||void 0}:void 0},runtime:{redirectMode:u,scopes:y.split(/[,\s]+/).map(e=>e.trim()).filter(Boolean),resource:x.trim()||void 0,usePkce:g,codeChallengeMethod:`S256`},display:{showSensitiveValues:f}}},Be=t=>{Te.current?.(),Te.current=e.subscribeOAuthDebuggerSession(t,n=>{fe(e=>[...e,n]),(n.type===`completed`||n.type===`error`||n.type===`stopped`)&&me(!1),e.getOAuthDebuggerSession(t).then(e=>{le(e.session),e.session.uiHints.authorizationUrl&&Ve(`${k7()}/api/oauth-debugger/sessions/${t}/authorize`),e.session.status===`completed`&&a(`report`)}).catch(()=>{})})},Ve=e=>{Oe.current&&!De.current&&e&&(De.current=!0,window.open(e,`_blank`,`noopener,noreferrer`))},He=async()=>{ge(!0),De.current=!1;try{let t=ze(),n=await e.createOAuthDebuggerSession(t);de(n.sessionId),le(n.session),fe([]),a(`run`),Be(n.sessionId);let r=await e.startOAuthDebuggerSession(n.sessionId);le(r.session),me(!0),(r.session.status===`waiting_for_user`||r.session.status===`waiting_for_browser_callback`)&&(me(!1),r.session.uiHints.authorizationUrl&&Ve(`${k7()}/api/oauth-debugger/sessions/${n.sessionId}/authorize`))}catch(e){O({title:`Could not start OAuth Debugger session`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{ge(!1)}},Ue=async()=>{if(ue)try{ge(!0);let t=await e.submitOAuthDebuggerManualCallback(ue,{redirectUrl:se.trim()||void 0});le(t.session),ce(``),me(!0)}catch(e){O({title:`Could not submit callback`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{ge(!1)}},We=async()=>{if(ue){ve(!0);try{let t=await e.stopOAuthDebuggerSession(ue);if(me(!1),t.status!==`running`){let t=await e.getOAuthDebuggerSession(ue);le(t.session),t.session.status===`completed`?a(`report`):a(`run`)}}catch(e){O({title:`Could not stop session`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{ve(!1)}}},Ge=async()=>{Te.current?.(),Te.current=null,le(null),de(null),fe([]),me(!1),ve(!1),ge(!1),ce(``),be(`all`),Se(`all`),we(`inspector`),a(`run`),await He()},Ke=async t=>{if(ue&&B)try{let n=await e.exportOAuthDebuggerSession(ue,t),r=``,i=t===`json`?`json`:t===`raw`?`txt`:`md`;r=typeof n==`string`?n:`${JSON.stringify(n,null,2)}\n`;let a=new Blob([r],{type:`text/plain;charset=utf-8`}),o=URL.createObjectURL(a),s=document.createElement(`a`);s.href=o,s.download=`oauth-debugger-${ue}.${i}`,s.click(),URL.revokeObjectURL(o)}catch(e){if(t===`markdown`){let e=ffe(B,V),t=new Blob([e],{type:`text/markdown;charset=utf-8`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`oauth-debugger-${B.id}.md`,r.click(),URL.revokeObjectURL(n);return}O({title:`Export failed`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}},qe=ue?`${k7()}/api/oauth-debugger/sessions/${ue}/authorize`:void 0,Je=e=>e===`error`?`destructive`:e===`warning`?`outline-solid`:`secondary`;return(0,I.jsxs)(`div`,{className:`space-y-6`,children:[(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h1`,{className:`text-2xl font-bold`,children:`OAuth Debugger`}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Step-by-step OAuth flow debugging for MCP servers (latest MCP authorization draft profile).`})]}),(0,I.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:cfe.map(e=>{let t=i===e.id,n=e.id===`configure`||e.id===`run`&&Ne||e.id===`report`&&Pe;return(0,I.jsx)(`button`,{type:`button`,onClick:()=>n&&Re(e.id),disabled:!n,className:`rounded-full`,children:(0,I.jsx)(Y,{variant:t?`default`:`outline-solid`,className:n?``:`opacity-50`,children:e.label})},e.id)})})]}),i===`configure`&&(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(K,{children:[(0,I.jsx)(gv,{className:`pb-3`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(_v,{className:`text-base`,children:`Target MCP Server`}),(0,I.jsx)(vv,{children:`Select one MCP server from Libraries and optionally override endpoints.`})]}),(0,I.jsxs)(W,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void n(),disabled:r,children:[(0,I.jsx)(Qn,{className:`mr-2 h-4 w-4 ${r?`animate-spin`:``}`}),`Refresh Servers`]})]})}),(0,I.jsx)(q,{className:`space-y-3`,children:(0,I.jsxs)(`div`,{className:`max-w-xl space-y-2`,children:[(0,I.jsx)(Q,{children:`MCP Server`}),(0,I.jsxs)(OY,{value:o,onValueChange:s,children:[(0,I.jsx)(AY,{children:(0,I.jsx)(kY,{placeholder:`Select an MCP server`})}),(0,I.jsx)(NY,{children:ke.map(e=>(0,I.jsx)(Z,{value:e.id,children:e.name||e.id},e.id))})]}),ke.length===0&&(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`No MCP servers with OAuth configured found. Add OAuth 2.0 auth in`,` `,(0,I.jsx)(`a`,{href:`/libraries/servers`,className:`underline text-primary`,children:`Manage Servers`}),`.`]}),Ae&&(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[Ae.transport,` ·`,` `,Ae.url||Ae.command||`No URL/command`,` · `,(0,I.jsxs)(`span`,{className:`text-primary`,children:[Ae.oauthMode===`dcr`?`DCR`:`pre-registered`,` fields pre-filled`]})]})]})})]}),(0,I.jsxs)(K,{children:[(0,I.jsxs)(gv,{className:`pb-3`,children:[(0,I.jsx)(_v,{className:`text-base`,children:`Client Registration Method`}),(0,I.jsx)(vv,{children:`How your OAuth client is identified with the authorization server.`})]}),(0,I.jsxs)(q,{className:`space-y-3`,children:[(0,I.jsx)(`div`,{className:`grid gap-2 md:grid-cols-3`,children:[{id:`pre_registered`,label:`Pre-registered client`,hint:`You already have a client_id issued by the authorization server.`},{id:`dcr`,label:`Dynamic Client Registration`,hint:`The server issues a client_id automatically at the start of the flow (RFC 7591).`},{id:`cimd`,label:`Client ID Metadata Document`,hint:`The client identifies itself via a hosted JSON metadata document at a public URL (RFC 9728).`}].map(e=>(0,I.jsxs)(`button`,{type:`button`,onClick:()=>l(e.id),className:`rounded-md border p-3 text-left`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`div`,{className:`h-2.5 w-2.5 shrink-0 rounded-full ${c===e.id?`bg-primary`:`bg-muted-foreground/30`}`}),(0,I.jsx)(`span`,{className:`text-sm font-medium`,children:e.label})]}),(0,I.jsx)(`p`,{className:`mt-1 pl-5 text-xs text-muted-foreground`,children:e.hint})]},e.id))}),(0,I.jsx)(`div`,{className:`grid gap-3 md:grid-cols-1`,children:(0,I.jsxs)(`div`,{className:`max-w-md space-y-1`,children:[(0,I.jsxs)(Q,{className:`text-xs flex items-center gap-1`,children:[`Redirect mode`,(0,I.jsx)(D7,{text:`Local callback (recommended): MCP Lab automatically captures the redirect after you log in — no copy-pasting needed. Manual: you complete the browser login and then paste the final redirect URL back here.`})]}),(0,I.jsxs)(OY,{value:u,onValueChange:e=>d(e),children:[(0,I.jsx)(AY,{children:(0,I.jsx)(kY,{})}),(0,I.jsxs)(NY,{children:[(0,I.jsx)(Z,{value:`local_callback`,children:`Local callback (recommended)`}),(0,I.jsx)(Z,{value:`manual`,children:`Manual paste redirect URL`})]})]})]})}),c===`pre_registered`&&(0,I.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(Q,{className:`text-xs flex items-center gap-1`,children:[`client_id`,(0,I.jsx)(D7,{text:`The unique identifier for your application, issued by the authorization server when you registered the client.`})]}),(0,I.jsx)(Op,{value:C,onChange:e=>w(e.target.value)})]}),(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(Q,{className:`text-xs flex items-center gap-1`,children:[`client_secret`,(0,I.jsx)(D7,{text:`Leave empty for public clients (e.g. SPAs or mobile apps). Required for confidential clients that authenticate with the token endpoint.`})]}),(0,I.jsx)(a8,{value:T,onChange:e=>E(e.target.value),placeholder:`optional`})]})]}),c===`cimd`&&(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(Q,{className:`text-xs flex items-center gap-1`,children:[`CIMD URL`,(0,I.jsx)(D7,{text:`A publicly reachable URL hosting a JSON document that describes this client. The authorization server fetches it to identify the client.`})]}),(0,I.jsx)(Op,{value:M,onChange:e=>N(e.target.value),placeholder:`https://.../client-metadata.json`})]})]})]}),(0,I.jsxs)(K,{children:[(0,I.jsxs)(gv,{className:`pb-3`,children:[(0,I.jsx)(_v,{className:`text-base`,children:`Runtime OAuth Inputs`}),(0,I.jsx)(vv,{children:`Parameters sent in the authorization request.`})]}),(0,I.jsxs)(q,{className:`grid gap-3 md:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(Q,{className:`text-xs`,children:`Scopes`}),(0,I.jsx)(Op,{value:y,onChange:e=>b(e.target.value),placeholder:`openid profile email`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Space or comma separated. Leave empty to use scopes auto-discovered from the server metadata.`})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2 md:col-span-2`,children:[(0,I.jsx)(KX,{checked:g,onCheckedChange:e=>v(!!e)}),(0,I.jsxs)(Q,{className:`flex items-center gap-1`,children:[`Use PKCE (S256)`,(0,I.jsx)(D7,{text:`Proof Key for Code Exchange — generates a one-time code verifier so the authorization code can't be hijacked. Recommended for all clients; required for public clients.`})]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2 md:col-span-2`,children:[(0,I.jsx)(KX,{checked:m,onCheckedChange:e=>h(!!e)}),(0,I.jsx)(Q,{children:`Auto-open browser when authorization URL is ready`})]})]})]}),(0,I.jsxs)(`details`,{className:`rounded-md border bg-card p-3 shadow-xs`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:`Advanced`}),(0,I.jsxs)(`div`,{className:`mt-3 space-y-4`,children:[(0,I.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(Q,{className:`text-xs flex items-center gap-1`,children:[`Token endpoint auth method`,(0,I.jsx)(D7,{text:`How your client authenticates when exchanging the authorization code for a token. Choose 'none' for public clients (no secret). Leave as server default if unsure.`})]}),(0,I.jsxs)(OY,{value:D,onValueChange:k,children:[(0,I.jsx)(AY,{children:(0,I.jsx)(kY,{placeholder:`Server default (recommended)`})}),(0,I.jsxs)(NY,{children:[(0,I.jsx)(Z,{value:`__default__`,children:`Server default (let the server decide)`}),(0,I.jsx)(Z,{value:`client_secret_basic`,children:`client_secret_basic — credentials in Authorization header`}),(0,I.jsx)(Z,{value:`client_secret_post`,children:`client_secret_post — credentials in request body`}),(0,I.jsx)(Z,{value:`none`,children:`none — public client, no secret`}),(0,I.jsx)(Z,{value:`private_key_jwt`,children:`private_key_jwt — signed JWT assertion`})]})]}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Use "server default" unless the server requires a specific method.`})]}),(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(Q,{className:`text-xs flex items-center gap-1`,children:[`Resource / audience`,(0,I.jsx)(D7,{text:`Some servers (RFC 8707) require the target API's URI in the token request to scope the token. Only set this if your server explicitly requires it.`})]}),(0,I.jsx)(Op,{value:x,onChange:e=>S(e.target.value),placeholder:`https://api.example.com`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Optional. Only needed for servers that use resource indicators.`})]})]}),c===`dcr`&&(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(Q,{className:`text-xs flex items-center gap-1`,children:[`DCR metadata JSON`,(0,I.jsx)(D7,{text:`Extra fields for the dynamic client registration request (RFC 7591), e.g. {"client_name": "My App"}. redirect_uris and grant_types are always added automatically.`})]}),(0,I.jsx)(iX,{value:A,onChange:e=>j(e.target.value),className:`min-h-32 font-mono text-xs`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Optional extra fields for the registration request body.`})]}),c===`cimd`&&(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(Q,{className:`text-xs flex items-center gap-1`,children:[`Expected client_id`,(0,I.jsx)(D7,{text:`If you know what client_id the server should assign from the metadata document, enter it here for verification. Leave blank to accept whatever the server returns.`})]}),(0,I.jsx)(Op,{value:P,onChange:e=>F(e.target.value),placeholder:`optional`})]}),(0,I.jsxs)(`div`,{className:`rounded-md border bg-background p-3`,children:[(0,I.jsx)(`div`,{className:`mb-1 text-sm font-medium`,children:`Endpoint overrides`}),(0,I.jsx)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:`Override specific endpoints if auto-discovery fails or you want to test against a specific URL. Leave blank to use what the server advertises.`}),(0,I.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(Q,{className:`text-xs flex items-center gap-1`,children:[`Authorization server metadata URL`,(0,I.jsx)(D7,{text:`The /.well-known/oauth-authorization-server URL. Override if the server uses a non-standard path.`})]}),(0,I.jsx)(Op,{value:L,onChange:e=>R(e.target.value),placeholder:`https://.../.well-known/oauth-authorization-server`})]}),(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(Q,{className:`text-xs flex items-center gap-1`,children:[`Resource server base URL`,(0,I.jsx)(D7,{text:`The MCP server's base URL used to look up its /.well-known/oauth-protected-resource metadata. Override if the server uses a different base path.`})]}),(0,I.jsx)(Op,{value:ae,onChange:e=>oe(e.target.value),placeholder:`https://resource.example.com`})]}),(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(Q,{className:`text-xs flex items-center gap-1`,children:[`Authorization endpoint`,(0,I.jsx)(D7,{text:`The URL where users are redirected to log in and grant consent. Normally discovered automatically from the server metadata.`})]}),(0,I.jsx)(Op,{value:z,onChange:e=>ee(e.target.value),placeholder:`https://.../authorize`})]}),(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(Q,{className:`text-xs flex items-center gap-1`,children:[`Token endpoint`,(0,I.jsx)(D7,{text:`The URL your app calls to exchange the authorization code for an access token. Normally discovered automatically.`})]}),(0,I.jsx)(Op,{value:te,onChange:e=>ne(e.target.value),placeholder:`https://.../token`})]}),(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(Q,{className:`text-xs flex items-center gap-1`,children:[`Registration endpoint (DCR)`,(0,I.jsx)(D7,{text:`The URL used to dynamically register a new client (RFC 7591). Only relevant when using DCR. Override if the server doesn't advertise it in its metadata.`})]}),(0,I.jsx)(Op,{value:re,onChange:e=>ie(e.target.value),placeholder:`https://.../register`})]}),(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(Q,{className:`text-xs flex items-center gap-1`,children:[`CIMD URL override`,(0,I.jsx)(D7,{text:`Override the Client ID Metadata Document URL. Use this if the server doesn't discover it automatically or you want to test with a specific metadata document.`})]}),(0,I.jsx)(Op,{value:M,onChange:e=>N(e.target.value),placeholder:`https://.../client-metadata.json`})]})]})]}),(0,I.jsxs)(R5,{children:[(0,I.jsx)(un,{className:`h-4 w-4`}),(0,I.jsx)(z5,{children:`Secrets display`}),(0,I.jsxs)(B5,{className:`space-y-2`,children:[(0,I.jsx)(`p`,{children:`By default, full tokens and secrets are visible in the network inspector and exports — useful for debugging but not for sharing.`}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(KX,{checked:!f,onCheckedChange:e=>p(e===!1)}),(0,I.jsx)(Q,{children:`Hide sensitive values in inspector`})]})]})]})]})]}),(0,I.jsx)(`div`,{className:`flex justify-end`,children:(0,I.jsxs)(W,{type:`button`,onClick:()=>void He(),disabled:he,children:[he&&(0,I.jsx)(zn,{className:`mr-2 h-4 w-4 animate-spin`}),`Start OAuth Debug Session`]})})]}),i===`run`&&(0,I.jsx)(`div`,{className:`space-y-4`,children:(0,I.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[1.2fr_1fr]`,children:[(0,I.jsxs)(K,{className:`xl:col-span-1 min-w-0`,children:[(0,I.jsx)(gv,{className:`pb-3`,children:(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(_v,{className:`text-base`,children:`Progress`}),(0,I.jsx)(vv,{children:`Visual OAuth flow guide with live session events and next-step actions.`})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[B?.uiHints.authorizationUrl&&qe&&(0,I.jsx)(W,{asChild:!0,type:`button`,size:`sm`,variant:`outline`,children:(0,I.jsxs)(`a`,{href:qe,target:`_blank`,rel:`noopener noreferrer`,children:[(0,I.jsx)(Sn,{className:`mr-2 h-4 w-4`}),`Open Authorization URL`]})}),(0,I.jsxs)(W,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>void Ge(),disabled:he,children:[(0,I.jsx)(Qn,{className:`mr-2 h-4 w-4`}),`Restart`]}),ue&&(0,I.jsxs)(W,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>void We(),disabled:_e||!ue,children:[(_e||pe)&&_e&&(0,I.jsx)(zn,{className:`mr-2 h-4 w-4 animate-spin`}),(0,I.jsx)(sr,{className:`mr-2 h-4 w-4`}),`Stop Debug Session`]})]})]})}),(0,I.jsxs)(q,{className:`space-y-3`,children:[(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,I.jsxs)(`span`,{children:[je.completed+je.failed,`/`,je.total,` steps`]}),(0,I.jsxs)(`span`,{children:[je.percent,`%`]})]}),(0,I.jsx)(t7,{value:je.percent,className:`h-2`})]}),B?.status===`waiting_for_user`&&(0,I.jsx)(K,{children:(0,I.jsxs)(q,{className:`pt-4 space-y-2`,children:[(0,I.jsx)(`div`,{className:`text-sm font-medium`,children:`Manual callback required`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Open the authorization URL, complete authentication, then paste the final redirect URL here.`}),(0,I.jsx)(iX,{value:se,onChange:e=>ce(e.target.value),placeholder:`Paste the final redirect URL (with code and state)`,className:`min-h-24 text-xs font-mono`}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsxs)(W,{type:`button`,size:`sm`,onClick:()=>void Ue(),disabled:he||!se.trim(),children:[he&&(0,I.jsx)(zn,{className:`mr-2 h-4 w-4 animate-spin`}),`Continue`]}),B.uiHints.authorizationUrl&&qe&&(0,I.jsx)(W,{asChild:!0,type:`button`,size:`sm`,variant:`outline`,children:(0,I.jsx)(`a`,{href:qe,target:`_blank`,rel:`noopener noreferrer`,children:`Open Authorization URL`})})]})]})}),B?.status===`waiting_for_browser_callback`&&(0,I.jsxs)(R5,{children:[(0,I.jsx)(un,{className:`h-4 w-4`}),(0,I.jsx)(z5,{children:`Waiting for browser callback`}),(0,I.jsxs)(B5,{className:`space-y-1`,children:[(0,I.jsx)(`p`,{className:`text-xs`,children:`Complete the authorization flow in your browser. MCP Lab is listening for the callback at:`}),(0,I.jsx)(`p`,{className:`text-xs font-mono break-all`,children:B.uiHints.callbackUrl}),B.uiHints.authorizationUrl&&qe&&(0,I.jsx)(`div`,{className:`pt-2`,children:(0,I.jsx)(W,{asChild:!0,type:`button`,size:`sm`,variant:`outline`,children:(0,I.jsxs)(`a`,{href:qe,target:`_blank`,rel:`noopener noreferrer`,children:[(0,I.jsx)(Sn,{className:`mr-2 h-4 w-4`}),`Open Authorization URL`]})})})]})]}),(0,I.jsx)(`div`,{className:`space-y-2`,children:B?.stepStates.map(e=>{let t=Fe.get(e.id),n=Le.get(e.id),r=e.id===ufe||e.id===dfe,i=!!(n&&(n.requests.length>0||n.responses.length>0)),a=r&&e.status!==`pending`&&i;return(0,I.jsxs)(`div`,{className:`rounded-md border p-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsxs)(`div`,{className:`min-w-0 flex items-start gap-2`,children:[(0,I.jsx)(`div`,{className:`mt-0.5 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full border bg-muted text-xs font-semibold`,children:t}),(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsxs)(`div`,{className:`inline-flex items-center gap-1 text-sm font-medium`,children:[(0,I.jsx)(`span`,{children:e.title}),e.status===`completed`&&(0,I.jsx)(dn,{className:`h-4 w-4 shrink-0 text-emerald-600`,"aria-hidden":`true`})]}),(0,I.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.description})]})]}),(0,I.jsx)(Y,{variant:e.status===`failed`?`destructive`:e.status===`completed`?`outline-solid`:e.status===`active`?`secondary`:`outline-solid`,className:e.status===`completed`?`border-emerald-300 bg-emerald-50 text-emerald-700`:void 0,children:e.status})]}),e.outcomeSummary&&(0,I.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground break-all whitespace-pre-line`,children:e.outcomeSummary}),e.id===lfe&&(0,I.jsxs)(`details`,{className:`mt-3 rounded-md border bg-muted/20 p-3`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer text-xs font-semibold text-muted-foreground`,children:`OAuth Metadata Sources`}),(0,I.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(`div`,{className:`text-xs font-medium`,children:`Resource Metadata`}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground break-all`,children:[`From `,Ie.resourceMetadata?.url??`not captured`]}),(0,I.jsx)(`pre`,{className:`max-h-56 overflow-x-auto rounded-md bg-muted p-2 text-xs`,children:A7(Ie.resourceMetadata?.bodyText)})]}),(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(`div`,{className:`text-xs font-medium`,children:`Authorization Server Metadata`}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground break-all`,children:[`From`,` `,Ie.authorizationServerMetadata?.url??`not captured`]}),(0,I.jsx)(`pre`,{className:`max-h-56 overflow-x-auto rounded-md bg-muted p-2 text-xs`,children:A7(Ie.authorizationServerMetadata?.bodyText)})]})]})]}),a&&n&&(0,I.jsxs)(`details`,{className:`mt-3 rounded-md border bg-muted/20 p-3`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer text-xs font-semibold text-muted-foreground`,children:`Captured exchange details`}),(0,I.jsx)(`div`,{className:`mt-3 space-y-3`,children:Array.from({length:Math.max(n.requests.length,n.responses.length)}).map((t,r)=>{let i=n.requests[r],a=n.responses[r];return(0,I.jsxs)(`div`,{className:`rounded-md border bg-background p-2`,children:[(0,I.jsx)(`div`,{className:`text-xs font-medium`,children:i?.label??a?.label??`Exchange ${r+1}`}),(0,I.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground break-all`,children:[i?.method?`${i.method} `:``,i?.url??a?.url??`-`]}),typeof a?.status==`number`&&(0,I.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`HTTP `,a.status]}),i?.bodyText&&(0,I.jsx)(`pre`,{className:`mt-2 max-h-40 overflow-auto rounded bg-muted p-2 text-xs`,children:i.bodyText}),a?.bodyText&&(0,I.jsx)(`pre`,{className:`mt-2 max-h-48 overflow-auto rounded bg-muted p-2 text-xs`,children:A7(a.bodyText)})]},`${e.id}-exchange-${r}`)})})]})]},e.id)})||(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No steps yet.`})})]})]}),(0,I.jsx)(`div`,{className:`space-y-4 xl:col-span-1 min-w-0`,children:(0,I.jsxs)(K,{children:[(0,I.jsx)(gv,{className:`pb-3`,children:(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(_v,{className:`text-base`,children:`Inspect`}),(0,I.jsx)(vv,{children:`Live events and network requests/responses for the OAuth flow.`})]}),(0,I.jsxs)(W,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>void Ke(`raw`),disabled:!ue||!B,children:[(0,I.jsx)(yn,{className:`mr-2 h-4 w-4`}),`Copy/Export Raw Trace`]})]})}),(0,I.jsx)(q,{className:`space-y-3`,children:(0,I.jsxs)(CX,{value:Ce,onValueChange:e=>we(e),className:`min-w-0`,children:[(0,I.jsxs)(wX,{className:`grid grid-cols-2`,children:[(0,I.jsx)(TX,{value:`inspector`,children:`Network Inspector`}),(0,I.jsx)(TX,{value:`events`,children:`Live Debug`})]}),(0,I.jsx)(EX,{value:`events`,className:`mt-3`,children:(0,I.jsxs)(`div`,{className:`max-h-64 space-y-1 overflow-auto rounded-md border bg-muted/10 p-3 text-xs`,children:[V.length===0?(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`No events yet.`}):V.map((e,t)=>(0,I.jsxs)(`div`,{className:`break-all`,children:[(0,I.jsx)(`span`,{className:`mr-2 font-mono text-muted-foreground`,children:new Date(e.ts).toLocaleTimeString()}),(0,I.jsx)(Y,{variant:`outline`,className:`mr-2 text-[10px]`,children:e.type}),typeof e.payload.message==`string`?e.payload.message:JSON.stringify(e.payload)]},`${e.ts}-${t}`)),(0,I.jsx)(`div`,{ref:Ee})]})}),(0,I.jsxs)(EX,{value:`inspector`,className:`space-y-3 mt-3`,children:[(0,I.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(Q,{className:`text-xs`,children:`Filter by step`}),(0,I.jsxs)(OY,{value:ye,onValueChange:be,children:[(0,I.jsx)(AY,{className:`h-8`,children:(0,I.jsx)(kY,{})}),(0,I.jsxs)(NY,{children:[(0,I.jsx)(Z,{value:`all`,children:`All steps`}),(B?.stepStates??[]).map(e=>(0,I.jsxs)(Z,{value:e.id,children:[Fe.get(e.id),`. `,e.title]},e.id))]})]})]}),(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(Q,{className:`text-xs`,children:`Filter by status`}),(0,I.jsxs)(OY,{value:xe,onValueChange:Se,children:[(0,I.jsx)(AY,{className:`h-8`,children:(0,I.jsx)(kY,{})}),(0,I.jsxs)(NY,{children:[(0,I.jsx)(Z,{value:`all`,children:`All`}),(0,I.jsx)(Z,{value:`ok`,children:`Successful responses`}),(0,I.jsx)(Z,{value:`error`,children:`Error responses`})]})]})]})]}),(0,I.jsx)(`div`,{className:`max-h-136 min-w-0 space-y-2 overflow-auto`,children:Me.length===0?(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No network exchanges captured yet.`}):Me.map(e=>(0,I.jsxs)(`details`,{className:`rounded-md border p-3`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer list-none`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsxs)(`div`,{className:`min-w-0 flex items-start gap-2`,children:[(0,I.jsx)(`div`,{className:`mt-0.5 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full border bg-muted text-xs font-semibold`,children:Fe.get(e.stepId)}),(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`div`,{className:`text-sm font-medium`,children:e.label}),(0,I.jsxs)(`div`,{className:`text-xs text-muted-foreground break-all`,children:[e.method?`${e.method} `:``,e.url]})]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(Y,{variant:`outline`,children:`request`}),(0,I.jsx)(Y,{variant:`outline`,children:`response`}),typeof e.response?.status==`number`&&(0,I.jsx)(Y,{variant:e.response.status>=400?`destructive`:`secondary`,children:e.response.status})]})]})}),(0,I.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`mb-1 text-xs font-medium`,children:`Request Headers`}),(0,I.jsx)(`pre`,{className:`max-h-40 max-w-full overflow-auto whitespace-pre-wrap break-all rounded bg-muted p-2 text-xs`,children:JSON.stringify(e.request?.headers??{},null,2)})]}),e.request?.bodyText&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`mb-1 text-xs font-medium`,children:`Request Body`}),(0,I.jsx)(`pre`,{className:`max-h-64 max-w-full overflow-auto whitespace-pre-wrap break-all rounded bg-muted p-2 text-xs`,children:e.request.bodyText})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`mb-1 text-xs font-medium`,children:`Response Headers`}),(0,I.jsx)(`pre`,{className:`max-h-40 max-w-full overflow-auto whitespace-pre-wrap break-all rounded bg-muted p-2 text-xs`,children:JSON.stringify(e.response?.headers??{},null,2)})]}),e.response?.bodyText&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`mb-1 text-xs font-medium`,children:`Response Body`}),(0,I.jsx)(`pre`,{className:`max-h-64 max-w-full overflow-auto whitespace-pre-wrap break-all rounded bg-muted p-2 text-xs`,children:e.response.bodyText})]}),(0,I.jsx)(`div`,{className:`flex gap-2`,children:(0,I.jsxs)(W,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>void O7(JSON.stringify(e,null,2)),children:[(0,I.jsx)(vn,{className:`mr-2 h-4 w-4`}),`Copy JSON`]})})]})]},e.key))})]})]})})]})})]})}),i===`report`&&B&&(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Report / Export`}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`OAuth debug session summary, validations, and trace exports.`})]}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsx)(W,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>a(`configure`),children:`Back to Configure`}),(0,I.jsxs)(W,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>void Ke(`json`),children:[(0,I.jsx)(yn,{className:`mr-2 h-4 w-4`}),`Export JSON`]}),(0,I.jsxs)(W,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>void Ke(`markdown`),children:[(0,I.jsx)(yn,{className:`mr-2 h-4 w-4`}),`Export Markdown`]}),(0,I.jsxs)(W,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>void Ke(`raw`),children:[(0,I.jsx)(yn,{className:`mr-2 h-4 w-4`}),`Copy/Export Raw Trace`]})]})]}),(0,I.jsxs)(R5,{children:[(0,I.jsx)(un,{className:`h-4 w-4`}),(0,I.jsx)(z5,{children:`Secrets display mode`}),(0,I.jsx)(B5,{children:B.summary?.showSensitiveValues?`This session is configured to show full tokens and secrets in network logs/exports.`:`Sensitive values are hidden in the inspector for this session.`})]}),(0,I.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:[(0,I.jsx)(K,{children:(0,I.jsxs)(q,{className:`pt-4`,children:[(0,I.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Status`}),(0,I.jsx)(`div`,{className:`text-lg font-semibold`,children:B.status})]})}),(0,I.jsx)(K,{children:(0,I.jsxs)(q,{className:`pt-4`,children:[(0,I.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Requests`}),(0,I.jsx)(`div`,{className:`text-lg font-semibold`,children:B.networkSummary.requestCount})]})}),(0,I.jsx)(K,{children:(0,I.jsxs)(q,{className:`pt-4`,children:[(0,I.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Network errors`}),(0,I.jsx)(`div`,{className:`text-lg font-semibold`,children:B.networkSummary.errorCount})]})}),(0,I.jsx)(K,{children:(0,I.jsxs)(q,{className:`pt-4`,children:[(0,I.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Validation findings`}),(0,I.jsx)(`div`,{className:`text-lg font-semibold`,children:B.validations.length})]})})]}),(0,I.jsxs)(K,{children:[(0,I.jsx)(gv,{className:`pb-3`,children:(0,I.jsx)(_v,{className:`text-base`,children:`Key values`})}),(0,I.jsxs)(q,{className:`grid gap-3 md:grid-cols-2`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(Q,{className:`text-xs`,children:`Issuer`}),(0,I.jsx)(`p`,{className:`text-sm break-all`,children:B.summary?.issuer||`-`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(Q,{className:`text-xs`,children:`Client ID`}),(0,I.jsx)(`p`,{className:`text-sm break-all`,children:B.summary?.clientId||`-`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(Q,{className:`text-xs`,children:`Redirect URI`}),(0,I.jsx)(`p`,{className:`text-sm break-all`,children:B.summary?.redirectUri||`-`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(Q,{className:`text-xs`,children:`Token endpoint status`}),(0,I.jsx)(`p`,{className:`text-sm`,children:B.summary?.tokenEndpointStatus??`-`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(Q,{className:`text-xs`,children:`Token type`}),(0,I.jsx)(`p`,{className:`text-sm`,children:B.summary?.tokenType||`-`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(Q,{className:`text-xs`,children:`Scopes granted`}),(0,I.jsx)(`p`,{className:`text-sm break-all`,children:(B.summary?.grantedScopes??[]).join(`, `)||`-`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(Q,{className:`text-xs`,children:`Token validity`}),(0,I.jsxs)(`p`,{className:`text-sm`,children:[typeof B.summary?.accessTokenValidForSeconds==`number`?`${f6(B.summary.accessTokenValidForSeconds)} remaining`:typeof B.summary?.accessTokenExpiresInSeconds==`number`?`${f6(B.summary.accessTokenExpiresInSeconds)} from issuance`:`No expiry advertised by token endpoint`,B.summary?.accessTokenExpiresAt?(0,I.jsxs)(I.Fragment,{children:[` (until `,(0,I.jsx)(`span`,{children:new Date(B.summary.accessTokenExpiresAt).toLocaleTimeString()}),`)`]}):``]}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Source:`,` `,B.summary?.accessTokenExpirySource===`expires_in`?`token endpoint expires_in`:B.summary?.accessTokenExpirySource===`jwt_exp`?`JWT exp claim`:`not available`]})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(Q,{className:`text-xs`,children:`Refresh option`}),(0,I.jsx)(`p`,{className:`text-sm`,children:B.summary?.refreshTokenAvailable?`Refresh token available (silent refresh possible)`:`No refresh token in response (full login likely required after expiry)`})]}),B.summary?.accessToken&&(0,I.jsxs)(`div`,{className:`md:col-span-2 space-y-1`,children:[(0,I.jsx)(Q,{className:`text-xs`,children:`Access token`}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsxs)(`code`,{className:`flex-1 truncate rounded bg-muted px-2 py-1 text-xs font-mono text-muted-foreground`,children:[B.summary.accessToken.slice(0,48),`…`]}),(0,I.jsxs)(W,{type:`button`,size:`sm`,variant:`outline`,className:`shrink-0 h-7 px-2 text-xs`,onClick:()=>void O7(B.summary.accessToken),children:[(0,I.jsx)(vn,{className:`mr-1 h-3 w-3`}),`Copy token`]})]}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Visible because "Hide sensitive values" is off. Use this token with the CLI via`,` `,(0,I.jsx)(`code`,{className:`font-mono`,children:`--oauth-token`}),`.`]})]})]})]}),(0,I.jsxs)(K,{children:[(0,I.jsx)(gv,{className:`pb-3`,children:(0,I.jsx)(_v,{className:`text-base`,children:`Validation findings`})}),(0,I.jsx)(q,{className:`space-y-2`,children:B.validations.length===0?(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No validation findings recorded.`}):B.validations.map((e,t)=>(0,I.jsxs)(`div`,{className:`rounded-md border p-3`,children:[(0,I.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`inline-flex h-5 min-w-5 items-center justify-center rounded-full border bg-muted px-1 text-[10px] font-semibold text-muted-foreground`,children:t+1}),(0,I.jsx)(`span`,{className:`font-bold`,children:e.title})]}),(0,I.jsx)(Y,{variant:Je(e.severity),children:e.severity})]}),(0,I.jsxs)(`p`,{className:`text-sm`,children:[(0,I.jsx)(`span`,{className:`font-bold`,children:`Finding:`}),` `,e.detail]}),e.recommendation&&(0,I.jsxs)(`div`,{className:`mt-2 rounded-md border px-2.5 py-2 text-xs`,children:[(0,I.jsx)(`div`,{className:`mb-1 font-medium text-muted-foreground`,children:`Suggested improvement`}),(0,I.jsx)(`p`,{children:e.recommendation})]}),(0,I.jsxs)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Step: `,e.stepId,e.specReference&&(0,I.jsxs)(I.Fragment,{children:[` · `,(0,I.jsx)(`a`,{href:e.specReference,target:`_blank`,rel:`noreferrer`,className:`text-primary underline`,children:`Spec reference`})]})]})]},e.id))})]})]})]})}function mfe(e){let t=e.filter(e=>typeof e.sourcePath==`string`&&e.sourcePath.trim().length>0&&typeof e.relativePath==`string`&&e.relativePath.trim().length>0).map(e=>[e.sourcePath,e.relativePath]);return new Map(t)}function hfe(e){let t=e.filter(e=>typeof e.sourcePath==`string`&&e.sourcePath.trim().length>0).map(e=>[e.sourcePath,e.configName?.trim()||e.name]);return new Map(t)}function gfe(e,t){let n=new Map;for(let r of e){if(!r.sourcePath)continue;let e=new Map,i=r.scenarioEntries&&r.scenarioEntries.length>0?r.scenarioEntries:r.scenarios.map(e=>({kind:`inline`,scenario:e}));for(let n of i){if(n.kind===`inline`){e.set(n.scenario.id,n.scenario.name?.trim()||n.scenario.id);continue}let r=t.find(e=>e.id===n.ref);e.set(n.ref,r?.name?.trim()||n.ref)}n.set(r.sourcePath,e)}return n}function j7(e,t){let n=t.get(e);if(n)return n;let r=e.replace(/\\/g,`/`),i=r.lastIndexOf(`/evals/`);if(i>=0)return r.slice(i+7);let a=r.split(`/`).filter(Boolean);return a.length<=1?r:a.slice(-3).join(`/`)}function M7(e,t,n){let r=t.get(n);if(!e||e.length===0){if(r&&r.size===1){let e=r.values().next().value;if(e)return e}return`All scenarios`}if(!r)return e.length===1?e[0]:`${e[0]} +${e.length-1}`;let i=e.map(e=>r.get(e)??e);return i.length===1?i[0]:`${i[0]} +${i.length-1}`}var N7=`mcplab.runEvaluation.activeJobId`;function _fe(e){return e.configName?.trim()||e.name}function vfe(e){if(e.suitePath?.trim())return e.suitePath.trim();if(e.relativePath?.includes(`/`)){let t=e.relativePath.lastIndexOf(`/`);return e.relativePath.slice(0,t)}return null}function P7(){return new Date().toLocaleTimeString()}function F7(e){return e.executionType===`rover`&&[`queued`,`waiting_for_rover`,`running`,`paused_rover`].includes(e.status)}function yfe(e){return e.jobs.flatMap(e=>e.childProgress?.length?e.childProgress.map(t=>({job:e,child:t})):[{job:e}])}var bfe=()=>{let[e]=cp(),[t,n]=(0,_.useState)(``),[r,i]=(0,_.useState)(`1`),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(0),[l,u]=(0,_.useState)([]),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(``),[S,C]=(0,_.useState)(null),[w,T]=(0,_.useState)([]),[E,D]=(0,_.useState)(`agent_default`),[k,A]=(0,_.useState)([]),[j,M]=(0,_.useState)(!1),[N,P]=(0,_.useState)([]),[F,L]=(0,_.useState)({}),[R,z]=(0,_.useState)({}),[ee,te]=(0,_.useState)(``),[ne,re]=(0,_.useState)([]),[ie,ae]=(0,_.useState)([]),[oe,se]=(0,_.useState)([]),[ce,B]=(0,_.useState)([]),[le,ue]=(0,_.useState)(null),[de,V]=(0,_.useState)(null),[fe,pe]=(0,_.useState)(!1),[me,he]=(0,_.useState)(null),ge=(0,_.useRef)(null),_e=(0,_.useRef)(null),ve=(0,_.useRef)(null),ye=(0,_.useRef)(new Map),be=(0,_.useRef)(!1),{configs:xe,reload:Se}=fv(),{source:Ce}=nv(),{agents:we,scenarios:Te,servers:Ee,reload:De}=hv(),Oe=b.trim(),ke=Oe?`/results/${encodeURIComponent(Oe)}${t?`?configId=${encodeURIComponent(t)}`:``}`:`/results`,Ae=xe.find(e=>e.id===t),je=(0,_.useMemo)(()=>mfe(xe),[xe]),Me=(0,_.useMemo)(()=>hfe(xe),[xe]),Ne=(0,_.useMemo)(()=>gfe(xe,Te),[xe,Te]),Pe=ie[0]??null,Fe=(0,_.useMemo)(()=>ce.find(e=>e.jobs.some(e=>e.jobId===S))??null,[ce,S]),Ie=Fe?Math.max(s,Fe.totalJobs>0?Math.round(Fe.completedJobs/Fe.totalJobs*100):0):s,Le=e.get(`configId`),Re=(0,_.useMemo)(()=>{if(!Ae)return[];let e=new Map,t=Ae.agentEntries&&Ae.agentEntries.length>0?Ae.agentEntries:Ae.agents.map(e=>({kind:`inline`,agent:e}));for(let n of t){if(n.kind===`inline`){let t=n.agent.id;e.has(t)||e.set(t,n.agent);continue}let t=we.find(e=>e.id===n.ref);t&&!e.has(t.id)&&e.set(t.id,t)}for(let t of we)e.has(t.id)||e.set(t.id,t);return Array.from(e.values())},[Ae,we]),ze=(0,_.useMemo)(()=>{if(!Ae)return[];let e=new Map,t=Ae.scenarioEntries&&Ae.scenarioEntries.length>0?Ae.scenarioEntries:Ae.scenarios.map(e=>({kind:`inline`,scenario:e}));for(let n of t){if(n.kind===`inline`){e.has(n.scenario.id)||e.set(n.scenario.id,n.scenario);continue}let t=Te.find(e=>e.id===n.ref);t&&!e.has(t.id)&&e.set(t.id,t)}return Array.from(e.values())},[Ae,Te]),Be=(0,_.useMemo)(()=>Re.filter(e=>e.type===`browser`&&w.includes(e.id)),[Re,w]),Ve=Be.length>0?1:Number(r),He=(0,_.useMemo)(()=>[{label:`LLM Agents`,agents:Re.filter(e=>e.type!==`browser`)},{label:`Browser Agents`,agents:Re.filter(e=>e.type===`browser`)}],[Re]),Ue=(0,_.useMemo)(()=>{let e=new Map;for(let t of Ee)e.has(t.id)||e.set(t.id,{id:t.id,name:t.name});for(let t of Ae?.servers??[])e.set(t.id,{id:t.id,name:t.name});return Array.from(e.values()).sort((e,t)=>e.id.localeCompare(t.id))},[Ae?.servers,Ee]);(0,_.useEffect)(()=>{Le&&xe.some(e=>e.id===Le)&&n(Le)},[Le,xe]);let We=(0,_.useRef)(``);(0,_.useEffect)(()=>{let e=Ae?`${Ae.id}::${Ae.sourcePath??``}`:``;if(e===We.current)return;if(We.current=e,!Ae){T([]),D(`agent_default`),A([]),M(!1),P([]),L({}),z({});return}let t=IY(Ae);T(t.length>0?t:Re.map(e=>e.id)),D(`agent_default`),A(ze.map(e=>e.id)),M(!1),P([]),L({}),z({})},[Ae?.id,Ae?.sourcePath,Re,ze]);let Ge=async()=>{if(!Ae?.sourcePath){u(e=>[...e,`[${P7()}] Missing source path for selected config.`]);return}let e=Re.filter(e=>w.includes(e.id));if(e.length===0){u(e=>[...e,`[${P7()}] Select at least one agent.`]);return}let t=ze.filter(e=>k.includes(e.id)),n=new Set(t.map(e=>e.id)),r=j||Object.values(F).some(Boolean),i=Object.fromEntries(Object.entries(R).filter(([e])=>n.has(e)&&F[e])),a=t.map(e=>{let t=i[e.id]??(j?N:e.serverIds||[]);return`${e.id}=[${t.join(`, `)}]`}).join(`; `);if(t.length===0){u(e=>[...e,`[${P7()}] Select at least one test.`]);return}if(j&&N.length===0){u(e=>[...e,`[${P7()}] Select at least one server for "Override MCP Servers for Selected Tests", or turn that override off.`]);return}let s=Object.entries(i).filter(([,e])=>!Array.isArray(e)||e.length===0).map(([e])=>e);if(s.length>0){u(e=>[...e,`[${P7()}] Select at least one server for per-scenario overrides on: ${s.join(`, `)}, or turn those overrides off.`]);return}let l=Array.from(new Set(t.flatMap(e=>r?i[e.id]?i[e.id]??[]:j?N:e.serverIds||[]:e.serverIds||[]).filter(e=>{let t=(Ae.servers??[]).find(t=>t.id===e),n=Ee.find(t=>t.id===e);return(t||n)?.authType===`oauth2`})));try{l.length>0&&(pe(!0),await e6({serverNames:l,source:Ce,onServerAuthStart:e=>{u(t=>[...t,`[${P7()}] OAuth login required for '${e}'. Complete the browser sign-in flow...`])}}),u(e=>[...e,`[${P7()}] OAuth login completed for required server(s): ${l.join(`, `)}.`]))}catch(e){let t=e instanceof Error?e.message:String(e);u(e=>[...e,`[${P7()}] OAuth error: ${t}`]),pe(!1);return}finally{pe(!1)}o(!0),f(!1),y(!1),x(``);let d=(Ae.serverEntries??[]).some(e=>e.kind===`referenced`)||(Ae.agentEntries??[]).some(e=>e.kind===`referenced`)||(Ae.scenarioEntries??[]).some(e=>e.kind===`referenced`)?`refs-composed`:`single-file/inline`,p={...Be.length>0&&E!==`agent_default`?{newConversationBeforeStart:E===`new`,newConversationBetweenScenarios:E===`new`}:{}};u([`[${P7()}] Starting evaluation run...`,`[${P7()}] Config=${Ae.name} mode=${d} agents=${e.map(e=>e.name||e.id).join(`, `)} tests=${t.map(e=>e.id).join(`, `)} runs=${Ve}${Be.length>0?` newConversationBeforeStart=${p.newConversationBeforeStart??`agent_default`} newConversationBetweenScenarios=${p.newConversationBetweenScenarios??`agent_default`}`:``}${ee.trim()?` note=${ee.trim()}`:``}`,`[${P7()}] Effective MCP servers per selected test: ${a||`(none)`}`]),c(10);try{let{jobId:n}=await Ce.startRun({configPath:Ae.sourcePath,runsPerScenario:Ve,agents:e.map(e=>e.id),scenarioIds:t.map(e=>e.id),...p,...r&&j?{serverOverrideAll:N}:{},...r&&Object.keys(i).length>0?{scenarioServerOverrides:i}:{},runNote:ee.trim()?ee.trim():void 0});C(n),Ye(n),rt(n),Xe()}catch(e){let t=e instanceof Error?e.message:String(e),n=t.includes(`Anthropic model not found`)?` Hint: this usually means the API key works but the model ID is not enabled for that Anthropic account. Change the agent model in Manage Agents (library) or inline config.`:``;u(e=>[...e,`[${P7()}] Error: ${t}${n}`]),o(!1),c(0),C(null),pe(!1)}},Ke=()=>{Ge()},qe=()=>{ve.current=null,S&&Ce.stopRun(S),_e.current?.(),_e.current=null,Je(),C(null),o(!1),f(!1),y(!0),u(e=>[...e,`[${P7()}] Run aborted by user.`]),Xe()};(0,_.useEffect)(()=>{ge.current&&(ge.current.scrollTop=ge.current.scrollHeight)},[l]),(0,_.useEffect)(()=>()=>{ve.current=null,_e.current?.()},[]),(0,_.useEffect)(()=>{if(S||d)return;let e=``;try{e=sessionStorage.getItem(N7)??``}catch{e=``}if(e)return C(e),o(!0),f(!1),y(!1),u(e=>e.length>0?e:[`[${P7()}] Reattached to in-progress evaluation run...`]),rt(e),()=>{}},[S,d]);let Je=()=>{try{sessionStorage.removeItem(N7)}catch{}},Ye=e=>{try{sessionStorage.setItem(N7,e)}catch{}},Xe=async(e=!1)=>{try{let t=await Ce.getRunQueue(),n=t.evaluations??[],r=new Set(n.map(e=>e.evaluationRunId)),i=ye.current;if(e&&!ve.current){let e=Array.from(i.values()).find(e=>[`queued`,`running`].includes(e.status)&&!r.has(e.evaluationRunId));e&&Ce.getResult(e.evaluationRunId).then(t=>{if(!t||ve.current)return;let n=(t.outcomes?.stopped??0)>0||(t.outcomes?.incomplete??0)>0;o(!1),c(100),x(e.evaluationRunId),g(null),m((t.outcomes?.error??0)>0),y(n),f(!n)}).catch(()=>{})}ye.current=new Map(n.map(e=>[e.evaluationRunId,e])),re(t.queued),ae(t.active_jobs??(t.active?[t.active]:[])),se(t.admitting_jobs??[]),B((t.evaluations??[]).filter(e=>![`completed`,`partial`,`failed`].includes(e.status)));let a=S==null?void 0:t.queued.find(e=>e.jobId===S&&e.status===`blocked_auth`&&e.blockedReason===`oauth_required`);a&&(a.requiredServers??[]).length>0?he(e=>e?.jobId===a.jobId?e:{jobId:a.jobId,servers:a.requiredServers}):(me?.jobId&&me.jobId!==S||S!=null&&!t.queued.some(e=>e.jobId===S&&e.status===`blocked_auth`&&e.blockedReason===`oauth_required`))&&he(null)}catch{}},Ze=()=>{Se(),De()};(0,_.useEffect)(()=>{Ze(),Xe();let e=Ce.subscribeRunQueue(e=>{e.type===`queue_event`&&Xe(!0)}),t=()=>{Ze(),Xe()},n=()=>{Xe()};return window.addEventListener(`focus`,t),window.addEventListener(`mcplab:run-queue-changed`,n),()=>{window.removeEventListener(`focus`,t),window.removeEventListener(`mcplab:run-queue-changed`,n),e()}},[Se,De,Ce]);let Qe=async e=>{try{await Ce.removeQueuedRun(e),re(t=>t.filter(t=>t.jobId!==e))}catch(t){let n=t instanceof Error?t.message:String(t);if(n.includes(`Use the /stop endpoint`))try{await Ce.stopRun(e)}catch{}else O({title:`Could not remove queued run`,description:n,variant:`destructive`})}Xe()},$e=async e=>{let t=Array.from(new Set(e.jobs.flatMap(e=>e.requiredServers??[])));if(!(t.length===0||be.current)){be.current=!0,pe(!0);try{await e6({serverNames:t,source:Ce}),await Ce.resumeQueue()}catch(e){O({title:`Could not connect OAuth`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{be.current=!1,pe(!1),Xe()}}},et=async e=>{if(de!==e){V(e);try{await Ce.stopEvaluationRun(e),await Xe()}catch(e){O({title:`Could not stop run`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{V(null)}}},tt=async e=>{try{await Ce.removeEvaluationRun(e),await Xe()}catch(e){O({title:`Could not remove run`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}},nt=async e=>{try{await Ce.openRover(e),await Xe()}catch(e){O({title:`Could not open browser agent`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}},rt=e=>{S===e&&_e.current||(_e.current?.(),ve.current=e,_e.current=Ce.subscribeRunJob(e,t=>{let n=new Date(t.ts).toLocaleTimeString();if(t.type===`queued`)u(e=>{let r=t.payload.position?` (position ${t.payload.position})`:``,i=`[${n}] Run queued${r}. Waiting for active run to finish...`;return e.includes(i)?e:[...e,i]}),c(5);else if(t.type===`oauth_required`){let e=Array.isArray(t.payload.servers)?t.payload.servers:[],r=String(t.payload.jobId??``);he({jobId:r,servers:e}),u(t=>{let r=`[${n}] OAuth required for server(s): ${e.join(`, `)}. Click "Connect & Resume" to authenticate.`;return t.includes(r)?t:[...t,r]})}else{if(t.type===`started`&&(he(null),be.current=!1,o(!0),f(!1),y(!1),u(e=>{let t=`[${n}] Run started.`;return e.includes(t)?e:[...e,t]}),c(e=>Math.max(e,30)),Xe()),t.type===`log`){let e=String(t.payload.message??``).trim();e&&(u(t=>{let r=`[${n}] ${e}`;return t.includes(r)?t:[...t,r]}),c(t=>{let n=e.toLowerCase();if(n.startsWith(`loading mcp evaluation config`))return Math.max(t,15);if(n.startsWith(`loaded config`))return Math.max(t,20);if(n.startsWith(`selected `))return Math.max(t,30);if(n.startsWith(`using requested agents`)||n.startsWith(`using run default agents`)||n.startsWith(`using config-declared agents`))return Math.max(t,35);if(n.startsWith(`expanded to `))return Math.max(t,45);if(n.startsWith(`running evaluation`))return Math.max(t,50);let r=n.match(/^scenario (\d+)\/(\d+) finished:/);if(r){let e=Number(r[1]),n=Number(r[2]);return Math.max(t,50+Math.round(e/n*25))}return n.startsWith(`evaluation execution finished`)?Math.max(t,78):n.startsWith(`writing results to `)?Math.max(t,94):n.startsWith(`run finished:`)?Math.max(t,98):t}))}if(t.type===`completed`||t.type===`error`){let r=t.type===`error`,i=String(t.payload.runId??``).trim(),a=n=>t.payload.status===`stopped`||[`Run stopped by user`,`Run aborted by user`].includes(String(t.payload.message))||n?.status===`stopped`||n?.jobs.find(t=>t.jobId===e)?.status===`stopped`,s=e=>{if(!r||a(e))return;let i=String(t.payload.message??`Unknown error`),o=i.includes(`Anthropic model not found`)?` Hint: this usually means the API key works but the model ID is not enabled for that Anthropic account. Change the agent model in Manage Agents (library) or inline config.`:``;u(e=>[...e,`[${n}] Error: ${i}${o}`])},l=e=>{s(e);let t=r&&!a(e)||(e?.failedJobs??0)-(e?.stoppedJobs??0)>0,l=a(e)&&!t&&!e?.completedJobs&&!i;he(null),be.current=!1,u(r=>{let i=`[${n}] ${t?`Run completed with errors.`:a(e)?`Run stopped.`:`Run completed.`}`;return r.includes(i)?r:[...r,i]}),c(100),o(!1),f(!l),m(t),g(e??null),y(l),x(e?.completedJobs?e.evaluationRunId:r&&!a(e)?``:i),Je(),C(null),ve.current=null,_e.current?.(),_e.current=null,Xe()};Ce.getRunQueue().then(t=>{if(ve.current!==e)return;let r=t.evaluations?.find(t=>t.jobs.some(t=>t.jobId===e))??t.evaluations?.find(e=>e.evaluationRunId===i),a=r?.jobs.find(t=>t.jobId!==e&&[`queued`,`waiting_for_rover`,`paused_rover`,`running`].includes(t.status))??r?.jobs.find(t=>t.jobId!==e&&t.status===`blocked_auth`);if(a&&r){s(r);let e=r.completedJobs+r.failedJobs,t=`[${n}] Subtask finished. ${e}/${r.totalJobs} finished. Continuing with the remaining run tasks...`;u(e=>e.includes(t)?e:[...e,t]),c(t=>Math.max(t,r.totalJobs>0?Math.round(e/r.totalJobs*100):t)),he(a.status===`blocked_auth`?{jobId:a.jobId,servers:a.requiredServers??[]}:null),be.current=!1,o(!0),f(!1),y(!1),C(a.jobId),Ye(a.jobId),Xe(),rt(a.jobId)}else l(r)}).catch(()=>{ve.current===e&&l()})}}}))},it=e=>{S===e&&_e.current||(C(e),Ye(e),o(!0),f(!1),y(!1),u([`[${P7()}] Attached to running job ${e}...`]),c(10),rt(e))};return(0,I.jsxs)(`div`,{className:`space-y-6`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`h1`,{className:`inline-flex items-center gap-2 text-2xl font-bold`,children:[(0,I.jsx)(Yn,{className:`h-6 w-6`}),`Run Evaluation`]}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Execute evaluation scenarios against MCP servers`})]}),(0,I.jsx)(K,{children:(0,I.jsxs)(q,{className:`pt-6 space-y-4`,children:[(0,I.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(Q,{children:`MCP Evaluation`}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsxs)(OY,{value:t,onValueChange:n,children:[(0,I.jsx)(AY,{children:(0,I.jsx)(kY,{placeholder:`Select a config`})}),(0,I.jsx)(NY,{children:xe.map(e=>{let t=vfe(e);return(0,I.jsxs)(Z,{value:e.id,children:[(0,I.jsx)(`span`,{children:_fe(e)}),t&&(0,I.jsxs)(`span`,{className:`ml-2 text-muted-foreground`,children:[`(`,t,`)`]})]},e.id)})})]}),(0,I.jsx)(W,{type:`button`,variant:`outline`,size:`icon`,className:`h-10 w-10 shrink-0`,onClick:Ze,"aria-label":`Refresh configs`,title:`Refresh configs`,children:(0,I.jsx)(Qn,{className:`h-4 w-4`})})]})]}),(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(Q,{htmlFor:`variance-runs`,children:`Variance Runs`}),(0,I.jsx)(Op,{id:`variance-runs`,type:`number`,min:`1`,max:`10`,value:Be.length>0?`1`:r,onChange:e=>i(e.target.value),disabled:Be.length>0}),Be.length>0&&(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Browser agents support one run per scenario.`})]})]}),(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsx)(Q,{htmlFor:`run-note`,children:`Run Note`}),(0,I.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[ee.length,`/500`]})]}),(0,I.jsx)(iX,{id:`run-note`,value:ee,onChange:e=>te(e.target.value.slice(0,500)),placeholder:`Optional context for this run (for example: mcp-server v1.8.2 #staging)`,rows:2})]}),Ae&&(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsx)(Q,{children:`Agents`}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,I.jsx)(`button`,{type:`button`,className:`text-primary hover:underline`,onClick:()=>T(Re.map(e=>e.id)),children:`Select all`}),(0,I.jsx)(`button`,{type:`button`,className:`text-primary hover:underline`,onClick:()=>T([]),children:`Clear`})]})]}),(0,I.jsx)(`div`,{className:`space-y-3`,children:He.map(e=>e.agents.length>0?(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,I.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:e.label}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,I.jsx)(`button`,{type:`button`,className:`text-primary hover:underline`,"aria-label":`Select all ${e.label}`,onClick:()=>{let t=new Set(e.agents.map(e=>e.id));T(e=>[...e.filter(e=>!t.has(e)),...t])},children:`Select all`}),(0,I.jsx)(`button`,{type:`button`,className:`text-primary hover:underline`,"aria-label":`Clear ${e.label}`,onClick:()=>{let t=new Set(e.agents.map(e=>e.id));T(e=>e.filter(e=>!t.has(e)))},children:`Clear`})]})]}),(0,I.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:e.agents.map(e=>{let t=w.includes(e.id);return(0,I.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md border p-2 text-sm`,children:[(0,I.jsx)(KX,{checked:t,onCheckedChange:t=>{let n=t===!0;T(t=>n?[...t,e.id]:t.filter(t=>t!==e.id))}}),(0,I.jsx)(`span`,{children:e.name||e.id})]},e.id)})})]},e.label):null)}),Be.length>0&&(0,I.jsxs)(`div`,{className:`space-y-1.5 rounded-md border bg-muted/20 p-3`,children:[(0,I.jsx)(Q,{htmlFor:`conversation-behavior`,children:`Conversation behavior`}),(0,I.jsxs)(OY,{value:E,onValueChange:e=>D(e),children:[(0,I.jsx)(AY,{id:`conversation-behavior`,children:(0,I.jsx)(kY,{})}),(0,I.jsxs)(NY,{children:[(0,I.jsx)(Z,{value:`agent_default`,children:`Use agent default`}),(0,I.jsx)(Z,{value:`new`,children:`Start a new conversation`}),(0,I.jsx)(Z,{value:`same`,children:`Continue the same conversation`})]})]}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`This setting is frozen into the Rover job. Rover cannot change it locally.`})]}),Re.length===0&&(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No agents available. Add agents to your workspace library, or define inline agents in this config.`})]}),Ae&&(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsx)(Q,{children:`Tests`}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,I.jsx)(`button`,{type:`button`,className:`text-primary hover:underline`,onClick:()=>A(ze.map(e=>e.id)),children:`Select all`}),(0,I.jsx)(`button`,{type:`button`,className:`text-primary hover:underline`,onClick:()=>A([]),children:`Clear`})]})]}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[k.length,` of `,ze.length,` selected`]}),(0,I.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:ze.map(e=>{let t=k.includes(e.id),n=R[e.id],r=!!F[e.id],i=r&&Array.isArray(n),a=new Set(e.serverIds||[]);return(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm rounded-md border p-2 cursor-pointer`,onClick:n=>{let r=n.target;r&&(r.closest(`button, a, input, select, textarea, [role='button']`)||A(n=>t?n.filter(t=>t!==e.id):[...n,e.id]))},children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,I.jsx)(KX,{checked:t,onCheckedChange:t=>{let n=t===!0;A(t=>n?[...t,e.id]:t.filter(t=>t!==e.id))}}),(0,I.jsxs)(`span`,{className:`min-w-0`,children:[(0,I.jsxs)(`span`,{className:`block font-medium`,children:[e.name||e.id,` `,i&&(0,I.jsx)(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] text-primary`,children:`Override`})]}),(0,I.jsx)(`span`,{className:`block font-mono text-xs text-muted-foreground truncate`,children:e.id})]})]}),t&&(0,I.jsxs)(`div`,{className:`pl-6`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsx)(Q,{className:`text-[11px] text-muted-foreground`,children:`Per-scenario: "Override MCP Servers"`}),(0,I.jsx)(L5,{checked:r,onCheckedChange:t=>{if(L(n=>({...n,[e.id]:t})),!t)z(t=>{let n={...t};return delete n[e.id],n});else if(!R[e.id]){let t=j&&N.length>0?[...N]:[...e.serverIds||[]];z(n=>({...n,[e.id]:t}))}}})]}),r&&(0,I.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:Ue.map(t=>{let r=t.id,i=(n??[]).includes(r),o=a.has(r);return(0,I.jsx)(Y,{variant:i?`default`:`outline-solid`,className:`cursor-pointer text-xs ${i?``:`opacity-60 hover:opacity-100`}`,style:!i&&o?{borderColor:`hsl(var(--primary))`}:void 0,onClick:t=>{t.stopPropagation(),z(t=>{let n=t[e.id]??[],i=n.includes(r)?n.filter(e=>e!==r):[...n,r];return{...t,[e.id]:i}})},children:t.name?.trim()?t.name:r},r)})})]})]},e.id)})}),(0,I.jsxs)(`div`,{className:`space-y-1 rounded-md border p-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(`div`,{className:`text-xs`,children:[(0,I.jsx)(`span`,{children:`Override MCP Servers for selected Tests `}),(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:`Selected tests run against the servers you choose here. Applies only to this run.`})]}),(0,I.jsx)(L5,{checked:j,onCheckedChange:M})]}),j&&(0,I.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Ue.map(e=>{let t=e.id,n=N.includes(t);return(0,I.jsx)(Y,{variant:n?`default`:`outline-solid`,className:`cursor-pointer text-xs ${n?``:`opacity-60 hover:opacity-100`}`,onClick:()=>P(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t]),children:e.name?.trim()?e.name:t},t)})})]})]}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsxs)(W,{onClick:Ke,disabled:!t||fe||Re.length>0&&w.length===0||ze.length>0&&k.length===0,children:[(0,I.jsx)(Yn,{className:`mr-2 h-4 w-4`}),Pe?`Queue Run`:`Run`]}),a&&(0,I.jsxs)(W,{variant:`destructive`,onClick:qe,children:[(0,I.jsx)(sr,{className:`mr-2 h-4 w-4`}),`Stop`]})]})]})}),(a||l.length>0)&&(0,I.jsxs)(K,{children:[(0,I.jsx)(gv,{className:`pb-3`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsx)(_v,{className:`text-base`,children:`Progress`}),(0,I.jsxs)(`span`,{className:`text-xs text-muted-foreground font-mono`,children:[Math.round(Ie),`%`]})]})}),(0,I.jsxs)(q,{className:`space-y-4`,children:[(0,I.jsx)(t7,{value:Ie,className:`h-2`}),(Fe||Pe)&&(0,I.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground`,children:Fe?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`span`,{children:[Fe.completedJobs,`/`,Fe.totalJobs,` subtasks complete`]}),Fe.failedJobs-Fe.stoppedJobs>0&&(0,I.jsxs)(`span`,{className:`font-medium text-destructive`,children:[Fe.failedJobs-Fe.stoppedJobs,` failed`]}),Fe.stoppedJobs>0&&(0,I.jsxs)(`span`,{className:`font-medium text-muted-foreground`,children:[Fe.stoppedJobs,` stopped`]}),Fe.pausedJobs>0&&(0,I.jsxs)(`span`,{className:`font-medium text-yellow-700 dark:text-yellow-400`,children:[Fe.pausedJobs,` paused`]}),(0,I.jsx)(Y,{variant:`outline`,className:`capitalize`,children:Fe.status})]}):(0,I.jsx)(`span`,{children:Pe?.roverProgress?`${Pe.roverProgress.completed}/${Pe.roverProgress.total} scenarios complete`:`Attached to active run`})}),me&&(0,I.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-yellow-500/40 bg-yellow-500/10 px-3 py-2 text-sm`,children:[(0,I.jsxs)(`span`,{className:`text-yellow-700 dark:text-yellow-400`,children:[`OAuth required for: `,(0,I.jsx)(`strong`,{children:me.servers.join(`, `)})]}),(0,I.jsx)(W,{size:`sm`,variant:`outline`,disabled:fe,onClick:()=>{be.current||(be.current=!0,pe(!0),e6({serverNames:me.servers,source:Ce,onServerAuthStart:e=>{u(t=>[...t,`[${P7()}] OAuth sign-in opened for '${e}'...`])}}).then(()=>Ce.resumeQueue()).then(()=>{let e=me?.jobId;u(e=>[...e,`[${P7()}] OAuth complete. Resuming run...`]),e&&(C(e),Ye(e),o(!0),f(!1),rt(e))}).catch(e=>{let t=e instanceof Error?e.message:String(e);u(e=>[...e,`[${P7()}] OAuth error: ${t}`]),be.current=!1}).finally(()=>{pe(!1)}))},children:fe?`Connecting...`:`Connect & Resume`})]}),(0,I.jsx)(`div`,{ref:ge,className:`h-64 overflow-auto rounded-md border bg-muted/30 p-3 font-mono text-xs space-y-0.5`,children:l.map((e,t)=>(0,I.jsx)(`div`,{className:e.includes(`✓`)?`text-success`:e.includes(`aborted`)?`text-destructive`:`text-foreground`,children:e},t))})]})]}),(0,I.jsxs)(K,{children:[(0,I.jsx)(gv,{className:`pb-3`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(_v,{className:`inline-flex items-center gap-2 text-base`,children:[(0,I.jsx)(_n,{className:`h-4 w-4`}),`Run Queue`]}),(0,I.jsx)(W,{variant:`ghost`,size:`sm`,onClick:()=>void Xe(),children:(0,I.jsx)(Qn,{className:`h-3 w-3`})})]})}),(0,I.jsx)(q,{children:!Pe&&oe.length===0&&ne.length===0&&ce.length===0?(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No active or queued runs. Start a run above.`}):(0,I.jsxs)(`div`,{className:`space-y-2`,children:[ce.map(e=>(0,I.jsxs)(`div`,{onClick:()=>{let t=e.jobs.find(e=>e.status===`running`||e.status===`waiting_for_rover`||e.status===`paused_rover`);t&&it(t.jobId)},className:`rounded-md border p-3 text-sm ${e.status===`failed`?`border-destructive/40 bg-destructive/5`:e.status===`stopped`?`border-muted-foreground/30 bg-muted/40`:e.status===`partial`?`border-yellow-500/40 bg-yellow-500/5`:e.status===`running`?`border-primary/20 bg-primary/5`:`border-border bg-background`}`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`font-semibold`,children:e.evaluationName||`Evaluation`}),(0,I.jsx)(Y,{variant:`outline`,className:`capitalize ${e.status===`running`?`border-emerald-500/40 bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`:``}`,children:e.status}),(0,I.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[e.completedJobs,`/`,e.totalJobs,` scenario-agent runs complete`]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[e.jobs.some(e=>e.status===`blocked_auth`)&&(0,I.jsx)(W,{size:`sm`,variant:`outline`,className:`h-7 text-xs border-yellow-500/50 text-yellow-700 dark:text-yellow-400`,disabled:fe,onClick:()=>void $e(e),children:fe?`Connecting...`:`Connect OAuth`}),e.jobs.some(F7)&&(0,I.jsx)(W,{size:`sm`,variant:`outline`,className:`h-7 text-xs`,onClick:()=>{let t=e.jobs.find(F7);t&&nt(t.jobId)},title:`Open the browser-agent URL, then activate the Rover extension`,children:`Open browser agent`}),(0,I.jsx)(W,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs`,onClick:()=>ue(t=>t===e.evaluationRunId?null:e.evaluationRunId),"aria-label":`${le===e.evaluationRunId?`Collapse`:`Expand`} evaluation details`,children:le===e.evaluationRunId?`Hide`:`Details`}),e.jobs.length>0&&(e.jobs.every(e=>[`queued`,`blocked_auth`,`waiting_for_rover`,`stopped`].includes(e.status))||e.status===`stopped`&&e.jobs.every(e=>[`completed`,`error`,`stopped`].includes(e.status)))&&(0,I.jsxs)(W,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs text-muted-foreground hover:text-destructive`,onClick:()=>void tt(e.evaluationRunId),title:e.status===`stopped`?`Remove stopped run from the queue`:`Remove evaluation from queue`,"aria-label":e.status===`stopped`?`Remove stopped run from queue`:`Remove evaluation from queue`,children:[(0,I.jsx)(hr,{className:`mr-1 h-3 w-3`}),e.status===`stopped`?`Remove run`:`Remove`]}),e.jobs.some(e=>[`blocked_auth`,`waiting_for_rover`,`paused_rover`,`running`].includes(e.status))&&(0,I.jsxs)(W,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs text-destructive hover:text-destructive hover:bg-destructive/10`,disabled:de===e.evaluationRunId,onClick:()=>void et(e.evaluationRunId),title:`Stop this evaluation run and its queued or running tasks`,children:[(0,I.jsx)(sr,{className:`mr-1 h-3 w-3`}),de===e.evaluationRunId?`Stopping run...`:`Stop run`]})]})]}),le===e.evaluationRunId&&(0,I.jsx)(`div`,{className:`mt-2 space-y-1 text-xs text-muted-foreground`,children:yfe(e).map(({job:e,child:t},n)=>(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded px-2 py-1 ${t?.status===`completed`?`border border-emerald-500/30 bg-emerald-500/10 text-emerald-800 dark:text-emerald-300`:t?.status===`error`||t?.status===`stopped`?`border border-destructive/30 bg-destructive/5`:`bg-background`}`,onClick:()=>it(e.jobId),children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 truncate`,children:[(0,I.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[n+1,`.`]}),(t?t.status===`running`:e.status===`running`)&&(0,I.jsx)(Kg,{label:`Subjob running`}),t?.status===`completed`&&(0,I.jsx)(dn,{className:`h-3.5 w-3.5 shrink-0 text-emerald-600 dark:text-emerald-400`}),(t?.status===`error`||t?.status===`stopped`)&&(0,I.jsx)(hr,{className:`h-3.5 w-3.5 shrink-0 text-destructive`}),t?`${t.scenarioId} · ${t.agentName}: `:`${e.roverAgent?.name??e.runParams.agents?.join(`, `)??`Agent`}: `,t?.status===`queued`?`queued`:t?.status===`running`?`running`:t?.status===`completed`?`completed`:t?.status===`error`?`error`:t?.status===`stopped`?`stopped`:e.status===`waiting_for_rover`?`waiting for Rover`:e.status===`paused_rover`?`paused`:e.status.replaceAll(`_`,` `),t?` (${t.completed}/${t.total} attempts)`:e.roverProgress&&` (${e.roverProgress.completed}/${e.roverProgress.total} scenarios)`,!t&&e.roverProgress?.lastDurationMs!=null&&` · ${Math.round(e.roverProgress.lastDurationMs/1e3)}s`,t?.error&&` · ${t.error}`,!t&&e.roverProgress?.error&&` · ${e.roverProgress.error}`]}),(0,I.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,onClick:e=>e.stopPropagation(),children:[F7(e)&&(!t||e.childProgress?.[0]?.scenarioId===t.scenarioId)&&(0,I.jsx)(W,{size:`sm`,variant:`outline`,className:`h-6 px-1.5 text-[11px]`,onClick:()=>void nt(e.jobId),children:`Open browser agent`}),!t&&e.executionType===`rover`&&e.status===`paused_rover`&&(0,I.jsx)(W,{size:`sm`,variant:`outline`,className:`h-6 px-1.5 text-[11px]`,onClick:()=>{Ce.resumeRover(e.jobId).then(()=>void Xe())},children:`Resume`}),(t&&(t.status===`running`||t.status===`queued`)||!t&&e.status===`queued`||!t&&e.executionType===`rover`&&(e.status===`waiting_for_rover`||e.status===`paused_rover`||e.status===`running`))&&(0,I.jsx)(W,{size:`sm`,variant:`ghost`,className:`h-6 px-1.5 text-[11px] text-destructive`,onClick:()=>{(t?Ce.stopScenario(e.jobId,t.scenarioId,t.agentName):Ce.stopRun(e.jobId)).then(()=>void Xe())},children:t?.status===`queued`||e.status===`queued`?`Remove`:`Stop`})]})]},`${e.jobId}:${t?.scenarioId??`job`}:${t?.agentName??`job`}`))})]},e.evaluationRunId)),ie.filter(e=>!e.evaluationRunId).map(e=>(0,I.jsxs)(`div`,{role:`button`,tabIndex:0,className:`flex items-center justify-between rounded-md border border-primary/30 bg-primary/5 p-2 text-sm cursor-pointer hover:bg-primary/10 transition-colors ${S===e.jobId?`ring-2 ring-primary/40`:``}`,onClick:()=>{S!==e.jobId&&(C(e.jobId),Ye(e.jobId),o(!0),f(!1),y(!1),u([`[${P7()}] Attached to running job ${e.jobId}...`]),c(10),rt(e.jobId))},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&S!==e.jobId&&(t.preventDefault(),C(e.jobId),Ye(e.jobId),o(!0),f(!1),y(!1),u([`[${P7()}] Attached to running job ${e.jobId}...`]),c(10),rt(e.jobId))},title:`Click to view progress`,children:[(0,I.jsxs)(`div`,{className:`min-w-0 flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`inline-flex items-center rounded-full bg-primary/10 px-2 py-0.5 text-xs font-medium text-primary`,children:`Running`}),(0,I.jsx)(`span`,{className:`text-xs font-bold`,children:Me.get(e.runParams.configPath)||M7(e.runParams.scenarioIds,Ne,e.runParams.configPath)}),(0,I.jsx)(`span`,{className:`font-mono text-xs`,children:j7(e.runParams.configPath,je)}),e.runParams.agents&&(0,I.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`agents: `,e.runParams.agents.join(`, `)]}),e.runParams.runNote&&(0,I.jsxs)(`span`,{className:`text-xs text-muted-foreground truncate`,children:[`note: `,e.runParams.runNote]})]}),(0,I.jsxs)(W,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs text-destructive hover:text-destructive hover:bg-destructive/10`,onClick:t=>{t.stopPropagation(),Ce.stopRun(e.jobId),Xe()},title:`Stop running job`,children:[(0,I.jsx)(sr,{className:`mr-1 h-3 w-3`}),`Stop`]})]},e.jobId)),oe.filter(e=>!e.evaluationRunId).map(e=>{let t=j7(e.runParams.configPath,je),n=M7(e.runParams.scenarioIds,Ne,e.runParams.configPath),r=Me.get(e.runParams.configPath)||n,i=e.status===`blocked_auth`;return(0,I.jsx)(`div`,{className:`flex items-center justify-between rounded-md border p-2 text-sm ${i?`border-yellow-500/40 bg-yellow-500/5`:`border-border bg-background`}`,children:(0,I.jsxs)(`div`,{className:`min-w-0 flex items-center gap-2 flex-wrap`,children:[(0,I.jsx)(`span`,{className:`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${i?`bg-yellow-500/15 text-yellow-700 dark:text-yellow-400`:`bg-primary/10 text-primary`}`,children:i?`Retrying OAuth`:`Starting`}),(0,I.jsx)(`span`,{className:`text-xs font-bold`,children:r}),(0,I.jsx)(`span`,{className:`font-mono text-xs`,children:t}),i&&(e.requiredServers??[]).length>0&&(0,I.jsxs)(`span`,{className:`text-xs text-yellow-700 dark:text-yellow-400`,children:[`OAuth: `,e.requiredServers.join(`, `)]})]})},e.jobId)}),ne.filter(e=>!e.evaluationRunId).map((e,t)=>{let n=j7(e.runParams.configPath,je),r=M7(e.runParams.scenarioIds,Ne,e.runParams.configPath),i=Me.get(e.runParams.configPath)||r,a=e.status===`blocked_auth`;return(0,I.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border p-2 text-sm ${a?`border-yellow-500/40 bg-yellow-500/5`:``}`,children:[(0,I.jsxs)(`div`,{className:`min-w-0 flex items-center gap-2 flex-wrap`,children:[a?(0,I.jsxs)(`span`,{className:`inline-flex items-center rounded-full bg-yellow-500/15 px-2 py-0.5 text-xs font-medium text-yellow-700 dark:text-yellow-400`,children:[`#`,t+1,` Blocked`]}):(0,I.jsxs)(`span`,{className:`inline-flex items-center rounded-full bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground`,children:[`#`,t+1,` Queued`]}),(0,I.jsx)(`span`,{className:`text-xs font-bold`,children:i}),(0,I.jsx)(`span`,{className:`font-mono text-xs`,children:n}),a&&(e.requiredServers??[]).length>0&&(0,I.jsxs)(`span`,{className:`text-xs text-yellow-700 dark:text-yellow-400`,children:[`OAuth: `,e.requiredServers.join(`, `)]}),!a&&e.runParams.agents&&(0,I.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`agents: `,e.runParams.agents.join(`, `)]}),e.runParams.runNote&&(0,I.jsxs)(`span`,{className:`text-xs text-muted-foreground truncate`,children:[`note: `,e.runParams.runNote]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[a&&(0,I.jsx)(W,{size:`sm`,variant:`outline`,className:`h-7 text-xs border-yellow-500/50 text-yellow-700 dark:text-yellow-400 hover:bg-yellow-500/10`,disabled:fe,onClick:()=>{if(be.current)return;let t=e.requiredServers??[];t.length!==0&&(be.current=!0,he({jobId:e.jobId,servers:t}),pe(!0),e6({serverNames:t,source:Ce,onServerAuthStart:e=>{u(t=>[...t,`[${P7()}] OAuth sign-in opened for '${e}'...`])}}).then(()=>Ce.resumeQueue()).then(()=>{u(e=>[...e,`[${P7()}] OAuth complete. Resuming run...`]),C(e.jobId),Ye(e.jobId),o(!0),f(!1),rt(e.jobId)}).catch(e=>{let t=e instanceof Error?e.message:String(e);u(e=>[...e,`[${P7()}] OAuth error: ${t}`]),be.current=!1}).finally(()=>{pe(!1)}))},children:fe&&me?.jobId===e.jobId?`Connecting...`:`Connect & Resume`}),(0,I.jsx)(W,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>void Qe(e.jobId),title:`Remove from queue`,children:(0,I.jsx)(hr,{className:`h-4 w-4`})})]})]},e.jobId)})]})})]}),v&&!a&&!d&&(0,I.jsx)(K,{className:`border-amber-300/60 bg-amber-50/40`,children:(0,I.jsx)(q,{className:`pt-6`,children:(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,I.jsx)(sr,{className:`h-5 w-5 text-amber-700`}),(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`p`,{className:`font-medium`,children:`Run stopped`}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The evaluation was stopped before completion. You can start it again or clear the progress log.`})]}),(0,I.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,I.jsx)(W,{type:`button`,variant:`outline`,onClick:()=>{u([]),c(0),y(!1)},children:`Clear Progress`}),(0,I.jsxs)(W,{type:`button`,onClick:Ke,disabled:!t,children:[(0,I.jsx)(Yn,{className:`mr-2 h-4 w-4`}),`Run Again`]})]})]})})}),d&&(0,I.jsx)(K,{className:p?`border-amber-500/50`:h?.stoppedJobs?`border-border`:`border-success/50`,children:(0,I.jsx)(q,{className:`pt-6`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[p?(0,I.jsx)(hr,{className:`h-6 w-6 text-destructive`}):h?.stoppedJobs?(0,I.jsx)(_n,{className:`h-6 w-6 text-muted-foreground`}):(0,I.jsx)(dn,{className:`h-6 w-6 text-success`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`font-medium`,children:p?`Completed with errors`:h?.stoppedJobs?h.completedJobs?`Completed with stopped scenarios`:`Run stopped`:`Evaluation Complete`}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:h?`${h.totalJobs}/${h.totalJobs} finished, ${h.completedJobs} completed, ${Math.max(0,h.failedJobs-h.stoppedJobs)} error(s), ${h.stoppedJobs} stopped.`:p?`The evaluation ended with errors. Review the log for details.`:`All scenarios have finished. Review the results for their outcomes.`})]}),(0,I.jsx)(W,{asChild:!0,className:`ml-auto`,children:(0,I.jsx)(np,{to:ke,children:Oe?`View Results`:`View Runs`})})]})})})]})};function I7({title:e,description:t,expanded:n,onToggleExpanded:r,onHide:i,messages:a,pendingToolCalls:o,loading:s,expired:c=!1,input:l,onInputChange:u,onSend:d,onCancel:f,inputPlaceholder:p,snippets:m,snippetsLabel:h=`Result Assistant Snippets`,onSnippetSelect:g,onApproveToolCall:_,onDenyToolCall:v,inputRef:y,renderMessageFooter:b,className:x=`min-w-0 overflow-hidden xl:flex xl:h-full xl:min-h-0 xl:flex-col`,contentClassName:S=`flex h-[70vh] min-h-[520px] flex-col p-0 xl:h-auto xl:min-h-0 xl:flex-1`}){return(0,I.jsxs)(K,{className:x,children:[(0,I.jsx)(gv,{className:`border-b px-4 py-3`,children:(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsxs)(_v,{className:`flex items-center gap-2 text-base`,children:[(0,I.jsx)(ar,{className:`h-4 w-4 text-amber-500`}),e]}),(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,I.jsxs)(W,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 gap-1 px-2 text-xs`,onClick:r,children:[n?(0,I.jsx)(Gn,{className:`h-3.5 w-3.5`}):(0,I.jsx)(Kn,{className:`h-3.5 w-3.5`}),n?`Compact`:`Expand`]}),(0,I.jsx)(W,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 px-2 text-xs`,onClick:i,children:`Hide`})]})]}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t})]})}),(0,I.jsx)(q,{className:S,children:(0,I.jsx)(q3,{messages:a,toolCalls:o,busy:s,expired:c,onApprove:_,onDeny:v,renderMessageFooter:b,scrollClassName:`bg-muted/15 px-4 py-4`,composer:{input:l,onInputChange:u,onSend:d,onCancel:f,inputPlaceholder:p,snippets:m,snippetsLabel:h,onSnippetSelect:g,loading:s,inputRef:y},composerClassName:`border-t bg-background px-4 py-3`})})]})}function L7(e,t){if(!Number.isFinite(e)||e<=0)return`0ms`;if(e<1e3)return`${Math.round(e)}ms`;if(t?.preciseUnderTenSeconds&&e<1e4){let t=e/1e3,n=Math.round(t*10)/10;return`${Number.isInteger(n)?n.toFixed(0):n.toFixed(1)}s`}let n=Math.floor(e/1e3),r=Math.floor(n/3600),i=Math.floor(n%3600/60),a=n%60;return r>0?`${r}h ${i}m ${a}s`:i>0?`${i}m ${a}s`:`${a}s`}function R7(e){return e.runs.length>0?e.runs.reduce((e,t)=>e+t.duration,0):e.avgDuration}function z7(e){return e.scenarios.some(e=>e.runs.length>0)?e.scenarios.reduce((e,t)=>e+R7(t),0):typeof e.totalDurationMs==`number`&&e.totalDurationMs>=0?e.totalDurationMs:null}function B7(e){return e.runs.length>0?e.runs.reduce((e,t)=>e+t.toolCalls.reduce((e,t)=>e+t.duration,0),0):0}function V7(e){return e.scenarios.some(e=>e.runs.length>0)?e.scenarios.reduce((e,t)=>e+B7(t),0):typeof e.totalToolDurationMs==`number`&&e.totalToolDurationMs>=0?e.totalToolDurationMs:null}var H7=`hsl(152, 69%, 40%)`,U7=`hsl(0, 72%, 51%)`,W7=`hsl(215, 16%, 47%)`,G7=`hsl(38, 92%, 50%)`,K7=`hsl(38, 92%, 50%)`,q7=`hsl(270, 55%, 50%)`,J7=`hsl(215, 16%, 47%)`;function Y7(e,t=0){return e.toLocaleString(void 0,{maximumFractionDigits:t,minimumFractionDigits:t})}function X7({title:e,passed:t,failed:n,incomplete:r=0,error:i=0,stopped:a=0,notEvaluated:o=0,notExecuted:s=0}){let c=[{name:`Passed`,value:t,color:H7},{name:`Failed`,value:n,color:U7},...r>0?[{name:`Incomplete`,value:r,color:K7}]:[],...i>0?[{name:`Error`,value:i,color:q7}]:[],...a>0?[{name:`Stopped`,value:a,color:J7}]:[],...o>0?[{name:`Not evaluated`,value:o,color:W7}]:[],...s>0?[{name:`Not executed`,value:s,color:G7}]:[]];return(0,I.jsxs)(K,{children:[(0,I.jsx)(gv,{className:`p-2.5 pb-0`,children:(0,I.jsx)(_v,{className:`text-xs font-medium uppercase tracking-wider text-muted-foreground`,children:e})}),(0,I.jsxs)(q,{className:`flex h-[92px] items-center justify-center gap-2 p-0`,children:[(0,I.jsx)(`div`,{className:`h-[82px] w-[82px] shrink-0`,children:(0,I.jsx)(sT,{width:`100%`,height:`100%`,children:(0,I.jsxs)(AW,{children:[(0,I.jsx)(JL,{data:c,dataKey:`value`,nameKey:`name`,innerRadius:`55%`,outerRadius:`78%`,paddingAngle:3,children:c.map(e=>(0,I.jsx)(cT,{fill:e.color},e.name))}),(0,I.jsx)(Hw,{})]})})}),(0,I.jsxs)(`div`,{className:`space-y-0.5 text-xs`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-full`,style:{backgroundColor:H7}}),Y7(t),` passed`]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-full`,style:{backgroundColor:U7}}),Y7(n),` failed`]}),r>0&&(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-full`,style:{backgroundColor:K7}}),Y7(r),` incomplete`]}),i>0&&(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-full`,style:{backgroundColor:q7}}),Y7(i),` error`]}),a>0&&(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-full`,style:{backgroundColor:J7}}),Y7(a),` stopped`]}),o>0&&(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-full`,style:{backgroundColor:W7}}),Y7(o),` not evaluated`]}),s>0&&(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-full`,style:{backgroundColor:G7}}),Y7(s),` not executed`]})]})]})]})}function xfe({runs:e,loading:t}){let n=(0,_.useMemo)(()=>{let t=e.reduce((e,t)=>e+Math.max(0,t.totalRuns),0),n=e.reduce((e,t)=>e+(t.outcomes?.passed??Math.round(Math.max(0,t.totalRuns)*(t.overallPassRate??0))),0),r=e.reduce((e,t)=>e+(t.outcomes?.incomplete??0),0),i=e.reduce((e,t)=>e+(t.outcomes?.error??0),0),a=e.reduce((e,t)=>e+(t.outcomes?.stopped??0),0),o=e.reduce((e,t)=>e+(t.outcomes?.failed??Math.max(0,t.totalRuns-Math.round(Math.max(0,t.totalRuns)*(t.overallPassRate??0))-(t.outcomes?.incomplete??0)-(t.outcomes?.error??0)-(t.outcomes?.stopped??0))),0),s=e.reduce((e,t)=>e+Math.max(0,t.totalScenarios),0),c=e.reduce((e,t)=>(e.passed+=t.checkCounts?.passed??0,e.failed+=t.checkCounts?.failed??0,e.not_evaluated+=t.checkCounts?.not_evaluated??0,e.not_executed+=t.checkCounts?.not_executed??0,e.total+=t.checkCounts?.total??0,e),{passed:0,failed:0,not_evaluated:0,not_executed:0,total:0}),l=n=>t===0?0:e.reduce((e,t)=>e+n(t)*Math.max(0,t.totalRuns),0)/t,u=e.reduce((e,t)=>e+(t.toolTokenUsage?.totalTokens??0),0),d=e.reduce((e,t)=>e+(t.totalDurationMs??0),0),f=e.reduce((e,t)=>e+(t.totalToolDurationMs??0),0);return{totalRuns:t,passedRuns:n,failedRuns:o,incompleteRuns:r,errorRuns:i,stoppedRuns:a,checkCounts:c,totalScenarios:s,passRate:b_(n,t,a),avgToolCalls:l(e=>e.avgToolCalls),avgLatency:l(e=>e.avgLatency),totalTokens:u,totalDurationMs:d,totalToolDurationMs:f}},[e]);return t?(0,I.jsx)(K,{children:(0,I.jsx)(q,{className:`p-6 text-sm text-muted-foreground`,children:`Calculating dashboard…`})}):e.length===0?(0,I.jsx)(K,{children:(0,I.jsx)(q,{className:`p-6 text-sm text-muted-foreground`,children:`No results in the selected range.`})}):(0,I.jsx)(`div`,{className:`space-y-2`,"data-testid":`results-dashboard`,children:(0,I.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-4`,children:[(0,I.jsx)(X7,{title:`Runs Pass / Fail / Incomplete / Error / Stopped`,passed:n.passedRuns,failed:n.failedRuns,incomplete:n.incompleteRuns,error:n.errorRuns,stopped:n.stoppedRuns}),(0,I.jsx)(X7,{title:`Checks Pass / Fail / Not evaluated / Not executed`,passed:n.checkCounts.passed,failed:n.checkCounts.failed,notEvaluated:n.checkCounts.not_evaluated,notExecuted:n.checkCounts.not_executed}),(0,I.jsxs)(`div`,{className:`grid self-start content-start gap-3 sm:grid-cols-2 lg:col-span-2 lg:grid-cols-4`,children:[(0,I.jsx)(Dv,{compact:!0,title:`Scenarios`,value:Y7(n.totalScenarios),icon:Pn}),(0,I.jsx)(Dv,{compact:!0,title:`Total Runs`,value:Y7(n.totalRuns),icon:Xt}),(0,I.jsx)(Dv,{compact:!0,title:`Pass Rate`,value:n.passRate===null?`–`:`${Y7(n.passRate*100,1)}%`,icon:rn}),(0,I.jsx)(Dv,{compact:!0,title:`Avg Tool Calls`,value:Y7(n.avgToolCalls,1),icon:dn}),(0,I.jsx)(Dv,{compact:!0,title:`Avg Latency`,value:`${Y7(n.avgLatency)}ms`,icon:cr}),(0,I.jsx)(Dv,{compact:!0,title:`Tool Tokens`,value:Y7(n.totalTokens),icon:mr}),n.totalDurationMs>0?(0,I.jsx)(Dv,{compact:!0,title:`Total Time`,value:L7(n.totalDurationMs),icon:_n}):null,n.totalToolDurationMs>0?(0,I.jsx)(Dv,{compact:!0,title:`Tool Duration`,value:L7(n.totalToolDurationMs),icon:_n}):null]})]})})}function Sfe(e){let t=[];for(let n of e.scenarios)for(let e of n.runs)e.error&&t.push(e.error),t.push(...e.failureReasons);return t.map(e=>String(e??``).trim()).filter(Boolean)}function Cfe(e){let t=e.toLowerCase();return t.includes(`invalid_token`)||t.includes(`authentication failed`)||t.includes(`bearer token`)||t.includes(`oauth`)?`auth`:t.includes(`429`)||t.includes(`too many requests`)||t.includes(`rate limit`)?`rate_limit`:t.includes(`scenario error:`)||t.includes(`failed to list tools`)||t.includes(`failed to connect to mcp server`)||t.includes(`tool call failed`)||t.includes(`fetch failed`)||t.includes(`streamable http error`)?`infra`:null}function wfe(e){return e===`auth`?`Auth error`:e===`rate_limit`?`Rate limited`:`Infra error`}function Tfe(e){let t=Sfe(e);for(let e of[`auth`,`rate_limit`,`infra`]){let n=t.find(t=>Cfe(t)===e);if(n)return{kind:e,label:wfe(e),detail:n}}return null}function Efe(e){return e===`auth`?`border-amber-500/30 bg-amber-500/10 text-amber-700`:e===`rate_limit`?`border-orange-500/30 bg-orange-500/10 text-orange-700`:`border-slate-500/30 bg-slate-500/10 text-slate-700`}function Dfe({run:e}){let t=Tfe(e);return t?(0,I.jsx)(gl,{delayDuration:0,children:(0,I.jsxs)(_l,{children:[(0,I.jsx)(vl,{asChild:!0,children:(0,I.jsx)(Y,{variant:`outline`,className:`h-5 text-[10px] ${Efe(t.kind)}`,children:t.label})}),(0,I.jsx)(yl,{className:`max-w-sm text-xs`,children:(0,I.jsx)(`p`,{children:t.detail})})]})}):null}function Z7(e){let{source:t,open:n,scope:r,runId:i,onSessionSync:a}=e,o=a6({api:(0,_.useMemo)(()=>ble(t,r===`run`&&i?{scope:`run`,runId:i}:{scope:`all_runs`}),[t,r,i]),open:n,label:`MCP Lab Assistant`,recreateExpiredOnSend:!0,onSession:a}),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(),d=(0,_.useRef)(null),f=(0,_.useCallback)(async()=>{let e=s.trim();e&&(r!==`run`||i)&&(c(``),await o.send(e))},[o,s,r,i]),p=(0,_.useCallback)(()=>{let e=o.cancel();e!==void 0&&c(e)},[o]),m=(0,_.useCallback)(()=>{o.reset(),c(``),u(void 0)},[o]),h=(0,_.useCallback)(e=>{u(t=>t??{id:`result-assistant-intro`,role:`assistant`,text:e,createdAt:new Date().toISOString()})},[]),g=(0,_.useCallback)(e=>{c(e),requestAnimationFrame(()=>d.current?.focus())},[]);(0,_.useEffect)(()=>{let e=d.current;if(!e)return;e.style.height=`0px`;let t=Math.min(e.scrollHeight,160);e.style.height=`${Math.max(40,t)}px`},[s,n]);let v=(0,_.useMemo)(()=>o.messages.length===0&&l?[l]:o.messages,[o.messages,l]);return{assistantSessionId:o.sessionId,assistantMessages:v,assistantPendingToolCalls:o.pendingToolCalls,assistantInput:s,assistantLoading:o.busy,assistantTurnCancelable:o.cancelable,assistantExpired:o.expired,cancelAssistantTurn:p,assistantInputRef:d,setAssistantInput:c,askAssistant:f,approveResultAssistantToolCall:o.approve,denyResultAssistantToolCall:o.deny,applyResultAssistantSnippet:g,ensureIntroMessage:h,resetAssistantSession:m}}var Ofe=24,kfe=448;function Afe(e,{active:t,observe:n,query:r=`(min-width: 1280px)`}){let[i,a]=(0,_.useState)();return(0,_.useLayoutEffect)(()=>{if(!t){a(void 0);return}let i=window.matchMedia?.(r),o=()=>{let t=e.current;if(!t||i&&!i.matches)return a(void 0);a(Math.max(kfe,Math.round(window.innerHeight-jfe(t)-Ofe)))};o(),window.addEventListener(`resize`,o),i?.addEventListener?.(`change`,o);let s=n?.current&&typeof ResizeObserver<`u`?new ResizeObserver(o):void 0;return n?.current&&s?.observe(n.current),()=>{window.removeEventListener(`resize`,o),i?.removeEventListener?.(`change`,o),s?.disconnect()}},[t,n,r,e]),i}function jfe(e){let t=e.getBoundingClientRect().top;for(let n=e.parentElement;n;n=n.parentElement)t+=n.scrollTop;return t}async function Q7(e,t){let n=t.configPath?.trim();if(!n)throw Error(`This run has no config path in metadata.`);let r=await e.getResult(t.id)??t,i=r.rerunAgents&&r.rerunAgents.length>0?r.rerunAgents:Array.from(new Set(r.scenarios.map(e=>e.agentId).filter(Boolean)));await e.startRun({configPath:n,runsPerScenario:1,scenarioIds:r.rerunScenarioIds,agents:i.length>0?i:void 0,runNote:r.runNote,serverOverrideAll:r.rerunServerOverrideAll,scenarioServerOverrides:r.rerunScenarioServerOverrides,newConversationBeforeStart:r.rerunNewConversationBeforeStart,newConversationBetweenScenarios:r.rerunNewConversationBetweenScenarios})}var $7=[{value:`15min`,label:`Last 15min`,durationMs:9e5},{value:`30min`,label:`Last 30min`,durationMs:18e5},{value:`1h`,label:`Last hour`,durationMs:36e5},{value:`2h`,label:`Last 2 hours`,durationMs:72e5},{value:`4h`,label:`Last 4 hours`,durationMs:144e5},{value:`8h`,label:`Last 8 hours`,durationMs:288e5},{value:`24h`,label:`Last 24 hours`,durationMs:864e5},{value:`7d`,label:`Last 7 days`,durationMs:6048e5},{value:`14d`,label:`Last 14 days`,durationMs:12096e5},{value:`30d`,label:`Last 30 days`,durationMs:2592e6}];function e9(e){return e===`all`||e===`last`||e===`custom`}function t9(e){return e===`15min`||e===`30min`||e===`1h`||e===`2h`||e===`4h`||e===`8h`||e===`24h`||e===`7d`||e===`14d`||e===`30d`}function n9(e){let t=e.get(`time_filter`),n=e.get(`time_preset`);return{mode:e9(t)?t:`all`,preset:t9(n)?n:`15min`,start:e.get(`time_start`)??``,end:e.get(`time_end`)??``}}var r9=8,i9=`mcplab:results:time-filter`,a9=`mcplab:results:dashboard-visible`;function o9(e){if(!e.trim())return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t}function s9(e,t,n,r){if(e===`all`)return{};if(e===`last`){let e=$7.find(e=>e.value===t)??$7[0],n=new Date(Date.now());return{since:new Date(n.getTime()-e.durationMs).toISOString(),until:n.toISOString()}}let i=o9(n),a=o9(r);return i&&a?i.getTime()<=a.getTime()?{since:i.toISOString(),until:a.toISOString()}:{since:a.toISOString(),until:i.toISOString()}:i?{since:i.toISOString()}:a?{until:a.toISOString()}:{}}function c9(e){let t=o9(e);return t?t.toLocaleString():``}function Mfe(e){let t=o9(e);return t?`${t.getUTCFullYear()}-${String(t.getUTCMonth()+1).padStart(2,`0`)}-${String(t.getUTCDate()).padStart(2,`0`)}`:e}function Nfe(e){let t=o9(e);return t?t.toLocaleDateString(void 0,{weekday:`long`,month:`short`,day:`numeric`,year:`numeric`,timeZone:`UTC`}):`Unknown day`}function Pfe(e){return e.has(`time_filter`)||e.has(`time_preset`)||e.has(`time_start`)||e.has(`time_end`)}function Ffe(){try{let e=localStorage.getItem(i9);if(!e)return null;let t=JSON.parse(e);return{mode:e9(typeof t.mode==`string`?t.mode:null)?t.mode:`all`,preset:t9(typeof t.preset==`string`?t.preset:null)?t.preset:`15min`,start:typeof t.start==`string`?t.start:``,end:typeof t.end==`string`?t.end:``}}catch{return null}}function Ife(){try{let e=localStorage.getItem(a9);return e===null||e===`true`}catch{return!0}}var Lfe=[{label:`Summarize Run Trends`,description:`Highlight the main changes across the selected runs.`,prompt:`Summarize the main trends across these runs. Call out pass-rate changes, latency, and tool usage shifts.`},{label:`Explain Failures`,description:`Identify the most important failures and likely root causes.`,prompt:`Identify the most important failures across these runs and explain likely root causes from the traces.`},{label:`Compare Agents`,description:`Compare agent behavior, tool use, and answer quality across runs.`,prompt:`Compare agent behavior across these runs. Highlight differences in tool use, answer quality, and consistency.`},{label:`Spot Anomalies`,description:`Find outliers in latency, tool calls, or pass rate.`,prompt:`Find unusual runs or outliers in latency, tool calls, or pass rate, and explain why they stand out.`}],l9=100,Rfe=()=>{let[e,t]=cp(),{source:n}=nv(),[r]=(0,_.useState)(()=>Pfe(e)?n9(e):Ffe()??n9(e)),[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)([]),c=(0,_.useRef)(0),l=(0,_.useRef)(null),u=(0,_.useRef)(null),[d,f]=(0,_.useState)(!0),[p,m]=(0,_.useState)(Ife),[h,g]=(0,_.useState)(!1),[v,y]=(0,_.useState)(null),[b,x]=(0,_.useState)(!1),[S,C]=(0,_.useState)(`timestamp`),[w,T]=(0,_.useState)(`desc`),[E,D]=(0,_.useState)(`all`),[k,A]=(0,_.useState)(!1),[j,M]=(0,_.useState)(r.mode),[N,P]=(0,_.useState)(r.preset),[F,L]=(0,_.useState)(r.start),[R,z]=(0,_.useState)(r.end),[ee,te]=(0,_.useState)(!1),[ne,re]=(0,_.useState)(!1),[ie,ae]=(0,_.useState)(!1),oe=Afe(u,{active:ne,observe:l}),se=oe!==void 0,{completionVersion:ce}=sv(),B=w7(l9),{offset:le,totalCount:ue,hasMore:de}=B,[V,fe]=(0,_.useState)(null),pe=E===`all`?void 0:E,me=e=>{S===e?T(e=>e===`asc`?`desc`:`asc`):(C(e),T(e===`timestamp`?`desc`:`asc`))},he=(0,_.useCallback)(async()=>{if(!p||!n.listRunSummaries)return;let e=++c.current;f(!0);try{let t=await n.listRunSummaries({...s9(j,N,F,R),scenario:pe});c.current===e&&s(t.map(NW))}catch{c.current===e&&s([])}finally{c.current===e&&f(!1)}},[pe,p,n,R,j,N,F]),ge=async()=>{g(!0);try{let e=s9(j,N,F,R);if(n.listRunSummariesPage){let t=await n.listRunSummariesPage({...e,scenario:pe,limit:l9,offset:le});B.updateMeta(t),a(t.data.map(NW))}else if(n.listRunSummaries){let t=await n.listRunSummaries({...e,scenario:pe,limit:l9,offset:le});B.setTotalCount(t.length),B.setHasMore(!1),a(t.map(NW))}else B.setTotalCount(0),B.setHasMore(!1),a(await n.listResults());he()}catch(e){O({title:`Could not load results`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{g(!1)}};(0,_.useEffect)(()=>{let e=!0;g(!0);let t=s9(j,N,F,R);return(n.listRunSummariesPage?n.listRunSummariesPage({...t,scenario:pe,limit:l9,offset:le}).then(t=>(e&&B.updateMeta(t),t.data.map(NW))):n.listRunSummaries?n.listRunSummaries({...t,scenario:pe,limit:l9,offset:le}).then(t=>(e&&(B.setTotalCount(t.length),B.setHasMore(!1)),t.map(NW))):n.listResults()).then(t=>{e&&a(t)}).catch(t=>{e&&O({title:`Could not load results`,description:t instanceof Error?t.message:String(t),variant:`destructive`})}).finally(()=>{e&&g(!1)}),()=>{e=!1}},[pe,ce,le,n,R,j,N,F]),(0,_.useEffect)(()=>{try{localStorage.setItem(a9,String(p))}catch{}},[p]),(0,_.useEffect)(()=>{he()},[ce,he]),(0,_.useEffect)(()=>{p&&n.listRunSummaries||(p&&s(i),f(!1))},[p,i,n]);let{assistantMessages:_e,assistantPendingToolCalls:ve,assistantInput:ye,assistantLoading:be,assistantTurnCancelable:xe,assistantExpired:Se,cancelAssistantTurn:Ce,assistantInputRef:we,setAssistantInput:Te,askAssistant:Ee,approveResultAssistantToolCall:De,denyResultAssistantToolCall:Oe,applyResultAssistantSnippet:ke,ensureIntroMessage:Ae}=Z7({source:n,open:ne,scope:`all_runs`}),je=(0,_.useMemo)(()=>{let e=new Map;return i.forEach(t=>{t.scenarios.forEach(t=>{let n=String(t.scenarioName??``).trim(),r=String(t.scenarioId??``).trim();r?e.set(r,n||r):n&&e.set(n,n)})}),Array.from(e.entries()).map(([e,t])=>({value:e,label:t})).sort((e,t)=>e.label.localeCompare(t.label))},[i]);(0,_.useEffect)(()=>{let t=(e.get(`scenario`)??``).trim();t&&(je.some(e=>e.value===t||e.label===t)?D(t):i.length>0&&D(`all`))},[e,je,i.length]),(0,_.useEffect)(()=>{let n=new URLSearchParams(e);j===`all`?(n.delete(`time_filter`),n.delete(`time_preset`),n.delete(`time_start`),n.delete(`time_end`)):j===`last`?(n.set(`time_filter`,`last`),n.set(`time_preset`,N),n.delete(`time_start`),n.delete(`time_end`)):(n.set(`time_filter`,`custom`),n.delete(`time_preset`),F.trim()?n.set(`time_start`,F.trim()):n.delete(`time_start`),R.trim()?n.set(`time_end`,R.trim()):n.delete(`time_end`)),n.toString()!==e.toString()&&t(n,{replace:!0})},[e,t,R,j,N,F]),(0,_.useEffect)(()=>{try{if(j===`all`){localStorage.removeItem(i9);return}let e={mode:j,preset:N,start:F,end:R};localStorage.setItem(i9,JSON.stringify(e))}catch{}},[R,j,N,F]);let Me=(0,_.useMemo)(()=>{if(n.listRunSummariesPage)return i;let e=E===`all`?i:i.filter(e=>e.scenarios.some(e=>{let t=String(e.scenarioName??``).trim(),n=String(e.scenarioId??``).trim();return t===E||n===E}));if(j===`all`)return e;let t=Date.now();if(j===`last`){let n=t-($7.find(e=>e.value===N)??$7[0]).durationMs;return e.filter(e=>{let r=new Date(e.timestamp).getTime();return r>=n&&r<=t})}let r=o9(F)?.getTime()??null,a=o9(R)?.getTime()??null,o=r!==null&&a!==null?Math.min(r,a):r??null,s=r!==null&&a!==null?Math.max(r,a):a??null;return e.filter(e=>{let t=new Date(e.timestamp).getTime();return!(Number.isNaN(t)||o!==null&&t<o||s!==null&&t>s)})},[i,E,n.listRunSummariesPage,R,j,N,F]);(0,_.useEffect)(()=>{B.reset()},[pe,B.reset,R,j,N,F]);let Ne=(0,_.useMemo)(()=>E===`all`?`All scenarios`:je.find(e=>e.value===E||e.label===E)?.label??E,[E,je]),Pe=(0,_.useMemo)(()=>{if(j===`all`)return`All time`;if(j===`last`)return $7.find(e=>e.value===N)?.label??`Last range`;let e=!!F.trim(),t=!!R.trim();return!e&&!t?`Custom range`:e&&t?`${c9(F)} - ${c9(R)}`:e?`From ${c9(F)}`:`Until ${c9(R)}`},[R,j,N,F]),Fe=(0,_.useMemo)(()=>{let e=(e,t)=>e===null&&t===null?0:e===null?1:t===null?-1:w===`asc`?e-t:t-e;return[...Me].sort((t,n)=>{if(S===`toolTokens`)return e(t.toolTokenUsage?.totalTokens??null,n.toolTokenUsage?.totalTokens??null);let r=0;return S===`id`&&(r=t.id.localeCompare(n.id)),S===`timestamp`&&(r=new Date(t.timestamp).getTime()-new Date(n.timestamp).getTime()),S===`passRate`&&(r=(t.overallPassRate??-1)-(n.overallPassRate??-1)),S===`scenarios`&&(r=t.totalScenarios-n.totalScenarios),S===`avgToolCalls`&&(r=t.avgToolCalls-n.avgToolCalls),w===`asc`?r:-r})},[Me,S,w]),Ie=(0,_.useMemo)(()=>{let e=[],t=null;for(let n of Fe){let r=Mfe(n.timestamp);r!==t&&(e.push({type:`day-separator`,dayKey:r,dayLabel:Nfe(n.timestamp)}),t=r),e.push({type:`run`,run:n})}return e},[Fe]),Le=e=>S===e?w===`asc`?(0,I.jsx)(cn,{className:`h-3.5 w-3.5`}):(0,I.jsx)(on,{className:`h-3.5 w-3.5`}):(0,I.jsx)(ln,{className:`h-3.5 w-3.5 text-muted-foreground`}),Re=e=>{let t=e.toolTokenUsage?.totalTokens;return typeof t==`number`?t.toLocaleString():`n/a`},ze=()=>{M(`all`),P(`15min`),L(``),z(``)},Be=(0,_.useMemo)(()=>{let e=new Map;for(let t of Fe){if(t.scenarios.length>0){e.set(t.id,MW(t));continue}let n=t.configName?.trim()||``,r=t.configPath?.trim()||``,i=n||r;e.set(t.id,{scenarioCount:t.totalScenarios,agentCount:0,scopePreview:i||`n/a`,modelSummary:``})}return e},[Fe]),Ve=()=>{ne?re(!1):(re(!0),Ae(`Ask me to compare runs, explain regressions over time, or summarize historical drift patterns.`))},He=async e=>{x(!0);try{await n.deleteResult(e),a(t=>t.filter(t=>t.id!==e)),s(t=>t.filter(t=>t.id!==e)),B.setTotalCount(e=>Math.max(0,e-1)),O({title:`Run deleted`,description:e}),y(null)}catch(e){O({title:`Could not delete run`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{x(!1)}},Ue=async e=>{if(!e.configPath?.trim())O({title:`Cannot rerun`,description:`This run has no config path in metadata.`,variant:`destructive`});else{fe(e.id);try{await Q7(n,e),O({title:`Rerun queued`,description:`${e.id} queued with previous run settings.`})}catch(e){O({title:`Could not rerun`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{fe(t=>t===e.id?null:t)}}};return(0,I.jsxs)(`div`,{ref:l,className:`flex flex-col`,children:[(0,I.jsx)(X6,{open:v!==null,onOpenChange:e=>{!e&&!b&&y(null)},children:(0,I.jsxs)(Q6,{children:[(0,I.jsxs)($6,{children:[(0,I.jsx)(t8,{children:`Delete run?`}),(0,I.jsxs)(n8,{children:[`This will permanently remove the run artifacts from disk for`,` `,(0,I.jsx)(`span`,{className:`font-mono`,children:v??``}),`.`]})]}),(0,I.jsxs)(e8,{children:[(0,I.jsx)(i8,{disabled:b,children:`Cancel`}),(0,I.jsx)(r8,{disabled:b||!v,onClick:e=>{e.preventDefault(),v&&He(v)},className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:b?`Deleting...`:`Delete run`})]})]})}),(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`h1`,{className:`inline-flex items-center gap-2 text-2xl font-bold`,children:[(0,I.jsx)(rn,{className:`h-6 w-6`}),`Results`]}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Browse evaluation runs and open detailed results`})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsxs)(K8,{open:k,onOpenChange:A,children:[(0,I.jsx)(q8,{asChild:!0,children:(0,I.jsxs)(W,{type:`button`,variant:`outline`,role:`combobox`,"aria-expanded":k,"aria-controls":`results-scenario-command-list`,className:`w-[260px] justify-between font-normal ${E===`all`?``:`border-primary/40`}`,children:[(0,I.jsx)(`span`,{className:`truncate text-left`,children:Ne}),(0,I.jsx)(on,{className:`ml-2 h-4 w-4 shrink-0 opacity-50`})]})}),(0,I.jsx)(J8,{className:`w-[260px] p-0`,align:`start`,children:(0,I.jsxs)(b5,{children:[(0,I.jsx)(x5,{placeholder:`Search scenarios...`}),(0,I.jsxs)(S5,{id:`results-scenario-command-list`,children:[(0,I.jsx)(C5,{children:`No scenarios found.`}),(0,I.jsxs)(w5,{children:[(0,I.jsx)(T5,{value:`all scenarios`,onSelect:()=>{D(`all`),A(!1)},children:`All scenarios`}),je.map(e=>(0,I.jsx)(T5,{value:`${e.label} ${e.value}`,onSelect:()=>{D(e.value),A(!1)},children:e.label},e.value))]})]})]})})]}),(0,I.jsxs)(K8,{open:ee,onOpenChange:te,children:[(0,I.jsx)(q8,{asChild:!0,children:(0,I.jsxs)(W,{type:`button`,variant:`outline`,role:`combobox`,"aria-expanded":ee,"aria-controls":`results-time-command-list`,className:`w-[320px] justify-between font-normal ${j===`all`?``:`border-primary/40`}`,children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 truncate text-left`,children:[(0,I.jsx)(nn,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,I.jsx)(`span`,{className:`truncate`,children:Pe})]}),(0,I.jsx)(on,{className:`ml-2 h-4 w-4 shrink-0 opacity-50`})]})}),(0,I.jsxs)(J8,{className:`w-[360px] p-0`,align:`start`,children:[(0,I.jsxs)(`div`,{className:`border-b px-3 py-2`,children:[(0,I.jsx)(`p`,{className:`text-sm font-medium`,children:`Date and time filter`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Filter runs by timestamp.`})]}),(0,I.jsxs)(`div`,{id:`results-time-command-list`,className:`grid gap-1 p-2`,children:[(0,I.jsx)(W,{type:`button`,variant:j===`all`?`secondary`:`ghost`,className:`justify-start`,onClick:()=>{ze(),te(!1)},children:`All time`}),$7.map(e=>(0,I.jsx)(W,{type:`button`,variant:j===`last`&&N===e.value?`secondary`:`ghost`,className:`justify-start`,onClick:()=>{M(`last`),P(e.value),te(!1)},children:e.label},e.value)),(0,I.jsx)(W,{type:`button`,variant:j===`custom`?`secondary`:`ghost`,className:`justify-start`,onClick:()=>M(`custom`),children:`Custom date time range`})]}),j===`custom`&&(0,I.jsxs)(`div`,{className:`space-y-3 border-t p-3`,children:[(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(Q,{htmlFor:`results-time-filter-start`,children:`Start`}),(0,I.jsx)(Op,{id:`results-time-filter-start`,type:`datetime-local`,value:F,onChange:e=>L(e.target.value)})]}),(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(Q,{htmlFor:`results-time-filter-end`,children:`End`}),(0,I.jsx)(Op,{id:`results-time-filter-end`,type:`datetime-local`,value:R,onChange:e=>z(e.target.value)})]}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsxs)(W,{type:`button`,variant:`ghost`,size:`sm`,className:`px-2`,onClick:ze,children:[(0,I.jsx)(hr,{className:`mr-1.5 h-3.5 w-3.5`}),`Clear`]}),(0,I.jsx)(W,{type:`button`,size:`sm`,onClick:()=>te(!1),children:`Done`})]})]})]})]}),(0,I.jsx)(W,{variant:`outline`,onClick:()=>void ge(),disabled:h,children:h?`Refreshing...`:`Refresh`}),(0,I.jsx)(W,{variant:`outline`,onClick:B.prev,disabled:h||le===0,children:`Prev`}),(0,I.jsx)(W,{variant:`outline`,onClick:B.next,disabled:h||!de,children:`Next`}),(0,I.jsxs)(W,{type:`button`,variant:`outline`,className:`gap-1.5`,"aria-pressed":ne,onClick:Ve,children:[(0,I.jsx)(ar,{className:`h-4 w-4 text-amber-500`}),`MCP Lab Assistant`]})]})]}),(0,I.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-3`,children:[(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:B.rangeLabel(i.length)}),(0,I.jsxs)(W,{variant:`ghost`,size:`sm`,className:`h-7 gap-1.5 px-2 text-xs text-muted-foreground`,onClick:()=>m(e=>!e),"aria-pressed":p,children:[(0,I.jsx)(Fn,{className:`h-3 w-3`}),p?`Hide dashboard`:`Show dashboard`]})]}),p?(0,I.jsx)(`div`,{className:`mt-2`,children:(0,I.jsx)(xfe,{runs:o,loading:d})}):null,(0,I.jsxs)(`div`,{ref:u,style:se?{height:oe}:void 0,className:U(`mt-4 grid gap-6`,se?`grid-rows-[minmax(0,1fr)]`:`items-start`,ne?ie?`xl:grid-cols-[minmax(0,1fr)_52rem]`:`xl:grid-cols-[minmax(0,1fr)_30rem]`:`grid-cols-1`),children:[(0,I.jsx)(K,{"data-testid":`results-table`,className:U(`results-table-container`,se&&`flex min-h-0 flex-col overflow-hidden`),children:(0,I.jsx)(q,{className:U(`p-0`,se&&`min-h-0 flex-1`),children:(0,I.jsxs)(bv,{className:`table-auto`,containerClassName:se?`h-full`:void 0,children:[(0,I.jsx)(xv,{className:se?`sticky top-0 z-10 bg-card shadow-[0_1px_0_var(--color-border)]`:void 0,children:(0,I.jsxs)(wv,{children:[(0,I.jsx)(Tv,{className:`results-table-column-run-id w-120 max-w-120`,children:(0,I.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 hover:text-foreground`,onClick:()=>me(`id`),children:[`Run ID`,Le(`id`)]})}),(0,I.jsx)(Tv,{className:`results-table-column-evaluation w-[20rem] max-w-[20rem] min-w-0`,children:`Evaluation`}),(0,I.jsx)(Tv,{className:`results-table-column-timestamp w-44 min-w-44 max-w-44`,children:(0,I.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 hover:text-foreground`,onClick:()=>me(`timestamp`),children:[`Timestamp`,Le(`timestamp`)]})}),(0,I.jsx)(Tv,{className:`results-table-column-pass-rate w-30 min-w-30 max-w-30 text-center`,children:(0,I.jsxs)(`button`,{type:`button`,className:`inline-flex w-full items-center justify-end gap-1 hover:text-foreground`,onClick:()=>me(`passRate`),children:[`Pass Rate`,Le(`passRate`)]})}),(0,I.jsx)(Tv,{className:`results-table-column-scenarios w-22 min-w-22 max-w-22 text-right`,children:(0,I.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 hover:text-foreground`,onClick:()=>me(`scenarios`),children:[`Scenarios`,Le(`scenarios`)]})}),(0,I.jsx)(Tv,{className:`results-table-column-avg-tools w-30 min-w-30 max-w-30 text-right`,children:(0,I.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 hover:text-foreground`,onClick:()=>me(`avgToolCalls`),children:[`Avg Tools`,Le(`avgToolCalls`)]})}),(0,I.jsx)(Tv,{className:`results-table-column-tool-tokens w-36 min-w-36 max-w-36 text-right`,children:(0,I.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 hover:text-foreground`,onClick:()=>me(`toolTokens`),children:[`Tool Tokens`,Le(`toolTokens`)]})}),(0,I.jsx)(Tv,{className:`results-table-column-actions w-36 min-w-36 max-w-36`})]})}),(0,I.jsx)(Sv,{children:Ie.length===0?(0,I.jsx)(wv,{children:(0,I.jsx)(J,{colSpan:r9,className:`px-4 py-10 text-center text-sm text-muted-foreground`,children:j===`all`&&E===`all`?`No runs yet.`:`No runs match current filters.`})}):Ie.map((e,t)=>e.type===`day-separator`?(0,I.jsx)(wv,{className:`bg-muted/30 hover:bg-muted/30`,children:(0,I.jsx)(J,{colSpan:r9,className:`px-4 py-3`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,I.jsx)(`div`,{className:`h-px flex-1 bg-border/70`}),(0,I.jsx)(`span`,{className:`shrink-0 rounded-full border border-border bg-background px-2.5 py-0.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:e.dayLabel}),(0,I.jsx)(`div`,{className:`h-px flex-1 bg-border/70`})]})})},`day-${e.dayKey}-${t}`):(0,I.jsxs)(wv,{children:[(0,I.jsx)(J,{className:`results-table-column-run-id w-120 max-w-120`,children:(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(np,{to:`/results/${e.run.id}`,className:`font-mono text-xs text-primary hover:underline`,children:e.run.id}),(0,I.jsx)(`div`,{className:`min-w-0 truncate font-mono text-xs text-foreground/80`,title:Be.get(e.run.id)?.scopePreview??`n/a`,children:Be.get(e.run.id)?.scopePreview??`n/a`}),e.run.runNote?(0,I.jsxs)(`div`,{className:`text-[11px] text-muted-foreground wrap-break-word`,children:[`Note: `,e.run.runNote]}):null]})}),(0,I.jsx)(J,{className:`results-table-column-evaluation w-[20rem] max-w-[20rem] min-w-0 text-[11px] text-muted-foreground`,children:(()=>{let t=Be.get(e.run.id)??{scenarioCount:0,agentCount:0,scopePreview:`n/a`,modelSummary:``};return(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[(0,I.jsxs)(`span`,{className:`shrink-0 whitespace-nowrap`,children:[t.scenarioCount,` scenario`,t.scenarioCount===1?``:`s`,` · `,t.agentCount,` `,`agent`,t.agentCount===1?``:`s`]}),t.modelSummary?(0,I.jsxs)(`span`,{className:`min-w-0 truncate`,title:t.modelSummary,children:[`· `,t.modelSummary]}):null]}),(0,I.jsx)(C7,{versions:e.run.mcpServerVersions,showPrefix:!1,className:`max-w-[18rem]`})]})})()}),(0,I.jsx)(J,{className:`results-table-column-timestamp w-44 min-w-44 max-w-44 text-xs text-muted-foreground`,children:(0,I.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,I.jsx)(_n,{className:`h-3 w-3`}),new Date(e.run.timestamp).toLocaleString()]}),(()=>{let t=z7(e.run);return t===null?null:(0,I.jsxs)(`div`,{className:`font-mono text-[11px] text-muted-foreground/90`,children:[`Total time: `,L7(t)]})})()]})}),(0,I.jsx)(J,{className:`results-table-column-pass-rate w-30 min-w-30 max-w-30 text-right`,children:(0,I.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,I.jsx)(kv,{rate:e.run.overallPassRate}),e.run.checkCounts&&e.run.checkCounts.total>0?(0,I.jsxs)(`span`,{className:`font-mono text-[11px] leading-none`,"aria-label":`${e.run.checkCounts.passed} checks passed, ${e.run.checkCounts.failed} checks failed${e.run.checkCounts.not_evaluated>0?`, ${e.run.checkCounts.not_evaluated} not evaluated`:``}${(e.run.checkCounts.not_executed??0)>0?`, ${e.run.checkCounts.not_executed} not executed`:``}`,title:`${e.run.checkCounts.passed} passed · ${e.run.checkCounts.failed} failed${e.run.checkCounts.not_evaluated>0?` · ${e.run.checkCounts.not_evaluated} not evaluated`:``}${(e.run.checkCounts.not_executed??0)>0?` · ${e.run.checkCounts.not_executed} not executed`:``}`,children:[(0,I.jsxs)(`span`,{className:`text-success`,children:[e.run.checkCounts.passed,` ✓`]}),(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:` · `}),(0,I.jsxs)(`span`,{className:`text-destructive`,children:[e.run.checkCounts.failed,` ✕`]})]}):null,(0,I.jsx)(Dfe,{run:e.run})]})}),(0,I.jsx)(J,{className:`results-table-column-scenarios w-22 min-w-22 max-w-22 text-right font-mono text-sm`,children:e.run.totalScenarios}),(0,I.jsx)(J,{className:`results-table-column-avg-tools w-30 min-w-30 max-w-30 text-center font-mono text-sm`,children:e.run.avgToolCalls.toFixed(0)}),(0,I.jsx)(J,{className:`results-table-column-tool-tokens w-36 min-w-36 max-w-36 text-right`,children:(0,I.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,I.jsx)(`div`,{className:`font-mono text-sm`,children:Re(e.run)}),(()=>{let t=V7(e.run);return t===null?null:(0,I.jsxs)(`div`,{className:`font-mono text-[11px] text-muted-foreground/90`,children:[`Tool time: `,L7(t)]})})()]})}),(0,I.jsx)(J,{className:`results-table-column-actions w-36 min-w-36 max-w-36`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,I.jsxs)(W,{size:`sm`,variant:`outline`,disabled:V===e.run.id,onClick:()=>void Ue(e.run),children:[(0,I.jsx)(Yn,{className:`mr-1.5 h-3.5 w-3.5`}),V===e.run.id?`Queueing...`:`Rerun`]}),(0,I.jsxs)(Rq,{children:[(0,I.jsx)(zq,{asChild:!0,children:(0,I.jsx)(W,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":`More actions`,children:(0,I.jsx)(xn,{className:`h-4 w-4`})})}),(0,I.jsxs)(Hq,{align:`end`,children:[(0,I.jsx)(Uq,{asChild:!0,children:(0,I.jsxs)(np,{to:`/results/${e.run.id}`,children:[(0,I.jsx)(wn,{className:`mr-2 h-3.5 w-3.5`}),`View`]})}),Object.entries(e.run.langsmithTraceUrls??{}).map(([e,t])=>(0,I.jsx)(Uq,{asChild:!0,children:(0,I.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,children:[(0,I.jsx)(Sn,{className:`mr-2 h-3.5 w-3.5`}),`LangSmith trace`]})},e)),(0,I.jsxs)(Uq,{children:[(0,I.jsx)(yn,{className:`mr-2 h-3.5 w-3.5`}),`Export JSON`]}),(0,I.jsxs)(Uq,{className:`text-destructive`,onSelect:t=>{t.preventDefault();let n=document.activeElement;n instanceof HTMLElement&&n.blur(),y(e.run.id)},children:[(0,I.jsx)(lr,{className:`mr-2 h-3.5 w-3.5`}),`Delete`]})]})]})]})})]},e.run.id))})]})})}),ne&&(0,I.jsx)(`div`,{className:`min-h-0 min-w-0`,children:(0,I.jsx)(I7,{title:`MCP Lab Assistant`,description:`Analyze historical differences and trends across all result runs.`,expanded:ie,onToggleExpanded:()=>ae(e=>!e),onHide:()=>re(!1),messages:_e,pendingToolCalls:ve,loading:be,onCancel:xe?Ce:void 0,input:ye,onInputChange:Te,onSend:()=>void Ee(),inputPlaceholder:`Ask about historical run differences...`,snippets:Lfe,onSnippetSelect:e=>{re(!0),ke(e)},onApproveToolCall:De,onDenyToolCall:Oe,expired:Se,inputRef:we,className:`min-w-0 overflow-hidden xl:flex xl:h-full xl:min-h-0 xl:flex-col`})})]})]})};function zfe(e,t){return _.useReducer((e,n)=>t[e][n]??e,e)}var u9=`ScrollArea`,[d9,Bfe]=R(u9),[Vfe,f9]=d9(u9),p9=_.forwardRef((e,t)=>{let{__scopeScrollArea:n,type:r=`hover`,dir:i,scrollHideDelay:a=600,...o}=e,[s,c]=_.useState(null),[l,u]=_.useState(null),[d,f]=_.useState(null),[p,m]=_.useState(null),[h,g]=_.useState(null),[v,y]=_.useState(0),[b,x]=_.useState(0),[S,C]=_.useState(!1),[w,T]=_.useState(!1),E=P(t,e=>c(e)),D=BW(i);return(0,I.jsx)(Vfe,{scope:n,type:r,dir:D,scrollHideDelay:a,scrollArea:s,viewport:l,onViewportChange:u,content:d,onContentChange:f,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:S,onScrollbarXEnabledChange:C,scrollbarY:h,onScrollbarYChange:g,scrollbarYEnabled:w,onScrollbarYEnabledChange:T,onCornerWidthChange:y,onCornerHeightChange:x,children:(0,I.jsx)(V.div,{dir:D,...o,ref:E,style:{position:`relative`,"--radix-scroll-area-corner-width":v+`px`,"--radix-scroll-area-corner-height":b+`px`,...e.style}})})});p9.displayName=u9;var m9=`ScrollAreaViewport`,h9=_.forwardRef((e,t)=>{let{__scopeScrollArea:n,children:r,nonce:i,...a}=e,o=f9(m9,n),s=P(t,_.useRef(null),o.onViewportChange);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}`},nonce:i}),(0,I.jsx)(V.div,{"data-radix-scroll-area-viewport":``,...a,ref:s,style:{overflowX:o.scrollbarXEnabled?`scroll`:`hidden`,overflowY:o.scrollbarYEnabled?`scroll`:`hidden`,...e.style},children:(0,I.jsx)(`div`,{ref:o.onContentChange,style:{minWidth:`100%`,display:`table`},children:r})})]})});h9.displayName=m9;var g9=`ScrollAreaScrollbar`,_9=_.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=f9(g9,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:o}=i,s=e.orientation===`horizontal`;return _.useEffect(()=>(s?a(!0):o(!0),()=>{s?a(!1):o(!1)}),[s,a,o]),i.type===`hover`?(0,I.jsx)(Hfe,{...r,ref:t,forceMount:n}):i.type===`scroll`?(0,I.jsx)(Ufe,{...r,ref:t,forceMount:n}):i.type===`auto`?(0,I.jsx)(v9,{...r,ref:t,forceMount:n}):i.type===`always`?(0,I.jsx)(y9,{...r,ref:t}):null});_9.displayName=g9;var Hfe=_.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=f9(g9,e.__scopeScrollArea),[a,o]=_.useState(!1);return _.useEffect(()=>{let e=i.scrollArea,t=0;if(e){let n=()=>{window.clearTimeout(t),o(!0)},r=()=>{t=window.setTimeout(()=>o(!1),i.scrollHideDelay)};return e.addEventListener(`pointerenter`,n),e.addEventListener(`pointerleave`,r),()=>{window.clearTimeout(t),e.removeEventListener(`pointerenter`,n),e.removeEventListener(`pointerleave`,r)}}},[i.scrollArea,i.scrollHideDelay]),(0,I.jsx)(Pe,{present:n||a,children:(0,I.jsx)(v9,{"data-state":a?`visible`:`hidden`,...r,ref:t})})}),Ufe=_.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=f9(g9,e.__scopeScrollArea),a=e.orientation===`horizontal`,o=M9(()=>c(`SCROLL_END`),100),[s,c]=zfe(`hidden`,{hidden:{SCROLL:`scrolling`},scrolling:{SCROLL_END:`idle`,POINTER_ENTER:`interacting`},interacting:{SCROLL:`interacting`,POINTER_LEAVE:`idle`},idle:{HIDE:`hidden`,SCROLL:`scrolling`,POINTER_ENTER:`interacting`}});return _.useEffect(()=>{if(s===`idle`){let e=window.setTimeout(()=>c(`HIDE`),i.scrollHideDelay);return()=>window.clearTimeout(e)}},[s,i.scrollHideDelay,c]),_.useEffect(()=>{let e=i.viewport,t=a?`scrollLeft`:`scrollTop`;if(e){let n=e[t],r=()=>{let r=e[t];n!==r&&(c(`SCROLL`),o()),n=r};return e.addEventListener(`scroll`,r),()=>e.removeEventListener(`scroll`,r)}},[i.viewport,a,c,o]),(0,I.jsx)(Pe,{present:n||s!==`hidden`,children:(0,I.jsx)(y9,{"data-state":s===`hidden`?`hidden`:`visible`,...r,ref:t,onPointerEnter:j(e.onPointerEnter,()=>c(`POINTER_ENTER`)),onPointerLeave:j(e.onPointerLeave,()=>c(`POINTER_LEAVE`))})})}),v9=_.forwardRef((e,t)=>{let n=f9(g9,e.__scopeScrollArea),{forceMount:r,...i}=e,[a,o]=_.useState(!1),s=e.orientation===`horizontal`,c=M9(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;o(s?e:t)}},10);return N9(n.viewport,c),N9(n.content,c),(0,I.jsx)(Pe,{present:r||a,children:(0,I.jsx)(y9,{"data-state":a?`visible`:`hidden`,...i,ref:t})})}),y9=_.forwardRef((e,t)=>{let{orientation:n=`vertical`,...r}=e,i=f9(g9,e.__scopeScrollArea),a=_.useRef(null),o=_.useRef(0),[s,c]=_.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=D9(s.viewport,s.content),u={...r,sizes:s,onSizesChange:c,hasThumb:l>0&&l<1,onThumbChange:e=>a.current=e,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:e=>o.current=e};function d(e,t){return Yfe(e,o.current,s,t)}return n===`horizontal`?(0,I.jsx)(Wfe,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollLeft,t=k9(e,s,i.dir);a.current.style.transform=`translate3d(${t}px, 0, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollLeft=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollLeft=d(e,i.dir))}}):n===`vertical`?(0,I.jsx)(Gfe,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollTop,t=k9(e,s);a.current.style.transform=`translate3d(0, ${t}px, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollTop=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollTop=d(e))}}):null}),Wfe=_.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=f9(g9,e.__scopeScrollArea),[o,s]=_.useState(),c=_.useRef(null),l=P(t,c,a.onScrollbarXChange);return _.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,I.jsx)(x9,{"data-orientation":`horizontal`,...i,ref:l,sizes:n,style:{bottom:0,left:a.dir===`rtl`?`var(--radix-scroll-area-corner-width)`:0,right:a.dir===`ltr`?`var(--radix-scroll-area-corner-width)`:0,"--radix-scroll-area-thumb-width":O9(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollLeft+t.deltaX;e.onWheelScroll(r),j9(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:E9(o.paddingLeft),paddingEnd:E9(o.paddingRight)}})}})}),Gfe=_.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=f9(g9,e.__scopeScrollArea),[o,s]=_.useState(),c=_.useRef(null),l=P(t,c,a.onScrollbarYChange);return _.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,I.jsx)(x9,{"data-orientation":`vertical`,...i,ref:l,sizes:n,style:{top:0,right:a.dir===`ltr`?0:void 0,left:a.dir===`rtl`?0:void 0,bottom:`var(--radix-scroll-area-corner-height)`,"--radix-scroll-area-thumb-height":O9(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollTop+t.deltaY;e.onWheelScroll(r),j9(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:E9(o.paddingTop),paddingEnd:E9(o.paddingBottom)}})}})}),[Kfe,b9]=d9(g9),x9=_.forwardRef((e,t)=>{let{__scopeScrollArea:n,sizes:r,hasThumb:i,onThumbChange:a,onThumbPointerUp:o,onThumbPointerDown:s,onThumbPositionChange:c,onDragScroll:l,onWheelScroll:u,onResize:d,...f}=e,p=f9(g9,n),[m,h]=_.useState(null),g=P(t,e=>h(e)),v=_.useRef(null),y=_.useRef(``),b=p.viewport,x=r.content-r.viewport,S=pe(u),C=pe(c),w=M9(d,10);function T(e){if(v.current){let t=e.clientX-v.current.left,n=e.clientY-v.current.top;l({x:t,y:n})}}return _.useEffect(()=>{let e=e=>{let t=e.target;m?.contains(t)&&S(e,x)};return document.addEventListener(`wheel`,e,{passive:!1}),()=>document.removeEventListener(`wheel`,e,{passive:!1})},[b,m,x,S]),_.useEffect(C,[r,C]),N9(m,w),N9(p.content,w),(0,I.jsx)(Kfe,{scope:n,scrollbar:m,hasThumb:i,onThumbChange:pe(a),onThumbPointerUp:pe(o),onThumbPositionChange:C,onThumbPointerDown:pe(s),children:(0,I.jsx)(V.div,{...f,ref:g,style:{position:`absolute`,...f.style},onPointerDown:j(e.onPointerDown,e=>{e.button===0&&(e.target.setPointerCapture(e.pointerId),v.current=m.getBoundingClientRect(),y.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect=`none`,p.viewport&&(p.viewport.style.scrollBehavior=`auto`),T(e))}),onPointerMove:j(e.onPointerMove,T),onPointerUp:j(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=y.current,p.viewport&&(p.viewport.style.scrollBehavior=``),v.current=null})})})}),S9=`ScrollAreaThumb`,C9=_.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=b9(S9,e.__scopeScrollArea);return(0,I.jsx)(Pe,{present:n||i.hasThumb,children:(0,I.jsx)(qfe,{ref:t,...r})})}),qfe=_.forwardRef((e,t)=>{let{__scopeScrollArea:n,style:r,...i}=e,a=f9(S9,n),o=b9(S9,n),{onThumbPositionChange:s}=o,c=P(t,e=>o.onThumbChange(e)),l=_.useRef(void 0),u=M9(()=>{l.current&&=(l.current(),void 0)},100);return _.useEffect(()=>{let e=a.viewport;if(e){let t=()=>{if(u(),!l.current){let t=Xfe(e,s);l.current=t,s()}};return s(),e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)}},[a.viewport,u,s]),(0,I.jsx)(V.div,{"data-state":o.hasThumb?`visible`:`hidden`,...i,ref:c,style:{width:`var(--radix-scroll-area-thumb-width)`,height:`var(--radix-scroll-area-thumb-height)`,...r},onPointerDownCapture:j(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;o.onThumbPointerDown({x:n,y:r})}),onPointerUp:j(e.onPointerUp,o.onThumbPointerUp)})});C9.displayName=S9;var w9=`ScrollAreaCorner`,T9=_.forwardRef((e,t)=>{let n=f9(w9,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!==`scroll`&&r?(0,I.jsx)(Jfe,{...e,ref:t}):null});T9.displayName=w9;var Jfe=_.forwardRef((e,t)=>{let{__scopeScrollArea:n,...r}=e,i=f9(w9,n),[a,o]=_.useState(0),[s,c]=_.useState(0),l=!!(a&&s);return N9(i.scrollbarX,()=>{let e=i.scrollbarX?.offsetHeight||0;i.onCornerHeightChange(e),c(e)}),N9(i.scrollbarY,()=>{let e=i.scrollbarY?.offsetWidth||0;i.onCornerWidthChange(e),o(e)}),l?(0,I.jsx)(V.div,{...r,ref:t,style:{width:a,height:s,position:`absolute`,right:i.dir===`ltr`?0:void 0,left:i.dir===`rtl`?0:void 0,bottom:0,...e.style}}):null});function E9(e){return e?parseInt(e,10):0}function D9(e,t){let n=e/t;return isNaN(n)?0:n}function O9(e){let t=D9(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Yfe(e,t,n,r=`ltr`){let i=O9(n),a=i/2,o=t||a,s=i-o,c=n.scrollbar.paddingStart+o,l=n.scrollbar.size-n.scrollbar.paddingEnd-s,u=n.content-n.viewport,d=r===`ltr`?[0,u]:[u*-1,0];return A9([c,l],d)(e)}function k9(e,t,n=`ltr`){let r=O9(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=Jq(e,n===`ltr`?[0,o]:[o*-1,0]);return A9([0,o],[0,s])(c)}function A9(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function j9(e,t){return e>0&&e<t}var Xfe=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return(function i(){let a={left:e.scrollLeft,top:e.scrollTop},o=n.left!==a.left,s=n.top!==a.top;(o||s)&&t(),n=a,r=window.requestAnimationFrame(i)})(),()=>window.cancelAnimationFrame(r)};function M9(e,t){let n=pe(e),r=_.useRef(0);return _.useEffect(()=>()=>window.clearTimeout(r.current),[]),_.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function N9(e,t){let n=pe(t);Ae(()=>{let t=0;if(e){let r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}},[e,n])}var P9=p9,Zfe=h9,Qfe=T9,F9=_.forwardRef(({className:e,children:t,...n},r)=>(0,I.jsxs)(P9,{ref:r,className:U(`relative overflow-hidden`,e),...n,children:[(0,I.jsx)(Zfe,{className:`h-full w-full rounded-[inherit]`,children:t}),(0,I.jsx)(I9,{}),(0,I.jsx)(Qfe,{})]}));F9.displayName=P9.displayName;var I9=_.forwardRef(({className:e,orientation:t=`vertical`,...n},r)=>(0,I.jsx)(_9,{ref:r,orientation:t,className:U(`flex touch-none select-none transition-colors`,t===`vertical`&&`h-full w-2.5 border-l border-l-transparent p-px`,t===`horizontal`&&`h-2.5 flex-col border-t border-t-transparent p-px`,e),...n,children:(0,I.jsx)(C9,{className:`relative flex-1 rounded-full bg-border`})}));I9.displayName=_9.displayName;function $fe(e){let t=e.scenarios.reduce((e,t)=>e+t.runs.filter(e=>e.passed).length,0),n=e.outcomes?.stopped??e.scenarios.reduce((e,t)=>e+t.runs.filter(e=>e.outcome===`stopped`).length,0),r=Math.max(0,e.totalRuns-t-n),i=b_(t,e.totalRuns,n),a={};e.scenarios.forEach(e=>e.runs.forEach(e=>e.toolCalls.forEach(e=>{a[e.name]=(a[e.name]||0)+1})));let o=Object.keys(a),s=Object.values(a),c=e.scenarios.map(e=>{let t=b_(e.runs.filter(e=>e.passed).length,e.runs.length,e.runs.filter(e=>e.outcome===`stopped`).length);return`
164
+ `)}\n`}function pfe(){let{source:e}=nv(),{servers:t,reload:n,loading:r}=hv(),[i,a]=(0,_.useState)(`configure`),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(`pre_registered`),[u,d]=(0,_.useState)(`local_callback`),[f,p]=(0,_.useState)(!0),[m,h]=(0,_.useState)(!0),[g,v]=(0,_.useState)(!0),[y,b]=(0,_.useState)(``),[x,S]=(0,_.useState)(``),[C,w]=(0,_.useState)(``),[T,E]=(0,_.useState)(``),[D,k]=(0,_.useState)(`__default__`),[A,j]=(0,_.useState)(`{}`),[M,N]=(0,_.useState)(``),[P,F]=(0,_.useState)(``),[L,R]=(0,_.useState)(``),[z,ee]=(0,_.useState)(``),[te,ne]=(0,_.useState)(``),[re,ie]=(0,_.useState)(``),[ae,oe]=(0,_.useState)(``),[se,ce]=(0,_.useState)(``),[B,le]=(0,_.useState)(null),[ue,de]=(0,_.useState)(null),[V,fe]=(0,_.useState)([]),[pe,me]=(0,_.useState)(!1),[he,ge]=(0,_.useState)(!1),[_e,ve]=(0,_.useState)(!1),[ye,be]=(0,_.useState)(`all`),[xe,Se]=(0,_.useState)(`all`),[Ce,we]=(0,_.useState)(`inspector`),Te=(0,_.useRef)(null),Ee=(0,_.useRef)(null),De=(0,_.useRef)(!1),Oe=(0,_.useRef)(m);(0,_.useEffect)(()=>{Oe.current=m},[m]),(0,_.useEffect)(()=>()=>{Te.current?.(),Te.current=null},[]),(0,_.useEffect)(()=>{Ee.current?.scrollIntoView({behavior:`smooth`,block:`end`})},[V.length]);let ke=(0,_.useMemo)(()=>t.filter(e=>e.authType===`oauth2`).slice().sort((e,t)=>(e.name||e.id).localeCompare(t.name||t.id,void 0,{sensitivity:`base`})),[t]),Ae=ke.find(e=>e.id===o);(0,_.useEffect)(()=>{o&&(ke.some(e=>e.id===o)||s(``))},[ke,o]),(0,_.useEffect)(()=>{Ae&&(Ae.oauthMode===`dcr`?(l(`dcr`),w(``),E(``)):(l(`pre_registered`),w(Ae.oauthClientId??``),E(Ae.oauthClientSecret??``)),b(Ae.oauthScope??``),ee(Ae.oauthAuthorizationUrl??``),ne(Ae.oauthTokenEndpoint??``))},[Ae?.id]);let je=(0,_.useMemo)(()=>{let e=B?.stepStates.length??0,t=B?.stepStates.filter(e=>e.status===`completed`||e.status===`skipped`).length??0,n=B?.stepStates.filter(e=>e.status===`failed`).length??0;return{total:e,completed:t,failed:n,percent:e>0?Math.round((t+n)/e*100):0}},[B]),Me=(0,_.useMemo)(()=>{let e=B?.network??[],t=new Map,n=[],r=e=>`${e.stepId}::${e.label}::${e.url}`;for(let i of e){if(i.phase===`request`){let e=n.length;n.push({key:i.id,stepId:i.stepId,label:i.label,method:i.method,url:i.url,request:i});let a=r(i),o=t.get(a)??[];o.push(e),t.set(a,o);continue}let e=r(i),a=t.get(e),o=a?.shift();typeof o==`number`?(n[o]={...n[o],response:i},a&&a.length>0?t.set(e,a):t.delete(e)):n.push({key:i.id,stepId:i.stepId,label:i.label,method:i.method,url:i.url,response:i})}return n.filter(e=>ye!==`all`&&e.stepId!==ye?!1:xe===`error`?typeof e.response?.status==`number`&&e.response.status>=400:xe!==`ok`||typeof e.response?.status==`number`&&e.response.status<400)},[B?.network,ye,xe]),Ne=!!ue,Pe=!(!B||B.status!==`completed`&&B.status!==`error`&&B.status!==`stopped`),Fe=(0,_.useMemo)(()=>{let e=new Map;return(B?.stepStates??[]).forEach((t,n)=>{e.set(t.id,n+1)}),e},[B?.stepStates]),Ie=(0,_.useMemo)(()=>{let e=(B?.network??[]).filter(e=>e.phase===`response`),t=t=>{let n=e.filter(e=>e.label===t);return[...n].reverse().find(e=>typeof e.status==`number`&&e.status<400)??[...n].reverse()[0]};return{resourceMetadata:t(`Protected Resource Metadata`),authorizationServerMetadata:t(`Authorization Server Metadata`)}},[B?.network]),Le=(0,_.useMemo)(()=>{let e=new Map;for(let t of B?.network??[]){let n=e.get(t.stepId)??{requests:[],responses:[]};t.phase===`request`&&n.requests.push(t),t.phase===`response`&&n.responses.push(t),e.set(t.stepId,n)}return e},[B?.network]),Re=e=>{if(e===`configure`||e===`run`&&Ne||e===`report`&&Pe)return a(e)},ze=()=>{let e;if(c===`dcr`&&A.trim())try{e=JSON.parse(A)}catch{throw Error(`DCR metadata JSON is invalid`)}if(!Ae)throw Error(`Select an MCP server`);return{profile:`latest`,target:{serverName:Ae.id,overrides:{authorizationServerMetadataUrl:L||void 0,authorizationEndpoint:z||void 0,tokenEndpoint:te||void 0,registrationEndpoint:re||void 0,cimdUrl:M||void 0,resourceBaseUrl:ae||void 0}},registrationMethod:c,clientConfig:{preRegistered:c===`pre_registered`?{clientId:C.trim(),clientSecret:T.trim()||void 0,tokenEndpointAuthMethod:D===`__default__`?void 0:D||void 0}:void 0,dcr:c===`dcr`?{metadata:e,tokenEndpointAuthMethod:D===`__default__`?void 0:D||void 0}:void 0,cimd:c===`cimd`?{cimdUrl:M||void 0,expectedClientId:P||void 0}:void 0},runtime:{redirectMode:u,scopes:y.split(/[,\s]+/).map(e=>e.trim()).filter(Boolean),resource:x.trim()||void 0,usePkce:g,codeChallengeMethod:`S256`},display:{showSensitiveValues:f}}},Be=t=>{Te.current?.(),Te.current=e.subscribeOAuthDebuggerSession(t,n=>{fe(e=>[...e,n]),(n.type===`completed`||n.type===`error`||n.type===`stopped`)&&me(!1),e.getOAuthDebuggerSession(t).then(e=>{le(e.session),e.session.uiHints.authorizationUrl&&Ve(`${k7()}/api/oauth-debugger/sessions/${t}/authorize`),e.session.status===`completed`&&a(`report`)}).catch(()=>{})})},Ve=e=>{Oe.current&&!De.current&&e&&(De.current=!0,window.open(e,`_blank`,`noopener,noreferrer`))},He=async()=>{ge(!0),De.current=!1;try{let t=ze(),n=await e.createOAuthDebuggerSession(t);de(n.sessionId),le(n.session),fe([]),a(`run`),Be(n.sessionId);let r=await e.startOAuthDebuggerSession(n.sessionId);le(r.session),me(!0),(r.session.status===`waiting_for_user`||r.session.status===`waiting_for_browser_callback`)&&(me(!1),r.session.uiHints.authorizationUrl&&Ve(`${k7()}/api/oauth-debugger/sessions/${n.sessionId}/authorize`))}catch(e){O({title:`Could not start OAuth Debugger session`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{ge(!1)}},Ue=async()=>{if(ue)try{ge(!0);let t=await e.submitOAuthDebuggerManualCallback(ue,{redirectUrl:se.trim()||void 0});le(t.session),ce(``),me(!0)}catch(e){O({title:`Could not submit callback`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{ge(!1)}},We=async()=>{if(ue){ve(!0);try{let t=await e.stopOAuthDebuggerSession(ue);if(me(!1),t.status!==`running`){let t=await e.getOAuthDebuggerSession(ue);le(t.session),t.session.status===`completed`?a(`report`):a(`run`)}}catch(e){O({title:`Could not stop session`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{ve(!1)}}},Ge=async()=>{Te.current?.(),Te.current=null,le(null),de(null),fe([]),me(!1),ve(!1),ge(!1),ce(``),be(`all`),Se(`all`),we(`inspector`),a(`run`),await He()},Ke=async t=>{if(ue&&B)try{let n=await e.exportOAuthDebuggerSession(ue,t),r=``,i=t===`json`?`json`:t===`raw`?`txt`:`md`;r=typeof n==`string`?n:`${JSON.stringify(n,null,2)}\n`;let a=new Blob([r],{type:`text/plain;charset=utf-8`}),o=URL.createObjectURL(a),s=document.createElement(`a`);s.href=o,s.download=`oauth-debugger-${ue}.${i}`,s.click(),URL.revokeObjectURL(o)}catch(e){if(t===`markdown`){let e=ffe(B,V),t=new Blob([e],{type:`text/markdown;charset=utf-8`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`oauth-debugger-${B.id}.md`,r.click(),URL.revokeObjectURL(n);return}O({title:`Export failed`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}},qe=ue?`${k7()}/api/oauth-debugger/sessions/${ue}/authorize`:void 0,Je=e=>e===`error`?`destructive`:e===`warning`?`outline-solid`:`secondary`;return(0,I.jsxs)(`div`,{className:`space-y-6`,children:[(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h1`,{className:`text-2xl font-bold`,children:`OAuth Debugger`}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Step-by-step OAuth flow debugging for MCP servers (latest MCP authorization draft profile).`})]}),(0,I.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:cfe.map(e=>{let t=i===e.id,n=e.id===`configure`||e.id===`run`&&Ne||e.id===`report`&&Pe;return(0,I.jsx)(`button`,{type:`button`,onClick:()=>n&&Re(e.id),disabled:!n,className:`rounded-full`,children:(0,I.jsx)(Y,{variant:t?`default`:`outline-solid`,className:n?``:`opacity-50`,children:e.label})},e.id)})})]}),i===`configure`&&(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(K,{children:[(0,I.jsx)(gv,{className:`pb-3`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(_v,{className:`text-base`,children:`Target MCP Server`}),(0,I.jsx)(vv,{children:`Select one MCP server from Libraries and optionally override endpoints.`})]}),(0,I.jsxs)(W,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void n(),disabled:r,children:[(0,I.jsx)(Qn,{className:`mr-2 h-4 w-4 ${r?`animate-spin`:``}`}),`Refresh Servers`]})]})}),(0,I.jsx)(q,{className:`space-y-3`,children:(0,I.jsxs)(`div`,{className:`max-w-xl space-y-2`,children:[(0,I.jsx)(Q,{children:`MCP Server`}),(0,I.jsxs)(OY,{value:o,onValueChange:s,children:[(0,I.jsx)(AY,{children:(0,I.jsx)(kY,{placeholder:`Select an MCP server`})}),(0,I.jsx)(NY,{children:ke.map(e=>(0,I.jsx)(Z,{value:e.id,children:e.name||e.id},e.id))})]}),ke.length===0&&(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`No MCP servers with OAuth configured found. Add OAuth 2.0 auth in`,` `,(0,I.jsx)(`a`,{href:`/libraries/servers`,className:`underline text-primary`,children:`Manage Servers`}),`.`]}),Ae&&(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[Ae.transport,` ·`,` `,Ae.url||Ae.command||`No URL/command`,` · `,(0,I.jsxs)(`span`,{className:`text-primary`,children:[Ae.oauthMode===`dcr`?`DCR`:`pre-registered`,` fields pre-filled`]})]})]})})]}),(0,I.jsxs)(K,{children:[(0,I.jsxs)(gv,{className:`pb-3`,children:[(0,I.jsx)(_v,{className:`text-base`,children:`Client Registration Method`}),(0,I.jsx)(vv,{children:`How your OAuth client is identified with the authorization server.`})]}),(0,I.jsxs)(q,{className:`space-y-3`,children:[(0,I.jsx)(`div`,{className:`grid gap-2 md:grid-cols-3`,children:[{id:`pre_registered`,label:`Pre-registered client`,hint:`You already have a client_id issued by the authorization server.`},{id:`dcr`,label:`Dynamic Client Registration`,hint:`The server issues a client_id automatically at the start of the flow (RFC 7591).`},{id:`cimd`,label:`Client ID Metadata Document`,hint:`The client identifies itself via a hosted JSON metadata document at a public URL (RFC 9728).`}].map(e=>(0,I.jsxs)(`button`,{type:`button`,onClick:()=>l(e.id),className:`rounded-md border p-3 text-left`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`div`,{className:`h-2.5 w-2.5 shrink-0 rounded-full ${c===e.id?`bg-primary`:`bg-muted-foreground/30`}`}),(0,I.jsx)(`span`,{className:`text-sm font-medium`,children:e.label})]}),(0,I.jsx)(`p`,{className:`mt-1 pl-5 text-xs text-muted-foreground`,children:e.hint})]},e.id))}),(0,I.jsx)(`div`,{className:`grid gap-3 md:grid-cols-1`,children:(0,I.jsxs)(`div`,{className:`max-w-md space-y-1`,children:[(0,I.jsxs)(Q,{className:`text-xs flex items-center gap-1`,children:[`Redirect mode`,(0,I.jsx)(D7,{text:`Local callback (recommended): MCP Lab automatically captures the redirect after you log in — no copy-pasting needed. Manual: you complete the browser login and then paste the final redirect URL back here.`})]}),(0,I.jsxs)(OY,{value:u,onValueChange:e=>d(e),children:[(0,I.jsx)(AY,{children:(0,I.jsx)(kY,{})}),(0,I.jsxs)(NY,{children:[(0,I.jsx)(Z,{value:`local_callback`,children:`Local callback (recommended)`}),(0,I.jsx)(Z,{value:`manual`,children:`Manual paste redirect URL`})]})]})]})}),c===`pre_registered`&&(0,I.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(Q,{className:`text-xs flex items-center gap-1`,children:[`client_id`,(0,I.jsx)(D7,{text:`The unique identifier for your application, issued by the authorization server when you registered the client.`})]}),(0,I.jsx)(Op,{value:C,onChange:e=>w(e.target.value)})]}),(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(Q,{className:`text-xs flex items-center gap-1`,children:[`client_secret`,(0,I.jsx)(D7,{text:`Leave empty for public clients (e.g. SPAs or mobile apps). Required for confidential clients that authenticate with the token endpoint.`})]}),(0,I.jsx)(a8,{value:T,onChange:e=>E(e.target.value),placeholder:`optional`})]})]}),c===`cimd`&&(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(Q,{className:`text-xs flex items-center gap-1`,children:[`CIMD URL`,(0,I.jsx)(D7,{text:`A publicly reachable URL hosting a JSON document that describes this client. The authorization server fetches it to identify the client.`})]}),(0,I.jsx)(Op,{value:M,onChange:e=>N(e.target.value),placeholder:`https://.../client-metadata.json`})]})]})]}),(0,I.jsxs)(K,{children:[(0,I.jsxs)(gv,{className:`pb-3`,children:[(0,I.jsx)(_v,{className:`text-base`,children:`Runtime OAuth Inputs`}),(0,I.jsx)(vv,{children:`Parameters sent in the authorization request.`})]}),(0,I.jsxs)(q,{className:`grid gap-3 md:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(Q,{className:`text-xs`,children:`Scopes`}),(0,I.jsx)(Op,{value:y,onChange:e=>b(e.target.value),placeholder:`openid profile email`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Space or comma separated. Leave empty to use scopes auto-discovered from the server metadata.`})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2 md:col-span-2`,children:[(0,I.jsx)(KX,{checked:g,onCheckedChange:e=>v(!!e)}),(0,I.jsxs)(Q,{className:`flex items-center gap-1`,children:[`Use PKCE (S256)`,(0,I.jsx)(D7,{text:`Proof Key for Code Exchange — generates a one-time code verifier so the authorization code can't be hijacked. Recommended for all clients; required for public clients.`})]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2 md:col-span-2`,children:[(0,I.jsx)(KX,{checked:m,onCheckedChange:e=>h(!!e)}),(0,I.jsx)(Q,{children:`Auto-open browser when authorization URL is ready`})]})]})]}),(0,I.jsxs)(`details`,{className:`rounded-md border bg-card p-3 shadow-xs`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:`Advanced`}),(0,I.jsxs)(`div`,{className:`mt-3 space-y-4`,children:[(0,I.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(Q,{className:`text-xs flex items-center gap-1`,children:[`Token endpoint auth method`,(0,I.jsx)(D7,{text:`How your client authenticates when exchanging the authorization code for a token. Choose 'none' for public clients (no secret). Leave as server default if unsure.`})]}),(0,I.jsxs)(OY,{value:D,onValueChange:k,children:[(0,I.jsx)(AY,{children:(0,I.jsx)(kY,{placeholder:`Server default (recommended)`})}),(0,I.jsxs)(NY,{children:[(0,I.jsx)(Z,{value:`__default__`,children:`Server default (let the server decide)`}),(0,I.jsx)(Z,{value:`client_secret_basic`,children:`client_secret_basic — credentials in Authorization header`}),(0,I.jsx)(Z,{value:`client_secret_post`,children:`client_secret_post — credentials in request body`}),(0,I.jsx)(Z,{value:`none`,children:`none — public client, no secret`}),(0,I.jsx)(Z,{value:`private_key_jwt`,children:`private_key_jwt — signed JWT assertion`})]})]}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Use "server default" unless the server requires a specific method.`})]}),(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(Q,{className:`text-xs flex items-center gap-1`,children:[`Resource / audience`,(0,I.jsx)(D7,{text:`Some servers (RFC 8707) require the target API's URI in the token request to scope the token. Only set this if your server explicitly requires it.`})]}),(0,I.jsx)(Op,{value:x,onChange:e=>S(e.target.value),placeholder:`https://api.example.com`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Optional. Only needed for servers that use resource indicators.`})]})]}),c===`dcr`&&(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(Q,{className:`text-xs flex items-center gap-1`,children:[`DCR metadata JSON`,(0,I.jsx)(D7,{text:`Extra fields for the dynamic client registration request (RFC 7591), e.g. {"client_name": "My App"}. redirect_uris and grant_types are always added automatically.`})]}),(0,I.jsx)(iX,{value:A,onChange:e=>j(e.target.value),className:`min-h-32 font-mono text-xs`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Optional extra fields for the registration request body.`})]}),c===`cimd`&&(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(Q,{className:`text-xs flex items-center gap-1`,children:[`Expected client_id`,(0,I.jsx)(D7,{text:`If you know what client_id the server should assign from the metadata document, enter it here for verification. Leave blank to accept whatever the server returns.`})]}),(0,I.jsx)(Op,{value:P,onChange:e=>F(e.target.value),placeholder:`optional`})]}),(0,I.jsxs)(`div`,{className:`rounded-md border bg-background p-3`,children:[(0,I.jsx)(`div`,{className:`mb-1 text-sm font-medium`,children:`Endpoint overrides`}),(0,I.jsx)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:`Override specific endpoints if auto-discovery fails or you want to test against a specific URL. Leave blank to use what the server advertises.`}),(0,I.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(Q,{className:`text-xs flex items-center gap-1`,children:[`Authorization server metadata URL`,(0,I.jsx)(D7,{text:`The /.well-known/oauth-authorization-server URL. Override if the server uses a non-standard path.`})]}),(0,I.jsx)(Op,{value:L,onChange:e=>R(e.target.value),placeholder:`https://.../.well-known/oauth-authorization-server`})]}),(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(Q,{className:`text-xs flex items-center gap-1`,children:[`Resource server base URL`,(0,I.jsx)(D7,{text:`The MCP server's base URL used to look up its /.well-known/oauth-protected-resource metadata. Override if the server uses a different base path.`})]}),(0,I.jsx)(Op,{value:ae,onChange:e=>oe(e.target.value),placeholder:`https://resource.example.com`})]}),(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(Q,{className:`text-xs flex items-center gap-1`,children:[`Authorization endpoint`,(0,I.jsx)(D7,{text:`The URL where users are redirected to log in and grant consent. Normally discovered automatically from the server metadata.`})]}),(0,I.jsx)(Op,{value:z,onChange:e=>ee(e.target.value),placeholder:`https://.../authorize`})]}),(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(Q,{className:`text-xs flex items-center gap-1`,children:[`Token endpoint`,(0,I.jsx)(D7,{text:`The URL your app calls to exchange the authorization code for an access token. Normally discovered automatically.`})]}),(0,I.jsx)(Op,{value:te,onChange:e=>ne(e.target.value),placeholder:`https://.../token`})]}),(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(Q,{className:`text-xs flex items-center gap-1`,children:[`Registration endpoint (DCR)`,(0,I.jsx)(D7,{text:`The URL used to dynamically register a new client (RFC 7591). Only relevant when using DCR. Override if the server doesn't advertise it in its metadata.`})]}),(0,I.jsx)(Op,{value:re,onChange:e=>ie(e.target.value),placeholder:`https://.../register`})]}),(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(Q,{className:`text-xs flex items-center gap-1`,children:[`CIMD URL override`,(0,I.jsx)(D7,{text:`Override the Client ID Metadata Document URL. Use this if the server doesn't discover it automatically or you want to test with a specific metadata document.`})]}),(0,I.jsx)(Op,{value:M,onChange:e=>N(e.target.value),placeholder:`https://.../client-metadata.json`})]})]})]}),(0,I.jsxs)(R5,{children:[(0,I.jsx)(un,{className:`h-4 w-4`}),(0,I.jsx)(z5,{children:`Secrets display`}),(0,I.jsxs)(B5,{className:`space-y-2`,children:[(0,I.jsx)(`p`,{children:`By default, full tokens and secrets are visible in the network inspector and exports — useful for debugging but not for sharing.`}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(KX,{checked:!f,onCheckedChange:e=>p(e===!1)}),(0,I.jsx)(Q,{children:`Hide sensitive values in inspector`})]})]})]})]})]}),(0,I.jsx)(`div`,{className:`flex justify-end`,children:(0,I.jsxs)(W,{type:`button`,onClick:()=>void He(),disabled:he,children:[he&&(0,I.jsx)(zn,{className:`mr-2 h-4 w-4 animate-spin`}),`Start OAuth Debug Session`]})})]}),i===`run`&&(0,I.jsx)(`div`,{className:`space-y-4`,children:(0,I.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[1.2fr_1fr]`,children:[(0,I.jsxs)(K,{className:`xl:col-span-1 min-w-0`,children:[(0,I.jsx)(gv,{className:`pb-3`,children:(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(_v,{className:`text-base`,children:`Progress`}),(0,I.jsx)(vv,{children:`Visual OAuth flow guide with live session events and next-step actions.`})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[B?.uiHints.authorizationUrl&&qe&&(0,I.jsx)(W,{asChild:!0,type:`button`,size:`sm`,variant:`outline`,children:(0,I.jsxs)(`a`,{href:qe,target:`_blank`,rel:`noopener noreferrer`,children:[(0,I.jsx)(Sn,{className:`mr-2 h-4 w-4`}),`Open Authorization URL`]})}),(0,I.jsxs)(W,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>void Ge(),disabled:he,children:[(0,I.jsx)(Qn,{className:`mr-2 h-4 w-4`}),`Restart`]}),ue&&(0,I.jsxs)(W,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>void We(),disabled:_e||!ue,children:[(_e||pe)&&_e&&(0,I.jsx)(zn,{className:`mr-2 h-4 w-4 animate-spin`}),(0,I.jsx)(sr,{className:`mr-2 h-4 w-4`}),`Stop Debug Session`]})]})]})}),(0,I.jsxs)(q,{className:`space-y-3`,children:[(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,I.jsxs)(`span`,{children:[je.completed+je.failed,`/`,je.total,` steps`]}),(0,I.jsxs)(`span`,{children:[je.percent,`%`]})]}),(0,I.jsx)(t7,{value:je.percent,className:`h-2`})]}),B?.status===`waiting_for_user`&&(0,I.jsx)(K,{children:(0,I.jsxs)(q,{className:`pt-4 space-y-2`,children:[(0,I.jsx)(`div`,{className:`text-sm font-medium`,children:`Manual callback required`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Open the authorization URL, complete authentication, then paste the final redirect URL here.`}),(0,I.jsx)(iX,{value:se,onChange:e=>ce(e.target.value),placeholder:`Paste the final redirect URL (with code and state)`,className:`min-h-24 text-xs font-mono`}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsxs)(W,{type:`button`,size:`sm`,onClick:()=>void Ue(),disabled:he||!se.trim(),children:[he&&(0,I.jsx)(zn,{className:`mr-2 h-4 w-4 animate-spin`}),`Continue`]}),B.uiHints.authorizationUrl&&qe&&(0,I.jsx)(W,{asChild:!0,type:`button`,size:`sm`,variant:`outline`,children:(0,I.jsx)(`a`,{href:qe,target:`_blank`,rel:`noopener noreferrer`,children:`Open Authorization URL`})})]})]})}),B?.status===`waiting_for_browser_callback`&&(0,I.jsxs)(R5,{children:[(0,I.jsx)(un,{className:`h-4 w-4`}),(0,I.jsx)(z5,{children:`Waiting for browser callback`}),(0,I.jsxs)(B5,{className:`space-y-1`,children:[(0,I.jsx)(`p`,{className:`text-xs`,children:`Complete the authorization flow in your browser. MCP Lab is listening for the callback at:`}),(0,I.jsx)(`p`,{className:`text-xs font-mono break-all`,children:B.uiHints.callbackUrl}),B.uiHints.authorizationUrl&&qe&&(0,I.jsx)(`div`,{className:`pt-2`,children:(0,I.jsx)(W,{asChild:!0,type:`button`,size:`sm`,variant:`outline`,children:(0,I.jsxs)(`a`,{href:qe,target:`_blank`,rel:`noopener noreferrer`,children:[(0,I.jsx)(Sn,{className:`mr-2 h-4 w-4`}),`Open Authorization URL`]})})})]})]}),(0,I.jsx)(`div`,{className:`space-y-2`,children:B?.stepStates.map(e=>{let t=Fe.get(e.id),n=Le.get(e.id),r=e.id===ufe||e.id===dfe,i=!!(n&&(n.requests.length>0||n.responses.length>0)),a=r&&e.status!==`pending`&&i;return(0,I.jsxs)(`div`,{className:`rounded-md border p-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsxs)(`div`,{className:`min-w-0 flex items-start gap-2`,children:[(0,I.jsx)(`div`,{className:`mt-0.5 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full border bg-muted text-xs font-semibold`,children:t}),(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsxs)(`div`,{className:`inline-flex items-center gap-1 text-sm font-medium`,children:[(0,I.jsx)(`span`,{children:e.title}),e.status===`completed`&&(0,I.jsx)(dn,{className:`h-4 w-4 shrink-0 text-emerald-600`,"aria-hidden":`true`})]}),(0,I.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.description})]})]}),(0,I.jsx)(Y,{variant:e.status===`failed`?`destructive`:e.status===`completed`?`outline-solid`:e.status===`active`?`secondary`:`outline-solid`,className:e.status===`completed`?`border-emerald-300 bg-emerald-50 text-emerald-700`:void 0,children:e.status})]}),e.outcomeSummary&&(0,I.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground break-all whitespace-pre-line`,children:e.outcomeSummary}),e.id===lfe&&(0,I.jsxs)(`details`,{className:`mt-3 rounded-md border bg-muted/20 p-3`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer text-xs font-semibold text-muted-foreground`,children:`OAuth Metadata Sources`}),(0,I.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(`div`,{className:`text-xs font-medium`,children:`Resource Metadata`}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground break-all`,children:[`From `,Ie.resourceMetadata?.url??`not captured`]}),(0,I.jsx)(`pre`,{className:`max-h-56 overflow-x-auto rounded-md bg-muted p-2 text-xs`,children:A7(Ie.resourceMetadata?.bodyText)})]}),(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(`div`,{className:`text-xs font-medium`,children:`Authorization Server Metadata`}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground break-all`,children:[`From`,` `,Ie.authorizationServerMetadata?.url??`not captured`]}),(0,I.jsx)(`pre`,{className:`max-h-56 overflow-x-auto rounded-md bg-muted p-2 text-xs`,children:A7(Ie.authorizationServerMetadata?.bodyText)})]})]})]}),a&&n&&(0,I.jsxs)(`details`,{className:`mt-3 rounded-md border bg-muted/20 p-3`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer text-xs font-semibold text-muted-foreground`,children:`Captured exchange details`}),(0,I.jsx)(`div`,{className:`mt-3 space-y-3`,children:Array.from({length:Math.max(n.requests.length,n.responses.length)}).map((t,r)=>{let i=n.requests[r],a=n.responses[r];return(0,I.jsxs)(`div`,{className:`rounded-md border bg-background p-2`,children:[(0,I.jsx)(`div`,{className:`text-xs font-medium`,children:i?.label??a?.label??`Exchange ${r+1}`}),(0,I.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground break-all`,children:[i?.method?`${i.method} `:``,i?.url??a?.url??`-`]}),typeof a?.status==`number`&&(0,I.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`HTTP `,a.status]}),i?.bodyText&&(0,I.jsx)(`pre`,{className:`mt-2 max-h-40 overflow-auto rounded bg-muted p-2 text-xs`,children:i.bodyText}),a?.bodyText&&(0,I.jsx)(`pre`,{className:`mt-2 max-h-48 overflow-auto rounded bg-muted p-2 text-xs`,children:A7(a.bodyText)})]},`${e.id}-exchange-${r}`)})})]})]},e.id)})||(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No steps yet.`})})]})]}),(0,I.jsx)(`div`,{className:`space-y-4 xl:col-span-1 min-w-0`,children:(0,I.jsxs)(K,{children:[(0,I.jsx)(gv,{className:`pb-3`,children:(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(_v,{className:`text-base`,children:`Inspect`}),(0,I.jsx)(vv,{children:`Live events and network requests/responses for the OAuth flow.`})]}),(0,I.jsxs)(W,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>void Ke(`raw`),disabled:!ue||!B,children:[(0,I.jsx)(yn,{className:`mr-2 h-4 w-4`}),`Copy/Export Raw Trace`]})]})}),(0,I.jsx)(q,{className:`space-y-3`,children:(0,I.jsxs)(CX,{value:Ce,onValueChange:e=>we(e),className:`min-w-0`,children:[(0,I.jsxs)(wX,{className:`grid grid-cols-2`,children:[(0,I.jsx)(TX,{value:`inspector`,children:`Network Inspector`}),(0,I.jsx)(TX,{value:`events`,children:`Live Debug`})]}),(0,I.jsx)(EX,{value:`events`,className:`mt-3`,children:(0,I.jsxs)(`div`,{className:`max-h-64 space-y-1 overflow-auto rounded-md border bg-muted/10 p-3 text-xs`,children:[V.length===0?(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`No events yet.`}):V.map((e,t)=>(0,I.jsxs)(`div`,{className:`break-all`,children:[(0,I.jsx)(`span`,{className:`mr-2 font-mono text-muted-foreground`,children:new Date(e.ts).toLocaleTimeString()}),(0,I.jsx)(Y,{variant:`outline`,className:`mr-2 text-[10px]`,children:e.type}),typeof e.payload.message==`string`?e.payload.message:JSON.stringify(e.payload)]},`${e.ts}-${t}`)),(0,I.jsx)(`div`,{ref:Ee})]})}),(0,I.jsxs)(EX,{value:`inspector`,className:`space-y-3 mt-3`,children:[(0,I.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(Q,{className:`text-xs`,children:`Filter by step`}),(0,I.jsxs)(OY,{value:ye,onValueChange:be,children:[(0,I.jsx)(AY,{className:`h-8`,children:(0,I.jsx)(kY,{})}),(0,I.jsxs)(NY,{children:[(0,I.jsx)(Z,{value:`all`,children:`All steps`}),(B?.stepStates??[]).map(e=>(0,I.jsxs)(Z,{value:e.id,children:[Fe.get(e.id),`. `,e.title]},e.id))]})]})]}),(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(Q,{className:`text-xs`,children:`Filter by status`}),(0,I.jsxs)(OY,{value:xe,onValueChange:Se,children:[(0,I.jsx)(AY,{className:`h-8`,children:(0,I.jsx)(kY,{})}),(0,I.jsxs)(NY,{children:[(0,I.jsx)(Z,{value:`all`,children:`All`}),(0,I.jsx)(Z,{value:`ok`,children:`Successful responses`}),(0,I.jsx)(Z,{value:`error`,children:`Error responses`})]})]})]})]}),(0,I.jsx)(`div`,{className:`max-h-136 min-w-0 space-y-2 overflow-auto`,children:Me.length===0?(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No network exchanges captured yet.`}):Me.map(e=>(0,I.jsxs)(`details`,{className:`rounded-md border p-3`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer list-none`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsxs)(`div`,{className:`min-w-0 flex items-start gap-2`,children:[(0,I.jsx)(`div`,{className:`mt-0.5 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full border bg-muted text-xs font-semibold`,children:Fe.get(e.stepId)}),(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`div`,{className:`text-sm font-medium`,children:e.label}),(0,I.jsxs)(`div`,{className:`text-xs text-muted-foreground break-all`,children:[e.method?`${e.method} `:``,e.url]})]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(Y,{variant:`outline`,children:`request`}),(0,I.jsx)(Y,{variant:`outline`,children:`response`}),typeof e.response?.status==`number`&&(0,I.jsx)(Y,{variant:e.response.status>=400?`destructive`:`secondary`,children:e.response.status})]})]})}),(0,I.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`mb-1 text-xs font-medium`,children:`Request Headers`}),(0,I.jsx)(`pre`,{className:`max-h-40 max-w-full overflow-auto whitespace-pre-wrap break-all rounded bg-muted p-2 text-xs`,children:JSON.stringify(e.request?.headers??{},null,2)})]}),e.request?.bodyText&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`mb-1 text-xs font-medium`,children:`Request Body`}),(0,I.jsx)(`pre`,{className:`max-h-64 max-w-full overflow-auto whitespace-pre-wrap break-all rounded bg-muted p-2 text-xs`,children:e.request.bodyText})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`mb-1 text-xs font-medium`,children:`Response Headers`}),(0,I.jsx)(`pre`,{className:`max-h-40 max-w-full overflow-auto whitespace-pre-wrap break-all rounded bg-muted p-2 text-xs`,children:JSON.stringify(e.response?.headers??{},null,2)})]}),e.response?.bodyText&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`mb-1 text-xs font-medium`,children:`Response Body`}),(0,I.jsx)(`pre`,{className:`max-h-64 max-w-full overflow-auto whitespace-pre-wrap break-all rounded bg-muted p-2 text-xs`,children:e.response.bodyText})]}),(0,I.jsx)(`div`,{className:`flex gap-2`,children:(0,I.jsxs)(W,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>void O7(JSON.stringify(e,null,2)),children:[(0,I.jsx)(vn,{className:`mr-2 h-4 w-4`}),`Copy JSON`]})})]})]},e.key))})]})]})})]})})]})}),i===`report`&&B&&(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Report / Export`}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`OAuth debug session summary, validations, and trace exports.`})]}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsx)(W,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>a(`configure`),children:`Back to Configure`}),(0,I.jsxs)(W,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>void Ke(`json`),children:[(0,I.jsx)(yn,{className:`mr-2 h-4 w-4`}),`Export JSON`]}),(0,I.jsxs)(W,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>void Ke(`markdown`),children:[(0,I.jsx)(yn,{className:`mr-2 h-4 w-4`}),`Export Markdown`]}),(0,I.jsxs)(W,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>void Ke(`raw`),children:[(0,I.jsx)(yn,{className:`mr-2 h-4 w-4`}),`Copy/Export Raw Trace`]})]})]}),(0,I.jsxs)(R5,{children:[(0,I.jsx)(un,{className:`h-4 w-4`}),(0,I.jsx)(z5,{children:`Secrets display mode`}),(0,I.jsx)(B5,{children:B.summary?.showSensitiveValues?`This session is configured to show full tokens and secrets in network logs/exports.`:`Sensitive values are hidden in the inspector for this session.`})]}),(0,I.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:[(0,I.jsx)(K,{children:(0,I.jsxs)(q,{className:`pt-4`,children:[(0,I.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Status`}),(0,I.jsx)(`div`,{className:`text-lg font-semibold`,children:B.status})]})}),(0,I.jsx)(K,{children:(0,I.jsxs)(q,{className:`pt-4`,children:[(0,I.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Requests`}),(0,I.jsx)(`div`,{className:`text-lg font-semibold`,children:B.networkSummary.requestCount})]})}),(0,I.jsx)(K,{children:(0,I.jsxs)(q,{className:`pt-4`,children:[(0,I.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Network errors`}),(0,I.jsx)(`div`,{className:`text-lg font-semibold`,children:B.networkSummary.errorCount})]})}),(0,I.jsx)(K,{children:(0,I.jsxs)(q,{className:`pt-4`,children:[(0,I.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Validation findings`}),(0,I.jsx)(`div`,{className:`text-lg font-semibold`,children:B.validations.length})]})})]}),(0,I.jsxs)(K,{children:[(0,I.jsx)(gv,{className:`pb-3`,children:(0,I.jsx)(_v,{className:`text-base`,children:`Key values`})}),(0,I.jsxs)(q,{className:`grid gap-3 md:grid-cols-2`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(Q,{className:`text-xs`,children:`Issuer`}),(0,I.jsx)(`p`,{className:`text-sm break-all`,children:B.summary?.issuer||`-`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(Q,{className:`text-xs`,children:`Client ID`}),(0,I.jsx)(`p`,{className:`text-sm break-all`,children:B.summary?.clientId||`-`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(Q,{className:`text-xs`,children:`Redirect URI`}),(0,I.jsx)(`p`,{className:`text-sm break-all`,children:B.summary?.redirectUri||`-`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(Q,{className:`text-xs`,children:`Token endpoint status`}),(0,I.jsx)(`p`,{className:`text-sm`,children:B.summary?.tokenEndpointStatus??`-`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(Q,{className:`text-xs`,children:`Token type`}),(0,I.jsx)(`p`,{className:`text-sm`,children:B.summary?.tokenType||`-`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(Q,{className:`text-xs`,children:`Scopes granted`}),(0,I.jsx)(`p`,{className:`text-sm break-all`,children:(B.summary?.grantedScopes??[]).join(`, `)||`-`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(Q,{className:`text-xs`,children:`Token validity`}),(0,I.jsxs)(`p`,{className:`text-sm`,children:[typeof B.summary?.accessTokenValidForSeconds==`number`?`${f6(B.summary.accessTokenValidForSeconds)} remaining`:typeof B.summary?.accessTokenExpiresInSeconds==`number`?`${f6(B.summary.accessTokenExpiresInSeconds)} from issuance`:`No expiry advertised by token endpoint`,B.summary?.accessTokenExpiresAt?(0,I.jsxs)(I.Fragment,{children:[` (until `,(0,I.jsx)(`span`,{children:new Date(B.summary.accessTokenExpiresAt).toLocaleTimeString()}),`)`]}):``]}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Source:`,` `,B.summary?.accessTokenExpirySource===`expires_in`?`token endpoint expires_in`:B.summary?.accessTokenExpirySource===`jwt_exp`?`JWT exp claim`:`not available`]})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(Q,{className:`text-xs`,children:`Refresh option`}),(0,I.jsx)(`p`,{className:`text-sm`,children:B.summary?.refreshTokenAvailable?`Refresh token available (silent refresh possible)`:`No refresh token in response (full login likely required after expiry)`})]}),B.summary?.accessToken&&(0,I.jsxs)(`div`,{className:`md:col-span-2 space-y-1`,children:[(0,I.jsx)(Q,{className:`text-xs`,children:`Access token`}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsxs)(`code`,{className:`flex-1 truncate rounded bg-muted px-2 py-1 text-xs font-mono text-muted-foreground`,children:[B.summary.accessToken.slice(0,48),`…`]}),(0,I.jsxs)(W,{type:`button`,size:`sm`,variant:`outline`,className:`shrink-0 h-7 px-2 text-xs`,onClick:()=>void O7(B.summary.accessToken),children:[(0,I.jsx)(vn,{className:`mr-1 h-3 w-3`}),`Copy token`]})]}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Visible because "Hide sensitive values" is off. Use this token with the CLI via`,` `,(0,I.jsx)(`code`,{className:`font-mono`,children:`--oauth-token`}),`.`]})]})]})]}),(0,I.jsxs)(K,{children:[(0,I.jsx)(gv,{className:`pb-3`,children:(0,I.jsx)(_v,{className:`text-base`,children:`Validation findings`})}),(0,I.jsx)(q,{className:`space-y-2`,children:B.validations.length===0?(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No validation findings recorded.`}):B.validations.map((e,t)=>(0,I.jsxs)(`div`,{className:`rounded-md border p-3`,children:[(0,I.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`inline-flex h-5 min-w-5 items-center justify-center rounded-full border bg-muted px-1 text-[10px] font-semibold text-muted-foreground`,children:t+1}),(0,I.jsx)(`span`,{className:`font-bold`,children:e.title})]}),(0,I.jsx)(Y,{variant:Je(e.severity),children:e.severity})]}),(0,I.jsxs)(`p`,{className:`text-sm`,children:[(0,I.jsx)(`span`,{className:`font-bold`,children:`Finding:`}),` `,e.detail]}),e.recommendation&&(0,I.jsxs)(`div`,{className:`mt-2 rounded-md border px-2.5 py-2 text-xs`,children:[(0,I.jsx)(`div`,{className:`mb-1 font-medium text-muted-foreground`,children:`Suggested improvement`}),(0,I.jsx)(`p`,{children:e.recommendation})]}),(0,I.jsxs)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Step: `,e.stepId,e.specReference&&(0,I.jsxs)(I.Fragment,{children:[` · `,(0,I.jsx)(`a`,{href:e.specReference,target:`_blank`,rel:`noreferrer`,className:`text-primary underline`,children:`Spec reference`})]})]})]},e.id))})]})]})]})}function mfe(e){let t=e.filter(e=>typeof e.sourcePath==`string`&&e.sourcePath.trim().length>0&&typeof e.relativePath==`string`&&e.relativePath.trim().length>0).map(e=>[e.sourcePath,e.relativePath]);return new Map(t)}function hfe(e){let t=e.filter(e=>typeof e.sourcePath==`string`&&e.sourcePath.trim().length>0).map(e=>[e.sourcePath,e.configName?.trim()||e.name]);return new Map(t)}function gfe(e,t){let n=new Map;for(let r of e){if(!r.sourcePath)continue;let e=new Map,i=r.scenarioEntries&&r.scenarioEntries.length>0?r.scenarioEntries:r.scenarios.map(e=>({kind:`inline`,scenario:e}));for(let n of i){if(n.kind===`inline`){e.set(n.scenario.id,n.scenario.name?.trim()||n.scenario.id);continue}let r=t.find(e=>e.id===n.ref);e.set(n.ref,r?.name?.trim()||n.ref)}n.set(r.sourcePath,e)}return n}function j7(e,t){let n=t.get(e);if(n)return n;let r=e.replace(/\\/g,`/`),i=r.lastIndexOf(`/evals/`);if(i>=0)return r.slice(i+7);let a=r.split(`/`).filter(Boolean);return a.length<=1?r:a.slice(-3).join(`/`)}function M7(e,t,n){let r=t.get(n);if(!e||e.length===0){if(r&&r.size===1){let e=r.values().next().value;if(e)return e}return`All scenarios`}if(!r)return e.length===1?e[0]:`${e[0]} +${e.length-1}`;let i=e.map(e=>r.get(e)??e);return i.length===1?i[0]:`${i[0]} +${i.length-1}`}var N7=`mcplab.runEvaluation.activeJobId`;function _fe(e){return e.configName?.trim()||e.name}function vfe(e){if(e.suitePath?.trim())return e.suitePath.trim();if(e.relativePath?.includes(`/`)){let t=e.relativePath.lastIndexOf(`/`);return e.relativePath.slice(0,t)}return null}function P7(){return new Date().toLocaleTimeString()}function F7(e){return e.executionType===`rover`&&[`queued`,`waiting_for_rover`,`running`,`paused_rover`].includes(e.status)}function yfe(e){return e.jobs.flatMap(e=>e.childProgress?.length?e.childProgress.map(t=>({job:e,child:t})):[{job:e}])}var bfe=()=>{let[e]=cp(),[t,n]=(0,_.useState)(``),[r,i]=(0,_.useState)(`1`),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(0),[l,u]=(0,_.useState)([]),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(``),[S,C]=(0,_.useState)(null),[w,T]=(0,_.useState)([]),[E,D]=(0,_.useState)(`agent_default`),[k,A]=(0,_.useState)([]),[j,M]=(0,_.useState)(!1),[N,P]=(0,_.useState)([]),[F,L]=(0,_.useState)({}),[R,z]=(0,_.useState)({}),[ee,te]=(0,_.useState)(``),[ne,re]=(0,_.useState)([]),[ie,ae]=(0,_.useState)([]),[oe,se]=(0,_.useState)([]),[ce,B]=(0,_.useState)([]),[le,ue]=(0,_.useState)(null),[de,V]=(0,_.useState)(null),[fe,pe]=(0,_.useState)(!1),[me,he]=(0,_.useState)(null),ge=(0,_.useRef)(null),_e=(0,_.useRef)(null),ve=(0,_.useRef)(null),ye=(0,_.useRef)(new Map),be=(0,_.useRef)(!1),{configs:xe,reload:Se}=fv(),{source:Ce}=nv(),{agents:we,scenarios:Te,servers:Ee,reload:De}=hv(),Oe=b.trim(),ke=Oe?`/results/${encodeURIComponent(Oe)}${t?`?configId=${encodeURIComponent(t)}`:``}`:`/results`,Ae=xe.find(e=>e.id===t),je=(0,_.useMemo)(()=>mfe(xe),[xe]),Me=(0,_.useMemo)(()=>hfe(xe),[xe]),Ne=(0,_.useMemo)(()=>gfe(xe,Te),[xe,Te]),Pe=ie[0]??null,Fe=(0,_.useMemo)(()=>ce.find(e=>e.jobs.some(e=>e.jobId===S))??null,[ce,S]),Ie=Fe?Math.max(s,Fe.totalJobs>0?Math.round(Fe.completedJobs/Fe.totalJobs*100):0):s,Le=e.get(`configId`),Re=(0,_.useMemo)(()=>{if(!Ae)return[];let e=new Map,t=Ae.agentEntries&&Ae.agentEntries.length>0?Ae.agentEntries:Ae.agents.map(e=>({kind:`inline`,agent:e}));for(let n of t){if(n.kind===`inline`){let t=n.agent.id;e.has(t)||e.set(t,n.agent);continue}let t=we.find(e=>e.id===n.ref);t&&!e.has(t.id)&&e.set(t.id,t)}for(let t of we)e.has(t.id)||e.set(t.id,t);return Array.from(e.values())},[Ae,we]),ze=(0,_.useMemo)(()=>{if(!Ae)return[];let e=new Map,t=Ae.scenarioEntries&&Ae.scenarioEntries.length>0?Ae.scenarioEntries:Ae.scenarios.map(e=>({kind:`inline`,scenario:e}));for(let n of t){if(n.kind===`inline`){e.has(n.scenario.id)||e.set(n.scenario.id,n.scenario);continue}let t=Te.find(e=>e.id===n.ref);t&&!e.has(t.id)&&e.set(t.id,t)}return Array.from(e.values())},[Ae,Te]),Be=(0,_.useMemo)(()=>Re.filter(e=>e.type===`browser`&&w.includes(e.id)),[Re,w]),Ve=Be.length>0?1:Number(r),He=(0,_.useMemo)(()=>[{label:`LLM Agents`,agents:Re.filter(e=>e.type!==`browser`)},{label:`Browser Agents`,agents:Re.filter(e=>e.type===`browser`)}],[Re]),Ue=(0,_.useMemo)(()=>{let e=new Map;for(let t of Ee)e.has(t.id)||e.set(t.id,{id:t.id,name:t.name});for(let t of Ae?.servers??[])e.set(t.id,{id:t.id,name:t.name});return Array.from(e.values()).sort((e,t)=>e.id.localeCompare(t.id))},[Ae?.servers,Ee]);(0,_.useEffect)(()=>{Le&&xe.some(e=>e.id===Le)&&n(Le)},[Le,xe]);let We=(0,_.useRef)(``);(0,_.useEffect)(()=>{let e=Ae?`${Ae.id}::${Ae.sourcePath??``}`:``;if(e===We.current)return;if(We.current=e,!Ae){T([]),D(`agent_default`),A([]),M(!1),P([]),L({}),z({});return}let t=IY(Ae);T(t.length>0?t:Re.map(e=>e.id)),D(`agent_default`),A(ze.map(e=>e.id)),M(!1),P([]),L({}),z({})},[Ae?.id,Ae?.sourcePath,Re,ze]);let Ge=async()=>{if(!Ae?.sourcePath){u(e=>[...e,`[${P7()}] Missing source path for selected config.`]);return}let e=Re.filter(e=>w.includes(e.id));if(e.length===0){u(e=>[...e,`[${P7()}] Select at least one agent.`]);return}let t=ze.filter(e=>k.includes(e.id)),n=new Set(t.map(e=>e.id)),r=j||Object.values(F).some(Boolean),i=Object.fromEntries(Object.entries(R).filter(([e])=>n.has(e)&&F[e])),a=t.map(e=>{let t=i[e.id]??(j?N:e.serverIds||[]);return`${e.id}=[${t.join(`, `)}]`}).join(`; `);if(t.length===0){u(e=>[...e,`[${P7()}] Select at least one test.`]);return}if(j&&N.length===0){u(e=>[...e,`[${P7()}] Select at least one server for "Override MCP Servers for Selected Tests", or turn that override off.`]);return}let s=Object.entries(i).filter(([,e])=>!Array.isArray(e)||e.length===0).map(([e])=>e);if(s.length>0){u(e=>[...e,`[${P7()}] Select at least one server for per-scenario overrides on: ${s.join(`, `)}, or turn those overrides off.`]);return}let l=Array.from(new Set(t.flatMap(e=>r?i[e.id]?i[e.id]??[]:j?N:e.serverIds||[]:e.serverIds||[]).filter(e=>{let t=(Ae.servers??[]).find(t=>t.id===e),n=Ee.find(t=>t.id===e);return(t||n)?.authType===`oauth2`})));try{l.length>0&&(pe(!0),await e6({serverNames:l,source:Ce,onServerAuthStart:e=>{u(t=>[...t,`[${P7()}] OAuth login required for '${e}'. Complete the browser sign-in flow...`])}}),u(e=>[...e,`[${P7()}] OAuth login completed for required server(s): ${l.join(`, `)}.`]))}catch(e){let t=e instanceof Error?e.message:String(e);u(e=>[...e,`[${P7()}] OAuth error: ${t}`]),pe(!1);return}finally{pe(!1)}o(!0),f(!1),y(!1),x(``);let d=(Ae.serverEntries??[]).some(e=>e.kind===`referenced`)||(Ae.agentEntries??[]).some(e=>e.kind===`referenced`)||(Ae.scenarioEntries??[]).some(e=>e.kind===`referenced`)?`refs-composed`:`single-file/inline`,p={...Be.length>0&&E!==`agent_default`?{newConversationBeforeStart:E===`new`,newConversationBetweenScenarios:E===`new`}:{}};u([`[${P7()}] Starting evaluation run...`,`[${P7()}] Config=${Ae.name} mode=${d} agents=${e.map(e=>e.name||e.id).join(`, `)} tests=${t.map(e=>e.id).join(`, `)} runs=${Ve}${Be.length>0?` newConversationBeforeStart=${p.newConversationBeforeStart??`agent_default`} newConversationBetweenScenarios=${p.newConversationBetweenScenarios??`agent_default`}`:``}${ee.trim()?` note=${ee.trim()}`:``}`,`[${P7()}] Effective MCP servers per selected test: ${a||`(none)`}`]),c(10);try{let{jobId:n}=await Ce.startRun({configPath:Ae.sourcePath,runsPerScenario:Ve,agents:e.map(e=>e.id),scenarioIds:t.map(e=>e.id),...p,...r&&j?{serverOverrideAll:N}:{},...r&&Object.keys(i).length>0?{scenarioServerOverrides:i}:{},runNote:ee.trim()?ee.trim():void 0});C(n),Ye(n),rt(n),Xe()}catch(e){let t=e instanceof Error?e.message:String(e),n=t.includes(`Anthropic model not found`)?` Hint: this usually means the API key works but the model ID is not enabled for that Anthropic account. Change the agent model in Manage Agents (library) or inline config.`:``;u(e=>[...e,`[${P7()}] Error: ${t}${n}`]),o(!1),c(0),C(null),pe(!1)}},Ke=()=>{Ge()},qe=()=>{ve.current=null,S&&Ce.stopRun(S),_e.current?.(),_e.current=null,Je(),C(null),o(!1),f(!1),y(!0),u(e=>[...e,`[${P7()}] Run aborted by user.`]),Xe()};(0,_.useEffect)(()=>{ge.current&&(ge.current.scrollTop=ge.current.scrollHeight)},[l]),(0,_.useEffect)(()=>()=>{ve.current=null,_e.current?.()},[]),(0,_.useEffect)(()=>{if(S||d)return;let e=``;try{e=sessionStorage.getItem(N7)??``}catch{e=``}if(e)return C(e),o(!0),f(!1),y(!1),u(e=>e.length>0?e:[`[${P7()}] Reattached to in-progress evaluation run...`]),rt(e),()=>{}},[S,d]);let Je=()=>{try{sessionStorage.removeItem(N7)}catch{}},Ye=e=>{try{sessionStorage.setItem(N7,e)}catch{}},Xe=async(e=!1)=>{try{let t=await Ce.getRunQueue(),n=t.evaluations??[],r=new Set(n.map(e=>e.evaluationRunId)),i=ye.current;if(e&&!ve.current){let e=Array.from(i.values()).find(e=>[`queued`,`running`].includes(e.status)&&!r.has(e.evaluationRunId));e&&Ce.getResult(e.evaluationRunId).then(t=>{if(!t||ve.current)return;let n=(t.outcomes?.stopped??0)>0||(t.outcomes?.incomplete??0)>0;o(!1),c(100),x(e.evaluationRunId),g(null),m((t.outcomes?.error??0)>0),y(n),f(!n)}).catch(()=>{})}ye.current=new Map(n.map(e=>[e.evaluationRunId,e])),re(t.queued),ae(t.active_jobs??(t.active?[t.active]:[])),se(t.admitting_jobs??[]),B((t.evaluations??[]).filter(e=>![`completed`,`partial`,`failed`].includes(e.status)));let a=S==null?void 0:t.queued.find(e=>e.jobId===S&&e.status===`blocked_auth`&&e.blockedReason===`oauth_required`);a&&(a.requiredServers??[]).length>0?he(e=>e?.jobId===a.jobId?e:{jobId:a.jobId,servers:a.requiredServers}):(me?.jobId&&me.jobId!==S||S!=null&&!t.queued.some(e=>e.jobId===S&&e.status===`blocked_auth`&&e.blockedReason===`oauth_required`))&&he(null)}catch{}},Ze=()=>{Se(),De()};(0,_.useEffect)(()=>{Ze(),Xe();let e=Ce.subscribeRunQueue(e=>{e.type===`queue_event`&&Xe(!0)}),t=()=>{Ze(),Xe()},n=()=>{Xe()};return window.addEventListener(`focus`,t),window.addEventListener(`mcplab:run-queue-changed`,n),()=>{window.removeEventListener(`focus`,t),window.removeEventListener(`mcplab:run-queue-changed`,n),e()}},[Se,De,Ce]);let Qe=async e=>{try{await Ce.removeQueuedRun(e),re(t=>t.filter(t=>t.jobId!==e))}catch(t){let n=t instanceof Error?t.message:String(t);if(n.includes(`Use the /stop endpoint`))try{await Ce.stopRun(e)}catch{}else O({title:`Could not remove queued run`,description:n,variant:`destructive`})}Xe()},$e=async e=>{let t=Array.from(new Set(e.jobs.flatMap(e=>e.requiredServers??[])));if(!(t.length===0||be.current)){be.current=!0,pe(!0);try{await e6({serverNames:t,source:Ce}),await Ce.resumeQueue()}catch(e){O({title:`Could not connect OAuth`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{be.current=!1,pe(!1),Xe()}}},et=async e=>{if(de!==e){V(e);try{await Ce.stopEvaluationRun(e),await Xe()}catch(e){O({title:`Could not stop run`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{V(null)}}},tt=async e=>{try{await Ce.removeEvaluationRun(e),await Xe()}catch(e){O({title:`Could not remove run`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}},nt=async e=>{try{await Ce.openRover(e),await Xe()}catch(e){O({title:`Could not open browser agent`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}},rt=e=>{S===e&&_e.current||(_e.current?.(),ve.current=e,_e.current=Ce.subscribeRunJob(e,t=>{let n=new Date(t.ts).toLocaleTimeString();if(t.type===`queued`)u(e=>{let r=t.payload.position?` (position ${t.payload.position})`:``,i=`[${n}] Run queued${r}. Waiting for active run to finish...`;return e.includes(i)?e:[...e,i]}),c(5);else if(t.type===`oauth_required`){let e=Array.isArray(t.payload.servers)?t.payload.servers:[],r=String(t.payload.jobId??``);he({jobId:r,servers:e}),u(t=>{let r=`[${n}] OAuth required for server(s): ${e.join(`, `)}. Click "Connect & Resume" to authenticate.`;return t.includes(r)?t:[...t,r]})}else{if(t.type===`started`&&(he(null),be.current=!1,o(!0),f(!1),y(!1),u(e=>{let t=`[${n}] Run started.`;return e.includes(t)?e:[...e,t]}),c(e=>Math.max(e,30)),Xe()),t.type===`log`){let e=String(t.payload.message??``).trim();e&&(u(t=>{let r=`[${n}] ${e}`;return t.includes(r)?t:[...t,r]}),c(t=>{let n=e.toLowerCase();if(n.startsWith(`loading mcp evaluation config`))return Math.max(t,15);if(n.startsWith(`loaded config`))return Math.max(t,20);if(n.startsWith(`selected `))return Math.max(t,30);if(n.startsWith(`using requested agents`)||n.startsWith(`using run default agents`)||n.startsWith(`using config-declared agents`))return Math.max(t,35);if(n.startsWith(`expanded to `))return Math.max(t,45);if(n.startsWith(`running evaluation`))return Math.max(t,50);let r=n.match(/^scenario (\d+)\/(\d+) finished:/);if(r){let e=Number(r[1]),n=Number(r[2]);return Math.max(t,50+Math.round(e/n*25))}return n.startsWith(`evaluation execution finished`)?Math.max(t,78):n.startsWith(`writing results to `)?Math.max(t,94):n.startsWith(`run finished:`)?Math.max(t,98):t}))}if(t.type===`completed`||t.type===`error`){let r=t.type===`error`,i=String(t.payload.runId??``).trim(),a=n=>t.payload.status===`stopped`||[`Run stopped by user`,`Run aborted by user`].includes(String(t.payload.message))||n?.status===`stopped`||n?.jobs.find(t=>t.jobId===e)?.status===`stopped`,s=e=>{if(!r||a(e))return;let i=String(t.payload.message??`Unknown error`),o=i.includes(`Anthropic model not found`)?` Hint: this usually means the API key works but the model ID is not enabled for that Anthropic account. Change the agent model in Manage Agents (library) or inline config.`:``;u(e=>[...e,`[${n}] Error: ${i}${o}`])},l=e=>{s(e);let t=r&&!a(e)||(e?.failedJobs??0)-(e?.stoppedJobs??0)>0,l=a(e)&&!t&&!e?.completedJobs&&!i;he(null),be.current=!1,u(r=>{let i=`[${n}] ${t?`Run completed with errors.`:a(e)?`Run stopped.`:`Run completed.`}`;return r.includes(i)?r:[...r,i]}),c(100),o(!1),f(!l),m(t),g(e??null),y(l),x(e?.completedJobs?e.evaluationRunId:r&&!a(e)?``:i),Je(),C(null),ve.current=null,_e.current?.(),_e.current=null,Xe()};Ce.getRunQueue().then(t=>{if(ve.current!==e)return;let r=t.evaluations?.find(t=>t.jobs.some(t=>t.jobId===e))??t.evaluations?.find(e=>e.evaluationRunId===i),a=r?.jobs.find(t=>t.jobId!==e&&[`queued`,`waiting_for_rover`,`paused_rover`,`running`].includes(t.status))??r?.jobs.find(t=>t.jobId!==e&&t.status===`blocked_auth`);if(a&&r){s(r);let e=r.completedJobs+r.failedJobs,t=`[${n}] Subtask finished. ${e}/${r.totalJobs} finished. Continuing with the remaining run tasks...`;u(e=>e.includes(t)?e:[...e,t]),c(t=>Math.max(t,r.totalJobs>0?Math.round(e/r.totalJobs*100):t)),he(a.status===`blocked_auth`?{jobId:a.jobId,servers:a.requiredServers??[]}:null),be.current=!1,o(!0),f(!1),y(!1),C(a.jobId),Ye(a.jobId),Xe(),rt(a.jobId)}else l(r)}).catch(()=>{ve.current===e&&l()})}}}))},it=e=>{S===e&&_e.current||(C(e),Ye(e),o(!0),f(!1),y(!1),u([`[${P7()}] Attached to running job ${e}...`]),c(10),rt(e))};return(0,I.jsxs)(`div`,{className:`space-y-6`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`h1`,{className:`inline-flex items-center gap-2 text-2xl font-bold`,children:[(0,I.jsx)(Yn,{className:`h-6 w-6`}),`Run Evaluation`]}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Execute evaluation scenarios against MCP servers`})]}),(0,I.jsx)(K,{children:(0,I.jsxs)(q,{className:`pt-6 space-y-4`,children:[(0,I.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(Q,{children:`MCP Evaluation`}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsxs)(OY,{value:t,onValueChange:n,children:[(0,I.jsx)(AY,{children:(0,I.jsx)(kY,{placeholder:`Select a config`})}),(0,I.jsx)(NY,{children:xe.map(e=>{let t=vfe(e);return(0,I.jsxs)(Z,{value:e.id,children:[(0,I.jsx)(`span`,{children:_fe(e)}),t&&(0,I.jsxs)(`span`,{className:`ml-2 text-muted-foreground`,children:[`(`,t,`)`]})]},e.id)})})]}),(0,I.jsx)(W,{type:`button`,variant:`outline`,size:`icon`,className:`h-10 w-10 shrink-0`,onClick:Ze,"aria-label":`Refresh configs`,title:`Refresh configs`,children:(0,I.jsx)(Qn,{className:`h-4 w-4`})})]})]}),(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(Q,{htmlFor:`variance-runs`,children:`Variance Runs`}),(0,I.jsx)(Op,{id:`variance-runs`,type:`number`,min:`1`,max:`10`,value:Be.length>0?`1`:r,onChange:e=>i(e.target.value),disabled:Be.length>0}),Be.length>0&&(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Browser agents support one run per scenario.`})]})]}),(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsx)(Q,{htmlFor:`run-note`,children:`Run Note`}),(0,I.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[ee.length,`/500`]})]}),(0,I.jsx)(iX,{id:`run-note`,value:ee,onChange:e=>te(e.target.value.slice(0,500)),placeholder:`Optional context for this run (for example: mcp-server v1.8.2 #staging)`,rows:2})]}),Ae&&(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsx)(Q,{children:`Agents`}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,I.jsx)(`button`,{type:`button`,className:`text-primary hover:underline`,onClick:()=>T(Re.map(e=>e.id)),children:`Select all`}),(0,I.jsx)(`button`,{type:`button`,className:`text-primary hover:underline`,onClick:()=>T([]),children:`Clear`})]})]}),(0,I.jsx)(`div`,{className:`space-y-3`,children:He.map(e=>e.agents.length>0?(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,I.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:e.label}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,I.jsx)(`button`,{type:`button`,className:`text-primary hover:underline`,"aria-label":`Select all ${e.label}`,onClick:()=>{let t=new Set(e.agents.map(e=>e.id));T(e=>[...e.filter(e=>!t.has(e)),...t])},children:`Select all`}),(0,I.jsx)(`button`,{type:`button`,className:`text-primary hover:underline`,"aria-label":`Clear ${e.label}`,onClick:()=>{let t=new Set(e.agents.map(e=>e.id));T(e=>e.filter(e=>!t.has(e)))},children:`Clear`})]})]}),(0,I.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:e.agents.map(e=>{let t=w.includes(e.id);return(0,I.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md border p-2 text-sm`,children:[(0,I.jsx)(KX,{checked:t,onCheckedChange:t=>{let n=t===!0;T(t=>n?[...t,e.id]:t.filter(t=>t!==e.id))}}),(0,I.jsx)(`span`,{children:e.name||e.id})]},e.id)})})]},e.label):null)}),Be.length>0&&(0,I.jsxs)(`div`,{className:`space-y-1.5 rounded-md border bg-muted/20 p-3`,children:[(0,I.jsx)(Q,{htmlFor:`conversation-behavior`,children:`Conversation behavior`}),(0,I.jsxs)(OY,{value:E,onValueChange:e=>D(e),children:[(0,I.jsx)(AY,{id:`conversation-behavior`,children:(0,I.jsx)(kY,{})}),(0,I.jsxs)(NY,{children:[(0,I.jsx)(Z,{value:`agent_default`,children:`Use agent default`}),(0,I.jsx)(Z,{value:`new`,children:`Start a new conversation`}),(0,I.jsx)(Z,{value:`same`,children:`Continue the same conversation`})]})]}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`This setting is frozen into the Rover job. Rover cannot change it locally.`})]}),Re.length===0&&(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No agents available. Add agents to your workspace library, or define inline agents in this config.`})]}),Ae&&(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsx)(Q,{children:`Tests`}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,I.jsx)(`button`,{type:`button`,className:`text-primary hover:underline`,onClick:()=>A(ze.map(e=>e.id)),children:`Select all`}),(0,I.jsx)(`button`,{type:`button`,className:`text-primary hover:underline`,onClick:()=>A([]),children:`Clear`})]})]}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[k.length,` of `,ze.length,` selected`]}),(0,I.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:ze.map(e=>{let t=k.includes(e.id),n=R[e.id],r=!!F[e.id],i=r&&Array.isArray(n),a=new Set(e.serverIds||[]);return(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm rounded-md border p-2 cursor-pointer`,onClick:n=>{let r=n.target;r&&(r.closest(`button, a, input, select, textarea, [role='button']`)||A(n=>t?n.filter(t=>t!==e.id):[...n,e.id]))},children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,I.jsx)(KX,{checked:t,onCheckedChange:t=>{let n=t===!0;A(t=>n?[...t,e.id]:t.filter(t=>t!==e.id))}}),(0,I.jsxs)(`span`,{className:`min-w-0`,children:[(0,I.jsxs)(`span`,{className:`block font-medium`,children:[e.name||e.id,` `,i&&(0,I.jsx)(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] text-primary`,children:`Override`})]}),(0,I.jsx)(`span`,{className:`block font-mono text-xs text-muted-foreground truncate`,children:e.id})]})]}),t&&(0,I.jsxs)(`div`,{className:`pl-6`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsx)(Q,{className:`text-[11px] text-muted-foreground`,children:`Per-scenario: "Override MCP Servers"`}),(0,I.jsx)(L5,{checked:r,onCheckedChange:t=>{if(L(n=>({...n,[e.id]:t})),!t)z(t=>{let n={...t};return delete n[e.id],n});else if(!R[e.id]){let t=j&&N.length>0?[...N]:[...e.serverIds||[]];z(n=>({...n,[e.id]:t}))}}})]}),r&&(0,I.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:Ue.map(t=>{let r=t.id,i=(n??[]).includes(r),o=a.has(r);return(0,I.jsx)(Y,{variant:i?`default`:`outline-solid`,className:`cursor-pointer text-xs ${i?``:`opacity-60 hover:opacity-100`}`,style:!i&&o?{borderColor:`hsl(var(--primary))`}:void 0,onClick:t=>{t.stopPropagation(),z(t=>{let n=t[e.id]??[],i=n.includes(r)?n.filter(e=>e!==r):[...n,r];return{...t,[e.id]:i}})},children:t.name?.trim()?t.name:r},r)})})]})]},e.id)})}),(0,I.jsxs)(`div`,{className:`space-y-1 rounded-md border p-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(`div`,{className:`text-xs`,children:[(0,I.jsx)(`span`,{children:`Override MCP Servers for selected Tests `}),(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:`Selected tests run against the servers you choose here. Applies only to this run.`})]}),(0,I.jsx)(L5,{checked:j,onCheckedChange:M})]}),j&&(0,I.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Ue.map(e=>{let t=e.id,n=N.includes(t);return(0,I.jsx)(Y,{variant:n?`default`:`outline-solid`,className:`cursor-pointer text-xs ${n?``:`opacity-60 hover:opacity-100`}`,onClick:()=>P(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t]),children:e.name?.trim()?e.name:t},t)})})]})]}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsxs)(W,{onClick:Ke,disabled:!t||fe||Re.length>0&&w.length===0||ze.length>0&&k.length===0,children:[(0,I.jsx)(Yn,{className:`mr-2 h-4 w-4`}),Pe?`Queue Run`:`Run`]}),a&&(0,I.jsxs)(W,{variant:`destructive`,onClick:qe,children:[(0,I.jsx)(sr,{className:`mr-2 h-4 w-4`}),`Stop`]})]})]})}),(a||l.length>0)&&(0,I.jsxs)(K,{children:[(0,I.jsx)(gv,{className:`pb-3`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsx)(_v,{className:`text-base`,children:`Progress`}),(0,I.jsxs)(`span`,{className:`text-xs text-muted-foreground font-mono`,children:[Math.round(Ie),`%`]})]})}),(0,I.jsxs)(q,{className:`space-y-4`,children:[(0,I.jsx)(t7,{value:Ie,className:`h-2`}),(Fe||Pe)&&(0,I.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground`,children:Fe?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`span`,{children:[Fe.completedJobs,`/`,Fe.totalJobs,` subtasks complete`]}),Fe.failedJobs-Fe.stoppedJobs>0&&(0,I.jsxs)(`span`,{className:`font-medium text-destructive`,children:[Fe.failedJobs-Fe.stoppedJobs,` failed`]}),Fe.stoppedJobs>0&&(0,I.jsxs)(`span`,{className:`font-medium text-muted-foreground`,children:[Fe.stoppedJobs,` stopped`]}),Fe.pausedJobs>0&&(0,I.jsxs)(`span`,{className:`font-medium text-yellow-700 dark:text-yellow-400`,children:[Fe.pausedJobs,` paused`]}),(0,I.jsx)(Y,{variant:`outline`,className:`capitalize`,children:Fe.status})]}):(0,I.jsx)(`span`,{children:Pe?.roverProgress?`${Pe.roverProgress.completed}/${Pe.roverProgress.total} scenarios complete`:`Attached to active run`})}),me&&(0,I.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-yellow-500/40 bg-yellow-500/10 px-3 py-2 text-sm`,children:[(0,I.jsxs)(`span`,{className:`text-yellow-700 dark:text-yellow-400`,children:[`OAuth required for: `,(0,I.jsx)(`strong`,{children:me.servers.join(`, `)})]}),(0,I.jsx)(W,{size:`sm`,variant:`outline`,disabled:fe,onClick:()=>{be.current||(be.current=!0,pe(!0),e6({serverNames:me.servers,source:Ce,onServerAuthStart:e=>{u(t=>[...t,`[${P7()}] OAuth sign-in opened for '${e}'...`])}}).then(()=>Ce.resumeQueue()).then(()=>{let e=me?.jobId;u(e=>[...e,`[${P7()}] OAuth complete. Resuming run...`]),e&&(C(e),Ye(e),o(!0),f(!1),rt(e))}).catch(e=>{let t=e instanceof Error?e.message:String(e);u(e=>[...e,`[${P7()}] OAuth error: ${t}`]),be.current=!1}).finally(()=>{pe(!1)}))},children:fe?`Connecting...`:`Connect & Resume`})]}),(0,I.jsx)(`div`,{ref:ge,className:`h-64 overflow-auto rounded-md border bg-muted/30 p-3 font-mono text-xs space-y-0.5`,children:l.map((e,t)=>(0,I.jsx)(`div`,{className:e.includes(`✓`)?`text-success`:e.includes(`aborted`)?`text-destructive`:`text-foreground`,children:e},t))})]})]}),(0,I.jsxs)(K,{children:[(0,I.jsx)(gv,{className:`pb-3`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(_v,{className:`inline-flex items-center gap-2 text-base`,children:[(0,I.jsx)(_n,{className:`h-4 w-4`}),`Run Queue`]}),(0,I.jsx)(W,{variant:`ghost`,size:`sm`,onClick:()=>void Xe(),children:(0,I.jsx)(Qn,{className:`h-3 w-3`})})]})}),(0,I.jsx)(q,{children:!Pe&&oe.length===0&&ne.length===0&&ce.length===0?(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No active or queued runs. Start a run above.`}):(0,I.jsxs)(`div`,{className:`space-y-2`,children:[ce.map(e=>(0,I.jsxs)(`div`,{onClick:()=>{let t=e.jobs.find(e=>e.status===`running`||e.status===`waiting_for_rover`||e.status===`paused_rover`);t&&it(t.jobId)},className:`rounded-md border p-3 text-sm ${e.status===`failed`?`border-destructive/40 bg-destructive/5`:e.status===`stopped`?`border-muted-foreground/30 bg-muted/40`:e.status===`partial`?`border-yellow-500/40 bg-yellow-500/5`:e.status===`running`?`border-primary/20 bg-primary/5`:`border-border bg-background`}`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`font-semibold`,children:e.evaluationName||`Evaluation`}),(0,I.jsx)(Y,{variant:`outline`,className:`capitalize ${e.status===`running`?`border-emerald-500/40 bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`:``}`,children:e.status}),(0,I.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[e.completedJobs,`/`,e.totalJobs,` scenario-agent runs complete`]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[e.jobs.some(e=>e.status===`blocked_auth`)&&(0,I.jsx)(W,{size:`sm`,variant:`outline`,className:`h-7 text-xs border-yellow-500/50 text-yellow-700 dark:text-yellow-400`,disabled:fe,onClick:()=>void $e(e),children:fe?`Connecting...`:`Connect OAuth`}),e.jobs.some(F7)&&(0,I.jsx)(W,{size:`sm`,variant:`outline`,className:`h-7 text-xs`,onClick:()=>{let t=e.jobs.find(F7);t&&nt(t.jobId)},title:`Open the browser-agent URL, then activate the Rover extension`,children:`Open browser agent`}),(0,I.jsx)(W,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs`,onClick:()=>ue(t=>t===e.evaluationRunId?null:e.evaluationRunId),"aria-label":`${le===e.evaluationRunId?`Collapse`:`Expand`} evaluation details`,children:le===e.evaluationRunId?`Hide`:`Details`}),e.jobs.length>0&&(e.jobs.every(e=>[`queued`,`blocked_auth`,`waiting_for_rover`,`stopped`].includes(e.status))||e.status===`stopped`&&e.jobs.every(e=>[`completed`,`error`,`stopped`].includes(e.status)))&&(0,I.jsxs)(W,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs text-muted-foreground hover:text-destructive`,onClick:()=>void tt(e.evaluationRunId),title:e.status===`stopped`?`Remove stopped run from the queue`:`Remove evaluation from queue`,"aria-label":e.status===`stopped`?`Remove stopped run from queue`:`Remove evaluation from queue`,children:[(0,I.jsx)(hr,{className:`mr-1 h-3 w-3`}),e.status===`stopped`?`Remove run`:`Remove`]}),e.jobs.some(e=>[`blocked_auth`,`waiting_for_rover`,`paused_rover`,`running`].includes(e.status))&&(0,I.jsxs)(W,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs text-destructive hover:text-destructive hover:bg-destructive/10`,disabled:de===e.evaluationRunId,onClick:()=>void et(e.evaluationRunId),title:`Stop this evaluation run and its queued or running tasks`,children:[(0,I.jsx)(sr,{className:`mr-1 h-3 w-3`}),de===e.evaluationRunId?`Stopping run...`:`Stop run`]})]})]}),le===e.evaluationRunId&&(0,I.jsx)(`div`,{className:`mt-2 space-y-1 text-xs text-muted-foreground`,children:yfe(e).map(({job:e,child:t},n)=>(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded px-2 py-1 ${t?.status===`completed`?`border border-emerald-500/30 bg-emerald-500/10 text-emerald-800 dark:text-emerald-300`:t?.status===`error`||t?.status===`stopped`?`border border-destructive/30 bg-destructive/5`:`bg-background`}`,onClick:()=>it(e.jobId),children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 truncate`,children:[(0,I.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[n+1,`.`]}),(t?t.status===`running`:e.status===`running`)&&(0,I.jsx)(Kg,{label:`Subjob running`}),t?.status===`completed`&&(0,I.jsx)(dn,{className:`h-3.5 w-3.5 shrink-0 text-emerald-600 dark:text-emerald-400`}),(t?.status===`error`||t?.status===`stopped`)&&(0,I.jsx)(hr,{className:`h-3.5 w-3.5 shrink-0 text-destructive`}),t?`${t.scenarioId} · ${t.agentName}: `:`${e.roverAgent?.name??e.runParams.agents?.join(`, `)??`Agent`}: `,t?.status===`queued`?`queued`:t?.status===`running`?`running`:t?.status===`completed`?`completed`:t?.status===`error`?`error`:t?.status===`stopped`?`stopped`:e.status===`waiting_for_rover`?`waiting for Rover`:e.status===`paused_rover`?`paused`:e.status.replaceAll(`_`,` `),t?` (${t.completed}/${t.total} attempts)`:e.roverProgress&&` (${e.roverProgress.completed}/${e.roverProgress.total} scenarios)`,!t&&e.roverProgress?.lastDurationMs!=null&&` · ${Math.round(e.roverProgress.lastDurationMs/1e3)}s`,t?.error&&` · ${t.error}`,!t&&e.roverProgress?.error&&` · ${e.roverProgress.error}`]}),(0,I.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,onClick:e=>e.stopPropagation(),children:[F7(e)&&(!t||e.childProgress?.[0]?.scenarioId===t.scenarioId)&&(0,I.jsx)(W,{size:`sm`,variant:`outline`,className:`h-6 px-1.5 text-[11px]`,onClick:()=>void nt(e.jobId),children:`Open browser agent`}),!t&&e.executionType===`rover`&&e.status===`paused_rover`&&(0,I.jsx)(W,{size:`sm`,variant:`outline`,className:`h-6 px-1.5 text-[11px]`,onClick:()=>{Ce.resumeRover(e.jobId).then(()=>void Xe())},children:`Resume`}),(t&&(t.status===`running`||t.status===`queued`)||!t&&e.status===`queued`||!t&&e.executionType===`rover`&&(e.status===`waiting_for_rover`||e.status===`paused_rover`||e.status===`running`))&&(0,I.jsx)(W,{size:`sm`,variant:`ghost`,className:`h-6 px-1.5 text-[11px] text-destructive`,onClick:()=>{(t?Ce.stopScenario(e.jobId,t.scenarioId,t.agentName):Ce.stopRun(e.jobId)).then(()=>void Xe())},children:t?.status===`queued`||e.status===`queued`?`Remove`:`Stop`})]})]},`${e.jobId}:${t?.scenarioId??`job`}:${t?.agentName??`job`}`))})]},e.evaluationRunId)),ie.filter(e=>!e.evaluationRunId).map(e=>(0,I.jsxs)(`div`,{role:`button`,tabIndex:0,className:`flex items-center justify-between rounded-md border border-primary/30 bg-primary/5 p-2 text-sm cursor-pointer hover:bg-primary/10 transition-colors ${S===e.jobId?`ring-2 ring-primary/40`:``}`,onClick:()=>{S!==e.jobId&&(C(e.jobId),Ye(e.jobId),o(!0),f(!1),y(!1),u([`[${P7()}] Attached to running job ${e.jobId}...`]),c(10),rt(e.jobId))},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&S!==e.jobId&&(t.preventDefault(),C(e.jobId),Ye(e.jobId),o(!0),f(!1),y(!1),u([`[${P7()}] Attached to running job ${e.jobId}...`]),c(10),rt(e.jobId))},title:`Click to view progress`,children:[(0,I.jsxs)(`div`,{className:`min-w-0 flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`inline-flex items-center rounded-full bg-primary/10 px-2 py-0.5 text-xs font-medium text-primary`,children:`Running`}),(0,I.jsx)(`span`,{className:`text-xs font-bold`,children:Me.get(e.runParams.configPath)||M7(e.runParams.scenarioIds,Ne,e.runParams.configPath)}),(0,I.jsx)(`span`,{className:`font-mono text-xs`,children:j7(e.runParams.configPath,je)}),e.runParams.agents&&(0,I.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`agents: `,e.runParams.agents.join(`, `)]}),e.runParams.runNote&&(0,I.jsxs)(`span`,{className:`text-xs text-muted-foreground truncate`,children:[`note: `,e.runParams.runNote]})]}),(0,I.jsxs)(W,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs text-destructive hover:text-destructive hover:bg-destructive/10`,onClick:t=>{t.stopPropagation(),Ce.stopRun(e.jobId),Xe()},title:`Stop running job`,children:[(0,I.jsx)(sr,{className:`mr-1 h-3 w-3`}),`Stop`]})]},e.jobId)),oe.filter(e=>!e.evaluationRunId).map(e=>{let t=j7(e.runParams.configPath,je),n=M7(e.runParams.scenarioIds,Ne,e.runParams.configPath),r=Me.get(e.runParams.configPath)||n,i=e.status===`blocked_auth`;return(0,I.jsx)(`div`,{className:`flex items-center justify-between rounded-md border p-2 text-sm ${i?`border-yellow-500/40 bg-yellow-500/5`:`border-border bg-background`}`,children:(0,I.jsxs)(`div`,{className:`min-w-0 flex items-center gap-2 flex-wrap`,children:[(0,I.jsx)(`span`,{className:`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${i?`bg-yellow-500/15 text-yellow-700 dark:text-yellow-400`:`bg-primary/10 text-primary`}`,children:i?`Retrying OAuth`:`Starting`}),(0,I.jsx)(`span`,{className:`text-xs font-bold`,children:r}),(0,I.jsx)(`span`,{className:`font-mono text-xs`,children:t}),i&&(e.requiredServers??[]).length>0&&(0,I.jsxs)(`span`,{className:`text-xs text-yellow-700 dark:text-yellow-400`,children:[`OAuth: `,e.requiredServers.join(`, `)]})]})},e.jobId)}),ne.filter(e=>!e.evaluationRunId).map((e,t)=>{let n=j7(e.runParams.configPath,je),r=M7(e.runParams.scenarioIds,Ne,e.runParams.configPath),i=Me.get(e.runParams.configPath)||r,a=e.status===`blocked_auth`;return(0,I.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border p-2 text-sm ${a?`border-yellow-500/40 bg-yellow-500/5`:``}`,children:[(0,I.jsxs)(`div`,{className:`min-w-0 flex items-center gap-2 flex-wrap`,children:[a?(0,I.jsxs)(`span`,{className:`inline-flex items-center rounded-full bg-yellow-500/15 px-2 py-0.5 text-xs font-medium text-yellow-700 dark:text-yellow-400`,children:[`#`,t+1,` Blocked`]}):(0,I.jsxs)(`span`,{className:`inline-flex items-center rounded-full bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground`,children:[`#`,t+1,` Queued`]}),(0,I.jsx)(`span`,{className:`text-xs font-bold`,children:i}),(0,I.jsx)(`span`,{className:`font-mono text-xs`,children:n}),a&&(e.requiredServers??[]).length>0&&(0,I.jsxs)(`span`,{className:`text-xs text-yellow-700 dark:text-yellow-400`,children:[`OAuth: `,e.requiredServers.join(`, `)]}),!a&&e.runParams.agents&&(0,I.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`agents: `,e.runParams.agents.join(`, `)]}),e.runParams.runNote&&(0,I.jsxs)(`span`,{className:`text-xs text-muted-foreground truncate`,children:[`note: `,e.runParams.runNote]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[a&&(0,I.jsx)(W,{size:`sm`,variant:`outline`,className:`h-7 text-xs border-yellow-500/50 text-yellow-700 dark:text-yellow-400 hover:bg-yellow-500/10`,disabled:fe,onClick:()=>{if(be.current)return;let t=e.requiredServers??[];t.length!==0&&(be.current=!0,he({jobId:e.jobId,servers:t}),pe(!0),e6({serverNames:t,source:Ce,onServerAuthStart:e=>{u(t=>[...t,`[${P7()}] OAuth sign-in opened for '${e}'...`])}}).then(()=>Ce.resumeQueue()).then(()=>{u(e=>[...e,`[${P7()}] OAuth complete. Resuming run...`]),C(e.jobId),Ye(e.jobId),o(!0),f(!1),rt(e.jobId)}).catch(e=>{let t=e instanceof Error?e.message:String(e);u(e=>[...e,`[${P7()}] OAuth error: ${t}`]),be.current=!1}).finally(()=>{pe(!1)}))},children:fe&&me?.jobId===e.jobId?`Connecting...`:`Connect & Resume`}),(0,I.jsx)(W,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>void Qe(e.jobId),title:`Remove from queue`,children:(0,I.jsx)(hr,{className:`h-4 w-4`})})]})]},e.jobId)})]})})]}),v&&!a&&!d&&(0,I.jsx)(K,{className:`border-amber-300/60 bg-amber-50/40`,children:(0,I.jsx)(q,{className:`pt-6`,children:(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,I.jsx)(sr,{className:`h-5 w-5 text-amber-700`}),(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`p`,{className:`font-medium`,children:`Run stopped`}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The evaluation was stopped before completion. You can start it again or clear the progress log.`})]}),(0,I.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,I.jsx)(W,{type:`button`,variant:`outline`,onClick:()=>{u([]),c(0),y(!1)},children:`Clear Progress`}),(0,I.jsxs)(W,{type:`button`,onClick:Ke,disabled:!t,children:[(0,I.jsx)(Yn,{className:`mr-2 h-4 w-4`}),`Run Again`]})]})]})})}),d&&(0,I.jsx)(K,{className:p?`border-amber-500/50`:h?.stoppedJobs?`border-border`:`border-success/50`,children:(0,I.jsx)(q,{className:`pt-6`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[p?(0,I.jsx)(hr,{className:`h-6 w-6 text-destructive`}):h?.stoppedJobs?(0,I.jsx)(_n,{className:`h-6 w-6 text-muted-foreground`}):(0,I.jsx)(dn,{className:`h-6 w-6 text-success`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`font-medium`,children:p?`Completed with errors`:h?.stoppedJobs?h.completedJobs?`Completed with stopped scenarios`:`Run stopped`:`Evaluation Complete`}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:h?`${h.totalJobs}/${h.totalJobs} finished, ${h.completedJobs} completed, ${Math.max(0,h.failedJobs-h.stoppedJobs)} error(s), ${h.stoppedJobs} stopped.`:p?`The evaluation ended with errors. Review the log for details.`:`All scenarios have finished. Review the results for their outcomes.`})]}),(0,I.jsx)(W,{asChild:!0,className:`ml-auto`,children:(0,I.jsx)(np,{to:ke,children:Oe?`View Results`:`View Runs`})})]})})})]})};function I7({title:e,description:t,expanded:n,onToggleExpanded:r,onHide:i,messages:a,pendingToolCalls:o,loading:s,expired:c=!1,input:l,onInputChange:u,onSend:d,onCancel:f,inputPlaceholder:p,snippets:m,snippetsLabel:h=`Result Assistant Snippets`,onSnippetSelect:g,onApproveToolCall:_,onDenyToolCall:v,inputRef:y,renderMessageFooter:b,className:x=`min-w-0 overflow-hidden xl:flex xl:h-full xl:min-h-0 xl:flex-col`,contentClassName:S=`flex h-[70vh] min-h-[520px] flex-col p-0 xl:h-auto xl:min-h-0 xl:flex-1`}){return(0,I.jsxs)(K,{className:x,children:[(0,I.jsx)(gv,{className:`border-b px-4 py-3`,children:(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsxs)(_v,{className:`flex items-center gap-2 text-base`,children:[(0,I.jsx)(ar,{className:`h-4 w-4 text-amber-500`}),e]}),(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,I.jsxs)(W,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 gap-1 px-2 text-xs`,onClick:r,children:[n?(0,I.jsx)(Gn,{className:`h-3.5 w-3.5`}):(0,I.jsx)(Kn,{className:`h-3.5 w-3.5`}),n?`Compact`:`Expand`]}),(0,I.jsx)(W,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 px-2 text-xs`,onClick:i,children:`Hide`})]})]}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t})]})}),(0,I.jsx)(q,{className:S,children:(0,I.jsx)(q3,{messages:a,toolCalls:o,busy:s,expired:c,onApprove:_,onDeny:v,renderMessageFooter:b,scrollClassName:`bg-muted/15 px-4 py-4`,composer:{input:l,onInputChange:u,onSend:d,onCancel:f,inputPlaceholder:p,snippets:m,snippetsLabel:h,onSnippetSelect:g,loading:s,inputRef:y},composerClassName:`border-t bg-background px-4 py-3`})})]})}function L7(e,t){if(!Number.isFinite(e)||e<=0)return`0ms`;if(e<1e3)return`${Math.round(e)}ms`;if(t?.preciseUnderTenSeconds&&e<1e4){let t=e/1e3,n=Math.round(t*10)/10;return`${Number.isInteger(n)?n.toFixed(0):n.toFixed(1)}s`}let n=Math.floor(e/1e3),r=Math.floor(n/3600),i=Math.floor(n%3600/60),a=n%60;return r>0?`${r}h ${i}m ${a}s`:i>0?`${i}m ${a}s`:`${a}s`}function R7(e){return e.runs.length>0?e.runs.reduce((e,t)=>e+t.duration,0):e.avgDuration}function z7(e){return e.scenarios.some(e=>e.runs.length>0)?e.scenarios.reduce((e,t)=>e+R7(t),0):typeof e.totalDurationMs==`number`&&e.totalDurationMs>=0?e.totalDurationMs:null}function B7(e){return e.runs.length>0?e.runs.reduce((e,t)=>e+t.toolCalls.reduce((e,t)=>e+t.duration,0),0):0}function V7(e){return e.scenarios.some(e=>e.runs.length>0)?e.scenarios.reduce((e,t)=>e+B7(t),0):typeof e.totalToolDurationMs==`number`&&e.totalToolDurationMs>=0?e.totalToolDurationMs:null}var H7=`hsl(152, 69%, 40%)`,U7=`hsl(0, 72%, 51%)`,W7=`hsl(215, 16%, 47%)`,G7=`hsl(38, 92%, 50%)`,K7=`hsl(38, 92%, 50%)`,q7=`hsl(270, 55%, 50%)`,J7=`hsl(215, 16%, 47%)`;function Y7(e,t=0){return e.toLocaleString(void 0,{maximumFractionDigits:t,minimumFractionDigits:t})}function X7({title:e,passed:t,failed:n,incomplete:r=0,error:i=0,stopped:a=0,notEvaluated:o=0,notExecuted:s=0}){let c=[{name:`Passed`,value:t,color:H7},{name:`Failed`,value:n,color:U7},...r>0?[{name:`Incomplete`,value:r,color:K7}]:[],...i>0?[{name:`Error`,value:i,color:q7}]:[],...a>0?[{name:`Stopped`,value:a,color:J7}]:[],...o>0?[{name:`Not evaluated`,value:o,color:W7}]:[],...s>0?[{name:`Not executed`,value:s,color:G7}]:[]];return(0,I.jsxs)(K,{children:[(0,I.jsx)(gv,{className:`p-2.5 pb-0`,children:(0,I.jsx)(_v,{className:`text-xs font-medium uppercase tracking-wider text-muted-foreground`,children:e})}),(0,I.jsxs)(q,{className:`flex h-[92px] items-center justify-center gap-2 p-0`,children:[(0,I.jsx)(`div`,{className:`h-[82px] w-[82px] shrink-0`,children:(0,I.jsx)(sT,{width:`100%`,height:`100%`,children:(0,I.jsxs)(AW,{children:[(0,I.jsx)(JL,{data:c,dataKey:`value`,nameKey:`name`,innerRadius:`55%`,outerRadius:`78%`,paddingAngle:3,children:c.map(e=>(0,I.jsx)(cT,{fill:e.color},e.name))}),(0,I.jsx)(Hw,{})]})})}),(0,I.jsxs)(`div`,{className:`space-y-0.5 text-xs`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-full`,style:{backgroundColor:H7}}),Y7(t),` passed`]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-full`,style:{backgroundColor:U7}}),Y7(n),` failed`]}),r>0&&(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-full`,style:{backgroundColor:K7}}),Y7(r),` incomplete`]}),i>0&&(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-full`,style:{backgroundColor:q7}}),Y7(i),` error`]}),a>0&&(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-full`,style:{backgroundColor:J7}}),Y7(a),` stopped`]}),o>0&&(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-full`,style:{backgroundColor:W7}}),Y7(o),` not evaluated`]}),s>0&&(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-full`,style:{backgroundColor:G7}}),Y7(s),` not executed`]})]})]})]})}function xfe({runs:e,loading:t}){let n=(0,_.useMemo)(()=>{let t=e.reduce((e,t)=>e+Math.max(0,t.totalRuns),0),n=e.reduce((e,t)=>e+(t.outcomes?.passed??Math.round(Math.max(0,t.totalRuns)*(t.overallPassRate??0))),0),r=e.reduce((e,t)=>e+(t.outcomes?.incomplete??0),0),i=e.reduce((e,t)=>e+(t.outcomes?.error??0),0),a=e.reduce((e,t)=>e+(t.outcomes?.stopped??0),0),o=e.reduce((e,t)=>e+(t.outcomes?.failed??Math.max(0,t.totalRuns-Math.round(Math.max(0,t.totalRuns)*(t.overallPassRate??0))-(t.outcomes?.incomplete??0)-(t.outcomes?.error??0)-(t.outcomes?.stopped??0))),0),s=e.reduce((e,t)=>e+Math.max(0,t.totalScenarios),0),c=e.reduce((e,t)=>(e.passed+=t.checkCounts?.passed??0,e.failed+=t.checkCounts?.failed??0,e.not_evaluated+=t.checkCounts?.not_evaluated??0,e.not_executed+=t.checkCounts?.not_executed??0,e.total+=t.checkCounts?.total??0,e),{passed:0,failed:0,not_evaluated:0,not_executed:0,total:0}),l=n=>t===0?0:e.reduce((e,t)=>e+n(t)*Math.max(0,t.totalRuns),0)/t,u=e.reduce((e,t)=>e+(t.toolTokenUsage?.totalTokens??0),0),d=e.reduce((e,t)=>e+(t.totalDurationMs??0),0),f=e.reduce((e,t)=>e+(t.totalToolDurationMs??0),0);return{totalRuns:t,passedRuns:n,failedRuns:o,incompleteRuns:r,errorRuns:i,stoppedRuns:a,checkCounts:c,totalScenarios:s,passRate:b_(n,t,a),avgToolCalls:l(e=>e.avgToolCalls),avgLatency:l(e=>e.avgLatency),totalTokens:u,totalDurationMs:d,totalToolDurationMs:f}},[e]);return t?(0,I.jsx)(K,{children:(0,I.jsx)(q,{className:`p-6 text-sm text-muted-foreground`,children:`Calculating dashboard…`})}):e.length===0?(0,I.jsx)(K,{children:(0,I.jsx)(q,{className:`p-6 text-sm text-muted-foreground`,children:`No results in the selected range.`})}):(0,I.jsx)(`div`,{className:`space-y-2`,"data-testid":`results-dashboard`,children:(0,I.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-4`,children:[(0,I.jsx)(X7,{title:`Runs Pass / Fail / Incomplete / Error / Stopped`,passed:n.passedRuns,failed:n.failedRuns,incomplete:n.incompleteRuns,error:n.errorRuns,stopped:n.stoppedRuns}),(0,I.jsx)(X7,{title:`Checks Pass / Fail / Not evaluated / Not executed`,passed:n.checkCounts.passed,failed:n.checkCounts.failed,notEvaluated:n.checkCounts.not_evaluated,notExecuted:n.checkCounts.not_executed}),(0,I.jsxs)(`div`,{className:`grid self-start content-start gap-3 sm:grid-cols-2 lg:col-span-2 lg:grid-cols-4`,children:[(0,I.jsx)(Dv,{compact:!0,title:`Scenarios`,value:Y7(n.totalScenarios),icon:Pn}),(0,I.jsx)(Dv,{compact:!0,title:`Total Runs`,value:Y7(n.totalRuns),icon:Xt}),(0,I.jsx)(Dv,{compact:!0,title:`Pass Rate`,value:n.passRate===null?`–`:`${Y7(n.passRate*100,1)}%`,icon:rn}),(0,I.jsx)(Dv,{compact:!0,title:`Avg Tool Calls`,value:Y7(n.avgToolCalls,1),icon:dn}),(0,I.jsx)(Dv,{compact:!0,title:`Avg Latency`,value:`${Y7(n.avgLatency)}ms`,icon:cr}),(0,I.jsx)(Dv,{compact:!0,title:`Tool Tokens`,value:Y7(n.totalTokens),icon:mr}),n.totalDurationMs>0?(0,I.jsx)(Dv,{compact:!0,title:`Total Time`,value:L7(n.totalDurationMs),icon:_n}):null,n.totalToolDurationMs>0?(0,I.jsx)(Dv,{compact:!0,title:`Tool Duration`,value:L7(n.totalToolDurationMs),icon:_n}):null]})]})})}function Sfe(e){let t=[];for(let n of e.scenarios)for(let e of n.runs)e.error&&t.push(e.error),t.push(...e.failureReasons);return t.map(e=>String(e??``).trim()).filter(Boolean)}function Cfe(e){let t=e.toLowerCase();return t.includes(`invalid_token`)||t.includes(`authentication failed`)||t.includes(`bearer token`)||t.includes(`oauth`)?`auth`:t.includes(`429`)||t.includes(`too many requests`)||t.includes(`rate limit`)?`rate_limit`:t.includes(`scenario error:`)||t.includes(`failed to list tools`)||t.includes(`failed to connect to mcp server`)||t.includes(`tool call failed`)||t.includes(`fetch failed`)||t.includes(`streamable http error`)?`infra`:null}function wfe(e){return e===`auth`?`Auth error`:e===`rate_limit`?`Rate limited`:`Infra error`}function Tfe(e){let t=Sfe(e);for(let e of[`auth`,`rate_limit`,`infra`]){let n=t.find(t=>Cfe(t)===e);if(n)return{kind:e,label:wfe(e),detail:n}}return null}function Efe(e){return e===`auth`?`border-amber-500/30 bg-amber-500/10 text-amber-700`:e===`rate_limit`?`border-orange-500/30 bg-orange-500/10 text-orange-700`:`border-slate-500/30 bg-slate-500/10 text-slate-700`}function Dfe({run:e}){let t=Tfe(e);return t?(0,I.jsx)(gl,{delayDuration:0,children:(0,I.jsxs)(_l,{children:[(0,I.jsx)(vl,{asChild:!0,children:(0,I.jsx)(Y,{variant:`outline`,className:`h-5 text-[10px] ${Efe(t.kind)}`,children:t.label})}),(0,I.jsx)(yl,{className:`max-w-sm text-xs`,children:(0,I.jsx)(`p`,{children:t.detail})})]})}):null}function Z7(e){let{source:t,open:n,scope:r,runId:i,onSessionSync:a}=e,o=a6({api:(0,_.useMemo)(()=>ble(t,r===`run`&&i?{scope:`run`,runId:i}:{scope:`all_runs`}),[t,r,i]),open:n,label:`MCP Lab Assistant`,recreateExpiredOnSend:!0,onSession:a}),{send:s,cancel:c,reset:l}=o,[u,d]=(0,_.useState)(``),[f,p]=(0,_.useState)(),m=(0,_.useRef)(null),h=(0,_.useCallback)(async()=>{let e=u.trim();e&&(r!==`run`||i)&&(d(``),await s(e))},[s,u,r,i]),g=(0,_.useCallback)(()=>{let e=c();e!==void 0&&d(e)},[c]),v=(0,_.useCallback)(()=>{l(),d(``),p(void 0)},[l]),y=(0,_.useCallback)(e=>{p(t=>t??{id:`result-assistant-intro`,role:`assistant`,text:e,createdAt:new Date().toISOString()})},[]),b=(0,_.useCallback)(e=>{d(e),requestAnimationFrame(()=>m.current?.focus())},[]);(0,_.useEffect)(()=>{let e=m.current;if(!e)return;e.style.height=`0px`;let t=Math.min(e.scrollHeight,160);e.style.height=`${Math.max(40,t)}px`},[u,n]);let x=(0,_.useMemo)(()=>o.messages.length===0&&f?[f]:o.messages,[o.messages,f]);return{assistantSessionId:o.sessionId,assistantMessages:x,assistantPendingToolCalls:o.pendingToolCalls,assistantInput:u,assistantLoading:o.busy,assistantTurnCancelable:o.cancelable,assistantExpired:o.expired,cancelAssistantTurn:g,assistantInputRef:m,setAssistantInput:d,askAssistant:h,approveResultAssistantToolCall:o.approve,denyResultAssistantToolCall:o.deny,applyResultAssistantSnippet:b,ensureIntroMessage:y,resetAssistantSession:v}}var Ofe=24,kfe=448;function Afe(e,{active:t,observe:n,query:r=`(min-width: 1280px)`}){let[i,a]=(0,_.useState)();return(0,_.useLayoutEffect)(()=>{if(!t){a(void 0);return}let i=window.matchMedia?.(r),o=()=>{let t=e.current;if(!t||i&&!i.matches)return a(void 0);a(Math.max(kfe,Math.round(window.innerHeight-jfe(t)-Ofe)))};o(),window.addEventListener(`resize`,o),i?.addEventListener?.(`change`,o);let s=n?.current&&typeof ResizeObserver<`u`?new ResizeObserver(o):void 0;return n?.current&&s?.observe(n.current),()=>{window.removeEventListener(`resize`,o),i?.removeEventListener?.(`change`,o),s?.disconnect()}},[t,n,r,e]),i}function jfe(e){let t=e.getBoundingClientRect().top;for(let n=e.parentElement;n;n=n.parentElement)t+=n.scrollTop;return t}async function Q7(e,t){let n=t.configPath?.trim();if(!n)throw Error(`This run has no config path in metadata.`);let r=await e.getResult(t.id)??t,i=r.rerunAgents&&r.rerunAgents.length>0?r.rerunAgents:Array.from(new Set(r.scenarios.map(e=>e.agentId).filter(Boolean)));await e.startRun({configPath:n,runsPerScenario:1,scenarioIds:r.rerunScenarioIds,agents:i.length>0?i:void 0,runNote:r.runNote,serverOverrideAll:r.rerunServerOverrideAll,scenarioServerOverrides:r.rerunScenarioServerOverrides,newConversationBeforeStart:r.rerunNewConversationBeforeStart,newConversationBetweenScenarios:r.rerunNewConversationBetweenScenarios})}var $7=[{value:`15min`,label:`Last 15min`,durationMs:9e5},{value:`30min`,label:`Last 30min`,durationMs:18e5},{value:`1h`,label:`Last hour`,durationMs:36e5},{value:`2h`,label:`Last 2 hours`,durationMs:72e5},{value:`4h`,label:`Last 4 hours`,durationMs:144e5},{value:`8h`,label:`Last 8 hours`,durationMs:288e5},{value:`24h`,label:`Last 24 hours`,durationMs:864e5},{value:`7d`,label:`Last 7 days`,durationMs:6048e5},{value:`14d`,label:`Last 14 days`,durationMs:12096e5},{value:`30d`,label:`Last 30 days`,durationMs:2592e6}];function e9(e){return e===`all`||e===`last`||e===`custom`}function t9(e){return e===`15min`||e===`30min`||e===`1h`||e===`2h`||e===`4h`||e===`8h`||e===`24h`||e===`7d`||e===`14d`||e===`30d`}function n9(e){let t=e.get(`time_filter`),n=e.get(`time_preset`);return{mode:e9(t)?t:`all`,preset:t9(n)?n:`15min`,start:e.get(`time_start`)??``,end:e.get(`time_end`)??``}}var r9=8,i9=`mcplab:results:time-filter`,a9=`mcplab:results:dashboard-visible`;function o9(e){if(!e.trim())return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t}function s9(e,t,n,r){if(e===`all`)return{};if(e===`last`){let e=$7.find(e=>e.value===t)??$7[0],n=new Date(Date.now());return{since:new Date(n.getTime()-e.durationMs).toISOString(),until:n.toISOString()}}let i=o9(n),a=o9(r);return i&&a?i.getTime()<=a.getTime()?{since:i.toISOString(),until:a.toISOString()}:{since:a.toISOString(),until:i.toISOString()}:i?{since:i.toISOString()}:a?{until:a.toISOString()}:{}}function c9(e){let t=o9(e);return t?t.toLocaleString():``}function Mfe(e){let t=o9(e);return t?`${t.getUTCFullYear()}-${String(t.getUTCMonth()+1).padStart(2,`0`)}-${String(t.getUTCDate()).padStart(2,`0`)}`:e}function Nfe(e){let t=o9(e);return t?t.toLocaleDateString(void 0,{weekday:`long`,month:`short`,day:`numeric`,year:`numeric`,timeZone:`UTC`}):`Unknown day`}function Pfe(e){return e.has(`time_filter`)||e.has(`time_preset`)||e.has(`time_start`)||e.has(`time_end`)}function Ffe(){try{let e=localStorage.getItem(i9);if(!e)return null;let t=JSON.parse(e);return{mode:e9(typeof t.mode==`string`?t.mode:null)?t.mode:`all`,preset:t9(typeof t.preset==`string`?t.preset:null)?t.preset:`15min`,start:typeof t.start==`string`?t.start:``,end:typeof t.end==`string`?t.end:``}}catch{return null}}function Ife(){try{let e=localStorage.getItem(a9);return e===null||e===`true`}catch{return!0}}var Lfe=[{label:`Summarize Run Trends`,description:`Highlight the main changes across the selected runs.`,prompt:`Summarize the main trends across these runs. Call out pass-rate changes, latency, and tool usage shifts.`},{label:`Explain Failures`,description:`Identify the most important failures and likely root causes.`,prompt:`Identify the most important failures across these runs and explain likely root causes from the traces.`},{label:`Compare Agents`,description:`Compare agent behavior, tool use, and answer quality across runs.`,prompt:`Compare agent behavior across these runs. Highlight differences in tool use, answer quality, and consistency.`},{label:`Spot Anomalies`,description:`Find outliers in latency, tool calls, or pass rate.`,prompt:`Find unusual runs or outliers in latency, tool calls, or pass rate, and explain why they stand out.`}],l9=100,Rfe=()=>{let[e,t]=cp(),{source:n}=nv(),[r]=(0,_.useState)(()=>Pfe(e)?n9(e):Ffe()??n9(e)),[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)([]),c=(0,_.useRef)(0),l=(0,_.useRef)(null),u=(0,_.useRef)(null),[d,f]=(0,_.useState)(!0),[p,m]=(0,_.useState)(Ife),[h,g]=(0,_.useState)(!1),[v,y]=(0,_.useState)(null),[b,x]=(0,_.useState)(!1),[S,C]=(0,_.useState)(`timestamp`),[w,T]=(0,_.useState)(`desc`),[E,D]=(0,_.useState)(`all`),[k,A]=(0,_.useState)(!1),[j,M]=(0,_.useState)(r.mode),[N,P]=(0,_.useState)(r.preset),[F,L]=(0,_.useState)(r.start),[R,z]=(0,_.useState)(r.end),[ee,te]=(0,_.useState)(!1),[ne,re]=(0,_.useState)(!1),[ie,ae]=(0,_.useState)(!1),oe=Afe(u,{active:ne,observe:l}),se=oe!==void 0,{completionVersion:ce}=sv(),B=w7(l9),{offset:le,totalCount:ue,hasMore:de}=B,[V,fe]=(0,_.useState)(null),pe=E===`all`?void 0:E,me=e=>{S===e?T(e=>e===`asc`?`desc`:`asc`):(C(e),T(e===`timestamp`?`desc`:`asc`))},he=(0,_.useCallback)(async()=>{if(!p||!n.listRunSummaries)return;let e=++c.current;f(!0);try{let t=await n.listRunSummaries({...s9(j,N,F,R),scenario:pe});c.current===e&&s(t.map(NW))}catch{c.current===e&&s([])}finally{c.current===e&&f(!1)}},[pe,p,n,R,j,N,F]),ge=async()=>{g(!0);try{let e=s9(j,N,F,R);if(n.listRunSummariesPage){let t=await n.listRunSummariesPage({...e,scenario:pe,limit:l9,offset:le});B.updateMeta(t),a(t.data.map(NW))}else if(n.listRunSummaries){let t=await n.listRunSummaries({...e,scenario:pe,limit:l9,offset:le});B.setTotalCount(t.length),B.setHasMore(!1),a(t.map(NW))}else B.setTotalCount(0),B.setHasMore(!1),a(await n.listResults());he()}catch(e){O({title:`Could not load results`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{g(!1)}};(0,_.useEffect)(()=>{let e=!0;g(!0);let t=s9(j,N,F,R);return(n.listRunSummariesPage?n.listRunSummariesPage({...t,scenario:pe,limit:l9,offset:le}).then(t=>(e&&B.updateMeta(t),t.data.map(NW))):n.listRunSummaries?n.listRunSummaries({...t,scenario:pe,limit:l9,offset:le}).then(t=>(e&&(B.setTotalCount(t.length),B.setHasMore(!1)),t.map(NW))):n.listResults()).then(t=>{e&&a(t)}).catch(t=>{e&&O({title:`Could not load results`,description:t instanceof Error?t.message:String(t),variant:`destructive`})}).finally(()=>{e&&g(!1)}),()=>{e=!1}},[pe,ce,le,n,R,j,N,F]),(0,_.useEffect)(()=>{try{localStorage.setItem(a9,String(p))}catch{}},[p]),(0,_.useEffect)(()=>{he()},[ce,he]),(0,_.useEffect)(()=>{p&&n.listRunSummaries||(p&&s(i),f(!1))},[p,i,n]);let{assistantMessages:_e,assistantPendingToolCalls:ve,assistantInput:ye,assistantLoading:be,assistantTurnCancelable:xe,assistantExpired:Se,cancelAssistantTurn:Ce,assistantInputRef:we,setAssistantInput:Te,askAssistant:Ee,approveResultAssistantToolCall:De,denyResultAssistantToolCall:Oe,applyResultAssistantSnippet:ke,ensureIntroMessage:Ae}=Z7({source:n,open:ne,scope:`all_runs`}),je=(0,_.useMemo)(()=>{let e=new Map;return i.forEach(t=>{t.scenarios.forEach(t=>{let n=String(t.scenarioName??``).trim(),r=String(t.scenarioId??``).trim();r?e.set(r,n||r):n&&e.set(n,n)})}),Array.from(e.entries()).map(([e,t])=>({value:e,label:t})).sort((e,t)=>e.label.localeCompare(t.label))},[i]);(0,_.useEffect)(()=>{let t=(e.get(`scenario`)??``).trim();t&&(je.some(e=>e.value===t||e.label===t)?D(t):i.length>0&&D(`all`))},[e,je,i.length]),(0,_.useEffect)(()=>{let n=new URLSearchParams(e);j===`all`?(n.delete(`time_filter`),n.delete(`time_preset`),n.delete(`time_start`),n.delete(`time_end`)):j===`last`?(n.set(`time_filter`,`last`),n.set(`time_preset`,N),n.delete(`time_start`),n.delete(`time_end`)):(n.set(`time_filter`,`custom`),n.delete(`time_preset`),F.trim()?n.set(`time_start`,F.trim()):n.delete(`time_start`),R.trim()?n.set(`time_end`,R.trim()):n.delete(`time_end`)),n.toString()!==e.toString()&&t(n,{replace:!0})},[e,t,R,j,N,F]),(0,_.useEffect)(()=>{try{if(j===`all`){localStorage.removeItem(i9);return}let e={mode:j,preset:N,start:F,end:R};localStorage.setItem(i9,JSON.stringify(e))}catch{}},[R,j,N,F]);let Me=(0,_.useMemo)(()=>{if(n.listRunSummariesPage)return i;let e=E===`all`?i:i.filter(e=>e.scenarios.some(e=>{let t=String(e.scenarioName??``).trim(),n=String(e.scenarioId??``).trim();return t===E||n===E}));if(j===`all`)return e;let t=Date.now();if(j===`last`){let n=t-($7.find(e=>e.value===N)??$7[0]).durationMs;return e.filter(e=>{let r=new Date(e.timestamp).getTime();return r>=n&&r<=t})}let r=o9(F)?.getTime()??null,a=o9(R)?.getTime()??null,o=r!==null&&a!==null?Math.min(r,a):r??null,s=r!==null&&a!==null?Math.max(r,a):a??null;return e.filter(e=>{let t=new Date(e.timestamp).getTime();return!(Number.isNaN(t)||o!==null&&t<o||s!==null&&t>s)})},[i,E,n.listRunSummariesPage,R,j,N,F]);(0,_.useEffect)(()=>{B.reset()},[pe,B.reset,R,j,N,F]);let Ne=(0,_.useMemo)(()=>E===`all`?`All scenarios`:je.find(e=>e.value===E||e.label===E)?.label??E,[E,je]),Pe=(0,_.useMemo)(()=>{if(j===`all`)return`All time`;if(j===`last`)return $7.find(e=>e.value===N)?.label??`Last range`;let e=!!F.trim(),t=!!R.trim();return!e&&!t?`Custom range`:e&&t?`${c9(F)} - ${c9(R)}`:e?`From ${c9(F)}`:`Until ${c9(R)}`},[R,j,N,F]),Fe=(0,_.useMemo)(()=>{let e=(e,t)=>e===null&&t===null?0:e===null?1:t===null?-1:w===`asc`?e-t:t-e;return[...Me].sort((t,n)=>{if(S===`toolTokens`)return e(t.toolTokenUsage?.totalTokens??null,n.toolTokenUsage?.totalTokens??null);let r=0;return S===`id`&&(r=t.id.localeCompare(n.id)),S===`timestamp`&&(r=new Date(t.timestamp).getTime()-new Date(n.timestamp).getTime()),S===`passRate`&&(r=(t.overallPassRate??-1)-(n.overallPassRate??-1)),S===`scenarios`&&(r=t.totalScenarios-n.totalScenarios),S===`avgToolCalls`&&(r=t.avgToolCalls-n.avgToolCalls),w===`asc`?r:-r})},[Me,S,w]),Ie=(0,_.useMemo)(()=>{let e=[],t=null;for(let n of Fe){let r=Mfe(n.timestamp);r!==t&&(e.push({type:`day-separator`,dayKey:r,dayLabel:Nfe(n.timestamp)}),t=r),e.push({type:`run`,run:n})}return e},[Fe]),Le=e=>S===e?w===`asc`?(0,I.jsx)(cn,{className:`h-3.5 w-3.5`}):(0,I.jsx)(on,{className:`h-3.5 w-3.5`}):(0,I.jsx)(ln,{className:`h-3.5 w-3.5 text-muted-foreground`}),Re=e=>{let t=e.toolTokenUsage?.totalTokens;return typeof t==`number`?t.toLocaleString():`n/a`},ze=()=>{M(`all`),P(`15min`),L(``),z(``)},Be=(0,_.useMemo)(()=>{let e=new Map;for(let t of Fe){if(t.scenarios.length>0){e.set(t.id,MW(t));continue}let n=t.configName?.trim()||``,r=t.configPath?.trim()||``,i=n||r;e.set(t.id,{scenarioCount:t.totalScenarios,agentCount:0,scopePreview:i||`n/a`,modelSummary:``})}return e},[Fe]),Ve=()=>{ne?re(!1):(re(!0),Ae(`Ask me to compare runs, explain regressions over time, or summarize historical drift patterns.`))},He=async e=>{x(!0);try{await n.deleteResult(e),a(t=>t.filter(t=>t.id!==e)),s(t=>t.filter(t=>t.id!==e)),B.setTotalCount(e=>Math.max(0,e-1)),O({title:`Run deleted`,description:e}),y(null)}catch(e){O({title:`Could not delete run`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{x(!1)}},Ue=async e=>{if(!e.configPath?.trim())O({title:`Cannot rerun`,description:`This run has no config path in metadata.`,variant:`destructive`});else{fe(e.id);try{await Q7(n,e),O({title:`Rerun queued`,description:`${e.id} queued with previous run settings.`})}catch(e){O({title:`Could not rerun`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{fe(t=>t===e.id?null:t)}}};return(0,I.jsxs)(`div`,{ref:l,className:`flex flex-col`,children:[(0,I.jsx)(X6,{open:v!==null,onOpenChange:e=>{!e&&!b&&y(null)},children:(0,I.jsxs)(Q6,{children:[(0,I.jsxs)($6,{children:[(0,I.jsx)(t8,{children:`Delete run?`}),(0,I.jsxs)(n8,{children:[`This will permanently remove the run artifacts from disk for`,` `,(0,I.jsx)(`span`,{className:`font-mono`,children:v??``}),`.`]})]}),(0,I.jsxs)(e8,{children:[(0,I.jsx)(i8,{disabled:b,children:`Cancel`}),(0,I.jsx)(r8,{disabled:b||!v,onClick:e=>{e.preventDefault(),v&&He(v)},className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:b?`Deleting...`:`Delete run`})]})]})}),(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`h1`,{className:`inline-flex items-center gap-2 text-2xl font-bold`,children:[(0,I.jsx)(rn,{className:`h-6 w-6`}),`Results`]}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Browse evaluation runs and open detailed results`})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsxs)(K8,{open:k,onOpenChange:A,children:[(0,I.jsx)(q8,{asChild:!0,children:(0,I.jsxs)(W,{type:`button`,variant:`outline`,role:`combobox`,"aria-expanded":k,"aria-controls":`results-scenario-command-list`,className:`w-[260px] justify-between font-normal ${E===`all`?``:`border-primary/40`}`,children:[(0,I.jsx)(`span`,{className:`truncate text-left`,children:Ne}),(0,I.jsx)(on,{className:`ml-2 h-4 w-4 shrink-0 opacity-50`})]})}),(0,I.jsx)(J8,{className:`w-[260px] p-0`,align:`start`,children:(0,I.jsxs)(b5,{children:[(0,I.jsx)(x5,{placeholder:`Search scenarios...`}),(0,I.jsxs)(S5,{id:`results-scenario-command-list`,children:[(0,I.jsx)(C5,{children:`No scenarios found.`}),(0,I.jsxs)(w5,{children:[(0,I.jsx)(T5,{value:`all scenarios`,onSelect:()=>{D(`all`),A(!1)},children:`All scenarios`}),je.map(e=>(0,I.jsx)(T5,{value:`${e.label} ${e.value}`,onSelect:()=>{D(e.value),A(!1)},children:e.label},e.value))]})]})]})})]}),(0,I.jsxs)(K8,{open:ee,onOpenChange:te,children:[(0,I.jsx)(q8,{asChild:!0,children:(0,I.jsxs)(W,{type:`button`,variant:`outline`,role:`combobox`,"aria-expanded":ee,"aria-controls":`results-time-command-list`,className:`w-[320px] justify-between font-normal ${j===`all`?``:`border-primary/40`}`,children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 truncate text-left`,children:[(0,I.jsx)(nn,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,I.jsx)(`span`,{className:`truncate`,children:Pe})]}),(0,I.jsx)(on,{className:`ml-2 h-4 w-4 shrink-0 opacity-50`})]})}),(0,I.jsxs)(J8,{className:`w-[360px] p-0`,align:`start`,children:[(0,I.jsxs)(`div`,{className:`border-b px-3 py-2`,children:[(0,I.jsx)(`p`,{className:`text-sm font-medium`,children:`Date and time filter`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Filter runs by timestamp.`})]}),(0,I.jsxs)(`div`,{id:`results-time-command-list`,className:`grid gap-1 p-2`,children:[(0,I.jsx)(W,{type:`button`,variant:j===`all`?`secondary`:`ghost`,className:`justify-start`,onClick:()=>{ze(),te(!1)},children:`All time`}),$7.map(e=>(0,I.jsx)(W,{type:`button`,variant:j===`last`&&N===e.value?`secondary`:`ghost`,className:`justify-start`,onClick:()=>{M(`last`),P(e.value),te(!1)},children:e.label},e.value)),(0,I.jsx)(W,{type:`button`,variant:j===`custom`?`secondary`:`ghost`,className:`justify-start`,onClick:()=>M(`custom`),children:`Custom date time range`})]}),j===`custom`&&(0,I.jsxs)(`div`,{className:`space-y-3 border-t p-3`,children:[(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(Q,{htmlFor:`results-time-filter-start`,children:`Start`}),(0,I.jsx)(Op,{id:`results-time-filter-start`,type:`datetime-local`,value:F,onChange:e=>L(e.target.value)})]}),(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(Q,{htmlFor:`results-time-filter-end`,children:`End`}),(0,I.jsx)(Op,{id:`results-time-filter-end`,type:`datetime-local`,value:R,onChange:e=>z(e.target.value)})]}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsxs)(W,{type:`button`,variant:`ghost`,size:`sm`,className:`px-2`,onClick:ze,children:[(0,I.jsx)(hr,{className:`mr-1.5 h-3.5 w-3.5`}),`Clear`]}),(0,I.jsx)(W,{type:`button`,size:`sm`,onClick:()=>te(!1),children:`Done`})]})]})]})]}),(0,I.jsx)(W,{variant:`outline`,onClick:()=>void ge(),disabled:h,children:h?`Refreshing...`:`Refresh`}),(0,I.jsx)(W,{variant:`outline`,onClick:B.prev,disabled:h||le===0,children:`Prev`}),(0,I.jsx)(W,{variant:`outline`,onClick:B.next,disabled:h||!de,children:`Next`}),(0,I.jsxs)(W,{type:`button`,variant:`outline`,className:`gap-1.5`,"aria-pressed":ne,onClick:Ve,children:[(0,I.jsx)(ar,{className:`h-4 w-4 text-amber-500`}),`MCP Lab Assistant`]})]})]}),(0,I.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-3`,children:[(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:B.rangeLabel(i.length)}),(0,I.jsxs)(W,{variant:`ghost`,size:`sm`,className:`h-7 gap-1.5 px-2 text-xs text-muted-foreground`,onClick:()=>m(e=>!e),"aria-pressed":p,children:[(0,I.jsx)(Fn,{className:`h-3 w-3`}),p?`Hide dashboard`:`Show dashboard`]})]}),p?(0,I.jsx)(`div`,{className:`mt-2`,children:(0,I.jsx)(xfe,{runs:o,loading:d})}):null,(0,I.jsxs)(`div`,{ref:u,style:se?{height:oe}:void 0,className:U(`mt-4 grid gap-6`,se?`grid-rows-[minmax(0,1fr)]`:`items-start`,ne?ie?`xl:grid-cols-[minmax(0,1fr)_52rem]`:`xl:grid-cols-[minmax(0,1fr)_30rem]`:`grid-cols-1`),children:[(0,I.jsx)(K,{"data-testid":`results-table`,className:U(`results-table-container`,se&&`flex min-h-0 flex-col overflow-hidden`),children:(0,I.jsx)(q,{className:U(`p-0`,se&&`min-h-0 flex-1`),children:(0,I.jsxs)(bv,{className:`table-auto`,containerClassName:se?`h-full`:void 0,children:[(0,I.jsx)(xv,{className:se?`sticky top-0 z-10 bg-card shadow-[0_1px_0_var(--color-border)]`:void 0,children:(0,I.jsxs)(wv,{children:[(0,I.jsx)(Tv,{className:`results-table-column-run-id w-120 max-w-120`,children:(0,I.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 hover:text-foreground`,onClick:()=>me(`id`),children:[`Run ID`,Le(`id`)]})}),(0,I.jsx)(Tv,{className:`results-table-column-evaluation w-[20rem] max-w-[20rem] min-w-0`,children:`Evaluation`}),(0,I.jsx)(Tv,{className:`results-table-column-timestamp w-44 min-w-44 max-w-44`,children:(0,I.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 hover:text-foreground`,onClick:()=>me(`timestamp`),children:[`Timestamp`,Le(`timestamp`)]})}),(0,I.jsx)(Tv,{className:`results-table-column-pass-rate w-30 min-w-30 max-w-30 text-center`,children:(0,I.jsxs)(`button`,{type:`button`,className:`inline-flex w-full items-center justify-end gap-1 hover:text-foreground`,onClick:()=>me(`passRate`),children:[`Pass Rate`,Le(`passRate`)]})}),(0,I.jsx)(Tv,{className:`results-table-column-scenarios w-22 min-w-22 max-w-22 text-right`,children:(0,I.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 hover:text-foreground`,onClick:()=>me(`scenarios`),children:[`Scenarios`,Le(`scenarios`)]})}),(0,I.jsx)(Tv,{className:`results-table-column-avg-tools w-30 min-w-30 max-w-30 text-right`,children:(0,I.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 hover:text-foreground`,onClick:()=>me(`avgToolCalls`),children:[`Avg Tools`,Le(`avgToolCalls`)]})}),(0,I.jsx)(Tv,{className:`results-table-column-tool-tokens w-36 min-w-36 max-w-36 text-right`,children:(0,I.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 hover:text-foreground`,onClick:()=>me(`toolTokens`),children:[`Tool Tokens`,Le(`toolTokens`)]})}),(0,I.jsx)(Tv,{className:`results-table-column-actions w-36 min-w-36 max-w-36`})]})}),(0,I.jsx)(Sv,{children:Ie.length===0?(0,I.jsx)(wv,{children:(0,I.jsx)(J,{colSpan:r9,className:`px-4 py-10 text-center text-sm text-muted-foreground`,children:j===`all`&&E===`all`?`No runs yet.`:`No runs match current filters.`})}):Ie.map((e,t)=>e.type===`day-separator`?(0,I.jsx)(wv,{className:`bg-muted/30 hover:bg-muted/30`,children:(0,I.jsx)(J,{colSpan:r9,className:`px-4 py-3`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,I.jsx)(`div`,{className:`h-px flex-1 bg-border/70`}),(0,I.jsx)(`span`,{className:`shrink-0 rounded-full border border-border bg-background px-2.5 py-0.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:e.dayLabel}),(0,I.jsx)(`div`,{className:`h-px flex-1 bg-border/70`})]})})},`day-${e.dayKey}-${t}`):(0,I.jsxs)(wv,{children:[(0,I.jsx)(J,{className:`results-table-column-run-id w-120 max-w-120`,children:(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(np,{to:`/results/${e.run.id}`,className:`font-mono text-xs text-primary hover:underline`,children:e.run.id}),(0,I.jsx)(`div`,{className:`min-w-0 truncate font-mono text-xs text-foreground/80`,title:Be.get(e.run.id)?.scopePreview??`n/a`,children:Be.get(e.run.id)?.scopePreview??`n/a`}),e.run.runNote?(0,I.jsxs)(`div`,{className:`text-[11px] text-muted-foreground wrap-break-word`,children:[`Note: `,e.run.runNote]}):null]})}),(0,I.jsx)(J,{className:`results-table-column-evaluation w-[20rem] max-w-[20rem] min-w-0 text-[11px] text-muted-foreground`,children:(()=>{let t=Be.get(e.run.id)??{scenarioCount:0,agentCount:0,scopePreview:`n/a`,modelSummary:``};return(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[(0,I.jsxs)(`span`,{className:`shrink-0 whitespace-nowrap`,children:[t.scenarioCount,` scenario`,t.scenarioCount===1?``:`s`,` · `,t.agentCount,` `,`agent`,t.agentCount===1?``:`s`]}),t.modelSummary?(0,I.jsxs)(`span`,{className:`min-w-0 truncate`,title:t.modelSummary,children:[`· `,t.modelSummary]}):null]}),(0,I.jsx)(C7,{versions:e.run.mcpServerVersions,showPrefix:!1,className:`max-w-[18rem]`})]})})()}),(0,I.jsx)(J,{className:`results-table-column-timestamp w-44 min-w-44 max-w-44 text-xs text-muted-foreground`,children:(0,I.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,I.jsx)(_n,{className:`h-3 w-3`}),new Date(e.run.timestamp).toLocaleString()]}),(()=>{let t=z7(e.run);return t===null?null:(0,I.jsxs)(`div`,{className:`font-mono text-[11px] text-muted-foreground/90`,children:[`Total time: `,L7(t)]})})()]})}),(0,I.jsx)(J,{className:`results-table-column-pass-rate w-30 min-w-30 max-w-30 text-right`,children:(0,I.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,I.jsx)(kv,{rate:e.run.overallPassRate}),e.run.checkCounts&&e.run.checkCounts.total>0?(0,I.jsxs)(`span`,{className:`font-mono text-[11px] leading-none`,"aria-label":`${e.run.checkCounts.passed} checks passed, ${e.run.checkCounts.failed} checks failed${e.run.checkCounts.not_evaluated>0?`, ${e.run.checkCounts.not_evaluated} not evaluated`:``}${(e.run.checkCounts.not_executed??0)>0?`, ${e.run.checkCounts.not_executed} not executed`:``}`,title:`${e.run.checkCounts.passed} passed · ${e.run.checkCounts.failed} failed${e.run.checkCounts.not_evaluated>0?` · ${e.run.checkCounts.not_evaluated} not evaluated`:``}${(e.run.checkCounts.not_executed??0)>0?` · ${e.run.checkCounts.not_executed} not executed`:``}`,children:[(0,I.jsxs)(`span`,{className:`text-success`,children:[e.run.checkCounts.passed,` ✓`]}),(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:` · `}),(0,I.jsxs)(`span`,{className:`text-destructive`,children:[e.run.checkCounts.failed,` ✕`]})]}):null,(0,I.jsx)(Dfe,{run:e.run})]})}),(0,I.jsx)(J,{className:`results-table-column-scenarios w-22 min-w-22 max-w-22 text-right font-mono text-sm`,children:e.run.totalScenarios}),(0,I.jsx)(J,{className:`results-table-column-avg-tools w-30 min-w-30 max-w-30 text-center font-mono text-sm`,children:e.run.avgToolCalls.toFixed(0)}),(0,I.jsx)(J,{className:`results-table-column-tool-tokens w-36 min-w-36 max-w-36 text-right`,children:(0,I.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,I.jsx)(`div`,{className:`font-mono text-sm`,children:Re(e.run)}),(()=>{let t=V7(e.run);return t===null?null:(0,I.jsxs)(`div`,{className:`font-mono text-[11px] text-muted-foreground/90`,children:[`Tool time: `,L7(t)]})})()]})}),(0,I.jsx)(J,{className:`results-table-column-actions w-36 min-w-36 max-w-36`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,I.jsxs)(W,{size:`sm`,variant:`outline`,disabled:V===e.run.id,onClick:()=>void Ue(e.run),children:[(0,I.jsx)(Yn,{className:`mr-1.5 h-3.5 w-3.5`}),V===e.run.id?`Queueing...`:`Rerun`]}),(0,I.jsxs)(Rq,{children:[(0,I.jsx)(zq,{asChild:!0,children:(0,I.jsx)(W,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":`More actions`,children:(0,I.jsx)(xn,{className:`h-4 w-4`})})}),(0,I.jsxs)(Hq,{align:`end`,children:[(0,I.jsx)(Uq,{asChild:!0,children:(0,I.jsxs)(np,{to:`/results/${e.run.id}`,children:[(0,I.jsx)(wn,{className:`mr-2 h-3.5 w-3.5`}),`View`]})}),Object.entries(e.run.langsmithTraceUrls??{}).map(([e,t])=>(0,I.jsx)(Uq,{asChild:!0,children:(0,I.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,children:[(0,I.jsx)(Sn,{className:`mr-2 h-3.5 w-3.5`}),`LangSmith trace`]})},e)),(0,I.jsxs)(Uq,{children:[(0,I.jsx)(yn,{className:`mr-2 h-3.5 w-3.5`}),`Export JSON`]}),(0,I.jsxs)(Uq,{className:`text-destructive`,onSelect:t=>{t.preventDefault();let n=document.activeElement;n instanceof HTMLElement&&n.blur(),y(e.run.id)},children:[(0,I.jsx)(lr,{className:`mr-2 h-3.5 w-3.5`}),`Delete`]})]})]})]})})]},e.run.id))})]})})}),ne&&(0,I.jsx)(`div`,{className:`min-h-0 min-w-0`,children:(0,I.jsx)(I7,{title:`MCP Lab Assistant`,description:`Analyze historical differences and trends across all result runs.`,expanded:ie,onToggleExpanded:()=>ae(e=>!e),onHide:()=>re(!1),messages:_e,pendingToolCalls:ve,loading:be,onCancel:xe?Ce:void 0,input:ye,onInputChange:Te,onSend:()=>void Ee(),inputPlaceholder:`Ask about historical run differences...`,snippets:Lfe,onSnippetSelect:e=>{re(!0),ke(e)},onApproveToolCall:De,onDenyToolCall:Oe,expired:Se,inputRef:we,className:`min-w-0 overflow-hidden xl:flex xl:h-full xl:min-h-0 xl:flex-col`})})]})]})};function zfe(e,t){return _.useReducer((e,n)=>t[e][n]??e,e)}var u9=`ScrollArea`,[d9,Bfe]=R(u9),[Vfe,f9]=d9(u9),p9=_.forwardRef((e,t)=>{let{__scopeScrollArea:n,type:r=`hover`,dir:i,scrollHideDelay:a=600,...o}=e,[s,c]=_.useState(null),[l,u]=_.useState(null),[d,f]=_.useState(null),[p,m]=_.useState(null),[h,g]=_.useState(null),[v,y]=_.useState(0),[b,x]=_.useState(0),[S,C]=_.useState(!1),[w,T]=_.useState(!1),E=P(t,e=>c(e)),D=BW(i);return(0,I.jsx)(Vfe,{scope:n,type:r,dir:D,scrollHideDelay:a,scrollArea:s,viewport:l,onViewportChange:u,content:d,onContentChange:f,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:S,onScrollbarXEnabledChange:C,scrollbarY:h,onScrollbarYChange:g,scrollbarYEnabled:w,onScrollbarYEnabledChange:T,onCornerWidthChange:y,onCornerHeightChange:x,children:(0,I.jsx)(V.div,{dir:D,...o,ref:E,style:{position:`relative`,"--radix-scroll-area-corner-width":v+`px`,"--radix-scroll-area-corner-height":b+`px`,...e.style}})})});p9.displayName=u9;var m9=`ScrollAreaViewport`,h9=_.forwardRef((e,t)=>{let{__scopeScrollArea:n,children:r,nonce:i,...a}=e,o=f9(m9,n),s=P(t,_.useRef(null),o.onViewportChange);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}`},nonce:i}),(0,I.jsx)(V.div,{"data-radix-scroll-area-viewport":``,...a,ref:s,style:{overflowX:o.scrollbarXEnabled?`scroll`:`hidden`,overflowY:o.scrollbarYEnabled?`scroll`:`hidden`,...e.style},children:(0,I.jsx)(`div`,{ref:o.onContentChange,style:{minWidth:`100%`,display:`table`},children:r})})]})});h9.displayName=m9;var g9=`ScrollAreaScrollbar`,_9=_.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=f9(g9,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:o}=i,s=e.orientation===`horizontal`;return _.useEffect(()=>(s?a(!0):o(!0),()=>{s?a(!1):o(!1)}),[s,a,o]),i.type===`hover`?(0,I.jsx)(Hfe,{...r,ref:t,forceMount:n}):i.type===`scroll`?(0,I.jsx)(Ufe,{...r,ref:t,forceMount:n}):i.type===`auto`?(0,I.jsx)(v9,{...r,ref:t,forceMount:n}):i.type===`always`?(0,I.jsx)(y9,{...r,ref:t}):null});_9.displayName=g9;var Hfe=_.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=f9(g9,e.__scopeScrollArea),[a,o]=_.useState(!1);return _.useEffect(()=>{let e=i.scrollArea,t=0;if(e){let n=()=>{window.clearTimeout(t),o(!0)},r=()=>{t=window.setTimeout(()=>o(!1),i.scrollHideDelay)};return e.addEventListener(`pointerenter`,n),e.addEventListener(`pointerleave`,r),()=>{window.clearTimeout(t),e.removeEventListener(`pointerenter`,n),e.removeEventListener(`pointerleave`,r)}}},[i.scrollArea,i.scrollHideDelay]),(0,I.jsx)(Pe,{present:n||a,children:(0,I.jsx)(v9,{"data-state":a?`visible`:`hidden`,...r,ref:t})})}),Ufe=_.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=f9(g9,e.__scopeScrollArea),a=e.orientation===`horizontal`,o=M9(()=>c(`SCROLL_END`),100),[s,c]=zfe(`hidden`,{hidden:{SCROLL:`scrolling`},scrolling:{SCROLL_END:`idle`,POINTER_ENTER:`interacting`},interacting:{SCROLL:`interacting`,POINTER_LEAVE:`idle`},idle:{HIDE:`hidden`,SCROLL:`scrolling`,POINTER_ENTER:`interacting`}});return _.useEffect(()=>{if(s===`idle`){let e=window.setTimeout(()=>c(`HIDE`),i.scrollHideDelay);return()=>window.clearTimeout(e)}},[s,i.scrollHideDelay,c]),_.useEffect(()=>{let e=i.viewport,t=a?`scrollLeft`:`scrollTop`;if(e){let n=e[t],r=()=>{let r=e[t];n!==r&&(c(`SCROLL`),o()),n=r};return e.addEventListener(`scroll`,r),()=>e.removeEventListener(`scroll`,r)}},[i.viewport,a,c,o]),(0,I.jsx)(Pe,{present:n||s!==`hidden`,children:(0,I.jsx)(y9,{"data-state":s===`hidden`?`hidden`:`visible`,...r,ref:t,onPointerEnter:j(e.onPointerEnter,()=>c(`POINTER_ENTER`)),onPointerLeave:j(e.onPointerLeave,()=>c(`POINTER_LEAVE`))})})}),v9=_.forwardRef((e,t)=>{let n=f9(g9,e.__scopeScrollArea),{forceMount:r,...i}=e,[a,o]=_.useState(!1),s=e.orientation===`horizontal`,c=M9(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;o(s?e:t)}},10);return N9(n.viewport,c),N9(n.content,c),(0,I.jsx)(Pe,{present:r||a,children:(0,I.jsx)(y9,{"data-state":a?`visible`:`hidden`,...i,ref:t})})}),y9=_.forwardRef((e,t)=>{let{orientation:n=`vertical`,...r}=e,i=f9(g9,e.__scopeScrollArea),a=_.useRef(null),o=_.useRef(0),[s,c]=_.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=D9(s.viewport,s.content),u={...r,sizes:s,onSizesChange:c,hasThumb:l>0&&l<1,onThumbChange:e=>a.current=e,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:e=>o.current=e};function d(e,t){return Yfe(e,o.current,s,t)}return n===`horizontal`?(0,I.jsx)(Wfe,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollLeft,t=k9(e,s,i.dir);a.current.style.transform=`translate3d(${t}px, 0, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollLeft=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollLeft=d(e,i.dir))}}):n===`vertical`?(0,I.jsx)(Gfe,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollTop,t=k9(e,s);a.current.style.transform=`translate3d(0, ${t}px, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollTop=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollTop=d(e))}}):null}),Wfe=_.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=f9(g9,e.__scopeScrollArea),[o,s]=_.useState(),c=_.useRef(null),l=P(t,c,a.onScrollbarXChange);return _.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,I.jsx)(x9,{"data-orientation":`horizontal`,...i,ref:l,sizes:n,style:{bottom:0,left:a.dir===`rtl`?`var(--radix-scroll-area-corner-width)`:0,right:a.dir===`ltr`?`var(--radix-scroll-area-corner-width)`:0,"--radix-scroll-area-thumb-width":O9(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollLeft+t.deltaX;e.onWheelScroll(r),j9(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:E9(o.paddingLeft),paddingEnd:E9(o.paddingRight)}})}})}),Gfe=_.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=f9(g9,e.__scopeScrollArea),[o,s]=_.useState(),c=_.useRef(null),l=P(t,c,a.onScrollbarYChange);return _.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,I.jsx)(x9,{"data-orientation":`vertical`,...i,ref:l,sizes:n,style:{top:0,right:a.dir===`ltr`?0:void 0,left:a.dir===`rtl`?0:void 0,bottom:`var(--radix-scroll-area-corner-height)`,"--radix-scroll-area-thumb-height":O9(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollTop+t.deltaY;e.onWheelScroll(r),j9(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:E9(o.paddingTop),paddingEnd:E9(o.paddingBottom)}})}})}),[Kfe,b9]=d9(g9),x9=_.forwardRef((e,t)=>{let{__scopeScrollArea:n,sizes:r,hasThumb:i,onThumbChange:a,onThumbPointerUp:o,onThumbPointerDown:s,onThumbPositionChange:c,onDragScroll:l,onWheelScroll:u,onResize:d,...f}=e,p=f9(g9,n),[m,h]=_.useState(null),g=P(t,e=>h(e)),v=_.useRef(null),y=_.useRef(``),b=p.viewport,x=r.content-r.viewport,S=pe(u),C=pe(c),w=M9(d,10);function T(e){if(v.current){let t=e.clientX-v.current.left,n=e.clientY-v.current.top;l({x:t,y:n})}}return _.useEffect(()=>{let e=e=>{let t=e.target;m?.contains(t)&&S(e,x)};return document.addEventListener(`wheel`,e,{passive:!1}),()=>document.removeEventListener(`wheel`,e,{passive:!1})},[b,m,x,S]),_.useEffect(C,[r,C]),N9(m,w),N9(p.content,w),(0,I.jsx)(Kfe,{scope:n,scrollbar:m,hasThumb:i,onThumbChange:pe(a),onThumbPointerUp:pe(o),onThumbPositionChange:C,onThumbPointerDown:pe(s),children:(0,I.jsx)(V.div,{...f,ref:g,style:{position:`absolute`,...f.style},onPointerDown:j(e.onPointerDown,e=>{e.button===0&&(e.target.setPointerCapture(e.pointerId),v.current=m.getBoundingClientRect(),y.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect=`none`,p.viewport&&(p.viewport.style.scrollBehavior=`auto`),T(e))}),onPointerMove:j(e.onPointerMove,T),onPointerUp:j(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=y.current,p.viewport&&(p.viewport.style.scrollBehavior=``),v.current=null})})})}),S9=`ScrollAreaThumb`,C9=_.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=b9(S9,e.__scopeScrollArea);return(0,I.jsx)(Pe,{present:n||i.hasThumb,children:(0,I.jsx)(qfe,{ref:t,...r})})}),qfe=_.forwardRef((e,t)=>{let{__scopeScrollArea:n,style:r,...i}=e,a=f9(S9,n),o=b9(S9,n),{onThumbPositionChange:s}=o,c=P(t,e=>o.onThumbChange(e)),l=_.useRef(void 0),u=M9(()=>{l.current&&=(l.current(),void 0)},100);return _.useEffect(()=>{let e=a.viewport;if(e){let t=()=>{if(u(),!l.current){let t=Xfe(e,s);l.current=t,s()}};return s(),e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)}},[a.viewport,u,s]),(0,I.jsx)(V.div,{"data-state":o.hasThumb?`visible`:`hidden`,...i,ref:c,style:{width:`var(--radix-scroll-area-thumb-width)`,height:`var(--radix-scroll-area-thumb-height)`,...r},onPointerDownCapture:j(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;o.onThumbPointerDown({x:n,y:r})}),onPointerUp:j(e.onPointerUp,o.onThumbPointerUp)})});C9.displayName=S9;var w9=`ScrollAreaCorner`,T9=_.forwardRef((e,t)=>{let n=f9(w9,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!==`scroll`&&r?(0,I.jsx)(Jfe,{...e,ref:t}):null});T9.displayName=w9;var Jfe=_.forwardRef((e,t)=>{let{__scopeScrollArea:n,...r}=e,i=f9(w9,n),[a,o]=_.useState(0),[s,c]=_.useState(0),l=!!(a&&s);return N9(i.scrollbarX,()=>{let e=i.scrollbarX?.offsetHeight||0;i.onCornerHeightChange(e),c(e)}),N9(i.scrollbarY,()=>{let e=i.scrollbarY?.offsetWidth||0;i.onCornerWidthChange(e),o(e)}),l?(0,I.jsx)(V.div,{...r,ref:t,style:{width:a,height:s,position:`absolute`,right:i.dir===`ltr`?0:void 0,left:i.dir===`rtl`?0:void 0,bottom:0,...e.style}}):null});function E9(e){return e?parseInt(e,10):0}function D9(e,t){let n=e/t;return isNaN(n)?0:n}function O9(e){let t=D9(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Yfe(e,t,n,r=`ltr`){let i=O9(n),a=i/2,o=t||a,s=i-o,c=n.scrollbar.paddingStart+o,l=n.scrollbar.size-n.scrollbar.paddingEnd-s,u=n.content-n.viewport,d=r===`ltr`?[0,u]:[u*-1,0];return A9([c,l],d)(e)}function k9(e,t,n=`ltr`){let r=O9(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=Jq(e,n===`ltr`?[0,o]:[o*-1,0]);return A9([0,o],[0,s])(c)}function A9(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function j9(e,t){return e>0&&e<t}var Xfe=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return(function i(){let a={left:e.scrollLeft,top:e.scrollTop},o=n.left!==a.left,s=n.top!==a.top;(o||s)&&t(),n=a,r=window.requestAnimationFrame(i)})(),()=>window.cancelAnimationFrame(r)};function M9(e,t){let n=pe(e),r=_.useRef(0);return _.useEffect(()=>()=>window.clearTimeout(r.current),[]),_.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function N9(e,t){let n=pe(t);Ae(()=>{let t=0;if(e){let r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}},[e,n])}var P9=p9,Zfe=h9,Qfe=T9,F9=_.forwardRef(({className:e,children:t,...n},r)=>(0,I.jsxs)(P9,{ref:r,className:U(`relative overflow-hidden`,e),...n,children:[(0,I.jsx)(Zfe,{className:`h-full w-full rounded-[inherit]`,children:t}),(0,I.jsx)(I9,{}),(0,I.jsx)(Qfe,{})]}));F9.displayName=P9.displayName;var I9=_.forwardRef(({className:e,orientation:t=`vertical`,...n},r)=>(0,I.jsx)(_9,{ref:r,orientation:t,className:U(`flex touch-none select-none transition-colors`,t===`vertical`&&`h-full w-2.5 border-l border-l-transparent p-px`,t===`horizontal`&&`h-2.5 flex-col border-t border-t-transparent p-px`,e),...n,children:(0,I.jsx)(C9,{className:`relative flex-1 rounded-full bg-border`})}));I9.displayName=_9.displayName;function $fe(e){let t=e.scenarios.reduce((e,t)=>e+t.runs.filter(e=>e.passed).length,0),n=e.outcomes?.stopped??e.scenarios.reduce((e,t)=>e+t.runs.filter(e=>e.outcome===`stopped`).length,0),r=Math.max(0,e.totalRuns-t-n),i=b_(t,e.totalRuns,n),a={};e.scenarios.forEach(e=>e.runs.forEach(e=>e.toolCalls.forEach(e=>{a[e.name]=(a[e.name]||0)+1})));let o=Object.keys(a),s=Object.values(a),c=e.scenarios.map(e=>{let t=b_(e.runs.filter(e=>e.passed).length,e.runs.length,e.runs.filter(e=>e.outcome===`stopped`).length);return`
165
165
  <div class="scenario-card">
166
166
  <div class="scenario-header" onclick="this.parentElement.classList.toggle('open')">
167
167
  <span class="chevron">▶</span>
@@ -16,7 +16,7 @@
16
16
  <meta name="twitter:card" content="summary_large_image" />
17
17
  <meta name="twitter:site" content="@Inspectr" />
18
18
  <meta name="twitter:image" content="" />
19
- <script type="module" crossorigin src="/assets/index-Cwogc_kk.js"></script>
19
+ <script type="module" crossorigin src="/assets/index-Co-US91U.js"></script>
20
20
  <link rel="stylesheet" crossorigin href="/assets/index-D5OYchKq.css">
21
21
  </head>
22
22
 
@@ -1,45 +1,39 @@
1
1
  import type { McpRequestHeaderContext } from '@inspectr/mcplab-core';
2
2
  export interface InspectrProxySession {
3
- upstreamOrigin: string;
4
- proxyOrigin: string;
5
- dashboardUrl: string;
3
+ upstreamOrigin: string;
4
+ proxyOrigin: string;
5
+ dashboardUrl: string;
6
6
  }
7
- export declare function buildInspectrRequestHeaders(
8
- context: McpRequestHeaderContext
9
- ): Record<string, string>;
7
+ export declare function buildInspectrRequestHeaders(context: McpRequestHeaderContext): Record<string, string>;
10
8
  interface InspectrChild {
11
- kill(signal?: NodeJS.Signals): boolean;
12
- once(event: string, listener: (...args: any[]) => void): this;
9
+ kill(signal?: NodeJS.Signals): boolean;
10
+ once(event: string, listener: (...args: any[]) => void): this;
13
11
  }
14
12
  interface InspectrSessionManagerOptions {
15
- storageRoot: string;
16
- commandPath?: string;
17
- log?: (message: string) => void;
18
- allocatePort?: () => Promise<number>;
19
- spawn?: (
20
- command: string,
21
- args: string[],
22
- options: {
23
- cwd: string;
24
- stdio: ['ignore', 'ignore', 'ignore'];
25
- }
26
- ) => InspectrChild;
27
- waitForReady?: (session: InspectrProxySession, child: InspectrChild) => Promise<void>;
13
+ storageRoot: string;
14
+ commandPath?: string;
15
+ log?: (message: string) => void;
16
+ allocatePort?: () => Promise<number>;
17
+ spawn?: (command: string, args: string[], options: {
18
+ cwd: string;
19
+ stdio: ['ignore', 'ignore', 'ignore'];
20
+ }) => InspectrChild;
21
+ waitForReady?: (session: InspectrProxySession, child: InspectrChild) => Promise<void>;
28
22
  }
29
23
  export declare class InspectrSessionManager {
30
- private readonly storageRoot;
31
- private readonly commandPath;
32
- private readonly log;
33
- private readonly allocatePort;
34
- private readonly spawn;
35
- private readonly waitForReady;
36
- private readonly sessions;
37
- private readonly starting;
38
- constructor(options: InspectrSessionManagerOptions);
39
- acquire(serverUrl: string): Promise<InspectrProxySession>;
40
- closeAll(): Promise<void>;
41
- private start;
24
+ private readonly storageRoot;
25
+ private readonly commandPath;
26
+ private readonly log;
27
+ private readonly allocatePort;
28
+ private readonly spawn;
29
+ private readonly waitForReady;
30
+ private readonly sessions;
31
+ private readonly starting;
32
+ constructor(options: InspectrSessionManagerOptions);
33
+ acquire(serverUrl: string): Promise<InspectrProxySession>;
34
+ closeAll(): Promise<void>;
35
+ private start;
42
36
  }
43
37
  export declare function rewriteUrlThroughInspectr(serverUrl: string, proxyOrigin: string): string;
44
38
  export {};
45
- //# sourceMappingURL=inspectr-session-manager.d.ts.map
39
+ //# sourceMappingURL=inspectr-session-manager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"inspectr-session-manager.d.ts","sourceRoot":"","sources":["../../src/app-server/inspectr-session-manager.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAErE,MAAM,WAAW,oBAAoB;IACnC,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,uBAAuB,GAC/B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAYxB;AAED,UAAU,aAAa;IACrB,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;IACvC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,IAAI,CAAC;CAC/D;AAED,UAAU,6BAA6B;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IACrC,KAAK,CAAC,EAAE,CACN,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;KAAE,KAC5D,aAAa,CAAC;IACnB,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,oBAAoB,EAAE,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvF;AAID,qBAAa,sBAAsB;IACjC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAA4B;IAChD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAwB;IACrD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAsD;IAC5E,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA6D;IAC1F,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqC;IAC9D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA8C;gBAE3D,OAAO,EAAE,6BAA6B;IAS5C,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAczD,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;YAOjB,KAAK;CAiDpB;AA2BD,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAGxF"}
1
+ {"version":3,"file":"inspectr-session-manager.d.ts","sourceRoot":"","sources":["../../src/app-server/inspectr-session-manager.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAErE,MAAM,WAAW,oBAAoB;IACnC,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,uBAAuB,GAC/B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAYxB;AAED,UAAU,aAAa;IACrB,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;IACvC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,IAAI,CAAC;CAC/D;AAED,UAAU,6BAA6B;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IACrC,KAAK,CAAC,EAAE,CACN,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;KAAE,KAC5D,aAAa,CAAC;IACnB,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,oBAAoB,EAAE,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvF;AAID,qBAAa,sBAAsB;IACjC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAA4B;IAChD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAwB;IACrD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAsD;IAC5E,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA6D;IAC1F,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqC;IAC9D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA8C;IAEvE,YAAY,OAAO,EAAE,6BAA6B,EAQjD;IAEK,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAY9D;IAEK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAK9B;YAEa,KAAK;CAiDpB;AA2BD,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAQxF"}
@@ -31,7 +31,8 @@ export class InspectrSessionManager {
31
31
  this.commandPath = options.commandPath ?? resolveInspectrCommand();
32
32
  this.log = options.log ?? console.log;
33
33
  this.allocatePort = options.allocatePort ?? allocateFreePort;
34
- this.spawn = options.spawn ?? ((command, args, spawnOptions) => defaultSpawn(command, args, spawnOptions));
34
+ this.spawn =
35
+ options.spawn ?? ((command, args, spawnOptions) => defaultSpawn(command, args, spawnOptions));
35
36
  this.waitForReady = options.waitForReady ?? waitForPorts;
36
37
  }
37
38
  async acquire(serverUrl) {
@@ -123,13 +124,21 @@ function normalizeOrigin(serverUrl) {
123
124
  }
124
125
  export function rewriteUrlThroughInspectr(serverUrl, proxyOrigin) {
125
126
  const original = new URL(serverUrl);
126
- return new URL(`${original.pathname}${original.search}`, proxyOrigin).toString();
127
+ // Assign path and query onto the proxy URL: resolving them as a relative reference would treat
128
+ // a `//host/...` path as a new authority and bypass the proxy.
129
+ const proxied = new URL(proxyOrigin);
130
+ proxied.pathname = original.pathname;
131
+ proxied.search = original.search;
132
+ return proxied.toString();
127
133
  }
128
134
  function originKey(origin) {
129
135
  return createHash('sha256').update(origin).digest('hex').slice(0, 16);
130
136
  }
131
137
  function tagPart(value) {
132
- return value.trim().replace(/[\u0000-\u001f\u007f,]+/g, '_').slice(0, 120) || 'unknown';
138
+ return (value
139
+ .trim()
140
+ .replace(/[\u0000-\u001f\u007f,]+/g, '_')
141
+ .slice(0, 120) || 'unknown');
133
142
  }
134
143
  async function allocateFreePort() {
135
144
  const server = createServer();
@@ -157,7 +166,7 @@ async function waitForPorts(session, child) {
157
166
  while (Date.now() < deadline) {
158
167
  if (childExited)
159
168
  throw new Error('Inspectr process exited during startup');
160
- if (await Promise.all(ports.map(canConnect))) {
169
+ if ((await Promise.all(ports.map(canConnect))).every(Boolean)) {
161
170
  stableChecks += 1;
162
171
  if (stableChecks >= 2 && (await hasDashboardConfig(session.dashboardUrl)))
163
172
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"inspectr-session-manager.js","sourceRoot":"","sources":["../../src/app-server/inspectr-session-manager.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"inspectr-session-manager.js","sourceRoot":"","sources":["../../src/app-server/inspectr-session-manager.ts"],"names":[],"mappings":"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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inspectr/mcplab",
3
- "version": "1.31.0",
3
+ "version": "1.31.1",
4
4
  "description": "MCPLab - Test and evaluate MCP servers with LLMs — run evals, compare agents and launch the MCPLab web app",
5
5
  "license": "MIT",
6
6
  "homepage": "https://mcplab.inspectr.dev",