( execute: (input: TInput) => Promise<AgentToolResult<TDetails>>, input: TInput, context: ToolContext, )
| 51 | } |
| 52 | |
| 53 | async function runTool<TInput, TDetails = unknown>( |
| 54 | execute: (input: TInput) => Promise<AgentToolResult<TDetails>>, |
| 55 | input: TInput, |
| 56 | context: ToolContext, |
| 57 | ): Promise<ToolResponse<TDetails>> { |
| 58 | try { |
| 59 | const result = await execute(input); |
| 60 | return { |
| 61 | content: toMcpContent(result), |
| 62 | details: result.details, |
| 63 | }; |
| 64 | } catch (error) { |
| 65 | return { content: formatToolError(error), isError: true }; |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | export async function readFileTool(input: ReadToolInput, context: ToolContext): Promise<ToolResponse> { |
| 70 | const path = resolveAllowedPath(input.path, context.cwd, context.readRoots ?? [context.root]); |
no test coverage detected