1- import { disableLiveUserInputCheck } from '@codebuff/agent-runtime/live-user-inputs'
21import * as analytics from '@codebuff/common/analytics'
32import db from '@codebuff/common/db'
43import { TEST_USER_ID } from '@codebuff/common/old-constants'
@@ -25,18 +24,17 @@ import {
2524} from 'bun:test'
2625import { z } from 'zod/v4'
2726
28- import { withAppContext } from '../context/app-context '
27+ import { disableLiveUserInputCheck } from '../live-user-inputs '
2928import { loopAgentSteps } from '../run-agent-step'
3029import { clearAgentGeneratorCache } from '../run-programmatic-step'
3130import { mockFileContext } from './test-utils'
3231
33- import type { AgentTemplate } from '@codebuff/agent-runtime /templates/types'
32+ import type { AgentTemplate } from '.. /templates/types'
3433import type { StepGenerator } from '@codebuff/common/types/agent-template'
3534import type {
3635 AgentRuntimeDeps ,
3736 AgentRuntimeScopedDeps ,
3837} from '@codebuff/common/types/contracts/agent-runtime'
39- import type { ParamsOf } from '@codebuff/common/types/function-params'
4038import type { AgentState } from '@codebuff/common/types/session-state'
4139
4240describe ( 'loopAgentSteps - runAgentStep vs runProgrammaticStep behavior' , ( ) => {
@@ -46,22 +44,6 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
4644 let agentRuntimeImpl : AgentRuntimeDeps
4745 let agentRuntimeScopedImpl : AgentRuntimeScopedDeps
4846
49- const runLoopAgentStepsWithContext = async (
50- options : ParamsOf < typeof loopAgentSteps > ,
51- ) => {
52- return await withAppContext (
53- {
54- userId : options . userId ,
55- clientSessionId : options . clientSessionId ,
56- } ,
57- {
58- currentUserId : options . userId ,
59- processedRepoId : 'test-repo' ,
60- } ,
61- async ( ) => loopAgentSteps ( options ) ,
62- )
63- }
64-
6547 beforeAll ( ( ) => {
6648 disableLiveUserInputCheck ( )
6749
@@ -181,7 +163,7 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
181163 'test-agent' : mockTemplate ,
182164 }
183165
184- const result = await runLoopAgentStepsWithContext ( {
166+ const result = await loopAgentSteps ( {
185167 ...agentRuntimeImpl ,
186168 ...agentRuntimeScopedImpl ,
187169 repoId : undefined ,
@@ -229,7 +211,7 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
229211 'test-agent' : mockTemplate ,
230212 }
231213
232- const result = await runLoopAgentStepsWithContext ( {
214+ const result = await loopAgentSteps ( {
233215 ...agentRuntimeImpl ,
234216 ...agentRuntimeScopedImpl ,
235217 repoId : undefined ,
@@ -279,7 +261,7 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
279261 'test-agent' : mockTemplate ,
280262 }
281263
282- const result = await runLoopAgentStepsWithContext ( {
264+ const result = await loopAgentSteps ( {
283265 ...agentRuntimeImpl ,
284266 ...agentRuntimeScopedImpl ,
285267 repoId : undefined ,
@@ -328,7 +310,7 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
328310 'test-agent' : mockTemplate ,
329311 }
330312
331- const result = await runLoopAgentStepsWithContext ( {
313+ const result = await loopAgentSteps ( {
332314 ...agentRuntimeImpl ,
333315 ...agentRuntimeScopedImpl ,
334316 repoId : undefined ,
@@ -370,7 +352,7 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
370352 'test-agent' : mockTemplate ,
371353 }
372354
373- const result = await runLoopAgentStepsWithContext ( {
355+ const result = await loopAgentSteps ( {
374356 ...agentRuntimeImpl ,
375357 ...agentRuntimeScopedImpl ,
376358 repoId : undefined ,
@@ -404,7 +386,7 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
404386 'test-agent' : llmOnlyTemplate ,
405387 }
406388
407- const result = await runLoopAgentStepsWithContext ( {
389+ const result = await loopAgentSteps ( {
408390 ...agentRuntimeImpl ,
409391 ...agentRuntimeScopedImpl ,
410392 repoId : undefined ,
@@ -440,7 +422,7 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
440422 'test-agent' : mockTemplate ,
441423 }
442424
443- const result = await runLoopAgentStepsWithContext ( {
425+ const result = await loopAgentSteps ( {
444426 ...agentRuntimeImpl ,
445427 ...agentRuntimeScopedImpl ,
446428 repoId : undefined ,
@@ -493,7 +475,7 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
493475 'test-agent' : mockTemplate ,
494476 }
495477
496- const result = await runLoopAgentStepsWithContext ( {
478+ const result = await loopAgentSteps ( {
497479 ...agentRuntimeImpl ,
498480 ...agentRuntimeScopedImpl ,
499481 repoId : undefined ,
@@ -523,7 +505,7 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
523505
524506 // Mock runProgrammaticStep module to capture calls and verify stepsComplete parameter
525507 const mockedRunProgrammaticStep = await mockModule (
526- '@codebuff/backend /run-programmatic-step' ,
508+ '@codebuff/agent-runtime /run-programmatic-step' ,
527509 ( ) => ( {
528510 runProgrammaticStep : async ( params : any ) => {
529511 runProgrammaticStepCalls . push ( params )
@@ -551,7 +533,7 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
551533 'test-agent' : mockTemplate ,
552534 }
553535
554- await runLoopAgentStepsWithContext ( {
536+ await loopAgentSteps ( {
555537 ...agentRuntimeImpl ,
556538 ...agentRuntimeScopedImpl ,
557539 repoId : undefined ,
@@ -623,7 +605,7 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
623605 return `mock-message-id-${ promptCallCount } `
624606 }
625607
626- await runLoopAgentStepsWithContext ( {
608+ await loopAgentSteps ( {
627609 ...agentRuntimeImpl ,
628610 ...agentRuntimeScopedImpl ,
629611 repoId : undefined ,
@@ -708,7 +690,7 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
708690 mockAgentState . output = undefined
709691 capturedAgentState = mockAgentState
710692
711- const result = await runLoopAgentStepsWithContext ( {
693+ const result = await loopAgentSteps ( {
712694 ...agentRuntimeImpl ,
713695 ...agentRuntimeScopedImpl ,
714696 repoId : undefined ,
@@ -783,7 +765,7 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
783765 mockAgentState . output = undefined
784766 capturedAgentState = mockAgentState
785767
786- const result = await runLoopAgentStepsWithContext ( {
768+ const result = await loopAgentSteps ( {
787769 ...agentRuntimeImpl ,
788770 ...agentRuntimeScopedImpl ,
789771 repoId : undefined ,
@@ -831,7 +813,7 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
831813 return 'mock-message-id'
832814 }
833815
834- const result = await runLoopAgentStepsWithContext ( {
816+ const result = await loopAgentSteps ( {
835817 ...agentRuntimeImpl ,
836818 ...agentRuntimeScopedImpl ,
837819 repoId : undefined ,
@@ -901,7 +883,7 @@ describe('loopAgentSteps - runAgentStep vs runProgrammaticStep behavior', () =>
901883 mockAgentState . output = undefined
902884 capturedAgentState = mockAgentState
903885
904- const result = await runLoopAgentStepsWithContext ( {
886+ const result = await loopAgentSteps ( {
905887 ...agentRuntimeImpl ,
906888 ...agentRuntimeScopedImpl ,
907889 repoId : undefined ,
0 commit comments