/**
 * 调度中心 SQLite 记忆存储适配器。
 * 主流程：所有 task_list/recently_memory 操作透传到 server，并由 server 按当前 agentId 做实例隔离。
 */
export class ServerMemoryStore {
    agentClient;
    constructor(agentClient) {
        this.agentClient = agentClient;
    }
    ensureSuccess(payload) {
        if (payload && typeof payload === "object" && "error" in payload) {
            const error = payload.error;
            throw new Error(typeof error === "string" ? error : "Server memory operation failed");
        }
        return payload;
    }
    async getStats() {
        return this.ensureSuccess(await this.agentClient.callAgentScopedTool("get_memory_stats", {}));
    }
    async createMemory(input) {
        return this.ensureSuccess(await this.agentClient.callAgentScopedTool("create_memory", input));
    }
    async readMemory(input) {
        return this.ensureSuccess(await this.agentClient.callAgentScopedTool("read_memory", input));
    }
    async updateMemory(input) {
        return this.ensureSuccess(await this.agentClient.callAgentScopedTool("update_memory", input));
    }
    async deleteMemory(input) {
        const result = this.ensureSuccess(await this.agentClient.callAgentScopedTool("delete_memory", input));
        return Boolean(result.deleted);
    }
    async searchMemory(input) {
        return this.ensureSuccess(await this.agentClient.callAgentScopedTool("search_memory", input));
    }
    async listByType(memory_type) {
        return this.ensureSuccess(await this.agentClient.callAgentScopedTool("list_memories", { memory_type }));
    }
    async removeTaskListMemory(uri) {
        const result = this.ensureSuccess(await this.agentClient.callAgentScopedTool("remove_task_list_memory", { uri }));
        return Boolean(result.removed);
    }
    async archiveRecentlyMemory(uri) {
        return this.ensureSuccess(await this.agentClient.callAgentScopedTool("archive_recently_memory", { uri }));
    }
}
//# sourceMappingURL=server-memory-store.js.map