@@ -1108,103 +1108,9 @@ export namespace Server {
11081108 return c . json ( commands )
11091109 } ,
11101110 )
1111- . get (
1112- "/plugin/command" ,
1113- describeRoute ( {
1114- description : "List all plugin commands" ,
1115- operationId : "pluginCommand.list" ,
1116- responses : {
1117- 200 : {
1118- description : "List of plugin commands" ,
1119- content : {
1120- "application/json" : {
1121- schema : resolver (
1122- z
1123- . array (
1124- z . object ( {
1125- name : z . string ( ) ,
1126- description : z . string ( ) ,
1127- aliases : z . array ( z . string ( ) ) . optional ( ) ,
1128- sessionOnly : z . boolean ( ) . optional ( ) ,
1129- } ) ,
1130- )
1131- . meta ( { ref : "PluginCommand" } ) ,
1132- ) ,
1133- } ,
1134- } ,
1135- } ,
1136- } ,
1137- } ) ,
1138- async ( c ) => {
1139- const plugins = await Plugin . list ( )
1140- const commands = [ ]
1141- for ( const plugin of plugins ) {
1142- const pluginCommands = plugin [ "plugin.command" ]
1143- if ( ! pluginCommands ) continue
1144- for ( const [ name , def ] of Object . entries ( pluginCommands ) ) {
1145- commands . push ( {
1146- name,
1147- description : def . description ,
1148- aliases : def . aliases ,
1149- sessionOnly : def . sessionOnly ,
1150- } )
1151- }
1152- }
1153- return c . json ( commands )
1154- } ,
1155- )
1156- . post (
1157- "/plugin/command/:name/execute" ,
1158- describeRoute ( {
1159- description : "Execute a plugin command" ,
1160- operationId : "pluginCommand.execute" ,
1161- responses : {
1162- 200 : {
1163- description : "Command executed" ,
1164- content : {
1165- "application/json" : {
1166- schema : resolver ( z . boolean ( ) ) ,
1167- } ,
1168- } ,
1169- } ,
1170- ...errors ( 400 , 404 ) ,
1171- } ,
1172- } ) ,
1173- validator (
1174- "param" ,
1175- z . object ( {
1176- name : z . string ( ) . meta ( { description : "Plugin command name" } ) ,
1177- } ) ,
1178- ) ,
1179- validator (
1180- "json" ,
1181- z . object ( {
1182- sessionID : z . string ( ) . optional ( ) . meta ( { description : "Session ID" } ) ,
1183- } ) ,
1184- ) ,
1185- async ( c ) => {
1186- const { name } = c . req . valid ( "param" )
1187- const { sessionID } = c . req . valid ( "json" )
1188-
1189- const plugins = await Plugin . list ( )
1190- for ( const plugin of plugins ) {
1191- const command = plugin [ "plugin.command" ] ?. [ name ]
1192- if ( ! command ) continue
1193-
1194- const client = createOpencodeClient ( {
1195- baseUrl : "http://localhost:4096" ,
1196- fetch : async ( ...args ) => Server . App ( ) . fetch ( ...args ) ,
1197- } )
1198-
1199- await command . execute ( { sessionID, client } )
1200- return c . json ( true )
1201- }
1202-
1203- return c . json ( { error : "Command not found" } , 404 )
1204- } ,
1205- )
12061111 . get (
12071112 "/config/providers" ,
1113+
12081114 describeRoute ( {
12091115 description : "List all providers" ,
12101116 operationId : "config.providers" ,
0 commit comments