fix(browser): remove stale snapshotForAI references

This commit is contained in:
Peter Steinberger
2026-04-25 00:10:00 +01:00
parent 5d9941c36d
commit c735b59043
5 changed files with 10 additions and 28 deletions

View File

@@ -157,7 +157,7 @@ function canRetryChromeActWithoutTargetId(request: Parameters<typeof browserAct>
function isAriaRefsUnsupportedError(err: unknown): boolean {
const msg = String(err).toLowerCase();
return msg.includes("refs=aria") && msg.includes("_snapshotforai");
return msg.includes("refs=aria") && msg.includes("not support");
}
function withRoleRefsFallback<T extends { refs?: "aria" | "role" }>(

View File

@@ -512,9 +512,7 @@ describe("browser tool snapshot maxChars", () => {
it("falls back to role refs when a node snapshot cannot provide aria refs", async () => {
mockSingleBrowserProxyNode();
gatewayMocks.callGatewayTool
.mockRejectedValueOnce(
new Error("INVALID_REQUEST: Error: refs=aria requires Playwright _snapshotForAI support."),
)
.mockRejectedValueOnce(new Error("INVALID_REQUEST: Error: refs=aria not supported."))
.mockResolvedValueOnce({
ok: true,
payload: {

View File

@@ -13,7 +13,6 @@ export {
getPageForTargetId,
listPagesViaPlaywright,
refLocator,
type WithSnapshotForAI,
} from "./pw-session.js";
export {

View File

@@ -57,13 +57,6 @@ export type BrowserNetworkRequest = {
failureText?: string;
};
type SnapshotForAIResult = { full: string; incremental?: string };
type SnapshotForAIOptions = { timeout?: number; track?: string };
export type WithSnapshotForAI = {
_snapshotForAI?: (options?: SnapshotForAIOptions) => Promise<SnapshotForAIResult>;
};
type TargetInfoResponse = {
targetInfo?: {
targetId?: string;

View File

@@ -481,22 +481,14 @@ export function registerBrowserAgentSnapshotRoutes(
const snap = plan.wantsRoleSnapshot
? await pw.snapshotRoleViaPlaywright(roleSnapshotArgs)
: await pw
.snapshotAiViaPlaywright({
cdpUrl: profileCtx.profile.cdpUrl,
targetId: tab.targetId,
ssrfPolicy: ctx.state().resolved.ssrfPolicy,
...(typeof plan.resolvedMaxChars === "number"
? { maxChars: plan.resolvedMaxChars }
: {}),
})
.catch(async (err) => {
// Public-API fallback when Playwright's private _snapshotForAI is missing.
if (String(err).toLowerCase().includes("_snapshotforai")) {
return await pw.snapshotRoleViaPlaywright(roleSnapshotArgs);
}
throw err;
});
: await pw.snapshotAiViaPlaywright({
cdpUrl: profileCtx.profile.cdpUrl,
targetId: tab.targetId,
ssrfPolicy: ctx.state().resolved.ssrfPolicy,
...(typeof plan.resolvedMaxChars === "number"
? { maxChars: plan.resolvedMaxChars }
: {}),
});
if (plan.labels) {
const labeled = await pw.screenshotWithLabelsViaPlaywright({
cdpUrl: profileCtx.profile.cdpUrl,