-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathcreate-memory.test.ts
More file actions
100 lines (88 loc) · 3.41 KB
/
Copy pathcreate-memory.test.ts
File metadata and controls
100 lines (88 loc) · 3.41 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
import { prereqs, readProjectConfig, runCLI } from '../src/test-utils/index.js';
import { randomUUID } from 'node:crypto';
import { mkdir, 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 memory options', () => {
let testDir: string;
beforeAll(async () => {
testDir = join(tmpdir(), `agentcore-integ-memory-${randomUUID()}`);
await mkdir(testDir, { recursive: true });
});
afterAll(async () => {
await rm(testDir, { recursive: true, force: true });
});
it('creates project with shortTerm memory', async () => {
const name = `ST${Date.now().toString().slice(-6)}`;
const result = await runCLI(
[
'create',
'--name',
name,
'--language',
'Python',
'--framework',
'Strands',
'--model-provider',
'Bedrock',
'--memory',
'shortTerm',
'--json',
],
testDir
);
expect(result.exitCode, `stderr: ${result.stderr}`).toBe(0);
const json = JSON.parse(result.stdout);
expect(json.success).toBe(true);
// Verify agentcore.json has memory configuration
const config = await readProjectConfig(json.projectPath);
const memories = config.memories as Record<string, unknown>[] | undefined;
expect(memories, 'memories should exist in config').toBeDefined();
expect(memories!.length).toBeGreaterThan(0);
});
it('creates project with longAndShortTerm memory', async () => {
const name = `LST${Date.now().toString().slice(-6)}`;
const result = await runCLI(
[
'create',
'--name',
name,
'--language',
'Python',
'--framework',
'Strands',
'--model-provider',
'Bedrock',
'--memory',
'longAndShortTerm',
'--json',
],
testDir
);
expect(result.exitCode, `stderr: ${result.stderr}`).toBe(0);
const json = JSON.parse(result.stdout);
expect(json.success).toBe(true);
// Verify agentcore.json has memory configuration with multiple strategies
const config = await readProjectConfig(json.projectPath);
const memories = config.memories as Record<string, unknown>[] | undefined;
expect(memories, 'memories should exist in config').toBeDefined();
expect(memories!.length).toBeGreaterThan(0);
// longAndShortTerm should have strategies defined
const memory = memories![0]!;
const strategies = memory.strategies as { type: string; reflectionNamespaceTemplates?: string[] }[] | undefined;
expect(strategies, 'memory should have strategies').toBeDefined();
expect(strategies!.length).toBe(4);
// Verify all four strategy types are present
const types = strategies!.map(s => s.type);
expect(types).toContain('SEMANTIC');
expect(types).toContain('USER_PREFERENCE');
expect(types).toContain('SUMMARIZATION');
expect(types).toContain('EPISODIC');
// Verify EPISODIC has reflectionNamespaceTemplates
const episodic = strategies!.find(s => s.type === 'EPISODIC');
expect(episodic, 'EPISODIC strategy should exist').toBeTruthy();
expect(episodic!.reflectionNamespaceTemplates, 'EPISODIC should have reflectionNamespaceTemplates').toBeDefined();
expect(episodic!.reflectionNamespaceTemplates!.length).toBeGreaterThan(0);
});
});