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.
TypeScript agentic-browseragentic-browsingagy-cliaiai-agentai-browser-extensionai-toolsbrave-extensionbrowser-agentbrowser-automationbrowser-extensionbrowser-usebrowserskillchrome-extensionclaude-codecodexfirefox-addonmcp-servernanobrowserweb-automation
feat(agent): add skillsDir and site map bounds to the config
Shahriar09fffd011fd7
diff --git a/mcp/src/agent/config.ts b/mcp/src/agent/config.tsindex 682d65f..ab7f7a0 100644--- a/mcp/src/agent/config.ts+++ b/mcp/src/agent/config.ts@@ -25,6 +25,55 @@ export interface AgentConfig {* dotted `~/.voicelink` state dir, since screenshots are user-facing artifacts to browse.*/screenshotDir?: string;+ /**+ * Where skills uploaded from the extension are written. Absolute path; `~` is expanded.+ * Defaults to `~/voicelink/skills` — user-facing like the screenshot dir, and separate from+ * the hand-authored `~/.voicelink/skills` so the daemon only ever writes files it owns.+ */+ skillsDir?: string;+ /** Bounds on a site-mapping run. Every value is clamped on read — see `readAgentConfig`. */+ siteMap?: {+ /** Let the mapping run use WebSearch/WebFetch for public background. Default true. */+ research?: boolean;+ /** Let it click, to reach routes that only exist behind an interaction. Default false. */+ allowClicks?: boolean;+ maxPages?: number;+ maxScreenshots?: number;+ /** Wall clock for the whole run, after which it is aborted and whatever it has is kept. */+ timeoutMs?: number;+ };+}++/** Defaults and hard bounds for a mapping run; a config value may narrow these, never widen them. */+export const SITE_MAP_LIMITS = {+ pages: { fallback: 15, max: 40 },+ screenshots: { fallback: 10, max: 24 },+ timeoutMs: { fallback: 10 * 60_000, max: 30 * 60_000 },+} as const;++export interface SiteMapSettings {+ research: boolean;+ allowClicks: boolean;+ maxPages: number;+ maxScreenshots: number;+ timeoutMs: number;+}++/** Resolve the mapping bounds, clamping anything a malformed config might try to widen. */+export function siteMapSettings(config: AgentConfig): SiteMapSettings {+ const stored = config.siteMap ?? {};+ return {+ research: stored.research !== false,+ allowClicks: stored.allowClicks === true,+ maxPages: clamp(stored.maxPages, SITE_MAP_LIMITS.pages),+ maxScreenshots: clamp(stored.maxScreenshots, SITE_MAP_LIMITS.screenshots),+ timeoutMs: clamp(stored.timeoutMs, SITE_MAP_LIMITS.timeoutMs),+ };+}++function clamp(value: unknown, { fallback, max }: { fallback: number; max: number }): number {+ if (typeof value !== 'number' || !Number.isFinite(value) || value < 1) return fallback;+ return Math.min(Math.floor(value), max);}export const configPath = join(stateDir, 'config.json');diff --git a/mcp/src/screenshots.ts b/mcp/src/screenshots.tsindex e4ac4a6..1dc6be9 100644--- a/mcp/src/screenshots.ts+++ b/mcp/src/screenshots.ts@@ -1,8 +1,9 @@import { randomBytes } from 'node:crypto';import { chmodSync, mkdirSync, writeFileSync } from 'node:fs';import { homedir } from 'node:os';-import { basename, isAbsolute, join } from 'node:path';+import { basename, isAbsolute, join, resolve, sep } from 'node:path';import { readAgentConfig } from './agent/config';+import { uploadedSkillsDir } from './agent/skills';/*** Save a base64 `data:` image (produced by the `page.screenshot` capture in the background) to@@ -10,9 +11,9 @@ import { readAgentConfig } from './agent/config';* `config.screenshotDir` (from `~/.voicelink/config.json`) or, by default, the user-facing* `~/voicelink/screenshot`. Mirrors the mkdir/write pattern in `lockfile.ts`.*/-export function saveScreenshot(dataUrl: string, opts: { filename?: string } = {}): string {+export function saveScreenshot(dataUrl: string, opts: { filename?: string; dir?: string } = {}): string {const { mime, bytes } = parseDataUrl(dataUrl);- const dir = resolveDir();+ const dir = opts.dir ? containedSkillDir(opts.dir) : resolveDir();mkdirSync(dir, { recursive: true, mode: 0o700 });const ext = extensionFor(mime);@@ -27,6 +28,20 @@ export function saveScreenshot(dataUrl: string, opts: { filename?: string } = {}return target;}+/**+ * An explicit destination is only ever computed by the daemon (a mapping run's staging+ * directory), never taken from a caller — but this is the one place a constructed path reaches+ * `mkdirSync`/`writeFileSync`, so it is worth asserting rather than assuming.+ */+function containedSkillDir(dir: string): string {+ const root = resolve(uploadedSkillsDir());+ const target = resolve(dir);+ if (target !== root && !target.startsWith(root + sep)) {+ throw new Error(`refusing to write a screenshot outside ${root}`);+ }+ return target;+}+function resolveDir(): string {const configured = readAgentConfig().screenshotDir;if (typeof configured === 'string' && configured.trim()) return expandHome(configured.trim());