zan-browser 3.0.20 → 3.0.22

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.
@@ -0,0 +1,62 @@
1
+ import type { ToolRegistry } from "../registry";
2
+ import type { ToolContext } from "../tools/base";
3
+ import type { AgentResult } from "./agent";
4
+ import type { SeedValue, CapturedRequest } from "../types";
5
+ export interface AttemptRecord {
6
+ agentResult: AgentResult;
7
+ goalGiven: string;
8
+ rejectionReason?: string;
9
+ }
10
+ export interface EndpointAttempt {
11
+ url: string;
12
+ method: string;
13
+ whyFailed: string;
14
+ }
15
+ export interface Rejection {
16
+ source: "validator" | "request-selector" | "external";
17
+ reason: string;
18
+ capturedUrl?: string;
19
+ }
20
+ export interface EndpointResult {
21
+ request: CapturedRequest;
22
+ urlTemplate: string;
23
+ score: number;
24
+ reproducible: boolean;
25
+ whyReproducible: string;
26
+ }
27
+ export interface OrchestratorConfig {
28
+ goal: string;
29
+ seedValues?: SeedValue[];
30
+ maxAttempts?: number;
31
+ maxTotalSteps?: number;
32
+ model?: string;
33
+ onProgress?: (msg: string) => void;
34
+ onAttemptComplete?: (attempt: AttemptRecord) => void;
35
+ }
36
+ export interface OrchestratorResult {
37
+ success: boolean;
38
+ attempts: AttemptRecord[];
39
+ bestEndpoint?: EndpointResult;
40
+ reason: string;
41
+ totalSteps: number;
42
+ totalTime: number;
43
+ }
44
+ export declare class AgentOrchestrator {
45
+ private registry;
46
+ private ctx;
47
+ private model;
48
+ private state;
49
+ constructor(registry: ToolRegistry, ctx: ToolContext, model?: string);
50
+ run(config: OrchestratorConfig): Promise<OrchestratorResult>;
51
+ /** Inject external feedback from the pipeline (validator, request-selector, etc.) */
52
+ injectFeedback(rejection: Rejection): void;
53
+ private buildEnrichedGoal;
54
+ private evaluateResult;
55
+ private buildUrlTemplate;
56
+ private explainReproducibility;
57
+ private diagnoseFailure;
58
+ private extractDomains;
59
+ private recordFailedEndpoints;
60
+ private buildFailureSummary;
61
+ }
62
+ //# sourceMappingURL=orchestrator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../src/agent/orchestrator.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,KAAK,EAAE,WAAW,EAAmB,MAAM,SAAS,CAAC;AAE5D,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAI3D,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,WAAW,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,WAAW,GAAG,kBAAkB,GAAG,UAAU,CAAC;IACtD,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,eAAe,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,CAAC;CACtD;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,YAAY,CAAC,EAAE,cAAc,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAiBD,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAe;IAC/B,OAAO,CAAC,GAAG,CAAc;IACzB,OAAO,CAAC,KAAK,CAAqB;IAClC,OAAO,CAAC,KAAK,CAAoB;gBAErB,QAAQ,EAAE,YAAY,EAAE,GAAG,EAAE,WAAW,EAAE,KAAK,CAAC,EAAE,MAAM;IAgB9D,GAAG,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA4ElE,qFAAqF;IACrF,cAAc,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAM1C,OAAO,CAAC,iBAAiB;IAmEzB,OAAO,CAAC,cAAc;IAmDtB,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,sBAAsB;IAY9B,OAAO,CAAC,eAAe;IAwBvB,OAAO,CAAC,cAAc;IAUtB,OAAO,CAAC,qBAAqB;IAkB7B,OAAO,CAAC,mBAAmB;CAe5B"}
@@ -0,0 +1,288 @@
1
+ "use strict";
2
+ // ─── Agent Orchestrator ──────────────────────────────────────────────────────
3
+ // Meta-reasoning layer that sits BETWEEN attempts. AgentLoop navigates and
4
+ // executes — the orchestrator analyzes results, accumulates context, builds
5
+ // the next goal, and decides when to stop.
6
+ //
7
+ // The core insight: the agent's real goal is not "find data" but "find a
8
+ // reproducible source that works without a browser at runtime". The orchestrator
9
+ // communicates that distinction and feeds back why previous attempts failed.
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.AgentOrchestrator = void 0;
12
+ const agent_1 = require("./agent");
13
+ const conversation_1 = require("./conversation");
14
+ // ─── Orchestrator ────────────────────────────────────────────────────────────
15
+ class AgentOrchestrator {
16
+ registry;
17
+ ctx;
18
+ model;
19
+ state;
20
+ constructor(registry, ctx, model) {
21
+ this.registry = registry;
22
+ this.ctx = ctx;
23
+ this.model = model;
24
+ this.state = {
25
+ attempts: [],
26
+ visitedDomains: new Set(),
27
+ triedEndpoints: new Map(),
28
+ rejections: [],
29
+ originalGoal: "",
30
+ seedValues: [],
31
+ totalStepsUsed: 0,
32
+ startTime: 0,
33
+ };
34
+ }
35
+ async run(config) {
36
+ const maxAttempts = config.maxAttempts ?? 3;
37
+ const maxTotalSteps = config.maxTotalSteps ?? 45;
38
+ const progress = config.onProgress ?? (() => { });
39
+ this.state.originalGoal = config.goal;
40
+ this.state.seedValues = config.seedValues ?? [];
41
+ this.state.startTime = Date.now();
42
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
43
+ const remainingSteps = maxTotalSteps - this.state.totalStepsUsed;
44
+ if (remainingSteps <= 0)
45
+ break;
46
+ const stepsForAttempt = Math.min(Math.ceil(remainingSteps / (maxAttempts - attempt)), remainingSteps);
47
+ progress(`Attempt ${attempt + 1}/${maxAttempts} (${stepsForAttempt} steps budget, ${remainingSteps} remaining)`);
48
+ // 1. Build enriched goal with accumulated context
49
+ const enrichedGoal = this.buildEnrichedGoal();
50
+ // 2. Fresh conversation for each attempt
51
+ const conversation = new conversation_1.ConversationHistory();
52
+ // 3. Create and run AgentLoop
53
+ const agent = new agent_1.AgentLoop(this.registry, this.ctx, this.model, conversation);
54
+ const agentResult = await agent.run({
55
+ goal: enrichedGoal,
56
+ seedValues: config.seedValues,
57
+ maxSteps: stepsForAttempt,
58
+ onProgress: progress,
59
+ });
60
+ // 4. Count steps used
61
+ this.state.totalStepsUsed += agentResult.steps.length;
62
+ // 5. Extract domains visited from steps
63
+ this.extractDomains(agentResult.steps);
64
+ // 6. Evaluate result — is it a reproducible endpoint?
65
+ const endpoint = this.evaluateResult(agentResult);
66
+ const record = {
67
+ agentResult,
68
+ goalGiven: enrichedGoal,
69
+ rejectionReason: endpoint ? undefined : this.diagnoseFailure(agentResult),
70
+ };
71
+ this.state.attempts.push(record);
72
+ config.onAttemptComplete?.(record);
73
+ if (endpoint) {
74
+ progress(`Attempt ${attempt + 1}: found reproducible endpoint → ${endpoint.urlTemplate}`);
75
+ return {
76
+ success: true,
77
+ attempts: this.state.attempts,
78
+ bestEndpoint: endpoint,
79
+ reason: endpoint.whyReproducible,
80
+ totalSteps: this.state.totalStepsUsed,
81
+ totalTime: Date.now() - this.state.startTime,
82
+ };
83
+ }
84
+ progress(`Attempt ${attempt + 1} failed: ${record.rejectionReason}`);
85
+ }
86
+ return {
87
+ success: false,
88
+ attempts: this.state.attempts,
89
+ reason: this.buildFailureSummary(),
90
+ totalSteps: this.state.totalStepsUsed,
91
+ totalTime: Date.now() - this.state.startTime,
92
+ };
93
+ }
94
+ /** Inject external feedback from the pipeline (validator, request-selector, etc.) */
95
+ injectFeedback(rejection) {
96
+ this.state.rejections.push(rejection);
97
+ }
98
+ // ─── Private ───────────────────────────────────────────────────────────────
99
+ buildEnrichedGoal() {
100
+ const lines = [];
101
+ // Core goal
102
+ lines.push(`GOAL: ${this.state.originalGoal}`);
103
+ // What counts as success
104
+ lines.push("");
105
+ lines.push("SUCCESS CRITERIA: Find an HTTP endpoint (API, JSON feed, or structured data URL) " +
106
+ "that can be called directly with fetch/curl — no browser session required at runtime. " +
107
+ "DOM extractions, scraped HTML text, and framework data-transport routes (/_next/data/, " +
108
+ "__data.json) do NOT count. The result must be a reproducible URL with a real HTTP response.");
109
+ // Seed values context
110
+ if (this.state.seedValues.length > 0) {
111
+ lines.push("");
112
+ lines.push("SEED VALUES (use these verbatim when searching/filling):");
113
+ for (const s of this.state.seedValues) {
114
+ lines.push(` • ${s.paramName} (${s.description}): "${s.exampleValue}"`);
115
+ }
116
+ }
117
+ // Previous attempts — what was tried and why it failed
118
+ if (this.state.attempts.length > 0) {
119
+ lines.push("");
120
+ lines.push("PREVIOUS ATTEMPTS (do not repeat these):");
121
+ for (let i = 0; i < this.state.attempts.length; i++) {
122
+ const a = this.state.attempts[i];
123
+ const stepsUsed = a.agentResult.steps.length;
124
+ const endedAt = a.agentResult.finalUrl;
125
+ lines.push(` Attempt ${i + 1}: ${stepsUsed} steps, ended at ${endedAt}`);
126
+ if (a.rejectionReason) {
127
+ lines.push(` Failed because: ${a.rejectionReason}`);
128
+ }
129
+ }
130
+ }
131
+ // Pipeline feedback — specific reasons from downstream
132
+ if (this.state.rejections.length > 0) {
133
+ lines.push("");
134
+ lines.push("PIPELINE FEEDBACK (specific reasons previous results were rejected):");
135
+ for (const r of this.state.rejections) {
136
+ const urlNote = r.capturedUrl ? ` (URL: ${r.capturedUrl})` : "";
137
+ lines.push(` [${r.source}] ${r.reason}${urlNote}`);
138
+ }
139
+ }
140
+ // Domains already explored
141
+ if (this.state.visitedDomains.size > 0) {
142
+ lines.push("");
143
+ lines.push(`DOMAINS ALREADY VISITED: ${[...this.state.visitedDomains].join(", ")}`);
144
+ }
145
+ // Endpoints already tried and failed
146
+ if (this.state.triedEndpoints.size > 0) {
147
+ lines.push("");
148
+ lines.push("ENDPOINTS ALREADY TRIED:");
149
+ for (const [url, ep] of this.state.triedEndpoints) {
150
+ lines.push(` ${ep.method} ${url} → ${ep.whyFailed}`);
151
+ }
152
+ }
153
+ return lines.join("\n");
154
+ }
155
+ evaluateResult(agentResult) {
156
+ const candidates = agentResult.capturedRequests.filter((r) => {
157
+ // Must not be a DOM extraction synthetic
158
+ if (r.isDomExtraction)
159
+ return false;
160
+ // Must have a meaningful score
161
+ if (r.score < 50)
162
+ return false;
163
+ // Must be XHR/fetch, not an asset
164
+ if (r.isAsset)
165
+ return false;
166
+ return true;
167
+ });
168
+ // Also consider requests found via direct fetch_url (agent called fetch_url explicitly)
169
+ const fetchUrlSteps = agentResult.steps.filter((s) => s.toolName === "fetch_url" && s.result.success);
170
+ for (const step of fetchUrlSteps) {
171
+ const url = String(step.params.url ?? "");
172
+ if (!url)
173
+ continue;
174
+ // Check if this URL is already in candidates
175
+ if (candidates.some((c) => c.url === url))
176
+ continue;
177
+ // Check if interceptor captured it with any score
178
+ const allCaptured = this.ctx.interceptor?.getAll() ?? [];
179
+ const match = allCaptured.find((r) => r.url === url && !r.isDomExtraction);
180
+ if (match)
181
+ candidates.push(match);
182
+ }
183
+ // Exclude endpoints that already failed in previous attempts
184
+ const viable = candidates.filter((r) => !this.state.triedEndpoints.has(r.url));
185
+ if (viable.length === 0) {
186
+ // Record failed endpoints for context
187
+ this.recordFailedEndpoints(agentResult);
188
+ return null;
189
+ }
190
+ // Pick the best candidate by score
191
+ viable.sort((a, b) => b.score - a.score);
192
+ const best = viable[0];
193
+ // Build URL template by replacing seed values
194
+ const urlTemplate = this.buildUrlTemplate(best.url);
195
+ return {
196
+ request: best,
197
+ urlTemplate,
198
+ score: best.score,
199
+ reproducible: true,
200
+ whyReproducible: this.explainReproducibility(best),
201
+ };
202
+ }
203
+ buildUrlTemplate(url) {
204
+ let template = url;
205
+ for (const seed of this.state.seedValues) {
206
+ if (template.includes(seed.exampleValue)) {
207
+ template = template.split(seed.exampleValue).join(`{${seed.paramName}}`);
208
+ }
209
+ }
210
+ return template;
211
+ }
212
+ explainReproducibility(req) {
213
+ const parts = [];
214
+ if (req.isXHR)
215
+ parts.push("real XHR/fetch request");
216
+ if (req.contentType?.includes("json"))
217
+ parts.push("returns JSON");
218
+ if (req.score >= 80)
219
+ parts.push("high relevance score");
220
+ if (req.method === "GET")
221
+ parts.push("stateless GET — no session dependency");
222
+ if (req.method === "POST" && req.requestBody)
223
+ parts.push("POST with known payload structure");
224
+ return parts.length > 0
225
+ ? `Reproducible: ${parts.join(", ")}`
226
+ : "Captured as a real network request with structured response";
227
+ }
228
+ diagnoseFailure(agentResult) {
229
+ if (!agentResult.success) {
230
+ return agentResult.reason;
231
+ }
232
+ // Agent said success but we don't agree — explain why
233
+ const captured = agentResult.capturedRequests;
234
+ if (captured.length === 0) {
235
+ return "Agent reported success but no requests were captured — likely found data via DOM extraction only";
236
+ }
237
+ const domOnly = captured.every((r) => r.isDomExtraction);
238
+ if (domOnly) {
239
+ return "All captured data came from DOM extraction (scrape/extract_dom) — not a reproducible API endpoint";
240
+ }
241
+ const lowScore = captured.every((r) => r.score < 50);
242
+ if (lowScore) {
243
+ return `Captured requests have low scores (max: ${Math.max(...captured.map((r) => r.score))}) — likely config/tracking, not data APIs`;
244
+ }
245
+ return "Captured requests did not meet reproducibility criteria";
246
+ }
247
+ extractDomains(steps) {
248
+ for (const s of steps) {
249
+ if ((s.toolName === "navigate" || s.toolName === "fetch_url") && s.params.url) {
250
+ try {
251
+ this.state.visitedDomains.add(new URL(String(s.params.url)).hostname);
252
+ }
253
+ catch { /* ignore invalid URLs */ }
254
+ }
255
+ }
256
+ }
257
+ recordFailedEndpoints(agentResult) {
258
+ // Record fetch_url attempts that didn't produce a good result
259
+ for (const step of agentResult.steps) {
260
+ if (step.toolName === "fetch_url" && step.params.url) {
261
+ const url = String(step.params.url);
262
+ if (!this.state.triedEndpoints.has(url)) {
263
+ this.state.triedEndpoints.set(url, {
264
+ url,
265
+ method: String(step.params.method ?? "GET"),
266
+ whyFailed: step.result.success
267
+ ? "returned data but not structured/useful enough"
268
+ : String(step.result.error ?? "request failed"),
269
+ });
270
+ }
271
+ }
272
+ }
273
+ }
274
+ buildFailureSummary() {
275
+ const parts = [];
276
+ parts.push(`Exhausted ${this.state.attempts.length} attempts (${this.state.totalStepsUsed} total steps)`);
277
+ if (this.state.visitedDomains.size > 0) {
278
+ parts.push(`Visited: ${[...this.state.visitedDomains].join(", ")}`);
279
+ }
280
+ const lastAttempt = this.state.attempts[this.state.attempts.length - 1];
281
+ if (lastAttempt?.rejectionReason) {
282
+ parts.push(`Last failure: ${lastAttempt.rejectionReason}`);
283
+ }
284
+ return parts.join(". ");
285
+ }
286
+ }
287
+ exports.AgentOrchestrator = AgentOrchestrator;
288
+ //# sourceMappingURL=orchestrator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestrator.js","sourceRoot":"","sources":["../../src/agent/orchestrator.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,2EAA2E;AAC3E,4EAA4E;AAC5E,2CAA2C;AAC3C,EAAE;AACF,yEAAyE;AACzE,iFAAiF;AACjF,6EAA6E;;;AAI7E,mCAAoC;AAEpC,iDAAqD;AA+DrD,gFAAgF;AAEhF,MAAa,iBAAiB;IACpB,QAAQ,CAAe;IACvB,GAAG,CAAc;IACjB,KAAK,CAAqB;IAC1B,KAAK,CAAoB;IAEjC,YAAY,QAAsB,EAAE,GAAgB,EAAE,KAAc;QAClE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,KAAK,GAAG;YACX,QAAQ,EAAE,EAAE;YACZ,cAAc,EAAE,IAAI,GAAG,EAAE;YACzB,cAAc,EAAE,IAAI,GAAG,EAAE;YACzB,UAAU,EAAE,EAAE;YACd,YAAY,EAAE,EAAE;YAChB,UAAU,EAAE,EAAE;YACd,cAAc,EAAE,CAAC;YACjB,SAAS,EAAE,CAAC;SACb,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,MAA0B;QAClC,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,CAAC,CAAC;QAC5C,MAAM,aAAa,GAAG,MAAM,CAAC,aAAa,IAAI,EAAE,CAAC;QACjD,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QAEjD,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC;QACtC,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC;QAChD,IAAI,CAA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B,WAAW,CAAC,eAAe,EAAE,CAAC,CAAC;QAC7D,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF;AAxTD,8CAwTC"}
@@ -1 +1 @@
1
- {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/agent/prompt.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhD,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,YAAY,GAAG,MAAM,CAuHhE"}
1
+ {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/agent/prompt.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhD,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,YAAY,GAAG,MAAM,CA8LhE"}
@@ -86,6 +86,72 @@ Before each action, read the PROGRESS SUMMARY appended to every step result and
86
86
  - You decide when to change strategy based on what you see in PROGRESS SUMMARY — there is
87
87
  no fixed step limit forcing you to stop, but be efficient and do not waste steps
88
88
 
89
+ ─── Site Type Recognition & Strategy ──────────────────────────────────────
90
+
91
+ When a site produces no useful XHR traffic after interaction, stop navigating the UI
92
+ and start thinking like a developer inspecting the app:
93
+
94
+ 1. Identify what you're dealing with. Use eval_js to check for framework globals
95
+ (Next.js, Nuxt, React, Angular, etc.) and read any embedded data or config objects.
96
+ The page's JS bundles often contain the API base URLs, endpoint paths, and auth
97
+ patterns the app uses internally.
98
+
99
+ 2. Read the source. Use eval_js to inspect script tags or fetch the app's JS bundles
100
+ via fetch_url. Scan for API endpoint patterns, authorization headers, and request
101
+ construction logic. You're reading code — reason about what you find, don't just
102
+ grep for known strings.
103
+
104
+ 3. Reconstruct the call. Once you identify an internal endpoint, use fetch_url to call
105
+ it directly. Copy the headers, cookies, or tokens the app would send — check
106
+ document.cookie, localStorage, meta tags, or visible config objects in the DOM.
107
+
108
+ 4. Iterate. If the first attempt fails, read the error response and adjust. The app's
109
+ own code already knows how to call this endpoint correctly — your job is to reverse
110
+ what that code does.
111
+
112
+ This approach works because SPAs and SSR apps always fetch their data from somewhere.
113
+ If you can't see it in the network logs, the data was either embedded at build time
114
+ (check eval_js) or the requests were fired before interception started (reconstruct
115
+ and call directly).
116
+
117
+ ─── HTTP Errors Are Information ───────────────────────────────────────────
118
+
119
+ An HTTP error from fetch_url is not a dead end — it's a clue. Treat it like a
120
+ developer debugging a failing curl command:
121
+
122
+ - Read the response body. A 400 almost always tells you which parameter is missing
123
+ or malformed. A 403 may include details about what auth scheme is expected. A 500
124
+ with a stack trace reveals the backend framework and sometimes the expected payload.
125
+
126
+ - Reason about what's missing. Look at other captured requests in read_network_logs
127
+ for headers the site sends (Authorization, X-API-Key, CSRF tokens, session cookies).
128
+ Check the DOM and JS for tokens or config that the app injects at runtime.
129
+
130
+ - Retry with the deduced fix. Add the missing header, adjust the query parameter,
131
+ fix the content type. Each failed attempt narrows the space of what's wrong.
132
+
133
+ The only true dead ends are: CAPTCHA walls, OAuth flows requiring real user credentials,
134
+ and endpoints that require paid API keys. Everything else is solvable with enough
135
+ information from the error response.
136
+
137
+ ─── Anti-Loop: Recognizing and Breaking Stalls ────────────────────────────
138
+
139
+ Before each action, check whether you're making real progress or spinning in place.
140
+
141
+ Signs you're stalled:
142
+ - You've used the same tool repeatedly and the page state or network capture hasn't
143
+ changed meaningfully between uses.
144
+ - You're revisiting pages or re-trying actions you already attempted.
145
+ - Your memory field keeps describing the same situation across multiple steps.
146
+
147
+ When you recognize a stall, stop executing and reason explicitly in your memory about
148
+ why you're stuck and what fundamentally different approach could work. "Different"
149
+ means a different source, a different extraction method, or a different way of finding
150
+ the data — not the same approach with minor variations.
151
+
152
+ The goal is forward motion. If your current path isn't producing new information,
153
+ abandon it and try something structurally different.
154
+
89
155
  ─── Rules ─────────────────────────────────────────────────────────────────────
90
156
 
91
157
  1. On a new page with content, always observe first before interacting.
@@ -108,14 +174,19 @@ Before each action, read the PROGRESS SUMMARY appended to every step result and
108
174
  14. Use "read_network_logs" to check if useful data has already been captured.
109
175
  15. Use "eval_js" to extract SSR data (window.__NEXT_DATA__, etc.).
110
176
  16. Reason like a real user. Click what you can see. Do not invent element IDs.
111
- 17. HTTP 401/403 = IMMEDIATE REJECTION. If any fetch_url or API call returns HTTP 401
112
- or 403, that endpoint requires authentication or an API key you don't have.
113
- Do NOT mark it as data_found. Move on immediately to a different source.
114
- 18. SOURCE PRIORITY prefer public HTML pages over API documentation:
115
- 1. First try public HTML pages that render real data (e.g. flightradar24, avionio,
116
- Wikipedia, government portals). These have data in the HTML use scrape or eval_js.
117
- 2. Only look at API documentation sites as a last resort, and only if the API
118
- has no authentication requirement.
177
+ 17. HTTP 401/403 do NOT mark as data_found. Read the error body, check if the
178
+ missing auth (token, cookie, header) is available in the page context. If you
179
+ can reconstruct the call with correct auth, retry. If it requires credentials
180
+ or a paid API key you genuinely don't have, move on.
181
+ 18. SOURCE PRIORITY choose the extraction method that matches the site:
182
+ 1. Direct API if you know or discover a public endpoint, call it with fetch_url.
183
+ This is always the fastest and cleanest path.
184
+ 2. App internals — if the site is a modern SPA with no useful XHR traffic, read
185
+ its JS bundles and config to find and reconstruct internal API calls.
186
+ 3. SSR embedded data — if the server pre-renders data into the page, extract it
187
+ with eval_js (framework globals, inline JSON, script tags).
188
+ 4. Visible HTML — if the data is only in the rendered markup with no API or
189
+ embedded state, use scrape or extract_dom as a last resort.
119
190
 
120
191
  CRITICAL RESPONSE FORMAT:
121
192
  You MUST respond with a single valid JSON object. Your ENTIRE response must be parseable by JSON.parse().
@@ -1 +1 @@
1
- {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/agent/prompt.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,0EAA0E;AAC1E,6EAA6E;AAC7E,qEAAqE;;AAKrE,8CAuHC;AAzHD,0CAAwD;AAExD,SAAgB,iBAAiB,CAAC,QAAsB;IACtD,MAAM,UAAU,GAAG,QAAQ,CAAC,kBAAkB,EAAE,CAAC;IACjD,MAAM,iBAAiB,GAAG,IAAA,oCAAyB,GAAE,CAAC;IAEtD,OAAO;;;;;;EAMP,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAmCb,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oEAyEoD,CAAC;AACrE,CAAC"}
1
+ {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/agent/prompt.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,0EAA0E;AAC1E,6EAA6E;AAC7E,qEAAqE;;AAKrE,8CA8LC;AAhMD,0CAAwD;AAExD,SAAgB,iBAAiB,CAAC,QAAsB;IACtD,MAAM,UAAU,GAAG,QAAQ,CAAC,kBAAkB,EAAE,CAAC;IACjD,MAAM,iBAAiB,GAAG,IAAA,oCAAyB,GAAE,CAAC;IAEtD,OAAO;;;;;;EAMP,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAmCb,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oEAgJoD,CAAC;AACrE,CAAC"}
package/dist/index.d.ts CHANGED
@@ -2,9 +2,11 @@ export { RensanBrowser } from "./browser";
2
2
  export { Session } from "./session";
3
3
  export { ToolRegistry } from "./registry";
4
4
  export { AgentLoop } from "./agent/agent";
5
+ export { AgentOrchestrator } from "./agent/orchestrator";
5
6
  export type { Tool, ToolContext, ToolResult, JSONSchema } from "./tools/base";
6
7
  export type { AgentConfig, AgentResult, AgentStepRecord } from "./agent/agent";
7
8
  export type { ConversationMessage } from "./agent/conversation";
9
+ export type { OrchestratorConfig, OrchestratorResult, EndpointResult, Rejection, AttemptRecord, } from "./agent/orchestrator";
8
10
  export type { ObservedElement, ObserveResult, CapturedRequest, SeedValue, AgentAction, ActResult, FindDataResult, SessionConfig, AIConfig, BrowserConfig, Screenshot, ElementType, } from "./types";
9
11
  export type { PageHandle, BrowserHandle, BrowserProvider, ProviderType, } from "./browser-provider";
10
12
  export type { Perception, StepContext, StepRecord, } from "./perception";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG1C,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG9E,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC/E,YAAY,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAGhE,YAAY,EACV,eAAe,EACf,aAAa,EACb,eAAe,EACf,SAAS,EACT,WAAW,EACX,SAAS,EACT,cAAc,EACd,aAAa,EACb,QAAQ,EACR,aAAa,EACb,UAAU,EACV,WAAW,GACZ,MAAM,SAAS,CAAC;AAEjB,YAAY,EACV,UAAU,EACV,aAAa,EACb,eAAe,EACf,YAAY,GACb,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EACV,UAAU,EACV,WAAW,EACX,UAAU,GACX,MAAM,cAAc,CAAC;AAEtB,YAAY,EACV,YAAY,EACZ,gBAAgB,GACjB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAGvD,OAAO,EAAE,SAAS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A+B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC"}
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  // ─── Public API ──────────────────────────────────────────────────────────────
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.ReadNetworkLogsTool = exports.DownloadFileTool = exports.FetchUrlTool = exports.WebSearchTool = exports.ExtractDomTool = exports.ScrapeTool = exports.ObserveTool = exports.ScreenshotTool = exports.EvalJsTool = exports.WaitTool = exports.NavigateTool = exports.ScrollTool = exports.FillTool = exports.ClickTool = exports.hasStructuredData = exports.isBlacklisted = exports.AgentLoop = exports.ToolRegistry = exports.Session = exports.RensanBrowser = void 0;
4
+ exports.ReadNetworkLogsTool = exports.DownloadFileTool = exports.FetchUrlTool = exports.WebSearchTool = exports.ExtractDomTool = exports.ScrapeTool = exports.ObserveTool = exports.ScreenshotTool = exports.EvalJsTool = exports.WaitTool = exports.NavigateTool = exports.ScrollTool = exports.FillTool = exports.ClickTool = exports.hasStructuredData = exports.isBlacklisted = exports.AgentOrchestrator = exports.AgentLoop = exports.ToolRegistry = exports.Session = exports.RensanBrowser = void 0;
5
5
  var browser_1 = require("./browser");
6
6
  Object.defineProperty(exports, "RensanBrowser", { enumerable: true, get: function () { return browser_1.RensanBrowser; } });
7
7
  var session_1 = require("./session");
@@ -10,6 +10,8 @@ var registry_1 = require("./registry");
10
10
  Object.defineProperty(exports, "ToolRegistry", { enumerable: true, get: function () { return registry_1.ToolRegistry; } });
11
11
  var agent_1 = require("./agent/agent");
12
12
  Object.defineProperty(exports, "AgentLoop", { enumerable: true, get: function () { return agent_1.AgentLoop; } });
13
+ var orchestrator_1 = require("./agent/orchestrator");
14
+ Object.defineProperty(exports, "AgentOrchestrator", { enumerable: true, get: function () { return orchestrator_1.AgentOrchestrator; } });
13
15
  var blacklist_1 = require("./blacklist");
14
16
  Object.defineProperty(exports, "isBlacklisted", { enumerable: true, get: function () { return blacklist_1.isBlacklisted; } });
15
17
  var validation_1 = require("./agent/validation");
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,gFAAgF;;;AAEhF,qCAA0C;AAAjC,wGAAA,aAAa,OAAA;AACtB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,uCAA0C;AAAjC,wGAAA,YAAY,OAAA;AACrB,uCAA0C;AAAjC,kGAAA,SAAS,OAAA;AA2ClB,yCAA4C;AAAnC,0GAAA,aAAa,OAAA;AACtB,iDAAuD;AAA9C,+GAAA,iBAAiB,OAAA;AAE1B,+EAA+E;AAC/E,+CAAkD;AAAzC,kGAAA,SAAS,OAAA;AAClB,6CAAgD;AAAvC,gGAAA,QAAQ,OAAA;AACjB,iDAAoD;AAA3C,oGAAA,UAAU,OAAA;AACnB,qDAAwD;AAA/C,wGAAA,YAAY,OAAA;AACrB,6CAAgD;AAAvC,gGAAA,QAAQ,OAAA;AACjB,mDAAqD;AAA5C,qGAAA,UAAU,OAAA;AACnB,yDAA4D;AAAnD,4GAAA,cAAc,OAAA;AACvB,gDAAmD;AAA1C,sGAAA,WAAW,OAAA;AACpB,8CAAiD;AAAxC,oGAAA,UAAU,OAAA;AACnB,wDAA0D;AAAjD,6GAAA,cAAc,OAAA;AACvB,yDAA2D;AAAlD,2GAAA,aAAa,OAAA;AACtB,uDAAyD;AAAhD,yGAAA,YAAY,OAAA;AACrB,+DAAiE;AAAxD,iHAAA,gBAAgB,OAAA;AACzB,uEAAwE;AAA/D,wHAAA,mBAAmB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,gFAAgF;;;AAEhF,qCAA0C;AAAjC,wGAAA,aAAa,OAAA;AACtB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,uCAA0C;AAAjC,wGAAA,YAAY,OAAA;AACrB,uCAA0C;AAAjC,kGAAA,SAAS,OAAA;AAClB,qDAAyD;AAAhD,iHAAA,iBAAiB,OAAA;AAkD1B,yCAA4C;AAAnC,0GAAA,aAAa,OAAA;AACtB,iDAAuD;AAA9C,+GAAA,iBAAiB,OAAA;AAE1B,+EAA+E;AAC/E,+CAAkD;AAAzC,kGAAA,SAAS,OAAA;AAClB,6CAAgD;AAAvC,gGAAA,QAAQ,OAAA;AACjB,iDAAoD;AAA3C,oGAAA,UAAU,OAAA;AACnB,qDAAwD;AAA/C,wGAAA,YAAY,OAAA;AACrB,6CAAgD;AAAvC,gGAAA,QAAQ,OAAA;AACjB,mDAAqD;AAA5C,qGAAA,UAAU,OAAA;AACnB,yDAA4D;AAAnD,4GAAA,cAAc,OAAA;AACvB,gDAAmD;AAA1C,sGAAA,WAAW,OAAA;AACpB,8CAAiD;AAAxC,oGAAA,UAAU,OAAA;AACnB,wDAA0D;AAAjD,6GAAA,cAAc,OAAA;AACvB,yDAA2D;AAAlD,2GAAA,aAAa,OAAA;AACtB,uDAAyD;AAAhD,yGAAA,YAAY,OAAA;AACrB,+DAAiE;AAAxD,iHAAA,gBAAgB,OAAA;AACzB,uEAAwE;AAA/D,wHAAA,mBAAmB,OAAA"}
package/dist/session.d.ts CHANGED
@@ -3,6 +3,7 @@ import type { Screenshot, CapturedRequest } from "./types";
3
3
  import { ToolRegistry } from "./registry";
4
4
  import type { ToolContext } from "./tools/base";
5
5
  import type { AgentConfig, AgentResult } from "./agent/agent";
6
+ import { AgentOrchestrator } from "./agent/orchestrator";
6
7
  export declare class Session {
7
8
  private page;
8
9
  private browserHandle;
@@ -23,6 +24,7 @@ export declare class Session {
23
24
  getCapturedRequests(): CapturedRequest[];
24
25
  getUsefulRequests(minScore?: number): CapturedRequest[];
25
26
  act(goal: string, config?: Partial<AgentConfig>): Promise<AgentResult>;
27
+ createOrchestrator(model?: string): AgentOrchestrator;
26
28
  /** Reset conversation history. Page, interceptor, and browser stay intact. */
27
29
  resetConversation(): void;
28
30
  getRegistry(): ToolReg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OAAO,CAAC,EAAE,MAAM;IAiCZ,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAWtE,IAAI,GAAG,IAAI,MAAM,CAEhB;IAIK,UAAU,IAAI,OAAO,CAAC,UAAU,CAAC;IAWvC,mBAAmB,IAAI,eAAe,EAAE;IAIxC,iBAAiB,CAAC,QAAQ,SAAI,GAAG,eAAe,EAAE;IAM5C,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC;IAa5E,kBAAkB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,iBAAiB;IAMrD,8EAA8E;IAC9E,iBAAiB,IAAI,IAAI;IAMzB,WAAW,IAAI,YAAY;IAI3B,cAAc,IAAI,WAAW;IAMvB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAOtB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAO/B,OAAO,CAAC,oBAAoB;CAqB7B"}
package/dist/session.js CHANGED
@@ -8,6 +8,7 @@ const interceptor_1 = require("./interceptor");
8
8
  const observer_1 = require("./observer");
9
9
  const registry_1 = require("./registry");
10
10
  const agent_1 = require("./agent/agent");
11
+ const orchestrator_1 = require("./agent/orchestrator");
11
12
  const conversation_1 = require("./agent/conversation");
12
13
  // ─── Browser tools ───────────────────────────────────────────────────────────
13
14
  const click_1 = require("./tools/browser/click");
@@ -103,6 +104,10 @@ class Session {
103
104
  ...config,
104
105
  });
105
106
  }
107
+ // ─── Orchestrator — multi-attempt with accumulated context ───────────────────
108
+ createOrchestrator(model) {
109
+ return new orchestrator_1.AgentOrchestrator(this.registry, this.ctx, model ?? this.aiModel);
110
+ }
106
111
  // ─── Conversation control ────────────────────────────────────────────────────
107
112
  /** Reset conversation history. Page, interceptor, and browser stay intact. */
108
113
  resetConversation() {
@@ -1 +1 @@
1
- {"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,gFAAgF;AAChF,yEAAyE;;;AAIzE,+CAA4C;AAC5C,yCAAsC;AACtC,yCAA0C;AAE1C,yCAA0C;AAE1C,uDAA2D;AAE3D,gFAAgF;AAChF,iDAAkD;AAClD,+CAAgD;AAChD,mDAAoD;AACpD,uDAAwD;AACxD,+CAAgD;AAChD,qDAAqD;AACrD,2DAA4D;AAE5D,gFAAgF;AAChF,kDAAmD;AACnD,gDAAiD;AACjD,0DAA0D;AAE1D,+EAA+E;AAC/E,2DAA2D;AAC3D,yDAAyD;AACzD,iEAAiE;AACjE,yEAAwE;AAExE,MAAa,OAAO;IACV,IAAI,CAAa;IACjB,aAAa,CAAgB;IAC7B,WAAW,CAAc;IACzB,QAAQ,CAAW;IACnB,QAAQ,CAAe;IACvB,GAAG,CAAc;IACjB,YAAY,CAAsB;IAClC,cAAc,CAAS;IACvB,OAAO,CAAU;IAChB,SAAS,CAAqB;IAEvC,YACE,IAAgB,EAChB,aAA4B,EAC5B,eAAuB,EACvB,OAAO,GAAG,MAAM,EAChB,SAAkB,EAClB,OAAgB;QAEhB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC;QAC9B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,IAAI,CAAC,WAAW,GAAG,IAAI,yBAAW,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,QAAQ,GAAG,IAAI,mBAAQ,CAAC,IAAI,CAAC,CAAC;QAEnC,4CAA4C;QAC5C,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QAEzB,qBAAqB;QACrB,IAAI,CAAC,GAAG,GAAG;YACT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C,QAAQ,CAAC,IAAI,wBAAY,EAAE,CAAC,CAAC;QAC3C,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,gCAAgB,EAAE,CAAC,CAAC;QAC/C,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,uCAAmB,EAAE,CAAC,CAAC;IACpD,CAAC;CACF;AAhKD,0BAgKC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zan-browser",
3
- "version": "3.0.20",
3
+ "version": "3.0.22",
4
4
  "description": "AI-powered cloud browser library with observe-first, screenshot-as-fallback pattern",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",