@rhq/rover 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +384 -2
- package/Rover.podspec +32 -0
- package/android/CMakeLists.txt +32 -0
- package/android/build.gradle +77 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/cpp/rover-jni.cpp +15 -0
- package/android/src/main/java/com/relayhq/rover/RoverJsiModule.kt +16 -0
- package/android/src/main/java/com/relayhq/rover/RoverModule.kt +56 -0
- package/android/src/main/java/com/relayhq/rover/RoverNativeBridge.kt +45 -0
- package/android/src/main/java/com/relayhq/rover/RoverNativeModule.kt +73 -0
- package/android/src/main/java/com/relayhq/rover/RoverPackage.kt +16 -0
- package/android/src/main/java/uniffi/relay_rover/relay_rover.kt +1089 -0
- package/android/src/main/jniLibs/arm64-v8a/librelay_rover.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/librelay_rover.so +0 -0
- package/android/src/main/jniLibs/x86_64/librelay_rover.so +0 -0
- package/cpp/RoverJsi.cpp +156 -0
- package/cpp/RoverJsi.h +20 -0
- package/eng/relay_rover.wasm +0 -0
- package/expo-module.config.json +10 -0
- package/index.d.ts +204 -0
- package/index.js +425 -0
- package/index.native.js +476 -0
- package/ios/Rover-Bridging-Header.h +1 -0
- package/ios/RoverBridge.mm +117 -0
- package/ios/RoverModule.swift +54 -0
- package/ios/relay_rover.swift +623 -0
- package/ios/relay_roverFFI.h +589 -0
- package/ios/relay_roverFFI.modulemap +7 -0
- package/package.json +48 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 RelayHQ
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,385 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @rhq/rover (Relay Rover)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> **High-Performance WebAssembly Email Intelligence Engine for Real-World Email Clients, React Native, and Relay Mail.**
|
|
4
|
+
> *Zero LLMs. Zero cloud API calls. 100% on-device deterministic understanding.*
|
|
5
|
+
|
|
6
|
+
[](https://www.npmjs.com/package/@rhq/rover)
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
[](https://webassembly.org/)
|
|
9
|
+
[](#performance-benchmarks)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## The Problem: Emails Are More Than Messages
|
|
14
|
+
|
|
15
|
+
Traditional email clients treat every message the same: they show sender, subject, and an excerpt of raw text or messy HTML, forcing the user to manually open the email to hunt for verification codes, tracking numbers, flight gates, or payment receipts.
|
|
16
|
+
|
|
17
|
+
> *"Gmail gives Relay the emails. Rover gives Relay an understanding of those emails."*
|
|
18
|
+
> — [*Meet Rover: The Intelligence Behind Relay Mail*](https://blogs.relaymail.online/blog/rover)
|
|
19
|
+
|
|
20
|
+
`@rhq/rover` is the production email intelligence engine behind **Relay Mail**. Written in Rust and compiled directly to WebAssembly (`eng/relay_rover.wasm`), Rover runs client-side inside the user's application with microsecond latency, zero operational costs, and total data privacy.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Key Capabilities
|
|
25
|
+
|
|
26
|
+
- **Dual-Layer Classification:**
|
|
27
|
+
- **Folder Layer (General):** `Primary`, `Updates`, `Social`, `Promotions`, `Forums`.
|
|
28
|
+
- **Action Layer (Purpose):** `Authentication` (OTP), `Transactions` (Payment/Invoice), `Deliveries` (Shopping), `Jobs`, `SecurityAlerts`, `Travel`, `Subscriptions`, `Newsletters`.
|
|
29
|
+
- **Urgency & Alert Engine:** Automatically flags critical emails with `is_alert: true` and urgency tiers (`Urgent`, `High`, `Normal`, `Low`) for real-time notification banners and inbox badges.
|
|
30
|
+
- **Deep Deterministic Extraction:**
|
|
31
|
+
- **OTPs:** Extract code, service, expiration timeframe, and auth purpose (e.g. `0313`, `Nintendo`, `24 hours`).
|
|
32
|
+
- **Orders & Deliveries:** Extract order ID, merchant, product, amount, tax/GST, order date, and delivery status.
|
|
33
|
+
- **Payments & Receipts:** Extract amount, currency, payer, recipient, transaction ID, date, time, and payment method.
|
|
34
|
+
- **Job Vacancies & Alerts:** Extract company, position, location, job vacancy count, and application URLs.
|
|
35
|
+
- **Social & Alerts:** Extract actor, interaction type, target post URL, or CI/CD build failure details.
|
|
36
|
+
- **Semantic Contextual Previews:** Generates clean, informative preview lines (< 100 characters) tailored to the category (e.g., `₹29.00 · Special Airdrop 412 (Google Play)` or `Job Alert · 8 React Native Developer jobs at Webomindapps`).
|
|
37
|
+
- **The Rover Intelligence Index:** Computes `timeline_key` identifiers to automatically group related emails (Order Confirmation $\rightarrow$ Payment Receipt $\rightarrow$ Shipment $\rightarrow$ Delivery) into connected purchase and activity timelines.
|
|
38
|
+
- **HTML Sanitization & Normalization:** Built-in fast HTML-to-text parser that strips `<style>`, scripts, and tracking markup without third-party dependencies.
|
|
39
|
+
- **Blistering Throughput:** Processes over **4,900 emails/second** in WebAssembly and **9,200 emails/second** natively.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Installation
|
|
44
|
+
|
|
45
|
+
### React Native & Expo
|
|
46
|
+
```bash
|
|
47
|
+
# In an Expo project
|
|
48
|
+
npx expo install @rhq/rover
|
|
49
|
+
|
|
50
|
+
# In a React Native project
|
|
51
|
+
npm install @rhq/rover
|
|
52
|
+
# on iOS, install CocoaPods:
|
|
53
|
+
npx pod-install
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Web & Node.js
|
|
57
|
+
```bash
|
|
58
|
+
npm install @rhq/rover
|
|
59
|
+
# or with pnpm
|
|
60
|
+
pnpm add @rhq/rover
|
|
61
|
+
# or with yarn
|
|
62
|
+
yarn add @rhq/rover
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## ⚡ React Native & Hermes Architecture
|
|
68
|
+
|
|
69
|
+
Rover includes dedicated first-class React Native support:
|
|
70
|
+
- **Zero Node Built-in Dependencies**: No `fs`, `path`, or `url` imports in the React Native execution path.
|
|
71
|
+
- **Hermes Native Performance**: Functions execute via compiled C++ JSI host objects and UniFFI native bindings, completely bypassing legacy React Native JSON bridge overhead.
|
|
72
|
+
- **Off-Thread Background Processing**: Execute heavy batch email syncs off the UI thread via `processAsync` and `processBatchAsync` without dropping a single frame (120fps smooth animations).
|
|
73
|
+
- **Zero Breaking API Changes**: Existing code runs without changes. The same exports, function signatures, and return objects work seamlessly on Web, Node, iOS, and Android.
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Integrating Into an Email Client Application
|
|
78
|
+
|
|
79
|
+
### 1. Ingesting Real-World Raw Emails (IMAP, Gmail API, JMAP)
|
|
80
|
+
|
|
81
|
+
In a production email application, incoming emails contain messy HTML, multi-part bodies, and complex header structures. Rover accepts raw email objects, normalizes headers, sanitizes HTML, and extracts intelligence in one call:
|
|
82
|
+
|
|
83
|
+
```javascript
|
|
84
|
+
import { RelayRover } from '@rhq/rover';
|
|
85
|
+
|
|
86
|
+
// Example raw email payload from Gmail API / IMAP / backend sync
|
|
87
|
+
const rawEmail = {
|
|
88
|
+
id: "msg_18b5ef21a4",
|
|
89
|
+
from: "Google Play <googleplay-noreply@google.com>",
|
|
90
|
+
subject: "Your Google Play Order Receipt from 27 Oct 2026",
|
|
91
|
+
date: "2026-10-27T12:29:12+05:30",
|
|
92
|
+
htmlBody: `
|
|
93
|
+
<div>
|
|
94
|
+
<style>.btn { color: red; }</style>
|
|
95
|
+
<h1>Order number: GPA.3399-0949-2150-45472</h1>
|
|
96
|
+
<p>Special Airdrop 412 (Free Fire MAX x NARUTO) ₹29.00</p>
|
|
97
|
+
<p>Total: ₹29.00 (Includes GST of ₹4.42)</p>
|
|
98
|
+
<p>Payment method: Google Play balance</p>
|
|
99
|
+
</div>
|
|
100
|
+
`
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// Process email with Rover
|
|
104
|
+
const processed = RelayRover.process(rawEmail);
|
|
105
|
+
|
|
106
|
+
console.log(processed.primary_category);
|
|
107
|
+
// "shopping"
|
|
108
|
+
|
|
109
|
+
console.log(processed.preview);
|
|
110
|
+
// "₹29.00 · Special Airdrop 412 (Google Play)"
|
|
111
|
+
|
|
112
|
+
console.log(processed.classification);
|
|
113
|
+
// {
|
|
114
|
+
// general_category: "updates",
|
|
115
|
+
// purpose: "shopping",
|
|
116
|
+
// importance: "normal",
|
|
117
|
+
// is_alert: false,
|
|
118
|
+
// security: "none",
|
|
119
|
+
// confidence: 0.95
|
|
120
|
+
// }
|
|
121
|
+
|
|
122
|
+
console.log(processed.extraction.data);
|
|
123
|
+
// {
|
|
124
|
+
// store: "Google Play",
|
|
125
|
+
// order_id: "GPA.3399-0949-2150-45472",
|
|
126
|
+
// product: "Special Airdrop 412",
|
|
127
|
+
// amount: "29.00",
|
|
128
|
+
// currency: "INR",
|
|
129
|
+
// tax: "4.42",
|
|
130
|
+
// order_date: "27 Oct 2026",
|
|
131
|
+
// payment_method: "Google Play balance",
|
|
132
|
+
// timeline_key: "order:GPA.3399-0949-2150-45472"
|
|
133
|
+
// }
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
### 2. High-Speed Batch Ingestion (Initial Sync & Background Fetch)
|
|
139
|
+
|
|
140
|
+
When your app syncs an inbox folder or executes a background fetch, pass the array of emails to `processBatch()`. The entire batch is processed in WebAssembly memory in a single invocation without round-trips:
|
|
141
|
+
|
|
142
|
+
```javascript
|
|
143
|
+
import { RelayRover } from '@rhq/rover';
|
|
144
|
+
|
|
145
|
+
// Syncing 100+ emails from the local SQLite store or IMAP cache
|
|
146
|
+
async function onInboxSync(incomingMessages) {
|
|
147
|
+
const startTime = performance.now();
|
|
148
|
+
|
|
149
|
+
// Process 100 emails in ~20 ms (~4,900 emails/sec)
|
|
150
|
+
const results = RelayRover.processBatch(incomingMessages);
|
|
151
|
+
|
|
152
|
+
const duration = (performance.now() - startTime).toFixed(1);
|
|
153
|
+
console.log(`Classified & extracted ${results.length} emails in ${duration} ms`);
|
|
154
|
+
|
|
155
|
+
// Persist structured metadata into your SQLite or Realm database
|
|
156
|
+
for (const item of results) {
|
|
157
|
+
await db.emails.update(item.id, {
|
|
158
|
+
category: item.primary_category,
|
|
159
|
+
folder: item.classification.general_category,
|
|
160
|
+
previewText: item.preview,
|
|
161
|
+
importance: item.classification.importance,
|
|
162
|
+
isAlert: item.classification.is_alert,
|
|
163
|
+
timelineKey: item.timeline_key,
|
|
164
|
+
extractedData: JSON.stringify(item.extraction.data),
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
### 3. Rendering Actionable Inbox Cards & Action Banners
|
|
173
|
+
|
|
174
|
+
Rover provides structured fields that allow your UI to render rich, actionable elements directly in the inbox feed without opening the email:
|
|
175
|
+
|
|
176
|
+
#### A. One-Tap OTP Copy Banner
|
|
177
|
+
```tsx
|
|
178
|
+
import React from 'react';
|
|
179
|
+
import { View, Text, TouchableOpacity, Clipboard } from 'react-native';
|
|
180
|
+
|
|
181
|
+
export function OtpActionBanner({ processedEmail }) {
|
|
182
|
+
if (processedEmail.primary_category !== 'otp') return null;
|
|
183
|
+
|
|
184
|
+
const { otp_code, service_name, expiration_time } = processedEmail.extraction.data;
|
|
185
|
+
if (!otp_code) return null;
|
|
186
|
+
|
|
187
|
+
return (
|
|
188
|
+
<View style={{ backgroundColor: '#EEF2FF', padding: 12, borderRadius: 8, flexDirection: 'row', alignItems: 'center' }}>
|
|
189
|
+
<View style={{ flex: 1 }}>
|
|
190
|
+
<Text style={{ fontWeight: 'bold', color: '#1E40AF' }}>
|
|
191
|
+
{service_name || 'Authentication'} Verification Code
|
|
192
|
+
</Text>
|
|
193
|
+
<Text style={{ fontSize: 24, letterSpacing: 4, fontWeight: '700', color: '#1E1B4B' }}>
|
|
194
|
+
{otp_code}
|
|
195
|
+
</Text>
|
|
196
|
+
{expiration_time && (
|
|
197
|
+
<Text style={{ fontSize: 12, color: '#6B7280' }}>Expires in {expiration_time}</Text>
|
|
198
|
+
)}
|
|
199
|
+
</View>
|
|
200
|
+
<TouchableOpacity
|
|
201
|
+
onPress={() => Clipboard.setString(otp_code)}
|
|
202
|
+
style={{ backgroundColor: '#3B82F6', paddingHorizontal: 16, paddingVertical: 8, borderRadius: 6 }}
|
|
203
|
+
>
|
|
204
|
+
<Text style={{ color: '#fff', fontWeight: '600' }}>Copy</Text>
|
|
205
|
+
</TouchableOpacity>
|
|
206
|
+
</View>
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
#### B. Delivery Tracking Card
|
|
212
|
+
```tsx
|
|
213
|
+
export function DeliveryCard({ processedEmail }) {
|
|
214
|
+
if (processedEmail.primary_category !== 'shopping') return null;
|
|
215
|
+
const { store, product, tracking_number, delivery_status } = processedEmail.extraction.data;
|
|
216
|
+
|
|
217
|
+
return (
|
|
218
|
+
<View style={{ padding: 12, borderWidth: 1, borderColor: '#E5E7EB', borderRadius: 8 }}>
|
|
219
|
+
<Text style={{ fontSize: 14, color: '#4B5563' }}>{store} · {delivery_status}</Text>
|
|
220
|
+
<Text style={{ fontSize: 16, fontWeight: 'bold' }}>{product}</Text>
|
|
221
|
+
{tracking_number && (
|
|
222
|
+
<TouchableOpacity onPress={() => openTracking(tracking_number)}>
|
|
223
|
+
<Text style={{ color: '#2563EB', marginTop: 4 }}>Track Package: {tracking_number}</Text>
|
|
224
|
+
</TouchableOpacity>
|
|
225
|
+
)}
|
|
226
|
+
</View>
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
### 4. Connecting Fragmented Emails with the Rover Intelligence Index
|
|
234
|
+
|
|
235
|
+
Purchases, trips, and projects often scatter multiple emails over days or weeks:
|
|
236
|
+
1. *Order Confirmation*
|
|
237
|
+
2. *Payment Receipt*
|
|
238
|
+
3. *Shipping Update*
|
|
239
|
+
4. *Delivered Notification*
|
|
240
|
+
|
|
241
|
+
Rover provides `RoverIndex` to automatically connect these related communications into unified activity timelines:
|
|
242
|
+
|
|
243
|
+
```javascript
|
|
244
|
+
import { RelayRover, RoverIndex } from '@rhq/rover';
|
|
245
|
+
|
|
246
|
+
// Array of all emails in the inbox
|
|
247
|
+
const processedEmails = RelayRover.processBatch(inboxEmails);
|
|
248
|
+
|
|
249
|
+
// Group related emails by timeline key
|
|
250
|
+
const { timelines, unlinked } = RoverIndex.buildTimelines(processedEmails);
|
|
251
|
+
|
|
252
|
+
// Inspect continuous order timeline:
|
|
253
|
+
console.log(timelines["order:GPA.3399-0949-2150-45472"]);
|
|
254
|
+
/*
|
|
255
|
+
{
|
|
256
|
+
timelineKey: "order:GPA.3399-0949-2150-45472",
|
|
257
|
+
primaryCategory: "shopping",
|
|
258
|
+
events: [
|
|
259
|
+
{ preview: "Order Confirmed · Special Airdrop 412", date: "2026-10-27" },
|
|
260
|
+
{ preview: "₹29.00 · Google Play receipt", date: "2026-10-27" },
|
|
261
|
+
{ preview: "In Transit · Special Airdrop 412", date: "2026-10-28" }
|
|
262
|
+
]
|
|
263
|
+
}
|
|
264
|
+
*/
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
### 5. Multi-Folder Inbox Navigation
|
|
270
|
+
|
|
271
|
+
Use the dual-layer classification to power your email client's primary navigation tabs and sub-category filters:
|
|
272
|
+
|
|
273
|
+
```typescript
|
|
274
|
+
// Filter emails for the "Primary" or "Updates" folder tab
|
|
275
|
+
const primaryInbox = allEmails.filter(
|
|
276
|
+
email => email.classification.general_category === 'primary'
|
|
277
|
+
);
|
|
278
|
+
|
|
279
|
+
const updatesTab = allEmails.filter(
|
|
280
|
+
email => email.classification.general_category === 'updates'
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
// Filter by actionable purpose chip in your search bar
|
|
284
|
+
const allOrders = allEmails.filter(
|
|
285
|
+
email => email.primary_category === 'shopping'
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
const pendingJobs = allEmails.filter(
|
|
289
|
+
email => email.primary_category === 'job'
|
|
290
|
+
);
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
## Complete API Reference
|
|
296
|
+
|
|
297
|
+
### `RelayRover.process(email: EmailRecordInput | string): ProcessedEmail`
|
|
298
|
+
Processes an email object or text string. Automatically handles HTML sanitization, header normalization, category detection, typed entity extraction, and contextual preview generation.
|
|
299
|
+
|
|
300
|
+
### `RelayRover.processBatch(emails: EmailRecordInput[] | string): ProcessedEmail[]`
|
|
301
|
+
Processes an array of emails in a single linear WebAssembly memory call. Designed for initial inbox loads and background sync workers.
|
|
302
|
+
|
|
303
|
+
### `RelayRover.classify(subject: string, body: string): string`
|
|
304
|
+
Ultra-fast sub-millisecond purpose category classification without full extraction.
|
|
305
|
+
|
|
306
|
+
### `RelayRover.generatePreview(subject: string, body: string): string`
|
|
307
|
+
Generates a concise contextual summary line (< 100 characters) for push notifications or inbox row subtitles.
|
|
308
|
+
|
|
309
|
+
### `RoverIndex.buildTimelines(processedEmails: ProcessedEmail[]): TimelineBuildResult`
|
|
310
|
+
Groups an array of processed emails into connected timelines (`timelines`) and standalone emails (`unlinked`) using deterministic timeline keys (`order:*`, `payment:*`, `travel:*`, `invoice:*`).
|
|
311
|
+
|
|
312
|
+
### `cleanEmailBody(email: EmailRecordInput | string): string`
|
|
313
|
+
Extracts readable plain-text, strips script and style blocks, unescapes entities, and preserves line breaks.
|
|
314
|
+
|
|
315
|
+
### `htmlToText(html: string): string`
|
|
316
|
+
Fast WASM-powered HTML-to-plain-text sanitizer.
|
|
317
|
+
|
|
318
|
+
### `normalizeEmail(email: EmailRecordInput): NormalizedEmail`
|
|
319
|
+
Standardizes various header formats (`from`, `sender`, `sender_name`, `date`, `received_at`) into a uniform record.
|
|
320
|
+
|
|
321
|
+
---
|
|
322
|
+
|
|
323
|
+
## TypeScript Typings & Extraction Schemas
|
|
324
|
+
|
|
325
|
+
All types are exported from `@rhq/rover`:
|
|
326
|
+
|
|
327
|
+
```typescript
|
|
328
|
+
import type {
|
|
329
|
+
ProcessedEmail,
|
|
330
|
+
EmailClassification,
|
|
331
|
+
GeneralCategory,
|
|
332
|
+
Importance,
|
|
333
|
+
SecurityClassification,
|
|
334
|
+
PaymentExtraction,
|
|
335
|
+
OtpExtraction,
|
|
336
|
+
JobExtraction,
|
|
337
|
+
ShoppingExtraction,
|
|
338
|
+
SocialExtraction
|
|
339
|
+
} from '@rhq/rover';
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
### Extraction Types Summary
|
|
343
|
+
|
|
344
|
+
- **`OtpExtraction`**: `otp_code`, `service_name`, `expiration_time`, `auth_purpose`, `action_url`
|
|
345
|
+
- **`ShoppingExtraction`**: `store`, `order_id`, `product`, `amount`, `currency`, `tax`, `order_date`, `delivery_status`, `tracking_number`, `courier`, `payment_method`, `timeline_key`
|
|
346
|
+
- **`PaymentExtraction`**: `amount`, `currency`, `payer`, `recipient`, `transaction_id`, `transaction_date`, `transaction_time`, `payment_method`, `transaction_status`, `timeline_key`
|
|
347
|
+
- **`JobExtraction`**: `company`, `position`, `location`, `salary`, `job_count`, `is_job_alert`, `job_url`, `application_deadline`, `interview_date`
|
|
348
|
+
- **`SocialExtraction`**: `platform`, `activity_type`, `relevant_entity`, `actor`, `post_url`
|
|
349
|
+
- **`SecurityAlertExtraction`**: `alert_type`, `target_resource`, `severity`, `action_required`, `timeline_key`
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
## Performance & Architecture Comparison
|
|
354
|
+
|
|
355
|
+
| Metric / Feature | Relay Rover (`@rhq/rover`) | Cloud LLM (e.g. GPT-4o / Claude) |
|
|
356
|
+
|---|---|---|
|
|
357
|
+
| **Latency per Email** | **~200 µs** (0.2 ms) | **1,200 ms – 3,500 ms** |
|
|
358
|
+
| **Throughput** | **4,900+ emails/sec** | 2 – 10 emails/sec (rate limited) |
|
|
359
|
+
| **Cost per 100,000 Emails** | **$0.00 (Free, runs on-device)** | **$1,500 – $3,000+** in tokens |
|
|
360
|
+
| **Network Dependency** | **100% Offline Capable** | Requires active internet & API keys |
|
|
361
|
+
| **Privacy & Compliance** | **Zero Data Leaves Device** | Full user email sent to cloud |
|
|
362
|
+
| **Determinism** | **100% Consistent (Zero Hallucination)** | Variable responses, model drift |
|
|
363
|
+
|
|
364
|
+
---
|
|
365
|
+
|
|
366
|
+
## Compiling & Updating the Engine
|
|
367
|
+
|
|
368
|
+
To rebuild the WebAssembly binary from Rust source:
|
|
369
|
+
|
|
370
|
+
```bash
|
|
371
|
+
# 1. Compile optimized release target
|
|
372
|
+
cargo build --target wasm32-unknown-unknown --release
|
|
373
|
+
|
|
374
|
+
# 2. Copy compiled binary into package eng/ directory
|
|
375
|
+
cp target/wasm32-unknown-unknown/release/relay_rover.wasm packages/rover/eng/relay_rover.wasm
|
|
376
|
+
|
|
377
|
+
# 3. Run validation tests
|
|
378
|
+
node test_rover.js
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
---
|
|
382
|
+
|
|
383
|
+
## License
|
|
384
|
+
|
|
385
|
+
MIT © [Relay](https://blogs.relaymail.online)
|
package/Rover.podspec
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "Rover"
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.homepage = "https://blogs.relaymail.online/blog/rover"
|
|
10
|
+
s.license = package['license']
|
|
11
|
+
s.authors = package['author']
|
|
12
|
+
s.platforms = { :ios => "13.4" }
|
|
13
|
+
s.source = { :git => "https://github.com/RelayHQX/rover.git", :tag => "v#{s.version}" }
|
|
14
|
+
|
|
15
|
+
s.source_files = "ios/**/*.{h,m,mm,swift}", "cpp/**/*.{h,cpp}"
|
|
16
|
+
s.public_header_files = "ios/**/*.h", "cpp/**/*.h"
|
|
17
|
+
|
|
18
|
+
s.pod_target_xcconfig = {
|
|
19
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
|
|
20
|
+
"SWIFT_INCLUDE_PATHS" => "$(PODS_TARGET_SRCROOT)/ios",
|
|
21
|
+
"OTHER_SWIFT_FLAGS" => "-import-objc-header $(PODS_TARGET_SRCROOT)/ios/Rover-Bridging-Header.h"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
s.dependency "React-Core"
|
|
25
|
+
s.dependency "React-callinvoker"
|
|
26
|
+
|
|
27
|
+
if defined?(install_modules_dependencies)
|
|
28
|
+
install_modules_dependencies(s)
|
|
29
|
+
else
|
|
30
|
+
s.dependency "ExpoModulesCore" rescue nil
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.18.1)
|
|
2
|
+
project(roverjsi)
|
|
3
|
+
|
|
4
|
+
set(CMAKE_CXX_STANDARD 17)
|
|
5
|
+
|
|
6
|
+
include_directories(
|
|
7
|
+
${CMAKE_CURRENT_SOURCE_DIR}/../cpp
|
|
8
|
+
${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
# Location of prebuilt librelay_rover.so compiled by cargo
|
|
12
|
+
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/librelay_rover.so")
|
|
13
|
+
add_library(relay_rover SHARED IMPORTED)
|
|
14
|
+
set_target_properties(relay_rover PROPERTIES
|
|
15
|
+
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/librelay_rover.so"
|
|
16
|
+
)
|
|
17
|
+
endif()
|
|
18
|
+
|
|
19
|
+
add_library(roverjsi SHARED
|
|
20
|
+
${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp/rover-jni.cpp
|
|
21
|
+
${CMAKE_CURRENT_SOURCE_DIR}/../cpp/RoverJsi.cpp
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
find_library(LOG_LIB log)
|
|
25
|
+
find_library(ANDROID_LIB android)
|
|
26
|
+
|
|
27
|
+
target_link_libraries(roverjsi
|
|
28
|
+
PRIVATE
|
|
29
|
+
relay_rover
|
|
30
|
+
${LOG_LIB}
|
|
31
|
+
${ANDROID_LIB}
|
|
32
|
+
)
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
apply plugin: 'com.android.library'
|
|
2
|
+
apply plugin: 'kotlin-android'
|
|
3
|
+
|
|
4
|
+
group = 'com.relayhq.rover'
|
|
5
|
+
version = '0.1.0'
|
|
6
|
+
|
|
7
|
+
buildscript {
|
|
8
|
+
repositories {
|
|
9
|
+
google()
|
|
10
|
+
mavenCentral()
|
|
11
|
+
}
|
|
12
|
+
dependencies {
|
|
13
|
+
classpath 'com.android.tools.build:gradle:8.2.1'
|
|
14
|
+
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.22'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
android {
|
|
19
|
+
compileSdkVersion 34
|
|
20
|
+
namespace "com.relayhq.rover"
|
|
21
|
+
|
|
22
|
+
defaultConfig {
|
|
23
|
+
minSdkVersion 21
|
|
24
|
+
targetSdkVersion 34
|
|
25
|
+
versionCode 1
|
|
26
|
+
versionName "0.1.0"
|
|
27
|
+
|
|
28
|
+
ndk {
|
|
29
|
+
abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86_64', 'x86'
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
externalNativeBuild {
|
|
33
|
+
cmake {
|
|
34
|
+
cppFlags "-std=c++17 -O3"
|
|
35
|
+
arguments "-DANDROID_STL=c++_shared"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
externalNativeBuild {
|
|
41
|
+
cmake {
|
|
42
|
+
path "CMakeLists.txt"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
sourceSets {
|
|
47
|
+
main {
|
|
48
|
+
jniLibs.srcDirs = ['src/main/jniLibs']
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
lintOptions {
|
|
53
|
+
abortOnError false
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
repositories {
|
|
58
|
+
google()
|
|
59
|
+
mavenCentral()
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
dependencies {
|
|
63
|
+
// Kotlin & Coroutines
|
|
64
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.9.22"
|
|
65
|
+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3"
|
|
66
|
+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3"
|
|
67
|
+
|
|
68
|
+
// JNA for UniFFI bindings
|
|
69
|
+
implementation "net.java.dev.jna:jna:5.14.0@aar"
|
|
70
|
+
|
|
71
|
+
// Optional Expo Modules Core dependency
|
|
72
|
+
compileOnly "host.exp:expo:+"
|
|
73
|
+
compileOnly project(':expo-modules-core')
|
|
74
|
+
|
|
75
|
+
// Optional React Native dependency
|
|
76
|
+
compileOnly "com.facebook.react:react-android:+"
|
|
77
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#include <jni.h>
|
|
2
|
+
#include <jsi/jsi.h>
|
|
3
|
+
#include "RoverJsi.h"
|
|
4
|
+
|
|
5
|
+
extern "C" JNIEXPORT void JNICALL
|
|
6
|
+
Java_com_relayhq_rover_RoverJsiModule_nativeInstall(
|
|
7
|
+
JNIEnv* env,
|
|
8
|
+
jobject /* this */,
|
|
9
|
+
jlong jsiRuntimePointer
|
|
10
|
+
) {
|
|
11
|
+
if (jsiRuntimePointer != 0) {
|
|
12
|
+
auto* runtime = reinterpret_cast<facebook::jsi::Runtime*>(jsiRuntimePointer);
|
|
13
|
+
relay_rover::RoverHostObject::install(*runtime);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
package com.relayhq.rover
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* JNI wrapper to install the RoverHostObject directly into the Hermes / React Native JSI runtime.
|
|
5
|
+
*/
|
|
6
|
+
object RoverJsiModule {
|
|
7
|
+
init {
|
|
8
|
+
try {
|
|
9
|
+
System.loadLibrary("roverjsi")
|
|
10
|
+
} catch (_: UnsatisfiedLinkError) {
|
|
11
|
+
// Handled when embedded directly
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
external fun nativeInstall(jsiRuntimePointer: Long)
|
|
16
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
package com.relayhq.rover
|
|
2
|
+
|
|
3
|
+
import expo.modules.kotlin.modules.Module
|
|
4
|
+
import expo.modules.kotlin.modules.ModuleDefinition
|
|
5
|
+
import kotlinx.coroutines.Dispatchers
|
|
6
|
+
import kotlinx.coroutines.withContext
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Expo Module implementation for Relay Rover on Android.
|
|
10
|
+
* Integrates Rust core through UniFFI bindings and exposes high-performance JSI methods.
|
|
11
|
+
*/
|
|
12
|
+
class RoverModule : Module() {
|
|
13
|
+
override fun definition() = ModuleDefinition {
|
|
14
|
+
Name("RelayRover")
|
|
15
|
+
|
|
16
|
+
Function("classify") { subject: String, body: String ->
|
|
17
|
+
RoverNativeBridge.classify(subject, body)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
Function("generatePreview") { subject: String, body: String ->
|
|
21
|
+
RoverNativeBridge.generatePreview(subject, body)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
Function("processEmail") { subject: String, body: String ->
|
|
25
|
+
RoverNativeBridge.processEmail(subject, body)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
Function("processEmailJson") { emailJson: String ->
|
|
29
|
+
RoverNativeBridge.processEmailJson(emailJson)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
Function("processBatchJson") { batchJson: String ->
|
|
33
|
+
RoverNativeBridge.processBatchJson(batchJson)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
Function("htmlToText") { html: String ->
|
|
37
|
+
RoverNativeBridge.htmlToText(html)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
Function("cleanEmailBody") { bodyOrHtml: String ->
|
|
41
|
+
RoverNativeBridge.cleanEmailBody(bodyOrHtml)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
AsyncFunction("processEmailAsync") { emailJson: String ->
|
|
45
|
+
withContext(Dispatchers.Default) {
|
|
46
|
+
RoverNativeBridge.processEmailJson(emailJson)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
AsyncFunction("processBatchAsync") { batchJson: String ->
|
|
51
|
+
withContext(Dispatchers.Default) {
|
|
52
|
+
RoverNativeBridge.processBatchJson(batchJson)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|