Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(acp): follow replaced provider logs during quiet turns
Afloat8431cf267295
diff --git a/server/drivers/acp/quiet-log-rotation.test.ts b/server/drivers/acp/quiet-log-rotation.test.tsnew file mode 100644index 0000000000..4eeb19b1d5--- /dev/null+++ b/server/drivers/acp/quiet-log-rotation.test.ts@@ -0,0 +1,68 @@+import { appendFileSync, mkdtempSync, renameSync, rmSync, writeFileSync } from "node:fs";+import { tmpdir } from "node:os";+import { join } from "node:path";+import { afterEach, describe, expect, it } from "vitest";+import { LogTail, parseQwenLogLine, classifyQuiet } from "./quiet-status.ts";++const dirs: string[] = [];+function fixture(contents: string) {+ const dir = mkdtempSync(join(tmpdir(), "omb-quiet-rotation-"));+ dirs.push(dir);+ const file = join(dir, "agent.log");+ writeFileSync(file, contents);+ const tail = new LogTail(file);+ expect(tail.read()).toEqual([]);+ return { file, tail, replace(text: string) { renameSync(file, `${file}.old`); writeFileSync(file, text); } };+}+afterEach(() => { for (const dir of dirs.splice(0)) rmSync(dir, { recursive: true, force: true }); });++describe("quiet log replacement", () => {+ it("reads a replacement whose size equals the previous log", () => {+ const h = fixture("old row\n");+ h.replace("new row\n");+ expect(h.tail.read()).toEqual(["new row"]);+ expect(h.tail.read()).toEqual([]);+ });++ it("reads a larger replacement from its beginning", () => {+ const h = fixture("old\n");+ h.replace("first new row\nsecond new row\n");+ expect(h.tail.read()).toEqual(["first new row", "second new row"]);+ appendFileSync(h.file, "third new row\n");+ expect(h.tail.read()).toEqual(["third new row"]);+ });++ it("does not join an unfinished old row to the replacement's first row", () => {+ const h = fixture("old\n");+ appendFileSync(h.file, "incomplete-old-row");+ expect(h.tail.read()).toEqual([]);+ h.replace("this new row is longer than the previous file\n");+ expect(h.tail.read()).toEqual(["this new row is longer than the previous file"]);+ });++ it("keeps observing retries when rotation includes a missing-file interval", () => {+ const h = fixture("old\n");+ renameSync(h.file, `${h.file}.old`);+ expect(h.tail.read()).toEqual([]);+ const retry = "[WARN] [RETRY] Attempt 3 failed with status 429. Retrying in 12s...";+ writeFileSync(h.file, `${retry}\n`);+ const lines = h.tail.read();+ expect(lines).toEqual([retry]);+ const logged = parseQwenLogLine(lines[0]!);+ expect(classifyQuiet({ logged, context: null, sample: { cpuMs: 0, connections: 0 }, previous: { cpuMs: 0, connections: 0 }, sinceMs: 15_000 }))+ .toEqual({ kind: "retrying", status: 429, delayMs: 12_000, attempt: 3 });+ });++ it("continues to ignore history on first open and follows same-file appends", () => {+ const h = fixture("old\n");+ appendFileSync(h.file, "new\n");+ expect(h.tail.read()).toEqual(["new"]);+ expect(h.tail.read()).toEqual([]);+ });++ it("keeps same-file truncation recovery", () => {+ const h = fixture("a long historical row\n");+ writeFileSync(h.file, "short\n");+ expect(h.tail.read()).toEqual(["short"]);+ });+});diff --git a/server/drivers/acp/quiet-status.ts b/server/drivers/acp/quiet-status.tsindex 854c2a3552..bb4f9c24c7 100644--- a/server/drivers/acp/quiet-status.ts+++ b/server/drivers/acp/quiet-status.ts@@ -96,6 +96,7 @@ export function parseOpenCodeLogLine(line: string, sessionId: string): LogSignalexport class LogTail {private offset: number | null = null;+ private identity: string | null = null;private partial = "";private readonly path: string;private readonly maxBytes: number;@@ -113,7 +114,11 @@ export class LogTail {return [];}try {- const size = fstatSync(fd).size;+ const stat = fstatSync(fd);+ const size = stat.size;+ const identity = `${stat.dev}:${stat.ino}`;+ if (this.identity !== null && this.identity !== identity) { this.offset = 0; this.partial = ""; }+ this.identity = identity;if (this.offset === null) {this.offset = size;return [];