fix(browser): remove stale snapshotForAI references · openclaw/openclaw@c735b59
steipete
·
2026-04-25
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -157,7 +157,7 @@ function canRetryChromeActWithoutTargetId(request: Parameters<typeof browserAct>
|
157 | 157 | |
158 | 158 | function isAriaRefsUnsupportedError(err: unknown): boolean { |
159 | 159 | const msg = String(err).toLowerCase(); |
160 | | -return msg.includes("refs=aria") && msg.includes("_snapshotforai"); |
| 160 | +return msg.includes("refs=aria") && msg.includes("not support"); |
161 | 161 | } |
162 | 162 | |
163 | 163 | function withRoleRefsFallback<T extends { refs?: "aria" | "role" }>( |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -512,9 +512,7 @@ describe("browser tool snapshot maxChars", () => {
|
512 | 512 | it("falls back to role refs when a node snapshot cannot provide aria refs", async () => { |
513 | 513 | mockSingleBrowserProxyNode(); |
514 | 514 | gatewayMocks.callGatewayTool |
515 | | -.mockRejectedValueOnce( |
516 | | -new Error("INVALID_REQUEST: Error: refs=aria requires Playwright _snapshotForAI support."), |
517 | | -) |
| 515 | +.mockRejectedValueOnce(new Error("INVALID_REQUEST: Error: refs=aria not supported.")) |
518 | 516 | .mockResolvedValueOnce({ |
519 | 517 | ok: true, |
520 | 518 | payload: { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -13,7 +13,6 @@ export {
|
13 | 13 | getPageForTargetId, |
14 | 14 | listPagesViaPlaywright, |
15 | 15 | refLocator, |
16 | | -type WithSnapshotForAI, |
17 | 16 | } from "./pw-session.js"; |
18 | 17 | |
19 | 18 | export { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -57,13 +57,6 @@ export type BrowserNetworkRequest = {
|
57 | 57 | failureText?: string; |
58 | 58 | }; |
59 | 59 | |
60 | | -type SnapshotForAIResult = { full: string; incremental?: string }; |
61 | | -type SnapshotForAIOptions = { timeout?: number; track?: string }; |
62 | | - |
63 | | -export type WithSnapshotForAI = { |
64 | | -_snapshotForAI?: (options?: SnapshotForAIOptions) => Promise<SnapshotForAIResult>; |
65 | | -}; |
66 | | - |
67 | 60 | type TargetInfoResponse = { |
68 | 61 | targetInfo?: { |
69 | 62 | targetId?: string; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -481,22 +481,14 @@ export function registerBrowserAgentSnapshotRoutes(
|
481 | 481 | |
482 | 482 | const snap = plan.wantsRoleSnapshot |
483 | 483 | ? await pw.snapshotRoleViaPlaywright(roleSnapshotArgs) |
484 | | - : await pw |
485 | | -.snapshotAiViaPlaywright({ |
486 | | -cdpUrl: profileCtx.profile.cdpUrl, |
487 | | -targetId: tab.targetId, |
488 | | -ssrfPolicy: ctx.state().resolved.ssrfPolicy, |
489 | | - ...(typeof plan.resolvedMaxChars === "number" |
490 | | - ? { maxChars: plan.resolvedMaxChars } |
491 | | - : {}), |
492 | | -}) |
493 | | -.catch(async (err) => { |
494 | | -// Public-API fallback when Playwright's private _snapshotForAI is missing. |
495 | | -if (String(err).toLowerCase().includes("_snapshotforai")) { |
496 | | -return await pw.snapshotRoleViaPlaywright(roleSnapshotArgs); |
497 | | -} |
498 | | -throw err; |
499 | | -}); |
| 484 | + : await pw.snapshotAiViaPlaywright({ |
| 485 | +cdpUrl: profileCtx.profile.cdpUrl, |
| 486 | +targetId: tab.targetId, |
| 487 | +ssrfPolicy: ctx.state().resolved.ssrfPolicy, |
| 488 | + ...(typeof plan.resolvedMaxChars === "number" |
| 489 | + ? { maxChars: plan.resolvedMaxChars } |
| 490 | + : {}), |
| 491 | +}); |
500 | 492 | if (plan.labels) { |
501 | 493 | const labeled = await pw.screenshotWithLabelsViaPlaywright({ |
502 | 494 | cdpUrl: profileCtx.profile.cdpUrl, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。