UNPKG

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

85 lines 2.92 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AgentSessionManager = void 0; class AgentSessionManager { constructor(config, sessionManager, workspace, currentTask, currentSession, status, conversationHistory, lastError, taskContext) { this.config = null; this.sessionManager = null; this.workspace = null; this.currentTask = null; this.currentSession = null; this.status = 'uninitialized'; this.conversationHistory = []; this.lastError = null; this.taskContext = null; this.config = config; this.sessionManager = sessionManager; this.workspace = workspace; this.currentTask = currentTask; this.currentSession = currentSession; this.status = status; this.conversationHistory = conversationHistory; this.lastError = lastError; this.taskContext = taskContext; } /** * Create a session for task execution */ async createSession() { if (!this.sessionManager || !this.currentTask || !this.workspace) { throw new Error('Session manager, task, or workspace not available'); } const workspacePath = this.workspace.getWorktreePath(this.currentTask.id); this.currentSession = await this.sessionManager.createSession(this.currentTask.id, workspacePath); return this.currentSession; } /** * Run command in session */ async runInSession(command) { if (!this.sessionManager || !this.currentSession) { throw new Error('No active session'); } return await this.sessionManager.runCommandInSession(this.currentSession.sessionId, command); } /** * Format prompt template with context variables */ formatPrompt(template, context) { let formatted = template; for (const [key, value] of Object.entries(context)) { const placeholder = `{{${key}}}`; formatted = formatted.replace(new RegExp(placeholder, 'g'), String(value)); } return formatted; } /** * Reset agent state */ async reset() { // Clean up session if exists if (this.currentSession && this.sessionManager) { try { await this.sessionManager.killSession(this.currentSession.sessionId); } catch (error) { console.warn(`Failed to clean up session: ${error.message}`); } this.currentSession = null; } } /** * Get current session info */ getCurrentSession() { return this.currentSession; } /** * Check if session is active */ hasActiveSession() { return this.currentSession !== null; } } exports.AgentSessionManager = AgentSessionManager; //# sourceMappingURL=agent-session-management.js.map