diff --git a/src/main/capabilities/desktop.ts b/src/main/capabilities/desktop.ts index e6a7248..35bcfc0 100644 --- a/src/main/capabilities/desktop.ts +++ b/src/main/capabilities/desktop.ts @@ -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);