mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-28 02:12:59 +00:00
fix: route direct thread event wakes to main DMs
This commit is contained in:
@@ -25,6 +25,14 @@ describe("event session routing", () => {
|
||||
accountId: "work",
|
||||
peerId: "123",
|
||||
});
|
||||
expect(
|
||||
parseDirectAgentSessionTarget("agent:main:telegram:work:direct:123:thread:1712345678.123"),
|
||||
).toEqual({
|
||||
agentId: "main",
|
||||
channel: "telegram",
|
||||
accountId: "work",
|
||||
peerId: "123",
|
||||
});
|
||||
});
|
||||
|
||||
it("routes single-owner dmScope=main direct event keys to the agent main session", () => {
|
||||
@@ -53,6 +61,12 @@ describe("event session routing", () => {
|
||||
policy,
|
||||
),
|
||||
).toEqual({ reason: "exec-event", sessionKey: "agent:main:main" });
|
||||
expect(
|
||||
resolveEventSessionKeyForPolicy(
|
||||
"agent:main:telegram:work:direct:123:thread:1712345678.123",
|
||||
policy,
|
||||
),
|
||||
).toBe("agent:main:main");
|
||||
});
|
||||
|
||||
it("does not route multi-owner or wildcard direct sessions to main", () => {
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
buildAgentMainSessionKey,
|
||||
normalizeAgentId,
|
||||
parseAgentSessionKey,
|
||||
parseThreadSessionSuffix,
|
||||
} from "../routing/session-key.js";
|
||||
import { resolveEventSessionKey, scopedHeartbeatWakeOptions } from "../routing/session-key.js";
|
||||
import { resolvePinnedMainDmOwnerFromAllowlist } from "../security/dm-policy-shared.js";
|
||||
@@ -66,8 +67,10 @@ function normalizeEntry(value: string): string | undefined {
|
||||
export function parseDirectAgentSessionTarget(
|
||||
sessionKey: string | undefined | null,
|
||||
): DirectSessionTarget | null {
|
||||
const parsed = parseAgentSessionKey(sessionKey);
|
||||
if (!parsed || deriveSessionChatTypeFromKey(sessionKey) !== "direct") {
|
||||
const { baseSessionKey } = parseThreadSessionSuffix(sessionKey);
|
||||
const directSessionKey = baseSessionKey ?? sessionKey;
|
||||
const parsed = parseAgentSessionKey(directSessionKey);
|
||||
if (!parsed || deriveSessionChatTypeFromKey(directSessionKey) !== "direct") {
|
||||
return null;
|
||||
}
|
||||
const parts = parsed.rest.split(":");
|
||||
|
||||
Reference in New Issue
Block a user