Module base

Module base 

Source
Expand description

Wave base utilities: directory management, lock files, environment, platform detection. Port of Go’s pkg/base/.

Structs§

WaveLock
File-based lock for single-instance enforcement.

Constants§

CONFIG_DIR
DOMAIN_SOCKET_BASE_NAME
REMOTE_DOMAIN_SOCKET_BASE_NAME
REMOTE_FULL_DOMAIN_SOCKET_PATH
REMOTE_WAVE_HOME_DIR_NAME
WAVE_APP_PATH_ENV
WAVE_CONFIG_HOME_ENV
WAVE_DATA_HOME_ENV
WAVE_DB_DIR
WAVE_DEV_ENV
WAVE_DEV_VITE_ENV
WAVE_JWT_TOKEN_ENV
WAVE_LOCK_FILE
WAVE_SWAP_TOKEN_ENV

Statics§

BUILD_TIME 🔒
WAVE_VERSION 🔒

Functions§

client_arch
Get the client architecture string (“os/arch”).
copy_dir_all 🔒
Recursively copy a directory tree.
determine_lang
Determine the system language.
ensure_dir
Ensure a directory exists with the given permissions.
ensure_wave_config_dir
Ensure the Wave config directory exists.
ensure_wave_data_dir
Ensure the Wave data directory exists.
ensure_wave_db_dir
Ensure the Wave DB directory exists.
ensure_wave_presets_dir
Ensure the Wave presets directory exists.
expand_home_dir
Expand ~ at the start of a path to the home directory. Rejects ~user/ and paths containing .. components (path traversal).
expand_home_dir_safe
Safe version of expand_home_dir that returns the original on error.
get_build_time
Get the build time.
get_domain_socket_name
Get the domain socket path.
get_home_dir
Get the user’s home directory.
get_system_summary
Get a system summary string.
get_version
Get the application version.
get_wave_app_bin_path
Get the Wave app bin path.
get_wave_app_path
Get the Wave app path from env.
get_wave_config_dir
Get the Wave config directory. Uses AGENTMUX_CONFIG_HOME env var, or defaults to ~/.agentmux/config.
get_wave_data_dir
Get the Wave data directory. Uses AGENTMUX_DATA_HOME env var, or defaults to ~/.agentmux.
get_wave_db_dir
Get the Wave DB directory (~/.agentmux/db).
get_wave_lock_file
Get the Wave lock file path.
has_drive_letter_prefix 🔒
True if s starts with <ASCII letter>: — a Windows drive-letter prefix. Both rooted (C:\foo) and drive-relative (C:foo) forms match. Used by safe_join_within_base to reject paths that would rebase off the working directory under Windows path semantics.
is_dev_mode
Check if Wave is in dev mode.
migrate_legacy_data_dir
Migrate data from ~/.waveterm to ~/.agentmux if needed. Called once at startup. No-op if ~/.agentmux already exists.
replace_home_dir
Replace the home directory prefix with ~.
safe_join_within_base
Lexically join relative onto base while guaranteeing the result stays inside base. No filesystem access — does not require either path to exist, which matters on Windows where Path::canonicalize adds the \\?\ UNC prefix and breaks naive starts_with checks against not-yet-created files.
set_build_time
Set the build time (called once at startup).
set_version
Set the application version (called once at startup).
verify_no_symlink_escape
After a lexical join, verify that no symlinked ancestor of the candidate path escapes base_canonical. The lexical helper alone can’t catch this: if <base>/.claude is a symlink to /tmp/outside and the caller writes <base>/.claude/commands/startup.md, the final write follows the symlink and lands outside the working dir.