openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
56 lines (55 loc) • 2.15 kB
JavaScript
import { n as stylePromptMessage } from "./prompt-style-CLys-6GQ.mjs";
import { a as guardCancel } from "./onboard-helpers-I6fwzX78.mjs";
import { t as styleSelectParams } from "./prompt-select-styled-params-x2CCDNEh.mjs";
import { n as resolveDoctorRepairMode, r as shouldAutoApproveDoctorFix } from "./doctor-repair-mode-D2HKy2yZ.mjs";
import { confirm, select } from "@clack/prompts";
//#region src/commands/doctor-prompter.ts
function createDoctorPrompter(e) {
const t = resolveDoctorRepairMode(e.options);
const confirmPrompt = async (n) => {
if (e.signal?.aborted || t.nonInteractive) return false;
if (!t.canPrompt) return n.initialValue ?? false;
const r = await confirm({
...n,
signal: e.signal ? n.signal ? AbortSignal.any([n.signal, e.signal]) : e.signal : n.signal,
message: stylePromptMessage(n.message)
});
return e.signal?.aborted ? false : guardCancel(r, e.runtime, 130);
};
const confirmDefault = async (e) => {
if (shouldAutoApproveDoctorFix(t)) return true;
return confirmPrompt(e);
};
return {
confirm: confirmDefault,
confirmAutoFix: confirmDefault,
confirmAggressiveAutoFix: async (e) => {
if (shouldAutoApproveDoctorFix(t, { requiresForce: true })) return true;
if (t.shouldRepair && !t.shouldForce) return false;
return confirmPrompt(e);
},
confirmRuntimeRepair: async (e) => {
const { requiresInteractiveConfirmation: n, ...r } = e;
if (n !== true && shouldAutoApproveDoctorFix(t, { blockDuringUpdate: true })) return true;
if (n === true && !t.canPrompt) return false;
return confirmPrompt(r);
},
select: async (n, r) => {
if (!t.canPrompt || t.shouldRepair) return r;
return guardCancel(await select(styleSelectParams(n)), e.runtime, 130);
},
selectRuntimeRepair: async (n, r) => {
if (!t.canPrompt || t.updateInProgress || e.signal?.aborted) return r;
const i = await select(styleSelectParams({
...n,
signal: e.signal ?? n.signal
}));
return e.signal?.aborted ? r : guardCancel(i, e.runtime, 130);
},
shouldRepair: t.shouldRepair,
shouldForce: t.shouldForce,
repairMode: t
};
}
//#endregion
export { createDoctorPrompter };