mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 16:41:23 +00:00
Skills: clean up remote node cache on disconnect
This commit is contained in:
36
src/infra/skills-remote.test.ts
Normal file
36
src/infra/skills-remote.test.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
getRemoteSkillEligibility,
|
||||
recordRemoteNodeBins,
|
||||
recordRemoteNodeInfo,
|
||||
removeRemoteNodeInfo,
|
||||
} from "./skills-remote.js";
|
||||
|
||||
describe("skills-remote", () => {
|
||||
it("removes disconnected nodes from remote skill eligibility", () => {
|
||||
const nodeId = `node-${randomUUID()}`;
|
||||
const bin = `bin-${randomUUID()}`;
|
||||
recordRemoteNodeInfo({
|
||||
nodeId,
|
||||
displayName: "Remote Mac",
|
||||
platform: "darwin",
|
||||
commands: ["system.run"],
|
||||
});
|
||||
recordRemoteNodeBins(nodeId, [bin]);
|
||||
|
||||
expect(getRemoteSkillEligibility()?.hasBin(bin)).toBe(true);
|
||||
|
||||
removeRemoteNodeInfo(nodeId);
|
||||
|
||||
expect(getRemoteSkillEligibility()?.hasBin(bin) ?? false).toBe(false);
|
||||
});
|
||||
|
||||
it("supports idempotent remote node removal", () => {
|
||||
const nodeId = `node-${randomUUID()}`;
|
||||
expect(() => {
|
||||
removeRemoteNodeInfo(nodeId);
|
||||
removeRemoteNodeInfo(nodeId);
|
||||
}).not.toThrow();
|
||||
});
|
||||
});
|
||||
@@ -168,6 +168,10 @@ export function recordRemoteNodeBins(nodeId: string, bins: string[]) {
|
||||
upsertNode({ nodeId, bins });
|
||||
}
|
||||
|
||||
export function removeRemoteNodeInfo(nodeId: string) {
|
||||
remoteNodes.delete(nodeId);
|
||||
}
|
||||
|
||||
function listWorkspaceDirs(cfg: OpenClawConfig): string[] {
|
||||
const dirs = new Set<string>();
|
||||
const list = cfg.agents?.list;
|
||||
|
||||
Reference in New Issue
Block a user