mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-18 13:27:27 +00:00
Agents/Replies: scope done fallback to direct sessions
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { getSubagentDepth, isCronSessionKey } from "../sessions/session-key-utils.js";
|
||||
import {
|
||||
deriveSessionChatType,
|
||||
getSubagentDepth,
|
||||
isCronSessionKey,
|
||||
} from "../sessions/session-key-utils.js";
|
||||
import { classifySessionKeyShape } from "./session-key.js";
|
||||
|
||||
describe("classifySessionKeyShape", () => {
|
||||
@@ -66,3 +70,26 @@ describe("isCronSessionKey", () => {
|
||||
expect(isCronSessionKey(undefined)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("deriveSessionChatType", () => {
|
||||
it("detects canonical direct/group/channel session keys", () => {
|
||||
expect(deriveSessionChatType("agent:main:discord:direct:user1")).toBe("direct");
|
||||
expect(deriveSessionChatType("agent:main:telegram:group:g1")).toBe("group");
|
||||
expect(deriveSessionChatType("agent:main:discord:channel:c1")).toBe("channel");
|
||||
});
|
||||
|
||||
it("detects legacy direct markers", () => {
|
||||
expect(deriveSessionChatType("agent:main:telegram:dm:123456")).toBe("direct");
|
||||
expect(deriveSessionChatType("telegram:dm:123456")).toBe("direct");
|
||||
});
|
||||
|
||||
it("detects legacy discord guild channel keys", () => {
|
||||
expect(deriveSessionChatType("discord:acc-1:guild-123:channel-456")).toBe("channel");
|
||||
});
|
||||
|
||||
it("returns unknown for main or malformed session keys", () => {
|
||||
expect(deriveSessionChatType("agent:main:main")).toBe("unknown");
|
||||
expect(deriveSessionChatType("agent:main")).toBe("unknown");
|
||||
expect(deriveSessionChatType("")).toBe("unknown");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user