@mondaydotcomorg/atp-vercel-sdk 0.20.2 → 0.20.4

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/tools.js CHANGED
@@ -1,79 +1,100 @@
1
1
  import { z } from 'zod';
2
2
  import { VercelAIATPClient } from './client.js';
3
- import { createToolsFromATPClient, ToolNames } from '@mondaydotcomorg/atp-client';
3
+ import { ToolNames, executeCodeInputSchema, exploreApiInputSchema, searchApiInputSchema, fetchAllApisInputSchema, } from '@mondaydotcomorg/atp-client';
4
4
  import { ExecutionStatus } from '@mondaydotcomorg/atp-protocol';
5
5
  import { tool } from 'ai';
6
6
  import { createVercelEventHandler } from './event-adapter.js';
7
+ const TOOL_SCHEMAS = {
8
+ [ToolNames.EXECUTE_CODE]: executeCodeInputSchema.pick({ code: true }),
9
+ [ToolNames.EXPLORE_API]: exploreApiInputSchema,
10
+ [ToolNames.SEARCH_API]: searchApiInputSchema,
11
+ [ToolNames.FETCH_ALL_APIS]: fetchAllApisInputSchema,
12
+ };
7
13
  export async function createATPTools(options) {
8
14
  const { defaultExecutionConfig, ...clientOptions } = options;
9
15
  const client = new VercelAIATPClient(clientOptions);
10
16
  await client.connect();
11
- const atpTools = createToolsFromATPClient(client.getUnderlyingClient());
17
+ const underlyingClient = client.getUnderlyingClient();
12
18
  const vercelTools = {};
13
- for (const atpTool of atpTools) {
14
- if (atpTool.name === ToolNames.EXECUTE_CODE) {
15
- vercelTools.atp_execute_code = tool({
16
- description: atpTool.description ||
17
- 'Execute TypeScript code in ATP sandbox with access to runtime APIs (atp.llm.*, atp.embedding.*, atp.approval.*)',
18
- parameters: z.object({
19
- code: z.string().describe('TypeScript code to execute in the ATP sandbox'),
20
- }),
21
- execute: async ({ code }) => {
22
- try {
23
- const result = await client.execute(code, defaultExecutionConfig);
24
- if (result.status === ExecutionStatus.COMPLETED) {
25
- return {
26
- success: true,
27
- result: result.result,
28
- stats: result.stats,
29
- };
30
- }
31
- else if (result.status === ExecutionStatus.FAILED) {
32
- return {
33
- success: false,
34
- error: result.error,
35
- stats: result.stats,
36
- };
37
- }
38
- else {
39
- return {
40
- success: false,
41
- error: 'Execution in unexpected state: ' + result.status,
42
- };
43
- }
44
- }
45
- catch (error) {
46
- return {
47
- success: false,
48
- error: error.message || 'Unknown error',
49
- };
50
- }
51
- },
52
- });
53
- }
54
- else {
55
- const toolName = `atp_${atpTool.name}`;
56
- vercelTools[toolName] = tool({
57
- description: atpTool.description || '',
58
- parameters: atpTool.zodSchema || z.object({}),
59
- execute: async (input) => {
60
- try {
61
- const result = await atpTool.func(input);
62
- return {
63
- success: true,
64
- result,
65
- };
66
- }
67
- catch (error) {
68
- return {
69
- success: false,
70
- error: error.message,
71
- };
72
- }
73
- },
74
- });
75
- }
76
- }
19
+ vercelTools.atp_execute_code = tool({
20
+ description: 'Execute TypeScript code in ATP sandbox with access to runtime APIs (atp.llm.*, atp.embedding.*, atp.approval.*)',
21
+ parameters: TOOL_SCHEMAS[ToolNames.EXECUTE_CODE],
22
+ execute: async ({ code }) => {
23
+ try {
24
+ const result = await client.execute(code, defaultExecutionConfig);
25
+ if (result.status === ExecutionStatus.COMPLETED) {
26
+ return {
27
+ success: true,
28
+ result: result.result,
29
+ stats: result.stats,
30
+ };
31
+ }
32
+ else if (result.status === ExecutionStatus.FAILED) {
33
+ return {
34
+ success: false,
35
+ error: result.error,
36
+ stats: result.stats,
37
+ };
38
+ }
39
+ else {
40
+ return {
41
+ success: false,
42
+ error: 'Execution in unexpected state: ' + result.status,
43
+ };
44
+ }
45
+ }
46
+ catch (error) {
47
+ return {
48
+ success: false,
49
+ error: error.message || 'Unknown error',
50
+ };
51
+ }
52
+ },
53
+ });
54
+ vercelTools.atp_explore_api = tool({
55
+ description: 'Explore APIs using filesystem-like navigation. Navigate through directories to discover available functions.',
56
+ parameters: TOOL_SCHEMAS[ToolNames.EXPLORE_API],
57
+ execute: async ({ path }) => {
58
+ try {
59
+ const result = await underlyingClient.exploreAPI(path);
60
+ return {
61
+ success: true,
62
+ result,
63
+ };
64
+ }
65
+ catch (error) {
66
+ return {
67
+ success: false,
68
+ error: error.message,
69
+ };
70
+ }
71
+ },
72
+ });
73
+ vercelTools.atp_search_api = tool({
74
+ description: 'Search for APIs by keyword. Provide search term as string like "add", "math", "user", etc.',
75
+ parameters: TOOL_SCHEMAS[ToolNames.SEARCH_API],
76
+ execute: async ({ query }) => {
77
+ try {
78
+ const results = await underlyingClient.searchAPI(query);
79
+ return {
80
+ success: true,
81
+ results: results.map((r) => ({
82
+ apiGroup: r.apiGroup,
83
+ functionName: r.functionName,
84
+ description: r.description,
85
+ signature: r.signature,
86
+ })),
87
+ count: results.length,
88
+ };
89
+ }
90
+ catch (error) {
91
+ return {
92
+ success: false,
93
+ error: error.message,
94
+ };
95
+ }
96
+ },
97
+ });
77
98
  vercelTools.atp_get_type_definitions = tool({
78
99
  description: 'Get TypeScript type definitions for ATP runtime APIs to understand available functions',
79
100
  parameters: z.object({}),
@@ -133,9 +154,7 @@ export async function createATPStreamingTools(options) {
133
154
  const vercelTools = {};
134
155
  vercelTools.atp_execute_code = tool({
135
156
  description: 'Execute TypeScript code in ATP sandbox with streaming events for thinking, tool execution, and text output',
136
- parameters: z.object({
137
- code: z.string().describe('TypeScript code to execute in the ATP sandbox'),
138
- }),
157
+ parameters: TOOL_SCHEMAS[ToolNames.EXECUTE_CODE],
139
158
  execute: async ({ code }) => {
140
159
  try {
141
160
  const result = await underlyingClient.executeStream(code, defaultExecutionConfig, eventHandler);
@@ -168,6 +187,50 @@ export async function createATPStreamingTools(options) {
168
187
  }
169
188
  },
170
189
  });
190
+ vercelTools.atp_explore_api = tool({
191
+ description: 'Explore APIs using filesystem-like navigation. Navigate through directories to discover available functions.',
192
+ parameters: TOOL_SCHEMAS[ToolNames.EXPLORE_API],
193
+ execute: async ({ path }) => {
194
+ try {
195
+ const result = await underlyingClient.exploreAPI(path);
196
+ return {
197
+ success: true,
198
+ result,
199
+ };
200
+ }
201
+ catch (error) {
202
+ return {
203
+ success: false,
204
+ error: error.message,
205
+ };
206
+ }
207
+ },
208
+ });
209
+ vercelTools.atp_search_api = tool({
210
+ description: 'Search for APIs by keyword. Provide search term as string like "add", "math", "user", etc.',
211
+ parameters: TOOL_SCHEMAS[ToolNames.SEARCH_API],
212
+ execute: async ({ query }) => {
213
+ try {
214
+ const results = await underlyingClient.searchAPI(query);
215
+ return {
216
+ success: true,
217
+ results: results.map((r) => ({
218
+ apiGroup: r.apiGroup,
219
+ functionName: r.functionName,
220
+ description: r.description,
221
+ signature: r.signature,
222
+ })),
223
+ count: results.length,
224
+ };
225
+ }
226
+ catch (error) {
227
+ return {
228
+ success: false,
229
+ error: error.message,
230
+ };
231
+ }
232
+ },
233
+ });
171
234
  vercelTools.atp_get_type_definitions = tool({
172
235
  description: 'Get TypeScript type definitions for ATP runtime APIs to understand available functions',
173
236
  parameters: z.object({}),
package/dist/tools.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,wBAAwB,EAA8B,MAAM,oBAAoB,CAAC;AAE1F,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAA8B;IAClE,MAAM,EAAE,sBAAsB,EAAE,GAAG,aAAa,EAAE,GAAG,OAAO,CAAC;IAE7D,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC,aAAa,CAAC,CAAC;IACpD,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;IAEvB,MAAM,QAAQ,G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BACrB,OAAO;oBACN,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,KAAK,CAAC,OAAO;iBACpB,CAAC;YACH,CAAC;QACF,CAAC;KACD,CAAC,CAAC;IAEH,WAAW,CAAC,wBAAwB,GAAG,IAAI,CAAC;QAC3C,WAAW,EACV,wFAAwF;QACzF,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;QACxB,OAAO,EAAE,KAAK,IAAI,EAAE;YACnB,IAAI,CAAC;gBACJ,MAAM,KAAK,GAAG,MAAM,CAAC,kBAAkB,EAAE,CAAC;gBAC1C,OAAO;oBACN,OAAO,EAAE,IAAI;oBACb,KAAK;iBACL,CAAC;YACH,CAAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBACrB,OAAO;oBACN,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,KAAK,CAAC,OAAO;iBACpB,CAAC;YACH,CAAC;QACF,CAAC;KACD,CAAC,CAAC;IAEH,OAAO;QACN,MAAM;QACN,KAAK,EAAE,WAAW;KAClB,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mondaydotcomorg/atp-vercel-sdk",
3
- "version": "0.20.2",
3
+ "version": "0.20.4",
4
4
  "description": "Vercel AI SDK integration for Agent Tool Protocol",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -44,7 +44,7 @@
44
44
  ],
45
45
  "license": "MIT",
46
46
  "dependencies": {
47
- "@mondaydotcomorg/atp-client": "0.19.15",
47
+ "@mondaydotcomorg/atp-client": "0.19.16",
48
48
  "@mondaydotcomorg/atp-protocol": "0.19.15"
49
49
  },
50
50
  "peerDependencies": {
package/src/tools.ts CHANGED
@@ -1,82 +1,113 @@
1
1
  import { z } from 'zod';
2
2
  import { VercelAIATPClient } from './client.js';
3
3
  import type { CreateATPToolsOptions, ATPToolsResult, StreamingToolsOptions } from './types.js';
4
- import { createToolsFromATPClient, ToolNames } from '@mondaydotcomorg/atp-client';
4
+ import {
5
+ ToolNames,
6
+ executeCodeInputSchema,
7
+ exploreApiInputSchema,
8
+ searchApiInputSchema,
9
+ fetchAllApisInputSchema,
10
+ } from '@mondaydotcomorg/atp-client';
5
11
  import { ExecutionStatus } from '@mondaydotcomorg/atp-protocol';
6
12
  import { tool } from 'ai';
7
13
  import { createVercelEventHandler, type UIMessageStreamWriter } from './event-adapter.js';
8
14
 
15
+ const TOOL_SCHEMAS = {
16
+ [ToolNames.EXECUTE_CODE]: executeCodeInputSchema.pick({ code: true }),
17
+ [ToolNames.EXPLORE_API]: exploreApiInputSchema,
18
+ [ToolNames.SEARCH_API]: searchApiInputSchema,
19
+ [ToolNames.FETCH_ALL_APIS]: fetchAllApisInputSchema,
20
+ } as const;
21
+
9
22
  export async function createATPTools(options: CreateATPToolsOptions): Promise<ATPToolsResult> {
10
23
  const { defaultExecutionConfig, ...clientOptions } = options;
11
24
 
12
25
  const client = new VercelAIATPClient(clientOptions);
13
26
  await client.connect();
14
27
 
15
- const atpTools = createToolsFromATPClient(client.getUnderlyingClient());
16
-
28
+ const underlyingClient = client.getUnderlyingClient();
17
29
  const vercelTools: Record<string, any> = {};
18
30
 
19
- for (const atpTool of atpTools) {
20
- if (atpTool.name === ToolNames.EXECUTE_CODE) {
21
- vercelTools.atp_execute_code = tool({
22
- description:
23
- atpTool.description ||
24
- 'Execute TypeScript code in ATP sandbox with access to runtime APIs (atp.llm.*, atp.embedding.*, atp.approval.*)',
25
- parameters: z.object({
26
- code: z.string().describe('TypeScript code to execute in the ATP sandbox'),
27
- }),
28
- execute: async ({ code }: { code: string }) => {
29
- try {
30
- const result = await client.execute(code, defaultExecutionConfig);
31
-
32
- if (result.status === ExecutionStatus.COMPLETED) {
33
- return {
34
- success: true,
35
- result: result.result,
36
- stats: result.stats,
37
- };
38
- } else if (result.status === ExecutionStatus.FAILED) {
39
- return {
40
- success: false,
41
- error: result.error,
42
- stats: result.stats,
43
- };
44
- } else {
45
- return {
46
- success: false,
47
- error: 'Execution in unexpected state: ' + result.status,
48
- };
49
- }
50
- } catch (error: any) {
51
- return {
52
- success: false,
53
- error: error.message || 'Unknown error',
54
- };
55
- }
56
- },
57
- });
58
- } else {
59
- const toolName = `atp_${atpTool.name}`;
60
- vercelTools[toolName] = tool({
61
- description: atpTool.description || '',
62
- parameters: atpTool.zodSchema || z.object({}),
63
- execute: async (input: any) => {
64
- try {
65
- const result = await atpTool.func(input);
66
- return {
67
- success: true,
68
- result,
69
- };
70
- } catch (error: any) {
71
- return {
72
- success: false,
73
- error: error.message,
74
- };
75
- }
76
- },
77
- });
78
- }
79
- }
31
+ vercelTools.atp_execute_code = tool({
32
+ description:
33
+ 'Execute TypeScript code in ATP sandbox with access to runtime APIs (atp.llm.*, atp.embedding.*, atp.approval.*)',
34
+ parameters: TOOL_SCHEMAS[ToolNames.EXECUTE_CODE],
35
+ execute: async ({ code }: { code: string }) => {
36
+ try {
37
+ const result = await client.execute(code, defaultExecutionConfig);
38
+
39
+ if (result.status === ExecutionStatus.COMPLETED) {
40
+ return {
41
+ success: true,
42
+ result: result.result,
43
+ stats: result.stats,
44
+ };
45
+ } else if (result.status === ExecutionStatus.FAILED) {
46
+ return {
47
+ success: false,
48
+ error: result.error,
49
+ stats: result.stats,
50
+ };
51
+ } else {
52
+ return {
53
+ success: false,
54
+ error: 'Execution in unexpected state: ' + result.status,
55
+ };
56
+ }
57
+ } catch (error: any) {
58
+ return {
59
+ success: false,
60
+ error: error.message || 'Unknown error',
61
+ };
62
+ }
63
+ },
64
+ });
65
+
66
+ vercelTools.atp_explore_api = tool({
67
+ description:
68
+ 'Explore APIs using filesystem-like navigation. Navigate through directories to discover available functions.',
69
+ parameters: TOOL_SCHEMAS[ToolNames.EXPLORE_API],
70
+ execute: async ({ path }: { path: string }) => {
71
+ try {
72
+ const result = await underlyingClient.exploreAPI(path);
73
+ return {
74
+ success: true,
75
+ result,
76
+ };
77
+ } catch (error: any) {
78
+ return {
79
+ success: false,
80
+ error: error.message,
81
+ };
82
+ }
83
+ },
84
+ });
85
+
86
+ vercelTools.atp_search_api = tool({
87
+ description:
88
+ 'Search for APIs by keyword. Provide search term as string like "add", "math", "user", etc.',
89
+ parameters: TOOL_SCHEMAS[ToolNames.SEARCH_API],
90
+ execute: async ({ query }: { query: string }) => {
91
+ try {
92
+ const results = await underlyingClient.searchAPI(query);
93
+ return {
94
+ success: true,
95
+ results: results.map((r: any) => ({
96
+ apiGroup: r.apiGroup,
97
+ functionName: r.functionName,
98
+ description: r.description,
99
+ signature: r.signature,
100
+ })),
101
+ count: results.length,
102
+ };
103
+ } catch (error: any) {
104
+ return {
105
+ success: false,
106
+ error: error.message,
107
+ };
108
+ }
109
+ },
110
+ });
80
111
 
81
112
  vercelTools.atp_get_type_definitions = tool({
82
113
  description:
@@ -146,9 +177,7 @@ export async function createATPStreamingTools(
146
177
  vercelTools.atp_execute_code = tool({
147
178
  description:
148
179
  'Execute TypeScript code in ATP sandbox with streaming events for thinking, tool execution, and text output',
149
- parameters: z.object({
150
- code: z.string().describe('TypeScript code to execute in the ATP sandbox'),
151
- }),
180
+ parameters: TOOL_SCHEMAS[ToolNames.EXECUTE_CODE],
152
181
  execute: async ({ code }: { code: string }) => {
153
182
  try {
154
183
  const result = await underlyingClient.executeStream(
@@ -184,6 +213,52 @@ export async function createATPStreamingTools(
184
213
  },
185
214
  });
186
215
 
216
+ vercelTools.atp_explore_api = tool({
217
+ description:
218
+ 'Explore APIs using filesystem-like navigation. Navigate through directories to discover available functions.',
219
+ parameters: TOOL_SCHEMAS[ToolNames.EXPLORE_API],
220
+ execute: async ({ path }: { path: string }) => {
221
+ try {
222
+ const result = await underlyingClient.exploreAPI(path);
223
+ return {
224
+ success: true,
225
+ result,
226
+ };
227
+ } catch (error: any) {
228
+ return {
229
+ success: false,
230
+ error: error.message,
231
+ };
232
+ }
233
+ },
234
+ });
235
+
236
+ vercelTools.atp_search_api = tool({
237
+ description:
238
+ 'Search for APIs by keyword. Provide search term as string like "add", "math", "user", etc.',
239
+ parameters: TOOL_SCHEMAS[ToolNames.SEARCH_API],
240
+ execute: async ({ query }: { query: string }) => {
241
+ try {
242
+ const results = await underlyingClient.searchAPI(query);
243
+ return {
244
+ success: true,
245
+ results: results.map((r: any) => ({
246
+ apiGroup: r.apiGroup,
247
+ functionName: r.functionName,
248
+ description: r.description,
249
+ signature: r.signature,
250
+ })),
251
+ count: results.length,
252
+ };
253
+ } catch (error: any) {
254
+ return {
255
+ success: false,
256
+ error: error.message,
257
+ };
258
+ }
259
+ },
260
+ });
261
+
187
262
  vercelTools.atp_get_type_definitions = tool({
188
263
  description:
189
264
  'Get TypeScript type definitions for ATP runtime APIs to understand available functions',