Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions scripts/run-agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,10 @@ async function loadEnv(filePath) {
}

async function run(agentName, agentPath, agentFunc, agentData) {
let mod;
if (os.platform() === "win32") {
agentPath = `file://${agentPath}`;
}
try {
mod = await import(agentPath);
} catch {
throw new Error(`Unable to load agent tools at '${agentPath}'`);
}
const mod = await import(agentPath);
if (!mod || !mod[agentFunc]) {
throw new Error(`Not module function '${agentFunc}' at '${agentPath}'`);
}
Expand Down
13 changes: 5 additions & 8 deletions scripts/run-agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,11 @@ def load_env(file_path):


def run(agent_name, agent_path, agent_func, agent_data):
try:
spec = importlib.util.spec_from_file_location(
os.path.basename(agent_path), agent_path
)
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
except:
raise Exception(f"Unable to load agent tools at '{agent_path}'")
spec = importlib.util.spec_from_file_location(
os.path.basename(agent_path), agent_path
)
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)

if not hasattr(mod, agent_func):
raise Exception(f"Not module function '{agent_func}' at '{agent_path}'")
Expand Down
7 changes: 1 addition & 6 deletions scripts/run-tool.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}'`);
}
Expand Down
13 changes: 5 additions & 8 deletions scripts/run-tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,11 @@ def load_env(file_path):


def run(tool_name, tool_path, tool_func, tool_data):
try:
spec = importlib.util.spec_from_file_location(
os.path.basename(tool_path), tool_path
)
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
except:
raise Exception(f"Unable to load tool at '{tool_path}'")
spec = importlib.util.spec_from_file_location(
os.path.basename(tool_path), tool_path
)
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)

if not hasattr(mod, tool_func):
raise Exception(f"Not module function '{tool_func}' at '{tool_path}'")
Expand Down