@@ -15,12 +15,10 @@ const getLocalAuthToken = () => {
1515}
1616
1717export class CodebuffRunner implements Runner {
18- private client : CodebuffClient | null
1918 private runState : RunState
2019 private agent : string
2120
2221 constructor ( runState : RunState , agent ?: string ) {
23- this . client = null
2422 this . runState = runState
2523 this . agent = agent ?? 'base'
2624 }
@@ -39,15 +37,13 @@ export class CodebuffRunner implements Runner {
3937
4038 const apiKey = process . env [ API_KEY_ENV_VAR ] || getLocalAuthToken ( )
4139
42- if ( ! this . client ) {
43- this . client = new CodebuffClient ( {
44- apiKey,
45- cwd : this . runState . sessionState . fileContext . cwd ,
46- onError : ( error ) => {
47- throw new Error ( error . message )
48- } ,
49- } )
50- }
40+ const client = new CodebuffClient ( {
41+ apiKey,
42+ cwd : this . runState . sessionState . fileContext . cwd ,
43+ onError : ( error ) => {
44+ throw new Error ( error . message )
45+ } ,
46+ } )
5147
5248 const agentsPath = path . join ( __dirname , '../../../.agents' )
5349 const localAgentDefinitions = Object . values (
@@ -60,7 +56,7 @@ export class CodebuffRunner implements Runner {
6056 localAgentDefinitions . map ( ( a ) => a . id ) ,
6157 )
6258
63- this . runState = await this . client . run ( {
59+ this . runState = await client . run ( {
6460 agent : this . agent ,
6561 previousRun : this . runState ,
6662 prompt,
@@ -93,6 +89,8 @@ export class CodebuffRunner implements Runner {
9389 } )
9490 flushStep ( )
9591
92+ client . closeConnection ( )
93+
9694 return { steps }
9795 }
9896}
0 commit comments