@devries-cameron20 / composio Mirror · read-only
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.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 03:37 UTC

next
sh 252 lines 6.78 KB
Raw
1 #!/bin/bash
2
3 # Check if provider name is provided
4 if [ -z "$1" ]; then
5 echo "Please provide a provider name"
6 echo "Usage: npm run create-provider <provider-name> [--agentic]"
7 exit 1
8 fi
9
10 TOOLSET_NAME=$1
11 TOOLSET_PATH="ts/packages/providers/$TOOLSET_NAME"
12 CAPITAL_TOOLSET_NAME="$(tr '[:lower:]' '[:upper:]' <<< ${TOOLSET_NAME:0:1})${TOOLSET_NAME:1}"
13
14 # Check if provider should be agentic
15 IS_AGENTIC=false
16 if [ "$2" = "--agentic" ]; then
17 IS_AGENTIC=true
18 fi
19
20 # Create directory structure
21 mkdir -p "$TOOLSET_PATH/src"
22
23 # Create package.json
24 cat > "$TOOLSET_PATH/package.json" << EOL
25 {
26 "name": "@composio/${TOOLSET_NAME}",
27 "version": "0.1.0",
28 "description": "${IS_AGENTIC:+Agentic }Provider for ${TOOLSET_NAME} in Composio SDK",
29 "main": "src/index.ts",
30 "type": "module",
31 "publishConfig": {
32 "access": "public",
33 "main": "dist/index.mjs",
34 "types": "dist/index.d.mts"
35 },
36 "exports": {
37 ".": {
38 "types": "./dist/index.d.mts",
39 "default": "./dist/index.mjs"
40 }
41 },
42 "files": [
43 "README.md",
44 "dist"
45 ],
46 "scripts": {
47 "build": "tsdown",
48 "test": "vitest run"
49 },
50 "keywords": ["composio", "provider", "${TOOLSET_NAME}"],
51 "author": "",
52 "license": "ISC",
53 "peerDependencies": {
54 "@composio/core": "^0.1.0"
55 },
56 "devDependencies": {
57 "@composio/core": "workspace:*",
58 "tsdown": "catalog:",
59 "typescript": "catalog:"
60 }
61 }
62 EOL
63
64 # Create tsconfig.json
65 cat > "$TOOLSET_PATH/tsconfig.json" << EOL
66 {
67 "extends": "../../../tsconfig.base.json",
68 "compilerOptions": {
69 "target": "es2022",
70 "module": "esnext",
71 "declaration": true,
72 "declarationDir": "./dist",
73 "outDir": "./dist",
74 "strict": true,
75 "esModuleInterop": true,
76 "moduleResolution": "bundler",
77 "skipLibCheck": true,
78 "resolveJsonModule": true
79 },
80 "include": ["src"]
81 }
82 EOL
83
84 # Create tsdown.config.ts
85 cat > "$TOOLSET_PATH/tsdown.config.ts" << EOL
86 import { defineConfig } from 'tsdown';
87 import { baseConfig } from '../../../../tsdown.config.base.ts';
88
89 export default defineConfig({
90 ...baseConfig,
91 tsconfig: 'tsconfig.json',
92 });
93 EOL
94
95 # Create src/index.ts
96 cat > "$TOOLSET_PATH/src/index.ts" << EOL
97 /**
98 * ${CAPITAL_TOOLSET_NAME} Provider
99 *
100 * This provider provides a set of tools for interacting with ${CAPITAL_TOOLSET_NAME}.
101 *
102 * @packageDocumentation
103 * @module providers/${TOOLSET_NAME}
104 */
105 import { ${IS_AGENTIC:+BaseAgenticProvider}${!IS_AGENTIC:+BaseNonAgenticProvider}, Tool${IS_AGENTIC:+, ExecuteToolFn} } from '@composio/core';
106
107 ${IS_AGENTIC:+interface ${CAPITAL_TOOLSET_NAME}Tool {
108 // Add your tool type here
109 }}${!IS_AGENTIC:+interface ${CAPITAL_TOOLSET_NAME}Tool {
110 // Add your tool type here
111 }}
112
113 ${IS_AGENTIC:+interface ${CAPITAL_TOOLSET_NAME}ToolCollection {
114 // Add your tool collection type here
115 }}${!IS_AGENTIC:+type ${CAPITAL_TOOLSET_NAME}ToolCollection = Array<${CAPITAL_TOOLSET_NAME}Tool>}
116
117 export class ${CAPITAL_TOOLSET_NAME}Provider extends ${IS_AGENTIC:+BaseAgenticProvider}${!IS_AGENTIC:+BaseNonAgenticProvider}<${CAPITAL_TOOLSET_NAME}ToolCollection, ${CAPITAL_TOOLSET_NAME}Tool> {
118 readonly name = '${TOOLSET_NAME}';
119
120 /**
121 * Wrap a tool in the ${TOOLSET_NAME} format.
122 * @param tool - The tool to wrap.
123 * @returns The wrapped tool.
124 */
125 ${IS_AGENTIC:+wrapTool(tool: Tool, executeTool: ExecuteToolFn): ${CAPITAL_TOOLSET_NAME}Tool {
126 return {
127 // Implement your tool wrapping logic here
128 } as ${CAPITAL_TOOLSET_NAME}Tool;
129 }}${!IS_AGENTIC:+wrapTool(tool: Tool): ${CAPITAL_TOOLSET_NAME}Tool {
130 return {
131 // Implement your tool wrapping logic here
132 } as ${CAPITAL_TOOLSET_NAME}Tool;
133 }}
134
135 /**
136 * Wrap a list of tools in the ${TOOLSET_NAME} format.
137 * @param tools - The tools to wrap.
138 * @returns The wrapped tools.
139 */
140 ${IS_AGENTIC:+wrapTools(tools: Tool[], executeTool: ExecuteToolFn): ${CAPITAL_TOOLSET_NAME}ToolCollection {
141 return tools.reduce((acc, tool) => {
142 // Implement your tool collection wrapping logic here
143 return acc;
144 }, {} as ${CAPITAL_TOOLSET_NAME}ToolCollection);
145 }}${!IS_AGENTIC:+wrapTools(tools: Tool[]): ${CAPITAL_TOOLSET_NAME}ToolCollection {
146 return tools.map(tool => this.wrapTool(tool));
147 }}
148 }
149 EOL
150
151 # Create README.md
152 cat > "$TOOLSET_PATH/README.md" << EOL
153 # @composio/${TOOLSET_NAME}
154
155 ${IS_AGENTIC:+Agentic }Provider for ${CAPITAL_TOOLSET_NAME} in Composio SDK.
156
157 ## Features
158
159 ${IS_AGENTIC:+- **Full Modifier Support**: Support for both schema and execution modifiers
160 - **Tool Execution**: Execute tools with proper parameter handling
161 - **Type Safety**: Full TypeScript support with proper type definitions}${!IS_AGENTIC:+- **Schema Modifiers**: Support for transforming tool schemas
162 - **Type Safety**: Full TypeScript support with proper type definitions}
163
164 ## Installation
165
166 \`\`\`bash
167 npm install @composio/${TOOLSET_NAME}
168 # or
169 yarn add @composio/${TOOLSET_NAME}
170 # or
171 pnpm add @composio/${TOOLSET_NAME}
172 \`\`\`
173
174 ## Quick Start
175
176 \`\`\`typescript
177 import { Composio } from '@composio/core';
178 import { ${CAPITAL_TOOLSET_NAME}Provider } from '@composio/${TOOLSET_NAME}';
179
180 // Initialize Composio with ${CAPITAL_TOOLSET_NAME} provider
181 const composio = new Composio({
182 apiKey: 'your-composio-api-key',
183 provider: new ${CAPITAL_TOOLSET_NAME}Provider(),
184 });
185
186 // Get available tools
187 const tools = await composio.tools.get('user123', {
188 toolkits: ['gmail', 'googlecalendar'],
189 limit: 10,
190 });
191 \`\`\`
192
193 ## Usage Examples
194
195 ### Basic Example
196
197 \`\`\`typescript
198 import { Composio } from '@composio/core';
199 import { ${CAPITAL_TOOLSET_NAME}Provider } from '@composio/${TOOLSET_NAME}';
200
201 // Initialize Composio
202 const composio = new Composio({
203 apiKey: process.env.COMPOSIO_API_KEY,
204 provider: new ${CAPITAL_TOOLSET_NAME}Provider(),
205 });
206
207 // Get tools
208 const tools = await composio.tools.get('user123', {
209 toolkits: ['gmail'],
210 });
211
212 // Use tools with ${CAPITAL_TOOLSET_NAME}
213 // Add your usage example here
214 \`\`\`
215
216 ## API Reference
217
218 ### ${CAPITAL_TOOLSET_NAME}Provider Class
219
220 The \`${CAPITAL_TOOLSET_NAME}Provider\` class extends \`${IS_AGENTIC:+BaseAgenticProvider}${!IS_AGENTIC:+BaseNonAgenticProvider}\` and provides ${TOOLSET_NAME}-specific functionality.
221
222 #### Methods
223
224 ##### \`wrapTool(tool: Tool${IS_AGENTIC:+, executeTool: ExecuteToolFn}): ${CAPITAL_TOOLSET_NAME}Tool\`
225
226 Wraps a tool in the ${TOOLSET_NAME} format.
227
228 \`\`\`typescript
229 const tool = provider.wrapTool(composioTool${IS_AGENTIC:+, executeTool});
230 \`\`\`
231
232 ## Contributing
233
234 We welcome contributions! Please see our [Contributing Guide](../../CONTRIBUTING.md) for more details.
235
236 ## License
237
238 ISC License
239
240 ## Support
241
242 For support, please visit our [Documentation](https://docs.composio.dev) or join our [Discord Community](https://discord.gg/composio).
243 EOL
244
245 # Make the script executable
246 chmod +x "$TOOLSET_PATH"
247
248 # Install dependencies using pnpm
249 cd "$TOOLSET_PATH" && pnpm install
250
251 echo "✨ Created new ${IS_AGENTIC:+agentic }provider at $TOOLSET_PATH"
252 echo "✨ Dependencies installed successfully"