@@ -152,6 +152,7 @@ export class JsonRpcTransport implements A2ATransport {
152152 }
153153
154154 private async _sendRpcRequest <
155+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
155156 TParams extends { [ key : string ] : any } ,
156157 TResponse extends JSONRPCResponse ,
157158 > ( method : string , params : TParams , idOverride : number | undefined ) : Promise < TResponse > {
@@ -168,11 +169,11 @@ export class JsonRpcTransport implements A2ATransport {
168169
169170 if ( ! httpResponse . ok ) {
170171 let errorBodyText = '(empty or non-JSON response)' ;
171- let errorJson : any = { } ;
172+ let errorJson : JSONRPCErrorResponse ;
172173 try {
173174 errorBodyText = await httpResponse . text ( ) ;
174175 errorJson = JSON . parse ( errorBodyText ) ;
175- } catch ( e : any ) {
176+ } catch ( e ) {
176177 throw new Error (
177178 `HTTP error for ${ method } ! Status: ${ httpResponse . status } ${ httpResponse . statusText } . Response: ${ errorBodyText } ` ,
178179 { cause : e }
@@ -218,25 +219,25 @@ export class JsonRpcTransport implements A2ATransport {
218219
219220 private async * _sendStreamingRequest (
220221 method : string ,
221- params : any
222+ params : unknown
222223 ) : AsyncGenerator < A2AStreamEventData , void , undefined > {
223224 const clientRequestId = this . requestIdCounter ++ ;
224225 const rpcRequest : JSONRPCRequest = {
225226 jsonrpc : '2.0' ,
226227 method,
227- params : params as { [ key : string ] : any } ,
228+ params : params as { [ key : string ] : unknown } ,
228229 id : clientRequestId ,
229230 } ;
230231
231232 const response = await this . _fetchRpc ( rpcRequest , 'text/event-stream' ) ;
232233
233234 if ( ! response . ok ) {
234235 let errorBody = '' ;
235- let errorJson : any = { } ;
236+ let errorJson : JSONRPCErrorResponse ;
236237 try {
237238 errorBody = await response . text ( ) ;
238239 errorJson = JSON . parse ( errorBody ) ;
239- } catch ( e : any ) {
240+ } catch ( e ) {
240241 throw new Error (
241242 `HTTP error establishing stream for ${ method } : ${ response . status } ${ response . statusText } . Response: ${ errorBody || '(empty)' } ` ,
242243 { cause : e }
@@ -305,8 +306,11 @@ export class JsonRpcTransport implements A2ATransport {
305306 }
306307 }
307308 }
308- } catch ( error : any ) {
309- console . error ( 'Error reading or parsing SSE stream:' , error . message ) ;
309+ } catch ( error ) {
310+ console . error (
311+ 'Error reading or parsing SSE stream:' ,
312+ ( error instanceof Error && error . message ) || 'Error unknown'
313+ ) ;
310314 throw error ;
311315 } finally {
312316 reader . releaseLock ( ) ;
@@ -342,10 +346,11 @@ export class JsonRpcTransport implements A2ATransport {
342346 }
343347
344348 return a2aStreamResponse . result as TStreamItem ;
345- } catch ( e : any ) {
349+ } catch ( e ) {
346350 if (
347- e . message . startsWith ( 'SSE event contained an error' ) ||
348- e . message . startsWith ( "SSE event JSON-RPC response is missing 'result' field" )
351+ e instanceof Error &&
352+ ( e . message . startsWith ( 'SSE event contained an error' ) ||
353+ e . message . startsWith ( "SSE event JSON-RPC response is missing 'result' field" ) )
349354 ) {
350355 throw e ;
351356 }
@@ -355,7 +360,7 @@ export class JsonRpcTransport implements A2ATransport {
355360 e
356361 ) ;
357362 throw new Error (
358- `Failed to parse SSE event data: "${ jsonData . substring ( 0 , 100 ) } ...". Original error: ${ e . message } `
363+ `Failed to parse SSE event data: "${ jsonData . substring ( 0 , 100 ) } ...". Original error: ${ ( e instanceof Error && e . message ) || 'Unknown error' } `
359364 ) ;
360365 }
361366 }
0 commit comments