mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 17:51:24 +00:00
chore: Fix type errors from reverts.
This commit is contained in:
@@ -24,6 +24,15 @@ const multiselect = <T>(params: Parameters<typeof clackMultiselect<T>>[0]) =>
|
||||
),
|
||||
});
|
||||
|
||||
function guardPromptCancel<T>(value: T | symbol, runtime: RuntimeEnv): T {
|
||||
if (isCancel(value)) {
|
||||
cancel(stylePromptTitle("Model scan cancelled.") ?? "Model scan cancelled.");
|
||||
runtime.exit(0);
|
||||
throw new Error("unreachable");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
const pad = (value: string, size: number) => value.padEnd(size);
|
||||
|
||||
const truncate = (value: string, max: number) => {
|
||||
@@ -262,12 +271,7 @@ export async function modelsScanCommand(
|
||||
initialValues: preselected,
|
||||
});
|
||||
|
||||
if (isCancel(selection)) {
|
||||
cancel(stylePromptTitle("Model scan cancelled.") ?? "Model scan cancelled.");
|
||||
runtime.exit(0);
|
||||
}
|
||||
|
||||
selected = selection;
|
||||
selected = guardPromptCancel(selection, runtime);
|
||||
if (imageSorted.length > 0) {
|
||||
const imageSelection = await multiselect({
|
||||
message: "Select image fallback models (ordered)",
|
||||
@@ -279,12 +283,7 @@ export async function modelsScanCommand(
|
||||
initialValues: imagePreselected,
|
||||
});
|
||||
|
||||
if (isCancel(imageSelection)) {
|
||||
cancel(stylePromptTitle("Model scan cancelled.") ?? "Model scan cancelled.");
|
||||
runtime.exit(0);
|
||||
}
|
||||
|
||||
selectedImages = imageSelection;
|
||||
selectedImages = guardPromptCancel(imageSelection, runtime);
|
||||
}
|
||||
} else if (!process.stdin.isTTY && !opts.yes && !noInput && !opts.json) {
|
||||
throw new Error("Non-interactive scan: pass --yes to apply defaults.");
|
||||
|
||||
@@ -31,6 +31,7 @@ export function guardCancel<T>(value: T | symbol, runtime: RuntimeEnv): T {
|
||||
if (isCancel(value)) {
|
||||
cancel(stylePromptTitle("Setup cancelled.") ?? "Setup cancelled.");
|
||||
runtime.exit(0);
|
||||
throw new Error("unreachable");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ const NON_INTERACTIVE_DEFAULT_OPTIONS = {
|
||||
export function createThrowingRuntime(): NonInteractiveRuntime {
|
||||
return {
|
||||
log: () => {},
|
||||
error: (msg: string) => {
|
||||
throw new Error(msg);
|
||||
error: (...args: unknown[]) => {
|
||||
throw new Error(args.map(String).join(" "));
|
||||
},
|
||||
exit: (code: number) => {
|
||||
throw new Error(`exit:${code}`);
|
||||
|
||||
Reference in New Issue
Block a user