@composio/openai-agents 0.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,78 @@
1
+ # @composio/openai-agents
2
+
3
+ The OpenAI Agents API provider for Composio SDK, providing seamless integration with OpenAI's Agents API and tools.
4
+
5
+ ## Features
6
+
7
+ - **OpenAI Agents Integration**: Seamless integration with OpenAI's Agents SDK
8
+ - **Tool Integration**: Easy integration of Composio tools with OpenAI Agents
9
+ - **Type Safety**: Full TypeScript support with proper type definitions
10
+ - **Strict Mode**: Support for strict mode tool parameter validation
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install @composio/openai-agents @openai/agents
16
+ # or
17
+ yarn add @composio/openai-agents @openai/agents
18
+ # or
19
+ pnpm add @composio/openai-agents @openai/agents
20
+ ```
21
+
22
+ ## Environment Variables
23
+
24
+ Required environment variables:
25
+
26
+ - `COMPOSIO_API_KEY`: Your Composio API key
27
+ - `OPENAI_API_KEY`: Your OpenAI API key
28
+
29
+ ## Example
30
+
31
+ ```typescript
32
+ import { OpenAIAgentsProvider } from '@composio/openai-agents';
33
+ import { Composio } from '@composio/core';
34
+ import { Agent, run } from '@openai/agents';
35
+
36
+ const composio = new Composio({
37
+ provider: new OpenAIAgentsProvider(),
38
+ });
39
+
40
+ // Fetch tools from Composio
41
+ const tools = await composio.tools.get('default', 'HACKERNEWS_GET_USER', {
42
+ beforeExecute: async (toolSlug, toolkitSlug, params) => {
43
+ console.log(`🔄 Executing tool ${toolSlug} from toolkit ${toolkitSlug}...`);
44
+ return params;
45
+ },
46
+ afterExecute: async (toolSlug, toolkitSlug, result) => {
47
+ console.log(`✅ Tool ${toolSlug} executed`);
48
+ return result;
49
+ },
50
+ });
51
+
52
+ // Create an agent with the tools
53
+ const agent = new Agent({
54
+ name: 'Hackernews assistant',
55
+ tools: tools,
56
+ });
57
+
58
+ // Run the agent with a query
59
+ const result = await run(agent, 'Tell me about the user `pg` in hackernews');
60
+ ```
61
+
62
+ ## Provider Configuration
63
+
64
+ The OpenAI Agents provider can be configured with various options:
65
+
66
+ ```typescript
67
+ const provider = new OpenAIAgentsProvider({
68
+ strict: true, // Enable strict mode for tool parameters
69
+ });
70
+ ```
71
+
72
+ ## Documentation
73
+
74
+ For more information about OpenAI Agents and how to use them, see:
75
+
76
+ - [OpenAI Strict Mode](https://openai.github.io/openai-agents-js/guides/tools/#options-reference)
77
+ - [OpenAI Agents SDK Documentation](https://openai.github.io/openai-agents-js/)
78
+ - [OpenAI Agents SDK GitHub](https://github.com/openai/openai-agents-js)
package/dist/index.cjs ADDED
@@ -0,0 +1,169 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ OpenAIAgentsProvider: () => OpenAIAgentsProvider
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+ var import_core = require("@composio/core");
27
+ var import_agents = require("@openai/agents");
28
+ var OpenAIAgentsProvider = class extends import_core.BaseAgenticProvider {
29
+ name = "openai-agents";
30
+ strict;
31
+ /**
32
+ * Creates a new instance of the OpenAIAgentsProvider.
33
+ *
34
+ * This provider enables integration with the @openai/agents package,
35
+ * allowing Composio tools to be used with OpenAI Agents.
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * // Initialize the OpenAIAgentsProvider
40
+ * const provider = new OpenAIAgentsProvider();
41
+ *
42
+ * // Use with Composio
43
+ * const composio = new Composio({
44
+ * apiKey: 'your-api-key',
45
+ * provider: new OpenAIAgentsProvider()
46
+ * });
47
+ *
48
+ * // Use the provider to wrap tools for @openai/agents
49
+ * const vercelTools = provider.wrapTools(composioTools, composio.tools.execute);
50
+ * ```
51
+ */
52
+ constructor(options) {
53
+ super();
54
+ this.strict = options?.strict ?? false;
55
+ }
56
+ /**
57
+ * Wraps a Composio tool in a OpenAI Agents tool format.
58
+ *
59
+ * This method transforms a Composio tool definition into the format
60
+ * expected by @openai/agents for function calling.
61
+ *
62
+ * @param {ComposioTool} composioTool - The Composio tool to wrap
63
+ * @param {ExecuteToolFn} executeTool - Function to execute the tool
64
+ * @returns {OpenAIAgentsTool} The wrapped OpenAI Agents tool
65
+ *
66
+ * @example
67
+ * ```typescript
68
+ * // Wrap a single tool for use with Vercel AI SDK
69
+ * const composioTool = {
70
+ * slug: 'SEARCH_TOOL',
71
+ * description: 'Search for information',
72
+ * inputParameters: {
73
+ * type: 'object',
74
+ * properties: {
75
+ * query: { type: 'string' }
76
+ * },
77
+ * required: ['query']
78
+ * }
79
+ * };
80
+ *
81
+ * // Create a Vercel tool using the provider
82
+ * const vercelTool = provider.wrapTool(
83
+ * composioTool,
84
+ * composio.tools.execute
85
+ * );
86
+ *
87
+ * // Use with Vercel AI SDK
88
+ * import { StreamingTextResponse, Message } from 'ai';
89
+ * import { OpenAI } from 'openai';
90
+ *
91
+ * export async function POST(req: Request) {
92
+ * const { messages } = await req.json();
93
+ * const openai = new OpenAI();
94
+ *
95
+ * const response = await openai.chat.completions.create({
96
+ * model: 'gpt-4',
97
+ * messages,
98
+ * tools: [vercelTool]
99
+ * });
100
+ *
101
+ * return new StreamingTextResponse(response.choices[0].message);
102
+ * }
103
+ * ```
104
+ */
105
+ wrapTool(composioTool, executeTool) {
106
+ return (0, import_agents.tool)({
107
+ name: composioTool.slug,
108
+ description: composioTool.description ?? "",
109
+ parameters: (0, import_core.jsonSchemaToZodSchema)(
110
+ composioTool.inputParameters ?? {},
111
+ {
112
+ strict: this.strict ? true : false
113
+ }
114
+ ),
115
+ execute: async (params) => {
116
+ const input = typeof params === "string" ? JSON.parse(params) : params;
117
+ return await executeTool(composioTool.slug, input);
118
+ }
119
+ });
120
+ }
121
+ /**
122
+ * Wraps a list of Composio tools as a OpenAI Agents tool collection.
123
+ *
124
+ * This method transforms multiple Composio tool definitions into the format
125
+ * expected by OpenAI Agents for function calling, organizing them
126
+ * into a dictionary keyed by tool slug.
127
+ *
128
+ * @param {ComposioTool[]} tools - Array of Composio tools to wrap
129
+ * @param {ExecuteToolFn} executeTool - Function to execute the tools
130
+ * @returns {OpenAIAgentsToolCollection} Dictionary of wrapped tools in OpenAI Agents format
131
+ *
132
+ * @example
133
+ * ```typescript
134
+ * // Get OpenAI Agents tools from Composio
135
+ * const composio = new Composio({
136
+ * apiKey: 'your-api-key',
137
+ * provider: new OpenAIAgentsProvider()
138
+ * });
139
+ *
140
+ * const tools = await composio.tools.get('default', {
141
+ * toolkits: ['github'],
142
+ * });
143
+ *
144
+ * import { OpenAI } from '@openai/agents';
145
+ *
146
+ * export async function POST(req: Request) {
147
+ * const { messages } = await req.json();
148
+ * const openai = new OpenAI();
149
+ *
150
+ * const response = await openai.chat.completions.create({
151
+ * model: 'gpt-4',
152
+ * messages,
153
+ * tools: openaiAgentsTools
154
+ * });
155
+ *
156
+ * return new StreamingTextResponse(response.choices[0].message);
157
+ * }
158
+ * ```
159
+ */
160
+ wrapTools(tools, executeTool) {
161
+ return tools.map((tool) => {
162
+ return this.wrapTool(tool, executeTool);
163
+ });
164
+ }
165
+ };
166
+ // Annotate the CommonJS export names for ESM import in node:
167
+ 0 && (module.exports = {
168
+ OpenAIAgentsProvider
169
+ });
@@ -0,0 +1,137 @@
1
+ import { BaseAgenticProvider, Tool as Tool$1, ExecuteToolFn } from '@composio/core';
2
+ import { Tool } from '@openai/agents';
3
+
4
+ /**
5
+ * OpenAI Agents Provider
6
+ * To be used with the @openai/agents package
7
+ *
8
+ * Author: Musthaq Ahamad <musthaq@composio.dev>
9
+ * Reference: https://openai.github.io/openai-agents-js/
10
+ *
11
+ * This provider provides a set of tools for interacting with Vercel AI SDK.
12
+ *
13
+ * @packageDocumentation
14
+ * @module providers/openai-agents
15
+ */
16
+
17
+ type OpenAIAgentsToolCollection = Array<Tool>;
18
+ declare class OpenAIAgentsProvider extends BaseAgenticProvider<OpenAIAgentsToolCollection, Tool> {
19
+ readonly name = "openai-agents";
20
+ private strict;
21
+ /**
22
+ * Creates a new instance of the OpenAIAgentsProvider.
23
+ *
24
+ * This provider enables integration with the @openai/agents package,
25
+ * allowing Composio tools to be used with OpenAI Agents.
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * // Initialize the OpenAIAgentsProvider
30
+ * const provider = new OpenAIAgentsProvider();
31
+ *
32
+ * // Use with Composio
33
+ * const composio = new Composio({
34
+ * apiKey: 'your-api-key',
35
+ * provider: new OpenAIAgentsProvider()
36
+ * });
37
+ *
38
+ * // Use the provider to wrap tools for @openai/agents
39
+ * const vercelTools = provider.wrapTools(composioTools, composio.tools.execute);
40
+ * ```
41
+ */
42
+ constructor(options?: {
43
+ strict?: boolean;
44
+ });
45
+ /**
46
+ * Wraps a Composio tool in a OpenAI Agents tool format.
47
+ *
48
+ * This method transforms a Composio tool definition into the format
49
+ * expected by @openai/agents for function calling.
50
+ *
51
+ * @param {ComposioTool} composioTool - The Composio tool to wrap
52
+ * @param {ExecuteToolFn} executeTool - Function to execute the tool
53
+ * @returns {OpenAIAgentsTool} The wrapped OpenAI Agents tool
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * // Wrap a single tool for use with Vercel AI SDK
58
+ * const composioTool = {
59
+ * slug: 'SEARCH_TOOL',
60
+ * description: 'Search for information',
61
+ * inputParameters: {
62
+ * type: 'object',
63
+ * properties: {
64
+ * query: { type: 'string' }
65
+ * },
66
+ * required: ['query']
67
+ * }
68
+ * };
69
+ *
70
+ * // Create a Vercel tool using the provider
71
+ * const vercelTool = provider.wrapTool(
72
+ * composioTool,
73
+ * composio.tools.execute
74
+ * );
75
+ *
76
+ * // Use with Vercel AI SDK
77
+ * import { StreamingTextResponse, Message } from 'ai';
78
+ * import { OpenAI } from 'openai';
79
+ *
80
+ * export async function POST(req: Request) {
81
+ * const { messages } = await req.json();
82
+ * const openai = new OpenAI();
83
+ *
84
+ * const response = await openai.chat.completions.create({
85
+ * model: 'gpt-4',
86
+ * messages,
87
+ * tools: [vercelTool]
88
+ * });
89
+ *
90
+ * return new StreamingTextResponse(response.choices[0].message);
91
+ * }
92
+ * ```
93
+ */
94
+ wrapTool(composioTool: Tool$1, executeTool: ExecuteToolFn): Tool;
95
+ /**
96
+ * Wraps a list of Composio tools as a OpenAI Agents tool collection.
97
+ *
98
+ * This method transforms multiple Composio tool definitions into the format
99
+ * expected by OpenAI Agents for function calling, organizing them
100
+ * into a dictionary keyed by tool slug.
101
+ *
102
+ * @param {ComposioTool[]} tools - Array of Composio tools to wrap
103
+ * @param {ExecuteToolFn} executeTool - Function to execute the tools
104
+ * @returns {OpenAIAgentsToolCollection} Dictionary of wrapped tools in OpenAI Agents format
105
+ *
106
+ * @example
107
+ * ```typescript
108
+ * // Get OpenAI Agents tools from Composio
109
+ * const composio = new Composio({
110
+ * apiKey: 'your-api-key',
111
+ * provider: new OpenAIAgentsProvider()
112
+ * });
113
+ *
114
+ * const tools = await composio.tools.get('default', {
115
+ * toolkits: ['github'],
116
+ * });
117
+ *
118
+ * import { OpenAI } from '@openai/agents';
119
+ *
120
+ * export async function POST(req: Request) {
121
+ * const { messages } = await req.json();
122
+ * const openai = new OpenAI();
123
+ *
124
+ * const response = await openai.chat.completions.create({
125
+ * model: 'gpt-4',
126
+ * messages,
127
+ * tools: openaiAgentsTools
128
+ * });
129
+ *
130
+ * return new StreamingTextResponse(response.choices[0].message);
131
+ * }
132
+ * ```
133
+ */
134
+ wrapTools(tools: Tool$1[], executeTool: ExecuteToolFn): OpenAIAgentsToolCollection;
135
+ }
136
+
137
+ export { OpenAIAgentsProvider };
@@ -0,0 +1,137 @@
1
+ import { BaseAgenticProvider, Tool as Tool$1, ExecuteToolFn } from '@composio/core';
2
+ import { Tool } from '@openai/agents';
3
+
4
+ /**
5
+ * OpenAI Agents Provider
6
+ * To be used with the @openai/agents package
7
+ *
8
+ * Author: Musthaq Ahamad <musthaq@composio.dev>
9
+ * Reference: https://openai.github.io/openai-agents-js/
10
+ *
11
+ * This provider provides a set of tools for interacting with Vercel AI SDK.
12
+ *
13
+ * @packageDocumentation
14
+ * @module providers/openai-agents
15
+ */
16
+
17
+ type OpenAIAgentsToolCollection = Array<Tool>;
18
+ declare class OpenAIAgentsProvider extends BaseAgenticProvider<OpenAIAgentsToolCollection, Tool> {
19
+ readonly name = "openai-agents";
20
+ private strict;
21
+ /**
22
+ * Creates a new instance of the OpenAIAgentsProvider.
23
+ *
24
+ * This provider enables integration with the @openai/agents package,
25
+ * allowing Composio tools to be used with OpenAI Agents.
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * // Initialize the OpenAIAgentsProvider
30
+ * const provider = new OpenAIAgentsProvider();
31
+ *
32
+ * // Use with Composio
33
+ * const composio = new Composio({
34
+ * apiKey: 'your-api-key',
35
+ * provider: new OpenAIAgentsProvider()
36
+ * });
37
+ *
38
+ * // Use the provider to wrap tools for @openai/agents
39
+ * const vercelTools = provider.wrapTools(composioTools, composio.tools.execute);
40
+ * ```
41
+ */
42
+ constructor(options?: {
43
+ strict?: boolean;
44
+ });
45
+ /**
46
+ * Wraps a Composio tool in a OpenAI Agents tool format.
47
+ *
48
+ * This method transforms a Composio tool definition into the format
49
+ * expected by @openai/agents for function calling.
50
+ *
51
+ * @param {ComposioTool} composioTool - The Composio tool to wrap
52
+ * @param {ExecuteToolFn} executeTool - Function to execute the tool
53
+ * @returns {OpenAIAgentsTool} The wrapped OpenAI Agents tool
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * // Wrap a single tool for use with Vercel AI SDK
58
+ * const composioTool = {
59
+ * slug: 'SEARCH_TOOL',
60
+ * description: 'Search for information',
61
+ * inputParameters: {
62
+ * type: 'object',
63
+ * properties: {
64
+ * query: { type: 'string' }
65
+ * },
66
+ * required: ['query']
67
+ * }
68
+ * };
69
+ *
70
+ * // Create a Vercel tool using the provider
71
+ * const vercelTool = provider.wrapTool(
72
+ * composioTool,
73
+ * composio.tools.execute
74
+ * );
75
+ *
76
+ * // Use with Vercel AI SDK
77
+ * import { StreamingTextResponse, Message } from 'ai';
78
+ * import { OpenAI } from 'openai';
79
+ *
80
+ * export async function POST(req: Request) {
81
+ * const { messages } = await req.json();
82
+ * const openai = new OpenAI();
83
+ *
84
+ * const response = await openai.chat.completions.create({
85
+ * model: 'gpt-4',
86
+ * messages,
87
+ * tools: [vercelTool]
88
+ * });
89
+ *
90
+ * return new StreamingTextResponse(response.choices[0].message);
91
+ * }
92
+ * ```
93
+ */
94
+ wrapTool(composioTool: Tool$1, executeTool: ExecuteToolFn): Tool;
95
+ /**
96
+ * Wraps a list of Composio tools as a OpenAI Agents tool collection.
97
+ *
98
+ * This method transforms multiple Composio tool definitions into the format
99
+ * expected by OpenAI Agents for function calling, organizing them
100
+ * into a dictionary keyed by tool slug.
101
+ *
102
+ * @param {ComposioTool[]} tools - Array of Composio tools to wrap
103
+ * @param {ExecuteToolFn} executeTool - Function to execute the tools
104
+ * @returns {OpenAIAgentsToolCollection} Dictionary of wrapped tools in OpenAI Agents format
105
+ *
106
+ * @example
107
+ * ```typescript
108
+ * // Get OpenAI Agents tools from Composio
109
+ * const composio = new Composio({
110
+ * apiKey: 'your-api-key',
111
+ * provider: new OpenAIAgentsProvider()
112
+ * });
113
+ *
114
+ * const tools = await composio.tools.get('default', {
115
+ * toolkits: ['github'],
116
+ * });
117
+ *
118
+ * import { OpenAI } from '@openai/agents';
119
+ *
120
+ * export async function POST(req: Request) {
121
+ * const { messages } = await req.json();
122
+ * const openai = new OpenAI();
123
+ *
124
+ * const response = await openai.chat.completions.create({
125
+ * model: 'gpt-4',
126
+ * messages,
127
+ * tools: openaiAgentsTools
128
+ * });
129
+ *
130
+ * return new StreamingTextResponse(response.choices[0].message);
131
+ * }
132
+ * ```
133
+ */
134
+ wrapTools(tools: Tool$1[], executeTool: ExecuteToolFn): OpenAIAgentsToolCollection;
135
+ }
136
+
137
+ export { OpenAIAgentsProvider };
package/dist/index.js ADDED
@@ -0,0 +1,147 @@
1
+ // src/index.ts
2
+ import {
3
+ BaseAgenticProvider,
4
+ jsonSchemaToZodSchema
5
+ } from "@composio/core";
6
+ import { tool as createOpenAIAgentTool } from "@openai/agents";
7
+ var OpenAIAgentsProvider = class extends BaseAgenticProvider {
8
+ name = "openai-agents";
9
+ strict;
10
+ /**
11
+ * Creates a new instance of the OpenAIAgentsProvider.
12
+ *
13
+ * This provider enables integration with the @openai/agents package,
14
+ * allowing Composio tools to be used with OpenAI Agents.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * // Initialize the OpenAIAgentsProvider
19
+ * const provider = new OpenAIAgentsProvider();
20
+ *
21
+ * // Use with Composio
22
+ * const composio = new Composio({
23
+ * apiKey: 'your-api-key',
24
+ * provider: new OpenAIAgentsProvider()
25
+ * });
26
+ *
27
+ * // Use the provider to wrap tools for @openai/agents
28
+ * const vercelTools = provider.wrapTools(composioTools, composio.tools.execute);
29
+ * ```
30
+ */
31
+ constructor(options) {
32
+ super();
33
+ this.strict = options?.strict ?? false;
34
+ }
35
+ /**
36
+ * Wraps a Composio tool in a OpenAI Agents tool format.
37
+ *
38
+ * This method transforms a Composio tool definition into the format
39
+ * expected by @openai/agents for function calling.
40
+ *
41
+ * @param {ComposioTool} composioTool - The Composio tool to wrap
42
+ * @param {ExecuteToolFn} executeTool - Function to execute the tool
43
+ * @returns {OpenAIAgentsTool} The wrapped OpenAI Agents tool
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * // Wrap a single tool for use with Vercel AI SDK
48
+ * const composioTool = {
49
+ * slug: 'SEARCH_TOOL',
50
+ * description: 'Search for information',
51
+ * inputParameters: {
52
+ * type: 'object',
53
+ * properties: {
54
+ * query: { type: 'string' }
55
+ * },
56
+ * required: ['query']
57
+ * }
58
+ * };
59
+ *
60
+ * // Create a Vercel tool using the provider
61
+ * const vercelTool = provider.wrapTool(
62
+ * composioTool,
63
+ * composio.tools.execute
64
+ * );
65
+ *
66
+ * // Use with Vercel AI SDK
67
+ * import { StreamingTextResponse, Message } from 'ai';
68
+ * import { OpenAI } from 'openai';
69
+ *
70
+ * export async function POST(req: Request) {
71
+ * const { messages } = await req.json();
72
+ * const openai = new OpenAI();
73
+ *
74
+ * const response = await openai.chat.completions.create({
75
+ * model: 'gpt-4',
76
+ * messages,
77
+ * tools: [vercelTool]
78
+ * });
79
+ *
80
+ * return new StreamingTextResponse(response.choices[0].message);
81
+ * }
82
+ * ```
83
+ */
84
+ wrapTool(composioTool, executeTool) {
85
+ return createOpenAIAgentTool({
86
+ name: composioTool.slug,
87
+ description: composioTool.description ?? "",
88
+ parameters: jsonSchemaToZodSchema(
89
+ composioTool.inputParameters ?? {},
90
+ {
91
+ strict: this.strict ? true : false
92
+ }
93
+ ),
94
+ execute: async (params) => {
95
+ const input = typeof params === "string" ? JSON.parse(params) : params;
96
+ return await executeTool(composioTool.slug, input);
97
+ }
98
+ });
99
+ }
100
+ /**
101
+ * Wraps a list of Composio tools as a OpenAI Agents tool collection.
102
+ *
103
+ * This method transforms multiple Composio tool definitions into the format
104
+ * expected by OpenAI Agents for function calling, organizing them
105
+ * into a dictionary keyed by tool slug.
106
+ *
107
+ * @param {ComposioTool[]} tools - Array of Composio tools to wrap
108
+ * @param {ExecuteToolFn} executeTool - Function to execute the tools
109
+ * @returns {OpenAIAgentsToolCollection} Dictionary of wrapped tools in OpenAI Agents format
110
+ *
111
+ * @example
112
+ * ```typescript
113
+ * // Get OpenAI Agents tools from Composio
114
+ * const composio = new Composio({
115
+ * apiKey: 'your-api-key',
116
+ * provider: new OpenAIAgentsProvider()
117
+ * });
118
+ *
119
+ * const tools = await composio.tools.get('default', {
120
+ * toolkits: ['github'],
121
+ * });
122
+ *
123
+ * import { OpenAI } from '@openai/agents';
124
+ *
125
+ * export async function POST(req: Request) {
126
+ * const { messages } = await req.json();
127
+ * const openai = new OpenAI();
128
+ *
129
+ * const response = await openai.chat.completions.create({
130
+ * model: 'gpt-4',
131
+ * messages,
132
+ * tools: openaiAgentsTools
133
+ * });
134
+ *
135
+ * return new StreamingTextResponse(response.choices[0].message);
136
+ * }
137
+ * ```
138
+ */
139
+ wrapTools(tools, executeTool) {
140
+ return tools.map((tool) => {
141
+ return this.wrapTool(tool, executeTool);
142
+ });
143
+ }
144
+ };
145
+ export {
146
+ OpenAIAgentsProvider
147
+ };
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@composio/openai-agents",
3
+ "version": "0.1.22",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "type": "module",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "exports": {
11
+ ".": {
12
+ "import": "./dist/index.js",
13
+ "types": "./dist/index.d.ts",
14
+ "require": "./dist/index.cjs"
15
+ }
16
+ },
17
+ "files": [
18
+ "README.md",
19
+ "dist"
20
+ ],
21
+ "keywords": [],
22
+ "author": "",
23
+ "license": "ISC",
24
+ "peerDependencies": {
25
+ "@composio/core": "0.1.22",
26
+ "@openai/agents": "^0.0.7"
27
+ },
28
+ "devDependencies": {
29
+ "tsup": "^8.4.0",
30
+ "typescript": "^5.8.3",
31
+ "vitest": "^3.1.4",
32
+ "@composio/core": "0.1.22"
33
+ },
34
+ "gitHead": "4fae6e54d5c150fba955cc5fa314281da5a1e064",
35
+ "scripts": {
36
+ "build": "tsup",
37
+ "test": "vitest run"
38
+ },
39
+ "types": "dist/index.d.ts"
40
+ }