UNPKG

agentic-qe

Version:

Agentic Quality Engineering Fleet System - AI-driven quality management platform

59 lines 2.14 kB
"use strict"; /** * Agent Clone Command * Clone an existing agent with optional config modifications */ Object.defineProperty(exports, "__esModule", { value: true }); exports.clone = void 0; const Logger_1 = require("../../../utils/Logger"); async function clone(options) { const logger = Logger_1.Logger.getInstance(); try { // Get source agent const sourceAgent = options.fleetManager.getAgent(options.sourceAgentId); if (!sourceAgent) { throw new Error(`Agent ${options.sourceAgentId} not found`); } // Get source config const sourceConfig = sourceAgent.config || {}; // Merge with overrides const newConfig = options.configOverrides ? { ...sourceConfig, ...options.configOverrides } : sourceConfig; const configModified = options.configOverrides !== undefined; // Add clone metadata const cloneMetadata = { ...newConfig, clonedFrom: options.sourceAgentId, clonedAt: new Date().toISOString(), name: options.name || `${sourceAgent.getType()}-clone` }; // Get clone counter const agents = options.fleetManager.getAllAgents(); const clones = agents.filter(a => { const config = a.config; return config?.clonedFrom === options.sourceAgentId; }); const cloneNumber = clones.length + 1; // Spawn cloned agent const newAgent = await options.fleetManager.spawnAgent(sourceAgent.getType(), cloneMetadata); logger.info(`Agent cloned: ${options.sourceAgentId} -> ${newAgent.getId()}`); return { success: true, newAgentId: newAgent.getId(), configModified, cloneNumber }; } catch (error) { logger.error('Failed to clone agent:', error); return { success: false, configModified: false, cloneNumber: 0, error: error instanceof Error ? error.message : String(error) }; } } exports.clone = clone; //# sourceMappingURL=clone.js.map