feat(im,datasource): support Lark, Feishu's international edition
Lark and Feishu are the same product deployed on two isolated clouds (open.larksuite.com and open.feishu.cn). WeKnora touches both from two places — the IM bot and the Wiki data-source connector — and this brings Lark to parity across both. Neither API surface differs, so rather than duplicate either implementation, each is parametrized by a Region and registered twice. IM (internal/im/feishu): Every API call routes through a.api(), which prefixes the region's host, and the WebSocket client passes larkws.WithDomain — the SDK defaults to open.feishu.cn, so Lark long connections would otherwise fail to authenticate. Data source (internal/datasource/connector/feishu): Lark was half-supported: the client honoured a base_url override and a LarkBaseURL constant existed, but the connector registered only as "feishu" and the UI never exposed base_url, so Lark wikis could not be configured at all. Lark is now its own connector type. base_url is kept as an explicit override so data sources that pointed a "feishu" connector at open.larksuite.com keep working. Bugs found and fixed along the way: - Wiki resource links were hardcoded to https://feishu.cn/wiki/{token} in four places, so a Lark wiki linked into the wrong cloud entirely. - Bot identity is now platform-prefixed (feishu:cli_x vs lark:cli_x). BotIdentity carries a unique index, so without this a Lark channel would be rejected as a duplicate of an unrelated Feishu bot sharing an app_id. - The card image cache is now keyed by app_id. image_keys are issued per app on one cloud; a Feishu key handed to a Lark app fails the card update with code=200570. - The datasource doc claimed Lark "adapts automatically" — it could not, since the UI had no way to reach base_url. Permissions are where the clouds genuinely diverge. Identical APIs do not mean identical permission catalogues: aily:file:read, aily:file:write and corehr:file:download exist on Feishu but not on Lark, so pasting Feishu's scope JSON into Lark fails to import. That JSON is also over-broad (it covers products WeKnora never calls) and simultaneously incomplete (it omits the drive:*/docx:* scopes the connector needs). Lark therefore gets its own list, derived from the 17 endpoints the code actually calls and checked identifier-by-identifier against Lark's own API reference, plus a full Feishu→Lark mapping table marking each scope verified, unverified, or absent. Both features use tenant_access_token only — no user_access_ token exists anywhere in the repo — so the user dimension stays empty. Known limitation: Region.ThinkingText makes Lark's initial card placeholder English, but once streaming starts the think-block headers come from the shared MarkdownThinkStyle and are Chinese on every platform (Lark, Slack, Telegram, Mattermost alike). Fixing that means threading a locale through FormatIMDisplayContent, which has no platform context — a cross-platform change, not a Lark one. Documented as such. The channel-creation 400 message is now derived from validIMPlatforms so the list cannot drift as platforms are added. Tests: region invariants and per-region URL construction on both sides, the Feishu/Lark bot-identity split, platform-to-channel mapping, base_url override precedence, an end-to-end SendReply against a fake Open Platform (token fetch, reply, thread-unsupported fallback, hard-error surfacing), and a ListResources drive asserting wiki links never leak the other cloud's host. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -295,7 +295,8 @@ export interface IMChannel {
|
||||
id: string;
|
||||
tenant_id?: number;
|
||||
agent_id: string;
|
||||
platform: 'wecom' | 'feishu' | 'slack' | 'telegram' | 'dingtalk' | 'mattermost' | 'wechat' | 'qqbot';
|
||||
// 'lark' is Feishu's international edition; it shares Feishu's credentials and modes.
|
||||
platform: 'wecom' | 'feishu' | 'lark' | 'slack' | 'telegram' | 'dingtalk' | 'mattermost' | 'wechat' | 'qqbot';
|
||||
name: string;
|
||||
enabled: boolean;
|
||||
mode: 'webhook' | 'websocket' | 'longpoll';
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 48 48"><g fill="#3370ff" fill-rule="evenodd" clip-rule="evenodd"><path d="M41.0716 5.99409L3.31071 16.5187L12.3856 25.8126L20.7998 25.9594L30.4827 16.5187C30.2266 15.9943 30.0985 15.5552 30.0985 15.2013C30.0985 14.4074 30.4104 13.7786 30.8947 13.333C31.7241 12.57 32.7222 12.4558 33.8889 12.9905L41.0716 5.99409Z"/><path d="M42.1021 6.72842L31.5775 44.4893L22.2836 35.4144L22.1367 27.0002L31.5115 17.4816C32.0195 17.8454 32.5743 18.0105 33.1759 17.9769C34.0784 17.9264 34.6614 17.3813 34.9349 17.0602C35.2083 16.7392 35.5293 16.2051 35.5025 15.4113C35.4847 14.8821 35.3109 14.3941 34.9812 13.9472L42.1021 6.72842Z"/></g></svg>
|
||||
|
After Width: | Height: | Size: 705 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 48 48"><g fill="#3370ff" fill-rule="evenodd" clip-rule="evenodd"><path d="M41.0716 5.99409L3.31071 16.5187L12.3856 25.8126L20.7998 25.9594L30.4827 16.5187C30.2266 15.9943 30.0985 15.5552 30.0985 15.2013C30.0985 14.4074 30.4104 13.7786 30.8947 13.333C31.7241 12.57 32.7222 12.4558 33.8889 12.9905L41.0716 5.99409Z"/><path d="M42.1021 6.72842L31.5775 44.4893L22.2836 35.4144L22.1367 27.0002L31.5115 17.4816C32.0195 17.8454 32.5743 18.0105 33.1759 17.9769C34.0784 17.9264 34.6614 17.3813 34.9349 17.0602C35.2083 16.7392 35.5293 16.2051 35.5025 15.4113C35.4847 14.8821 35.3109 14.3941 34.9812 13.9472L42.1021 6.72842Z"/></g></svg>
|
||||
|
After Width: | Height: | Size: 705 B |
@@ -295,11 +295,11 @@
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<!-- Feishu credentials -->
|
||||
<template v-if="formData.platform === 'feishu'">
|
||||
<!-- Feishu / Lark credentials — same fields, different open platform -->
|
||||
<template v-if="formData.platform === 'feishu' || formData.platform === 'lark'">
|
||||
<div class="platform-link-hint">
|
||||
<a href="https://open.feishu.cn/" target="_blank" rel="noopener noreferrer" class="doc-link">
|
||||
{{ $t('agentEditor.im.feishuConsole') }}
|
||||
<a :href="openPlatformConsole.url" target="_blank" rel="noopener noreferrer" class="doc-link">
|
||||
{{ $t(openPlatformConsole.labelKey) }}
|
||||
<t-icon name="link" class="link-icon" />
|
||||
</a>
|
||||
<span class="hint-text">{{ $t('agentEditor.im.consoleTip') }}</span>
|
||||
@@ -538,6 +538,7 @@ import SettingDrawer from '@/components/settings/SettingDrawer.vue';
|
||||
import IntegrationsAgentFilter from '@/components/IntegrationsAgentFilter.vue';
|
||||
import wecomLogo from '@/assets/img/im/wecom.svg';
|
||||
import feishuLogo from '@/assets/img/im/feishu.svg';
|
||||
import larkLogo from '@/assets/img/im/lark.svg';
|
||||
import slackLogo from '@/assets/img/im/slack.svg';
|
||||
import telegramLogo from '@/assets/img/im/telegram.svg';
|
||||
import dingtalkLogo from '@/assets/img/im/dingtalk.svg';
|
||||
@@ -550,6 +551,7 @@ type IMPlatform = IMChannel['platform'];
|
||||
const PLATFORM_LOGO: Record<string, string> = {
|
||||
wecom: wecomLogo,
|
||||
feishu: feishuLogo,
|
||||
lark: larkLogo,
|
||||
slack: slackLogo,
|
||||
telegram: telegramLogo,
|
||||
dingtalk: dingtalkLogo,
|
||||
@@ -600,6 +602,7 @@ const drawerConfirmText = computed(() =>
|
||||
const platformOptions = computed(() => ([
|
||||
{ value: 'wecom' as IMPlatform, label: t('agentEditor.im.wecom'), logo: wecomLogo },
|
||||
{ value: 'feishu' as IMPlatform, label: t('agentEditor.im.feishu'), logo: feishuLogo },
|
||||
{ value: 'lark' as IMPlatform, label: t('agentEditor.im.lark'), logo: larkLogo },
|
||||
{ value: 'slack' as IMPlatform, label: t('agentEditor.im.slack'), logo: slackLogo },
|
||||
{ value: 'telegram' as IMPlatform, label: t('agentEditor.im.telegram'), logo: telegramLogo },
|
||||
{ value: 'dingtalk' as IMPlatform, label: t('agentEditor.im.dingtalk'), logo: dingtalkLogo },
|
||||
@@ -608,6 +611,14 @@ const platformOptions = computed(() => ([
|
||||
{ value: 'qqbot' as IMPlatform, label: t('agentEditor.im.qqbot'), logo: qqbotLogo },
|
||||
]));
|
||||
|
||||
// Feishu and Lark are the same product on separate clouds, so each has its own
|
||||
// open platform console. Bots must be created on the one matching the channel.
|
||||
const openPlatformConsole = computed(() =>
|
||||
formData.value.platform === 'lark'
|
||||
? { url: 'https://open.larksuite.com/', labelKey: 'agentEditor.im.larkConsole' }
|
||||
: { url: 'https://open.feishu.cn/', labelKey: 'agentEditor.im.feishuConsole' },
|
||||
);
|
||||
|
||||
const drawerTitle = computed(() => {
|
||||
if (editingChannel.value) {
|
||||
return formData.value.name?.trim() || t('agentEditor.im.unnamed');
|
||||
@@ -708,7 +719,7 @@ function resolvedChannelName(): string {
|
||||
}
|
||||
|
||||
function platformSupportsThread(platform: string): boolean {
|
||||
return ['slack', 'mattermost', 'feishu', 'telegram'].includes(platform);
|
||||
return ['slack', 'mattermost', 'feishu', 'lark', 'telegram'].includes(platform);
|
||||
}
|
||||
|
||||
watch(
|
||||
|
||||
@@ -255,6 +255,7 @@ const chatResources = useChatResourcesStore();
|
||||
// visually consistent with the channels admin view.
|
||||
import wecomLogo from '@/assets/img/im/wecom.svg';
|
||||
import feishuLogo from '@/assets/img/im/feishu.svg';
|
||||
import larkLogo from '@/assets/img/im/lark.svg';
|
||||
import slackLogo from '@/assets/img/im/slack.svg';
|
||||
import telegramLogo from '@/assets/img/im/telegram.svg';
|
||||
import dingtalkLogo from '@/assets/img/im/dingtalk.svg';
|
||||
@@ -265,6 +266,7 @@ import qqbotLogo from '@/assets/img/im/qqbot.png';
|
||||
const PLATFORM_LOGO: Record<string, string> = {
|
||||
wecom: wecomLogo,
|
||||
feishu: feishuLogo,
|
||||
lark: larkLogo,
|
||||
slack: slackLogo,
|
||||
telegram: telegramLogo,
|
||||
dingtalk: dingtalkLogo,
|
||||
|
||||
@@ -5840,8 +5840,9 @@ export default {
|
||||
},
|
||||
im: {
|
||||
title: 'IM Integration',
|
||||
description: 'Connect agent to instant messaging platforms like WeCom, Feishu, Slack, Telegram, DingTalk, Mattermost, WeChat and QQBot',
|
||||
description: 'Connect agent to instant messaging platforms like WeCom, Feishu, Lark, Slack, Telegram, DingTalk, Mattermost, WeChat and QQBot',
|
||||
feishu: 'Feishu',
|
||||
lark: 'Lark',
|
||||
slack: 'Slack',
|
||||
telegram: 'Telegram',
|
||||
dingtalk: 'DingTalk',
|
||||
@@ -5868,6 +5869,7 @@ export default {
|
||||
docLink: 'Integration Guide',
|
||||
wecomConsole: 'WeCom Admin Console',
|
||||
feishuConsole: 'Feishu Open Platform',
|
||||
larkConsole: 'Lark Open Platform',
|
||||
slackConsole: 'Slack API Console',
|
||||
telegramConsole: 'Telegram BotFather',
|
||||
dingtalkConsole: 'DingTalk Open Platform',
|
||||
@@ -6162,12 +6164,14 @@ export default {
|
||||
},
|
||||
connector: {
|
||||
feishu: 'Feishu',
|
||||
lark: 'Lark',
|
||||
notion: 'Notion',
|
||||
yuque: 'Yuque',
|
||||
rss: 'RSS / Atom Feed',
|
||||
},
|
||||
connectorDesc: {
|
||||
feishu: 'Sync documents, spreadsheets and files from Feishu Wiki',
|
||||
lark: 'Sync documents, spreadsheets and files from Lark Wiki (Feishu international)',
|
||||
notion: 'Sync pages and databases from Notion',
|
||||
yuque: 'Sync documents from Yuque knowledge bases',
|
||||
rss: 'Sync articles from RSS / Atom feeds',
|
||||
|
||||
@@ -5777,6 +5777,7 @@ export default {
|
||||
description: "에이전트를 Feishu, Slack, Telegram, DingTalk, Mattermost, QQBot 등 인스턴트 메시징 플랫폼에 연결",
|
||||
wecom: "WeCom",
|
||||
feishu: "Feishu",
|
||||
lark: "Lark",
|
||||
slack: "Slack",
|
||||
telegram: "Telegram",
|
||||
dingtalk: "DingTalk",
|
||||
@@ -5802,6 +5803,7 @@ export default {
|
||||
docLink: "통합 가이드 보기",
|
||||
wecomConsole: "WeCom 관리 콘솔",
|
||||
feishuConsole: "Feishu 개발 플랫폼",
|
||||
larkConsole: "Lark 개발 플랫폼",
|
||||
slackConsole: "Slack API 콘솔",
|
||||
telegramConsole: "Telegram BotFather",
|
||||
dingtalkConsole: "DingTalk 개발 플랫폼",
|
||||
@@ -6167,12 +6169,14 @@ export default {
|
||||
},
|
||||
connector: {
|
||||
feishu: "페이슈 (Feishu)",
|
||||
lark: "Lark (Feishu 글로벌)",
|
||||
notion: "Notion",
|
||||
yuque: "위큐 (Yuque)",
|
||||
rss: "RSS / Atom 피드",
|
||||
},
|
||||
connectorDesc: {
|
||||
feishu: "페이슈 위키에서 문서, 스프레드시트, 파일 동기화",
|
||||
lark: "Lark 위키에서 문서, 스프레드시트, 파일 동기화",
|
||||
notion: "Notion에서 페이지 및 데이터베이스 동기화",
|
||||
yuque: "위큐 지식베이스에서 문서 동기화",
|
||||
rss: "RSS / Atom 피드에서 글 동기화",
|
||||
|
||||
@@ -5347,6 +5347,7 @@ export default {
|
||||
description: 'Подключите агента к платформам мгновенных сообщений, таким как Feishu, Slack, Telegram, DingTalk, Mattermost и QQBot',
|
||||
wecom: 'WeCom',
|
||||
feishu: 'Feishu',
|
||||
lark: 'Lark',
|
||||
slack: 'Slack',
|
||||
telegram: 'Telegram',
|
||||
dingtalk: 'DingTalk',
|
||||
@@ -5372,6 +5373,7 @@ export default {
|
||||
docLink: 'Руководство по интеграции',
|
||||
wecomConsole: 'Консоль WeCom',
|
||||
feishuConsole: 'Платформа Feishu',
|
||||
larkConsole: 'Платформа Lark',
|
||||
slackConsole: 'Консоль Slack API',
|
||||
telegramConsole: 'Telegram BotFather',
|
||||
dingtalkConsole: 'Платформа DingTalk',
|
||||
@@ -5988,12 +5990,14 @@ export default {
|
||||
},
|
||||
connector: {
|
||||
feishu: 'Feishu (Фэйшу)',
|
||||
lark: 'Lark',
|
||||
notion: 'Notion',
|
||||
yuque: 'Yuque (Юйцюэ)',
|
||||
rss: 'RSS / Atom лента',
|
||||
},
|
||||
connectorDesc: {
|
||||
feishu: 'Синхронизация документов, таблиц и файлов из Feishu Wiki',
|
||||
lark: 'Синхронизация документов, таблиц и файлов из Lark Wiki',
|
||||
notion: 'Синхронизация страниц и баз данных из Notion',
|
||||
yuque: 'Синхронизация документов из баз знаний Yuque',
|
||||
rss: 'Синхронизация статей из лент RSS / Atom',
|
||||
|
||||
@@ -5798,6 +5798,7 @@ export default {
|
||||
description: "将智能体接入即时通讯平台,支持企业微信、飞书、Slack、Telegram、钉钉、Mattermost、微信和 QQBot",
|
||||
wecom: "企业微信",
|
||||
feishu: "飞书",
|
||||
lark: "Lark(飞书国际版)",
|
||||
slack: "Slack",
|
||||
telegram: "Telegram",
|
||||
dingtalk: "钉钉",
|
||||
@@ -5823,6 +5824,7 @@ export default {
|
||||
docLink: "查看接入文档",
|
||||
wecomConsole: "企业微信管理后台",
|
||||
feishuConsole: "飞书开放平台",
|
||||
larkConsole: "Lark 开放平台",
|
||||
slackConsole: "Slack API 控制台",
|
||||
telegramConsole: "Telegram BotFather",
|
||||
dingtalkConsole: "钉钉开放平台",
|
||||
@@ -6187,12 +6189,14 @@ export default {
|
||||
},
|
||||
connector: {
|
||||
feishu: "飞书",
|
||||
lark: "Lark(飞书国际版)",
|
||||
notion: "Notion",
|
||||
yuque: "语雀",
|
||||
rss: "RSS / Atom 订阅",
|
||||
},
|
||||
connectorDesc: {
|
||||
feishu: "同步飞书知识库中的文档、表格、文件",
|
||||
lark: "同步 Lark 知识库中的文档、表格、文件(飞书国际版)",
|
||||
notion: "同步 Notion 中的页面和数据库",
|
||||
yuque: "同步语雀知识库中的文档",
|
||||
rss: "同步 RSS / Atom 订阅源中的文章",
|
||||
|
||||
@@ -368,6 +368,26 @@ const connectorDefs = computed<ConnectorDef[]>(() => [
|
||||
{ key: 'app_secret', labelKey: 'datasource.field.appSecret', placeholder: '', secret: true },
|
||||
],
|
||||
},
|
||||
{
|
||||
// Lark is Feishu's international cloud. Same wiki/docx/drive APIs and the
|
||||
// same scope identifiers, but a separate console, tenant and app — an app
|
||||
// created on open.feishu.cn cannot read a Lark wiki.
|
||||
type: 'lark',
|
||||
available: true,
|
||||
docUrl: 'https://open.larksuite.com/app',
|
||||
permissionDocUrl: 'https://open.larksuite.com/document/server-docs/docs/wiki-v2/wiki-overview',
|
||||
permissionPageUrl: 'https://open.larksuite.com/app',
|
||||
requiredPermissions: [
|
||||
'wiki:wiki:readonly',
|
||||
'drive:drive:readonly',
|
||||
'drive:export:readonly',
|
||||
'docx:document:readonly',
|
||||
],
|
||||
fields: [
|
||||
{ key: 'app_id', labelKey: 'datasource.field.appId', placeholder: 'cli_xxxx' },
|
||||
{ key: 'app_secret', labelKey: 'datasource.field.appSecret', placeholder: '', secret: true },
|
||||
],
|
||||
},
|
||||
{
|
||||
type: 'notion',
|
||||
available: true,
|
||||
|
||||
@@ -17,6 +17,8 @@ function fallbackText(type: string) {
|
||||
switch (type) {
|
||||
case 'feishu':
|
||||
return 'F'
|
||||
case 'lark':
|
||||
return 'L'
|
||||
case 'notion':
|
||||
return 'N'
|
||||
case 'yuque':
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import feishuIcon from '@/assets/img/datasource-feishu.ico'
|
||||
import larkIcon from '@/assets/img/datasource-lark.svg'
|
||||
import notionIcon from '@/assets/img/datasource-notion.ico'
|
||||
import yuqueIcon from '@/assets/img/datasource-yuque.ico'
|
||||
import rssIcon from '@/assets/img/datasource-rss.svg'
|
||||
|
||||
export const datasourceIconMap: Record<string, string> = {
|
||||
feishu: feishuIcon,
|
||||
lark: larkIcon,
|
||||
notion: notionIcon,
|
||||
yuque: yuqueIcon,
|
||||
rss: rssIcon,
|
||||
|
||||
Reference in New Issue
Block a user