This commit implements a permanent fix for the proto extraction process to handle
WhatsApp's recent changes where they mark certain fields as "required" in their
JavaScript metadata.
Changes:
1. proto-extract/index.js:
- Added automatic conversion of 'required' to 'optional' after proto generation
- Proto3 spec doesn't support 'required' keyword (only proto2 does)
- All fields in proto3 are implicitly optional by default
2. WAProto/WAProto.proto:
- Updated to WhatsApp version 2.3000.1033472679 (latest)
- All 27 'required' fields converted to 'optional'
- Now compiles successfully with protoc
3. WAProto/index.d.ts & index.js:
- Regenerated with correct proto3 syntax
- index.d.ts now has 14,572 lines (was 2 lines when broken)
- Full TypeScript definitions restored
Impact:
- ✅ Build now succeeds (was failing with proto3 required error)
- ✅ Tests: 582/583 passing (99.8%)
- ✅ Lint: 0 errors, 239 warnings
- ✅ Future proto updates will auto-fix 'required' fields
Technical details:
WhatsApp Web still uses proto3 but now marks certain fields as "required" in their
JS metadata. The extractor was copying these flags directly, causing invalid proto3
syntax. This fix ensures all 'required' keywords are converted to 'optional' after
extraction, maintaining proto3 compliance.
https://claude.ai/code/session_015R3U3kiprQiNTTNNt31Sg6
- Changed WAProto.proto from proto2 back to proto3 (aligned with Baileys upstream)
- Removed 27 invalid 'required' fields (proto3 does not support required keyword)
- Replaced all 'required' with 'optional' to maintain proto3 compatibility
- Regenerated WAProto static files (index.d.ts, index.js) with correct proto3 syntax
- Preserved WhatsApp version 2.3000.1033381705 (daily updates)
- Preserved all custom messages (AIMediaCollectionMessage, AIMediaCollectionMetadata, etc)
- All TypeScript errors resolved, build passing
https://claude.ai/code/session_015R3U3kiprQiNTTNNt31Sg6
- Changed WAProto.proto syntax from proto3 to proto2 to support required fields
- Regenerated WAProto static files (index.d.ts, index.js) with correct proto2 syntax
- Fixed type annotations in test files (circuit-breaker, sync-action-utils, trace-context)
- Fixed Mock type errors in baileys-event-stream and cache-utils tests
- Fixed LID mapping test expectations to match array type
- All 78 TypeScript errors resolved, 0 remaining
https://claude.ai/code/session_015R3U3kiprQiNTTNNt31Sg6
- Remove hasSubtitle (field 10) from Header proto definition, index.js
and index.d.ts - this field was adding extra bytes to encoded protobuf
that working implementations don't send, potentially causing rejection
- Remove hasSubtitle from carousel card headers and root header
- Add [CAROUSEL DEBUG] logging in relayMessage to dump:
- Encoded message bytes as base64 (for binary comparison)
- Message structure as JSON
- Per-device encoded bytes with DSM flag
- This enables byte-level comparison with working implementations
https://claude.ai/code/session_01EK9NpViRCtda1WAvFd8ptR
Implementação completa baseada na análise ponto-a-ponto de 5 diferenças:
1. hasSubtitle adicionado ao proto schema (field 10, bool em Header)
- Adicionado ao WAProto.proto, index.js (encode/decode/fromObject/toObject)
- Adicionado ao index.d.ts (IHeader, Header class)
- Usado no root header e em cada card do carousel
2. relayMessage direto para carousel em sendMessage
- Detecta nativeCarousel no content e bypassa generateWAMessage inteiro
- Chama generateWAMessageContent (que usa fromObject) diretamente
- Depois relayMessage sem passar por generateWAMessageFromContent
- Elimina: segundo WAProto.Message.create(), contextInfo.expiration, etc.
3. Pipeline final do carousel agora:
sendMessage → generateWAMessageContent(fromObject) → relayMessage
Sem: generateWAMessageFromContent, WAProto.Message.create, ephemeral
Commits anteriores já incluem:
- viewOnceMessage wrapper
- fromObject no generateWAMessageContent
- Skip tctoken no stanza
https://claude.ai/code/session_01EK9NpViRCtda1WAvFd8ptR
* feat: add patch-tojson functionality for improved proto serialization
* Remove patch-tojson functionality and its import from the main index file to streamline the codebase.
* refactor: simplify longToString and longToNumber functions for better readability and performance