import { getPendingConfirmation, respondToConfirmation } from "../services/confirmation-store.mjs";
//#region extensions/crypto/src/commands/confirm-commands.ts
/**
* /approve and /deny commands — respond to plan step confirmations.
*
* When a plan step has `requireConfirmation: true`, the executor pauses
* and asks the user. The user responds with /approve or /deny.
*/
const approveCommand = {
	name: "approve",
	description: "Approve a pending plan step",
	acceptsArgs: false,
	requireAuth: true,
	handler: async (ctx) => {
		const userId = ctx?.senderId ?? ctx?.from ?? ctx?.metadata?.senderId ?? "owner";
		if (!getPendingConfirmation(userId)) return { text: "No pending confirmations.\n\nConfirmation requests appear when a plan step needs your approval before executing." };
		const confirmed = respondToConfirmation(userId, true);
		if (!confirmed) return { text: "No pending confirmations." };
		return { text: `Approved: **${confirmed.stepLabel}**\n\nThe plan will continue executing.` };
	}
};
const denyCommand = {
	name: "deny",
	description: "Deny a pending plan step",
	acceptsArgs: false,
	requireAuth: true,
	handler: async (ctx) => {
		const userId = ctx?.senderId ?? ctx?.from ?? ctx?.metadata?.senderId ?? "owner";
		if (!getPendingConfirmation(userId)) return { text: "No pending confirmations." };
		const denied = respondToConfirmation(userId, false);
		if (!denied) return { text: "No pending confirmations." };
		return { text: `Denied: **${denied.stepLabel}**\n\nThe step will be skipped. The plan may continue with remaining steps.` };
	}
};
//#endregion
export { approveCommand, denyCommand };

//# sourceMappingURL=confirm-commands.mjs.map