automagik-genie
Version:
Self-evolving AI agent orchestration framework with Model Context Protocol support
59 lines (58 loc) ⢠2.45 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.runInstallChat = runInstallChat;
const prompts_1 = __importDefault(require("prompts"));
const gradient_string_1 = __importDefault(require("gradient-string"));
async function runInstallChat(options) {
console.log('\n' + gradient_string_1.default.cristal(`š§ Install Agent (${options.template})`) + '\n');
console.log('Starting install agent...\n');
try {
// Start MCP session with install agent
const result = await options.mcpClient.run({
agent: options.agent,
prompt: `Initialize ${options.template} template. Guide the user through setup.`,
name: `install-${options.template}-${Date.now()}`
});
const taskId = result.taskId;
console.log(`š¤ Agent: ${result.response || 'Hello! I\'m the install agent. Let me help you set up Genie.'}\n`);
// Interactive chat loop
let isDone = false;
while (!isDone) {
const { userInput } = await (0, prompts_1.default)({
type: 'text',
name: 'userInput',
message: 'š¤ You:',
}, {
onCancel: () => {
console.log('\nā Cancelled');
process.exit(0);
}
});
if (!userInput || !userInput.trim())
continue;
console.log('\nā³ Agent is thinking...\n');
try {
const result = await options.mcpClient.resume({
taskId,
prompt: userInput
});
console.log(`š¤ Agent: ${result.response || ''}\n`);
// Check if agent signals completion
if (result.status === 'completed' || result.response?.includes('[INSTALL_COMPLETE]')) {
console.log('ā
Installation complete!\n');
isDone = true;
}
}
catch (error) {
console.error(`ā Error: ${error instanceof Error ? error.message : String(error)}\n`);
}
}
}
catch (error) {
console.error(`ā Error: ${error instanceof Error ? error.message : String(error)}\n`);
throw error;
}
}