270 lines
6.9 KiB
JavaScript
Executable File
270 lines
6.9 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
||
|
||
/**
|
||
* AgentDB 2.0.0-alpha.2.11 Verification Script
|
||
*
|
||
* This script verifies all key features of the published package:
|
||
* - All 5 RuVector packages installation
|
||
* - All 5 attention mechanisms
|
||
* - Vector search functionality
|
||
* - GNN (Graph Neural Networks)
|
||
* - Graph database with Cypher queries
|
||
*/
|
||
|
||
const AgentDB = require('agentdb');
|
||
|
||
console.log('🔍 AgentDB Package Verification\n');
|
||
console.log('=' .repeat(60));
|
||
|
||
// Test Results Tracker
|
||
const results = {
|
||
passed: [],
|
||
failed: [],
|
||
warnings: []
|
||
};
|
||
|
||
function pass(test) {
|
||
console.log(`✅ ${test}`);
|
||
results.passed.push(test);
|
||
}
|
||
|
||
function fail(test, error) {
|
||
console.log(`❌ ${test}`);
|
||
console.log(` Error: ${error.message}`);
|
||
results.failed.push({ test, error: error.message });
|
||
}
|
||
|
||
function warn(message) {
|
||
console.log(`⚠️ ${message}`);
|
||
results.warnings.push(message);
|
||
}
|
||
|
||
async function verifyPackageStructure() {
|
||
console.log('\n📦 Package Structure Verification\n');
|
||
|
||
try {
|
||
// Verify AgentDB main module
|
||
if (typeof AgentDB === 'object' || typeof AgentDB === 'function') {
|
||
pass('AgentDB module loaded');
|
||
} else {
|
||
throw new Error('AgentDB module not properly exported');
|
||
}
|
||
|
||
// Verify RuVector packages are accessible
|
||
const packages = [
|
||
'@ruvector/attention',
|
||
'@ruvector/gnn',
|
||
'@ruvector/graph-node',
|
||
'@ruvector/router',
|
||
'ruvector'
|
||
];
|
||
|
||
for (const pkg of packages) {
|
||
try {
|
||
const module = require(pkg);
|
||
pass(`${pkg} accessible`);
|
||
} catch (err) {
|
||
fail(`${pkg} accessible`, err);
|
||
}
|
||
}
|
||
|
||
} catch (error) {
|
||
fail('Package structure verification', error);
|
||
}
|
||
}
|
||
|
||
async function verifyAttentionMechanisms() {
|
||
console.log('\n🧠 Attention Mechanisms Verification\n');
|
||
|
||
try {
|
||
const attention = require('@ruvector/attention');
|
||
|
||
// Check if attention mechanisms are exported
|
||
const mechanisms = {
|
||
'Multi-Head Attention': attention.MultiHeadAttention || attention.multihead,
|
||
'Flash Attention': attention.FlashAttention || attention.flash,
|
||
'Linear Attention': attention.LinearAttention || attention.linear,
|
||
'Hyperbolic Attention': attention.HyperbolicAttention || attention.hyperbolic,
|
||
'MoE Attention': attention.MoEAttention || attention.moe
|
||
};
|
||
|
||
for (const [name, impl] of Object.entries(mechanisms)) {
|
||
if (impl) {
|
||
pass(`${name} available`);
|
||
} else {
|
||
warn(`${name} not found in exports`);
|
||
}
|
||
}
|
||
|
||
// Try to list all exports
|
||
console.log('\n Available exports:', Object.keys(attention).join(', '));
|
||
|
||
} catch (error) {
|
||
fail('Attention mechanisms verification', error);
|
||
}
|
||
}
|
||
|
||
async function verifyVectorSearch() {
|
||
console.log('\n🔎 Vector Search Verification\n');
|
||
|
||
try {
|
||
const ruvector = require('ruvector');
|
||
|
||
// Create a simple vector database
|
||
if (ruvector.VectorDB || ruvector.default) {
|
||
pass('RuVector VectorDB available');
|
||
|
||
// Try to perform basic operations
|
||
try {
|
||
// This is a basic check - actual implementation may vary
|
||
const VectorDB = ruvector.VectorDB || ruvector.default || ruvector;
|
||
if (typeof VectorDB === 'function' || typeof VectorDB.search === 'function') {
|
||
pass('VectorDB has expected interface');
|
||
}
|
||
} catch (err) {
|
||
warn(`VectorDB interface check: ${err.message}`);
|
||
}
|
||
} else {
|
||
warn('VectorDB not found in expected exports');
|
||
}
|
||
|
||
console.log('\n Available exports:', Object.keys(ruvector).join(', '));
|
||
|
||
} catch (error) {
|
||
fail('Vector search verification', error);
|
||
}
|
||
}
|
||
|
||
async function verifyGNN() {
|
||
console.log('\n🕸️ Graph Neural Network Verification\n');
|
||
|
||
try {
|
||
const gnn = require('@ruvector/gnn');
|
||
|
||
if (gnn) {
|
||
pass('GNN module loaded');
|
||
|
||
// Check for common GNN exports
|
||
const expectedExports = ['GNN', 'GraphNeuralNetwork', 'TensorCompression'];
|
||
const availableExports = Object.keys(gnn);
|
||
|
||
console.log('\n Available exports:', availableExports.join(', '));
|
||
|
||
if (availableExports.length > 0) {
|
||
pass('GNN has exports');
|
||
}
|
||
}
|
||
|
||
} catch (error) {
|
||
fail('GNN verification', error);
|
||
}
|
||
}
|
||
|
||
async function verifyGraphDatabase() {
|
||
console.log('\n🗄️ Graph Database Verification\n');
|
||
|
||
try {
|
||
const graphNode = require('@ruvector/graph-node');
|
||
|
||
if (graphNode) {
|
||
pass('Graph Node module loaded');
|
||
|
||
const availableExports = Object.keys(graphNode);
|
||
console.log('\n Available exports:', availableExports.join(', '));
|
||
|
||
// Check for Cypher query support
|
||
if (graphNode.query || graphNode.cypher || graphNode.Query) {
|
||
pass('Cypher query support detected');
|
||
} else {
|
||
warn('Cypher query support not found in exports');
|
||
}
|
||
|
||
// Check for hyperedge support
|
||
if (graphNode.HyperEdge || graphNode.hyperedge) {
|
||
pass('Hyperedge support detected');
|
||
} else {
|
||
warn('Hyperedge support not found in exports');
|
||
}
|
||
}
|
||
|
||
} catch (error) {
|
||
fail('Graph database verification', error);
|
||
}
|
||
}
|
||
|
||
async function verifyRouter() {
|
||
console.log('\n🔀 Semantic Router Verification\n');
|
||
|
||
try {
|
||
const router = require('@ruvector/router');
|
||
|
||
if (router) {
|
||
pass('Router module loaded');
|
||
|
||
const availableExports = Object.keys(router);
|
||
console.log('\n Available exports:', availableExports.join(', '));
|
||
|
||
if (router.Router || router.SemanticRouter) {
|
||
pass('Semantic router available');
|
||
}
|
||
}
|
||
|
||
} catch (error) {
|
||
fail('Router verification', error);
|
||
}
|
||
}
|
||
|
||
async function printSummary() {
|
||
console.log('\n' + '='.repeat(60));
|
||
console.log('\n📊 Verification Summary\n');
|
||
|
||
console.log(`✅ Passed: ${results.passed.length} tests`);
|
||
console.log(`❌ Failed: ${results.failed.length} tests`);
|
||
console.log(`⚠️ Warnings: ${results.warnings.length} items`);
|
||
|
||
if (results.failed.length > 0) {
|
||
console.log('\n❌ Failed Tests:');
|
||
results.failed.forEach(({ test, error }) => {
|
||
console.log(` - ${test}: ${error}`);
|
||
});
|
||
}
|
||
|
||
if (results.warnings.length > 0) {
|
||
console.log('\n⚠️ Warnings:');
|
||
results.warnings.forEach(warning => {
|
||
console.log(` - ${warning}`);
|
||
});
|
||
}
|
||
|
||
console.log('\n' + '='.repeat(60));
|
||
|
||
// Exit with appropriate code
|
||
if (results.failed.length > 0) {
|
||
console.log('\n❌ Verification FAILED\n');
|
||
process.exit(1);
|
||
} else {
|
||
console.log('\n✅ Verification PASSED\n');
|
||
console.log('🎉 agentdb@2.0.0-alpha.2.11 is working correctly!\n');
|
||
process.exit(0);
|
||
}
|
||
}
|
||
|
||
// Run all verifications
|
||
async function runVerification() {
|
||
try {
|
||
await verifyPackageStructure();
|
||
await verifyAttentionMechanisms();
|
||
await verifyVectorSearch();
|
||
await verifyGNN();
|
||
await verifyGraphDatabase();
|
||
await verifyRouter();
|
||
await printSummary();
|
||
} catch (error) {
|
||
console.error('\n💥 Fatal error during verification:', error);
|
||
process.exit(1);
|
||
}
|
||
}
|
||
|
||
// Start verification
|
||
runVerification().catch(console.error);
|