| 782 | middleware: [ |
| 783 | { |
| 784 | async transformParams(args) { |
| 785 | if (args.type === "stream") { |
| 786 | // @ts-expect-error - prompt types are compatible at runtime |
| 787 | args.params.prompt = ProviderTransform.message(args.params.prompt, model) |
| 788 | } |
| 789 | // Transform tool schemas for provider compatibility |
| 790 | if (args.params.tools && Array.isArray(args.params.tools)) { |
| 791 | args.params.tools = args.params.tools.map((tool: any) => { |
| 792 | // Tools at middleware level have inputSchema, not parameters |
| 793 | if (tool.inputSchema && typeof tool.inputSchema === "object") { |
| 794 | // Transform the inputSchema for provider compatibility |
| 795 | return { |
| 796 | ...tool, |
| 797 | inputSchema: ProviderTransform.schema(model, tool.inputSchema), |
| 798 | } |
| 799 | } |
| 800 | // If no inputSchema, return tool unchanged |
| 801 | return tool |
| 802 | }) |
| 803 | } |
| 804 | return args.params |
| 805 | }, |
| 806 | }, |
| 807 | ], |
| 808 | }), |