Spaces:
Running
Running
| // Transforms the internal DB schema to target SDK formats | |
| function formatResponse(tool, targetFormat) { | |
| // Safety check | |
| if (!tool) return null; | |
| switch (targetFormat) { | |
| case 'gemini': | |
| // Gemini: Function Declarations | |
| return { | |
| name: tool.name.replace(/[^a-zA-Z0-9]/g, '_'), // Gemini strict naming | |
| description: tool.description, | |
| // In a real scenario, we would parse the README or code to get parameters. | |
| // For now, we return a generic schema so the Agent knows it exists. | |
| parameters: { type: "OBJECT", properties: {} } | |
| }; | |
| case 'openai': | |
| // OpenAI: Tools Array | |
| return { | |
| type: "function", | |
| function: { | |
| name: tool.name, | |
| description: tool.description, | |
| parameters: { type: "object", properties: {} } | |
| } | |
| }; | |
| case 'vscode': | |
| case 'claude': | |
| // Config for claude_desktop_config.json | |
| return { | |
| [tool.name]: { | |
| command: "npx", | |
| args: ["-y", tool.name] | |
| } | |
| }; | |
| default: | |
| // Default: Return the AgentQ Enhanced Schema | |
| return tool; | |
| } | |
| } | |
| module.exports = { formatResponse }; |