@rtrvr-ai/rover 0.1.0 → 1.0.0

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/README.md ADDED
@@ -0,0 +1,221 @@
1
+ # @rtrvr-ai/rover
2
+
3
+ Rover is a DOM-native embedded web agent that lives inside your website. Unlike traditional chat widgets that run in iframes, Rover reads the actual DOM and executes actions directly in the user's browser — enabling real task completion, not just conversation.
4
+
5
+ ## Prerequisites
6
+
7
+ You need an rtrvr.ai account with available credits. Free accounts get 250 credits/month. [Sign up or manage your plan](https://rtrvr.ai/cloud).
8
+
9
+ ## Quick Start (Script Tag)
10
+
11
+ Add this snippet before `</body>` on any page:
12
+
13
+ ```html
14
+ <script>
15
+ (function(){
16
+ var r = window.rover = window.rover || function(){
17
+ (r.q = r.q || []).push(arguments);
18
+ };
19
+ r.l = +new Date();
20
+ })();
21
+
22
+ rover('boot', {
23
+ siteId: 'YOUR_SITE_ID',
24
+ apiKey: 'YOUR_API_KEY',
25
+ allowedDomains: ['yourdomain.com'],
26
+ });
27
+ </script>
28
+ <script src="https://rover.rtrvr.ai/embed.js" async></script>
29
+ ```
30
+
31
+ Or use the single-tag shorthand with data attributes:
32
+
33
+ ```html
34
+ <script src="https://rover.rtrvr.ai/embed.js"
35
+ data-site-id="YOUR_SITE_ID"
36
+ data-api-key="YOUR_API_KEY"
37
+ data-allowed-domains="yourdomain.com">
38
+ </script>
39
+ ```
40
+
41
+ ## npm Install
42
+
43
+ ```bash
44
+ npm install @rtrvr-ai/rover
45
+ ```
46
+
47
+ ```typescript
48
+ import { boot, shutdown } from '@rtrvr-ai/rover';
49
+
50
+ boot({
51
+ siteId: 'YOUR_SITE_ID',
52
+ apiKey: 'YOUR_API_KEY',
53
+ allowedDomains: ['yourdomain.com'],
54
+ });
55
+ ```
56
+
57
+ ### React / Next.js
58
+
59
+ ```tsx
60
+ import { useEffect } from 'react';
61
+ import { boot, shutdown } from '@rtrvr-ai/rover';
62
+
63
+ export function RoverWidget() {
64
+ useEffect(() => {
65
+ boot({
66
+ siteId: 'YOUR_SITE_ID',
67
+ apiKey: 'YOUR_API_KEY',
68
+ allowedDomains: ['yourdomain.com'],
69
+ });
70
+
71
+ return () => {
72
+ shutdown();
73
+ };
74
+ }, []);
75
+
76
+ return null;
77
+ }
78
+ ```
79
+
80
+ For Next.js with SSR, use a dynamic import:
81
+
82
+ ```tsx
83
+ import dynamic from 'next/dynamic';
84
+
85
+ const RoverWidget = dynamic(() => import('./RoverWidget'), { ssr: false });
86
+ ```
87
+
88
+ ## Script Tag vs npm
89
+
90
+ | Feature | Script Tag | npm Package |
91
+ |---|---|---|
92
+ | TypeScript types | No | Yes |
93
+ | Version pinning | CDN serves latest | Locked in package.json |
94
+ | SPA lifecycle | Manual | Framework hooks (useEffect, etc.) |
95
+ | SSR safety | N/A (browser only) | Requires dynamic import guard |
96
+ | Tree-shaking | No | Yes |
97
+ | Build tools required | No | Yes |
98
+
99
+ ## Configuration
100
+
101
+ | Option | Type | Default | Description |
102
+ |---|---|---|---|
103
+ | `siteId` | `string` | *required* | Your site identifier |
104
+ | `apiKey` | `string` | *required* | API key from Rover Workspace |
105
+ | `allowedDomains` | `string[]` | `[]` | Hostnames where Rover may operate |
106
+ | `domainScopeMode` | `'registrable_domain' \| 'host_only'` | `'registrable_domain'` | Domain matching strategy |
107
+ | `openOnInit` | `boolean` | `false` | Open panel immediately on boot |
108
+ | `taskRouting` | `object` | `{ mode: 'act' }` | Task routing strategy |
109
+ | `externalNavigationPolicy` | `string` | `'open_new_tab_notice'` | Policy for out-of-scope links |
110
+ | `workerUrl` | `string` | auto | Custom worker URL for self-hosting |
111
+ | `ui.muted` | `boolean` | `false` | Start with audio muted (user can toggle via UI) |
112
+ | `ui.mascot.disabled` | `boolean` | `false` | Disable mascot video (removes `media-src` CSP need) |
113
+ | `visitorId` | `string` | auto | Stable visitor identifier |
114
+ | `sessionScope` | `'shared_site' \| 'tab'` | `'shared_site'` | Session sharing across tabs |
115
+
116
+ See [full configuration reference](https://github.com/rtrvr-ai/rover/blob/main/docs/INTEGRATION.md#configuration-reference).
117
+
118
+ ## API Methods
119
+
120
+ All methods are available as both command-style and method-style calls:
121
+
122
+ ```javascript
123
+ // Command style
124
+ rover('boot', config);
125
+ rover('send', 'Hello');
126
+
127
+ // Method style
128
+ rover.boot(config);
129
+ rover.send('Hello');
130
+ ```
131
+
132
+ | Method | Description |
133
+ |---|---|
134
+ | `boot(config)` | Initialize Rover with configuration |
135
+ | `shutdown()` | Tear down Rover and clean up resources |
136
+ | `open()` | Open the chat panel |
137
+ | `close()` | Close the chat panel |
138
+ | `show()` | Show the widget (launcher + panel) |
139
+ | `hide()` | Hide the widget entirely |
140
+ | `send(text)` | Send a message to Rover |
141
+ | `newTask(options?)` | Start a new task, clearing context |
142
+ | `endTask(options?)` | End the current task |
143
+ | `getState()` | Get current runtime state |
144
+ | `update(config)` | Update configuration without rebooting |
145
+ | `registerTool(def, handler)` | Register a client-side tool |
146
+ | `on(event, handler)` | Subscribe to events (returns unsubscribe fn) |
147
+
148
+ ## Events
149
+
150
+ ```javascript
151
+ rover.on('ready', () => console.log('Rover ready'));
152
+ rover.on('status', (payload) => console.log(payload.stage, payload.compactThought));
153
+ rover.on('error', (err) => console.error(err));
154
+ ```
155
+
156
+ | Event | Payload | Description |
157
+ |---|---|---|
158
+ | `ready` | — | SDK initialized and worker connected |
159
+ | `status` | `{ stage, compactThought }` | Execution progress updates |
160
+ | `error` | `{ message, code? }` | Runtime errors |
161
+ | `auth_required` | `{ code, missing }` | Authentication needed |
162
+ | `open` | — | Panel opened |
163
+ | `close` | — | Panel closed |
164
+ | `mode_change` | `{ mode }` | Execution mode changed |
165
+ | `navigation_guardrail` | `{ url, policy }` | Out-of-scope navigation intercepted |
166
+ | `task_started` | `{ reason }` | New task started |
167
+ | `task_ended` | `{ reason }` | Task ended |
168
+
169
+ ## Content Security Policy (CSP)
170
+
171
+ If your site sets a CSP header, add these directives:
172
+
173
+ | Directive | Value | Why |
174
+ |---|---|---|
175
+ | `script-src` | `https://rover.rtrvr.ai blob:` | SDK script + Web Worker blob |
176
+ | `worker-src` | `blob: https://rover.rtrvr.ai` | Web Worker execution |
177
+ | `connect-src` | `https://us-central1-rtrvr-extension-functions.cloudfunctions.net` | API calls |
178
+ | `style-src` | `'unsafe-inline'` | Shadow DOM styles |
179
+ | `font-src` | `https://rover.rtrvr.ai` | Self-hosted Manrope font |
180
+
181
+ Optional (if mascot video is enabled):
182
+
183
+ | Directive | Value | Why |
184
+ |---|---|---|
185
+ | `media-src` | `https://www.rtrvr.ai` | Mascot video |
186
+
187
+ Disable the mascot to remove the `media-src` requirement:
188
+
189
+ ```javascript
190
+ rover('boot', { ..., ui: { mascot: { disabled: true } } });
191
+ ```
192
+
193
+ **No CSP header?** No action needed — Rover works out of the box.
194
+
195
+ ### Self-Hosting (Strict CSP)
196
+
197
+ For environments that cannot allow external domains:
198
+
199
+ 1. Download `embed.js` and `worker/rover-worker.js` from `https://rover.rtrvr.ai/`
200
+ 2. Host them on your own domain
201
+ 3. Point Rover to your hosted files:
202
+
203
+ ```javascript
204
+ rover('boot', {
205
+ siteId: 'YOUR_SITE_ID',
206
+ apiKey: 'YOUR_API_KEY',
207
+ workerUrl: '/assets/rover-worker.js',
208
+ });
209
+ ```
210
+
211
+ Load your self-hosted `embed.js` instead of the CDN version:
212
+
213
+ ```html
214
+ <script src="/assets/embed.js" async></script>
215
+ ```
216
+
217
+ ## Links
218
+
219
+ - [Integration Guide](https://github.com/rtrvr-ai/rover/blob/main/docs/INTEGRATION.md)
220
+ - [Rover Workspace](https://rover.rtrvr.ai/workspace) — generate site keys and install snippets
221
+ - [Website](https://www.rtrvr.ai/rover)