refactor: improve run-agent/run-agent scripts (#160)

This commit is contained in:
sigoden
2025-02-10 14:47:37 +08:00
committed by GitHub
parent e4f85a056c
commit fad2c60605
4 changed files with 12 additions and 28 deletions
+1 -6
View File
@@ -93,15 +93,10 @@ async function loadEnv(filePath) {
}
async function run(toolName, toolPath, toolFunc, toolData) {
let mod;
if (os.platform() === "win32") {
toolPath = `file://${toolPath}`;
}
try {
mod = await import(toolPath);
} catch {
throw new Error(`Unable to load tool at '${toolPath}'`);
}
const mod = await import(toolPath);
if (!mod || !mod[toolFunc]) {
throw new Error(`Not module function '${toolFunc}' at '${toolPath}'`);
}