@duckmind/deepquark-darwin-arm64 0.9.83 โ 0.9.90
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/.deepquark/skills/bundled/knowledge-graph/SKILL.md +385 -0
- package/.deepquark/skills/bundled/knowledge-graph/STANDARDS.md +461 -0
- package/.deepquark/skills/bundled/knowledge-graph/lib/cli.ts +588 -0
- package/.deepquark/skills/bundled/knowledge-graph/lib/config.ts +630 -0
- package/.deepquark/skills/bundled/knowledge-graph/lib/connection-profile.ts +629 -0
- package/.deepquark/skills/bundled/knowledge-graph/lib/container.ts +756 -0
- package/.deepquark/skills/bundled/knowledge-graph/lib/mcp-client.ts +1310 -0
- package/.deepquark/skills/bundled/knowledge-graph/lib/output-formatter.ts +997 -0
- package/.deepquark/skills/bundled/knowledge-graph/lib/token-metrics.ts +335 -0
- package/.deepquark/skills/bundled/knowledge-graph/lib/transformation-log.ts +137 -0
- package/.deepquark/skills/bundled/knowledge-graph/lib/wrapper-config.ts +113 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/.env.example +129 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/compare-embeddings.ts +175 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/config-falkordb.yaml +108 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/config-neo4j.yaml +111 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/diagnose.ts +483 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/docker-compose-falkordb-dev.yml +146 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/docker-compose-falkordb.yml +151 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/docker-compose-neo4j-dev-local.yml +161 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/docker-compose-neo4j-dev.yml +161 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/docker-compose-neo4j.yml +169 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/docker-compose-production.yml +128 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/docker-compose-test.yml +10 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/docker-compose.yml +84 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/entrypoint.sh +40 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/install.ts +2054 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/podman-compose-falkordb.yml +78 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/podman-compose-neo4j.yml +88 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/podman-compose.yml +83 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/test-all-llms-mcp.ts +387 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/test-embedding-models.ts +201 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/test-embedding-providers.ts +641 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/test-graphiti-model.ts +217 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/test-grok-correct.ts +141 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/test-grok-llms-mcp.ts +386 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/test-grok-models.ts +173 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/test-llama-extraction.ts +188 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/test-mcp-final.ts +240 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/test-mcp-live.ts +187 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/test-mcp-session.ts +127 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/test-model-combinations.ts +316 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/test-ollama-models.ts +228 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/test-openrouter-models.ts +460 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/test-real-life-mcp.ts +311 -0
- package/.deepquark/skills/bundled/knowledge-graph/server/test-search-debug.ts +199 -0
- package/.deepquark/skills/bundled/knowledge-graph/tools/Install.md +104 -0
- package/.deepquark/skills/bundled/knowledge-graph/tools/README.md +120 -0
- package/.deepquark/skills/bundled/knowledge-graph/tools/knowledge-cli.ts +996 -0
- package/.deepquark/skills/bundled/knowledge-graph/tools/server-cli.ts +531 -0
- package/.deepquark/skills/bundled/knowledge-graph/workflows/BulkImport.md +514 -0
- package/.deepquark/skills/bundled/knowledge-graph/workflows/CaptureEpisode.md +242 -0
- package/.deepquark/skills/bundled/knowledge-graph/workflows/ClearGraph.md +392 -0
- package/.deepquark/skills/bundled/knowledge-graph/workflows/GetRecent.md +352 -0
- package/.deepquark/skills/bundled/knowledge-graph/workflows/GetStatus.md +373 -0
- package/.deepquark/skills/bundled/knowledge-graph/workflows/HealthReport.md +212 -0
- package/.deepquark/skills/bundled/knowledge-graph/workflows/InvestigateEntity.md +142 -0
- package/.deepquark/skills/bundled/knowledge-graph/workflows/OntologyManagement.md +201 -0
- package/.deepquark/skills/bundled/knowledge-graph/workflows/RunMaintenance.md +302 -0
- package/.deepquark/skills/bundled/knowledge-graph/workflows/SearchByDate.md +255 -0
- package/.deepquark/skills/bundled/knowledge-graph/workflows/SearchFacts.md +382 -0
- package/.deepquark/skills/bundled/knowledge-graph/workflows/SearchKnowledge.md +374 -0
- package/.deepquark/skills/bundled/knowledge-graph/workflows/StixImport.md +212 -0
- package/bin/deepquark +0 -0
- package/package.json +1 -1
- package/.deepquark/skills/bundled/ge-payroll/SKILL.md +0 -153
- package/.deepquark/skills/bundled/ge-payroll/evals/evals.json +0 -23
- package/.deepquark/skills/bundled/ge-payroll/references/pain-points-improvements.md +0 -106
- package/.deepquark/skills/bundled/ge-payroll/references/process-detail.md +0 -217
- package/.deepquark/skills/bundled/ge-payroll/references/raci-stakeholders.md +0 -85
- package/.deepquark/skills/bundled/ge-payroll/references/timeline-mandays.md +0 -64
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* Test Llama 3.1 8B entity extraction via MCP
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const MCP_URL = 'http://localhost:8000/mcp';
|
|
7
|
+
const ACCEPT = 'application/json, text/event-stream';
|
|
8
|
+
|
|
9
|
+
let sessionId: string | null = null;
|
|
10
|
+
|
|
11
|
+
async function mcpRequest(method: string, params: any = {}): Promise<any> {
|
|
12
|
+
const headers: Record<string, string> = {
|
|
13
|
+
'Content-Type': 'application/json',
|
|
14
|
+
Accept: ACCEPT,
|
|
15
|
+
};
|
|
16
|
+
if (sessionId) headers['mcp-session-id'] = sessionId;
|
|
17
|
+
|
|
18
|
+
const res = await fetch(MCP_URL, {
|
|
19
|
+
method: 'POST',
|
|
20
|
+
headers,
|
|
21
|
+
body: JSON.stringify({ jsonrpc: '2.0', id: Date.now(), method, params }),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const newSessionId = res.headers.get('mcp-session-id');
|
|
25
|
+
if (newSessionId) sessionId = newSessionId;
|
|
26
|
+
|
|
27
|
+
const text = await res.text();
|
|
28
|
+
let result: any = null;
|
|
29
|
+
let error: any = null;
|
|
30
|
+
|
|
31
|
+
for (const line of text.split('\n')) {
|
|
32
|
+
if (line.startsWith('data: ')) {
|
|
33
|
+
try {
|
|
34
|
+
const data = JSON.parse(line.slice(6));
|
|
35
|
+
if (data.result) result = data.result;
|
|
36
|
+
if (data.error) error = data.error;
|
|
37
|
+
} catch {}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!result && !error) {
|
|
42
|
+
try {
|
|
43
|
+
const json = JSON.parse(text);
|
|
44
|
+
result = json.result;
|
|
45
|
+
error = json.error;
|
|
46
|
+
} catch {}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return { result, error, raw: text };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async function callTool(
|
|
53
|
+
name: string,
|
|
54
|
+
args: any
|
|
55
|
+
): Promise<{ success: boolean; data: any; duration: number }> {
|
|
56
|
+
const start = Date.now();
|
|
57
|
+
const { result, error } = await mcpRequest('tools/call', { name, arguments: args });
|
|
58
|
+
const duration = Date.now() - start;
|
|
59
|
+
|
|
60
|
+
if (error) return { success: false, data: error, duration };
|
|
61
|
+
|
|
62
|
+
let data: any = result;
|
|
63
|
+
try {
|
|
64
|
+
if (result?.content?.[0]?.text) {
|
|
65
|
+
data = JSON.parse(result.content[0].text);
|
|
66
|
+
}
|
|
67
|
+
} catch {}
|
|
68
|
+
|
|
69
|
+
return { success: true, data, duration };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const TEST_EPISODE = {
|
|
73
|
+
name: 'Llama Test Episode',
|
|
74
|
+
body: 'During the Q4 planning meeting, CEO Michael Chen announced that TechVentures Inc will acquire DataFlow Systems for $500 million. The deal, brokered by Goldman Sachs, includes all patents and the 200-person engineering team based in Seattle.',
|
|
75
|
+
group: 'llama-test',
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
async function main() {
|
|
79
|
+
console.log('โ'.repeat(60));
|
|
80
|
+
console.log('๐ฆ Llama 3.1 8B Entity Extraction Test');
|
|
81
|
+
console.log('โ'.repeat(60));
|
|
82
|
+
|
|
83
|
+
// Health check
|
|
84
|
+
const health = await fetch('http://localhost:8000/health').then((r) => r.json());
|
|
85
|
+
console.log(`\n๐ Server: ${health.status}`);
|
|
86
|
+
|
|
87
|
+
// Initialize session
|
|
88
|
+
console.log('\n๐ Initializing MCP session...');
|
|
89
|
+
await mcpRequest('initialize', {
|
|
90
|
+
protocolVersion: '2024-11-05',
|
|
91
|
+
capabilities: {},
|
|
92
|
+
clientInfo: { name: 'llama-test', version: '1.0' },
|
|
93
|
+
});
|
|
94
|
+
await mcpRequest('notifications/initialized', {});
|
|
95
|
+
console.log(` Session: ${sessionId}`);
|
|
96
|
+
|
|
97
|
+
// Test add_memory
|
|
98
|
+
console.log(`\n${'โ'.repeat(60)}`);
|
|
99
|
+
console.log('๐ฅ ADD_MEMORY Test');
|
|
100
|
+
console.log('โ'.repeat(60));
|
|
101
|
+
console.log(`\nInput: "${TEST_EPISODE.body}"`);
|
|
102
|
+
|
|
103
|
+
const _addStart = Date.now();
|
|
104
|
+
const addRes = await callTool('add_memory', {
|
|
105
|
+
name: TEST_EPISODE.name,
|
|
106
|
+
episode_body: TEST_EPISODE.body,
|
|
107
|
+
source: 'text',
|
|
108
|
+
group_id: TEST_EPISODE.group,
|
|
109
|
+
});
|
|
110
|
+
console.log(`\n${addRes.success ? 'โ
' : 'โ'} add_memory (${addRes.duration}ms)`);
|
|
111
|
+
|
|
112
|
+
// Wait for async processing
|
|
113
|
+
console.log('\nโณ Waiting 15s for entity extraction...');
|
|
114
|
+
await Bun.sleep(15000);
|
|
115
|
+
|
|
116
|
+
// Check extracted entities
|
|
117
|
+
console.log(`\n${'โ'.repeat(60)}`);
|
|
118
|
+
console.log('๐ SEARCH_NODES Test (checking extracted entities)');
|
|
119
|
+
console.log('โ'.repeat(60));
|
|
120
|
+
|
|
121
|
+
const queries = ['TechVentures', 'Michael Chen', 'DataFlow', 'Goldman Sachs', 'Seattle'];
|
|
122
|
+
let found = 0;
|
|
123
|
+
|
|
124
|
+
for (const q of queries) {
|
|
125
|
+
const res = await callTool('search_nodes', {
|
|
126
|
+
query: q,
|
|
127
|
+
group_ids: ['llama-test'],
|
|
128
|
+
max_nodes: 5,
|
|
129
|
+
});
|
|
130
|
+
const nodes = res.data?.nodes || [];
|
|
131
|
+
const match = nodes.find((n: any) => n.name?.toLowerCase().includes(q.toLowerCase()));
|
|
132
|
+
|
|
133
|
+
if (match) {
|
|
134
|
+
console.log(` โ
"${q}" โ Found: ${match.name}`);
|
|
135
|
+
found++;
|
|
136
|
+
} else {
|
|
137
|
+
console.log(` โ ๏ธ "${q}" โ Not found (${nodes.length} nodes returned)`);
|
|
138
|
+
}
|
|
139
|
+
await Bun.sleep(300);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Check facts
|
|
143
|
+
console.log(`\n${'โ'.repeat(60)}`);
|
|
144
|
+
console.log('๐ SEARCH_FACTS Test');
|
|
145
|
+
console.log('โ'.repeat(60));
|
|
146
|
+
|
|
147
|
+
const factsRes = await callTool('search_memory_facts', {
|
|
148
|
+
query: 'acquisition deal',
|
|
149
|
+
group_ids: ['llama-test'],
|
|
150
|
+
max_facts: 10,
|
|
151
|
+
});
|
|
152
|
+
const facts = factsRes.data?.facts || [];
|
|
153
|
+
console.log(`\nFound ${facts.length} facts:`);
|
|
154
|
+
facts.slice(0, 5).forEach((f: any) => console.log(` โข ${f.fact?.slice(0, 80)}...`));
|
|
155
|
+
|
|
156
|
+
// Summary
|
|
157
|
+
console.log(`\n${'โ'.repeat(60)}`);
|
|
158
|
+
console.log('๐ RESULTS');
|
|
159
|
+
console.log('โ'.repeat(60));
|
|
160
|
+
console.log(`
|
|
161
|
+
Model: Llama 3.1 8B via OpenRouter
|
|
162
|
+
Cost: $0.0145/1K calls (9x cheaper than GPT-4o-mini)
|
|
163
|
+
|
|
164
|
+
Entity Extraction: ${found}/${queries.length} expected entities found
|
|
165
|
+
Facts Extracted: ${facts.length}
|
|
166
|
+
|
|
167
|
+
${found >= 3 ? 'โ
PASS - Llama 3.1 8B works for entity extraction!' : 'โ ๏ธ Some entities not found - may need longer processing time'}
|
|
168
|
+
`);
|
|
169
|
+
|
|
170
|
+
// Save results
|
|
171
|
+
await Bun.write(
|
|
172
|
+
'llama-test-results.json',
|
|
173
|
+
JSON.stringify(
|
|
174
|
+
{
|
|
175
|
+
model: 'meta-llama/llama-3.1-8b-instruct',
|
|
176
|
+
provider: 'openrouter',
|
|
177
|
+
entitiesFound: found,
|
|
178
|
+
totalExpected: queries.length,
|
|
179
|
+
factsFound: facts.length,
|
|
180
|
+
timestamp: new Date().toISOString(),
|
|
181
|
+
},
|
|
182
|
+
null,
|
|
183
|
+
2
|
|
184
|
+
)
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
main().catch(console.error);
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* MCP Knowledge System Test - Final version with correct protocol
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const MCP_URL = 'http://localhost:8000/mcp';
|
|
7
|
+
const ACCEPT = 'application/json, text/event-stream';
|
|
8
|
+
|
|
9
|
+
let sessionId: string | null = null;
|
|
10
|
+
|
|
11
|
+
async function mcpRequest(method: string, params: any = {}): Promise<any> {
|
|
12
|
+
const headers: Record<string, string> = {
|
|
13
|
+
'Content-Type': 'application/json',
|
|
14
|
+
Accept: ACCEPT,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
if (sessionId) {
|
|
18
|
+
headers['mcp-session-id'] = sessionId;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const res = await fetch(MCP_URL, {
|
|
22
|
+
method: 'POST',
|
|
23
|
+
headers,
|
|
24
|
+
body: JSON.stringify({
|
|
25
|
+
jsonrpc: '2.0',
|
|
26
|
+
id: Date.now(),
|
|
27
|
+
method,
|
|
28
|
+
params,
|
|
29
|
+
}),
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Capture session ID from response
|
|
33
|
+
const newSessionId = res.headers.get('mcp-session-id');
|
|
34
|
+
if (newSessionId) sessionId = newSessionId;
|
|
35
|
+
|
|
36
|
+
const text = await res.text();
|
|
37
|
+
|
|
38
|
+
// Parse SSE or JSON response
|
|
39
|
+
let result: any = null;
|
|
40
|
+
let error: any = null;
|
|
41
|
+
|
|
42
|
+
for (const line of text.split('\n')) {
|
|
43
|
+
if (line.startsWith('data: ')) {
|
|
44
|
+
try {
|
|
45
|
+
const data = JSON.parse(line.slice(6));
|
|
46
|
+
if (data.result) result = data.result;
|
|
47
|
+
if (data.error) error = data.error;
|
|
48
|
+
} catch {}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Fallback to direct JSON
|
|
53
|
+
if (!result && !error) {
|
|
54
|
+
try {
|
|
55
|
+
const json = JSON.parse(text);
|
|
56
|
+
result = json.result;
|
|
57
|
+
error = json.error;
|
|
58
|
+
} catch {}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return { result, error, raw: text };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function callTool(
|
|
65
|
+
name: string,
|
|
66
|
+
args: any
|
|
67
|
+
): Promise<{ success: boolean; data: any; duration: number }> {
|
|
68
|
+
const start = Date.now();
|
|
69
|
+
const { result, error } = await mcpRequest('tools/call', { name, arguments: args });
|
|
70
|
+
const duration = Date.now() - start;
|
|
71
|
+
|
|
72
|
+
if (error) {
|
|
73
|
+
return { success: false, data: error, duration };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Parse tool result content
|
|
77
|
+
let data: any = result;
|
|
78
|
+
try {
|
|
79
|
+
if (result?.content?.[0]?.text) {
|
|
80
|
+
data = JSON.parse(result.content[0].text);
|
|
81
|
+
}
|
|
82
|
+
} catch {}
|
|
83
|
+
|
|
84
|
+
return { success: true, data, duration };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const TEST_EPISODES = [
|
|
88
|
+
{
|
|
89
|
+
name: 'Tech Stack',
|
|
90
|
+
body: 'Team uses TypeScript with Bun. Sarah chose Hono for HTTP framework.',
|
|
91
|
+
group: 'mcp-test',
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: 'Partnership',
|
|
95
|
+
body: 'John Smith from Acme Corp met CTO Alice Chen about payment API integration.',
|
|
96
|
+
group: 'mcp-test',
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: 'PAI System',
|
|
100
|
+
body: 'PAI uses Neo4j graph database. GPT-4o-mini for extraction. Ollama for embeddings.',
|
|
101
|
+
group: 'mcp-test',
|
|
102
|
+
},
|
|
103
|
+
];
|
|
104
|
+
|
|
105
|
+
async function main() {
|
|
106
|
+
console.log('โ'.repeat(60));
|
|
107
|
+
console.log('๐งช MCP Knowledge System - Real Life Tests');
|
|
108
|
+
console.log('โ'.repeat(60));
|
|
109
|
+
|
|
110
|
+
// Health check
|
|
111
|
+
const health = await fetch('http://localhost:8000/health').then((r) => r.json());
|
|
112
|
+
console.log(`\n๐ Server: ${health.status} | Patch: ${health.patch}`);
|
|
113
|
+
|
|
114
|
+
// Initialize session
|
|
115
|
+
console.log('\n๐ Initializing MCP session...');
|
|
116
|
+
const initRes = await mcpRequest('initialize', {
|
|
117
|
+
protocolVersion: '2024-11-05',
|
|
118
|
+
capabilities: {},
|
|
119
|
+
clientInfo: { name: 'bun-test', version: '1.0' },
|
|
120
|
+
});
|
|
121
|
+
console.log(` Session: ${sessionId}`);
|
|
122
|
+
if (initRes.error) {
|
|
123
|
+
console.log(` Error: ${initRes.error.message}`);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Send initialized notification
|
|
127
|
+
await mcpRequest('notifications/initialized', {});
|
|
128
|
+
|
|
129
|
+
const results: any[] = [];
|
|
130
|
+
|
|
131
|
+
// ADD_MEMORY Tests
|
|
132
|
+
console.log(`\n${'โ'.repeat(60)}`);
|
|
133
|
+
console.log('๐ฅ ADD_MEMORY Tests (using gpt-4o-mini for entity extraction)');
|
|
134
|
+
console.log('โ'.repeat(60));
|
|
135
|
+
|
|
136
|
+
for (const ep of TEST_EPISODES) {
|
|
137
|
+
const res = await callTool('add_memory', {
|
|
138
|
+
name: ep.name,
|
|
139
|
+
episode_body: ep.body,
|
|
140
|
+
source: 'text',
|
|
141
|
+
group_id: ep.group,
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
const icon = res.success ? 'โ
' : 'โ';
|
|
145
|
+
console.log(`${icon} ${ep.name} (${res.duration}ms)`);
|
|
146
|
+
if (!res.success) console.log(` Error: ${JSON.stringify(res.data).slice(0, 100)}`);
|
|
147
|
+
|
|
148
|
+
results.push({ op: 'add_memory', name: ep.name, success: res.success, duration: res.duration });
|
|
149
|
+
await Bun.sleep(3000); // Wait for async graph processing
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// SEARCH_NODES Tests
|
|
153
|
+
console.log(`\n${'โ'.repeat(60)}`);
|
|
154
|
+
console.log('๐ SEARCH_NODES Tests (semantic search via embeddings)');
|
|
155
|
+
console.log('โ'.repeat(60));
|
|
156
|
+
|
|
157
|
+
const nodeQueries = ['TypeScript Bun framework', 'Acme Corp partnership', 'PAI graph database'];
|
|
158
|
+
for (const q of nodeQueries) {
|
|
159
|
+
const res = await callTool('search_nodes', { query: q, group_ids: ['mcp-test'], max_nodes: 5 });
|
|
160
|
+
const nodes = res.data?.nodes || [];
|
|
161
|
+
|
|
162
|
+
const icon = nodes.length > 0 ? 'โ
' : 'โ ๏ธ';
|
|
163
|
+
console.log(`${icon} "${q}" โ ${nodes.length} nodes (${res.duration}ms)`);
|
|
164
|
+
nodes.slice(0, 3).forEach((n: any) => console.log(` โข ${n.name} (${n.entity_type})`));
|
|
165
|
+
|
|
166
|
+
results.push({
|
|
167
|
+
op: 'search_nodes',
|
|
168
|
+
query: q,
|
|
169
|
+
success: nodes.length > 0,
|
|
170
|
+
nodes: nodes.length,
|
|
171
|
+
duration: res.duration,
|
|
172
|
+
});
|
|
173
|
+
await Bun.sleep(500);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// SEARCH_MEMORY_FACTS Tests
|
|
177
|
+
console.log(`\n${'โ'.repeat(60)}`);
|
|
178
|
+
console.log('๐ SEARCH_MEMORY_FACTS Tests (relationship queries)');
|
|
179
|
+
console.log('โ'.repeat(60));
|
|
180
|
+
|
|
181
|
+
const factQueries = ['technology decisions', 'company partnerships', 'database systems'];
|
|
182
|
+
for (const q of factQueries) {
|
|
183
|
+
const res = await callTool('search_memory_facts', {
|
|
184
|
+
query: q,
|
|
185
|
+
group_ids: ['mcp-test'],
|
|
186
|
+
max_facts: 5,
|
|
187
|
+
});
|
|
188
|
+
const facts = res.data?.facts || [];
|
|
189
|
+
|
|
190
|
+
const icon = facts.length > 0 ? 'โ
' : 'โ ๏ธ';
|
|
191
|
+
console.log(`${icon} "${q}" โ ${facts.length} facts (${res.duration}ms)`);
|
|
192
|
+
facts.slice(0, 2).forEach((f: any) => console.log(` โข ${f.fact?.slice(0, 70)}...`));
|
|
193
|
+
|
|
194
|
+
results.push({
|
|
195
|
+
op: 'search_memory_facts',
|
|
196
|
+
query: q,
|
|
197
|
+
success: facts.length > 0,
|
|
198
|
+
facts: facts.length,
|
|
199
|
+
duration: res.duration,
|
|
200
|
+
});
|
|
201
|
+
await Bun.sleep(500);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Summary
|
|
205
|
+
console.log(`\n${'โ'.repeat(60)}`);
|
|
206
|
+
console.log('๐ RESULTS SUMMARY');
|
|
207
|
+
console.log('โ'.repeat(60));
|
|
208
|
+
|
|
209
|
+
const ops = ['add_memory', 'search_nodes', 'search_memory_facts'];
|
|
210
|
+
console.log('\n| Operation | Success | Avg Time | Notes |');
|
|
211
|
+
console.log('|---------------------|---------|----------|----------------|');
|
|
212
|
+
|
|
213
|
+
for (const op of ops) {
|
|
214
|
+
const opRes = results.filter((r) => r.op === op);
|
|
215
|
+
const success = opRes.filter((r) => r.success).length;
|
|
216
|
+
const avgMs = Math.round(opRes.reduce((a, r) => a + r.duration, 0) / opRes.length);
|
|
217
|
+
const notes = op === 'add_memory' ? 'gpt-4o-mini' : 'embeddings';
|
|
218
|
+
console.log(
|
|
219
|
+
`| ${op.padEnd(19)} | ${success}/${opRes.length} | ${String(avgMs).padStart(6)}ms | ${notes.padEnd(14)} |`
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Save results
|
|
224
|
+
await Bun.write(
|
|
225
|
+
'mcp-final-results.json',
|
|
226
|
+
JSON.stringify(
|
|
227
|
+
{
|
|
228
|
+
results,
|
|
229
|
+
config: { llm: 'gpt-4o-mini', embedder: 'openai', database: 'neo4j' },
|
|
230
|
+
timestamp: new Date().toISOString(),
|
|
231
|
+
},
|
|
232
|
+
null,
|
|
233
|
+
2
|
|
234
|
+
)
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
console.log('\n๐ Results saved to mcp-final-results.json');
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
main().catch(console.error);
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* Real-life MCP Knowledge System Test
|
|
4
|
+
* Uses proper SSE/streaming protocol for MCP communication
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const MCP_URL = 'http://localhost:8000/mcp';
|
|
8
|
+
|
|
9
|
+
interface MCPResult {
|
|
10
|
+
success: boolean;
|
|
11
|
+
duration: number;
|
|
12
|
+
data?: any;
|
|
13
|
+
error?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Test data
|
|
17
|
+
const TEST_EPISODES = [
|
|
18
|
+
{
|
|
19
|
+
name: 'Tech Stack Decision',
|
|
20
|
+
body: 'The team decided to use TypeScript with Bun runtime for the new API project. Sarah recommended Hono for the HTTP framework.',
|
|
21
|
+
group_id: 'mcp-test',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'Meeting Notes',
|
|
25
|
+
body: "John Smith from Acme Corp met with CTO Alice Chen to discuss partnership for integrating Acme's payment API.",
|
|
26
|
+
group_id: 'mcp-test',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'PAI Documentation',
|
|
30
|
+
body: 'The PAI system uses Neo4j as graph database. OpenAI gpt-4o-mini handles entity extraction. Ollama mxbai-embed-large does embeddings.',
|
|
31
|
+
group_id: 'mcp-test',
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
async function callMCP(method: string, params: any): Promise<MCPResult> {
|
|
36
|
+
const start = Date.now();
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
const response = await fetch(MCP_URL, {
|
|
40
|
+
method: 'POST',
|
|
41
|
+
headers: {
|
|
42
|
+
'Content-Type': 'application/json',
|
|
43
|
+
Accept: 'application/json, text/event-stream',
|
|
44
|
+
},
|
|
45
|
+
body: JSON.stringify({
|
|
46
|
+
jsonrpc: '2.0',
|
|
47
|
+
id: Date.now(),
|
|
48
|
+
method,
|
|
49
|
+
params,
|
|
50
|
+
}),
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const text = await response.text();
|
|
54
|
+
const duration = Date.now() - start;
|
|
55
|
+
|
|
56
|
+
// Parse response - could be JSON or SSE
|
|
57
|
+
let result: any = null;
|
|
58
|
+
let error: string | undefined;
|
|
59
|
+
|
|
60
|
+
// Try direct JSON first
|
|
61
|
+
try {
|
|
62
|
+
const json = JSON.parse(text);
|
|
63
|
+
if (json.result) result = json.result;
|
|
64
|
+
if (json.error) error = json.error.message;
|
|
65
|
+
} catch {
|
|
66
|
+
// Try SSE format
|
|
67
|
+
for (const line of text.split('\n')) {
|
|
68
|
+
if (line.startsWith('data: ')) {
|
|
69
|
+
try {
|
|
70
|
+
const data = JSON.parse(line.slice(6));
|
|
71
|
+
if (data.result) result = data.result;
|
|
72
|
+
if (data.error) error = data.error.message;
|
|
73
|
+
} catch {}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return { success: !error && result !== null, duration, data: result, error };
|
|
79
|
+
} catch (e: any) {
|
|
80
|
+
return { success: false, duration: Date.now() - start, error: e.message };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function main() {
|
|
85
|
+
console.log('โ'.repeat(60));
|
|
86
|
+
console.log('๐งช MCP Knowledge System Real-Life Test');
|
|
87
|
+
console.log('โ'.repeat(60));
|
|
88
|
+
|
|
89
|
+
// Health check
|
|
90
|
+
const health = await fetch('http://localhost:8000/health').then((r) => r.json());
|
|
91
|
+
console.log(`\n๐ Health: ${health.status} | LLM: gpt-4o-mini | DB: neo4j`);
|
|
92
|
+
|
|
93
|
+
const results: any[] = [];
|
|
94
|
+
|
|
95
|
+
// Test add_memory
|
|
96
|
+
console.log(`\n${'โ'.repeat(60)}`);
|
|
97
|
+
console.log('๐ฅ ADD_MEMORY Tests');
|
|
98
|
+
console.log('โ'.repeat(60));
|
|
99
|
+
|
|
100
|
+
for (const ep of TEST_EPISODES) {
|
|
101
|
+
const res = await callMCP('tools/call', {
|
|
102
|
+
name: 'add_memory',
|
|
103
|
+
arguments: { name: ep.name, episode_body: ep.body, source: 'text', group_id: ep.group_id },
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
console.log(`${res.success ? 'โ
' : 'โ'} ${ep.name} (${res.duration}ms)`);
|
|
107
|
+
if (res.error) console.log(` Error: ${res.error}`);
|
|
108
|
+
|
|
109
|
+
results.push({ op: 'add_memory', name: ep.name, ...res });
|
|
110
|
+
await Bun.sleep(3000); // Wait for processing
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Test search_nodes
|
|
114
|
+
console.log(`\n${'โ'.repeat(60)}`);
|
|
115
|
+
console.log('๐ SEARCH_NODES Tests');
|
|
116
|
+
console.log('โ'.repeat(60));
|
|
117
|
+
|
|
118
|
+
const nodeQueries = ['TypeScript Bun', 'Acme Corp partnership', 'Neo4j PAI'];
|
|
119
|
+
for (const q of nodeQueries) {
|
|
120
|
+
const res = await callMCP('tools/call', {
|
|
121
|
+
name: 'search_nodes',
|
|
122
|
+
arguments: { query: q, group_ids: ['mcp-test'], max_nodes: 5 },
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
let nodes: any[] = [];
|
|
126
|
+
try {
|
|
127
|
+
const content = res.data?.content?.[0]?.text;
|
|
128
|
+
if (content) nodes = JSON.parse(content).nodes || [];
|
|
129
|
+
} catch {}
|
|
130
|
+
|
|
131
|
+
console.log(
|
|
132
|
+
`${nodes.length > 0 ? 'โ
' : 'โ ๏ธ'} "${q}" โ ${nodes.length} nodes (${res.duration}ms)`
|
|
133
|
+
);
|
|
134
|
+
nodes.slice(0, 2).forEach((n) => console.log(` โข ${n.name} (${n.entity_type})`));
|
|
135
|
+
|
|
136
|
+
results.push({ op: 'search_nodes', query: q, nodes: nodes.length, ...res });
|
|
137
|
+
await Bun.sleep(500);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Test search_memory_facts
|
|
141
|
+
console.log(`\n${'โ'.repeat(60)}`);
|
|
142
|
+
console.log('๐ SEARCH_MEMORY_FACTS Tests');
|
|
143
|
+
console.log('โ'.repeat(60));
|
|
144
|
+
|
|
145
|
+
const factQueries = ['technology decisions', 'company partnerships', 'database systems'];
|
|
146
|
+
for (const q of factQueries) {
|
|
147
|
+
const res = await callMCP('tools/call', {
|
|
148
|
+
name: 'search_memory_facts',
|
|
149
|
+
arguments: { query: q, group_ids: ['mcp-test'], max_facts: 5 },
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
let facts: any[] = [];
|
|
153
|
+
try {
|
|
154
|
+
const content = res.data?.content?.[0]?.text;
|
|
155
|
+
if (content) facts = JSON.parse(content).facts || [];
|
|
156
|
+
} catch {}
|
|
157
|
+
|
|
158
|
+
console.log(
|
|
159
|
+
`${facts.length > 0 ? 'โ
' : 'โ ๏ธ'} "${q}" โ ${facts.length} facts (${res.duration}ms)`
|
|
160
|
+
);
|
|
161
|
+
facts.slice(0, 2).forEach((f) => console.log(` โข ${f.fact?.slice(0, 70)}...`));
|
|
162
|
+
|
|
163
|
+
results.push({ op: 'search_memory_facts', query: q, facts: facts.length, ...res });
|
|
164
|
+
await Bun.sleep(500);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Summary
|
|
168
|
+
console.log(`\n${'โ'.repeat(60)}`);
|
|
169
|
+
console.log('๐ SUMMARY');
|
|
170
|
+
console.log('โ'.repeat(60));
|
|
171
|
+
|
|
172
|
+
const ops = ['add_memory', 'search_nodes', 'search_memory_facts'];
|
|
173
|
+
for (const op of ops) {
|
|
174
|
+
const opResults = results.filter((r) => r.op === op);
|
|
175
|
+
const success = opResults.filter((r) => r.success).length;
|
|
176
|
+
const avgMs = Math.round(opResults.reduce((a, r) => a + r.duration, 0) / opResults.length);
|
|
177
|
+
console.log(`${op.padEnd(20)} ${success}/${opResults.length} passed | avg ${avgMs}ms`);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
await Bun.write(
|
|
181
|
+
'mcp-live-results.json',
|
|
182
|
+
JSON.stringify({ results, timestamp: new Date().toISOString() }, null, 2)
|
|
183
|
+
);
|
|
184
|
+
console.log('\n๐ Saved to mcp-live-results.json');
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
main();
|