Skip to content

Rust crate architecture

The Rust workspace separates WeChat transport, official-profile access, account orchestration and client adapters. Four libraries are published; the daemon, CLI and supporting runtime crates remain internal.

Package dependencies

Arrows below mean “depends on.” wechat-protocol does not depend on wechat-calls, wechat-audio or wechat-profile.

wx-native: daemon and CLI wechat-api: HTTP and WebSockets wechat-audio: local devices wechat-config: configuration wechat-core: account runtime wechat-calls: media and Opus wechat-protocol: WeChat transport wechat-profile: official profile wechat-store: operational records wechat-media: message media wechat-platform: OS primitives wechat-simulator: development fixtures

Utility dependencies are omitted. The API uses wechat-calls for internal PCM envelopes; the CLI reuses its audio format types. Client sockets carry raw PCM samples and JSON metadata, while the daemon assembles and paces audio frames.

PackageResponsibilityPublished crate?
wechat-platformOS/file primitivesYes
wechat-mediaMessage image/media inspectionYes
wechat-profileSupported official profile readers and writersYes
wechat-protocolWeChat requests, signaling and encrypted transportYes
wechat-callsPCM frames, pacing, queues and optional Opus codecNo
wechat-audioMicrophone/speaker adapter and resamplingNo
wechat-coreAccount authorization, ownership, call state and workersNo
wechat-apiHTTP routes, authenticated control/media sockets and contractsNo
wechat-storePending operations and recovery receiptsNo
wechat-configCLI/daemon configuration filesNo
wechat-simulatorSynthetic backend and development fixturesNo
wx-nativewx executable, daemon startup and CLI participationNo

Canonical chat state stays in the official profile. Operational call records do not create another history database. The four public crates remain unchanged. Reusable Rust libraries describes their standalone APIs.

Media adapters

Outgoing client PCM passes through the API, Core’s call worker, wechat-calls encoding and wechat-protocol transport. Incoming media follows the reverse path. Negotiation belongs in the worker/transport layers, not the device adapter.

DependencyWhere and why
opusic-c = 1.6.1Included in native wechat-calls builds; uses libopus for audio encoding/decoding
rubatowechat-audio resampling between device and call formats
libpulse-bindingLinux capture/playback
coreaudio-rs / coreaudio-sysmacOS capture/playback, including VoiceProcessingIO
wasapiWindows capture/playback

wechat-audio is our internal adaptation of sys-voice and the acpfx fork, with upstream licensing and source pins retained in its provenance file. Device setup does not establish measured acoustic echo-cancellation quality.

The private TypeScript HTTP/WebSocket SDK and OpenClaw extension talk to the daemon; neither needs libopus or OS audio bindings in Node. The Rust daemon still has native dependencies. A standalone JavaScript WeChat transport is not provided.

Building

Build from source covers workspace builds and platform prerequisites. Calling describes daemon, CLI and OpenClaw use; Calls API owns call payloads and events.