navvi 2.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/LICENSE +201 -0
- package/README.md +179 -0
- package/bin/navvi.js +150 -0
- package/container/Dockerfile +63 -0
- package/container/marionette.py +147 -0
- package/container/navvi-server.py +652 -0
- package/container/requirements.txt +2 -0
- package/container/start.sh +126 -0
- package/docs/navvi-logo.png +0 -0
- package/mcp/server.mjs +1278 -0
- package/package.json +41 -0
- package/personas/default.yaml +5 -0
- package/personas/dev.yaml +15 -0
- package/personas/fry.yaml +18 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="docs/navvi-logo.png" alt="Navvi" width="120" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">Navvi</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong>Give your AI agent a real browser identity.</strong>
|
|
9
|
+
<br />
|
|
10
|
+
Persistent browser personas that don't get blocked.
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
<p align="center">
|
|
14
|
+
<a href="#quick-start">Quick Start</a> ·
|
|
15
|
+
<a href="#use-cases">Use Cases</a> ·
|
|
16
|
+
<a href="#how-it-works">How It Works</a> ·
|
|
17
|
+
<a href="#mcp-tools">MCP Tools</a>
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## The Problem
|
|
23
|
+
|
|
24
|
+
AI agents need to use the web. But every automation tool gets detected and blocked:
|
|
25
|
+
|
|
26
|
+
- Selenium, Playwright, Puppeteer → `navigator.webdriver = true`
|
|
27
|
+
- Chrome DevTools Protocol → detectable protocol markers
|
|
28
|
+
- Synthetic events → `isTrusted: false`
|
|
29
|
+
|
|
30
|
+
Even "stealth" plugins get flagged by modern bot detection (Arkose Labs, Cloudflare Turnstile, PerimeterX). Your agent can't sign up for accounts, can't fill out forms on protected sites, can't pass CAPTCHAs.
|
|
31
|
+
|
|
32
|
+
## The Solution
|
|
33
|
+
|
|
34
|
+
Navvi gives your agent a real browser with real input. No protocol tricks, no stealth patches — just a Firefox window controlled by OS-level mouse and keyboard, exactly like a human sitting at a desk.
|
|
35
|
+
|
|
36
|
+
- **Real mouse events** that websites cannot distinguish from a person
|
|
37
|
+
- **Persistent identities** — cookies, logins, and history survive across sessions
|
|
38
|
+
- **Live view** — connect via VNC when your agent needs human help (CAPTCHAs, OAuth)
|
|
39
|
+
- **20 MCP tools** — drop into any Claude Code project
|
|
40
|
+
|
|
41
|
+
## Use Cases
|
|
42
|
+
|
|
43
|
+
**Account creation for AI personas.** Sign up for email, dev platforms, social accounts. Fill every form field, handle dropdowns and date pickers, get all the way to the CAPTCHA step undetected.
|
|
44
|
+
|
|
45
|
+
**Visual evidence for pull requests.** Screenshot your staging app before and after a code change. Record a GIF of a user flow. Attach it to the PR automatically.
|
|
46
|
+
|
|
47
|
+
**OAuth and login flows.** Log into a service once via VNC, and the session persists in a named volume. Your agent reuses the authenticated browser on every future run.
|
|
48
|
+
|
|
49
|
+
**Web scraping on protected sites.** Navigate sites that block headless browsers. Your agent sees a real Firefox with a real fingerprint.
|
|
50
|
+
|
|
51
|
+
**QA and smoke testing.** Point your agent at a form-heavy app and let it click through every flow, filling fields and verifying results.
|
|
52
|
+
|
|
53
|
+
## Quick Start
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# Install
|
|
57
|
+
npm install -g navvi
|
|
58
|
+
|
|
59
|
+
# Build the Docker image (one-time)
|
|
60
|
+
navvi build
|
|
61
|
+
|
|
62
|
+
# Add to Claude Code — in your .mcp.json:
|
|
63
|
+
# { "mcpServers": { "navvi": { "command": "navvi" } } }
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Or skip the install: `"command": "npx", "args": ["-y", "navvi"]`
|
|
67
|
+
|
|
68
|
+
Your agent now has 21 browser tools. The workflow:
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
navvi_start # spin up a browser container
|
|
72
|
+
navvi_open url=https://example.com # navigate
|
|
73
|
+
navvi_find selector="input[type=email]" # find element → get (x, y)
|
|
74
|
+
navvi_fill x=512 y=498 value="me@example.com" # type into it
|
|
75
|
+
navvi_screenshot # verify visually
|
|
76
|
+
navvi_creds action=autofill entry=navvi/default/tuta # or autofill from gopass
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
<details>
|
|
80
|
+
<summary>Manual Docker setup (no npm)</summary>
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
git clone https://github.com/Fellowship-dev/navvi
|
|
84
|
+
cd navvi
|
|
85
|
+
docker build -t navvi container/
|
|
86
|
+
docker run -d --name navvi-default -p 8024:8024 -p 6080:6080 navvi
|
|
87
|
+
```
|
|
88
|
+
</details>
|
|
89
|
+
|
|
90
|
+
## How It Works
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
Your AI agent (Claude Code, etc.)
|
|
94
|
+
|
|
|
95
|
+
| MCP tools / HTTP API
|
|
96
|
+
v
|
|
97
|
+
+--------------------------------------+
|
|
98
|
+
| Docker container |
|
|
99
|
+
| |
|
|
100
|
+
| Firefox <-- Marionette (navigate) |
|
|
101
|
+
| | |
|
|
102
|
+
| Xvfb <-- xdotool (click, type) |
|
|
103
|
+
| | |
|
|
104
|
+
| x11vnc --> noVNC (live view) |
|
|
105
|
+
| |
|
|
106
|
+
| navvi-server (REST API on :8024) |
|
|
107
|
+
+--------------------------------------+
|
|
108
|
+
|
|
|
109
|
+
v
|
|
110
|
+
Volume: persistent Firefox profile
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Navigation** goes through Firefox Marionette — a built-in protocol that doesn't expose automation markers.
|
|
114
|
+
|
|
115
|
+
**All input** goes through xdotool — OS-level mouse and keyboard events that are indistinguishable from a real user.
|
|
116
|
+
|
|
117
|
+
**Screenshots** are captured at the display level, not through the browser API.
|
|
118
|
+
|
|
119
|
+
**Profiles persist** in Docker named volumes. Stop a container, start it again — you're still logged in.
|
|
120
|
+
|
|
121
|
+
## MCP Tools
|
|
122
|
+
|
|
123
|
+
| Tool | What it does |
|
|
124
|
+
|------|-------------|
|
|
125
|
+
| `navvi_start` | Start a browser container for a persona |
|
|
126
|
+
| `navvi_stop` | Stop container (profile preserved) |
|
|
127
|
+
| `navvi_open` | Navigate to a URL |
|
|
128
|
+
| `navvi_find` | Find element by CSS selector → screen coordinates |
|
|
129
|
+
| `navvi_click` | Click at (x, y) |
|
|
130
|
+
| `navvi_fill` | Click + type text into a field |
|
|
131
|
+
| `navvi_press` | Press a key (Enter, Tab, Escape...) |
|
|
132
|
+
| `navvi_scroll` | Scroll the page |
|
|
133
|
+
| `navvi_drag` | Drag from point A to point B |
|
|
134
|
+
| `navvi_mousedown` | Press and hold (for CAPTCHAs) |
|
|
135
|
+
| `navvi_mouseup` | Release mouse button |
|
|
136
|
+
| `navvi_screenshot` | Capture the screen |
|
|
137
|
+
| `navvi_vnc` | Get live view URL for human help |
|
|
138
|
+
| `navvi_url` | Get current page URL |
|
|
139
|
+
| `navvi_record_start` | Start recording a video |
|
|
140
|
+
| `navvi_record_stop` | Stop and assemble MP4 |
|
|
141
|
+
| `navvi_record_gif` | Convert recording to GIF |
|
|
142
|
+
|
|
143
|
+
### The Workflow
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
navvi_find("input[type=email]") --> { x: 512, y: 498 }
|
|
147
|
+
navvi_fill(x=512, y=498, value="me@example.com")
|
|
148
|
+
navvi_screenshot() --> verify it worked
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
`navvi_find` is the key tool. It finds elements by CSS selector and returns **screen-ready coordinates** that you pass directly to `navvi_click` or `navvi_fill`. No coordinate math required.
|
|
152
|
+
|
|
153
|
+
### When Your Agent Gets Stuck
|
|
154
|
+
|
|
155
|
+
Some CAPTCHAs (Arkose Labs, image puzzles) require human eyes. When that happens:
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
navvi_vnc() --> http://127.0.0.1:6080/vnc.html?autoconnect=true
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Send the URL to the user. They solve the CAPTCHA in their browser, your agent continues.
|
|
162
|
+
|
|
163
|
+
## Personas
|
|
164
|
+
|
|
165
|
+
Define a persona in `personas/`:
|
|
166
|
+
|
|
167
|
+
```yaml
|
|
168
|
+
name: default
|
|
169
|
+
description: Default browser persona
|
|
170
|
+
browser:
|
|
171
|
+
locale: en-US
|
|
172
|
+
timezone: America/Santiago
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Each persona gets its own Docker volume (`navvi-profile-<name>`). Start it, log into your services via VNC, and the session persists forever. Your agent reuses the authenticated browser every time.
|
|
176
|
+
|
|
177
|
+
## License
|
|
178
|
+
|
|
179
|
+
Apache 2.0
|
package/bin/navvi.js
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Navvi CLI + MCP entry point.
|
|
4
|
+
*
|
|
5
|
+
* No args / piped stdin → run as MCP stdio server (for Claude Code)
|
|
6
|
+
* Subcommand → CLI mode (build, start, stop, status, vnc)
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { execSync } from 'child_process';
|
|
10
|
+
import { createRequire } from 'module';
|
|
11
|
+
import path from 'path';
|
|
12
|
+
import fs from 'fs';
|
|
13
|
+
import { fileURLToPath } from 'url';
|
|
14
|
+
|
|
15
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
16
|
+
const PACKAGE_DIR = path.resolve(__dirname, '..');
|
|
17
|
+
const cmd = process.argv[2];
|
|
18
|
+
|
|
19
|
+
// --- MCP mode: no args and stdin is not a TTY (piped by MCP client) ---
|
|
20
|
+
if (!cmd && !process.stdin.isTTY) {
|
|
21
|
+
const serverPath = path.join(PACKAGE_DIR, 'mcp', 'server.mjs');
|
|
22
|
+
process.env.NAVVI_PACKAGE_DIR = PACKAGE_DIR;
|
|
23
|
+
await import(serverPath);
|
|
24
|
+
// server.mjs sets up stdin/stdout listeners and runs forever
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// --- CLI mode ---
|
|
28
|
+
else {
|
|
29
|
+
const IMAGE = process.env.NAVVI_IMAGE || 'navvi';
|
|
30
|
+
const PREFIX = 'navvi-';
|
|
31
|
+
|
|
32
|
+
function sh(command) {
|
|
33
|
+
try {
|
|
34
|
+
return execSync(command, { encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();
|
|
35
|
+
} catch (e) {
|
|
36
|
+
return e.stderr ? e.stderr.trim() : e.message;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function version() {
|
|
41
|
+
try {
|
|
42
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(PACKAGE_DIR, 'package.json'), 'utf8'));
|
|
43
|
+
return pkg.version;
|
|
44
|
+
} catch {
|
|
45
|
+
return 'unknown';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
switch (cmd) {
|
|
50
|
+
case 'build': {
|
|
51
|
+
const dockerfile = path.join(PACKAGE_DIR, 'container');
|
|
52
|
+
console.log(`Building Navvi Docker image from ${dockerfile}...`);
|
|
53
|
+
try {
|
|
54
|
+
execSync(`docker build -t ${IMAGE} ${dockerfile}`, { stdio: 'inherit' });
|
|
55
|
+
console.log(`\nDone. Image: ${IMAGE}`);
|
|
56
|
+
} catch {
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
case 'start': {
|
|
63
|
+
const persona = process.argv[3] || 'default';
|
|
64
|
+
const cname = `${PREFIX}${persona}`;
|
|
65
|
+
const existing = sh(`docker ps -q --filter "name=${cname}" 2>/dev/null`);
|
|
66
|
+
if (existing) {
|
|
67
|
+
console.log(`Already running: ${cname}`);
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
sh(`docker rm ${cname} 2>/dev/null`);
|
|
71
|
+
const volume = `navvi-profile-${persona}`;
|
|
72
|
+
console.log(`Starting ${persona}...`);
|
|
73
|
+
const result = sh(`docker run -d --name ${cname} -p 8024:8024 -p 6080:6080 -v ${volume}:/home/user/.mozilla ${IMAGE}`);
|
|
74
|
+
if (result.includes('Error')) {
|
|
75
|
+
console.error(result);
|
|
76
|
+
console.error(`\nIs the image built? Run: navvi build`);
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
console.log(`Container: ${cname}`);
|
|
80
|
+
console.log(`API: http://127.0.0.1:8024`);
|
|
81
|
+
console.log(`VNC: http://127.0.0.1:6080/vnc.html?autoconnect=true`);
|
|
82
|
+
console.log(`Volume: ${volume}`);
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
case 'stop': {
|
|
87
|
+
const persona = process.argv[3];
|
|
88
|
+
if (persona) {
|
|
89
|
+
sh(`docker stop ${PREFIX}${persona} 2>/dev/null`);
|
|
90
|
+
sh(`docker rm ${PREFIX}${persona} 2>/dev/null`);
|
|
91
|
+
console.log(`Stopped: ${PREFIX}${persona}`);
|
|
92
|
+
} else {
|
|
93
|
+
const containers = sh(`docker ps --filter "name=${PREFIX}" --format "{{.Names}}" 2>/dev/null`);
|
|
94
|
+
if (!containers) { console.log('No running Navvi containers.'); break; }
|
|
95
|
+
for (const c of containers.split('\n')) {
|
|
96
|
+
sh(`docker stop ${c} 2>/dev/null`);
|
|
97
|
+
sh(`docker rm ${c} 2>/dev/null`);
|
|
98
|
+
console.log(`Stopped: ${c}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
case 'status': {
|
|
105
|
+
const containers = sh(`docker ps --filter "name=${PREFIX}" --format "{{.Names}}\t{{.Status}}\t{{.Ports}}" 2>/dev/null`);
|
|
106
|
+
if (!containers) { console.log('No running Navvi containers.'); break; }
|
|
107
|
+
console.log('Running:');
|
|
108
|
+
for (const line of containers.split('\n')) {
|
|
109
|
+
const [name, status, ports] = line.split('\t');
|
|
110
|
+
console.log(` ${name.replace(PREFIX, '')} — ${status}`);
|
|
111
|
+
}
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
case 'vnc': {
|
|
116
|
+
const persona = process.argv[3] || 'default';
|
|
117
|
+
console.log(`http://127.0.0.1:6080/vnc.html?autoconnect=true`);
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
case '--version':
|
|
122
|
+
case '-v':
|
|
123
|
+
console.log(`navvi ${version()}`);
|
|
124
|
+
break;
|
|
125
|
+
|
|
126
|
+
case '--help':
|
|
127
|
+
case '-h':
|
|
128
|
+
case 'help':
|
|
129
|
+
case undefined:
|
|
130
|
+
console.log(`navvi ${version()} — Give your AI agent a real browser identity.
|
|
131
|
+
|
|
132
|
+
Usage:
|
|
133
|
+
navvi Run as MCP server (for Claude Code)
|
|
134
|
+
navvi build Build the Docker image (one-time setup)
|
|
135
|
+
navvi start [persona] Start a browser container
|
|
136
|
+
navvi stop [persona] Stop container(s)
|
|
137
|
+
navvi status List running containers
|
|
138
|
+
navvi vnc [persona] Show noVNC URL for live view
|
|
139
|
+
navvi --version Show version
|
|
140
|
+
|
|
141
|
+
MCP setup:
|
|
142
|
+
Add to .mcp.json: { "mcpServers": { "navvi": { "command": "navvi" } } }
|
|
143
|
+
Or use npx: { "command": "npx", "args": ["-y", "navvi"] }`);
|
|
144
|
+
break;
|
|
145
|
+
|
|
146
|
+
default:
|
|
147
|
+
console.error(`Unknown command: ${cmd}\nRun: navvi --help`);
|
|
148
|
+
process.exit(1);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
FROM debian:bookworm-slim
|
|
2
|
+
|
|
3
|
+
ENV DEBIAN_FRONTEND=noninteractive
|
|
4
|
+
ENV DISPLAY=:1
|
|
5
|
+
ENV NAVVI_PORT=8024
|
|
6
|
+
ENV VNC_PORT=6080
|
|
7
|
+
|
|
8
|
+
# System packages: Firefox ESR, Xvfb, xdotool, scrot, x11vnc, Python
|
|
9
|
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
10
|
+
firefox-esr \
|
|
11
|
+
xvfb \
|
|
12
|
+
xdotool \
|
|
13
|
+
scrot \
|
|
14
|
+
x11vnc \
|
|
15
|
+
python3 \
|
|
16
|
+
python3-pip \
|
|
17
|
+
python3-venv \
|
|
18
|
+
wget \
|
|
19
|
+
unzip \
|
|
20
|
+
procps \
|
|
21
|
+
ca-certificates \
|
|
22
|
+
gnupg \
|
|
23
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
24
|
+
|
|
25
|
+
# Install gopass (credential manager) — needs git as dependency
|
|
26
|
+
RUN apt-get update && apt-get install -y --no-install-recommends git && rm -rf /var/lib/apt/lists/*
|
|
27
|
+
ARG GOPASS_VERSION=1.15.14
|
|
28
|
+
RUN ARCH=$(dpkg --print-architecture) \
|
|
29
|
+
&& wget -q "https://github.com/gopasspw/gopass/releases/download/v${GOPASS_VERSION}/gopass_${GOPASS_VERSION}_linux_${ARCH}.deb" -O /tmp/gopass.deb \
|
|
30
|
+
&& dpkg -i /tmp/gopass.deb \
|
|
31
|
+
&& rm /tmp/gopass.deb
|
|
32
|
+
|
|
33
|
+
# noVNC (web-based VNC client)
|
|
34
|
+
RUN wget -q https://github.com/novnc/noVNC/archive/refs/tags/v1.4.0.tar.gz -O /tmp/novnc.tar.gz \
|
|
35
|
+
&& tar -xzf /tmp/novnc.tar.gz -C /opt \
|
|
36
|
+
&& mv /opt/noVNC-1.4.0 /opt/novnc \
|
|
37
|
+
&& ln -s /opt/novnc/vnc.html /opt/novnc/index.html \
|
|
38
|
+
&& rm /tmp/novnc.tar.gz
|
|
39
|
+
|
|
40
|
+
# websockify (noVNC needs it to proxy VNC)
|
|
41
|
+
RUN pip3 install --no-cache-dir --break-system-packages websockify
|
|
42
|
+
|
|
43
|
+
# Python dependencies
|
|
44
|
+
COPY requirements.txt /opt/navvi/requirements.txt
|
|
45
|
+
RUN pip3 install --no-cache-dir --break-system-packages -r /opt/navvi/requirements.txt
|
|
46
|
+
|
|
47
|
+
# Application code
|
|
48
|
+
COPY navvi-server.py /opt/navvi/navvi-server.py
|
|
49
|
+
COPY marionette.py /opt/navvi/marionette.py
|
|
50
|
+
COPY start.sh /opt/navvi/start.sh
|
|
51
|
+
RUN chmod +x /opt/navvi/start.sh
|
|
52
|
+
|
|
53
|
+
# Create non-root user
|
|
54
|
+
RUN useradd -m -s /bin/bash user
|
|
55
|
+
USER user
|
|
56
|
+
WORKDIR /home/user
|
|
57
|
+
|
|
58
|
+
# Firefox profile directory (mount a named volume here for persistence)
|
|
59
|
+
RUN mkdir -p /home/user/.mozilla
|
|
60
|
+
|
|
61
|
+
EXPOSE 8024 6080
|
|
62
|
+
|
|
63
|
+
ENTRYPOINT ["/opt/navvi/start.sh"]
|