mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 07:51:41 +00:00
refactor(core): dedupe browser route signatures and cli watchdog schema
This commit is contained in:
@@ -22,30 +22,7 @@ export type BrowserServerState = {
|
|||||||
profiles: Map<string, ProfileRuntimeState>;
|
profiles: Map<string, ProfileRuntimeState>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type BrowserRouteContext = {
|
type BrowserProfileActions = {
|
||||||
state: () => BrowserServerState;
|
|
||||||
forProfile: (profileName?: string) => ProfileContext;
|
|
||||||
listProfiles: () => Promise<ProfileStatus[]>;
|
|
||||||
// Legacy methods delegate to default profile for backward compatibility
|
|
||||||
ensureBrowserAvailable: () => Promise<void>;
|
|
||||||
ensureTabAvailable: (targetId?: string) => Promise<BrowserTab>;
|
|
||||||
isHttpReachable: (timeoutMs?: number) => Promise<boolean>;
|
|
||||||
isReachable: (timeoutMs?: number) => Promise<boolean>;
|
|
||||||
listTabs: () => Promise<BrowserTab[]>;
|
|
||||||
openTab: (url: string) => Promise<BrowserTab>;
|
|
||||||
focusTab: (targetId: string) => Promise<void>;
|
|
||||||
closeTab: (targetId: string) => Promise<void>;
|
|
||||||
stopRunningBrowser: () => Promise<{ stopped: boolean }>;
|
|
||||||
resetProfile: () => Promise<{
|
|
||||||
moved: boolean;
|
|
||||||
from: string;
|
|
||||||
to?: string;
|
|
||||||
}>;
|
|
||||||
mapTabError: (err: unknown) => { status: number; message: string } | null;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type ProfileContext = {
|
|
||||||
profile: ResolvedBrowserProfile;
|
|
||||||
ensureBrowserAvailable: () => Promise<void>;
|
ensureBrowserAvailable: () => Promise<void>;
|
||||||
ensureTabAvailable: (targetId?: string) => Promise<BrowserTab>;
|
ensureTabAvailable: (targetId?: string) => Promise<BrowserTab>;
|
||||||
isHttpReachable: (timeoutMs?: number) => Promise<boolean>;
|
isHttpReachable: (timeoutMs?: number) => Promise<boolean>;
|
||||||
@@ -58,6 +35,18 @@ export type ProfileContext = {
|
|||||||
resetProfile: () => Promise<{ moved: boolean; from: string; to?: string }>;
|
resetProfile: () => Promise<{ moved: boolean; from: string; to?: string }>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type BrowserRouteContext = {
|
||||||
|
state: () => BrowserServerState;
|
||||||
|
forProfile: (profileName?: string) => ProfileContext;
|
||||||
|
listProfiles: () => Promise<ProfileStatus[]>;
|
||||||
|
// Legacy methods delegate to default profile for backward compatibility
|
||||||
|
mapTabError: (err: unknown) => { status: number; message: string } | null;
|
||||||
|
} & BrowserProfileActions;
|
||||||
|
|
||||||
|
export type ProfileContext = {
|
||||||
|
profile: ResolvedBrowserProfile;
|
||||||
|
} & BrowserProfileActions;
|
||||||
|
|
||||||
export type ProfileStatus = {
|
export type ProfileStatus = {
|
||||||
name: string;
|
name: string;
|
||||||
cdpPort: number;
|
cdpPort: number;
|
||||||
|
|||||||
@@ -248,6 +248,16 @@ export const HumanDelaySchema = z
|
|||||||
})
|
})
|
||||||
.strict();
|
.strict();
|
||||||
|
|
||||||
|
const CliBackendWatchdogModeSchema = z
|
||||||
|
.object({
|
||||||
|
noOutputTimeoutMs: z.number().int().min(1000).optional(),
|
||||||
|
noOutputTimeoutRatio: z.number().min(0.05).max(0.95).optional(),
|
||||||
|
minMs: z.number().int().min(1000).optional(),
|
||||||
|
maxMs: z.number().int().min(1000).optional(),
|
||||||
|
})
|
||||||
|
.strict()
|
||||||
|
.optional();
|
||||||
|
|
||||||
export const CliBackendSchema = z
|
export const CliBackendSchema = z
|
||||||
.object({
|
.object({
|
||||||
command: z.string(),
|
command: z.string(),
|
||||||
@@ -279,24 +289,8 @@ export const CliBackendSchema = z
|
|||||||
.object({
|
.object({
|
||||||
watchdog: z
|
watchdog: z
|
||||||
.object({
|
.object({
|
||||||
fresh: z
|
fresh: CliBackendWatchdogModeSchema,
|
||||||
.object({
|
resume: CliBackendWatchdogModeSchema,
|
||||||
noOutputTimeoutMs: z.number().int().min(1000).optional(),
|
|
||||||
noOutputTimeoutRatio: z.number().min(0.05).max(0.95).optional(),
|
|
||||||
minMs: z.number().int().min(1000).optional(),
|
|
||||||
maxMs: z.number().int().min(1000).optional(),
|
|
||||||
})
|
|
||||||
.strict()
|
|
||||||
.optional(),
|
|
||||||
resume: z
|
|
||||||
.object({
|
|
||||||
noOutputTimeoutMs: z.number().int().min(1000).optional(),
|
|
||||||
noOutputTimeoutRatio: z.number().min(0.05).max(0.95).optional(),
|
|
||||||
minMs: z.number().int().min(1000).optional(),
|
|
||||||
maxMs: z.number().int().min(1000).optional(),
|
|
||||||
})
|
|
||||||
.strict()
|
|
||||||
.optional(),
|
|
||||||
})
|
})
|
||||||
.strict()
|
.strict()
|
||||||
.optional(),
|
.optional(),
|
||||||
|
|||||||
Reference in New Issue
Block a user