fix(config): Defer retrieval of tool names
No longer attempts to calculate tool names as module-load time, but instead defers it until the values are needed. Additionally, this change updates the schema to support optional tool exposure when using smithery.ai.
This commit is contained in:
1 file changed
+9
-2
+9
-2
@@ -9,6 +9,14 @@ dotenv.config({ debug: false, quiet: true });
|
|||||||
// Config schema for Smithery.ai
|
// Config schema for Smithery.ai
|
||||||
export const configSchema = z.object({
|
export const configSchema = z.object({
|
||||||
braveApiKey: z.string().describe('Your API key'),
|
braveApiKey: z.string().describe('Your API key'),
|
||||||
|
enabledTools: z
|
||||||
|
.array(z.string())
|
||||||
|
.describe('Enforces a tool whitelist (cannot be used with disabledTools)')
|
||||||
|
.optional(),
|
||||||
|
disabledTools: z
|
||||||
|
.array(z.string())
|
||||||
|
.describe('Enforces a tool blacklist (cannot be used with enabledTools)')
|
||||||
|
.optional(),
|
||||||
loggingLevel: z
|
loggingLevel: z
|
||||||
.enum(LoggingLevelSchema.options)
|
.enum(LoggingLevelSchema.options)
|
||||||
.default('info')
|
.default('info')
|
||||||
@@ -39,8 +47,6 @@ const state: Configuration & { ready: boolean } = {
|
|||||||
disabledTools: [],
|
disabledTools: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
const toolNames = Object.values(tools).map((tool) => tool.name);
|
|
||||||
|
|
||||||
export function isToolPermittedByUser(toolName: string): boolean {
|
export function isToolPermittedByUser(toolName: string): boolean {
|
||||||
return state.enabledTools.length > 0
|
return state.enabledTools.length > 0
|
||||||
? state.enabledTools.includes(toolName)
|
? state.enabledTools.includes(toolName)
|
||||||
@@ -80,6 +86,7 @@ export function getOptions(): Configuration | false {
|
|||||||
.parse(process.argv);
|
.parse(process.argv);
|
||||||
|
|
||||||
const options = program.opts();
|
const options = program.opts();
|
||||||
|
const toolNames = Object.values(tools).map((tool) => tool.name);
|
||||||
|
|
||||||
// Validate tool inclusion configuration
|
// Validate tool inclusion configuration
|
||||||
const { enabledTools, disabledTools } = options;
|
const { enabledTools, disabledTools } = options;
|
||||||
|
|||||||
Reference in new issue
Block a user