style: apply lint fixes

This commit is contained in:
Peter Steinberger
2026-01-08 04:44:11 +00:00
parent c2a6e04e06
commit dc3e3f27d4
23 changed files with 94 additions and 95 deletions

View File

@@ -6,6 +6,7 @@ import {
createProcessTool,
processTool,
} from "./bash-tools.js";
import { sanitizeBinaryOutput } from "./shell-utils.js";
const isWin = process.platform === "win32";
const shortDelayCmd = isWin ? "ping -n 2 127.0.0.1 > nul" : "sleep 0.05";
@@ -17,10 +18,9 @@ const echoAfterDelay = (message: string) =>
const echoLines = (lines: string[]) =>
joinCommands(lines.map((line) => `echo ${line}`));
const normalizeText = (value?: string) =>
(value ?? "")
sanitizeBinaryOutput(value ?? "")
.replace(/\r\n/g, "\n")
.replace(/\r/g, "\n")
.replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g, "")
.split("\n")
.map((line) => line.replace(/\s+$/u, ""))
.join("\n")

View File

@@ -424,8 +424,42 @@ export async function scanOpenRouterModels(
filtered,
concurrency,
async (entry) => {
const isFree = isFreeOpenRouterModel(entry);
if (!probe) {
const isFree = isFreeOpenRouterModel(entry);
if (!probe) {
return {
id: entry.id,
name: entry.name,
provider: "openrouter",
modelRef: `openrouter/${entry.id}`,
contextLength: entry.contextLength,
maxCompletionTokens: entry.maxCompletionTokens,
supportedParametersCount: entry.supportedParametersCount,
supportsToolsMeta: entry.supportsToolsMeta,
modality: entry.modality,
inferredParamB: entry.inferredParamB,
createdAtMs: entry.createdAtMs,
pricing: entry.pricing,
isFree,
tool: { ok: false, latencyMs: null, skipped: true },
image: { ok: false, latencyMs: null, skipped: true },
} satisfies ModelScanResult;
}
const model: OpenAIModel = {
...baseModel,
id: entry.id,
name: entry.name || entry.id,
contextWindow: entry.contextLength ?? baseModel.contextWindow,
maxTokens: entry.maxCompletionTokens ?? baseModel.maxTokens,
input: parseModality(entry.modality),
reasoning: baseModel.reasoning,
};
const toolResult = await probeTool(model, apiKey, timeoutMs);
const imageResult = model.input.includes("image")
? await probeImage(ensureImageInput(model), apiKey, timeoutMs)
: { ok: false, latencyMs: null, skipped: true };
return {
id: entry.id,
name: entry.name,
@@ -440,44 +474,10 @@ export async function scanOpenRouterModels(
createdAtMs: entry.createdAtMs,
pricing: entry.pricing,
isFree,
tool: { ok: false, latencyMs: null, skipped: true },
image: { ok: false, latencyMs: null, skipped: true },
tool: toolResult,
image: imageResult,
} satisfies ModelScanResult;
}
const model: OpenAIModel = {
...baseModel,
id: entry.id,
name: entry.name || entry.id,
contextWindow: entry.contextLength ?? baseModel.contextWindow,
maxTokens: entry.maxCompletionTokens ?? baseModel.maxTokens,
input: parseModality(entry.modality),
reasoning: baseModel.reasoning,
};
const toolResult = await probeTool(model, apiKey, timeoutMs);
const imageResult = model.input.includes("image")
? await probeImage(ensureImageInput(model), apiKey, timeoutMs)
: { ok: false, latencyMs: null, skipped: true };
return {
id: entry.id,
name: entry.name,
provider: "openrouter",
modelRef: `openrouter/${entry.id}`,
contextLength: entry.contextLength,
maxCompletionTokens: entry.maxCompletionTokens,
supportedParametersCount: entry.supportedParametersCount,
supportsToolsMeta: entry.supportsToolsMeta,
modality: entry.modality,
inferredParamB: entry.inferredParamB,
createdAtMs: entry.createdAtMs,
pricing: entry.pricing,
isFree,
tool: toolResult,
image: imageResult,
} satisfies ModelScanResult;
},
},
{
onProgress: (completed, total) =>
options.onProgress?.({

View File

@@ -26,4 +26,3 @@ describe("buildInboundMediaNote", () => {
);
});
});

View File

@@ -18,16 +18,15 @@ function formatMediaAttachedLine(params: {
}
export function buildInboundMediaNote(ctx: MsgContext): string | undefined {
const hasPathsArray =
Array.isArray(ctx.MediaPaths) && ctx.MediaPaths.length > 0;
const pathsFromArray = Array.isArray(ctx.MediaPaths)
? ctx.MediaPaths
: undefined;
const paths = pathsFromArray && pathsFromArray.length > 0
? pathsFromArray
: ctx.MediaPath?.trim()
? [ctx.MediaPath.trim()]
: [];
const paths =
pathsFromArray && pathsFromArray.length > 0
? pathsFromArray
: ctx.MediaPath?.trim()
? [ctx.MediaPath.trim()]
: [];
if (paths.length === 0) return undefined;
const urls =

View File

@@ -11,7 +11,8 @@ vi.mock("../agents/pi-embedded.js", () => ({
abortEmbeddedPiRun: vi.fn().mockReturnValue(false),
runEmbeddedPiAgent: vi.fn(),
queueEmbeddedPiMessage: vi.fn().mockReturnValue(false),
resolveEmbeddedSessionLane: (key: string) => `session:${key.trim() || "main"}`,
resolveEmbeddedSessionLane: (key: string) =>
`session:${key.trim() || "main"}`,
isEmbeddedPiRunActive: vi.fn().mockReturnValue(false),
isEmbeddedPiRunStreaming: vi.fn().mockReturnValue(false),
}));
@@ -90,4 +91,3 @@ describe("getReplyFromConfig media note plumbing", () => {
});
});
});

View File

@@ -35,6 +35,7 @@ import {
listChatCommands,
shouldHandleTextCommands,
} from "./commands-registry.js";
import { buildInboundMediaNote } from "./media-note.js";
import { getAbortMemory } from "./reply/abort.js";
import { runReplyAgent } from "./reply/agent-runner.js";
import { resolveBlockStreamingChunking } from "./reply/block-streaming.js";
@@ -80,7 +81,6 @@ import {
import { SILENT_REPLY_TOKEN } from "./tokens.js";
import { isAudio, transcribeInboundAudio } from "./transcription.js";
import type { GetReplyOptions, ReplyPayload } from "./types.js";
import { buildInboundMediaNote } from "./media-note.js";
export {
extractElevatedDirective,
@@ -856,15 +856,17 @@ async function stageSandboxMedia(params: {
workspaceDir: string;
}) {
const { ctx, sessionCtx, cfg, sessionKey, workspaceDir } = params;
const hasPathsArray = Array.isArray(ctx.MediaPaths) && ctx.MediaPaths.length > 0;
const hasPathsArray =
Array.isArray(ctx.MediaPaths) && ctx.MediaPaths.length > 0;
const pathsFromArray = Array.isArray(ctx.MediaPaths)
? ctx.MediaPaths
: undefined;
const rawPaths = pathsFromArray && pathsFromArray.length > 0
? pathsFromArray
: ctx.MediaPath?.trim()
? [ctx.MediaPath.trim()]
: [];
const rawPaths =
pathsFromArray && pathsFromArray.length > 0
? pathsFromArray
: ctx.MediaPath?.trim()
? [ctx.MediaPath.trim()]
: [];
if (rawPaths.length === 0 || !sessionKey) return;
const sandbox = await ensureSandboxWorkspaceForSession({

View File

@@ -92,7 +92,6 @@ export const formatContextUsageShort = (
contextTokens: number | null | undefined,
) => `Context ${formatTokens(total, contextTokens ?? null)}`;
const formatQueueDetails = (queue?: QueueStatus) => {
if (!queue) return "";
const depth = typeof queue.depth === "number" ? `depth ${queue.depth}` : null;

View File

@@ -33,10 +33,7 @@ export function formatCliBannerLine(
return `${title} ${version} (${commitLabel}) — ${tagline}`;
}
export function emitCliBanner(
version: string,
options: BannerOptions = {},
) {
export function emitCliBanner(version: string, options: BannerOptions = {}) {
if (bannerEmitted) return;
const argv = options.argv ?? process.argv;
if (!process.stdout.isTTY) return;

View File

@@ -3,12 +3,12 @@ import fs from "node:fs/promises";
import type { Command } from "commander";
import { callGateway, randomIdempotencyKey } from "../gateway/call.js";
import { defaultRuntime } from "../runtime.js";
import { withProgress } from "./progress.js";
import { writeBase64ToFile } from "./nodes-camera.js";
import {
canvasSnapshotTempPath,
parseCanvasSnapshotPayload,
} from "./nodes-canvas.js";
import { withProgress } from "./progress.js";
type CanvasOpts = {
url?: string;

View File

@@ -160,8 +160,7 @@ function printCronList(jobs: CronJob[], runtime = defaultRuntime) {
const targetLabel = pad(job.sessionTarget, CRON_TARGET_PAD);
const coloredStatus = (() => {
if (statusRaw === "ok")
return colorize(rich, theme.success, statusLabel);
if (statusRaw === "ok") return colorize(rich, theme.success, statusLabel);
if (statusRaw === "error")
return colorize(rich, theme.error, statusLabel);
if (statusRaw === "running")

View File

@@ -1,7 +1,6 @@
import type { Command } from "commander";
import { callGateway, randomIdempotencyKey } from "../gateway/call.js";
import { defaultRuntime } from "../runtime.js";
import { withProgress } from "./progress.js";
import {
type CameraFacing,
cameraTempPath,
@@ -20,6 +19,7 @@ import {
writeScreenRecordToFile,
} from "./nodes-screen.js";
import { parseDurationMs } from "./parse-duration.js";
import { withProgress } from "./progress.js";
type NodesRpcOpts = {
url?: string;

View File

@@ -26,8 +26,10 @@ import { danger, setVerbose } from "../globals.js";
import { autoMigrateLegacyState } from "../infra/state-migrations.js";
import { loginWeb, logoutWeb } from "../provider-web.js";
import { defaultRuntime } from "../runtime.js";
import { isRich, theme } from "../terminal/theme.js";
import { VERSION } from "../version.js";
import { resolveWhatsAppAccount } from "../web/accounts.js";
import { emitCliBanner, formatCliBannerLine } from "./banner.js";
import { registerBrowserCli } from "./browser-cli.js";
import { registerCanvasCli } from "./canvas-cli.js";
import { hasExplicitOptions } from "./command-options.js";
@@ -45,8 +47,6 @@ import { forceFreePort } from "./ports.js";
import { registerProvidersCli } from "./providers-cli.js";
import { registerTelegramCli } from "./telegram-cli.js";
import { registerTuiCli } from "./tui-cli.js";
import { emitCliBanner, formatCliBannerLine } from "./banner.js";
import { isRich, theme } from "../terminal/theme.js";
export { forceFreePort };

View File

@@ -1,8 +1,5 @@
import { spinner } from "@clack/prompts";
import {
createOscProgressController,
supportsOscProgress,
} from "osc-progress";
import { createOscProgressController, supportsOscProgress } from "osc-progress";
import { theme } from "../terminal/theme.js";
@@ -44,11 +41,12 @@ export function createCliProgress(options: ProgressOptions): ProgressReporter {
typeof options.delayMs === "number" ? options.delayMs : DEFAULT_DELAY_MS;
const canOsc = supportsOscProgress(process.env, stream.isTTY);
const allowSpinner =
!canOsc && (options.fallback === undefined || options.fallback === "spinner");
!canOsc &&
(options.fallback === undefined || options.fallback === "spinner");
let started = false;
let label = options.label;
let total = options.total ?? null;
const total = options.total ?? null;
let completed = 0;
let percent = 0;
let indeterminate =
@@ -103,8 +101,7 @@ export function createCliProgress(options: ProgressOptions): ProgressReporter {
const tick = (delta = 1) => {
if (!total) return;
completed = Math.min(total, completed + delta);
const nextPercent =
total > 0 ? Math.round((completed / total) * 100) : 0;
const nextPercent = total > 0 ? Math.round((completed / total) * 100) : 0;
setPercent(nextPercent);
};

View File

@@ -22,7 +22,9 @@ export interface TaglineOptions {
export function activeTaglines(options: TaglineOptions = {}): string[] {
if (TAGLINES.length === 0) return [DEFAULT_TAGLINE];
const today = options.now ? options.now() : new Date();
const filtered = TAGLINES.filter((tagline) => isTaglineActive(tagline, today));
const filtered = TAGLINES.filter((tagline) =>
isTaglineActive(tagline, today),
);
return filtered.length > 0 ? filtered : TAGLINES;
}

View File

@@ -1,4 +1,5 @@
import type { CliDeps } from "../cli/deps.js";
import { withProgress } from "../cli/progress.js";
import { loadConfig } from "../config/config.js";
import {
loadSessionStore,
@@ -7,7 +8,6 @@ import {
} from "../config/sessions.js";
import { callGateway, randomIdempotencyKey } from "../gateway/call.js";
import type { RuntimeEnv } from "../runtime.js";
import { withProgress } from "../cli/progress.js";
import { normalizeMessageProvider } from "../utils/message-provider.js";
import { agentCommand } from "./agent.js";

View File

@@ -21,6 +21,7 @@ import {
CODEX_CLI_PROFILE_ID,
ensureAuthProfileStore,
} from "../agents/auth-profiles.js";
import { createCliProgress } from "../cli/progress.js";
import type { ClawdbotConfig } from "../config/config.js";
import {
CONFIG_PATH_CLAWDBOT,
@@ -31,7 +32,6 @@ import {
import { GATEWAY_LAUNCH_AGENT_LABEL } from "../daemon/constants.js";
import { resolveGatewayProgramArguments } from "../daemon/program-args.js";
import { resolveGatewayService } from "../daemon/service.js";
import { createCliProgress } from "../cli/progress.js";
import { ensureControlUiAssetsBuilt } from "../infra/control-ui-assets.js";
import type { RuntimeEnv } from "../runtime.js";
import { defaultRuntime } from "../runtime.js";

View File

@@ -1,10 +1,10 @@
import { withProgress } from "../cli/progress.js";
import { loadConfig } from "../config/config.js";
import { loadSessionStore, resolveStorePath } from "../config/sessions.js";
import { type DiscordProbe, probeDiscord } from "../discord/probe.js";
import { buildGatewayConnectionDetails, callGateway } from "../gateway/call.js";
import { info } from "../globals.js";
import type { RuntimeEnv } from "../runtime.js";
import { withProgress } from "../cli/progress.js";
import { probeTelegram, type TelegramProbe } from "../telegram/probe.js";
import { resolveTelegramToken } from "../telegram/token.js";
import { resolveWhatsAppAccount } from "../web/accounts.js";

View File

@@ -35,7 +35,11 @@ import {
shouldEnableShellEnvFallback,
} from "../../infra/shell-env.js";
import type { RuntimeEnv } from "../../runtime.js";
import { colorize, isRich as isRichTerminal, theme } from "../../terminal/theme.js";
import {
colorize,
isRich as isRichTerminal,
theme,
} from "../../terminal/theme.js";
import { shortenHomePath } from "../../utils.js";
import {
DEFAULT_MODEL,
@@ -69,8 +73,7 @@ const formatKeyValue = (
valueColor: (value: string) => string = theme.info,
) => `${formatKey(key, rich)}=${colorize(rich, valueColor, value)}`;
const formatSeparator = (rich: boolean) =>
colorize(rich, theme.muted, " | ");
const formatSeparator = (rich: boolean) => colorize(rich, theme.muted, " | ");
const formatTag = (tag: string, rich: boolean) => {
if (!rich) return tag;
@@ -468,7 +471,11 @@ function printModelTable(
);
const coloredLocal = colorize(
rich,
row.local === null ? theme.muted : row.local ? theme.success : theme.muted,
row.local === null
? theme.muted
: row.local
? theme.success
: theme.muted,
localLabel,
);
const coloredAuth = colorize(

View File

@@ -1,4 +1,5 @@
import type { CliDeps } from "../cli/deps.js";
import { withProgress } from "../cli/progress.js";
import { callGateway, randomIdempotencyKey } from "../gateway/call.js";
import { success } from "../globals.js";
import { buildOutboundResultEnvelope } from "../infra/outbound/envelope.js";
@@ -8,7 +9,6 @@ import {
} from "../infra/outbound/format.js";
import { normalizePollInput, type PollInput } from "../polls.js";
import type { RuntimeEnv } from "../runtime.js";
import { withProgress } from "../cli/progress.js";
function parseIntOption(value: unknown, label: string): number | undefined {
if (value === undefined || value === null) return undefined;

View File

@@ -1,4 +1,5 @@
import type { CliDeps } from "../cli/deps.js";
import { withProgress } from "../cli/progress.js";
import { loadConfig } from "../config/config.js";
import { callGateway, randomIdempotencyKey } from "../gateway/call.js";
import { success } from "../globals.js";
@@ -11,7 +12,6 @@ import {
} from "../infra/outbound/format.js";
import { resolveOutboundTarget } from "../infra/outbound/targets.js";
import type { RuntimeEnv } from "../runtime.js";
import { withProgress } from "../cli/progress.js";
import { normalizeMessageProvider } from "../utils/message-provider.js";
export async function sendCommand(

View File

@@ -5,6 +5,7 @@ import {
DEFAULT_PROVIDER,
} from "../agents/defaults.js";
import { resolveConfiguredModelRef } from "../agents/model-selection.js";
import { withProgress } from "../cli/progress.js";
import { loadConfig } from "../config/config.js";
import {
loadSessionStore,
@@ -18,7 +19,6 @@ import {
formatUsageReportLines,
loadProviderUsageSummary,
} from "../infra/provider-usage.js";
import { withProgress } from "../cli/progress.js";
import { peekSystemEvents } from "../infra/system-events.js";
import type { RuntimeEnv } from "../runtime.js";
import { resolveWhatsAppAccount } from "../web/accounts.js";

View File

@@ -37,10 +37,9 @@ const resolveGitHead = (startDir: string) => {
let cachedCommit: string | null | undefined;
export const resolveCommitHash = (options: {
cwd?: string;
env?: NodeJS.ProcessEnv;
} = {}) => {
export const resolveCommitHash = (
options: { cwd?: string; env?: NodeJS.ProcessEnv } = {},
) => {
if (cachedCommit !== undefined) return cachedCommit;
const env = options.env ?? process.env;
const envCommit = env.GIT_COMMIT?.trim() || env.GIT_SHA?.trim();

View File

@@ -11,11 +11,10 @@ import {
spinner,
text,
} from "@clack/prompts";
import type { WizardProgress, WizardPrompter } from "./prompts.js";
import { WizardCancelledError } from "./prompts.js";
import { createCliProgress } from "../cli/progress.js";
import { theme } from "../terminal/theme.js";
import type { WizardProgress, WizardPrompter } from "./prompts.js";
import { WizardCancelledError } from "./prompts.js";
function guardCancel<T>(value: T | symbol): T {
if (isCancel(value)) {