mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-18 21:17:27 +00:00
test(nodes): cover wrapped system.run prepare
This commit is contained in:
@@ -85,4 +85,50 @@ describe("createNodesTool screen_record duration guardrails", () => {
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("omits rawCommand when preparing wrapped argv execution", async () => {
|
||||
nodeUtilsMocks.listNodes.mockResolvedValue([
|
||||
{
|
||||
nodeId: "node-1",
|
||||
commands: ["system.run"],
|
||||
},
|
||||
]);
|
||||
gatewayMocks.callGatewayTool.mockImplementation(async (_method, _opts, payload) => {
|
||||
if (payload?.command === "system.run.prepare") {
|
||||
return {
|
||||
payload: {
|
||||
cmdText: "echo hi",
|
||||
plan: {
|
||||
argv: ["bash", "-lc", "echo hi"],
|
||||
cwd: null,
|
||||
rawCommand: null,
|
||||
agentId: null,
|
||||
sessionKey: null,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
if (payload?.command === "system.run") {
|
||||
return { payload: { ok: true } };
|
||||
}
|
||||
throw new Error(`unexpected command: ${String(payload?.command)}`);
|
||||
});
|
||||
const tool = createNodesTool();
|
||||
|
||||
await tool.execute("call-1", {
|
||||
action: "run",
|
||||
node: "macbook",
|
||||
command: ["bash", "-lc", "echo hi"],
|
||||
});
|
||||
|
||||
const prepareCall = gatewayMocks.callGatewayTool.mock.calls.find(
|
||||
(call) => call[2]?.command === "system.run.prepare",
|
||||
)?.[2];
|
||||
expect(prepareCall).toBeTruthy();
|
||||
expect(prepareCall?.params).toMatchObject({
|
||||
command: ["bash", "-lc", "echo hi"],
|
||||
agentId: "main",
|
||||
});
|
||||
expect(prepareCall?.params).not.toHaveProperty("rawCommand");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user