@agentuity/cli 0.0.69 → 0.0.70
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/AGENTS.md +1 -1
- package/README.md +1 -1
- package/dist/cmd/ai/capabilities/show.d.ts.map +1 -1
- package/dist/cmd/ai/capabilities/show.js +0 -13
- package/dist/cmd/ai/capabilities/show.js.map +1 -1
- package/dist/cmd/ai/prompt/agent.js +1 -1
- package/dist/cmd/ai/prompt/api.js +1 -1
- package/dist/cmd/build/ast.d.ts +1 -2
- package/dist/cmd/build/ast.d.ts.map +1 -1
- package/dist/cmd/build/ast.js +261 -260
- package/dist/cmd/build/ast.js.map +1 -1
- package/dist/cmd/build/bundler.d.ts +2 -1
- package/dist/cmd/build/bundler.d.ts.map +1 -1
- package/dist/cmd/build/bundler.js +11 -2
- package/dist/cmd/build/bundler.js.map +1 -1
- package/dist/cmd/build/index.js +1 -1
- package/dist/cmd/build/index.js.map +1 -1
- package/dist/cmd/build/plugin.d.ts.map +1 -1
- package/dist/cmd/build/plugin.js +152 -414
- package/dist/cmd/build/plugin.js.map +1 -1
- package/dist/cmd/build/route-registry.d.ts +36 -0
- package/dist/cmd/build/route-registry.d.ts.map +1 -0
- package/dist/cmd/build/route-registry.js +151 -0
- package/dist/cmd/build/route-registry.js.map +1 -0
- package/dist/cmd/cloud/deploy.d.ts.map +1 -1
- package/dist/cmd/cloud/deploy.js +1 -0
- package/dist/cmd/cloud/deploy.js.map +1 -1
- package/dist/cmd/cloud/index.d.ts.map +1 -1
- package/dist/cmd/cloud/index.js +0 -2
- package/dist/cmd/cloud/index.js.map +1 -1
- package/dist/cmd/dev/index.js +3 -3
- package/dist/cmd/dev/index.js.map +1 -1
- package/dist/cmd/dev/sync.d.ts.map +1 -1
- package/dist/cmd/dev/sync.js +0 -15
- package/dist/cmd/dev/sync.js.map +1 -1
- package/dist/cmd/dev/templates.d.ts.map +1 -1
- package/dist/cmd/dev/templates.js +11 -35
- package/dist/cmd/dev/templates.js.map +1 -1
- package/dist/cmd/profile/create.d.ts.map +1 -1
- package/dist/cmd/profile/create.js +0 -1
- package/dist/cmd/profile/create.js.map +1 -1
- package/dist/cmd/project/template-flow.d.ts.map +1 -1
- package/dist/cmd/project/template-flow.js +64 -53
- package/dist/cmd/project/template-flow.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +0 -3
- package/dist/config.js.map +1 -1
- package/dist/tui/box.d.ts +19 -0
- package/dist/tui/box.d.ts.map +1 -0
- package/dist/tui/box.js +160 -0
- package/dist/tui/box.js.map +1 -0
- package/dist/tui/colors.d.ts +20 -0
- package/dist/tui/colors.d.ts.map +1 -0
- package/dist/tui/colors.js +52 -0
- package/dist/tui/colors.js.map +1 -0
- package/dist/tui/group.d.ts +25 -0
- package/dist/tui/group.d.ts.map +1 -0
- package/dist/tui/group.js +32 -0
- package/dist/tui/group.js.map +1 -0
- package/dist/tui/prompt.d.ts +65 -0
- package/dist/tui/prompt.d.ts.map +1 -0
- package/dist/tui/prompt.js +377 -0
- package/dist/tui/prompt.js.map +1 -0
- package/dist/tui/symbols.d.ts +32 -0
- package/dist/tui/symbols.d.ts.map +1 -0
- package/dist/tui/symbols.js +52 -0
- package/dist/tui/symbols.js.map +1 -0
- package/dist/tui.d.ts +6 -0
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +6 -0
- package/dist/tui.js.map +1 -1
- package/dist/types.d.ts +0 -24
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -1
- package/dist/types.js.map +1 -1
- package/package.json +3 -3
- package/src/cmd/ai/capabilities/show.ts +0 -13
- package/src/cmd/ai/prompt/agent.ts +1 -1
- package/src/cmd/ai/prompt/api.ts +1 -1
- package/src/cmd/build/ast.ts +364 -334
- package/src/cmd/build/bundler.ts +16 -1
- package/src/cmd/build/index.ts +1 -1
- package/src/cmd/build/plugin.ts +171 -493
- package/src/cmd/build/route-registry.ts +198 -0
- package/src/cmd/cloud/deploy.ts +1 -0
- package/src/cmd/cloud/index.ts +0 -2
- package/src/cmd/dev/index.ts +3 -3
- package/src/cmd/dev/sync.ts +0 -28
- package/src/cmd/dev/templates.ts +11 -35
- package/src/cmd/profile/create.ts +0 -1
- package/src/cmd/project/template-flow.ts +77 -57
- package/src/config.ts +0 -3
- package/src/tui/box.ts +202 -0
- package/src/tui/colors.ts +55 -0
- package/src/tui/group.ts +56 -0
- package/src/tui/prompt.ts +506 -0
- package/src/tui/symbols.ts +64 -0
- package/src/tui.ts +14 -0
- package/src/types.ts +0 -1
- package/dist/cmd/cloud/objectstore/delete-bucket.d.ts +0 -3
- package/dist/cmd/cloud/objectstore/delete-bucket.d.ts.map +0 -1
- package/dist/cmd/cloud/objectstore/delete-bucket.js +0 -72
- package/dist/cmd/cloud/objectstore/delete-bucket.js.map +0 -1
- package/dist/cmd/cloud/objectstore/delete.d.ts +0 -3
- package/dist/cmd/cloud/objectstore/delete.d.ts.map +0 -1
- package/dist/cmd/cloud/objectstore/delete.js +0 -65
- package/dist/cmd/cloud/objectstore/delete.js.map +0 -1
- package/dist/cmd/cloud/objectstore/get.d.ts +0 -3
- package/dist/cmd/cloud/objectstore/get.d.ts.map +0 -1
- package/dist/cmd/cloud/objectstore/get.js +0 -75
- package/dist/cmd/cloud/objectstore/get.js.map +0 -1
- package/dist/cmd/cloud/objectstore/index.d.ts +0 -3
- package/dist/cmd/cloud/objectstore/index.d.ts.map +0 -1
- package/dist/cmd/cloud/objectstore/index.js +0 -36
- package/dist/cmd/cloud/objectstore/index.js.map +0 -1
- package/dist/cmd/cloud/objectstore/list-buckets.d.ts +0 -3
- package/dist/cmd/cloud/objectstore/list-buckets.d.ts.map +0 -1
- package/dist/cmd/cloud/objectstore/list-buckets.js +0 -46
- package/dist/cmd/cloud/objectstore/list-buckets.js.map +0 -1
- package/dist/cmd/cloud/objectstore/list-keys.d.ts +0 -3
- package/dist/cmd/cloud/objectstore/list-keys.d.ts.map +0 -1
- package/dist/cmd/cloud/objectstore/list-keys.js +0 -58
- package/dist/cmd/cloud/objectstore/list-keys.js.map +0 -1
- package/dist/cmd/cloud/objectstore/put.d.ts +0 -3
- package/dist/cmd/cloud/objectstore/put.d.ts.map +0 -1
- package/dist/cmd/cloud/objectstore/put.js +0 -66
- package/dist/cmd/cloud/objectstore/put.js.map +0 -1
- package/dist/cmd/cloud/objectstore/repl.d.ts +0 -3
- package/dist/cmd/cloud/objectstore/repl.d.ts.map +0 -1
- package/dist/cmd/cloud/objectstore/repl.js +0 -224
- package/dist/cmd/cloud/objectstore/repl.js.map +0 -1
- package/dist/cmd/cloud/objectstore/url.d.ts +0 -3
- package/dist/cmd/cloud/objectstore/url.d.ts.map +0 -1
- package/dist/cmd/cloud/objectstore/url.js +0 -64
- package/dist/cmd/cloud/objectstore/url.js.map +0 -1
- package/dist/cmd/cloud/objectstore/util.d.ts +0 -11
- package/dist/cmd/cloud/objectstore/util.d.ts.map +0 -1
- package/dist/cmd/cloud/objectstore/util.js +0 -18
- package/dist/cmd/cloud/objectstore/util.js.map +0 -1
- package/src/cmd/build/ast.test.ts +0 -418
- package/src/cmd/build/fix-duplicate-exports.test.ts +0 -387
- package/src/cmd/cloud/objectstore/delete-bucket.ts +0 -77
- package/src/cmd/cloud/objectstore/delete.ts +0 -67
- package/src/cmd/cloud/objectstore/get.ts +0 -77
- package/src/cmd/cloud/objectstore/index.ts +0 -36
- package/src/cmd/cloud/objectstore/list-buckets.ts +0 -51
- package/src/cmd/cloud/objectstore/list-keys.ts +0 -63
- package/src/cmd/cloud/objectstore/put.ts +0 -74
- package/src/cmd/cloud/objectstore/repl.ts +0 -239
- package/src/cmd/cloud/objectstore/url.ts +0 -67
- package/src/cmd/cloud/objectstore/util.ts +0 -29
- package/src/crypto/box.test.ts +0 -431
- package/src/env-util.test.ts +0 -194
|
@@ -1,418 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect } from 'bun:test';
|
|
2
|
-
import { parseRoute, parseAgentMetadata } from './ast';
|
|
3
|
-
import { writeFileSync, mkdirSync, rmSync } from 'node:fs';
|
|
4
|
-
import { join } from 'node:path';
|
|
5
|
-
|
|
6
|
-
const TEST_DIR = '/tmp/agentuity-cli-test-routes';
|
|
7
|
-
|
|
8
|
-
describe('parseRoute - Crash Prevention Scenarios', () => {
|
|
9
|
-
const setup = () => {
|
|
10
|
-
rmSync(TEST_DIR, { recursive: true, force: true });
|
|
11
|
-
mkdirSync(TEST_DIR, { recursive: true });
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const cleanup = () => {
|
|
15
|
-
rmSync(TEST_DIR, { recursive: true, force: true });
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
test('should handle files with interface definitions', async () => {
|
|
19
|
-
setup();
|
|
20
|
-
const routeFile = join(TEST_DIR, 'route.ts');
|
|
21
|
-
const code = `
|
|
22
|
-
import { createRouter } from '@agentuity/runtime';
|
|
23
|
-
const router = createRouter();
|
|
24
|
-
|
|
25
|
-
interface SomeInterface {
|
|
26
|
-
foo: string;
|
|
27
|
-
bar: string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
router.get('/', (c) => c.json({ status: 'ok' }));
|
|
31
|
-
|
|
32
|
-
export default router;
|
|
33
|
-
`;
|
|
34
|
-
writeFileSync(routeFile, code);
|
|
35
|
-
|
|
36
|
-
const routes = await parseRoute(TEST_DIR, routeFile, 'proj_1', 'dep_1');
|
|
37
|
-
expect(routes).toHaveLength(1);
|
|
38
|
-
expect(routes[0].method).toBe('get');
|
|
39
|
-
|
|
40
|
-
cleanup();
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test('should handle non-call expression statements', async () => {
|
|
44
|
-
setup();
|
|
45
|
-
const routeFile = join(TEST_DIR, 'route.ts');
|
|
46
|
-
const code = `
|
|
47
|
-
import { createRouter } from '@agentuity/runtime';
|
|
48
|
-
const router = createRouter();
|
|
49
|
-
|
|
50
|
-
1 + 1;
|
|
51
|
-
"string literal";
|
|
52
|
-
true;
|
|
53
|
-
|
|
54
|
-
router.get('/', (c) => c.text('ok'));
|
|
55
|
-
|
|
56
|
-
export default router;
|
|
57
|
-
`;
|
|
58
|
-
writeFileSync(routeFile, code);
|
|
59
|
-
|
|
60
|
-
const routes = await parseRoute(TEST_DIR, routeFile, 'proj_1', 'dep_1');
|
|
61
|
-
expect(routes).toHaveLength(1);
|
|
62
|
-
|
|
63
|
-
cleanup();
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test('should handle variable access identifiers', async () => {
|
|
67
|
-
setup();
|
|
68
|
-
const routeFile = join(TEST_DIR, 'route.ts');
|
|
69
|
-
const code = `
|
|
70
|
-
import { createRouter } from '@agentuity/runtime';
|
|
71
|
-
const router = createRouter();
|
|
72
|
-
|
|
73
|
-
router; // Just accessing the variable
|
|
74
|
-
|
|
75
|
-
router.get('/', (c) => c.text('ok'));
|
|
76
|
-
|
|
77
|
-
export default router;
|
|
78
|
-
`;
|
|
79
|
-
writeFileSync(routeFile, code);
|
|
80
|
-
|
|
81
|
-
const routes = await parseRoute(TEST_DIR, routeFile, 'proj_1', 'dep_1');
|
|
82
|
-
expect(routes).toHaveLength(1);
|
|
83
|
-
|
|
84
|
-
cleanup();
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
test('should handle direct function calls (not member expressions)', async () => {
|
|
88
|
-
setup();
|
|
89
|
-
const routeFile = join(TEST_DIR, 'route.ts');
|
|
90
|
-
const code = `
|
|
91
|
-
import { createRouter } from '@agentuity/runtime';
|
|
92
|
-
const router = createRouter();
|
|
93
|
-
|
|
94
|
-
console.log("logging");
|
|
95
|
-
(function() { })();
|
|
96
|
-
|
|
97
|
-
router.get('/', (c) => c.text('ok'));
|
|
98
|
-
|
|
99
|
-
export default router;
|
|
100
|
-
`;
|
|
101
|
-
writeFileSync(routeFile, code);
|
|
102
|
-
|
|
103
|
-
const routes = await parseRoute(TEST_DIR, routeFile, 'proj_1', 'dep_1');
|
|
104
|
-
expect(routes).toHaveLength(1);
|
|
105
|
-
|
|
106
|
-
cleanup();
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
test('should handle mixed complex scenarios', async () => {
|
|
110
|
-
setup();
|
|
111
|
-
const routeFile = join(TEST_DIR, 'route.ts');
|
|
112
|
-
const code = `
|
|
113
|
-
import { createRouter } from '@agentuity/runtime';
|
|
114
|
-
|
|
115
|
-
// Variable declarations
|
|
116
|
-
const router = createRouter();
|
|
117
|
-
const someVar = "test";
|
|
118
|
-
|
|
119
|
-
// Interface
|
|
120
|
-
interface User {
|
|
121
|
-
id: string;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// Function declaration
|
|
125
|
-
function helper() {
|
|
126
|
-
return true;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// Direct call
|
|
130
|
-
helper();
|
|
131
|
-
|
|
132
|
-
// Non-route member expression
|
|
133
|
-
console.log(someVar);
|
|
134
|
-
|
|
135
|
-
// Valid route
|
|
136
|
-
router.post('/users', (c) => c.json({ id: '1' }));
|
|
137
|
-
|
|
138
|
-
// Another expression type
|
|
139
|
-
if (true) {
|
|
140
|
-
console.log("block");
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
export default router;
|
|
144
|
-
`;
|
|
145
|
-
writeFileSync(routeFile, code);
|
|
146
|
-
|
|
147
|
-
const routes = await parseRoute(TEST_DIR, routeFile, 'proj_1', 'dep_1');
|
|
148
|
-
expect(routes).toHaveLength(1);
|
|
149
|
-
expect(routes[0].method).toBe('post');
|
|
150
|
-
|
|
151
|
-
cleanup();
|
|
152
|
-
});
|
|
153
|
-
test('should reject invalid router method', async () => {
|
|
154
|
-
setup();
|
|
155
|
-
const routeFile = join(TEST_DIR, 'route.ts');
|
|
156
|
-
const code = `
|
|
157
|
-
import { createRouter } from '@agentuity/runtime';
|
|
158
|
-
|
|
159
|
-
// Variable declarations
|
|
160
|
-
const router = createRouter();
|
|
161
|
-
|
|
162
|
-
// Invalid route with unknown method
|
|
163
|
-
router.foo('/users', (c) => c.json({ id: '1' }));
|
|
164
|
-
|
|
165
|
-
export default router;
|
|
166
|
-
`;
|
|
167
|
-
writeFileSync(routeFile, code);
|
|
168
|
-
|
|
169
|
-
await expect(parseRoute(TEST_DIR, routeFile, 'proj_1', 'dep_1')).rejects.toThrow();
|
|
170
|
-
|
|
171
|
-
cleanup();
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
describe('parseAgentMetadata - Schema Code Extraction', () => {
|
|
176
|
-
const setup = () => {
|
|
177
|
-
rmSync(TEST_DIR, { recursive: true, force: true });
|
|
178
|
-
mkdirSync(TEST_DIR, { recursive: true });
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
const cleanup = () => {
|
|
182
|
-
rmSync(TEST_DIR, { recursive: true, force: true });
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
test('should extract input and output schema code', async () => {
|
|
186
|
-
setup();
|
|
187
|
-
const agentFile = join(TEST_DIR, 'agent.ts');
|
|
188
|
-
const code = `
|
|
189
|
-
import { createAgent } from '@agentuity/runtime';
|
|
190
|
-
import { z } from 'zod';
|
|
191
|
-
|
|
192
|
-
const agent = createAgent({
|
|
193
|
-
metadata: {
|
|
194
|
-
name: 'test-agent',
|
|
195
|
-
description: 'Test agent',
|
|
196
|
-
},
|
|
197
|
-
schema: {
|
|
198
|
-
input: z.object({
|
|
199
|
-
name: z.string(),
|
|
200
|
-
age: z.number(),
|
|
201
|
-
}),
|
|
202
|
-
output: z.object({
|
|
203
|
-
result: z.string(),
|
|
204
|
-
}),
|
|
205
|
-
},
|
|
206
|
-
handler: async (ctx, input) => {
|
|
207
|
-
return { result: 'success' };
|
|
208
|
-
},
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
export default agent;
|
|
212
|
-
`;
|
|
213
|
-
writeFileSync(agentFile, code);
|
|
214
|
-
|
|
215
|
-
const transpiler = new Bun.Transpiler({ loader: 'ts', target: 'bun' });
|
|
216
|
-
const contents = transpiler.transformSync(code);
|
|
217
|
-
const [, metadata] = await parseAgentMetadata(
|
|
218
|
-
TEST_DIR,
|
|
219
|
-
agentFile,
|
|
220
|
-
contents,
|
|
221
|
-
'proj_1',
|
|
222
|
-
'dep_1'
|
|
223
|
-
);
|
|
224
|
-
|
|
225
|
-
expect(metadata.has('inputSchemaCode')).toBe(true);
|
|
226
|
-
expect(metadata.has('outputSchemaCode')).toBe(true);
|
|
227
|
-
|
|
228
|
-
const inputSchemaCode = metadata.get('inputSchemaCode');
|
|
229
|
-
const outputSchemaCode = metadata.get('outputSchemaCode');
|
|
230
|
-
|
|
231
|
-
expect(inputSchemaCode).toContain('z.object');
|
|
232
|
-
expect(inputSchemaCode).toContain('name');
|
|
233
|
-
expect(inputSchemaCode).toContain('age');
|
|
234
|
-
|
|
235
|
-
expect(outputSchemaCode).toContain('z.object');
|
|
236
|
-
expect(outputSchemaCode).toContain('result');
|
|
237
|
-
|
|
238
|
-
cleanup();
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
test('should extract only input schema code when output is missing', async () => {
|
|
242
|
-
setup();
|
|
243
|
-
const agentFile = join(TEST_DIR, 'agent.ts');
|
|
244
|
-
const code = `
|
|
245
|
-
import { createAgent } from '@agentuity/runtime';
|
|
246
|
-
import { z } from 'zod';
|
|
247
|
-
|
|
248
|
-
const agent = createAgent({
|
|
249
|
-
metadata: {
|
|
250
|
-
name: 'test-agent',
|
|
251
|
-
},
|
|
252
|
-
schema: {
|
|
253
|
-
input: z.string(),
|
|
254
|
-
},
|
|
255
|
-
handler: async (ctx, input) => {
|
|
256
|
-
return 'success';
|
|
257
|
-
},
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
export default agent;
|
|
261
|
-
`;
|
|
262
|
-
writeFileSync(agentFile, code);
|
|
263
|
-
|
|
264
|
-
const transpiler = new Bun.Transpiler({ loader: 'ts', target: 'bun' });
|
|
265
|
-
const contents = transpiler.transformSync(code);
|
|
266
|
-
const [, metadata] = await parseAgentMetadata(
|
|
267
|
-
TEST_DIR,
|
|
268
|
-
agentFile,
|
|
269
|
-
contents,
|
|
270
|
-
'proj_1',
|
|
271
|
-
'dep_1'
|
|
272
|
-
);
|
|
273
|
-
|
|
274
|
-
expect(metadata.has('inputSchemaCode')).toBe(true);
|
|
275
|
-
expect(metadata.has('outputSchemaCode')).toBe(false);
|
|
276
|
-
|
|
277
|
-
const inputSchemaCode = metadata.get('inputSchemaCode');
|
|
278
|
-
expect(inputSchemaCode).toContain('z.string');
|
|
279
|
-
|
|
280
|
-
cleanup();
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
test('should extract only output schema code when input is missing', async () => {
|
|
284
|
-
setup();
|
|
285
|
-
const agentFile = join(TEST_DIR, 'agent.ts');
|
|
286
|
-
const code = `
|
|
287
|
-
import { createAgent } from '@agentuity/runtime';
|
|
288
|
-
import { z } from 'zod';
|
|
289
|
-
|
|
290
|
-
const agent = createAgent({
|
|
291
|
-
metadata: {
|
|
292
|
-
name: 'test-agent',
|
|
293
|
-
},
|
|
294
|
-
schema: {
|
|
295
|
-
output: z.array(z.string()),
|
|
296
|
-
},
|
|
297
|
-
handler: async (ctx) => {
|
|
298
|
-
return ['item1', 'item2'];
|
|
299
|
-
},
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
export default agent;
|
|
303
|
-
`;
|
|
304
|
-
writeFileSync(agentFile, code);
|
|
305
|
-
|
|
306
|
-
const transpiler = new Bun.Transpiler({ loader: 'ts', target: 'bun' });
|
|
307
|
-
const contents = transpiler.transformSync(code);
|
|
308
|
-
const [, metadata] = await parseAgentMetadata(
|
|
309
|
-
TEST_DIR,
|
|
310
|
-
agentFile,
|
|
311
|
-
contents,
|
|
312
|
-
'proj_1',
|
|
313
|
-
'dep_1'
|
|
314
|
-
);
|
|
315
|
-
|
|
316
|
-
expect(metadata.has('inputSchemaCode')).toBe(false);
|
|
317
|
-
expect(metadata.has('outputSchemaCode')).toBe(true);
|
|
318
|
-
|
|
319
|
-
const outputSchemaCode = metadata.get('outputSchemaCode');
|
|
320
|
-
expect(outputSchemaCode).toContain('z.array');
|
|
321
|
-
expect(outputSchemaCode).toContain('z.string');
|
|
322
|
-
|
|
323
|
-
cleanup();
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
test('should handle complex nested schemas', async () => {
|
|
327
|
-
setup();
|
|
328
|
-
const agentFile = join(TEST_DIR, 'agent.ts');
|
|
329
|
-
const code = `
|
|
330
|
-
import { createAgent } from '@agentuity/runtime';
|
|
331
|
-
import { z } from 'zod';
|
|
332
|
-
|
|
333
|
-
const agent = createAgent({
|
|
334
|
-
metadata: {
|
|
335
|
-
name: 'test-agent',
|
|
336
|
-
},
|
|
337
|
-
schema: {
|
|
338
|
-
input: z.object({
|
|
339
|
-
user: z.object({
|
|
340
|
-
name: z.string(),
|
|
341
|
-
email: z.string().email(),
|
|
342
|
-
}),
|
|
343
|
-
tags: z.array(z.string()),
|
|
344
|
-
}),
|
|
345
|
-
output: z.union([
|
|
346
|
-
z.object({ success: z.boolean() }),
|
|
347
|
-
z.object({ error: z.string() }),
|
|
348
|
-
]),
|
|
349
|
-
},
|
|
350
|
-
handler: async (ctx, input) => {
|
|
351
|
-
return { success: true };
|
|
352
|
-
},
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
export default agent;
|
|
356
|
-
`;
|
|
357
|
-
writeFileSync(agentFile, code);
|
|
358
|
-
|
|
359
|
-
const transpiler = new Bun.Transpiler({ loader: 'ts', target: 'bun' });
|
|
360
|
-
const contents = transpiler.transformSync(code);
|
|
361
|
-
const [, metadata] = await parseAgentMetadata(
|
|
362
|
-
TEST_DIR,
|
|
363
|
-
agentFile,
|
|
364
|
-
contents,
|
|
365
|
-
'proj_1',
|
|
366
|
-
'dep_1'
|
|
367
|
-
);
|
|
368
|
-
|
|
369
|
-
expect(metadata.has('inputSchemaCode')).toBe(true);
|
|
370
|
-
expect(metadata.has('outputSchemaCode')).toBe(true);
|
|
371
|
-
|
|
372
|
-
const inputSchemaCode = metadata.get('inputSchemaCode');
|
|
373
|
-
const outputSchemaCode = metadata.get('outputSchemaCode');
|
|
374
|
-
|
|
375
|
-
expect(inputSchemaCode).toContain('z.object');
|
|
376
|
-
expect(inputSchemaCode).toContain('user');
|
|
377
|
-
expect(inputSchemaCode).toContain('tags');
|
|
378
|
-
|
|
379
|
-
expect(outputSchemaCode).toContain('z.union');
|
|
380
|
-
|
|
381
|
-
cleanup();
|
|
382
|
-
});
|
|
383
|
-
|
|
384
|
-
test('should handle agent without schema property', async () => {
|
|
385
|
-
setup();
|
|
386
|
-
const agentFile = join(TEST_DIR, 'agent.ts');
|
|
387
|
-
const code = `
|
|
388
|
-
import { createAgent } from '@agentuity/runtime';
|
|
389
|
-
|
|
390
|
-
const agent = createAgent({
|
|
391
|
-
metadata: {
|
|
392
|
-
name: 'test-agent',
|
|
393
|
-
},
|
|
394
|
-
handler: async (ctx) => {
|
|
395
|
-
return 'success';
|
|
396
|
-
},
|
|
397
|
-
});
|
|
398
|
-
|
|
399
|
-
export default agent;
|
|
400
|
-
`;
|
|
401
|
-
writeFileSync(agentFile, code);
|
|
402
|
-
|
|
403
|
-
const transpiler = new Bun.Transpiler({ loader: 'ts', target: 'bun' });
|
|
404
|
-
const contents = transpiler.transformSync(code);
|
|
405
|
-
const [, metadata] = await parseAgentMetadata(
|
|
406
|
-
TEST_DIR,
|
|
407
|
-
agentFile,
|
|
408
|
-
contents,
|
|
409
|
-
'proj_1',
|
|
410
|
-
'dep_1'
|
|
411
|
-
);
|
|
412
|
-
|
|
413
|
-
expect(metadata.has('inputSchemaCode')).toBe(false);
|
|
414
|
-
expect(metadata.has('outputSchemaCode')).toBe(false);
|
|
415
|
-
|
|
416
|
-
cleanup();
|
|
417
|
-
});
|
|
418
|
-
});
|