cortexweaver
Version:
CortexWeaver is a command-line interface (CLI) tool that orchestrates a swarm of specialized AI agents, powered by Claude Code and Gemini CLI, to assist in software development. It transforms a high-level project plan (plan.md) into a series of coordinate
196 lines • 6.6 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AuthStrategies = exports.AuthManager = exports.AuthMethod = void 0;
const auth_strategies_1 = require("./auth-strategies");
Object.defineProperty(exports, "AuthStrategies", { enumerable: true, get: function () { return auth_strategies_1.AuthStrategies; } });
/**
* Authentication methods supported by CortexWeaver
*/
var AuthMethod;
(function (AuthMethod) {
AuthMethod["NONE"] = "none";
AuthMethod["CLAUDE_CODE_SESSION"] = "claude_code_session";
AuthMethod["CLAUDE_CODE_CONFIG"] = "claude_code_config";
AuthMethod["GEMINI_CLI"] = "gemini_cli";
AuthMethod["API_KEY"] = "api_key";
})(AuthMethod || (exports.AuthMethod = AuthMethod = {}));
/**
* AuthManager handles authentication discovery, validation, and management
* for CortexWeaver, supporting Claude Code CLI, Gemini CLI, and direct API keys
*/
class AuthManager {
constructor(projectRoot = process.cwd()) {
this.claudeAuth = null;
this.geminiAuth = null;
this.projectRoot = projectRoot;
this.authStrategies = new auth_strategies_1.AuthStrategies();
}
/**
* Get the project root directory
*/
getProjectRoot() {
return this.projectRoot;
}
/**
* Discover and initialize all available authentication methods
*/
async discoverAuthentication() {
this.claudeAuth = await this.authStrategies.discoverClaudeAuthentication();
this.geminiAuth = await this.authStrategies.discoverGeminiAuthentication();
}
/**
* Get comprehensive authentication status
*/
async getAuthStatus() {
// Ensure authentication is discovered
if (!this.claudeAuth || !this.geminiAuth) {
await this.discoverAuthentication();
}
const claudeAuth = this.claudeAuth || { method: AuthMethod.NONE };
const geminiAuth = this.geminiAuth || { method: AuthMethod.NONE };
// Check if authentication is valid and not expired
const isClaudeAuthenticated = await this.authStrategies.isAuthenticationValid(claudeAuth);
const isGeminiAuthenticated = await this.authStrategies.isAuthenticationValid(geminiAuth);
// Generate recommendations
const recommendations = this.authStrategies.generateRecommendations(claudeAuth, geminiAuth);
return {
claudeAuth: {
...claudeAuth,
isAuthenticated: isClaudeAuthenticated
},
geminiAuth: {
...geminiAuth,
isAuthenticated: isGeminiAuthenticated
},
recommendations,
lastChecked: new Date()
};
}
/**
* Check if authentication is expired
*/
async isAuthExpired(auth) {
return this.authStrategies.isAuthExpired(auth);
}
/**
* Validate Claude authentication
*/
async validateClaudeAuth(auth) {
return this.authStrategies.validateClaudeAuth(auth);
}
/**
* Validate Gemini authentication
*/
async validateGeminiAuth(auth) {
return this.authStrategies.validateGeminiAuth(auth);
}
/**
* Manually set Claude authentication
*/
async setClaudeAuth(auth) {
this.claudeAuth = auth;
}
/**
* Manually set Gemini authentication
*/
async setGeminiAuth(auth) {
this.geminiAuth = auth;
}
/**
* Clear Claude authentication
*/
async clearClaudeAuth() {
this.claudeAuth = { method: AuthMethod.NONE };
}
/**
* Clear Gemini authentication
*/
async clearGeminiAuth() {
this.geminiAuth = { method: AuthMethod.NONE };
}
/**
* Attempt to refresh Claude authentication
*/
async refreshClaudeAuth() {
return this.authStrategies.refreshClaudeAuth();
}
/**
* Attempt to refresh Gemini authentication
*/
async refreshGeminiAuth() {
return this.authStrategies.refreshGeminiAuth();
}
/**
* Get authentication credentials for Claude
*/
async getClaudeCredentials() {
if (!this.claudeAuth || this.claudeAuth.method === AuthMethod.NONE) {
return null;
}
const details = this.claudeAuth.details;
return {
apiKey: details?.api_key,
sessionToken: details?.session_token
};
}
/**
* Get authentication credentials for Gemini
*/
async getGeminiCredentials() {
if (!this.geminiAuth || this.geminiAuth.method === AuthMethod.NONE) {
return null;
}
const details = this.geminiAuth.details;
return {
apiKey: details?.api_key,
refreshToken: details?.refresh_token
};
}
/**
* Get preferred authentication method for Claude
*/
getClaudeAuthMethod() {
return this.claudeAuth?.method || AuthMethod.NONE;
}
/**
* Get preferred authentication method for Gemini
*/
getGeminiAuthMethod() {
return this.geminiAuth?.method || AuthMethod.NONE;
}
/**
* Check if authentication is available for both services
*/
async isFullyAuthenticated() {
const status = await this.getAuthStatus();
return status.claudeAuth.isAuthenticated && status.geminiAuth.isAuthenticated;
}
/**
* Get detailed authentication report
*/
async getAuthReport() {
const status = await this.getAuthStatus();
const report = [
'🔐 CortexWeaver Authentication Status',
'='.repeat(50),
'',
'🤖 Claude Authentication:',
` Method: ${status.claudeAuth.method}`,
` Status: ${status.claudeAuth.isAuthenticated ? '✅ Authenticated' : '❌ Not Authenticated'}`,
status.claudeAuth.error ? ` Error: ${status.claudeAuth.error}` : '',
'',
'🧠 Gemini Authentication:',
` Method: ${status.geminiAuth.method}`,
` Status: ${status.geminiAuth.isAuthenticated ? '✅ Authenticated' : '❌ Not Authenticated'}`,
status.geminiAuth.error ? ` Error: ${status.geminiAuth.error}` : '',
'',
'💡 Recommendations:',
...status.recommendations.map(rec => ` • ${rec}`),
'',
`📊 Last Checked: ${status.lastChecked.toISOString()}`
].filter(line => line !== '').join('\n');
return report;
}
}
exports.AuthManager = AuthManager;
//# sourceMappingURL=index.js.map