mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-30 11:21:07 +00:00
fix(line): normalize canonical ACP targets (#56713)
This commit is contained in:
@@ -335,6 +335,43 @@ describe("buildLineMessageContext", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("normalizes canonical LINE targets through the plugin bindings surface", async () => {
|
||||
const compiled = linePlugin.bindings?.compileConfiguredBinding({
|
||||
binding: {
|
||||
type: "acp",
|
||||
agentId: "codex",
|
||||
match: { channel: "line", accountId: "default", peer: { kind: "direct", id: "unused" } },
|
||||
} as AgentBinding,
|
||||
conversationId: "line:U1234567890abcdef1234567890abcdef",
|
||||
});
|
||||
|
||||
expect(compiled).toEqual({
|
||||
conversationId: "U1234567890abcdef1234567890abcdef",
|
||||
});
|
||||
expect(
|
||||
linePlugin.bindings?.resolveCommandConversation?.({
|
||||
accountId: "default",
|
||||
originatingTo: "line:U1234567890abcdef1234567890abcdef",
|
||||
}),
|
||||
).toEqual({
|
||||
conversationId: "U1234567890abcdef1234567890abcdef",
|
||||
});
|
||||
expect(
|
||||
linePlugin.bindings?.matchInboundConversation({
|
||||
binding: {
|
||||
type: "acp",
|
||||
agentId: "codex",
|
||||
match: { channel: "line", accountId: "default", peer: { kind: "direct", id: "unused" } },
|
||||
} as AgentBinding,
|
||||
compiledBinding: compiled!,
|
||||
conversationId: "U1234567890abcdef1234567890abcdef",
|
||||
}),
|
||||
).toEqual({
|
||||
conversationId: "U1234567890abcdef1234567890abcdef",
|
||||
matchPriority: 2,
|
||||
});
|
||||
});
|
||||
|
||||
it("routes LINE conversations through active ACP session bindings", async () => {
|
||||
const userId = "U1234567890abcdef1234567890abcdef";
|
||||
await getSessionBindingService().bind({
|
||||
|
||||
@@ -17,7 +17,7 @@ function normalizeLineConversationId(raw?: string | null): string | null {
|
||||
if (!trimmed) {
|
||||
return null;
|
||||
}
|
||||
const prefixed = trimmed.match(/^line:(?:user|group|room):(.+)$/i)?.[1];
|
||||
const prefixed = trimmed.match(/^line:(?:(?:user|group|room):)?(.+)$/i)?.[1];
|
||||
return (prefixed ?? trimmed).trim() || null;
|
||||
}
|
||||
|
||||
|
||||
@@ -201,6 +201,24 @@ describe("commands-acp context", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("resolves LINE conversation ids from canonical line targets", () => {
|
||||
const params = buildCommandTestParams("/acp status", baseCfg, {
|
||||
Provider: "line",
|
||||
Surface: "line",
|
||||
OriginatingChannel: "line",
|
||||
OriginatingTo: "line:U1234567890abcdef1234567890abcdef",
|
||||
AccountId: "work",
|
||||
});
|
||||
|
||||
expect(resolveAcpCommandBindingContext(params)).toEqual({
|
||||
channel: "line",
|
||||
accountId: "work",
|
||||
threadId: undefined,
|
||||
conversationId: "U1234567890abcdef1234567890abcdef",
|
||||
});
|
||||
expect(resolveAcpCommandConversationId(params)).toBe("U1234567890abcdef1234567890abcdef");
|
||||
});
|
||||
|
||||
it("resolves Matrix thread context from the current room and thread root", () => {
|
||||
const params = buildCommandTestParams("/acp status", baseCfg, {
|
||||
Provider: "matrix",
|
||||
|
||||
Reference in New Issue
Block a user