mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 08:41:23 +00:00
feat(browser): add ai snapshot refs + click
This commit is contained in:
@@ -103,6 +103,13 @@ export type SnapshotResult =
|
||||
type?: string;
|
||||
value?: string;
|
||||
}>;
|
||||
}
|
||||
| {
|
||||
ok: true;
|
||||
format: "ai";
|
||||
targetId: string;
|
||||
url: string;
|
||||
snapshot: string;
|
||||
};
|
||||
|
||||
function unwrapCause(err: unknown): unknown {
|
||||
@@ -310,7 +317,7 @@ export async function browserDom(
|
||||
export async function browserSnapshot(
|
||||
baseUrl: string,
|
||||
opts: {
|
||||
format: "aria" | "domSnapshot";
|
||||
format: "aria" | "domSnapshot" | "ai";
|
||||
targetId?: string;
|
||||
limit?: number;
|
||||
},
|
||||
@@ -326,3 +333,24 @@ export async function browserSnapshot(
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export async function browserClickRef(
|
||||
baseUrl: string,
|
||||
opts: {
|
||||
ref: string;
|
||||
targetId?: string;
|
||||
},
|
||||
): Promise<{ ok: true; targetId: string; url: string }> {
|
||||
return await fetchJson<{ ok: true; targetId: string; url: string }>(
|
||||
`${baseUrl}/click`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
ref: opts.ref,
|
||||
targetId: opts.targetId,
|
||||
}),
|
||||
timeoutMs: 20000,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user