"use strict";const r=require("crypto"),s=require("./shared-types-B8BH5zz1.cjs"),u=require("./cancellation-DiXZPuOm.cjs");function l(t){const e=t[t.length-1]?.role==="user"?t[t.length-1]:t.slice().reverse().find(n=>n.role==="user");if(e)return typeof e.content=="string"?e.content:e.content.filter(n=>n.type==="text").map(n=>n.text).join(`

`)}function f(t,e){return e==="No"&&t.classification==="spec"?"chat":e==="Yes"?t.classification:"ambiguous"}function d(t){switch(t){case"chat":return{chat:1,do:0,spec:0};case"do":return{chat:0,do:1,spec:0};case"spec":return{chat:0,do:0,spec:1};default:return{chat:0,do:0,spec:0}}}function p(t,e){const n="Help me understand your goal better. Which of the following would you like to do?";let i="";for(const o of e)i+=`
- ${o}`;return n+i}async function h(t,e){const n={id:"intent-clarification",question:e},i=r.randomUUID(),o={executionId:t.execution.executionId,actionId:i,actionState:s.OperationStatus.PendingAction,actionType:"userInput",output:{questions:[n],reason:"intent-clarification"}};t.execution.emit({type:"AgentExecutionAction",...o}),t.execution.addQuestion(n);let a=!1,c;try{await t.execution.acquireYield("clarification"),a=!0,c=(await u.abortable(t.execution.waitForAllQuestions(),t.execution.abortController.signal))[n.id],t.execution.emit({type:"AgentExecutionAction",...o,output:{questions:[c]}})}finally{if(a)try{await t.execution.releaseYield("clarification")}catch{}}return t.execution.saveState(t),c}exports.extractLastUserMessage=l;exports.generateClarificationQuestion=p;exports.getIntentVectorFromClassification=d;exports.handleIntentClarification=h;exports.mapIntentClassificationOptionToClassification=f;
//# sourceMappingURL=clarification-handler-ZVL45Dms.cjs.map
