rhai-mcp 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/dist/agent.js ADDED
@@ -0,0 +1,542 @@
1
+ import OpenAI from "openai";
2
+ import { config, log, debug } from "./config.js";
3
+ import * as memory from "./memory.js";
4
+ const SYSTEM_PROMPT = `You are Rhai, an autonomous browser operator with persistent memory and the ability to research solutions on the web. A coding agent (like Claude Code or Codex) has delegated a manual web task to you that would normally require a human clicking through a web UI — e.g. enabling an API in Google Cloud Console, creating a Supabase project, generating an API key, or changing a dashboard setting.
5
+
6
+ You drive a real Chrome browser that is ALREADY LOGGED IN to the user's accounts (sessions persist). Your job is to complete the task end to end and report a precise result.
7
+
8
+ ## Your loop: recall → plan → act → detect failure → fix → verify → remember
9
+
10
+ 1. RECALL: Relevant learnings from your past runs are provided below under MEMORY. They are often the fastest path — trust them but verify they still apply. You can also call "recall_memory" mid-task to search for more.
11
+ 2. PLAN: After your first "snapshot", call "set_plan" with the concrete steps you intend to take. Keep it short and outcome-focused.
12
+ 3. ACT: You cannot see the page directly. Call "snapshot" for the URL, title, and a numbered list of interactive elements. Element refs are ONLY valid for the most recent snapshot — after ANY action that changes the page, take a fresh snapshot before acting again. Use "read_text" for prose (instructions, errors, confirmations).
13
+ 4. DETECT FAILURE: After each action, check whether it did what you expected. If a button is missing, a setting is greyed out, an error appears, or the page didn't change as planned — that is a roadblock. Do NOT blindly repeat a failing action.
14
+ 5. FIX: When blocked, reason about WHY. The coding agent's suggested steps may be wrong, outdated, or missing a prerequisite. First check MEMORY. If still stuck, use the web_search tool to find how others solved this exact problem (search the error text or "how to X in <service>"). Then "set_plan" again with the corrected approach and continue. Try genuinely different approaches — explore the navigation, look for prerequisites.
15
+ 6. VERIFY (do not skip, do not assume): You MUST have concrete positive evidence the goal is done before reporting success — not merely that the UI looked plausible. Get a positive signal: run a SELECT and read back the expected rows/count, see an explicit success toast, or see the created resource actually listed. After running SQL, READ the results/errors pane: if it shows an error, the run FAILED — fix and retry. If you cannot obtain real evidence, report status "blocked", never "success". Reporting success without verification is itself a failure.
16
+ 7. REMEMBER: Whenever you discover something reusable — the correct navigation path for a service, a non-obvious prerequisite, or the fix to a roadblock — call "remember" so future runs are faster. Use a stable service name (e.g. the domain like "console.cloud.google.com").
17
+
18
+ ## Code editors (e.g. the Supabase SQL editor)
19
+ To put SQL or code into an editor, ALWAYS use "type_keys" (never "type"). It clears the editor and pastes verbatim, so brackets aren't auto-closed and content isn't duplicated on re-runs. Steps: snapshot → click the editor area → type_keys with the FULL text → click the Run button (or press_key Cmd+Enter / Control+Enter) → read_text to confirm success or read the error. If a syntax error mentions a stray ')' or duplicated text, you used the wrong tool or didn't clear — just type_keys the full text again (it re-clears) and re-run.
20
+
21
+ ## Work fast — minimize round-trips
22
+ - Every click / type / navigate ALREADY returns the updated page (interactive elements + a "Page text" excerpt). Do NOT call snapshot or read_text just to look again after acting — read the result that came back. Only snapshot when you truly have no current view.
23
+ - Trust MEMORY: if a past session recorded the navigation path or the fix, follow it directly instead of re-exploring.
24
+ - Be decisive: pick the most likely element and act; don't over-deliberate or take confirmatory peeks. You can also issue several independent tool calls in one turn when they don't depend on each other's result.
25
+
26
+ ## Rules
27
+ - Never ask the human for help mid-task; they delegated this so they don't have to click. Make reasonable decisions and proceed.
28
+ - If you ever land on a sign-in / login / OAuth screen (the session expired or you got logged out), do NOT attempt to log in or enter credentials. Stop and call "report_result" with status "blocked" and a summary telling the user to run \`npm run login\` for that service.
29
+ - Only stop if you genuinely cannot proceed: a hard paywall, a 2FA you cannot satisfy, a login wall, or a destructive/irreversible action you shouldn't take unprompted. Then call "report_result" with status "blocked".
30
+ - When done, call "report_result" exactly once. If the task produced values the coding agent needs (API keys, IDs, URLs, secrets), include them verbatim in "result".`;
31
+ function snapshotText(s) {
32
+ const lines = s.elements.map((e) => {
33
+ const val = e.value ? ` value="${e.value}"` : "";
34
+ return `[${e.ref}] ${e.role} "${e.name}"${val}`;
35
+ });
36
+ const textBlock = s.text ? `\n\nPage text (excerpt):\n${s.text}` : "";
37
+ return `URL: ${s.url}\nTitle: ${s.title}\n\nInteractive elements:\n${lines.join("\n") || "(none found)"}${textBlock}`;
38
+ }
39
+ /**
40
+ * Read the task and pick an execution profile — effort, step budget, and a
41
+ * strategy hint — so Rhai adapts WHAT to do and HOW per task, instead of one
42
+ * fixed setting. Cheap heuristics (no extra model call). Env vars override.
43
+ */
44
+ export function planProfile(task, hasRecipe, pastSuccesses) {
45
+ const t = task.toLowerCase();
46
+ const complex = (t.match(/\b(create|set up|setup|configure|enable|migrate|deploy|generate|provision|install|integrate|then|after that)\b/g) || []).length;
47
+ const simple = (t.match(/\b(open|read|report|get|fetch|check|view|list|find|show|count|verify|confirm|copy)\b/g) || []).length;
48
+ const long = task.length > 220;
49
+ if (hasRecipe) {
50
+ return {
51
+ effort: "low",
52
+ maxSteps: 25,
53
+ strategy: "A known recipe for this service will be replayed first — then just VERIFY the goal with real evidence and finish. Don't re-explore.",
54
+ };
55
+ }
56
+ if (complex >= 2 || long) {
57
+ return {
58
+ effort: "medium",
59
+ maxSteps: 60,
60
+ strategy: "Multi-step setup. Plan briefly, expect slow operations (use ONE wait-for-text instead of many short waits), and verify each milestone before moving on.",
61
+ };
62
+ }
63
+ if (simple > 0 && complex === 0) {
64
+ return {
65
+ effort: pastSuccesses > 0 ? "minimal" : "low",
66
+ maxSteps: 22,
67
+ strategy: "Quick task. Go straight to the goal, do the minimum, verify, and report. No exploration or extra peeks.",
68
+ };
69
+ }
70
+ return { effort: "low", maxSteps: 40, strategy: "Standard task. Act decisively; lean on memory; verify before reporting." };
71
+ }
72
+ /** Convert a successful tool call into a replayable recipe step (or null to skip). */
73
+ function toRecipeStep(name, input, cap) {
74
+ switch (name) {
75
+ case "navigate":
76
+ return input.url ? { tool: "navigate", url: input.url } : null;
77
+ case "click":
78
+ return cap ? { tool: "click", locator: cap } : null;
79
+ case "type":
80
+ return cap ? { tool: "type", locator: cap, text: input.text, submit: input.submit } : null;
81
+ case "type_keys":
82
+ return cap ? { tool: "type_keys", locator: cap, text: input.text } : null;
83
+ case "select":
84
+ return cap ? { tool: "select", locator: cap, value: input.value } : null;
85
+ case "press_key":
86
+ return input.key ? { tool: "press_key", key: input.key } : null;
87
+ case "wait":
88
+ return input.for_text ? { tool: "wait", forText: input.for_text } : null;
89
+ default:
90
+ return null; // snapshot/read_text/plan/recall/remember/report aren't replayable steps
91
+ }
92
+ }
93
+ /** Replay recorded steps deterministically; return how many succeeded before any divergence. */
94
+ async function replayRecipe(browser, steps) {
95
+ let done = 0;
96
+ for (const s of steps) {
97
+ let ok = false;
98
+ try {
99
+ if (s.tool === "navigate" && s.url) {
100
+ await browser.navigate(s.url);
101
+ ok = true;
102
+ }
103
+ else if (s.tool === "click")
104
+ ok = await browser.replayClick(s.locator);
105
+ else if (s.tool === "type")
106
+ ok = await browser.replayType(s.locator, s.text ?? "", s.submit);
107
+ else if (s.tool === "type_keys")
108
+ ok = await browser.replayTypeKeys(s.locator, s.text ?? "");
109
+ else if (s.tool === "select")
110
+ ok = await browser.replaySelect(s.locator, s.value ?? "");
111
+ else if (s.tool === "press_key" && s.key) {
112
+ await browser.pressKey(s.key);
113
+ ok = true;
114
+ }
115
+ else if (s.tool === "wait") {
116
+ if (s.forText)
117
+ await browser.waitForText(s.forText);
118
+ ok = true;
119
+ }
120
+ }
121
+ catch {
122
+ ok = false;
123
+ }
124
+ if (!ok)
125
+ break;
126
+ await browser.snapshot().catch(() => { }); // settle between steps
127
+ done++;
128
+ }
129
+ return done;
130
+ }
131
+ function serviceFromUrl(url) {
132
+ if (!url)
133
+ return undefined;
134
+ try {
135
+ return new URL(url).hostname;
136
+ }
137
+ catch {
138
+ return undefined;
139
+ }
140
+ }
141
+ const text = (s) => ({ text: s });
142
+ /** A short, human-readable description of an action, for the live progress log. */
143
+ function describe(name, input) {
144
+ const clip = (s, n = 40) => (s ?? "").replace(/\s+/g, " ").slice(0, n);
145
+ switch (name) {
146
+ case "navigate": return `navigate ${input.url}`;
147
+ case "click": return `click [${input.ref}]`;
148
+ case "type": return `type [${input.ref}] "${clip(input.text)}"${input.submit ? " ⏎" : ""}`;
149
+ case "type_keys": return `type "${clip(input.text)}"`;
150
+ case "select": return `select [${input.ref}] = ${clip(input.value)}`;
151
+ case "press_key": return `press ${input.key}`;
152
+ case "wait": return `wait ${input.for_text ? `for "${clip(input.for_text)}"` : `${input.seconds ?? 2}s`}`;
153
+ case "set_plan": return `plan: ${clip((input.steps ?? []).join(" › "), 90)}`;
154
+ case "recall_memory": return `recall "${clip(input.query)}"`;
155
+ case "remember": return `remember [${input.service}] ${clip(input.title)}`;
156
+ case "snapshot": return "look at page";
157
+ case "read_text": return "read page text";
158
+ case "screenshot": return "screenshot";
159
+ default: return name;
160
+ }
161
+ }
162
+ // Function tools in the Responses API are flat: { type, name, description, parameters }.
163
+ const FUNCTION_TOOLS = [
164
+ {
165
+ type: "function",
166
+ name: "recall_memory",
167
+ description: "Search your persistent memory of past runs for relevant learnings (navigation paths, gotchas, fixes).",
168
+ parameters: {
169
+ type: "object",
170
+ properties: { query: { type: "string", description: "What you're trying to do or the problem you hit" } },
171
+ required: ["query"],
172
+ additionalProperties: false,
173
+ },
174
+ },
175
+ {
176
+ type: "function",
177
+ name: "set_plan",
178
+ description: "Record or revise your plan. Call after your first snapshot, and again whenever you change approach after a roadblock.",
179
+ parameters: {
180
+ type: "object",
181
+ properties: {
182
+ steps: { type: "array", items: { type: "string" }, description: "Ordered steps you intend to take" },
183
+ notes: { type: "string", description: "Optional reasoning, e.g. why you revised the plan" },
184
+ },
185
+ required: ["steps"],
186
+ additionalProperties: false,
187
+ },
188
+ },
189
+ {
190
+ type: "function",
191
+ name: "snapshot",
192
+ description: "Capture the current page: URL, title, and a numbered list of interactive elements with refs. Call before acting and after any page change.",
193
+ parameters: { type: "object", properties: {}, additionalProperties: false },
194
+ },
195
+ {
196
+ type: "function",
197
+ name: "read_text",
198
+ description: "Return the visible text content of the page. Use to read instructions, errors, or confirmation messages.",
199
+ parameters: { type: "object", properties: {}, additionalProperties: false },
200
+ },
201
+ {
202
+ type: "function",
203
+ name: "navigate",
204
+ description: "Go to a URL.",
205
+ parameters: {
206
+ type: "object",
207
+ properties: { url: { type: "string" } },
208
+ required: ["url"],
209
+ additionalProperties: false,
210
+ },
211
+ },
212
+ {
213
+ type: "function",
214
+ name: "click",
215
+ description: "Click the element with the given ref from the latest snapshot.",
216
+ parameters: {
217
+ type: "object",
218
+ properties: { ref: { type: "integer" } },
219
+ required: ["ref"],
220
+ additionalProperties: false,
221
+ },
222
+ },
223
+ {
224
+ type: "function",
225
+ name: "type",
226
+ description: "Type text into the input/textarea with the given ref. Set submit=true to press Enter afterward.",
227
+ parameters: {
228
+ type: "object",
229
+ properties: { ref: { type: "integer" }, text: { type: "string" }, submit: { type: "boolean" } },
230
+ required: ["ref", "text"],
231
+ additionalProperties: false,
232
+ },
233
+ },
234
+ {
235
+ type: "function",
236
+ name: "type_keys",
237
+ description: "Insert text verbatim into a CODE EDITOR (Supabase SQL editor, Monaco, CodeMirror). ALWAYS use this — never 'type' — for code/SQL: it first clears the editor (so re-runs replace, not append) and pastes the text in one shot, so brackets aren't auto-closed and nothing is duplicated. Pass the editor's ref to focus it, plus the full text. To run SQL after, click the Run button (or press Cmd/Ctrl+Enter).",
238
+ parameters: {
239
+ type: "object",
240
+ properties: {
241
+ text: { type: "string", description: "Text/code to type" },
242
+ ref: { type: "integer", description: "Optional element ref to click/focus first" },
243
+ },
244
+ required: ["text"],
245
+ additionalProperties: false,
246
+ },
247
+ },
248
+ {
249
+ type: "function",
250
+ name: "select",
251
+ description: "Choose an option in a <select> dropdown by its value or visible label.",
252
+ parameters: {
253
+ type: "object",
254
+ properties: { ref: { type: "integer" }, value: { type: "string" } },
255
+ required: ["ref", "value"],
256
+ additionalProperties: false,
257
+ },
258
+ },
259
+ {
260
+ type: "function",
261
+ name: "press_key",
262
+ description: "Press a keyboard key globally, e.g. 'Enter', 'Escape', 'Tab'.",
263
+ parameters: {
264
+ type: "object",
265
+ properties: { key: { type: "string" } },
266
+ required: ["key"],
267
+ additionalProperties: false,
268
+ },
269
+ },
270
+ {
271
+ type: "function",
272
+ name: "wait",
273
+ description: "Wait for a number of seconds, OR (preferred) until specific text appears — for_text polls in-browser up to 2 minutes, so use ONE wait with for_text for slow operations like project provisioning (e.g. for_text 'is ready' or the project name) instead of many short waits.",
274
+ parameters: {
275
+ type: "object",
276
+ properties: { seconds: { type: "number" }, for_text: { type: "string" } },
277
+ additionalProperties: false,
278
+ },
279
+ },
280
+ {
281
+ type: "function",
282
+ name: "screenshot",
283
+ description: "Take a screenshot of the current viewport. Use only when the DOM snapshot is ambiguous.",
284
+ parameters: { type: "object", properties: {}, additionalProperties: false },
285
+ },
286
+ {
287
+ type: "function",
288
+ name: "remember",
289
+ description: "Save a reusable learning to persistent memory so future runs are faster. Use for correct navigation paths, prerequisites, and fixes to roadblocks.",
290
+ parameters: {
291
+ type: "object",
292
+ properties: {
293
+ service: { type: "string", description: "Stable service identifier, e.g. 'console.cloud.google.com'" },
294
+ title: { type: "string", description: "Short label, e.g. 'Enable an API'" },
295
+ content: { type: "string", description: "The actual learning — concrete and reusable" },
296
+ },
297
+ required: ["service", "title", "content"],
298
+ additionalProperties: false,
299
+ },
300
+ },
301
+ {
302
+ type: "function",
303
+ name: "report_result",
304
+ description: "Call exactly once when the task is complete or genuinely blocked. Ends the task.",
305
+ parameters: {
306
+ type: "object",
307
+ properties: {
308
+ status: { type: "string", enum: ["success", "blocked"] },
309
+ summary: { type: "string", description: "What you did and the final state, in 1-4 sentences." },
310
+ result: { type: "string", description: "Concrete values the coding agent needs (keys, IDs, URLs), verbatim. Empty string if none." },
311
+ },
312
+ required: ["status", "summary", "result"],
313
+ additionalProperties: false,
314
+ },
315
+ },
316
+ ];
317
+ // OpenAI's built-in, server-side web search tool.
318
+ const WEB_SEARCH_TOOL = { type: "web_search" };
319
+ export async function runBrowserTask(browser, task, opts = {}) {
320
+ const client = new OpenAI({ apiKey: config.openaiApiKey });
321
+ const service = serviceFromUrl(opts.startUrl);
322
+ const taskId = await memory.startTask(task, opts.startUrl, opts.context, service);
323
+ // Deterministic auth gate — runs BEFORE any model call. If we're not logged
324
+ // in, stop immediately with clear instructions instead of guessing, wandering,
325
+ // or spending tokens. This is the production guarantee against acting unauthenticated.
326
+ if (opts.startUrl) {
327
+ await browser.navigate(opts.startUrl);
328
+ const auth = await browser.checkAuth();
329
+ if (!auth.authed) {
330
+ const host = service ?? "the service";
331
+ const msg = `Not logged in to ${host} — ${auth.reason} (landed on ${auth.finalUrl}). ` +
332
+ `Log in once, then retry:\n npm run login -- ${opts.startUrl}`;
333
+ log(msg);
334
+ await memory.finishTask(taskId, "blocked", msg, "", 0);
335
+ return { status: "blocked", summary: msg, result: "", steps: 0 };
336
+ }
337
+ debug(`auth ok (${auth.finalUrl})`);
338
+ }
339
+ const recalled = await memory.recall(`${task} ${opts.context ?? ""} ${service ?? ""}`);
340
+ const memoryBlock = memory.formatMemories(recalled);
341
+ const pastTasks = await memory.recentTasks(service);
342
+ const pastBlock = memory.formatPastTasks(pastTasks);
343
+ const userParts = [`TASK:\n${task}`];
344
+ if (opts.context)
345
+ userParts.push(`\nCONTEXT FROM THE CODING AGENT:\n${opts.context}`);
346
+ if (pastBlock)
347
+ userParts.push(`\nWHAT HAPPENED IN PREVIOUS SESSIONS (most recent first — use this to avoid recreating things that already exist or repeating past mistakes):\n${pastBlock}`);
348
+ if (memoryBlock)
349
+ userParts.push(`\nMEMORY (learnings from your past runs — may speed you up):\n${memoryBlock}`);
350
+ if (pastTasks.length)
351
+ debug(`recalled ${pastTasks.length} past session(s) on ${service ?? "various services"}`);
352
+ // Look up a recipe first (so the profile knows whether this is a replay), then
353
+ // pick a per-task execution profile (effort / step budget / strategy).
354
+ const recipe = process.env.RHAI_RECIPES !== "0" ? await memory.findRecipe(service, task) : null;
355
+ const hasRecipe = Boolean(recipe && recipe.length);
356
+ const pastSuccesses = pastTasks.filter((t) => t.status === "success").length;
357
+ const profile = planProfile(task, hasRecipe, pastSuccesses);
358
+ // Env vars override the auto-profile; otherwise Rhai adapts per task.
359
+ const baseEffort = config.effort || profile.effort;
360
+ const maxSteps = config.maxStepsEnv || profile.maxSteps;
361
+ debug(`profile: effort=${baseEffort}, steps=${maxSteps}${hasRecipe ? `, recipe(${recipe.length})` : ""} — ${profile.strategy}`);
362
+ userParts.push(`\nSTRATEGY FOR THIS TASK: ${profile.strategy}`);
363
+ // FAST PATH: replay the known recipe deterministically (no model calls per step),
364
+ // then let the model only verify/finish or self-heal where the page diverged.
365
+ const recipeSteps = [];
366
+ if (hasRecipe && recipe) {
367
+ debug(`fast-path: replaying ${recipe.length}-step recipe…`);
368
+ const done = await replayRecipe(browser, recipe);
369
+ recipeSteps.push(...recipe.slice(0, done)); // keep the saved recipe current on re-save
370
+ debug(`fast-path: replayed ${done}/${recipe.length} steps`);
371
+ userParts.push(`\nFAST-PATH REPLAY: I deterministically replayed ${done}/${recipe.length} steps from a known recipe for ${service ?? "this service"} (no reasoning needed). ` +
372
+ (done < recipe.length
373
+ ? `Step ${done + 1} no longer matched (the page differs) — take over from the CURRENT page and continue.`
374
+ : `All recipe steps replayed. `) +
375
+ `Snapshot now, VERIFY the goal is actually complete with real evidence, and report success — or continue if anything is missing.`);
376
+ }
377
+ userParts.push("\nBegin by taking a snapshot of the current page, then set a plan.");
378
+ let actionIndex = 0;
379
+ const recordAction = (tool, input, observation, ok) => {
380
+ void memory.logAction(taskId, actionIndex++, tool, input, observation, ok);
381
+ };
382
+ const handlers = {
383
+ recall_memory: async ({ query }) => {
384
+ const found = await memory.recall(query);
385
+ return text(found.length ? memory.formatMemories(found) : "No relevant memories found.");
386
+ },
387
+ set_plan: async ({ steps, notes }) => {
388
+ await memory.savePlan(taskId, steps, notes);
389
+ return text(`Plan recorded (${steps.length} steps).`);
390
+ },
391
+ snapshot: async () => text(snapshotText(await browser.snapshot())),
392
+ read_text: async () => text((await browser.readText()) || "(page is empty)"),
393
+ navigate: async ({ url }) => {
394
+ await browser.navigate(url);
395
+ return text(snapshotText(await browser.snapshot()));
396
+ },
397
+ click: async ({ ref }) => {
398
+ await browser.click(ref);
399
+ return text(`Clicked [${ref}]. ${snapshotText(await browser.snapshot())}`);
400
+ },
401
+ type: async ({ ref, text: t, submit }) => {
402
+ await browser.type(ref, t, submit ?? false);
403
+ return text(`Typed into [${ref}]${submit ? " and submitted" : ""}. ${snapshotText(await browser.snapshot())}`);
404
+ },
405
+ type_keys: async ({ text: t, ref }) => {
406
+ await browser.typeKeys(t, ref);
407
+ return text(`Typed ${t.length} chars via keyboard${ref != null ? ` (focused [${ref}])` : ""}.`);
408
+ },
409
+ select: async ({ ref, value }) => {
410
+ await browser.select(ref, value);
411
+ return text(`Selected "${value}" in [${ref}].`);
412
+ },
413
+ press_key: async ({ key }) => {
414
+ await browser.pressKey(key);
415
+ return text(`Pressed ${key}. ${snapshotText(await browser.snapshot())}`);
416
+ },
417
+ wait: async ({ seconds, for_text }) => {
418
+ if (for_text) {
419
+ const found = await browser.waitForText(for_text);
420
+ return text(found ? `Text "${for_text}" appeared.` : `Text "${for_text}" did not appear within 15s.`);
421
+ }
422
+ await browser.wait((seconds ?? 2) * 1000);
423
+ return text(`Waited ${seconds ?? 2}s.`);
424
+ },
425
+ screenshot: async () => ({ text: "Screenshot captured; shown in the next message.", image: await browser.screenshot() }),
426
+ remember: async ({ service: svc, title, content }) => {
427
+ await memory.remember(svc, title, content);
428
+ return text(`Saved to memory: [${svc}] ${title}`);
429
+ },
430
+ report_result: async () => text(""),
431
+ };
432
+ const finish = async (status, summary, result, steps) => {
433
+ await memory.finishTask(taskId, status, summary, result, steps);
434
+ return { status, summary, result, steps };
435
+ };
436
+ // OpenAI disallows the web_search server tool at reasoning.effort "minimal".
437
+ const webSearchOk = baseEffort !== "minimal";
438
+ const tools = webSearchOk ? [...FUNCTION_TOOLS, WEB_SEARCH_TOOL] : [...FUNCTION_TOOLS];
439
+ if (!webSearchOk)
440
+ debug("(web search off at minimal effort)");
441
+ // Adaptive effort: start at the configured tier and step up only when the agent
442
+ // gets stuck, so the happy path stays fast and hard moments get more reasoning.
443
+ const EFFORTS = ["minimal", "low", "medium", "high", "xhigh"];
444
+ const baseIdx = Math.max(0, EFFORTS.indexOf(baseEffort));
445
+ let fails = 0;
446
+ const currentEffort = () => EFFORTS[Math.min(EFFORTS.length - 1, baseIdx + Math.min(fails, 2))];
447
+ const createResponse = (args) => client.responses.create({
448
+ model: config.model,
449
+ instructions: SYSTEM_PROMPT,
450
+ input: args.input,
451
+ tools: tools,
452
+ reasoning: { effort: currentEffort() },
453
+ max_output_tokens: 8000,
454
+ store: true,
455
+ ...(args.previousId ? { previous_response_id: args.previousId } : {}),
456
+ });
457
+ const t0 = Date.now();
458
+ const elapsed = () => `${Math.round((Date.now() - t0) / 1000)}s`;
459
+ log("thinking…");
460
+ let response = await createResponse({ input: userParts.join("\n") });
461
+ for (let step = 1; step <= maxSteps; step++) {
462
+ const output = response.output ?? [];
463
+ // Surface the model's narration and any web searches.
464
+ if (response.output_text?.trim())
465
+ log(`💬 ${response.output_text.trim()}`);
466
+ for (const item of output) {
467
+ if (item.type === "web_search_call") {
468
+ const q = item.action?.query ?? item.query ?? "";
469
+ log(`▸ ${elapsed()} | web search ${q ? `"${q}"` : ""}`);
470
+ }
471
+ }
472
+ const functionCalls = output.filter((i) => i.type === "function_call");
473
+ if (functionCalls.length === 0) {
474
+ // No tool calls — the model is done. Use its text as the summary.
475
+ await memory.saveRecipe(service, task, recipeSteps);
476
+ return finish("success", response.output_text?.trim() || "Task ended.", "", step);
477
+ }
478
+ const followups = [];
479
+ const imageMessages = [];
480
+ let turnHadError = false;
481
+ for (const fc of functionCalls) {
482
+ let input = {};
483
+ try {
484
+ input = fc.arguments ? JSON.parse(fc.arguments) : {};
485
+ }
486
+ catch {
487
+ /* leave empty */
488
+ }
489
+ if (fc.name === "report_result") {
490
+ const i = input;
491
+ log(`✓ ${elapsed()} | done (${i.status}): ${i.summary}`);
492
+ if (i.status === "success")
493
+ await memory.saveRecipe(service, task, recipeSteps);
494
+ return finish(i.status ?? "success", i.summary ?? "", i.result ?? "", step);
495
+ }
496
+ log(`▸ ${elapsed()} | step ${step} · ${describe(fc.name, input)}`);
497
+ // Capture a durable locator BEFORE acting (the element is still in the DOM).
498
+ let cap = null;
499
+ if (["click", "type", "type_keys", "select"].includes(fc.name) && input.ref != null) {
500
+ cap = await browser.captureLocator(input.ref).catch(() => null);
501
+ }
502
+ const handler = handlers[fc.name];
503
+ try {
504
+ const out = handler ? await handler(input) : { text: `Unknown tool: ${fc.name}` };
505
+ recordAction(fc.name, input, out.text || (out.image ? "[image]" : ""), true);
506
+ const st = toRecipeStep(fc.name, input, cap);
507
+ if (st)
508
+ recipeSteps.push(st);
509
+ followups.push({ type: "function_call_output", call_id: fc.call_id, output: out.text });
510
+ if (out.image) {
511
+ imageMessages.push({
512
+ role: "user",
513
+ content: [
514
+ { type: "input_text", text: "Screenshot of the current page:" },
515
+ { type: "input_image", image_url: `data:image/png;base64,${out.image}` },
516
+ ],
517
+ });
518
+ }
519
+ }
520
+ catch (err) {
521
+ const msg = err instanceof Error ? err.message : String(err);
522
+ log(`tool ${fc.name} failed: ${msg}`);
523
+ recordAction(fc.name, input, msg, false);
524
+ turnHadError = true;
525
+ followups.push({
526
+ type: "function_call_output",
527
+ call_id: fc.call_id,
528
+ output: `Error: ${msg}. Re-snapshot and try a different approach — consider recall_memory or web_search.`,
529
+ });
530
+ }
531
+ }
532
+ // Drive adaptive effort: escalate after failures, relax once things go smoothly.
533
+ const prevEffort = currentEffort();
534
+ fails = turnHadError ? fails + 1 : 0;
535
+ if (currentEffort() !== prevEffort)
536
+ debug(`(raising reasoning effort → ${currentEffort()})`);
537
+ log("thinking…");
538
+ response = await createResponse({ input: [...followups, ...imageMessages], previousId: response.id });
539
+ }
540
+ return finish("max_steps", `Reached the step limit (${maxSteps}) without completing the task.`, "", maxSteps);
541
+ }
542
+ //# s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