From 5687a03f0b2c1cc11e65daff953c7b55aaaa8ae7 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 20 Dec 2025 18:38:56 +0100 Subject: [PATCH] chore: biome format --- src/agents/pi-tools.ts | 2 +- src/web/inbound.ts | 30 +++++++++++++++--------------- src/web/login-qr.ts | 24 +++++++++++++++++------- src/web/qr-image.ts | 16 +++++++++------- 4 files changed, 42 insertions(+), 30 deletions(-) diff --git a/src/agents/pi-tools.ts b/src/agents/pi-tools.ts index b21477e71..092f68a16 100644 --- a/src/agents/pi-tools.ts +++ b/src/agents/pi-tools.ts @@ -1,6 +1,6 @@ import type { AgentTool, AgentToolResult } from "@mariozechner/pi-ai"; import { bashTool, codingTools, readTool } from "@mariozechner/pi-coding-agent"; -import { Type, type TSchema } from "@sinclair/typebox"; +import { type TSchema, Type } from "@sinclair/typebox"; import { getImageMetadata, resizeToJpeg } from "../media/image-ops.js"; import { detectMime } from "../media/mime.js"; diff --git a/src/web/inbound.ts b/src/web/inbound.ts index f7f8ea334..51ec075a6 100644 --- a/src/web/inbound.ts +++ b/src/web/inbound.ts @@ -234,21 +234,21 @@ export async function monitorWebInbox(options: { conversationId: from, to: selfE164 ?? "me", body, - pushName: senderName, - timestamp, - chatType: group ? "group" : "direct", - chatId: remoteJid, - senderJid: participantJid, - senderE164: senderE164 ?? undefined, - senderName, - groupSubject, - groupParticipants, - mentionedJids: mentionedJids ?? undefined, - selfJid, - selfE164, - sendComposing, - reply, - sendMedia, + pushName: senderName, + timestamp, + chatType: group ? "group" : "direct", + chatId: remoteJid, + senderJid: participantJid, + senderE164: senderE164 ?? undefined, + senderName, + groupSubject, + groupParticipants, + mentionedJids: mentionedJids ?? undefined, + selfJid, + selfE164, + sendComposing, + reply, + sendMedia, mediaPath, mediaType, }), diff --git a/src/web/login-qr.ts b/src/web/login-qr.ts index 35f60f597..486b2deb6 100644 --- a/src/web/login-qr.ts +++ b/src/web/login-qr.ts @@ -3,6 +3,7 @@ import { randomUUID } from "node:crypto"; import { danger, info, success } from "../globals.js"; import { logInfo } from "../logger.js"; import { defaultRuntime, type RuntimeEnv } from "../runtime.js"; +import { renderQrPngBase64 } from "./qr-image.js"; import { createWaSocket, formatError, @@ -10,7 +11,6 @@ import { waitForWaConnection, webAuthExists, } from "./session.js"; -import { renderQrPngBase64 } from "./qr-image.js"; type WaSocket = Awaited>; @@ -84,9 +84,12 @@ export async function startWebLoginWithQr( rejectQr = reject; }); - const qrTimer = setTimeout(() => { - rejectQr?.(new Error("Timed out waiting for WhatsApp QR")); - }, Math.max(opts.timeoutMs ?? 30_000, 5000)); + const qrTimer = setTimeout( + () => { + rejectQr?.(new Error("Timed out waiting for WhatsApp QR")); + }, + Math.max(opts.timeoutMs ?? 30_000, 5000), + ); let sock: WaSocket; try { @@ -151,7 +154,10 @@ export async function waitForWebLogin( ): Promise<{ connected: boolean; message: string }> { const runtime = opts.runtime ?? defaultRuntime; if (!activeLogin) { - return { connected: false, message: "No active WhatsApp login in progress." }; + return { + connected: false, + message: "No active WhatsApp login in progress.", + }; } const login = activeLogin; @@ -166,12 +172,16 @@ export async function waitForWebLogin( const timeout = new Promise<"timeout">((resolve) => setTimeout(() => resolve("timeout"), timeoutMs), ); - const result = await Promise.race([login.waitPromise.then(() => "done"), timeout]); + const result = await Promise.race([ + login.waitPromise.then(() => "done"), + timeout, + ]); if (result === "timeout") { return { connected: false, - message: "Still waiting for the QR scan. Let me know when you’ve scanned it.", + message: + "Still waiting for the QR scan. Let me know when you’ve scanned it.", }; } diff --git a/src/web/qr-image.ts b/src/web/qr-image.ts index 7c3243700..c4e2a501f 100644 --- a/src/web/qr-image.ts +++ b/src/web/qr-image.ts @@ -12,12 +12,12 @@ type QRCodeConstructor = new ( }; const require = createRequire(import.meta.url); -const QRCode = require( - "qrcode-terminal/vendor/QRCode", -) as QRCodeConstructor; -const QRErrorCorrectLevel = require( - "qrcode-terminal/vendor/QRCode/QRErrorCorrectLevel", -) as Record; +const QRCode = require("qrcode-terminal/vendor/QRCode") as QRCodeConstructor; +const QRErrorCorrectLevel = + require("qrcode-terminal/vendor/QRCode/QRErrorCorrectLevel") as Record< + string, + unknown + >; function createQrMatrix(input: string) { const qr = new QRCode(-1, QRErrorCorrectLevel.L); @@ -85,7 +85,9 @@ function encodePngRgba(buffer: Buffer, width: number, height: number) { } const compressed = deflateSync(raw); - const signature = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]); + const signature = Buffer.from([ + 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, + ]); const ihdr = Buffer.alloc(13); ihdr.writeUInt32BE(width, 0); ihdr.writeUInt32BE(height, 4);