From dc3e3f27d4ce8b79029dd330cd4b94f4a8c9e845 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Thu, 8 Jan 2026 04:44:11 +0000 Subject: [PATCH] style: apply lint fixes --- src/agents/bash-tools.test.ts | 4 +- src/agents/model-scan.ts | 78 ++++++++++++------------- src/auto-reply/media-note.test.ts | 1 - src/auto-reply/media-note.ts | 13 ++--- src/auto-reply/reply.media-note.test.ts | 4 +- src/auto-reply/reply.ts | 16 ++--- src/auto-reply/status.ts | 1 - src/cli/banner.ts | 5 +- src/cli/canvas-cli.ts | 2 +- src/cli/cron-cli.ts | 3 +- src/cli/nodes-cli.ts | 2 +- src/cli/program.ts | 4 +- src/cli/progress.ts | 13 ++--- src/cli/tagline.ts | 4 +- src/commands/agent-via-gateway.ts | 2 +- src/commands/configure.ts | 2 +- src/commands/health.ts | 2 +- src/commands/models/list.ts | 15 +++-- src/commands/poll.ts | 2 +- src/commands/send.ts | 2 +- src/commands/status.ts | 2 +- src/infra/git-commit.ts | 7 +-- src/wizard/clack-prompter.ts | 5 +- 23 files changed, 94 insertions(+), 95 deletions(-) diff --git a/src/agents/bash-tools.test.ts b/src/agents/bash-tools.test.ts index 15ca2b0fc..4a94ce46d 100644 --- a/src/agents/bash-tools.test.ts +++ b/src/agents/bash-tools.test.ts @@ -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") diff --git a/src/agents/model-scan.ts b/src/agents/model-scan.ts index a36016ee8..664eb22a1 100644 --- a/src/agents/model-scan.ts +++ b/src/agents/model-scan.ts @@ -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?.({ diff --git a/src/auto-reply/media-note.test.ts b/src/auto-reply/media-note.test.ts index ac50b552f..3e6dd3527 100644 --- a/src/auto-reply/media-note.test.ts +++ b/src/auto-reply/media-note.test.ts @@ -26,4 +26,3 @@ describe("buildInboundMediaNote", () => { ); }); }); - diff --git a/src/auto-reply/media-note.ts b/src/auto-reply/media-note.ts index 3460c0911..7917c9d7a 100644 --- a/src/auto-reply/media-note.ts +++ b/src/auto-reply/media-note.ts @@ -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 = diff --git a/src/auto-reply/reply.media-note.test.ts b/src/auto-reply/reply.media-note.test.ts index fd2133b9e..6a625fd06 100644 --- a/src/auto-reply/reply.media-note.test.ts +++ b/src/auto-reply/reply.media-note.test.ts @@ -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", () => { }); }); }); - diff --git a/src/auto-reply/reply.ts b/src/auto-reply/reply.ts index 072b33c86..224518f4d 100644 --- a/src/auto-reply/reply.ts +++ b/src/auto-reply/reply.ts @@ -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({ diff --git a/src/auto-reply/status.ts b/src/auto-reply/status.ts index baa0b233c..a6a5c8588 100644 --- a/src/auto-reply/status.ts +++ b/src/auto-reply/status.ts @@ -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; diff --git a/src/cli/banner.ts b/src/cli/banner.ts index bfd882891..3153d5a81 100644 --- a/src/cli/banner.ts +++ b/src/cli/banner.ts @@ -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; diff --git a/src/cli/canvas-cli.ts b/src/cli/canvas-cli.ts index 875b66104..bde5ced6b 100644 --- a/src/cli/canvas-cli.ts +++ b/src/cli/canvas-cli.ts @@ -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; diff --git a/src/cli/cron-cli.ts b/src/cli/cron-cli.ts index ec32ad5cc..636698de4 100644 --- a/src/cli/cron-cli.ts +++ b/src/cli/cron-cli.ts @@ -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") diff --git a/src/cli/nodes-cli.ts b/src/cli/nodes-cli.ts index aa32b82cf..a2ab3a8a6 100644 --- a/src/cli/nodes-cli.ts +++ b/src/cli/nodes-cli.ts @@ -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; diff --git a/src/cli/program.ts b/src/cli/program.ts index 5c63775b3..55227d739 100644 --- a/src/cli/program.ts +++ b/src/cli/program.ts @@ -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 }; diff --git a/src/cli/progress.ts b/src/cli/progress.ts index 33226cc98..e7e6c5862 100644 --- a/src/cli/progress.ts +++ b/src/cli/progress.ts @@ -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); }; diff --git a/src/cli/tagline.ts b/src/cli/tagline.ts index 3b5530d34..20b49ebc0 100644 --- a/src/cli/tagline.ts +++ b/src/cli/tagline.ts @@ -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; } diff --git a/src/commands/agent-via-gateway.ts b/src/commands/agent-via-gateway.ts index d6941aec6..18afb4d0b 100644 --- a/src/commands/agent-via-gateway.ts +++ b/src/commands/agent-via-gateway.ts @@ -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"; diff --git a/src/commands/configure.ts b/src/commands/configure.ts index c4d794382..549e3d95d 100644 --- a/src/commands/configure.ts +++ b/src/commands/configure.ts @@ -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"; diff --git a/src/commands/health.ts b/src/commands/health.ts index b4be98e07..4599deee4 100644 --- a/src/commands/health.ts +++ b/src/commands/health.ts @@ -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"; diff --git a/src/commands/models/list.ts b/src/commands/models/list.ts index 72a4636b7..a7ad9445d 100644 --- a/src/commands/models/list.ts +++ b/src/commands/models/list.ts @@ -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( diff --git a/src/commands/poll.ts b/src/commands/poll.ts index 1f5e0aac9..d53b69a41 100644 --- a/src/commands/poll.ts +++ b/src/commands/poll.ts @@ -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; diff --git a/src/commands/send.ts b/src/commands/send.ts index 114d8218f..f2cd1c159 100644 --- a/src/commands/send.ts +++ b/src/commands/send.ts @@ -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( diff --git a/src/commands/status.ts b/src/commands/status.ts index 0b7e14c73..a51e816a2 100644 --- a/src/commands/status.ts +++ b/src/commands/status.ts @@ -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"; diff --git a/src/infra/git-commit.ts b/src/infra/git-commit.ts index 34c684323..435c702ed 100644 --- a/src/infra/git-commit.ts +++ b/src/infra/git-commit.ts @@ -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(); diff --git a/src/wizard/clack-prompter.ts b/src/wizard/clack-prompter.ts index 4cf985e86..537fcfc5a 100644 --- a/src/wizard/clack-prompter.ts +++ b/src/wizard/clack-prompter.ts @@ -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(value: T | symbol): T { if (isCancel(value)) {