Files
openclaw/extensions/feishu/src/session-route.ts
Peter Steinberger a2a68d154b fix(agent): preserve explicit recipient sessions (#101507)
* fix(agent): honor recipient session routing

Co-authored-by: vincentkoc <25068+vincentkoc@users.noreply.github.com>
Co-authored-by: pingfanfan <pingfan.work@gmail.com>

* fix(agent): preserve canonical recipient routes

* fix(agent): require exact recipient routes

Co-authored-by: vincentkoc <25068+vincentkoc@users.noreply.github.com>

Co-authored-by: pingfanfan <pingfan.work@gmail.com>

* fix(agent): harden recipient route resolution

* fix(imessage): require canonical recipient handles

* fix(agent): refine provider recipient exactness

* fix(agent): bound direct alias session routing

* fix(signal): preserve direct alias route type

* fix(agent): honor binding-scoped recipient sessions

* fix(routing): honor configured main session aliases

* fix(clickclack): align account-owned session routes

* fix(twitch): preserve canonical recipient sessions

* fix(routing): isolate stable outbound identities

* chore: defer recipient session changelog

* fix(sms): use dedicated channel SDK facade

---------

Co-authored-by: vincentkoc <25068+vincentkoc@users.noreply.github.com>
Co-authored-by: pingfanfan <pingfan.work@gmail.com>
2026-07-07 10:07:13 +01:00

46 lines
1.7 KiB
TypeScript

// Feishu plugin module implements session route behavior.
import {
buildChannelOutboundSessionRoute,
stripChannelTargetPrefix,
type ChannelOutboundSessionRouteParams,
} from "openclaw/plugin-sdk/channel-core";
import { resolveFeishuAccount } from "./accounts.js";
import { resolveConfiguredFeishuGroupSessionScope } from "./conversation-id.js";
import { resolveFeishuGroupConfig } from "./policy.js";
import { normalizeFeishuTarget, resolveReceiveIdType } from "./targets.js";
export function resolveFeishuOutboundSessionRoute(params: ChannelOutboundSessionRouteParams) {
const rawTarget = stripChannelTargetPrefix(params.target, "feishu", "lark");
const target = normalizeFeishuTarget(rawTarget);
if (!target) {
return null;
}
const isGroup = resolveReceiveIdType(rawTarget) === "chat_id";
const account = resolveFeishuAccount({ cfg: params.cfg, accountId: params.accountId });
const groupSessionScope = isGroup
? resolveConfiguredFeishuGroupSessionScope({
groupConfig: resolveFeishuGroupConfig({ cfg: account.config, groupId: target }),
feishuCfg: account.config,
})
: undefined;
// Sender/topic-scoped inbound sessions cannot be recovered from a bare outbound chat id.
const recipientSessionExact = isGroup
? target.startsWith("oc_") && groupSessionScope === "group"
: target.startsWith("ou_");
return buildChannelOutboundSessionRoute({
cfg: params.cfg,
agentId: params.agentId,
channel: "feishu",
accountId: params.accountId,
recipientSessionExact,
peer: {
kind: isGroup ? "group" : "direct",
id: target,
},
chatType: isGroup ? "group" : "direct",
from: isGroup ? `feishu:group:${target}` : `feishu:${target}`,
to: target,
});
}