Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
chore(ts): add CommonJS example in ts/examples/cjs
jkomynoe6ee55af94aa
diff --git a/ts/examples/cjs/README.md b/ts/examples/cjs/README.mdnew file mode 100644index 000000000..6895bb1b7--- /dev/null+++ b/ts/examples/cjs/README.md@@ -0,0 +1,31 @@+# CJS Example++This example demonstrates how to use Composio SDK with CommonJS.++## Setup++1. **Install dependencies:**+ ```bash+ pnpm install+ ```++2. **Configure environment:**+ ```bash+ cp .env.example .env+ ```++ Then edit `.env` and add your API keys:+ - `COMPOSIO_API_KEY`: Get it from [Composio Dashboard](https://app.composio.dev)++## Running the Example++```bash+# Run the example+pnpm start+```++## Support++- [Documentation](https://docs.composio.dev)+- [Discord Community](https://discord.gg/composio)+- [GitHub Issues](https://github.com/composio/composio/issues)diff --git a/ts/examples/cjs/package.json b/ts/examples/cjs/package.jsonnew file mode 100644index 000000000..afd2be7dd--- /dev/null+++ b/ts/examples/cjs/package.json@@ -0,0 +1,24 @@+{+ "name": "cjs-example",+ "type": "commonjs",+ "private": true,+ "version": "0.1.0",+ "description": "Example project for CommonJS",+ "main": "src/index.ts",+ "scripts": {+ "start": "node ./src/index.cjs"+ },+ "keywords": ["composio", "example", "cjs"],+ "author": "",+ "license": "ISC",+ "packageManager": "[email protected]",+ "dependencies": {+ "@composio/core": "workspace:*",+ "dotenv": "^16.4.1",+ "zod": "catalog:"+ },+ "devDependencies": {+ "@types/bun": "^1.2.9",+ "typescript": "catalog:"+ }+}diff --git a/ts/examples/cjs/src/index.cjs b/ts/examples/cjs/src/index.cjsnew file mode 100644index 000000000..108959dfc--- /dev/null+++ b/ts/examples/cjs/src/index.cjs@@ -0,0 +1,35 @@+const { Composio } = require('@composio/core');+const { z } = require('zod/v3');+require('dotenv/config');++const composio = new Composio()++async function main() {+ console.log('Creating custom tool...');++ const tool = await composio.tools.createCustomTool({+ name: 'My Custom Tool',+ description: 'A custom tool that does something specific',+ slug: 'MY_CUSTOM_TOOL',+ inputParams: z.object({+ param1: z.string().describe('First parameter'),+ }),+ execute: async (_input) => {+ return {+ data: {+ result: 'Success!',+ },+ error: null,+ successful: true,+ };+ },+ });++ console.log('Custom tool created:', tool);+}++main()+ .catch(e => {+ console.error(e);+ process.exit(1);+ })diff --git a/ts/examples/cjs/tsconfig.json b/ts/examples/cjs/tsconfig.jsonnew file mode 100644index 000000000..f736a53ab--- /dev/null+++ b/ts/examples/cjs/tsconfig.json@@ -0,0 +1,16 @@+{+ "compilerOptions": {+ "target": "es2022",+ "module": "esnext",+ "declaration": true,+ "declarationDir": "./dist",+ "outDir": "./dist",+ "rootDir": "./src",+ "strict": true,+ "esModuleInterop": true,+ "moduleResolution": "bundler",+ "skipLibCheck": true,+ "resolveJsonModule": true+ },+ "include": ["src"]+}