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.
Files changed (90) hide show
  1. package/package.json +10 -4
  2. package/readme.md +169 -35
  3. package/dist/agent/actions.d.ts +0 -5
  4. package/dist/agent/actions.d.ts.map +0 -1
  5. package/dist/agent/actions.js +0 -26
  6. package/dist/agent/actions.js.map +0 -1
  7. package/dist/agent/agent.d.ts +0 -12
  8. package/dist/agent/agent.d.ts.map +0 -1
  9. package/dist/agent/agent.js +0 -159
  10. package/dist/agent/agent.js.map +0 -1
  11. package/dist/agent/loop.d.ts +0 -6
  12. package/dist/agent/loop.d.ts.map +0 -1
  13. package/dist/agent/loop.js +0 -175
  14. package/dist/agent/loop.js.map +0 -1
  15. package/dist/agent/report.d.ts +0 -3
  16. package/dist/agent/report.d.ts.map +0 -1
  17. package/dist/agent/report.js +0 -95
  18. package/dist/agent/report.js.map +0 -1
  19. package/dist/browser/executor.d.ts +0 -5
  20. package/dist/browser/executor.d.ts.map +0 -1
  21. package/dist/browser/executor.js +0 -33
  22. package/dist/browser/executor.js.map +0 -1
  23. package/dist/browser/snapshot.d.ts +0 -6
  24. package/dist/browser/snapshot.d.ts.map +0 -1
  25. package/dist/browser/snapshot.js +0 -145
  26. package/dist/browser/snapshot.js.map +0 -1
  27. package/dist/config/defaults.d.ts +0 -11
  28. package/dist/config/defaults.d.ts.map +0 -1
  29. package/dist/config/defaults.js +0 -11
  30. package/dist/config/defaults.js.map +0 -1
  31. package/dist/config/schema.d.ts +0 -62
  32. package/dist/config/schema.d.ts.map +0 -1
  33. package/dist/config/schema.js +0 -24
  34. package/dist/config/schema.js.map +0 -1
  35. package/dist/index.d.ts +0 -7
  36. package/dist/index.d.ts.map +0 -1
  37. package/dist/index.js +0 -8
  38. package/dist/index.js.map +0 -1
  39. package/dist/llm/client.d.ts +0 -23
  40. package/dist/llm/client.d.ts.map +0 -1
  41. package/dist/llm/client.js +0 -51
  42. package/dist/llm/client.js.map +0 -1
  43. package/dist/llm/prompt.d.ts +0 -3
  44. package/dist/llm/prompt.d.ts.map +0 -1
  45. package/dist/llm/prompt.js +0 -36
  46. package/dist/llm/prompt.js.map +0 -1
  47. package/dist/scraper/extractors/content.d.ts +0 -32
  48. package/dist/scraper/extractors/content.d.ts.map +0 -1
  49. package/dist/scraper/extractors/content.js +0 -276
  50. package/dist/scraper/extractors/content.js.map +0 -1
  51. package/dist/scraper/extractors/ssr.d.ts +0 -17
  52. package/dist/scraper/extractors/ssr.d.ts.map +0 -1
  53. package/dist/scraper/extractors/ssr.js +0 -162
  54. package/dist/scraper/extractors/ssr.js.map +0 -1
  55. package/dist/scraper/extractors/to-markdown.d.ts +0 -5
  56. package/dist/scraper/extractors/to-markdown.d.ts.map +0 -1
  57. package/dist/scraper/extractors/to-markdown.js +0 -103
  58. package/dist/scraper/extractors/to-markdown.js.map +0 -1
  59. package/dist/scraper/index.d.ts +0 -35
  60. package/dist/scraper/index.d.ts.map +0 -1
  61. package/dist/scraper/index.js +0 -299
  62. package/dist/scraper/index.js.map +0 -1
  63. package/dist/scraper/tiers/tier1-http.d.ts +0 -5
  64. package/dist/scraper/tiers/tier1-http.d.ts.map +0 -1
  65. package/dist/scraper/tiers/tier1-http.js +0 -122
  66. package/dist/scraper/tiers/tier1-http.js.map +0 -1
  67. package/dist/scraper/tiers/tier2-stealth.d.ts +0 -5
  68. package/dist/scraper/tiers/tier2-stealth.d.ts.map +0 -1
  69. package/dist/scraper/tiers/tier2-stealth.js +0 -108
  70. package/dist/scraper/tiers/tier2-stealth.js.map +0 -1
  71. package/dist/scraper/tiers/tier3-browser.d.ts +0 -10
  72. package/dist/scraper/tiers/tier3-browser.d.ts.map +0 -1
  73. package/dist/scraper/tiers/tier3-browser.js +0 -506
  74. package/dist/scraper/tiers/tier3-browser.js.map +0 -1
  75. package/dist/scraper/types.d.ts +0 -161
  76. package/dist/scraper/types.d.ts.map +0 -1
  77. package/dist/scraper/types.js +0 -3
  78. package/dist/scraper/types.js.map +0 -1
  79. package/dist/security/action-validator.d.ts +0 -83
  80. package/dist/security/action-validator.d.ts.map +0 -1
  81. package/dist/security/action-validator.js +0 -36
  82. package/dist/security/action-validator.js.map +0 -1
  83. package/dist/security/url-validator.d.ts +0 -9
  84. package/dist/security/url-validator.d.ts.map +0 -1
  85. package/dist/security/url-validator.js +0 -69
  86. package/dist/security/url-validator.js.map +0 -1
  87. package/dist/types.d.ts +0 -96
  88. package/dist/types.d.ts.map +0 -1
  89. package/dist/types.js +0 -2
  90. package/dist/types.js.map +0 -1
@@ -1,161 +0,0 @@
1
- /**
2
- * Qual tier foi usado para fazer o scrape:
3
- * - "http" → Tier 1: fetch nativo + Cheerio (sem browser, ~100-500ms)
4
- * - "stealth" → Tier 2: got-scraping com TLS fingerprint spoofing (~200-800ms)
5
- * - "browser" → Tier 3: Playwright Chromium (browser completo, fallback final)
6
- */
7
- export type ScrapeTier = "http" | "stealth" | "browser";
8
- /** Resultado interno retornado por cada tier (não exposto ao usuário final) */
9
- export interface TierRawResult {
10
- /** HTML completo da página */
11
- html: string;
12
- /** URL final após redirecionamentos */
13
- finalUrl: string;
14
- /** HTTP status code */
15
- statusCode: number;
16
- /**
17
- * true = conteúdo suficiente (sem loading screen / anti-bot).
18
- * false = deve tentar o próximo tier na cascata.
19
- */
20
- sufficient: boolean;
21
- }
22
- /** Configuração global do Scraper */
23
- export interface ScraperConfig {
24
- /** Timeout padrão em ms. Default: 30_000 */
25
- timeout?: number;
26
- /**
27
- * Forçar uso de um tier específico em todos os scrapes desta instância.
28
- * Pode ser sobrescrito por opção na chamada de `scrape()`.
29
- */
30
- forceTier?: ScrapeTier;
31
- /** Domínios permitidos (whitelist anti-SSRF). Qualquer URL fora da lista é rejeitada. */
32
- allowedDomains?: string[];
33
- /** Domínios bloqueados (blacklist anti-SSRF). */
34
- blockedDomains?: string[];
35
- /** Log detalhado mostrando qual tier foi usado e por quê. Default: false */
36
- verbose?: boolean;
37
- /** Configurações do browser Chromium (Tier 3) */
38
- browserConfig?: {
39
- /** Rodar em modo headless. Default: true */
40
- headless?: boolean;
41
- /**
42
- * Canal do browser instalado no sistema.
43
- * Exemplos: 'chrome', 'chromium', 'msedge'.
44
- * Se omitido, tenta 'chrome' (sistema) e depois playwright-chromium.
45
- */
46
- channel?: string;
47
- /** Caminho explícito para o executável do browser */
48
- executablePath?: string;
49
- };
50
- }
51
- /** Formatos de saída do conteúdo */
52
- export type ContentFormat = "markdown" | "html" | "text";
53
- /** Opções de scraping passadas pelo usuário */
54
- export interface ScrapeOptions {
55
- /** Formatos de saída desejados. Default: ['markdown', 'text'] */
56
- formats?: ContentFormat[];
57
- /** Timeout em ms. Default: 30_000 */
58
- timeout?: number;
59
- /** Só tentar extrair o conteúdo principal (remove nav, footer, ads). Default: true */
60
- onlyMainContent?: boolean;
61
- /** Headers HTTP extras */
62
- headers?: Record<string, string>;
63
- /**
64
- * Forçar uso de um tier específico (ignora a cascata automática).
65
- * - "http" → só HTTP + Cheerio
66
- * - "stealth" → pula HTTP, usa got-scraping diretamente
67
- * - "browser" → vai direto ao Playwright Chromium
68
- */
69
- forceTier?: ScrapeTier;
70
- /** Incluir HTML bruto (antes da extração de conteúdo). Útil para map(). Default: false */
71
- getRawHtml?: boolean;
72
- /** Aguardar esse seletor CSS aparecer e estar visível antes de extrair */
73
- waitForSelector?: string;
74
- /** Interceptar respostas JSON das APIs chamadas pela SPA */
75
- interceptAPIs?: boolean;
76
- }
77
- /** Dados SSR embutidos em tags <script> pelo framework */
78
- export interface SSRData {
79
- /**
80
- * Framework que gerou o dado:
81
- * - "next" → Next.js (#__NEXT_DATA__)
82
- * - "nuxt" → Nuxt 2/3 (window.__NUXT__)
83
- * - "gatsby" → Gatsby (window.___gatsby)
84
- * - "remix" → Remix (window.__remixContext)
85
- * - "sveltekit" → SvelteKit (script[data-sveltekit-fetched] ou window.__SVELTEKIT__)
86
- * - "vue" → Vue SSR (window.__VUE_SSR_CONTEXT__ / window.__VUE_STORE__)
87
- * - "angular" → Angular Universal (script#ng-state)
88
- * - "tanstack" → TanStack Router / Start (window.__TSR_DEHYDRATED__)
89
- * - "generic" → Outros (window.__INITIAL_STATE__, __APP_STATE__, etc.)
90
- */
91
- type: "next" | "nuxt" | "gatsby" | "remix" | "sveltekit" | "vue" | "angular" | "tanstack" | "generic";
92
- /** Objeto JSON extraído */
93
- data: unknown;
94
- }
95
- /** Chamada de API interceptada durante renderização do browser */
96
- export interface InterceptedAPI {
97
- url: string;
98
- method: string;
99
- statusCode: number;
100
- contentType: string;
101
- data: unknown;
102
- }
103
- /** Link descoberto no mapeamento */
104
- export interface MapLink {
105
- url: string;
106
- /** Texto do âncora (innerText do <a>) */
107
- title?: string;
108
- }
109
- /** Opções do mapeamento */
110
- export interface MapOptions {
111
- /** Filtrar/ordenar links por relevância a este termo */
112
- search?: string;
113
- /** Incluir links de subdomínios. Default: true */
114
- includeSubdomains?: boolean;
115
- /** Ignorar query strings (?foo=bar). Default: true */
116
- ignoreQueryParameters?: boolean;
117
- /** Máximo de links a retornar. Default: 500 */
118
- limit?: number;
119
- /** Tier forçado (igual ao scrape) */
120
- forceTier?: ScrapeTier;
121
- }
122
- /** Resultado do mapeamento */
123
- export interface MapResult {
124
- url: string;
125
- links: MapLink[];
126
- tier: ScrapeTier;
127
- durationMs: number;
128
- error?: string;
129
- }
130
- /** Resultado completo do scrape */
131
- export interface ScrapeResult {
132
- /** URL final (após redirecionamentos) */
133
- url: string;
134
- /** HTTP status code */
135
- statusCode: number;
136
- /** Título da página */
137
- title: string;
138
- /** Meta description */
139
- description?: string;
140
- /** Conteúdo em Markdown */
141
- markdown?: string;
142
- /** Conteúdo em HTML limpo */
143
- html?: string;
144
- /** Conteúdo em texto puro */
145
- text?: string;
146
- /** Tier usado para fazer o scrape */
147
- tier: ScrapeTier;
148
- /** Tempo total em ms */
149
- durationMs: number;
150
- /** Links encontrados na página */
151
- links?: string[];
152
- /** HTML bruto (quando getRawHtml: true) */
153
- rawHtml?: string;
154
- /** Dados SSR extraídos (Next.js, Nuxt, etc.) */
155
- ssrData?: SSRData;
156
- /** Chamadas JSON interceptadas durante renderização (só Tier 3) */
157
- interceptedAPIs?: InterceptedAPI[];
158
- /** Motivo de falha, se houver */
159
- error?: string;
160
- }
161
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/scraper/types.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;AAExD,+EAA+E;AAC/E,MAAM,WAAW,aAAa;IAC5B,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,uBAAuB;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,qCAAqC;AACrC,MAAM,WAAW,aAAa;IAC5B,4CAA4C;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,SAAS,CAAC,EAAE,UAAU,CAAC;IAEvB,yFAAyF;IACzF,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAE1B,iDAAiD;IACjD,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAE1B,4EAA4E;IAC5E,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,iDAAiD;IACjD,aAAa,CAAC,EAAE;QACd,4CAA4C;QAC5C,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB;;;;WAIG;QACH,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,qDAAqD;QACrD,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;CACH;AAED,oCAAoC;AACpC,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC;AAEzD,+CAA+C;AAC/C,MAAM,WAAW,aAAa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,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,SAAS,CAAC,EAAE,UAAU,CAAC;CACxB;AAED,8BAA8B;AAC9B,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,OAAO,EAAE,CAAC;IACjB,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,mCAAmC;AACnC,MAAM,WAAW,YAAY;IAC3B,yCAAyC;IACzC,GAAG,EAAE,MAAM,CAAC;IACZ,uBAAuB;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,uBAAuB;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IAGrB,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6BAA6B;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6BAA6B;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IAGd,qCAAqC;IACrC,IAAI,EAAE,UAAU,CAAC;IACjB,wBAAwB;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,kCAAkC;IAClC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IAEjB,2CAA2C;IAC3C,OAAO,CAAC,EAAE,MAAM,CAAC;IAGjB,gDAAgD;IAChD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,mEAAmE;IACnE,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;IAEnC,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
@@ -1,3 +0,0 @@
1
- // ─── Tipos do Scraper ──────────────────────────────────────────────────────
2
- export {};
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/scraper/types.ts"],"names":[],"mappings":"AAAA,8EAA8E"}
@@ -1,83 +0,0 @@
1
- import { z } from "zod";
2
- export declare const actionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
3
- type: z.ZodLiteral<"click">;
4
- selector: z.ZodEffects<z.ZodString, string, string>;
5
- }, "strip", z.ZodTypeAny, {
6
- type: "click";
7
- selector: string;
8
- }, {
9
- type: "click";
10
- selector: string;
11
- }>, z.ZodObject<{
12
- type: z.ZodLiteral<"type">;
13
- selector: z.ZodEffects<z.ZodString, string, string>;
14
- text: z.ZodString;
15
- }, "strip", z.ZodTypeAny, {
16
- type: "type";
17
- text: string;
18
- selector: string;
19
- }, {
20
- type: "type";
21
- text: string;
22
- selector: string;
23
- }>, z.ZodObject<{
24
- type: z.ZodLiteral<"goto">;
25
- url: z.ZodString;
26
- }, "strip", z.ZodTypeAny, {
27
- type: "goto";
28
- url: string;
29
- }, {
30
- type: "goto";
31
- url: string;
32
- }>, z.ZodObject<{
33
- type: z.ZodLiteral<"wait">;
34
- ms: z.ZodNumber;
35
- }, "strip", z.ZodTypeAny, {
36
- type: "wait";
37
- ms: number;
38
- }, {
39
- type: "wait";
40
- ms: number;
41
- }>, z.ZodObject<{
42
- type: z.ZodLiteral<"scroll">;
43
- direction: z.ZodEnum<["up", "down"]>;
44
- }, "strip", z.ZodTypeAny, {
45
- type: "scroll";
46
- direction: "up" | "down";
47
- }, {
48
- type: "scroll";
49
- direction: "up" | "down";
50
- }>, z.ZodObject<{
51
- type: z.ZodLiteral<"done">;
52
- result: z.ZodString;
53
- }, "strip", z.ZodTypeAny, {
54
- type: "done";
55
- result: string;
56
- }, {
57
- type: "done";
58
- result: string;
59
- }>]>;
60
- export declare class ActionValidationError extends Error {
61
- constructor(message: string);
62
- }
63
- export declare function validateAction(raw: unknown): {
64
- type: "click";
65
- selector: string;
66
- } | {
67
- type: "type";
68
- text: string;
69
- selector: string;
70
- } | {
71
- type: "goto";
72
- url: string;
73
- } | {
74
- type: "wait";
75
- ms: number;
76
- } | {
77
- type: "scroll";
78
- direction: "up" | "down";
79
- } | {
80
- type: "done";
81
- result: string;
82
- };
83
- //# sourceMappingURL=action-validator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"action-validator.d.ts","sourceRoot":"","sources":["../../src/security/action-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAiBvB,CAAC;AAEH,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,OAAO,EAAE,MAAM;CAI5B;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO;;;;;;;;;;;;;;;;;;;EAQ1C"}
@@ -1,36 +0,0 @@
1
- import { z } from "zod";
2
- import { DEFAULTS } from "../config/defaults.js";
3
- const SELECTOR_BLACKLIST = [/javascript:/i, /on\w+\s*=/i, /<script/i];
4
- const selectorSchema = z.string().trim().min(1, "Selector must not be empty or whitespace-only").refine((s) => !SELECTOR_BLACKLIST.some((pattern) => pattern.test(s)), "Selector contains forbidden pattern");
5
- export const actionSchema = z.discriminatedUnion("type", [
6
- z.object({ type: z.literal("click"), selector: selectorSchema }),
7
- z.object({
8
- type: z.literal("type"),
9
- selector: selectorSchema,
10
- text: z.string().max(DEFAULTS.maxTypeLength),
11
- }),
12
- z.object({ type: z.literal("goto"), url: z.string().url() }),
13
- z.object({
14
- type: z.literal("wait"),
15
- ms: z.number().int().positive().max(DEFAULTS.maxWaitMs),
16
- }),
17
- z.object({
18
- type: z.literal("scroll"),
19
- direction: z.enum(["up", "down"]),
20
- }),
21
- z.object({ type: z.literal("done"), result: z.string() }),
22
- ]);
23
- export class ActionValidationError extends Error {
24
- constructor(message) {
25
- super(message);
26
- this.name = "ActionValidationError";
27
- }
28
- }
29
- export function validateAction(raw) {
30
- const result = actionSchema.safeParse(raw);
31
- if (!result.success) {
32
- throw new ActionValidationError(`Invalid action: ${result.error.issues.map((i) => i.message).join(", ")}`);
33
- }
34
- return result.data;
35
- }
36
- //# sourceMappingURL=action-validator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"action-validator.js","sourceRoot":"","sources":["../../src/security/action-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,MAAM,kBAAkB,GAAG,CAAC,cAAc,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;AAEtE,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,+CAA+C,CAAC,CAAC,MAAM,CACrG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAC7D,qCAAqC,CACtC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE;IACvD,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC;IAChE,CAAC,CAAC,MAAM,CAAC;QACP,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;QACvB,QAAQ,EAAE,cAAc;QACxB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,aAAa,CAAC;KAC7C,CAAC;IACF,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC;IAC5D,CAAC,CAAC,MAAM,CAAC;QACP,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;QACvB,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC;KACxD,CAAC;IACF,CAAC,CAAC,MAAM,CAAC;QACP,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;QACzB,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;KAClC,CAAC;IACF,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;CAC1D,CAAC,CAAC;AAEH,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AAED,MAAM,UAAU,cAAc,CAAC,GAAY;IACzC,MAAM,MAAM,GAAG,YAAY,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC3C,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,qBAAqB,CAC7B,mBAAmB,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC1E,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC"}
@@ -1,9 +0,0 @@
1
- export interface UrlValidationOptions {
2
- allowedDomains?: string[];
3
- blockedDomains?: string[];
4
- }
5
- export declare class UrlValidationError extends Error {
6
- constructor(message: string);
7
- }
8
- export declare function validateUrl(rawUrl: string, options?: UrlValidationOptions): Promise<string>;
9
- //# sourceMappingURL=url-validator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"url-validator.d.ts","sourceRoot":"","sources":["../../src/security/url-validator.ts"],"names":[],"mappings":"AAsBA,MAAM,WAAW,oBAAoB;IACnC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAI5B;AAED,wBAAsB,WAAW,CAC/B,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,MAAM,CAAC,CA2DjB"}
@@ -1,69 +0,0 @@
1
- import { resolve } from "node:dns/promises";
2
- const ALLOWED_PROTOCOLS = new Set(["http:", "https:"]);
3
- const BLOCKED_HOSTS = new Set(["localhost", "[::1]"]);
4
- const PRIVATE_IP_RANGES = [
5
- /^127\./,
6
- /^10\./,
7
- /^192\.168\./,
8
- /^172\.(1[6-9]|2\d|3[01])\./,
9
- /^169\.254\./,
10
- /^0\./,
11
- /^fc00:/i,
12
- /^fe80:/i,
13
- /^::1$/,
14
- ];
15
- function isPrivateIp(ip) {
16
- return PRIVATE_IP_RANGES.some((range) => range.test(ip));
17
- }
18
- export class UrlValidationError extends Error {
19
- constructor(message) {
20
- super(message);
21
- this.name = "UrlValidationError";
22
- }
23
- }
24
- export async function validateUrl(rawUrl, options = {}) {
25
- let parsed;
26
- try {
27
- parsed = new URL(rawUrl);
28
- }
29
- catch {
30
- throw new UrlValidationError(`Invalid URL: ${rawUrl}`);
31
- }
32
- if (!ALLOWED_PROTOCOLS.has(parsed.protocol)) {
33
- throw new UrlValidationError(`Blocked protocol: ${parsed.protocol} — only http and https are allowed`);
34
- }
35
- const hostname = parsed.hostname;
36
- if (BLOCKED_HOSTS.has(hostname)) {
37
- throw new UrlValidationError(`Blocked host: ${hostname}`);
38
- }
39
- if (isPrivateIp(hostname)) {
40
- throw new UrlValidationError(`Blocked private IP: ${hostname}`);
41
- }
42
- if (options.allowedDomains && options.allowedDomains.length > 0) {
43
- const allowed = options.allowedDomains.some((d) => hostname === d || hostname.endsWith(`.${d}`));
44
- if (!allowed) {
45
- throw new UrlValidationError(`Domain ${hostname} is not in the allowedDomains list`);
46
- }
47
- }
48
- if (options.blockedDomains && options.blockedDomains.length > 0) {
49
- const blocked = options.blockedDomains.some((d) => hostname === d || hostname.endsWith(`.${d}`));
50
- if (blocked) {
51
- throw new UrlValidationError(`Domain ${hostname} is in the blockedDomains list`);
52
- }
53
- }
54
- try {
55
- const addresses = await resolve(hostname);
56
- for (const addr of addresses) {
57
- if (isPrivateIp(addr)) {
58
- throw new UrlValidationError(`DNS rebinding detected: ${hostname} resolves to private IP ${addr}`);
59
- }
60
- }
61
- }
62
- catch (err) {
63
- if (err instanceof UrlValidationError)
64
- throw err;
65
- // DNS resolution failed — allow the request through, the browser will handle the error
66
- }
67
- return parsed.href;
68
- }
69
- //# sourceMappingURL=url-validator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"url-validator.js","sourceRoot":"","sources":["../../src/security/url-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;AAEvD,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;AAEtD,MAAM,iBAAiB,GAAG;IACxB,QAAQ;IACR,OAAO;IACP,aAAa;IACb,4BAA4B;IAC5B,aAAa;IACb,MAAM;IACN,SAAS;IACT,SAAS;IACT,OAAO;CACR,CAAC;AAEF,SAAS,WAAW,CAAC,EAAU;IAC7B,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAA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AE,CAAC;YACb,MAAM,IAAI,kBAAkB,CAC1B,UAAU,QAAQ,oCAAoC,CACvD,CAAC;QACJ,CAAC;IACH,CAAC;IAED,IAAI,OAAO,CAAC,cAAc,IAAI,OAAO,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChE,MAAM,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC,IAAI,CACzC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,KAAK,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CACpD,CAAC;QACF,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,IAAI,kBAAkB,CAAC,UAAU,QAAQ,gCAAgC,CAAC,CAAC;QACnF,CAAC;IACH,CAAC;IAED,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC1C,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;YAC7B,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;gBACtB,MAAM,IAAI,kBAAkB,CAC1B,2BAA2B,QAAQ,2BAA2B,IAAI,EAAE,CACrE,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,kBAAkB;YAAE,MAAM,GAAG,CAAC;QACjD,uFAAuF;IACzF,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC"}
package/dist/types.d.ts DELETED
@@ -1,96 +0,0 @@
1
- export interface AgentConfig {
2
- llmApiKey: string;
3
- llmBaseUrl?: string;
4
- port?: number;
5
- model?: string;
6
- temperature?: number;
7
- maxTokens?: number;
8
- topP?: number;
9
- frequencyPenalty?: number;
10
- presencePenalty?: number;
11
- maxIterations?: number;
12
- timeoutMs?: number;
13
- maxWaitMs?: number;
14
- gotoTimeoutMs?: number;
15
- allowedDomains?: string[];
16
- blockedDomains?: string[];
17
- }
18
- export interface RunOptions {
19
- url: string;
20
- prompt: string;
21
- }
22
- export type AgentAction = {
23
- type: "click";
24
- selector: string;
25
- } | {
26
- type: "type";
27
- selector: string;
28
- text: string;
29
- } | {
30
- type: "goto";
31
- url: string;
32
- } | {
33
- type: "wait";
34
- ms: number;
35
- } | {
36
- type: "scroll";
37
- direction: "up" | "down";
38
- } | {
39
- type: "done";
40
- result: string;
41
- };
42
- export interface ActionRecord {
43
- action: AgentAction;
44
- iteration: number;
45
- timestamp: number;
46
- }
47
- export type AgentStatus = "done" | "max_iterations" | "error" | "timeout";
48
- /** Método de execução utilizado pelo agente */
49
- export type AgentTier = "http" | "playwright";
50
- export interface LLMUsage {
51
- promptTokens: number;
52
- completionTokens: number;
53
- totalTokens: number;
54
- calls: number;
55
- }
56
- export interface MemoryUsage {
57
- /** RSS do processo do browser Playwright em KB. 0 quando tier="http". */
58
- browserPeakRssKb: number;
59
- /** Heap usado pelo processo Node.js no momento da conclusão (MB) */
60
- nodeHeapUsedMb: number;
61
- }
62
- export interface AgentResult {
63
- status: AgentStatus;
64
- /** Método usado: "http" = Cheerio sem browser | "playwright" = browser completo */
65
- tier: AgentTier;
66
- data: string | null;
67
- report: string;
68
- durationMs: number;
69
- actions: ActionRecord[];
70
- usage: LLMUsage;
71
- memory: MemoryUsage;
72
- error?: string;
73
- }
74
- export interface PageSnapshot {
75
- url: string;
76
- title: string;
77
- text: string;
78
- links: SnapshotLink[];
79
- forms: SnapshotForm[];
80
- }
81
- export interface SnapshotLink {
82
- text: string;
83
- href: string;
84
- index: number;
85
- }
86
- export interface SnapshotForm {
87
- action: string;
88
- inputs: SnapshotInput[];
89
- }
90
- export interface SnapshotInput {
91
- name: string;
92
- type: string;
93
- placeholder: string;
94
- selector: string;
95
- }
96
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;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Aa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB"}
package/dist/types.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}