auspex 0.1.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 (91) hide show
  1. package/LICENSE +21 -0
  2. package/dist/agent/actions.d.ts +5 -0
  3. package/dist/agent/actions.d.ts.map +1 -0
  4. package/dist/agent/actions.js +26 -0
  5. package/dist/agent/actions.js.map +1 -0
  6. package/dist/agent/agent.d.ts +12 -0
  7. package/dist/agent/agent.d.ts.map +1 -0
  8. package/dist/agent/agent.js +147 -0
  9. package/dist/agent/agent.js.map +1 -0
  10. package/dist/agent/loop.d.ts +6 -0
  11. package/dist/agent/loop.d.ts.map +1 -0
  12. package/dist/agent/loop.js +165 -0
  13. package/dist/agent/loop.js.map +1 -0
  14. package/dist/agent/report.d.ts +3 -0
  15. package/dist/agent/report.d.ts.map +1 -0
  16. package/dist/agent/report.js +90 -0
  17. package/dist/agent/report.js.map +1 -0
  18. package/dist/browser/executor.d.ts +5 -0
  19. package/dist/browser/executor.d.ts.map +1 -0
  20. package/dist/browser/executor.js +33 -0
  21. package/dist/browser/executor.js.map +1 -0
  22. package/dist/browser/snapshot.d.ts +6 -0
  23. package/dist/browser/snapshot.d.ts.map +1 -0
  24. package/dist/browser/snapshot.js +145 -0
  25. package/dist/browser/snapshot.js.map +1 -0
  26. package/dist/config/defaults.d.ts +10 -0
  27. package/dist/config/defaults.d.ts.map +1 -0
  28. package/dist/config/defaults.js +10 -0
  29. package/dist/config/defaults.js.map +1 -0
  30. package/dist/config/schema.d.ts +59 -0
  31. package/dist/config/schema.d.ts.map +1 -0
  32. package/dist/config/schema.js +23 -0
  33. package/dist/config/schema.js.map +1 -0
  34. package/dist/index.d.ts +7 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +8 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/llm/client.d.ts +23 -0
  39. package/dist/llm/client.d.ts.map +1 -0
  40. package/dist/llm/client.js +51 -0
  41. package/dist/llm/client.js.map +1 -0
  42. package/dist/llm/prompt.d.ts +3 -0
  43. package/dist/llm/prompt.d.ts.map +1 -0
  44. package/dist/llm/prompt.js +36 -0
  45. package/dist/llm/prompt.js.map +1 -0
  46. package/dist/scraper/extractors/content.d.ts +22 -0
  47. package/dist/scraper/extractors/content.d.ts.map +1 -0
  48. package/dist/scraper/extractors/content.js +237 -0
  49. package/dist/scraper/extractors/content.js.map +1 -0
  50. package/dist/scraper/extractors/ssr.d.ts +17 -0
  51. package/dist/scraper/extractors/ssr.d.ts.map +1 -0
  52. package/dist/scraper/extractors/ssr.js +162 -0
  53. package/dist/scraper/extractors/ssr.js.map +1 -0
  54. package/dist/scraper/extractors/to-markdown.d.ts +5 -0
  55. package/dist/scraper/extractors/to-markdown.d.ts.map +1 -0
  56. package/dist/scraper/extractors/to-markdown.js +103 -0
  57. package/dist/scraper/extractors/to-markdown.js.map +1 -0
  58. package/dist/scraper/index.d.ts +27 -0
  59. package/dist/scraper/index.d.ts.map +1 -0
  60. package/dist/scraper/index.js +178 -0
  61. package/dist/scraper/index.js.map +1 -0
  62. package/dist/scraper/tiers/tier1-http.d.ts +5 -0
  63. package/dist/scraper/tiers/tier1-http.d.ts.map +1 -0
  64. package/dist/scraper/tiers/tier1-http.js +120 -0
  65. package/dist/scraper/tiers/tier1-http.js.map +1 -0
  66. package/dist/scraper/tiers/tier2-stealth.d.ts +5 -0
  67. package/dist/scraper/tiers/tier2-stealth.d.ts.map +1 -0
  68. package/dist/scraper/tiers/tier2-stealth.js +106 -0
  69. package/dist/scraper/tiers/tier2-stealth.js.map +1 -0
  70. package/dist/scraper/tiers/tier3-browser.d.ts +10 -0
  71. package/dist/scraper/tiers/tier3-browser.d.ts.map +1 -0
  72. package/dist/scraper/tiers/tier3-browser.js +504 -0
  73. package/dist/scraper/tiers/tier3-browser.js.map +1 -0
  74. package/dist/scraper/types.d.ts +130 -0
  75. package/dist/scraper/types.d.ts.map +1 -0
  76. package/dist/scraper/types.js +3 -0
  77. package/dist/scraper/types.js.map +1 -0
  78. package/dist/security/action-validator.d.ts +83 -0
  79. package/dist/security/action-validator.d.ts.map +1 -0
  80. package/dist/security/action-validator.js +36 -0
  81. package/dist/security/action-validator.js.map +1 -0
  82. package/dist/security/url-validator.d.ts +9 -0
  83. package/dist/security/url-validator.d.ts.map +1 -0
  84. package/dist/security/url-validator.js +69 -0
  85. package/dist/security/url-validator.js.map +1 -0
  86. package/dist/types.d.ts +95 -0
  87. package/dist/types.d.ts.map +1 -0
  88. package/dist/types.js +2 -0
  89. package/dist/types.js.map +1 -0
  90. package/package.json +54 -0
  91. package/readme.md +760 -0
@@ -0,0 +1,83 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,36 @@
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
@@ -0,0 +1 @@
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,C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,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"}
@@ -0,0 +1,9 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,69 @@
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
@@ -0,0 +1 @@
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,CAAC,CAAC;AAC3D,CAAC;AAOD,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAc,EACd,UAAgC,EAAE;IAElC,IAAI,MAAW,CAAC;IAChB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,kBAAkB,CAAC,gBAAgB,MAAM,EAAE,CAAC,CAAC;IACzD,CAAC;IAED,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,kBAAkB,CAC1B,qBAAqB,MAAM,CAAC,QAAQ,oCAAoC,CACzE,CAAC;IACJ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C7B,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"}
@@ -0,0 +1,95 @@
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
+ allowedDomains?: string[];
15
+ blockedDomains?: string[];
16
+ }
17
+ export interface RunOptions {
18
+ url: string;
19
+ prompt: string;
20
+ }
21
+ export type AgentAction = {
22
+ type: "click";
23
+ selector: string;
24
+ } | {
25
+ type: "type";
26
+ selector: string;
27
+ text: string;
28
+ } | {
29
+ type: "goto";
30
+ url: string;
31
+ } | {
32
+ type: "wait";
33
+ ms: number;
34
+ } | {
35
+ type: "scroll";
36
+ direction: "up" | "down";
37
+ } | {
38
+ type: "done";
39
+ result: string;
40
+ };
41
+ export interface ActionRecord {
42
+ action: AgentAction;
43
+ iteration: number;
44
+ timestamp: number;
45
+ }
46
+ export type AgentStatus = "done" | "max_iterations" | "error" | "timeout";
47
+ /** Método de execução utilizado pelo agente */
48
+ export type AgentTier = "http" | "playwright";
49
+ export interface LLMUsage {
50
+ promptTokens: number;
51
+ completionTokens: number;
52
+ totalTokens: number;
53
+ calls: number;
54
+ }
55
+ export interface MemoryUsage {
56
+ /** RSS do processo do browser Playwright em KB. 0 quando tier="http". */
57
+ browserPeakRssKb: number;
58
+ /** Heap usado pelo processo Node.js no momento da conclusão (MB) */
59
+ nodeHeapUsedMb: number;
60
+ }
61
+ export interface AgentResult {
62
+ status: AgentStatus;
63
+ /** Método usado: "http" = Cheerio sem browser | "playwright" = browser completo */
64
+ tier: AgentTier;
65
+ data: string | null;
66
+ report: string;
67
+ durationMs: number;
68
+ actions: ActionRecord[];
69
+ usage: LLMUsage;
70
+ memory: MemoryUsage;
71
+ error?: string;
72
+ }
73
+ export interface PageSnapshot {
74
+ url: string;
75
+ title: string;
76
+ text: string;
77
+ links: SnapshotLink[];
78
+ forms: SnapshotForm[];
79
+ }
80
+ export interface SnapshotLink {
81
+ text: string;
82
+ href: string;
83
+ index: number;
84
+ }
85
+ export interface SnapshotForm {
86
+ action: string;
87
+ inputs: SnapshotInput[];
88
+ }
89
+ export interface SnapshotInput {
90
+ name: string;
91
+ type: string;
92
+ placeholder: string;
93
+ selector: string;
94
+ }
95
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,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B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,KAAK,EAAE,QAAQ,CAAC;IAChB,MAAM,EAAE,WAAW,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,KAAK,EAAE,YAAY,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,aAAa,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,aAAa;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 ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "auspex",
3
+ "version": "0.1.0",
4
+ "description": "AI-powered browser agent with tiered scraping — HTTP/Cheerio first, Playwright as fallback",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "files": ["dist", "readme.md"],
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "scripts": {
16
+ "build": "tsc",
17
+ "dev": "tsx src/index.ts",
18
+ "example": "tsx examples/basic.ts",
19
+ "example:scraper": "tsx examples/scraper.ts",
20
+ "install:browser": "playwright install chromium"
21
+ },
22
+ "keywords": [
23
+ "auspex",
24
+ "browser",
25
+ "automation",
26
+ "ai",
27
+ "agent",
28
+ "playwright",
29
+ "scraping",
30
+ "cheerio",
31
+ "llm"
32
+ ],
33
+ "license": "MIT",
34
+ "dependencies": {
35
+ "@mozilla/readability": "^0.5.0",
36
+ "cheerio": "^1.2.0",
37
+ "got-scraping": "^4.0.4",
38
+ "jsdom": "^25.0.1",
39
+ "openai": "^4.77.0",
40
+ "playwright": "^1.49.0",
41
+ "playwright-core": "^1.49.0",
42
+ "turndown": "^7.2.2",
43
+ "turndown-plugin-gfm": "^1.0.2",
44
+ "zod": "^3.24.0"
45
+ },
46
+ "devDependencies": {
47
+ "@types/jsdom": "^21.1.7",
48
+ "@types/node": "^22.10.0",
49
+ "@types/turndown": "^5.0.6",
50
+ "dotenv": "^16.4.0",
51
+ "tsx": "^4.19.0",
52
+ "typescript": "^5.7.0"
53
+ }
54
+ }