{"version":3,"file":"confirm-commands.mjs","names":[],"sources":["../../../src/commands/confirm-commands.ts"],"sourcesContent":["/**\n * /approve and /deny commands — respond to plan step confirmations.\n *\n * When a plan step has `requireConfirmation: true`, the executor pauses\n * and asks the user. The user responds with /approve or /deny.\n */\n\nimport {\n  respondToConfirmation,\n  getPendingConfirmation,\n} from '../services/confirmation-store.js';\n\nexport const approveCommand = {\n  name: 'approve',\n  description: 'Approve a pending plan step',\n  acceptsArgs: false,\n  requireAuth: true,\n\n  handler: async (ctx: any) => {\n    // Extract userId from context\n    const userId = ctx?.senderId ?? ctx?.from ?? ctx?.metadata?.senderId ?? 'owner';\n\n    const pending = getPendingConfirmation(userId);\n    if (!pending) {\n      return { text: 'No pending confirmations.\\n\\nConfirmation requests appear when a plan step needs your approval before executing.' };\n    }\n\n    const confirmed = respondToConfirmation(userId, true);\n    if (!confirmed) {\n      return { text: 'No pending confirmations.' };\n    }\n\n    return {\n      text: `Approved: **${confirmed.stepLabel}**\\n\\nThe plan will continue executing.`,\n    };\n  },\n};\n\nexport const denyCommand = {\n  name: 'deny',\n  description: 'Deny a pending plan step',\n  acceptsArgs: false,\n  requireAuth: true,\n\n  handler: async (ctx: any) => {\n    const userId = ctx?.senderId ?? ctx?.from ?? ctx?.metadata?.senderId ?? 'owner';\n\n    const pending = getPendingConfirmation(userId);\n    if (!pending) {\n      return { text: 'No pending confirmations.' };\n    }\n\n    const denied = respondToConfirmation(userId, false);\n    if (!denied) {\n      return { text: 'No pending confirmations.' };\n    }\n\n    return {\n      text: `Denied: **${denied.stepLabel}**\\n\\nThe step will be skipped. The plan may continue with remaining steps.`,\n    };\n  },\n};\n"],"mappings":";;;;;;;;AAYA,MAAa,iBAAiB;CAC5B,MAAM;CACN,aAAa;CACb,aAAa;CACb,aAAa;CAEb,SAAS,OAAO,QAAa;EAE3B,MAAM,SAAS,KAAK,YAAY,KAAK,QAAQ,KAAK,UAAU,YAAY;AAGxE,MAAI,CADY,uBAAuB,OAAO,CAE5C,QAAO,EAAE,MAAM,oHAAoH;EAGrI,MAAM,YAAY,sBAAsB,QAAQ,KAAK;AACrD,MAAI,CAAC,UACH,QAAO,EAAE,MAAM,6BAA6B;AAG9C,SAAO,EACL,MAAM,eAAe,UAAU,UAAU,0CAC1C;;CAEJ;AAED,MAAa,cAAc;CACzB,MAAM;CACN,aAAa;CACb,aAAa;CACb,aAAa;CAEb,SAAS,OAAO,QAAa;EAC3B,MAAM,SAAS,KAAK,YAAY,KAAK,QAAQ,KAAK,UAAU,YAAY;AAGxE,MAAI,CADY,uBAAuB,OAAO,CAE5C,QAAO,EAAE,MAAM,6BAA6B;EAG9C,MAAM,SAAS,sBAAsB,QAAQ,MAAM;AACnD,MAAI,CAAC,OACH,QAAO,EAAE,MAAM,6BAA6B;AAG9C,SAAO,EACL,MAAM,aAAa,OAAO,UAAU,8EACrC;;CAEJ"}