Native bridge
src/native/AIEngine.ts is the typed TypeScript facade around Android native AI modules. It normalizes platform calls for the React Native app and provides development fallbacks when native code is unavailable.
Responsibilities
| Category | Purpose |
|---|---|
| Generation | Send text generation requests and normalize native responses. |
| Multimodal routing | Route typed text, file, image, and attachment requests to compatible runtimes. |
| Indexing | Start or inspect device-side indexing and retrieval state. |
| Status | Read startup, model, runtime, and background work status. |
| Lifecycle | Download, load, unload, and cancel model operations. |
Call flow
Screen or component → AIEngine TypeScript facade → NativeModules.AIEngine → Android bridge method → runtime / router / database / worker → normalized Promise result
Development fallback
The browser preview does not have access to mobile native modules. The facade must return predictable development responses so the interface can be exercised without pretending native inference occurred.
Contract design
- Keep request and response types explicit.
- Represent cancellation and lifecycle state as first-class behavior.
- Return errors that identify setup, asset, compatibility, or runtime failures.
- Keep platform-specific details behind the facade unless the UI genuinely needs them.
- Update documentation and tests whenever the public contract changes.
Stability
Streaming and richer runtime APIs are represented in the project but are not yet treated as a stable public SDK. Contributors should preserve compatibility within a focused change and document any migration.
The SwiftUI iOS app does not depend on this React Native bridge. It uses native Swift clients that should preserve equivalent product semantics where practical.
Open GitHub