pi-agent-browser-native 0.2.34 → 0.2.36
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 +44 -0
- package/README.md +25 -15
- package/docs/ARCHITECTURE.md +19 -13
- package/docs/COMMAND_REFERENCE.md +274 -44
- package/docs/ELECTRON.md +3 -3
- package/docs/RELEASE.md +11 -11
- package/docs/REQUIREMENTS.md +5 -5
- package/docs/SUPPORT_MATRIX.md +43 -24
- package/docs/TOOL_CONTRACT.md +50 -30
- package/extensions/agent-browser/index.ts +518 -2402
- package/extensions/agent-browser/lib/argv-descriptor.ts +90 -0
- package/extensions/agent-browser/lib/argv-grammar.ts +128 -0
- package/extensions/agent-browser/lib/command-policy.ts +71 -0
- package/extensions/agent-browser/lib/command-taxonomy.ts +336 -0
- package/extensions/agent-browser/lib/electron/cleanup.ts +1 -0
- package/extensions/agent-browser/lib/executable-path.ts +19 -0
- package/extensions/agent-browser/lib/input-modes/params.ts +6 -6
- package/extensions/agent-browser/lib/orchestration/batch-stdin.ts +65 -0
- package/extensions/agent-browser/lib/orchestration/browser-run/browser-action-model.ts +154 -0
- package/extensions/agent-browser/lib/orchestration/browser-run/click-dispatch.ts +149 -0
- package/extensions/agent-browser/lib/orchestration/browser-run/diagnostics.ts +56 -30
- package/extensions/agent-browser/lib/orchestration/browser-run/final-result.ts +13 -3
- package/extensions/agent-browser/lib/orchestration/browser-run/index.ts +33 -27
- package/extensions/agent-browser/lib/orchestration/browser-run/prepare.ts +48 -22
- package/extensions/agent-browser/lib/orchestration/browser-run/process-output.ts +39 -10
- package/extensions/agent-browser/lib/orchestration/browser-run/prompt-guards.ts +93 -0
- package/extensions/agent-browser/lib/orchestration/browser-run/session-state.ts +98 -124
- package/extensions/agent-browser/lib/orchestration/browser-run/types.ts +40 -1
- package/extensions/agent-browser/lib/orchestration/electron-host/index.ts +860 -0
- package/extensions/agent-browser/lib/playbook.ts +10 -10
- package/extensions/agent-browser/lib/prompt-policy.ts +122 -0
- package/extensions/agent-browser/lib/results/action-recommendations.ts +3 -23
- package/extensions/agent-browser/lib/results/presentation/navigation.ts +2 -34
- package/extensions/agent-browser/lib/runtime.ts +93 -227
- package/extensions/agent-browser/lib/session-page-state.ts +31 -14
- package/extensions/agent-browser/lib/temp.ts +148 -23
- package/package.json +4 -4
- package/scripts/agent-browser-capability-baseline.mjs +198 -1
|
@@ -4,6 +4,7 @@ import type { ElectronLaunchStatus } from "../../electron/cleanup.js";
|
|
|
4
4
|
import type { ElectronCdpTarget, ElectronLaunchRecord } from "../../electron/launch.js";
|
|
5
5
|
import { runAgentBrowserProcess } from "../../process.js";
|
|
6
6
|
import { buildAgentBrowserNextActions, getAgentBrowserErrorText, parseAgentBrowserEnvelope, type AgentBrowserBatchResult, type AgentBrowserEnvelope, type AgentBrowserNextAction } from "../../results.js";
|
|
7
|
+
import { buildNextToolAction, withOptionalSessionArgs } from "../../results/next-actions.js";
|
|
7
8
|
import {
|
|
8
9
|
extractRefSnapshotFromData,
|
|
9
10
|
isAboutBlankUrl,
|
|
@@ -14,8 +15,18 @@ import {
|
|
|
14
15
|
type SessionRefSnapshotInvalidation,
|
|
15
16
|
type SessionTabTarget,
|
|
16
17
|
} from "../../session-page-state.js";
|
|
18
|
+
import {
|
|
19
|
+
isCloseCommand,
|
|
20
|
+
isElectronPostCommandHealthCommand,
|
|
21
|
+
isNavigationObservableCommandName,
|
|
22
|
+
isRefGuardedCommand,
|
|
23
|
+
isRefInvalidatingBatchCommand,
|
|
24
|
+
isSessionTabPinningExcludedCommand,
|
|
25
|
+
isSessionTabPostCommandCorrectionExcludedCommand,
|
|
26
|
+
} from "../../command-taxonomy.js";
|
|
17
27
|
import { chooseOpenResultTabCorrection, redactInvocationArgs, type OpenResultTabCorrection } from "../../runtime.js";
|
|
18
28
|
import { isRecord } from "../../parsing.js";
|
|
29
|
+
import { parseUserBatchStdin } from "../batch-stdin.js";
|
|
19
30
|
import type {
|
|
20
31
|
AboutBlankSessionMismatch,
|
|
21
32
|
BatchCommandStep,
|
|
@@ -35,65 +46,8 @@ import type {
|
|
|
35
46
|
TraceOwner,
|
|
36
47
|
} from "./types.js";
|
|
37
48
|
|
|
38
|
-
export const NAVIGATION_SUMMARY_COMMANDS = new Set(["back", "click", "dblclick", "forward", "reload"]);
|
|
39
49
|
export const NAVIGATION_SUMMARY_EVAL = `({ title: document.title, url: location.href })`;
|
|
40
50
|
|
|
41
|
-
const SESSION_TAB_PINNING_EXCLUDED_COMMANDS = new Set(["close", "goto", "navigate", "open", "session", "tab"]);
|
|
42
|
-
const SESSION_TAB_POST_COMMAND_CORRECTION_EXCLUDED_COMMANDS = new Set(["batch", "close", "session", "tab"]);
|
|
43
|
-
const REF_INVALIDATING_BATCH_COMMANDS = new Set([
|
|
44
|
-
"back",
|
|
45
|
-
"check",
|
|
46
|
-
"click",
|
|
47
|
-
"dblclick",
|
|
48
|
-
"drag",
|
|
49
|
-
"forward",
|
|
50
|
-
"goto",
|
|
51
|
-
"keyboard",
|
|
52
|
-
"mouse",
|
|
53
|
-
"navigate",
|
|
54
|
-
"open",
|
|
55
|
-
"press",
|
|
56
|
-
"reload",
|
|
57
|
-
"select",
|
|
58
|
-
"type",
|
|
59
|
-
"uncheck",
|
|
60
|
-
"upload",
|
|
61
|
-
]);
|
|
62
|
-
const REF_GUARDED_COMMANDS = new Set([
|
|
63
|
-
"check",
|
|
64
|
-
"click",
|
|
65
|
-
"dblclick",
|
|
66
|
-
"download",
|
|
67
|
-
"drag",
|
|
68
|
-
"fill",
|
|
69
|
-
"focus",
|
|
70
|
-
"hover",
|
|
71
|
-
"keyboard",
|
|
72
|
-
"mouse",
|
|
73
|
-
"press",
|
|
74
|
-
"scrollintoview",
|
|
75
|
-
"select",
|
|
76
|
-
"type",
|
|
77
|
-
"uncheck",
|
|
78
|
-
"upload",
|
|
79
|
-
]);
|
|
80
|
-
const ELECTRON_POST_COMMAND_HEALTH_COMMANDS = new Set([
|
|
81
|
-
"back",
|
|
82
|
-
"check",
|
|
83
|
-
"click",
|
|
84
|
-
"dblclick",
|
|
85
|
-
"fill",
|
|
86
|
-
"find",
|
|
87
|
-
"forward",
|
|
88
|
-
"keyboard",
|
|
89
|
-
"mouse",
|
|
90
|
-
"press",
|
|
91
|
-
"reload",
|
|
92
|
-
"select",
|
|
93
|
-
"type",
|
|
94
|
-
"uncheck",
|
|
95
|
-
]);
|
|
96
|
-
|
|
97
51
|
export function applyBrowserRunStatePatch(state: BrowserRunState, patch: BrowserRunStatePatch | undefined): void {
|
|
98
52
|
if (!patch) return;
|
|
99
53
|
if ("artifactManifest" in patch) state.artifactManifest = patch.artifactManifest;
|
|
@@ -103,10 +57,6 @@ export function applyBrowserRunStatePatch(state: BrowserRunState, patch: Browser
|
|
|
103
57
|
if (patch.managedSessionName !== undefined) state.managedSessionName = patch.managedSessionName;
|
|
104
58
|
}
|
|
105
59
|
|
|
106
|
-
export function mergeBrowserRunStatePatch(left: BrowserRunStatePatch | undefined, right: BrowserRunStatePatch | undefined): BrowserRunStatePatch {
|
|
107
|
-
return { ...(left ?? {}), ...(right ?? {}) };
|
|
108
|
-
}
|
|
109
|
-
|
|
110
60
|
export function buildSessionDetailFields(sessionName: string | undefined, usedImplicitSession: boolean): Record<string, unknown> {
|
|
111
61
|
return sessionName ? { sessionName, usedImplicitSession } : {};
|
|
112
62
|
}
|
|
@@ -126,7 +76,7 @@ export function buildManagedSessionOutcome(options: {
|
|
|
126
76
|
if (!attemptedSessionName) return undefined;
|
|
127
77
|
let status: ManagedSessionOutcome["status"];
|
|
128
78
|
let summary: string;
|
|
129
|
-
if (command
|
|
79
|
+
if (isCloseCommand(command)) {
|
|
130
80
|
status = succeeded ? "closed" : activeBefore ? "preserved" : "abandoned";
|
|
131
81
|
summary = succeeded
|
|
132
82
|
? `Managed session ${attemptedSessionName} was closed.`
|
|
@@ -169,8 +119,85 @@ export function buildManagedSessionOutcome(options: {
|
|
|
169
119
|
};
|
|
170
120
|
}
|
|
171
121
|
|
|
122
|
+
function isFreshPostLaunchFailure(outcome: ManagedSessionOutcome): boolean {
|
|
123
|
+
return !outcome.succeeded && outcome.sessionMode === "fresh" && outcome.activeAfter && !!outcome.currentSessionName && (outcome.status === "created" || outcome.status === "replaced" || outcome.status === "unchanged");
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function formatManagedSessionOutcomeHeadline(outcome: ManagedSessionOutcome): string {
|
|
127
|
+
if (outcome.status === "preserved") {
|
|
128
|
+
return "Managed session outcome: Fresh launch failed; your previous browser session is still active.";
|
|
129
|
+
}
|
|
130
|
+
if (outcome.status === "abandoned") {
|
|
131
|
+
return "Managed session outcome: Fresh launch failed; no managed browser session is current.";
|
|
132
|
+
}
|
|
133
|
+
if (isFreshPostLaunchFailure(outcome)) {
|
|
134
|
+
return "Managed session outcome: Fresh launch became current, but this tool call failed after launch.";
|
|
135
|
+
}
|
|
136
|
+
return `Managed session outcome: ${outcome.summary}`;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function formatManagedSessionOutcomeRecoveryGuidance(outcome: ManagedSessionOutcome): string {
|
|
140
|
+
const lines = ["Recovery:"];
|
|
141
|
+
if (outcome.status === "preserved") {
|
|
142
|
+
lines.push('- Continue with sessionMode "auto" on the current session, or retry the intended launch with sessionMode "fresh".');
|
|
143
|
+
lines.push("- Run doctor to verify agent-browser install and environment when failures persist.");
|
|
144
|
+
} else if (outcome.status === "abandoned") {
|
|
145
|
+
lines.push('- Retry with sessionMode "fresh" (for example args: ["open", "<url>"]) after verifying agent-browser is on PATH.');
|
|
146
|
+
lines.push("- Run doctor when install or environment issues are suspected.");
|
|
147
|
+
} else if (isFreshPostLaunchFailure(outcome)) {
|
|
148
|
+
lines.push('- Continue with sessionMode "auto" on the current session, or inspect failureCategory / qaPreset to fix the post-launch failure.');
|
|
149
|
+
lines.push("- Run doctor only if later browser commands also fail.");
|
|
150
|
+
} else {
|
|
151
|
+
lines.push('- Retry with sessionMode "fresh" when launch-scoped flags must apply, or run doctor to verify the environment.');
|
|
152
|
+
}
|
|
153
|
+
lines.push("- Full session names and transition details remain in details.managedSessionOutcome.");
|
|
154
|
+
return lines.join("\n");
|
|
155
|
+
}
|
|
156
|
+
|
|
172
157
|
export function formatManagedSessionOutcomeText(outcome: ManagedSessionOutcome | undefined): string | undefined {
|
|
173
|
-
|
|
158
|
+
if (!outcome || outcome.succeeded || outcome.sessionMode !== "fresh") return undefined;
|
|
159
|
+
return [formatManagedSessionOutcomeHeadline(outcome), formatManagedSessionOutcomeRecoveryGuidance(outcome)].join("\n");
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export function buildManagedSessionFreshFailureNextActions(outcome: ManagedSessionOutcome | undefined): AgentBrowserNextAction[] {
|
|
163
|
+
if (!outcome || outcome.succeeded || outcome.sessionMode !== "fresh") return [];
|
|
164
|
+
const actions: AgentBrowserNextAction[] = [];
|
|
165
|
+
if (!isFreshPostLaunchFailure(outcome)) {
|
|
166
|
+
actions.push(buildNextToolAction({
|
|
167
|
+
args: ["doctor"],
|
|
168
|
+
id: "run-agent-browser-doctor",
|
|
169
|
+
reason: "Verify agent-browser install, PATH, and environment after a failed fresh launch.",
|
|
170
|
+
safety: "Read-only local diagnostics; does not mutate browser state.",
|
|
171
|
+
}));
|
|
172
|
+
}
|
|
173
|
+
if ((outcome.status === "preserved" || isFreshPostLaunchFailure(outcome)) && outcome.activeAfter && outcome.currentSessionName) {
|
|
174
|
+
const sessionLabel = isFreshPostLaunchFailure(outcome) ? "current managed session" : "preserved managed session";
|
|
175
|
+
actions.push(
|
|
176
|
+
buildNextToolAction({
|
|
177
|
+
args: withOptionalSessionArgs(outcome.currentSessionName, ["get", "url"]),
|
|
178
|
+
id: "verify-current-managed-session",
|
|
179
|
+
reason: `Confirm the ${sessionLabel} before continuing with sessionMode auto.`,
|
|
180
|
+
safety: `Read-only URL check on the ${sessionLabel}.`,
|
|
181
|
+
}),
|
|
182
|
+
buildNextToolAction({
|
|
183
|
+
args: withOptionalSessionArgs(outcome.currentSessionName, ["snapshot", "-i"]),
|
|
184
|
+
id: "snapshot-current-managed-session",
|
|
185
|
+
reason: `Refresh interactive refs on the ${sessionLabel} before retrying the workflow.`,
|
|
186
|
+
safety: "Read-only snapshot; no navigation.",
|
|
187
|
+
}),
|
|
188
|
+
);
|
|
189
|
+
} else {
|
|
190
|
+
actions.push(
|
|
191
|
+
buildNextToolAction({
|
|
192
|
+
args: ["open", "about:blank"],
|
|
193
|
+
id: "retry-fresh-managed-session",
|
|
194
|
+
reason: "Start a new managed browser session after the failed fresh launch.",
|
|
195
|
+
safety: "Replace about:blank with the intended URL from your workflow.",
|
|
196
|
+
sessionMode: "fresh",
|
|
197
|
+
}),
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
return actions;
|
|
174
201
|
}
|
|
175
202
|
|
|
176
203
|
function getTraceOwner(command: string | undefined): TraceOwner | undefined {
|
|
@@ -238,8 +265,7 @@ export function extractNavigationSummaryFromData(data: unknown): NavigationSumma
|
|
|
238
265
|
|
|
239
266
|
export function shouldCaptureNavigationSummary(command: string | undefined, data: unknown): boolean {
|
|
240
267
|
return (
|
|
241
|
-
command
|
|
242
|
-
NAVIGATION_SUMMARY_COMMANDS.has(command) &&
|
|
268
|
+
isNavigationObservableCommandName(command) &&
|
|
243
269
|
(!isRecord(data) || (typeof data.title !== "string" && typeof data.url !== "string"))
|
|
244
270
|
);
|
|
245
271
|
}
|
|
@@ -263,58 +289,6 @@ function extractBatchResultCommand(item: Record<string, unknown>): string[] {
|
|
|
263
289
|
return Array.isArray(item.command) ? item.command.filter((token): token is string => typeof token === "string") : [];
|
|
264
290
|
}
|
|
265
291
|
|
|
266
|
-
function validateUserBatchStep(
|
|
267
|
-
step: unknown,
|
|
268
|
-
index: number,
|
|
269
|
-
):
|
|
270
|
-
| { ok: true; step: BatchCommandStep }
|
|
271
|
-
| { ok: false; error: string } {
|
|
272
|
-
if (!Array.isArray(step)) {
|
|
273
|
-
return {
|
|
274
|
-
ok: false,
|
|
275
|
-
error: `agent_browser batch stdin step ${index} must be a non-empty array of string command tokens.`,
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
if (step.length === 0) {
|
|
279
|
-
return {
|
|
280
|
-
ok: false,
|
|
281
|
-
error: `agent_browser batch stdin step ${index} must not be empty.`,
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
const invalidTokenIndex = step.findIndex((token) => typeof token !== "string");
|
|
285
|
-
if (invalidTokenIndex !== -1) {
|
|
286
|
-
return {
|
|
287
|
-
ok: false,
|
|
288
|
-
error: `agent_browser batch stdin step ${index} token ${invalidTokenIndex} must be a string.`,
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
return { ok: true, step: step as BatchCommandStep };
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
function parseUserBatchStdin(stdin: string | undefined): { error?: string; steps?: BatchCommandStep[] } {
|
|
295
|
-
if (stdin === undefined) {
|
|
296
|
-
return { steps: [] };
|
|
297
|
-
}
|
|
298
|
-
try {
|
|
299
|
-
const parsed = JSON.parse(stdin) as unknown;
|
|
300
|
-
if (!Array.isArray(parsed)) {
|
|
301
|
-
return { error: "agent_browser batch stdin must be a JSON array of command steps." };
|
|
302
|
-
}
|
|
303
|
-
const steps: BatchCommandStep[] = [];
|
|
304
|
-
for (const [index, rawStep] of parsed.entries()) {
|
|
305
|
-
const validated = validateUserBatchStep(rawStep, index);
|
|
306
|
-
if (!validated.ok) {
|
|
307
|
-
return { error: validated.error };
|
|
308
|
-
}
|
|
309
|
-
steps.push(validated.step);
|
|
310
|
-
}
|
|
311
|
-
return { steps };
|
|
312
|
-
} catch (error) {
|
|
313
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
314
|
-
return { error: `agent_browser batch stdin could not be parsed as JSON: ${message}` };
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
292
|
export function getStaleRefArgs(commandTokens: string[], stdin?: string): string[] {
|
|
319
293
|
if (commandTokens[0] !== "batch" || stdin === undefined) {
|
|
320
294
|
return commandTokens;
|
|
@@ -331,7 +305,7 @@ function collectRefsFromTokens(tokens: string[]): string[] {
|
|
|
331
305
|
}
|
|
332
306
|
|
|
333
307
|
export function getGuardedRefUsage(commandTokens: string[], stdin?: string, options: { includeRefsAfterBatchSnapshot?: boolean } = {}): string[] {
|
|
334
|
-
const collectFromStep = (step: string[]) =>
|
|
308
|
+
const collectFromStep = (step: string[]) => isRefGuardedCommand(step[0]) ? collectRefsFromTokens(step) : [];
|
|
335
309
|
if (commandTokens[0] !== "batch" || stdin === undefined) {
|
|
336
310
|
return collectFromStep(commandTokens);
|
|
337
311
|
}
|
|
@@ -357,10 +331,10 @@ function getBatchRefInvalidationMessage(commandTokens: string[], stdin?: string)
|
|
|
357
331
|
priorStepInvalidatesRefs = false;
|
|
358
332
|
}
|
|
359
333
|
const refIds = collectRefsFromTokens(step);
|
|
360
|
-
if (refIds.length > 0 &&
|
|
334
|
+
if (refIds.length > 0 && isRefGuardedCommand(step[0]) && priorStepInvalidatesRefs) {
|
|
361
335
|
return `Batch step ${step[0]} uses page-scoped ref ${refIds.map((refId) => `@${refId}`).join(", ")} after an earlier batch step can navigate or mutate the page. Split the batch, run snapshot -i after the page-changing step, then retry with current refs.`;
|
|
362
336
|
}
|
|
363
|
-
if (
|
|
337
|
+
if (isRefInvalidatingBatchCommand(step[0])) {
|
|
364
338
|
priorStepInvalidatesRefs = true;
|
|
365
339
|
}
|
|
366
340
|
}
|
|
@@ -438,7 +412,7 @@ export function shouldPinSessionTabForCommand(options: {
|
|
|
438
412
|
options.pinningRequired === true &&
|
|
439
413
|
options.sessionName !== undefined &&
|
|
440
414
|
options.command !== undefined &&
|
|
441
|
-
!
|
|
415
|
+
!isSessionTabPinningExcludedCommand(options.command) &&
|
|
442
416
|
supportsPinnedStdinCommand(options)
|
|
443
417
|
);
|
|
444
418
|
}
|
|
@@ -464,7 +438,7 @@ export function buildPinnedBatchPlan(options: {
|
|
|
464
438
|
if (options.commandTokens.length === 0) {
|
|
465
439
|
return undefined;
|
|
466
440
|
}
|
|
467
|
-
const includeNavigationSummary =
|
|
441
|
+
const includeNavigationSummary = isNavigationObservableCommandName(options.command);
|
|
468
442
|
const tabSelectionStep: BatchCommandStep = ["tab", options.selectedTab];
|
|
469
443
|
const commandStep = options.commandTokens as BatchCommandStep;
|
|
470
444
|
const navigationSummarySteps: BatchCommandStep[] = includeNavigationSummary ? [["eval", NAVIGATION_SUMMARY_EVAL]] : [];
|
|
@@ -480,7 +454,7 @@ export function shouldCorrectSessionTabAfterCommand(options: { command?: string;
|
|
|
480
454
|
options.pinningRequired === true &&
|
|
481
455
|
options.sessionName !== undefined &&
|
|
482
456
|
options.command !== undefined &&
|
|
483
|
-
!
|
|
457
|
+
!isSessionTabPostCommandCorrectionExcludedCommand(options.command)
|
|
484
458
|
);
|
|
485
459
|
}
|
|
486
460
|
|
|
@@ -747,7 +721,7 @@ export function formatElectronSessionMismatchText(mismatch: ElectronSessionMisma
|
|
|
747
721
|
}
|
|
748
722
|
|
|
749
723
|
export function shouldInspectElectronPostCommandHealth(command: string | undefined): boolean {
|
|
750
|
-
return
|
|
724
|
+
return isElectronPostCommandHealthCommand(command);
|
|
751
725
|
}
|
|
752
726
|
|
|
753
727
|
export function buildElectronLifecycleNextActions(record: ElectronLaunchRecord): AgentBrowserNextAction[] {
|
|
@@ -20,7 +20,9 @@ import type { SessionArtifactManifest } from "../../results/contracts.js";
|
|
|
20
20
|
import type { RichInputRecoveryDiagnostic, VisibleRefFallbackDiagnostic } from "../../results/selector-recovery.js";
|
|
21
21
|
import type { SessionPageState, SessionRefSnapshot, SessionRefSnapshotInvalidation, SessionTabTarget } from "../../session-page-state.js";
|
|
22
22
|
import type { buildExecutionPlan, CompatibilityWorkaround, OpenResultTabCorrection } from "../../runtime.js";
|
|
23
|
+
import type { PromptPolicy } from "../../prompt-policy.js";
|
|
23
24
|
import type { AgentBrowserExecuteParams, ResolvedAgentBrowserValidInput } from "../input-plan.js";
|
|
25
|
+
import type { BatchCommandStep } from "../batch-stdin.js";
|
|
24
26
|
|
|
25
27
|
export type AgentBrowserToolResult = AgentToolResult<unknown> & { isError?: boolean };
|
|
26
28
|
export type AgentBrowserProcessResult = Awaited<ReturnType<typeof runAgentBrowserProcess>>;
|
|
@@ -30,7 +32,7 @@ export type AgentBrowserResultCategoryDetails = ReturnType<typeof buildAgentBrow
|
|
|
30
32
|
|
|
31
33
|
export type TraceOwner = "profiler" | "trace";
|
|
32
34
|
export type PinnedBatchUnwrapMode = "single-command" | "user-batch";
|
|
33
|
-
export type BatchCommandStep
|
|
35
|
+
export type { BatchCommandStep } from "../batch-stdin.js";
|
|
34
36
|
|
|
35
37
|
export interface BrowserRunContext {
|
|
36
38
|
cwd: string;
|
|
@@ -61,6 +63,7 @@ export interface BrowserRunInputFields {
|
|
|
61
63
|
|
|
62
64
|
export interface BrowserRunState {
|
|
63
65
|
artifactManifest?: SessionArtifactManifest;
|
|
66
|
+
closedManagedSessionNames: Set<string>;
|
|
64
67
|
electronChildProcesses: Map<string, ChildProcess>;
|
|
65
68
|
electronLaunchRecords: Map<string, ElectronLaunchRecord>;
|
|
66
69
|
ephemeralSessionSeed: string;
|
|
@@ -91,6 +94,7 @@ export interface BrowserRunOptions {
|
|
|
91
94
|
input: ResolvedAgentBrowserValidInput;
|
|
92
95
|
onUpdate?: (result: AgentToolResult<unknown>) => void;
|
|
93
96
|
params: AgentBrowserExecuteParams;
|
|
97
|
+
promptPolicy: PromptPolicy;
|
|
94
98
|
sessionPageStateUpdate: ReturnType<SessionPageState["beginUpdate"]>;
|
|
95
99
|
signal?: AbortSignal;
|
|
96
100
|
state: BrowserRunState;
|
|
@@ -120,12 +124,38 @@ export interface OverlayBlockerDiagnostic {
|
|
|
120
124
|
summary: string;
|
|
121
125
|
}
|
|
122
126
|
|
|
127
|
+
export interface ClickDispatchProbeTarget {
|
|
128
|
+
kind: "selector" | "xpath";
|
|
129
|
+
selector: string;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface ClickDispatchProbe {
|
|
133
|
+
marker: string;
|
|
134
|
+
target: ClickDispatchProbeTarget;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export interface ClickDispatchDiagnostic {
|
|
138
|
+
nativeEventCount: number;
|
|
139
|
+
reason: "native-click-produced-no-target-dom-event";
|
|
140
|
+
status: "no-native-event-observed";
|
|
141
|
+
summary: string;
|
|
142
|
+
target: ClickDispatchProbeTarget;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export interface SelectorTextVisibilityCandidate {
|
|
146
|
+
index: number;
|
|
147
|
+
role?: string;
|
|
148
|
+
tagName: string;
|
|
149
|
+
textPreview?: string;
|
|
150
|
+
}
|
|
151
|
+
|
|
123
152
|
export interface SelectorTextVisibilityDiagnostic {
|
|
124
153
|
firstMatchVisible?: boolean;
|
|
125
154
|
firstVisibleTextPreview?: string;
|
|
126
155
|
matchCount: number;
|
|
127
156
|
selector: string;
|
|
128
157
|
summary: string;
|
|
158
|
+
visibleCandidates?: SelectorTextVisibilityCandidate[];
|
|
129
159
|
visibleCount: number;
|
|
130
160
|
}
|
|
131
161
|
|
|
@@ -174,6 +204,11 @@ export interface EvalStdinHint {
|
|
|
174
204
|
suggestion: string;
|
|
175
205
|
}
|
|
176
206
|
|
|
207
|
+
export interface EvalResultWarning {
|
|
208
|
+
reason: string;
|
|
209
|
+
suggestion: string;
|
|
210
|
+
}
|
|
211
|
+
|
|
177
212
|
export interface ArtifactCleanupGuidance {
|
|
178
213
|
explicitArtifactPaths: string[];
|
|
179
214
|
note: string;
|
|
@@ -353,6 +388,7 @@ export interface PreparedBrowserRun {
|
|
|
353
388
|
exactSensitiveValues: string[];
|
|
354
389
|
executionPlan: AgentBrowserExecutionPlan;
|
|
355
390
|
includePinnedNavigationSummary: boolean;
|
|
391
|
+
clickDispatchProbe?: ClickDispatchProbe;
|
|
356
392
|
pinnedBatchUnwrapMode?: PinnedBatchUnwrapMode;
|
|
357
393
|
preparedArgs: PreparedAgentBrowserArgs;
|
|
358
394
|
priorRefSnapshotState?: SessionRefSnapshot;
|
|
@@ -417,6 +453,8 @@ export interface FinalResultInput {
|
|
|
417
453
|
aboutBlankSessionMismatch?: AboutBlankSessionMismatch;
|
|
418
454
|
artifactCleanup?: ArtifactCleanupGuidance;
|
|
419
455
|
categoryDetails: AgentBrowserResultCategoryDetails;
|
|
456
|
+
clickDispatchDiagnostic?: ClickDispatchDiagnostic;
|
|
457
|
+
commandTokens: string[];
|
|
420
458
|
comboboxFocusDiagnostic?: ComboboxFocusDiagnostic;
|
|
421
459
|
compiledNetworkSourceLookup?: CompiledAgentBrowserNetworkSourceLookup;
|
|
422
460
|
compiledSemanticAction?: CompiledAgentBrowserSemanticAction;
|
|
@@ -436,6 +474,7 @@ export interface FinalResultInput {
|
|
|
436
474
|
electronSessionMismatch?: ElectronSessionMismatch;
|
|
437
475
|
errorText?: string;
|
|
438
476
|
evalStdinHint?: EvalStdinHint;
|
|
477
|
+
evalResultWarning?: EvalResultWarning;
|
|
439
478
|
exactSensitiveValues: string[];
|
|
440
479
|
executionPlan: AgentBrowserExecutionPlan;
|
|
441
480
|
fillVerificationDiagnostic?: FillVerificationDiagnostic;
|