@@ -44,11 +44,12 @@ const hoisted = vi.hoisted(() => {
4444 cancel : vi . fn ( ) . mockResolvedValue ( undefined ) ,
4545 } ) ;
4646
47- const clientSideConnectionCtor = vi . fn ( ( ) => {
48- const conn = makeConnection ( ) ;
49- createdConnections . push ( conn ) ;
50- return conn ;
51- } ) ;
47+ const clientSideConnectionCtor = class {
48+ constructor ( ) {
49+ Object . assign ( this , makeConnection ( ) ) ;
50+ createdConnections . push ( this as unknown as MockCodexConnection ) ;
51+ }
52+ } ;
5253
5354 const spawnCodexProcessMock = vi . fn ( ( ) => {
5455 const handle : SpawnHandle = {
@@ -75,7 +76,6 @@ const hoisted = vi.hoisted(() => {
7576
7677const createdConnections = hoisted . createdConnections ;
7778const spawnedProcesses = hoisted . spawnedProcesses ;
78- const clientSideConnectionCtor = hoisted . clientSideConnectionCtor ;
7979
8080vi . mock ( "@agentclientprotocol/sdk" , async ( ) => {
8181 const actual = await vi . importActual ( "@agentclientprotocol/sdk" ) ;
@@ -91,13 +91,14 @@ vi.mock("./spawn", () => ({
9191} ) ) ;
9292
9393vi . mock ( "./settings" , ( ) => ( {
94- CodexSettingsManager : vi . fn ( ) . mockImplementation ( ( cwd : string ) => ( {
95- initialize : vi . fn ( ) . mockResolvedValue ( undefined ) ,
96- dispose : vi . fn ( ) ,
97- getCwd : ( ) => cwd ,
98- setCwd : vi . fn ( ) ,
99- getSettings : ( ) => ( { mcpServerNames : [ ] } ) ,
100- } ) ) ,
94+ CodexSettingsManager : class {
95+ constructor ( private readonly cwd : string ) { }
96+ initialize = vi . fn ( ) . mockResolvedValue ( undefined ) ;
97+ dispose = vi . fn ( ) ;
98+ getCwd = ( ) => this . cwd ;
99+ setCwd = vi . fn ( ) ;
100+ getSettings = ( ) => ( { mcpServerNames : [ ] } ) ;
101+ } ,
101102} ) ) ;
102103
103104import { CodexAcpAgent } from "./codex-agent" ;
@@ -171,7 +172,6 @@ describe("CodexAcpAgent.extMethod refresh_session", () => {
171172 beforeEach ( ( ) => {
172173 spawnedProcesses . length = 0 ;
173174 createdConnections . length = 0 ;
174- clientSideConnectionCtor . mockClear ( ) ;
175175 } ) ;
176176
177177 it ( "returns methodNotFound for unknown extension methods" , async ( ) => {
0 commit comments