Commit Graph

15 Commits

Author SHA1 Message Date
jacentsao 150c07368b feat(im): add Yunzhijia integration 2026-07-21 12:24:33 +08:00
qilifan 9afb8b7b68 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>
2026-07-17 11:05:54 +08:00
wizardchen 7099a7e181 fix(security): redact IM list credentials and harden MinerU SSRF
Stop returning bot credentials from Viewer-accessible IM channel list
endpoints and validate self-hosted MinerU URLs at config save and fetch time.
2026-07-02 17:58:20 +08:00
YS-zdck b8ce6a699c feat(im): 新增QQBot即时通讯平台集成支持
完整实现QQBot的IM适配器功能,包括客户端封装、WebSocket长连接管理、消息收发与事件解析;更新后端合法平台校验列表与适配器注册配置;补充前端平台选型选项、logo资源、多语言文案以及渠道配置表单,同时添加对应的单元测试。
2026-06-26 16:53:00 +08:00
wizardchen 635d7c9643 feat(integrations): polish embed/IM channel editors and agent rebind
Align embed channel setup with a step wizard, simplify deploy layout,
and allow changing bound agents on update for embed and IM channels.
2026-06-24 20:09:19 +08:00
nullkey c753c67608 docs(api): add and fix swag annotations on handlers
将 swag 注解覆盖率从 ~88% 提升到 100%,并修复审计中发现的若干既有
注解 bug。

新增注解(24 个):
- im.go: 4 (UpdateIMChannel/DeleteIMChannel/ToggleIMChannel/IMCallback)
  其中 IMCallback 同时注册 GET 和 POST,两个方法都加了 @Router 声明。
- web_search.go: 1 (GetProviders)
- web_search_provider.go: 6
- wechat_qrcode.go: 2
- weknoracloud.go: 2
- knowledge.go: 2 (MoveKnowledge/GetKnowledgeMoveProgress)
- knowledgebase.go: 1 (ListMoveTargets)
- organization.go: 3 (ListSharedAgents/ListOrgAgentShares/RemoveAgentShare)
- mcp_service.go: 2 (SetMCPToolApproval/ResolveToolApproval)
- chunker_debug.go: 1 (PreviewChunking)

修复既有注解 bug(12 处):
- initialization.go: 10 个 @Router 路径与真实路由不符
  (e.g. /initialization/kb/{kbId}/config → /initialization/config/{kbId}
   /initialization/fabri/tag GET → /initialization/extract/fabri-tag POST)
- session/stream.go: ContinueStream 路径
  /sessions/{session_id}/continue → /sessions/continue-stream/{session_id}
- mcp_service.go: ResolveToolApproval 请求体 {approve: bool}
  → {decision: "approve"|"reject", reason?, modified_args?}

收敛响应 schema 到已有命名 struct(之前用 map[string]interface{}):
- knowledge.go MoveKnowledge → handler.MoveKnowledgeResponse
- knowledge.go GetKnowledgeMoveProgress → types.KnowledgeMoveProgress
- web_search_provider.go GetProvider/UpdateProvider → types.WebSearchProviderEntity
- initialization.go InitializeByKB → handler.InitializationRequest
- initialization.go 三个 model-test endpoint → handler.ModelTestRequest

修正 organization.go 中 errors.AppError 应使用 apperrors 别名(该文件
stdlib errors 未别名化)。

不补 /files 和 /api/v1/files/presigned 内联闭包路由(文件服务,非业务 REST)。

Refs #890 #1049 #1168
2026-05-12 13:16:58 +08:00
wizardchen e029d31f86 feat(im): tenant-wide IM channels overview under the user menu
Until now the IM channels a tenant has connected were only visible from
inside each agent's editor (AgentEditorModal → IMChannelPanel). Finding
out which bots are live across all agents meant clicking through every
one of them. Add a tenant-scoped overview so the set of connected IMs is
always one hop away from the avatar.

Backend

- im.Service.ListChannelsByTenant(tenantID) returns all non-deleted
  channels in the tenant, LEFT JOIN'd with custom_agents.name so
  built-in agents (which don't have rows in custom_agents) still show
  up with an empty agent_name; the frontend substitutes a localized
  "built-in agent" label.
- Credentials are intentionally stripped from this response — the list
  view is read-only and the editor route (GET /agents/:id/im-channels)
  remains the only source for secrets.
- New ChannelWithAgent DTO + IMHandler.ListAllIMChannels wired at
  GET /api/v1/im-channels under the existing RegisterIMChannelRoutes
  group, so auth middleware is inherited.

Frontend

- IMChannelsOverviewPanel.vue: floating submenu pane, stacked rows
  (agent on top, channel below) with identical 20px avatars and 12px
  labels so neither identity dominates. Each row is the whole click
  target (jumps to the agent editor); the switch uses @click.stop to
  toggle in place without triggering navigation.
- UserMenu.vue: new hover-driven submenu entry ("已接入的 IM" + link
  icon). The pane is teleported to <body> because the sidebar container
  has overflow:hidden that would otherwise clip right-flying content.
  Position is computed from the menu item's rect and clamps/flips
  against the viewport edges.
- "Live" indicator: a pulsing green dot on the menu item when at least
  one channel is enabled. UserMenu prefetches the list once on mount;
  the panel re-emits channels-changed after every load/toggle so the
  dot stays in sync. Respects prefers-reduced-motion.
- AgentList.vue: supplement the existing onMounted-only
  checkAndOpenEditModal with a watch(route.query.edit) so
  router.push({ path: '/platform/agents', query: { edit, section } })
  from an already-mounted AgentList (the common case when navigating
  from the overview) opens the editor immediately instead of only
  after a hard refresh.

Assets

- Seven platform SVGs under assets/img/im/, pulled from iconify
  (simple-icons / logos / tdesign / icon-park / remix icon) and baked
  with brand colors so monochrome sources (wecom/wechat/dingtalk/
  feishu) don't render black.

i18n

- New imOverview namespace in zh-CN / en-US / ko-KR / ru-RU covering
  the menu label, panel title/subtitle, column headers, builtin-agent
  fallback, and the live-indicator tooltip.

Tested

- go build ./...
- go test ./internal/im/...
- vue-tsc --noEmit
- npm run build
2026-04-30 15:29:14 +08:00
wizardchen d1c7da97f9 feat(im): add WeChat integration with QR code login and long-polling support
- Extended the IMChannel interface to include WeChat as a platform, supporting long-polling mode and full output mode.
- Implemented WeChat QR code login functionality, allowing users to authenticate via a QR code.
- Added new API endpoints for generating and polling the status of WeChat QR codes.
- Updated the frontend to handle WeChat-specific UI elements and interactions, including dynamic form adjustments based on the selected platform.
- Enhanced localization files to include WeChat-related translations.
- Introduced a WeChat adapter for message handling and file downloading via the iLink Bot API.
2026-04-13 14:17:57 +08:00
Austin Xia 463f40fadc Add im channel Mattermost 2026-03-27 14:32:07 +08:00
nullkey a1a384ec67 feat(im): add DingTalk platform integration
Add DingTalk bot adapter supporting both webhook (HmacSHA256 signature
verification) and Stream mode (via official dingtalk-stream-sdk-go),
with sessionWebhook/OpenAPI reply fallback and AccessToken caching.
2026-03-24 22:12:08 +08:00
nullkey aea0a97be3 feat(im): add Telegram platform integration
Add Telegram Bot API adapter supporting both webhook and long-polling
modes with streaming replies via editMessageText, file download via
getFile API, and timing-safe secret token verification.
2026-03-24 22:12:08 +08:00
joeyczheng 49b5f1a739 feat(IM): support both websocket/webhook mode im channel for slack
Signed-off-by: joeyczheng <joeyczheng@tencent.com>
2026-03-18 21:26:53 +08:00
wizardchen 09d9fe5ddb feat(im): add file support and knowledge base integration 2026-03-17 22:23:24 +08:00
wizardchen 6159e8e3f7 feat: implement IM channel management in agent editor
- Introduced a new IMChannelPanel component for managing WeCom and Feishu channels.
- Added CRUD operations for IM channels, including create, update, delete, and list functionalities.
- Enhanced the backend with new API endpoints for IM channel management.
- Updated documentation to reflect changes in IM integration and channel management.
- Improved localization support for new IM-related UI elements across multiple languages.
2026-03-16 02:28:10 +08:00
nullkey 9fa969fb5c feat: add WeCom and Feishu IM bot integration
- support webhook and websocket modes for both platforms
- add im_channel_sessions migration for channel-session mapping
- register IM adapters and callback routes
- update config and docker-compose for IM env vars
2026-03-16 02:26:17 +08:00