@jkudish/jev-browser 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.
- package/CHANGELOG.md +14 -0
- package/LICENSE +21 -0
- package/README.md +206 -0
- package/SECURITY.md +17 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +78 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +66 -0
- package/dist/index.js.map +1 -0
- package/dist/lib.d.ts +39 -0
- package/dist/lib.js +117 -0
- package/dist/lib.js.map +1 -0
- package/dist/navigate.d.ts +82 -0
- package/dist/navigate.js +491 -0
- package/dist/navigate.js.map +1 -0
- package/dist/questions.d.ts +19 -0
- package/dist/questions.js +38 -0
- package/dist/questions.js.map +1 -0
- package/package.json +65 -0
- package/scripts/ensure-chromium.mjs +19 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export interface NavigateOptions {
|
|
2
|
+
task: string;
|
|
3
|
+
startUrl: string;
|
|
4
|
+
maxSteps?: number;
|
|
5
|
+
maxSeconds?: number;
|
|
6
|
+
allowTyping?: boolean;
|
|
7
|
+
format?: "text" | "markdown" | "html" | "aria";
|
|
8
|
+
maxChars?: number;
|
|
9
|
+
screenshot?: "final" | "none";
|
|
10
|
+
}
|
|
11
|
+
export interface StepRecord {
|
|
12
|
+
step: number;
|
|
13
|
+
proposed_action: string;
|
|
14
|
+
executed_action: string | null;
|
|
15
|
+
detail: string;
|
|
16
|
+
recovery_reason?: string;
|
|
17
|
+
action_error?: string;
|
|
18
|
+
outcome: string;
|
|
19
|
+
confidence: number | null;
|
|
20
|
+
top_probability: number | null;
|
|
21
|
+
goal_done: number;
|
|
22
|
+
stuck: number;
|
|
23
|
+
}
|
|
24
|
+
export interface ConsoleEvent {
|
|
25
|
+
step: number;
|
|
26
|
+
type: "console_error" | "console_warning" | "page_error" | "request_failed";
|
|
27
|
+
text: string;
|
|
28
|
+
page: string;
|
|
29
|
+
}
|
|
30
|
+
export interface JevUsage {
|
|
31
|
+
jev_calls: number;
|
|
32
|
+
input_tokens: number;
|
|
33
|
+
output_tokens: number;
|
|
34
|
+
est_cost_usd: number;
|
|
35
|
+
}
|
|
36
|
+
export declare function navigate(options: NavigateOptions, externalSignal?: AbortSignal): Promise<{
|
|
37
|
+
status: string;
|
|
38
|
+
final_url: string;
|
|
39
|
+
final_title: string;
|
|
40
|
+
format: "text" | "markdown" | "html" | "aria";
|
|
41
|
+
max_chars: number;
|
|
42
|
+
page: {
|
|
43
|
+
truncated: boolean;
|
|
44
|
+
true_length: number;
|
|
45
|
+
content: string;
|
|
46
|
+
} | null;
|
|
47
|
+
extraction_problems: string[] | undefined;
|
|
48
|
+
steps: StepRecord[];
|
|
49
|
+
console_events: ConsoleEvent[];
|
|
50
|
+
console_events_dropped: number;
|
|
51
|
+
usage: {
|
|
52
|
+
jev_calls: number;
|
|
53
|
+
input_tokens: number;
|
|
54
|
+
output_tokens: number;
|
|
55
|
+
est_cost_usd: number;
|
|
56
|
+
};
|
|
57
|
+
elapsed_ms: number;
|
|
58
|
+
model: string;
|
|
59
|
+
screenshot_base64_jpeg: string | null;
|
|
60
|
+
error?: undefined;
|
|
61
|
+
} | {
|
|
62
|
+
status: string;
|
|
63
|
+
error: string;
|
|
64
|
+
steps: StepRecord[];
|
|
65
|
+
console_events: ConsoleEvent[];
|
|
66
|
+
console_events_dropped: number;
|
|
67
|
+
usage: {
|
|
68
|
+
jev_calls: number;
|
|
69
|
+
input_tokens: number;
|
|
70
|
+
output_tokens: number;
|
|
71
|
+
est_cost_usd: number;
|
|
72
|
+
};
|
|
73
|
+
elapsed_ms: number;
|
|
74
|
+
model: string;
|
|
75
|
+
final_url?: undefined;
|
|
76
|
+
final_title?: undefined;
|
|
77
|
+
format?: undefined;
|
|
78
|
+
max_chars?: undefined;
|
|
79
|
+
page?: undefined;
|
|
80
|
+
extraction_problems?: undefined;
|
|
81
|
+
screenshot_base64_jpeg?: undefined;
|
|
82
|
+
}>;
|
package/dist/navigate.js
ADDED
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
// The navigation loop. Code owns control flow; Jev owns the judgments.
|
|
2
|
+
// Hardening pass applied per external review: stop gates run BEFORE action
|
|
3
|
+
// execution, the deadline is a real AbortSignal threaded through Jev, the
|
|
4
|
+
// typing generator, and every Playwright timeout, usage is per-run, and the
|
|
5
|
+
// final payload/screenshot extraction is best-effort.
|
|
6
|
+
import { chromium } from "playwright";
|
|
7
|
+
import { generateText } from "ai";
|
|
8
|
+
import { createOpenAI } from "@ai-sdk/openai";
|
|
9
|
+
import { createAnthropic } from "@ai-sdk/anthropic";
|
|
10
|
+
import { createGoogleGenerativeAI } from "@ai-sdk/google";
|
|
11
|
+
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
|
|
12
|
+
import { TypeSafeClient } from "@typesafe-ai/sdk";
|
|
13
|
+
import TurndownService from "turndown";
|
|
14
|
+
import * as gfm from "turndown-plugin-gfm";
|
|
15
|
+
import { buildActionSpace, buildCriteria, heuristicQuery, pickAlternate, PRICE_PER_MTOK_IN, selectorFor, } from "./lib.js";
|
|
16
|
+
import { selectOptionQuestion, stepQuestions } from "./questions.js";
|
|
17
|
+
const MODEL = process.env.JEV_BROWSER_MODEL ?? "jev-latest";
|
|
18
|
+
const MAX_CONSOLE_EVENTS = 200;
|
|
19
|
+
const STATE_EXCERPT_CHARS = 1_500;
|
|
20
|
+
const DEFAULT_CAPS = {
|
|
21
|
+
text: 8_000,
|
|
22
|
+
markdown: 16_000,
|
|
23
|
+
html: 1_000_000,
|
|
24
|
+
aria: 16_000,
|
|
25
|
+
};
|
|
26
|
+
const turndown = new TurndownService({ headingStyle: "atx", codeBlockStyle: "fenced" });
|
|
27
|
+
turndown.use(gfm.gfm);
|
|
28
|
+
// Lazy so a missing API key produces a structured error from a call, not a
|
|
29
|
+
// server that never starts.
|
|
30
|
+
let jevClient = null;
|
|
31
|
+
function jev() {
|
|
32
|
+
jevClient ??= new TypeSafeClient();
|
|
33
|
+
return jevClient;
|
|
34
|
+
}
|
|
35
|
+
async function askJev(budget, state, questions) {
|
|
36
|
+
const response = await jev().systemOne({ state, questions, model: MODEL }, { signal: budget.signal });
|
|
37
|
+
budget.usage.jev_calls += 1;
|
|
38
|
+
budget.usage.input_tokens += response.usage?.input_tokens ?? 0;
|
|
39
|
+
budget.usage.output_tokens += response.usage?.output_tokens ?? 0;
|
|
40
|
+
budget.usage.est_cost_usd = (budget.usage.input_tokens / 1e6) * PRICE_PER_MTOK_IN;
|
|
41
|
+
return response.answers;
|
|
42
|
+
}
|
|
43
|
+
// ── Typing generator: provider-agnostic via the Vercel AI SDK ────────────────
|
|
44
|
+
function resolveGeneratorModel() {
|
|
45
|
+
const providerEnv = process.env.JEV_BROWSER_TYPE_PROVIDER;
|
|
46
|
+
const modelEnv = process.env.JEV_BROWSER_TYPE_MODEL;
|
|
47
|
+
// An explicit OpenAI-compatible endpoint wins: Ollama, LM Studio, vLLM, proxies.
|
|
48
|
+
const baseUrl = process.env.JEV_BROWSER_TYPE_BASE_URL;
|
|
49
|
+
if (baseUrl) {
|
|
50
|
+
const provider = createOpenAICompatible({
|
|
51
|
+
name: "custom",
|
|
52
|
+
baseURL: baseUrl,
|
|
53
|
+
apiKey: process.env.JEV_BROWSER_TYPE_API_KEY ?? "",
|
|
54
|
+
});
|
|
55
|
+
return { model: provider(modelEnv ?? "gpt-5.6-luna"), label: "compatible-endpoint" };
|
|
56
|
+
}
|
|
57
|
+
const candidates = [
|
|
58
|
+
{
|
|
59
|
+
provider: "openai",
|
|
60
|
+
test: /^sk-/,
|
|
61
|
+
make: (m) => createOpenAI({ apiKey: process.env.OPENAI_API_KEY })(m),
|
|
62
|
+
defaultModel: "gpt-5.6-luna",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
provider: "openrouter",
|
|
66
|
+
test: /^sk-or-/,
|
|
67
|
+
make: (m) => createOpenAICompatible({
|
|
68
|
+
name: "openrouter",
|
|
69
|
+
baseURL: "https://openrouter.ai/api/v1",
|
|
70
|
+
apiKey: process.env.OPENROUTER_API_KEY,
|
|
71
|
+
})(m),
|
|
72
|
+
defaultModel: "openai/gpt-5.6-luna",
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
provider: "anthropic",
|
|
76
|
+
test: /^sk-ant-/,
|
|
77
|
+
make: (m) => createAnthropic({ apiKey: process.env.ANTHROPIC_API_KEY })(m),
|
|
78
|
+
defaultModel: "claude-haiku-4.5",
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
provider: "google",
|
|
82
|
+
test: /^AIza/,
|
|
83
|
+
make: (m) => createGoogleGenerativeAI({ apiKey: (process.env.GOOGLE_GENERATIVE_AI_API_KEY ?? process.env.GEMINI_API_KEY) })(m),
|
|
84
|
+
defaultModel: "gemini-2.5-flash",
|
|
85
|
+
},
|
|
86
|
+
];
|
|
87
|
+
// Explicit provider first, then auto-detection by key shape.
|
|
88
|
+
const ordered = providerEnv
|
|
89
|
+
? [...candidates.filter((c) => c.provider === providerEnv), ...candidates.filter((c) => c.provider !== providerEnv)]
|
|
90
|
+
: candidates;
|
|
91
|
+
for (const candidate of ordered) {
|
|
92
|
+
const key = candidate.provider === "openai"
|
|
93
|
+
? (process.env.OPENAI_API_KEY ?? "")
|
|
94
|
+
: candidate.provider === "openrouter"
|
|
95
|
+
? (process.env.OPENROUTER_API_KEY ?? "")
|
|
96
|
+
: candidate.provider === "anthropic"
|
|
97
|
+
? (process.env.ANTHROPIC_API_KEY ?? "")
|
|
98
|
+
: (process.env.GOOGLE_GENERATIVE_AI_API_KEY ?? process.env.GEMINI_API_KEY ?? "");
|
|
99
|
+
if (key.length > 20 && candidate.test.test(key)) {
|
|
100
|
+
return { model: candidate.make(modelEnv ?? candidate.defaultModel), label: candidate.provider };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
async function generateTextToType(budget, task, elementDescription, url) {
|
|
106
|
+
const generator = resolveGeneratorModel();
|
|
107
|
+
if (!generator)
|
|
108
|
+
return { text: heuristicQuery(task), via: "keyword-heuristic" };
|
|
109
|
+
try {
|
|
110
|
+
const { text } = await generateText({
|
|
111
|
+
model: generator.model,
|
|
112
|
+
prompt: `A browser agent is performing this task: "${task}". It must type into the ${elementDescription} on ${url}. Reply with ONLY the exact text to type (for a search box: a short search query; no quotes, no explanation).`,
|
|
113
|
+
maxOutputTokens: 48,
|
|
114
|
+
abortSignal: budget.signal,
|
|
115
|
+
});
|
|
116
|
+
const cleaned = text.trim().replace(/^["']|["']$/g, "");
|
|
117
|
+
if (cleaned.length === 0)
|
|
118
|
+
throw new Error("empty generation");
|
|
119
|
+
return { text: cleaned, via: generator.label };
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
if (budget.signal.aborted)
|
|
123
|
+
throw error; // deadline/cancellation propagates
|
|
124
|
+
// A bad model id or provider outage must not kill the task; degrade and say so.
|
|
125
|
+
return { text: heuristicQuery(task), via: "keyword-heuristic-after-generator-error" };
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// ── Extraction: DOM-first (a11y trees under-report inputs) ───────────────────
|
|
129
|
+
async function extractAndStamp(page, bounded) {
|
|
130
|
+
return page.evaluate(() => {
|
|
131
|
+
// Clear stamps from previous steps first: elements that dropped out of
|
|
132
|
+
// the candidate list keep their old data-jev-id, which would make
|
|
133
|
+
// selectors match more than one element.
|
|
134
|
+
document.querySelectorAll("[data-jev-id]").forEach((el) => el.removeAttribute("data-jev-id"));
|
|
135
|
+
const SEL = 'a[href], button, input, textarea, select, [role="button"], [role="link"], [role="searchbox"], [role="textbox"]';
|
|
136
|
+
const out = [];
|
|
137
|
+
for (const el of document.querySelectorAll(SEL)) {
|
|
138
|
+
// Cap accepted candidates AFTER filtering so hidden boilerplate at the
|
|
139
|
+
// top of the DOM cannot crowd out usable controls below it.
|
|
140
|
+
if (out.length >= 2000)
|
|
141
|
+
break;
|
|
142
|
+
const rects = el.getClientRects();
|
|
143
|
+
if (!rects.length)
|
|
144
|
+
continue;
|
|
145
|
+
const style = getComputedStyle(el);
|
|
146
|
+
if (style.display === "none" || style.visibility === "hidden")
|
|
147
|
+
continue;
|
|
148
|
+
const tag = el.tagName.toLowerCase();
|
|
149
|
+
const roleAttr = el.getAttribute("role") || "";
|
|
150
|
+
const typeAttr = (el.getAttribute("type") || "").toLowerCase();
|
|
151
|
+
const label = (el.getAttribute("aria-label") ||
|
|
152
|
+
el.getAttribute("placeholder") ||
|
|
153
|
+
el.getAttribute("title") ||
|
|
154
|
+
el.innerText ||
|
|
155
|
+
el.textContent ||
|
|
156
|
+
"")
|
|
157
|
+
.replace(/\s+/g, " ")
|
|
158
|
+
.trim();
|
|
159
|
+
const href = tag === "a" ? el.getAttribute("href") || "" : "";
|
|
160
|
+
const clickable = ["a", "button"].includes(tag) ||
|
|
161
|
+
["button", "link"].includes(roleAttr) ||
|
|
162
|
+
["submit", "button", "checkbox", "radio"].includes(typeAttr);
|
|
163
|
+
const typeable = tag === "textarea" ||
|
|
164
|
+
(tag === "input" && !["submit", "button", "checkbox", "radio", "file", "hidden", "range", "password"].includes(typeAttr)) ||
|
|
165
|
+
["searchbox", "textbox"].includes(roleAttr);
|
|
166
|
+
const selectable = tag === "select";
|
|
167
|
+
if (!clickable && !typeable && !selectable)
|
|
168
|
+
continue;
|
|
169
|
+
const attr = `j${out.length + 1}`;
|
|
170
|
+
el.setAttribute("data-jev-id", attr);
|
|
171
|
+
const options = tag === "select"
|
|
172
|
+
? Array.from(el.options)
|
|
173
|
+
.map((o) => (o.label || o.value || "").trim())
|
|
174
|
+
.filter(Boolean)
|
|
175
|
+
.slice(0, 200)
|
|
176
|
+
: undefined;
|
|
177
|
+
out.push({ attr, tag, role: roleAttr || tag, text: label.slice(0, 80), href, typeAttr, clickable, typeable, selectable, options });
|
|
178
|
+
}
|
|
179
|
+
return out;
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
async function pageObservables(page, bounded) {
|
|
183
|
+
const url = page.url();
|
|
184
|
+
const title = await page.title().catch(() => "");
|
|
185
|
+
const data = await page
|
|
186
|
+
.evaluate(() => ({
|
|
187
|
+
length: document.body?.innerText?.length ?? 0,
|
|
188
|
+
scrollY: window.scrollY,
|
|
189
|
+
excerpt: (document.body?.innerText ?? "").replace(/\s+/g, " ").slice(0, 1500),
|
|
190
|
+
}))
|
|
191
|
+
.catch(() => ({ length: 0, scrollY: 0, excerpt: "" }));
|
|
192
|
+
return { url, title, textLength: data.length, scrollY: data.scrollY, excerpt: data.excerpt };
|
|
193
|
+
}
|
|
194
|
+
async function settle(page, bounded) {
|
|
195
|
+
await page.waitForLoadState("networkidle", { timeout: bounded(3_000) }).catch(() => { });
|
|
196
|
+
await page.waitForTimeout(400);
|
|
197
|
+
}
|
|
198
|
+
// ── The loop ─────────────────────────────────────────────────────────────────
|
|
199
|
+
export async function navigate(options, externalSignal) {
|
|
200
|
+
const { task, startUrl, maxSteps = 24, maxSeconds = 180, allowTyping = true, format = "text", screenshot = "final", } = options;
|
|
201
|
+
const maxChars = options.maxChars ?? DEFAULT_CAPS[format];
|
|
202
|
+
const started = performance.now();
|
|
203
|
+
const deadlineAt = started + maxSeconds * 1000;
|
|
204
|
+
// One abort source per run: the wall-clock deadline, optionally composed
|
|
205
|
+
// with caller cancellation (the MCP layer forwards its signal).
|
|
206
|
+
const controller = new AbortController();
|
|
207
|
+
const deadlineTimer = setTimeout(() => controller.abort(new Error("deadline-exceeded")), maxSeconds * 1000);
|
|
208
|
+
const onExternalAbort = () => controller.abort(new Error("cancelled-by-caller"));
|
|
209
|
+
externalSignal?.addEventListener("abort", onExternalAbort, { once: true });
|
|
210
|
+
if (externalSignal?.aborted)
|
|
211
|
+
controller.abort(new Error("cancelled-by-caller"));
|
|
212
|
+
const budget = {
|
|
213
|
+
usage: { jev_calls: 0, input_tokens: 0, output_tokens: 0, est_cost_usd: 0 },
|
|
214
|
+
signal: controller.signal,
|
|
215
|
+
deadlineAt,
|
|
216
|
+
};
|
|
217
|
+
const remaining = () => Math.max(0, deadlineAt - performance.now());
|
|
218
|
+
const bounded = (cap) => Math.max(250, Math.min(cap, remaining() || 250));
|
|
219
|
+
const steps = [];
|
|
220
|
+
const consoleEvents = [];
|
|
221
|
+
let consoleDropped = 0;
|
|
222
|
+
const currentStep = { n: 0 };
|
|
223
|
+
const extractionProblems = [];
|
|
224
|
+
let browser = null;
|
|
225
|
+
let status = "error";
|
|
226
|
+
const recordEvent = (event) => {
|
|
227
|
+
if (consoleEvents.length >= MAX_CONSOLE_EVENTS) {
|
|
228
|
+
consoleDropped += 1;
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
consoleEvents.push({ ...event, step: currentStep.n });
|
|
232
|
+
};
|
|
233
|
+
const attachPageObservers = (p) => {
|
|
234
|
+
p.on("console", (msg) => {
|
|
235
|
+
const type = msg.type();
|
|
236
|
+
if (type !== "error" && type !== "warning")
|
|
237
|
+
return;
|
|
238
|
+
recordEvent({ type: `console_${type}`, text: msg.text().slice(0, 300), page: p.url().slice(0, 120) });
|
|
239
|
+
});
|
|
240
|
+
p.on("pageerror", (err) => recordEvent({ type: "page_error", text: String(err).slice(0, 300), page: p.url().slice(0, 120) }));
|
|
241
|
+
p.on("requestfailed", (req) => recordEvent({
|
|
242
|
+
type: "request_failed",
|
|
243
|
+
text: `${req.method()} ${req.url().slice(0, 200)} ${req.failure()?.errorText ?? ""}`.slice(0, 300),
|
|
244
|
+
page: p.url().slice(0, 120),
|
|
245
|
+
}));
|
|
246
|
+
};
|
|
247
|
+
try {
|
|
248
|
+
browser = await chromium.launch({ headless: process.env.JEV_BROWSER_HEADED !== "1" });
|
|
249
|
+
const context = await browser.newContext({ viewport: { width: 1024, height: 640 } });
|
|
250
|
+
// No Playwright default (30s) may ever outlive the run budget.
|
|
251
|
+
context.setDefaultTimeout(8_000);
|
|
252
|
+
let page = await context.newPage();
|
|
253
|
+
attachPageObservers(page);
|
|
254
|
+
let pendingPage = null;
|
|
255
|
+
context.on("page", (p) => {
|
|
256
|
+
attachPageObservers(p); // adopted tabs keep producing diagnostics
|
|
257
|
+
pendingPage = p;
|
|
258
|
+
});
|
|
259
|
+
await page.goto(startUrl, { waitUntil: "domcontentloaded", timeout: bounded(30_000) });
|
|
260
|
+
let lastExecuted = null;
|
|
261
|
+
let lastOutcome = null;
|
|
262
|
+
const history = [];
|
|
263
|
+
for (let step = 1; step <= maxSteps; step++) {
|
|
264
|
+
currentStep.n = step;
|
|
265
|
+
if (remaining() <= 0) {
|
|
266
|
+
status = "timeout";
|
|
267
|
+
break;
|
|
268
|
+
}
|
|
269
|
+
const raw = await extractAndStamp(page, bounded);
|
|
270
|
+
const { elements, truncated } = buildActionSpace(raw);
|
|
271
|
+
const observables = await pageObservables(page, bounded);
|
|
272
|
+
// Empty action space is still judged normally: controls-only criteria
|
|
273
|
+
// (scroll/back/done) plus the page excerpt. goal_done can and should
|
|
274
|
+
// fire on terminal pages with no interactive elements.
|
|
275
|
+
const state = {
|
|
276
|
+
task,
|
|
277
|
+
current_page: { url: observables.url, title: observables.title },
|
|
278
|
+
page_text_excerpt: observables.excerpt,
|
|
279
|
+
interactive_elements: elements.map((e) => ({ id: e.id, description: e.description })),
|
|
280
|
+
element_list_truncated: truncated,
|
|
281
|
+
no_interactive_elements: elements.length === 0,
|
|
282
|
+
history,
|
|
283
|
+
};
|
|
284
|
+
const answers = await askJev(budget, state, stepQuestions(buildCriteria(elements)));
|
|
285
|
+
const actionAnswer = answers.action;
|
|
286
|
+
const proposed = actionAnswer.choice;
|
|
287
|
+
const probabilities = actionAnswer.probabilities ?? {};
|
|
288
|
+
const base = {
|
|
289
|
+
step,
|
|
290
|
+
proposed_action: proposed,
|
|
291
|
+
confidence: actionAnswer.confidence ?? null,
|
|
292
|
+
top_probability: probabilities[proposed] ?? null,
|
|
293
|
+
goal_done: answers.goal_done.noul,
|
|
294
|
+
stuck: answers.stuck.noul,
|
|
295
|
+
};
|
|
296
|
+
// Stop gates run BEFORE execution: a watcher that fires on the current
|
|
297
|
+
// state must not be overridden by acting on that state.
|
|
298
|
+
if (proposed === "done") {
|
|
299
|
+
steps.push({ ...base, executed_action: null, detail: "done proposed; not executed", outcome: "agent declared done before acting" });
|
|
300
|
+
status = "done";
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
if (answers.goal_done.noul > 0.85) {
|
|
304
|
+
steps.push({ ...base, executed_action: null, detail: "goal watcher fired; proposed action not executed", outcome: "goal watcher fired before acting" });
|
|
305
|
+
status = "goal_achieved";
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
if (answers.stuck.noul > 0.85 && step > 2) {
|
|
309
|
+
steps.push({ ...base, executed_action: null, detail: "stuck watcher fired; proposed action not executed", outcome: "stuck watcher fired before acting" });
|
|
310
|
+
status = "stuck";
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
// Repeat-no-op recovery: switch to the next-best option from the
|
|
314
|
+
// distribution. No low-confidence override by design: split probability
|
|
315
|
+
// across similar elements is usually several acceptable alternatives.
|
|
316
|
+
let chosen = proposed;
|
|
317
|
+
let recoveryReason;
|
|
318
|
+
if (lastExecuted === proposed && lastOutcome === "no visible change") {
|
|
319
|
+
const alternate = pickAlternate(probabilities, new Set([proposed]));
|
|
320
|
+
if (alternate) {
|
|
321
|
+
chosen = alternate;
|
|
322
|
+
recoveryReason = "repeated action had no effect; switched to next-best option";
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
const element = elements.find((e) => chosen === `click_${e.id}` || chosen === `type_${e.id}` || chosen === `select_${e.id}`);
|
|
326
|
+
let detail = chosen;
|
|
327
|
+
let actionError;
|
|
328
|
+
try {
|
|
329
|
+
if (chosen === "back") {
|
|
330
|
+
const wentBack = await page.goBack({ waitUntil: "domcontentloaded", timeout: bounded(10_000) }).catch(() => null);
|
|
331
|
+
detail = wentBack ? "went back" : "no history to go back to";
|
|
332
|
+
}
|
|
333
|
+
else if (chosen === "scroll_down" || chosen === "scroll_up") {
|
|
334
|
+
await page.evaluate((dir) => window.scrollBy(0, dir * window.innerHeight * 0.8), chosen === "scroll_down" ? 1 : -1);
|
|
335
|
+
detail = chosen;
|
|
336
|
+
}
|
|
337
|
+
else if (!element) {
|
|
338
|
+
actionError = `unknown action ${chosen}`;
|
|
339
|
+
}
|
|
340
|
+
else if (chosen.startsWith("type_")) {
|
|
341
|
+
if (!allowTyping) {
|
|
342
|
+
actionError = "typing disabled by caller";
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
const generated = await generateTextToType(budget, task, element.description, page.url());
|
|
346
|
+
await page.fill(selectorFor(element), generated.text, { timeout: bounded(8_000) });
|
|
347
|
+
await page.press(selectorFor(element), "Enter", { timeout: bounded(8_000) });
|
|
348
|
+
detail = `typed "${generated.text}" via ${generated.via}`;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
else if (chosen.startsWith("select_")) {
|
|
352
|
+
const opts = element.options ?? [];
|
|
353
|
+
if (opts.length === 0) {
|
|
354
|
+
actionError = "select had no options";
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
const optionAnswer = await askJev(budget, { task, page: { url: observables.url, title: observables.title }, dropdown: element.description, options: opts }, { option: selectOptionQuestion(element.description, opts) });
|
|
358
|
+
const pickedIndex = Number(optionAnswer.option.choice.slice(1));
|
|
359
|
+
const label = opts[pickedIndex] ?? opts[0];
|
|
360
|
+
await page.selectOption(selectorFor(element), { label });
|
|
361
|
+
detail = `selected "${label}"`;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
await page.click(selectorFor(element), { timeout: bounded(8_000) });
|
|
366
|
+
detail = element.description;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
catch (error) {
|
|
370
|
+
if (controller.signal.aborted)
|
|
371
|
+
throw error; // deadline/cancellation propagates
|
|
372
|
+
actionError = error.message.slice(0, 160);
|
|
373
|
+
}
|
|
374
|
+
await settle(page, bounded);
|
|
375
|
+
if (pendingPage) {
|
|
376
|
+
page = pendingPage;
|
|
377
|
+
pendingPage = null;
|
|
378
|
+
await settle(page, bounded);
|
|
379
|
+
detail += " (followed new tab)";
|
|
380
|
+
}
|
|
381
|
+
const after = await pageObservables(page, bounded);
|
|
382
|
+
// Execution failures are attributed to the action, not to ambient page
|
|
383
|
+
// changes that happened to occur in the same window.
|
|
384
|
+
const outcome = actionError
|
|
385
|
+
? "action failed"
|
|
386
|
+
: after.url !== observables.url
|
|
387
|
+
? `navigated to ${after.url}`
|
|
388
|
+
: after.title !== observables.title
|
|
389
|
+
? `page changed: "${after.title}"`
|
|
390
|
+
: Math.abs(after.textLength - observables.textLength) > 50
|
|
391
|
+
? "page content changed"
|
|
392
|
+
: Math.abs(after.scrollY - observables.scrollY) > 40
|
|
393
|
+
? "scrolled"
|
|
394
|
+
: "no visible change";
|
|
395
|
+
lastExecuted = chosen;
|
|
396
|
+
lastOutcome = outcome;
|
|
397
|
+
history.push({ step, action: chosen, outcome });
|
|
398
|
+
steps.push({
|
|
399
|
+
...base,
|
|
400
|
+
executed_action: chosen,
|
|
401
|
+
detail,
|
|
402
|
+
recovery_reason: recoveryReason,
|
|
403
|
+
action_error: actionError,
|
|
404
|
+
outcome,
|
|
405
|
+
});
|
|
406
|
+
if (step === maxSteps)
|
|
407
|
+
status = "max_steps";
|
|
408
|
+
}
|
|
409
|
+
const finalObservables = await pageObservables(page, bounded);
|
|
410
|
+
let payload = null;
|
|
411
|
+
let screenshotBase64 = null;
|
|
412
|
+
try {
|
|
413
|
+
payload = await extractPayload(page, format, maxChars, bounded);
|
|
414
|
+
}
|
|
415
|
+
catch (error) {
|
|
416
|
+
extractionProblems.push(`page payload: ${error.message.slice(0, 160)}`);
|
|
417
|
+
}
|
|
418
|
+
if (screenshot === "final") {
|
|
419
|
+
try {
|
|
420
|
+
const buffer = await page.screenshot({ type: "jpeg", quality: 70, timeout: bounded(10_000) });
|
|
421
|
+
screenshotBase64 = buffer.toString("base64");
|
|
422
|
+
}
|
|
423
|
+
catch (error) {
|
|
424
|
+
extractionProblems.push(`screenshot: ${error.message.slice(0, 160)}`);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
return {
|
|
428
|
+
status,
|
|
429
|
+
final_url: finalObservables.url,
|
|
430
|
+
final_title: finalObservables.title,
|
|
431
|
+
format,
|
|
432
|
+
max_chars: maxChars,
|
|
433
|
+
page: payload,
|
|
434
|
+
extraction_problems: extractionProblems.length ? extractionProblems : undefined,
|
|
435
|
+
steps,
|
|
436
|
+
console_events: consoleEvents,
|
|
437
|
+
console_events_dropped: consoleDropped,
|
|
438
|
+
usage: { ...budget.usage },
|
|
439
|
+
elapsed_ms: Math.round(performance.now() - started),
|
|
440
|
+
model: MODEL,
|
|
441
|
+
screenshot_base64_jpeg: screenshotBase64,
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
catch (runError) {
|
|
445
|
+
const aborted = controller.signal.aborted;
|
|
446
|
+
status = aborted && String(runError.message).includes("deadline") ? "timeout" : "error";
|
|
447
|
+
return {
|
|
448
|
+
status,
|
|
449
|
+
error: aborted ? `aborted: ${runError.message}` : runError.message,
|
|
450
|
+
steps,
|
|
451
|
+
console_events: consoleEvents,
|
|
452
|
+
console_events_dropped: consoleDropped,
|
|
453
|
+
usage: { ...budget.usage },
|
|
454
|
+
elapsed_ms: Math.round(performance.now() - started),
|
|
455
|
+
model: MODEL,
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
finally {
|
|
459
|
+
clearTimeout(deadlineTimer);
|
|
460
|
+
externalSignal?.removeEventListener("abort", onExternalAbort);
|
|
461
|
+
await browser?.close().catch(() => { });
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
async function extractPayload(page, format, maxChars, bounded) {
|
|
465
|
+
let content = "";
|
|
466
|
+
if (format === "html") {
|
|
467
|
+
// Strip the extraction stamps so returned HTML matches the page the user
|
|
468
|
+
// would see, not the instrumented one.
|
|
469
|
+
content = await page.evaluate(() => {
|
|
470
|
+
const clone = document.documentElement.cloneNode(true);
|
|
471
|
+
clone.querySelectorAll("[data-jev-id]").forEach((el) => el.removeAttribute("data-jev-id"));
|
|
472
|
+
return clone.outerHTML;
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
else if (format === "aria") {
|
|
476
|
+
content = await page.locator("body").ariaSnapshot({ timeout: bounded(10_000) });
|
|
477
|
+
}
|
|
478
|
+
else if (format === "markdown") {
|
|
479
|
+
const html = await page.evaluate(() => document.body?.innerHTML ?? "");
|
|
480
|
+
content = turndown.turndown(html);
|
|
481
|
+
}
|
|
482
|
+
else {
|
|
483
|
+
content = await page.evaluate(() => document.body?.innerText ?? "");
|
|
484
|
+
}
|
|
485
|
+
return {
|
|
486
|
+
truncated: content.length > maxChars,
|
|
487
|
+
true_length: content.length,
|
|
488
|
+
content: content.slice(0, maxChars),
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
//# sourceMappingURL=navigate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigate.js","sourceRoot":"","sources":["../src/navigate.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,2EAA2E;AAC3E,0EAA0E;AAC1E,4EAA4E;AAC5E,sDAAsD;AACtD,OAAO,EAAE,QAAQ,EAA2B,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,eAAe,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EACL,gBAAgB,EAChB,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AAK,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,CAAC;YAC3F,OAAO,KAAK,CAAC,SAAS,CAAC;QACzB,CAAC,CAAC,CAAC;IACP,CAAC;SAAM,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QAC7B,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAClF,CAAC;SAAM,IAAI,MAAM,KAAK,UAAU,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,IAAI,EAAE,CAAC,CAAC;QACvE,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,IAAI,EAAE,CAAC,CAAC;IACtE,CAAC;IACD,OAAO;QACL,SAAS,EAAE,OAAO,CAAC,MAAM,GAAG,QAAQ;QACpC,WAAW,EAAE,OAAO,CAAC,MAAM;QAC3B,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC;KACpC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The primary Jev call for each step: three independent judgments over the
|
|
3
|
+
* same state. A select action adds one second-stage call for its option (see
|
|
4
|
+
* selectOptionQuestion), so "one call per step" means one primary call.
|
|
5
|
+
* Patterns: fan-out (docs.typesafe.ai/patterns/fan-out.md) — the questions
|
|
6
|
+
* cannot see each other's answers, which is what makes goal_done an honest
|
|
7
|
+
* cross-check on the action Choice rather than a rationalization of it.
|
|
8
|
+
*/
|
|
9
|
+
export declare function stepQuestions(criteria: Record<string, string>): {
|
|
10
|
+
action: import("@typesafe-ai/sdk").ChoiceQuestion<Record<string, string>>;
|
|
11
|
+
goal_done: import("@typesafe-ai/sdk").NoulQuestion;
|
|
12
|
+
stuck: import("@typesafe-ai/sdk").NoulQuestion;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Second stage for native <select> elements, asked only when the step Choice
|
|
16
|
+
* picked select_eN. Option labels are the defined set; Jev picks the value.
|
|
17
|
+
* Two-stage pattern: docs.typesafe.ai (Choice cardinality is bounded at 255).
|
|
18
|
+
*/
|
|
19
|
+
export declare function selectOptionQuestion(elementDescription: string, options: string[]): import("@typesafe-ai/sdk").ChoiceQuestion<Record<string, string>>;
|