fix(browser): harden CDP readiness

This commit is contained in:
Peter Steinberger
2026-01-01 16:15:12 +00:00
parent 9f704d7aa7
commit 538c1eb660
7 changed files with 269 additions and 27 deletions

View File

@@ -6,6 +6,8 @@ export type BrowserStatus = {
enabled: boolean;
controlUrl: string;
running: boolean;
cdpReady?: boolean;
cdpHttp?: boolean;
pid: number | null;
cdpPort: number;
chosenBrowser: string | null;
@@ -15,6 +17,13 @@ export type BrowserStatus = {
attachOnly: boolean;
};
export type BrowserResetProfileResult = {
ok: true;
moved: boolean;
from: string;
to?: string;
};
export type BrowserTab = {
targetId: string;
title: string;
@@ -75,6 +84,18 @@ export async function browserStop(baseUrl: string): Promise<void> {
});
}
export async function browserResetProfile(
baseUrl: string,
): Promise<BrowserResetProfileResult> {
return await fetchBrowserJson<BrowserResetProfileResult>(
`${baseUrl}/reset-profile`,
{
method: "POST",
timeoutMs: 20000,
},
);
}
export async function browserTabs(baseUrl: string): Promise<BrowserTab[]> {
const res = await fetchBrowserJson<{ running: boolean; tabs: BrowserTab[] }>(
`${baseUrl}/tabs`,