mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 08:21:41 +00:00
fix(nodes): reject facing=both when camera deviceId is set
This commit is contained in:
@@ -136,6 +136,17 @@ describe("nodes camera_snap", () => {
|
|||||||
deviceId: "cam-123",
|
deviceId: "cam-123",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("rejects facing both when deviceId is provided", async () => {
|
||||||
|
await expect(
|
||||||
|
executeNodes({
|
||||||
|
action: "camera_snap",
|
||||||
|
node: NODE_ID,
|
||||||
|
facing: "both",
|
||||||
|
deviceId: "cam-123",
|
||||||
|
}),
|
||||||
|
).rejects.toThrow(/facing=both is not allowed when deviceId is set/i);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("nodes notifications_list", () => {
|
describe("nodes notifications_list", () => {
|
||||||
|
|||||||
@@ -248,6 +248,9 @@ export function createNodesTool(options?: {
|
|||||||
typeof params.deviceId === "string" && params.deviceId.trim()
|
typeof params.deviceId === "string" && params.deviceId.trim()
|
||||||
? params.deviceId.trim()
|
? params.deviceId.trim()
|
||||||
: undefined;
|
: undefined;
|
||||||
|
if (deviceId && facings.length > 1) {
|
||||||
|
throw new Error("facing=both is not allowed when deviceId is set");
|
||||||
|
}
|
||||||
|
|
||||||
const content: AgentToolResult<unknown>["content"] = [];
|
const content: AgentToolResult<unknown>["content"] = [];
|
||||||
const details: Array<Record<string, unknown>> = [];
|
const details: Array<Record<string, unknown>> = [];
|
||||||
|
|||||||
@@ -121,6 +121,9 @@ export function registerNodesCameraCommands(nodes: Command) {
|
|||||||
const quality = opts.quality ? Number.parseFloat(String(opts.quality)) : undefined;
|
const quality = opts.quality ? Number.parseFloat(String(opts.quality)) : undefined;
|
||||||
const delayMs = opts.delayMs ? Number.parseInt(String(opts.delayMs), 10) : undefined;
|
const delayMs = opts.delayMs ? Number.parseInt(String(opts.delayMs), 10) : undefined;
|
||||||
const deviceId = opts.deviceId ? String(opts.deviceId).trim() : undefined;
|
const deviceId = opts.deviceId ? String(opts.deviceId).trim() : undefined;
|
||||||
|
if (deviceId && facings.length > 1) {
|
||||||
|
throw new Error("facing=both is not allowed when --device-id is set");
|
||||||
|
}
|
||||||
const timeoutMs = opts.invokeTimeout
|
const timeoutMs = opts.invokeTimeout
|
||||||
? Number.parseInt(String(opts.invokeTimeout), 10)
|
? Number.parseInt(String(opts.invokeTimeout), 10)
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|||||||
@@ -284,6 +284,38 @@ describe("cli program (nodes media)", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("fails nodes camera snap when --facing both and --device-id are combined", async () => {
|
||||||
|
mockNodeGateway();
|
||||||
|
|
||||||
|
const program = new Command();
|
||||||
|
program.exitOverride();
|
||||||
|
registerNodesCli(program);
|
||||||
|
runtime.error.mockClear();
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
program.parseAsync(
|
||||||
|
[
|
||||||
|
"nodes",
|
||||||
|
"camera",
|
||||||
|
"snap",
|
||||||
|
"--node",
|
||||||
|
"ios-node",
|
||||||
|
"--facing",
|
||||||
|
"both",
|
||||||
|
"--device-id",
|
||||||
|
"cam-123",
|
||||||
|
],
|
||||||
|
{ from: "user" },
|
||||||
|
),
|
||||||
|
).rejects.toThrow(/exit/i);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
runtime.error.mock.calls.some(([msg]) =>
|
||||||
|
/facing=both is not allowed when --device-id is set/i.test(String(msg)),
|
||||||
|
),
|
||||||
|
).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
describe("URL-based payloads", () => {
|
describe("URL-based payloads", () => {
|
||||||
let originalFetch: typeof globalThis.fetch;
|
let originalFetch: typeof globalThis.fetch;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user