@cortexmemory/cli 0.27.1 โ 0.27.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/commands/convex.js +1 -1
- package/dist/commands/convex.js.map +1 -1
- package/dist/commands/deploy.d.ts +1 -1
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +839 -141
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +89 -26
- package/dist/commands/dev.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/utils/app-template-sync.d.ts +95 -0
- package/dist/utils/app-template-sync.d.ts.map +1 -0
- package/dist/utils/app-template-sync.js +445 -0
- package/dist/utils/app-template-sync.js.map +1 -0
- package/dist/utils/deployment-selector.d.ts +21 -0
- package/dist/utils/deployment-selector.d.ts.map +1 -1
- package/dist/utils/deployment-selector.js +32 -0
- package/dist/utils/deployment-selector.js.map +1 -1
- package/dist/utils/init/graph-setup.d.ts.map +1 -1
- package/dist/utils/init/graph-setup.js +13 -2
- package/dist/utils/init/graph-setup.js.map +1 -1
- package/package.json +1 -1
- package/templates/vercel-ai-quickstart/app/api/auth/check/route.ts +30 -0
- package/templates/vercel-ai-quickstart/app/api/auth/login/route.ts +128 -0
- package/templates/vercel-ai-quickstart/app/api/auth/register/route.ts +94 -0
- package/templates/vercel-ai-quickstart/app/api/auth/setup/route.ts +59 -0
- package/templates/vercel-ai-quickstart/app/api/chat/route.ts +139 -3
- package/templates/vercel-ai-quickstart/app/api/chat-v6/route.ts +333 -0
- package/templates/vercel-ai-quickstart/app/api/conversations/route.ts +179 -0
- package/templates/vercel-ai-quickstart/app/globals.css +161 -0
- package/templates/vercel-ai-quickstart/app/page.tsx +110 -11
- package/templates/vercel-ai-quickstart/components/AdminSetup.tsx +139 -0
- package/templates/vercel-ai-quickstart/components/AuthProvider.tsx +283 -0
- package/templates/vercel-ai-quickstart/components/ChatHistorySidebar.tsx +323 -0
- package/templates/vercel-ai-quickstart/components/ChatInterface.tsx +117 -17
- package/templates/vercel-ai-quickstart/components/LoginScreen.tsx +202 -0
- package/templates/vercel-ai-quickstart/jest.config.js +52 -0
- package/templates/vercel-ai-quickstart/lib/agents/memory-agent.ts +165 -0
- package/templates/vercel-ai-quickstart/lib/cortex.ts +27 -0
- package/templates/vercel-ai-quickstart/lib/password.ts +120 -0
- package/templates/vercel-ai-quickstart/lib/versions.ts +60 -0
- package/templates/vercel-ai-quickstart/next.config.js +20 -0
- package/templates/vercel-ai-quickstart/package.json +11 -2
- package/templates/vercel-ai-quickstart/test-api.mjs +272 -0
- package/templates/vercel-ai-quickstart/tests/e2e/chat-memory-flow.test.ts +454 -0
- package/templates/vercel-ai-quickstart/tests/helpers/mock-cortex.ts +263 -0
- package/templates/vercel-ai-quickstart/tests/helpers/setup.ts +48 -0
- package/templates/vercel-ai-quickstart/tests/integration/auth.test.ts +455 -0
- package/templates/vercel-ai-quickstart/tests/integration/conversations.test.ts +461 -0
- package/templates/vercel-ai-quickstart/tests/unit/password.test.ts +228 -0
- package/templates/vercel-ai-quickstart/tsconfig.json +1 -1
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Programmatic API Route Tests
|
|
4
|
+
* Tests both v5 and v6 routes for memory functionality
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const BASE_URL = process.env.QUICKSTART_URL || 'http://localhost:3000';
|
|
8
|
+
|
|
9
|
+
// Test configuration
|
|
10
|
+
const TEST_USER_ID = `test-user-${Date.now()}`;
|
|
11
|
+
const TEST_MEMORY_SPACE_ID = 'quickstart-demo';
|
|
12
|
+
|
|
13
|
+
async function sleep(ms) {
|
|
14
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async function testRoute(routePath, routeName) {
|
|
18
|
+
console.log(`\n${'='.repeat(60)}`);
|
|
19
|
+
console.log(`Testing ${routeName} (${routePath})`);
|
|
20
|
+
console.log('='.repeat(60));
|
|
21
|
+
|
|
22
|
+
const conversationId = `conv-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
23
|
+
|
|
24
|
+
// Test 1: Send a message with a fact
|
|
25
|
+
console.log('\n๐ค Test 1: Sending message with a fact...');
|
|
26
|
+
const message1 = {
|
|
27
|
+
id: `msg-${Date.now()}-1`,
|
|
28
|
+
role: 'user',
|
|
29
|
+
content: `My favorite programming language is TypeScript and I work at a company called TechCorp.`,
|
|
30
|
+
createdAt: new Date().toISOString(),
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
const response1 = await fetch(`${BASE_URL}${routePath}`, {
|
|
35
|
+
method: 'POST',
|
|
36
|
+
headers: { 'Content-Type': 'application/json' },
|
|
37
|
+
body: JSON.stringify({
|
|
38
|
+
messages: [message1],
|
|
39
|
+
userId: TEST_USER_ID,
|
|
40
|
+
memorySpaceId: TEST_MEMORY_SPACE_ID,
|
|
41
|
+
conversationId,
|
|
42
|
+
}),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
if (!response1.ok) {
|
|
46
|
+
const errorText = await response1.text();
|
|
47
|
+
console.log(`โ Request failed with status ${response1.status}`);
|
|
48
|
+
console.log(` Error: ${errorText.slice(0, 500)}`);
|
|
49
|
+
return { success: false, route: routeName, error: `HTTP ${response1.status}` };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Read streaming response
|
|
53
|
+
const reader = response1.body.getReader();
|
|
54
|
+
const decoder = new TextDecoder();
|
|
55
|
+
let fullResponse = '';
|
|
56
|
+
let chunks = 0;
|
|
57
|
+
|
|
58
|
+
while (true) {
|
|
59
|
+
const { done, value } = await reader.read();
|
|
60
|
+
if (done) break;
|
|
61
|
+
const chunk = decoder.decode(value, { stream: true });
|
|
62
|
+
fullResponse += chunk;
|
|
63
|
+
chunks++;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
console.log(`โ
Response received (${chunks} chunks, ${fullResponse.length} bytes)`);
|
|
67
|
+
|
|
68
|
+
// Check for layer observer data
|
|
69
|
+
const hasLayerData = fullResponse.includes('FACTS_LAYER') ||
|
|
70
|
+
fullResponse.includes('MEMORY_LAYER') ||
|
|
71
|
+
fullResponse.includes('layerId');
|
|
72
|
+
console.log(` Layer observer data: ${hasLayerData ? 'โ
Present' : 'โ Missing'}`);
|
|
73
|
+
|
|
74
|
+
// Check for text content
|
|
75
|
+
const hasTextContent = fullResponse.includes('"type":"text"') ||
|
|
76
|
+
fullResponse.includes('text-delta');
|
|
77
|
+
console.log(` Text content: ${hasTextContent ? 'โ
Present' : 'โ Missing'}`);
|
|
78
|
+
|
|
79
|
+
} catch (error) {
|
|
80
|
+
console.log(`โ Request error: ${error.message}`);
|
|
81
|
+
return { success: false, route: routeName, error: error.message };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Wait for async processing (fact extraction, etc.)
|
|
85
|
+
console.log('\nโณ Waiting for memory processing...');
|
|
86
|
+
await sleep(3000);
|
|
87
|
+
|
|
88
|
+
// Test 2: Check if facts were stored
|
|
89
|
+
console.log('\n๐ Test 2: Checking stored facts...');
|
|
90
|
+
try {
|
|
91
|
+
const factsResponse = await fetch(
|
|
92
|
+
`${BASE_URL}/api/facts?userId=${TEST_USER_ID}&memorySpaceId=${TEST_MEMORY_SPACE_ID}`,
|
|
93
|
+
{ method: 'GET' }
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
if (factsResponse.ok) {
|
|
97
|
+
const factsData = await factsResponse.json();
|
|
98
|
+
const facts = factsData.facts || factsData || [];
|
|
99
|
+
console.log(`โ
Facts API returned: ${Array.isArray(facts) ? facts.length : 'unknown'} facts`);
|
|
100
|
+
|
|
101
|
+
if (Array.isArray(facts) && facts.length > 0) {
|
|
102
|
+
console.log(' Sample facts:');
|
|
103
|
+
facts.slice(0, 3).forEach((fact, i) => {
|
|
104
|
+
const content = fact.content || fact.text || JSON.stringify(fact).slice(0, 100);
|
|
105
|
+
console.log(` ${i + 1}. ${content.slice(0, 80)}...`);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
} else {
|
|
109
|
+
console.log(`โ ๏ธ Facts API returned ${factsResponse.status}`);
|
|
110
|
+
}
|
|
111
|
+
} catch (error) {
|
|
112
|
+
console.log(`โ ๏ธ Could not check facts: ${error.message}`);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Test 3: Send follow-up message and verify recall
|
|
116
|
+
console.log('\n๐ค Test 3: Sending follow-up to test recall...');
|
|
117
|
+
const message2 = {
|
|
118
|
+
id: `msg-${Date.now()}-2`,
|
|
119
|
+
role: 'user',
|
|
120
|
+
content: 'What programming language do I prefer?',
|
|
121
|
+
createdAt: new Date().toISOString(),
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// Include previous assistant response for context
|
|
125
|
+
const message1Response = {
|
|
126
|
+
id: `msg-${Date.now()}-1r`,
|
|
127
|
+
role: 'assistant',
|
|
128
|
+
content: 'Great! TypeScript is a fantastic choice for type-safe development.',
|
|
129
|
+
createdAt: new Date().toISOString(),
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
try {
|
|
133
|
+
const response2 = await fetch(`${BASE_URL}${routePath}`, {
|
|
134
|
+
method: 'POST',
|
|
135
|
+
headers: { 'Content-Type': 'application/json' },
|
|
136
|
+
body: JSON.stringify({
|
|
137
|
+
messages: [message1, message1Response, message2],
|
|
138
|
+
userId: TEST_USER_ID,
|
|
139
|
+
memorySpaceId: TEST_MEMORY_SPACE_ID,
|
|
140
|
+
conversationId,
|
|
141
|
+
}),
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
if (!response2.ok) {
|
|
145
|
+
console.log(`โ Follow-up request failed with status ${response2.status}`);
|
|
146
|
+
return { success: false, route: routeName, error: `Follow-up HTTP ${response2.status}` };
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const reader = response2.body.getReader();
|
|
150
|
+
const decoder = new TextDecoder();
|
|
151
|
+
let fullResponse = '';
|
|
152
|
+
|
|
153
|
+
while (true) {
|
|
154
|
+
const { done, value } = await reader.read();
|
|
155
|
+
if (done) break;
|
|
156
|
+
fullResponse += decoder.decode(value, { stream: true });
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Check if TypeScript was mentioned in the response (recall working)
|
|
160
|
+
const mentionsTypeScript = fullResponse.toLowerCase().includes('typescript');
|
|
161
|
+
console.log(`โ
Response received`);
|
|
162
|
+
console.log(` Recalls TypeScript preference: ${mentionsTypeScript ? 'โ
Yes' : 'โ No'}`);
|
|
163
|
+
|
|
164
|
+
return {
|
|
165
|
+
success: true,
|
|
166
|
+
route: routeName,
|
|
167
|
+
recallWorks: mentionsTypeScript
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
} catch (error) {
|
|
171
|
+
console.log(`โ Follow-up request error: ${error.message}`);
|
|
172
|
+
return { success: false, route: routeName, error: error.message };
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
async function testConversationAPI() {
|
|
177
|
+
console.log(`\n${'='.repeat(60)}`);
|
|
178
|
+
console.log('Testing Conversation API');
|
|
179
|
+
console.log('='.repeat(60));
|
|
180
|
+
|
|
181
|
+
try {
|
|
182
|
+
const response = await fetch(
|
|
183
|
+
`${BASE_URL}/api/conversations?userId=${TEST_USER_ID}&memorySpaceId=${TEST_MEMORY_SPACE_ID}`,
|
|
184
|
+
{ method: 'GET' }
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
if (response.ok) {
|
|
188
|
+
const data = await response.json();
|
|
189
|
+
const conversations = data.conversations || data || [];
|
|
190
|
+
console.log(`โ
Conversations API works: ${Array.isArray(conversations) ? conversations.length : 'unknown'} conversations`);
|
|
191
|
+
return true;
|
|
192
|
+
} else {
|
|
193
|
+
console.log(`โ Conversations API returned ${response.status}`);
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
} catch (error) {
|
|
197
|
+
console.log(`โ Conversations API error: ${error.message}`);
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
async function checkServerHealth() {
|
|
203
|
+
console.log('๐ฅ Checking server health...');
|
|
204
|
+
try {
|
|
205
|
+
const response = await fetch(`${BASE_URL}/api/health`, {
|
|
206
|
+
method: 'GET',
|
|
207
|
+
signal: AbortSignal.timeout(5000)
|
|
208
|
+
});
|
|
209
|
+
if (response.ok) {
|
|
210
|
+
console.log('โ
Server is healthy');
|
|
211
|
+
return true;
|
|
212
|
+
} else {
|
|
213
|
+
console.log(`โ Health check failed: ${response.status}`);
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
} catch (error) {
|
|
217
|
+
console.log(`โ Server not reachable: ${error.message}`);
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
async function main() {
|
|
223
|
+
console.log('๐งช Cortex Memory API Route Tests');
|
|
224
|
+
console.log(`๐ Testing server at: ${BASE_URL}`);
|
|
225
|
+
console.log(`๐ค Test user: ${TEST_USER_ID}`);
|
|
226
|
+
console.log(`๐ฆ Memory space: ${TEST_MEMORY_SPACE_ID}`);
|
|
227
|
+
|
|
228
|
+
// Check server health first
|
|
229
|
+
const healthy = await checkServerHealth();
|
|
230
|
+
if (!healthy) {
|
|
231
|
+
console.log('\nโ Server is not running. Please start the quickstart first:');
|
|
232
|
+
console.log(' cd packages/vercel-ai-provider/quickstart && npm run dev');
|
|
233
|
+
process.exit(1);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const results = [];
|
|
237
|
+
|
|
238
|
+
// Test conversation API
|
|
239
|
+
await testConversationAPI();
|
|
240
|
+
|
|
241
|
+
// Test v5 route
|
|
242
|
+
const v5Result = await testRoute('/api/chat', 'V5 Route');
|
|
243
|
+
results.push(v5Result);
|
|
244
|
+
|
|
245
|
+
// Test v6 route
|
|
246
|
+
const v6Result = await testRoute('/api/chat-v6', 'V6 Route');
|
|
247
|
+
results.push(v6Result);
|
|
248
|
+
|
|
249
|
+
// Summary
|
|
250
|
+
console.log(`\n${'='.repeat(60)}`);
|
|
251
|
+
console.log('๐ Test Summary');
|
|
252
|
+
console.log('='.repeat(60));
|
|
253
|
+
|
|
254
|
+
let allPassed = true;
|
|
255
|
+
for (const result of results) {
|
|
256
|
+
const status = result.success ? 'โ
PASS' : 'โ FAIL';
|
|
257
|
+
const recall = result.recallWorks !== undefined
|
|
258
|
+
? (result.recallWorks ? ' (recall โ
)' : ' (recall โ)')
|
|
259
|
+
: '';
|
|
260
|
+
const error = result.error ? ` - ${result.error}` : '';
|
|
261
|
+
console.log(`${status} ${result.route}${recall}${error}`);
|
|
262
|
+
if (!result.success) allPassed = false;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
console.log('');
|
|
266
|
+
process.exit(allPassed ? 0 : 1);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
main().catch(error => {
|
|
270
|
+
console.error('Test runner error:', error);
|
|
271
|
+
process.exit(1);
|
|
272
|
+
});
|