/**
 * Central initialization for ~/.avis directory structure.
 * Called once at startup to ensure all required directories exist.
 */
import { existsSync, mkdirSync } from "node:fs";
import { getAgentDir, getAvisRootDir, getBinDir, getConversationBufferPath, getCurrentWorkPath, getInteractionsPath, getMemoryCheckpointPath, getMemoryDir, getMemoryGraphDir, getMemoryPath, getPromptsDir, getSemanticTriePath, getSessionsDir, getToolsDir, } from "../config.js";
/**
 * Standard ~/.avis directory structure:
 *
 * ~/.avis/
 * ├── agent/                     # User-facing agent config
 * │   ├── themes/                # Custom themes
 * │   ├── prompts/               # Prompt templates
 * │   ├── models.json            # Model registry
 * │   ├── auth.json              # API keys (chmod 600)
 * │   ├── settings.json          # User settings
 * │   └── avis-debug.log         # Debug logs
 * ├── self/
 * │   └── memory/                # All Avis memory/session state
 * │       ├── sessions/          # Chat session history
 * │       ├── state/             # Memory daemon + current work checkpoints
 * │       ├── graph/             # Memory graph artifacts
 * │       ├── memory.jsonl       # Long-term memory log
 * │       ├── interactions.jsonl # Cross-session interaction log
 * │       ├── conversation-buffer.json
 * │       └── semantic-trie.json
 * ├── tools/                     # User tools
 * ├── bin/                       # Managed binaries (fd, rg)
 * ├── browser/                   # Browser automation
 * │   ├── profiles/              # Browser profiles
 * │   └── downloads/             # Downloaded files
 * ├── voice/                     # Voice I/O
 * │   └── recordings/            # Audio recordings
 * ├── models/                    # Local AI models
 * ├── logs/                      # Daemon logs
 * │   └── daemon.log
 * └── screenshots/               # Vision/screen capture
 */
const AVIS_ROOT = getAvisRootDir();
export const AVIS_PATHS = {
    root: AVIS_ROOT,
    agent: getAgentDir(),
    memory: getMemoryDir(),
    sessions: getSessionsDir(),
    memoryState: getMemoryCheckpointPath().replace(/\/memory-checkpoint\.json$/, ""),
    memoryGraph: getMemoryGraphDir(),
    themes: `${getAgentDir()}/themes`,
    tools: getToolsDir(),
    bin: getBinDir(),
    prompts: getPromptsDir(),
    browser: `${AVIS_ROOT}/browser`,
    browserProfiles: `${AVIS_ROOT}/browser/profiles`,
    browserDownloads: `${AVIS_ROOT}/browser/downloads`,
    voice: `${AVIS_ROOT}/voice`,
    voiceRecordings: `${AVIS_ROOT}/voice/recordings`,
    models: `${AVIS_ROOT}/models`,
    logs: `${AVIS_ROOT}/logs`,
    screenshots: `${AVIS_ROOT}/screenshots`,
};
/**
 * Ensure all required ~/.avis directories exist.
 * Safe to call multiple times (idempotent).
 */
export function ensureAvisDirectories() {
    const dirs = [
        AVIS_PATHS.root,
        AVIS_PATHS.agent,
        AVIS_PATHS.memory,
        AVIS_PATHS.sessions,
        AVIS_PATHS.memoryState,
        AVIS_PATHS.memoryGraph,
        AVIS_PATHS.themes,
        AVIS_PATHS.tools,
        AVIS_PATHS.bin,
        AVIS_PATHS.prompts,
        AVIS_PATHS.browser,
        AVIS_PATHS.browserProfiles,
        AVIS_PATHS.browserDownloads,
        AVIS_PATHS.voice,
        AVIS_PATHS.voiceRecordings,
        AVIS_PATHS.models,
        AVIS_PATHS.logs,
        AVIS_PATHS.screenshots,
    ];
    for (const dir of dirs) {
        if (!existsSync(dir)) {
            mkdirSync(dir, { recursive: true, mode: 0o755 });
        }
    }
    // Touch parent directories for files that are created lazily by the memory system.
    for (const file of [
        getMemoryPath(),
        getInteractionsPath(),
        getConversationBufferPath(),
        getSemanticTriePath(),
        getCurrentWorkPath(),
    ]) {
        const dir = file.slice(0, file.lastIndexOf("/"));
        if (dir && !existsSync(dir))
            mkdirSync(dir, { recursive: true, mode: 0o755 });
    }
}
//# sourceMappingURL=init.js.map