Files
openclaw/extensions/browser/src/browser-runtime.ts
Peter Steinberger 2a12c9916a feat(browser): import Chrome-family system-profile cookies into managed profiles (#104057)
* feat(browser): import Chrome-family system-profile cookies into managed profiles

Import cookies from a real Chrome/Brave/Edge/Chromium system profile (macOS)
into a fresh OpenClaw-managed browser profile so the agent can browse as the
signed-in user. Reads the source Cookies DB via a coherent VACUUM INTO snapshot,
decrypts v10 AES-128-CBC values with the Safe Storage Keychain key (one Touch ID
consent), maps rows to Playwright cookies (FILETIME expiry, SameSite, M124+
domain-hash prefix strip, CHIPS skipped), and best-effort injects them via
addCookies into a mock-keychain profile so they persist without further prompts.
Decrypted values are never logged or returned.

Exposed as agent tool action=importprofile, CLI system-profiles/import-profile,
and POST /profiles/import; action=profiles surfaces importable systemProfiles.
Listing and import are pinned host-local at every surface (gateway, browser
tool, node proxy) since they read the local Keychain and Chrome profiles.
Malformed domain filters fail closed via a shared validator. Gated by
browser.allowSystemProfileImport (default on). Imports cookies only.

* fix(browser): satisfy CI lint (OpenClaw temp dir, Unicode control-char class)

Use resolvePreferredOpenClawTmpDir() instead of os.tmpdir() for the cookie DB
snapshot (messaging/channel runtime tmpdir guard), and match control characters
via the Unicode \p{Cc} class instead of a literal control-char range so the
CLI table sanitizer passes the no-control-regex lint.
2026-07-10 19:15:52 -07:00

107 lines
3.5 KiB
TypeScript

/**
* Public browser runtime barrel.
*
* Exposes the browser control server, client helpers, config resolution, and
* route/runtime primitives used by the plugin entrypoints and local CLI.
*/
export { startBrowserBridgeServer, stopBrowserBridgeServer } from "./browser/bridge-server.js";
export type { BrowserBridge } from "./browser/bridge-server.js";
export {
browserAct,
browserArmDialog,
browserArmFileChooser,
browserConsoleMessages,
browserNavigate,
browserPdfSave,
browserScreenshotAction,
} from "./browser/client-actions.js";
export {
browserCloseTab,
browserFocusTab,
browserOpenTab,
browserCreateProfile,
browserDeleteProfile,
browserDoctor,
browserImportProfile,
browserProfiles,
browserSystemProfiles,
browserResetProfile,
browserSnapshot,
browserStart,
browserStatus,
browserStop,
browserTabAction,
browserTabs,
} from "./browser/client.js";
export { runBrowserProxyCommand } from "./node-host/invoke-browser.js";
export type {
BrowserCreateProfileResult,
BrowserDeleteProfileResult,
BrowserDoctorCheck,
BrowserDoctorReport,
BrowserImportProfileResult,
BrowserResetProfileResult,
BrowserStatus,
BrowserTab,
BrowserTransport,
ProfileStatus,
SystemProfileInfo,
SnapshotResult,
} from "./browser/client.js";
export type { BrowserExecutable } from "./browser/chrome.executables.js";
export type { ResolvedBrowserConfig, ResolvedBrowserProfile } from "./browser/config.js";
export { resolveBrowserConfig, resolveProfile } from "./browser/config.js";
export {
DEFAULT_AI_SNAPSHOT_MAX_CHARS,
DEFAULT_BROWSER_EVALUATE_ENABLED,
DEFAULT_OPENCLAW_BROWSER_COLOR,
DEFAULT_OPENCLAW_BROWSER_PROFILE_NAME,
} from "./browser/constants.js";
export {
parseBrowserMajorVersion,
readBrowserVersion,
resolveGoogleChromeExecutableForPlatform,
} from "./browser/chrome.executables.js";
export { redactCdpUrl } from "./browser/cdp.helpers.js";
export {
DEFAULT_UPLOAD_DIR,
resolveExistingPathsWithinRoot,
resolveExistingUploadPaths,
} from "./browser/paths.js";
export { getBrowserProfileCapabilities } from "./browser/profile-capabilities.js";
export { applyBrowserProxyPaths, persistBrowserProxyFiles } from "./browser/proxy-files.js";
export {
isBrowserHostLocalRoute,
isBrowserSystemProfileImport,
isPersistentBrowserProfileMutation,
normalizeBrowserRequestPath,
resolveRequestedBrowserProfile,
} from "./browser/request-policy.js";
export {
closeTrackedBrowserTabsForSessions,
trackSessionBrowserTab,
untrackSessionBrowserTab,
} from "./browser/session-tab-registry.js";
export { ensureBrowserControlAuth, resolveBrowserControlAuth } from "./browser/control-auth.js";
export { movePathToTrash } from "./browser/trash.js";
export {
createBrowserControlContext,
getBrowserControlState,
startBrowserControlServiceFromConfig,
stopBrowserControlService,
} from "./control-service.js";
export { createBrowserRuntimeState, stopBrowserRuntime } from "./browser/runtime-lifecycle.js";
export { type BrowserServerState, createBrowserRouteContext } from "./browser/server-context.js";
export { registerBrowserRoutes } from "./browser/routes/index.js";
export { createBrowserRouteDispatcher } from "./browser/routes/dispatcher.js";
export type { BrowserRouteRegistrar } from "./browser/routes/types.js";
export {
installBrowserAuthMiddleware,
installBrowserCommonMiddleware,
} from "./browser/server-middleware.js";
export type { BrowserFormField } from "./browser/client-actions-core.js";
export {
normalizeBrowserFormField,
normalizeBrowserFormFieldValue,
} from "./browser/form-fields.js";