feat(browser): add ai snapshot refs + click

This commit is contained in:
Peter Steinberger
2025-12-13 18:48:55 +00:00
parent a59cfa7670
commit ba22890205
6 changed files with 431 additions and 10 deletions

View File

@@ -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,
},
);
}