Skip to content

An agentic browser harness: an AI side panel & orb in your own logged-in Chrome, Edge, Arc, Brave or even Firefox run by the agent/subscription you already use (Claude Code, Codex, Antigravity). Free, open source, no API key. Also an MCP server.

fix(agents): renew a run's folder on every turn, because a conversation's folder kept its first turn's time and the sweep would take it a day later mid-conversation

Shahriarb31a63604b6c
diff --git a/src/daemon/agent/runners/drive.test.ts b/src/daemon/agent/runners/drive.test.ts
index db233d9..8d3daa9 100644
--- a/src/daemon/agent/runners/drive.test.ts
+++ b/src/daemon/agent/runners/drive.test.ts
@@ -1,5 +1,5 @@
import { once } from 'node:events';
-import { existsSync, readFileSync, statSync } from 'node:fs';
+import { existsSync, readFileSync, statSync, utimesSync } from 'node:fs';
import { join } from 'node:path';
import type { Readable } from 'node:stream';
import { afterEach, describe, expect, test, vi } from 'vitest';
@@ -108,6 +108,15 @@ describe('a streamed run', () => {
}).toEqual({ said: 'You are Browsentic.\n', directory: 0o700, instructions: 0o600, mcpConfig: 0o600 });
});
+ test("a folder a conversation keeps is new again on every turn, so the sweep ages it from its last", async () => {
+ const cwd = join(antigravityRunner.workspace('run'), 'kept-run');
+ await run(standIn(printing(['done', 'end_turn'])), { runId: 'kept-run' });
+ const nearlyADayAgo = new Date(Date.now() - 23 * 60 * 60_000);
+ utimesSync(cwd, nearlyADayAgo, nearlyADayAgo);
+ await run(standIn(printing(['done', 'end_turn'])), { runId: 'kept-run' });
+ expect(statSync(cwd).mtimeMs).toBeGreaterThan(Date.now() - 60_000);
+ });
+
test('a run that finished is not undone by the exit code that follows', async () => {
expect((await run(standIn(`${printing(['done', 'end_turn'])} process.exitCode = 2;`))).outcome.stopReason).toBe('end_turn');
});
diff --git a/src/daemon/agent/runners/drive.ts b/src/daemon/agent/runners/drive.ts
index e55372d..35d067c 100644
--- a/src/daemon/agent/runners/drive.ts
+++ b/src/daemon/agent/runners/drive.ts
@@ -1,5 +1,5 @@
import { spawn, type ChildProcessByStdio } from 'node:child_process';
-import { mkdirSync, writeFileSync } from 'node:fs';
+import { mkdirSync, utimesSync, writeFileSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { createInterface } from 'node:readline';
import type { Readable, Writable } from 'node:stream';
@@ -52,6 +52,10 @@ export function launch(
mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
writeFileSync(path, file.content, { mode: 0o600 });
}
+ // The sweep ages a workspace by its folder's time, which rewriting a file already in it leaves
+ // alone — so a conversation's folder would be swept a day after its first turn, not its last.
+ const now = new Date();
+ utimesSync(plan.cwd, now, now);
const dropped = sealedAway(kind, process.env);
if (dropped.length) log(`sealed ${dropped.length} credential-shaped variables out of the ${kind} environment`);