zan-browser 1.3.38 → 2.0.1

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 (51) hide show
  1. package/dist/ai.d.ts +3 -16
  2. package/dist/ai.d.ts.map +1 -1
  3. package/dist/ai.js +101 -208
  4. package/dist/ai.js.map +1 -1
  5. package/dist/blacklist.d.ts +2 -0
  6. package/dist/blacklist.d.ts.map +1 -0
  7. package/dist/blacklist.js +115 -0
  8. package/dist/blacklist.js.map +1 -0
  9. package/dist/browser-provider.d.ts +81 -0
  10. package/dist/browser-provider.d.ts.map +1 -0
  11. package/dist/browser-provider.js +6 -0
  12. package/dist/browser-provider.js.map +1 -0
  13. package/dist/browser.d.ts +1 -1
  14. package/dist/browser.d.ts.map +1 -1
  15. package/dist/browser.js +57 -59
  16. package/dist/browser.js.map +1 -1
  17. package/dist/index.d.ts +7 -1
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +5 -1
  20. package/dist/index.js.map +1 -1
  21. package/dist/interceptor.d.ts +6 -3
  22. package/dist/interceptor.d.ts.map +1 -1
  23. package/dist/interceptor.js +61 -21
  24. package/dist/interceptor.js.map +1 -1
  25. package/dist/navigator.d.ts +40 -0
  26. package/dist/navigator.d.ts.map +1 -0
  27. package/dist/navigator.js +506 -0
  28. package/dist/navigator.js.map +1 -0
  29. package/dist/observer.d.ts +23 -3
  30. package/dist/observer.d.ts.map +1 -1
  31. package/dist/observer.js +310 -270
  32. package/dist/observer.js.map +1 -1
  33. package/dist/perception.d.ts +42 -0
  34. package/dist/perception.d.ts.map +1 -0
  35. package/dist/perception.js +140 -0
  36. package/dist/perception.js.map +1 -0
  37. package/dist/providers/browserbase.d.ts +12 -0
  38. package/dist/providers/browserbase.d.ts.map +1 -0
  39. package/dist/providers/browserbase.js +226 -0
  40. package/dist/providers/browserbase.js.map +1 -0
  41. package/dist/providers/puppeteer-local.d.ts +5 -0
  42. package/dist/providers/puppeteer-local.d.ts.map +1 -0
  43. package/dist/providers/puppeteer-local.js +218 -0
  44. package/dist/providers/puppeteer-local.js.map +1 -0
  45. package/dist/session.d.ts +17 -23
  46. package/dist/session.d.ts.map +1 -1
  47. package/dist/session.js +123 -407
  48. package/dist/session.js.map +1 -1
  49. package/dist/types.d.ts +1 -32
  50. package/dist/types.d.ts.map +1 -1
  51. package/package.json +3 -2
package/dist/ai.d.ts CHANGED
@@ -1,23 +1,10 @@
1
- import type { ObserveResult, AgentCompletion, SeedValue, PageLink } from "./types";
1
+ import type { ObserveResult, AgentAction, SeedValue } from "./types";
2
2
  export declare class AIClient {
3
3
  private client;
4
4
  private model;
5
5
  constructor(apiKey: string, model?: string);
6
- decideFromObservation(goal: string, observation: ObserveResult, trajectory: Array<{
7
- role: "assistant" | "user";
8
- content: string;
9
- }>, step: number, maxSteps: number, seedValues?: SeedValue[]): Promise<AgentCompletion>;
10
- decideFromScreenshot(goal: string, screenshotBase64: string, trajectory: Array<{
11
- role: "assistant" | "user";
12
- content: string;
13
- }>, step: number, maxSteps: number, seedValues?: SeedValue[]): Promise<AgentCompletion>;
14
- scrapePageContent(goal: string, pageContent: string, seedValues?: SeedValue[], availableLinks?: PageLink[]): Promise<{
15
- found: boolean;
16
- data: Record<string, unknown> | null;
17
- nextUrl: string | null;
18
- reasoning: string;
19
- }>;
20
- private parseCompletion;
6
+ decideFromObservation(goal: string, observation: ObserveResult, history: string[], seedValues?: SeedValue[]): Promise<AgentAction>;
7
+ decideFromScreenshot(goal: string, screenshotBase64: string, history: string[], seedValues?: SeedValue[]): Promise<AgentAction>;
21
8
  private parseAction;
22
9
  }
23
10
  //# sourceMappingURL=ai.d.ts.map
package/dist/ai.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../src/ai.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAe,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAyDhG,q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,SAAS,EAAE,MAAM,SAAS,CAAC;AAIrE,qBAAa,QAAQ;IACnB,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,KAAK,CAAS;gBAEV,MAAM,EAAE,MAAM,EAAE,KAAK,SAAgB;IAM3C,qBAAqB,CACzB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,aAAa,EAC1B,OAAO,EAAE,MAAM,EAAE,EACjB,UAAU,CAAC,EAAE,SAAS,EAAE,GACvB,OAAO,CAAC,WAAW,CAAC;IAuDjB,oBAAoB,CACxB,IAAI,EAAE,MAAM,EACZ,gBAAgB,EAAE,MAAM,EACxB,OAAO,EAAE,MAAM,EAAE,EACjB,UAAU,CAAC,EAAE,SAAS,EAAE,GACvB,OAAO,CAAC,WAAW,CAAC;IAgEvB,OAAO,CAAC,WAAW;CA2BpB"}
package/dist/ai.js CHANGED
@@ -5,59 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.AIClient = void 0;
7
7
  const sdk_1 = __importDefault(require("@anthropic-ai/sdk"));
8
- const DEFAULT_MODEL = "claude-sonnet-4-6";
9
- const SYSTEM_PROMPT = `You are a precise browser automation agent that interacts with websites through structured commands.
10
- Your role is to:
11
- 1. Analyze the provided webpage elements and structure
12
- 2. Plan actions to accomplish the given task
13
- 3. Respond with valid JSON containing your action and state assessment
14
-
15
- INPUT STRUCTURE:
16
- Elements use this format:
17
- id[:]<element_type attr1="val" attr2="val">text</element_type>
18
- _[:] Non-interactive text context
19
-
20
- IDs: B=button, L=link, I=input, S=select, O=option, F=image, M=misc
21
-
22
- CRITICAL: Never use an ID that is not explicitly shown in the current elements.
23
- CRITICAL: Never invent URLs. Only use hrefs from the elements list.
24
-
25
- RESPONSE FORMAT:
26
- You must ALWAYS respond with valid JSON in this exact format (no markdown, no backticks):
27
- {
28
- "state": {
29
- "previous_goal_status": "success" | "failure" | "unknown",
30
- "previous_goal_eval": "evaluation of whether the previous action achieved its goal",
31
- "page_summary": "brief description of the current page",
32
- "relevant_interactions": [{"id": "B1", "reason": "why this element matters"}],
33
- "memory": "important information to remember across steps",
34
- "next_goal": "what you plan to do next"
35
- },
36
- "action": { ... one of the actions below ... }
37
- }
38
-
39
- ACTIONS (choose exactly one):
40
- - goto: {"type": "goto", "url": "https://...", "reason": "why"} — navigate to URL (ONLY from element hrefs)
41
- - click: {"type": "click", "elementId": "B1", "reason": "why"}
42
- - fill: {"type": "fill", "elementId": "I1", "value": "text", "reason": "why"}
43
- - press_key: {"type": "press_key", "key": "Enter", "reason": "why"}
44
- - scroll_down: {"type": "scroll", "direction": "down", "reason": "why"}
45
- - scroll_up: {"type": "scroll", "direction": "up", "reason": "why"}
46
- - scrape: {"type": "scrape", "reason": "why"} — data is visible on page, extract it
47
- - done: {"type": "done", "reason": "why", "data": {}} — task complete, return extracted data
48
- - impossible: {"type": "impossible", "reason": "why this cannot be done"}
49
-
50
- NAVIGATION & ERROR HANDLING:
51
- - If no suitable elements exist, use scroll or goto to find them
52
- - If stuck, try alternative approaches
53
- - Handle popups/cookies by accepting or closing them
54
- - Use scroll to find elements you are looking for
55
-
56
- TASK COMPLETION:
57
- - Use done action as soon as the task is complete
58
- - Include all relevant data in the done action
59
- - If running out of steps, speed up and use done
60
- - relevant_interactions should have at most 3 items`;
8
+ const DEFAULT_MODEL = "claude-haiku-4-5-20251001";
61
9
  class AIClient {
62
10
  client;
63
11
  model;
@@ -65,189 +13,134 @@ class AIClient {
65
13
  this.client = new sdk_1.default({ apiKey });
66
14
  this.model = model;
67
15
  }
68
- // Decide the next action given the observed DOM state Notte-style prompt
69
- async decideFromObservation(goal, observation, trajectory, step, maxSteps, seedValues) {
16
+ // Decide the next action given the observed DOM state (text first, no screenshot)
17
+ async decideFromObservation(goal, observation, history, seedValues) {
18
+ const historyText = history.length > 0
19
+ ? `\nPREVIOUS STEPS:\n${history.slice(-5).join("\n")}`
20
+ : "";
70
21
  const seedContext = seedValues && seedValues.length > 0
71
22
  ? `\nINPUT VALUES TO USE:\n${seedValues.map(s => `- ${s.paramName} (${s.description}): use "${s.exampleValue}" when filling any relevant input field`).join("\n")}`
72
23
  : "";
73
- const userMessage = `<WEBSITE_CONTENT_BEGIN>
74
- * Current url: ${observation.currentUrl}
75
- * Current page title: ${observation.pageTitle}
76
- * Current step: ${step}/${maxSteps}
24
+ const prompt = `You are controlling a browser to achieve a goal. You are discovering APIs by navigating websites like a real user.
25
+ Decide the SINGLE next action to take based on the current page state.
26
+
27
+ GOAL: ${goal}
28
+ ${historyText}${seedContext}
77
29
 
78
- [Interaction elements and context]
79
- [Start of page]
30
+ CURRENT PAGE STATE:
80
31
  ${observation.text}
81
- [End of page]
82
- <WEBSITE_CONTENT_END>
83
32
 
84
- Given the previous information, start by reflecting on your last action. Then, summarize the current page and list immediately relevant available interactions (max of 3).
85
- Absolutely do not under any circumstance use any id that is not explicitly found in the page.
86
- From there, select your next goal, and in turn, your next action.`;
87
- // Build messages: task first, then trajectory history (last 8), then current observation
88
- const messages = [
89
- { role: "user", content: `TASK: ${goal}${seedContext}` },
90
- { role: "assistant", content: `I'll help you accomplish this task. Let me analyze the page and take the appropriate actions.` },
91
- ];
92
- // Add trajectory history (last 8 steps)
93
- const recentTrajectory = trajectory.slice(-16); // 8 pairs = 16 entries
94
- for (const entry of recentTrajectory) {
95
- messages.push({ role: entry.role, content: entry.content });
96
- }
97
- // Current observation
98
- messages.push({ role: "user", content: userMessage });
99
- const response = await this.client.messages.create({
100
- model: this.model,
101
- max_tokens: 1024,
102
- system: SYSTEM_PROMPT,
103
- messages,
104
- });
105
- const text = response.content[0].type === "text" ? response.content[0].text : "";
106
- return this.parseCompletion(text);
107
- }
108
- async decideFromScreenshot(goal, screenshotBase64, trajectory, step, maxSteps, seedValues) {
109
- const seedContext = seedValues && seedValues.length > 0
110
- ? `\nINPUT VALUES TO USE:\n${seedValues.map(s => `- ${s.paramName} (${s.description}): use "${s.exampleValue}" when filling any relevant input field`).join("\n")}`
111
- : "";
112
- const userMessage = `The DOM observer couldn't identify enough elements — you're seeing a screenshot instead.
113
- Current step: ${step}/${maxSteps}
33
+ IMPORTANT RULES:
34
+ - Always dismiss cookie banners first if detected
35
+ - If a modal is open, interact with it first
36
+ - If the page is loading, return a wait action (1000ms)
37
+ - If an AUTOCOMPLETE DROPDOWN IS OPEN, you MUST click the first result using "click" on the relevant element
38
+ - If SEED VALUE FOUND IN NETWORK RESPONSES, return "done" immediately the target API is captured
39
+ - Take the MINIMUM actions needed stop as soon as the goal is achievable
40
+ - If INPUT VALUES are provided above, use them when filling search boxes or input fields
41
+ - If you see error messages or "no results", the input may be wrong — return "done" to try next value
42
+ - Think like a REAL USER navigating this website, not a programmer
43
+ - If you cannot achieve the goal, return "impossible" with a clear reason
114
44
 
115
- Decide the SINGLE next action. Use the same JSON response format.`;
116
- const messages = [
117
- { role: "user", content: `TASK: ${goal}${seedContext}` },
118
- { role: "assistant", content: `I'll help you accomplish this task. Let me analyze the page and take the appropriate actions.` },
119
- ];
120
- const recentTrajectory = trajectory.slice(-8);
121
- for (const entry of recentTrajectory) {
122
- messages.push({ role: entry.role, content: entry.content });
123
- }
124
- messages.push({
125
- role: "user",
126
- content: [
127
- {
128
- type: "image",
129
- source: {
130
- type: "base64",
131
- media_type: "image/jpeg",
132
- data: screenshotBase64,
133
- },
134
- },
135
- { type: "text", text: userMessage },
136
- ],
137
- });
45
+ Respond with a JSON object (no markdown, no code fences):
46
+ {
47
+ "type": "click" | "fill" | "scroll" | "wait" | "navigate" | "done" | "impossible",
48
+ "elementId": "@B3" (required for click/fill use the element IDs from the page state),
49
+ "value": "text to type" (required for fill),
50
+ "direction": "up" | "down" (required for scroll),
51
+ "amount": 300 (optional for scroll, pixels),
52
+ "ms": 1000 (required for wait),
53
+ "url": "https://..." (required for navigate),
54
+ "reason": "why this action"
55
+ }`;
138
56
  const response = await this.client.messages.create({
139
57
  model: this.model,
140
- max_tokens: 1024,
141
- system: SYSTEM_PROMPT,
142
- messages,
58
+ max_tokens: 300,
59
+ messages: [{ role: "user", content: prompt }],
143
60
  });
144
61
  const text = response.content[0].type === "text" ? response.content[0].text : "";
145
- return this.parseCompletion(text);
62
+ return this.parseAction(text);
146
63
  }
147
- // ─── Intelligent content scrape — Notte-style page understanding ─────────────
148
- async scrapePageContent(goal, pageContent, seedValues, availableLinks) {
149
- const seedContext = seedValues && seedValues.length > 0
150
- ? `\nCONCRETE EXAMPLE INPUTS:\n${seedValues.map((s) => `- ${s.paramName}: "${s.exampleValue}"`).join("\n")}`
64
+ async decideFromScreenshot(goal, screenshotBase64, history, seedValues) {
65
+ const historyText = history.length > 0
66
+ ? `\nPREVIOUS STEPS:\n${history.slice(-3).join("\n")}`
151
67
  : "";
152
- const linksSection = availableLinks && availableLinks.length > 0
153
- ? `\nAVAILABLE LINKS ON THIS PAGE:\n${availableLinks.map((l, i) => `[${i}] ${l.text} ${l.href}`).join("\n")}`
68
+ const seedContext = seedValues && seedValues.length > 0
69
+ ? `\nINPUT VALUES TO USE:\n${seedValues.map(s => `- ${s.paramName} (${s.description}): use "${s.exampleValue}" when filling any relevant input field`).join("\n")}`
154
70
  : "";
155
- const linkInstruction = availableLinks && availableLinks.length > 0
156
- ? "IMPORTANT: Only return a nextUrl that exists in the AVAILABLE LINKS list above do NOT invent or guess URLs."
157
- : "If no, look for links or navigation that would lead to the data and return the most relevant URL to visit next.";
158
- const prompt = `The user wants: ${goal}${seedContext}
71
+ const prompt = `You are controlling a browser to discover APIs by navigating websites.
72
+ The DOM observer couldn't identify enough elementsyou're seeing a screenshot instead.
73
+ Decide the SINGLE next action.
159
74
 
160
- Here is the visible content of a web page:
161
- ${pageContent}
162
- ${linksSection}
75
+ GOAL: ${goal}
76
+ ${historyText}${seedContext}
163
77
 
164
- Does this page contain the data the user is looking for? If yes, extract it as structured JSON.
165
- ${linkInstruction}
78
+ RULES:
79
+ - Think like a real USER navigating this website
80
+ - Take minimum actions needed
81
+ - Return "done" when the goal is achievable
82
+ - If INPUT VALUES are provided, use them for search boxes
83
+ - Return "impossible" if it cannot be done
166
84
 
167
- Respond with JSON only (no markdown):
85
+ Respond with JSON (no markdown, no code fences):
168
86
  {
169
- "found": true or false,
170
- "data": extracted object or null,
171
- "nextUrl": "https://..." or null,
172
- "reasoning": "brief explanation"
87
+ "type": "click" | "fill" | "scroll" | "wait" | "navigate" | "done" | "impossible",
88
+ "elementId": "describe the element visually if no ID available",
89
+ "value": "text to type" (for fill),
90
+ "direction": "up" | "down" (for scroll),
91
+ "ms": 1000 (for wait),
92
+ "url": "https://..." (for navigate),
93
+ "reason": "why"
173
94
  }`;
174
95
  const response = await this.client.messages.create({
175
- model: "claude-sonnet-4-6",
176
- max_tokens: 2000,
177
- messages: [{ role: "user", content: prompt }],
96
+ model: this.model,
97
+ max_tokens: 300,
98
+ messages: [
99
+ {
100
+ role: "user",
101
+ content: [
102
+ {
103
+ type: "image",
104
+ source: {
105
+ type: "base64",
106
+ media_type: "image/jpeg",
107
+ data: screenshotBase64,
108
+ },
109
+ },
110
+ { type: "text", text: prompt },
111
+ ],
112
+ },
113
+ ],
178
114
  });
179
- const text = response.content[0].type === "text" ? response.content[0].text : "{}";
180
- try {
181
- const cleaned = text.replace(/```json\n?/g, "").replace(/```\n?/g, "").trim();
182
- return JSON.parse(cleaned);
183
- }
184
- catch {
185
- return { found: false, data: null, nextUrl: null, reasoning: "failed to parse scrape response" };
186
- }
115
+ const text = response.content[0].type === "text" ? response.content[0].text : "";
116
+ return this.parseAction(text);
187
117
  }
188
118
  // ─── Private ─────────────────────────────────────────────────────────────────
189
- parseCompletion(raw) {
119
+ parseAction(raw) {
190
120
  try {
191
121
  const cleaned = raw.replace(/```json\n?/g, "").replace(/```\n?/g, "").trim();
192
122
  const parsed = JSON.parse(cleaned);
193
- const state = parsed.state ?? {
194
- previous_goal_status: "unknown",
195
- previous_goal_eval: "",
196
- page_summary: "",
197
- relevant_interactions: [],
198
- memory: "",
199
- next_goal: "",
200
- };
201
- const action = this.parseAction(parsed.action ?? parsed);
202
- return { state, action };
123
+ switch (parsed.type) {
124
+ case "click":
125
+ return { type: "click", elementId: parsed.elementId ?? "", reason: parsed.reason ?? "" };
126
+ case "fill":
127
+ return { type: "fill", elementId: parsed.elementId ?? "", value: parsed.value ?? "", reason: parsed.reason ?? "" };
128
+ case "scroll":
129
+ return { type: "scroll", direction: parsed.direction ?? "down", amount: parsed.amount, reason: parsed.reason ?? "" };
130
+ case "wait":
131
+ return { type: "wait", ms: parsed.ms ?? 1000, reason: parsed.reason ?? "" };
132
+ case "navigate":
133
+ return { type: "navigate", url: parsed.url ?? "", reason: parsed.reason ?? "" };
134
+ case "done":
135
+ return { type: "done", reason: parsed.reason ?? "" };
136
+ case "impossible":
137
+ return { type: "impossible", reason: parsed.reason ?? "could not achieve goal" };
138
+ default:
139
+ return { type: "impossible", reason: `unknown action type: ${parsed.type}` };
140
+ }
203
141
  }
204
142
  catch {
205
- return {
206
- state: {
207
- previous_goal_status: "unknown",
208
- previous_goal_eval: "failed to parse response",
209
- page_summary: "",
210
- relevant_interactions: [],
211
- memory: "",
212
- next_goal: "",
213
- },
214
- action: { type: "impossible", reason: `failed to parse AI response: ${raw.slice(0, 100)}` },
215
- };
216
- }
217
- }
218
- parseAction(parsed) {
219
- if (!parsed || typeof parsed !== "object") {
220
- return { type: "impossible", reason: "invalid action object" };
221
- }
222
- const type = parsed.type;
223
- const reason = parsed.reason ?? "";
224
- switch (type) {
225
- case "click":
226
- return { type: "click", elementId: (parsed.elementId ?? parsed.id ?? ""), reason };
227
- case "fill":
228
- return { type: "fill", elementId: (parsed.elementId ?? parsed.id ?? ""), value: (parsed.value ?? ""), reason };
229
- case "scroll":
230
- case "scroll_down":
231
- return { type: "scroll", direction: parsed.direction ?? "down", amount: parsed.amount, reason };
232
- case "scroll_up":
233
- return { type: "scroll", direction: "up", reason };
234
- case "wait":
235
- return { type: "wait", ms: parsed.ms ?? 1000, reason };
236
- case "goto":
237
- case "navigate":
238
- return { type: "navigate", url: (parsed.url ?? ""), reason };
239
- case "press_key":
240
- return { type: "press_key", key: (parsed.key ?? ""), reason };
241
- case "scrape":
242
- return { type: "scrape", reason };
243
- case "screenshot":
244
- return { type: "screenshot", reason: reason || "need visual confirmation" };
245
- case "done":
246
- return { type: "done", reason, data: parsed.data };
247
- case "impossible":
248
- return { type: "impossible", reason: reason || "could not achieve goal" };
249
- default:
250
- return { type: "impossible", reason: `unknown action type: ${type}` };
143
+ return { type: "impossible", reason: `failed to parse AI response: ${raw.slice(0, 100)}` };
251
144
  }
252
145
  }
253
146
  }
package/dist/ai.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ai.js","sourceRoot":"","sources":["../src/ai.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA0C;AAG1C,MAAM,aAAa,GAAG,mBAAmB,CAAC;AAE1C,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oDAmD8B,CAAC;AAErD,MAAa,QAAQ;IACX,MAAM,CAAY;IAClB,KAAK,CAAS;IAEtB,YAAY,MAAc,EAAE,KAAK,GAAG,aAAa;QAC/C,IAAI,CAAC,MAAM,GAAG,IAAI,aAAS,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QACxC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,2EAA2E;IAC3E,KAAK,CAAC,qBAAqB,CACzB,IAAY,EACZ,WAA0B,EAC1B,UAAkE,EAClE,IAAY,EACZ,QAAgB,EAChB,UAAwB;QAExB,MAAM,WAAW,GACf,UAAU,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC;YACjC,CAAC,CAAC,2BAA2B,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,SAAS,KAAK,CAAC,CAAC,WAAW,WAAW,CAAC,CAAC,YAAY,yCAAyC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YACnK,CAAC,CAA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file":"blacklist.d.ts","sourceRoot":"","sources":["../src/blacklist.ts"],"names":[],"mappings":"AA4HA,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAIlD"}
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ // ─── Aggressive domain/URL blacklist ──────────────────────────────────────────
3
+ // Consolidated from test-api + zan-browser patterns.
4
+ // Filters out analytics, tracking, ads, consent, fonts, auth providers, and other noise.
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.isBlacklisted = isBlacklisted;
7
+ const BLACKLISTED_DOMAINS = [
8
+ // Analytics & tracking
9
+ /google-analytics/i,
10
+ /googletagmanager/i,
11
+ /doubleclick/i,
12
+ /googlesyndication/i,
13
+ /googleadservices/i,
14
+ /facebook\.net/i,
15
+ /facebook\.com\/tr/i,
16
+ /hotjar/i,
17
+ /sentry\.io/i,
18
+ /newrelic/i,
19
+ /segment\.io/i,
20
+ /segment\.com/i,
21
+ /amplitude\.com/i,
22
+ /mixpanel\.com/i,
23
+ /heap\.io/i,
24
+ /fullstory\.com/i,
25
+ /clarity\.ms/i,
26
+ /mouseflow\.com/i,
27
+ /crazyegg\.com/i,
28
+ /optimizely\.com/i,
29
+ /branch\.io/i,
30
+ /appsflyer\.com/i,
31
+ /adjust\.com/i,
32
+ // Consent / cookie banners
33
+ /cookielaw/i,
34
+ /onetrust/i,
35
+ /consent/i,
36
+ /optanon/i,
37
+ /cookiebot/i,
38
+ /trustarc/i,
39
+ // Firebase
40
+ /firebaseinstallations/i,
41
+ /firebaseremoteconfig/i,
42
+ /firebase.*config/i,
43
+ // Fonts & maps (not data APIs)
44
+ /fonts\.googleapis/i,
45
+ /fonts\.gstatic/i,
46
+ /maps\.googleapis.*(?:mapsjs|mapConfigs|styles|tiles)/i,
47
+ // Search/algolia (internal, not user data)
48
+ /\.algolia\.net/i,
49
+ // Accessibility overlays
50
+ /userway\.org/i,
51
+ /accessibe\.com/i,
52
+ // Video/streaming infrastructure
53
+ /clipro\.tv/i,
54
+ /blazesdk/i,
55
+ /ivs-device-config\.live-video/i,
56
+ /mux\.com/i,
57
+ // Auth providers (internal)
58
+ /sp\.auth\.adobe\.com/i,
59
+ // ESPN/Disney ad/tracking infra
60
+ /bamgrid\.com/i,
61
+ /espncdn\.com/i,
62
+ /broadband\.espn/i,
63
+ /fastcast\.espn/i,
64
+ /log\.espn/i,
65
+ /dcf\.espn/i,
66
+ /pinpoint\.espn/i,
67
+ // Twitch internal
68
+ /gql\.twitch\.tv/i,
69
+ /twitch\.tv\/gql/i,
70
+ // CDN telemetry
71
+ /cdn-cgi\//i,
72
+ /cloudflareinsights/i,
73
+ // Recaptcha / hcaptcha
74
+ /recaptcha/i,
75
+ /hcaptcha/i,
76
+ // Push notifications
77
+ /onesignal/i,
78
+ /pushwoosh/i,
79
+ // Customer support widgets
80
+ /intercom/i,
81
+ /zendesk/i,
82
+ /drift\.com/i,
83
+ /tawk\.to/i,
84
+ /livechat/i,
85
+ /crisp\.chat/i,
86
+ ];
87
+ const BLACKLISTED_URL_PATTERNS = [
88
+ // Static assets
89
+ /\.(png|jpg|jpeg|gif|svg|ico|woff2?|ttf|eot|css|webp|avif|mp4|mp3|pdf|zip|map)(\?|$)/i,
90
+ // Manifest, favicons, service workers
91
+ /manifest\.json/i,
92
+ /favicon/i,
93
+ /sw\.js/i,
94
+ /service-worker/i,
95
+ /workbox/i,
96
+ // Source maps
97
+ /\.map$/i,
98
+ // Build artifacts
99
+ /\/_next\/static\//i,
100
+ /\/webpack/i,
101
+ /\/chunks\//i,
102
+ // Tracking pixels
103
+ /\/pixel/i,
104
+ /\/beacon/i,
105
+ /\/collect\?/i,
106
+ /\/__utm/i,
107
+ ];
108
+ function isBlacklisted(url) {
109
+ if (BLACKLISTED_DOMAINS.some((pattern) => pattern.test(url)))
110
+ return true;
111
+ if (BLACKLISTED_URL_PATTERNS.some((pattern) => pattern.test(url)))
112
+ return true;
113
+ return false;
114
+ }
115
+ //# sourceMappingURL=blacklist.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blacklist.js","sourceRoot":"","sources":["../src/blacklist.ts"],"names":[],"mappings":";AAAA,iFAAiF;AACjF,qDAAqD;AACrD,yFAAyF;;AA0HzF,sCAIC;AA5HD,MAAM,mBAAmB,GAAG;IAC1B,uBAAuB;IACvB,mBAAmB;IACnB,mBAAmB;IACnB,cAAc;IACd,oBAAoB;IACpB,mBAAmB;IACnB,gBAAgB;IAChB,oBAAoB;IACpB,SAAS;IACT,aAAa;IACb,WAAW;IACX,cAAc;IACd,eAAe;IACf,iBAAiB;IACjB,gBAAgB;IAChB,WAAW;IACX,iBAAiB;IACjB,cAAc;IACd,iBAAiB;IACjB,gBAAgB;IAChB,kBAAkB;IAClB,aAAa;IACb,iBAAiB;IACjB,cAAc;IAEd,2BAA2B;IAC3B,YAAY;IACZ,WAAW;IACX,UAAU;IACV,UAAU;IACV,YAAY;IACZ,WAAW;IAEX,WAAW;IACX,wBAAwB;IACxB,uBAAuB;IACvB,mBAAmB;IAEnB,+BAA+B;IAC/B,oBAAoB;IACpB,iBAAiB;IACjB,uDAAuD;IAEvD,2CAA2C;IAC3C,iBAAiB;IAEjB,yBAAyB;IACzB,eAAe;IACf,iBAAiB;IAEjB,iCAAiC;IACjC,aAAa;IACb,WAAW;IACX,gCAAgC;IAChC,WAAW;IAEX,4BAA4B;IAC5B,uBAAuB;IAEvB,gCAAgC;IAChC,eAAe;IACf,eAAe;IACf,kBAAkB;IAClB,iBAAiB;IACjB,YAAY;IACZ,YAAY;IACZ,iBAAiB;IAEjB,kBAAkB;IAClB,kBAAkB;IAClB,kBAAkB;IAElB,gBAAgB;IAChB,YAAY;IACZ,qBAAqB;IAErB,uBAAuB;IACvB,YAAY;IACZ,WAAW;IAEX,qBAAqB;IACrB,YAAY;IACZ,YAAY;IAEZ,2BAA2B;IAC3B,WAAW;IACX,UAAU;IACV,aAAa;IACb,WAAW;IACX,WAAW;IACX,cAAc;CACf,CAAC;AAEF,MAAM,wBAAwB,GAAG;IAC/B,gBAAgB;IAChB,sFAAsF;IAEtF,sCAAsC;IACtC,iBAAiB;IACjB,UAAU;IACV,SAAS;IACT,iBAAiB;IACjB,UAAU;IAEV,cAAc;IACd,SAAS;IAET,kBAAkB;IAClB,oBAAoB;IACpB,YAAY;IACZ,aAAa;IAEb,kBAAkB;IAClB,UAAU;IACV,WAAW;IACX,cAAc;IACd,UAAU;CACX,CAAC;AAEF,SAAgB,aAAa,CAAC,GAAW;IACvC,IAAI,mBAAmB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAC1E,IAAI,wBAAwB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAC/E,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,81 @@
1
+ export interface ElementHandle {
2
+ click(): Promise<void>;
3
+ boundingBox(): Promise<{
4
+ x: number;
5
+ y: number;
6
+ width: number;
7
+ height: number;
8
+ } | null>;
9
+ }
10
+ export interface PageHandle {
11
+ goto(url: string, options?: {
12
+ waitUntil?: string;
13
+ timeout?: number;
14
+ }): Promise<void>;
15
+ url(): string;
16
+ title(): Promise<string>;
17
+ content(): Promise<string>;
18
+ reload(options?: {
19
+ timeout?: number;
20
+ }): Promise<void>;
21
+ evaluate<T>(fn: (...args: any[]) => T, ...args: any[]): Promise<T>;
22
+ screenshot(options?: {
23
+ type?: "jpeg" | "png";
24
+ quality?: number;
25
+ encoding?: "base64" | "binary";
26
+ }): Promise<Buffer | string>;
27
+ click(selector: string, options?: {
28
+ clickCount?: number;
29
+ }): Promise<void>;
30
+ type(selector: string, text: string, options?: {
31
+ delay?: number;
32
+ }): Promise<void>;
33
+ keyboard: {
34
+ press(key: string): Promise<void>;
35
+ type(text: string, options?: {
36
+ delay?: number;
37
+ }): Promise<void>;
38
+ };
39
+ mouse: {
40
+ click(x: number, y: number): Promise<void>;
41
+ move(x: number, y: number): Promise<void>;
42
+ };
43
+ waitForTimeout(ms: number): Promise<void>;
44
+ waitForSelector(selector: string, options?: {
45
+ timeout?: number;
46
+ visible?: boolean;
47
+ }): Promise<ElementHandle | null>;
48
+ waitForNetworkIdle(options?: {
49
+ timeout?: number;
50
+ idleTime?: number;
51
+ }): Promise<void>;
52
+ $$(selector: string): Promise<ElementHandle[]>;
53
+ setRequestInterception(enabled: boolean): Promise<void>;
54
+ on(event: string, handler: (...args: any[]) => void): void;
55
+ off(event: string, handler: (...args: any[]) => void): void;
56
+ close(): Promise<void>;
57
+ isClosed(): boolean;
58
+ }
59
+ export interface BrowserHandle {
60
+ newPage(): Promise<PageHandle>;
61
+ close(): Promise<void>;
62
+ viewerUrl?: string;
63
+ }
64
+ export interface BrowserProvider {
65
+ launch(config: ProviderConfig): Promise<BrowserHandle>;
66
+ }
67
+ export interface ProviderConfig {
68
+ viewport?: {
69
+ width: number;
70
+ height: number;
71
+ };
72
+ proxy?: {
73
+ server: string;
74
+ username?: string;
75
+ password?: string;
76
+ };
77
+ timeout?: number;
78
+ headless?: boolean;
79
+ }
80
+ export type ProviderType = "puppeteer-local" | "browserbase" | "ws-endpoint";
81
+ //# sourceMappingURL=browser-provider.d.ts.map