import { resolve } from 'node:path';
import { MemoryVisibilityService } from '../../../../core/memory/visibility.js';
export class ControlPlaneMemoryController {
    static async readStatus(stateRoot) {
        return await ControlPlaneMemoryController.memory(stateRoot).loadStatus();
    }
    static async listNotes(stateRoot, path) {
        const memoryRoot = ControlPlaneMemoryController.memoryRoot(stateRoot);
        return {
            memoryRoot,
            notes: await new MemoryVisibilityService(memoryRoot).listNotePaths(path),
        };
    }
    static async readNote(stateRoot, path, options) {
        const memoryRoot = ControlPlaneMemoryController.memoryRoot(stateRoot);
        return {
            memoryRoot,
            path,
            content: await new MemoryVisibilityService(memoryRoot).readNote({
                path,
                offset: options?.offset,
                maxLines: options?.maxLines,
            }),
        };
    }
    static async searchNotes(stateRoot, query, options) {
        const memoryRoot = ControlPlaneMemoryController.memoryRoot(stateRoot);
        return {
            memoryRoot,
            query,
            matches: await new MemoryVisibilityService(memoryRoot).searchNotes({
                query,
                path: options?.path,
                maxResults: options?.maxResults,
            }),
        };
    }
    static memoryRoot(stateRoot) {
        return resolve(stateRoot, 'memory');
    }
    static memory(stateRoot) {
        return new MemoryVisibilityService(ControlPlaneMemoryController.memoryRoot(stateRoot));
    }
}
//# sourceMappingURL=memory.js.map