11import { TEST_USER_ID } from '@codebuff/common/old-constants'
2+ import { testAgentRuntimeImpl } from '@codebuff/common/testing/impl/agent-runtime'
23import { getInitialSessionState } from '@codebuff/common/types/session-state'
34import {
45 spyOn ,
@@ -18,7 +19,6 @@ import * as websocketAction from '../websockets/websocket-action'
1819
1920import type { AgentTemplate } from '../templates/types'
2021import type { ProjectFileContext } from '@codebuff/common/util/file'
21- import type { Logger } from '@codebuff/types/logger'
2222import type { WebSocket } from 'ws'
2323
2424const mockFileContext : ProjectFileContext = {
@@ -99,12 +99,6 @@ class MockWebSocket {
9999describe ( 'Cost Aggregation Integration Tests' , ( ) => {
100100 let mockLocalAgentTemplates : Record < string , any >
101101 let mockWebSocket : MockWebSocket
102- const logger : Logger = {
103- debug : ( ) => { } ,
104- error : ( ) => { } ,
105- info : ( ) => { } ,
106- warn : ( ) => { } ,
107- }
108102
109103 beforeEach ( async ( ) => {
110104 mockWebSocket = new MockWebSocket ( )
@@ -256,13 +250,13 @@ describe('Cost Aggregation Integration Tests', () => {
256250 }
257251
258252 const result = await mainPrompt ( {
253+ ...testAgentRuntimeImpl ,
259254 ws : mockWebSocket as unknown as WebSocket ,
260255 action,
261256 userId : TEST_USER_ID ,
262257 clientSessionId : 'test-session' ,
263258 onResponseChunk : ( ) => { } ,
264259 localAgentTemplates : mockLocalAgentTemplates ,
265- logger,
266260 } )
267261
268262 // Verify the total cost includes both main agent and subagent costs
@@ -291,12 +285,12 @@ describe('Cost Aggregation Integration Tests', () => {
291285
292286 // Call through websocket action handler to test full integration
293287 await websocketAction . callMainPrompt ( {
288+ ...testAgentRuntimeImpl ,
294289 ws : mockWebSocket as unknown as WebSocket ,
295290 action,
296291 userId : TEST_USER_ID ,
297292 promptId : 'test-prompt' ,
298293 clientSessionId : 'test-session' ,
299- logger,
300294 } )
301295
302296 // Verify final cost is included in prompt response
@@ -361,13 +355,13 @@ describe('Cost Aggregation Integration Tests', () => {
361355 }
362356
363357 const result = await mainPrompt ( {
358+ ...testAgentRuntimeImpl ,
364359 ws : mockWebSocket as unknown as WebSocket ,
365360 action,
366361 userId : TEST_USER_ID ,
367362 clientSessionId : 'test-session' ,
368363 onResponseChunk : ( ) => { } ,
369364 localAgentTemplates : mockLocalAgentTemplates ,
370- logger,
371365 } )
372366
373367 // Should aggregate costs from all levels: main + sub1 + sub2
@@ -419,13 +413,13 @@ describe('Cost Aggregation Integration Tests', () => {
419413 let result
420414 try {
421415 result = await mainPrompt ( {
416+ ...testAgentRuntimeImpl ,
422417 ws : mockWebSocket as unknown as WebSocket ,
423418 action,
424419 userId : TEST_USER_ID ,
425420 clientSessionId : 'test-session' ,
426421 onResponseChunk : ( ) => { } ,
427422 localAgentTemplates : mockLocalAgentTemplates ,
428- logger,
429423 } )
430424 } catch ( error ) {
431425 // Expected to fail, but costs may still be tracked
@@ -468,13 +462,13 @@ describe('Cost Aggregation Integration Tests', () => {
468462 }
469463
470464 await mainPrompt ( {
465+ ...testAgentRuntimeImpl ,
471466 ws : mockWebSocket as unknown as WebSocket ,
472467 action,
473468 userId : TEST_USER_ID ,
474469 clientSessionId : 'test-session' ,
475470 onResponseChunk : ( ) => { } ,
476471 localAgentTemplates : mockLocalAgentTemplates ,
477- logger,
478472 } )
479473
480474 // Verify no duplicate message IDs (no double-counting)
@@ -508,12 +502,12 @@ describe('Cost Aggregation Integration Tests', () => {
508502
509503 // Call through websocket action to test server-side reset
510504 await websocketAction . callMainPrompt ( {
505+ ...testAgentRuntimeImpl ,
511506 ws : mockWebSocket as unknown as WebSocket ,
512507 action,
513508 userId : TEST_USER_ID ,
514509 promptId : 'test-prompt' ,
515510 clientSessionId : 'test-session' ,
516- logger,
517511 } )
518512
519513 // Server should have reset the malicious value and calculated correct cost
0 commit comments