fix: Make --tools work (#167)
This commit is contained in:
@@ -65,6 +65,12 @@ export async function handleHeadlessCommand(
|
||||
allowPositionals: true,
|
||||
});
|
||||
|
||||
// Set tool filter if provided (controls which tools are loaded)
|
||||
if (values.tools !== undefined) {
|
||||
const { toolFilter } = await import("./tools/filter");
|
||||
toolFilter.setEnabledTools(values.tools as string);
|
||||
}
|
||||
|
||||
// Get prompt from either positional args or stdin
|
||||
let prompt = positionals.slice(2).join(" ");
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user