fix: Make --tools work (#167)

This commit is contained in:
Devansh Jain
2025-12-08 18:34:00 -08:00
committed by GitHub
parent 723dd17d47
commit 38b532e8ba
2 changed files with 23 additions and 2 deletions

View File

@@ -62,5 +62,20 @@ class ToolFilterManager {
}
}
// Singleton instance
export const toolFilter = new ToolFilterManager();
// Use globalThis to ensure singleton across bundle
// This prevents Bun's bundler from creating duplicate instances
const FILTER_KEY = Symbol.for("@letta/toolFilter");
type GlobalWithFilter = typeof globalThis & {
[key: symbol]: ToolFilterManager;
};
function getFilter(): ToolFilterManager {
const global = globalThis as GlobalWithFilter;
if (!global[FILTER_KEY]) {
global[FILTER_KEY] = new ToolFilterManager();
}
return global[FILTER_KEY];
}
export const toolFilter = getFilter();