pi-agent-browser-native 0.2.77 → 0.3.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 +27 -0
- package/README.md +8 -17
- package/dist/extensions/agent-browser/index.js +127 -19
- package/dist/extensions/agent-browser/lib/argv-descriptor.js +0 -5
- package/dist/extensions/agent-browser/lib/argv-grammar.js +4 -5
- package/dist/extensions/agent-browser/lib/command-policy.js +0 -5
- package/dist/extensions/agent-browser/lib/command-taxonomy.js +0 -6
- package/dist/extensions/agent-browser/lib/config-policy.js +0 -5
- package/dist/extensions/agent-browser/lib/config.js +0 -6
- package/dist/extensions/agent-browser/lib/electron/cdp.js +6 -7
- package/dist/extensions/agent-browser/lib/electron/cleanup.js +0 -7
- package/dist/extensions/agent-browser/lib/electron/discovery.js +0 -7
- package/dist/extensions/agent-browser/lib/electron/launch.js +0 -7
- package/dist/extensions/agent-browser/lib/input-modes/electron.js +0 -5
- package/dist/extensions/agent-browser/lib/input-modes/job.js +0 -5
- package/dist/extensions/agent-browser/lib/input-modes/lookups.js +0 -5
- package/dist/extensions/agent-browser/lib/input-modes/params.js +1 -6
- package/dist/extensions/agent-browser/lib/input-modes/semantic-action.js +0 -5
- package/dist/extensions/agent-browser/lib/input-modes/shared.js +0 -5
- package/dist/extensions/agent-browser/lib/input-modes/types.js +0 -5
- package/dist/extensions/agent-browser/lib/json-schema.js +0 -5
- package/dist/extensions/agent-browser/lib/launch-scoped-flags.js +4 -5
- package/dist/extensions/agent-browser/lib/managed-session-capabilities.js +0 -2
- package/dist/extensions/agent-browser/lib/managed-session-policy-lock.js +0 -3
- package/dist/extensions/agent-browser/lib/managed-session-restore.js +30 -13
- package/dist/extensions/agent-browser/lib/managed-session-snapshots.js +0 -5
- package/dist/extensions/agent-browser/lib/managed-session-state-policy.js +1 -7
- package/dist/extensions/agent-browser/lib/managed-session-storage.js +0 -5
- package/dist/extensions/agent-browser/lib/navigation-policy.js +0 -5
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/diagnostics.js +1 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result.js +41 -30
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-daemon-policy.js +17 -11
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/direct-anchor-download.js +1 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/network-page-filter.js +1 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/scroll-shims.js +1 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-filter.js +1 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare.js +22 -5
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output.js +35 -7
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state.js +17 -1
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/index.js +35 -18
- package/dist/extensions/agent-browser/lib/orchestration/input-plan.js +4 -1
- package/dist/extensions/agent-browser/lib/orchestration/output-file.js +42 -1
- package/dist/extensions/agent-browser/lib/parsing.js +0 -7
- package/dist/extensions/agent-browser/lib/pi-tool-rendering.js +4 -1
- package/dist/extensions/agent-browser/lib/playbook.js +3 -10
- package/dist/extensions/agent-browser/lib/process-identity.js +0 -5
- package/dist/extensions/agent-browser/lib/process.js +0 -7
- package/dist/extensions/agent-browser/lib/prompt-policy.js +171 -27
- package/dist/extensions/agent-browser/lib/results/action-recommendations.js +1 -8
- package/dist/extensions/agent-browser/lib/results/artifact-manifest.js +6 -7
- package/dist/extensions/agent-browser/lib/results/categories.js +1 -8
- package/dist/extensions/agent-browser/lib/results/confirmation.js +0 -7
- package/dist/extensions/agent-browser/lib/results/contracts.js +0 -7
- package/dist/extensions/agent-browser/lib/results/editable-ref-evidence.js +0 -7
- package/dist/extensions/agent-browser/lib/results/envelope.js +0 -7
- package/dist/extensions/agent-browser/lib/results/network.js +0 -7
- package/dist/extensions/agent-browser/lib/results/next-actions.js +0 -30
- package/dist/extensions/agent-browser/lib/results/presentation/artifacts.js +1 -7
- package/dist/extensions/agent-browser/lib/results/presentation/browser-profile-recovery.js +0 -5
- package/dist/extensions/agent-browser/lib/results/presentation/common.js +0 -5
- package/dist/extensions/agent-browser/lib/results/presentation/content.js +0 -5
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostics.js +0 -5
- package/dist/extensions/agent-browser/lib/results/presentation/large-output.js +0 -5
- package/dist/extensions/agent-browser/lib/results/presentation/managed-list-filter.js +0 -5
- package/dist/extensions/agent-browser/lib/results/presentation/navigation.js +0 -5
- package/dist/extensions/agent-browser/lib/results/presentation/semantic-action.js +0 -5
- package/dist/extensions/agent-browser/lib/results/presentation/skills.js +0 -5
- package/dist/extensions/agent-browser/lib/results/presentation.js +0 -5
- package/dist/extensions/agent-browser/lib/results/recovery-actions.js +0 -7
- package/dist/extensions/agent-browser/lib/results/recovery-next-actions.js +0 -7
- package/dist/extensions/agent-browser/lib/results/selector-recovery.js +0 -7
- package/dist/extensions/agent-browser/lib/results/snapshot-high-value-controls.js +0 -7
- package/dist/extensions/agent-browser/lib/results/snapshot-refs.js +0 -7
- package/dist/extensions/agent-browser/lib/results/snapshot-segments.js +0 -7
- package/dist/extensions/agent-browser/lib/results/snapshot-spill.js +0 -7
- package/dist/extensions/agent-browser/lib/results/snapshot.js +0 -7
- package/dist/extensions/agent-browser/lib/results/text.js +0 -7
- package/dist/extensions/agent-browser/lib/runtime.js +4 -14
- package/dist/extensions/agent-browser/lib/session-page-state.js +0 -7
- package/dist/extensions/agent-browser/lib/string-enum-schema.js +0 -5
- package/dist/extensions/agent-browser/lib/temp.js +0 -7
- package/dist/extensions/agent-browser/lib/web-search.js +0 -5
- package/docs/ARCHITECTURE.md +16 -16
- package/docs/COMMAND_REFERENCE.md +8 -7
- package/docs/ELECTRON.md +3 -19
- package/docs/RELEASE.md +5 -17
- package/docs/REQUIREMENTS.md +4 -4
- package/docs/SUPPORT_MATRIX.md +17 -17
- package/docs/TOOL_CONTRACT.md +18 -16
- package/docs/platform-smoke.md +1 -1
- package/package.json +5 -6
- package/scripts/doctor.mjs +1 -1
- package/dist/extensions/agent-browser/lib/electron/text.js +0 -13
- package/dist/extensions/agent-browser/lib/input-modes.js +0 -10
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-artifacts.js +0 -5
- package/dist/extensions/agent-browser/lib/results/artifact-state.js +0 -13
- package/dist/extensions/agent-browser/lib/results.js +0 -14
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Hold tiny shared parsing helpers for structured agent_browser input modes.
|
|
3
|
-
* Responsibilities: Normalize common select values, batch result rows, and workspace scan limits.
|
|
4
|
-
* Scope: Generic input-mode helpers only; mode-specific policy stays in the owning module.
|
|
5
|
-
*/
|
|
6
1
|
import { isRecord } from "../parsing.js";
|
|
7
2
|
import { SOURCE_LOOKUP_DEFAULT_MAX_WORKSPACE_FILES, SOURCE_LOOKUP_MAX_WORKSPACE_FILES } from "./types.js";
|
|
8
3
|
export function getSelectValues(input, context) {
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Define structured agent_browser input-mode constants and TypeScript contracts.
|
|
3
|
-
* Responsibilities: Share schema enums and compiled input-mode result types across input-mode modules.
|
|
4
|
-
* Scope: Types and constants only; validation and compilation live in sibling modules.
|
|
5
|
-
*/
|
|
6
1
|
export const DEFAULT_SESSION_MODE = "auto";
|
|
7
2
|
export const AGENT_BROWSER_SEMANTIC_ACTIONS = ["check", "click", "fill", "select"];
|
|
8
3
|
export const AGENT_BROWSER_SEMANTIC_LOCATORS = ["alt", "label", "placeholder", "role", "testid", "text", "title"];
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Build the small JSON Schema subset used by Pi tool schemas without importing TypeBox at runtime.
|
|
3
|
-
* Responsibilities: Preserve plain JSON Schema objects Pi consumes while keeping extension startup cheap.
|
|
4
|
-
* Scope: Schema construction only; runtime validation still belongs to Pi and the tool input compilers.
|
|
5
|
-
*/
|
|
6
1
|
const OPTIONAL_SCHEMA = Symbol("pi-agent-browser-optional-schema");
|
|
7
2
|
function withOptions(schema, options) {
|
|
8
3
|
return { ...schema, ...(options ?? {}) };
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Canonical launch-scoped agent-browser flag metadata shared by runtime planning and agent-facing guidance.
|
|
3
|
-
* Responsibilities: Define which upstream flags require a fresh launch, explain why, expose stable guidance labels, and share launch-token detection used by runtime and managed restore policy.
|
|
4
|
-
* Scope: Launch-scoped metadata and token classification; broader execution planning lives in runtime.ts.
|
|
5
|
-
*/
|
|
6
1
|
import { findCommandStartIndex } from "./argv-descriptor.js";
|
|
7
2
|
import { isBooleanFlagEnabled, optionalGlobalValueFlagConsumesNext } from "./argv-grammar.js";
|
|
8
3
|
export const LAUNCH_SCOPED_FLAG_DEFINITIONS = [
|
|
@@ -42,6 +37,10 @@ export const LAUNCH_SCOPED_FLAG_DEFINITIONS = [
|
|
|
42
37
|
flag: "--idle-timeout",
|
|
43
38
|
reason: "configures background browser lifecycle for the launched session",
|
|
44
39
|
},
|
|
40
|
+
{
|
|
41
|
+
flag: "--headed",
|
|
42
|
+
reason: "selects whether the launched browser has a visible window",
|
|
43
|
+
},
|
|
45
44
|
{
|
|
46
45
|
flag: "--device",
|
|
47
46
|
reason: "selects the provider device for the upstream launch",
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// Purpose: Identify and redact wrapper-owned managed restore capabilities.
|
|
2
|
-
// Scope: Pure string helpers shared by storage, policy, and presentation paths.
|
|
3
1
|
const MANAGED_SESSION_RESTORE_KEY_PATTERN = /piab-r(?:2)?-[a-f\d]{32}/gi;
|
|
4
2
|
const MANAGED_SESSION_RESTORE_KEY_EXACT_PATTERN = /^piab-r2-[a-f\d]{32}$/i;
|
|
5
3
|
const WRAPPER_MANAGED_SESSION_PREFIX = "piab-";
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// Purpose: Serialize wrapper-owned daemon policy decisions across cooperating Pi processes.
|
|
2
|
-
// Responsibilities: Elect one live claim, bridge the pre-update v2 path, recover proven-dead current-protocol artifacts, and release only the caller's immutable token.
|
|
3
|
-
// Scope: Wrapper coordination only; agent-browser never reads these claims.
|
|
4
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
5
2
|
import { lstat, mkdir, readFile, readdir, rename, rm, writeFile } from "node:fs/promises";
|
|
6
3
|
import { tmpdir } from "node:os";
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Own automatic restore policy for wrapper-managed browser sessions.
|
|
3
|
-
* Responsibilities: Resolve owned session identity, isolate per-call policy, reject incompatible argv/env/config, and persist sticky restore-disable state.
|
|
4
|
-
* Scope: Restore policy only; storage identity and snapshot retention live in focused sibling modules.
|
|
5
|
-
*/
|
|
6
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
7
2
|
import { chmodSync, lstatSync, readFileSync, unlinkSync } from "node:fs";
|
|
8
3
|
import { join } from "node:path";
|
|
9
4
|
import { extractCommandTokens, parseCommandInfo } from "./argv-descriptor.js";
|
|
10
|
-
import { canonicalizeAgentBrowserNamespace, extractExplicitNamespace, extractExplicitSessionName, extractRequestedRestoreKey, getAgentBrowserSessionIdentityKey, scanUpstreamGlobalFlagOccurrences, } from "./argv-grammar.js";
|
|
5
|
+
import { canonicalizeAgentBrowserNamespace, extractExplicitNamespace, extractExplicitSessionName, extractRequestedRestoreKey, getAgentBrowserSessionIdentityKey, isUpstreamEnvFlagEnabled, scanUpstreamGlobalFlagOccurrences, } from "./argv-grammar.js";
|
|
11
6
|
import { hasLaunchScopedFlagToken, MANAGED_RESTORE_INCOMPATIBLE_BOOLEAN_ENVS, MANAGED_RESTORE_INCOMPATIBLE_ENVS, MANAGED_RESTORE_INCOMPATIBLE_FLAGS, } from "./launch-scoped-flags.js";
|
|
12
7
|
import { createManagedSessionRestoreKey, ensureManagedSessionRestoreStorageIsSecure, getManagedSessionRestoreProtectedStorageEnv, hasManagedSessionRestoreProjectIdentity, resolveManagedSessionRestoreHome, } from "./managed-session-storage.js";
|
|
13
8
|
import { parseUserBatchStdin } from "./orchestration/batch-stdin.js";
|
|
@@ -28,10 +23,6 @@ function isDisabledEnvFlag(value) {
|
|
|
28
23
|
return false;
|
|
29
24
|
return ["0", "false", "no", "off"].includes(value.trim().toLowerCase());
|
|
30
25
|
}
|
|
31
|
-
/** Match upstream env_var_is_truthy exactly: lowercase only, without trimming or accepting "off". */
|
|
32
|
-
function isUpstreamEnvFlagEnabled(value) {
|
|
33
|
-
return value !== undefined && !["", "0", "false", "no"].includes(value.toLowerCase());
|
|
34
|
-
}
|
|
35
26
|
function hasUpstreamEnvValue(env, name) {
|
|
36
27
|
return env?.[name] !== undefined;
|
|
37
28
|
}
|
|
@@ -194,11 +185,35 @@ export function getOwnedManagedSessionNamespaceEnv(options) {
|
|
|
194
185
|
const { namespace, owned, ownedContext } = resolveManagedSessionRestorePolicy(options);
|
|
195
186
|
return owned ? { AGENT_BROWSER_NAMESPACE: ownedContext?.namespace ?? namespace ?? "" } : {};
|
|
196
187
|
}
|
|
188
|
+
const DEFAULT_AUTOSAVE_INTERVAL_MS = "30000";
|
|
189
|
+
const MAX_U64 = 18446744073709551615n;
|
|
190
|
+
export function resolveExplicitAutosaveInterval(value) {
|
|
191
|
+
if (value === undefined)
|
|
192
|
+
return undefined;
|
|
193
|
+
if (!/^\+?\d+$/.test(value))
|
|
194
|
+
return DEFAULT_AUTOSAVE_INTERVAL_MS;
|
|
195
|
+
try {
|
|
196
|
+
const parsed = BigInt(value);
|
|
197
|
+
return parsed <= MAX_U64 ? parsed.toString() : DEFAULT_AUTOSAVE_INTERVAL_MS;
|
|
198
|
+
}
|
|
199
|
+
catch {
|
|
200
|
+
return DEFAULT_AUTOSAVE_INTERVAL_MS;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
197
203
|
export function getOwnedManagedSessionCompatibilityEnv(options) {
|
|
198
204
|
const { owned, ownedContext } = resolveManagedSessionRestorePolicy(options);
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
205
|
+
if (!owned || !ownedContext)
|
|
206
|
+
return {};
|
|
207
|
+
const parentEnv = options.parentEnv ?? process.env;
|
|
208
|
+
const callEnv = options.env ?? {};
|
|
209
|
+
const explicitRawInterval = Object.hasOwn(callEnv, "AGENT_BROWSER_AUTOSAVE_INTERVAL_MS")
|
|
210
|
+
? callEnv.AGENT_BROWSER_AUTOSAVE_INTERVAL_MS
|
|
211
|
+
: parentEnv.AGENT_BROWSER_AUTOSAVE_INTERVAL_MS;
|
|
212
|
+
const explicitIntervalMatches = resolveExplicitAutosaveInterval(explicitRawInterval) === ownedContext.headedManagedAutosaveInterval;
|
|
213
|
+
return {
|
|
214
|
+
...(ownedContext.compatibilityUserAgent ? { AGENT_BROWSER_USER_AGENT: ownedContext.compatibilityUserAgent } : {}),
|
|
215
|
+
...(ownedContext.headedManagedAutosaveInterval !== undefined && !explicitIntervalMatches ? { AGENT_BROWSER_AUTOSAVE_INTERVAL_MS: ownedContext.headedManagedAutosaveInterval } : {}),
|
|
216
|
+
};
|
|
202
217
|
}
|
|
203
218
|
export function shouldOmitOwnedManagedSessionRestoreEnv(options) {
|
|
204
219
|
return resolveManagedSessionRestorePolicy(options).owned && closesBrowserSession(options.args);
|
|
@@ -365,6 +380,8 @@ export function buildOwnedManagedSessionRestoreContext(options) {
|
|
|
365
380
|
return {
|
|
366
381
|
...owned,
|
|
367
382
|
compatibilityUserAgent: options.compatibilityUserAgent,
|
|
383
|
+
headedManagedAutosaveDisabled: options.headedManagedAutosaveDisabled,
|
|
384
|
+
headedManagedAutosaveInterval: options.headedManagedAutosaveInterval,
|
|
368
385
|
expectedDaemonRestoreKey: enabled ? restoreKey : extractRequestedRestoreKey(options.args, owned.sessionName, effectiveEnv[AGENT_BROWSER_RESTORE_ENV]),
|
|
369
386
|
protectedStorageEnv: enabled ? getManagedSessionRestoreProtectedStorageEnv(true, effectiveEnv) : undefined,
|
|
370
387
|
restoreDecision: optedOut ? "opted-out" : incompatible ? "incompatible" : "enabled",
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Retain only wrapper-owned managed-restore snapshots after successful close operations.
|
|
3
|
-
* Responsibilities: Persist atomic per-snapshot ownership records, self-heal malformed records, and apply per-key plus superseded-generation retention without deleting unproven paths.
|
|
4
|
-
* Scope: Snapshot ownership and pruning only; restore eligibility and daemon policy live in sibling modules.
|
|
5
|
-
*/
|
|
6
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
7
2
|
import { chmodSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmdirSync, unlinkSync, writeFileSync } from "node:fs";
|
|
8
3
|
import { basename, dirname, isAbsolute, join } from "node:path";
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// Purpose: Prevent native tool calls from crossing wrapper-owned managed-state boundaries.
|
|
2
|
-
// Responsibilities: Guard destructive global state operations, foreign checkout restore/state references, and browser file access to local agent-browser state.
|
|
3
|
-
// Scope: Pre-spawn policy only; result redaction and managed snapshot retention live elsewhere.
|
|
4
1
|
import { realpathSync } from "node:fs";
|
|
5
2
|
import { basename, dirname, isAbsolute, resolve } from "node:path";
|
|
6
3
|
import { fileURLToPath } from "node:url";
|
|
@@ -9,7 +6,7 @@ import { needsManagedSession } from "./command-policy.js";
|
|
|
9
6
|
import { getScreenshotPathTokenIndex } from "./orchestration/browser-run/artifact-paths.js";
|
|
10
7
|
import { parseBatchCommandArgument, parseUserBatchStdin } from "./orchestration/batch-stdin.js";
|
|
11
8
|
import { isUnverifiedPageTransitionCommand } from "./command-taxonomy.js";
|
|
12
|
-
import { GLOBAL_BOOLEAN_FLAGS_WITH_OPTIONAL_VALUES, VALUE_FLAGS, extractExplicitSessionName, optionalGlobalValueFlagConsumesNext, } from "./argv-grammar.js";
|
|
9
|
+
import { GLOBAL_BOOLEAN_FLAGS_WITH_OPTIONAL_VALUES, VALUE_FLAGS, extractExplicitSessionName, isUpstreamEnvFlagEnabled, optionalGlobalValueFlagConsumesNext, } from "./argv-grammar.js";
|
|
13
10
|
import { extractManagedSessionRestoreKeys, isWrapperManagedSessionName } from "./managed-session-capabilities.js";
|
|
14
11
|
import { agentBrowserConfigIsPresent } from "./managed-session-restore.js";
|
|
15
12
|
import { createManagedSessionRestoreKey, hasManagedSessionRestoreProjectIdentity } from "./managed-session-storage.js";
|
|
@@ -262,9 +259,6 @@ function getBrowserFileOperands(args, env) {
|
|
|
262
259
|
values.push(...positionals.slice(1));
|
|
263
260
|
return values.filter((value) => typeof value === "string" && value.length > 0);
|
|
264
261
|
}
|
|
265
|
-
function isUpstreamEnvFlagEnabled(value) {
|
|
266
|
-
return value !== undefined && !["", "0", "false", "no"].includes(value.toLowerCase());
|
|
267
|
-
}
|
|
268
262
|
function rawBrowserArgsEnableFileAccess(args, env) {
|
|
269
263
|
return getRawBrowserArgsValues(args, env).some((value) => typeof value === "string" && /(?:^|[,\p{White_Space}])--(?:allow-file-access(?:-from-files)?|disable-web-security)(?=$|[=,\p{White_Space}])/iu.test(value));
|
|
270
264
|
}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Resolve and secure the filesystem identity used by automatic managed-session restore.
|
|
3
|
-
* Responsibilities: Bind restore keys to one Git checkout generation, validate trusted HOME ancestry, and prepare owner-only upstream state directories.
|
|
4
|
-
* Scope: Filesystem policy only; argv/session ownership and snapshot retention live in sibling modules.
|
|
5
|
-
*/
|
|
6
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
7
2
|
import { linkSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
8
3
|
import { homedir } from "node:os";
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Keep wrapper-side navigation policy parsing and evaluation small and explicit.
|
|
3
|
-
* Responsibilities: Parse allowed-domain argv values and detect final-page host escapes.
|
|
4
|
-
* Scope: Wrapper diagnostics only; upstream remains responsible for browser-time enforcement.
|
|
5
|
-
*/
|
|
6
1
|
function normalizeDomainEntry(value) {
|
|
7
2
|
let candidate = value.trim().toLowerCase();
|
|
8
3
|
if (!candidate)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { stat } from "node:fs/promises";
|
|
2
2
|
import { isAbsolute, resolve } from "node:path";
|
|
3
3
|
import { isCloseCommand, isOpenNavigationCommand } from "../../command-taxonomy.js";
|
|
4
|
-
import { boundElectronProbeString } from "../../electron/
|
|
4
|
+
import { boundElectronProbeString } from "../../electron/cdp.js";
|
|
5
5
|
import { executableExistsOnPath } from "../../executable-path.js";
|
|
6
6
|
import { isHttpOrHttpsUrl } from "../../input-modes/job.js";
|
|
7
7
|
import { formatSessionArtifactRetentionSummary } from "../../results/artifact-manifest.js";
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { cleanupElectronLaunchResources } from "../../electron/cleanup.js";
|
|
2
|
-
import { getCompiledSemanticActionCommandIndex, getCompiledSemanticActionSessionPrefix, isCompiledSemanticActionFindCommand
|
|
3
|
-
import {
|
|
2
|
+
import { getCompiledSemanticActionCommandIndex, getCompiledSemanticActionSessionPrefix, isCompiledSemanticActionFindCommand } from "../../input-modes/semantic-action.js";
|
|
3
|
+
import { redactNetworkSourceLookupSurface } from "../../input-modes/lookups.js";
|
|
4
|
+
import { buildAgentBrowserNextActions } from "../../results/action-recommendations.js";
|
|
5
|
+
import { buildAgentBrowserResultCategoryDetails } from "../../results/categories.js";
|
|
4
6
|
import { formatSessionArtifactRetentionSummary } from "../../results/artifact-manifest.js";
|
|
5
|
-
import {
|
|
7
|
+
import { alignPageChangeSummaryNextActionIds, appendUniqueAgentBrowserNextActions, applyNamespaceToNextActions, isStandaloneSnapshotNextAction, withOptionalSessionArgs, } from "../../results/next-actions.js";
|
|
6
8
|
import { buildConnectedSessionNextActions, buildNoActivePageNextActions, buildSessionAwareStaleRefNextActions, buildSessionTabRecoveryNextActions, } from "../../results/recovery-next-actions.js";
|
|
7
9
|
import { buildRichInputRecoveryDiagnostic, buildRichInputRecoveryNextActions, buildVisibleRefFallbackNextActions, formatRichInputRecoveryText, formatVisibleRefFallbackText, sanitizeVisibleRefFallbackDiagnostic, } from "../../results/selector-recovery.js";
|
|
8
10
|
import { buildNoActivePageRefSnapshotInvalidation, isNoActivePageSnapshotFailure, } from "../../session-page-state.js";
|
|
@@ -257,68 +259,75 @@ function buildDialogTimeoutNextActions(options) {
|
|
|
257
259
|
];
|
|
258
260
|
}
|
|
259
261
|
function buildResultNextActions(options) {
|
|
260
|
-
|
|
262
|
+
let nextActions = options.presentation.nextActions ? [...options.presentation.nextActions] : [];
|
|
263
|
+
const append = (actions) => {
|
|
264
|
+
if (actions && actions.length > 0)
|
|
265
|
+
nextActions.push(...actions);
|
|
266
|
+
};
|
|
267
|
+
const appendUnique = (actions) => {
|
|
268
|
+
appendUniqueAgentBrowserNextActions(nextActions, actions);
|
|
269
|
+
};
|
|
261
270
|
if (options.categoryDetails.resultCategory === "success" && options.executionPlan.commandInfo.command === "connect" && !options.electronLaunchRecord)
|
|
262
|
-
|
|
271
|
+
appendUnique(buildConnectedSessionNextActions(options.executionPlan.sessionName));
|
|
263
272
|
if (options.noActivePageSnapshotFailure)
|
|
264
|
-
|
|
273
|
+
appendUnique(buildNoActivePageNextActions(options.executionPlan.sessionName));
|
|
265
274
|
if (options.aboutBlankSessionMismatch) {
|
|
266
|
-
|
|
275
|
+
appendUnique(buildSessionTabRecoveryNextActions({ kind: "about-blank", recoveryApplied: options.aboutBlankSessionMismatch.recoveryApplied, sessionName: options.executionPlan.sessionName, tabCorrection: options.aboutBlankSessionMismatch.recoveryApplied ? options.sessionTabCorrection : undefined, target: { title: options.aboutBlankSessionMismatch.targetTitle, url: options.aboutBlankSessionMismatch.targetUrl } }));
|
|
267
276
|
if (!options.aboutBlankSessionMismatch.recoveryApplied)
|
|
268
|
-
|
|
277
|
+
nextActions = nextActions.filter((action) => !isStandaloneSnapshotNextAction(action));
|
|
269
278
|
}
|
|
270
279
|
else if (options.categoryDetails.resultCategory === "success" && (options.sessionTabCorrection || options.openResultTabCorrection))
|
|
271
|
-
|
|
280
|
+
appendUnique(buildSessionTabRecoveryNextActions({ kind: "tab-drift", recoveryApplied: true, sessionName: options.executionPlan.sessionName, tabCorrection: options.sessionTabCorrection ?? options.openResultTabCorrection, target: options.currentSessionTabTarget ?? options.priorSessionTabTarget }));
|
|
272
281
|
if (options.categoryDetails.failureCategory === "stale-ref")
|
|
273
|
-
|
|
282
|
+
nextActions = [...buildSessionAwareStaleRefNextActions(options.executionPlan.sessionName)];
|
|
274
283
|
if (options.visibleRefFallbackDiagnostic)
|
|
275
|
-
|
|
284
|
+
append(buildVisibleRefFallbackNextActions({ diagnostic: options.visibleRefFallbackDiagnostic, sessionName: options.visibleRefFallbackSessionName }));
|
|
276
285
|
if (options.richInputRecoveryDiagnostic)
|
|
277
|
-
|
|
286
|
+
append(buildRichInputRecoveryNextActions({ diagnostic: options.richInputRecoveryDiagnostic, sessionName: options.visibleRefFallbackSessionName }));
|
|
278
287
|
if (options.electronPostCommandHealth) {
|
|
279
288
|
const electronRecord = options.electronLaunchRecords.get(options.electronPostCommandHealth.launchId);
|
|
280
289
|
if (electronRecord)
|
|
281
|
-
|
|
290
|
+
appendUnique(buildElectronLifecycleNextActions(electronRecord));
|
|
282
291
|
}
|
|
283
292
|
if (options.electronSessionMismatch) {
|
|
284
293
|
const electronRecord = options.electronLaunchRecords.get(options.electronSessionMismatch.launchId);
|
|
285
294
|
if (electronRecord)
|
|
286
|
-
|
|
295
|
+
appendUnique(buildElectronMismatchNextActions(electronRecord, options.electronSessionMismatch.liveTarget));
|
|
287
296
|
}
|
|
288
297
|
if (options.categoryDetails.failureCategory === "selector-not-found" && options.redactedCompiledSemanticAction) {
|
|
289
298
|
const candidateActions = buildSemanticActionCandidateActions(options.redactedCompiledSemanticAction);
|
|
290
299
|
if (candidateActions.length > 0)
|
|
291
|
-
|
|
300
|
+
append(candidateActions);
|
|
292
301
|
}
|
|
293
302
|
if (options.overlayBlockerDiagnostic)
|
|
294
|
-
|
|
303
|
+
append(buildOverlayBlockerNextActions({ diagnostic: options.overlayBlockerDiagnostic, sessionName: options.executionPlan.sessionName }));
|
|
295
304
|
if (options.fillVerificationDiagnostic)
|
|
296
|
-
|
|
305
|
+
appendUnique(buildFillVerificationNextActions(options.fillVerificationDiagnostic, options.executionPlan.sessionName));
|
|
297
306
|
if (options.electronRefFreshnessDiagnostic)
|
|
298
|
-
|
|
307
|
+
appendUnique(buildElectronRefFreshnessNextActions(options.executionPlan.sessionName));
|
|
299
308
|
if (options.selectorTextVisibilityDiagnostics.length > 0)
|
|
300
|
-
|
|
309
|
+
append(buildSelectorTextVisibilityNextActions({ diagnostics: options.selectorTextVisibilityDiagnostics, sessionName: options.executionPlan.sessionName }));
|
|
301
310
|
if (options.electronBroadGetTextScopeDiagnostics.length > 0)
|
|
302
|
-
|
|
311
|
+
append(buildElectronBroadGetTextScopeNextActions({ diagnostics: options.electronBroadGetTextScopeDiagnostics, sessionName: options.executionPlan.sessionName }));
|
|
303
312
|
if (options.sourceLookup?.electronContext)
|
|
304
|
-
|
|
313
|
+
appendUnique(buildSourceLookupElectronNextActions(options.sourceLookup));
|
|
305
314
|
if (options.clickDispatchDiagnostic)
|
|
306
|
-
|
|
315
|
+
append(buildClickDispatchNextActions({ commandTokens: options.commandTokens, diagnostic: options.clickDispatchDiagnostic, sessionName: options.executionPlan.sessionName }));
|
|
307
316
|
if (options.scrollNoopDiagnostic)
|
|
308
|
-
|
|
317
|
+
append(buildScrollNoopNextActions(options.executionPlan.sessionName));
|
|
309
318
|
if (options.comboboxFocusDiagnostic)
|
|
310
|
-
|
|
319
|
+
append(buildComboboxFocusNextActions(options.executionPlan.sessionName));
|
|
311
320
|
if (options.managedSessionOutcome)
|
|
312
|
-
|
|
321
|
+
appendUnique(buildManagedSessionFreshFailureNextActions(options.managedSessionOutcome));
|
|
313
322
|
if (options.categoryDetails.failureCategory === "timeout" && options.processResult.timedOut) {
|
|
314
|
-
|
|
315
|
-
|
|
323
|
+
appendUnique(buildTimeoutPartialProgressNextActions(options));
|
|
324
|
+
appendUnique(buildDialogTimeoutNextActions({ command: options.executionPlan.commandInfo.command, sessionName: options.executionPlan.sessionName }));
|
|
316
325
|
}
|
|
317
326
|
if (options.categoryDetails.failureCategory === "stale-ref" && options.redactedCompiledSemanticAction && isCompiledSemanticActionFindCommand(options.compiledSemanticAction))
|
|
318
|
-
|
|
327
|
+
append([{ id: "retry-semantic-action-after-stale-ref", params: { args: options.redactedCompiledSemanticAction.args }, reason: "Retry the same semantic target via its compiled find command after the upstream stale-ref failure proves the prior action did not execute.", safety: "Use only for the same intended target; direct stale @refs still require a fresh snapshot or stable locator before retrying.", tool: "agent_browser" }]);
|
|
319
328
|
if (options.electronLaunchRecord)
|
|
320
|
-
|
|
321
|
-
return
|
|
329
|
+
append(buildAgentBrowserNextActions({ electron: { launchId: options.electronLaunchRecord.launchId, sessionName: options.electronLaunchRecord.sessionName, status: options.electronLaunchRecord.cleanupState }, failureCategory: options.categoryDetails.failureCategory, resultCategory: options.categoryDetails.resultCategory, successCategory: options.categoryDetails.successCategory }));
|
|
330
|
+
return nextActions.length > 0 ? nextActions : undefined;
|
|
322
331
|
}
|
|
323
332
|
function buildAgentBrowserResultDetails(options, nextActions) {
|
|
324
333
|
const publicVisibleRefFallbackDiagnostic = options.visibleRefFallbackDiagnostic ? sanitizeVisibleRefFallbackDiagnostic(options.visibleRefFallbackDiagnostic) : undefined;
|
|
@@ -358,6 +367,8 @@ function buildAgentBrowserResultDetails(options, nextActions) {
|
|
|
358
367
|
fullOutputPath: options.parseFailureOutput.fullOutputPath ?? options.presentation.fullOutputPath,
|
|
359
368
|
fullOutputPaths: options.presentation.fullOutputPaths,
|
|
360
369
|
fullOutputUnavailable: options.parseFailureOutput.fullOutputUnavailable,
|
|
370
|
+
managedSessionHeadedAutosaveDisabled: options.managedSessionHeadedAutosaveDisabled,
|
|
371
|
+
managedSessionHeadedAutosaveInterval: options.managedSessionHeadedAutosaveInterval,
|
|
361
372
|
managedSessionOutcome: options.managedSessionOutcome,
|
|
362
373
|
imagePath: options.presentation.imagePath,
|
|
363
374
|
imagePaths: options.presentation.imagePaths,
|
package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-daemon-policy.js
CHANGED
|
@@ -1,24 +1,28 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Coordinate wrapper-owned managed-session daemon inspection, reuse, and cleanup policy.
|
|
3
|
-
* Responsibilities: Serialize daemon policy decisions, verify live restore keys, and close owned sessions with snapshot cleanup.
|
|
4
|
-
* Scope: Managed-session daemon policy only; page state and browser-result shaping live in sibling modules.
|
|
5
|
-
* Usage: Called by browser-run preparation, Electron host probes, result handling, and extension shutdown cleanup.
|
|
6
|
-
* Invariants/Assumptions: Every owned daemon decision holds the cross-process policy lock until its caller finishes the related operation.
|
|
7
|
-
*/
|
|
8
1
|
import { rm } from "node:fs/promises";
|
|
9
2
|
import { acquireManagedSessionPolicyLock } from "../../managed-session-policy-lock.js";
|
|
10
|
-
import { pruneOwnedManagedSessionRestoreSnapshots, } from "../../managed-session-restore.js";
|
|
3
|
+
import { pruneOwnedManagedSessionRestoreSnapshots, resolveExplicitAutosaveInterval, } from "../../managed-session-restore.js";
|
|
11
4
|
import { isManagedSessionRestoreKey } from "../../managed-session-storage.js";
|
|
12
5
|
import { isRecord } from "../../parsing.js";
|
|
13
6
|
import { runAgentBrowserProcess } from "../../process.js";
|
|
14
|
-
import { getAgentBrowserErrorText, parseAgentBrowserEnvelope } from "../../results.js";
|
|
7
|
+
import { getAgentBrowserErrorText, parseAgentBrowserEnvelope } from "../../results/envelope.js";
|
|
15
8
|
import { redactInvocationArgs } from "../../runtime.js";
|
|
16
|
-
const MANAGED_SESSION_DAEMON_INSPECTION_TIMEOUT_MS =
|
|
9
|
+
const MANAGED_SESSION_DAEMON_INSPECTION_TIMEOUT_MS = 35_000;
|
|
10
|
+
const RUNNING_HEADED_AUTOSAVE_POLICY_CHANGE_ERROR = "AGENT_BROWSER_AUTOSAVE_INTERVAL_MS cannot change a running wrapper-owned headed session's launch-time periodic autosave interval. Close that session first, then retry with sessionMode: \"fresh\" so the new daemon starts with the requested interval.";
|
|
11
|
+
export function getRunningHeadedAutosavePolicyChangeError(recordedInterval, closeCommand = false) {
|
|
12
|
+
const explicitInterval = resolveExplicitAutosaveInterval(process.env.AGENT_BROWSER_AUTOSAVE_INTERVAL_MS);
|
|
13
|
+
return recordedInterval !== undefined && !closeCommand && explicitInterval !== undefined && explicitInterval !== recordedInterval
|
|
14
|
+
? RUNNING_HEADED_AUTOSAVE_POLICY_CHANGE_ERROR
|
|
15
|
+
: undefined;
|
|
16
|
+
}
|
|
17
|
+
function getHeadedManagedAutosaveEnv(interval) {
|
|
18
|
+
return interval !== undefined ? { AGENT_BROWSER_AUTOSAVE_INTERVAL_MS: interval } : undefined;
|
|
19
|
+
}
|
|
17
20
|
export async function inspectManagedSessionDaemon(options) {
|
|
18
21
|
const processResult = await runAgentBrowserProcess({
|
|
19
22
|
allowManagedSessionTarget: options.allowManagedSessionTarget,
|
|
20
23
|
args: ["--json", "--namespace", options.namespace ?? "", "--session", options.sessionName, "session", "info"],
|
|
21
24
|
cwd: options.cwd,
|
|
25
|
+
env: getHeadedManagedAutosaveEnv(options.headedManagedAutosaveInterval),
|
|
22
26
|
preserveAttachedBrowserSession: options.preserveAttachedBrowserSession,
|
|
23
27
|
signal: options.signal,
|
|
24
28
|
timeoutMs: options.timeoutMs ?? MANAGED_SESSION_DAEMON_INSPECTION_TIMEOUT_MS,
|
|
@@ -65,6 +69,7 @@ export async function acquireOwnedManagedSessionDaemonPolicy(options) {
|
|
|
65
69
|
const daemon = await inspectManagedSessionDaemon({
|
|
66
70
|
allowManagedSessionTarget: true,
|
|
67
71
|
cwd: context.cwd,
|
|
72
|
+
headedManagedAutosaveInterval: context.headedManagedAutosaveInterval,
|
|
68
73
|
namespace: context.namespace,
|
|
69
74
|
sessionName: context.sessionName,
|
|
70
75
|
signal,
|
|
@@ -128,6 +133,7 @@ export async function closeManagedSession(options) {
|
|
|
128
133
|
const daemon = await inspectManagedSessionDaemon({
|
|
129
134
|
allowManagedSessionTarget: true,
|
|
130
135
|
cwd: options.cwd,
|
|
136
|
+
headedManagedAutosaveInterval: options.headedManagedAutosaveInterval,
|
|
131
137
|
namespace: options.namespace,
|
|
132
138
|
preserveAttachedBrowserSession: options.preserveAttachedBrowserSession,
|
|
133
139
|
sessionName: options.sessionName,
|
|
@@ -142,7 +148,7 @@ export async function closeManagedSession(options) {
|
|
|
142
148
|
const processResult = await runAgentBrowserProcess({
|
|
143
149
|
args: closeArgs,
|
|
144
150
|
cwd: options.cwd,
|
|
145
|
-
env: { AGENT_BROWSER_JSON: "1" },
|
|
151
|
+
env: { AGENT_BROWSER_JSON: "1", ...getHeadedManagedAutosaveEnv(options.headedManagedAutosaveInterval) },
|
|
146
152
|
managedSessionRestoreState: options.restoreState,
|
|
147
153
|
ownedManagedSession: true,
|
|
148
154
|
preserveAttachedBrowserSession: options.preserveAttachedBrowserSession,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mkdir, stat, writeFile } from "node:fs/promises";
|
|
2
2
|
import { dirname, resolve } from "node:path";
|
|
3
3
|
import { isRecord } from "../../../parsing.js";
|
|
4
|
-
import { buildAgentBrowserResultCategoryDetails } from "../../../results.js";
|
|
4
|
+
import { buildAgentBrowserResultCategoryDetails } from "../../../results/categories.js";
|
|
5
5
|
import { formatSessionArtifactRetentionSummary, mergeSessionArtifactManifest } from "../../../results/artifact-manifest.js";
|
|
6
6
|
import { redactSensitiveText } from "../../../runtime.js";
|
|
7
7
|
import { buildSessionDetailFields, runSessionCommandData } from "../session-state.js";
|
package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/network-page-filter.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isRecord } from "../../../parsing.js";
|
|
2
|
-
import { buildAgentBrowserResultCategoryDetails } from "../../../results.js";
|
|
2
|
+
import { buildAgentBrowserResultCategoryDetails } from "../../../results/categories.js";
|
|
3
3
|
import { redactSensitiveText } from "../../../runtime.js";
|
|
4
4
|
import { buildSessionDetailFields, runSessionCommandData } from "../session-state.js";
|
|
5
5
|
function parseNetworkRequestsPageFilterRequest(commandTokens) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isRecord } from "../../../parsing.js";
|
|
2
|
-
import { buildAgentBrowserResultCategoryDetails } from "../../../results.js";
|
|
2
|
+
import { buildAgentBrowserResultCategoryDetails } from "../../../results/categories.js";
|
|
3
3
|
import { applyNamespaceToNextActions } from "../../../results/next-actions.js";
|
|
4
4
|
import { buildScrollNoopNextActions } from "../diagnostics.js";
|
|
5
5
|
import { buildSessionDetailFields, runSessionCommandData } from "../session-state.js";
|
package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-filter.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isRecord } from "../../../parsing.js";
|
|
2
|
-
import { buildAgentBrowserResultCategoryDetails } from "../../../results.js";
|
|
2
|
+
import { buildAgentBrowserResultCategoryDetails } from "../../../results/categories.js";
|
|
3
3
|
import { buildSnapshotPresentation } from "../../../results/snapshot.js";
|
|
4
4
|
import { extractRefSnapshotFromData } from "../../../session-page-state.js";
|
|
5
5
|
import { collectScrollPositionSnapshot } from "../diagnostics.js";
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import { copyFile, mkdir } from "node:fs/promises";
|
|
2
2
|
import { dirname, resolve } from "node:path";
|
|
3
|
+
import { getBooleanFlagValue, isUpstreamEnvFlagEnabled } from "../../argv-grammar.js";
|
|
3
4
|
import { isCloseCommand } from "../../command-taxonomy.js";
|
|
4
5
|
import { cleanupElectronLaunchResources } from "../../electron/cleanup.js";
|
|
5
6
|
import { launchElectronApp } from "../../electron/launch.js";
|
|
6
7
|
import { pathExists } from "../../fs-utils.js";
|
|
7
|
-
import { getCompiledSemanticActionSessionPrefix } from "../../input-modes.js";
|
|
8
|
+
import { getCompiledSemanticActionSessionPrefix } from "../../input-modes/semantic-action.js";
|
|
8
9
|
import { tryDirectAnchorDownload } from "./prepare/direct-anchor-download.js";
|
|
9
10
|
import { tryNetworkRequestsPageFilter } from "./prepare/network-page-filter.js";
|
|
10
11
|
import { tryContainerScroll, tryPageScrollTo } from "./prepare/scroll-shims.js";
|
|
11
12
|
import { trySnapshotFilter } from "./prepare/snapshot-filter.js";
|
|
12
13
|
import { commandTimeoutNeedsActivePageUrl, getCommandAwareProcessTimeoutMs } from "./prepare/wait-timeouts.js";
|
|
13
|
-
import { getPersistentSessionArtifactStore } from "./session-
|
|
14
|
-
import { buildAgentBrowserResultCategoryDetails } from "../../results.js";
|
|
14
|
+
import { getPersistentSessionArtifactStore } from "./session-state.js";
|
|
15
|
+
import { buildAgentBrowserResultCategoryDetails } from "../../results/categories.js";
|
|
15
16
|
import { applyNamespaceToNextActions } from "../../results/next-actions.js";
|
|
16
17
|
import { buildSessionAwareStaleRefNextActions, buildSessionTabRecoveryNextActions } from "../../results/recovery-next-actions.js";
|
|
17
18
|
import { resolveVisibleRefActionFromSnapshot } from "../../results/selector-recovery.js";
|
|
18
19
|
import { extractRefSnapshotFromData } from "../../session-page-state.js";
|
|
19
20
|
import { buildExecutionPlan, createFreshSessionName, extractCommandTokens, getDefaultHeadlessCompatUserAgent, redactInvocationArgs, } from "../../runtime.js";
|
|
20
|
-
import { buildOwnedManagedSessionRestoreContext, canonicalizeOwnedManagedSessionCloseArgs, withOwnedManagedSessionContext, } from "../../managed-session-restore.js";
|
|
21
|
+
import { buildOwnedManagedSessionRestoreContext, canonicalizeOwnedManagedSessionCloseArgs, resolveExplicitAutosaveInterval, withOwnedManagedSessionContext, } from "../../managed-session-restore.js";
|
|
21
22
|
import { getCallerOwnedSessionLivePageVerificationRequirement, getManagedSessionStateAccessValidationError, getManagedSessionTargetAccessValidationError, } from "../../managed-session-state-policy.js";
|
|
22
|
-
import { acquireOwnedManagedSessionDaemonPolicy } from "./managed-session-daemon-policy.js";
|
|
23
|
+
import { acquireOwnedManagedSessionDaemonPolicy, getRunningHeadedAutosavePolicyChangeError } from "./managed-session-daemon-policy.js";
|
|
23
24
|
import { applyOpenResultTabCorrection, buildManagedSessionOutcome, buildPinnedBatchPlan, buildSessionDetailFields, buildStaleRefPreflight, getSessionContextKey, extractStringResultField, collectAnySessionTabSelection, collectSessionTabSelection, getGuardedRefUsage, getTraceOwnerGuardMessage, runSessionCommandData, shouldPinSessionTabForCommand, } from "./session-state.js";
|
|
24
25
|
import { parseBatchStdinJsonArray } from "../batch-stdin.js";
|
|
25
26
|
import { buildElectronHostFailureResult, getElectronLaunchFailureCategory, redactRecoveryHint } from "./final-result.js";
|
|
@@ -397,11 +398,27 @@ export async function prepareBrowserRun(options) {
|
|
|
397
398
|
if (!executionPlan.validationError && managedStateAccessError)
|
|
398
399
|
executionPlan = { ...executionPlan, recoveryHint: undefined, validationError: managedStateAccessError };
|
|
399
400
|
const recordedOwnedSession = ownedSessionKey ? state.ownedManagedSessions.get(ownedSessionKey) : undefined;
|
|
401
|
+
const targetsCurrentManagedSession = state.managedSessionActive
|
|
402
|
+
&& ownedSessionKey === getSessionContextKey(state.managedSessionName, state.managedSessionNamespace);
|
|
403
|
+
const retainedHeadedAutosaveDisabled = recordedOwnedSession?.headedManagedAutosaveDisabled === true
|
|
404
|
+
|| (targetsCurrentManagedSession && state.managedSessionHeadedAutosaveDisabled === true);
|
|
405
|
+
const retainedHeadedAutosaveInterval = recordedOwnedSession?.headedManagedAutosaveInterval
|
|
406
|
+
?? (targetsCurrentManagedSession ? state.managedSessionHeadedAutosaveInterval : undefined);
|
|
407
|
+
const explicitAutosaveInterval = resolveExplicitAutosaveInterval(process.env.AGENT_BROWSER_AUTOSAVE_INTERVAL_MS);
|
|
408
|
+
const autosavePolicyChangeError = getRunningHeadedAutosavePolicyChangeError(retainedHeadedAutosaveInterval, isCloseCommand(executionPlan.commandInfo.command));
|
|
409
|
+
if (!executionPlan.validationError && autosavePolicyChangeError) {
|
|
410
|
+
executionPlan = { ...executionPlan, recoveryHint: undefined, validationError: autosavePolicyChangeError };
|
|
411
|
+
}
|
|
412
|
+
const headedLaunch = getBooleanFlagValue(executionPlan.effectiveArgs, "--headed") ?? isUpstreamEnvFlagEnabled(process.env.AGENT_BROWSER_HEADED);
|
|
413
|
+
const headedManagedAutosaveDisabled = retainedHeadedAutosaveDisabled || (explicitAutosaveInterval === undefined && headedLaunch);
|
|
414
|
+
const headedManagedAutosaveInterval = retainedHeadedAutosaveInterval ?? (headedLaunch ? explicitAutosaveInterval ?? "0" : undefined);
|
|
400
415
|
const ownedManagedSession = buildOwnedManagedSessionRestoreContext({
|
|
401
416
|
args: executionPlan.effectiveArgs,
|
|
402
417
|
cwd: recordedOwnedSession?.cwd ?? cwd,
|
|
403
418
|
currentManagedSessionName: state.managedSessionName,
|
|
404
419
|
currentManagedSessionNamespace: state.managedSessionNamespace,
|
|
420
|
+
headedManagedAutosaveDisabled,
|
|
421
|
+
headedManagedAutosaveInterval,
|
|
405
422
|
managedSessionName: executionPlan.managedSessionName,
|
|
406
423
|
namespace: executionPlan.namespace,
|
|
407
424
|
recordedOwnedSession,
|