@composio/vercel 0.9.2 → 0.10.0
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/dist/index.d.mts +0 -1
- package/dist/index.mjs +4 -5
- package/package.json +20 -20
- package/dist/index.cjs +0 -192
- package/dist/index.d.cts +0 -161
package/dist/index.d.mts
CHANGED
|
@@ -2,7 +2,6 @@ import { BaseAgenticProvider, ExecuteToolFn, McpServerGetResponse, McpUrlRespons
|
|
|
2
2
|
import { Tool as Tool$1, ToolSet } from "ai";
|
|
3
3
|
|
|
4
4
|
//#region src/index.d.ts
|
|
5
|
-
|
|
6
5
|
type VercelToolCollection = ToolSet;
|
|
7
6
|
declare class VercelProvider extends BaseAgenticProvider<VercelToolCollection, Tool$1, McpServerGetResponse> {
|
|
8
7
|
readonly name = "vercel";
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseAgenticProvider, jsonSchemaToZodSchema, removeNonRequiredProperties } from "@composio/core";
|
|
1
|
+
import { BaseAgenticProvider, jsonSchemaToZodSchema, normalizeToolArguments, removeNonRequiredProperties } from "@composio/core";
|
|
2
2
|
import { tool } from "ai";
|
|
3
3
|
|
|
4
4
|
//#region src/index.ts
|
|
@@ -98,8 +98,7 @@ var VercelProvider = class extends BaseAgenticProvider {
|
|
|
98
98
|
description: composioTool.description,
|
|
99
99
|
inputSchema: inputParametersSchema,
|
|
100
100
|
execute: async (params) => {
|
|
101
|
-
|
|
102
|
-
return await executeTool(composioTool.slug, input);
|
|
101
|
+
return await executeTool(composioTool.slug, normalizeToolArguments(params, composioTool.slug));
|
|
103
102
|
}
|
|
104
103
|
});
|
|
105
104
|
}
|
|
@@ -167,8 +166,8 @@ var VercelProvider = class extends BaseAgenticProvider {
|
|
|
167
166
|
* ```
|
|
168
167
|
*/
|
|
169
168
|
wrapTools(tools, executeTool) {
|
|
170
|
-
return tools.reduce((acc, tool
|
|
171
|
-
acc[tool
|
|
169
|
+
return tools.reduce((acc, tool) => {
|
|
170
|
+
acc[tool.slug] = this.wrapTool(tool, executeTool);
|
|
172
171
|
return acc;
|
|
173
172
|
}, {});
|
|
174
173
|
}
|
package/package.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@composio/vercel",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.mjs",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/ComposioHQ/composio.git",
|
|
10
|
+
"directory": "ts/packages/providers/vercel"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/ComposioHQ/composio/issues"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/ComposioHQ/composio/tree/main/ts/packages/providers/vercel#readme",
|
|
6
16
|
"publishConfig": {
|
|
7
17
|
"access": "public"
|
|
8
18
|
},
|
|
9
19
|
"exports": {
|
|
10
20
|
".": {
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
"default": "./dist/index.mjs"
|
|
14
|
-
},
|
|
15
|
-
"require": {
|
|
16
|
-
"types": "./dist/index.d.cts",
|
|
17
|
-
"default": "./dist/index.cjs"
|
|
18
|
-
},
|
|
19
|
-
"default": {
|
|
20
|
-
"types": "./dist/index.d.cts",
|
|
21
|
-
"default": "./dist/index.cjs"
|
|
22
|
-
}
|
|
21
|
+
"types": "./dist/index.d.mts",
|
|
22
|
+
"default": "./dist/index.mjs"
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
@@ -34,17 +34,17 @@
|
|
|
34
34
|
"ai": "^5.0.0 || ^6.0.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"ai": "^6.0.
|
|
38
|
-
"tsdown": "^0.
|
|
39
|
-
"typescript": "^
|
|
40
|
-
"vitest": "^
|
|
41
|
-
"zod": "^4.
|
|
42
|
-
"@composio/core": "0.
|
|
37
|
+
"ai": "^6.0.206",
|
|
38
|
+
"tsdown": "^0.22.3",
|
|
39
|
+
"typescript": "^6.0.3",
|
|
40
|
+
"vitest": "^4.1.9",
|
|
41
|
+
"zod": "^4.4.3",
|
|
42
|
+
"@composio/core": "0.12.0"
|
|
43
43
|
},
|
|
44
44
|
"gitHead": "4fae6e54d5c150fba955cc5fa314281da5a1e064",
|
|
45
45
|
"scripts": {
|
|
46
46
|
"clean": "git clean -xdf node_modules",
|
|
47
|
-
"build": "
|
|
47
|
+
"build": "tsdown",
|
|
48
48
|
"test": "vitest run"
|
|
49
49
|
},
|
|
50
50
|
"types": "dist/index.d.mts"
|
package/dist/index.cjs
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
let _composio_core = require("@composio/core");
|
|
2
|
-
let ai = require("ai");
|
|
3
|
-
|
|
4
|
-
//#region src/index.ts
|
|
5
|
-
/**
|
|
6
|
-
* Vercel AI Provider
|
|
7
|
-
* To be used with the Vercel AI SDK
|
|
8
|
-
*
|
|
9
|
-
* Author: Musthaq Ahamad <musthaq@composio.dev>
|
|
10
|
-
* Legacy Reference: https://github.com/ComposioHQ/composio/blob/master/js/src/frameworks/vercel.ts
|
|
11
|
-
*
|
|
12
|
-
* This provider provides a set of tools for interacting with Vercel AI SDK.
|
|
13
|
-
*
|
|
14
|
-
* @packageDocumentation
|
|
15
|
-
* @module providers/vercel
|
|
16
|
-
*/
|
|
17
|
-
var VercelProvider = class extends _composio_core.BaseAgenticProvider {
|
|
18
|
-
name = "vercel";
|
|
19
|
-
strict;
|
|
20
|
-
/**
|
|
21
|
-
* Creates a new instance of the VercelProvider.
|
|
22
|
-
*
|
|
23
|
-
* This provider enables integration with the Vercel AI SDK,
|
|
24
|
-
* allowing Composio tools to be used with Vercel AI applications.
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```typescript
|
|
28
|
-
* // Initialize the Vercel provider
|
|
29
|
-
* const provider = new VercelProvider();
|
|
30
|
-
*
|
|
31
|
-
* // Use with Composio
|
|
32
|
-
* const composio = new Composio({
|
|
33
|
-
* apiKey: 'your-api-key',
|
|
34
|
-
* provider: new VercelProvider()
|
|
35
|
-
* });
|
|
36
|
-
*
|
|
37
|
-
* // Use the provider to wrap tools for Vercel AI SDK
|
|
38
|
-
* const vercelTools = provider.wrapTools(composioTools, composio.tools.execute);
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
constructor({ strict = false } = {}) {
|
|
42
|
-
super();
|
|
43
|
-
this.strict = strict;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Wraps a Composio tool in a Vercel AI SDK tool format.
|
|
47
|
-
*
|
|
48
|
-
* This method transforms a Composio tool definition into the format
|
|
49
|
-
* expected by Vercel's AI SDK for function calling.
|
|
50
|
-
*
|
|
51
|
-
* @param {ComposioTool} composioTool - The Composio tool to wrap
|
|
52
|
-
* @param {ExecuteToolFn} executeTool - Function to execute the tool
|
|
53
|
-
* @returns {VercelTool} The wrapped Vercel 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, executeTool) {
|
|
95
|
-
const inputParams = composioTool.inputParameters;
|
|
96
|
-
const inputParametersSchema = (0, _composio_core.jsonSchemaToZodSchema)(this.strict && inputParams?.type === "object" ? (0, _composio_core.removeNonRequiredProperties)(inputParams) : inputParams ?? {});
|
|
97
|
-
return (0, ai.tool)({
|
|
98
|
-
description: composioTool.description,
|
|
99
|
-
inputSchema: inputParametersSchema,
|
|
100
|
-
execute: async (params) => {
|
|
101
|
-
const input = typeof params === "string" ? JSON.parse(params) : params;
|
|
102
|
-
return await executeTool(composioTool.slug, input);
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Wraps a list of Composio tools as a Vercel AI SDK tool collection.
|
|
108
|
-
*
|
|
109
|
-
* This method transforms multiple Composio tool definitions into the format
|
|
110
|
-
* expected by Vercel's AI SDK for function calling, organizing them
|
|
111
|
-
* into a dictionary keyed by tool slug.
|
|
112
|
-
*
|
|
113
|
-
* @param {ComposioTool[]} tools - Array of Composio tools to wrap
|
|
114
|
-
* @param {ExecuteToolFn} executeTool - Function to execute the tools
|
|
115
|
-
* @returns {VercelToolCollection} Dictionary of wrapped tools in Vercel AI SDK format
|
|
116
|
-
*
|
|
117
|
-
* @example
|
|
118
|
-
* ```typescript
|
|
119
|
-
* // Wrap multiple tools for use with Vercel AI SDK
|
|
120
|
-
* const composioTools = [
|
|
121
|
-
* {
|
|
122
|
-
* slug: 'SEARCH_TOOL',
|
|
123
|
-
* description: 'Search for information',
|
|
124
|
-
* inputParameters: {
|
|
125
|
-
* type: 'object',
|
|
126
|
-
* properties: {
|
|
127
|
-
* query: { type: 'string' }
|
|
128
|
-
* },
|
|
129
|
-
* required: ['query']
|
|
130
|
-
* }
|
|
131
|
-
* },
|
|
132
|
-
* {
|
|
133
|
-
* slug: 'WEATHER_TOOL',
|
|
134
|
-
* description: 'Get weather information',
|
|
135
|
-
* inputParameters: {
|
|
136
|
-
* type: 'object',
|
|
137
|
-
* properties: {
|
|
138
|
-
* location: { type: 'string' }
|
|
139
|
-
* },
|
|
140
|
-
* required: ['location']
|
|
141
|
-
* }
|
|
142
|
-
* }
|
|
143
|
-
* ];
|
|
144
|
-
*
|
|
145
|
-
* // Create Vercel tools using the provider
|
|
146
|
-
* const vercelTools = provider.wrapTools(
|
|
147
|
-
* composioTools,
|
|
148
|
-
* composio.tools.execute
|
|
149
|
-
* );
|
|
150
|
-
*
|
|
151
|
-
* // Use with Vercel AI SDK in a Next.js API route
|
|
152
|
-
* import { StreamingTextResponse } from 'ai';
|
|
153
|
-
* import { OpenAI } from 'openai';
|
|
154
|
-
*
|
|
155
|
-
* export async function POST(req: Request) {
|
|
156
|
-
* const { messages } = await req.json();
|
|
157
|
-
* const openai = new OpenAI();
|
|
158
|
-
*
|
|
159
|
-
* const response = await openai.chat.completions.create({
|
|
160
|
-
* model: 'gpt-4',
|
|
161
|
-
* messages,
|
|
162
|
-
* tools: Object.values(vercelTools)
|
|
163
|
-
* });
|
|
164
|
-
*
|
|
165
|
-
* return new StreamingTextResponse(response.choices[0].message);
|
|
166
|
-
* }
|
|
167
|
-
* ```
|
|
168
|
-
*/
|
|
169
|
-
wrapTools(tools, executeTool) {
|
|
170
|
-
return tools.reduce((acc, tool$1) => {
|
|
171
|
-
acc[tool$1.slug] = this.wrapTool(tool$1, executeTool);
|
|
172
|
-
return acc;
|
|
173
|
-
}, {});
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Transform MCP URL response into Anthropic-specific format.
|
|
177
|
-
* By default, Anthropic uses the standard format (same as default),
|
|
178
|
-
* but this method is here to show providers can customize if needed.
|
|
179
|
-
*
|
|
180
|
-
* @param data - The MCP URL response data
|
|
181
|
-
* @returns Standard MCP server response format
|
|
182
|
-
*/
|
|
183
|
-
wrapMcpServerResponse(data) {
|
|
184
|
-
return data.map((item) => ({
|
|
185
|
-
url: new URL(item.url),
|
|
186
|
-
name: item.name
|
|
187
|
-
}));
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
//#endregion
|
|
192
|
-
exports.VercelProvider = VercelProvider;
|
package/dist/index.d.cts
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { BaseAgenticProvider, ExecuteToolFn, McpServerGetResponse, McpUrlResponse, Tool } from "@composio/core";
|
|
2
|
-
import { Tool as Tool$1, ToolSet } from "ai";
|
|
3
|
-
|
|
4
|
-
//#region src/index.d.ts
|
|
5
|
-
|
|
6
|
-
type VercelToolCollection = ToolSet;
|
|
7
|
-
declare class VercelProvider extends BaseAgenticProvider<VercelToolCollection, Tool$1, McpServerGetResponse> {
|
|
8
|
-
readonly name = "vercel";
|
|
9
|
-
private strict;
|
|
10
|
-
/**
|
|
11
|
-
* Creates a new instance of the VercelProvider.
|
|
12
|
-
*
|
|
13
|
-
* This provider enables integration with the Vercel AI SDK,
|
|
14
|
-
* allowing Composio tools to be used with Vercel AI applications.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* // Initialize the Vercel provider
|
|
19
|
-
* const provider = new VercelProvider();
|
|
20
|
-
*
|
|
21
|
-
* // Use with Composio
|
|
22
|
-
* const composio = new Composio({
|
|
23
|
-
* apiKey: 'your-api-key',
|
|
24
|
-
* provider: new VercelProvider()
|
|
25
|
-
* });
|
|
26
|
-
*
|
|
27
|
-
* // Use the provider to wrap tools for Vercel AI SDK
|
|
28
|
-
* const vercelTools = provider.wrapTools(composioTools, composio.tools.execute);
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
constructor({
|
|
32
|
-
strict
|
|
33
|
-
}?: {
|
|
34
|
-
strict?: boolean;
|
|
35
|
-
});
|
|
36
|
-
/**
|
|
37
|
-
* Wraps a Composio tool in a Vercel AI SDK tool format.
|
|
38
|
-
*
|
|
39
|
-
* This method transforms a Composio tool definition into the format
|
|
40
|
-
* expected by Vercel's AI SDK for function calling.
|
|
41
|
-
*
|
|
42
|
-
* @param {ComposioTool} composioTool - The Composio tool to wrap
|
|
43
|
-
* @param {ExecuteToolFn} executeTool - Function to execute the tool
|
|
44
|
-
* @returns {VercelTool} The wrapped Vercel tool
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* ```typescript
|
|
48
|
-
* // Wrap a single tool for use with Vercel AI SDK
|
|
49
|
-
* const composioTool = {
|
|
50
|
-
* slug: 'SEARCH_TOOL',
|
|
51
|
-
* description: 'Search for information',
|
|
52
|
-
* inputParameters: {
|
|
53
|
-
* type: 'object',
|
|
54
|
-
* properties: {
|
|
55
|
-
* query: { type: 'string' }
|
|
56
|
-
* },
|
|
57
|
-
* required: ['query']
|
|
58
|
-
* }
|
|
59
|
-
* };
|
|
60
|
-
*
|
|
61
|
-
* // Create a Vercel tool using the provider
|
|
62
|
-
* const vercelTool = provider.wrapTool(
|
|
63
|
-
* composioTool,
|
|
64
|
-
* composio.tools.execute
|
|
65
|
-
* );
|
|
66
|
-
*
|
|
67
|
-
* // Use with Vercel AI SDK
|
|
68
|
-
* import { StreamingTextResponse, Message } from 'ai';
|
|
69
|
-
* import { OpenAI } from 'openai';
|
|
70
|
-
*
|
|
71
|
-
* export async function POST(req: Request) {
|
|
72
|
-
* const { messages } = await req.json();
|
|
73
|
-
* const openai = new OpenAI();
|
|
74
|
-
*
|
|
75
|
-
* const response = await openai.chat.completions.create({
|
|
76
|
-
* model: 'gpt-4',
|
|
77
|
-
* messages,
|
|
78
|
-
* tools: [vercelTool]
|
|
79
|
-
* });
|
|
80
|
-
*
|
|
81
|
-
* return new StreamingTextResponse(response.choices[0].message);
|
|
82
|
-
* }
|
|
83
|
-
* ```
|
|
84
|
-
*/
|
|
85
|
-
wrapTool(composioTool: Tool, executeTool: ExecuteToolFn): Tool$1;
|
|
86
|
-
/**
|
|
87
|
-
* Wraps a list of Composio tools as a Vercel AI SDK tool collection.
|
|
88
|
-
*
|
|
89
|
-
* This method transforms multiple Composio tool definitions into the format
|
|
90
|
-
* expected by Vercel's AI SDK for function calling, organizing them
|
|
91
|
-
* into a dictionary keyed by tool slug.
|
|
92
|
-
*
|
|
93
|
-
* @param {ComposioTool[]} tools - Array of Composio tools to wrap
|
|
94
|
-
* @param {ExecuteToolFn} executeTool - Function to execute the tools
|
|
95
|
-
* @returns {VercelToolCollection} Dictionary of wrapped tools in Vercel AI SDK format
|
|
96
|
-
*
|
|
97
|
-
* @example
|
|
98
|
-
* ```typescript
|
|
99
|
-
* // Wrap multiple tools for use with Vercel AI SDK
|
|
100
|
-
* const composioTools = [
|
|
101
|
-
* {
|
|
102
|
-
* slug: 'SEARCH_TOOL',
|
|
103
|
-
* description: 'Search for information',
|
|
104
|
-
* inputParameters: {
|
|
105
|
-
* type: 'object',
|
|
106
|
-
* properties: {
|
|
107
|
-
* query: { type: 'string' }
|
|
108
|
-
* },
|
|
109
|
-
* required: ['query']
|
|
110
|
-
* }
|
|
111
|
-
* },
|
|
112
|
-
* {
|
|
113
|
-
* slug: 'WEATHER_TOOL',
|
|
114
|
-
* description: 'Get weather information',
|
|
115
|
-
* inputParameters: {
|
|
116
|
-
* type: 'object',
|
|
117
|
-
* properties: {
|
|
118
|
-
* location: { type: 'string' }
|
|
119
|
-
* },
|
|
120
|
-
* required: ['location']
|
|
121
|
-
* }
|
|
122
|
-
* }
|
|
123
|
-
* ];
|
|
124
|
-
*
|
|
125
|
-
* // Create Vercel tools using the provider
|
|
126
|
-
* const vercelTools = provider.wrapTools(
|
|
127
|
-
* composioTools,
|
|
128
|
-
* composio.tools.execute
|
|
129
|
-
* );
|
|
130
|
-
*
|
|
131
|
-
* // Use with Vercel AI SDK in a Next.js API route
|
|
132
|
-
* import { StreamingTextResponse } from 'ai';
|
|
133
|
-
* import { OpenAI } from 'openai';
|
|
134
|
-
*
|
|
135
|
-
* export async function POST(req: Request) {
|
|
136
|
-
* const { messages } = await req.json();
|
|
137
|
-
* const openai = new OpenAI();
|
|
138
|
-
*
|
|
139
|
-
* const response = await openai.chat.completions.create({
|
|
140
|
-
* model: 'gpt-4',
|
|
141
|
-
* messages,
|
|
142
|
-
* tools: Object.values(vercelTools)
|
|
143
|
-
* });
|
|
144
|
-
*
|
|
145
|
-
* return new StreamingTextResponse(response.choices[0].message);
|
|
146
|
-
* }
|
|
147
|
-
* ```
|
|
148
|
-
*/
|
|
149
|
-
wrapTools(tools: Tool[], executeTool: ExecuteToolFn): VercelToolCollection;
|
|
150
|
-
/**
|
|
151
|
-
* Transform MCP URL response into Anthropic-specific format.
|
|
152
|
-
* By default, Anthropic uses the standard format (same as default),
|
|
153
|
-
* but this method is here to show providers can customize if needed.
|
|
154
|
-
*
|
|
155
|
-
* @param data - The MCP URL response data
|
|
156
|
-
* @returns Standard MCP server response format
|
|
157
|
-
*/
|
|
158
|
-
wrapMcpServerResponse(data: McpUrlResponse): McpServerGetResponse;
|
|
159
|
-
}
|
|
160
|
-
//#endregion
|
|
161
|
-
export { VercelProvider, VercelToolCollection };
|