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(antigravity): give each run its own workspace and sweep stale ones

Shahriare35e747afb43
diff --git a/mcp/src/agent/runners/antigravity.ts b/mcp/src/agent/runners/antigravity.ts
index 5795dba..6780ba1 100644
--- a/mcp/src/agent/runners/antigravity.ts
+++ b/mcp/src/agent/runners/antigravity.ts
@@ -6,7 +6,7 @@ import type { AgentProblem } from '@/lib/agents/catalog';
import { stateDir } from '../../lockfile';
import { log } from '../../log';
import { MCP_SERVER_NAME } from './claude';
-import { effortOf, parseJsonLine } from './util';
+import { effortOf, parseJsonLine, sweepRunDirs } from './util';
import type { JsonContext, McpServer, Plan, Runner, RunMode, StreamContext, StreamReader } from './types';
/** Antigravity reads MCP servers and instructions from the directory it runs in, not from flags. */
@@ -68,8 +68,10 @@ export const antigravityRunner: Runner = {
stream(context: StreamContext): Plan {
const { settings } = context;
const effort = effortOf(settings, this.efforts);
+ const base = this.workspace('run');
+ sweepRunDirs(base);
return {
- cwd: this.workspace('run'),
+ cwd: join(base, context.runId),
env: { BROWSENTIC_AGENT_RUN: context.runId },
files: [
{ path: MCP_CONFIG, content: mcpConfig(context.mcp) },
diff --git a/mcp/src/agent/runners/util.ts b/mcp/src/agent/runners/util.ts
index c4a0194..4fecd35 100644
--- a/mcp/src/agent/runners/util.ts
+++ b/mcp/src/agent/runners/util.ts
@@ -1,6 +1,29 @@
+import { readdirSync, rmSync, statSync } from 'node:fs';
+import { join } from 'node:path';
import { log } from '../../log';
import type { AgentSettings } from '../config';
+const RUN_DIR_TTL_MS = 24 * 60 * 60_000;
+
+/** Concurrent runs each get their own workspace; yesterday's are nobody's. */
+export function sweepRunDirs(base: string, ttlMs = RUN_DIR_TTL_MS): void {
+ let entries: string[];
+ try {
+ entries = readdirSync(base);
+ } catch {
+ return;
+ }
+ const cutoff = Date.now() - ttlMs;
+ for (const entry of entries) {
+ const path = join(base, entry);
+ try {
+ if (statSync(path).mtimeMs < cutoff) rmSync(path, { recursive: true, force: true });
+ } catch {
+ continue;
+ }
+ }
+}
+
/** Drops a reasoning-effort name the CLI would reject rather than letting it fail the run. */
export function effortOf(settings: AgentSettings, accepted: string[]): string | undefined {
const effort = settings.effort;