11import type { AgentToolInput , AgentToolProviderHandle } from 'devframe/types'
22import type {
3+ DevframeCommandAgentOptions ,
34 DevframeCommandHandle ,
45 DevframeCommandsHost as DevframeCommandsHostType ,
56 DevframeServerCommandEntry ,
67 DevframeServerCommandInput ,
78} from '../types/commands'
89import type { DevframeHubContext } from './context'
910import { createEventEmitter } from 'devframe/utils/events'
10- import { valibotArgsToJsonSchema } from 'devframe/utils/valibot-json-schema'
1111import { diagnostics } from './diagnostics'
1212
1313function findChildCommand ( command : DevframeServerCommandInput , id : string ) : DevframeServerCommandInput | undefined {
@@ -145,7 +145,7 @@ export class DevframeCommandsHost implements DevframeCommandsHostType {
145145 }
146146
147147 private toSerializable ( cmd : DevframeServerCommandInput ) : DevframeServerCommandEntry {
148- // `agent` stays server-side: it carries valibot schemas (not wire-safe)
148+ // `agent` stays server-side: it carries Standard Schema validators (not wire-safe)
149149 // and only concerns the agent projection, not the palette.
150150 const { handler : _ , agent : __ , children, ...rest } = cmd
151151 return {
@@ -179,16 +179,16 @@ export class DevframeCommandsHost implements DevframeCommandsHostType {
179179 const walk = ( command : DevframeServerCommandInput ) : void => {
180180 const agent = command . agent
181181 if ( agent && command . handler ) {
182- const { schema, unwrapped } = valibotArgsToJsonSchema ( agent . args )
183182 tools . push ( {
184183 id : command . id ,
185184 title : agent . title ?? command . title ,
186185 description : agent . description ,
187186 safety : agent . safety ?? 'action' ,
188187 tags : agent . tags ,
189- inputSchema : schema ,
188+ // The agent host derives the tool's JSON-Schema input from these.
189+ args : agent . args ,
190190 handler : async ( args : unknown ) =>
191- this . execute ( command . id , ...coercePositionalArgs ( args , agent . args , unwrapped ) ) ,
191+ this . execute ( command . id , ...coercePositionalArgs ( args , agent . args ) ) ,
192192 } )
193193 }
194194 for ( const child of command . children ?? [ ] )
@@ -201,20 +201,17 @@ export class DevframeCommandsHost implements DevframeCommandsHostType {
201201}
202202
203203/**
204- * Map the single-object args an MCP client sends onto the command handler's
205- * positional parameters, mirroring the agent host's RPC coercion: no declared
206- * schemas → zero-arg call; a single unwrapped object schema → the object
207- * itself; positional schemas → `arg0.. argN` keys in order.
204+ * Map the `arg0`/`arg1`/… keyed object an MCP client sends onto the command
205+ * handler's positional parameters — mirroring the agent host's RPC
206+ * coercion: no declared schemas → zero-arg call; each declared schema reads
207+ * its own ` argN` key, in order.
208208 */
209209function coercePositionalArgs (
210210 args : unknown ,
211- schemas : readonly unknown [ ] | undefined ,
212- unwrapped : boolean ,
211+ schemas : DevframeCommandAgentOptions [ 'args' ] ,
213212) : unknown [ ] {
214213 if ( ! schemas || schemas . length === 0 )
215214 return [ ]
216- if ( unwrapped )
217- return [ args ?? { } ]
218215 const obj = ( args ?? { } ) as Record < string , unknown >
219216 return schemas . map ( ( _ , i ) => obj [ `arg${ i } ` ] )
220217}
0 commit comments