mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-25 02:32:47 +00:00
* feat(browser): generalize browser automation hosts Rename the browser automation client capability to a host-neutral payload, advertise supported commands, and route tab-scoped commands by browserId affinity so future browser hosts can register without another protocol shape change. * fix(browser): harden browser host registration Reject unusable browser host capabilities, clean up pending requests when a host registration is replaced, and defer list_tabs affinity updates until every host in the aggregation succeeds. * fix(browser): preserve host tab affinity across reconnects Keep stranded tab ownership tied to the disconnected host so the same host can reclaim open tabs after reconnect, and tolerate future command names in browser_host capability payloads while retaining only known commands.
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import { z } from "zod";
|
|
import {
|
|
BROWSER_AUTOMATION_COMMAND_NAMES,
|
|
type BrowserAutomationCommandName,
|
|
} from "./rpc-schemas.js";
|
|
|
|
const KNOWN_BROWSER_AUTOMATION_COMMAND_NAMES = new Set<string>(BROWSER_AUTOMATION_COMMAND_NAMES);
|
|
|
|
export const BrowserAutomationHostCapabilitySchema = z
|
|
.object({
|
|
supportedCommands: z.array(z.string().min(1)).transform((commands, context) => {
|
|
const supportedCommands: BrowserAutomationCommandName[] = [];
|
|
const seen = new Set<BrowserAutomationCommandName>();
|
|
|
|
for (const command of commands) {
|
|
if (!isKnownBrowserAutomationCommandName(command) || seen.has(command)) {
|
|
continue;
|
|
}
|
|
seen.add(command);
|
|
supportedCommands.push(command);
|
|
}
|
|
|
|
if (supportedCommands.length === 0) {
|
|
context.addIssue({
|
|
code: "custom",
|
|
message: "supportedCommands must include at least one known browser automation command",
|
|
});
|
|
return z.NEVER;
|
|
}
|
|
|
|
return supportedCommands;
|
|
}),
|
|
hostKind: z.string().min(1).default("browser host"),
|
|
})
|
|
.passthrough();
|
|
|
|
export type BrowserAutomationHostCapability = z.infer<typeof BrowserAutomationHostCapabilitySchema>;
|
|
|
|
function isKnownBrowserAutomationCommandName(value: string): value is BrowserAutomationCommandName {
|
|
return KNOWN_BROWSER_AUTOMATION_COMMAND_NAMES.has(value);
|
|
}
|