feat: 接入 System_ExecuteCommandV1——按 command_type 分派 PS/DOS/BAT

This commit is contained in:
yu 2026-10-29 09:25:20 +08:00
parent 303560f0f8
commit de514500a7

View File

@ -147,6 +147,20 @@ const executeCommand: CapabilityHandler = async (_ctx, node, args) => {
return powershell(command, Math.max(1000, number(args, ["timeoutMs"], 120000)));
};
register("System_ExecuteCommandV1", async (ctx, node, args) => {
const type = String(args.command_type ?? "1");
const dos = String(args.dos_command ?? "").trim();
const bat = String(args.bat_file ?? "").trim();
const ps = String(args.ps_command ?? "").trim();
let command = ps;
if (type === "2") command = dos;
else if (type === "3") command = bat ? ("& '" + bat.replace(/'/g, "''") + "'") : "";
if (!command) {
throw new RuntimeError("validation_error", "命令为空", { nodeId: node.id, componentId: node.componentId, recommendation: "填写 PowerShell/DOS 命令或 BAT 文件路径" });
}
return powershell(command, Math.max(1000, Number(args.timeoutMs) || 120000));
});
register(["Keyboard_Send_V1", "Keyboard_Send", "Keyboard_PressNew", "Keyboard_Press"], keyboardSend);
register(["Mouse_Click", "Mouse_ClickNew"], mouseClick);
register(["Mouse_MoveTo", "Mouse_Move"], mouseMove);