@@ -210,7 +210,9 @@ export class AcpGatewayAgent implements Agent {
210210 if ( ! session ) {
211211 throw new Error ( `Session ${ params . sessionId } not found` ) ;
212212 }
213- if ( ! params . modeId ) return { } ;
213+ if ( ! params . modeId ) {
214+ return { } ;
215+ }
214216 try {
215217 await this . gateway . request ( "sessions.patch" , {
216218 key : session . sessionKey ,
@@ -276,7 +278,9 @@ export class AcpGatewayAgent implements Agent {
276278
277279 async cancel ( params : CancelNotification ) : Promise < void > {
278280 const session = this . sessionStore . getSession ( params . sessionId ) ;
279- if ( ! session ) return ;
281+ if ( ! session ) {
282+ return ;
283+ }
280284
281285 this . sessionStore . cancelActiveRun ( params . sessionId ) ;
282286 try {
@@ -294,24 +298,38 @@ export class AcpGatewayAgent implements Agent {
294298
295299 private async handleAgentEvent ( evt : EventFrame ) : Promise < void > {
296300 const payload = evt . payload as Record < string , unknown > | undefined ;
297- if ( ! payload ) return ;
301+ if ( ! payload ) {
302+ return ;
303+ }
298304 const stream = payload . stream as string | undefined ;
299305 const data = payload . data as Record < string , unknown > | undefined ;
300306 const sessionKey = payload . sessionKey as string | undefined ;
301- if ( ! stream || ! data || ! sessionKey ) return ;
307+ if ( ! stream || ! data || ! sessionKey ) {
308+ return ;
309+ }
302310
303- if ( stream !== "tool" ) return ;
311+ if ( stream !== "tool" ) {
312+ return ;
313+ }
304314 const phase = data . phase as string | undefined ;
305315 const name = data . name as string | undefined ;
306316 const toolCallId = data . toolCallId as string | undefined ;
307- if ( ! toolCallId ) return ;
317+ if ( ! toolCallId ) {
318+ return ;
319+ }
308320
309321 const pending = this . findPendingBySessionKey ( sessionKey ) ;
310- if ( ! pending ) return ;
322+ if ( ! pending ) {
323+ return ;
324+ }
311325
312326 if ( phase === "start" ) {
313- if ( ! pending . toolCalls ) pending . toolCalls = new Set ( ) ;
314- if ( pending . toolCalls . has ( toolCallId ) ) return ;
327+ if ( ! pending . toolCalls ) {
328+ pending . toolCalls = new Set ( ) ;
329+ }
330+ if ( pending . toolCalls . has ( toolCallId ) ) {
331+ return ;
332+ }
315333 pending . toolCalls . add ( toolCallId ) ;
316334 const args = data . args as Record < string , unknown > | undefined ;
317335 await this . connection . sessionUpdate ( {
@@ -344,17 +362,25 @@ export class AcpGatewayAgent implements Agent {
344362
345363 private async handleChatEvent ( evt : EventFrame ) : Promise < void > {
346364 const payload = evt . payload as Record < string , unknown > | undefined ;
347- if ( ! payload ) return ;
365+ if ( ! payload ) {
366+ return ;
367+ }
348368
349369 const sessionKey = payload . sessionKey as string | undefined ;
350370 const state = payload . state as string | undefined ;
351371 const runId = payload . runId as string | undefined ;
352372 const messageData = payload . message as Record < string , unknown > | undefined ;
353- if ( ! sessionKey || ! state ) return ;
373+ if ( ! sessionKey || ! state ) {
374+ return ;
375+ }
354376
355377 const pending = this . findPendingBySessionKey ( sessionKey ) ;
356- if ( ! pending ) return ;
357- if ( runId && pending . idempotencyKey !== runId ) return ;
378+ if ( ! pending ) {
379+ return ;
380+ }
381+ if ( runId && pending . idempotencyKey !== runId ) {
382+ return ;
383+ }
358384
359385 if ( state === "delta" && messageData ) {
360386 await this . handleDeltaEvent ( pending . sessionId , messageData ) ;
@@ -381,10 +407,14 @@ export class AcpGatewayAgent implements Agent {
381407 const content = messageData . content as Array < { type : string ; text ?: string } > | undefined ;
382408 const fullText = content ?. find ( ( c ) => c . type === "text" ) ?. text ?? "" ;
383409 const pending = this . pendingPrompts . get ( sessionId ) ;
384- if ( ! pending ) return ;
410+ if ( ! pending ) {
411+ return ;
412+ }
385413
386414 const sentSoFar = pending . sentTextLength ?? 0 ;
387- if ( fullText . length <= sentSoFar ) return ;
415+ if ( fullText . length <= sentSoFar ) {
416+ return ;
417+ }
388418
389419 const newText = fullText . slice ( sentSoFar ) ;
390420 pending . sentTextLength = fullText . length ;
@@ -407,7 +437,9 @@ export class AcpGatewayAgent implements Agent {
407437
408438 private findPendingBySessionKey ( sessionKey : string ) : PendingPrompt | undefined {
409439 for ( const pending of this . pendingPrompts . values ( ) ) {
410- if ( pending . sessionKey === sessionKey ) return pending ;
440+ if ( pending . sessionKey === sessionKey ) {
441+ return pending ;
442+ }
411443 }
412444 return undefined ;
413445 }
0 commit comments