* Processes custom tool definitions into the format expected by SessionState. * Converts Zod schemas to JSON Schema format so they can survive JSON serialization.
( customToolDefinitions: CustomToolDefinition[], )
| 108 | * Converts Zod schemas to JSON Schema format so they can survive JSON serialization. |
| 109 | */ |
| 110 | function processCustomToolDefinitions( |
| 111 | customToolDefinitions: CustomToolDefinition[], |
| 112 | ): CustomToolDefinitions { |
| 113 | return Object.fromEntries( |
| 114 | customToolDefinitions.map((toolDefinition) => { |
| 115 | // Convert Zod schema to JSON Schema format so it survives JSON serialization |
| 116 | // The agent-runtime will wrap this with AI SDK's jsonSchema() helper |
| 117 | const jsonSchema = z.toJSONSchema(toolDefinition.inputSchema, { |
| 118 | io: 'input', |
| 119 | }) as Record<string, unknown> |
| 120 | delete jsonSchema['$schema'] |
| 121 | |
| 122 | return [ |
| 123 | toolDefinition.toolName, |
| 124 | { |
| 125 | inputSchema: jsonSchema, |
| 126 | description: toolDefinition.description, |
| 127 | endsAgentStep: toolDefinition.endsAgentStep, |
| 128 | exampleInputs: toolDefinition.exampleInputs, |
| 129 | }, |
| 130 | ] |
| 131 | }), |
| 132 | ) |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * Computes project file indexes (file tree and token scores) |
no outgoing calls
no test coverage detected