@devries-cameron20 / composio-1 / commits / e6ee55af9
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

chore(ts): add CommonJS example in ts/examples/cjs

jkomyno committed Dec 3, 2025 at 23:23 UTC e6ee55af94aa5c15afad74e2e803705f51ec3f17
4 files changed +106
ts/examples/cjs/README.md new
+31
@@ -0,0 +1,31 @@
1 +# CJS Example
2 +
3 +This example demonstrates how to use Composio SDK with CommonJS.
4 +
5 +## Setup
6 +
7 +1. **Install dependencies:**
8 + ```bash
9 + pnpm install
10 + ```
11 +
12 +2. **Configure environment:**
13 + ```bash
14 + cp .env.example .env
15 + ```
16 +
17 + Then edit `.env` and add your API keys:
18 + - `COMPOSIO_API_KEY`: Get it from [Composio Dashboard](https://app.composio.dev)
19 +
20 +## Running the Example
21 +
22 +```bash
23 +# Run the example
24 +pnpm start
25 +```
26 +
27 +## Support
28 +
29 +- [Documentation](https://docs.composio.dev)
30 +- [Discord Community](https://discord.gg/composio)
31 +- [GitHub Issues](https://github.com/composio/composio/issues)
ts/examples/cjs/package.json new
+24
@@ -0,0 +1,24 @@
1 +{
2 + "name": "cjs-example",
3 + "type": "commonjs",
4 + "private": true,
5 + "version": "0.1.0",
6 + "description": "Example project for CommonJS",
7 + "main": "src/index.ts",
8 + "scripts": {
9 + "start": "node ./src/index.cjs"
10 + },
11 + "keywords": ["composio", "example", "cjs"],
12 + "author": "",
13 + "license": "ISC",
14 + "packageManager": "pnpm@10.17.0",
15 + "dependencies": {
16 + "@composio/core": "workspace:*",
17 + "dotenv": "^16.4.1",
18 + "zod": "catalog:"
19 + },
20 + "devDependencies": {
21 + "@types/bun": "^1.2.9",
22 + "typescript": "catalog:"
23 + }
24 +}
ts/examples/cjs/src/index.cjs new
+35
@@ -0,0 +1,35 @@
1 +const { Composio } = require('@composio/core');
2 +const { z } = require('zod/v3');
3 +require('dotenv/config');
4 +
5 +const composio = new Composio()
6 +
7 +async function main() {
8 + console.log('Creating custom tool...');
9 +
10 + const tool = await composio.tools.createCustomTool({
11 + name: 'My Custom Tool',
12 + description: 'A custom tool that does something specific',
13 + slug: 'MY_CUSTOM_TOOL',
14 + inputParams: z.object({
15 + param1: z.string().describe('First parameter'),
16 + }),
17 + execute: async (_input) => {
18 + return {
19 + data: {
20 + result: 'Success!',
21 + },
22 + error: null,
23 + successful: true,
24 + };
25 + },
26 + });
27 +
28 + console.log('Custom tool created:', tool);
29 +}
30 +
31 +main()
32 + .catch(e => {
33 + console.error(e);
34 + process.exit(1);
35 + })
ts/examples/cjs/tsconfig.json new
+16
@@ -0,0 +1,16 @@
1 +{
2 + "compilerOptions": {
3 + "target": "es2022",
4 + "module": "esnext",
5 + "declaration": true,
6 + "declarationDir": "./dist",
7 + "outDir": "./dist",
8 + "rootDir": "./src",
9 + "strict": true,
10 + "esModuleInterop": true,
11 + "moduleResolution": "bundler",
12 + "skipLibCheck": true,
13 + "resolveJsonModule": true
14 + },
15 + "include": ["src"]
16 +}