style: fix biome lint errors

This commit is contained in:
Joao Lisboa
2025-12-02 17:11:45 -03:00
committed by Peter Steinberger
parent 499a3e3227
commit d8b1a38350
3 changed files with 22 additions and 11 deletions

View File

@@ -189,7 +189,7 @@ export async function runCommandReply(
systemSent, systemSent,
identityPrefix: agentCfg.identityPrefix, identityPrefix: agentCfg.identityPrefix,
format: agentCfg.format, format: agentCfg.format,
}) })
: argv; : argv;
logVerbose( logVerbose(
@@ -208,7 +208,7 @@ export async function runCommandReply(
const rpcArgv = (() => { const rpcArgv = (() => {
const copy = [...finalArgv]; const copy = [...finalArgv];
copy.splice(bodyIndex, 1); copy.splice(bodyIndex, 1);
const modeIdx = copy.findIndex((a) => a === "--mode"); const modeIdx = copy.indexOf("--mode");
if (modeIdx >= 0 && copy[modeIdx + 1]) { if (modeIdx >= 0 && copy[modeIdx + 1]) {
copy.splice(modeIdx, 2, "--mode", "rpc"); copy.splice(modeIdx, 2, "--mode", "rpc");
} else if (!copy.includes("--mode")) { } else if (!copy.includes("--mode")) {
@@ -231,7 +231,9 @@ export async function runCommandReply(
queuedMs = waitMs; queuedMs = waitMs;
queuedAhead = ahead; queuedAhead = ahead;
if (isVerbose()) { if (isVerbose()) {
logVerbose(`Command auto-reply queued for ${waitMs}ms (${queuedAhead} ahead)`); logVerbose(
`Command auto-reply queued for ${waitMs}ms (${queuedAhead} ahead)`,
);
} }
}, },
}); });

View File

@@ -1,4 +1,4 @@
import { spawn, type ChildProcessWithoutNullStreams } from "node:child_process"; import { type ChildProcessWithoutNullStreams, spawn } from "node:child_process";
import readline from "node:readline"; import readline from "node:readline";
type TauRpcOptions = { type TauRpcOptions = {
@@ -22,7 +22,10 @@ class TauRpcClient {
} }
| undefined; | undefined;
constructor(private readonly argv: string[], private readonly cwd: string | undefined) {} constructor(
private readonly argv: string[],
private readonly cwd: string | undefined,
) {}
private ensureChild() { private ensureChild() {
if (this.child) return; if (this.child) return;
@@ -37,7 +40,9 @@ class TauRpcClient {
}); });
this.child.on("exit", (code, signal) => { this.child.on("exit", (code, signal) => {
if (this.pending) { if (this.pending) {
this.pending.reject(new Error(`tau rpc exited (code=${code}, signal=${signal})`)); this.pending.reject(
new Error(`tau rpc exited (code=${code}, signal=${signal})`),
);
clearTimeout(this.pending.timer); clearTimeout(this.pending.timer);
this.pending = undefined; this.pending = undefined;
} }
@@ -49,7 +54,10 @@ class TauRpcClient {
if (!this.pending) return; if (!this.pending) return;
this.buffer.push(line); this.buffer.push(line);
// Finish on assistant message_end event to mirror parse logic in piSpec // Finish on assistant message_end event to mirror parse logic in piSpec
if (line.includes('"type":"message_end"') && line.includes('"role":"assistant"')) { if (
line.includes('"type":"message_end"') &&
line.includes('"role":"assistant"')
) {
const out = this.buffer.join("\n"); const out = this.buffer.join("\n");
clearTimeout(this.pending.timer); clearTimeout(this.pending.timer);
const pending = this.pending; const pending = this.pending;
@@ -64,13 +72,14 @@ class TauRpcClient {
if (this.pending) { if (this.pending) {
throw new Error("tau rpc already handling a request"); throw new Error("tau rpc already handling a request");
} }
const child = this.child!; const child = this.child;
if (!child) throw new Error("tau rpc child not initialized");
await new Promise<void>((resolve, reject) => { await new Promise<void>((resolve, reject) => {
const ok = child.stdin.write( const ok = child.stdin.write(
JSON.stringify({ `${JSON.stringify({
type: "prompt", type: "prompt",
message: { role: "user", content: [{ type: "text", text: prompt }] }, message: { role: "user", content: [{ type: "text", text: prompt }] },
}) + "\n", })}\n`,
(err) => (err ? reject(err) : resolve()), (err) => (err ? reject(err) : resolve()),
); );
if (!ok) child.stdin.once("drain", () => resolve()); if (!ok) child.stdin.once("drain", () => resolve());

View File

@@ -41,7 +41,7 @@ export async function sendMessageWeb(
const mimetype = const mimetype =
media.contentType === "audio/ogg" media.contentType === "audio/ogg"
? "audio/ogg; codecs=opus" ? "audio/ogg; codecs=opus"
: media.contentType ?? "application/octet-stream"; : (media.contentType ?? "application/octet-stream");
payload = { audio: media.buffer, ptt: true, mimetype }; payload = { audio: media.buffer, ptt: true, mimetype };
} else if (media.kind === "video") { } else if (media.kind === "video") {
const mimetype = media.contentType ?? "application/octet-stream"; const mimetype = media.contentType ?? "application/octet-stream";