openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
30 lines (29 loc) • 1.51 kB
JavaScript
import { l as getRuntimeConfigSourceSnapshot } from "./runtime-snapshot-DYptB0Cf.mjs";
import "./runtime-config-snapshot-A-BTduWa.mjs";
import { i as resolveBrowserConfig, s as resolveProfile } from "./config-DQZ6ubGi.mjs";
import { t as getBrowserProfileCapabilities } from "./profile-capabilities-DHBwe9FJ.mjs";
import { o as isChromeReachable } from "./chrome-20QYVHm0.mjs";
import { t as resolveBrowserExecutableForPlatform } from "./chrome.executables-dmultiw4.mjs";
import { r as getBrowserControlState } from "./browser-control-state-JJcvp7Kt.mjs";
//#region extensions/browser/src/browser-host-availability.ts
/** Inspect local capability before routing, without launching or replaying a browser action. */
async function isBrowserHostAvailable(config, profileName) {
const source = getRuntimeConfigSourceSnapshot() ?? config;
const resolved = resolveBrowserConfig(source.browser, source);
if (!resolved.enabled) return false;
const profile = resolveProfile(resolved, profileName ?? resolved.defaultProfile);
if (!profile) return false;
if (getBrowserProfileCapabilities(profile).mode !== "local-managed" || profile.attachOnly) return true;
if (getBrowserControlState()?.profiles.get(profile.name)?.running) return true;
try {
if (resolveBrowserExecutableForPlatform({
...resolved,
executablePath: profile.executablePath
}, process.platform)) return true;
} catch {
return true;
}
return await isChromeReachable(profile.cdpUrl);
}
//#endregion
export { isBrowserHostAvailable };