@@ -19,6 +19,10 @@ import ListPane from "./ListPane";
19
19
import JsonView from "./JsonView" ;
20
20
import ToolResults from "./ToolResults" ;
21
21
22
+ // Type guard to safely detect the optional _meta field without using `any`
23
+ const hasMeta = ( tool : Tool ) : tool is Tool & { _meta : unknown } =>
24
+ typeof ( tool as { _meta ?: unknown } ) . _meta !== "undefined" ;
25
+
22
26
const ToolsTab = ( {
23
27
tools,
24
28
listTools,
@@ -246,38 +250,40 @@ const ToolsTab = ({
246
250
</ div >
247
251
</ div >
248
252
) }
249
- { selectedTool && ( selectedTool as any ) . _meta && (
250
- < div className = "bg-gray-50 dark:bg-gray-900 p-3 rounded-lg" >
251
- < div className = "flex items-center justify-between mb-2" >
252
- < h4 className = "text-sm font-semibold" > Meta:</ h4 >
253
- < Button
254
- size = "sm"
255
- variant = "ghost"
256
- onClick = { ( ) => setIsMetaExpanded ( ! isMetaExpanded ) }
257
- className = "h-6 px-2"
253
+ { selectedTool &&
254
+ hasMeta ( selectedTool ) &&
255
+ selectedTool . _meta && (
256
+ < div className = "bg-gray-50 dark:bg-gray-900 p-3 rounded-lg" >
257
+ < div className = "flex items-center justify-between mb-2" >
258
+ < h4 className = "text-sm font-semibold" > Meta:</ h4 >
259
+ < Button
260
+ size = "sm"
261
+ variant = "ghost"
262
+ onClick = { ( ) => setIsMetaExpanded ( ! isMetaExpanded ) }
263
+ className = "h-6 px-2"
264
+ >
265
+ { isMetaExpanded ? (
266
+ < >
267
+ < ChevronUp className = "h-3 w-3 mr-1" />
268
+ Collapse
269
+ </ >
270
+ ) : (
271
+ < >
272
+ < ChevronDown className = "h-3 w-3 mr-1" />
273
+ Expand
274
+ </ >
275
+ ) }
276
+ </ Button >
277
+ </ div >
278
+ < div
279
+ className = { `transition-all ${
280
+ isMetaExpanded ? "" : "max-h-[8rem] overflow-y-auto"
281
+ } `}
258
282
>
259
- { isMetaExpanded ? (
260
- < >
261
- < ChevronUp className = "h-3 w-3 mr-1" />
262
- Collapse
263
- </ >
264
- ) : (
265
- < >
266
- < ChevronDown className = "h-3 w-3 mr-1" />
267
- Expand
268
- </ >
269
- ) }
270
- </ Button >
271
- </ div >
272
- < div
273
- className = { `transition-all ${
274
- isMetaExpanded ? "" : "max-h-[8rem] overflow-y-auto"
275
- } `}
276
- >
277
- < JsonView data = { ( selectedTool as any ) . _meta } />
283
+ < JsonView data = { selectedTool . _meta } />
284
+ </ div >
278
285
</ div >
279
- </ div >
280
- ) }
286
+ ) }
281
287
< Button
282
288
onClick = { async ( ) => {
283
289
try {
0 commit comments