@devries-cameron20 / composio-1 / commits / bb32cc2d8
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: Update Openai dependencies to v5 and deprecate assistant API helper methods (#1878)

Musthaq Ahamad committed Aug 27, 2025 at 13:42 UTC bb32cc2d8f96a10e49e9366cc168012abba30a3e
15 files changed +177 -381
.changeset/lemon-brooms-hunt.md new
+7
@@ -0,0 +1,7 @@
1 +---
2 +'@composio/core': patch
3 +'@composio/openai': patch
4 +'@composio/openai-agents': patch
5 +---
6 +
7 +Bump openai responses and deprecate openai assistant
pnpm-lock.yaml
+88 -46
@@ -296,7 +296,7 @@ importers:
296 version: link:../../packages/providers/google
297 '@google/genai':
298 specifier: ^1.1.0
299 - version: 1.5.1(@modelcontextprotocol/sdk@1.13.0)
299 + version: 1.5.1(@modelcontextprotocol/sdk@1.17.4)
300 dotenv:
301 specifier: ^16.4.1
302 version: 16.5.0
@@ -423,14 +423,14 @@ importers:
423 specifier: workspace:*
424 version: link:../../packages/providers/openai-agents
425 '@openai/agents':
426 - specifier: ^0.0.7
427 - version: 0.0.7(ws@8.18.2)(zod@3.25.67)
426 + specifier: ^0.0.17
427 + version: 0.0.17(ws@8.18.2)(zod@3.25.67)
428 dotenv:
429 specifier: ^16.4.1
430 version: 16.5.0
431 openai:
432 - specifier: ^4.94.0
433 - version: 4.104.0(ws@8.18.2)(zod@3.25.67)
432 + specifier: ^5.16.0
433 + version: 5.16.0(ws@8.18.2)(zod@3.25.67)
434 zod:
435 specifier: ^3.24.2
436 version: 3.25.67
@@ -652,8 +652,8 @@ importers:
652 specifier: ^4.1.2
653 version: 4.1.2
654 openai:
655 - specifier: ^4.94.0
656 - version: 4.104.0(ws@8.18.2)(zod@3.25.67)
655 + specifier: ^5.16.0
656 + version: 5.16.0(ws@8.18.2)(zod@3.25.67)
657 pusher-js:
658 specifier: ^8.4.0
659 version: 8.4.0
@@ -750,7 +750,7 @@ importers:
750 dependencies:
751 '@google/genai':
752 specifier: ^1.1.0
753 - version: 1.5.1(@modelcontextprotocol/sdk@1.13.0)
753 + version: 1.5.1(@modelcontextprotocol/sdk@1.17.4)
754 devDependencies:
755 '@composio/core':
756 specifier: workspace:*
@@ -766,7 +766,7 @@ importers:
766 dependencies:
767 '@langchain/core':
768 specifier: ^0.3.63
769 - version: 0.3.63(openai@5.5.1(ws@8.18.2)(zod@3.25.67))
769 + version: 0.3.63(openai@5.16.0(ws@8.18.2)(zod@3.25.67))
770 devDependencies:
771 '@composio/core':
772 specifier: workspace:*
@@ -803,8 +803,8 @@ importers:
803 ts/packages/providers/openai:
804 dependencies:
805 openai:
806 - specifier: ^4.3.8
807 - version: 4.104.0(ws@8.18.2)(zod@3.25.67)
806 + specifier: ^5.16.0
807 + version: 5.16.0(ws@8.18.2)(zod@3.25.67)
808 devDependencies:
809 '@composio/core':
810 specifier: workspace:*
@@ -822,8 +822,8 @@ importers:
822 ts/packages/providers/openai-agents:
823 dependencies:
824 '@openai/agents':
825 - specifier: ^0.0.7
826 - version: 0.0.7(ws@8.18.2)(zod@3.25.67)
825 + specifier: ^0.0.17
826 + version: 0.0.17(ws@8.18.2)(zod@3.25.67)
827 devDependencies:
828 '@composio/core':
829 specifier: workspace:*
@@ -2222,6 +2222,10 @@ packages:
2222 resolution: {integrity: sha512-P5FZsXU0kY881F6Hbk9GhsYx02/KgWK1DYf7/tyE/1lcFKhDYPQR9iYjhQXJn+Sg6hQleMo3DB7h7+p4wgp2Lw==}
2223 engines: {node: '>=18'}
2224
2225 + '@modelcontextprotocol/sdk@1.17.4':
2226 + resolution: {integrity: sha512-zq24hfuAmmlNZvik0FLI58uE5sriN0WWsQzIlYnzSuKDAHFqJtBFrl/LfB1NLgJT5Y7dEBzaX4yAKqOPrcetaw==}
2227 + engines: {node: '>=18'}
2228 +
2229 '@msgpackr-extract/msgpackr-extract-darwin-arm64@3.0.3':
2230 resolution: {integrity: sha512-QZHtlVgbAdy2zAqNA9Gu1UpIuI8Xvsd1v8ic6B2pZmeFnFcMWiPLfWXh7TVw4eGEZ/C9TH281KwhVoeQUKbyjw==}
2231 cpu: [arm64]
@@ -2315,22 +2319,28 @@ packages:
2319 resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==}
2320 engines: {node: '>= 8'}
2321
2318 - '@openai/agents-core@0.0.7':
2319 - resolution: {integrity: sha512-qbJ0w20hTMUJM97q9aGWchr7kyNo35emvjKiVjCW/grR4sMJo1fLia4bE52tjCQGo8EZJBJ9bkjXFSqETjdJYw==}
2322 + '@openai/agents-core@0.0.17':
2323 + resolution: {integrity: sha512-+V8rtwq8OtvCvXIVN/8ZFJNfQXLeCpeaBuFwJY7QBa44lIdMSB3vULcUVm1L7bTGKeVKpdB8GDky64hOFG4w7Q==}
2324 peerDependencies:
2325 zod: ^3.25.40
2326 peerDependenciesMeta:
2327 zod:
2328 optional: true
2329
2326 - '@openai/agents-openai@0.0.7':
2327 - resolution: {integrity: sha512-bWlJUZ6VutBnuESd74i9ttpIsfbw9kuH6mhHhN5bNgUjmbQfxM+2aUBfyxXGzr4mEvBkAuKiyAs3DX1shqOBdQ==}
2330 + '@openai/agents-openai@0.0.17':
2331 + resolution: {integrity: sha512-gGpcAWXh858HiNI51Nhl0MxM66asG0mv1LGASwB4jfzP7/GjM9k0on/ZlMBffM+6HID1zuDDYPbETD2y4XTY4w==}
2332 + peerDependencies:
2333 + zod: ^3.25.40
2334
2329 - '@openai/agents-realtime@0.0.7':
2330 - resolution: {integrity: sha512-ndPVQpOIX0J+C5wYo+YUb68q4zrXTIbQH/VS24qSIo9fxJokSxwS5P5hNSxDrdQ3+UlYyx/s1Xu6zRCE11H63Q==}
2335 + '@openai/agents-realtime@0.0.17':
2336 + resolution: {integrity: sha512-9yxe93XKuy/pMhFMSrqAu0GlB3mpHh6J9ZGv6PdVpgQyc8uTmujJakMTsYBlogWHJNmGlWIRgf0+x8jIVoTv4A==}
2337 + peerDependencies:
2338 + zod: ^3.25.40
2339
2332 - '@openai/agents@0.0.7':
2333 - resolution: {integrity: sha512-qDQn7f33fCySEuEVP+PIpBASmD5bjxhzSglzJ3Z21JcRbLq+hxyBz6hpJy6sa0XOSgHh50u2nlsz+rogTizdew==}
2340 + '@openai/agents@0.0.17':
2341 + resolution: {integrity: sha512-3tkN03WRLTTqcuzkopf37rAF6WtX0js3ciOqFn+EC1873J04Yf2m4xTYkYKT4RkwbOZh620+sIMPNKiUhW2rMg==}
2342 + peerDependencies:
2343 + zod: ^3.25.40
2344
2345 '@opentelemetry/api-logs@0.201.1':
2346 resolution: {integrity: sha512-IxcFDP1IGMDemVFG2by/AMK+/o6EuBQ8idUq3xZ6MxgQGeumYZuX5OwR0h9HuvcUc/JPjQGfU5OHKIKYDJcXeA==}
@@ -5787,6 +5797,18 @@ packages:
5797 zod:
5798 optional: true
5799
5800 + openai@5.16.0:
5801 + resolution: {integrity: sha512-hoEH8ZNvg1HXjU9mp88L/ZH8O082Z8r6FHCXGiWAzVRrEv443aI57qhch4snu07yQydj+AUAWLenAiBXhu89Tw==}
5802 + hasBin: true
5803 + peerDependencies:
5804 + ws: ^8.18.0
5805 + zod: ^3.23.8
5806 + peerDependenciesMeta:
5807 + ws:
5808 + optional: true
5809 + zod:
5810 + optional: true
5811 +
5812 openai@5.5.1:
5813 resolution: {integrity: sha512-5i19097mGotHA1eFsM6Tjd/tJ8uo9sa5Ysv4Q6bKJ2vtN6rc0MzMrUefXnLXYAJcmMQrC1Efhj0AvfIkXrQamw==}
5814 hasBin: true
@@ -8273,14 +8295,14 @@ snapshots:
8295 '@shikijs/types': 3.6.0
8296 '@shikijs/vscode-textmate': 10.0.2
8297
8276 - '@google/genai@1.5.1(@modelcontextprotocol/sdk@1.13.0)':
8298 + '@google/genai@1.5.1(@modelcontextprotocol/sdk@1.17.4)':
8299 dependencies:
8300 google-auth-library: 9.15.1
8301 ws: 8.18.2
8302 zod: 3.25.67
8303 zod-to-json-schema: 3.24.5(zod@3.25.67)
8304 optionalDependencies:
8283 - '@modelcontextprotocol/sdk': 1.13.0
8305 + '@modelcontextprotocol/sdk': 1.17.4
8306 transitivePeerDependencies:
8307 - bufferutil
8308 - encoding
@@ -8630,14 +8652,14 @@ snapshots:
8652 transitivePeerDependencies:
8653 - openai
8654
8633 - '@langchain/core@0.3.63(openai@5.5.1(ws@8.18.2)(zod@3.25.67))':
8655 + '@langchain/core@0.3.63(openai@5.16.0(ws@8.18.2)(zod@3.25.67))':
8656 dependencies:
8657 '@cfworker/json-schema': 4.1.1
8658 ansi-styles: 5.2.0
8659 camelcase: 6.3.0
8660 decamelize: 1.2.0
8661 js-tiktoken: 1.0.20
8640 - langsmith: 0.3.33(openai@5.5.1(ws@8.18.2)(zod@3.25.67))
8662 + langsmith: 0.3.33(openai@5.16.0(ws@8.18.2)(zod@3.25.67))
8663 mustache: 4.2.0
8664 p-queue: 6.6.2
8665 p-retry: 4.6.2
@@ -8888,6 +8910,24 @@ snapshots:
8910 transitivePeerDependencies:
8911 - supports-color
8912
8913 + '@modelcontextprotocol/sdk@1.17.4':
8914 + dependencies:
8915 + ajv: 6.12.6
8916 + content-type: 1.0.5
8917 + cors: 2.8.5
8918 + cross-spawn: 7.0.6
8919 + eventsource: 3.0.7
8920 + eventsource-parser: 3.0.3
8921 + express: 5.1.0
8922 + express-rate-limit: 7.5.0(express@5.1.0)
8923 + pkce-challenge: 5.0.0
8924 + raw-body: 3.0.0
8925 + zod: 3.25.67
8926 + zod-to-json-schema: 3.24.5(zod@3.25.67)
8927 + transitivePeerDependencies:
8928 + - supports-color
8929 + optional: true
8930 +
8931 '@msgpackr-extract/msgpackr-extract-darwin-arm64@3.0.3':
8932 optional: true
8933
@@ -8944,55 +8984,52 @@ snapshots:
8984 '@nodelib/fs.scandir': 2.1.5
8985 fastq: 1.19.1
8986
8947 - '@openai/agents-core@0.0.7(ws@8.18.2)(zod@3.25.67)':
8987 + '@openai/agents-core@0.0.17(ws@8.18.2)(zod@3.25.67)':
8988 dependencies:
8949 - '@openai/zod': zod@3.25.67
8989 debug: 4.4.1(supports-color@10.0.0)
8951 - openai: 5.5.1(ws@8.18.2)(zod@3.25.67)
8990 + openai: 5.16.0(ws@8.18.2)(zod@3.25.67)
8991 optionalDependencies:
8953 - '@modelcontextprotocol/sdk': 1.13.0
8992 + '@modelcontextprotocol/sdk': 1.17.4
8993 zod: 3.25.67
8994 transitivePeerDependencies:
8995 - supports-color
8996 - ws
8997
8959 - '@openai/agents-openai@0.0.7(ws@8.18.2)(zod@3.25.67)':
8998 + '@openai/agents-openai@0.0.17(ws@8.18.2)(zod@3.25.67)':
8999 dependencies:
8961 - '@openai/agents-core': 0.0.7(ws@8.18.2)(zod@3.25.67)
8962 - '@openai/zod': zod@3.25.67
9000 + '@openai/agents-core': 0.0.17(ws@8.18.2)(zod@3.25.67)
9001 debug: 4.4.1(supports-color@10.0.0)
8964 - openai: 5.5.1(ws@8.18.2)(zod@3.25.67)
9002 + openai: 5.16.0(ws@8.18.2)(zod@3.25.67)
9003 + zod: 3.25.67
9004 transitivePeerDependencies:
9005 - supports-color
9006 - ws
8968 - - zod
9007
8970 - '@openai/agents-realtime@0.0.7(zod@3.25.67)':
9008 + '@openai/agents-realtime@0.0.17(zod@3.25.67)':
9009 dependencies:
8972 - '@openai/agents-core': 0.0.7(ws@8.18.2)(zod@3.25.67)
8973 - '@openai/zod': zod@3.25.67
9010 + '@openai/agents-core': 0.0.17(ws@8.18.2)(zod@3.25.67)
9011 '@types/ws': 8.18.1
9012 debug: 4.4.1(supports-color@10.0.0)
9013 ws: 8.18.2
9014 + zod: 3.25.67
9015 transitivePeerDependencies:
9016 - bufferutil
9017 - supports-color
9018 - utf-8-validate
8981 - - zod
9019
8983 - '@openai/agents@0.0.7(ws@8.18.2)(zod@3.25.67)':
9020 + '@openai/agents@0.0.17(ws@8.18.2)(zod@3.25.67)':
9021 dependencies:
8985 - '@openai/agents-core': 0.0.7(ws@8.18.2)(zod@3.25.67)
8986 - '@openai/agents-openai': 0.0.7(ws@8.18.2)(zod@3.25.67)
8987 - '@openai/agents-realtime': 0.0.7(zod@3.25.67)
9022 + '@openai/agents-core': 0.0.17(ws@8.18.2)(zod@3.25.67)
9023 + '@openai/agents-openai': 0.0.17(ws@8.18.2)(zod@3.25.67)
9024 + '@openai/agents-realtime': 0.0.17(zod@3.25.67)
9025 debug: 4.4.1(supports-color@10.0.0)
8989 - openai: 5.5.1(ws@8.18.2)(zod@3.25.67)
9026 + openai: 5.16.0(ws@8.18.2)(zod@3.25.67)
9027 + zod: 3.25.67
9028 transitivePeerDependencies:
9029 - bufferutil
9030 - supports-color
9031 - utf-8-validate
9032 - ws
8995 - - zod
9033
9034 '@opentelemetry/api-logs@0.201.1':
9035 dependencies:
@@ -12689,7 +12726,7 @@ snapshots:
12726 optionalDependencies:
12727 openai: 4.104.0(ws@8.18.2)(zod@3.25.67)
12728
12692 - langsmith@0.3.33(openai@5.5.1(ws@8.18.2)(zod@3.25.67)):
12729 + langsmith@0.3.33(openai@5.16.0(ws@8.18.2)(zod@3.25.67)):
12730 dependencies:
12731 '@types/uuid': 10.0.0
12732 chalk: 4.1.2
@@ -12699,7 +12736,7 @@ snapshots:
12736 semver: 7.7.2
12737 uuid: 10.0.0
12738 optionalDependencies:
12702 - openai: 5.5.1(ws@8.18.2)(zod@3.25.67)
12739 + openai: 5.16.0(ws@8.18.2)(zod@3.25.67)
12740
12741 levn@0.4.1:
12742 dependencies:
@@ -13065,6 +13102,11 @@ snapshots:
13102 transitivePeerDependencies:
13103 - encoding
13104
13105 + openai@5.16.0(ws@8.18.2)(zod@3.25.67):
13106 + optionalDependencies:
13107 + ws: 8.18.2
13108 + zod: 3.25.67
13109 +
13110 openai@5.5.1(ws@8.18.2)(zod@3.25.67):
13111 optionalDependencies:
13112 ws: 8.18.2
ts/examples/openai/package.json
+3 -3
@@ -22,13 +22,13 @@
22 "@composio/core": "workspace:*",
23 "@composio/openai": "workspace:*",
24 "@composio/openai-agents": "workspace:*",
25 - "@openai/agents": "^0.0.7",
25 + "@openai/agents": "^0.0.17",
26 "dotenv": "^16.4.1",
27 - "openai": "^4.94.0",
27 + "openai": "^5.16.0",
28 "zod": "^3.24.2"
29 },
30 "devDependencies": {
31 "@types/bun": "^1.2.9",
32 "typescript": "^5.8.3"
33 }
34 -}
34 +}
\ No newline at end of file
ts/examples/openai/src/assistants.ts deleted
-88
@@ -1,88 +0,0 @@
1 -/**
2 - * OpenAI Assistants with Composio Tool Example
3 - *
4 - * This example demonstrates how to use the Composio OpenAIProvider with OpenAI Assistants API.
5 - * It uses the HACKERNEWS_GET_USER tool to fetch information about a HackerNews user.
6 - */
7 -import { Composio } from '@composio/core';
8 -import { OpenAI } from 'openai';
9 -import dotenv from 'dotenv';
10 -
11 -dotenv.config();
12 -
13 -const openai = new OpenAI({
14 - apiKey: process.env.OPENAI_API_KEY,
15 -});
16 -
17 -const composio = new Composio({
18 - apiKey: process.env.COMPOSIO_API_KEY,
19 -});
20 -
21 -/**
22 - * Main function to demonstrate OpenAI Assistants with Composio tool
23 - */
24 -async function main() {
25 - try {
26 - console.log('🔄 Setting up Composio and fetching tool...');
27 -
28 - const tools = await composio.tools.get('default', 'HACKERNEWS_GET_USER');
29 -
30 - console.log('🔄 Creating OpenAI Assistant with Composio tool...');
31 -
32 - const assistant = await openai.beta.assistants.create({
33 - name: 'HackerNews Helper',
34 - instructions:
35 - 'You are a helpful assistant that can fetch information about HackerNews users.',
36 - model: 'gpt-4o',
37 - tools: tools,
38 - });
39 -
40 - console.log(`✅ Assistant created with ID: ${assistant.id}`);
41 -
42 - const thread = await openai.beta.threads.create();
43 - console.log(`✅ Thread created with ID: ${thread.id}`);
44 -
45 - const query = "Get information about the HackerNews user 'pg'";
46 - console.log(`🔄 Adding message to thread: "${query}"`);
47 -
48 - await openai.beta.threads.messages.create(thread.id, {
49 - role: 'user',
50 - content: query,
51 - });
52 -
53 - console.log('🔄 Running the assistant...');
54 - const run = await openai.beta.threads.runs.create(thread.id, {
55 - assistant_id: assistant.id,
56 - });
57 -
58 - console.log('🔄 Waiting for assistant response and handling tool calls...');
59 - const completedRun = await composio.provider.waitAndHandleAssistantToolCalls(
60 - 'default',
61 - openai,
62 - run,
63 - thread
64 - );
65 -
66 - console.log(`✅ Run completed with status: ${completedRun.status}`);
67 -
68 - const messages = await openai.beta.threads.messages.list(thread.id);
69 -
70 - console.log('🤖 Assistant responses:');
71 - for (const message of messages.data) {
72 - if (message.role === 'assistant') {
73 - for (const content of message.content) {
74 - if (content.type === 'text') {
75 - console.log(`- ${content.text.value}`);
76 - }
77 - }
78 - }
79 - }
80 -
81 - await openai.beta.assistants.del(assistant.id);
82 - console.log('🧹 Cleaned up: Assistant deleted');
83 - } catch (error) {
84 - console.error('❌ Error:', error);
85 - }
86 -}
87 -
88 -main();
ts/examples/openai/src/chat-completions.ts
+1 -1
@@ -44,7 +44,7 @@ async function main() {
44 tool_choice: 'auto',
45 });
46
47 - if (response.choices[0].message.tool_calls) {
47 + if (response.choices[0].message.tool_calls && response.choices[0].message.tool_calls[0].type === 'function') {
48 console.log(
49 '🔧 Assistant is using tool:',
50 response.choices[0].message.tool_calls[0].function.name
ts/examples/openai/src/index.ts
+7 -2
@@ -44,8 +44,13 @@ const response = await openai.chat.completions.create({
44 /**
45 * If the assistant has tool calls, execute them and log the result
46 */
47 -if (response.choices[0].message.tool_calls) {
48 - console.log(`✅ Calling tool ${response.choices[0].message.tool_calls[0].function.name}`);
47 +if (response.choices[0].message.tool_calls && response.choices[0].message.tool_calls[0].type === 'function') {
48 + console.log(JSON.stringify(response, null, 2));
49 + const toolCall = response.choices[0].message.tool_calls[0];
50 + if (toolCall.type === 'function') {
51 +
52 + console.log(`✅ Calling tool ${response.choices[0].message.tool_calls[0].function.name}`);
53 + }
54 const result = await composio.provider.handleToolCalls('default', response);
55 console.log(result);
56 }
ts/examples/openai/src/mcp.ts deleted
-188
@@ -1,188 +0,0 @@
1 -/**
2 - * OpenAI MCP Gmail Example
3 - *
4 - * This example demonstrates how to use Composio MCP with OpenAI to:
5 - * 1. Create an MCP server for Gmail toolkit
6 - * 2. Generate URLs for the server
7 - * 3. Use OpenAI to summarize emails
8 - *
9 - */
10 -
11 -import { OpenAIResponsesProvider } from '@composio/openai';
12 -import { Composio, ConnectionStatus } from '@composio/core';
13 -import OpenAI from 'openai';
14 -import dotenv from 'dotenv';
15 -dotenv.config();
16 -
17 -/**
18 - * Initialize Composio with OpenAI provider
19 - */
20 -const composio = new Composio({
21 - apiKey: process.env.COMPOSIO_API_KEY,
22 - provider: new OpenAIResponsesProvider(),
23 -});
24 -
25 -/**
26 - * Initialize OpenAI client
27 - */
28 -const openai = new OpenAI({
29 - apiKey: process.env.OPENAI_API_KEY,
30 -});
31 -
32 -const MCP_SERVER_NAME = "gmail-readonly-server";
33 -const USER_ID = "utkarsh";
34 -
35 -/**
36 - * Get or create MCP server
37 - */
38 -async function getOrCreateMCPServer() {
39 - try {
40 - // Check if MCP server with name already exists
41 - const existingServer = await composio.mcp.getByName(MCP_SERVER_NAME);
42 - console.log(`✅ Found existing MCP server: ${existingServer.id}`);
43 - return existingServer;
44 - } catch (error) {
45 - // Server doesn't exist, create a new one
46 - console.log(`📝 Creating new MCP server: ${MCP_SERVER_NAME}`);
47 -
48 - // Get available auth configs for Gmail
49 - const authConfigsResponse = await composio.authConfigs.list();
50 - const gmailAuthConfig = authConfigsResponse.items.find((config) =>
51 - config.name?.toLowerCase().includes('gmail') ||
52 - config.name?.toLowerCase().includes('google')
53 - );
54 -
55 - if (!gmailAuthConfig) {
56 - throw new Error('No Gmail/Google auth config found. Please create one first.');
57 - }
58 -
59 - // Create MCP server using the new API signature
60 - await composio.mcp.create(
61 - MCP_SERVER_NAME,
62 - [
63 - {
64 - authConfigId: gmailAuthConfig.id,
65 - allowedTools: [
66 - "GMAIL_FETCH_EMAILS"
67 - ]
68 - }
69 - ],
70 - {
71 - isChatAuth: true
72 - }
73 - );
74 -
75 - // Get the newly created server details
76 - const newServer = await composio.mcp.getByName(MCP_SERVER_NAME);
77 - console.log(`✅ MCP server created: ${newServer.id}`);
78 - return newServer;
79 - }
80 -}
81 -
82 -/**
83 - * Handle authentication for disconnected toolkits
84 - */
85 -async function handleAuthentication(serverId: string) {
86 - const connectionStatus = await composio.mcp.getUserConnectionStatus(
87 - USER_ID,
88 - serverId
89 - );
90 -
91 - console.log("Connection status:", connectionStatus);
92 -
93 - const toolkits = connectionStatus.connectedToolkits;
94 -
95 - for (let toolkit of Object.values(toolkits)) {
96 - if (toolkit.type === ConnectionStatus.DISCONNECTED) {
97 - try {
98 - const requiredParams = await composio.mcp.getConnectionParams(
99 - serverId,
100 - toolkit.toolkit
101 - );
102 - console.log("Required params:", requiredParams);
103 -
104 - const authStatus = await composio.mcp.authorize(
105 - serverId,
106 - USER_ID,
107 - toolkit.toolkit
108 - );
109 - console.log("Connection status:", authStatus);
110 -
111 - if (authStatus.redirectUrl) {
112 - console.log(`Please complete the authentication by visiting the following URL: ${authStatus.redirectUrl}`);
113 - console.log("Press 'Enter' once you have completed the authentication.");
114 - await new Promise(resolve => process.stdin.once('data', resolve));
115 - }
116 - } catch (error) {
117 - console.error(`Error handling authentication for ${toolkit.toolkit}:`, error);
118 - }
119 - }
120 - }
121 -}
122 -
123 -/**
124 - * Fetch and summarize emails using OpenAI
125 - */
126 -async function fetchAndSummarizeEmails(serverUrls: unknown) {
127 - try {
128 - console.log('\n=== Generating Email Summary ===');
129 - const completion = await openai.responses.create({
130 - model: "gpt-4o-mini",
131 - input: "I've connected to gmail and I want to fetch the latest email from my inbox and summarize it",
132 - tools: serverUrls,
133 - });
134 -
135 - console.log('\n📬 Email Summary:');
136 - console.log(completion.output_text);
137 -
138 - } catch (error) {
139 - console.error('Error fetching or summarizing emails:', error);
140 - throw error;
141 - }
142 -}
143 -
144 -/**
145 - * Main function to run the MCP example
146 - */
147 -async function main() {
148 - try {
149 - // Validate environment variables
150 - if (!process.env.COMPOSIO_API_KEY) {
151 - throw new Error('COMPOSIO_API_KEY environment variable is required');
152 - }
153 - if (!process.env.OPENAI_API_KEY) {
154 - throw new Error('OPENAI_API_KEY environment variable is required');
155 - }
156 -
157 - // Get or create MCP server
158 - const server = await getOrCreateMCPServer();
159 - console.log("Server details:", server);
160 -
161 - // Handle authentication for disconnected toolkits
162 - await handleAuthentication(server.id);
163 -
164 - // Get server URLs with user ID using the new API signature
165 - const serverUrls = await composio.mcp.getServer(
166 - server.id,
167 - USER_ID,
168 - {
169 - limitTools: ["GMAIL_FETCH_EMAILS"],
170 - isChatAuth: true
171 - }
172 - );
173 -
174 - // Fetch and summarize emails
175 - await fetchAndSummarizeEmails(serverUrls);
176 -
177 - console.log('\n✅ OpenAI MCP Example completed successfully!');
178 - console.log('\n💡 Note: The MCP server URLs can be used to connect from other MCP-compatible clients');
179 - console.log(`📍 Server ID for future reference: ${server.id}`);
180 -
181 - } catch (error) {
182 - console.error('❌ Error running MCP example:', error);
183 - process.exit(1);
184 - }
185 -}
186 -
187 -// Run the example
188 -main();
ts/examples/triggers/src/create.ts
+2 -6
@@ -11,12 +11,8 @@ console.log(JSON.stringify(triggerType, null, 2));
11
12 // create a trigger
13 const trigger = await composio.triggers.create('default', triggerType.slug, {
14 - connectedAccountId: 'ca_jjYIG9L40LDIS',
15 - triggerConfig: {
16 - labelIds: 'INBOX',
17 - userId: 'me',
18 - interval: 60,
19 - },
14 + connectedAccountId: 'ca_uQvmu9uZOhQo',
15 + triggerConfig: {},
16 });
17
18 console.log(trigger);
ts/packages/core/package.json
+1 -1
@@ -48,7 +48,7 @@
48 "@composio/json-schema-to-zod": "0.1.13",
49 "@types/json-schema": "^7.0.15",
50 "chalk": "^4.1.2",
51 - "openai": "^4.94.0",
51 + "openai": "^5.16.0",
52 "pusher-js": "^8.4.0",
53 "semver": "^7.7.2",
54 "uuid": "^11.1.0",
ts/packages/core/src/provider/OpenAIProvider.ts
+27 -9
@@ -175,7 +175,7 @@ export class OpenAIProvider extends BaseNonAgenticProvider<OpenAiToolCollection,
175 */
176 async executeToolCall(
177 userId: string,
178 - tool: OpenAI.ChatCompletionMessageToolCall,
178 + tool: OpenAI.ChatCompletionMessageFunctionToolCall,
179 options?: ExecuteToolFnOptions,
180 modifiers?: ExecuteToolModifiers
181 ): Promise<string> {
@@ -240,7 +240,7 @@ export class OpenAIProvider extends BaseNonAgenticProvider<OpenAiToolCollection,
240 ): Promise<OpenAI.ChatCompletionToolMessageParam[]> {
241 const outputs: OpenAI.ChatCompletionToolMessageParam[] = [];
242 for (const message of chatCompletion.choices) {
243 - if (message.message.tool_calls) {
243 + if (message.message.tool_calls && message.message.tool_calls[0].type === 'function') {
244 const toolResult = await this.executeToolCall(
245 userId,
246 message.message.tool_calls[0],
@@ -263,12 +263,15 @@ export class OpenAIProvider extends BaseNonAgenticProvider<OpenAiToolCollection,
263 * This method processes tool calls from an OpenAI Assistant run,
264 * executes each tool call, and returns the tool outputs for submission.
265 *
266 + * @deprecated Assistant API is deprecated, please use responses or chat completions instead. This method will be removed in the next major version.
267 + *
268 * @param {string} userId - The user ID for authentication and tracking
269 * @param {OpenAI.Beta.Threads.Run} run - The Assistant run object containing tool calls
270 * @param {ExecuteToolFnOptions} [options] - Optional execution options
271 * @param {ExecuteToolModifiers} [modifiers] - Optional execution modifiers
272 * @returns {Promise<OpenAI.Beta.Threads.Runs.RunSubmitToolOutputsParams.ToolOutput[]>} Array of tool outputs for submission
273 *
274 + *
275 * @example
276 * ```typescript
277 * // Handle tool calls from an OpenAI Assistant run
@@ -319,7 +322,7 @@ export class OpenAIProvider extends BaseNonAgenticProvider<OpenAiToolCollection,
322 // Execute each tool call and get the response
323 const tool_response = await this.executeToolCall(
324 userId,
322 - tool_call as OpenAI.ChatCompletionMessageToolCall,
325 + tool_call as OpenAI.ChatCompletionMessageFunctionToolCall,
326 options,
327 modifiers
328 );
@@ -342,6 +345,8 @@ export class OpenAIProvider extends BaseNonAgenticProvider<OpenAiToolCollection,
345 * that require action, and yields each event from the stream. It's designed
346 * for streaming Assistant responses while handling tool calls in real-time.
347 *
348 + * @deprecated Assistant API is deprecated, please use responses or chat completions instead. It will be removed in the next major version.
349 + *
350 * @param {string} userId - The user ID for authentication and tracking
351 * @param {OpenAI} client - The OpenAI client instance
352 * @param {Stream<OpenAI.Beta.Assistants.AssistantStreamEvent>} runStream - The Assistant run stream
@@ -350,6 +355,8 @@ export class OpenAIProvider extends BaseNonAgenticProvider<OpenAiToolCollection,
355 * @param {ExecuteToolModifiers} [modifiers] - Optional execution modifiers
356 * @returns {AsyncGenerator<OpenAI.Beta.Assistants.AssistantStreamEvent, void, unknown>} Generator yielding stream events
357 *
358 + *
359 + *
360 * @example
361 * ```typescript
362 * // Process an OpenAI Assistant stream with tool calls
@@ -410,7 +417,8 @@ export class OpenAIProvider extends BaseNonAgenticProvider<OpenAiToolCollection,
417 );
418
419 // Submit the tool outputs
413 - await client.beta.threads.runs.submitToolOutputs(thread.id, runId, {
420 + await client.beta.threads.runs.submitToolOutputs(runId, {
421 + thread_id: thread.id,
422 tool_outputs: toolOutputs,
423 });
424 }
@@ -433,19 +441,24 @@ export class OpenAIProvider extends BaseNonAgenticProvider<OpenAiToolCollection,
441 }
442
443 // Handle any final actions after the stream ends
436 - let finalRun = await client.beta.threads.runs.retrieve(thread.id, runId);
444 + let finalRun = await client.beta.threads.runs.retrieve(runId, {
445 + thread_id: thread.id,
446 + });
447
448 while (['queued', 'in_progress', 'requires_action'].includes(finalRun.status)) {
449 if (finalRun.status === 'requires_action') {
450 const toolOutputs = await this.handleAssistantMessage(userId, finalRun, options, modifiers);
451
452 // Submit tool outputs
443 - finalRun = await client.beta.threads.runs.submitToolOutputs(thread.id, runId, {
453 + finalRun = await client.beta.threads.runs.submitToolOutputs(runId, {
454 + thread_id: thread.id,
455 tool_outputs: toolOutputs,
456 });
457 } else {
458 // Update the run status
448 - finalRun = await client.beta.threads.runs.retrieve(thread.id, runId);
459 + finalRun = await client.beta.threads.runs.retrieve(runId, {
460 + thread_id: thread.id,
461 + });
462 await new Promise(resolve => setTimeout(resolve, 500)); // Wait before rechecking
463 }
464 }
@@ -458,6 +471,8 @@ export class OpenAIProvider extends BaseNonAgenticProvider<OpenAiToolCollection,
471 * handles any tool calls, and returns the final run object. It's designed for
472 * non-streaming Assistant interactions.
473 *
474 + * @deprecated Assistant API is deprecated, please use responses or chat completions instead. It will be removed in the next major version.
475 + *
476 * @param {string} userId - The user ID for authentication and tracking
477 * @param {OpenAI} client - The OpenAI client instance
478 * @param {OpenAI.Beta.Threads.Run} run - The initial run object
@@ -509,11 +524,14 @@ export class OpenAIProvider extends BaseNonAgenticProvider<OpenAiToolCollection,
524 // logger.debug(
525 // `Submitting tool outputs for run ID: ${run.id} in thread ID: ${thread.id}`
526 // );
512 - run = await client.beta.threads.runs.submitToolOutputs(thread.id, run.id, {
527 + run = await client.beta.threads.runs.submitToolOutputs(run.id, {
528 + thread_id: thread.id,
529 tool_outputs: tool_outputs,
530 });
531 } else {
516 - run = await client.beta.threads.runs.retrieve(thread.id, run.id);
532 + run = await client.beta.threads.runs.retrieve(run.id, {
533 + thread_id: thread.id,
534 + });
535 await new Promise(resolve => setTimeout(resolve, 500));
536 }
537 }
ts/packages/core/test/provider/openai-provider.test.ts
+27 -29
@@ -74,8 +74,10 @@ describe('OpenAIProvider', () => {
74 const wrapped = provider.wrapTools(tools);
75
76 expect(wrapped).toHaveLength(2);
77 - expect(wrapped[0].function.name).toBe(mockTool.slug);
78 - expect(wrapped[1].function.name).toBe(anotherTool.slug);
77 + expect((wrapped[0] as OpenAI.ChatCompletionFunctionTool).function.name).toBe(mockTool.slug);
78 + expect((wrapped[1] as OpenAI.ChatCompletionFunctionTool).function.name).toBe(
79 + anotherTool.slug
80 + );
81 });
82 });
83
@@ -89,7 +91,7 @@ describe('OpenAIProvider', () => {
91 name: 'test-tool',
92 arguments: JSON.stringify({ input: 'test-value' }),
93 },
92 - } as OpenAI.ChatCompletionMessageToolCall;
94 + } as OpenAI.ChatCompletionMessageFunctionToolCall;
95
96 const result = await provider.executeToolCall(userId, toolCall);
97
@@ -115,7 +117,7 @@ describe('OpenAIProvider', () => {
117 name: 'test-tool',
118 arguments: JSON.stringify({ input: 'test-value' }),
119 },
118 - } as OpenAI.ChatCompletionMessageToolCall;
120 + } as OpenAI.ChatCompletionMessageFunctionToolCall;
121
122 const options = {
123 connectedAccountId: 'conn-123',
@@ -419,19 +421,18 @@ describe('OpenAIProvider', () => {
421 undefined,
422 undefined
423 );
422 - expect(client.beta.threads.runs.submitToolOutputs).toHaveBeenCalledWith(
423 - 'thread-123',
424 - 'run-123',
425 - {
426 - tool_outputs: [
427 - {
428 - tool_call_id: 'call-123',
429 - output: JSON.stringify({ result: 'success' }),
430 - },
431 - ],
432 - }
433 - );
434 - expect(client.beta.threads.runs.retrieve).toHaveBeenCalledWith('thread-123', 'run-123');
424 + expect(client.beta.threads.runs.submitToolOutputs).toHaveBeenCalledWith('run-123', {
425 + thread_id: 'thread-123',
426 + tool_outputs: [
427 + {
428 + tool_call_id: 'call-123',
429 + output: JSON.stringify({ result: 'success' }),
430 + },
431 + ],
432 + });
433 + expect(client.beta.threads.runs.retrieve).toHaveBeenCalledWith('run-123', {
434 + thread_id: 'thread-123',
435 + });
436 expect(result).toEqual(completedRun);
437 });
438 });
@@ -543,18 +544,15 @@ describe('OpenAIProvider', () => {
544 undefined,
545 undefined
546 );
546 - expect(client.beta.threads.runs.submitToolOutputs).toHaveBeenCalledWith(
547 - 'thread-123',
548 - 'run-123',
549 - {
550 - tool_outputs: [
551 - {
552 - tool_call_id: 'call-123',
553 - output: JSON.stringify({ result: 'success' }),
554 - },
555 - ],
556 - }
557 - );
547 + expect(client.beta.threads.runs.submitToolOutputs).toHaveBeenCalledWith('run-123', {
548 + thread_id: 'thread-123',
549 + tool_outputs: [
550 + {
551 + tool_call_id: 'call-123',
552 + output: JSON.stringify({ result: 'success' }),
553 + },
554 + ],
555 + });
556 });
557 });
558 });
ts/packages/providers/openai-agents/package.json
+1 -1
@@ -31,7 +31,7 @@
31 "packageManager": "pnpm@10.8.0",
32 "peerDependencies": {
33 "@composio/core": "0.1.47",
34 - "@openai/agents": "^0.0.7"
34 + "@openai/agents": "^0.0.17"
35 },
36 "devDependencies": {
37 "@composio/core": "workspace:*",
ts/packages/providers/openai/package.json
+1 -1
@@ -31,7 +31,7 @@
31 "packageManager": "pnpm@10.8.0",
32 "peerDependencies": {
33 "@composio/core": "0.1.47",
34 - "openai": "^4.3.8"
34 + "openai": "^5.16.0"
35 },
36 "devDependencies": {
37 "@composio/core": "workspace:*",
ts/packages/providers/openai/src/OpenAIResponsesProvider.ts
+1 -1
@@ -42,7 +42,7 @@ export interface OpenAIMcpServerResponse {
42 export class OpenAIResponsesProvider extends BaseNonAgenticProvider<
43 OpenAiToolCollection,
44 OpenAiTool,
45 - OpenAIMcpServerResponse[]
45 + OpenAiMcpTool[]
46 > {
47 readonly name = 'openai';
48 private strict: boolean | null;
ts/packages/providers/openai/test/openai.test.ts
+11 -5
@@ -10,10 +10,10 @@ vi.mock('openai', () => {
10 beta: {
11 threads: {
12 runs: {
13 - retrieve: vi.fn().mockImplementation((threadId, runId) => {
13 + retrieve: vi.fn().mockImplementation((runId, options) => {
14 return { id: runId, status: 'completed' };
15 }),
16 - submitToolOutputs: vi.fn().mockImplementation((threadId, runId, options) => {
16 + submitToolOutputs: vi.fn().mockImplementation((runId, options) => {
17 return { id: runId, status: 'completed' };
18 }),
19 },
@@ -172,7 +172,7 @@ describe('OpenAIProvider', () => {
172 name: 'test-tool',
173 arguments: JSON.stringify({ input: 'test-value' }),
174 },
175 - } as OpenAI.ChatCompletionMessageToolCall;
175 + } as OpenAI.ChatCompletionMessageFunctionToolCall;
176
177 const result = await provider.executeToolCall(userId, toolCall);
178
@@ -218,7 +218,12 @@ describe('OpenAIProvider', () => {
218 afterExecute: vi.fn(({ result }) => result),
219 };
220
221 - await provider.executeToolCall(userId, toolCall, options, modifiers);
221 + await provider.executeToolCall(
222 + userId,
223 + toolCall as OpenAI.ChatCompletionMessageFunctionToolCall,
224 + options,
225 + modifiers
226 + );
227
228 expect(mockExecuteToolFn).toHaveBeenCalledWith(
229 'test-tool',
@@ -500,7 +505,8 @@ describe('OpenAIProvider', () => {
505 const result = await provider.waitAndHandleAssistantToolCalls(userId, client, run, thread);
506
507 expect(handleAssistantMessageSpy).toHaveBeenCalledWith(userId, run, undefined, undefined);
503 - expect(client.beta.threads.runs.submitToolOutputs).toHaveBeenCalledWith(thread.id, run.id, {
508 + expect(client.beta.threads.runs.submitToolOutputs).toHaveBeenCalledWith(run.id, {
509 + thread_id: thread.id,
510 tool_outputs: [
511 {
512 tool_call_id: 'tool-call-123',