2.6 KiB
2.6 KiB
Tasks: Add Feishu (飞书) channel extension
1. Extension scaffold
- Create
extensions/feishu/workspace package (package.json,clawdbot.plugin.json,index.ts,src/). - Add plugin catalog metadata in
extensions/feishu/package.json(clawdbot.channel+clawdbot.install) so onboarding can install it.
2. Config + normalization
- Define Feishu config Zod schema (extension-local) and expose it as
configSchemaviabuildChannelConfigSchema. - Add
mode: http | wsto select HTTP callback vs long connection. - Implement target normalization (
user:<open_id>,chat:<chat_id>) and allowlist formatting. - Implement account model (start with default account; keep
accountsextensible).
3. Token manager + API client
- Implement tenant access token fetch + cache (
/auth/v3/tenant_access_token/internal). - Implement Feishu “bot info” fetch (
/bot/v3/info) for mention gating. - Implement send message (
/im/v1/messages) and reply message (/im/v1/messages/:message_id/reply).
4. Webhook handler
- Implement
handleFeishuWebhookRequest(req,res)and register viaapi.registerHttpHandler. - Support
url_verificationchallenge response (plain + encrypted). - Implement secure validation:
- Raw-body capture with size limit.
- Signature verification when
encryptKeyis configured. - Verification token checks when
encryptKeyis not configured.
- Implement decrypt for payloads with
encrypt.
5. Event processing + routing
- Handle
im.message.receive_v1(text-only V1):- DM policy + pairing store integration (mirror GoogleChat monitor behavior).
- Group policy allowlists + mention gating integration.
- Control command gating for group chats.
- Build inbound context via
runtime.channel.reply.finalizeInboundContextand dispatch replies via buffered dispatcher.
6. Outbound adapters
- Implement
outbound.sendTextforclawdbot message sendand heartbeats.
7. Status + probe
- Implement
statusadapter snapshot + summary. - Implement
probeAccountto validate credentials (token + bot info).
8. Onboarding
- Add onboarding adapter with prompts for app id/secret and delivery mode.
9. Long connection (WebSocket)
- Implement long connection transport (
mode="ws") for event subscriptions. - Acknowledge events quickly and process messages asynchronously.
10. Tests
- Add unit tests for: signature, decrypt, target normalization.
- Add unit tests for: url_verification, event parsing.
- Add unit tests for: long connection frame codec + monitor lifecycle.