11<script setup lang="ts">
22import type { AgentManifest , InvokeResult } from ' @devframes/plugin-inspect/client'
3- import { onMounted , reactive , ref , shallowRef } from ' vue'
4- import { isStatic , useRpc } from ' ../composables/rpc'
5- import { useRefreshProvider } from ' ../composables/refresh'
3+ import { ref , reactive } from ' vue'
64import JsonView from ' ./JsonView.vue'
75
8- const rpc = useRpc ()
9- const manifest = shallowRef < AgentManifest | null >( null )
10- const expanded = ref < string | null >( null )
11- const argsInput = reactive < Record <string , string >>({})
12- const results = reactive < Record <string , InvokeResult | { ok : false , error : { name : string , message : string } }>>({})
13- const pending = reactive < Record < string , boolean >>({} )
6+ const props = defineProps <{
7+ manifest: AgentManifest | null
8+ isStatic : boolean
9+ results : Record <string , InvokeResult | { ok : false , error : { name : string , message : string } }>
10+ pending : Record <string , boolean >
11+ }>( )
1412
15- async function fetchData(): Promise <void > {
16- if (! rpc .value )
17- return
18- manifest .value = await rpc .value .call (' devframes-plugin-inspect:describe-agent' )
19- }
13+ const emit = defineEmits <{
14+ (e : ' invoke' , id : string , parsedArgs : unknown ): void
15+ (e : ' read' , id : string ): void
16+ }>()
2017
21- useRefreshProvider ( fetchData )
22- onMounted ( fetchData )
18+ const expanded = ref < string | null >( null )
19+ const argsInput = reactive < Record < string , string >>({} )
2320
2421function toggle(id : string ): void {
2522 expanded .value = expanded .value === id ? null : id
@@ -28,38 +25,20 @@ function toggle(id: string): void {
2825 }
2926}
3027
31- async function invokeTool(id : string ) {
32- if (! rpc .value ) return
28+ function invokeTool(id : string ) {
3329 let parsed: unknown
3430 try {
3531 const raw = JSON .parse (argsInput [id ] || ' {}' )
3632 parsed = raw
37- } catch (e ) {
38- results [id ] = { ok: false , error: { name: ' SyntaxError' , message: ` Invalid JSON args: ${(e as Error ).message } ` } }
39- return
40- }
41- pending [id ] = true
42- try {
43- results [id ] = await rpc .value .call (' devframes-plugin-inspect:invoke-agent-tool' , id , parsed )
44- } catch (e ) {
45- const err = e as Error
46- results [id ] = { ok: false , error: { name: err ?.name ?? ' Error' , message: err ?.message ?? String (e ) } }
47- } finally {
48- pending [id ] = false
33+ } catch (err ) {
34+ // Emitting error would be cleaner, for now we will throw to stop execution
35+ throw new Error (` Invalid JSON args: ${(err as Error ).message } ` )
4936 }
37+ emit (' invoke' , id , parsed )
5038}
5139
52- async function readResource(id : string ) {
53- if (! rpc .value ) return
54- pending [id ] = true
55- try {
56- results [id ] = await rpc .value .call (' devframes-plugin-inspect:read-agent-resource' , id )
57- } catch (e ) {
58- const err = e as Error
59- results [id ] = { ok: false , error: { name: err ?.name ?? ' Error' , message: err ?.message ?? String (e ) } }
60- } finally {
61- pending [id ] = false
62- }
40+ function readResource(id : string ) {
41+ emit (' read' , id )
6342}
6443 </script >
6544
@@ -78,7 +57,7 @@ async function readResource(id: string) {
7857 <div v-else class =" cards" >
7958 <div v-for =" tool in manifest.tools" :key =" tool.id" class =" card" >
8059 <div class =" card-head" style =" cursor : pointer ; user-select : none ;" @click =" toggle(tool.id)" >
81- <svg class =" chev" :class =" { open: expanded === tool.id }" width = " 14 " height = " 14 " viewBox = " 0 0 24 24 " fill = " none " stroke = " currentColor " stroke-width = " 2 " >< path d = " m9 18 6-6-6-6 " /></ svg >
60+ <div class =" chev i-ph-caret-right " :class =" { open: expanded === tool.id }" / >
8261 <span class =" card-title" >{{ tool.title }}</span >
8362 <span class =" badge flag" >{{ tool.kind }}</span >
8463 <span class =" badge" :class =" `safety-${tool.safety}`" >{{ tool.safety }}</span >
@@ -106,13 +85,13 @@ async function readResource(id: string) {
10685 <JsonView :value =" tool .examples " :expand-depth =" 1 " />
10786 </template >
10887
109- <div class =" label" >Invoke (JSON object )</div >
88+ <div class =" label" >Invoke (MCP format )</div >
11089 <textarea v-model =" argsInput[tool.id]" class =" args" spellcheck =" false" placeholder =" {}" />
11190 <div style =" margin-top : 8px ; display : flex ; gap : 8px ; align-items : center ;" >
112- <button class =" btn" :disabled =" pending[tool.id] || isStatic() " @click =" invokeTool(tool.id)" >
91+ <button class =" btn" :disabled =" pending[tool.id] || isStatic" @click =" invokeTool(tool.id)" >
11392 {{ pending[tool.id] ? 'Invoking…' : 'Invoke' }}
11493 </button >
115- <span v-if =" isStatic() " class =" note" >read-only static backend</span >
94+ <span v-if =" isStatic" class =" note" >read-only static backend</span >
11695 </div >
11796
11897 <div v-if =" results[tool.id]" class =" result" >
@@ -141,7 +120,7 @@ async function readResource(id: string) {
141120 <div v-else class =" cards" >
142121 <div v-for =" res in manifest.resources" :key =" res.id" class =" card" >
143122 <div class =" card-head" style =" cursor : pointer ; user-select : none ;" @click =" toggle(res.id)" >
144- <svg class =" chev" :class =" { open: expanded === res.id }" width = " 14 " height = " 14 " viewBox = " 0 0 24 24 " fill = " none " stroke = " currentColor " stroke-width = " 2 " >< path d = " m9 18 6-6-6-6 " /></ svg >
123+ <div class =" chev i-ph-caret-right " :class =" { open: expanded === res.id }" / >
145124 <span class =" card-title" >{{ res.name }}</span >
146125 <span v-if =" res.mimeType" class =" badge flag" >{{ res.mimeType }}</span >
147126 </div >
@@ -154,10 +133,10 @@ async function readResource(id: string) {
154133
155134 <template v-if =" expanded === res .id " >
156135 <div style =" margin-top : 8px ; display : flex ; gap : 8px ; align-items : center ;" >
157- <button class =" btn" :disabled =" pending[res.id] || isStatic() " @click =" readResource(res.id)" >
136+ <button class =" btn" :disabled =" pending[res.id] || isStatic" @click =" readResource(res.id)" >
158137 {{ pending[res.id] ? 'Reading…' : 'Read Resource' }}
159138 </button >
160- <span v-if =" isStatic() " class =" note" >read-only static backend</span >
139+ <span v-if =" isStatic" class =" note" >read-only static backend</span >
161140 </div >
162141
163142 <div v-if =" results[res.id]" class =" result" >
0 commit comments