Liking cljdoc? Tell your friends :D

com.blockether.spel.profile

Chrome/Chromium user-profile lookup and cloning for --profile <name>.

Matches the semantics of vercel-labs/agent-browser:

  1. Three-tier resolution of the user-supplied string to an on-disk profile directory (exact match → case-insensitive display name → case-insensitive directory name). Ambiguous display-name matches raise an error.

  2. Selective copy to a fresh temp user-data directory. Large cache/non-auth subdirectories are skipped (e.g. Cache, Code Cache, GPUCache, Service Worker) because they are not needed for login-state reuse and would bloat the copy by hundreds of MB. See exclude-dirs.

  3. The clone function returns BOTH the temp user-data dir path AND the resolved profile directory name. The caller is responsible for passing --profile-directory=<dir> to Chrome so it picks the right profile from the cloned user-data dir (without this, Chrome always defaults to Default and ignores other profiles in the clone).

Platform-specific Chrome user-data roots: macOS ~/Library/Application Support/Google/Chrome Linux ~/.config/google-chrome Windows %LOCALAPPDATA%/Google/Chrome/User Data

Chrome/Chromium user-profile lookup and cloning for `--profile <name>`.

Matches the semantics of vercel-labs/agent-browser:

1. Three-tier resolution of the user-supplied string to an on-disk profile
   directory (exact match → case-insensitive display name → case-insensitive
   directory name). Ambiguous display-name matches raise an error.

2. Selective copy to a fresh temp user-data directory. Large cache/non-auth
   subdirectories are skipped (e.g. `Cache`, `Code Cache`, `GPUCache`,
   `Service Worker`) because they are not needed for login-state reuse and
   would bloat the copy by hundreds of MB. See `exclude-dirs`.

3. The clone function returns BOTH the temp user-data dir path AND the
   resolved profile directory name. The caller is responsible for passing
   `--profile-directory=<dir>` to Chrome so it picks the right profile from
   the cloned user-data dir (without this, Chrome always defaults to
   `Default` and ignores other profiles in the clone).

Platform-specific Chrome user-data roots:
  macOS   ~/Library/Application Support/Google/Chrome
  Linux   ~/.config/google-chrome
  Windows %LOCALAPPDATA%/Google/Chrome/User Data
raw docstring

chrome-user-data-rootclj

(chrome-user-data-root)

Returns the absolute path (as a String) to the current user's Chrome user-data directory for the host OS, or nil if the standard location does not exist on disk.

Returns the absolute path (as a String) to the current user's Chrome
user-data directory for the host OS, or nil if the standard location does
not exist on disk.
sourceraw docstring

clone-profile!clj

(clone-profile! input)

Clones the requested Chrome profile into a fresh temp user-data directory and returns both the temp path AND the resolved profile directory name.

Structure of the output temp dir:

<tempdir>/ Local State (copied from the source user-data root) <profile-dir>/ (e.g. 'Default' or 'Profile 1') Cookies, Login Data, Preferences, ... (auth-relevant files)

The caller MUST pass --profile-directory=<profile-directory> as a Chrome command-line argument when launching — otherwise Chrome defaults to 'Default' and ignores any other profile that was cloned.

Returns: {:user-data-dir "<tmp-path>" :profile-directory "<dir>"}. Throws ex-info on missing Chrome, unknown profile, or ambiguous name.

Clones the requested Chrome profile into a fresh temp user-data directory
and returns both the temp path AND the resolved profile directory name.

Structure of the output temp dir:

  <tempdir>/
    Local State         (copied from the source user-data root)
    <profile-dir>/      (e.g. 'Default' or 'Profile 1')
      Cookies, Login Data, Preferences, ...  (auth-relevant files)

The caller MUST pass `--profile-directory=<profile-directory>` as a Chrome
command-line argument when launching — otherwise Chrome defaults to
'Default' and ignores any other profile that was cloned.

Returns: `{:user-data-dir "<tmp-path>" :profile-directory "<dir>"}`.
Throws ex-info on missing Chrome, unknown profile, or ambiguous name.
sourceraw docstring

delete-tree!clj

(delete-tree! path)

Recursively deletes a directory tree. Used for temp profile cleanup on browser close. Best-effort: retries once after a short sleep to handle transient file locks (Chrome sometimes releases .lock files lazily). Returns true on success, false on final failure.

Recursively deletes a directory tree. Used for temp profile cleanup on
browser close. Best-effort: retries once after a short sleep to handle
transient file locks (Chrome sometimes releases .lock files lazily).
Returns true on success, false on final failure.
sourceraw docstring

expand-tildeclj

(expand-tilde s)

Expands a leading ~ in a path to the current user's home directory, the way POSIX shells do. Matches agent-browser's expand_tilde semantics so --profile ~/my-profile works without requiring the shell to pre-expand.

Expands a leading `~` in a path to the current user's home directory, the
way POSIX shells do. Matches agent-browser's `expand_tilde` semantics so
`--profile ~/my-profile` works without requiring the shell to pre-expand.
sourceraw docstring

list-profilesclj

(list-profiles)

Lists available Chrome profiles on the current system. Returns [] if Chrome is not installed or no profiles exist.

Lists available Chrome profiles on the current system. Returns `[]` if
Chrome is not installed or no profiles exist.
sourceraw docstring

list-profiles-inclj

(list-profiles-in user-data-dir)

Lists Chrome profiles found in a specific user-data-dir. Extracted from list-profiles so tests can point at fixture directories without touching the real Chrome installation.

Each entry: {:name <display> :dir <directory> :user-name <email?>}. :dir is the on-disk subdirectory name (e.g. Default, Profile 1) which is what Chrome's --profile-directory flag expects.

Lists Chrome profiles found in a specific `user-data-dir`. Extracted from
`list-profiles` so tests can point at fixture directories without touching
the real Chrome installation.

Each entry: `{:name <display> :dir <directory> :user-name <email?>}`.
`:dir` is the on-disk subdirectory name (e.g. `Default`, `Profile 1`) which
is what Chrome's `--profile-directory` flag expects.
sourceraw docstring

name?clj

(name? s)

Returns true if s looks like a profile name rather than a filesystem path. A name contains no path separators, no ~, and is non-blank. Path- like inputs are handed to the existing persistent-profile-path flow as-is.

Returns true if `s` looks like a profile *name* rather than a filesystem
*path*. A name contains no path separators, no `~`, and is non-blank. Path-
like inputs are handed to the existing persistent-profile-path flow as-is.
sourceraw docstring

resolve-profileclj

(resolve-profile input)

Resolves a user-supplied profile name against the active Chrome installation. See resolve-profile-in for matching rules. Throws if Chrome is not found.

Resolves a user-supplied profile name against the active Chrome installation.
See `resolve-profile-in` for matching rules. Throws if Chrome is not found.
sourceraw docstring

resolve-profile-inclj

(resolve-profile-in user-data-dir input)

Three-tier profile resolution against the profile list from a specific user-data directory. Mirrors agent-browser's semantics:

  • Tier 1: exact directory name match (case-sensitive)
  • Tier 2: case-insensitive display name match. If multiple profiles share the same display name (rare but possible), raises an error with the list of candidates — the caller must disambiguate using the directory name.
  • Tier 3: case-insensitive directory name match.

Returns the resolved directory name (String) on success. Throws ex-info with :profile-not-found or :ambiguous-profile-name on failure.

Three-tier profile resolution against the profile list from a specific
user-data directory. Mirrors agent-browser's semantics:

- Tier 1: exact directory name match (case-sensitive)
- Tier 2: case-insensitive display name match. If multiple profiles share
          the same display name (rare but possible), raises an error with
          the list of candidates — the caller must disambiguate using the
          directory name.
- Tier 3: case-insensitive directory name match.

Returns the resolved directory name (String) on success. Throws ex-info
with `:profile-not-found` or `:ambiguous-profile-name` on failure.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close