Fix OpenClaw plugin approved target matching #3

Merged
ledadmin merged 1 commits from feature/runtime-target-matching-fix into main 2026-09-03 19:38:21 -04:00
+5 -2
View File
@@ -68,7 +68,7 @@ export async function inventory(config: PluginConfig): Promise<{ groups: unknown
const meshesResponse = await request('meshes'); const meshesResponse = await request('meshes');
const meshes = (meshesResponse.meshes ?? []).map((mesh) => ({ const meshes = (meshesResponse.meshes ?? []).map((mesh) => ({
id: mesh.id ?? mesh._id ?? '', name: mesh.name, description: mesh.description ?? mesh.desc, id: mesh.id ?? mesh._id ?? '', name: mesh.name, description: mesh.description ?? mesh.desc,
})).filter((mesh) => mesh.id && mesh.name === config.groupName); })).filter((mesh) => mesh.id && mesh.name.toLowerCase() === config.groupName.toLowerCase());
if (meshes.length !== 1) throw new Error('Approved MeshCentral group was not found uniquely'); if (meshes.length !== 1) throw new Error('Approved MeshCentral group was not found uniquely');
const group = meshes[0]; const group = meshes[0];
@@ -77,7 +77,10 @@ export async function inventory(config: PluginConfig): Promise<{ groups: unknown
id: node.id ?? node._id ?? '', name: node.name, groupId: node.meshid ?? groupId, id: node.id ?? node._id ?? '', name: node.name, groupId: node.meshid ?? groupId,
online: node.online ?? node.conn === 1, os: node.device?.os ?? node.osdesc, online: node.online ?? node.conn === 1, os: node.device?.os ?? node.osdesc,
ipAddresses: node.device?.ip ?? node.ip, ipAddresses: node.device?.ip ?? node.ip,
}))).filter((node) => node.id && node.groupId === group.id && node.name === config.deviceName); // The nodes request is already scoped to the approved group. MeshCentral
// may omit or normalize the per-node meshid differently, so do not apply
// a second brittle group-id comparison here.
}))).filter((node) => node.id && node.name.toLowerCase() === config.deviceName.toLowerCase());
return { groups: meshes, devices }; return { groups: meshes, devices };
} finally { } finally {
await new Promise<void>((resolve) => { await new Promise<void>((resolve) => {