-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtool_config.ts
28 lines (25 loc) · 972 Bytes
/
tool_config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import {ToolConfig} from "../types/interfaces.ts"
export class ToolConfigManager {
validateToolConfig(config: ToolConfig[]): boolean {
return config.every(tool => {
return tool.toolName &&
tool.command &&
Array.isArray(tool.inputs) &&
tool.inputs.every(input => input.name && input.type);
});
}
loadConfig(configPath: string): ToolConfig[] {
try {
const configText = Deno.readTextFileSync(configPath);
const config = JSON.parse(configText);
const tools = Array.isArray(config) ? config : config.tools || [];
if (!this.validateToolConfig(tools)) {
throw new Error("Invalid tool configuration format");
}
return tools;
} catch (error) {
console.warn(`Could not load config from ${configPath}: ${error}`);
return [];
}
}
}