Skip to content

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

Add support for openai agents and other providers

haxzie9d0861d3a4f4
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 0fe577100..dab3d1c27 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -2,8 +2,9 @@ name: Test Typescript SDK
on:
push:
- branches: [main]
+ branches: [main, next]
pull_request:
+ branches: [main, next]
jobs:
test:
diff --git a/examples/connected-accounts/src/scopes.ts b/examples/connected-accounts/src/scopes.ts
new file mode 100644
index 000000000..49088bde8
--- /dev/null
+++ b/examples/connected-accounts/src/scopes.ts
@@ -0,0 +1,7 @@
+import { Composio } from '@composio/core';
+
+const composio = new Composio();
+
+const response = await composio.authConfigs.get('ac_3COrKCdQYLNu');
+
+console.log(JSON.stringify(response, null, 2));
diff --git a/examples/openai/package.json b/examples/openai/package.json
index a1df95a29..1b1d6fb78 100644
--- a/examples/openai/package.json
+++ b/examples/openai/package.json
@@ -6,8 +6,9 @@
"main": "index.js",
"scripts": {
"start": "bun src/index.ts",
- "chat": "bun src/chat-completions.ts",
- "assistant": "bun src/assistants.ts",
+ "start:chat-completion": "bun src/chat-completions.ts",
+ "start:assistant": "bun src/assistants.ts",
+ "start:agents": "bun src/agents-api/index.ts",
"examples": "bun src/examples.ts",
"test": "echo \"Error: no test specified\" && exit 1"
},
@@ -17,6 +18,9 @@
"packageManager": "[email protected]",
"dependencies": {
"@composio/core": "workspace:*",
+ "@composio/openai": "workspace:*",
+ "@composio/openai-agents": "workspace:*",
+ "@openai/agents": "^0.0.7",
"dotenv": "^16.4.1",
"openai": "^4.94.0",
"zod": "^3.24.2"
diff --git a/examples/openai/src/agents-api/index.ts b/examples/openai/src/agents-api/index.ts
new file mode 100644
index 000000000..4ce303324
--- /dev/null
+++ b/examples/openai/src/agents-api/index.ts
@@ -0,0 +1,35 @@
+import { OpenAIAgentsProvider } from '@composio/openai-agents';
+import { Composio } from '@composio/core';
+import { Agent, run } from '@openai/agents';
+
+const composio = new Composio({
+ provider: new OpenAIAgentsProvider({
+ strict: true,
+ }),
+});
+
+console.log(`πŸ”„ Fetching tools from composio...`);
+const tools = await composio.tools.get('default', 'HACKERNEWS_GET_USER', {
+ beforeExecute: async (toolSlug, toolkitSlug, params) => {
+ console.log(`πŸ”„ Executing tool ${toolSlug} from toolkit ${toolkitSlug}...`);
+ return params;
+ },
+ afterExecute: async (toolSlug, toolkitSlug, result) => {
+ console.log(`βœ… Tool ${toolSlug} executed`);
+ return result;
+ },
+});
+
+console.log(`βœ… Tools fetched from composio`);
+
+const agent = new Agent({
+ name: 'Hackernews assistant',
+ tools: tools,
+});
+
+console.log(`πŸ”„ Running agent...`);
+const result = await run(agent, 'Tell me about the user `pg` in hackernews');
+console.log(`βœ… Received response from agent`);
+if (result.finalOutput) {
+ console.log(JSON.stringify(result.finalOutput, null, 2));
+}
diff --git a/examples/openai/src/agents.ts b/examples/openai/src/agents.ts
new file mode 100644
index 000000000..5772a0122
--- /dev/null
+++ b/examples/openai/src/agents.ts
@@ -0,0 +1,11 @@
+import { Composio } from '@composio/core';
+import { Agent, webSearchTool, fileSearchTool } from '@openai/agents';
+
+const composio = new Composio();
+
+const tools = await composio.tools.get('default', 'HACKERNEWS_GET_USER');
+
+const agent = new Agent({
+ name: 'Travel assistant',
+ tools: tools,
+});
diff --git a/examples/openai/src/reponses-api/index.ts b/examples/openai/src/reponses-api/index.ts
new file mode 100644
index 000000000..7c5ffe6ae
--- /dev/null
+++ b/examples/openai/src/reponses-api/index.ts
@@ -0,0 +1,55 @@
+import OpenAI from 'openai';
+import { Composio } from '@composio/core';
+import { OpenAIResponsesProvider } from '@composio/openai';
+
+const openai = new OpenAI();
+const composio = new Composio({
+ provider: new OpenAIResponsesProvider(),
+});
+
+console.log(`πŸ”„ Fetching tools from composio...`);
+const tools = await composio.tools.get('default', 'HACKERNEWS_GET_USER');
+console.log(`βœ… Tools fetched from composio`);
+
+console.log(`πŸ”„ Generating response from OpenAI...`);
+const initialResponse = await openai.responses.create({
+ model: 'gpt-4.1',
+ input: 'Tell me about the user `pg` in hackernews',
+ tools,
+});
+console.log(`βœ… Response generated from OpenAI`);
+console.log(JSON.stringify(initialResponse.output, null, 2));
+
+console.log(`πŸ”„ Handling tool calls from response...`);
+const modelInputs = await composio.provider.handleResponse(
+ 'default',
+ initialResponse,
+ {},
+ {
+ beforeExecute: async (toolSlug, toolkitSlug, params) => {
+ console.log(`πŸ”„ Executing tool ${toolSlug} from toolkit ${toolkitSlug}...`);
+ return params;
+ },
+ afterExecute: async (toolSlug, toolkitSlug, result) => {
+ console.log(`βœ… Tool ${toolSlug} executed`);
+ return result;
+ },
+ }
+);
+
+console.log(`πŸ”„ Submitting tool outputs to OpenAI...`);
+console.log(JSON.stringify(modelInputs, null, 2));
+const finalResponse = await openai.responses.create({
+ model: 'gpt-4.1',
+ input: [...initialResponse.output, ...modelInputs],
+ tools,
+});
+
+console.log(`βœ… Tool outputs submitted to OpenAI`);
+const finalContent = finalResponse.output[0];
+if (finalContent.type === 'message' && finalContent.content[0].type === 'output_text') {
+ console.log(`πŸ€– OpenAI response`, finalContent.content[0].text);
+} else {
+ console.error(`❌ Unexpected response from OpenAI`);
+ console.log(JSON.stringify(finalResponse.output, null, 2));
+}
diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts
index 1963f7947..71649a896 100644
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@ -4,7 +4,7 @@ export { ComposioProvider } from './provider/ComposioProvider';
export { BaseAgenticProvider, BaseNonAgenticProvider } from './provider/BaseProvider';
export type { BaseComposioProvider } from './provider/BaseProvider';
export { OpenAIProvider } from './provider/OpenAIProvider';
-export { jsonSchemaToZodSchema } from './utils/jsonSchema';
+export { jsonSchemaToZodSchema, removeNonRequiredProperties } from './utils/jsonSchema';
export { AuthScheme } from './models/AuthScheme';
export * from './types/provider.types';
export * from './types/customTool.types';
diff --git a/packages/core/src/models/AuthConfigs.ts b/packages/core/src/models/AuthConfigs.ts
index 0a785ddda..0a688f42f 100644
--- a/packages/core/src/models/AuthConfigs.ts
+++ b/packages/core/src/models/AuthConfigs.ts
@@ -83,6 +83,7 @@ export class AuthConfigs {
createdBy: authConfig.created_by,
createdAt: authConfig.created_at,
lastUpdatedAt: authConfig.last_updated_at,
+ restrictToFollowingTools: authConfig.restrict_to_following_tools,
});
if (result.error) {
throw new ValidationError('Failed to parse auth config response', {
diff --git a/packages/core/src/models/Tools.ts b/packages/core/src/models/Tools.ts
index 26d460c92..2f428b6fe 100644
--- a/packages/core/src/models/Tools.ts
+++ b/packages/core/src/models/Tools.ts
@@ -40,7 +40,6 @@ import {
} from '../errors/ToolErrors';
import { ValidationError } from '../errors/ValidationErrors';
import { telemetry } from '../telemetry/Telemetry';
-import { removeNonRequiredProperties } from '../utils/jsonSchema';
/**
* This class is used to manage tools in the Composio SDK.
* It provides methods to list, get, and execute tools.
@@ -455,19 +454,7 @@ export class Tools<
return this.provider.wrapTools([tool], executeToolFn) as TToolCollection;
} else {
// if the first argument is an object, get a list of tools
- let tools = await this.getRawComposioTools(userId, arg2, options?.modifySchema);
- // if the strict flag is true, remove all non-required properties from the input and output parameters
- if (arg2?.strict) {
- tools = tools.map(tool => ({
- ...tool,
- inputParameters: tool.inputParameters
- ? removeNonRequiredProperties(tool.inputParameters)
- : undefined,
- outputParameters: tool.outputParameters
- ? removeNonRequiredProperties(tool.outputParameters)
- : undefined,
- }));
- }
+ const tools = await this.getRawComposioTools(userId, arg2, options?.modifySchema);
return this.provider.wrapTools(tools, executeToolFn) as TToolCollection;
}
}
diff --git a/packages/core/src/types/authConfigs.types.ts b/packages/core/src/types/authConfigs.types.ts
index 3c4ea3df6..7acd673b5 100644
--- a/packages/core/src/types/authConfigs.types.ts
+++ b/packages/core/src/types/authConfigs.types.ts
@@ -83,6 +83,7 @@ export const AuthConfigRetrieveResponseSchema = z.object({
authScheme: AuthSchemeEnum.optional(),
credentials: z.record(z.string(), z.unknown()).optional(),
expectedInputFields: z.array(z.unknown()).optional(),
+ restrictToFollowingTools: z.array(z.string()).optional(),
isComposioManaged: z.boolean().optional(),
createdBy: z.string().optional(),
createdAt: z.string().optional(),
diff --git a/packages/core/src/types/tool.types.ts b/packages/core/src/types/tool.types.ts
index caee23429..a47111aa0 100644
--- a/packages/core/src/types/tool.types.ts
+++ b/packages/core/src/types/tool.types.ts
@@ -137,12 +137,6 @@ export const ToolListFilterByToolkitsSchema = z.object({
cursor: z.string().optional(),
limit: z.number().optional(),
search: z.string().optional(),
- strict: z
- .boolean()
- .optional()
- .describe(
- 'If true, all the non-required fields will be removed from the input/output params of the tool'
- ),
});
export type ToolListFilterByToolkits = z.infer<typeof ToolListFilterByToolkitsSchema>;
@@ -151,12 +145,6 @@ export const ToolListFilterBySearchSchema = z.object({
toolkits: z.array(z.string()).optional(),
cursor: z.string().optional(),
limit: z.number().optional(),
- strict: z
- .boolean()
- .optional()
- .describe(
- 'If true, all the non-required fields will be removed from the input/output params of the tool'
- ),
});
export type ToolListFilterBySearch = z.infer<typeof ToolListFilterBySearchSchema>;
@@ -167,7 +155,6 @@ type ToolsOnlyParams = {
cursor?: never;
limit?: never;
search?: never;
- strict?: boolean;
};
type ToolkitsOnlyParams = {
@@ -177,7 +164,6 @@ type ToolkitsOnlyParams = {
cursor?: string;
limit?: number;
search?: never;
- strict?: boolean;
};
type ToolkitSearchOnlyParams = {
@@ -187,7 +173,6 @@ type ToolkitSearchOnlyParams = {
cursor?: string;
limit?: number;
search?: string;
- strict?: boolean;
};
/**
* ToolListParams is the parameters for the list of tools.
diff --git a/packages/core/src/utils/jsonSchema.ts b/packages/core/src/utils/jsonSchema.ts
index b6f182987..6e0485cb2 100644
--- a/packages/core/src/utils/jsonSchema.ts
+++ b/packages/core/src/utils/jsonSchema.ts
@@ -1,4 +1,4 @@
-import { z } from 'zod';
+import { z, ZodObject, ZodTypeAny } from 'zod';
import { JsonSchemaToZodError } from '../errors';
import { jsonSchemaToZod } from '@composio/json-schema-to-zod';
@@ -10,7 +10,12 @@ import { jsonSchemaToZod } from '@composio/json-schema-to-zod';
* @returns The JSON schema with all non-required properties removed
*/
export const removeNonRequiredProperties = <
- T extends { type: 'object'; properties: Record<string, unknown>; required?: string[] },
+ T extends {
+ type: 'object';
+ properties: Record<string, unknown>;
+ required?: string[];
+ additionalProperties?: boolean;
+ },
>(
schema: T
): T => {
@@ -21,6 +26,7 @@ export const removeNonRequiredProperties = <
)
);
}
+ schema.additionalProperties = false;
return schema as T;
};
@@ -63,12 +69,12 @@ export const removeNonRequiredProperties = <
* // })
* ```
*/
-export function jsonSchemaToZodSchema(
+export function jsonSchemaToZodSchema<T extends z.ZodTypeAny>(
jsonSchema: Record<string, unknown>,
{ strict }: { strict?: boolean } = {
strict: false,
}
-): z.ZodTypeAny {
+): T {
try {
let schema = jsonSchema;
// Remove all non-required properties from the schema if strict is true
@@ -82,7 +88,7 @@ export function jsonSchemaToZodSchema(
);
}
// Convert the JSON schema properties to Zod schema
- const zodSchema = jsonSchemaToZod(schema) as z.ZodTypeAny;
+ const zodSchema = jsonSchemaToZod(schema) as T;
return zodSchema;
} catch (error) {
throw new JsonSchemaToZodError('Failed to convert JSON Schema to Zod Schema', {
diff --git a/packages/core/test/tools/tools.test.ts b/packages/core/test/tools/tools.test.ts
index c1d2e92db..5f1bdbdc3 100644
--- a/packages/core/test/tools/tools.test.ts
+++ b/packages/core/test/tools/tools.test.ts
@@ -329,136 +329,6 @@ describe('Tools', () => {
expect(getRawComposioToolBySlugSpy).toHaveBeenCalledWith(userId, slug, schemaModifier);
});
-
- it('should remove non-required properties when strict mode is enabled', async () => {
- const userId = 'test-user';
- const filters = {
- tools: ['TOOL1'],
- strict: true,
- };
-
- const toolWithOptionalParams = {
- ...toolMocks.transformedTool,
- inputParameters: {
- type: 'object',
- required: ['requiredParam'],
- properties: {
- requiredParam: {
- type: 'string',
- description: 'Required parameter',
- },
- optionalParam: {
- type: 'string',
- description: 'Optional parameter',
- },
- },
- },
- outputParameters: {
- type: 'object',
- required: ['requiredOutput'],
- properties: {
- requiredOutput: {
- type: 'string',
- description: 'Required output',
- },
- optionalOutput: {
- type: 'string',
- description: 'Optional output',
- },
- },
- },
- };
-
- const getRawComposioToolsSpy = vi.spyOn(context.tools, 'getRawComposioTools');
- getRawComposioToolsSpy.mockResolvedValueOnce([toolWithOptionalParams as unknown as Tool]);
-
- context.mockProvider.wrapTools.mockReturnValueOnce('wrapped-tools-collection');
-
- const result = await context.tools.get(userId, filters);
-
- expect(context.mockProvider.wrapTools).toHaveBeenCalledWith(
- [
- {
- ...toolWithOptionalParams,
- inputParameters: {
- type: 'object',
- required: ['requiredParam'],
- properties: {
- requiredParam: {
- type: 'string',
- description: 'Required parameter',
- },
- },
- },
- outputParameters: {
- type: 'object',
- required: ['requiredOutput'],
- properties: {
- requiredOutput: {
- type: 'string',
- description: 'Required output',
- },
- },
- },
- },
- ],
- expect.any(Function)
- );
- expect(result).toEqual('wrapped-tools-collection');
- });
-
- it('should not modify properties when strict mode is disabled', async () => {
- const userId = 'test-user';
- const filters = {
- tools: ['TOOL1'],
- strict: false,
- };
-
- const toolWithOptionalParams = {
- ...toolMocks.transformedTool,
- inputParameters: {
- type: 'object',
- required: ['requiredParam'],
- properties: {
- requiredParam: {
- type: 'string',
- description: 'Required parameter',
- },
- optionalParam: {
- type: 'string',
- description: 'Optional parameter',
- },
- },
- },
- outputParameters: {
- type: 'object',
- required: ['requiredOutput'],
- properties: {
- requiredOutput: {
- type: 'string',
- description: 'Required output',
- },
- optionalOutput: {
- type: 'string',
- description: 'Optional output',
- },
- },
- },
- };
-
- const getRawComposioToolsSpy = vi.spyOn(context.tools, 'getRawComposioTools');
- getRawComposioToolsSpy.mockResolvedValueOnce([toolWithOptionalParams as unknown as Tool]);
-
- context.mockProvider.wrapTools.mockReturnValueOnce('wrapped-tools-collection');
-
- const result = await context.tools.get(userId, filters);
-
- expect(context.mockProvider.wrapTools).toHaveBeenCalledWith(
- [toolWithOptionalParams],
- expect.any(Function)
- );
- expect(result).toEqual('wrapped-tools-collection');
- });
});
describe('execute', () => {
diff --git a/packages/providers/openai-agents/CHANGELOG.md b/packages/providers/openai-agents/CHANGELOG.md
new file mode 100644
index 000000000..81bb33449
--- /dev/null
+++ b/packages/providers/openai-agents/CHANGELOG.md
@@ -0,0 +1,181 @@
+# @composio/vercel
+
+## 0.1.21
+
+### Patch Changes
+
+- Add host name support in SDK
+- Updated dependencies
+ - @composio/[email protected]
+
+## 0.1.20
+
+### Patch Changes
+
+- 1ab34ef: Fix json schema support in tools
+- Updated dependencies [1ab34ef]
+ - @composio/[email protected]
+
+## 0.1.19
+
+### Patch Changes
+
+- c8e89d5: Fix telemetry transport
+- Updated dependencies [c8e89d5]
+ - @composio/[email protected]
+
+## 0.1.18
+
+### Patch Changes
+
+- 37a1f01: Feat better connected account creation flow
+- Updated dependencies [37a1f01]
+ - @composio/[email protected]
+
+## 0.1.17
+
+### Patch Changes
+
+- df31cc2: Fix json schema parsing
+- Updated dependencies [df31cc2]
+ - @composio/[email protected]
+
+## 0.1.16
+
+### Patch Changes
+
+- f943ba4: Export all the types from the core SDK
+- Updated dependencies [f943ba4]
+ - @composio/[email protected]
+
+## 0.1.15
+
+### Patch Changes
+
+- 208e320: Update json schema transformations issues related to strict mode
+- Updated dependencies [208e320]
+ - @composio/[email protected]
+
+## 0.1.14
+
+### Patch Changes
+
+- 4ddfafc: Add json schema to zod schema
+- Updated dependencies [4ddfafc]
+ - @composio/[email protected]
+
+## 0.1.13
+
+### Patch Changes
+
+- 040b5a4: Ability to create sessions for transferring request ids
+- Updated dependencies [040b5a4]
+ - @composio/[email protected]
+
+## 0.1.12
+
+### Patch Changes
+
+- c1443db: Improved error handling and telemetry
+- b121e73: Update packages to stable version
+- f144202: Update tsdocs across all the functions
+- ba8d991: Fix initiate connection flows and api issues
+- ca59bcd: Update documentations and fix API discrepencies
+- e51680c: Fix versioning with changesets
+- 0b15376: Add custom toolkit examples
+- de3f522: Stable version with test coverage and other stuff
+- a2f9537: Update tools.get to accept discriminated unions
+- 83a0d15: Test github ci publish
+- eeec413: Rename modifiers, add docs and other miscellanious improvements
+- Updated dependencies [c1443db]
+- Updated dependencies [b121e73]
+- Updated dependencies [f144202]
+- Updated dependencies [ba8d991]
+- Updated dependencies [ca59bcd]
+- Updated dependencies [e51680c]
+- Updated dependencies [0b15376]
+- Updated dependencies [de3f522]
+- Updated dependencies [a2f9537]
+- Updated dependencies [83a0d15]
+- Updated dependencies [eeec413]
+ - @composio/[email protected]
+
+## 0.1.12-alpha.16
+
+### Patch Changes
+
+- 0b15376: Add custom toolkit examples
+- Updated dependencies [0b15376]
+ - @composio/[email protected]
+
+## 0.1.12-alpha.15
+
+### Patch Changes
+
+- f144202: Update tsdocs across all the functions
+- Updated dependencies [f144202]
+ - @composio/[email protected]
+
+## 0.1.12-alpha.14
+
+### Patch Changes
+
+- 83a0d15: Test github ci publish
+- Updated dependencies [83a0d15]
+ - @composio/[email protected]
+
+## 0.1.12-alpha.13
+
+### Patch Changes
+
+- a2f9537: Update tools.get to accept discriminated unions
+- Updated dependencies [a2f9537]
+ - @composio/[email protected]
+
+## 0.1.12-alpha.12
+
+### Patch Changes
+
+- de3f522: Stable version with test coverage and other stuff
+- Updated dependencies [de3f522]
+ - @composio/[email protected]
+
+## 0.1.12-alpha.11
+
+### Patch Changes
+
+- Improved error handling and telemetry
+- Updated dependencies
+ - @composio/[email protected]
+
+## 0.1.12-alpha.10
+
+### Patch Changes
+
+- eeec413: Rename modifiers, add docs and other miscellanious improvements
+- Updated dependencies [eeec413]
+ - @composio/[email protected]
+
+## 0.1.12-alpha.9
+
+### Patch Changes
+
+- ba8d991: Fix initiate connection flows and api issues
+- Updated dependencies [ba8d991]
+ - @composio/[email protected]
+
+## 0.1.12-alpha.8
+
+### Patch Changes
+
+- ca59bcd: Update documentations and fix API discrepencies
+- Updated dependencies [ca59bcd]
+ - @composio/[email protected]
+
+## 0.1.12-alpha.7
+
+### Patch Changes
+
+- e51680c: Fix versioning with changesets
+- Updated dependencies [e51680c]
+ - @composio/[email protected]
diff --git a/packages/providers/openai-agents/README.md b/packages/providers/openai-agents/README.md
new file mode 100644
index 000000000..dad7fb19c
--- /dev/null
+++ b/packages/providers/openai-agents/README.md
@@ -0,0 +1,238 @@
+# @composio/vercel
+
+The Vercel AI SDK provider for Composio SDK, providing seamless integration with Vercel's AI SDK and tools.
+
+## Features
+
+- **Vercel AI SDK Integration**: Seamless integration with Vercel's AI SDK
+- **Streaming Support**: First-class support for streaming responses
+- **Model Agnostic**: Works with any model supported by Vercel AI SDK (OpenAI, Anthropic, etc.)
+- **UI Components**: Integration with Vercel's React components for chat interfaces
+- **Tool Execution**: Execute tools with proper parameter handling and streaming
+- **Type Safety**: Full TypeScript support with proper type definitions
+
+## Installation
+
+```bash
+npm install @composio/vercel ai
+# or
+yarn add @composio/vercel ai
+# or
+pnpm add @composio/vercel ai
+```
+
+## Environment Variables
+
+Required environment variables:
+
+- `COMPOSIO_API_KEY`: Your Composio API key
+
+Optional environment variables (based on model choice):
+
+- `OPENAI_API_KEY`: Your OpenAI API key (if using OpenAI)
+- `ANTHROPIC_API_KEY`: Your Anthropic API key (if using Anthropic)
+- `GEMINI_API_KEY`: Your Google AI API key (if using Gemini)
+
+## Quick Start
+
+```typescript
+import { Composio } from '@composio/core';
+import { VercelProvider } from '@composio/vercel';
+
+// Initialize Composio with Vercel provider
+const composio = new Composio({
+ apiKey: 'your-composio-api-key',
+ provider: new VercelProvider(),
+});
+
+// Get available tools
+const tools = await composio.tools.get('user123', {
+ toolkits: ['gmail', 'googlecalendar'],
+ limit: 10,
+});
+
+// Get a specific tool
+const sendEmailTool = await composio.tools.get('user123', 'GMAIL_SEND_EMAIL');
+```
+
+## Examples
+
+Check out our complete example implementations:
+
+- [Basic Vercel Integration](../../examples/vercel/src/index.ts)
+
+### Basic Chat Completion with Streaming
+
+```typescript
+import { Composio } from '@composio/core';
+import { VercelProvider } from '@composio/vercel';
+import { useChat } from 'ai/react';
+
+// Initialize Composio with Vercel provider
+const composio = new Composio({
+ apiKey: process.env.COMPOSIO_API_KEY,
+ provider: new VercelProvider()
+});
+
+// In your React component
+function ChatComponent() {
+ const { messages, input, handleInputChange, handleSubmit } = useChat({
+ api: '/api/chat',
+ });
+
+ return (
+ <div>
+ {messages.map(m => (
+ <div key={m.id}>
+ {m.role === 'user' ? 'User: ' : 'AI: '}
+ {m.content}
+ </div>
+ ))}
+
+ <form onSubmit={handleSubmit}>
+ <input
+ value={input}
+ onChange={handleInputChange}
+ placeholder="Say something..."
+ />
+ <button type="submit">Send</button>
+ </form>
+ </div>
+ );
+}
+
+// In your API route (e.g. app/api/chat/route.ts)
+import { streamText } from 'ai';
+import { openai } from '@ai-sdk/openai';
+
+export async function POST(req: Request) {
+ const { messages } = await req.json();
+ const tools = await composio.tools.get('user123', {
+ toolkits: ['gmail'],
+ });
+
+ const result = streamText({
+ model: openai('gpt-4'),
+ messages,
+ tools,
+ });
+
+ return result.toDataStreamResponse();
+}
+```
+
+### Tool Execution with Streaming
+
+```typescript
+import { Composio } from '@composio/core';
+import { VercelProvider } from '@composio/vercel';
+import { streamText } from 'ai';
+
+const composio = new Composio({
+ apiKey: process.env.COMPOSIO_API_KEY,
+ provider: new VercelProvider(),
+});
+
+// Example API route that handles tool execution
+export async function POST(req: Request) {
+ const { messages } = await req.json();
+ const tools = await composio.tools.get('user123', {
+ toolkits: ['gmail', 'googlecalendar'],
+ });
+
+ const stream = streamText({
+ model: openai('gpt-4'),
+ messages,
+ tools,
+ callbacks: {
+ onToolCall: async tool => {
+ // Execute the tool and return result
+ return await composio.provider.executeToolCall(tool);
+ },
+ },
+ });
+
+ return stream.toDataStreamResponse();
+}
+```
+
+## Provider Configuration
+
+The Vercel provider can be configured with various options:
+
+```typescript
+const provider = new VercelProvider({
+ // Default model configuration
+ model: openai('gpt-4'),
+ // Custom execution modifiers
+ modifiers: {
+ beforeExecute: params => {
+ // Transform parameters before execution
+ return params;
+ },
+ afterExecute: response => {
+ // Transform response after execution
+ return response;
+ },
+ },
+});
+```
+
+### Strict Mode
+
+When using tools with Vercel AI SDK, you might need to ensure that all tool parameters are marked as required. This is because Vercel AI SDK's function calling implementation requires all fields to be marked as required. You can enable strict mode when fetching tools to automatically remove all non-required properties from both input and output parameters:
+
+```typescript
+// Get tools with strict mode enabled
+const tools = await composio.tools.get('user123', {
+ toolkits: ['gmail', 'googlecalendar'],
+ strict: true, // This will remove all non-required properties from tool parameters
+});
+
+// Use these tools with Vercel AI SDK
+const stream = streamText({
+ model: openai('gpt-4'),
+ messages,
+ tools, // These tools will only have required parameters
+});
+```
+
+For more information about strict mode in function calling, see [OpenAI's documentation](https://platform.openai.com/docs/guides/function-calling#strict-mode).
+
+## API Reference
+
+### VercelProvider Class
+
+The `VercelProvider` class extends `BaseComposioProvider` and provides Vercel AI SDK-specific functionality.
+
+#### Methods
+
+##### `executeToolCall(tool: ToolCall): Promise<string>`
+
+Executes a tool call and returns the result.
+
+```typescript
+const result = await provider.executeToolCall(toolCall);
+```
+
+##### `handleToolCalls(stream: AIStream): AsyncGenerator<AIStreamEvent>`
+
+Handles tool calls from a stream and yields events.
+
+```typescript
+for await (const event of provider.handleToolCalls(stream)) {
+ // Handle events
+}
+```
+
+## Contributing
+
+We welcome contributions! Please see our [Contributing Guide](../../CONTRIBUTING.md) for more details.
+
+## License
+
+ISC License
+
+## Support
+
+For support, please visit our [Documentation](https://docs.composio.dev) or join our [Discord Community](https://discord.gg/composio).
diff --git a/packages/providers/openai-agents/package.json b/packages/providers/openai-agents/package.json
new file mode 100644
index 000000000..f37bba6e0
--- /dev/null
+++ b/packages/providers/openai-agents/package.json
@@ -0,0 +1,42 @@
+{
+ "name": "@composio/openai-agents",
+ "version": "0.1.21",
+ "description": "",
+ "main": "src/index.ts",
+ "type": "module",
+ "publishConfig": {
+ "access": "public",
+ "main": "dist/index.js",
+ "types": "dist/index.d.ts"
+ },
+ "exports": {
+ ".": {
+ "import": "./dist/index.js",
+ "types": "./dist/index.d.ts",
+ "require": "./dist/index.cjs"
+ }
+ },
+ "files": [
+ "README.md",
+ "dist"
+ ],
+ "scripts": {
+ "build": "tsup",
+ "test": "vitest run"
+ },
+ "keywords": [],
+ "author": "",
+ "license": "ISC",
+ "packageManager": "[email protected]",
+ "peerDependencies": {
+ "@composio/core": "0.1.21",
+ "@openai/agents": "^0.0.7"
+ },
+ "devDependencies": {
+ "@composio/core": "workspace:*",
+ "tsup": "^8.4.0",
+ "typescript": "^5.8.3",
+ "vitest": "^3.1.4"
+ },
+ "gitHead": "4fae6e54d5c150fba955cc5fa314281da5a1e064"
+}
diff --git a/packages/providers/openai-agents/src/index.ts b/packages/providers/openai-agents/src/index.ts
new file mode 100644
index 000000000..822f24e6e
--- /dev/null
+++ b/packages/providers/openai-agents/src/index.ts
@@ -0,0 +1,166 @@
+/**
+ * OpenAI Agents Provider
+ * To be used with the @openai/agents package
+ *
+ * Author: Musthaq Ahamad <[email protected]>
+ * Reference: https://openai.github.io/openai-agents-js/
+ *
+ * This provider provides a set of tools for interacting with Vercel AI SDK.
+ *
+ * @packageDocumentation
+ * @module providers/openai-agents
+ */
+import {
+ BaseAgenticProvider,
+ Tool as ComposioTool,
+ ExecuteToolFn,
+ jsonSchemaToZodSchema,
+} from '@composio/core';
+import type { Tool as OpenAIAgentTool } from '@openai/agents';
+import { tool as createOpenAIAgentTool } from '@openai/agents';
+
+type OpenAIAgentsToolCollection = Array<OpenAIAgentTool>;
+export class OpenAIAgentsProvider extends BaseAgenticProvider<
+ OpenAIAgentsToolCollection,
+ OpenAIAgentTool
+> {
+ readonly name = 'openai-agents';
+ private strict: boolean | null;
+
+ /**
+ * Creates a new instance of the OpenAIAgentsProvider.
+ *
+ * This provider enables integration with the @openai/agents package,
+ * allowing Composio tools to be used with OpenAI Agents.
+ *
+ * @example
+ * ```typescript
+ * // Initialize the OpenAIAgentsProvider
+ * const provider = new OpenAIAgentsProvider();
+ *
+ * // Use with Composio
+ * const composio = new Composio({
+ * apiKey: 'your-api-key',
+ * provider: new OpenAIAgentsProvider()
+ * });
+ *
+ * // Use the provider to wrap tools for @openai/agents
+ * const vercelTools = provider.wrapTools(composioTools, composio.tools.execute);
+ * ```
+ */
+ constructor(options?: { strict?: boolean }) {
+ super();
+ this.strict = options?.strict ?? false;
+ }
+
+ /**
+ * Wraps a Composio tool in a OpenAI Agents tool format.
+ *
+ * This method transforms a Composio tool definition into the format
+ * expected by @openai/agents for function calling.
+ *
+ * @param {ComposioTool} composioTool - The Composio tool to wrap
+ * @param {ExecuteToolFn} executeTool - Function to execute the tool
+ * @returns {OpenAIAgentsTool} The wrapped OpenAI Agents tool
+ *
+ * @example
+ * ```typescript
+ * // Wrap a single tool for use with Vercel AI SDK
+ * const composioTool = {
+ * slug: 'SEARCH_TOOL',
+ * description: 'Search for information',
+ * inputParameters: {
+ * type: 'object',
+ * properties: {
+ * query: { type: 'string' }
+ * },
+ * required: ['query']
+ * }
+ * };
+ *
+ * // Create a Vercel tool using the provider
+ * const vercelTool = provider.wrapTool(
+ * composioTool,
+ * composio.tools.execute
+ * );
+ *
+ * // Use with Vercel AI SDK
+ * import { StreamingTextResponse, Message } from 'ai';
+ * import { OpenAI } from 'openai';
+ *
+ * export async function POST(req: Request) {
+ * const { messages } = await req.json();
+ * const openai = new OpenAI();
+ *
+ * const response = await openai.chat.completions.create({
+ * model: 'gpt-4',
+ * messages,
+ * tools: [vercelTool]
+ * });
+ *
+ * return new StreamingTextResponse(response.choices[0].message);
+ * }
+ * ```
+ */
+ wrapTool(composioTool: ComposioTool, executeTool: ExecuteToolFn): OpenAIAgentTool {
+ return createOpenAIAgentTool({
+ name: composioTool.slug,
+ description: composioTool.description ?? '',
+ parameters: jsonSchemaToZodSchema(
+ (composioTool.inputParameters as Record<string, unknown>) ?? {},
+ {
+ strict: this.strict ? true : false,
+ }
+ ),
+ execute: async params => {
+ const input = typeof params === 'string' ? JSON.parse(params) : params;
+ return await executeTool(composioTool.slug, input);
+ },
+ });
+ }
+
+ /**
+ * Wraps a list of Composio tools as a OpenAI Agents tool collection.
+ *
+ * This method transforms multiple Composio tool definitions into the format
+ * expected by OpenAI Agents for function calling, organizing them
+ * into a dictionary keyed by tool slug.
+ *
+ * @param {ComposioTool[]} tools - Array of Composio tools to wrap
+ * @param {ExecuteToolFn} executeTool - Function to execute the tools
+ * @returns {OpenAIAgentsToolCollection} Dictionary of wrapped tools in OpenAI Agents format
+ *
+ * @example
+ * ```typescript
+ * // Get OpenAI Agents tools from Composio
+ * const composio = new Composio({
+ * apiKey: 'your-api-key',
+ * provider: new OpenAIAgentsProvider()
+ * });
+ *
+ * const tools = await composio.tools.get('default', {
+ * toolkits: ['github'],
+ * });
+ *
+ * import { OpenAI } from '@openai/agents';
+ *
+ * export async function POST(req: Request) {
+ * const { messages } = await req.json();
+ * const openai = new OpenAI();
+ *
+ * const response = await openai.chat.completions.create({
+ * model: 'gpt-4',
+ * messages,
+ * tools: openaiAgentsTools
+ * });
+ *
+ * return new StreamingTextResponse(response.choices[0].message);
+ * }
+ * ```
+ */
+ wrapTools(tools: ComposioTool[], executeTool: ExecuteToolFn): OpenAIAgentsToolCollection {
+ return tools.map(tool => {
+ return this.wrapTool(tool, executeTool);
+ });
+ }
+}
diff --git a/packages/providers/openai-agents/test/openai-agents.test.ts b/packages/providers/openai-agents/test/openai-agents.test.ts
new file mode 100644
index 000000000..50c0dd038
--- /dev/null
+++ b/packages/providers/openai-agents/test/openai-agents.test.ts
@@ -0,0 +1,203 @@
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+import { OpenAIAgentsProvider } from '../src';
+import { Tool } from '@composio/core';
+import { tool as createOpenAIAgentTool } from '@openai/agents';
+
+// Define an interface for our mocked OpenAI Agent tool
+interface MockedOpenAIAgentTool {
+ name: string;
+ description: string;
+ parameters: any;
+ execute: Function;
+ _isMockedOpenAIAgentTool: boolean;
+}
+
+// Mock the @openai/agents module
+vi.mock('@openai/agents', () => {
+ return {
+ tool: vi.fn().mockImplementation(toolConfig => {
+ return {
+ ...toolConfig,
+ _isMockedOpenAIAgentTool: true,
+ } as MockedOpenAIAgentTool;
+ }),
+ };
+});
+
+describe('OpenAIAgentsProvider', () => {
+ let provider: OpenAIAgentsProvider;
+ let mockTool: Tool;
+ let mockExecuteToolFn: any;
+
+ beforeEach(() => {
+ provider = new OpenAIAgentsProvider();
+
+ // Mock the global execute tool function
+ mockExecuteToolFn = vi.fn().mockResolvedValue({
+ data: { result: 'success' },
+ error: null,
+ successful: true,
+ });
+ provider._setExecuteToolFn(mockExecuteToolFn);
+
+ // Create a mock Composio tool
+ mockTool = {
+ slug: 'test-tool',
+ name: 'Test Tool',
+ description: 'A tool for testing',
+ inputParameters: {
+ type: 'object',
+ properties: {
+ input: {
+ type: 'string',
+ description: 'Test input',
+ },
+ },
+ required: ['input'],
+ },
+ tags: [],
+ };
+
+ // Reset mocks before each test
+ vi.clearAllMocks();
+ });
+
+ describe('name property', () => {
+ it('should have the correct name', () => {
+ expect(provider.name).toBe('openai-agents');
+ });
+ });
+
+ describe('_isAgentic property', () => {
+ it('should be agentic', () => {
+ expect(provider._isAgentic).toBe(true);
+ });
+ });
+
+ describe('wrapTool', () => {
+ it('should wrap a tool in OpenAI Agent tool format', () => {
+ const wrapped = provider.wrapTool(
+ mockTool,
+ mockExecuteToolFn
+ ) as unknown as MockedOpenAIAgentTool;
+
+ expect(createOpenAIAgentTool).toHaveBeenCalledWith({
+ name: mockTool.slug,
+ description: mockTool.description,
+ parameters: mockTool.inputParameters,
+ execute: expect.any(Function),
+ });
+
+ expect(wrapped._isMockedOpenAIAgentTool).toBe(true);
+ });
+
+ it('should handle tools without input parameters', () => {
+ const toolWithoutParams: Tool = {
+ ...mockTool,
+ inputParameters: undefined,
+ };
+
+ const wrapped = provider.wrapTool(
+ toolWithoutParams,
+ mockExecuteToolFn
+ ) as unknown as MockedOpenAIAgentTool;
+
+ expect(wrapped._isMockedOpenAIAgentTool).toBe(true);
+ });
+
+ it('should create a function that executes the tool with the right parameters', async () => {
+ provider.wrapTool(mockTool, mockExecuteToolFn) as unknown as MockedOpenAIAgentTool;
+
+ // Extract the execute function from the call to tool()
+ const executeFunction = (createOpenAIAgentTool as any).mock.calls[0][0].execute;
+
+ // Test the execute function with an object parameter
+ const params = { input: 'test-value' };
+ await executeFunction(params);
+
+ expect(mockExecuteToolFn).toHaveBeenCalledWith(mockTool.slug, params);
+
+ // Reset and test with a JSON string parameter
+ vi.clearAllMocks();
+ const stringParams = JSON.stringify(params);
+ await executeFunction(stringParams);
+
+ expect(mockExecuteToolFn).toHaveBeenCalledWith(mockTool.slug, params);
+ });
+ });
+
+ describe('wrapTools', () => {
+ it('should wrap multiple tools', () => {
+ const anotherTool: Tool = {
+ ...mockTool,
+ slug: 'another-tool',
+ name: 'Another Tool',
+ };
+ const tools = [mockTool, anotherTool];
+
+ const wrapped = provider.wrapTools(tools, mockExecuteToolFn);
+
+ expect(Array.isArray(wrapped)).toBe(true);
+ expect(wrapped).toHaveLength(2);
+ expect(wrapped[0]).toHaveProperty('name', 'test-tool');
+ expect(wrapped[1]).toHaveProperty('name', 'another-tool');
+
+ // Verify tool was called with the right parameters for each tool
+ expect(createOpenAIAgentTool).toHaveBeenCalledTimes(2);
+ expect(createOpenAIAgentTool).toHaveBeenCalledWith({
+ name: mockTool.slug,
+ description: mockTool.description,
+ parameters: mockTool.inputParameters,
+ execute: expect.any(Function),
+ });
+ expect(createOpenAIAgentTool).toHaveBeenCalledWith({
+ name: anotherTool.slug,
+ description: anotherTool.description,
+ parameters: anotherTool.inputParameters,
+ execute: expect.any(Function),
+ });
+ });
+
+ it('should return an empty array for empty tools array', () => {
+ const wrapped = provider.wrapTools([], mockExecuteToolFn);
+ expect(wrapped).toEqual([]);
+ expect(createOpenAIAgentTool).not.toHaveBeenCalled();
+ });
+ });
+
+ describe('executeTool', () => {
+ it('should execute a tool using the global execute function', async () => {
+ const toolSlug = 'test-tool';
+ const toolParams = {
+ userId: 'test-user',
+ arguments: { input: 'test-value' },
+ };
+
+ const result = await provider.executeTool(toolSlug, toolParams);
+
+ expect(mockExecuteToolFn).toHaveBeenCalledWith(toolSlug, toolParams, undefined);
+ expect(result).toEqual({
+ data: { result: 'success' },
+ error: null,
+ successful: true,
+ });
+ });
+
+ it('should pass modifiers to the global execute function', async () => {
+ const toolSlug = 'test-tool';
+ const toolParams = {
+ userId: 'test-user',
+ arguments: { input: 'test-value' },
+ };
+
+ const modifiers = {
+ beforeExecute: vi.fn(params => params),
+ afterExecute: vi.fn(response => response),
+ };
+
+ await provider.executeTool(toolSlug, toolParams, modifiers);
+
+ expect(mockExecuteToolFn).toHaveBeenCalledWith(toolSlug, toolParams, modifiers);
+ });
+ });
+});
diff --git a/packages/providers/openai-agents/tsconfig.json b/packages/providers/openai-agents/tsconfig.json
new file mode 100644
index 000000000..a05651a3a
--- /dev/null
+++ b/packages/providers/openai-agents/tsconfig.json
@@ -0,0 +1,16 @@
+{
+ "extends": "../../../tsconfig.base.json",
+ "compilerOptions": {
+ "target": "ESNext",
+ "module": "ESNext",
+ "declaration": true,
+ "declarationDir": "./dist",
+ "outDir": "./dist",
+ "strict": true,
+ "esModuleInterop": true,
+ "moduleResolution": "node",
+ "skipLibCheck": true,
+ "resolveJsonModule": true
+ },
+ "include": ["src"]
+}
diff --git a/packages/providers/openai-agents/tsup.config.ts b/packages/providers/openai-agents/tsup.config.ts
new file mode 100644
index 000000000..f9cdf4040
--- /dev/null
+++ b/packages/providers/openai-agents/tsup.config.ts
@@ -0,0 +1,10 @@
+import { defineConfig } from 'tsup';
+
+export default defineConfig({
+ entry: ['src/index.ts'],
+ format: ['esm', 'cjs'],
+ dts: true,
+ clean: true,
+ minify: false,
+ outDir: 'dist',
+});
diff --git a/packages/providers/openai/src/OpenAIResponsesProvider.ts b/packages/providers/openai/src/OpenAIResponsesProvider.ts
new file mode 100644
index 000000000..5acc4a5e4
--- /dev/null
+++ b/packages/providers/openai/src/OpenAIResponsesProvider.ts
@@ -0,0 +1,314 @@
+/**
+ * OpenAI ToolSet
+ *
+ * Author: Musthaq Ahamad <[email protected]>
+ * Legacy Reference: https://github.com/ComposioHQ/composio/blob/master/js/src/toolsets/openai.ts
+ */
+import { OpenAI } from 'openai';
+import { BaseNonAgenticProvider, removeNonRequiredProperties } from '@composio/core';
+import { Tool, ToolExecuteParams } from '@composio/core';
+import { ExecuteToolModifiers } from '@composio/core';
+import { ExecuteToolFnOptions } from '@composio/core';
+import { Stream } from 'openai/streaming';
+
+export type OpenAiTool = OpenAI.Responses.FunctionTool;
+export type OpenAiToolCollection = Array<OpenAiTool>;
+export type OpenAIResponsesProviderOptions = {
+ /**
+ * Whether to enforce strict parameter validation. Default `false`.
+ */
+ strict?: boolean;
+};
+export class OpenAIResponsesProvider extends BaseNonAgenticProvider<
+ OpenAiToolCollection,
+ OpenAiTool
+> {
+ readonly name = 'openai';
+ private strict: boolean | null;
+
+ /**
+ * Creates a new instance of the OpenAIProvider.
+ *
+ * This is the default provider for the Composio SDK and is automatically
+ * available without additional installation.
+ *
+ * @param {OpenAIResponsesProviderOptions} [options] - Optional provider options
+ * @returns {OpenAIResponsesProvider} The OpenAIResponsesProvider instance
+ *
+ * @example
+ * ```typescript
+ * // The OpenAIProvider is used by default when initializing Composio
+ * const composio = new Composio({
+ * apiKey: 'your-api-key'
+ * });
+ *
+ * // You can also explicitly specify it
+ * const composio = new Composio({
+ * apiKey: 'your-api-key',
+ * provider: new OpenAIResponsesProvider({
+ * strict: true // Optional, default is false
+ * })
+ * });
+ * ```
+ */
+ constructor(options?: OpenAIResponsesProviderOptions) {
+ super();
+ this.strict = options?.strict ?? false;
+ }
+
+ /**
+ * Wraps a Composio tool in the OpenAI function calling format.
+ *
+ * This method transforms a Composio tool definition into the format
+ * expected by OpenAI's function calling API.
+ *
+ * @param tool - The Composio tool to wrap
+ * @returns The wrapped tool in OpenAI format
+ *
+ * @example
+ * ```typescript
+ * // Wrap a single tool for use with OpenAI
+ * const composioTool = {
+ * slug: 'SEARCH_TOOL',
+ * description: 'Search for information',
+ * inputParameters: {
+ * type: 'object',
+ * properties: {
+ * query: { type: 'string' }
+ * },
+ * required: ['query']
+ * }
+ * };
+ *
+ * const openAITool = provider.wrapTool(composioTool);
+ * ```
+ */
+ override wrapTool(tool: Tool): OpenAiTool {
+ const inputParams = tool.inputParameters;
+
+ const parameters =
+ this.strict && inputParams?.type === 'object'
+ ? removeNonRequiredProperties(
+ inputParams as {
+ type: 'object';
+ properties: Record<string, unknown>;
+ required?: string[];
+ }
+ )
+ : (inputParams ?? {});
+
+ return {
+ name: tool.slug,
+ description: tool.description,
+ parameters,
+ strict: this.strict,
+ type: 'function',
+ };
+ }
+
+ /**
+ * Wraps multiple Composio tools in the OpenAI function calling format.
+ *
+ * This method transforms a list of Composio tools into the format
+ * expected by OpenAI's function calling API.
+ *
+ * @param tools - Array of Composio tools to wrap
+ * @returns Array of wrapped tools in OpenAI format
+ *
+ * @example
+ * ```typescript
+ * // Wrap multiple tools for use with OpenAI
+ * const composioTools = [
+ * {
+ * slug: 'SEARCH_TOOL',
+ * description: 'Search for information',
+ * inputParameters: {
+ * type: 'object',
+ * properties: {
+ * query: { type: 'string' }
+ * }
+ * }
+ * },
+ * {
+ * slug: 'WEATHER_TOOL',
+ * description: 'Get weather information',
+ * inputParameters: {
+ * type: 'object',
+ * properties: {
+ * location: { type: 'string' }
+ * }
+ * }
+ * }
+ * ];
+ *
+ * const openAITools = provider.wrapTools(composioTools);
+ * ```
+ */
+ override wrapTools = (tools: Tool[]): OpenAiToolCollection => {
+ return tools.map(tool => this.wrapTool(tool));
+ };
+
+ /**
+ * Executes a tool call from OpenAI's chat completion.
+ *
+ * This method processes a tool call from OpenAI's chat completion API,
+ * executes the corresponding Composio tool, and returns the result.
+ *
+ * @param {string} userId - The user ID for authentication and tracking
+ * @param {OpenAI.ChatCompletionMessageToolCall} tool - The tool call from OpenAI
+ * @param {ExecuteToolFnOptions} [options] - Optional execution options
+ * @param {ExecuteToolModifiers} [modifiers] - Optional execution modifiers
+ * @returns {Promise<string>} The result of the tool call as a JSON string
+ *
+ * @example
+ * ```typescript
+ * // Execute a tool call from OpenAI
+ * const toolCall = {
+ * id: 'call_abc123',
+ * type: 'function',
+ * function: {
+ * name: 'SEARCH_TOOL',
+ * arguments: '{"query":"composio documentation"}'
+ * }
+ * };
+ *
+ * const result = await provider.executeToolCall(
+ * 'user123',
+ * toolCall,
+ * { connectedAccountId: 'conn_xyz456' }
+ * );
+ * console.log(JSON.parse(result));
+ * ```
+ */
+ async executeToolCall(
+ userId: string,
+ tool: OpenAI.Responses.ResponseFunctionToolCall,
+ options?: ExecuteToolFnOptions,
+ modifiers?: ExecuteToolModifiers
+ ): Promise<string> {
+ const payload: ToolExecuteParams = {
+ arguments: JSON.parse(tool.arguments),
+ connectedAccountId: options?.connectedAccountId,
+ customAuthParams: options?.customAuthParams,
+ userId: userId,
+ };
+ const result = await this.executeTool(tool.name, payload, modifiers);
+ return JSON.stringify(result);
+ }
+
+ /**
+ * Handles tool calls from OpenAI's response.
+ *
+ * This method processes tool calls from an OpenAI response,
+ * executes each tool call, and returns the results.
+ *
+ * @param {string} userId - The user ID for authentication and tracking
+ * @param {OpenAI.ChatCompletion} chatCompletion - The response from OpenAI
+ * @param {ExecuteToolFnOptions} [options] - Optional execution options
+ * @param {ExecuteToolModifiers} [modifiers] - Optional execution modifiers
+ * @returns {Promise<string[]>} Array of tool execution results as JSON strings
+ *
+ * @example
+ * ```typescript
+ * // Handle tool calls from a response
+ * const response = await openai.responses.create({
+ * model: 'gpt-4o-2024-11-20',
+ * input: 'What is the capital of France?',
+ * tools: await composio.tools.get(composioTools)
+ * });
+ *
+ * const inputItems = await composio.provider.handleToolCalls(
+ * 'user123',
+ * response.output
+ * );
+ * console.log(inputItems); // Array of tool execution results
+ *
+ * // Submit tool outputs back to OpenAI
+ * const response = await openai.responses.create({
+ * model: 'gpt-4o-2024-11-20',
+ * input: inputItems,
+ * tools: await composio.tools.get(composioTools),
+ * });
+ * ```
+ * ```
+ */
+ async handleToolCalls(
+ userId: string,
+ toolCalls: OpenAI.Responses.ResponseOutputItem[],
+ options?: ExecuteToolFnOptions,
+ modifiers?: ExecuteToolModifiers
+ ): Promise<OpenAI.Responses.ResponseInputItem.FunctionCallOutput[]> {
+ const toolOutputs: OpenAI.Responses.ResponseInputItem.FunctionCallOutput[] = [];
+ for (const output of toolCalls) {
+ if (output.type === 'function_call') {
+ const tool_call = {
+ id: output.id,
+ name: output.name,
+ arguments: output.arguments,
+ } as OpenAI.Responses.ResponseFunctionToolCall;
+ try {
+ const toolOutput = await this.executeToolCall(userId, tool_call, options, modifiers);
+ toolOutputs.push({
+ call_id: output.call_id ?? '',
+ type: 'function_call_output',
+ output: toolOutput,
+ // id: output.id ?? '',
+ status: 'completed',
+ });
+ } catch (error) {
+ toolOutputs.push({
+ call_id: output.call_id ?? '',
+ type: 'function_call_output',
+ output: error instanceof Error ? error.message : 'Unknown error',
+ // id: output.id ?? '',
+ status: 'incomplete',
+ });
+ }
+ }
+ }
+ return toolOutputs;
+ }
+
+ /**
+ * Handles all the tool calls from the OpenAI Responses API.
+ *
+ * This method processes tool calls from an OpenAI Responses request,
+ * executes each tool call, and returns the tool outputs for submission.
+ *
+ * @param {string} userId - The user ID for authentication and tracking
+ * @param {OpenAI.Responses.Response} response - The Responses request object containing tool calls
+ * @param {ExecuteToolFnOptions} [options] - Optional execution options
+ * @param {ExecuteToolModifiers} [modifiers] - Optional execution modifiers
+ * @returns {Promise<OpenAI.Beta.Threads.Runs.RunSubmitToolOutputsParams.ToolOutput[]>} Array of tool outputs for submission
+ *
+ * @example
+ * ```typescript
+ * // Handle tool calls from an OpenAI response
+ * const response = await openai.responses.create({
+ * model: 'gpt-4o-2024-11-20',
+ * input: 'What is the capital of France?',
+ * tools: await composio.tools.get(composioTools),
+ * tool_choice: 'auto',
+ * });
+ *
+ * const inputItems = await composio.provider.handleResponse('default', response);
+ *
+ * // Submit tool outputs back to OpenAI
+ * const response = await openai.responses.create({
+ * model: 'gpt-4o-2024-11-20',
+ * input: inputItems,
+ * tools: await composio.tools.get(composioTools),
+ * });
+ * ```
+ */
+ async handleResponse(
+ userId: string,
+ response: OpenAI.Responses.Response,
+ options?: ExecuteToolFnOptions,
+ modifiers?: ExecuteToolModifiers
+ ): Promise<OpenAI.Responses.ResponseInputItem.FunctionCallOutput[]> {
+ const tool_calls = response.output?.filter(output => output.type === 'function_call') || [];
+ const tool_outputs = await this.handleToolCalls(userId, tool_calls, options, modifiers);
+ return tool_outputs;
+ }
+}
diff --git a/packages/providers/openai/src/index.ts b/packages/providers/openai/src/index.ts
index 5750988c1..70d6d5db5 100644
--- a/packages/providers/openai/src/index.ts
+++ b/packages/providers/openai/src/index.ts
@@ -13,3 +13,4 @@
* @module providers/openai
*/
export { OpenAIProvider } from '@composio/core';
+export { OpenAIResponsesProvider } from './OpenAIResponsesProvider';
diff --git a/packages/providers/openai/test/opeanai-responses.test.ts b/packages/providers/openai/test/opeanai-responses.test.ts
new file mode 100644
index 000000000..33b657935
--- /dev/null
+++ b/packages/providers/openai/test/opeanai-responses.test.ts
@@ -0,0 +1,417 @@
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+import { OpenAIResponsesProvider } from '../src';
+import { Tool } from '@composio/core';
+import { OpenAI } from 'openai';
+
+// Mock the openai modules
+vi.mock('openai', () => {
+ return {
+ OpenAI: vi.fn().mockImplementation(() => ({
+ beta: {
+ threads: {
+ runs: {
+ retrieve: vi.fn().mockImplementation((threadId, runId) => {
+ return { id: runId, status: 'completed' };
+ }),
+ submitToolOutputs: vi.fn().mockImplementation((threadId, runId, options) => {
+ return { id: runId, status: 'completed' };
+ }),
+ },
+ },
+ },
+ })),
+ };
+});
+
+// Define interfaces for our OpenAI mocked types
+interface MockedOpenAITool {
+ type: 'function';
+ name: string;
+ description?: string;
+ parameters?: any;
+ strict?: boolean;
+}
+
+describe('OpenAIResponsesProvider', () => {
+ let provider: OpenAIResponsesProvider;
+ let mockTool: Tool;
+ let mockExecuteToolFn: any;
+
+ beforeEach(() => {
+ provider = new OpenAIResponsesProvider();
+
+ // Mock the global execute tool function
+ mockExecuteToolFn = vi.fn().mockResolvedValue({
+ data: { result: 'success' },
+ error: null,
+ successful: true,
+ });
+ provider._setExecuteToolFn(mockExecuteToolFn);
+
+ // Create a mock Composio tool
+ mockTool = {
+ slug: 'test-tool',
+ name: 'Test Tool',
+ description: 'A tool for testing',
+ inputParameters: {
+ type: 'object',
+ properties: {
+ input: {
+ type: 'string',
+ description: 'Test input',
+ },
+ },
+ required: ['input'],
+ },
+ tags: [],
+ };
+
+ // Reset mocks before each test
+ vi.clearAllMocks();
+ });
+
+ describe('name property', () => {
+ it('should have the correct name', () => {
+ expect(provider.name).toBe('openai');
+ });
+ });
+
+ describe('wrapTool', () => {
+ it('should wrap a tool in OpenAI function format', () => {
+ const wrapped = provider.wrapTool(mockTool) as MockedOpenAITool;
+
+ expect(wrapped).toEqual({
+ type: 'function',
+ name: mockTool.slug,
+ description: mockTool.description,
+ parameters: mockTool.inputParameters,
+ strict: false,
+ });
+ });
+
+ it('should handle tools without input parameters', () => {
+ const toolWithoutParams: Tool = {
+ ...mockTool,
+ inputParameters: undefined,
+ };
+
+ const wrapped = provider.wrapTool(toolWithoutParams) as MockedOpenAITool;
+
+ expect(wrapped).toEqual({
+ type: 'function',
+ name: toolWithoutParams.slug,
+ description: toolWithoutParams.description,
+ parameters: {},
+ strict: false,
+ });
+ });
+
+ it('should respect strict mode when wrapping tools', () => {
+ const strictProvider = new OpenAIResponsesProvider({ strict: true });
+ const wrapped = strictProvider.wrapTool(mockTool) as MockedOpenAITool;
+
+ expect(wrapped.strict).toBe(true);
+ expect(wrapped.parameters).toEqual(mockTool.inputParameters);
+ });
+ });
+
+ describe('wrapTools', () => {
+ it('should wrap multiple tools', () => {
+ const anotherTool: Tool = {
+ ...mockTool,
+ slug: 'another-tool',
+ name: 'Another Tool',
+ };
+ const tools = [mockTool, anotherTool];
+
+ const wrapped = provider.wrapTools(tools);
+
+ expect(wrapped).toHaveLength(2);
+ expect(wrapped[0]).toEqual({
+ type: 'function',
+ name: mockTool.slug,
+ description: mockTool.description,
+ parameters: mockTool.inputParameters,
+ strict: false,
+ });
+ expect(wrapped[1]).toEqual({
+ type: 'function',
+ name: anotherTool.slug,
+ description: anotherTool.description,
+ parameters: anotherTool.inputParameters,
+ strict: false,
+ });
+ });
+
+ it('should return an empty array for empty tools array', () => {
+ const wrapped = provider.wrapTools([]);
+ expect(wrapped).toEqual([]);
+ });
+ });
+
+ describe('executeToolCall', () => {
+ it('should execute a tool call and return the result as string', async () => {
+ const userId = 'test-user';
+ const toolCall = {
+ id: 'call-123',
+ type: 'function',
+ name: 'test-tool',
+ arguments: JSON.stringify({ input: 'test-value' }),
+ call_id: 'call-123',
+ } as unknown as OpenAI.Responses.ResponseFunctionToolCall;
+
+ const result = await provider.executeToolCall(userId, toolCall);
+
+ expect(mockExecuteToolFn).toHaveBeenCalledWith(
+ 'test-tool',
+ {
+ arguments: { input: 'test-value' },
+ userId: 'test-user',
+ connectedAccountId: undefined,
+ customAuthParams: undefined,
+ },
+ undefined
+ );
+ expect(result).toBe(
+ JSON.stringify({
+ data: { result: 'success' },
+ error: null,
+ successful: true,
+ })
+ );
+ });
+
+ it('should pass options to executeTool', async () => {
+ const userId = 'test-user';
+ const toolCall = {
+ id: 'call-123',
+ type: 'function',
+ name: 'test-tool',
+ arguments: JSON.stringify({ input: 'test-value' }),
+ call_id: 'call-123',
+ } as unknown as OpenAI.Responses.ResponseFunctionToolCall;
+
+ const options = {
+ connectedAccountId: 'conn-123',
+ customAuthParams: {
+ parameters: [{ name: 'token', value: 'abc123', in: 'header' as const }],
+ },
+ };
+
+ const modifiers = {
+ beforeExecute: vi.fn(params => params),
+ afterExecute: vi.fn(response => response),
+ };
+
+ await provider.executeToolCall(userId, toolCall, options, modifiers);
+
+ expect(mockExecuteToolFn).toHaveBeenCalledWith(
+ 'test-tool',
+ {
+ arguments: { input: 'test-value' },
+ userId: 'test-user',
+ connectedAccountId: 'conn-123',
+ customAuthParams: options.customAuthParams,
+ },
+ modifiers
+ );
+ });
+ });
+
+ describe('handleToolCalls', () => {
+ it('should handle tool calls from OpenAI response', async () => {
+ const userId = 'test-user';
+ const toolCalls = [
+ {
+ id: 'call-123',
+ type: 'function_call',
+ name: 'test-tool',
+ arguments: JSON.stringify({ input: 'test-value' }),
+ call_id: 'call-123',
+ },
+ ] as OpenAI.Responses.ResponseOutputItem[];
+
+ const executeToolCallSpy = vi.spyOn(provider, 'executeToolCall');
+ executeToolCallSpy.mockResolvedValue(JSON.stringify({ result: 'success' }));
+
+ const results = await provider.handleToolCalls(userId, toolCalls);
+
+ expect(executeToolCallSpy).toHaveBeenCalledWith(
+ userId,
+ {
+ id: 'call-123',
+ name: 'test-tool',
+ arguments: JSON.stringify({ input: 'test-value' }),
+ },
+ undefined,
+ undefined
+ );
+ expect(results).toEqual([
+ {
+ call_id: 'call-123',
+ type: 'function_call_output',
+ output: JSON.stringify({ result: 'success' }),
+ status: 'completed',
+ },
+ ]);
+ });
+
+ it('should handle errors during tool execution', async () => {
+ const userId = 'test-user';
+ const toolCalls = [
+ {
+ id: 'call-123',
+ type: 'function_call',
+ name: 'test-tool',
+ arguments: JSON.stringify({ input: 'test-value' }),
+ call_id: 'call-123',
+ },
+ ] as OpenAI.Responses.ResponseOutputItem[];
+
+ const executeToolCallSpy = vi.spyOn(provider, 'executeToolCall');
+ executeToolCallSpy.mockRejectedValue(new Error('Tool execution failed'));
+
+ const results = await provider.handleToolCalls(userId, toolCalls);
+
+ expect(results).toEqual([
+ {
+ call_id: 'call-123',
+ type: 'function_call_output',
+ output: 'Tool execution failed',
+ status: 'incomplete',
+ },
+ ]);
+ });
+
+ it('should handle multiple tool calls', async () => {
+ const userId = 'test-user';
+ const toolCalls = [
+ {
+ id: 'call-123',
+ type: 'function_call',
+ name: 'test-tool-1',
+ arguments: JSON.stringify({ input: 'test-value-1' }),
+ call_id: 'call-123',
+ },
+ {
+ id: 'call-456',
+ type: 'function_call',
+ name: 'test-tool-2',
+ arguments: JSON.stringify({ input: 'test-value-2' }),
+ call_id: 'call-456',
+ },
+ ] as OpenAI.Responses.ResponseOutputItem[];
+
+ const executeToolCallSpy = vi.spyOn(provider, 'executeToolCall');
+ executeToolCallSpy
+ .mockResolvedValueOnce(JSON.stringify({ result: 'success-1' }))
+ .mockResolvedValueOnce(JSON.stringify({ result: 'success-2' }));
+
+ const results = await provider.handleToolCalls(userId, toolCalls);
+
+ expect(executeToolCallSpy).toHaveBeenCalledTimes(2);
+ expect(results).toEqual([
+ {
+ call_id: 'call-123',
+ type: 'function_call_output',
+ output: JSON.stringify({ result: 'success-1' }),
+ status: 'completed',
+ },
+ {
+ call_id: 'call-456',
+ type: 'function_call_output',
+ output: JSON.stringify({ result: 'success-2' }),
+ status: 'completed',
+ },
+ ]);
+ });
+ });
+
+ describe('handleResponse', () => {
+ it('should handle OpenAI response with tool calls', async () => {
+ const userId = 'test-user';
+ const response = {
+ id: 'response-123',
+ created_at: new Date().toISOString(),
+ output: [
+ {
+ id: 'call-123',
+ type: 'function_call',
+ name: 'test-tool',
+ arguments: JSON.stringify({ input: 'test-value' }),
+ call_id: 'call-123',
+ },
+ ],
+ output_text: 'Test output',
+ error: null,
+ status: 'completed',
+ } as unknown as OpenAI.Responses.Response;
+
+ const handleToolCallsSpy = vi.spyOn(provider, 'handleToolCalls');
+ handleToolCallsSpy.mockResolvedValue([
+ {
+ call_id: 'call-123',
+ type: 'function_call_output',
+ output: JSON.stringify({ result: 'success' }),
+ status: 'completed',
+ },
+ ]);
+
+ const results = await provider.handleResponse(userId, response);
+
+ expect(handleToolCallsSpy).toHaveBeenCalledWith(
+ userId,
+ response.output,
+ undefined,
+ undefined
+ );
+ expect(results).toEqual([
+ {
+ call_id: 'call-123',
+ type: 'function_call_output',
+ output: JSON.stringify({ result: 'success' }),
+ status: 'completed',
+ },
+ ]);
+ });
+
+ it('should handle OpenAI response without tool calls', async () => {
+ const userId = 'test-user';
+ const response = {
+ id: 'response-123',
+ created_at: new Date().toISOString(),
+ output: [],
+ output_text: 'Test output',
+ error: null,
+ status: 'completed',
+ } as unknown as OpenAI.Responses.Response;
+
+ const handleToolCallsSpy = vi.spyOn(provider, 'handleToolCalls');
+ handleToolCallsSpy.mockResolvedValue([]);
+
+ const results = await provider.handleResponse(userId, response);
+
+ expect(handleToolCallsSpy).toHaveBeenCalledWith(userId, [], undefined, undefined);
+ expect(results).toEqual([]);
+ });
+
+ it('should handle OpenAI response with undefined output', async () => {
+ const userId = 'test-user';
+ const response = {
+ id: 'response-123',
+ created_at: new Date().toISOString(),
+ output_text: 'Test output',
+ error: null,
+ status: 'completed',
+ } as unknown as OpenAI.Responses.Response;
+
+ const handleToolCallsSpy = vi.spyOn(provider, 'handleToolCalls');
+ handleToolCallsSpy.mockResolvedValue([]);
+
+ const results = await provider.handleResponse(userId, response);
+
+ expect(handleToolCallsSpy).toHaveBeenCalledWith(userId, [], undefined, undefined);
+ expect(results).toEqual([]);
+ });
+ });
+});
diff --git a/packages/providers/vercel/src/index.ts b/packages/providers/vercel/src/index.ts
index ffc089b80..f3eb6f1b6 100644
--- a/packages/providers/vercel/src/index.ts
+++ b/packages/providers/vercel/src/index.ts
@@ -20,21 +20,21 @@ export class VercelProvider extends BaseAgenticProvider<VercelToolCollection, Ve
/**
* Creates a new instance of the VercelProvider.
- *
+ *
* This provider enables integration with the Vercel AI SDK,
* allowing Composio tools to be used with Vercel AI applications.
- *
+ *
* @example
* ```typescript
* // Initialize the Vercel provider
* const provider = new VercelProvider();
- *
+ *
* // Use with Composio
* const composio = new Composio({
* apiKey: 'your-api-key',
* provider: new VercelProvider()
* });
- *
+ *
* // Use the provider to wrap tools for Vercel AI SDK
* const vercelTools = provider.wrapTools(composioTools, composio.tools.execute);
* ```
@@ -45,14 +45,14 @@ export class VercelProvider extends BaseAgenticProvider<VercelToolCollection, Ve
/**
* Wraps a Composio tool in a Vercel AI SDK tool format.
- *
+ *
* This method transforms a Composio tool definition into the format
* expected by Vercel's AI SDK for function calling.
- *
+ *
* @param {ComposioTool} composioTool - The Composio tool to wrap
* @param {ExecuteToolFn} executeTool - Function to execute the tool
* @returns {VercelTool} The wrapped Vercel tool
- *
+ *
* @example
* ```typescript
* // Wrap a single tool for use with Vercel AI SDK
@@ -67,27 +67,27 @@ export class VercelProvider extends BaseAgenticProvider<VercelToolCollection, Ve
* required: ['query']
* }
* };
- *
+ *
* // Create a Vercel tool using the provider
* const vercelTool = provider.wrapTool(
* composioTool,
* composio.tools.execute
* );
- *
+ *
* // Use with Vercel AI SDK
* import { StreamingTextResponse, Message } from 'ai';
* import { OpenAI } from 'openai';
- *
+ *
* export async function POST(req: Request) {
* const { messages } = await req.json();
* const openai = new OpenAI();
- *
+ *
* const response = await openai.chat.completions.create({
* model: 'gpt-4',
* messages,
* tools: [vercelTool]
* });
- *
+ *
* return new StreamingTextResponse(response.choices[0].message);
* }
* ```
@@ -105,15 +105,15 @@ export class VercelProvider extends BaseAgenticProvider<VercelToolCollection, Ve
/**
* Wraps a list of Composio tools as a Vercel AI SDK tool collection.
- *
+ *
* This method transforms multiple Composio tool definitions into the format
* expected by Vercel's AI SDK for function calling, organizing them
* into a dictionary keyed by tool slug.
- *
+ *
* @param {ComposioTool[]} tools - Array of Composio tools to wrap
* @param {ExecuteToolFn} executeTool - Function to execute the tools
* @returns {VercelToolCollection} Dictionary of wrapped tools in Vercel AI SDK format
- *
+ *
* @example
* ```typescript
* // Wrap multiple tools for use with Vercel AI SDK
@@ -141,27 +141,27 @@ export class VercelProvider extends BaseAgenticProvider<VercelToolCollection, Ve
* }
* }
* ];
- *
+ *
* // Create Vercel tools using the provider
* const vercelTools = provider.wrapTools(
* composioTools,
* composio.tools.execute
* );
- *
+ *
* // Use with Vercel AI SDK in a Next.js API route
* import { StreamingTextResponse } from 'ai';
* import { OpenAI } from 'openai';
- *
+ *
* export async function POST(req: Request) {
* const { messages } = await req.json();
* const openai = new OpenAI();
- *
+ *
* const response = await openai.chat.completions.create({
* model: 'gpt-4',
* messages,
* tools: Object.values(vercelTools)
* });
- *
+ *
* return new StreamingTextResponse(response.choices[0].message);
* }
* ```
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 6140bdbb0..667df66fe 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -248,6 +248,15 @@ importers:
'@composio/core':
specifier: workspace:*
version: link:../../packages/core
+ '@composio/openai':
+ specifier: workspace:^
+ version: link:../../packages/providers/openai
+ '@composio/openai-agents':
+ specifier: workspace:^
+ version: link:../../packages/providers/openai-agents
+ '@openai/agents':
+ specifier: ^0.0.7
dotenv:
specifier: ^16.4.1
version: 16.5.0
@@ -430,8 +439,8 @@ importers:
specifier: 0.1.0-alpha.22
version: 0.1.0-alpha.22
'@composio/json-schema-to-zod':
- specifier: 0.1.6
- version: 0.1.6
+ specifier: 0.1.9
+ version: 0.1.9
chalk:
specifier: ^5.4.1
version: 5.4.1
@@ -550,7 +559,7 @@ importers:
dependencies:
'@langchain/core':
specifier: ^0.3.44
devDependencies:
'@composio/core':
specifier: workspace:*
@@ -603,6 +612,25 @@ importers:
specifier: ^3.1.4
+ packages/providers/openai-agents:
+ dependencies:
+ '@openai/agents':
+ specifier: ^0.0.7
+ devDependencies:
+ '@composio/core':
+ specifier: workspace:*
+ version: link:../../core
+ tsup:
+ specifier: ^8.4.0
+ typescript:
+ specifier: ^5.8.3
+ version: 5.8.3
+ vitest:
+ specifier: ^3.1.4
+
packages/providers/vercel:
dependencies:
ai:
@@ -876,8 +904,8 @@ packages:
'@composio/[email protected]':
resolution: {integrity: sha512-b9KCO5gy0EsCG+nXikOdm17PiZZ85rw3vwu9aNRIse9rEj2FA1SScpP+P9GN4G0lQHl+QPyDuVvGa6U9AATFeg==}
- '@composio/[email protected]':
- resolution: {integrity: sha512-Eso0rvvdCAxgcjejXXdyJsG4jB3ScUaxkrMaytG4B9Y6uwKJ/uxFrzWqRcwMl5wwQ7nd1vtpJUW/nzr8iRcQMg==}
+ '@composio/[email protected]':
+ resolution: {integrity: sha512-uDOAPPkaMWM2DJLCFCW6/rxTgair6EmQ4Ojo6RDayzIl2BRUro0wGkpof4Za8sJPrmdTfSqteRMDy46xPnOYhw==}
'@esbuild/[email protected]':
resolution: {integrity: sha512-9o3TMmpmftaCMepOdA5k/yDw8SfInyzWWTjYTFCX3kPSDJMROQTb8jg+h9Cnwnmm1vOzvxN7gIfB5V2ewpjtGA==}
@@ -1208,6 +1236,23 @@ packages:
resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==}
engines: {node: '>= 8'}
+ '@openai/[email protected]':
+ resolution: {integrity: sha512-qbJ0w20hTMUJM97q9aGWchr7kyNo35emvjKiVjCW/grR4sMJo1fLia4bE52tjCQGo8EZJBJ9bkjXFSqETjdJYw==}
+ peerDependencies:
+ zod: ^3.25.40
+ peerDependenciesMeta:
+ zod:
+ optional: true
+
+ '@openai/[email protected]':
+ resolution: {integrity: sha512-bWlJUZ6VutBnuESd74i9ttpIsfbw9kuH6mhHhN5bNgUjmbQfxM+2aUBfyxXGzr4mEvBkAuKiyAs3DX1shqOBdQ==}
+
+ '@openai/[email protected]':
+ resolution: {integrity: sha512-ndPVQpOIX0J+C5wYo+YUb68q4zrXTIbQH/VS24qSIo9fxJokSxwS5P5hNSxDrdQ3+UlYyx/s1Xu6zRCE11H63Q==}
+
+ '@openai/[email protected]':
+ resolution: {integrity: sha512-qDQn7f33fCySEuEVP+PIpBASmD5bjxhzSglzJ3Z21JcRbLq+hxyBz6hpJy6sa0XOSgHh50u2nlsz+rogTizdew==}
+
'@opentelemetry/[email protected]':
resolution: {integrity: sha512-IxcFDP1IGMDemVFG2by/AMK+/o6EuBQ8idUq3xZ6MxgQGeumYZuX5OwR0h9HuvcUc/JPjQGfU5OHKIKYDJcXeA==}
engines: {node: '>=8.0.0'}
@@ -2142,6 +2187,9 @@ packages:
resolution: {integrity: sha512-jg+97EGIcY9AGHJJRaaPVgetKDsrTgbRjQ5Msgjh/DQKEFl0DtyRr/VCOyD1T2R1MNeWPK/u7JoGhlDZnKBAfA==}
+ '@types/[email protected]':
+ resolution: {integrity: sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==}
+
resolution: {integrity: sha512-8WMXRDD1D+wCohjfslHDgICd2JtMATZU8CkhH8LVJqcJs6dyYj5TGptzP8wApbmEullGBSsCEzzap73DQ1HJaA==}
deprecated: This is a stub types definition. yaml provides its own type definitions, so you do not need this installed.
@@ -3585,6 +3633,18 @@ packages:
zod:
optional: true
+ resolution: {integrity: sha512-VIKmoF7y4oJCDOwP/oHXGzM69+x0dpGFmN9QmYO+uPbLFOmmnwO+x1GbsgUtI+6oraxomGZ566Y421oYVu191w==}
+ hasBin: true
+ peerDependencies:
+ ws: ^8.18.0
+ zod: ^3.23.8
+ peerDependenciesMeta:
+ ws:
+ optional: true
+ zod:
+ optional: true
+
resolution: {integrity: sha512-N4YtSYJqghVu4iek2ZUvcN/0aqH1kRDuNqzcycDxhOUpg7GdvLa2F3DgS6yBNhInhv2r/6I0Flkn7CqL8+nIcw==}
@@ -5269,7 +5329,7 @@ snapshots:
'@composio/[email protected]': {}
- '@composio/[email protected]':
+ '@composio/[email protected]':
dependencies:
'@types/json-schema': 7.0.15
zod: 3.25.62
@@ -5490,14 +5550,14 @@ snapshots:
transitivePeerDependencies:
- openai
dependencies:
'@cfworker/json-schema': 4.1.1
ansi-styles: 5.2.0
camelcase: 6.3.0
decamelize: 1.2.0
js-tiktoken: 1.0.20
mustache: 4.2.0
p-queue: 6.6.2
p-retry: 4.6.2
@@ -5648,6 +5708,56 @@ snapshots:
'@nodelib/fs.scandir': 2.1.5
fastq: 1.19.1
+ dependencies:
+ '@openai/zod': [email protected]
+ debug: 4.4.1
+ optionalDependencies:
+ '@modelcontextprotocol/sdk': 1.12.1
+ zod: 3.25.62
+ transitivePeerDependencies:
+ - supports-color
+ - ws
+
+ dependencies:
+ '@openai/agents-core': 0.0.7([email protected])([email protected])
+ '@openai/zod': [email protected]
+ debug: 4.4.1
+ transitivePeerDependencies:
+ - supports-color
+ - ws
+ - zod
+
+ dependencies:
+ '@openai/agents-core': 0.0.7([email protected])([email protected])
+ '@openai/zod': [email protected]
+ '@types/ws': 8.18.1
+ debug: 4.4.1
+ ws: 8.18.2
+ transitivePeerDependencies:
+ - bufferutil
+ - supports-color
+ - utf-8-validate
+ - zod
+
+ dependencies:
+ '@openai/agents-core': 0.0.7([email protected])([email protected])
+ '@openai/agents-openai': 0.0.7([email protected])([email protected])
+ '@openai/agents-realtime': 0.0.7([email protected])
+ debug: 4.4.1
+ transitivePeerDependencies:
+ - bufferutil
+ - supports-color
+ - utf-8-validate
+ - ws
+ - zod
+
'@opentelemetry/[email protected]':
dependencies:
'@opentelemetry/api': 1.9.0
@@ -6890,6 +7000,10 @@ snapshots:
'@types/[email protected]': {}
+ '@types/[email protected]':
+ dependencies:
+ '@types/node': 24.0.1
+
dependencies:
yaml: 2.8.0
@@ -6994,14 +7108,6 @@ snapshots:
chai: 5.2.0
tinyrainbow: 2.0.0
- dependencies:
- '@vitest/spy': 3.2.3
- estree-walker: 3.0.3
- magic-string: 0.30.17
- optionalDependencies:
-
dependencies:
'@vitest/spy': 3.2.3
@@ -7010,14 +7116,6 @@ snapshots:
optionalDependencies:
- dependencies:
- '@vitest/spy': 3.2.3
- estree-walker: 3.0.3
- magic-string: 0.30.17
- optionalDependencies:
-
'@vitest/[email protected]':
dependencies:
tinyrainbow: 2.0.0
@@ -7047,7 +7145,7 @@ snapshots:
sirv: 3.0.1
tinyglobby: 0.2.14
tinyrainbow: 2.0.0
'@vitest/[email protected]':
dependencies:
@@ -8161,7 +8259,7 @@ snapshots:
optionalDependencies:
dependencies:
'@types/uuid': 10.0.0
chalk: 4.1.2
@@ -8171,7 +8269,7 @@ snapshots:
semver: 7.7.2
uuid: 10.0.0
optionalDependencies:
- openai: 4.104.0([email protected])
dependencies:
@@ -8419,20 +8517,10 @@ snapshots:
transitivePeerDependencies:
- encoding
- dependencies:
- '@types/node': 18.19.111
- '@types/node-fetch': 2.6.12
- abort-controller: 3.0.0
- agentkeepalive: 4.6.0
- form-data-encoder: 1.7.2
- formdata-node: 4.4.1
- node-fetch: 2.7.0
optionalDependencies:
+ ws: 8.18.2
zod: 3.25.62
- transitivePeerDependencies:
- - encoding
- optional: true
@@ -9418,7 +9506,7 @@ snapshots:
dependencies:
'@types/chai': 5.2.2
'@vitest/expect': 3.2.3
'@vitest/pretty-format': 3.2.3
'@vitest/runner': 3.2.3
'@vitest/snapshot': 3.2.3
@@ -9502,7 +9590,7 @@ snapshots:
dependencies:
'@types/chai': 5.2.2
'@vitest/expect': 3.2.3
'@vitest/pretty-format': 3.2.3
'@vitest/runner': 3.2.3
'@vitest/snapshot': 3.2.3
diff --git a/ts/docs/api/tools.md b/ts/docs/api/tools.md
index 4862f4e6c..bf3d943e5 100644
--- a/ts/docs/api/tools.md
+++ b/ts/docs/api/tools.md
@@ -196,7 +196,6 @@ type ToolkitsOnlyParams = {
cursor?: string; // Pagination cursor
limit?: number; // Limit the number of results
search?: never; // Cannot be used with important flag,
- strict?: boolean; // Remove non-required properties from input/output parameters
};
type ToolkitSearchOnlyParams = {
@@ -206,7 +205,6 @@ type ToolkitSearchOnlyParams = {
cursor?: string; // Pagination cursor
limit?: number; // Limit the number of results
search: string; // Search term
- strict?: boolean; // Remove non-required properties from input/output parameters
};
type ToolListParams = ToolsOnlyParams | ToolkitsOnlyParams | ToolkitSearchOnlyParams;
@@ -218,8 +216,6 @@ Note: The parameters are organized into three mutually exclusive combinations:
2. Using `toolkits` with optional `important` flag to fetch tools from specific toolkits
3. Using `search` with optional `toolkits` to search for tools by name/description
-The `strict` parameter is a special flag that can be used with any of the above combinations. When set to `true`, it removes all non-required properties from both input and output parameters of the tools. This is particularly useful when working with providers that have strict parameter requirements, such as VercelAISDK, OpenAI, [where all fields must be marked as required.](https://platform.openai.com/docs/guides/function-calling#strict-mode)
-
Examples:
```typescript
@@ -228,14 +224,6 @@ const specificTools = await composio.tools.get('default', {
tools: ['GITHUB_GET_REPO', 'GITHUB_LIST_ISSUES'],
});
-// Get all tools from specific toolkits with strict mode enabled
-const toolkitTools = await composio.tools.get('default', {
- toolkits: ['github', 'gitlab'],
- important: true,
- limit: 10,
- strict: true, // This will remove all non-required properties from tool parameters
-});
-
// Search for tools across all or specific toolkits
const searchResults = await composio.tools.get('default', {
search: 'repository',