(
tool: {
name: string
maxResultSizeChars: number
mapToolResultToToolResultBlockParam: (
result: T,
toolUseID: string,
) => ToolResultBlockParam
},
toolUseResult: T,
toolUseID: string,
)
| 203 | * Maps the result to the API format and persists large results to disk. |
| 204 | */ |
| 205 | export async function processToolResultBlock<T>( |
| 206 | tool: { |
| 207 | name: string |
| 208 | maxResultSizeChars: number |
| 209 | mapToolResultToToolResultBlockParam: ( |
| 210 | result: T, |
| 211 | toolUseID: string, |
| 212 | ) => ToolResultBlockParam |
| 213 | }, |
| 214 | toolUseResult: T, |
| 215 | toolUseID: string, |
| 216 | ): Promise<ToolResultBlockParam> { |
| 217 | const toolResultBlock = tool.mapToolResultToToolResultBlockParam( |
| 218 | toolUseResult, |
| 219 | toolUseID, |
| 220 | ) |
| 221 | return maybePersistLargeToolResult( |
| 222 | toolResultBlock, |
| 223 | tool.name, |
| 224 | getPersistenceThreshold(tool.name, tool.maxResultSizeChars), |
| 225 | ) |
| 226 | } |
| 227 | |
| 228 | /** |
| 229 | * Process a pre-mapped tool result block. Applies persistence for large results |
no test coverage detected