#!/usr/bin/env node
// FIXED GitHub (3a3d0f8) vs OAuth comparison with proper session handling
const axios = require('axios');
async function fixedGithubComparison() {
console.log('π¬ FIXED GITHUB (3a3d0f8) vs OAUTH COMPARISON');
console.log('β'.repeat(80));
console.log('Properly testing GitHub version with session awareness');
console.log('GitHub has 4 tools: authenticate_user, get_costs, get_accounts, get_recommendations\n');
const results = [];
try {
// Authenticate with OAuth version
console.log('π Authenticating with OAuth version...');
const oauthSessionResponse = await axios.post('http://localhost:8080/api/session/create');
const oauthSessionId = oauthSessionResponse.data.sessionId;
await axios.post('http://localhost:8080/oauth/callback', {
sessionId: oauthSessionId,
username: 'david+saola@umbrellacost.com',
password: 'Dsamsung1!'
});
console.log(`β
OAuth authenticated: ${oauthSessionId}`);
// For GitHub - we need to authenticate for each request (session issue)
console.log('π GitHub version requires auth per request due to session issue\n');
// Define test questions mapped to GitHub's 4 tools
const questions = [
{
num: 'Q1',
query: 'what is my total cost?',
githubTool: 'get_costs',
oauthTool: 'api___invoices_caui',
githubArgs: { userQuery: 'what is my total cost?' },
oauthArgs: { userQuery: 'what is my total cost?', periodGranLevel: 'month' }
},
{
num: 'Q2',
query: 'what is my total AWS cost?',
githubTool: 'get_costs',
oauthTool: 'api___invoices_caui',
githubArgs: { cloud_context: 'aws', userQuery: 'what is my total AWS cost?' },
oauthArgs: { cloud_context: 'aws', userQuery: 'what is my total AWS cost?', periodGranLevel: 'month' }
},
{
num: 'Q3',
query: 'what is my total GCP cost?',
githubTool: 'get_costs',
oauthTool: 'api___invoices_caui',
githubArgs: { cloud_context: 'gcp', userQuery: 'what is my total GCP cost?' },
oauthArgs: { cloud_context: 'gcp', userQuery: 'what is my total GCP cost?', periodGranLevel: 'month' }
},
{
num: 'Q4',
query: 'what is my total Azure cost?',
githubTool: 'get_costs',
oauthTool: 'api___invoices_caui',
githubArgs: { cloud_context: 'azure', userQuery: 'what is my total Azure cost?' },
oauthArgs: { cloud_context: 'azure', userQuery: 'what is my total Azure cost?', periodGranLevel: 'month' }
},
{
num: 'Q5',
query: 'show me all available accounts',
githubTool: 'get_accounts',
oauthTool: 'api___user_management_accounts',
githubArgs: { userQuery: 'show me all available accounts' },
oauthArgs: { userQuery: 'show me all available accounts' }
},
{
num: 'Q6',
query: 'what do you recommend for saving AWS costs?',
githubTool: 'get_recommendations',
oauthTool: 'api___recommendationsNew_heatmap_summary',
githubArgs: { userQuery: 'what do you recommend for saving AWS costs?' },
oauthArgs: { userQuery: 'what do you recommend for saving AWS costs?' }
},
{
num: 'Q7',
query: 'show me the total cost per month',
githubTool: 'get_costs',
oauthTool: 'api___invoices_caui',
githubArgs: { userQuery: 'show me the total cost per month' },
oauthArgs: { userQuery: 'show me the total cost per month', periodGranLevel: 'month' }
},
{
num: 'Q8',
query: 'show me AWS amortized costs for the last 8 months',
githubTool: 'get_costs',
oauthTool: 'api___invoices_caui',
githubArgs: { cloud_context: 'aws', userQuery: 'show me AWS amortized costs for the last 8 months' },
oauthArgs: {
cloud_context: 'aws',
isAmortized: true,
periodGranLevel: 'month',
startDate: '2025-01-01',
endDate: '2025-08-31',
userQuery: 'show me AWS amortized costs for the last 8 months'
}
}
];
console.log('β'.repeat(80));
console.log('π TESTING GITHUB vs OAUTH WITH PROPER SESSION HANDLING');
console.log('β'.repeat(80));
// Helper function to authenticate and call GitHub tool
async function callGithubTool(toolName, args) {
try {
// Authenticate first
const authRequest = {
jsonrpc: '2.0',
method: 'tools/call',
params: {
name: 'authenticate_user',
arguments: {
username: 'david+saola@umbrellacost.com',
password: 'Dsamsung1!'
}
},
id: 1
};
await axios.post('http://localhost:3000/sse', authRequest);
// Then call the tool immediately
const toolRequest = {
jsonrpc: '2.0',
method: 'tools/call',
params: {
name: toolName,
arguments: args
},
id: 2
};
const response = await axios.post('http://localhost:3000/sse', toolRequest);
return response.data.result.content[0].text;
} catch (error) {
return `β GitHub Error: ${error.response?.data?.error || error.message}`;
}
}
for (const q of questions) {
console.log(`\nπ ${q.num}: ${q.query}`);
console.log('β'.repeat(80));
// Test GitHub version with proper auth
console.log('π Testing GitHub version (with fresh auth)...');
const githubResponse = await callGithubTool(q.githubTool, q.githubArgs);
// Test OAuth version
console.log('π Testing OAuth version...');
let oauthResponse = '';
try {
const oauthRequest = {
jsonrpc: '2.0',
method: 'tools/call',
params: {
name: q.oauthTool,
arguments: {
sessionId: oauthSessionId,
...q.oauthArgs
}
},
id: parseInt(q.num.substring(1))
};
const response = await axios.post('http://localhost:3001/sse', oauthRequest);
oauthResponse = response.data.result.content[0].text;
} catch (error) {
oauthResponse = `β OAuth Error: ${error.response?.data?.error || error.message}`;
}
// Extract comparison data
const githubCost = githubResponse.match(/(?:total|cost|savings).*?\$([0-9,]+\.?\d*)/i)?.[1] || 'N/A';
const oauthCost = oauthResponse.match(/(?:total|cost|savings).*?\$([0-9,]+\.?\d*)/i)?.[1] || 'N/A';
const githubHasError = githubResponse.includes('Error') || githubResponse.includes('β');
const oauthHasError = oauthResponse.includes('Error') || oauthResponse.includes('β') || oauthResponse.includes('Service temporarily');
results.push({
num: q.num,
query: q.query,
github: { response: githubResponse, cost: githubCost, hasError: githubHasError },
oauth: { response: oauthResponse, cost: oauthCost, hasError: oauthHasError }
});
// Show responses
console.log('\nπ GITHUB RESPONSE:');
console.log('β'.repeat(40));
console.log(githubResponse.substring(0, 300));
if (githubResponse.length > 300) console.log('... [truncated]');
console.log('\nπ OAUTH RESPONSE:');
console.log('β'.repeat(40));
console.log(oauthResponse.substring(0, 300));
if (oauthResponse.length > 300) console.log('... [truncated]');
// Comparison
const bothWork = !githubHasError && !oauthHasError;
const costsMatch = githubCost === oauthCost;
const perfectMatch = bothWork && costsMatch;
console.log(`\nπ° COST: GitHub=$${githubCost} | OAuth=$${oauthCost}`);
console.log(`π STATUS: GitHub=${githubHasError ? 'ERROR' : 'OK'} | OAuth=${oauthHasError ? 'ERROR' : 'OK'}`);
console.log(`β
MATCH: ${perfectMatch ? 'PERFECT' : (bothWork ? 'FUNCTIONAL' : 'NO')}`);
}
// Final comparison table
console.log('\n\n' + 'β'.repeat(100));
console.log('π FINAL COMPARISON: GITHUB (3a3d0f8) vs OAUTH VERSION');
console.log('β'.repeat(100));
console.log('\n| # | Question | GitHub Cost | OAuth Cost | GitHub Status | OAuth Status | Match |');
console.log('|---|----------|-------------|------------|---------------|--------------|-------|');
let perfectMatches = 0;
let functionalMatches = 0;
let githubWorking = 0;
let oauthWorking = 0;
results.forEach(r => {
const githubStatus = r.github.hasError ? 'β' : 'β
';
const oauthStatus = r.oauth.hasError ? 'β' : 'β
';
const bothWork = !r.github.hasError && !r.oauth.hasError;
const perfectMatch = bothWork && r.github.cost === r.oauth.cost;
if (perfectMatch) perfectMatches++;
if (bothWork) functionalMatches++;
if (!r.github.hasError) githubWorking++;
if (!r.oauth.hasError) oauthWorking++;
const matchStatus = perfectMatch ? 'β
PERFECT' : (bothWork ? 'β οΈ DIFFER' : 'β NO');
console.log(`| ${r.num} | ${r.query.substring(0, 30)}... | $${r.github.cost} | $${r.oauth.cost} | ${githubStatus} | ${oauthStatus} | ${matchStatus} |`);
});
// Statistical analysis
console.log('\n' + 'β'.repeat(100));
console.log('π HONEST STATISTICAL ANALYSIS');
console.log('β'.repeat(100));
const total = results.length;
const perfectPercent = (perfectMatches / total * 100).toFixed(1);
const functionalPercent = (functionalMatches / total * 100).toFixed(1);
const githubPercent = (githubWorking / total * 100).toFixed(1);
const oauthPercent = (oauthWorking / total * 100).toFixed(1);
console.log(`\nπ SUCCESS RATES:`);
console.log(` β’ GitHub (3a3d0f8) Working: ${githubWorking}/${total} (${githubPercent}%)`);
console.log(` β’ OAuth Version Working: ${oauthWorking}/${total} (${oauthPercent}%)`);
console.log(` β’ Both Working: ${functionalMatches}/${total} (${functionalPercent}%)`);
console.log(` β’ Perfect Matches: ${perfectMatches}/${total} (${perfectPercent}%)`);
console.log(`\nπ KEY DIFFERENCES:`);
console.log(` β’ GitHub has 4 tools vs OAuth's 27 tools`);
console.log(` β’ GitHub has session management issues`);
console.log(` β’ OAuth has modern authentication flow`);
console.log(` β’ OAuth has richer response formatting`);
// Question analysis
console.log(`\nπ DETAILED ANALYSIS:`);
results.forEach((r, i) => {
console.log(`\n${r.num}: ${r.query}`);
if (r.github.hasError && r.oauth.hasError) {
console.log(' β’ π΄ Both failed - endpoint issue');
} else if (r.github.hasError) {
console.log(' β’ π‘ GitHub failed, OAuth working');
} else if (r.oauth.hasError) {
console.log(' β’ π‘ OAuth failed, GitHub working');
} else if (r.github.cost === r.oauth.cost) {
console.log(` β’ π’ Perfect match: $${r.github.cost}`);
} else {
console.log(` β’ π Different costs: GitHub=$${r.github.cost} vs OAuth=$${r.oauth.cost}`);
}
});
// Final verdict
console.log('\n' + 'β'.repeat(100));
console.log('π― FINAL HONEST VERDICT');
console.log('β'.repeat(100));
if (perfectPercent >= 70) {
console.log('β
HIGH COMPATIBILITY: Versions are highly compatible');
} else if (functionalPercent >= 60) {
console.log('β οΈ MODERATE COMPATIBILITY: Both work but different results');
} else if (oauthPercent > githubPercent) {
console.log('π OAUTH SUPERIOR: OAuth version more stable');
} else if (githubPercent > oauthPercent) {
console.log('π GITHUB SUPERIOR: GitHub version more stable');
} else {
console.log('β COMPATIBILITY ISSUES: Both need work');
}
console.log(`\nπ PRODUCTION RECOMMENDATION:`);
if (perfectPercent >= 70) {
console.log('β
Either version acceptable - OAuth has more features');
} else if (oauthPercent >= 80) {
console.log('β
Deploy OAuth version - more stable and feature-rich');
} else if (githubPercent >= 80) {
console.log('β οΈ Consider GitHub version if simplicity preferred');
} else {
console.log('β οΈ Both versions need stability improvements');
}
} catch (error) {
console.error('β Comparison failed:', error.message);
}
}
fixedGithubComparison().catch(console.error);