Skip to content

feat(adapter-lark): add Lark (Feishu) adapter#420

Closed
mazhe-nerd wants to merge 1 commit into
vercel:mainfrom
mazhe-nerd:feature/adaptor-lark
Closed

feat(adapter-lark): add Lark (Feishu) adapter#420
mazhe-nerd wants to merge 1 commit into
vercel:mainfrom
mazhe-nerd:feature/adaptor-lark

Conversation

@mazhe-nerd
Copy link
Copy Markdown

Summary

Adds @chat-adapter/lark, a new Chat SDK adapter for Lark / Feishu, built on @larksuiteoapi/node-sdk's LarkChannel.

Capabilities

Inbound (WebSocket long-connection):

  • Receives messages (23 Lark message types normalized by the SDK), reactions, and card button clicks
  • Routes to onNewMention / onDirectMessage / onSubscribedMessage / onReaction / onAction
  • Mention detection uses the SDK's structured mentionedBot field (works even when Lark strips @bot from the text)

Outbound:

  • postMessage — markdown → Lark post with code-fence-aware chunking and auto-retry
  • stream — native cardkit typewriter (progressive rendering, not PATCH polling)
  • editMessage / deleteMessage — via the SDK's channel.editMessage / channel.recallMessage (handles post-vs-text format matching)
  • addReaction / removeReaction — with chat-SDK emoji name ↔ Lark emoji_type mapping
  • Long messages auto-split while preserving markdown code blocks

History / lookup:

  • fetchMessages — paged listing, direction-aware (ByCreateTimeDesc / Asc)
  • fetchMessage, fetchThread, fetchChannelInfo
  • listThreads — derived client-side by grouping messages by root_id
  • Handles bot-authored history entries consistently (resolves app_id → open_id)

DM:

  • openDM returns a placeholder thread ID; routing to ou_* recipients handled transparently by the SDK's channel.send
  • isDM uses a p2p-chat cache populated from inbound events

Onboarding:

  • registerLarkApp re-exported from the SDK — scan a QR with the Lark mobile app to create the app and get credentials back

Docs:

  • Entry at /adapters/lark, Lark SVG logo, README auto-rendered as the detail page

Thread ID format: lark:{chatId}:{rootId}, where rootId is root_id ?? message_id.

Test plan

  • Unit: 82 tests across thread-id, emoji, and LarkAdapterpnpm --filter @chat-adapter/lark test
  • Typecheck / build: pnpm --filter @chat-adapter/lark typecheck / build — clean
  • Manual: exercised end-to-end against a real Lark app via 6 runnable scenarios under smokes/:
    • smoke:echo — mention / DM / subscribed-thread routing
    • smoke:stream — cardkit typewriter reply
    • smoke:edit — post → edit → delete
    • smoke:reactions — add/remove reactions + inbound reaction events
    • smoke:long — multi-chunk markdown with code blocks
    • smoke:historyfetchMessages / listThreads / fetchMessage

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 24, 2026

@mazhe-nerd is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

@mazhe-nerd mazhe-nerd force-pushed the feature/adaptor-lark branch from 802de9e to 1764dae Compare April 24, 2026 12:27
@socket-security
Copy link
Copy Markdown

socket-security Bot commented Apr 24, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatednpm/​@​streamdown/​cjk@​1.0.2 ⏵ 1.0.3681005784 -5100
Updatednpm/​@​streamdown/​code@​1.0.3 ⏵ 1.1.176 +110061 +186 -4100
Updatednpm/​discord.js@​14.25.1 ⏵ 14.26.373 +110010098100
Updatednpm/​@​types/​pg@​8.18.0 ⏵ 8.20.0100 +110073 +189100
Updatednpm/​@​ai-sdk/​react@​2.0.135 ⏵ 2.0.181981007396 -2100
Updatednpm/​dexie-react-hooks@​4.2.0 ⏵ 4.4.0100 +110075 +190 +4100
Updatednpm/​shiki@​3.22.0 ⏵ 3.23.0100 +110077 +194100
Updatednpm/​@​types/​react@​19.2.7 ⏵ 19.2.14100 +110079 +188100
Updatednpm/​vitest@​4.0.18 ⏵ 4.1.59610079 +199100
Updatednpm/​@​vitest/​coverage-v8@​4.0.18 ⏵ 4.1.59910079 +1199100
Updatednpm/​nanoid@​5.1.6 ⏵ 5.1.9100 +11008089100
Updatednpm/​@​types/​node@​25.3.2 ⏵ 25.6.01001008195100
Updatednpm/​postcss@​8.5.9 ⏵ 8.5.1099 +110082 +191100
Updatednpm/​tailwindcss@​4.1.18 ⏵ 4.2.4100 +110084 +198100
Updatednpm/​react@​19.2.3 ⏵ 19.2.51001008497100
Updatednpm/​turbo@​2.8.12 ⏵ 2.9.6100 +110085 +196 -1100
Updatednpm/​tailwind-merge@​3.4.1 ⏵ 3.5.0100 +110086 +196100
Updatednpm/​remend@​1.2.1 ⏵ 1.3.0100 +1100100 +188 -4100
Updatednpm/​zod@​4.3.3 ⏵ 4.3.6100 +1100100 +188 -7100
Updatednpm/​feed@​5.2.0 ⏵ 5.2.110010010089 +6100
Addednpm/​@​larksuiteoapi/​node-sdk@​1.62.08910010099100
Updatednpm/​ioredis@​5.8.2 ⏵ 5.10.193 +1100100 +190100
Updatednpm/​@​icons-pack/​react-simple-icons@​13.11.2 ⏵ 13.13.090 +1100100 +194 +3100
Updatednpm/​ai@​6.0.6 ⏵ 5.0.17992 -710010099100
Updatednpm/​ai@​6.0.6 ⏵ 6.0.16892 -710010099100
Updatednpm/​react-dom@​19.2.3 ⏵ 19.2.51001009298100
Updatednpm/​streamdown@​2.3.0 ⏵ 2.5.099 +110010093 -5100
Updatednpm/​jotai@​2.17.1 ⏵ 2.19.1100 +110010094100
Updatednpm/​motion@​12.34.0 ⏵ 12.38.0100 +1100100 +194 -3100
Updatednpm/​dexie@​4.3.0 ⏵ 4.4.210010010094 -1100
Updatednpm/​mermaid@​11.12.2 ⏵ 11.14.094100100 +194100
Updatednpm/​dotenv@​17.2.3 ⏵ 17.4.29910010094100
See 5 more rows in the dashboard

View full report

Comment thread packages/adapter-lark/src/index.ts Outdated
@mazhe-nerd mazhe-nerd force-pushed the feature/adaptor-lark branch from 1764dae to ed9c54f Compare April 24, 2026 12:49
@bensabic
Copy link
Copy Markdown
Contributor

Hey there! Thanks for submitting this PR. However at this time, we will have to decline it. But you are more than welcome to submit it as a community adapter.

@bensabic bensabic closed this Apr 25, 2026
@mazhe-nerd
Copy link
Copy Markdown
Author

Thanks for the review and for clarifying the path! Totally fair — I'll move the package to a standalone repo, publish to npm, and follow up with a small PR adding the Lark entry to adapters.json (similar to the Webex / Matrix / Resend community adapters).

Appreciate the time you took to look at it.

@mazhe-nerd
Copy link
Copy Markdown
Author

Reopened as #517 — rebased onto main and migrated to the new MDX adapter docs structure from #474. Couldn't
reopen this directly due to the force-push. Thanks for the earlier review!

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.

2 participants