@mcp-use/inspector 20.0.4 → 20.0.5-canary.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.
@@ -99,7 +99,7 @@ Return ONLY JSON.`:`Resource Information:
99
99
  Based on this information, suggest 3-5 common customizable properties like theme, dimensions, colors, titles, or configuration options that would be useful for this type of resource. Keep it simple and practical.`,u=[{role:"system",content:c},{role:"user",content:l}],f=await cf({config:{provider:e.provider,model:e.model,apiKey:e.apiKey,temperature:e.temperature,baseUrl:e.baseUrl},messages:u});try{let d=df(f);if(d)return Object.entries(d).map(([v,p])=>({key:v,value:typeof p=="object"&&p!==null?JSON.stringify(p):String(p)}));let g=f.split(`
100
100
  `),m=[];for(let v of g){let p=v.match(/^\s*["']?(\w+)["']?\s*[:=]\s*["']?(.+?)["']?\s*,?\s*$/);p&&m.push({key:p[1].trim(),value:p[2].trim().replace(/^["']|["']$/g,"")})}if(m.length>0)return m;throw new Error("Could not parse props from LLM response")}catch(d){throw console.error("[usePropsLLM] Failed to parse LLM response:",d),new Error(`Failed to parse props from LLM response: ${f.slice(0,100)}...`)}},[e]),isAvailable:e!==null}}import{Loader2 as N0,Plus as k0,Sparkles as S0,Trash2 as T0}from"lucide-react";import{useEffect as R0,useMemo as P0,useState as ra}from"react";import{toast as kr}from"sonner";import{jsx as Tn,jsxs as Nr}from"react/jsx-runtime";function mf(e,t){if(!e?.$ref)return e;let n=e.$ref;if(n.startsWith("#/")){let o=n.substring(2).split("/"),r=t;for(let s of o)if(r&&typeof r=="object"&&s in r)r=r[s];else return console.warn(`Could not resolve $ref: ${n}`),e;return r}return e}function w0(e,t){if(e.anyOf&&Array.isArray(e.anyOf)){let n=e.anyOf.find(o=>o.type!=="null");if(n)return{...mf(n,t),nullable:!0}}return e}function C0(e){return Array.isArray(e.enum)?e.enum:null}function pf({name:e,schema:t,value:n,onChange:o,required:r=!1,disabled:s=!1,rootSchema:a}){let i=a||t,c=w0(t,i);c=mf(c,i);let l=C0(c),u=c.type==="string"&&l!==null,f=c;return f.type==="object"||f.type==="array"?Nr("div",{className:"space-y-2",children:[Nr(tt,{htmlFor:e,className:"text-sm font-medium",children:[e,r&&Tn("span",{className:"text-red-500 ml-1",children:"*"})]}),Tn(Qn,{id:e,value:n,onChange:g=>o(g.target.value),placeholder:f?.description||f?.default?JSON.stringify(f.default,null,2):`Enter ${e}`,className:"min-h-[100px]",disabled:s}),f?.description&&Tn("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:f.description})]}):u&&l?Nr("div",{className:"space-y-2",children:[Nr(tt,{htmlFor:e,className:"text-sm font-medium",children:[e,r&&Tn("span",{className:"text-red-500 ml-1",children:"*"})]}),Nr(Sn,{value:n||"",onValueChange:o,disabled:s,children:[Tn(Un,{id:e,className:"w-full",children:Tn(Bn,{placeholder:f.description||"Select an option"})}),Tn(Hn,{children:l.map((g,m)=>Tn(Wt,{value:g,children:f.enumNames?.[m]||g},g))})]}),f.description&&Tn("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:f.description})]}):Nr("div",{className:"space-y-2",children:[Nr(tt,{htmlFor:e,className:"text-sm font-medium",children:[e,r&&Tn("span",{className:"text-red-500 ml-1",children:"*"})]}),Tn(Ge,{id:e,value:n,onChange:g=>o(g.target.value),placeholder:f?.description||(f?.default!==void 0?String(f.default):`Enter ${e}`),type:f.type==="number"?"number":"text",disabled:s}),f?.description&&Tn("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:f.description})]})}import{Fragment as ff,jsx as Pt,jsxs as Ht}from"react/jsx-runtime";function gf({open:e,onOpenChange:t,onSave:n,existingPresets:o,resource:r,resourceAnnotations:s,llmConfig:a,editingPreset:i}){let c=P0(()=>{let I=L=>{if(!L)return null;if(L.type==="object"&&L.properties)return L;let _=L?.def?.shape??L?._def?.shape;if(_&&typeof _=="object"){let K={},F=[],Y=Q=>({ZodString:"string",string:"string",ZodNumber:"number",number:"number",ZodBoolean:"boolean",boolean:"boolean",ZodArray:"array",array:"array",ZodObject:"object",object:"object"})[Q]||"string",ee=Q=>Q?.typeName??Q?.type??"",$=Q=>{let V=Q?._def??Q?.def??{},Z=Q,be=ee(V);for(;be==="ZodOptional"||be==="ZodDefault"||be==="ZodNullable";){Z=V.innerType??Z;let q=Z?._def??Z?.def??{};be=ee(q)}let re=Y(be);if(re==="array"){let q=Z?._def?.type??Z?.def?.element??Z?.element;if(q){let W=q._def??q.def??{};if(Y(ee(W))==="object"){let de=W.shape??q._def?.shape??q.def?.shape??{};return{type:"array",items:{type:"object",properties:Object.fromEntries(Object.entries(de).map(([ke,Ne])=>{let ae=Ne?._def??Ne?.def??{};return[ke,{type:Y(ee(ae))}]}))}}}}return{type:"array"}}return{type:re}};for(let[Q,V]of Object.entries(_)){let Z=V,be=Z?._def??Z?.def??{},re=ee(be),q=re==="ZodOptional"||re==="ZodDefault"||re==="ZodNullable",W=$(Z);K[Q]={type:W.type,...W.items&&{items:W.items},description:Z?.description??be.description},q||F.push(Q)}if(Object.keys(K).length>0)return{type:"object",properties:K,required:F.length>0?F:void 0}}return null},k=s;if(k?.["mcp-use/propsSchema"])return I(k["mcp-use/propsSchema"]);let N=r.annotations;return N?.["mcp-use/propsSchema"]?I(N["mcp-use/propsSchema"]):null},[s,r.annotations,r.uri,r.name]),l=!!c,[u,f]=ra(""),[d,g]=ra({}),[m,v]=ra([{id:crypto.randomUUID(),key:"",value:""}]),[p,x]=ra(!1),[C,b]=ra(null),{generateProps:h,isAvailable:y}=uf({llmConfig:a});R0(()=>{if(e){if(i)if(f(i.name),l)g(i.props);else{let I=Object.entries(i.props).map(([k,N])=>({id:crypto.randomUUID(),key:k,value:N}));v(I.length>0?I:[{id:crypto.randomUUID(),key:"",value:""}])}else f(""),l?g({}):v([{id:crypto.randomUUID(),key:"",value:""}]);b(null)}},[e,i,l]);let R=()=>{v([...m,{id:crypto.randomUUID(),key:"",value:""}])},P=I=>{m.length>1&&v(m.filter(k=>k.id!==I))},S=(I,k,N)=>{v(m.map(L=>L.id===I?{...L,[k]:N}:L))},T=async()=>{if(!y){kr.error("LLM not configured",{description:"Please configure LLM in the Chat tab first."});return}x(!0),b(null);try{let I=await h({resource:r,resourceAnnotations:s,propsSchema:l?c:void 0});if(l){let k={};for(let N of I)c.properties?.[N.key]&&(k[N.key]=N.value);g(k)}else v(I.map(k=>({id:crypto.randomUUID(),key:k.key,value:k.value})));kr.success("Props generated successfully",{description:`Generated ${I.length} prop(s) using ${a?.provider}`})}catch(I){let k=I instanceof Error?I.message:"Failed to generate props";b(k),kr.error("LLM Generation Failed",{description:k})}finally{x(!1)}},M=()=>{if(!u.trim()){kr.error("Preset name required",{description:"Please enter a name for this preset."});return}if(o.find(L=>L.name.toLowerCase()===u.toLowerCase()&&L.id!==i?.id)){kr.error("Duplicate preset name",{description:"A preset with this name already exists."});return}let k;if(l)k={...d};else{k={};for(let L of m)L.key.trim()&&(k[L.key.trim()]=L.value)}if(Object.keys(k).length===0){kr.error("No props defined",{description:"Please add at least one prop with a key."});return}let N={id:i?.id||crypto.randomUUID(),name:u.trim(),props:k};n(N),t(!1),kr.success(i?"Preset updated":"Preset created",{description:`Preset "${N.name}" saved successfully.`})};return Pt(fn,{open:e,onOpenChange:t,children:Ht(rn,{scrollable:!0,className:"sm:max-w-[600px] max-h-[80vh]","data-testid":"props-config-dialog",children:[Ht(Xt,{children:[Pt(qt,{children:i?"Edit Preset":"Create Props Preset"}),Ht(mo,{children:["Configure props for ",r.name||r.uri,". You can manually add key-value pairs or generate them with AI."]})]}),Ht(zn,{className:"space-y-4 py-4",children:[Ht("div",{className:"space-y-2",children:[Pt(tt,{htmlFor:"preset-name",children:"Preset Name"}),Pt(Ge,{id:"preset-name","data-testid":"props-config-preset-name",value:u,onChange:I=>f(I.target.value),placeholder:"e.g., Dark Theme, Production Config",disabled:p})]}),Ht("div",{className:"space-y-2 p-3 bg-muted rounded-lg",children:[Ht("div",{className:"flex items-center justify-between",children:[Pt(tt,{className:"text-sm font-medium",children:"Generate with AI"}),y&&Ht("span",{className:"text-xs text-muted-foreground",children:["Using ",a?.provider," (",a?.model,")"]})]}),y?Pt(A,{onClick:T,disabled:p,size:"sm",variant:"outline",className:"w-full","data-testid":"props-config-generate-llm-button",children:p?Ht("span",{"data-testid":"props-config-generating",className:"flex items-center gap-2",children:[Pt(N0,{className:"h-4 w-4 mr-2 animate-spin"}),"Generating..."]}):Ht(ff,{children:[Pt(S0,{className:"h-4 w-4 mr-2"}),"Generate Props with LLM"]})}):Pt("p",{className:"text-xs text-muted-foreground",children:"LLM not configured. Please configure LLM in the Chat tab to use this feature."}),C&&Pt("p",{className:"text-xs text-destructive","data-testid":"props-config-error",children:C})]}),Ht("div",{className:"space-y-3",children:[Pt(tt,{className:"text-sm font-medium",children:"Props"}),l?Pt("div",{className:"space-y-4",children:Object.entries(c.properties||{}).map(([I,k])=>Pt(pf,{name:I,schema:k,value:d[I]||"",onChange:N=>g(L=>({...L,[I]:N})),required:c.required?.includes(I),disabled:p,rootSchema:c},I))}):Ht(ff,{children:[Pt("div",{className:"flex items-center justify-between",children:Ht(A,{onClick:R,size:"sm",variant:"ghost",disabled:p,"data-testid":"props-config-add-prop",children:[Pt(k0,{className:"h-4 w-4 mr-1"}),"Add Prop"]})}),m.map((I,k)=>Ht("div",{className:"flex items-center gap-2",children:[Ht("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[Pt(Ge,{placeholder:"Key",value:I.key,onChange:N=>S(I.id,"key",N.target.value),disabled:p,"data-testid":`props-config-key-${k}`}),Pt(Ge,{placeholder:"Value",value:I.value,onChange:N=>S(I.id,"value",N.target.value),disabled:p,"data-testid":`props-config-value-${k}`})]}),Pt(A,{variant:"ghost",size:"sm",onClick:()=>P(I.id),disabled:m.length===1||p,className:"h-9 w-9 p-0","data-testid":`props-config-remove-${k}`,children:Pt(T0,{className:"h-4 w-4 text-muted-foreground"})})]},I.id))]})]})]}),Ht(bi,{children:[Pt(A,{variant:"outline",onClick:()=>t(!1),disabled:p,"data-testid":"props-config-cancel-button",children:"Cancel"}),Ht(A,{onClick:M,disabled:p,"data-testid":"props-config-save-button",children:[i?"Update":"Create"," Preset"]})]})]})})}function hf(e){if(e===0)return"0 Bytes";let t=1024,n=["Bytes","KB","MB","GB"],o=Math.floor(Math.log(e)/Math.log(t));return Math.round(e/Math.pow(t,o)*100)/100+" "+n[o]}function vf(e){if(e===0)return"0 B";let t=1024,n=["B","KB","MB"],o=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/Math.pow(t,o)).toFixed(1))} ${n[o]}`}var bf=100*1024,yf=1024*20;function qi(e,t){if(e==null)return e;if(typeof e=="string")return e.length>t?e.substring(0,t)+"... (truncated)":e;if(Array.isArray(e))return e.map(n=>qi(n,t));if(typeof e=="object"){let n={};for(let o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=qi(e[o],t));return n}return e}function xf(e){let t=JSON.stringify(e,null,2);return new TextEncoder().encode(t).length>bf?qi(e,yf):e}function Wi(e){let t=JSON.stringify(e,null,2),n=new TextEncoder().encode(t).length,o=n>bf,r;if(o){let a=qi(e,yf);r=JSON.stringify(a,null,2)}else r=t;let s=hf(n);return{isLarge:o,size:n,sizeFormatted:s,preview:r,full:t}}function Ki(e,t){try{let n=JSON.stringify(e,null,2),o=globalThis.Blob,r=new o([n],{type:"application/json"}),s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=t||`data-${Date.now()}.json`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(s)}catch(n){throw console.error("Failed to download JSON:",n),n}}import{jsx as E0}from"react/jsx-runtime";var M0={key:"text-sky-600 dark:text-sky-400",string:"text-emerald-600 dark:text-emerald-400",number:"text-amber-600 dark:text-amber-400",boolean:"text-violet-600 dark:text-violet-400",null:"text-zinc-500 dark:text-zinc-400",punctuation:"text-muted-foreground"};function I0(e){let t=[],n=0,o=(r,s)=>{s&&t.push({kind:r,text:s})};for(;n<e.length;){let r=e[n];if(r==='"'){let s=n;for(n++;n<e.length;){if(e[n]==="\\"){n+=2;continue}if(e[n]==='"'){n++;break}n++}let a=e.slice(s,n),i=n;for(;i<e.length&&/[ \t]/.test(e[i]);)i++;let c=e[i]===":";o(c?"key":"string",a);continue}if(/[0-9-]/.test(r)){let s=n;for(e[n]==="-"&&n++;n<e.length&&/[0-9.eE+-]/.test(e[n]);)n++;o("number",e.slice(s,n));continue}if(e.startsWith("true",n)||e.startsWith("false",n)){let s=e.startsWith("true",n)?"true":"false";o("boolean",s),n+=s.length;continue}if(e.startsWith("null",n)){o("null","null"),n+=4;continue}if(/[{}[\],:]/.test(r)){o("punctuation",r),n++;continue}o("punctuation",r),n++}return t}function Kc(e){return I0(e).map((t,n)=>E0("span",{className:M0[t.kind],children:t.text},n))}import{Download as O0}from"lucide-react";import{ChevronRight as A0}from"lucide-react";import{useState as L0}from"react";import{Fragment as Ji,jsx as yt,jsxs as eo}from"react/jsx-runtime";var en={string:"text-emerald-600 dark:text-emerald-400",number:"text-amber-600 dark:text-amber-400",boolean:"text-violet-600 dark:text-violet-400",null:"text-zinc-500 dark:text-zinc-400",key:"text-sky-600 dark:text-sky-400",punctuation:"text-muted-foreground"};function D0(e){return e===null?yt("span",{className:en.null,children:"null"}):typeof e=="string"?yt("span",{className:en.string,children:JSON.stringify(e)}):typeof e=="number"?yt("span",{className:en.number,children:String(e)}):typeof e=="boolean"?yt("span",{className:en.boolean,children:String(e)}):yt("span",{className:en.string,children:JSON.stringify(e)})}function _0(e){return Array.isArray(e)?`[${e.length}]`:`{${Object.keys(e).length}}`}function wf({label:e,value:t,depth:n,defaultExpanded:o}){let r=t!==null&&typeof t=="object"&&!Array.isArray(t)?Object.keys(t).length>0:Array.isArray(t)?t.length>0:!1,[s,a]=L0(r&&(o||n===0));if(!r){let d=Array.isArray(t)?"[]":"{}";return t!==null&&typeof t=="object"?eo("div",{className:"font-mono text-[0.8rem] leading-relaxed",style:{paddingLeft:n*12},children:[e!=null&&eo(Ji,{children:[yt("span",{className:en.key,children:JSON.stringify(e)}),yt("span",{className:en.punctuation,children:": "})]}),yt("span",{className:en.punctuation,children:d})]}):eo("div",{className:"font-mono text-[0.8rem] leading-relaxed",style:{paddingLeft:n*12},children:[e!=null&&eo(Ji,{children:[yt("span",{className:en.key,children:JSON.stringify(e)}),yt("span",{className:en.punctuation,children:": "})]}),D0(t)]})}let i=Array.isArray(t)?t.map((f,d)=>[String(d),f]):Object.entries(t),c=Array.isArray(t),l=c?"[":"{",u=c?"]":"}";return eo("div",{className:"font-mono text-[0.8rem] leading-relaxed",children:[eo("div",{className:"flex items-start gap-0.5",style:{paddingLeft:n*12},children:[yt("button",{type:"button","aria-expanded":s,onClick:()=>a(f=>!f),className:"mt-0.5 inline-flex shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:text-foreground",children:yt(A0,{className:w("h-3.5 w-3.5 transition-transform",s&&"rotate-90")})}),eo("div",{className:"min-w-0 flex-1",children:[e!=null&&eo(Ji,{children:[yt("span",{className:en.key,children:JSON.stringify(e)}),yt("span",{className:en.punctuation,children:": "})]}),yt("span",{className:en.punctuation,children:l}),!s&&eo(Ji,{children:[yt("button",{type:"button",onClick:()=>a(!0),className:"mx-1 text-xs text-muted-foreground hover:text-foreground",children:_0(t)}),yt("span",{className:en.punctuation,children:u})]})]})]}),s&&eo("div",{children:[i.map(([f,d])=>yt(wf,{label:f,value:d,depth:n+1,defaultExpanded:o},`${n}-${f}`)),yt("div",{style:{paddingLeft:n*12},children:yt("span",{className:en.punctuation,children:u})})]})]})}function Cf({data:e,defaultExpanded:t=!0,className:n}){return yt("div",{className:w("text-gray-900 dark:text-gray-100 [overflow-wrap:anywhere]",n),"data-testid":"collapsible-json",children:yt(wf,{value:e,depth:0,defaultExpanded:t})})}import{jsx as fo,jsxs as ms}from"react/jsx-runtime";var Nf="font-mono text-[0.8rem] text-gray-900 dark:text-gray-100 whitespace-pre-wrap break-words [overflow-wrap:anywhere]";function xt({data:e,filename:t,className:n,collapsible:o=!1,defaultExpanded:r=!0,...s}){let a=Wi(e),i=xf(e),c=()=>{Ki(e,t)},l=a.isLarge?fo("div",{className:"mb-3 p-3 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg",children:ms("div",{className:"flex items-center justify-between gap-2",children:[ms("div",{className:"flex-1",children:[ms("p",{className:"text-sm font-medium text-yellow-800 dark:text-yellow-300 mb-1",children:["JSON is too large (",a.sizeFormatted,")"]}),fo("p",{className:"text-xs text-yellow-700 dark:text-yellow-400",children:"Showing full structure with truncated values. Download the full JSON file to see complete values."})]}),ms(A,{variant:"outline",size:"sm",onClick:c,className:"shrink-0",children:[fo(O0,{className:"h-4 w-4 mr-1"}),"Download"]})]})}):null;return o?ms("div",{className:n,...s,children:[l,fo(Cf,{data:i,defaultExpanded:r})]}):a.isLarge?ms("div",{className:n,...s,children:[l,fo("pre",{className:Nf,children:fo("code",{children:Kc(a.preview)})})]}):fo("div",{className:n,...s,children:fo("pre",{className:Nf,children:fo("code",{children:Kc(a.preview)})})})}import{jsx as $o,jsxs as sa}from"react/jsx-runtime";function kf({value:e,onChange:t}){let n=(o,r)=>{let s=parseInt(r,10);isNaN(s)||t({...e,[o]:s})};return sa("div",{className:"grid grid-cols-2 gap-2",children:[sa("div",{className:"space-y-1",children:[$o("label",{className:"text-xs text-muted-foreground",children:"Top"}),$o(Ge,{type:"number",min:"0",value:e.top,onChange:o=>n("top",o.target.value),className:"h-8","data-testid":"debugger-safe-area-top"})]}),sa("div",{className:"space-y-1",children:[$o("label",{className:"text-xs text-muted-foreground",children:"Right"}),$o(Ge,{type:"number",min:"0",value:e.right,onChange:o=>n("right",o.target.value),className:"h-8","data-testid":"debugger-safe-area-right"})]}),sa("div",{className:"space-y-1",children:[$o("label",{className:"text-xs text-muted-foreground",children:"Bottom"}),$o(Ge,{type:"number",min:"0",value:e.bottom,onChange:o=>n("bottom",o.target.value),className:"h-8","data-testid":"debugger-safe-area-bottom"})]}),sa("div",{className:"space-y-1",children:[$o("label",{className:"text-xs text-muted-foreground",children:"Left"}),$o(Ge,{type:"number",min:"0",value:e.left,onChange:o=>n("left",o.target.value),className:"h-8","data-testid":"debugger-safe-area-left"})]})]})}function Sf(e,t){let n=new Set(t?.connectDomains??[]),o=new Set(t?.resourceDomains??[]),r=new Set(t?.frameDomains??[]),s=new Set(["script-src","style-src","img-src","font-src","media-src"]),a="connect-src",i="frame-src";for(let l of e){let u=(l.blockedUri||"").trim();if(!u||u==="(inline)"||u.startsWith("blob:")||u.startsWith("data:"))continue;let f=null;try{f=new URL(u).origin}catch{continue}if(!f)continue;let d=(l.effectiveDirective||l.directive||"").toLowerCase();d===a?(n.add(f),f.startsWith("http://")?n.add(f.replace("http://","ws://")):f.startsWith("https://")&&n.add(f.replace("https://","wss://"))):s.has(d)?o.add(f):d===i&&r.add(f)}let c={connectDomains:Array.from(n).sort(),resourceDomains:Array.from(o).sort()};return r.size>0&&(c.frameDomains=Array.from(r).sort()),c}var z0="https://raw.githubusercontent.com/modelcontextprotocol/ext-apps/bcfffb6585ea4fb1e3a9da39fb8911b83399fa71/specification/2026-01-26/apps.mdx",B0="https://mcp-use.com/docs/typescript/server/csp";function Tf(e,t,n,o){let r=["Fix the Content Security Policy (CSP) for this MCP Apps widget. The widget has CSP violations that block network requests and resources.","","**References:**",`- MCP Apps CSP spec: ${z0}`,`- mcp-use CSP docs: ${B0}`,""];if(r.push("**Current declared CSP:**"),e?(r.push(`connectDomains: ${JSON.stringify(e.connectDomains??[])}`),r.push(`resourceDomains: ${JSON.stringify(e.resourceDomains??[])}`),r.push(`frameDomains: ${JSON.stringify(e.frameDomains??[])}`),r.push(`baseUriDomains: ${JSON.stringify(e.baseUriDomains??[])}`)):r.push("No CSP declared."),r.push(""),t&&(r.push("**Effective policy (originalPolicy):**"),r.push("```"),r.push(t),r.push("```"),r.push("")),n.length>0){r.push(`**Blocked requests (${n.length}):**`);for(let s of n){let a=s.effectiveDirective||s.directive,i=s.blockedUri||"(inline)";r.push(`- ${a}: ${i}`)}r.push("")}return o?(r.push("**Apply this CSP config to fix the violations:**"),r.push("Add these domains to the widget's CSP metadata (resource _meta.ui.csp). Use camelCase for MCP Apps (connectDomains, resourceDomains)."),r.push(""),r.push("```json"),r.push(JSON.stringify({connectDomains:o.connectDomains,resourceDomains:o.resourceDomains,...o.frameDomains?.length?{frameDomains:o.frameDomains}:{}},null,2)),r.push("```")):r.push("No blocked requests - no fix needed."),r.join(`
101
101
  `)}import{Popover as aa}from"@base-ui/react/popover";import{jsx as ia}from"react/jsx-runtime";function Vo({...e}){return ia(aa.Root,{"data-slot":"popover",...e})}function jo(e){return ia(aa.Trigger,{"data-slot":"popover-trigger",...e})}function qo({className:e,align:t="center",alignOffset:n=0,side:o="bottom",sideOffset:r=4,...s}){return ia(aa.Portal,{children:ia(aa.Positioner,{align:t,alignOffset:n,side:o,sideOffset:r,className:"isolate z-50",children:ia(aa.Popup,{"data-slot":"popover-content",className:w("z-50 flex w-72 origin-(--transform-origin) flex-col gap-4 rounded-md bg-popover p-4 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...s})})})}import{Fragment as Df,jsx as H,jsxs as xe}from"react/jsx-runtime";var Sr="__no_props__",la="__tool_props__",Ef="__create_preset__",Af=[{value:"desktop",label:"Desktop",icon:_f},{value:"mobile",label:"Mobile",icon:Of}];function Lf({options:e,value:t,onValueChange:n,placeholder:o,contentTestId:r,searchTestId:s,optionTestId:a,trigger:i}){let[c,l]=go(!1),[u,f]=go(""),d=Q0(null);Gi(()=>{if(!c){f("");return}let v=requestAnimationFrame(()=>d.current?.focus());return()=>cancelAnimationFrame(v)},[c]);let g=ca(()=>{let v=u.trim().toLowerCase();return v?e.filter(p=>p.label.toLowerCase().includes(v)||p.value.toLowerCase().includes(v)):[...e]},[e,u]),m=g.findIndex(v=>v.value===t);return xe(hr,{open:c,onOpenChange:l,children:[i,xe(vr,{"data-testid":r,checkedIndex:m>=0?m:void 0,className:"w-80 overflow-hidden",children:[H("div",{className:"border-b border-border p-2",onKeyDown:v=>v.stopPropagation(),children:H(Ge,{ref:d,value:u,onChange:v=>f(v.target.value),placeholder:o,"data-testid":s,className:"h-8"})}),H("div",{className:"max-h-64 overflow-y-auto",children:g.length===0?H("p",{className:"px-3 py-4 text-xs text-muted-foreground",children:"No results found."}):g.map((v,p)=>H(pr,{index:p,label:v.label,checked:t===v.value,"data-testid":a(v.value),onSelect:()=>{n(v.value),l(!1)}},v.value))})]})]})}function Yi({displayMode:e,onDisplayModeChange:t,toolCallId:n,propsContext:o,resourceUri:r,toolInput:s,resourceAnnotations:a,llmConfig:i,resource:c,onPropsChange:l,requiredProps:u}){let{resolvedTheme:f,setTheme:d}=Zn(),{playground:g,updatePlaygroundSettings:m,widgets:v,clearCspViolations:p}=Ho(),x=v.get(n),C=x?.cspViolations??[],b=x?.declaredCsp,h=x?.effectivePolicy,y=C.length>0?Sf(C,b):null,R=C.length>0?Tf(b,h,C,y):"",P=e==="fullscreen",S=e==="pip",{presets:T,activePresetId:M,savePreset:I,deletePreset:k,setActivePreset:N,getActiveProps:L}=Kp(r),[_,K]=go(!1),Y=!!u?.length&&!M,[ee,$]=go(()=>Y);Gi(()=>{Y&&$(!0)},[Y]);let[Q,V]=go(null),[Z,be]=go(!1),[re,q]=go("mode"),[W,de]=go(!0),ke=ca(()=>fp(b),[b]),Ne=ca(()=>gp(h),[h]),ae=ca(()=>hp(ke,Ne),[ke,Ne]),G=ca(()=>vp({mode:g.cspMode,declared:b,effectivePolicy:h,violations:C}),[g.cspMode,b,h,C]),ne=X0(()=>o==="tool"&&s?la:Sr,[o,s]),[ue,Pe]=go(ne());Gi(()=>{M&&o!=="tool"?Pe(M):ue!==Sr&&ue!==la&&Pe(ne())},[M,ue,ne,o]),Gi(()=>{if(l){if(ue===Sr||ue===la)l(null);else if(M&&ue===M){let D=L();D&&l(D)}}},[ue,M,s,L,l,T]);let qe=D=>{if(D===Ef){V(null),K(!0);return}if(D===Sr||D===la)N(null),Pe(D),l?.(null);else{N(D),Pe(D);let ye=T.find(te=>te.id===D);l?.(ye?.props??null)}},it=D=>{I(D),N(D.id),Pe(D.id),l?.(D.props)},Ve=(D,ye)=>{ye.stopPropagation();let te=T.find(ie=>ie.id===D);te&&(k(D),Jc.success("Preset deleted",{description:`Preset "${te.name}" has been deleted.`}))},Rt=(D,ye)=>{ye.stopPropagation(),V(D),K(!0)},ce=()=>g.deviceType==="mobile"?H(Of,{className:"size-3"}):H(_f,{className:"size-3"}),j=Af.findIndex(D=>D.value===g.deviceType);return xe("div",{className:"flex items-center gap-2",children:[!P&&!S&&xe(Df,{children:[xe(Re,{children:[H(Se,{render:H(A,{"data-testid":"debugger-fullscreen-button",variant:"outline",size:"sm",className:"bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",onClick:()=>t("fullscreen"),children:H($0,{className:"size-4"})}),nativeButton:!0}),H(Te,{children:"Enter fullscreen mode"})]}),xe(Re,{children:[H(Se,{render:H(A,{"data-testid":"debugger-pip-button",variant:"outline",size:"sm",className:"bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",onClick:()=>t("pip"),children:H(q0,{className:"size-4"})}),nativeButton:!0}),H(Te,{children:"Picture-in-picture"})]})]}),xe(hr,{children:[xe(Re,{children:[H(Se,{render:H(_o,{render:H(A,{"data-testid":"debugger-device-button",variant:"outline",size:"sm",className:"h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",children:ce()}),nativeButton:!0}),nativeButton:!0}),xe(Te,{children:["Device: ",g.deviceType]})]}),H(vr,{"data-testid":"debugger-device-dialog",checkedIndex:j>=0?j:void 0,className:"w-56",children:Af.map((D,ye)=>H(pr,{index:ye,icon:D.icon,label:D.label,checked:g.deviceType===D.value,"data-testid":`debugger-device-option-${D.value}`,onSelect:()=>m({deviceType:D.value})},D.value))})]}),xe(Re,{children:[H(Se,{render:H(A,{"data-testid":"debugger-theme-button",variant:"outline",size:"sm",className:"h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",onClick:()=>{d(f==="dark"?"light":"dark")},children:f==="dark"?H(V0,{className:"size-3.5"}):H(G0,{className:"size-3.5"})}),nativeButton:!0}),xe(Te,{children:["Theme: ",f==="dark"?"Dark":"Light"]})]}),H(Lf,{options:$p,value:g.locale,onValueChange:D=>m({locale:D}),placeholder:"Search locales...",contentTestId:"debugger-locale-dialog",searchTestId:"debugger-locale-search",optionTestId:D=>`debugger-locale-option-${D}`,trigger:xe(Re,{children:[H(Se,{render:H(_o,{render:H(A,{"data-testid":"debugger-locale-button",variant:"outline",size:"sm",className:"h-8 min-w-[50px] px-2 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",children:H("span",{className:"text-xs font-mono",children:g.locale})}),nativeButton:!0}),nativeButton:!0}),H(Te,{children:"Locale"})]})}),H(Lf,{options:Vp,value:g.timeZone,onValueChange:D=>m({timeZone:D}),placeholder:"Search timezones...",contentTestId:"debugger-timezone-dialog",searchTestId:"debugger-timezone-search",optionTestId:D=>`debugger-timezone-option-${D.replace(/\//g,"-")}`,trigger:xe(Re,{children:[H(Se,{render:H(_o,{render:H(A,{"data-testid":"debugger-timezone-button",variant:"outline",size:"sm",className:"h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",children:H(F0,{className:"size-3.5"})}),nativeButton:!0}),nativeButton:!0}),xe(Te,{children:["Timezone: ",g.timeZone]})]})}),xe(fn,{open:Z,onOpenChange:be,children:[xe(Re,{children:[H(Se,{render:H(ic,{render:xe(A,{"data-testid":"debugger-csp-button",variant:"outline",size:"sm",className:"relative h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",children:[g.cspMode==="permissive"?H(If,{className:"size-3.5"}):H(Mf,{className:"size-3.5"}),C.length>0&&H("span",{className:`absolute -top-1.5 -right-1.5 flex h-4 min-w-4 items-center justify-center rounded-full px-0.5 text-[9px] font-bold text-white leading-none ${g.cspMode==="permissive"?"bg-yellow-500":"bg-red-500"}`,children:C.length>99?"99+":C.length})]}),nativeButton:!0}),nativeButton:!0}),xe(Te,{children:["CSP:"," ",g.cspMode==="permissive"?"Permissive":"Declared",C.length>0&&` \xB7 ${C.length} ${g.cspMode==="permissive"?"would be blocked":"blocked"}`]})]}),xe(rn,{scrollable:!0,className:"sm:max-w-[520px] max-h-[85vh]","data-testid":"debugger-csp-dialog",children:[H(Xt,{children:H(qt,{children:"CSP Mode"})}),xe(zn,{className:"space-y-3",children:[H("div",{role:"tablist","aria-label":"CSP diagnostics",className:"grid grid-cols-3 rounded-md border border-zinc-200 dark:border-zinc-700 p-1",children:[["mode","Mode"],["diff","Policy Diff"],["findings","Findings"]].map(([D,ye])=>H("button",{type:"button",role:"tab","aria-selected":re===D,onClick:()=>q(D),className:`rounded px-2 py-1.5 text-xs font-medium ${re===D?"bg-zinc-100 dark:bg-zinc-800":"text-muted-foreground"}`,children:ye},D))}),re==="mode"&&xe("div",{role:"tabpanel",className:"space-y-2",children:[xe(A,{"data-testid":"debugger-csp-option-permissive",variant:g.cspMode==="permissive"?"default":"outline",className:"w-full justify-start",onClick:()=>m({cspMode:"permissive"}),children:[H(If,{className:"size-4 mr-2"}),"Permissive"]}),xe(A,{"data-testid":"debugger-csp-option-widget-declared",variant:g.cspMode==="widget-declared"?"default":"outline",className:"w-full justify-start",onClick:()=>m({cspMode:"widget-declared"}),children:[H(Mf,{className:"size-4 mr-2"}),"Widget-Declared"]}),H("p",{className:"text-xs text-muted-foreground",children:"Permissive records would-be blocks; Widget-Declared enforces the resource metadata policy."})]}),re==="diff"&&xe("div",{role:"tabpanel",className:"space-y-2",children:[ae.length?H("div",{className:"max-h-64 overflow-y-auto rounded border border-zinc-200 dark:border-zinc-700",children:ae.map(D=>xe("div",{className:"border-b border-zinc-100 dark:border-zinc-800 p-2 text-xs last:border-0",children:[xe("div",{className:"flex items-center justify-between",children:[H("code",{children:D.directive}),H("span",{className:"text-[10px] uppercase text-muted-foreground",children:D.status})]}),xe("div",{className:"mt-1 font-mono text-[10px] text-muted-foreground break-all",children:["requested: ",D.requested.join(" ")||"\u2014",H("br",{}),"effective: ",D.effective.join(" ")||"\u2014"]})]},D.directive))}):H("p",{className:"text-xs text-muted-foreground",children:"No requested or effective policy data yet."}),h&&xe(A,{variant:"outline",size:"sm",onClick:async()=>{try{await Ze(h),Jc.success("Policy copied to clipboard")}catch{Jc.error("Failed to copy")}},children:[H(Pf,{className:"size-3.5 mr-2"}),"Copy effective policy"]})]}),re==="findings"&&xe("div",{role:"tabpanel",className:"space-y-2",children:[H("div",{className:"space-y-1.5",children:G.map((D,ye)=>xe("div",{className:"rounded border border-zinc-200 dark:border-zinc-700 p-2",children:[H("div",{className:"text-xs font-medium",children:D.title}),H("div",{className:"text-[11px] text-muted-foreground break-all",children:D.detail})]},`${D.title}-${ye}`))}),C.length>0&&xe(Df,{children:[xe("div",{className:"flex items-center justify-between",children:[xe("span",{className:"text-xs font-medium",children:[C.length," observed request",C.length===1?"":"s"]}),H("button",{className:"text-xs text-muted-foreground underline",onClick:()=>p(n),children:"Clear"})]}),xe("div",{className:"border border-amber-200 dark:border-amber-800 rounded-md overflow-hidden",children:[xe("div",{className:"flex items-center justify-between bg-amber-50 dark:bg-amber-950/30 px-3 py-2",children:[xe("button",{type:"button",className:"flex items-center gap-2 text-xs font-medium text-amber-800 dark:text-amber-200",onClick:()=>de(D=>!D),children:[W?H(H0,{className:"size-3.5"}):H(U0,{className:"size-3.5"}),"Prompt for Agents"]}),H(A,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>{Ze(R)},"aria-label":"Copy prompt for agents",children:H(Pf,{className:"size-3.5"})})]}),W&&H("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap p-2 text-[11px]","data-testid":"debugger-csp-prompt-for-agents",children:R})]})]})]})]})]})]}),xe(Re,{children:[H(Se,{render:H(A,{"data-testid":"debugger-touch-button",variant:"outline",size:"sm",className:`h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900 ${g.capabilities.touch?"border-blue-500 dark:border-blue-400":""}`,onClick:()=>{let D={...g.capabilities,touch:!g.capabilities.touch};m({capabilities:D})},children:H(W0,{className:`size-3.5 ${g.capabilities.touch?"text-blue-600 dark:text-blue-400":""}`})}),nativeButton:!0}),xe(Te,{children:["Touch: ",g.capabilities.touch?"Enabled":"Disabled"]})]}),xe(Re,{children:[H(Se,{render:H(A,{"data-testid":"debugger-hover-button",variant:"outline",size:"sm",className:`h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900 ${g.capabilities.hover?"border-blue-500 dark:border-blue-400":""}`,onClick:()=>{let D={...g.capabilities,hover:!g.capabilities.hover};m({capabilities:D})},children:H(j0,{className:`size-3.5 ${g.capabilities.hover?"text-blue-600 dark:text-blue-400":""}`})}),nativeButton:!0}),xe(Te,{children:["Hover: ",g.capabilities.hover?"Enabled":"Disabled"]})]}),xe(Vo,{children:[H(jo,{render:H(A,{"data-testid":"debugger-safe-area-button",variant:"outline",size:"sm",className:"h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",children:H(J0,{className:"size-3.5"})}),nativeButton:!0}),H(qo,{className:"w-64 p-3","data-testid":"debugger-safe-area-dialog",children:xe("div",{className:"space-y-2",children:[H("label",{className:"text-xs font-medium",children:"Safe Area Insets"}),H(kf,{value:g.safeAreaInsets,onChange:D=>{m({safeAreaInsets:D})}})]})})]}),o==="tool"?xe(fn,{children:[xe(Re,{children:[H(Se,{render:H(ic,{render:H(A,{variant:"outline",size:"sm",className:"h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900","data-testid":"debugger-props-button",children:H(Rf,{className:"size-3.5"})}),nativeButton:!0}),nativeButton:!0}),H(Te,{children:"View Tool Props"})]}),xe(rn,{scrollable:!0,className:"sm:max-w-[600px] max-h-[85vh]","data-testid":"debugger-props-dialog",children:[H(Xt,{children:H(qt,{children:"Tool Props"})}),H(zn,{children:H(vi,{children:H(xt,{data:s??{},filename:"tool-props.json"})})})]})]}):xe(Vo,{open:ee,onOpenChange:$,children:[xe(Re,{children:[H(Se,{render:H(jo,{render:H(A,{variant:"outline",size:"sm",className:`h-8 w-8 p-0 backdrop-blur-sm shadow-sm ${Y?"bg-amber-50 dark:bg-amber-950/40 border-amber-300 dark:border-amber-700 hover:bg-amber-100 dark:hover:bg-amber-900/50 animate-pulse":"bg-white/90 dark:bg-zinc-900/90 hover:bg-white dark:hover:bg-zinc-900"}`,"data-testid":"debugger-props-button",children:H(Rf,{className:`size-3.5 ${Y?"text-amber-500":""}`})}),nativeButton:!0}),nativeButton:!0}),xe(Te,{children:["Props:"," ",ue===Sr?"No Props":ue===la?"Tool Props":T.find(D=>D.id===ue)?.name||"Custom"]})]}),xe(qo,{className:"w-64 p-2","data-testid":"debugger-props-popover",children:[Y&&xe("div",{className:"mb-2 rounded-md border border-amber-200 dark:border-amber-800/50 bg-amber-50 dark:bg-amber-950/30 px-3 py-2",children:[H("p",{className:"text-xs font-medium text-amber-700 dark:text-amber-300 mb-0.5",children:"Props required to render this widget:"}),H("p",{className:"text-xs font-mono text-amber-600 dark:text-amber-400",children:u.join(", ")}),H("p",{className:"text-xs text-amber-500 dark:text-amber-400 mt-1",children:"Create a preset below to set them."})]}),xe("div",{className:"space-y-1",children:[H(A,{variant:ue===Sr?"secondary":"ghost",size:"sm",className:"w-full justify-start",onClick:()=>qe(Sr),"data-testid":"debugger-props-no-props",children:"No Props"}),T.map(D=>xe("div",{className:"relative group flex items-center",children:[H(A,{variant:ue===D.id?"secondary":"ghost",size:"sm",className:"w-full justify-start pr-14",onClick:()=>qe(D.id),"data-testid":`debugger-props-preset-${D.id}`,children:D.name}),xe("div",{className:"absolute right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[H(A,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:ye=>Rt(D,ye),"data-testid":`debugger-props-edit-${D.id}`,children:H(K0,{className:"h-3 w-3"})}),H(A,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:ye=>Ve(D.id,ye),"data-testid":`debugger-props-delete-${D.id}`,children:H(Y0,{className:"h-3 w-3 text-destructive"})})]})]},D.id)),H(A,{variant:"ghost",size:"sm",className:"w-full justify-start text-primary",onClick:()=>qe(Ef),"data-testid":"debugger-props-create-preset",children:"+ Create Preset..."})]})]})]}),H(lf,{iframeId:n,enabled:!0}),c&&H(gf,{open:_,onOpenChange:K,onSave:it,existingPresets:T,resource:c,resourceAnnotations:a,llmConfig:i||null,editingPreset:Q})]})}import{jsx as Xi,jsxs as zf}from"react/jsx-runtime";function ps({message:e,className:t="",vertical:n,noBorder:o}){return Xi("div",{className:w(`mt-2 rounded-md p-6 ${t}`,!o&&"border"),children:zf("p",{className:w("text-sm text-muted-foreground flex items-center gap-4",n&&"flex-col"),children:[zf("svg",{viewBox:"-6 -6 512 512",xmlns:"http://www.w3.org/2000/svg",className:"size-14 shrink-0 stroke-black dark:stroke-white",fill:"none",strokeWidth:"4.8",strokeLinecap:"round",strokeLinejoin:"round",children:[Xi("path",{d:"M105.933 0C164.437 0.000116002 211.865 47.607 211.865 106.333C211.865 131.829 210.493 158.403 221.068 181.602L228.975 198.947C243.584 230.997 269.265 256.7 301.303 271.336L316.155 278.121C340.142 289.079 367.694 287.335 394.066 287.335C452.571 287.335 499.999 334.942 499.999 393.668C499.999 452.394 452.571 500.001 394.066 500.001C335.562 500.001 288.134 452.394 288.134 393.668C288.134 368.974 289.24 343.275 278.992 320.807L270.586 302.38C255.948 270.29 230.214 244.565 198.118 229.939L180.164 221.758C157.282 211.331 131.078 212.666 105.933 212.666C47.4278 212.666 4.86252e-05 165.059 0 106.333C0 47.607 47.4278 0 105.933 0Z"}),Xi("circle",{cx:"100.426",cy:"399.575",r:"100.426"}),Xi("path",{d:"M500 100.426C500 155.889 455.037 200.851 399.574 200.851C344.11 200.851 299.148 155.889 299.148 100.426C299.148 44.962 344.11 0 399.574 0C455.037 0 500 44.962 500 100.426Z"})]}),e]})})}import{jsx as oe,jsxs as _e}from"react/jsx-runtime";function lw({timestamp:e}){let[t,n]=Tr(()=>Gc(e));return da(()=>{let o=()=>n(Gc(e));o();let r=setInterval(o,1e3);return()=>clearInterval(r)},[e]),oe("span",{children:t})}function Gc(e){let n=Date.now()-e,o=Math.floor(n/1e3),r=Math.floor(o/60),s=Math.floor(r/60),a=Math.floor(s/24);return o<10?"now":o<60?`${o}s ago`:r<60?`${r}m ago`:s<24?`${s}h ago`:`${a}d ago`}function Hf(e){if(!e?.isError)return null;let t=e.content;if(Array.isArray(t)){let n=t.filter(o=>o.type==="text").map(o=>o.text).filter(Boolean);if(n.length>0)return n.join(`
102
- `)}return"An error occurred"}function cw(e){try{return JSON.parse(e),!0}catch{return!1}}function dw({content:e}){let[t,n]=Tr(new Set),o=Uf(r=>{n(s=>{let a=new Set(s);return a.has(r)?a.delete(r):a.add(r),a})},[]);return!Array.isArray(e)||e.length===0?oe("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No content"}):oe("div",{className:"space-y-4",children:e.map((r,s)=>{if(r.type==="text"){let a=r.text||"",i=t.has(s),c=cw(a),l=c?(()=>{try{return JSON.parse(a)}catch{return null}})():null;return _e("div",{className:"space-y-2",children:[_e("div",{className:"flex items-center justify-between gap-2",children:[_e("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:["Text Content",i?" (formatted)":""]}),c&&oe("button",{type:"button",onClick:()=>o(s),className:"text-xs text-blue-600 dark:text-blue-400 hover:underline","data-testid":`tool-result-format-toggle-${s}`,children:i?"Show as text":"Try to format"})]}),i&&l!==null?oe(xt,{data:l,filename:`content-${s}.json`}):oe("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 font-mono text-sm whitespace-pre-wrap break-words","data-testid":"tool-execution-results-text-content",children:a})]},s)}if(r.type==="image")return _e("div",{className:"space-y-2",children:[oe("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Image Content"}),_e("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3",children:[oe("img",{src:`data:${r.mimeType||"image/png"};base64,${r.data}`,alt:"Result",className:"max-w-full rounded","data-testid":"tool-execution-results-image-content"}),r.annotations&&oe("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:oe(xt,{data:r.annotations,filename:`image-annotations-${s}.json`,"data-testid":"tool-execution-results-image-annotations"})})]})]},s);if(r.type==="audio")return _e("div",{className:"space-y-2",children:[oe("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Audio Content"}),_e("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3",children:[oe("audio",{controls:!0,src:`data:${r.mimeType||"audio/wav"};base64,${r.data}`,className:"w-full","data-testid":"tool-execution-results-audio-content"}),r.annotations&&oe("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:oe(xt,{data:r.annotations,filename:`audio-annotations-${s}.json`,"data-testid":"tool-execution-results-audio-annotations"})})]})]},s);if(r.type==="resource_link")return _e("div",{className:"space-y-2",children:[oe("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Resource Link"}),_e("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2",children:[_e("div",{className:"font-mono text-sm break-all",children:[oe("span",{className:"text-gray-600 dark:text-gray-400",children:"URI:"})," ",r.uri]}),r.name&&_e("div",{className:"text-sm",children:[oe("span",{className:"text-gray-600 dark:text-gray-400",children:"Name:"})," ",r.name]}),r.description&&_e("div",{className:"text-sm",children:[oe("span",{className:"text-gray-600 dark:text-gray-400",children:"Description:"})," ",r.description]}),r.mimeType&&_e("div",{className:"text-sm",children:[oe("span",{className:"text-gray-600 dark:text-gray-400",children:"MIME Type:"})," ",r.mimeType]}),r.annotations&&_e("div",{className:"mt-2",children:[oe("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Annotations:"}),oe(xt,{data:r.annotations,filename:`resource-link-annotations-${s}.json`,"data-testid":"tool-execution-results-resource-link-annotations"})]})]})]},s);if(r.type==="resource"){let a=r.resource||{};return _e("div",{className:"space-y-2",children:[oe("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Embedded Resource"}),_e("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2",children:[_e("div",{className:"font-mono text-sm break-all","data-testid":"tool-execution-results-resource-uri",children:[oe("span",{className:"text-gray-600 dark:text-gray-400",children:"URI:"})," ",a.uri]}),a.mimeType&&_e("div",{className:"text-sm",children:[oe("span",{className:"text-gray-600 dark:text-gray-400","data-testid":"tool-execution-results-mime-type",children:"MIME Type:"})," ",a.mimeType]}),a.text&&_e("div",{"data-testid":"tool-execution-results-resource-text-content",children:[oe("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Content:"}),oe("div",{className:"bg-white dark:bg-black rounded p-2 font-mono text-sm whitespace-pre-wrap break-words max-h-60 overflow-y-auto",children:a.text})]}),a.blob&&_e("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:["[Binary content: ",a.blob.length||0," bytes]"]}),a.annotations&&_e("div",{className:"mt-2",children:[oe("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Annotations:"}),oe(xt,{data:a.annotations,filename:`resource-annotations-${s}.json`,"data-testid":"tool-execution-results-resource-annotations"})]})]})]},s)}return _e("div",{className:"space-y-2",children:[_e("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:["Unknown Content Type: ",r.type||"N/A"]}),oe(xt,{data:r,filename:`content-${s}.json`,"data-testid":"tool-execution-results-unknown-content"})]},s)})})}function Qi({results:e,copiedResult:t,serverId:n,readResource:o,onCopy:r,onMaximize:s,isMaximized:a=!1,onRerunTool:i,onWidgetHeightChange:c}){let[l,u]=Tr(0),[f,d]=Tr(!0),[g,m]=Tr("json"),[v,p]=Tr("inline"),[x,C]=Tr(null),b=e[0],h=b?e.filter($=>$.toolName===b.toolName):[],y=h[l]||h[0],R=e.findIndex($=>$===y),P=y?y.error||Hf(y.result):null,S=P??(y!=null?JSON.stringify(y.result,null,2):"");da(()=>{h.length>0&&l>=h.length&&u(0)},[h.length,l]);let T=to(()=>y?.args,[y?.timestamp,l]),M=to(()=>y?.result,[y?.timestamp,y?.duration,l]),I=Uf($=>o($),[o]),k=to(()=>y&&iw(y.toolMeta)?"mcp-apps":null,[y]),N=to(()=>y?.toolMeta?aw(y.toolMeta):null,[y?.toolMeta]),L=to(()=>k==="mcp-apps"&&!!N,[k,N]);da(()=>{m(L?"mcp-apps":"json")},[b?.toolName,L]);let _=to(()=>y?.result?.content||[],[y]),K=to(()=>N||null,[N]),F=to(()=>!!(_&&_.length>0||y?.result?.structuredContent),[_,y]),Y=to(()=>!L&&F,[L,F]),ee=to(()=>{let $=[];return L&&N&&$.push({mode:"mcp-apps",label:"Component (MCP Apps)"}),$.push({mode:"json",label:"Raw JSON"}),$},[L,N]);return da(()=>{ee.length!==0&&(ee.some($=>$.mode===g)||m(L?"mcp-apps":"json"))},[ee,L,g]),da(()=>{c&&(e.length===0||g!=="mcp-apps"||v!=="inline"||!L)&&c(null)},[c,e.length,g,v,L]),e.length===0?oe("div",{className:"flex flex-col h-full bg-white dark:bg-black",children:oe("div",{className:"flex-1 overflow-y-auto h-full",children:oe("div",{className:"flex items-center justify-center h-full",children:oe("div",{className:"text-center",children:oe(ps,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})}):_e("div",{className:"relative flex flex-col h-full bg-white dark:bg-black",children:[oe("div",{className:"flex-1 overflow-y-auto h-full",children:_e("div",{className:"space-y-0 flex flex-col flex-1 h-full",children:[_e("div",{className:`sticky top-0 z-40 flex items-center gap-2 px-4 pt-2 backdrop-blur-xs bg-white/50 dark:bg-black/50 ${L||Y?"border-b border-gray-200 dark:border-zinc-600 pb-2":""}`,children:[oe("h3",{className:"text-sm font-medium hidden sm:block",children:"Response"}),y.duration!==void 0&&_e("div",{className:"hidden sm:flex items-center gap-1",children:[oe(rw,{className:"h-3 w-3 text-gray-400"}),_e("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[y.duration,"ms"]})]}),L&&oe("div",{className:"flex items-center gap-4 sm:ml-4",children:oe("div",{className:"flex items-center gap-2",children:ee.map(($,Q)=>_e(sw.Fragment,{children:[Q>0&&oe("span",{className:"text-xs text-zinc-400",children:"|"}),oe("button",{"data-testid":`tool-result-view-${$.mode}`,onClick:()=>m($.mode),className:`text-xs font-medium ${g===$.mode?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:$.label})]},$.mode))})}),Y&&_e("div",{className:"flex items-center gap-2 sm:ml-4",children:[oe("button",{onClick:()=>d(!0),className:`text-xs font-medium ${f?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Formatted"}),oe("span",{className:"text-xs text-zinc-400",children:"|"}),oe("button",{onClick:()=>d(!1),className:`text-xs font-medium ${f?"text-zinc-500 dark:text-zinc-400":"text-black dark:text-white"}`,children:"Raw"})]}),_e("div",{className:"ml-auto flex items-center gap-1",children:[a&&i&&_e(A,{"data-testid":"tool-result-rerun",variant:"ghost",size:"sm",onClick:i,title:"Re-run with same arguments",children:[oe(ow,{className:"h-4 w-4"}),oe("span",{className:"hidden sm:inline ml-1",children:"Re-run"})]}),L&&s&&oe(A,{"data-testid":"tool-result-maximize",variant:"ghost",size:"sm",onClick:s,title:a?"Restore":"Maximize",children:a?oe(nw,{className:"h-4 w-4"}):oe(tw,{className:"h-4 w-4"})}),h.length>1&&_e(Sn,{value:l.toString(),onValueChange:$=>u(parseInt($)),children:[oe(Un,{className:"w-[140px] h-8 text-xs",leading:_e("div",{className:"flex items-center gap-1",children:[oe(Bf,{className:"h-3 w-3"}),oe(lw,{timestamp:y.timestamp})]})}),oe(Hn,{children:h.map(($,Q)=>oe(Wt,{value:Q.toString(),children:_e("div",{className:"flex items-center gap-2",children:[oe(Bf,{className:"h-3 w-3"}),oe("span",{children:Gc($.timestamp)}),_e("span",{className:"text-xs text-muted-foreground",children:["(",new Date($.timestamp).toLocaleTimeString(),")"]})]})},Q))})]}),oe(A,{"data-testid":`tool-result-copy-${R}`,variant:"ghost",size:"sm",onClick:()=>r(R,S),children:t===R?oe(Z0,{className:"h-4 w-4"}):oe(ew,{className:"h-4 w-4"})})]})]}),(()=>{let $=y.error||Hf(y.result);return $?_e("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3 mx-4 mt-4",children:[oe("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),oe("p",{className:"text-red-700 dark:text-red-400 text-sm",children:$})]}):(()=>{switch(g){case"mcp-apps":return!L||!N?oe("div",{className:"px-4 pt-4",children:oe("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3",children:oe("p",{className:"text-sm text-red-600 dark:text-red-400",children:"MCP Apps resource not available"})})}):_e(na,{className:"relative flex flex-1 w-full min-h-[240px] items-stretch",children:[oe("div",{className:"absolute top-2 right-2 z-30 flex items-center gap-2",children:oe(Yi,{toolCallId:`tool-${y.timestamp}`,displayMode:v,onDisplayModeChange:p,propsContext:"tool",resourceUri:N,toolInput:y.args,resourceAnnotations:y.toolMeta,llmConfig:null,resource:null,onPropsChange:C})}),oe("div",{className:"flex min-h-0 flex-1 flex-col pt-11",children:oe(is,{serverId:n,viewId:`tool-${y.timestamp}`,toolName:y.toolName,toolInput:T,toolOutput:M,toolMetadata:y.toolMeta,resourceUri:N,readResource:I,customProps:x||void 0,displayMode:v,onDisplayModeChange:p,onWidgetHeightChange:c?V=>c(V):void 0,noWrapper:!0},`mcp-apps-${y.timestamp}`)})]});case"json":{if(Y&&f){let V=y.result?.structuredContent;return _e("div",{className:"px-4 pt-4 space-y-4","data-testid":"tool-execution-results-content",children:[V&&_e("div",{className:"space-y-2","data-testid":"tool-execution-results-structured-content",children:[oe("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Structured Content"}),oe(xt,{data:V,filename:`structured-content-${y.toolName}-${Date.now()}.json`})]}),_&&_.length>0&&oe(dw,{content:_}),!V&&(!_||_.length===0)&&oe("div",{className:"text-sm text-gray-500 dark:text-gray-400","data-testid":"tool-execution-results-no-content",children:"No content to display"})]})}return oe("div",{className:"px-4 pt-4",children:oe(xt,{data:y.result,filename:`tool-result-${y.toolName}-${Date.now()}.json`})})}default:return null}})()})()]})}),K&&g==="mcp-apps"&&oe("div",{className:"absolute bottom-0 left-1/2 -translate-x-1/2 z-40 pointer-events-none",children:oe("span",{className:"text-[11px] bg-gray-200 dark:bg-zinc-800 text-gray-500 dark:text-gray-400 px-3 py-0.5 rounded-t-xl font-mono max-w-[320px] truncate block",children:K})})]})}import{isViewTool as uw}from"@mcp-use/client/react";import{useMemo as Zi,useState as mw}from"react";import{Fragment as fw,jsx as ho,jsxs as Ff}from"react/jsx-runtime";function pw({widgetId:e}){let{getWidget:t}=Ho(),o=t(e)?.modelContext;if(!o?.content?.length&&!o?.structuredContent)return null;let r=o.content?.map(s=>s.text).join(" ")??JSON.stringify(o.structuredContent).slice(0,80);return Ff("div",{className:"flex items-center gap-1.5 px-3 py-1.5 text-[11px] text-muted-foreground bg-muted/30 border border-border/40 rounded-md mt-1",children:[ho("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-blue-400 shrink-0"}),ho("span",{className:"font-medium",children:"State synced to model"}),ho("span",{className:"truncate opacity-60 max-w-[300px]",children:r})]})}function el({toolName:e,toolArgs:t,result:n,serverId:o,readResource:r,toolMeta:s,onSendFollowUp:a,modelContextScope:i,llmConfig:c,partialToolArgs:l,cancelled:u}){let f=Zi(()=>`chat-tool-${e}-${Date.now()}-${Math.random().toString(36).substring(2,11)}`,[e]),[d,g]=mw("inline"),m=Zi(()=>{if(!n)return null;if(typeof n=="string")try{return JSON.parse(n)}catch{return n}return n},[n]),v=uw(s),p=v?s?.ui?.resourceUri??null:null,x=Zi(()=>t,[e,m]),C=Zi(()=>m,[e,m]);return v&&p&&o&&r?Ff(fw,{children:[ho(is,{serverId:o,viewId:f,toolName:e,resourceUri:p,toolInput:x,toolOutput:C,toolMetadata:s,readResource:r,displayMode:d,onDisplayModeChange:g,onSendFollowUp:a,modelContextScope:i,llmConfig:c,partialToolInput:l,cancelled:u,noWrapper:!0,className:"my-4"}),ho(pw,{widgetId:f})]}):v&&!p?ho("div",{className:"flex items-center justify-center w-full h-[200px] rounded border",children:ho(hn,{className:"size-5"})}):v&&(!o||!r)?ho("div",{className:"my-4 p-4 bg-red-50/30 dark:bg-red-950/20 border border-red-200/50 dark:border-red-800/50 rounded-lg",children:ho("p",{className:"text-sm text-red-600 dark:text-red-400",children:"Cannot render widget: Missing required props (serverId or readResource)"})}):null}import{ViewRenderer as SU,isViewTool as TU,getViewResourceUri as RU}from"@mcp-use/client/react";import{createContext as gw,use as hw,useCallback as Rn,useState as vw}from"react";import{jsx as yw}from"react/jsx-runtime";var $f=gw(void 0);function bw({children:e}){let t=typeof window<"u"?window.__MANUFACT_CHAT_URL__:void 0,n=typeof import.meta<"u"?import.meta.env?.VITE_MANUFACT_CHAT_URL:void 0,o=t?.trim()||n?.trim()||"https://cloud.manufact.com/api/v1/inspector/chat/stream",[r,s]=vw({selectedServerId:null,activeTab:"tools",selectedToolName:null,selectedPromptName:null,selectedResourceUri:null,selectedSamplingRequestId:null,selectedElicitationRequestId:null,tunnelUrl:null,isTunnelStarting:!1,isEmbedded:!1,embeddedConfig:{chatApiUrl:o,chatStreamProtocol:"data-stream",chatEnableFreeTierUpgrade:!0}}),a=Rn(b=>{s(h=>({...h,selectedServerId:b}))},[]),i=Rn(b=>{s(h=>({...h,activeTab:b}))},[]),c=Rn(b=>{s(h=>({...h,selectedToolName:b}))},[]),l=Rn(b=>{s(h=>({...h,selectedPromptName:b}))},[]),u=Rn(b=>{s(h=>({...h,selectedResourceUri:b}))},[]),f=Rn(b=>{s(h=>({...h,selectedSamplingRequestId:b}))},[]),d=Rn(b=>{s(h=>({...h,selectedElicitationRequestId:b}))},[]),g=Rn(b=>{s(h=>({...h,tunnelUrl:b}))},[]),m=Rn(b=>{s(h=>({...h,isTunnelStarting:b}))},[]),v=Rn((b,h={})=>{s(y=>({...y,isEmbedded:b,embeddedConfig:{...h,chatApiUrl:h.chatApiUrl?.trim()||o,chatStreamProtocol:h.chatStreamProtocol??"data-stream",chatEnableFreeTierUpgrade:h.chatEnableFreeTierUpgrade??!0}}))},[o]),p=Rn((b,h,y)=>{console.warn("[InspectorContext] navigateToItem called:",{serverId:b,tab:h,itemIdentifier:y}),s(R=>({...R,selectedServerId:b,activeTab:h,selectedToolName:h==="tools"&&y||null,selectedPromptName:h==="prompts"&&y||null,selectedResourceUri:h==="resources"&&y||null,selectedSamplingRequestId:h==="sampling"&&y||null,selectedElicitationRequestId:h==="elicitation"&&y||null}))},[]),x=Rn(()=>{s(b=>({...b,selectedToolName:null,selectedPromptName:null,selectedResourceUri:null,selectedSamplingRequestId:null,selectedElicitationRequestId:null}))},[]),C={...r,setSelectedServerId:a,setActiveTab:i,setSelectedToolName:c,setSelectedPromptName:l,setSelectedResourceUri:u,setSelectedSamplingRequestId:f,setSelectedElicitationRequestId:d,setTunnelUrl:g,setIsTunnelStarting:m,setEmbeddedMode:v,navigateToItem:p,clearSelection:x};return yw($f,{value:C,children:e})}function vo(){let e=hw($f);if(!e)throw new Error("useInspector must be used within InspectorProvider");return e}import{GripVerticalIcon as xw}from"lucide-react";import*as Rr from"react-resizable-panels";import{jsx as ua}from"react/jsx-runtime";var{usePanelRef:Pr}=Rr;function Wo({className:e,...t}){return ua(Rr.Group,{"data-slot":"resizable-panel-group",className:w("flex h-full w-full aria-[orientation=vertical]:flex-col",e),...t})}function vn({...e}){return ua(Rr.Panel,{"data-slot":"resizable-panel",...e})}function Ko({withHandle:e,className:t,...n}){return ua(Rr.Separator,{"data-slot":"resizable-handle",className:w("relative z-50 box-content shrink-0","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1","before:pointer-events-none before:absolute before:bg-zinc-200 before:transition-[height,width,background-color] before:duration-200 before:ease-out dark:before:bg-zinc-700","hover:before:bg-foreground/35 dark:hover:before:bg-foreground/45","aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:py-1.5 aria-[orientation=horizontal]:-my-1.5","aria-[orientation=horizontal]:before:inset-x-0 aria-[orientation=horizontal]:before:top-1.5 aria-[orientation=horizontal]:before:h-px","hover:aria-[orientation=horizontal]:before:h-0.5","aria-[orientation=vertical]:h-full aria-[orientation=vertical]:w-px aria-[orientation=vertical]:px-1.5 aria-[orientation=vertical]:-mx-1.5","aria-[orientation=vertical]:before:inset-y-0 aria-[orientation=vertical]:before:left-1.5 aria-[orientation=vertical]:before:w-px","hover:aria-[orientation=vertical]:before:w-0.5","[&[aria-orientation=horizontal]>div]:rotate-90",t),...n,children:e&&ua("div",{className:"pointer-events-none absolute top-1/2 left-1/2 z-10 flex h-4 w-3 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-xs border border-zinc-200 bg-background shadow-sm dark:border-zinc-700",children:ua(xw,{className:"size-2.5 text-muted-foreground"})})})}import{AnimatePresence as rC,motion as dd}from"motion/react";import{ChevronLeft as sC,Database as eg,Wrench as tg}from"lucide-react";import{useCallback as yn,useEffect as ng,useMemo as og,useRef as sl,useState as Mn}from"react";import{useState as ww}from"react";import{jsx as Vf}from"react/jsx-runtime";function no({className:e,scrollRef:t,children:n}){let[o,r]=ww(!1);return Vf("div",{ref:t,className:w("h-full overflow-y-auto overscroll-none",e),onScroll:s=>r(s.currentTarget.scrollTop>0),children:Vf("div",{className:"flex min-h-full flex-col",children:n(o)})})}import{jsx as ma,jsxs as jf}from"react/jsx-runtime";function $n({id:e,isSelected:t,isFocused:n,title:o,description:r,metadata:s,onClick:a,className:i,"data-testid":c}){return ma("button",{id:e,"data-testid":c,type:"button",onClick:a,className:w("w-full text-left cursor-pointer p-2 sm:p-4 border-b dark:border-zinc-700 hover:bg-gray-50 dark:hover:bg-zinc-800/50 transition-colors group",t&&"bg-zinc-50 dark:bg-zinc-800 border-l-4 border-l-zinc-500",n&&"ring-2 ring-zinc-500 dark:ring-zinc-400 ring-inset",i),children:jf("div",{className:"flex items-start gap-2 sm:gap-3",children:[jf("div",{className:"flex-1 min-w-0",children:[ma("div",{className:"flex items-center gap-2 mb-1",children:ma("h3",{className:w("font-medium truncate font-mono text-sm"),children:o})}),r&&ma("p",{className:"text-sm text-gray-600 dark:text-gray-400 line-clamp-2",children:r})]}),s&&ma("div",{className:"flex-shrink-0 flex items-center self-center",children:s})]})})}import{forwardRef as Cw}from"react";import{cva as Nw}from"class-variance-authority";import{jsx as tl}from"react/jsx-runtime";var kw={gray:"#a3a3a3",red:"#ef4444",orange:"#f97316",amber:"#f59e0b",yellow:"#eab308",lime:"#84cc16",green:"#22c55e",emerald:"#10b981",teal:"#14b8a6",cyan:"#06b6d4",blue:"#3b82f6",indigo:"#6366f1",violet:"#8b5cf6",purple:"#a855f7",fuchsia:"#d946ef",pink:"#ec4899",rose:"#f43f5e"},Sw=Nw("inline-flex items-center font-medium whitespace-nowrap",{variants:{variant:{solid:"",outline:"border border-border text-foreground"},size:{sm:"h-5 px-2 text-[11px] gap-1",md:"h-6 px-2.5 text-[12px] gap-1.5",lg:"h-7 px-3 text-[13px] gap-1.5"}},defaultVariants:{variant:"solid",size:"md"}}),qf={default:{variant:"solid",color:"blue"},secondary:{variant:"solid",color:"green"},destructive:{variant:"solid",color:"red"},outline:{variant:"outline",color:"gray"}};function Tw(e){return typeof e=="string"||typeof e=="number"}function Rw({children:e}){return Tw(e)?tl("span",{className:"[text-box:trim-both_cap_alphabetic]",children:e}):tl("span",{className:"inline-flex items-center gap-1",children:e})}var Kt=Cw(({className:e,variant:t="solid",size:n="md",color:o,children:r,style:s,...a},i)=>{let c=t&&t in qf?qf[t]:null,l=c?.variant??t,u=o??c?.color??"gray",f=vt(),d=kw[u],m=l==="solid"?u==="gray"?{backgroundColor:"var(--accent)",color:"var(--foreground)"}:{color:"var(--foreground)",backgroundColor:`color-mix(in srgb, ${d} 15%, var(--background))`}:{};return tl("span",{ref:i,className:w(Sw({variant:l,size:n}),f.item,e),style:{...m,...s},...a,children:tl(Rw,{children:r})})});Kt.displayName="Badge";import{RefreshCw as Mw,Search as Iw}from"lucide-react";import{jsx as Pw}from"react/jsx-runtime";function fs({className:e,...t}){return Pw("kbd",{"data-slot":"kbd",className:w("bg-muted text-muted-foreground pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium select-none","[&_svg:not([class*='size-'])]:size-3","[[data-slot=tooltip-content]_&]:bg-background/20 [[data-slot=tooltip-content]_&]:text-background dark:[[data-slot=tooltip-content]_&]:bg-background/10",e),...t})}import{Fragment as Wf,jsx as an,jsxs as bo}from"react/jsx-runtime";var Ew="h-3.5 w-3.5 shrink-0 text-muted-foreground";function Mr({activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabTitle:o,secondaryTabTitle:r,primaryCount:s,secondaryCount:a,secondaryIcon:i,primaryIcon:c,searchPlaceholder:l="Search...",onSearchExpand:u,onSearchChange:f,onSearchBlur:d,onTabSwitch:g,searchInputRef:m,primaryTabName:v,onRefresh:p,isRefreshing:x=!1,isScrolled:C=!1}){let b=e===v,h=b?c:i,y=b?o:r;return bo("div",{className:`flex flex-row items-center justify-between gap-2 ${yi(C)} ${Io}`,children:[an("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:t?an(Ge,{ref:m,placeholder:l,value:n,onChange:R=>f(R.target.value),onBlur:d,className:"h-8 border-gray-300 dark:border-zinc-600"}):bo(Wf,{children:[bo("h2",{className:`${Eo} flex items-center gap-1.5`,children:[an(h,{className:Ew,"aria-hidden":!0}),y]}),b&&bo(Wf,{children:[an(Kt,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:s}),bo(Re,{children:[an(Se,{render:an(A,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:an(Iw,{className:"h-4 w-4"})}),nativeButton:!0}),bo(Te,{side:"bottom",className:"flex gap-2",children:["Search",an(fs,{children:"F"})]})]}),p&&bo(Re,{children:[an(Se,{render:an(A,{variant:"ghost",size:"sm",onClick:p,disabled:x,className:"h-8 w-8 p-0",children:an(Mw,{className:`h-4 w-4 ${x?"animate-spin":""}`})}),nativeButton:!0}),bo(Te,{side:"bottom",className:"flex gap-2",children:["Refresh list",an(fs,{children:"R"})]})]})]})]})}),bo(A,{variant:"ghost",size:"sm",onClick:g,className:"gap-2 flex-shrink-0",children:[an("span",{className:"hidden sm:inline",children:b?r:o}),b&&a>0&&an(Kt,{className:"bg-purple-500/20 text-purple-600 dark:text-purple-400 border-transparent",variant:"outline",children:a})]})]})}import{RefreshCw as Aw,Search as Lw}from"lucide-react";import{Fragment as Dw,jsx as Ut,jsxs as Jo}from"react/jsx-runtime";function nl({title:e,count:t,icon:n,isSearchExpanded:o,searchQuery:r,searchPlaceholder:s,onSearchExpand:a,onSearchChange:i,onSearchBlur:c,searchInputRef:l,titleTestId:u,bulkAction:f,onRefresh:d,isRefreshing:g=!1,isScrolled:m=!1}){let v=f?.icon;return Jo("div",{className:`flex flex-row items-center justify-between gap-2 ${yi(m)} ${Io}`,children:[Ut("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:o?Ut(Ge,{ref:l,placeholder:s,value:r,onChange:x=>i(x.target.value),onBlur:c,className:"h-8 border-gray-300 dark:border-zinc-600"}):Jo(Dw,{children:[Jo("h2",{className:`${Eo} flex items-center gap-1.5`,"data-testid":u,children:[n?Ut(n,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}):null,e]}),Ut(Kt,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:t}),Jo(Re,{children:[Ut(Se,{render:Ut(A,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:Ut(Lw,{className:"h-4 w-4"})}),nativeButton:!0}),Jo(Te,{side:"bottom",className:"flex gap-2",children:["Search",Ut(fs,{children:"F"})]})]}),d&&Jo(Re,{children:[Ut(Se,{render:Ut(A,{variant:"ghost",size:"sm",onClick:d,disabled:g,className:"h-8 w-8 p-0",children:Ut(Aw,{className:`h-4 w-4 ${g?"animate-spin":""}`})}),nativeButton:!0}),Jo(Te,{side:"bottom",className:"flex gap-2",children:["Refresh list",Ut(fs,{children:"R"})]})]})]})}),f&&v&&Ut("div",{className:"flex items-center gap-2",children:Jo(Re,{children:[Ut(Se,{render:Ut(A,{variant:"ghost",size:"sm",onClick:f.onClick,disabled:f.disabled,className:"h-8 w-8 p-0",children:Ut(v,{className:"h-4 w-4"})}),nativeButton:!0}),Ut(Te,{side:"bottom",children:f.label})]})})]})}import{AlertTriangle as pL,Check as fL,Loader2 as gL,XCircle as hL}from"lucide-react";import{jsx as bL}from"react/jsx-runtime";import{Database as _w,Trash2 as Ow}from"lucide-react";import{jsx as bn,jsxs as Yc}from"react/jsx-runtime";function Xc({savedRequests:e,selectedRequest:t,onLoadRequest:n,onDeleteRequest:o,focusedIndex:r}){if(e.length===0)return Yc("div",{className:"flex flex-1 flex-col items-center justify-center p-4 text-center",children:[bn(_w,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),bn("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"No saved requests yet"}),bn("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Execute a tool and click Save to store requests"})]});let s=(a,i)=>{a.stopPropagation(),i()};return bn("div",{children:e.map((a,i)=>Yc("div",{className:"relative group",children:[bn($n,{id:`saved-${a.id}`,isSelected:t?.id===a.id,isFocused:r===i,title:a.name,description:a.toolName,metadata:bn("div",{className:"flex flex-col gap-1",children:bn("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:new Date(a.savedAt).toLocaleString()})}),onClick:()=>n(a)}),bn("div",{className:"absolute top-1/2 right-2 -translate-y-1/2 opacity-0 group-hover:opacity-100 transition-opacity z-10",children:Yc(Re,{children:[bn(Se,{render:bn(A,{variant:"secondary",size:"sm",onClick:c=>s(c,()=>o(a.id)),className:"h-8 w-8 p-0",children:bn(Ow,{className:"h-4 w-4"})}),nativeButton:!0}),bn(Te,{children:bn("p",{children:"Delete saved request"})})]})})]},a.id))})}import{Save as zw}from"lucide-react";import{jsx as gs,jsxs as pa}from"react/jsx-runtime";function Qc({isOpen:e,requestName:t,defaultPlaceholder:n,onRequestNameChange:o,onSave:r,onCancel:s}){return e?gs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:s,children:pa("div",{className:"bg-white dark:bg-zinc-800 rounded-lg p-6 w-[400px] shadow-xl border border-gray-200 dark:border-zinc-700",onClick:a=>a.stopPropagation(),children:[gs("h3",{className:"text-lg font-semibold mb-4 text-gray-900 dark:text-gray-100",children:"Save Request"}),pa("div",{className:"space-y-4",children:[pa("div",{children:[gs(tt,{htmlFor:"request-name",children:"Request Name (optional)"}),gs(Ge,{id:"request-name",value:t,onChange:a=>o(a.target.value),placeholder:n,className:"mt-2",onKeyDown:a=>{a.key==="Enter"&&r()},autoFocus:!0})]}),pa("div",{className:"flex justify-end gap-2",children:[gs(A,{variant:"outline",onClick:s,children:"Cancel"}),pa(A,{onClick:r,children:[gs(zw,{className:"h-4 w-4 mr-2"}),"Save"]})]})]})]})}):null}import{Check as Bw,ChevronDown as Hw,ChevronUp as Uw,Code as Fw,Copy as $w,Play as Vw,Save as jw,X as qw}from"lucide-react";import{useEffect as Kf,useRef as Ww,useState as fa}from"react";import{Fragment as hs,jsx as Ce,jsxs as kt}from"react/jsx-runtime";function Zc({selectedTool:e,toolArgs:t,payloadToSend:n,isExecuting:o,isConnected:r,onArgChange:s,onExecute:a,onSave:i,onCancel:c,onBulkPaste:l,autoFilledFields:u,setFields:f,sendEmptyFields:d,onToggleEmpty:g}){let m="hidden @[700px]/tool-exec:inline",v="hidden @[700px]/tool-exec:inline shrink-0 text-[10px] leading-none border border-current/30 p-1 rounded-full",p="@max-[699px]/tool-exec:size-8 @max-[699px]/tool-exec:min-w-8 @max-[699px]/tool-exec:shrink-0 @max-[699px]/tool-exec:gap-0 @max-[699px]/tool-exec:rounded-full @max-[699px]/tool-exec:!px-0 @max-[699px]/tool-exec:!py-0",x="@max-[699px]/tool-exec:!pr-0",[C,b]=fa(!1),[h,y]=fa(!1),[R,P]=fa(!1),[S,T]=fa(!1),[M,I]=fa(!1),k=Ww(null);Kf(()=>{if(k.current&&e?.description){let _=k.current,K=parseFloat(getComputedStyle(_).lineHeight),F=_.scrollHeight,Y=Math.round(F/K);I(Y>3),T(!1)}},[e?.description]);let N=async()=>{e&&await Ze(JSON.stringify(e,null,2))},L=async()=>{if(e)try{await Ze(JSON.stringify(n??t,null,2)),P(!0),setTimeout(()=>P(!1),2e3)}catch{}};return Kf(()=>{let _=K=>{if(K.key==="Escape"&&o&&c){K.preventDefault(),c();return}if(K.key!=="Enter")return;let F=K.metaKey||K.ctrlKey,Y=!K.metaKey&&!K.ctrlKey&&!K.altKey&&!K.shiftKey,ee=K.target,$=ee instanceof HTMLInputElement&&ee.dataset.toolArgumentInput==="true";(F||Y&&$)&&e&&!o&&r&&(K.preventDefault(),a())};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[e,o,r,a,c]),e?kt("div",{className:"flex flex-col h-full @container/tool-exec",children:[Ce("div",{className:"shrink-0 p-3 sm:p-5 pt-3 sm:pt-4 pb-2 sm:pb-2 sm:pr-4",children:Ce("div",{children:kt("div",{className:"flex flex-row items-center justify-between mb-0 gap-2",children:[Ce("h3",{className:"text-base sm:text-lg font-semibold","data-testid":"tool-execution-title",children:e.name}),kt("div",{className:"flex gap-2 shrink-0",children:[kt(Re,{children:[Ce(Se,{render:kt(A,{"data-testid":"tool-execution-metadata-button",variant:h?"default":"outline",onClick:()=>y(!h),disabled:o,size:"sm",className:w(ur,p),title:"View tool metadata",children:[Ce(Fw,{}),Ce("span",{className:m,children:"Metadata"})]}),nativeButton:!0}),Ce(Te,{children:Ce("p",{children:"View tool definition metadata"})})]}),kt(Re,{children:[Ce(Se,{render:kt(A,{"data-testid":"tool-execution-copy-payload-button",variant:"outline",onClick:L,disabled:o,size:"sm",className:w(ur,p),title:"Copy payload as JSON",children:[R?Ce(Bw,{className:"text-green-600"}):Ce($w,{}),Ce("span",{className:m,children:R?"Copied!":"Payload"})]}),nativeButton:!0}),Ce(Te,{children:Ce("p",{children:"Copy payload as JSON"})})]}),kt(Re,{children:[Ce(Se,{render:kt(A,{"data-testid":"tool-execution-save-button",variant:"outline",onClick:i,disabled:o,size:"sm",className:w(ur,p),title:"Save request",children:[Ce(jw,{}),Ce("span",{className:m,children:"Save"})]}),nativeButton:!0}),Ce(Te,{children:Ce("p",{children:"Save request"})})]}),o&&c?kt(Re,{open:C?void 0:!1,children:[Ce(Se,{render:Ce("div",{onMouseEnter:()=>b(!0),onMouseLeave:()=>b(!1),className:"relative",children:Ce(A,{"data-testid":"tool-execution-cancel-button",onClick:c,variant:C?"destructive":"default",size:"sm",className:w(Gs,p,x,"transition-all"),children:C?kt(hs,{children:[Ce(qw,{}),Ce("span",{className:m,children:"Cancel"}),Ce("span",{className:v,children:"Esc"})]}):kt(hs,{children:[Ce(hn,{}),Ce("span",{className:m,children:"Executing..."})]})})}),nativeButton:!1}),Ce(Te,{children:Ce("p",{children:"Hover to cancel (or press Esc)"})})]}):Ce(A,{"data-testid":"tool-execution-execute-button",onClick:a,disabled:o||!r,size:"sm",className:w(Gs,p,x),children:o?kt(hs,{children:[Ce(hn,{}),Ce("span",{className:m,children:"Executing..."})]}):kt(hs,{children:[Ce(Vw,{}),Ce("span",{className:m,children:"Execute"}),Ce("span",{className:v,children:"\u2318\u21B5"})]})})]})]})})}),kt("div",{className:"flex-1 overflow-y-auto px-3 sm:px-5 pb-4 pr-3",children:[e.description&&kt("div",{className:"relative mb-6",children:[kt("div",{className:"relative",children:[Ce("p",{ref:k,"data-testid":"tool-execution-description",className:`text-sm text-gray-600 dark:text-gray-400 leading-relaxed transition-all duration-300 ${!S&&M?"line-clamp-3":""}`,children:e.description}),M&&!S&&Ce("div",{className:"absolute bottom-0 left-0 right-0 h-[1.4em] bg-linear-to-t from-white/95 dark:from-black/95 via-white/55 dark:via-black/55 to-transparent pointer-events-none"})]}),M&&Ce("div",{className:"flex justify-end",children:Ce("button",{onClick:()=>T(!S),className:"relative z-10 inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 mt-1 transition-colors",children:S?kt(hs,{children:["Show less",Ce(Uw,{className:"h-3 w-3"})]}):kt(hs,{children:["Show more",Ce(Hw,{className:"h-3 w-3"})]})})})]}),Ce(Ec,{selectedTool:e,toolArgs:t,onArgChange:s,onBulkPaste:l,autoFilledFields:u,setFields:f,sendEmptyFields:d,onToggleEmpty:g})]}),Ce(fn,{open:h,onOpenChange:y,children:kt(rn,{scrollable:!0,className:"max-w-3xl max-h-[80vh]",children:[Ce(Xt,{sticky:!0,children:Ce(qt,{children:"Tool Definition"})}),Ce(zn,{children:Ce(vi,{onCopy:N,children:Ce(xt,{data:e,filename:`tool-definition-${e.name}-${Date.now()}.json`})})})]})})]}):kt("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[Ce("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a tool to get started"}),Ce("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Choose a tool from the list to view its details and execute it"})]})}import{PanelsTopLeft as Kw,Wrench as Jw}from"lucide-react";import{isViewTool as Gw}from"@mcp-use/client/react";import{jsx as yo,jsxs as ol}from"react/jsx-runtime";function ed({tools:e,selectedTool:t,onToolSelect:n,focusedIndex:o}){if(e.length===0)return ol("div",{className:"flex flex-1 flex-col items-center justify-center p-4 text-center",children:[yo(Jw,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),yo("p",{className:"text-gray-500 dark:text-gray-400",children:"No tools available"})]});let r=e.some(s=>s.inputSchema?.properties&&Object.keys(s.inputSchema.properties).length>0);return yo("div",{children:e.map((s,a)=>{let i=s._meta,c=Gw(i)?"mcp-apps":null,l=s.inputSchema?.properties,u=l?Object.keys(l).length:0,f=r&&u>0&&ol(Kt,{variant:"outline",className:"text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400",children:[u," params"]}),g=c==="mcp-apps"||f?ol("div",{className:"flex items-center gap-1.5",children:[c==="mcp-apps"&&ol(Re,{children:[yo(Se,{render:yo("span",{className:"inline-flex",children:yo(Kw,{className:"h-3.5 w-3.5"})}),nativeButton:!1}),yo(Te,{children:yo("p",{children:"UI widget"})})]}),f]}):void 0;return yo($n,{id:`tool-${s.name}`,"data-testid":`tool-item-${s.name}`,isSelected:t?.name===s.name,isFocused:o===a,title:s.name,description:s.description,metadata:g,onClick:()=>n(s)},s.name)})})}import{AlertDialog as Ir}from"@base-ui/react/alert-dialog";import{jsx as Pn,jsxs as Qw}from"react/jsx-runtime";function td({...e}){return Pn(Ir.Root,{"data-slot":"alert-dialog",...e})}function Yw({...e}){return Pn(Ir.Portal,{"data-slot":"alert-dialog-portal",...e})}function Xw({className:e,...t}){return Pn(Ir.Backdrop,{"data-slot":"alert-dialog-overlay",className:w("fixed inset-0 isolate z-50 bg-black/50 duration-100 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...t})}function nd({className:e,size:t="default",...n}){return Qw(Yw,{children:[Pn(Xw,{}),Pn(Ir.Popup,{"data-slot":"alert-dialog-content","data-size":t,className:w("group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-6 rounded-xl bg-popover p-6 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-lg data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...n})]})}function od({className:e,...t}){return Pn("div",{"data-slot":"alert-dialog-header",className:w("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",e),...t})}function rd({className:e,...t}){return Pn("div",{"data-slot":"alert-dialog-footer",className:w("flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",e),...t})}function sd({className:e,...t}){return Pn(Ir.Title,{"data-slot":"alert-dialog-title",className:w("text-lg font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",e),...t})}function ad({className:e,...t}){return Pn(Ir.Description,{"data-slot":"alert-dialog-description",className:w("text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}function id({className:e,...t}){return Pn(A,{"data-slot":"alert-dialog-action",className:w(e),...t})}function ld({className:e,variant:t="outline",size:n="default",...o}){return Pn(Ir.Close,{"data-slot":"alert-dialog-cancel",className:w(e),render:Pn(A,{variant:t,size:n}),...o})}import{useCallback as Zw,useEffect as Jf,useState as eC}from"react";var cd="mcp-inspector-saved-requests";function Gf(){let[e,t]=eC([]);Jf(()=>{try{let o=localStorage.getItem(cd);o&&t(JSON.parse(o))}catch(o){console.error("[useSavedRequests] Failed to load saved requests:",o)}},[]),Jf(()=>{let o=r=>{if(r.key===cd&&r.newValue)try{t(JSON.parse(r.newValue))}catch(s){console.error("[useSavedRequests] Failed to parse saved requests:",s)}};return window.addEventListener("storage",o),()=>window.removeEventListener("storage",o)},[]);let n=Zw(o=>{try{localStorage.setItem(cd,JSON.stringify(o)),t(o)}catch(r){console.error("[useSavedRequests] Failed to save requests:",r)}},[]);return{savedRequests:e,saveSavedRequests:n}}import{useCallback as ga,useMemo as tC,useState as rl}from"react";function Yf(e,t){if(!e)return t;if(!t)return e;let n=e.ui&&typeof e.ui=="object"&&!Array.isArray(e.ui)?e.ui:void 0,o=t.ui&&typeof t.ui=="object"&&!Array.isArray(t.ui)?t.ui:void 0;return{...e,...t,...n||o?{ui:{...n,...o}}:{}}}function Xf({selectedTool:e,payloadToSend:t,toolArgs:n,callTool:o,readResource:r,serverId:s}){let[a,i]=rl([]),[c,l]=rl(!1),[u,f]=rl(null),[d,g]=rl(null),m=ga(async()=>{if(!e||c)return;let h=new AbortController;g(h),l(!0);let y=Date.now();try{let R=t,P=e?._meta||e?.metadata,T=P?.ui?.resourceUri;if(T&&typeof T=="string"){try{await r(T)}catch{}i([{toolName:e.name,args:R,result:null,timestamp:y,duration:0,toolMeta:P}])}let M=await o(e.name,R,{timeout:6e5,resetTimeoutOnProgress:!0,signal:h.signal}),I=Date.now()-y,k=Yf(P,M?._meta);It(new Vs({toolName:e.name,serverId:s,success:!0,duration:I})).catch(()=>{}),window.dispatchEvent(new Event("mcp-tool-executed")),i(T&&typeof T=="string"?N=>N.map((L,_)=>_===0?{...L,result:M,duration:I,toolMeta:k}:L):N=>[{toolName:e.name,args:n,result:M,timestamp:y,duration:I,toolMeta:k},...N])}catch(R){let P=Date.now()-y;It(new Vs({toolName:e.name,serverId:s,success:!1,duration:P,error:R instanceof Error?R.message:String(R)})).catch(()=>{}),window.dispatchEvent(new Event("mcp-tool-executed"));let S=e?._meta||e?.metadata,T={toolName:e.name,args:n,result:null,error:R instanceof Error?R.message:String(R),timestamp:y,duration:P,toolMeta:S},M=S?.ui?.resourceUri;i(M?[T]:I=>[T,...I])}finally{l(!1)}},[e,t,n,c,o,r,s]),v=ga(async(h,y)=>{try{await Ze(y),f(h),setTimeout(()=>f(null),2e3)}catch(R){console.error("[ToolsTab] Failed to copy result:",R)}},[]),p=ga(h=>{i(y=>y.filter((R,P)=>P!==h))},[]),x=tC(()=>e?a.filter(h=>h.toolName===e.name):[],[a,e]),C=ga(h=>{let y=x[h];if(!y)return;let R=window.open("","_blank","width=800,height=600");R&&(R.document.write(`
102
+ `)}return"An error occurred"}function cw(e){try{return JSON.parse(e),!0}catch{return!1}}function dw({content:e}){let[t,n]=Tr(new Set),o=Uf(r=>{n(s=>{let a=new Set(s);return a.has(r)?a.delete(r):a.add(r),a})},[]);return!Array.isArray(e)||e.length===0?oe("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No content"}):oe("div",{className:"space-y-4",children:e.map((r,s)=>{if(r.type==="text"){let a=r.text||"",i=t.has(s),c=cw(a),l=c?(()=>{try{return JSON.parse(a)}catch{return null}})():null;return _e("div",{className:"space-y-2",children:[_e("div",{className:"flex items-center justify-between gap-2",children:[_e("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:["Text Content",i?" (formatted)":""]}),c&&oe("button",{type:"button",onClick:()=>o(s),className:"text-xs text-blue-600 dark:text-blue-400 hover:underline","data-testid":`tool-result-format-toggle-${s}`,children:i?"Show as text":"Try to format"})]}),i&&l!==null?oe(xt,{data:l,filename:`content-${s}.json`}):oe("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 font-mono text-sm whitespace-pre-wrap break-words","data-testid":"tool-execution-results-text-content",children:a})]},s)}if(r.type==="image")return _e("div",{className:"space-y-2",children:[oe("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Image Content"}),_e("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3",children:[oe("img",{src:`data:${r.mimeType||"image/png"};base64,${r.data}`,alt:"Result",className:"max-w-full rounded","data-testid":"tool-execution-results-image-content"}),r.annotations&&oe("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:oe(xt,{data:r.annotations,filename:`image-annotations-${s}.json`,"data-testid":"tool-execution-results-image-annotations"})})]})]},s);if(r.type==="audio")return _e("div",{className:"space-y-2",children:[oe("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Audio Content"}),_e("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3",children:[oe("audio",{controls:!0,src:`data:${r.mimeType||"audio/wav"};base64,${r.data}`,className:"w-full","data-testid":"tool-execution-results-audio-content"}),r.annotations&&oe("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:oe(xt,{data:r.annotations,filename:`audio-annotations-${s}.json`,"data-testid":"tool-execution-results-audio-annotations"})})]})]},s);if(r.type==="resource_link")return _e("div",{className:"space-y-2",children:[oe("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Resource Link"}),_e("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2",children:[_e("div",{className:"font-mono text-sm break-all",children:[oe("span",{className:"text-gray-600 dark:text-gray-400",children:"URI:"})," ",r.uri]}),r.name&&_e("div",{className:"text-sm",children:[oe("span",{className:"text-gray-600 dark:text-gray-400",children:"Name:"})," ",r.name]}),r.description&&_e("div",{className:"text-sm",children:[oe("span",{className:"text-gray-600 dark:text-gray-400",children:"Description:"})," ",r.description]}),r.mimeType&&_e("div",{className:"text-sm",children:[oe("span",{className:"text-gray-600 dark:text-gray-400",children:"MIME Type:"})," ",r.mimeType]}),r.annotations&&_e("div",{className:"mt-2",children:[oe("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Annotations:"}),oe(xt,{data:r.annotations,filename:`resource-link-annotations-${s}.json`,"data-testid":"tool-execution-results-resource-link-annotations"})]})]})]},s);if(r.type==="resource"){let a=r.resource||{};return _e("div",{className:"space-y-2",children:[oe("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Embedded Resource"}),_e("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2",children:[_e("div",{className:"font-mono text-sm break-all","data-testid":"tool-execution-results-resource-uri",children:[oe("span",{className:"text-gray-600 dark:text-gray-400",children:"URI:"})," ",a.uri]}),a.mimeType&&_e("div",{className:"text-sm",children:[oe("span",{className:"text-gray-600 dark:text-gray-400","data-testid":"tool-execution-results-mime-type",children:"MIME Type:"})," ",a.mimeType]}),a.text&&_e("div",{"data-testid":"tool-execution-results-resource-text-content",children:[oe("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Content:"}),oe("div",{className:"bg-white dark:bg-black rounded p-2 font-mono text-sm whitespace-pre-wrap break-words max-h-60 overflow-y-auto",children:a.text})]}),a.blob&&_e("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:["[Binary content: ",a.blob.length||0," bytes]"]}),a.annotations&&_e("div",{className:"mt-2",children:[oe("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Annotations:"}),oe(xt,{data:a.annotations,filename:`resource-annotations-${s}.json`,"data-testid":"tool-execution-results-resource-annotations"})]})]})]},s)}return _e("div",{className:"space-y-2",children:[_e("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:["Unknown Content Type: ",r.type||"N/A"]}),oe(xt,{data:r,filename:`content-${s}.json`,"data-testid":"tool-execution-results-unknown-content"})]},s)})})}function Qi({results:e,copiedResult:t,serverId:n,readResource:o,onCopy:r,onMaximize:s,isMaximized:a=!1,onRerunTool:i,onWidgetHeightChange:c}){let[l,u]=Tr(0),[f,d]=Tr(!0),[g,m]=Tr("json"),[v,p]=Tr("inline"),[x,C]=Tr(null),b=e[0],h=b?e.filter($=>$.toolName===b.toolName):[],y=h[l]||h[0],R=e.findIndex($=>$===y),P=y?y.error||Hf(y.result):null,S=P??(y!=null?JSON.stringify(y.result,null,2):"");da(()=>{h.length>0&&l>=h.length&&u(0)},[h.length,l]);let T=to(()=>y?.args,[y?.timestamp,l]),M=to(()=>y?.result,[y?.timestamp,y?.duration,l]),I=Uf($=>o($),[o]),k=to(()=>y&&iw(y.toolMeta)?"mcp-apps":null,[y]),N=to(()=>y?.toolMeta?aw(y.toolMeta):null,[y?.toolMeta]),L=to(()=>k==="mcp-apps"&&!!N,[k,N]);da(()=>{m(L?"mcp-apps":"json")},[b?.toolName,L]);let _=to(()=>y?.result?.content||[],[y]),K=to(()=>N||null,[N]),F=to(()=>!!(_&&_.length>0||y?.result?.structuredContent),[_,y]),Y=to(()=>!L&&F,[L,F]),ee=to(()=>{let $=[];return L&&N&&$.push({mode:"mcp-apps",label:"Component (MCP Apps)"}),$.push({mode:"json",label:"Raw JSON"}),$},[L,N]);return da(()=>{ee.length!==0&&(ee.some($=>$.mode===g)||m(L?"mcp-apps":"json"))},[ee,L,g]),da(()=>{c&&(e.length===0||g!=="mcp-apps"||v!=="inline"||!L)&&c(null)},[c,e.length,g,v,L]),e.length===0?oe("div",{className:"flex flex-col h-full bg-white dark:bg-black",children:oe("div",{className:"flex-1 overflow-y-auto h-full",children:oe("div",{className:"flex items-center justify-center h-full",children:oe("div",{className:"text-center",children:oe(ps,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})}):_e("div",{className:"relative flex flex-col h-full bg-white dark:bg-black",children:[oe("div",{className:"flex-1 overflow-y-auto h-full",children:_e("div",{className:"space-y-0 flex flex-col flex-1 h-full",children:[_e("div",{className:`sticky top-0 z-40 flex items-center gap-2 px-4 pt-2 backdrop-blur-xs bg-white/50 dark:bg-black/50 ${L||Y?"border-b border-gray-200 dark:border-zinc-600 pb-2":""}`,children:[oe("h3",{className:"text-sm font-medium hidden sm:block",children:"Response"}),y.duration!==void 0&&_e("div",{className:"hidden sm:flex items-center gap-1",children:[oe(rw,{className:"h-3 w-3 text-gray-400"}),_e("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[y.duration,"ms"]})]}),L&&oe("div",{className:"flex items-center gap-4 sm:ml-4",children:oe("div",{className:"flex items-center gap-2",children:ee.map(($,Q)=>_e(sw.Fragment,{children:[Q>0&&oe("span",{className:"text-xs text-zinc-400",children:"|"}),oe("button",{"data-testid":`tool-result-view-${$.mode}`,onClick:()=>m($.mode),className:`text-xs font-medium ${g===$.mode?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:$.label})]},$.mode))})}),Y&&_e("div",{className:"flex items-center gap-2 sm:ml-4",children:[oe("button",{onClick:()=>d(!0),className:`text-xs font-medium ${f?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Formatted"}),oe("span",{className:"text-xs text-zinc-400",children:"|"}),oe("button",{onClick:()=>d(!1),className:`text-xs font-medium ${f?"text-zinc-500 dark:text-zinc-400":"text-black dark:text-white"}`,children:"Raw"})]}),_e("div",{className:"ml-auto flex items-center gap-1",children:[a&&i&&_e(A,{"data-testid":"tool-result-rerun",variant:"ghost",size:"sm",onClick:i,title:"Re-run with same arguments",children:[oe(ow,{className:"h-4 w-4"}),oe("span",{className:"hidden sm:inline ml-1",children:"Re-run"})]}),L&&s&&oe(A,{"data-testid":"tool-result-maximize",variant:"ghost",size:"sm",onClick:s,title:a?"Restore":"Maximize",children:a?oe(nw,{className:"h-4 w-4"}):oe(tw,{className:"h-4 w-4"})}),h.length>1&&_e(Sn,{value:l.toString(),onValueChange:$=>u(parseInt($)),children:[oe(Un,{className:"w-[140px] h-8 text-xs",leading:_e("div",{className:"flex items-center gap-1",children:[oe(Bf,{className:"h-3 w-3"}),oe(lw,{timestamp:y.timestamp})]})}),oe(Hn,{children:h.map(($,Q)=>oe(Wt,{value:Q.toString(),children:_e("div",{className:"flex items-center gap-2",children:[oe(Bf,{className:"h-3 w-3"}),oe("span",{children:Gc($.timestamp)}),_e("span",{className:"text-xs text-muted-foreground",children:["(",new Date($.timestamp).toLocaleTimeString(),")"]})]})},Q))})]}),oe(A,{"data-testid":`tool-result-copy-${R}`,variant:"ghost",size:"sm",onClick:()=>r(R,S),children:t===R?oe(Z0,{className:"h-4 w-4"}):oe(ew,{className:"h-4 w-4"})})]})]}),(()=>{let $=y.error||Hf(y.result);return $?_e("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3 mx-4 mt-4",children:[oe("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),oe("p",{className:"text-red-700 dark:text-red-400 text-sm",children:$})]}):(()=>{switch(g){case"mcp-apps":return!L||!N?oe("div",{className:"px-4 pt-4",children:oe("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3",children:oe("p",{className:"text-sm text-red-600 dark:text-red-400",children:"MCP Apps resource not available"})})}):_e(na,{className:"relative flex flex-1 w-full min-h-[240px] items-stretch",children:[oe("div",{className:"absolute top-2 right-2 z-30 flex items-center gap-2",children:oe(Yi,{toolCallId:`tool-${y.timestamp}`,displayMode:v,onDisplayModeChange:p,propsContext:"tool",resourceUri:N,toolInput:y.args,resourceAnnotations:y.toolMeta,llmConfig:null,resource:null,onPropsChange:C})}),oe("div",{className:"flex min-h-0 flex-1 flex-col pt-11",children:oe(is,{serverId:n,viewId:`tool-${y.timestamp}`,toolName:y.toolName,toolInput:T,toolOutput:M,toolMetadata:y.toolMeta,resourceUri:N,readResource:I,customProps:x||void 0,displayMode:v,onDisplayModeChange:p,onWidgetHeightChange:c?V=>c(V):void 0,noWrapper:!0},`mcp-apps-${y.timestamp}`)})]});case"json":{if(Y&&f){let V=y.result?.structuredContent;return _e("div",{className:"px-4 pt-4 space-y-4","data-testid":"tool-execution-results-content",children:[V&&_e("div",{className:"space-y-2","data-testid":"tool-execution-results-structured-content",children:[oe("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Structured Content"}),oe(xt,{data:V,filename:`structured-content-${y.toolName}-${Date.now()}.json`})]}),_&&_.length>0&&oe(dw,{content:_}),!V&&(!_||_.length===0)&&oe("div",{className:"text-sm text-gray-500 dark:text-gray-400","data-testid":"tool-execution-results-no-content",children:"No content to display"})]})}return oe("div",{className:"px-4 pt-4",children:oe(xt,{data:y.result,filename:`tool-result-${y.toolName}-${Date.now()}.json`})})}default:return null}})()})()]})}),K&&g==="mcp-apps"&&oe("div",{className:"absolute bottom-0 left-1/2 -translate-x-1/2 z-40 pointer-events-none",children:oe("span",{className:"text-[11px] bg-gray-200 dark:bg-zinc-800 text-gray-500 dark:text-gray-400 px-3 py-0.5 rounded-t-xl font-mono max-w-[320px] truncate block",children:K})})]})}import{isViewTool as uw}from"@mcp-use/client/react";import{useMemo as Zi,useState as mw}from"react";import{Fragment as fw,jsx as ho,jsxs as Ff}from"react/jsx-runtime";function pw({widgetId:e}){let{getWidget:t}=Ho(),o=t(e)?.modelContext;if(!o?.content?.length&&!o?.structuredContent)return null;let r=o.content?.map(s=>s.text).join(" ")??JSON.stringify(o.structuredContent).slice(0,80);return Ff("div",{className:"flex items-center gap-1.5 px-3 py-1.5 text-[11px] text-muted-foreground bg-muted/30 border border-border/40 rounded-md mt-1",children:[ho("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-blue-400 shrink-0"}),ho("span",{className:"font-medium",children:"State synced to model"}),ho("span",{className:"truncate opacity-60 max-w-[300px]",children:r})]})}function el({toolName:e,toolArgs:t,result:n,serverId:o,readResource:r,toolMeta:s,onSendFollowUp:a,modelContextScope:i,llmConfig:c,partialToolArgs:l,cancelled:u}){let f=Zi(()=>`chat-tool-${e}-${Date.now()}-${Math.random().toString(36).substring(2,11)}`,[e]),[d,g]=mw("inline"),m=Zi(()=>{if(!n)return null;if(typeof n=="string")try{return JSON.parse(n)}catch{return n}return n},[n]),v=uw(s),p=v?s?.ui?.resourceUri??null:null,x=Zi(()=>t,[e,m]),C=Zi(()=>m,[e,m]);return v&&p&&o&&r?Ff(fw,{children:[ho(is,{serverId:o,viewId:f,toolName:e,resourceUri:p,toolInput:x,toolOutput:C,toolMetadata:s,readResource:r,displayMode:d,onDisplayModeChange:g,onSendFollowUp:a,modelContextScope:i,llmConfig:c,partialToolInput:l,cancelled:u,noWrapper:!0,className:"my-4"}),ho(pw,{widgetId:f})]}):v&&!p?ho("div",{className:"flex items-center justify-center w-full h-[200px] rounded border",children:ho(hn,{className:"size-5"})}):v&&(!o||!r)?ho("div",{className:"my-4 p-4 bg-red-50/30 dark:bg-red-950/20 border border-red-200/50 dark:border-red-800/50 rounded-lg",children:ho("p",{className:"text-sm text-red-600 dark:text-red-400",children:"Cannot render widget: Missing required props (serverId or readResource)"})}):null}import{ViewRenderer as pU,isViewTool as fU,getViewResourceUri as gU}from"@mcp-use/client/react";import{createContext as gw,use as hw,useCallback as Rn,useState as vw}from"react";import{jsx as yw}from"react/jsx-runtime";var $f=gw(void 0);function bw({children:e}){let t=typeof window<"u"?window.__MANUFACT_CHAT_URL__:void 0,n=typeof import.meta<"u"?import.meta.env?.VITE_MANUFACT_CHAT_URL:void 0,o=t?.trim()||n?.trim()||"https://cloud.manufact.com/api/v1/inspector/chat/stream",[r,s]=vw({selectedServerId:null,activeTab:"tools",selectedToolName:null,selectedPromptName:null,selectedResourceUri:null,selectedSamplingRequestId:null,selectedElicitationRequestId:null,tunnelUrl:null,isTunnelStarting:!1,isEmbedded:!1,embeddedConfig:{chatApiUrl:o,chatStreamProtocol:"data-stream",chatEnableFreeTierUpgrade:!0}}),a=Rn(b=>{s(h=>({...h,selectedServerId:b}))},[]),i=Rn(b=>{s(h=>({...h,activeTab:b}))},[]),c=Rn(b=>{s(h=>({...h,selectedToolName:b}))},[]),l=Rn(b=>{s(h=>({...h,selectedPromptName:b}))},[]),u=Rn(b=>{s(h=>({...h,selectedResourceUri:b}))},[]),f=Rn(b=>{s(h=>({...h,selectedSamplingRequestId:b}))},[]),d=Rn(b=>{s(h=>({...h,selectedElicitationRequestId:b}))},[]),g=Rn(b=>{s(h=>({...h,tunnelUrl:b}))},[]),m=Rn(b=>{s(h=>({...h,isTunnelStarting:b}))},[]),v=Rn((b,h={})=>{s(y=>({...y,isEmbedded:b,embeddedConfig:{...h,chatApiUrl:h.chatApiUrl?.trim()||o,chatStreamProtocol:h.chatStreamProtocol??"data-stream",chatEnableFreeTierUpgrade:h.chatEnableFreeTierUpgrade??!0}}))},[o]),p=Rn((b,h,y)=>{console.warn("[InspectorContext] navigateToItem called:",{serverId:b,tab:h,itemIdentifier:y}),s(R=>({...R,selectedServerId:b,activeTab:h,selectedToolName:h==="tools"&&y||null,selectedPromptName:h==="prompts"&&y||null,selectedResourceUri:h==="resources"&&y||null,selectedSamplingRequestId:h==="sampling"&&y||null,selectedElicitationRequestId:h==="elicitation"&&y||null}))},[]),x=Rn(()=>{s(b=>({...b,selectedToolName:null,selectedPromptName:null,selectedResourceUri:null,selectedSamplingRequestId:null,selectedElicitationRequestId:null}))},[]),C={...r,setSelectedServerId:a,setActiveTab:i,setSelectedToolName:c,setSelectedPromptName:l,setSelectedResourceUri:u,setSelectedSamplingRequestId:f,setSelectedElicitationRequestId:d,setTunnelUrl:g,setIsTunnelStarting:m,setEmbeddedMode:v,navigateToItem:p,clearSelection:x};return yw($f,{value:C,children:e})}function vo(){let e=hw($f);if(!e)throw new Error("useInspector must be used within InspectorProvider");return e}import{GripVerticalIcon as xw}from"lucide-react";import*as Rr from"react-resizable-panels";import{jsx as ua}from"react/jsx-runtime";var{usePanelRef:Pr}=Rr;function Wo({className:e,...t}){return ua(Rr.Group,{"data-slot":"resizable-panel-group",className:w("flex h-full w-full aria-[orientation=vertical]:flex-col",e),...t})}function vn({...e}){return ua(Rr.Panel,{"data-slot":"resizable-panel",...e})}function Ko({withHandle:e,className:t,...n}){return ua(Rr.Separator,{"data-slot":"resizable-handle",className:w("relative z-50 box-content shrink-0","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1","before:pointer-events-none before:absolute before:bg-zinc-200 before:transition-[height,width,background-color] before:duration-200 before:ease-out dark:before:bg-zinc-700","hover:before:bg-foreground/35 dark:hover:before:bg-foreground/45","aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:py-1.5 aria-[orientation=horizontal]:-my-1.5","aria-[orientation=horizontal]:before:inset-x-0 aria-[orientation=horizontal]:before:top-1.5 aria-[orientation=horizontal]:before:h-px","hover:aria-[orientation=horizontal]:before:h-0.5","aria-[orientation=vertical]:h-full aria-[orientation=vertical]:w-px aria-[orientation=vertical]:px-1.5 aria-[orientation=vertical]:-mx-1.5","aria-[orientation=vertical]:before:inset-y-0 aria-[orientation=vertical]:before:left-1.5 aria-[orientation=vertical]:before:w-px","hover:aria-[orientation=vertical]:before:w-0.5","[&[aria-orientation=horizontal]>div]:rotate-90",t),...n,children:e&&ua("div",{className:"pointer-events-none absolute top-1/2 left-1/2 z-10 flex h-4 w-3 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-xs border border-zinc-200 bg-background shadow-sm dark:border-zinc-700",children:ua(xw,{className:"size-2.5 text-muted-foreground"})})})}import{AnimatePresence as rC,motion as dd}from"motion/react";import{ChevronLeft as sC,Database as eg,Wrench as tg}from"lucide-react";import{useCallback as yn,useEffect as ng,useMemo as og,useRef as sl,useState as Mn}from"react";import{useState as ww}from"react";import{jsx as Vf}from"react/jsx-runtime";function no({className:e,scrollRef:t,children:n}){let[o,r]=ww(!1);return Vf("div",{ref:t,className:w("h-full overflow-y-auto overscroll-none",e),onScroll:s=>r(s.currentTarget.scrollTop>0),children:Vf("div",{className:"flex min-h-full flex-col",children:n(o)})})}import{jsx as ma,jsxs as jf}from"react/jsx-runtime";function $n({id:e,isSelected:t,isFocused:n,title:o,description:r,metadata:s,onClick:a,className:i,"data-testid":c}){return ma("button",{id:e,"data-testid":c,type:"button",onClick:a,className:w("w-full text-left cursor-pointer p-2 sm:p-4 border-b dark:border-zinc-700 hover:bg-gray-50 dark:hover:bg-zinc-800/50 transition-colors group",t&&"bg-zinc-50 dark:bg-zinc-800 border-l-4 border-l-zinc-500",n&&"ring-2 ring-zinc-500 dark:ring-zinc-400 ring-inset",i),children:jf("div",{className:"flex items-start gap-2 sm:gap-3",children:[jf("div",{className:"flex-1 min-w-0",children:[ma("div",{className:"flex items-center gap-2 mb-1",children:ma("h3",{className:w("font-medium truncate font-mono text-sm"),children:o})}),r&&ma("p",{className:"text-sm text-gray-600 dark:text-gray-400 line-clamp-2",children:r})]}),s&&ma("div",{className:"flex-shrink-0 flex items-center self-center",children:s})]})})}import{forwardRef as Cw}from"react";import{cva as Nw}from"class-variance-authority";import{jsx as tl}from"react/jsx-runtime";var kw={gray:"#a3a3a3",red:"#ef4444",orange:"#f97316",amber:"#f59e0b",yellow:"#eab308",lime:"#84cc16",green:"#22c55e",emerald:"#10b981",teal:"#14b8a6",cyan:"#06b6d4",blue:"#3b82f6",indigo:"#6366f1",violet:"#8b5cf6",purple:"#a855f7",fuchsia:"#d946ef",pink:"#ec4899",rose:"#f43f5e"},Sw=Nw("inline-flex items-center font-medium whitespace-nowrap",{variants:{variant:{solid:"",outline:"border border-border text-foreground"},size:{sm:"h-5 px-2 text-[11px] gap-1",md:"h-6 px-2.5 text-[12px] gap-1.5",lg:"h-7 px-3 text-[13px] gap-1.5"}},defaultVariants:{variant:"solid",size:"md"}}),qf={default:{variant:"solid",color:"blue"},secondary:{variant:"solid",color:"green"},destructive:{variant:"solid",color:"red"},outline:{variant:"outline",color:"gray"}};function Tw(e){return typeof e=="string"||typeof e=="number"}function Rw({children:e}){return Tw(e)?tl("span",{className:"[text-box:trim-both_cap_alphabetic]",children:e}):tl("span",{className:"inline-flex items-center gap-1",children:e})}var Kt=Cw(({className:e,variant:t="solid",size:n="md",color:o,children:r,style:s,...a},i)=>{let c=t&&t in qf?qf[t]:null,l=c?.variant??t,u=o??c?.color??"gray",f=vt(),d=kw[u],m=l==="solid"?u==="gray"?{backgroundColor:"var(--accent)",color:"var(--foreground)"}:{color:"var(--foreground)",backgroundColor:`color-mix(in srgb, ${d} 15%, var(--background))`}:{};return tl("span",{ref:i,className:w(Sw({variant:l,size:n}),f.item,e),style:{...m,...s},...a,children:tl(Rw,{children:r})})});Kt.displayName="Badge";import{RefreshCw as Mw,Search as Iw}from"lucide-react";import{jsx as Pw}from"react/jsx-runtime";function fs({className:e,...t}){return Pw("kbd",{"data-slot":"kbd",className:w("bg-muted text-muted-foreground pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium select-none","[&_svg:not([class*='size-'])]:size-3","[[data-slot=tooltip-content]_&]:bg-background/20 [[data-slot=tooltip-content]_&]:text-background dark:[[data-slot=tooltip-content]_&]:bg-background/10",e),...t})}import{Fragment as Wf,jsx as an,jsxs as bo}from"react/jsx-runtime";var Ew="h-3.5 w-3.5 shrink-0 text-muted-foreground";function Mr({activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabTitle:o,secondaryTabTitle:r,primaryCount:s,secondaryCount:a,secondaryIcon:i,primaryIcon:c,searchPlaceholder:l="Search...",onSearchExpand:u,onSearchChange:f,onSearchBlur:d,onTabSwitch:g,searchInputRef:m,primaryTabName:v,onRefresh:p,isRefreshing:x=!1,isScrolled:C=!1}){let b=e===v,h=b?c:i,y=b?o:r;return bo("div",{className:`flex flex-row items-center justify-between gap-2 ${yi(C)} ${Io}`,children:[an("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:t?an(Ge,{ref:m,placeholder:l,value:n,onChange:R=>f(R.target.value),onBlur:d,className:"h-8 border-gray-300 dark:border-zinc-600"}):bo(Wf,{children:[bo("h2",{className:`${Eo} flex items-center gap-1.5`,children:[an(h,{className:Ew,"aria-hidden":!0}),y]}),b&&bo(Wf,{children:[an(Kt,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:s}),bo(Re,{children:[an(Se,{render:an(A,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:an(Iw,{className:"h-4 w-4"})}),nativeButton:!0}),bo(Te,{side:"bottom",className:"flex gap-2",children:["Search",an(fs,{children:"F"})]})]}),p&&bo(Re,{children:[an(Se,{render:an(A,{variant:"ghost",size:"sm",onClick:p,disabled:x,className:"h-8 w-8 p-0",children:an(Mw,{className:`h-4 w-4 ${x?"animate-spin":""}`})}),nativeButton:!0}),bo(Te,{side:"bottom",className:"flex gap-2",children:["Refresh list",an(fs,{children:"R"})]})]})]})]})}),bo(A,{variant:"ghost",size:"sm",onClick:g,className:"gap-2 flex-shrink-0",children:[an("span",{className:"hidden sm:inline",children:b?r:o}),b&&a>0&&an(Kt,{className:"bg-purple-500/20 text-purple-600 dark:text-purple-400 border-transparent",variant:"outline",children:a})]})]})}import{RefreshCw as Aw,Search as Lw}from"lucide-react";import{Fragment as Dw,jsx as Ut,jsxs as Jo}from"react/jsx-runtime";function nl({title:e,count:t,icon:n,isSearchExpanded:o,searchQuery:r,searchPlaceholder:s,onSearchExpand:a,onSearchChange:i,onSearchBlur:c,searchInputRef:l,titleTestId:u,bulkAction:f,onRefresh:d,isRefreshing:g=!1,isScrolled:m=!1}){let v=f?.icon;return Jo("div",{className:`flex flex-row items-center justify-between gap-2 ${yi(m)} ${Io}`,children:[Ut("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:o?Ut(Ge,{ref:l,placeholder:s,value:r,onChange:x=>i(x.target.value),onBlur:c,className:"h-8 border-gray-300 dark:border-zinc-600"}):Jo(Dw,{children:[Jo("h2",{className:`${Eo} flex items-center gap-1.5`,"data-testid":u,children:[n?Ut(n,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}):null,e]}),Ut(Kt,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:t}),Jo(Re,{children:[Ut(Se,{render:Ut(A,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:Ut(Lw,{className:"h-4 w-4"})}),nativeButton:!0}),Jo(Te,{side:"bottom",className:"flex gap-2",children:["Search",Ut(fs,{children:"F"})]})]}),d&&Jo(Re,{children:[Ut(Se,{render:Ut(A,{variant:"ghost",size:"sm",onClick:d,disabled:g,className:"h-8 w-8 p-0",children:Ut(Aw,{className:`h-4 w-4 ${g?"animate-spin":""}`})}),nativeButton:!0}),Jo(Te,{side:"bottom",className:"flex gap-2",children:["Refresh list",Ut(fs,{children:"R"})]})]})]})}),f&&v&&Ut("div",{className:"flex items-center gap-2",children:Jo(Re,{children:[Ut(Se,{render:Ut(A,{variant:"ghost",size:"sm",onClick:f.onClick,disabled:f.disabled,className:"h-8 w-8 p-0",children:Ut(v,{className:"h-4 w-4"})}),nativeButton:!0}),Ut(Te,{side:"bottom",children:f.label})]})})]})}import{Database as _w,Trash2 as Ow}from"lucide-react";import{jsx as bn,jsxs as Yc}from"react/jsx-runtime";function Xc({savedRequests:e,selectedRequest:t,onLoadRequest:n,onDeleteRequest:o,focusedIndex:r}){if(e.length===0)return Yc("div",{className:"flex flex-1 flex-col items-center justify-center p-4 text-center",children:[bn(_w,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),bn("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"No saved requests yet"}),bn("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Execute a tool and click Save to store requests"})]});let s=(a,i)=>{a.stopPropagation(),i()};return bn("div",{children:e.map((a,i)=>Yc("div",{className:"relative group",children:[bn($n,{id:`saved-${a.id}`,isSelected:t?.id===a.id,isFocused:r===i,title:a.name,description:a.toolName,metadata:bn("div",{className:"flex flex-col gap-1",children:bn("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:new Date(a.savedAt).toLocaleString()})}),onClick:()=>n(a)}),bn("div",{className:"absolute top-1/2 right-2 -translate-y-1/2 opacity-0 group-hover:opacity-100 transition-opacity z-10",children:Yc(Re,{children:[bn(Se,{render:bn(A,{variant:"secondary",size:"sm",onClick:c=>s(c,()=>o(a.id)),className:"h-8 w-8 p-0",children:bn(Ow,{className:"h-4 w-4"})}),nativeButton:!0}),bn(Te,{children:bn("p",{children:"Delete saved request"})})]})})]},a.id))})}import{Save as zw}from"lucide-react";import{jsx as gs,jsxs as pa}from"react/jsx-runtime";function Qc({isOpen:e,requestName:t,defaultPlaceholder:n,onRequestNameChange:o,onSave:r,onCancel:s}){return e?gs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:s,children:pa("div",{className:"bg-white dark:bg-zinc-800 rounded-lg p-6 w-[400px] shadow-xl border border-gray-200 dark:border-zinc-700",onClick:a=>a.stopPropagation(),children:[gs("h3",{className:"text-lg font-semibold mb-4 text-gray-900 dark:text-gray-100",children:"Save Request"}),pa("div",{className:"space-y-4",children:[pa("div",{children:[gs(tt,{htmlFor:"request-name",children:"Request Name (optional)"}),gs(Ge,{id:"request-name",value:t,onChange:a=>o(a.target.value),placeholder:n,className:"mt-2",onKeyDown:a=>{a.key==="Enter"&&r()},autoFocus:!0})]}),pa("div",{className:"flex justify-end gap-2",children:[gs(A,{variant:"outline",onClick:s,children:"Cancel"}),pa(A,{onClick:r,children:[gs(zw,{className:"h-4 w-4 mr-2"}),"Save"]})]})]})]})}):null}import{Check as Bw,ChevronDown as Hw,ChevronUp as Uw,Code as Fw,Copy as $w,Play as Vw,Save as jw,X as qw}from"lucide-react";import{useEffect as Kf,useRef as Ww,useState as fa}from"react";import{Fragment as hs,jsx as Ce,jsxs as kt}from"react/jsx-runtime";function Zc({selectedTool:e,toolArgs:t,payloadToSend:n,isExecuting:o,isConnected:r,onArgChange:s,onExecute:a,onSave:i,onCancel:c,onBulkPaste:l,autoFilledFields:u,setFields:f,sendEmptyFields:d,onToggleEmpty:g}){let m="hidden @[700px]/tool-exec:inline",v="hidden @[700px]/tool-exec:inline shrink-0 text-[10px] leading-none border border-current/30 p-1 rounded-full",p="@max-[699px]/tool-exec:size-8 @max-[699px]/tool-exec:min-w-8 @max-[699px]/tool-exec:shrink-0 @max-[699px]/tool-exec:gap-0 @max-[699px]/tool-exec:rounded-full @max-[699px]/tool-exec:!px-0 @max-[699px]/tool-exec:!py-0",x="@max-[699px]/tool-exec:!pr-0",[C,b]=fa(!1),[h,y]=fa(!1),[R,P]=fa(!1),[S,T]=fa(!1),[M,I]=fa(!1),k=Ww(null);Kf(()=>{if(k.current&&e?.description){let _=k.current,K=parseFloat(getComputedStyle(_).lineHeight),F=_.scrollHeight,Y=Math.round(F/K);I(Y>3),T(!1)}},[e?.description]);let N=async()=>{e&&await Ze(JSON.stringify(e,null,2))},L=async()=>{if(e)try{await Ze(JSON.stringify(n??t,null,2)),P(!0),setTimeout(()=>P(!1),2e3)}catch{}};return Kf(()=>{let _=K=>{if(K.key==="Escape"&&o&&c){K.preventDefault(),c();return}if(K.key!=="Enter")return;let F=K.metaKey||K.ctrlKey,Y=!K.metaKey&&!K.ctrlKey&&!K.altKey&&!K.shiftKey,ee=K.target,$=ee instanceof HTMLInputElement&&ee.dataset.toolArgumentInput==="true";(F||Y&&$)&&e&&!o&&r&&(K.preventDefault(),a())};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[e,o,r,a,c]),e?kt("div",{className:"flex flex-col h-full @container/tool-exec",children:[Ce("div",{className:"shrink-0 p-3 sm:p-5 pt-3 sm:pt-4 pb-2 sm:pb-2 sm:pr-4",children:Ce("div",{children:kt("div",{className:"flex flex-row items-center justify-between mb-0 gap-2",children:[Ce("h3",{className:"text-base sm:text-lg font-semibold","data-testid":"tool-execution-title",children:e.name}),kt("div",{className:"flex gap-2 shrink-0",children:[kt(Re,{children:[Ce(Se,{render:kt(A,{"data-testid":"tool-execution-metadata-button",variant:h?"default":"outline",onClick:()=>y(!h),disabled:o,size:"sm",className:w(ur,p),title:"View tool metadata",children:[Ce(Fw,{}),Ce("span",{className:m,children:"Metadata"})]}),nativeButton:!0}),Ce(Te,{children:Ce("p",{children:"View tool definition metadata"})})]}),kt(Re,{children:[Ce(Se,{render:kt(A,{"data-testid":"tool-execution-copy-payload-button",variant:"outline",onClick:L,disabled:o,size:"sm",className:w(ur,p),title:"Copy payload as JSON",children:[R?Ce(Bw,{className:"text-green-600"}):Ce($w,{}),Ce("span",{className:m,children:R?"Copied!":"Payload"})]}),nativeButton:!0}),Ce(Te,{children:Ce("p",{children:"Copy payload as JSON"})})]}),kt(Re,{children:[Ce(Se,{render:kt(A,{"data-testid":"tool-execution-save-button",variant:"outline",onClick:i,disabled:o,size:"sm",className:w(ur,p),title:"Save request",children:[Ce(jw,{}),Ce("span",{className:m,children:"Save"})]}),nativeButton:!0}),Ce(Te,{children:Ce("p",{children:"Save request"})})]}),o&&c?kt(Re,{open:C?void 0:!1,children:[Ce(Se,{render:Ce("div",{onMouseEnter:()=>b(!0),onMouseLeave:()=>b(!1),className:"relative",children:Ce(A,{"data-testid":"tool-execution-cancel-button",onClick:c,variant:C?"destructive":"default",size:"sm",className:w(Gs,p,x,"transition-all"),children:C?kt(hs,{children:[Ce(qw,{}),Ce("span",{className:m,children:"Cancel"}),Ce("span",{className:v,children:"Esc"})]}):kt(hs,{children:[Ce(hn,{}),Ce("span",{className:m,children:"Executing..."})]})})}),nativeButton:!1}),Ce(Te,{children:Ce("p",{children:"Hover to cancel (or press Esc)"})})]}):Ce(A,{"data-testid":"tool-execution-execute-button",onClick:a,disabled:o||!r,size:"sm",className:w(Gs,p,x),children:o?kt(hs,{children:[Ce(hn,{}),Ce("span",{className:m,children:"Executing..."})]}):kt(hs,{children:[Ce(Vw,{}),Ce("span",{className:m,children:"Execute"}),Ce("span",{className:v,children:"\u2318\u21B5"})]})})]})]})})}),kt("div",{className:"flex-1 overflow-y-auto px-3 sm:px-5 pb-4 pr-3",children:[e.description&&kt("div",{className:"relative mb-6",children:[kt("div",{className:"relative",children:[Ce("p",{ref:k,"data-testid":"tool-execution-description",className:`text-sm text-gray-600 dark:text-gray-400 leading-relaxed transition-all duration-300 ${!S&&M?"line-clamp-3":""}`,children:e.description}),M&&!S&&Ce("div",{className:"absolute bottom-0 left-0 right-0 h-[1.4em] bg-linear-to-t from-white/95 dark:from-black/95 via-white/55 dark:via-black/55 to-transparent pointer-events-none"})]}),M&&Ce("div",{className:"flex justify-end",children:Ce("button",{onClick:()=>T(!S),className:"relative z-10 inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 mt-1 transition-colors",children:S?kt(hs,{children:["Show less",Ce(Uw,{className:"h-3 w-3"})]}):kt(hs,{children:["Show more",Ce(Hw,{className:"h-3 w-3"})]})})})]}),Ce(Ec,{selectedTool:e,toolArgs:t,onArgChange:s,onBulkPaste:l,autoFilledFields:u,setFields:f,sendEmptyFields:d,onToggleEmpty:g})]}),Ce(fn,{open:h,onOpenChange:y,children:kt(rn,{scrollable:!0,className:"max-w-3xl max-h-[80vh]",children:[Ce(Xt,{sticky:!0,children:Ce(qt,{children:"Tool Definition"})}),Ce(zn,{children:Ce(vi,{onCopy:N,children:Ce(xt,{data:e,filename:`tool-definition-${e.name}-${Date.now()}.json`})})})]})})]}):kt("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[Ce("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a tool to get started"}),Ce("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Choose a tool from the list to view its details and execute it"})]})}import{PanelsTopLeft as Kw,Wrench as Jw}from"lucide-react";import{isViewTool as Gw}from"@mcp-use/client/react";import{jsx as yo,jsxs as ol}from"react/jsx-runtime";function ed({tools:e,selectedTool:t,onToolSelect:n,focusedIndex:o}){if(e.length===0)return ol("div",{className:"flex flex-1 flex-col items-center justify-center p-4 text-center",children:[yo(Jw,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),yo("p",{className:"text-gray-500 dark:text-gray-400",children:"No tools available"})]});let r=e.some(s=>s.inputSchema?.properties&&Object.keys(s.inputSchema.properties).length>0);return yo("div",{children:e.map((s,a)=>{let i=s._meta,c=Gw(i)?"mcp-apps":null,l=s.inputSchema?.properties,u=l?Object.keys(l).length:0,f=r&&u>0&&ol(Kt,{variant:"outline",className:"text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400",children:[u," params"]}),g=c==="mcp-apps"||f?ol("div",{className:"flex items-center gap-1.5",children:[c==="mcp-apps"&&ol(Re,{children:[yo(Se,{render:yo("span",{className:"inline-flex",children:yo(Kw,{className:"h-3.5 w-3.5"})}),nativeButton:!1}),yo(Te,{children:yo("p",{children:"UI widget"})})]}),f]}):void 0;return yo($n,{id:`tool-${s.name}`,"data-testid":`tool-item-${s.name}`,isSelected:t?.name===s.name,isFocused:o===a,title:s.name,description:s.description,metadata:g,onClick:()=>n(s)},s.name)})})}import{AlertDialog as Ir}from"@base-ui/react/alert-dialog";import{jsx as Pn,jsxs as Qw}from"react/jsx-runtime";function td({...e}){return Pn(Ir.Root,{"data-slot":"alert-dialog",...e})}function Yw({...e}){return Pn(Ir.Portal,{"data-slot":"alert-dialog-portal",...e})}function Xw({className:e,...t}){return Pn(Ir.Backdrop,{"data-slot":"alert-dialog-overlay",className:w("fixed inset-0 isolate z-50 bg-black/50 duration-100 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...t})}function nd({className:e,size:t="default",...n}){return Qw(Yw,{children:[Pn(Xw,{}),Pn(Ir.Popup,{"data-slot":"alert-dialog-content","data-size":t,className:w("group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-6 rounded-xl bg-popover p-6 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-lg data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...n})]})}function od({className:e,...t}){return Pn("div",{"data-slot":"alert-dialog-header",className:w("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",e),...t})}function rd({className:e,...t}){return Pn("div",{"data-slot":"alert-dialog-footer",className:w("flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",e),...t})}function sd({className:e,...t}){return Pn(Ir.Title,{"data-slot":"alert-dialog-title",className:w("text-lg font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",e),...t})}function ad({className:e,...t}){return Pn(Ir.Description,{"data-slot":"alert-dialog-description",className:w("text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}function id({className:e,...t}){return Pn(A,{"data-slot":"alert-dialog-action",className:w(e),...t})}function ld({className:e,variant:t="outline",size:n="default",...o}){return Pn(Ir.Close,{"data-slot":"alert-dialog-cancel",className:w(e),render:Pn(A,{variant:t,size:n}),...o})}import{useCallback as Zw,useEffect as Jf,useState as eC}from"react";var cd="mcp-inspector-saved-requests";function Gf(){let[e,t]=eC([]);Jf(()=>{try{let o=localStorage.getItem(cd);o&&t(JSON.parse(o))}catch(o){console.error("[useSavedRequests] Failed to load saved requests:",o)}},[]),Jf(()=>{let o=r=>{if(r.key===cd&&r.newValue)try{t(JSON.parse(r.newValue))}catch(s){console.error("[useSavedRequests] Failed to parse saved requests:",s)}};return window.addEventListener("storage",o),()=>window.removeEventListener("storage",o)},[]);let n=Zw(o=>{try{localStorage.setItem(cd,JSON.stringify(o)),t(o)}catch(r){console.error("[useSavedRequests] Failed to save requests:",r)}},[]);return{savedRequests:e,saveSavedRequests:n}}import{useCallback as ga,useMemo as tC,useState as rl}from"react";function Yf(e,t){if(!e)return t;if(!t)return e;let n=e.ui&&typeof e.ui=="object"&&!Array.isArray(e.ui)?e.ui:void 0,o=t.ui&&typeof t.ui=="object"&&!Array.isArray(t.ui)?t.ui:void 0;return{...e,...t,...n||o?{ui:{...n,...o}}:{}}}function Xf({selectedTool:e,payloadToSend:t,toolArgs:n,callTool:o,readResource:r,serverId:s}){let[a,i]=rl([]),[c,l]=rl(!1),[u,f]=rl(null),[d,g]=rl(null),m=ga(async()=>{if(!e||c)return;let h=new AbortController;g(h),l(!0);let y=Date.now();try{let R=t,P=e?._meta||e?.metadata,T=P?.ui?.resourceUri;if(T&&typeof T=="string"){try{await r(T)}catch{}i([{toolName:e.name,args:R,result:null,timestamp:y,duration:0,toolMeta:P}])}let M=await o(e.name,R,{timeout:6e5,resetTimeoutOnProgress:!0,signal:h.signal}),I=Date.now()-y,k=Yf(P,M?._meta);It(new Vs({toolName:e.name,serverId:s,success:!0,duration:I})).catch(()=>{}),window.dispatchEvent(new Event("mcp-tool-executed")),i(T&&typeof T=="string"?N=>N.map((L,_)=>_===0?{...L,result:M,duration:I,toolMeta:k}:L):N=>[{toolName:e.name,args:n,result:M,timestamp:y,duration:I,toolMeta:k},...N])}catch(R){let P=Date.now()-y;It(new Vs({toolName:e.name,serverId:s,success:!1,duration:P,error:R instanceof Error?R.message:String(R)})).catch(()=>{}),window.dispatchEvent(new Event("mcp-tool-executed"));let S=e?._meta||e?.metadata,T={toolName:e.name,args:n,result:null,error:R instanceof Error?R.message:String(R),timestamp:y,duration:P,toolMeta:S},M=S?.ui?.resourceUri;i(M?[T]:I=>[T,...I])}finally{l(!1)}},[e,t,n,c,o,r,s]),v=ga(async(h,y)=>{try{await Ze(y),f(h),setTimeout(()=>f(null),2e3)}catch(R){console.error("[ToolsTab] Failed to copy result:",R)}},[]),p=ga(h=>{i(y=>y.filter((R,P)=>P!==h))},[]),x=tC(()=>e?a.filter(h=>h.toolName===e.name):[],[a,e]),C=ga(h=>{let y=x[h];if(!y)return;let R=window.open("","_blank","width=800,height=600");R&&(R.document.write(`
103
103
  <html>
104
104
  <head><title>${y.toolName} Result</title></head>
105
105
  <body><pre>${JSON.stringify(y.result,null,2)}</pre></body>
@@ -223,4 +223,4 @@ ${Le.join(`
223
223
 
224
224
  ---
225
225
 
226
- `),pe},[Xr,lm]),$v=$e(()=>{let z=ai(U);Ze(z).then(()=>Ls.success("Chat copied to clipboard"),()=>Ls.error("Failed to copy chat"))},[U,ai]),Vv=$e(z=>{let fe=`chat-export-${new Date().toISOString().split("T")[0]}`;if(z==="json"){let dt=U.map(Le=>({id:Le.id,role:Le.role,content:Xr(Le),timestamp:Le.timestamp,toolInvocations:Le.parts?.filter(De=>De.type==="tool-invocation"&&De.toolInvocation).map(De=>({toolName:De.toolInvocation.toolName,args:De.toolInvocation.args,result:De.toolInvocation.result}))}));Ki(dt,fe+".json")}else{let dt=ai(U),Le=new Blob([dt],{type:"text/markdown"}),De=URL.createObjectURL(Le),Qe=document.createElement("a");Qe.href=De,Qe.download=fe+".md",document.body.appendChild(Qe),Qe.click(),document.body.removeChild(Qe),setTimeout(()=>URL.revokeObjectURL(De),100)}Ls.success(`Chat exported as ${z.toUpperCase()}`)},[U,ai,Xr]),fm=$e(()=>{Ot(),zs()},[Ot,zs]),jv=$e(z=>{z.trim()&&(!ft||!t||(Gr(),Xe(z,[]).then(()=>{jt("mcp-inspector:chat:message_sent",{message:z,source:"quick_question"})})))},[jt,Xe,ft,t,Gr]),qv=$e(z=>{z.trim()&&(!ft||!t||Xe(z,[]).then(()=>{jt("mcp-inspector:chat:message_sent",{message:z,source:"followup"})}))},[jt,Xe,ft,t]),gm=co&&!(g&&co.kind==="login_required")?gt(wv,{notice:co,onConfigureApiKey:Bv,onSignIn:co.kind==="login_required"?c?Qu:()=>{window.location.href=co.loginUrl}:void 0,authorizing:Uv}):null;return ft&&U.length===0?cm(lr("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[gt("div",{className:"absolute top-4 right-4 z-10",children:gt(Aa,{open:ge,onOpenChange:me,tempProvider:B,tempModel:Oe,tempApiKey:$t,tempBaseUrl:lt,onProviderChange:Ie,onModelChange:Ae,onApiKeyChange:Ee,onBaseUrlChange:Vt,onSave:Gu,onClear:fm,showClearButton:!!O,buttonLabel:"Change API Key",hostedInspector:g,freeTierInfo:ni,managedCloudInfo:Yr,useManagedCloud:Wr,onSaveManagedCloud:Yr?om:void 0})}),gt(Nu,{serverDisplayName:Oi(e),composerNotice:gm,inputValue:j,isConnected:t&&!co&&!Bs,isLoading:ve,textareaRef:pt,llmConfig:ft,promptsDropdownOpen:ye,promptFocusedIndex:ie,prompts:uo,selectedPrompt:rm,promptResults:Hs,attachments:nt,tools:y?void 0:Yt,disabledTools:y?void 0:ht,onDisabledToolsChange:y?void 0:Ct,onDeletePromptResult:am,onPromptSelect:ri,onInputChange:D,onKeyDown:mm,onKeyUp:pm,onClick:Zr,onSendMessage:si,onStopStreaming:Nn,onConfigDialogOpenChange:me,onAttachmentAdd:Gn,onAttachmentRemove:Jr,hideModelBadge:em,freeTierInfo:ni,managedCloudInfo:Yr,modelBadgeMode:tm,modelDisplayName:nm,quickQuestions:Je,onQuickQuestionSelect:jv,pendingElicitationRequests:e.pendingElicitationRequests,onApproveElicitation:e.approveElicitation,onRejectElicitation:e.rejectElicitation,systemPromptProvider:re}),Yu]})):cm(lr("div",{className:"relative flex min-h-0 flex-1 flex-col overflow-hidden",children:[gt(fu,{llmConfig:ft,hasMessages:U.length>0,configDialogOpen:ge,onConfigDialogOpenChange:me,onClearChat:de?zs:Za,tempProvider:B,tempModel:Oe,tempApiKey:$t,tempBaseUrl:lt,onProviderChange:Ie,onModelChange:Ae,onApiKeyChange:Ee,onBaseUrlChange:Vt,onSaveConfig:Gu,onClearConfig:fm,showClearButton:!!O,hideConfigButton:Zu,hostedInspector:g,freeTierInfo:ni,managedCloudInfo:Yr,useManagedCloud:Wr,onSaveManagedCloud:Yr?om:void 0,onCopyChat:$v,onExportChat:Vv,clearButtonLabel:m,hideTitle:v,clearButtonHideIcon:x,clearButtonHideShortcut:C,clearButtonVariant:b,hideClearButton:h,activeChatId:ae,chatTitle:Ov,showViewToggle:!!ft,viewIndex:mn==="raw"?1:0,onViewIndexChange:z=>Ro(z===1?"raw":"conv"),elevatedHeader:Q}),lr("div",{className:"relative flex min-h-0 flex-1 flex-col overflow-hidden",children:[gt(dv,{visible:Ev&&!!ft}),gt("div",{ref:Dt,"data-testid":"chat-messages-scroll-container",className:"min-h-0 flex-1 overflow-y-auto overscroll-contain p-2 sm:p-4 pt-[80px] sm:pt-[100px]",children:ft?mn==="conv"?gt(Va,{messages:U,isLoading:ve,serverId:e.url,readResource:i,tools:e.tools,sendMessage:Rv,modelContextScope:Kr,llmConfig:ft,serverBaseUrl:e.url,messagesEndRef:Mv,traceEvents:Wu}):gt(Cv,{events:Wu,usage:Tv}):gt(ku,{onConfigureClick:()=>me(!0)})}),ft&&gt(cv,{visible:Iv,onClick:()=>Av("smooth")})]}),ft&&lr("div",{className:"relative shrink-0","data-chat-composer":!0,children:[gt(vv,{messages:U,isLoading:ve}),gm,gt(Ha,{variant:V?"fullscreen":"default",inputValue:j,isConnected:t&&!co&&!Bs,isLoading:ve,textareaRef:pt,llmConfig:ft,promptsDropdownOpen:ye,promptFocusedIndex:ie,prompts:uo,promptResults:Hs,selectedPrompt:rm,attachments:nt,tools:y?void 0:Yt,disabledTools:y?void 0:ht,onDisabledToolsChange:y?void 0:Ct,onDeletePromptResult:am,onPromptSelect:ri,onInputChange:D,onKeyDown:mm,onKeyUp:pm,onClick:Zr,onSendMessage:si,onStopStreaming:Nn,onConfigDialogOpenChange:me,onAttachmentAdd:Gn,onAttachmentRemove:Jr,hideModelBadge:em,freeTierInfo:ni,managedCloudInfo:Yr,modelBadgeMode:tm,modelDisplayName:nm,followups:Gt,onFollowupSelect:qv,pendingElicitationRequests:e.pendingElicitationRequests,onApproveElicitation:e.approveElicitation,onRejectElicitation:e.rejectElicitation,systemPromptProvider:re})]}),Yu]}))}function eR(e){if(!e.length)return[];let t=[...e].sort((a,i)=>new Date(a.createdAt).getTime()-new Date(i.createdAt).getTime()),n=[],o=null,r=new Map,s=()=>{if(!o)return;let a=(o.parts?.length??0)>0,i=typeof o.content=="string"&&o.content.trim()!=="";(a||i)&&n.push(o),o=null,r.clear()};for(let a of t){let i=new Date(a.createdAt).getTime();if(a.type==="user_message"){s();let l=a.eventData?.content?.text||"";n.push({id:a.id,role:"user",content:l,timestamp:i});continue}if(a.type==="tool_call"){let l=a.eventData?.content??{},u=typeof l.toolCallId=="string"?l.toolCallId:a.id;o||(o={id:`assistant-${a.id}`,role:"assistant",content:"",timestamp:i,parts:[]});let f=o.parts.length;o.parts.push({type:"tool-invocation",toolInvocation:{toolName:String(l.toolName??"unknown"),args:l.args??{},state:"pending"}}),r.set(u,f);continue}if(a.type==="tool_result"){let l=a.eventData?.content??{},u=typeof l.toolCallId=="string"?l.toolCallId:void 0;if(o&&u!==void 0&&o.parts){let f=r.get(u);if(f!==void 0){let d=o.parts[f];d?.type==="tool-invocation"&&d.toolInvocation&&(d.toolInvocation.result=l.result,d.toolInvocation.state="result")}}continue}if(a.type==="assistant_message"){let l=a.eventData?.content?.text||"";o?(o.id=a.id,o.timestamp=i,o.content=l,l&&(o.parts=o.parts??[],o.parts.push({type:"text",text:l})),s()):n.push({id:a.id,role:"assistant",content:l,timestamp:i,parts:l?[{type:"text",text:l}]:[]});continue}}return s(),n}export{Fy as AddToClientDropdown,_r as CHAT_TITLE_PLACEHOLDER,Zo as CHAT_TITLE_SIMPLE,fu as ChatHeader,Ed as ChatHistoryHeader,$d as ChatHistoryPanel,Vd as ChatHistoryRail,Ha as ChatInputArea,Nu as ChatLandingForm,Hd as ChatList,ZT as ChatTab,Na as ChatTitleReveal,Aa as ConfigurationDialog,ku as ConfigureEmptyState,$r as DEFAULT_CHAT_SYSTEM_PROMPT,bw as InspectorProvider,Sa as LocalChatStorageProvider,Va as MessageList,Sg as PromptsTab,fg as ResourcesTab,mx as ThemeProvider,Ec as ToolInputForm,Qi as ToolResultDisplay,el as ToolResultRenderer,sg as ToolsTab,SU as ViewRenderer,wx as WidgetDebugProvider,Ll as chatBarActionButtonClass,mu as chatBarFrostedPill,pu as chatBarTitleFrostedClass,eR as chatEventsToInspectorMessages,Fm as downloadMcpbFile,Ld as firstUserMessageFromMessages,Dd as generateChatTitleWithLlm,$m as generateClaudeCodeCommand,jm as generateCodexConfig,Bm as generateCursorDeepLink,Vm as generateGeminiCLICommand,Dy as generateMcpbConfig,jP as generatePythonSDKCode,VP as generateTypeScriptSDKCode,Hm as generateVSCodeDeepLink,Um as generateVSCodeInsidersDeepLink,vc as getEnvVarInstructions,Ga as getSystemPromptStorageKey,RU as getViewResourceUri,er as isPlaceholderTitle,TU as isViewTool,Fu as readStoredSystemPrompt,Vu as resolveSystemPrompt,Ud as useChatHistory,Ou as useChatMessages,Bu as useChatMessagesClientSide,qd as useChatTitleGeneration,va as useConfig,vo as useInspector,Ca as useMCPPrompts,$u as writeStoredSystemPrompt};
226
+ `),pe},[Xr,lm]),$v=$e(()=>{let z=ai(U);Ze(z).then(()=>Ls.success("Chat copied to clipboard"),()=>Ls.error("Failed to copy chat"))},[U,ai]),Vv=$e(z=>{let fe=`chat-export-${new Date().toISOString().split("T")[0]}`;if(z==="json"){let dt=U.map(Le=>({id:Le.id,role:Le.role,content:Xr(Le),timestamp:Le.timestamp,toolInvocations:Le.parts?.filter(De=>De.type==="tool-invocation"&&De.toolInvocation).map(De=>({toolName:De.toolInvocation.toolName,args:De.toolInvocation.args,result:De.toolInvocation.result}))}));Ki(dt,fe+".json")}else{let dt=ai(U),Le=new Blob([dt],{type:"text/markdown"}),De=URL.createObjectURL(Le),Qe=document.createElement("a");Qe.href=De,Qe.download=fe+".md",document.body.appendChild(Qe),Qe.click(),document.body.removeChild(Qe),setTimeout(()=>URL.revokeObjectURL(De),100)}Ls.success(`Chat exported as ${z.toUpperCase()}`)},[U,ai,Xr]),fm=$e(()=>{Ot(),zs()},[Ot,zs]),jv=$e(z=>{z.trim()&&(!ft||!t||(Gr(),Xe(z,[]).then(()=>{jt("mcp-inspector:chat:message_sent",{message:z,source:"quick_question"})})))},[jt,Xe,ft,t,Gr]),qv=$e(z=>{z.trim()&&(!ft||!t||Xe(z,[]).then(()=>{jt("mcp-inspector:chat:message_sent",{message:z,source:"followup"})}))},[jt,Xe,ft,t]),gm=co&&!(g&&co.kind==="login_required")?gt(wv,{notice:co,onConfigureApiKey:Bv,onSignIn:co.kind==="login_required"?c?Qu:()=>{window.location.href=co.loginUrl}:void 0,authorizing:Uv}):null;return ft&&U.length===0?cm(lr("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[gt("div",{className:"absolute top-4 right-4 z-10",children:gt(Aa,{open:ge,onOpenChange:me,tempProvider:B,tempModel:Oe,tempApiKey:$t,tempBaseUrl:lt,onProviderChange:Ie,onModelChange:Ae,onApiKeyChange:Ee,onBaseUrlChange:Vt,onSave:Gu,onClear:fm,showClearButton:!!O,buttonLabel:"Change API Key",hostedInspector:g,freeTierInfo:ni,managedCloudInfo:Yr,useManagedCloud:Wr,onSaveManagedCloud:Yr?om:void 0})}),gt(Nu,{serverDisplayName:Oi(e),composerNotice:gm,inputValue:j,isConnected:t&&!co&&!Bs,isLoading:ve,textareaRef:pt,llmConfig:ft,promptsDropdownOpen:ye,promptFocusedIndex:ie,prompts:uo,selectedPrompt:rm,promptResults:Hs,attachments:nt,tools:y?void 0:Yt,disabledTools:y?void 0:ht,onDisabledToolsChange:y?void 0:Ct,onDeletePromptResult:am,onPromptSelect:ri,onInputChange:D,onKeyDown:mm,onKeyUp:pm,onClick:Zr,onSendMessage:si,onStopStreaming:Nn,onConfigDialogOpenChange:me,onAttachmentAdd:Gn,onAttachmentRemove:Jr,hideModelBadge:em,freeTierInfo:ni,managedCloudInfo:Yr,modelBadgeMode:tm,modelDisplayName:nm,quickQuestions:Je,onQuickQuestionSelect:jv,pendingElicitationRequests:e.pendingElicitationRequests,onApproveElicitation:e.approveElicitation,onRejectElicitation:e.rejectElicitation,systemPromptProvider:re}),Yu]})):cm(lr("div",{className:"relative flex min-h-0 flex-1 flex-col overflow-hidden",children:[gt(fu,{llmConfig:ft,hasMessages:U.length>0,configDialogOpen:ge,onConfigDialogOpenChange:me,onClearChat:de?zs:Za,tempProvider:B,tempModel:Oe,tempApiKey:$t,tempBaseUrl:lt,onProviderChange:Ie,onModelChange:Ae,onApiKeyChange:Ee,onBaseUrlChange:Vt,onSaveConfig:Gu,onClearConfig:fm,showClearButton:!!O,hideConfigButton:Zu,hostedInspector:g,freeTierInfo:ni,managedCloudInfo:Yr,useManagedCloud:Wr,onSaveManagedCloud:Yr?om:void 0,onCopyChat:$v,onExportChat:Vv,clearButtonLabel:m,hideTitle:v,clearButtonHideIcon:x,clearButtonHideShortcut:C,clearButtonVariant:b,hideClearButton:h,activeChatId:ae,chatTitle:Ov,showViewToggle:!!ft,viewIndex:mn==="raw"?1:0,onViewIndexChange:z=>Ro(z===1?"raw":"conv"),elevatedHeader:Q}),lr("div",{className:"relative flex min-h-0 flex-1 flex-col overflow-hidden",children:[gt(dv,{visible:Ev&&!!ft}),gt("div",{ref:Dt,"data-testid":"chat-messages-scroll-container",className:"min-h-0 flex-1 overflow-y-auto overscroll-contain p-2 sm:p-4 pt-[80px] sm:pt-[100px]",children:ft?mn==="conv"?gt(Va,{messages:U,isLoading:ve,serverId:e.url,readResource:i,tools:e.tools,sendMessage:Rv,modelContextScope:Kr,llmConfig:ft,serverBaseUrl:e.url,messagesEndRef:Mv,traceEvents:Wu}):gt(Cv,{events:Wu,usage:Tv}):gt(ku,{onConfigureClick:()=>me(!0)})}),ft&&gt(cv,{visible:Iv,onClick:()=>Av("smooth")})]}),ft&&lr("div",{className:"relative shrink-0","data-chat-composer":!0,children:[gt(vv,{messages:U,isLoading:ve}),gm,gt(Ha,{variant:V?"fullscreen":"default",inputValue:j,isConnected:t&&!co&&!Bs,isLoading:ve,textareaRef:pt,llmConfig:ft,promptsDropdownOpen:ye,promptFocusedIndex:ie,prompts:uo,promptResults:Hs,selectedPrompt:rm,attachments:nt,tools:y?void 0:Yt,disabledTools:y?void 0:ht,onDisabledToolsChange:y?void 0:Ct,onDeletePromptResult:am,onPromptSelect:ri,onInputChange:D,onKeyDown:mm,onKeyUp:pm,onClick:Zr,onSendMessage:si,onStopStreaming:Nn,onConfigDialogOpenChange:me,onAttachmentAdd:Gn,onAttachmentRemove:Jr,hideModelBadge:em,freeTierInfo:ni,managedCloudInfo:Yr,modelBadgeMode:tm,modelDisplayName:nm,followups:Gt,onFollowupSelect:qv,pendingElicitationRequests:e.pendingElicitationRequests,onApproveElicitation:e.approveElicitation,onRejectElicitation:e.rejectElicitation,systemPromptProvider:re})]}),Yu]}))}function eR(e){if(!e.length)return[];let t=[...e].sort((a,i)=>new Date(a.createdAt).getTime()-new Date(i.createdAt).getTime()),n=[],o=null,r=new Map,s=()=>{if(!o)return;let a=(o.parts?.length??0)>0,i=typeof o.content=="string"&&o.content.trim()!=="";(a||i)&&n.push(o),o=null,r.clear()};for(let a of t){let i=new Date(a.createdAt).getTime();if(a.type==="user_message"){s();let l=a.eventData?.content?.text||"";n.push({id:a.id,role:"user",content:l,timestamp:i});continue}if(a.type==="tool_call"){let l=a.eventData?.content??{},u=typeof l.toolCallId=="string"?l.toolCallId:a.id;o||(o={id:`assistant-${a.id}`,role:"assistant",content:"",timestamp:i,parts:[]});let f=o.parts.length;o.parts.push({type:"tool-invocation",toolInvocation:{toolName:String(l.toolName??"unknown"),args:l.args??{},state:"pending"}}),r.set(u,f);continue}if(a.type==="tool_result"){let l=a.eventData?.content??{},u=typeof l.toolCallId=="string"?l.toolCallId:void 0;if(o&&u!==void 0&&o.parts){let f=r.get(u);if(f!==void 0){let d=o.parts[f];d?.type==="tool-invocation"&&d.toolInvocation&&(d.toolInvocation.result=l.result,d.toolInvocation.state="result")}}continue}if(a.type==="assistant_message"){let l=a.eventData?.content?.text||"";o?(o.id=a.id,o.timestamp=i,o.content=l,l&&(o.parts=o.parts??[],o.parts.push({type:"text",text:l})),s()):n.push({id:a.id,role:"assistant",content:l,timestamp:i,parts:l?[{type:"text",text:l}]:[]});continue}}return s(),n}export{Fy as AddToClientDropdown,_r as CHAT_TITLE_PLACEHOLDER,Zo as CHAT_TITLE_SIMPLE,fu as ChatHeader,Ed as ChatHistoryHeader,$d as ChatHistoryPanel,Vd as ChatHistoryRail,Ha as ChatInputArea,Nu as ChatLandingForm,Hd as ChatList,ZT as ChatTab,Na as ChatTitleReveal,Aa as ConfigurationDialog,ku as ConfigureEmptyState,$r as DEFAULT_CHAT_SYSTEM_PROMPT,bw as InspectorProvider,Sa as LocalChatStorageProvider,Va as MessageList,Sg as PromptsTab,fg as ResourcesTab,mx as ThemeProvider,Ec as ToolInputForm,Qi as ToolResultDisplay,el as ToolResultRenderer,sg as ToolsTab,pU as ViewRenderer,wx as WidgetDebugProvider,Ll as chatBarActionButtonClass,mu as chatBarFrostedPill,pu as chatBarTitleFrostedClass,eR as chatEventsToInspectorMessages,Fm as downloadMcpbFile,Ld as firstUserMessageFromMessages,Dd as generateChatTitleWithLlm,$m as generateClaudeCodeCommand,jm as generateCodexConfig,Bm as generateCursorDeepLink,Vm as generateGeminiCLICommand,Dy as generateMcpbConfig,jP as generatePythonSDKCode,VP as generateTypeScriptSDKCode,Hm as generateVSCodeDeepLink,Um as generateVSCodeInsidersDeepLink,vc as getEnvVarInstructions,Ga as getSystemPromptStorageKey,gU as getViewResourceUri,er as isPlaceholderTitle,fU as isViewTool,Fu as readStoredSystemPrompt,Vu as resolveSystemPrompt,Ud as useChatHistory,Ou as useChatMessages,Bu as useChatMessagesClientSide,qd as useChatTitleGeneration,va as useConfig,vo as useInspector,Ca as useMCPPrompts,$u as writeStoredSystemPrompt};