refactor(browser): unify navigation guard path and error typing

This commit is contained in:
Peter Steinberger
2026-02-19 14:04:08 +01:00
parent badafdc7b3
commit 9f9cd5cbb2
10 changed files with 133 additions and 36 deletions

View File

@@ -6,6 +6,7 @@ import {
DEFAULT_AI_SNAPSHOT_EFFICIENT_MAX_CHARS,
DEFAULT_AI_SNAPSHOT_MAX_CHARS,
} from "../constants.js";
import { withBrowserNavigationPolicy } from "../navigation-guard.js";
import {
DEFAULT_BROWSER_SCREENSHOT_MAX_BYTES,
DEFAULT_BROWSER_SCREENSHOT_MAX_SIDE,
@@ -65,12 +66,11 @@ export function registerBrowserAgentSnapshotRoutes(
targetId,
feature: "navigate",
run: async ({ cdpUrl, tab, pw }) => {
const ssrfPolicy = ctx.state().resolved.ssrfPolicy;
const result = await pw.navigateViaPlaywright({
cdpUrl,
targetId: tab.targetId,
url,
...(ssrfPolicy ? { ssrfPolicy } : {}),
...withBrowserNavigationPolicy(ctx.state().resolved.ssrfPolicy),
});
res.json({ ok: true, targetId: tab.targetId, ...result });
},

View File

@@ -121,6 +121,7 @@ export function registerBrowserTabRoutes(app: BrowserRouteRegistrar, ctx: Browse
req,
res,
ctx,
mapTabError: true,
run: async (profileCtx) => {
await profileCtx.ensureBrowserAvailable();
const tab = await profileCtx.openTab(url);