@@ -2,10 +2,7 @@ import { disableLiveUserInputCheck } from '@codebuff/agent-runtime/live-user-inp
22import { mainPrompt } from '@codebuff/agent-runtime/main-prompt'
33import * as agentRegistry from '@codebuff/agent-runtime/templates/agent-registry'
44import { TEST_USER_ID } from '@codebuff/common/old-constants'
5- import {
6- TEST_AGENT_RUNTIME_IMPL ,
7- TEST_AGENT_RUNTIME_SCOPED_IMPL ,
8- } from '@codebuff/common/testing/impl/agent-runtime'
5+ import { TEST_AGENT_RUNTIME_IMPL } from '@codebuff/common/testing/impl/agent-runtime'
96import { getInitialSessionState } from '@codebuff/common/types/session-state'
107import {
118 spyOn ,
@@ -90,17 +87,15 @@ const mockFileContext: ProjectFileContext = {
9087
9188describe ( 'Cost Aggregation Integration Tests' , ( ) => {
9289 let mockLocalAgentTemplates : Record < string , any >
93- let agentRuntimeImpl : AgentRuntimeDeps
94- let agentRuntimeScopedImpl : AgentRuntimeScopedDeps
90+ let agentRuntimeImpl : AgentRuntimeDeps & AgentRuntimeScopedDeps
9591
9692 beforeAll ( ( ) => {
9793 disableLiveUserInputCheck ( )
9894 } )
9995
10096 beforeEach ( async ( ) => {
101- agentRuntimeImpl = { ...TEST_AGENT_RUNTIME_IMPL }
102- agentRuntimeScopedImpl = {
103- ...TEST_AGENT_RUNTIME_SCOPED_IMPL ,
97+ agentRuntimeImpl = {
98+ ...TEST_AGENT_RUNTIME_IMPL ,
10499 sendAction : mock ( ( ) => { } ) ,
105100 }
106101
@@ -178,7 +173,7 @@ describe('Cost Aggregation Integration Tests', () => {
178173 }
179174
180175 // Mock tool call execution
181- agentRuntimeScopedImpl . requestToolCall = async ( { toolName, input } ) => {
176+ agentRuntimeImpl . requestToolCall = async ( { toolName, input } ) => {
182177 if ( toolName === 'write_file' ) {
183178 return {
184179 output : [
@@ -204,9 +199,7 @@ describe('Cost Aggregation Integration Tests', () => {
204199 }
205200
206201 // Mock file reading
207- agentRuntimeScopedImpl . requestFiles = async ( params : {
208- filePaths : string [ ]
209- } ) => {
202+ agentRuntimeImpl . requestFiles = async ( params : { filePaths : string [ ] } ) => {
210203 const results : Record < string , string | null > = { }
211204 params . filePaths . forEach ( ( path ) => {
212205 results [ path ] = path === 'hello.txt' ? 'Hello, World!' : null
@@ -244,7 +237,6 @@ describe('Cost Aggregation Integration Tests', () => {
244237
245238 const result = await mainPrompt ( {
246239 ...agentRuntimeImpl ,
247- ...agentRuntimeScopedImpl ,
248240 repoId : undefined ,
249241 repoUrl : undefined ,
250242 action,
@@ -281,7 +273,6 @@ describe('Cost Aggregation Integration Tests', () => {
281273 // Call through websocket action handler to test full integration
282274 await websocketAction . callMainPrompt ( {
283275 ...agentRuntimeImpl ,
284- ...agentRuntimeScopedImpl ,
285276 repoId : undefined ,
286277 repoUrl : undefined ,
287278 action,
@@ -292,7 +283,7 @@ describe('Cost Aggregation Integration Tests', () => {
292283
293284 // Verify final cost is included in prompt response
294285 const promptResponse = (
295- agentRuntimeScopedImpl . sendAction as Mock < SendActionFn >
286+ agentRuntimeImpl . sendAction as Mock < SendActionFn >
296287 ) . mock . calls
297288 . map ( ( call ) => call [ 0 ] . action )
298289 . find ( ( action : ServerAction ) => action . type === 'prompt-response' ) as any
@@ -353,7 +344,6 @@ describe('Cost Aggregation Integration Tests', () => {
353344
354345 const result = await mainPrompt ( {
355346 ...agentRuntimeImpl ,
356- ...agentRuntimeScopedImpl ,
357347 repoId : undefined ,
358348 repoUrl : undefined ,
359349 action,
@@ -411,7 +401,6 @@ describe('Cost Aggregation Integration Tests', () => {
411401 try {
412402 result = await mainPrompt ( {
413403 ...agentRuntimeImpl ,
414- ...agentRuntimeScopedImpl ,
415404 repoId : undefined ,
416405 repoUrl : undefined ,
417406 action,
@@ -462,7 +451,6 @@ describe('Cost Aggregation Integration Tests', () => {
462451
463452 await mainPrompt ( {
464453 ...agentRuntimeImpl ,
465- ...agentRuntimeScopedImpl ,
466454 repoId : undefined ,
467455 repoUrl : undefined ,
468456 action,
@@ -504,7 +492,6 @@ describe('Cost Aggregation Integration Tests', () => {
504492 // Call through websocket action to test server-side reset
505493 await websocketAction . callMainPrompt ( {
506494 ...agentRuntimeImpl ,
507- ...agentRuntimeScopedImpl ,
508495 repoId : undefined ,
509496 repoUrl : undefined ,
510497 action,
@@ -515,7 +502,7 @@ describe('Cost Aggregation Integration Tests', () => {
515502
516503 // Server should have reset the malicious value and calculated correct cost
517504 const promptResponse = (
518- agentRuntimeScopedImpl . sendAction as Mock < SendActionFn >
505+ agentRuntimeImpl . sendAction as Mock < SendActionFn >
519506 ) . mock . calls
520507 . map ( ( call ) => call [ 0 ] . action )
521508 . find ( ( action ) => action . type === 'prompt-response' ) as any
0 commit comments