UNPKG

automagik-genie

Version:

Self-evolving AI agent orchestration framework with Model Context Protocol support

33 lines (32 loc) 1.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createStopHandler = createStopHandler; const forge_executor_1 = require("../../lib/forge-executor"); const forge_helpers_1 = require("../../lib/forge-helpers"); function createStopHandler(ctx) { return async (parsed) => { const [attemptId] = parsed.commandArgs; if (!attemptId) { throw new Error('Usage: genie stop <attempt-id>'); } const store = ctx.sessionService.load({ onWarning: ctx.recordRuntimeWarning }); const entry = store.sessions[attemptId]; // Direct UUID lookup (issue #407 fix) if (!entry) { throw new Error(`Session '${attemptId}' not found. Use 'genie list' to see available sessions.`); } const forgeExecutor = (0, forge_executor_1.createForgeExecutor)(); try { await forgeExecutor.stopTask(attemptId); } catch (error) { const reason = (0, forge_helpers_1.describeForgeError)(error); ctx.recordRuntimeWarning(`Forge stop failed: ${reason}`); throw new Error(`Forge backend unavailable while stopping session '${attemptId}'. ${forge_helpers_1.FORGE_RECOVERY_HINT}`); } entry.status = 'stopped'; entry.lastUsed = new Date().toISOString(); store.sessions[attemptId] = entry; await ctx.sessionService.save(store); process.stdout.write(`✓ Session ${attemptId} stopped via Forge\n`); }; }