Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 22, 23:15 UTC
Fix examples
haxzie committed
Jun 19, 2025 at 19:35 UTC
23846256f5ca9d361da7519a7b81d5126a3bb29e
10 files changed
+20
-160
ts/examples/mastra/src/index.ts
+7
-7
@@ -27,21 +27,21 @@ const composio = new Composio({
27
* Attach beforeExecute and afterExecute hooks to the tools for logging
28
*/
29
const tools = await composio.tools.get('default', 'HACKERNEWS_GET_USER', {
30
- modifySchema: (toolSlug, toolkitSlug, schema) => {
30
+ modifySchema: ({ toolSlug, toolkitSlug, schema }) => {
31
console.log(
32
`🔄 Modifying schema for tool ${toolSlug}/${toolkitSlug} with schema ${JSON.stringify(schema)}`
33
);
34
return schema;
35
},
36
- beforeExecute: (toolSlug, toolkitSlug, input) => {
37
- console.log(`🔄 Executing tool ${toolSlug}/${toolkitSlug} with input ${JSON.stringify(input)}`);
38
- return input;
36
+ beforeExecute: ({ toolSlug, toolkitSlug, params }) => {
37
+ console.log(`🔄 Executing tool ${toolSlug}/${toolkitSlug} with input ${JSON.stringify(params)}`);
38
+ return params;
39
},
40
- afterExecute: (toolSlug, toolkitSlug, output) => {
40
+ afterExecute: ({ toolSlug, toolkitSlug, result }) => {
41
console.log(
42
- `✅ Tool ${toolSlug}/${toolkitSlug} executed successfully with output ${JSON.stringify(output)}`
42
+ `✅ Tool ${toolSlug}/${toolkitSlug} executed successfully with output ${JSON.stringify(result)}`
43
);
44
- return output;
44
+ return result;
45
},
46
});
47
ts/examples/modifiers/src/index.ts
+9
-9
@@ -10,14 +10,14 @@ const composio = new Composio({
10
11
const tools = await composio.tools.get('default', 'HACKERNEWS_GET_USER', {
12
// toolkit slug too
13
- modifySchema: (toolSlug, toolkitSlug, toolSchema) => {
13
+ modifySchema: ({ toolSlug, toolkitSlug, schema }) => {
14
if (toolSlug === 'HACKERNEWS_GET_USER') {
15
- toolSchema = {
16
- ...toolSchema,
15
+ schema = {
16
+ ...schema,
17
inputParameters: {
18
type: 'object',
19
properties: {
20
- ...toolSchema.inputParameters?.properties,
20
+ ...schema.inputParameters?.properties,
21
userId: {
22
type: 'string',
23
description: 'The user ID to get the user for',
@@ -27,7 +27,7 @@ const tools = await composio.tools.get('default', 'HACKERNEWS_GET_USER', {
27
};
28
}
29
30
- return toolSchema;
30
+ return schema;
31
},
32
});
33
@@ -47,17 +47,17 @@ const agenticTools = await vercel.tools.get(
47
// what is the type error i am getting here?
48
{ tools: ['HACKERNEWS_GET_USER'] },
49
{
50
- afterExecute: (toolSlug, toolkitSlug, result) => {
50
+ afterExecute: ({ toolSlug, toolkitSlug, result }) => {
51
// modify the result
52
return result;
53
},
54
- beforeExecute: (toolSlug, toolkitSlug, params) => {
54
+ beforeExecute: ({ toolSlug, toolkitSlug, params }) => {
55
// modify the params
56
return params;
57
},
58
- modifySchema: (toolSlug, toolkitSlug, toolSchema) => {
58
+ modifySchema: ({ toolSlug, toolkitSlug, schema }) => {
59
// modify the tool schema
60
- return toolSchema;
60
+ return schema;
61
},
62
}
63
);
ts/examples/openai/src/agents-api/index.ts
+2
-2
@@ -10,11 +10,11 @@ const composio = new Composio({
10
11
console.log(`🔄 Fetching tools from composio...`);
12
const tools = await composio.tools.get('default', 'HACKERNEWS_GET_USER', {
13
- beforeExecute: async (toolSlug, toolkitSlug, params) => {
13
+ beforeExecute: async ({ toolSlug, toolkitSlug, params }) => {
14
console.log(`🔄 Executing tool ${toolSlug} from toolkit ${toolkitSlug}...`);
15
return params;
16
},
17
- afterExecute: async (toolSlug, toolkitSlug, result) => {
17
+ afterExecute: async ({ toolSlug, toolkitSlug, result }) => {
18
console.log(`✅ Tool ${toolSlug} executed`);
19
return result;
20
},
ts/examples/openai/src/agents.ts
deleted
-11
@@ -1,11 +0,0 @@
1
-import { Composio } from '@composio/core';
2
-import { Agent, webSearchTool, fileSearchTool } from '@openai/agents';
3
-
4
-const composio = new Composio();
5
-
6
-const tools = await composio.tools.get('default', 'HACKERNEWS_GET_USER');
7
-
8
-const agent = new Agent({
9
- name: 'Travel assistant',
10
- tools: tools,
11
-});
ts/examples/openai/src/reponses-api/index.ts
+2
-2
@@ -26,11 +26,11 @@ const modelInputs = await composio.provider.handleResponse(
26
initialResponse,
27
{},
28
{
29
- beforeExecute: async (toolSlug, toolkitSlug, params) => {
29
+ beforeExecute: async ({ toolSlug, toolkitSlug, params }) => {
30
console.log(`🔄 Executing tool ${toolSlug} from toolkit ${toolkitSlug}...`);
31
return params;
32
},
33
- afterExecute: async (toolSlug, toolkitSlug, result) => {
33
+ afterExecute: async ({ toolSlug, toolkitSlug, result }) => {
34
console.log(`✅ Tool ${toolSlug} executed`);
35
return result;
36
},
ts/examples/telemetry/.env.example
deleted
-2
@@ -1,2 +0,0 @@
1
-COMPOSIO_API_KEY=
2
-OPENAI_API_KEY=
\ No newline at end of file
ts/examples/telemetry/README.md
deleted
-75
@@ -1,75 +0,0 @@
1
-# Vercel Example with Composio SDK
2
-
3
-This example demonstrates how to use the Composio SDK with Vercel's AI SDK to create an AI-powered application that can interact with HackerNews data.
4
-
5
-## Features
6
-
7
-- Integration with Composio SDK and Vercel AI SDK
8
-- HackerNews front page summarization using GPT-4
9
-- Streaming AI responses
10
-- TypeScript support
11
-
12
-## Prerequisites
13
-
14
-- [Node.js](https://nodejs.org/) (Latest LTS version recommended)
15
-- [pnpm](https://pnpm.io/) (v10.8.0 or later)
16
-- Composio API Key
17
-- OpenAI API Key
18
-
19
-## Getting Started
20
-
21
-1. Clone the repository and navigate to the example directory:
22
-
23
-```bash
24
-cd examples/vercel
25
-```
26
-
27
-2. Install dependencies:
28
-
29
-```bash
30
-pnpm install
31
-```
32
-
33
-3. Copy the `.env.example` file to `.env` and fill in your API keys:
34
-
35
-```bash
36
-cp .env.example .env
37
-```
38
-
39
-4. Update the `.env` file with your credentials:
40
-
41
-```env
42
-COMPOSIO_API_KEY=your_composio_api_key
43
-OPENAI_API_KEY=your_openai_api_key
44
-```
45
-
46
-5. Start the development server:
47
-
48
-```bash
49
-pnpm start
50
-```
51
-
52
-## How It Works
53
-
54
-This example showcases how to:
55
-
56
-1. Initialize the Composio SDK with the Vercel provider
57
-2. Use the HackerNews tool to fetch front page data
58
-3. Generate AI responses using OpenAI's GPT-4
59
-4. Handle tool calls and results in a chat-like interface
60
-
61
-## Dependencies
62
-
63
-- `@composio/core`: Core Composio SDK
64
-- `@composio/vercel`: Vercel integration for Composio
65
-- `@ai-sdk/openai`: OpenAI integration
66
-- `ai`: Vercel's AI SDK
67
-- TypeScript for type safety
68
-
69
-## License
70
-
71
-ISC
72
-
73
-## Support
74
-
75
-For questions and support, please refer to the [Composio documentation](https://docs.composio.dev) or open an issue in the repository.
ts/examples/telemetry/package.json
deleted
-25
@@ -1,25 +0,0 @@
1
-{
2
- "name": "telemetry-example",
3
- "private": true,
4
- "version": "0.1.10-alpha.0",
5
- "description": "",
6
- "main": "src/index.ts",
7
- "scripts": {
8
- "start": "COMPOSIO_LOG_LEVEL=debug NODE_ENV=test bun src/index.ts",
9
- "test": "echo \"Error: no test specified\" && exit 1"
10
- },
11
- "keywords": [],
12
- "author": "",
13
- "license": "ISC",
14
- "packageManager": "pnpm@10.8.0",
15
- "dependencies": {
16
- "@ai-sdk/openai": "^1.3.16",
17
- "@composio/core": "workspace:*",
18
- "@composio/vercel": "workspace:*",
19
- "ai": "^4.3.8"
20
- },
21
- "devDependencies": {
22
- "@types/bun": "^1.2.9",
23
- "typescript": "^5.8.3"
24
- }
25
-}
ts/examples/telemetry/src/index.ts
deleted
-12
@@ -1,12 +0,0 @@
1
-import { Composio, ConsoleTelemetryTransport } from '@composio/core';
2
-
3
-/**
4
- * Non agentic provider
5
- */
6
-const composio = new Composio({
7
- apiKey: process.env.COMPOSIO_API_KEY,
8
-});
9
-
10
-const tools = await composio.tools.get('default', 'HACKERNEWS_GET_USER');
11
-
12
-console.log(tools);
ts/examples/telemetry/tsconfig.json
deleted
-15
@@ -1,15 +0,0 @@
1
-{
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "ESNext",
5
- "declaration": true,
6
- "declarationDir": "./dist",
7
- "outDir": "./dist",
8
- "rootDir": "./src",
9
- "strict": true,
10
- "esModuleInterop": true,
11
- "moduleResolution": "node",
12
- "skipLibCheck": true
13
- },
14
- "include": ["src"]
15
-}