auspex 0.2.0 → 0.3.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/package.json +10 -4
- package/readme.md +169 -35
- package/dist/agent/actions.d.ts +0 -5
- package/dist/agent/actions.d.ts.map +0 -1
- package/dist/agent/actions.js +0 -26
- package/dist/agent/actions.js.map +0 -1
- package/dist/agent/agent.d.ts +0 -12
- package/dist/agent/agent.d.ts.map +0 -1
- package/dist/agent/agent.js +0 -159
- package/dist/agent/agent.js.map +0 -1
- package/dist/agent/loop.d.ts +0 -6
- package/dist/agent/loop.d.ts.map +0 -1
- package/dist/agent/loop.js +0 -175
- package/dist/agent/loop.js.map +0 -1
- package/dist/agent/report.d.ts +0 -3
- package/dist/agent/report.d.ts.map +0 -1
- package/dist/agent/report.js +0 -95
- package/dist/agent/report.js.map +0 -1
- package/dist/browser/executor.d.ts +0 -5
- package/dist/browser/executor.d.ts.map +0 -1
- package/dist/browser/executor.js +0 -33
- package/dist/browser/executor.js.map +0 -1
- package/dist/browser/snapshot.d.ts +0 -6
- package/dist/browser/snapshot.d.ts.map +0 -1
- package/dist/browser/snapshot.js +0 -145
- package/dist/browser/snapshot.js.map +0 -1
- package/dist/config/defaults.d.ts +0 -11
- package/dist/config/defaults.d.ts.map +0 -1
- package/dist/config/defaults.js +0 -11
- package/dist/config/defaults.js.map +0 -1
- package/dist/config/schema.d.ts +0 -62
- package/dist/config/schema.d.ts.map +0 -1
- package/dist/config/schema.js +0 -24
- package/dist/config/schema.js.map +0 -1
- package/dist/index.d.ts +0 -7
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -8
- package/dist/index.js.map +0 -1
- package/dist/llm/client.d.ts +0 -23
- package/dist/llm/client.d.ts.map +0 -1
- package/dist/llm/client.js +0 -51
- package/dist/llm/client.js.map +0 -1
- package/dist/llm/prompt.d.ts +0 -3
- package/dist/llm/prompt.d.ts.map +0 -1
- package/dist/llm/prompt.js +0 -36
- package/dist/llm/prompt.js.map +0 -1
- package/dist/scraper/extractors/content.d.ts +0 -32
- package/dist/scraper/extractors/content.d.ts.map +0 -1
- package/dist/scraper/extractors/content.js +0 -276
- package/dist/scraper/extractors/content.js.map +0 -1
- package/dist/scraper/extractors/ssr.d.ts +0 -17
- package/dist/scraper/extractors/ssr.d.ts.map +0 -1
- package/dist/scraper/extractors/ssr.js +0 -162
- package/dist/scraper/extractors/ssr.js.map +0 -1
- package/dist/scraper/extractors/to-markdown.d.ts +0 -5
- package/dist/scraper/extractors/to-markdown.d.ts.map +0 -1
- package/dist/scraper/extractors/to-markdown.js +0 -103
- package/dist/scraper/extractors/to-markdown.js.map +0 -1
- package/dist/scraper/index.d.ts +0 -35
- package/dist/scraper/index.d.ts.map +0 -1
- package/dist/scraper/index.js +0 -299
- package/dist/scraper/index.js.map +0 -1
- package/dist/scraper/tiers/tier1-http.d.ts +0 -5
- package/dist/scraper/tiers/tier1-http.d.ts.map +0 -1
- package/dist/scraper/tiers/tier1-http.js +0 -122
- package/dist/scraper/tiers/tier1-http.js.map +0 -1
- package/dist/scraper/tiers/tier2-stealth.d.ts +0 -5
- package/dist/scraper/tiers/tier2-stealth.d.ts.map +0 -1
- package/dist/scraper/tiers/tier2-stealth.js +0 -108
- package/dist/scraper/tiers/tier2-stealth.js.map +0 -1
- package/dist/scraper/tiers/tier3-browser.d.ts +0 -10
- package/dist/scraper/tiers/tier3-browser.d.ts.map +0 -1
- package/dist/scraper/tiers/tier3-browser.js +0 -506
- package/dist/scraper/tiers/tier3-browser.js.map +0 -1
- package/dist/scraper/types.d.ts +0 -161
- package/dist/scraper/types.d.ts.map +0 -1
- package/dist/scraper/types.js +0 -3
- package/dist/scraper/types.js.map +0 -1
- package/dist/security/action-validator.d.ts +0 -83
- package/dist/security/action-validator.d.ts.map +0 -1
- package/dist/security/action-validator.js +0 -36
- package/dist/security/action-validator.js.map +0 -1
- package/dist/security/url-validator.d.ts +0 -9
- package/dist/security/url-validator.d.ts.map +0 -1
- package/dist/security/url-validator.js +0 -69
- package/dist/security/url-validator.js.map +0 -1
- package/dist/types.d.ts +0 -96
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "auspex",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "AI-powered browser agent with tiered scraping — HTTP/Cheerio first, Playwright as fallback",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -20,7 +20,9 @@
|
|
|
20
20
|
"dev": "tsx src/index.ts",
|
|
21
21
|
"example": "tsx examples/basic.ts",
|
|
22
22
|
"example:scraper": "tsx examples/scraper.ts",
|
|
23
|
-
"install:browser": "playwright install chromium"
|
|
23
|
+
"install:browser": "playwright install chromium",
|
|
24
|
+
"test": "vitest run",
|
|
25
|
+
"test:watch": "vitest"
|
|
24
26
|
},
|
|
25
27
|
"keywords": [
|
|
26
28
|
"auspex",
|
|
@@ -42,9 +44,12 @@
|
|
|
42
44
|
"openai": "^4.77.0",
|
|
43
45
|
"playwright": "^1.49.0",
|
|
44
46
|
"playwright-core": "^1.49.0",
|
|
47
|
+
"playwright-extra": "^4.3.6",
|
|
48
|
+
"puppeteer-extra-plugin-stealth": "^2.11.2",
|
|
45
49
|
"turndown": "^7.2.2",
|
|
46
50
|
"turndown-plugin-gfm": "^1.0.2",
|
|
47
|
-
"zod": "^3.24.0"
|
|
51
|
+
"zod": "^3.24.0",
|
|
52
|
+
"zod-to-json-schema": "^3.25.1"
|
|
48
53
|
},
|
|
49
54
|
"devDependencies": {
|
|
50
55
|
"@types/jsdom": "^21.1.7",
|
|
@@ -52,6 +57,7 @@
|
|
|
52
57
|
"@types/turndown": "^5.0.6",
|
|
53
58
|
"dotenv": "^16.4.0",
|
|
54
59
|
"tsx": "^4.19.0",
|
|
55
|
-
"typescript": "^5.7.0"
|
|
60
|
+
"typescript": "^5.7.0",
|
|
61
|
+
"vitest": "^4.0.18"
|
|
56
62
|
}
|
|
57
63
|
}
|
package/readme.md
CHANGED
|
@@ -18,6 +18,8 @@ Framework de browser automation alimentado por LLM. Voce fornece uma **URL** e u
|
|
|
18
18
|
- [Relatorio de Execucao](#relatorio-de-execucao)
|
|
19
19
|
- [Parametros da LLM](#parametros-da-llm)
|
|
20
20
|
- [Providers de LLM compativeis](#providers-de-llm-compativeis)
|
|
21
|
+
- [Eventos](#eventos)
|
|
22
|
+
- [Browser Pool](#browser-pool)
|
|
21
23
|
- [Acoes do Agent](#acoes-do-agent)
|
|
22
24
|
- [Seguranca](#seguranca)
|
|
23
25
|
- [Monitoramento — Tokens e Memoria](#monitoramento--tokens-e-memoria)
|
|
@@ -126,6 +128,20 @@ const r2 = await agent.run({
|
|
|
126
128
|
await agent.close(); // limpa tudo no final
|
|
127
129
|
```
|
|
128
130
|
|
|
131
|
+
### Construtor com pool (opcional)
|
|
132
|
+
|
|
133
|
+
Voce pode passar um `BrowserPool` como segundo argumento para compartilhar instancias de browser entre multiplos agents (ex.: workers concorrentes). Sem pool, o agent usa um unico browser por instancia.
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
import { Auspex, BrowserPool } from "auspex";
|
|
137
|
+
|
|
138
|
+
const pool = new BrowserPool({ maxSize: 3 });
|
|
139
|
+
const agent = new Auspex({ llmApiKey: "sk-..." }, pool);
|
|
140
|
+
const result = await agent.run({ url, prompt });
|
|
141
|
+
await agent.close(); // apenas desvincula do pool; o pool continua ativo
|
|
142
|
+
// pool.close() quando nao for mais usar
|
|
143
|
+
```
|
|
144
|
+
|
|
129
145
|
---
|
|
130
146
|
|
|
131
147
|
## AgentConfig — Configuracao completa
|
|
@@ -154,6 +170,22 @@ new Auspex({
|
|
|
154
170
|
// ──── Seguranca ──────────────────────────────────
|
|
155
171
|
allowedDomains: ["example.com"], // se definido, SO permite esses dominios
|
|
156
172
|
blockedDomains: ["evil.com"], // dominios bloqueados explicitamente
|
|
173
|
+
|
|
174
|
+
// ──── Browser e rede ────────────────────────────
|
|
175
|
+
gotoTimeoutMs: 15000, // timeout do page.goto (default: 15s)
|
|
176
|
+
proxy: { server: "http://...", username?: "...", password?: "..." },
|
|
177
|
+
cookies: [{ name, value, domain?, path?, ... }], // cookies injetados no context
|
|
178
|
+
extraHeaders: { "Accept-Language": "pt-BR" }, // headers HTTP do context
|
|
179
|
+
|
|
180
|
+
// ──── Loop e orcamento ──────────────────────────
|
|
181
|
+
actionDelayMs: 500, // delay entre iteracoes (ms, default: 500)
|
|
182
|
+
maxTotalTokens: 0, // orcamento total de tokens (0 = ilimitado)
|
|
183
|
+
|
|
184
|
+
// ──── Log e vision ───────────────────────────────
|
|
185
|
+
log: false, // gravar log em arquivo por execucao (./logs/)
|
|
186
|
+
logDir: "logs", // diretorio dos logs
|
|
187
|
+
vision: false, // fallback com screenshot apos falhas (modelo com vision)
|
|
188
|
+
screenshotQuality: 75, // qualidade JPEG 1-100 (vision, default: 75)
|
|
157
189
|
});
|
|
158
190
|
```
|
|
159
191
|
|
|
@@ -172,8 +204,18 @@ new Auspex({
|
|
|
172
204
|
| `maxIterations` | `number` | Nao | `30` | Max iteracoes do agent loop |
|
|
173
205
|
| `timeoutMs` | `number` | Nao | `120000` | Timeout total da execucao (ms) |
|
|
174
206
|
| `maxWaitMs` | `number` | Nao | `5000` | Max ms para acao `wait` |
|
|
207
|
+
| `gotoTimeoutMs` | `number` | Nao | `15000` | Timeout do page.goto (ms) |
|
|
175
208
|
| `allowedDomains` | `string[]` | Nao | — | Whitelist de dominios permitidos |
|
|
176
209
|
| `blockedDomains` | `string[]` | Nao | — | Blacklist de dominios bloqueados |
|
|
210
|
+
| `actionDelayMs` | `number` | Nao | `500` | Delay entre iteracoes (ms) |
|
|
211
|
+
| `maxTotalTokens` | `number` | Nao | `0` | Orcamento total de tokens (0 = ilimitado) |
|
|
212
|
+
| `proxy` | `ProxyConfig` | Nao | — | Proxy para browser e requests |
|
|
213
|
+
| `cookies` | `CookieParam[]` | Nao | — | Cookies injetados no context |
|
|
214
|
+
| `extraHeaders` | `Record<string, string>` | Nao | — | Headers HTTP do context |
|
|
215
|
+
| `log` | `boolean` | Nao | `false` | Gravar log em arquivo por run |
|
|
216
|
+
| `logDir` | `string` | Nao | `"logs"` | Diretorio dos arquivos de log |
|
|
217
|
+
| `vision` | `boolean` | Nao | `false` | Fallback com screenshot apos falhas (modelo vision) |
|
|
218
|
+
| `screenshotQuality` | `number` | Nao | `75` | Qualidade JPEG 1-100 para screenshots |
|
|
177
219
|
|
|
178
220
|
---
|
|
179
221
|
|
|
@@ -185,12 +227,27 @@ Opcoes passadas para `agent.run(options)`:
|
|
|
185
227
|
|-----------|------|:-----------:|-----------|
|
|
186
228
|
| `url` | `string` | Sim | URL inicial para o agent navegar |
|
|
187
229
|
| `prompt` | `string` | Sim | Instrucao em linguagem natural |
|
|
230
|
+
| `maxIterations` | `number` | Nao | Override de maxIterations para este run |
|
|
231
|
+
| `timeoutMs` | `number` | Nao | Override de timeoutMs para este run |
|
|
232
|
+
| `actionDelayMs` | `number` | Nao | Override de actionDelayMs para este run |
|
|
233
|
+
| `signal` | `AbortSignal` | Nao | AbortSignal para cancelar o run |
|
|
234
|
+
| `schema` | `ZodType<T>` | Nao | Schema Zod: retorno tipado em `data` (T \| null) |
|
|
235
|
+
| `vision` | `boolean` | Nao | Override do fallback com screenshot |
|
|
188
236
|
|
|
189
237
|
```typescript
|
|
190
238
|
const result = await agent.run({
|
|
191
239
|
url: "https://example.com",
|
|
192
240
|
prompt: "Qual o titulo desta pagina?",
|
|
193
241
|
});
|
|
242
|
+
|
|
243
|
+
// Com schema Zod — data fica tipado
|
|
244
|
+
const schema = z.object({ title: z.string(), price: z.number() });
|
|
245
|
+
const result = await agent.run({
|
|
246
|
+
url: "https://shop.example.com",
|
|
247
|
+
prompt: "Extraia titulo e preco do produto.",
|
|
248
|
+
schema,
|
|
249
|
+
});
|
|
250
|
+
// result.data: { title: string; price: number } | null
|
|
194
251
|
```
|
|
195
252
|
|
|
196
253
|
---
|
|
@@ -201,9 +258,9 @@ O `agent.run()` retorna um objeto `AgentResult` com tudo que aconteceu:
|
|
|
201
258
|
|
|
202
259
|
```typescript
|
|
203
260
|
interface AgentResult {
|
|
204
|
-
status: "done" | "max_iterations" | "error" | "timeout";
|
|
261
|
+
status: "done" | "max_iterations" | "error" | "timeout" | "aborted";
|
|
205
262
|
tier: "http" | "playwright"; // metodo de scraping utilizado
|
|
206
|
-
data: string | null; // resultado
|
|
263
|
+
data: string | null; // resultado (texto). Com run({ schema }), pode ser objeto tipado
|
|
207
264
|
report: string; // relatorio formatado legivel
|
|
208
265
|
durationMs: number; // duracao total da execucao em ms
|
|
209
266
|
actions: ActionRecord[]; // historico de todas as acoes executadas
|
|
@@ -220,6 +277,7 @@ interface AgentResult {
|
|
|
220
277
|
| `"done"` | Tarefa concluida com sucesso. `data` contem o resultado. |
|
|
221
278
|
| `"max_iterations"` | Atingiu o limite de iteracoes sem concluir. |
|
|
222
279
|
| `"timeout"` | Tempo limite excedido (`timeoutMs`). |
|
|
280
|
+
| `"aborted"` | Cancelado pelo chamador (AbortSignal). |
|
|
223
281
|
| `"error"` | Erro durante execucao. Ver `error` para detalhes. |
|
|
224
282
|
|
|
225
283
|
### Tier
|
|
@@ -272,31 +330,32 @@ const result = await agent.run({ url, prompt });
|
|
|
272
330
|
console.log(result.report);
|
|
273
331
|
```
|
|
274
332
|
|
|
275
|
-
Exemplo de saida (tier HTTP):
|
|
333
|
+
Exemplo de saida (tier HTTP). O relatorio eh gerado em ingles:
|
|
276
334
|
|
|
277
335
|
```
|
|
278
336
|
═══════════════════════════════════════════
|
|
279
|
-
|
|
337
|
+
EXECUTION REPORT — auspex
|
|
280
338
|
═══════════════════════════════════════════
|
|
281
339
|
|
|
282
|
-
URL
|
|
283
|
-
Prompt
|
|
284
|
-
Status
|
|
285
|
-
|
|
286
|
-
|
|
340
|
+
URL : https://news.ycombinator.com
|
|
341
|
+
Prompt : Retorne o titulo do primeiro artigo.
|
|
342
|
+
Status : Task completed successfully.
|
|
343
|
+
Method : HTTP/Cheerio (no browser — static page)
|
|
344
|
+
Duration: 1.2s
|
|
287
345
|
|
|
288
346
|
───────────────────────────────────────────
|
|
289
|
-
|
|
347
|
+
RESULT
|
|
290
348
|
───────────────────────────────────────────
|
|
291
349
|
|
|
292
350
|
Show HN: My weekend project
|
|
293
351
|
|
|
294
352
|
───────────────────────────────────────────
|
|
295
|
-
|
|
353
|
+
RESOURCE USAGE
|
|
296
354
|
───────────────────────────────────────────
|
|
297
355
|
|
|
298
|
-
LLM
|
|
299
|
-
|
|
356
|
+
LLM : 1 call(s) | 1820 tokens
|
|
357
|
+
> 1650 prompt + 170 completion
|
|
358
|
+
RAM : Node.js 45.2 MB | Browser: not used
|
|
300
359
|
|
|
301
360
|
═══════════════════════════════════════════
|
|
302
361
|
```
|
|
@@ -305,37 +364,38 @@ Exemplo de saida (tier Playwright):
|
|
|
305
364
|
|
|
306
365
|
```
|
|
307
366
|
═══════════════════════════════════════════
|
|
308
|
-
|
|
367
|
+
EXECUTION REPORT — auspex
|
|
309
368
|
═══════════════════════════════════════════
|
|
310
369
|
|
|
311
|
-
URL
|
|
312
|
-
Prompt
|
|
313
|
-
Status
|
|
314
|
-
|
|
315
|
-
|
|
370
|
+
URL : https://app.exemplo.com
|
|
371
|
+
Prompt : Faca login e retorne o saldo da conta.
|
|
372
|
+
Status : Task completed successfully.
|
|
373
|
+
Method : Playwright Chromium (full browser — JS required)
|
|
374
|
+
Duration: 12.4s
|
|
316
375
|
|
|
317
376
|
───────────────────────────────────────────
|
|
318
|
-
|
|
377
|
+
STEP BY STEP
|
|
319
378
|
───────────────────────────────────────────
|
|
320
379
|
|
|
321
|
-
1.
|
|
322
|
-
2.
|
|
323
|
-
3.
|
|
324
|
-
4.
|
|
325
|
-
5.
|
|
380
|
+
1. Clicked element "input[name='email']"
|
|
381
|
+
2. Typed "user@email.com" into "input[name='email']"
|
|
382
|
+
3. Typed "••••••••" into "input[name='password']"
|
|
383
|
+
4. Clicked element "button[type='submit']"
|
|
384
|
+
5. Finished with result
|
|
326
385
|
|
|
327
386
|
───────────────────────────────────────────
|
|
328
|
-
|
|
387
|
+
RESULT
|
|
329
388
|
───────────────────────────────────────────
|
|
330
389
|
|
|
331
390
|
Saldo: R$ 1.234,56
|
|
332
391
|
|
|
333
392
|
───────────────────────────────────────────
|
|
334
|
-
|
|
393
|
+
RESOURCE USAGE
|
|
335
394
|
───────────────────────────────────────────
|
|
336
395
|
|
|
337
|
-
LLM
|
|
338
|
-
|
|
396
|
+
LLM : 5 call(s) | 9430 tokens
|
|
397
|
+
> 8100 prompt + 1330 completion
|
|
398
|
+
RAM : Node.js 67.0 MB | Chromium peak 412.3 MB
|
|
339
399
|
|
|
340
400
|
═══════════════════════════════════════════
|
|
341
401
|
```
|
|
@@ -443,14 +503,72 @@ O LLM so pode executar acoes de uma **whitelist rigorosa**. Qualquer coisa fora
|
|
|
443
503
|
|
|
444
504
|
| Acao | Formato JSON | Descricao |
|
|
445
505
|
|------|-------------|-----------|
|
|
446
|
-
| **click** | `{"type":"click","selector":"#btn"}` | Clica em um elemento
|
|
506
|
+
| **click** | `{"type":"click","selector":"#btn"}` | Clica em um elemento (CSS ou role=button[name="..."] ) |
|
|
447
507
|
| **type** | `{"type":"type","selector":"input[name='q']","text":"busca"}` | Digita texto em um campo (max 1000 chars) |
|
|
508
|
+
| **select** | `{"type":"select","selector":"select#country","value":"br"}` | Seleciona opcao em `<select>` (value = option value) |
|
|
509
|
+
| **pressKey** | `{"type":"pressKey","key":"Enter"}` | Tecla: Enter, Tab, Escape, Backspace, ArrowUp/Down, etc. |
|
|
510
|
+
| **hover** | `{"type":"hover","selector":"#menu"}` | Passa o mouse sobre o elemento (menus, tooltips) |
|
|
448
511
|
| **goto** | `{"type":"goto","url":"https://..."}` | Navega para uma URL (passa por validacao anti-SSRF) |
|
|
449
512
|
| **wait** | `{"type":"wait","ms":2000}` | Espera N milissegundos (max 5000ms) |
|
|
450
|
-
| **scroll** | `{"type":"scroll","direction":"down"}` | Scroll
|
|
451
|
-
| **done** | `{"type":"done","result":"
|
|
513
|
+
| **scroll** | `{"type":"scroll","direction":"down","amount":500}` | Scroll (amount opcional, default 500px) |
|
|
514
|
+
| **done** | `{"type":"done","result":"..."}` | Finaliza e retorna o resultado (max 50k chars) |
|
|
515
|
+
|
|
516
|
+
Selectors podem ser **CSS** ou **role-based** (ex.: `role=button[name="Submit"]`) quando a Accessibility Tree esta no snapshot.
|
|
517
|
+
|
|
518
|
+
---
|
|
519
|
+
|
|
520
|
+
## Eventos
|
|
521
|
+
|
|
522
|
+
O `Auspex` estende `EventEmitter`. Voce pode escutar eventos por run:
|
|
523
|
+
|
|
524
|
+
| Evento | Argumentos | Descricao |
|
|
525
|
+
|--------|------------|-----------|
|
|
526
|
+
| `tier` | `(tier: AgentTier)` | Indica se o run usou HTTP ou Playwright |
|
|
527
|
+
| `iteration` | `(iteration: number, snapshot: PageSnapshot)` | Apos cada snapshot no loop |
|
|
528
|
+
| `action` | `(action: AgentAction, iteration: number)` | Antes de executar cada acao |
|
|
529
|
+
| `error` | `(error: Error)` | Em caso de erro na execucao (se houver listener) |
|
|
530
|
+
| `done` | `(result: AgentResult)` | Ao finalizar o run (sucesso ou nao) |
|
|
531
|
+
|
|
532
|
+
```typescript
|
|
533
|
+
agent.on("tier", (tier) => console.log("[tier]", tier));
|
|
534
|
+
agent.on("iteration", (i, snapshot) => console.log(`[iter ${i}]`, snapshot.url));
|
|
535
|
+
agent.on("action", (action, i) => console.log(`[action ${i}]`, action.type));
|
|
536
|
+
agent.on("done", (result) => console.log("Done:", result.status));
|
|
537
|
+
|
|
538
|
+
const result = await agent.run({ url, prompt });
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
---
|
|
542
|
+
|
|
543
|
+
## Browser Pool
|
|
544
|
+
|
|
545
|
+
A classe `BrowserPool` gerencia um conjunto de browsers Playwright reutilizaveis. Util para limitar recursos quando varios agents rodam em paralelo.
|
|
546
|
+
|
|
547
|
+
```typescript
|
|
548
|
+
import { BrowserPool } from "auspex";
|
|
549
|
+
|
|
550
|
+
const pool = new BrowserPool({
|
|
551
|
+
maxSize: 3,
|
|
552
|
+
acquireTimeoutMs: 30_000,
|
|
553
|
+
launchOptions: { headless: true },
|
|
554
|
+
});
|
|
452
555
|
|
|
453
|
-
|
|
556
|
+
const browser = await pool.acquire();
|
|
557
|
+
// ... usar browser (newContext, newPage, etc.)
|
|
558
|
+
pool.release(browser);
|
|
559
|
+
|
|
560
|
+
await pool.close(); // fecha todos os browsers
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
| Opcao | Tipo | Default | Descricao |
|
|
564
|
+
|-------|------|---------|-----------|
|
|
565
|
+
| `maxSize` | `number` | `3` | Maximo de instancias de browser |
|
|
566
|
+
| `acquireTimeoutMs` | `number` | `30000` | Timeout ao esperar um browser livre |
|
|
567
|
+
| `launchOptions` | `LaunchOptions` | headless + stealth args | Opcoes do Playwright |
|
|
568
|
+
|
|
569
|
+
---
|
|
570
|
+
|
|
571
|
+
## Acoes BLOQUEADAS
|
|
454
572
|
|
|
455
573
|
O framework **nao permite** nenhuma forma de:
|
|
456
574
|
|
|
@@ -473,7 +591,7 @@ Toda URL (inicial e durante navegacao) passa por validacao rigorosa:
|
|
|
473
591
|
- **IPs privados**: `127.0.0.0/8`, `10.0.0.0/8`, `192.168.0.0/16`, `172.16.0.0/12`
|
|
474
592
|
- **Cloud metadata**: `169.254.169.254` (AWS/GCP metadata endpoint)
|
|
475
593
|
- **Localhost**: `localhost`, `[::1]`
|
|
476
|
-
- **DNS rebinding**: resolve o hostname antes de navegar — detecta dominios publicos apontando para IPs privados
|
|
594
|
+
- **DNS rebinding**: resolve o hostname antes de navegar — detecta dominios publicos apontando para IPs privados. Falha de DNS rejeita a URL (fail closed).
|
|
477
595
|
|
|
478
596
|
### Whitelist de acoes
|
|
479
597
|
|
|
@@ -486,6 +604,8 @@ Selectors CSS sao verificados contra padroes maliciosos antes de qualquer intera
|
|
|
486
604
|
- `javascript:` — bloqueado
|
|
487
605
|
- `on*=` (event handlers como `onclick=`) — bloqueado
|
|
488
606
|
- `<script>` — bloqueado
|
|
607
|
+
- `data:` — bloqueado
|
|
608
|
+
- Tamanho maximo de 500 caracteres (protecao DoS)
|
|
489
609
|
- Strings vazias ou so espacos — bloqueadas
|
|
490
610
|
|
|
491
611
|
### Anti-prompt injection
|
|
@@ -613,6 +733,9 @@ switch (result.status) {
|
|
|
613
733
|
case "timeout":
|
|
614
734
|
console.warn("Timeout — aumente timeoutMs ou simplifique a tarefa");
|
|
615
735
|
break;
|
|
736
|
+
case "aborted":
|
|
737
|
+
console.warn("Cancelado (AbortSignal)");
|
|
738
|
+
break;
|
|
616
739
|
case "error":
|
|
617
740
|
console.error("Erro:", result.error);
|
|
618
741
|
break;
|
|
@@ -632,7 +755,8 @@ Criar um `Auspex` uma vez e chamar `run()` multiplas vezes eh mais eficiente do
|
|
|
632
755
|
- **Sem file upload**: a acao `type` preenche campos de texto, mas nao faz upload de arquivos.
|
|
633
756
|
- **Dependencia de selectors CSS**: a qualidade da automacao depende da capacidade do LLM de identificar selectors corretos a partir do snapshot textual.
|
|
634
757
|
- **Snapshot limitado**: captura ate 25 links, 5 formularios e 3500 chars de texto por pagina. Paginas muito grandes podem ter elementos nao capturados.
|
|
635
|
-
- **
|
|
758
|
+
- **Vision**: ao usar `vision: true`, o modelo deve suportar entrada de imagem (ex.: gpt-4o, gpt-4o-mini). Screenshot so eh enviado apos falhas consecutivas (fallback).
|
|
759
|
+
- **JSON mode obrigatorio**: o provider LLM deve suportar `response_format: { type: "json_object" }` (exceto em chamadas com screenshot, quando pode ser omitido).
|
|
636
760
|
|
|
637
761
|
---
|
|
638
762
|
|
|
@@ -694,6 +818,11 @@ src/
|
|
|
694
818
|
loop.ts # Core loop: snapshot -> LLM -> validar -> executar
|
|
695
819
|
actions.ts # Parser e validador de acoes do LLM
|
|
696
820
|
report.ts # Gerador de relatorio de execucao
|
|
821
|
+
logger.ts # Log por run (arquivo em logDir)
|
|
822
|
+
browser/
|
|
823
|
+
pool.ts # BrowserPool — pool de browsers reutilizaveis
|
|
824
|
+
llm/
|
|
825
|
+
vision-models.ts # Whitelist de modelos com suporte a vision
|
|
697
826
|
scraper/
|
|
698
827
|
index.ts # Scraper — fallback HTTP -> Stealth -> Browser
|
|
699
828
|
tiers/
|
|
@@ -777,6 +906,7 @@ LLM_API_KEY=sk-your-key-here
|
|
|
777
906
|
```typescript
|
|
778
907
|
import {
|
|
779
908
|
Auspex,
|
|
909
|
+
BrowserPool,
|
|
780
910
|
type AgentConfig,
|
|
781
911
|
type AgentResult,
|
|
782
912
|
type AgentAction,
|
|
@@ -790,6 +920,10 @@ import {
|
|
|
790
920
|
type SnapshotLink,
|
|
791
921
|
type SnapshotForm,
|
|
792
922
|
type SnapshotInput,
|
|
923
|
+
type ProxyConfig,
|
|
924
|
+
type CookieParam,
|
|
925
|
+
type AuspexEvents,
|
|
926
|
+
type BrowserPoolOptions,
|
|
793
927
|
UrlValidationError,
|
|
794
928
|
ActionValidationError,
|
|
795
929
|
} from "auspex";
|
package/dist/agent/actions.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { AgentAction } from "../types.js";
|
|
2
|
-
import { type UrlValidationOptions } from "../security/url-validator.js";
|
|
3
|
-
export declare function parseAndValidateAction(raw: unknown, urlOptions: UrlValidationOptions): Promise<AgentAction>;
|
|
4
|
-
export declare function formatActionForHistory(action: AgentAction, iteration: number): string;
|
|
5
|
-
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/agent/actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAe,KAAK,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEtF,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,OAAO,EACZ,UAAU,EAAE,oBAAoB,GAC/B,OAAO,CAAC,WAAW,CAAC,CAQtB;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAerF"}
|
package/dist/agent/actions.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { validateAction } from "../security/action-validator.js";
|
|
2
|
-
import { validateUrl } from "../security/url-validator.js";
|
|
3
|
-
export async function parseAndValidateAction(raw, urlOptions) {
|
|
4
|
-
const action = validateAction(raw);
|
|
5
|
-
if (action.type === "goto") {
|
|
6
|
-
await validateUrl(action.url, urlOptions);
|
|
7
|
-
}
|
|
8
|
-
return action;
|
|
9
|
-
}
|
|
10
|
-
export function formatActionForHistory(action, iteration) {
|
|
11
|
-
switch (action.type) {
|
|
12
|
-
case "click":
|
|
13
|
-
return `[${iteration}] click "${action.selector}"`;
|
|
14
|
-
case "type":
|
|
15
|
-
return `[${iteration}] type "${action.text}" into "${action.selector}"`;
|
|
16
|
-
case "goto":
|
|
17
|
-
return `[${iteration}] navigate to ${action.url}`;
|
|
18
|
-
case "wait":
|
|
19
|
-
return `[${iteration}] wait ${action.ms}ms`;
|
|
20
|
-
case "scroll":
|
|
21
|
-
return `[${iteration}] scroll ${action.direction}`;
|
|
22
|
-
case "done":
|
|
23
|
-
return `[${iteration}] done: ${action.result}`;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=actions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../src/agent/actions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAyB,MAAM,iCAAiC,CAAC;AACxF,OAAO,EAAE,WAAW,EAA6B,MAAM,8BAA8B,CAAC;AAEtF,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,GAAY,EACZ,UAAgC;IAEhC,MAAM,MAAM,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;IAEnC,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAC3B,MAAM,WAAW,CAAC,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAC5C,CAAC;IAED,OAAO,MAAqB,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,MAAmB,EAAE,SAAiB;IAC3E,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,OAAO;YACV,OAAO,IAAI,SAAS,YAAY,MAAM,CAAC,QAAQ,GAAG,CAAC;QACrD,KAAK,MAAM;YACT,OAAO,IAAI,SAAS,WAAW,MAAM,CAAC,IAAI,WAAW,MAAM,CAAC,QAAQ,GAAG,CAAC;QAC1E,KAAK,MAAM;YACT,OAAO,IAAI,SAAS,iBAAiB,MAAM,CAAC,GAAG,EAAE,CAAC;QACpD,KAAK,MAAM;YACT,OAAO,IAAI,SAAS,UAAU,MAAM,CAAC,EAAE,IAAI,CAAC;QAC9C,KAAK,QAAQ;YACX,OAAO,IAAI,SAAS,YAAY,MAAM,CAAC,SAAS,EAAE,CAAC;QACrD,KAAK,MAAM;YACT,OAAO,IAAI,SAAS,WAAW,MAAM,CAAC,MAAM,EAAE,CAAC;IACnD,CAAC;AACH,CAAC"}
|
package/dist/agent/agent.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { AgentConfig, AgentResult, RunOptions } from "../types.js";
|
|
2
|
-
export declare class Auspex {
|
|
3
|
-
private config;
|
|
4
|
-
private browser;
|
|
5
|
-
constructor(config: AgentConfig);
|
|
6
|
-
private getChromiumPids;
|
|
7
|
-
private makeChromiumMemoryTracker;
|
|
8
|
-
private ensureBrowser;
|
|
9
|
-
run(options: RunOptions): Promise<AgentResult>;
|
|
10
|
-
close(): Promise<void>;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/agent/agent.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAOxE,qBAAa,MAAM;IACjB,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,OAAO,CAAwB;gBAE3B,MAAM,EAAE,WAAW;IAM/B,OAAO,CAAC,eAAe;IAcvB,OAAO,CAAC,yBAAyB;YA4BnB,aAAa;IAYrB,GAAG,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC;IA4F9C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAM7B"}
|
package/dist/agent/agent.js
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { execSync } from "node:child_process";
|
|
2
|
-
import { chromium } from "playwright";
|
|
3
|
-
import { gotScraping } from "got-scraping";
|
|
4
|
-
import { agentConfigSchema, runOptionsSchema } from "../config/schema.js";
|
|
5
|
-
import { validateUrl } from "../security/url-validator.js";
|
|
6
|
-
import { snapshotFromHtml } from "../browser/snapshot.js";
|
|
7
|
-
import { runStaticLoop, runAgentLoop } from "./loop.js";
|
|
8
|
-
import { generateReport } from "./report.js";
|
|
9
|
-
export class Auspex {
|
|
10
|
-
config;
|
|
11
|
-
browser = null;
|
|
12
|
-
constructor(config) {
|
|
13
|
-
this.config = agentConfigSchema.parse(config);
|
|
14
|
-
}
|
|
15
|
-
// ── Snapshot de PIDs do Chromium antes do launch ─────────────────────────
|
|
16
|
-
getChromiumPids() {
|
|
17
|
-
try {
|
|
18
|
-
const out = execSync("ps aux | grep -i chromium | grep -v grep | awk '{print $2}'", {
|
|
19
|
-
encoding: "utf-8",
|
|
20
|
-
timeout: 2_000,
|
|
21
|
-
});
|
|
22
|
-
return new Set(out.trim().split("\n").filter(Boolean));
|
|
23
|
-
}
|
|
24
|
-
catch {
|
|
25
|
-
return new Set();
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
// ── Soma RSS de todos os processos Chromium novos (KB) ────────────────────
|
|
29
|
-
makeChromiumMemoryTracker(pidsBeforeLaunch) {
|
|
30
|
-
return () => {
|
|
31
|
-
try {
|
|
32
|
-
const out = execSync("ps aux | grep -i chromium | grep -v grep | awk '{print $2}'", {
|
|
33
|
-
encoding: "utf-8",
|
|
34
|
-
timeout: 2_000,
|
|
35
|
-
});
|
|
36
|
-
const newPids = out.trim().split("\n").filter(p => p && !pidsBeforeLaunch.has(p));
|
|
37
|
-
if (newPids.length === 0)
|
|
38
|
-
return 0;
|
|
39
|
-
// Soma o RSS de todos os processos Chromium lançados por este agente
|
|
40
|
-
const pidsArg = newPids.join(",");
|
|
41
|
-
const rssOut = execSync(`ps -o rss= -p ${pidsArg}`, {
|
|
42
|
-
encoding: "utf-8",
|
|
43
|
-
timeout: 2_000,
|
|
44
|
-
});
|
|
45
|
-
return rssOut
|
|
46
|
-
.trim()
|
|
47
|
-
.split("\n")
|
|
48
|
-
.reduce((sum, line) => sum + (parseInt(line.trim(), 10) || 0), 0);
|
|
49
|
-
}
|
|
50
|
-
catch {
|
|
51
|
-
return 0;
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
// ── Garante que o browser Playwright está rodando ─────────────────────────
|
|
56
|
-
async ensureBrowser() {
|
|
57
|
-
if (!this.browser || !this.browser.isConnected()) {
|
|
58
|
-
this.browser = await chromium.launch({
|
|
59
|
-
headless: true,
|
|
60
|
-
args: ["--disable-blink-features=AutomationControlled"],
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
return this.browser;
|
|
64
|
-
}
|
|
65
|
-
// ── Execução principal ────────────────────────────────────────────────────
|
|
66
|
-
async run(options) {
|
|
67
|
-
const { url, prompt } = runOptionsSchema.parse(options);
|
|
68
|
-
const validUrl = await validateUrl(url, {
|
|
69
|
-
allowedDomains: this.config.allowedDomains,
|
|
70
|
-
blockedDomains: this.config.blockedDomains,
|
|
71
|
-
});
|
|
72
|
-
// ── 1. Tenta HTTP/Cheerio primeiro (sem browser) ──────────────────────
|
|
73
|
-
//
|
|
74
|
-
// Se o HTML da página já tiver conteúdo suficiente E o LLM conseguir
|
|
75
|
-
// responder com "done" na primeira tentativa → economizamos o Playwright
|
|
76
|
-
// (zero processos externos, ~100-500ms vs ~5-30s).
|
|
77
|
-
//
|
|
78
|
-
try {
|
|
79
|
-
const response = await gotScraping({
|
|
80
|
-
url: validUrl,
|
|
81
|
-
method: "GET",
|
|
82
|
-
headerGeneratorOptions: {
|
|
83
|
-
browsers: [{ name: "chrome", minVersion: 120 }],
|
|
84
|
-
operatingSystems: ["macos", "windows"],
|
|
85
|
-
devices: ["desktop"],
|
|
86
|
-
locales: ["pt-BR", "pt", "en-US"],
|
|
87
|
-
},
|
|
88
|
-
timeout: { request: Math.min(this.config.timeoutMs, 10_000) },
|
|
89
|
-
followRedirect: true,
|
|
90
|
-
maxRedirects: 10,
|
|
91
|
-
throwHttpErrors: false,
|
|
92
|
-
decompress: true,
|
|
93
|
-
});
|
|
94
|
-
const { body: html, statusCode: status } = response;
|
|
95
|
-
if (html && status < 400) {
|
|
96
|
-
const snapshot = snapshotFromHtml(html, validUrl);
|
|
97
|
-
// Só tenta o loop estático se houver conteúdo mínimo (evita SPA vazia)
|
|
98
|
-
if (snapshot.text.length > 200) {
|
|
99
|
-
const staticResult = await runStaticLoop(snapshot, validUrl, prompt, this.config);
|
|
100
|
-
if (staticResult)
|
|
101
|
-
return staticResult; // ✅ resolvido sem browser
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
catch {
|
|
106
|
-
// HTTP falhou (timeout, SSL, rede) → vai direto para o Playwright
|
|
107
|
-
}
|
|
108
|
-
// ── 2. Playwright (fallback — página precisa de JS ou de interação) ───
|
|
109
|
-
const pidsBefore = this.getChromiumPids();
|
|
110
|
-
const browser = await this.ensureBrowser();
|
|
111
|
-
const getMemoryKb = this.makeChromiumMemoryTracker(pidsBefore);
|
|
112
|
-
let page = null;
|
|
113
|
-
try {
|
|
114
|
-
const context = await browser.newContext({
|
|
115
|
-
viewport: { width: 1280, height: 720 },
|
|
116
|
-
locale: "pt-BR",
|
|
117
|
-
timezoneId: "America/Sao_Paulo",
|
|
118
|
-
});
|
|
119
|
-
context.addInitScript(() => {
|
|
120
|
-
Object.defineProperty(navigator, "webdriver", { get: () => false, configurable: true });
|
|
121
|
-
window.chrome = { runtime: {} };
|
|
122
|
-
});
|
|
123
|
-
page = await context.newPage();
|
|
124
|
-
const gotoTimeout = this.config.gotoTimeoutMs ?? 15_000;
|
|
125
|
-
await page.goto(validUrl, { waitUntil: "domcontentloaded", timeout: gotoTimeout });
|
|
126
|
-
return await runAgentLoop(page, validUrl, prompt, this.config, getMemoryKb);
|
|
127
|
-
}
|
|
128
|
-
catch (err) {
|
|
129
|
-
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
130
|
-
const result = {
|
|
131
|
-
status: "error",
|
|
132
|
-
tier: "playwright",
|
|
133
|
-
data: null,
|
|
134
|
-
report: "",
|
|
135
|
-
durationMs: 0,
|
|
136
|
-
actions: [],
|
|
137
|
-
usage: { promptTokens: 0, completionTokens: 0, totalTokens: 0, calls: 0 },
|
|
138
|
-
memory: { browserPeakRssKb: 0, nodeHeapUsedMb: 0 },
|
|
139
|
-
error: errorMsg,
|
|
140
|
-
};
|
|
141
|
-
result.report = generateReport(result, validUrl, prompt);
|
|
142
|
-
return result;
|
|
143
|
-
}
|
|
144
|
-
finally {
|
|
145
|
-
if (page) {
|
|
146
|
-
const context = page.context();
|
|
147
|
-
await page.close().catch(() => { });
|
|
148
|
-
await context.close().catch(() => { });
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
async close() {
|
|
153
|
-
if (this.browser) {
|
|
154
|
-
await this.browser.close().catch(() => { });
|
|
155
|
-
this.browser = null;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
//# sourceMappingURL=agent.js.map
|
package/dist/agent/agent.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/agent/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAA2B,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAwB,MAAM,qBAAqB,CAAC;AAChG,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,OAAO,MAAM;IACT,MAAM,CAAkB;IACxB,OAAO,GAAmB,IAAI,CAAC;IAEvC,YAAY,MAAmB;QAC7B,IAAI,CAAC,MAAM,GAAG,iBAAiB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAChD,CAAC;IAED,4EAA4E;IAEpE,eAAe;QACrB,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,QAAQ,CAAC,6DAA6D,EAAE;gBAClF,QAAQ,EAAE,OAAO;gBACjB,OAAO,EAAE,KAAK;aACf,CAAC,CAAC;YACH,OAAO,IAAI,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;QACzD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,GAAG,EAAE,CAAC;QACnB,CAAC;IACH,CAAC;IAED,6EAA6E;IAErE,yBAAyB,CAAC,gBAA6B;Q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YACxC,CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;YAC3C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACtB,CAAC;IACH,CAAC;CACF"}
|
package/dist/agent/loop.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Page } from "playwright-core";
|
|
2
|
-
import type { AgentResult, PageSnapshot } from "../types.js";
|
|
3
|
-
import type { ValidatedConfig } from "../config/schema.js";
|
|
4
|
-
export declare function runStaticLoop(snapshot: PageSnapshot, url: string, prompt: string, config: ValidatedConfig): Promise<AgentResult | null>;
|
|
5
|
-
export declare function runAgentLoop(page: Page, url: string, prompt: string, config: ValidatedConfig, getMemoryKb?: () => number): Promise<AgentResult>;
|
|
6
|
-
//# sourceMappingURL=loop.d.ts.map
|
package/dist/agent/loop.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../../src/agent/loop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAkD,YAAY,EAAE,MAAM,aAAa,CAAC;AAC7G,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAwD3D,wBAAsB,aAAa,CACjC,QAAQ,EAAE,YAAY,EACtB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAsD7B;AASD,wBAAsB,YAAY,CAChC,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,eAAe,EACvB,WAAW,GAAE,MAAM,MAAgB,GAClC,OAAO,CAAC,WAAW,CAAC,CAuGtB"}
|