UNPKG

@nomyx/assistant

Version:

A powerful assistant library and cli for your AI projects. works with Vertex AI (Claude and Gemini)

402 lines 29.2 kB
{ "generateAndExecuteCode": { "name": "generateAndExecuteCode", "input_schema": { "language": "string", "code": "string" }, "output_schema": { "result": "string", "error": "string" }, "code": "async function generateAndExecuteCode(language, code) {\n const tempFile = `temp_${Date.now()}.${language === 'python' ? 'py' : language === 'ruby' ? 'rb' : 'js'}`;\n \n let command;\n switch(language.toLowerCase()) {\n case 'javascript':\n command = `node ${tempFile}`;\n break;\n case 'python':\n command = `python ${tempFile}`;\n break;\n case 'ruby':\n command = `ruby ${tempFile}`;\n break;\n default:\n throw new Error(`Unsupported language: ${language}`);\n }\n\n try {\n await fs.writeFile(tempFile, code);\n const { stdout, stderr } = await execPromise(command);\n return { result: stdout, error: stderr };\n } catch (error) {\n return { result: '', error: error.message };\n } finally {\n await fs.unlink(tempFile).catch(() => {}); // Ignore errors if file doesn't exist\n }\n}\n\nconst { result, error } = await generateAndExecuteCode(params.language, params.code);\nreturn { result, error };", "description": "Generate and execute code in various programming languages" }, "executeBash": { "name": "executeBash", "input_schema": { "command": "string" }, "output_schema": { "output": "string" }, "code": "try {\n const { stdout, stderr } = await execPromise(params.command);\n return { output: stdout.trim() + (stderr ? '\\nError: ' + stderr.trim() : '') };\n} catch (error) {\n throw new Error(`Bash command failed: ${error.message}`);\n}", "description": "Execute a bash command and return its output" }, "readFile": { "name": "readFile", "input_schema": { "path": "string" }, "output_schema": { "content": "string" }, "code": "try {\n const content = await fs.readFile(params.path, 'utf8');\n return { content };\n} catch (error) {\n throw new Error(`Failed to read file: ${error.message}`);\n}", "description": "Read the contents of a file" }, "writeFile": { "name": "writeFile", "input_schema": { "path": "string", "content": "string" }, "output_schema": { "success": "boolean" }, "code": "try {\n await fs.writeFile(params.path, params.content, 'utf8');\n return { success: true };\n} catch (error) {\n throw new Error(`Failed to write file: ${error.message}`);\n}", "description": "Write content to a file" }, "searchFiles": { "name": "searchFiles", "input_schema": { "pattern": "string", "directory": "string" }, "output_schema": { "matches": "string" }, "code": "try {\n const { stdout, stderr } = await execPromise(`grep -r \"${params.pattern}\" ${params.directory}`);\n return { matches: stdout.trim() + (stderr ? '\\nError: ' + stderr.trim() : '') };\n} catch (error) {\n if (error.code === 1 && error.stdout === '') {\n return { matches: 'No matches found.' };\n }\n throw new Error(`File search failed: ${error.message}`);\n}", "description": "Search for a pattern in files within a directory" }, "searchAndReplace": { "name": "searchAndReplace", "input_schema": { "filePath": "string", "searchPattern": "string", "replaceText": "string" }, "output_schema": { "success": "boolean", "modifiedContent": "string" }, "code": "try {\n const content = await fs.readFile(params.filePath, 'utf8');\n const modifiedContent = content.replace(new RegExp(params.searchPattern, 'g'), params.replaceText);\n await fs.writeFile(params.filePath, modifiedContent, 'utf8');\n return { \n success: true, \n modifiedContent: modifiedContent \n };\n} catch (error) {\n throw new Error(`Search and replace failed: ${error.message}`);\n}", "description": "Search for a pattern in a file and replace all occurrences" }, "staticCodeAnalyzer": { "name": "staticCodeAnalyzer", "input_schema": { "filePath": "string" }, "output_schema": { "results": "array" }, "code": "const { filePath } = params;\nconst { logger } = context;\n\ntry {\n const fileContent = await fs.readFile(filePath, 'utf-8');\n const sourceFile = ts.createSourceFile(\n path.basename(filePath),\n fileContent,\n ts.ScriptTarget.Latest,\n true\n );\n\n const results = [{\n filename: path.basename(filePath),\n issues: []\n }];\n\n // Simple static analysis rules\n ts.forEachChild(sourceFile, node => {\n // Check for console.log statements\n if (ts.isCallExpression(node) &&\n ts.isPropertyAccessExpression(node.expression) &&\n node.expression.expression.getText() === 'console' &&\n node.expression.name.getText() === 'log') {\n results[0].issues.push({\n line: sourceFile.getLineAndCharacterOfPosition(node.getStart()).line + 1,\n character: sourceFile.getLineAndCharacterOfPosition(node.getStart()).character,\n message: 'Avoid using console.log in production code',\n severity: 'warning'\n });\n }\n\n // Check for empty catch blocks\n if (ts.isCatchClause(node) && \n ts.isBlock(node.block) && \n node.block.statements.length === 0) {\n results[0].issues.push({\n line: sourceFile.getLineAndCharacterOfPosition(node.getStart()).line + 1,\n character: sourceFile.getLineAndCharacterOfPosition(node.getStart()).character,\n message: 'Empty catch block detected',\n severity: 'warning'\n });\n }\n\n // Add more static analysis rules here...\n });\n\n logger.info(`Static code analysis completed for ${filePath}`);\n return { results };\n} catch (error) {\n logger.error(`Error during static code analysis: ${error}`);\n throw new Error(`Static code analysis failed: ${error}`);\n}", "description": "Perform static code analysis on a TypeScript file" }, "gitStatus": { "name": "gitStatus", "input_schema": {}, "output_schema": { "status": "string" }, "code": "try {\n const { stdout, stderr } = await execPromise('git status');\n return { status: stdout + stderr };\n} catch (error) {\n if (error instanceof Error) {\n throw new Error(`Git status failed: ${error.message}`);\n }\n throw new Error('Git status failed with an unknown error');\n}", "description": "Get the current Git status of the repository" }, "gitCommit": { "name": "gitCommit", "input_schema": { "message": "string" }, "output_schema": { "result": "string" }, "code": "try {\n const { stdout, stderr } = await execPromise(`git commit -m \"${params.message}\"`);\n return { result: stdout + stderr };\n} catch (error) {\n if (error instanceof Error) {\n throw new Error(`Git commit failed: ${error.message}`);\n }\n throw new Error('Git commit failed with an unknown error');\n}", "description": "Commit changes to the Git repository" }, "gitPush": { "name": "gitPush", "input_schema": { "remote": "string", "branch": "string" }, "output_schema": { "result": "string" }, "code": "try {\n const { stdout, stderr } = await execPromise(`git push ${params.remote} ${params.branch}`);\n return { result: stdout + stderr };\n} catch (error) {\n if (error instanceof Error) {\n throw new Error(`Git push failed: ${error.message}`);\n }\n throw new Error('Git push failed with an unknown error');\n}", "description": "Push changes to a remote Git repository" }, "gitPull": { "name": "gitPull", "input_schema": { "remote": "string", "branch": "string" }, "output_schema": { "result": "string" }, "code": "try {\n const { stdout, stderr } = await execPromise(`git pull ${params.remote} ${params.branch}`);\n return { result: stdout + stderr };\n} catch (error) {\n if (error instanceof Error) {\n throw new Error(`Git pull failed: ${error.message}`);\n }\n throw new Error('Git pull failed with an unknown error');\n}", "description": "Pull changes from a remote Git repository" }, "gitBranch": { "name": "gitBranch", "input_schema": { "operation": "string", "branchName": "string" }, "output_schema": { "result": "string" }, "code": "try {\n let command: string;\n switch (params.operation) {\n case 'create':\n command = `git branch ${params.branchName}`;\n break;\n case 'delete':\n command = `git branch -d ${params.branchName}`;\n break;\n case 'list':\n command = 'git branch';\n break;\n default:\n throw new Error(`Invalid branch operation: ${params.operation}`);\n }\n const { stdout, stderr } = await execPromise(command);\n return { result: stdout + stderr };\n} catch (error) {\n if (error instanceof Error) {\n throw new Error(`Git branch operation failed: ${error.message}`);\n }\n throw new Error('Git branch operation failed with an unknown error');\n}", "description": "Perform Git branch operations (create, delete, list)" }, "gitDiff": { "name": "gitDiff", "input_schema": { "target": "string" }, "output_schema": { "diff": "string" }, "code": "try {\n const { stdout, stderr } = await execPromise(`git diff ${params.target}`);\n return { diff: stdout + stderr };\n} catch (error) {\n if (error instanceof Error) {\n throw new Error(`Git diff failed: ${error.message}`);\n }\n throw new Error('Git diff failed with an unknown error');\n}", "description": "Show changes between commits, commit and working tree, etc" }, "gitClone": { "name": "gitClone", "input_schema": { "repositoryUrl": "string", "directory": "string" }, "output_schema": { "result": "string" }, "code": "try {\n const { stdout, stderr } = await execPromise(git clone ${params.repositoryUrl} ${params.directory});\n return { result: stdout + stderr };\n} catch (error) {\n throw new Error(Git clone failed: ${error.message});\n}", "description": "Clone a Git repository to a specified directory" }, "installDependencies": { "name": "installDependencies", "input_schema": { "packageManager": "string" }, "output_schema": { "result": "string" }, "code": "try {\n const command = params.packageManager === 'npm' ? 'npm install' : 'yarn install';\n const { stdout, stderr } = await execPromise(command);\n return { result: stdout + stderr };\n} catch (error) {\n throw new Error(Dependency installation failed: ${error.message});\n}", "description": "Install project dependencies using npm or yarn" }, "analyzeDbSchema": { "name": "analyzeDbSchema", "input_schema": { "dbType": "string", "connectionString": "string" }, "output_schema": { "schema": "object" }, "code": "try {\n // This is a placeholder. In a real implementation, you would use a database-specific\n // library to connect to the database and retrieve the schema.\n const { stdout, stderr } = await execPromise(`echo \"Analyzing ${params.dbType} schema for ${params.connectionString}\"`);\n return { schema: { tables: [], relationships: [] } };\n} catch (error) {\n if (error instanceof Error) {\n throw new Error(`Database schema analysis failed: ${error.message}`);\n }\n throw new Error('Database schema analysis failed with an unknown error');\n}", "description": "Analyze the schema of a database" }, "generateQuery": { "name": "generateQuery", "input_schema": { "dbType": "string", "schema": "object", "requirement": "string" }, "output_schema": { "query": "string" }, "code": "try {\n // This is a placeholder. In a real implementation, you would use AI or rule-based systems\n // to generate an optimized query based on the schema and requirement.\n const { stdout, stderr } = await execPromise(`echo \"Generating ${params.dbType} query for: ${params.requirement}\"`);\n return { query: `SELECT * FROM placeholder WHERE condition = true;` };\n} catch (error) {\n if (error instanceof Error) {\n throw new Error(`Query generation failed: ${error.message}`);\n }\n throw new Error('Query generation failed with an unknown error');\n}", "description": "Generate and optimize a database query based on requirements" }, "planDataMigration": { "name": "planDataMigration", "input_schema": { "sourceDbType": "string", "targetDbType": "string", "sourceSchema": "object", "targetSchema": "object" }, "output_schema": { "migrationPlan": "object" }, "code": "try {\n // This is a placeholder. In a real implementation, you would analyze the source and target schemas,\n // and generate a detailed migration plan.\n const { stdout, stderr } = await execPromise(`echo \"Planning migration from ${params.sourceDbType} to ${params.targetDbType}\"`);\n return { \n migrationPlan: { \n steps: [\n { description: \"Step 1: Export data from source database\" },\n { description: \"Step 2: Transform data to match target schema\" },\n { description: \"Step 3: Import data into target database\" },\n { description: \"Step 4: Verify data integrity\" }\n ] \n } \n };\n} catch (error) {\n if (error instanceof Error) {\n throw new Error(`Data migration planning failed: ${error.message}`);\n }\n throw new Error('Data migration planning failed with an unknown error');\n}", "description": "Plan a data migration between two databases" }, "generateApiDocs": { "name": "generateApiDocs", "input_schema": { "apiSpecPath": "string", "outputFormat": "string" }, "output_schema": { "documentation": "string" }, "code": "try {\n // This is a placeholder. In a real implementation, you would parse the API spec\n // and generate documentation in the specified format.\n const apiSpec = await fs.readFile(params.apiSpecPath, 'utf-8');\n const documentation = `API Documentation (${params.outputFormat}):\\n\\n${apiSpec}`;\n return { documentation };\n} catch (error) {\n if (error instanceof Error) {\n throw new Error(`API documentation generation failed: ${error.message}`);\n }\n throw new Error('API documentation generation failed with an unknown error');\n}", "description": "Generate API documentation from an API specification file" }, "runApiTests": { "name": "runApiTests", "input_schema": { "testSuitePath": "string", "apiBaseUrl": "string" }, "output_schema": { "testResults": "object" }, "code": "try {\n // This is a placeholder. In a real implementation, you would load and run\n // the API tests, then return the results.\n const testSuite = await fs.readFile(params.testSuitePath, 'utf-8');\n const testResults = {\n totalTests: 10,\n passed: 8,\n failed: 2,\n details: `Test suite: ${testSuite}\\nAPI Base URL: ${params.apiBaseUrl}`\n };\n return { testResults };\n} catch (error) {\n if (error instanceof Error) {\n throw new Error(`API testing failed: ${error.message}`);\n }\n throw new Error('API testing failed with an unknown error');\n}", "description": "Run automated tests for an API" }, "versionApi": { "name": "versionApi", "input_schema": { "currentVersion": "string", "changes": "object" }, "output_schema": { "newVersion": "string", "migrationPlan": "object" }, "code": "try {\n // This is a placeholder. In a real implementation, you would analyze the changes,\n // determine the new version number, and create a migration plan.\n const versionParts = params.currentVersion.split('.').map(Number);\n versionParts[2] += 1; // Increment patch version\n const newVersion = versionParts.join('.');\n const migrationPlan = {\n version: newVersion,\n steps: [\n { description: \"Update API version number in configuration files\" },\n { description: \"Apply changes to API endpoints\" },\n { description: \"Update API documentation\" },\n { description: \"Run regression tests\" }\n ]\n };\n return { newVersion, migrationPlan };\n} catch (error) {\n if (error instanceof Error) {\n throw new Error(`API versioning failed: ${error.message}`);\n }\n throw new Error('API versioning failed with an unknown error');\n}", "description": "Version an API based on changes and create a migration plan" }, "profileCode": { "name": "profileCode", "input_schema": { "filePath": "string", "language": "string" }, "output_schema": { "profileResult": "string" }, "code": "try {\n let command: string;\n switch (params.language.toLowerCase()) {\n case 'python':\n command = `python -m cProfile ${params.filePath}`;\n break;\n case 'javascript':\n command = `node --prof ${params.filePath} && node --prof-process isolate-*-v8.log > profile_output.txt && cat profile_output.txt`;\n break;\n default:\n throw new Error(`Unsupported language for profiling: ${params.language}`);\n }\n \n const { stdout, stderr } = await execPromise(command);\n return { profileResult: stdout + stderr };\n} catch (error) {\n if (error instanceof Error) {\n throw new Error(`Code profiling failed: ${error.message}`);\n }\n throw new Error('Code profiling failed with an unknown error');\n}", "description": "Profile code execution and return performance metrics" }, "analyzeMemoryUsage": { "name": "analyzeMemoryUsage", "input_schema": { "filePath": "string", "language": "string" }, "output_schema": { "memoryAnalysis": "string" }, "code": "try {\n let command: string;\n switch (params.language.toLowerCase()) {\n case 'python':\n command = `python -m memory_profiler ${params.filePath}`;\n break;\n case 'javascript':\n command = `node --expose-gc --max-old-space-size=4096 ${params.filePath}`;\n break;\n default:\n throw new Error(`Unsupported language for memory analysis: ${params.language}`);\n }\n \n const { stdout, stderr } = await execPromise(command);\n return { memoryAnalysis: stdout + stderr };\n} catch (error) {\n if (error instanceof Error) {\n throw new Error(`Memory usage analysis failed: ${error.message}`);\n }\n throw new Error('Memory usage analysis failed with an unknown error');\n}", "description": "Analyze memory usage of code execution" }, "suggestPerformanceImprovements": { "name": "suggestPerformanceImprovements", "input_schema": { "filePath": "string", "profileResult": "string", "memoryAnalysis": "string" }, "output_schema": { "suggestions": "string" }, "code": "try {\n // This is a placeholder. In a real implementation, you would analyze the profile results\n // and memory analysis to generate meaningful suggestions.\n const fileContent = await fs.readFile(params.filePath, 'utf-8');\n const suggestions = `\nBased on the profile results and memory analysis, here are some suggestions:\n1. Optimize the most time-consuming functions\n2. Reduce memory allocations in frequently called functions\n3. Consider using more efficient data structures\n4. Implement caching for expensive operations\n5. Review and optimize any nested loops\n `;\n return { suggestions };\n} catch (error) {\n if (error instanceof Error) {\n throw new Error(`Generating performance improvement suggestions failed: ${error.message}`);\n }\n throw new Error('Generating performance improvement suggestions failed with an unknown error');\n}", "description": "Suggest performance improvements based on profiling and memory analysis results" }, "scanVulnerabilities": { "name": "scanVulnerabilities", "input_schema": { "projectPath": "string", "scanType": "string" }, "output_schema": { "vulnerabilities": "object" }, "code": "try {\n // This is a placeholder. In a real implementation, you would use a security scanning tool\n // like OWASP ZAP, Snyk, or a custom script to perform the vulnerability scan.\n const { stdout, stderr } = await execPromise(`echo \"Scanning ${params.projectPath} for ${params.scanType} vulnerabilities\"`);\n return { \n vulnerabilities: {\n high: 2,\n medium: 5,\n low: 10,\n details: \"Placeholder vulnerability scan results\"\n } \n };\n} catch (error) {\n if (error instanceof Error) {\n throw new Error(`Vulnerability scan failed: ${error.message}`);\n }\n throw new Error('Vulnerability scan failed with an unknown error');\n}", "description": "Scan a project for security vulnerabilities" }, "checkSecureCoding": { "name": "checkSecureCoding", "input_schema": { "filePath": "string", "language": "string" }, "output_schema": { "issues": "array" }, "code": "try {\n // This is a placeholder. In a real implementation, you would use a static analysis tool\n // or a custom script to check for secure coding practices.\n const fileContent = await fs.readFile(params.filePath, 'utf-8');\n const issues = [\n { line: 10, message: \"Potential SQL injection vulnerability\" },\n { line: 25, message: \"Insecure random number generation\" },\n { line: 42, message: \"Hardcoded credentials detected\" }\n ];\n return { issues };\n} catch (error) {\n if (error instanceof Error) {\n throw new Error(`Secure coding check failed: ${error.message}`);\n }\n throw new Error('Secure coding check failed with an unknown error');\n}", "description": "Check a file for secure coding practices" }, "analyzeDependencies": { "name": "analyzeDependencies", "input_schema": { "projectPath": "string" }, "output_schema": { "vulnerableDependencies": "array" }, "code": "try {\n // This is a placeholder. In a real implementation, you would use a tool like npm audit,\n // yarn audit, or a third-party service to check for vulnerable dependencies.\n const { stdout, stderr } = await execPromise(`echo \"Analyzing dependencies in ${params.projectPath}\"`);\n const vulnerableDependencies = [\n { name: \"lodash\", version: \"4.17.15\", vulnerabilities: [\"CVE-2020-8203\"] },\n { name: \"axios\", version: \"0.19.2\", vulnerabilities: [\"CVE-2020-28168\"] }\n ];\n return { vulnerableDependencies };\n} catch (error) {\n if (error instanceof Error) {\n throw new Error(`Dependency analysis failed: ${error.message}`);\n }\n throw new Error('Dependency analysis failed with an unknown error');\n}", "description": "Analyze project dependencies for known vulnerabilities" }, "generateCiCdPipeline": { "name": "generateCiCdPipeline", "input_schema": { "projectType": "string", "cicdPlatform": "string" }, "output_schema": { "pipelineConfig": "string" }, "code": "try {\n // This is a placeholder. In a real implementation, you would generate a CI/CD pipeline\n // configuration based on the project type and CI/CD platform.\n const pipelineConfig = `\n# ${params.cicdPlatform} CI/CD Pipeline for ${params.projectType}\nname: CI/CD\n\non:\n push:\n branches: [ main ]\n pull_request:\n branches: [ main ]\n\njobs:\n build:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v2\n - name: Set up environment\n run: echo \"Setting up environment for ${params.projectType}\"\n - name: Install dependencies\n run: echo \"Installing dependencies\"\n - name: Run tests\n run: echo \"Running tests\"\n - name: Build\n run: echo \"Building ${params.projectType} project\"\n - name: Deploy\n run: echo \"Deploying to production\"\n `;\n return { pipelineConfig };\n} catch (error) {\n if (error instanceof Error) {\n throw new Error(`CI/CD pipeline generation failed: ${error.message}`);\n }\n throw new Error('CI/CD pipeline generation failed with an unknown error');\n}", "description": "Generate a CI/CD pipeline configuration" }, "createBuildScript": { "name": "createBuildScript", "input_schema": { "projectType": "string", "buildSteps": { "type": "array", "items": { "type": "string" } } }, "output_schema": { "buildScript": "string" }, "code": "try {\n // This is a placeholder. In a real implementation, you would create a build script\n // based on the project type and specified build steps.\n const buildScript = `\n#!/bin/bash\nset -e\n\necho \"Building ${params.projectType} project\"\n\n${params.buildSteps.map((step, index) => `echo \"Step ${index + 1}: ${step}\"\\n${step}`).join('\\n\\n')}\n\necho \"Build completed successfully\"\n `;\n return { buildScript };\n} catch (error) {\n if (error instanceof Error) {\n throw new Error(`Build script creation failed: ${error.message}`);\n }\n throw new Error('Build script creation failed with an unknown error');\n}", "description": "Create a build script for the project" }, "analyzeTestCoverage": { "name": "analyzeTestCoverage", "input_schema": { "projectPath": "string", "testCommand": "string" }, "output_schema": { "coverageReport": "object" }, "code": "try {\n // This is a placeholder. In a real implementation, you would run the tests\n // and analyze the coverage using a tool like Istanbul or Jest.\n const { stdout, stderr } = await execPromise(`cd ${params.projectPath} && ${params.testCommand}`);\n const coverageReport = {\n overallCoverage: '85%',\n statementCoverage: '90%',\n branchCoverage: '80%',\n functionCoverage: '85%',\n lineCoverage: '87%',\n details: stdout\n };\n return { coverageReport };\n} catch (error) {\n if (error instanceof Error) {\n throw new Error(`Test coverage analysis failed: ${error.message}`);\n }\n throw new Error('Test coverage analysis failed with an unknown error');\n}", "description": "Analyze test coverage for the project" }, "generateImplementationPlan": { "name": "generateImplementationPlan", "input_schema": { "requirements": "array", "projectType": "string" }, "output_schema": { "implementationPlan": "object" }, "code": "try {\n // This is a placeholder. In a real implementation, you would analyze the requirements\n // and generate an implementation plan based on the project type.\n const implementationPlan = {\n projectType: params.projectType,\n requirements: params.requirements,\n steps: [\n { description: \"Analyze requirements and constraints\" },\n { description: \"Design architecture and data model\" },\n { description: \"Implement core features\" },\n { description: \"Write tests and perform QA\" },\n { description: \"Deploy to production and monitor performance\" }\n ]\n };\n return { implementationPlan };\n} catch (error) {\n if (error instanceof Error) {\n throw new Error(`Implementation plan generation failed: ${error.message}`);\n }\n throw new Error('Implementation plan generation failed with an unknown error');\n}", "description": "Generate an implementation plan based on project requirements" }, "callAI": { "name": "callAI", "input_schema": { "system_prompt": "string", "user_prompt": "string", "provider": "string", "model": "string" }, "output_schema": { "result": "string" }, "code": "try {\n // This is a placeholder. In a real implementation, you would call an AI model\n // with the input data and return the prediction.\n const { stdout, stderr } = await execPromise(`echo \"Calling AI model: ${params.model}\"`);\n return { prediction: { result: 'Placeholder prediction', details: stdout } };\n} catch (error) {\n if (error instanceof Error) {\n throw new Error(`AI model call failed: ${error.message}`);\n }\n throw new Error('AI model call failed with an unknown error');\n}", "description": "Call the provider and AI model with system and user prompts" }, "search_google": { "name": "search_google", "input_schema": { "query": "string" }, "output_schema": { "results": "string" }, "code": "try {\n const config = {\n GOOGLE_API_KEY: process.env.GOOGLE_API_KEY,\n GOOGLE_CX_ID: process.env.GOOGLE_CX_ID\n };\n const axios = require('axios');\n const response = await axios.get(`https://www.googleapis.com/customsearch/v1?key=${config.GOOGLE_API_KEY}&cx=${config.GOOGLE_CX_ID}&q=${encodeURIComponent(params.query)}`);\n const results = response.data.items.map((item) => ({\n title: item.title,\n link: item.link\n }));\n return { results: JSON.stringify(results) };\n} catch (error) {\n if (error instanceof Error) {\n throw new Error(`Google search failed: ${error.message}`);\n }\n throw new Error('Google search failed with an unknown error');\n}", "description": "Perform a Google search using the given query" } }