refactor(core): dedupe infra, media, pairing, and plugin helpers

This commit is contained in:
Peter Steinberger
2026-03-02 21:31:18 +00:00
parent 91dd89313a
commit 34daed1d1e
11 changed files with 301 additions and 340 deletions

View File

@@ -4,6 +4,15 @@ import type { OpenClawConfig } from "../config/config.js";
import { resolveAgentRoute } from "./resolve-route.js";
describe("resolveAgentRoute", () => {
const resolveDiscordGuildRoute = (cfg: OpenClawConfig) =>
resolveAgentRoute({
cfg,
channel: "discord",
accountId: "default",
peer: { kind: "channel", id: "c1" },
guildId: "g1",
});
test("defaults to main/default when no bindings exist", () => {
const cfg: OpenClawConfig = {};
const route = resolveAgentRoute({
@@ -123,13 +132,7 @@ describe("resolveAgentRoute", () => {
},
],
};
const route = resolveAgentRoute({
cfg,
channel: "discord",
accountId: "default",
peer: { kind: "channel", id: "c1" },
guildId: "g1",
});
const route = resolveDiscordGuildRoute(cfg);
expect(route.agentId).toBe("chan");
expect(route.sessionKey).toBe("agent:chan:discord:channel:c1");
expect(route.matchedBy).toBe("binding.peer");
@@ -163,13 +166,7 @@ describe("resolveAgentRoute", () => {
},
],
};
const route = resolveAgentRoute({
cfg,
channel: "discord",
accountId: "default",
peer: { kind: "channel", id: "c1" },
guildId: "g1",
});
const route = resolveDiscordGuildRoute(cfg);
expect(route.agentId).toBe("guild");
expect(route.matchedBy).toBe("binding.guild");
});