11import { AgentState } from '@codebuff/common/types/session-state'
22import { logger } from '../../util/logger'
33import { CodebuffToolCall , CodebuffToolHandlerFunction } from '../constants'
4- import { agentRegistry } from '../../templates/agent-registry'
4+ import { getAllAgentTemplates } from '../../templates/agent-registry'
5+ import { ProjectFileContext } from '@codebuff/common/util/file'
56
67export const handleSetOutput = ( ( params : {
78 previousToolCallFinished : Promise < void >
89 toolCall : CodebuffToolCall < 'set_output' >
10+ fileContext : ProjectFileContext
911 state : {
1012 agentState ?: AgentState
1113 }
1214} ) : {
1315 result : Promise < string >
1416 state : { agentState : AgentState }
1517} => {
16- const { previousToolCallFinished, toolCall, state } = params
17- const output = toolCall . args // The entire args object is the output
18+ const { previousToolCallFinished, toolCall, state, fileContext } = params
19+ const output = toolCall . args
1820 const { agentState } = state
1921
2022 if ( ! agentState ) {
@@ -24,9 +26,12 @@ export const handleSetOutput = ((params: {
2426 }
2527
2628 const triggerSetOutput = async ( ) => {
29+ const { agentRegistry } = await getAllAgentTemplates ( {
30+ fileContext,
31+ } )
2732 // Validate output against outputSchema if defined
2833 const agentTemplate = agentState . agentType
29- ? agentRegistry . getTemplate ( agentState . agentType )
34+ ? agentRegistry [ agentState . agentType ]
3035 : null
3136 if ( agentTemplate ?. outputSchema ) {
3237 try {
0 commit comments