chore: biome format
This commit is contained in:
@@ -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";
|
||||
|
||||
@@ -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,
|
||||
}),
|
||||
|
||||
@@ -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<ReturnType<typeof createWaSocket>>;
|
||||
|
||||
@@ -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.",
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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<string, unknown>;
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user