mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-30 03:11:10 +00:00
29 lines
683 B
TypeScript
29 lines
683 B
TypeScript
import {
|
|
startBrowserControlServerIfEnabled,
|
|
type OpenClawPluginService,
|
|
} from "openclaw/plugin-sdk/browser-support";
|
|
|
|
type BrowserControlHandle = Awaited<ReturnType<typeof startBrowserControlServerIfEnabled>>;
|
|
|
|
export function createBrowserPluginService(): OpenClawPluginService {
|
|
let handle: BrowserControlHandle = null;
|
|
|
|
return {
|
|
id: "browser-control",
|
|
start: async () => {
|
|
if (handle) {
|
|
return;
|
|
}
|
|
handle = await startBrowserControlServerIfEnabled();
|
|
},
|
|
stop: async () => {
|
|
const current = handle;
|
|
handle = null;
|
|
if (!current) {
|
|
return;
|
|
}
|
|
await current.stop().catch(() => {});
|
|
},
|
|
};
|
|
}
|