forked from aws/agentcore-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-frameworks.test.ts
More file actions
163 lines (140 loc) · 5.4 KB
/
Copy pathcreate-frameworks.test.ts
File metadata and controls
163 lines (140 loc) · 5.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import { exists, prereqs, readProjectConfig, runCLI } from '../src/test-utils/index.js';
import { createTelemetryHelper } from '../src/test-utils/telemetry-helper.js';
import { randomUUID } from 'node:crypto';
import { mkdir, readFile, rm } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
describe.skipIf(!prereqs.npm || !prereqs.git)('integration: create with different frameworks', () => {
let testDir: string;
const telemetry = createTelemetryHelper();
beforeAll(async () => {
testDir = join(tmpdir(), `agentcore-integ-frameworks-${randomUUID()}`);
await mkdir(testDir, { recursive: true });
});
afterAll(async () => {
telemetry.destroy();
await rm(testDir, { recursive: true, force: true });
});
it('creates LangChain_LangGraph project', async () => {
const name = `LG${Date.now().toString().slice(-6)}`;
const result = await runCLI(
[
'create',
'--name',
name,
'--language',
'Python',
'--framework',
'LangChain_LangGraph',
'--model-provider',
'Bedrock',
'--memory',
'none',
'--json',
],
testDir,
{ env: telemetry.env }
);
expect(result.exitCode, `stderr: ${result.stderr}`).toBe(0);
const json = JSON.parse(result.stdout);
expect(json.success).toBe(true);
const agentName = json.agentName || name;
const agentDir = join(json.projectPath, 'app', agentName);
// Verify agent files exist
expect(await exists(agentDir), 'Agent directory should exist').toBe(true);
expect(await exists(join(agentDir, 'pyproject.toml')), 'pyproject.toml should exist').toBe(true);
// Verify pyproject.toml references langgraph and langchain
const pyproject = await readFile(join(agentDir, 'pyproject.toml'), 'utf-8');
const pyprojectLower = pyproject.toLowerCase();
expect(pyprojectLower.includes('langgraph'), 'pyproject.toml should reference langgraph').toBe(true);
expect(pyprojectLower.includes('langchain'), 'pyproject.toml should reference langchain').toBe(true);
// Verify config has agent registered
const config = await readProjectConfig(json.projectPath);
const agents = config.runtimes as Record<string, unknown>[];
expect(agents).toBeDefined();
expect(agents.length).toBe(1);
expect(agents[0]!.name).toBe(agentName);
telemetry.assertMetricEmitted({
command: 'create',
exit_reason: 'success',
language: 'python',
framework: 'langchain_langgraph',
model_provider: 'bedrock',
has_agent: 'true',
});
});
it('creates GoogleADK project with Gemini provider', async () => {
const name = `Gadk${Date.now().toString().slice(-6)}`;
const result = await runCLI(
[
'create',
'--name',
name,
'--language',
'Python',
'--framework',
'GoogleADK',
'--model-provider',
'Gemini',
'--memory',
'none',
'--json',
],
testDir
);
expect(result.exitCode, `stderr: ${result.stderr}`).toBe(0);
const json = JSON.parse(result.stdout);
expect(json.success).toBe(true);
const agentName = json.agentName || name;
const agentDir = join(json.projectPath, 'app', agentName);
expect(await exists(agentDir), 'Agent directory should exist').toBe(true);
expect(await exists(join(agentDir, 'pyproject.toml')), 'pyproject.toml should exist').toBe(true);
// Verify pyproject.toml references google-adk
const pyproject = await readFile(join(agentDir, 'pyproject.toml'), 'utf-8');
expect(
pyproject.toLowerCase().includes('google') || pyproject.toLowerCase().includes('adk'),
'pyproject.toml should reference google adk'
).toBeTruthy();
// Verify config has agent registered
const config = await readProjectConfig(json.projectPath);
const agents = config.runtimes as Record<string, unknown>[];
expect(agents.length).toBe(1);
expect(agents[0]!.name).toBe(agentName);
});
it('creates OpenAIAgents project with OpenAI provider', async () => {
const name = `Oai${Date.now().toString().slice(-6)}`;
const result = await runCLI(
[
'create',
'--name',
name,
'--language',
'Python',
'--framework',
'OpenAIAgents',
'--model-provider',
'OpenAI',
'--memory',
'none',
'--json',
],
testDir
);
expect(result.exitCode, `stderr: ${result.stderr}`).toBe(0);
const json = JSON.parse(result.stdout);
expect(json.success).toBe(true);
const agentName = json.agentName || name;
const agentDir = join(json.projectPath, 'app', agentName);
expect(await exists(agentDir), 'Agent directory should exist').toBe(true);
expect(await exists(join(agentDir, 'pyproject.toml')), 'pyproject.toml should exist').toBe(true);
// Verify pyproject.toml references openai-agents
const pyproject = await readFile(join(agentDir, 'pyproject.toml'), 'utf-8');
expect(pyproject.toLowerCase().includes('openai'), 'pyproject.toml should reference openai').toBeTruthy();
// Verify config has agent registered
const config = await readProjectConfig(json.projectPath);
const agents = config.runtimes as Record<string, unknown>[];
expect(agents.length).toBe(1);
expect(agents[0]!.name).toBe(agentName);
});
});