@@ -142,13 +142,16 @@ const definition = defineComponent({
142142
143143 const callTools = params . callTools ?? true ;
144144 const maxToolCalls = params . maxToolCalls ?? 10 ;
145+ const logDiagnostic = ( message : string ) : void => {
146+ context . logger . info ( message ) ;
147+ } ;
145148
146149 const connectedIds = connectedToolNodeIds ?? [ ] ;
147- console . log ( `[mock.agent] connectedToolNodeIds: ${ connectedIds . join ( ', ' ) || '(none)' } ` ) ;
148- console . log ( `[mock.agent] callTools=${ callTools } , maxToolCalls=${ maxToolCalls } ` ) ;
150+ logDiagnostic ( `[mock.agent] connectedToolNodeIds: ${ connectedIds . join ( ', ' ) || '(none)' } ` ) ;
151+ logDiagnostic ( `[mock.agent] callTools=${ callTools } , maxToolCalls=${ maxToolCalls } ` ) ;
149152
150153 if ( connectedIds . length === 0 ) {
151- console . log ( '[mock.agent] No connected tool nodes, returning empty list' ) ;
154+ logDiagnostic ( '[mock.agent] No connected tool nodes, returning empty list' ) ;
152155 return outputSchema . parse ( { discoveredTools : [ ] , toolCount : 0 , toolCallResults : [ ] } ) ;
153156 }
154157
@@ -157,7 +160,7 @@ const definition = defineComponent({
157160
158161 // 2. Connect to gateway via MCP SDK client
159162 const gatewayUrl = DEFAULT_GATEWAY_URL ;
160- console . log ( `[mock.agent] Connecting to gateway: ${ gatewayUrl } ` ) ;
163+ logDiagnostic ( `[mock.agent] Connecting to gateway: ${ gatewayUrl } ` ) ;
161164
162165 const transport = new TransportImpl ( new URL ( gatewayUrl ) , {
163166 requestInit : {
@@ -183,9 +186,9 @@ const definition = defineComponent({
183186 description : t . description ,
184187 } ) ) ;
185188
186- console . log ( `[mock.agent] Discovered ${ tools . length } tools:` ) ;
189+ logDiagnostic ( `[mock.agent] Discovered ${ tools . length } tools:` ) ;
187190 for ( const tool of tools ) {
188- console . log ( ` - ${ tool . name } : ${ tool . description ?? '(no description)' } ` ) ;
191+ logDiagnostic ( ` - ${ tool . name } : ${ tool . description ?? '(no description)' } ` ) ;
189192 }
190193
191194 // Phase 2: Call tools with test arguments
@@ -196,17 +199,17 @@ const definition = defineComponent({
196199
197200 for ( const tool of tools ) {
198201 if ( callCount >= maxToolCalls ) {
199- console . log ( `[mock.agent] Reached max tool calls (${ maxToolCalls } ), stopping.` ) ;
202+ logDiagnostic ( `[mock.agent] Reached max tool calls (${ maxToolCalls } ), stopping.` ) ;
200203 break ;
201204 }
202205
203206 const testArgs = getTestArgsForTool ( tool . name ) ;
204207 if ( ! testArgs ) {
205- console . log ( `[mock.agent] No test args for tool '${ tool . name } ', skipping call.` ) ;
208+ logDiagnostic ( `[mock.agent] No test args for tool '${ tool . name } ', skipping call.` ) ;
206209 continue ;
207210 }
208211
209- console . log (
212+ logDiagnostic (
210213 `[mock.agent] ▶ Calling tool '${ tool . name } ' with args: ${ JSON . stringify ( testArgs ) } ` ,
211214 ) ;
212215 const startTime = Date . now ( ) ;
@@ -232,7 +235,7 @@ const definition = defineComponent({
232235 }
233236
234237 if ( isError ) {
235- console . log (
238+ logDiagnostic (
236239 `[mock.agent] ✗ Tool '${ tool . name } ' returned error (${ durationMs } ms): ${ outputText . substring ( 0 , 200 ) } ` ,
237240 ) ;
238241 toolCallResults . push ( {
@@ -242,10 +245,10 @@ const definition = defineComponent({
242245 error : outputText . substring ( 0 , 500 ) ,
243246 } ) ;
244247 } else {
245- console . log (
248+ logDiagnostic (
246249 `[mock.agent] ✓ Tool '${ tool . name } ' succeeded (${ durationMs } ms), output length: ${ outputText . length } chars` ,
247250 ) ;
248- console . log (
251+ logDiagnostic (
249252 `[mock.agent] Preview: ${ outputText . substring ( 0 , 200 ) } ${ outputText . length > 200 ? '...' : '' } ` ,
250253 ) ;
251254 toolCallResults . push ( {
@@ -261,7 +264,7 @@ const definition = defineComponent({
261264 } catch ( error : unknown ) {
262265 const durationMs = Date . now ( ) - startTime ;
263266 const errorMsg = error instanceof Error ? error . message : String ( error ) ;
264- console . log (
267+ logDiagnostic (
265268 `[mock.agent] ✗ Tool '${ tool . name } ' threw exception (${ durationMs } ms): ${ errorMsg } ` ,
266269 ) ;
267270 toolCallResults . push ( {
@@ -277,7 +280,7 @@ const definition = defineComponent({
277280
278281 const succeeded = toolCallResults . filter ( ( r ) => r . success ) . length ;
279282 const failed = toolCallResults . filter ( ( r ) => ! r . success ) . length ;
280- console . log (
283+ logDiagnostic (
281284 `[mock.agent] Tool call summary: ${ succeeded } succeeded, ${ failed } failed out of ${ toolCallResults . length } calls` ,
282285 ) ;
283286 }
0 commit comments