mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 22:24:31 +00:00
feat(agents): add nodes notifications_list action
This commit is contained in:
@@ -138,6 +138,42 @@ describe("nodes camera_snap", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("nodes notifications_list", () => {
|
||||||
|
it("invokes notifications.list and returns payload", async () => {
|
||||||
|
callGateway.mockImplementation(async ({ method, params }) => {
|
||||||
|
if (method === "node.list") {
|
||||||
|
return mockNodeList(["notifications.list"]);
|
||||||
|
}
|
||||||
|
if (method === "node.invoke") {
|
||||||
|
expect(params).toMatchObject({
|
||||||
|
nodeId: NODE_ID,
|
||||||
|
command: "notifications.list",
|
||||||
|
params: {},
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
payload: {
|
||||||
|
enabled: true,
|
||||||
|
connected: true,
|
||||||
|
count: 1,
|
||||||
|
notifications: [{ key: "n1", packageName: "com.example.app" }],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return unexpectedGatewayMethod(method);
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await executeNodes({
|
||||||
|
action: "notifications_list",
|
||||||
|
node: NODE_ID,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result.content?.[0]).toMatchObject({
|
||||||
|
type: "text",
|
||||||
|
text: expect.stringContaining('"notifications"'),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("nodes run", () => {
|
describe("nodes run", () => {
|
||||||
it("passes invoke and command timeouts", async () => {
|
it("passes invoke and command timeouts", async () => {
|
||||||
callGateway.mockImplementation(async ({ method, params }) => {
|
callGateway.mockImplementation(async ({ method, params }) => {
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ const NODES_TOOL_ACTIONS = [
|
|||||||
"camera_clip",
|
"camera_clip",
|
||||||
"screen_record",
|
"screen_record",
|
||||||
"location_get",
|
"location_get",
|
||||||
|
"notifications_list",
|
||||||
"run",
|
"run",
|
||||||
"invoke",
|
"invoke",
|
||||||
] as const;
|
] as const;
|
||||||
@@ -122,7 +123,7 @@ export function createNodesTool(options?: {
|
|||||||
label: "Nodes",
|
label: "Nodes",
|
||||||
name: "nodes",
|
name: "nodes",
|
||||||
description:
|
description:
|
||||||
"Discover and control paired nodes (status/describe/pairing/notify/camera/screen/location/run/invoke).",
|
"Discover and control paired nodes (status/describe/pairing/notify/camera/screen/location/notifications/run/invoke).",
|
||||||
parameters: NodesToolSchema,
|
parameters: NodesToolSchema,
|
||||||
execute: async (_toolCallId, args) => {
|
execute: async (_toolCallId, args) => {
|
||||||
const params = args as Record<string, unknown>;
|
const params = args as Record<string, unknown>;
|
||||||
@@ -406,6 +407,17 @@ export function createNodesTool(options?: {
|
|||||||
});
|
});
|
||||||
return jsonResult(raw?.payload ?? {});
|
return jsonResult(raw?.payload ?? {});
|
||||||
}
|
}
|
||||||
|
case "notifications_list": {
|
||||||
|
const node = readStringParam(params, "node", { required: true });
|
||||||
|
const nodeId = await resolveNodeId(gatewayOpts, node);
|
||||||
|
const raw = await callGatewayTool<{ payload: unknown }>("node.invoke", gatewayOpts, {
|
||||||
|
nodeId,
|
||||||
|
command: "notifications.list",
|
||||||
|
params: {},
|
||||||
|
idempotencyKey: crypto.randomUUID(),
|
||||||
|
});
|
||||||
|
return jsonResult(raw?.payload ?? {});
|
||||||
|
}
|
||||||
case "run": {
|
case "run": {
|
||||||
const node = readStringParam(params, "node", { required: true });
|
const node = readStringParam(params, "node", { required: true });
|
||||||
const nodes = await listNodes(gatewayOpts);
|
const nodes = await listNodes(gatewayOpts);
|
||||||
|
|||||||
Reference in New Issue
Block a user