Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | import { Composio } from '@composio/core'; |
| 2 | import 'dotenv/config'; |
| 3 | |
| 4 | export const tool = 'HACKERNEWS_GET_USER'; |
| 5 | export const approvalTools = [tool, 'HACKERNEWS_GET_MAX_ITEM_ID']; |
| 6 | export const toolArguments = { username: 'pg' }; |
| 7 | export const multiArguments = { |
| 8 | tools: [ |
| 9 | { tool_slug: tool, arguments: toolArguments }, |
| 10 | { tool_slug: 'HACKERNEWS_GET_MAX_ITEM_ID', arguments: {} }, |
| 11 | ], |
| 12 | sync_response_to_workbench: false, |
| 13 | }; |
| 14 | |
| 15 | export function createComposio() { |
| 16 | const apiKey = process.env.COMPOSIO_API_KEY; |
| 17 | if (!apiKey) throw new Error('Set COMPOSIO_API_KEY before running this example'); |
| 18 | return new Composio({ apiKey, baseURL: process.env.COMPOSIO_BASE_URL }); |
| 19 | } |
| 20 | |
| 21 | export async function createApprovalSession(composio: Composio) { |
| 22 | return composio.create(`approvals-example-${crypto.randomUUID()}`, { |
| 23 | toolkits: ['hackernews'], |
| 24 | tools: { hackernews: { enable: approvalTools, requireApproval: approvalTools } }, |
| 25 | sandbox: { enable: false }, |
| 26 | }); |
| 27 | } |