mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 15:40:44 +00:00
fix(browser): remove stale snapshotForAI references
This commit is contained in:
@@ -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" }>(
|
||||
|
||||
@@ -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: {
|
||||
|
||||
@@ -13,7 +13,6 @@ export {
|
||||
getPageForTargetId,
|
||||
listPagesViaPlaywright,
|
||||
refLocator,
|
||||
type WithSnapshotForAI,
|
||||
} from "./pw-session.js";
|
||||
|
||||
export {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user