mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-16 13:03:31 +08:00
Add a WhatsApp adapter backed by Baileys linked-device auth, plus desktop QR binding UI, server config endpoints, sidecar startup wiring, tests, and documentation. Constraint: Uses WhatsApp Web linked-device auth, not Meta WhatsApp Business Cloud API. Tested: - cd adapters && bun run check:adapters - bun test src/server/__tests__/adapters.test.ts - cd desktop && bun run check:desktop - bun run check:native - bun run check:persistence-upgrade - bun run check:docs Not-tested: - Live WhatsApp QR pairing, because no WhatsApp account/device was exercised here. - bun run check:server, because the existing src/server/__tests__/conversations.test.ts timeout still fails independently. Confidence: medium Scope-risk: moderate
25 lines
831 B
TypeScript
25 lines
831 B
TypeScript
import { convertMarkdownTablesToBullets, splitMessage } from '../common/format.js'
|
|
|
|
const DEFAULT_THINKING_PREVIEW_LIMIT = 800
|
|
|
|
export function formatWhatsAppOutboundText(text: string): string {
|
|
return convertMarkdownTablesToBullets(text).trim()
|
|
}
|
|
|
|
export function buildWhatsAppThinkingPreview(
|
|
currentText: string,
|
|
deltaText: string,
|
|
previewLimit = DEFAULT_THINKING_PREVIEW_LIMIT,
|
|
): { fullText: string; messageText: string } {
|
|
const fullText = currentText + deltaText
|
|
const preview = fullText.slice(0, Math.max(0, previewLimit)).trimStart()
|
|
return {
|
|
fullText,
|
|
messageText: preview ? `思考中...\n${preview}` : '思考中...',
|
|
}
|
|
}
|
|
|
|
export function splitWhatsAppText(text: string, limit: number): string[] {
|
|
return splitMessage(formatWhatsAppOutboundText(text), limit).filter((chunk) => chunk.trim())
|
|
}
|