Refactor settings manager (#39)

Co-authored-by: Shubham Naik <shub@memgpt.ai>
This commit is contained in:
Shubham Naik
2025-10-30 13:37:34 -07:00
committed by GitHub
parent 30a3883f04
commit d144dd50d9
7 changed files with 929 additions and 29 deletions

View File

@@ -1,8 +1,8 @@
import Letta from "@letta-ai/letta-client";
import { loadSettings, updateSettings } from "../settings";
import { settingsManager } from "../settings-manager";
export async function getClient() {
const settings = await loadSettings();
const settings = settingsManager.getSettings();
const apiKey = process.env.LETTA_API_KEY || settings.env?.LETTA_API_KEY;
if (!apiKey) {
@@ -34,7 +34,7 @@ export async function getClient() {
}
if (needsUpdate) {
await updateSettings({ env: updatedEnv });
settingsManager.updateSettings({ env: updatedEnv });
}
return new Letta({ apiKey, baseURL });

View File

@@ -11,7 +11,7 @@ import {
loadProjectSettings,
updateProjectSettings,
} from "../project-settings";
import { loadSettings, updateSettings } from "../settings";
import { settingsManager } from "../settings-manager";
import { getToolNames } from "../tools/manager";
import { getClient } from "./client";
import { getDefaultMemoryBlocks } from "./memory";
@@ -37,7 +37,7 @@ export async function createAgent(
const defaultMemoryBlocks = await getDefaultMemoryBlocks();
// Load global shared memory blocks from user settings
const settings = await loadSettings();
const settings = settingsManager.getSettings();
const globalSharedBlockIds = settings.globalSharedBlockIds;
// Load project-local shared blocks from project settings
@@ -117,7 +117,7 @@ export async function createAgent(
// Save newly created global block IDs to user settings
if (Object.keys(newGlobalBlockIds).length > 0) {
await updateSettings({
settingsManager.updateSettings({
globalSharedBlockIds: {
...globalSharedBlockIds,
...newGlobalBlockIds,