export async function* handleHITLDecision(ctx, decision, checkpointId, context) {
    switch (decision.action) {
        case 'pause': {
            await ctx.emitEvent({
                type: 'run_paused',
                runId: ctx.runMgr.id,
                checkpointId: checkpointId,
                reason: decision.reason,
            });
            yield* ctx.drainPending();
            ctx.runMgr.setStopReason('paused');
            ctx.log.info(`Run paused at ${context}`, {
                sessionId: ctx.runMgr.id,
                reason: decision.reason,
            });
            return 'stop';
        }
        case 'abort': {
            ctx.runMgr.setStopReason('cancelled');
            ctx.runMgr.markCancelled();
            ctx.log.info(`Run aborted at ${context}`, {
                sessionId: ctx.runMgr.id,
                reason: decision.reason,
            });
            return 'stop';
        }
        case 'reject_plan': {
            ctx.runMgr.setStopReason('plan_rejected');
            ctx.log.info('Plan rejected by user', {
                sessionId: ctx.runMgr.id,
                feedback: decision.feedback,
            });
            return 'stop';
        }
        case 'approve_plan': {
            if (ctx.planManager.active) {
                ctx.planManager.approve();
                ctx.planManager.startExecution();
            }
            ctx.log.info('Plan approved by user', { sessionId: ctx.runMgr.id });
            return 'continue';
        }
        case 'continue':
        case 'approve_tools':
        case 'modify_tools':
        case 'reject_tools':
            return 'continue';
        default: {
            const _exhaustive = decision;
            throw new Error(`Unhandled HITL decision: ${_exhaustive.action}`);
        }
    }
}
//# sourceMappingURL=context.js.map