mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 15:13:43 +00:00
fix(core): unify session-key normalization and plugin boundary checks
This commit is contained in:
@@ -4,7 +4,11 @@ import {
|
||||
getSubagentDepth,
|
||||
isCronSessionKey,
|
||||
} from "../sessions/session-key-utils.js";
|
||||
import { classifySessionKeyShape } from "./session-key.js";
|
||||
import {
|
||||
classifySessionKeyShape,
|
||||
parseAgentSessionKey,
|
||||
toAgentStoreSessionKey,
|
||||
} from "./session-key.js";
|
||||
|
||||
describe("classifySessionKeyShape", () => {
|
||||
it("classifies empty keys as missing", () => {
|
||||
@@ -93,3 +97,21 @@ describe("deriveSessionChatType", () => {
|
||||
expect(deriveSessionChatType("")).toBe("unknown");
|
||||
});
|
||||
});
|
||||
|
||||
describe("session key canonicalization", () => {
|
||||
it("parses agent keys case-insensitively and returns lowercase tokens", () => {
|
||||
expect(parseAgentSessionKey("AGENT:Main:Hook:Webhook:42")).toEqual({
|
||||
agentId: "main",
|
||||
rest: "hook:webhook:42",
|
||||
});
|
||||
});
|
||||
|
||||
it("does not double-prefix already-qualified agent keys", () => {
|
||||
expect(
|
||||
toAgentStoreSessionKey({
|
||||
agentId: "main",
|
||||
requestKey: "agent:main:main",
|
||||
}),
|
||||
).toBe("agent:main:main");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user