From e2899ee393d8b83ce7c7083874a9398090fb02c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=9A=E6=96=87=E6=BB=940668001436?= Date: Tue, 3 Mar 2026 15:59:36 +0800 Subject: [PATCH] fix: resolve Cron + isolated session + Feishu announce message failed --- src/infra/outbound/outbound-session.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/infra/outbound/outbound-session.ts b/src/infra/outbound/outbound-session.ts index 3655c6e69ff..bcadd73419e 100644 --- a/src/infra/outbound/outbound-session.ts +++ b/src/infra/outbound/outbound-session.ts @@ -845,13 +845,30 @@ function resolveFeishuSession( accountId: params.accountId, peer, }); + + // Normalize the session "to" field so that downstream tooling (including the + // message tool in isolated/cron runs) sees the same Feishu target shapes as + // the main session: + // - DM/user targets -> user:ou_xxx + // - Chat/group targets -> chat:oc_xxx + // This keeps DeliveryContext.To aligned with the Feishu plugin's + // normalizeFeishuTarget/looksLikeFeishuId helpers and avoids + // Unknown target "user" for Feishu / missing-target errors when the + // message tool infers its default target from the session route. + const to = + isGroup || idLower.startsWith("oc_") + ? `chat:${trimmed}` + : idLower.startsWith("ou_") || idLower.startsWith("on_") + ? `user:${trimmed}` + : trimmed; + return { sessionKey: baseSessionKey, baseSessionKey, peer, chatType: isGroup ? "group" : "direct", from: isGroup ? `feishu:group:${trimmed}` : `feishu:${trimmed}`, - to: trimmed, + to, }; }