One-time migration of legacy state files into ~/.deepagents/.state/.
Earlier versions wrote internal state directly under ~/.deepagents/,
mixing it with user-facing agent directories (so e.g. mcp-tokens/
showed up in deepagents agents list). State now lives in a dedicated
.state/ subdirectory; this module moves any legacy files into place
on startup.
The migration is best-effort and idempotent: it skips entries whose destination already exists, logs and continues on per-entry failures, and never blocks startup on I/O errors.
User-level Deep Agents directory, optionally set by DEEPAGENTS_HOME.
Directory for app-managed internal state in the selected profile.
Holds files the app writes for its own bookkeeping — OAuth tokens, the sessions database, version-check caches, input history. Kept separate from top-level user-facing config and agent directories so listing the profile root doesn't conflate state with agents.
Marker filename under ~/.deepagents/.state after onboarding has completed.
Create a state directory and restrict it to its owner.
The state directory holds sessions.db and history.jsonl, which hold
full conversation content and are written with the default file mode. The
directory permissions are the only thing that keeps another local user out,
so every creator must go through this function rather than a bare mkdir.
Move legacy state entries from config_dir into state_dir.
Idempotent: each entry is skipped when the destination already exists (the migration ran on a prior invocation) or when the source does not exist (nothing to move). Errors on individual entries are logged and swallowed so a single unmovable file does not block the rest.