Files
openclaw/extensions/browser/src/browser-tool.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

73 lines
2.3 KiB
TypeScript

/**
* Runtime dependency barrel for the Browser agent tool.
*
* Kept separate from browser-tool.ts so tests can mock the tool boundary while
* production still imports SDK helpers and browser client actions lazily.
*/
import { getRuntimeConfig } from "./sdk-config.js";
export { getRuntimeConfig };
/** Resolve global image downscaling for screenshots returned to agent tools. */
export function resolveRuntimeImageSanitization(): { maxDimensionPx: number } | undefined {
const configured = getRuntimeConfig().agents?.defaults?.imageMaxDimensionPx;
if (typeof configured !== "number" || !Number.isFinite(configured)) {
return undefined;
}
return { maxDimensionPx: Math.max(1, Math.floor(configured)) };
}
export {
callGatewayTool,
describeImageFile,
imageResultFromFile,
jsonResult,
listNodes,
readPositiveIntegerParam,
readStringParam,
resolveNodeIdFromList,
saveMediaBuffer,
selectDefaultNodeFromList,
} from "./sdk-setup-tools.js";
export type { AnyAgentTool, NodeListNode } from "./sdk-setup-tools.js";
export { wrapExternalContent } from "./sdk-security-runtime.js";
export {
normalizeOptionalString,
readStringValue,
} from "openclaw/plugin-sdk/string-coerce-runtime";
export { BrowserToolSchema } from "./browser-tool.schema.js";
export {
browserAct,
browserArmDialog,
browserArmFileChooser,
browserConsoleMessages,
browserDownload,
browserNavigate,
browserPdfSave,
browserScreenshotAction,
browserWaitForDownload,
} from "./browser/client-actions.js";
export {
browserCloseTab,
browserDoctor,
browserFocusTab,
browserImportProfile,
browserOpenTab,
browserProfiles,
browserSystemProfiles,
browserSnapshot,
browserStart,
browserStatus,
browserStop,
browserTabs,
} from "./browser/client.js";
export { resolveBrowserConfig, resolveProfile } from "./browser/config.js";
export { DEFAULT_AI_SNAPSHOT_MAX_CHARS } from "./browser/constants.js";
export { resolveExistingUploadPaths } from "./browser/paths.js";
export { getBrowserProfileCapabilities } from "./browser/profile-capabilities.js";
export { applyBrowserProxyPaths, persistBrowserProxyFiles } from "./browser/proxy-files.js";
export { stageBrowserScreenshotForSharing } from "./browser/screenshot-sharing.js";
export {
touchSessionBrowserTab,
trackSessionBrowserTab,
untrackSessionBrowserTab,
} from "./browser/session-tab-registry.js";