Skip to content

feat(feishu): add webhook mode for Lark international#238

Open
Viviadx wants to merge 6 commits intoop7418:mainfrom
Viviadx:feat/lark-webhook-mode
Open

feat(feishu): add webhook mode for Lark international#238
Viviadx wants to merge 6 commits intoop7418:mainfrom
Viviadx:feat/lark-webhook-mode

Conversation

@Viviadx
Copy link

@Viviadx Viviadx commented Mar 11, 2026

Summary

Closes #237

Lark (international) does not support WebSocket long connection for event subscriptions. This PR adds an alternative webhook mode to the Feishu adapter, enabling Lark international users to use the bridge.

Changes

  • feishu-adapter.ts: Added startWebhookServer() that starts a local HTTP server on 127.0.0.1:9898. The start() method branches on bridge_feishu_mode setting (default: websocket)
  • settings/feishu/route.ts: Added 3 new setting keys (bridge_feishu_mode, bridge_feishu_webhook_port, bridge_feishu_webhook_verification_token) with masking
  • FeishuBridgeSection.tsx: Mode selector UI, webhook-specific fields (port, verification token), conditional setup guide
  • i18n: 14 new translation keys in both en.ts and zh.ts
  • tools/lark-webhook-worker/: Standalone Cloudflare Worker relay (~80 lines) that handles Lark URL verification and forwards events via Cloudflare Tunnel
  • Unit tests: 7 test cases for webhook event parsing and verification

Architecture

Lark → Lark Platform (webhook POST) → Cloudflare Worker (free) → Cloudflare Tunnel (free) → localhost:9898 → CodePilot → Claude

Design Principles

  • Zero new dependencies — uses Node.js built-in http module
  • 100% reuse — all existing message processing, auth, queue, and send logic unchanged
  • Backward compatible — default mode is websocket, existing users unaffected
  • Free — Cloudflare Workers free tier (100k req/day) + Cloudflare Tunnel (free)
  • Secure — local server listens on 127.0.0.1 only, tunnel encrypts traffic

Test plan

  • Unit tests pass (296/296, 0 failures)
  • Typecheck clean (no errors in changed files; pre-existing type issues in CodeBlock.tsx/db.ts unrelated)
  • Manual test with Lark international app
  • Verify webhook mode receives and processes messages correctly
  • Verify websocket mode still works unchanged

🤖 Generated with Claude Code

CodePilot Dev and others added 6 commits March 11, 2026 10:29
…ational support

Lark (international) does not support WebSocket long connection.
This adds an alternative 'webhook' mode that starts a local HTTP server
on 127.0.0.1 to receive events forwarded via Cloudflare Tunnel.

All existing message processing, auth, and send logic is reused unchanged.
Mode is controlled by bridge_feishu_mode setting (default: websocket).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds bridge_feishu_mode, bridge_feishu_webhook_port, and
bridge_feishu_webhook_verification_token to the settings allowlist.
Verification token is masked in GET responses like app_secret.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Standalone Worker project that handles Lark URL verification and
forwards events to CodePilot via Cloudflare Tunnel.
Free tier: 100k requests/day, zero cost.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Mar 11, 2026

Someone is attempting to deploy a commit to the op7418's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

feat: Add webhook mode for Lark international (no WebSocket support)

1 participant