fix(core): unify session-key normalization and plugin boundary checks

This commit is contained in:
Peter Steinberger
2026-02-26 12:40:57 +00:00
parent e3385a6578
commit 4b71de384c
13 changed files with 182 additions and 34 deletions

View File

@@ -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");
});
});