fix(browser): harden CDP readiness
This commit is contained in:
@@ -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`,
|
||||
|
||||
Reference in New Issue
Block a user