11import { checkLiveUserInput } from '@codebuff/agent-runtime/live-user-inputs'
22import { getMCPToolData } from '@codebuff/agent-runtime/mcp'
3+ import { codebuffToolDefs } from '@codebuff/agent-runtime/tools/definitions/list'
34import { endsAgentStepParam } from '@codebuff/common/tools/constants'
45import { generateCompactId } from '@codebuff/common/util/string'
56import { type ToolCallPart } from 'ai'
67import { cloneDeep } from 'lodash'
78import z from 'zod/v4'
89import { convertJsonSchemaToZod } from 'zod-from-json-schema'
910
10- import { codebuffToolDefs } from '@codebuff/agent-runtime/tools/definitions/list'
1111import { codebuffToolHandlers } from './handlers/list'
1212
1313import type { AgentTemplate } from '@codebuff/agent-runtime/templates/types'
@@ -133,6 +133,7 @@ export type ExecuteToolCallParams<T extends string = ToolName> = {
133133 userId : string | undefined
134134 autoInsertEndStepParam ?: boolean
135135 excludeToolFromMessageHistory ?: boolean
136+ fetch : typeof globalThis . fetch
136137 fromHandleSteps ?: boolean
137138} & AgentRuntimeDeps &
138139 AgentRuntimeScopedDeps
@@ -231,19 +232,14 @@ export function executeToolCall<T extends ToolName>(
231232 }
232233
233234 // Cast to any to avoid type errors
234- const handler = codebuffToolHandlers [ toolName ] as any
235+ const handler = codebuffToolHandlers [
236+ toolName
237+ ] as unknown as CodebuffToolHandlerFunction < T >
235238 const { result : toolResultPromise , state : stateUpdate } = handler ( {
236239 ...params ,
237240 previousToolCallFinished,
238- fileContext,
239- agentStepId,
240- clientSessionId,
241- userInputId,
242- repoUrl,
243- repoId,
244- fullResponse,
245241 writeToClient : onResponseChunk ,
246- requestClientToolCall : async (
242+ requestClientToolCall : ( async (
247243 clientToolCall : ClientToolCall < T extends ClientToolName ? T : never > ,
248244 ) => {
249245 if ( ! checkLiveUserInput ( params ) ) {
@@ -256,11 +252,11 @@ export function executeToolCall<T extends ToolName>(
256252 input : clientToolCall . input ,
257253 } )
258254 return clientToolResult . output as CodebuffToolOutput < T >
259- } ,
255+ } ) as any ,
260256 toolCall,
261257 getLatestState : ( ) => state ,
262258 state,
263- } ) as ReturnType < CodebuffToolHandlerFunction < T > >
259+ } )
264260
265261 for ( const [ key , value ] of Object . entries ( stateUpdate ?? { } ) ) {
266262 if ( key === 'agentState' && typeof value === 'object' && value !== null ) {
0 commit comments