11<script setup lang="ts">
2- import { ref , toRaw } from ' vue'
2+ import { ref , toRaw , computed } from ' vue'
33import { ElicitationTransfer } from ' @/renderer/utils'
4- import type { ElicitRequest , ElicitResult } from ' @modelcontextprotocol/sdk/ types'
4+ import { IpcElicitRequestCallback , ElicitRequest , ElicitResponse } from ' @/ types/ipc '
55import { validateNumberRange } from ' @/renderer/store/dxt'
66import { useI18n } from ' vue-i18n'
77const { t } = useI18n ()
@@ -20,6 +20,14 @@ const elicitationParams = ref<ElicitRequestParams | {}>({})
2020
2121const elicitationChannel = ref (' ' )
2222
23+ const normalizedProperties = computed (() => {
24+ const props = (elicitationParams .value as ElicitRequestParams ).requestedSchema .properties
25+ return Object .keys (props ).map ((key ) => ({
26+ key ,
27+ para: props [key ]
28+ }))
29+ })
30+
2331const getConfigAttribute = (name : string ) => {
2432 return elicitationResults .value [name ] ?? null
2533}
@@ -34,7 +42,7 @@ const dynamicModel = (name: string) => ({
3442})
3543
3644const declineElicitation = () => {
37- const response: ElicitResult = {
45+ const response: ElicitResponse = {
3846 action: ' decline'
3947 }
4048 ElicitationTransfer .response (elicitationChannel .value , response )
@@ -43,7 +51,7 @@ const declineElicitation = () => {
4351}
4452
4553// const cancelElicitation = () => {
46- // const response: ElicitResult = {
54+ // const response: ElicitResponse = {
4755// "action": "cancel"
4856// }
4957// ElicitationTransfer.response(elicitationChannel.value, response)
@@ -52,7 +60,7 @@ const declineElicitation = () => {
5260// }
5361
5462const acceptElicitation = () => {
55- const response: ElicitResult = {
63+ const response: ElicitResponse = {
5664 action: ' accept' ,
5765 content: toRaw (elicitationResults .value )
5866 }
@@ -110,10 +118,10 @@ const validateStringLength = (
110118 }
111119}
112120
113- const handleProgress = (_event , progress ) => {
121+ const handleProgress: IpcElicitRequestCallback = (_event , progress ) => {
114122 console .log (' Elicitation' , progress )
115123 elicitationDialog .value = true
116- elicitationParams .value = progress .args [ 0 ] .params
124+ elicitationParams .value = progress .request .params as ElicitRequestParams
117125 elicitationChannel .value = progress .responseChannel
118126}
119127
@@ -137,11 +145,7 @@ ElicitationTransfer.request(handleProgress)
137145 'properties' in elicitationParams.requestedSchema
138146 "
139147 >
140- <v-row
141- v-for =" (para, key) in elicitationParams.requestedSchema.properties"
142- :key =" key"
143- class =" mx-3 mb-3"
144- >
148+ <v-row v-for =" { para, key } in normalizedProperties" :key =" key" class =" mx-3 mb-3" >
145149 <v-select
146150 v-if =" para.enum"
147151 prepend-icon =" mdi-list-box-outline"
0 commit comments