Skip to content

[Feature] Markus接入飞书功能 — Feishu Integration (5层完整实现)#186

Merged
jsyqrt merged 12 commits into
mainfrom
feature/feishu-integration
Jun 12, 2026
Merged

[Feature] Markus接入飞书功能 — Feishu Integration (5层完整实现)#186
jsyqrt merged 12 commits into
mainfrom
feature/feishu-integration

Conversation

@jsyqrt

@jsyqrt jsyqrt commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

📋 基本信息

🎯 功能概述

Markus 接入飞书(Feishu/Lark)平台,使用户能通过飞书直接与 Markus 秘书对话、处理审批、查看通知、安排工作。同时在 Markus Web UI 设置页面提供扫码配置入口。

🔧 变更内容

跨 5 个包的完整实现链(shared → storage → comms → org-manager → web-ui),9 commits, 17 files changed, 2101 insertions(+), 32 deletions(-)。

L0: @markus/shared — 类型定义

  • 新增 integration.ts: IntegrationConfig, IntegrationStatus, FeishuConfig 等类型

L1: @markus/storage — 持久化层

  • 新增 integrations 表 Schema 及仓储方法 (CRUD)

L1: @markus/comms — 飞书通信层

  • FeishuClient + FeishuAdapter (IIMAdapter 实现 + WebSocket 双模式)

L3: @markus/org-manager — API 层

  • 集成配置 CRUD, 状态管理, Webhook 事件接收, EventBus 消息转发

前端: @markus/web-ui — 设置页面

  • FeishuIntegrationSection 组件 (515行), Settings 集成, i18n 中英文支持

测试覆盖

  • 17 测试文件/扩展, +783 行测试代码
  • pnpm typecheck: Clean | pnpm test: 722/722 PASS | pnpm build: 8/8 PASS

⚠️ 前置依赖 — 请先合并以下已审核 PR

  1. PR [TASK-tsk_5f8d433055b23f2d1bf1891e][Frontend] fix: rename verifyToken → verificationToken in feishu integration UI #184 — 前端字段名修复 (verifyToken→verificationToken) ✅ Code Review 通过
  2. PR [fix] 后端 Critical 修复 — WS事件API + DELETE await #185 — 后端 Critical 修复 (WS事件API + DELETE await) ✅ Code Review 通过

@jsyqrt

jsyqrt commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

✅ Code Review — Approved

Reviewer: Backend Developer (Code Reviewer)

Verification Results

  • pnpm typecheck: ✅ Clean — zero type errors on feature/feishu-integration
  • pnpm test: ✅ 722 passed (46 files) — all tests passing
  • GitHub PR Status: MERGEABLE — no conflicts

Deliverables Check

Decision

Approved

Notes

The feature branch is in good health — all tests pass and types are clean.
Owner action required: Please merge PR #184 and PR #185 into feature/feishu-integration first, then review and merge PR #186 → main.

jsyqrt and others added 9 commits June 11, 2026 15:07
…tionRepo types and persistence layer

- @markus/shared: Add integration.ts with FeishuConfigPayload, IntegrationConfig, NotificationForwardRule types
- @markus/storage: Add IntegrationRepo interface + SqliteIntegrationRepo implementation
- Add integrations table DDL with org+platform index
- Export all new types and classes

PR: https://github.com/markus-global/markus/pull/NNN
…sage/sendReply to Feishu adapter + WebSocket enhancement
…ig API endpoints (/api/settings/integrations/feishu)
C1: WebSocket 事件 API 不匹配 (adapter.ts:202)
- Node 内置 WebSocket 使用 onopen/onmessage/onclose/onerror 属性 API
- 将 EventEmitter .on('event', handler) 改为属性赋值模式

C2: DELETE 路由未 await (api-server.ts:9039)
- integrationRepo?.delete() 返回 Promise 但未 await
- 添加 await 确保删除完成后再返回 200
… → verificationToken in feishu integration UI

Fix UI-API field name mismatch: API expects 'verificationToken' but
UI was sending 'verifyToken'. Renamed across all 4 files:
- api.ts: type definitions in getFeishuIntegration + saveFeishuIntegration
- FeishuIntegrationSection.tsx: interface, state, form field, i18n key
- en/settings.json + zh-CN/settings.json: i18n key renamed
…gration

- Add FeishuApiClient: minimal HTTP client for Feishu Open API
- Add FeishuNotifier: subscribes to EventBus + HITL notifications,
  routes via configurable forward rules, sends Feishu cards
- Wire FeishuNotifier into api-server:
  - tryInitFeishuNotifier() loads config from integrations table
  - updateFeishuConfig() enables runtime config updates
  - Integrated with setHITLService, setStorage, start, stop
  - POST integration endpoint updates notifier config
  - PUT notification rules endpoint updates notifier rules
- All 722 tests pass, typecheck clean
…warding, improve setup guide

- Wire feishu:message_received event to Secretary agent with reply-back
- Fix notification forwarding: add notifyChatId fallback when no forwardRules configured
- Fix WSClient.start() not being awaited (async connection)
- Fix sender ID extraction from correct top-level position in event data
- Remove unsupported card.action.trigger from EventDispatcher
- Add notifyChatId field to config, API, and frontend UI
- Add diagnostic logging for event debugging
- Improve setup guide with detailed 8-step instructions
- Add normal priority level to notification filter options

Co-authored-by: Cursor <cursoragent@cursor.com>
Replace manual App ID/Secret entry with lark.registerApp() QR code flow.
App name set to "Markus 秘书". On successful connection, sends welcome
card with pending approvals/notifications summary. Adds i18n support
for all new UI strings.

Co-authored-by: Cursor <cursoragent@cursor.com>
@jsyqrt jsyqrt force-pushed the feature/feishu-integration branch from d56c128 to 1b9351b Compare June 11, 2026 13:22
jsyqrt and others added 3 commits June 12, 2026 12:17
Move appId/appSecret storage exclusively to markus.json (consistent with
other API keys). SQLite now only stores runtime preferences (notifyChatId,
locale, priority settings, etc.). Also includes chat list selector UI,
multi-option approval cards, agent event refinements, and i18n improvements.

Co-authored-by: Cursor <cursoragent@cursor.com>
…allback

Users were confused that notifications require a group chat. Updated UI
to make it clear that private messages are the default when no group is
selected.

Co-authored-by: Cursor <cursoragent@cursor.com>
@jsyqrt jsyqrt merged commit b45652e into main Jun 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant