navia-ai 0.2.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 +21 -0
- package/README.md +126 -0
- package/dist/chunk-EVN4KO6M.js +987 -0
- package/dist/chunk-EVN4KO6M.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +122 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +164 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/package.json +76 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 azulls1
|
|
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
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# 🌐 Navia
|
|
2
|
+
|
|
3
|
+
> Agente de navegador autónomo con IA. Le das una **instrucción en lenguaje natural** y abre un navegador **real** (Chrome o Firefox), lee la página, hace clic, llena formularios, extrae datos y opera **cualquier portal web** — como lo haría una persona.
|
|
4
|
+
|
|
5
|
+
Funciona con tu **API key de Anthropic (Claude)**. Sin scripts a medida por sitio: la IA descubre los botones y campos en vivo con el método **navegar → leer → actuar → verificar**.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx navia-ai "abre example.com y dime de qué trata la página"
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## ✨ Qué hace
|
|
14
|
+
|
|
15
|
+
- 🧠 **Una instrucción, no un script.** Describes la tarea; Navia decide los pasos.
|
|
16
|
+
- 🦊 **Chrome o Firefox reales** a elegir.
|
|
17
|
+
- 🛡️ **Anti-Cloudflare incluido.** Modo `--browser chrome` que se conecta por **CDP a un Chrome real** → `navigator.webdriver=false` → pasa el muro "Just a moment…". No es evasión: es tu navegador.
|
|
18
|
+
- 👁️ **Lee como humano:** árbol de accesibilidad (no píxeles) + screenshots para verificar con visión.
|
|
19
|
+
- 🧩 **Extracción masiva** con JavaScript (listados → JSON).
|
|
20
|
+
- 🔐 **Seguro por diseño:** pide confirmación antes de acciones irreversibles (enviar, pagar, borrar) y te cede la ventana para login / captcha / 2FA.
|
|
21
|
+
- 📦 **CLI + librería** (TypeScript, ESM).
|
|
22
|
+
|
|
23
|
+
## 📦 Instalación
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install -g navia-ai # global, para usar el comando `navia`
|
|
27
|
+
# o sin instalar:
|
|
28
|
+
npx navia-ai "tu tarea"
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Primera vez (instala los navegadores de Playwright):
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npx playwright install chromium firefox
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Configura tu API key (archivo `.env` o variable de entorno):
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
ANTHROPIC_API_KEY=sk-ant-...
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## 🚀 Uso (CLI)
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Navegador por defecto (Chromium)
|
|
47
|
+
navia "busca 'camisetas' en example-shop.com y lístame los primeros 5 productos con precio"
|
|
48
|
+
|
|
49
|
+
# Firefox
|
|
50
|
+
navia run "entra a mi-portal.com, inicia sesión y descarga mi última factura" --browser firefox
|
|
51
|
+
|
|
52
|
+
# Chrome real (sitios con Cloudflare)
|
|
53
|
+
navia chrome # 1) lanza Chrome con depuración
|
|
54
|
+
navia run "busca empleos de QA en {portal}" --browser chrome # 2) la tarea
|
|
55
|
+
|
|
56
|
+
# Otras opciones
|
|
57
|
+
navia "..." --headless # sin ventana
|
|
58
|
+
navia "..." --slow-mo 300 # ir lento (anti rate-limit)
|
|
59
|
+
navia "..." --start-url https://... # abrir una URL antes de empezar
|
|
60
|
+
navia "..." --model claude-opus-4-8 # otro modelo
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Durante la ejecución:
|
|
64
|
+
- Si hace falta **login / captcha / 2FA**, Navia pausa y te pasa la ventana.
|
|
65
|
+
- Antes de algo **irreversible**, te pide confirmación (`s/N`).
|
|
66
|
+
|
|
67
|
+
### Sesiones / perfiles (no volver a loguear cada vez)
|
|
68
|
+
```bash
|
|
69
|
+
# 1) Inicia sesión una vez y guarda el perfil (cookies/almacenamiento)
|
|
70
|
+
navia login mi-portal --browser chromium --start-url https://mi-portal.com/login
|
|
71
|
+
|
|
72
|
+
# 2) Reusa esa sesión: arranca ya autenticado, se salta el login/captcha
|
|
73
|
+
navia run "descarga mi última factura" --profile mi-portal
|
|
74
|
+
```
|
|
75
|
+
- El perfil se guarda en `~/.navia/profiles/` (cubierto por `.gitignore`).
|
|
76
|
+
- Define **`NAVIA_SECRET`** para **cifrar** el perfil (AES-256-GCM). Contiene cookies de sesión — recomendado.
|
|
77
|
+
|
|
78
|
+
## 🧑💻 Uso (librería)
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import { runNavia } from "navia-ai";
|
|
82
|
+
|
|
83
|
+
const { summary, steps } = await runNavia({
|
|
84
|
+
task: "Abre example.com y extrae todos los enlaces del menú principal",
|
|
85
|
+
browser: "chromium",
|
|
86
|
+
hooks: {
|
|
87
|
+
log: (m) => console.log(m),
|
|
88
|
+
confirmAction: async (desc) => /* tu lógica */ true,
|
|
89
|
+
waitForHuman: async (reason) => { /* resolver y */ return ""; },
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
console.log(summary);
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## 🔧 Cómo funciona (arquitectura)
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
Tu instrucción ─► BrowserAgent (loop de tool-use con Claude)
|
|
100
|
+
│ navigate · snapshot · click · type · fill_form · evaluate · wait_for · screenshot
|
|
101
|
+
▼
|
|
102
|
+
BrowserDriver (Playwright)
|
|
103
|
+
▼
|
|
104
|
+
Chrome real (CDP) / Firefox / Chromium ─► el sitio web
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
1. **snapshot** = árbol de accesibilidad con `ref` por elemento (la IA actúa por `ref`).
|
|
108
|
+
- En **Chromium/Chrome** el snapshot se construye con **CDP** (`Accessibility.getFullAXTree`): no muta el DOM, atraviesa **shadow DOM**, y los `ref` son **estables** (`backendNodeId`). Las acciones se resuelven por CDP.
|
|
109
|
+
- En **Firefox** (que no habla CDP) se usa un snapshot por inyección de JS como *fallback*; ahí los `ref` son efímeros → re-snapshotea tras cambios del DOM.
|
|
110
|
+
2. **evaluate** ejecuta JS para extraer listados o resolver clics tercos.
|
|
111
|
+
3. **detectChallenge** reconoce muros (Cloudflare/Turnstile/hCaptcha/reCAPTCHA/DataDome) y cede la ventana al humano.
|
|
112
|
+
4. El **system prompt** lleva destilado el método probado en producción.
|
|
113
|
+
|
|
114
|
+
| Motor | Cuándo usarlo |
|
|
115
|
+
|---|---|
|
|
116
|
+
| `chromium` (default) | La mayoría de sitios. |
|
|
117
|
+
| `firefox` | Alternativa; algunos portales se portan mejor. |
|
|
118
|
+
| `chrome` (CDP) | 🔑 Sitios con muro **Cloudflare**. Lanza tu Chrome real y se conecta por CDP. |
|
|
119
|
+
|
|
120
|
+
## ⚠️ Uso responsable
|
|
121
|
+
|
|
122
|
+
Navia opera un navegador real con tus credenciales y tu sesión. Úsalo solo en sitios y cuentas **propias o con autorización**, respetando los Términos de Servicio. El truco CDP **no burla** protecciones por fuerza: usa tu navegador real. No incluye solvers de captcha ni stealth: cuando hace falta un humano (captcha/2FA), te cede la ventana.
|
|
123
|
+
|
|
124
|
+
## 📄 Licencia
|
|
125
|
+
|
|
126
|
+
MIT
|