mirror of
https://github.com/moltbot/moltbot.git
synced 2026-03-07 22:44:16 +00:00
chore: Fix type errors from reverts.
This commit is contained in:
@@ -40,8 +40,8 @@ export async function monitorIrcProvider(opts: IrcMonitorOptions): Promise<{ sto
|
||||
});
|
||||
|
||||
const runtime: RuntimeEnv = opts.runtime ?? {
|
||||
log: (message: string) => core.logging.getChildLogger().info(message),
|
||||
error: (message: string) => core.logging.getChildLogger().error(message),
|
||||
log: (...args: unknown[]) => core.logging.getChildLogger().info(args.map(String).join(" ")),
|
||||
error: (...args: unknown[]) => core.logging.getChildLogger().error(args.map(String).join(" ")),
|
||||
exit: () => {
|
||||
throw new Error("Runtime exit not available");
|
||||
},
|
||||
|
||||
@@ -213,8 +213,8 @@ export async function monitorNextcloudTalkProvider(
|
||||
accountId: opts.accountId,
|
||||
});
|
||||
const runtime: RuntimeEnv = opts.runtime ?? {
|
||||
log: (message: string) => core.logging.getChildLogger().info(message),
|
||||
error: (message: string) => core.logging.getChildLogger().error(message),
|
||||
log: (...args: unknown[]) => core.logging.getChildLogger().info(args.map(String).join(" ")),
|
||||
error: (...args: unknown[]) => core.logging.getChildLogger().error(args.map(String).join(" ")),
|
||||
exit: () => {
|
||||
throw new Error("Runtime exit not available");
|
||||
},
|
||||
|
||||
@@ -261,7 +261,7 @@ const formatUsagePair = (input?: number | null, output?: number | null) => {
|
||||
return `🧮 Tokens: ${inputLabel} in / ${outputLabel} out`;
|
||||
};
|
||||
|
||||
const formatMediaUnderstandingLine = (decisions?: MediaUnderstandingDecision[]) => {
|
||||
const formatMediaUnderstandingLine = (decisions?: ReadonlyArray<MediaUnderstandingDecision>) => {
|
||||
if (!decisions || decisions.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -84,6 +84,7 @@ export function registerBrowserExtensionCommands(
|
||||
} catch (err) {
|
||||
defaultRuntime.error(danger(String(err)));
|
||||
defaultRuntime.exit(1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (parent?.json) {
|
||||
|
||||
@@ -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}`);
|
||||
|
||||
@@ -88,7 +88,8 @@ export async function handlePortError(
|
||||
logDebug(`stderr: ${stderr.trim()}`);
|
||||
}
|
||||
}
|
||||
return runtime.exit(1);
|
||||
runtime.exit(1);
|
||||
throw new Error("unreachable");
|
||||
}
|
||||
|
||||
export { PortInUseError };
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { inspect } from "node:util";
|
||||
import { Chalk } from "chalk";
|
||||
import type { Logger as TsLogger } from "tslog";
|
||||
import { CHAT_CHANNEL_ORDER } from "../channels/registry.js";
|
||||
@@ -320,9 +321,14 @@ export function runtimeForLogger(
|
||||
logger: SubsystemLogger,
|
||||
exit: RuntimeEnv["exit"] = defaultRuntime.exit,
|
||||
): RuntimeEnv {
|
||||
const formatArgs = (...args: unknown[]) =>
|
||||
args
|
||||
.map((arg) => (typeof arg === "string" ? arg : inspect(arg)))
|
||||
.join(" ")
|
||||
.trim();
|
||||
return {
|
||||
log: (message: string) => logger.info(message),
|
||||
error: (message: string) => logger.error(message),
|
||||
log: (...args: unknown[]) => logger.info(formatArgs(...args)),
|
||||
error: (...args: unknown[]) => logger.error(formatArgs(...args)),
|
||||
exit,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user