@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/index.cjs +537 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +530 -3
- package/dist/index.js.map +1 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +132 -69
- package/dist/tools.js.map +1 -1
- package/package.json +2 -2
- package/src/tools.ts +142 -67
package/dist/tools.js
CHANGED
|
@@ -1,79 +1,100 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { VercelAIATPClient } from './client.js';
|
|
3
|
-
import {
|
|
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
|
|
17
|
+
const underlyingClient = client.getUnderlyingClient();
|
|
12
18
|
const vercelTools = {};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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:
|
|
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,
|
|
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,EACN,SAAS,EACT,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,GACvB,MAAM,6BAA6B,CAAC;AACrC,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,YAAY,GAAG;IACpB,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,sBAAsB,CAA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;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.
|
|
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.
|
|
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 {
|
|
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
|
|
16
|
-
|
|
28
|
+
const underlyingClient = client.getUnderlyingClient();
|
|
17
29
|
const vercelTools: Record<string, any> = {};
|
|
18
30
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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:
|
|
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',
|