pi-agent-browser-native 0.9.3 → 0.9.4
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 +77 -5
- package/README.md +103 -81
- package/dist/extensions/agent-browser/index.js +43057 -2031
- package/dist/extensions/agent-browser/lib/argv-descriptor.js +49 -26
- package/dist/extensions/agent-browser/lib/argv-grammar.js +82 -93
- package/dist/extensions/agent-browser/lib/bash-guard.js +129 -126
- package/dist/extensions/agent-browser/lib/batch-lifecycle.js +112 -51
- package/dist/extensions/agent-browser/lib/browser-execution-claim-codec.js +61 -0
- package/dist/extensions/agent-browser/lib/browser-execution-claim-storage.js +232 -0
- package/dist/extensions/agent-browser/lib/browser-execution-claims.js +202 -0
- package/dist/extensions/agent-browser/lib/browser-execution-identity.js +77 -0
- package/dist/extensions/agent-browser/lib/browser-journal-branch.js +98 -0
- package/dist/extensions/agent-browser/lib/browser-journal-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/browser-journal-projection.js +221 -0
- package/dist/extensions/agent-browser/lib/browser-journal-reader.js +89 -0
- package/dist/extensions/agent-browser/lib/browser-journal-replay.js +246 -0
- package/dist/extensions/agent-browser/lib/browser-journal.js +103 -394
- package/dist/extensions/agent-browser/lib/browser-legacy-pages.js +220 -0
- package/dist/extensions/agent-browser/lib/browser-legacy-projection.js +282 -0
- package/dist/extensions/agent-browser/lib/browser-legacy-types.js +1 -0
- package/dist/extensions/agent-browser/lib/browser-session-conversion-stream.js +217 -0
- package/dist/extensions/agent-browser/lib/browser-session-conversion.js +80 -335
- package/dist/extensions/agent-browser/lib/browser-transcript-contracts.js +35 -0
- package/dist/extensions/agent-browser/lib/browser-transcript-validation.js +166 -0
- package/dist/extensions/agent-browser/lib/browser-transcript.js +137 -82
- package/dist/extensions/agent-browser/lib/browser-value-parsing.js +15 -0
- package/dist/extensions/agent-browser/lib/command-capabilities.js +340 -0
- package/dist/extensions/agent-browser/lib/command-policy.js +107 -88
- package/dist/extensions/agent-browser/lib/command-taxonomy.js +49 -322
- package/dist/extensions/agent-browser/lib/config-policy.js +138 -343
- package/dist/extensions/agent-browser/lib/config-providers.js +71 -0
- package/dist/extensions/agent-browser/lib/config-validation.js +218 -0
- package/dist/extensions/agent-browser/lib/config.js +19 -7
- package/dist/extensions/agent-browser/lib/electron/cdp.js +15 -7
- package/dist/extensions/agent-browser/lib/electron/cleanup.js +134 -55
- package/dist/extensions/agent-browser/lib/electron/discovery-darwin.js +109 -0
- package/dist/extensions/agent-browser/lib/electron/discovery-desktop.js +136 -0
- package/dist/extensions/agent-browser/lib/electron/discovery-evidence.js +89 -0
- package/dist/extensions/agent-browser/lib/electron/discovery-linux.js +93 -0
- package/dist/extensions/agent-browser/lib/electron/discovery-packages.js +162 -0
- package/dist/extensions/agent-browser/lib/electron/discovery-types.js +2 -0
- package/dist/extensions/agent-browser/lib/electron/discovery.js +140 -549
- package/dist/extensions/agent-browser/lib/electron/launch-monitor.js +102 -0
- package/dist/extensions/agent-browser/lib/electron/launch-process.js +209 -0
- package/dist/extensions/agent-browser/lib/electron/launch-types.js +2 -0
- package/dist/extensions/agent-browser/lib/electron/launch.js +249 -354
- package/dist/extensions/agent-browser/lib/executable-path.js +21 -12
- package/dist/extensions/agent-browser/lib/execution-cwd.js +35 -18
- package/dist/extensions/agent-browser/lib/input-modes/electron.js +162 -121
- package/dist/extensions/agent-browser/lib/input-modes/job.js +116 -313
- package/dist/extensions/agent-browser/lib/input-modes/lookup-network-evidence.js +104 -0
- package/dist/extensions/agent-browser/lib/input-modes/lookup-plan.js +132 -0
- package/dist/extensions/agent-browser/lib/input-modes/lookup-redaction.js +57 -0
- package/dist/extensions/agent-browser/lib/input-modes/lookup-source-evidence.js +151 -0
- package/dist/extensions/agent-browser/lib/input-modes/lookup-workspace.js +142 -0
- package/dist/extensions/agent-browser/lib/input-modes/lookups.js +57 -412
- package/dist/extensions/agent-browser/lib/input-modes/params.js +63 -17
- package/dist/extensions/agent-browser/lib/input-modes/qa-analysis.js +268 -0
- package/dist/extensions/agent-browser/lib/input-modes/qa-presentation.js +117 -0
- package/dist/extensions/agent-browser/lib/input-modes/script-child.js +396 -0
- package/dist/extensions/agent-browser/lib/input-modes/script-protocol.js +86 -0
- package/dist/extensions/agent-browser/lib/input-modes/script-types.js +1 -0
- package/dist/extensions/agent-browser/lib/input-modes/script-validation.js +60 -0
- package/dist/extensions/agent-browser/lib/input-modes/script.js +60 -409
- package/dist/extensions/agent-browser/lib/input-modes/semantic-action.js +218 -128
- package/dist/extensions/agent-browser/lib/input-modes/shared.js +15 -4
- package/dist/extensions/agent-browser/lib/input-modes/types.js +56 -7
- package/dist/extensions/agent-browser/lib/json-schema.js +22 -10
- package/dist/extensions/agent-browser/lib/launch-scoped-flags.js +17 -5
- package/dist/extensions/agent-browser/lib/managed-session-policy-lock.js +92 -425
- package/dist/extensions/agent-browser/lib/managed-session-posix-storage.js +58 -0
- package/dist/extensions/agent-browser/lib/managed-session-project-identity.js +244 -0
- package/dist/extensions/agent-browser/lib/managed-session-restore-context.js +84 -0
- package/dist/extensions/agent-browser/lib/managed-session-restore-policy.js +119 -0
- package/dist/extensions/agent-browser/lib/managed-session-restore-state.js +83 -0
- package/dist/extensions/agent-browser/lib/managed-session-restore.js +168 -300
- package/dist/extensions/agent-browser/lib/managed-session-snapshot-records.js +277 -0
- package/dist/extensions/agent-browser/lib/managed-session-snapshots.js +128 -305
- package/dist/extensions/agent-browser/lib/managed-session-storage.js +56 -253
- package/dist/extensions/agent-browser/lib/native-confirmation.js +140 -0
- package/dist/extensions/agent-browser/lib/native-output.js +43 -9
- package/dist/extensions/agent-browser/lib/orchestration/batch-stdin.js +106 -59
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/artifact-merge.js +14 -6
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/artifact-paths.js +109 -57
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/browser-observation-result.js +82 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/click-dispatch.js +164 -60
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/diagnostic-values.js +31 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/diagnostics.js +152 -781
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/electron-observation.js +202 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/electron-text-diagnostics.js +109 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/fill-diagnostics.js +119 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-action-recovery.js +147 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-actions.js +144 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-content.js +123 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-details.js +156 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-electron.js +179 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-evidence.js +39 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-missing-binary.js +89 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-recovery.js +97 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-redaction.js +106 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-timeout.js +110 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result.js +41 -538
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/index.js +199 -154
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/interaction-diagnostics.js +290 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-close.js +167 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-daemon-inspection.js +108 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-daemon-policy.js +127 -205
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/native-helper-observation.js +65 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/observation-types.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/overlay-diagnostics.js +120 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/network-page-filter.js +113 -30
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/scroll-shims.js +109 -28
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-filter-data.js +150 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-filter.js +138 -253
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-rendered-text.js +147 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/wait-timeouts.js +59 -24
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-artifacts.js +159 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-command.js +131 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-daemon.js +93 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-failure.js +42 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-guards.js +242 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-input.js +75 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-observations.js +92 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-page-selection.js +254 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-page-state.js +121 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-refs.js +130 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-resources.js +114 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-semantic.js +121 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-session-plan.js +222 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-timeouts.js +68 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare.js +176 -1123
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-analysis.js +191 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-confirmation.js +152 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-diagnostics.js +182 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-electron.js +150 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle-phase-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle-phase.js +115 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle.js +256 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-managed-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-managed.js +256 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-native-phase-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-native-phase.js +93 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-native.js +113 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-navigation-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-navigation.js +316 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-ownership.js +28 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-page-phase-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-page-phase.js +142 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-presentation-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-presentation.js +333 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-publication-phase-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-publication-phase.js +71 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-publication.js +201 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-receipts.js +183 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-refs.js +200 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-tabs.js +142 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output.js +18 -968
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prompt-guards.js +23 -13
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-receipt-reconciliation.js +198 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-recovery-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-recovery-presentation.js +154 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-recovery.js +68 -151
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/screenshot-capture.js +14 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/screenshot-observation.js +169 -46
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-commands.js +130 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-electron.js +210 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-observations.js +61 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-outcomes.js +187 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-refs.js +171 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-tabs.js +228 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state.js +77 -765
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/text-visibility-diagnostics.js +182 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/timeout-diagnostics.js +256 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/timeout-progress.js +108 -0
- package/dist/extensions/agent-browser/lib/orchestration/code-artifact-observation.js +39 -0
- package/dist/extensions/agent-browser/lib/orchestration/code-image-observation.js +119 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/branch.js +92 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/cleanup-result.js +58 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/cleanup.js +78 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/discovery.js +106 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/index.js +48 -821
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/policy.js +86 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-collection.js +69 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-data.js +167 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-presentation.js +164 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe.js +161 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/status.js +165 -0
- package/dist/extensions/agent-browser/lib/orchestration/execution-queue.js +21 -9
- package/dist/extensions/agent-browser/lib/orchestration/extension-artifact-preflight.js +211 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-artifacts.js +23 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-attachment-replay.js +99 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-branch-restore.js +275 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-code.js +280 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-admission.js +303 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-output.js +36 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-result.js +335 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-run.js +227 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-state.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-electron-ownership.js +204 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-execution-locks.js +139 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-execution-queue.js +24 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-host-coordination.js +98 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-host-run.js +295 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-intent-replay.js +41 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-invocation.js +7 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-lifecycle.js +102 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-managed-ownership.js +133 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-observation.js +120 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-prompt.js +180 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-recording.js +290 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-resource-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-resource-replay.js +269 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-result-state.js +113 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-runtime.js +146 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-script-leases.js +58 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-tool-boundary.js +62 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-version-check.js +54 -0
- package/dist/extensions/agent-browser/lib/orchestration/input-plan-types.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/input-plan.js +261 -185
- package/dist/extensions/agent-browser/lib/orchestration/input-redaction.js +62 -0
- package/dist/extensions/agent-browser/lib/orchestration/native-config.js +144 -0
- package/dist/extensions/agent-browser/lib/orchestration/native-root-launch.js +77 -0
- package/dist/extensions/agent-browser/lib/orchestration/native-session-defaults.js +210 -157
- package/dist/extensions/agent-browser/lib/orchestration/operation-paths.js +124 -58
- package/dist/extensions/agent-browser/lib/orchestration/output-file.js +197 -99
- package/dist/extensions/agent-browser/lib/orchestration/script-mode.js +199 -96
- package/dist/extensions/agent-browser/lib/owned-managed-session-context.js +55 -0
- package/dist/extensions/agent-browser/lib/page-target-batch.js +118 -0
- package/dist/extensions/agent-browser/lib/page-target-guards.js +50 -0
- package/dist/extensions/agent-browser/lib/page-target-navigation.js +104 -0
- package/dist/extensions/agent-browser/lib/page-target-validation.js +55 -246
- package/dist/extensions/agent-browser/lib/parsing.js +13 -4
- package/dist/extensions/agent-browser/lib/pi-tool-rendering.js +133 -68
- package/dist/extensions/agent-browser/lib/playbook.js +16 -12
- package/dist/extensions/agent-browser/lib/process-child.js +284 -0
- package/dist/extensions/agent-browser/lib/process-environment.js +13 -6
- package/dist/extensions/agent-browser/lib/process-errors.js +23 -0
- package/dist/extensions/agent-browser/lib/process-identity.js +47 -15
- package/dist/extensions/agent-browser/lib/process-socket-storage.js +256 -0
- package/dist/extensions/agent-browser/lib/process-stdout.js +74 -0
- package/dist/extensions/agent-browser/lib/process.js +145 -536
- package/dist/extensions/agent-browser/lib/prompt-artifacts.js +287 -0
- package/dist/extensions/agent-browser/lib/prompt-policy.js +15 -194
- package/dist/extensions/agent-browser/lib/read-command.js +41 -0
- package/dist/extensions/agent-browser/lib/read-confirmation.js +131 -68
- package/dist/extensions/agent-browser/lib/recording-reservations.js +118 -45
- package/dist/extensions/agent-browser/lib/redaction-fields.js +75 -0
- package/dist/extensions/agent-browser/lib/redaction-json.js +149 -0
- package/dist/extensions/agent-browser/lib/redaction-url.js +88 -0
- package/dist/extensions/agent-browser/lib/results/action-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/results/action-recommendations.js +28 -271
- package/dist/extensions/agent-browser/lib/results/artifact-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/results/artifact-manifest-validation.js +133 -0
- package/dist/extensions/agent-browser/lib/results/artifact-manifest.js +96 -94
- package/dist/extensions/agent-browser/lib/results/artifact-recommendations.js +73 -0
- package/dist/extensions/agent-browser/lib/results/categories.js +111 -54
- package/dist/extensions/agent-browser/lib/results/confirmation.js +29 -13
- package/dist/extensions/agent-browser/lib/results/editable-ref-evidence.js +62 -27
- package/dist/extensions/agent-browser/lib/results/electron-recommendations.js +83 -0
- package/dist/extensions/agent-browser/lib/results/envelope-decoding.js +48 -0
- package/dist/extensions/agent-browser/lib/results/envelope.js +90 -67
- package/dist/extensions/agent-browser/lib/results/evidence-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/results/failure-recommendations.js +180 -0
- package/dist/extensions/agent-browser/lib/results/network-routes.js +86 -45
- package/dist/extensions/agent-browser/lib/results/network.js +35 -12
- package/dist/extensions/agent-browser/lib/results/next-actions.js +49 -19
- package/dist/extensions/agent-browser/lib/results/presentation/artifact-files.js +320 -0
- package/dist/extensions/agent-browser/lib/results/presentation/artifact-format.js +138 -0
- package/dist/extensions/agent-browser/lib/results/presentation/artifact-images.js +113 -0
- package/dist/extensions/agent-browser/lib/results/presentation/artifact-verification.js +145 -0
- package/dist/extensions/agent-browser/lib/results/presentation/artifacts.js +99 -555
- package/dist/extensions/agent-browser/lib/results/presentation/batch-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/results/presentation/batch-recording.js +118 -0
- package/dist/extensions/agent-browser/lib/results/presentation/batch-redaction.js +68 -0
- package/dist/extensions/agent-browser/lib/results/presentation/batch-rendering.js +135 -0
- package/dist/extensions/agent-browser/lib/results/presentation/batch-step.js +227 -0
- package/dist/extensions/agent-browser/lib/results/presentation/batch-summary.js +91 -0
- package/dist/extensions/agent-browser/lib/results/presentation/batch.js +91 -460
- package/dist/extensions/agent-browser/lib/results/presentation/browser-profile-recovery.js +9 -5
- package/dist/extensions/agent-browser/lib/results/presentation/command-presenters.js +216 -0
- package/dist/extensions/agent-browser/lib/results/presentation/common.js +26 -9
- package/dist/extensions/agent-browser/lib/results/presentation/content.js +86 -29
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-a11y.js +67 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-health.js +79 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-identity.js +199 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-logs.js +75 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-network-actions.js +216 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-network.js +124 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-redaction.js +64 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-storage.js +209 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-stream.js +69 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-summary.js +222 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostics.js +103 -1052
- package/dist/extensions/agent-browser/lib/results/presentation/early-result.js +70 -0
- package/dist/extensions/agent-browser/lib/results/presentation/errors.js +130 -60
- package/dist/extensions/agent-browser/lib/results/presentation/input-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/results/presentation/large-output.js +60 -145
- package/dist/extensions/agent-browser/lib/results/presentation/navigation.js +147 -88
- package/dist/extensions/agent-browser/lib/results/presentation/notices.js +75 -0
- package/dist/extensions/agent-browser/lib/results/presentation/observation-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/results/presentation/observation-rendering.js +127 -0
- package/dist/extensions/agent-browser/lib/results/presentation/outcomes.js +120 -0
- package/dist/extensions/agent-browser/lib/results/presentation/output-completion.js +77 -0
- package/dist/extensions/agent-browser/lib/results/presentation/output-spill.js +51 -0
- package/dist/extensions/agent-browser/lib/results/presentation/registry.js +116 -240
- package/dist/extensions/agent-browser/lib/results/presentation/semantic-action.js +35 -21
- package/dist/extensions/agent-browser/lib/results/presentation/skills.js +104 -73
- package/dist/extensions/agent-browser/lib/results/presentation/source.js +109 -0
- package/dist/extensions/agent-browser/lib/results/presentation.js +17 -261
- package/dist/extensions/agent-browser/lib/results/recommendation-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/results/recording.js +52 -14
- package/dist/extensions/agent-browser/lib/results/recovery-actions.js +14 -5
- package/dist/extensions/agent-browser/lib/results/recovery-next-actions.js +30 -22
- package/dist/extensions/agent-browser/lib/results/selector-recovery-target.js +83 -0
- package/dist/extensions/agent-browser/lib/results/selector-recovery.js +119 -119
- package/dist/extensions/agent-browser/lib/results/snapshot-compact.js +266 -0
- package/dist/extensions/agent-browser/lib/results/snapshot-content.js +32 -0
- package/dist/extensions/agent-browser/lib/results/snapshot-high-value-controls.js +104 -71
- package/dist/extensions/agent-browser/lib/results/snapshot-refs.js +31 -11
- package/dist/extensions/agent-browser/lib/results/snapshot-segments.js +125 -66
- package/dist/extensions/agent-browser/lib/results/snapshot-spill.js +26 -7
- package/dist/extensions/agent-browser/lib/results/snapshot.js +28 -248
- package/dist/extensions/agent-browser/lib/results/text.js +16 -5
- package/dist/extensions/agent-browser/lib/runtime-args-validation.js +133 -0
- package/dist/extensions/agent-browser/lib/runtime-compatibility.js +81 -0
- package/dist/extensions/agent-browser/lib/runtime-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/runtime-redaction.js +118 -0
- package/dist/extensions/agent-browser/lib/runtime-replay-events.js +144 -0
- package/dist/extensions/agent-browser/lib/runtime-session-identity.js +76 -0
- package/dist/extensions/agent-browser/lib/runtime-session-plan.js +114 -0
- package/dist/extensions/agent-browser/lib/runtime-session-replay.js +123 -0
- package/dist/extensions/agent-browser/lib/runtime-tab-correction.js +65 -0
- package/dist/extensions/agent-browser/lib/runtime-timeouts.js +28 -0
- package/dist/extensions/agent-browser/lib/runtime.js +137 -1041
- package/dist/extensions/agent-browser/lib/session-identity.js +51 -0
- package/dist/extensions/agent-browser/lib/session-page-observation.js +357 -0
- package/dist/extensions/agent-browser/lib/session-page-state.js +178 -333
- package/dist/extensions/agent-browser/lib/session-page-types.js +1 -0
- package/dist/extensions/agent-browser/lib/temp-artifact-budget.js +78 -0
- package/dist/extensions/agent-browser/lib/temp-mutation-queue.js +7 -0
- package/dist/extensions/agent-browser/lib/temp-root-ownership.js +234 -0
- package/dist/extensions/agent-browser/lib/temp-root.js +207 -0
- package/dist/extensions/agent-browser/lib/temp.js +33 -446
- package/dist/extensions/agent-browser/lib/tool-surface.js +94 -24
- package/dist/extensions/agent-browser/lib/upstream-version.js +3 -2
- package/dist/extensions/agent-browser/lib/web-search-providers.js +229 -0
- package/dist/extensions/agent-browser/lib/web-search-request.js +108 -0
- package/dist/extensions/agent-browser/lib/web-search-results.js +281 -0
- package/dist/extensions/agent-browser/lib/web-search-schema.js +82 -0
- package/dist/extensions/agent-browser/lib/web-search.js +109 -617
- package/dist/extensions/agent-browser/lib/webmcp-observation.js +13 -6
- package/dist/extensions/agent-browser/lib/windows-stock-launcher.js +63 -37
- package/dist/extensions/agent-browser/script-worker.js +80 -43
- package/dist/scripts/agent-browser-target.mjs +4 -2
- package/docs/ARCHITECTURE.md +17 -5
- package/docs/CODE_QUALITY.md +242 -0
- package/docs/COMMAND_REFERENCE.md +251 -220
- package/docs/ELECTRON.md +53 -44
- package/docs/RELEASE.md +18 -15
- package/docs/REQUIREMENTS.md +1 -0
- package/docs/SUPPORT_MATRIX.md +76 -75
- package/docs/TOOL_CONTRACT.md +145 -116
- package/docs/platform-smoke.md +5 -5
- package/package.json +143 -120
- package/scripts/agent-browser-capability-baseline.mjs +361 -957
- package/scripts/agent-browser-target.mjs +6 -2
- package/scripts/build.mjs +37 -8
- package/scripts/capability-core-commands.mjs +193 -0
- package/scripts/capability-options.mjs +283 -0
- package/scripts/capability-samples.mjs +133 -0
- package/scripts/capability-section.mjs +11 -0
- package/scripts/config.mjs +213 -114
- package/scripts/convert-browser-session.mjs +30 -9
- package/scripts/doctor-sources.mjs +195 -0
- package/scripts/doctor.mjs +92 -247
- package/scripts/platform-smoke/artifacts.mjs +38 -11
- package/scripts/platform-smoke/commands.mjs +104 -0
- package/scripts/platform-smoke/crabbox-runner.mjs +167 -80
- package/scripts/platform-smoke/doctor-support.mjs +157 -0
- package/scripts/platform-smoke/doctor-windows.mjs +230 -0
- package/scripts/platform-smoke/doctor.mjs +212 -320
- package/scripts/platform-smoke/lease-evidence.mjs +134 -0
- package/scripts/platform-smoke/suite-checks.mjs +98 -0
- package/scripts/platform-smoke/suite-evidence.mjs +281 -0
- package/scripts/platform-smoke/targets.mjs +158 -472
- package/scripts/platform-smoke.mjs +55 -40
- package/scripts/prepare.mjs +16 -7
|
@@ -1,417 +1,104 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isCloseCommand } from "../../command-taxonomy.js";
|
|
1
|
+
import { extractUpstreamCommandTokens } from "../../argv-descriptor.js";
|
|
3
2
|
import { isRecord } from "../../parsing.js";
|
|
4
|
-
import { getAgentBrowserSessionIdentityKey } from "../../argv-grammar.js";
|
|
5
|
-
import { extractUpstreamCommandTokens, parseCommandInfo, redactInvocationArgs, redactSensitiveText, redactSensitiveValue } from "../../runtime.js";
|
|
6
3
|
import { buildAgentBrowserNextActions } from "../action-recommendations.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
import { buildPageChangeSummary } from "./navigation.js";
|
|
17
|
-
import { appendSelectorRecoveryHint, getClipboardWritePayloadCandidates, isOverlayBlockedClickError, redactClipboardPermissionErrorValue } from "./errors.js";
|
|
4
|
+
import { formatSessionArtifactRetentionSummary } from "../artifact-manifest.js";
|
|
5
|
+
import { applyNetworkRouteRecords } from "../network-routes.js";
|
|
6
|
+
import { appendUniqueAgentBrowserNextActions, applyNamespaceToNextActions, } from "../next-actions.js";
|
|
7
|
+
import { buildArtifactVerificationSummary, classifyPresentationSuccessCategory, manifestHasNewNoticeWorthyEntries, } from "./artifacts.js";
|
|
8
|
+
import { getPresentationImages, getPresentationPaths, isStringArray } from "./content.js";
|
|
9
|
+
import { buildBatchStepPresentation } from "./batch-step.js";
|
|
10
|
+
import { coalesceTerminalBatchRecordingArtifacts } from "./batch-recording.js";
|
|
11
|
+
import { buildBatchPageChangeSummary, formatBatchStatusText, serializeBatchData, summarizeBatchStatus, } from "./batch-summary.js";
|
|
12
|
+
export { redactBatchStepErrorData } from "./batch-redaction.js";
|
|
18
13
|
export function isAgentBrowserBatchResultArray(value) {
|
|
19
|
-
return Array.isArray(value) &&
|
|
14
|
+
return (Array.isArray(value) &&
|
|
15
|
+
value.every((row) => isRecord(row) &&
|
|
16
|
+
(row.command === undefined || isStringArray(row.command)) &&
|
|
17
|
+
(row.success === undefined || typeof row.success === "boolean")));
|
|
20
18
|
}
|
|
21
|
-
function
|
|
22
|
-
return command?.[0] === "wait" && command.includes("--text");
|
|
23
|
-
}
|
|
24
|
-
function buildWaitTextAssertionFailureNextAction(sessionName) {
|
|
25
|
-
return {
|
|
26
|
-
id: "inspect-after-text-assertion-failure",
|
|
27
|
-
params: { args: withOptionalSessionArgs(sessionName, ["snapshot", "-i"]) },
|
|
28
|
-
reason: "Inspect the current page after the text assertion failed before concluding the expected text is absent.",
|
|
29
|
-
safety: "Read-only snapshot; use current refs or visible text from this page before retrying the assertion.",
|
|
30
|
-
tool: "agent_browser",
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
function mergePresentationNextActions(...groups) {
|
|
34
|
-
const actions = [];
|
|
35
|
-
const seen = new Set();
|
|
36
|
-
for (const group of groups) {
|
|
37
|
-
for (const action of group ?? []) {
|
|
38
|
-
if (seen.has(action.id))
|
|
39
|
-
continue;
|
|
40
|
-
actions.push(action);
|
|
41
|
-
seen.add(action.id);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return actions.length > 0 ? actions : undefined;
|
|
45
|
-
}
|
|
46
|
-
function formatBatchStepError(error) {
|
|
47
|
-
const errorText = stringifyModelFacing(error).trim();
|
|
48
|
-
const formattedErrorText = errorText.length > 0 ? `Error: ${errorText}` : "Error: batch step failed.";
|
|
49
|
-
return appendSelectorRecoveryHint(formattedErrorText);
|
|
50
|
-
}
|
|
51
|
-
function getBatchFailureDetails(steps) {
|
|
52
|
-
const failedSteps = steps.filter((step) => step.details.success === false);
|
|
53
|
-
if (failedSteps.length === 0)
|
|
54
|
-
return undefined;
|
|
55
|
-
const successCount = steps.length - failedSteps.length;
|
|
56
|
-
return {
|
|
57
|
-
failedStep: failedSteps[0].details,
|
|
58
|
-
failureCount: failedSteps.length,
|
|
59
|
-
successCount,
|
|
60
|
-
totalCount: steps.length,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
function hasModelFacingArgRedaction(args) {
|
|
64
|
-
return args?.some((arg) => arg === "[REDACTED]" || arg.includes("%5BREDACTED%5D") || arg.includes("[REDACTED]")) === true;
|
|
65
|
-
}
|
|
66
|
-
function getStatefulCommandSensitiveValues(command) {
|
|
67
|
-
if (!command)
|
|
68
|
-
return [];
|
|
69
|
-
const tokens = extractUpstreamCommandTokens(command);
|
|
70
|
-
const values = [];
|
|
71
|
-
if (tokens[0] === "cookies" && tokens[1] === "set" && !tokens.slice(2).includes("--curl") && tokens[3])
|
|
72
|
-
values.push(tokens[3]);
|
|
73
|
-
if (tokens[0] === "storage" && ["local", "session"].includes(tokens[1] ?? "") && tokens[2] === "set" && tokens[4])
|
|
74
|
-
values.push(tokens[4]);
|
|
75
|
-
for (let index = 0; index < tokens.length; index += 1) {
|
|
76
|
-
const token = tokens[index];
|
|
77
|
-
if (token === "--password" && tokens[index + 1])
|
|
78
|
-
values.push(tokens[index + 1]);
|
|
79
|
-
else if (token?.startsWith("--password="))
|
|
80
|
-
values.push(token.slice("--password=".length));
|
|
81
|
-
}
|
|
82
|
-
return values.filter((value) => value.length > 0);
|
|
83
|
-
}
|
|
84
|
-
function redactExactValues(value, sensitiveValues) {
|
|
85
|
-
if (sensitiveValues.length === 0)
|
|
86
|
-
return redactSensitiveValue(value);
|
|
87
|
-
if (typeof value === "string") {
|
|
88
|
-
let redacted = value;
|
|
89
|
-
for (const sensitiveValue of sensitiveValues)
|
|
90
|
-
redacted = redacted.split(sensitiveValue).join("[REDACTED]");
|
|
91
|
-
return redactSensitiveText(redacted);
|
|
92
|
-
}
|
|
93
|
-
if (Array.isArray(value))
|
|
94
|
-
return value.map((item) => redactExactValues(item, sensitiveValues));
|
|
95
|
-
if (!isRecord(value))
|
|
96
|
-
return value;
|
|
97
|
-
return redactSensitiveValue(Object.fromEntries(Object.entries(value).map(([key, entryValue]) => [key, redactExactValues(entryValue, sensitiveValues)])));
|
|
98
|
-
}
|
|
99
|
-
export function redactBatchStepErrorData(command, value) {
|
|
100
|
-
return command?.[0] === "clipboard"
|
|
101
|
-
? redactSensitiveValue(redactClipboardPermissionErrorValue({ command: "clipboard", subcommand: command[1] }, value, getClipboardWritePayloadCandidates(command)))
|
|
102
|
-
: redactExactValues(value, getStatefulCommandSensitiveValues(command));
|
|
103
|
-
}
|
|
104
|
-
function getTypedTextLength(command) {
|
|
105
|
-
return command?.[0] === "keyboard" && command[1] === "type" && typeof command[2] === "string"
|
|
106
|
-
? Array.from(command[2]).length
|
|
107
|
-
: undefined;
|
|
108
|
-
}
|
|
109
|
-
function getWaitDelayMs(command) {
|
|
110
|
-
return command?.[0] === "wait" && typeof command[1] === "string" && /^\d+$/.test(command[1]) ? command[1] : undefined;
|
|
111
|
-
}
|
|
112
|
-
function formatBatchStepDetails(details, presentation) {
|
|
113
|
-
const inlineImageCount = getPresentationImages(presentation).length;
|
|
114
|
-
const status = details.success ? "succeeded" : "failed";
|
|
115
|
-
const lines = [`Step ${details.index + 1} — ${details.commandText} (${status})`];
|
|
116
|
-
if (details.text.length > 0)
|
|
117
|
-
lines.push(details.text);
|
|
118
|
-
if (inlineImageCount > 0)
|
|
119
|
-
lines.push(`(${inlineImageCount} inline image attachment${inlineImageCount === 1 ? "" : "s"} below)`);
|
|
120
|
-
return lines.join("\n");
|
|
121
|
-
}
|
|
122
|
-
function formatTypedSequenceSummary(steps, startIndex) {
|
|
123
|
-
let index = startIndex;
|
|
124
|
-
const firstDetails = steps[index]?.details;
|
|
125
|
-
if (!firstDetails?.success)
|
|
126
|
-
return undefined;
|
|
127
|
-
let target;
|
|
128
|
-
if (firstDetails.command?.[0] === "focus" && typeof firstDetails.command[1] === "string") {
|
|
129
|
-
target = firstDetails.command[1];
|
|
130
|
-
index += 1;
|
|
131
|
-
}
|
|
132
|
-
let typedCharCount = 0;
|
|
133
|
-
let typedStepCount = 0;
|
|
134
|
-
let delayMs;
|
|
135
|
-
while (index < steps.length) {
|
|
136
|
-
const details = steps[index]?.details;
|
|
137
|
-
if (!details?.success)
|
|
138
|
-
break;
|
|
139
|
-
const typedLength = getTypedTextLength(details.command);
|
|
140
|
-
if (typedLength === undefined)
|
|
141
|
-
break;
|
|
142
|
-
typedCharCount += typedLength;
|
|
143
|
-
typedStepCount += 1;
|
|
144
|
-
index += 1;
|
|
145
|
-
const nextDelay = getWaitDelayMs(steps[index]?.details.command);
|
|
146
|
-
const followingTypedLength = getTypedTextLength(steps[index + 1]?.details.command);
|
|
147
|
-
if (nextDelay !== undefined && followingTypedLength !== undefined && steps[index]?.details.success && steps[index + 1]?.details.success) {
|
|
148
|
-
if (delayMs !== undefined && delayMs !== nextDelay)
|
|
149
|
-
return undefined;
|
|
150
|
-
delayMs = nextDelay;
|
|
151
|
-
index += 1;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
if (typedStepCount < 2)
|
|
155
|
-
return undefined;
|
|
156
|
-
let pressedKey;
|
|
157
|
-
const pressDetails = steps[index]?.details;
|
|
158
|
-
if (pressDetails?.success && pressDetails.command?.[0] === "press" && typeof pressDetails.command[1] === "string") {
|
|
159
|
-
pressedKey = pressDetails.command[1];
|
|
160
|
-
index += 1;
|
|
161
|
-
}
|
|
162
|
-
const firstStep = firstDetails.index + 1;
|
|
163
|
-
const lastStep = steps[index - 1]?.details.index + 1;
|
|
164
|
-
const stepRange = lastStep && lastStep > firstStep ? `${firstStep}-${lastStep}` : String(firstStep);
|
|
165
|
-
const commandLabel = target ? `type ${target}` : "keyboard type";
|
|
166
|
-
const lines = [
|
|
167
|
-
`Step ${stepRange} — ${commandLabel} (succeeded)`,
|
|
168
|
-
`Typed ${typedCharCount} char${typedCharCount === 1 ? "" : "s"}${delayMs ? ` with delayMs=${delayMs}` : ""}.`,
|
|
169
|
-
];
|
|
170
|
-
if (pressedKey)
|
|
171
|
-
lines.push(`Pressed ${pressedKey}.`);
|
|
172
|
-
return { nextIndex: index, text: lines.join("\n") };
|
|
173
|
-
}
|
|
174
|
-
function formatBatchStepsText(steps) {
|
|
175
|
-
if (steps.length === 0)
|
|
176
|
-
return "(no batch steps)";
|
|
177
|
-
const lines = [];
|
|
178
|
-
for (let index = 0; index < steps.length;) {
|
|
179
|
-
const typedSequence = formatTypedSequenceSummary(steps, index);
|
|
180
|
-
if (typedSequence) {
|
|
181
|
-
lines.push(typedSequence.text);
|
|
182
|
-
index = typedSequence.nextIndex;
|
|
183
|
-
continue;
|
|
184
|
-
}
|
|
185
|
-
const step = steps[index];
|
|
186
|
-
if (step)
|
|
187
|
-
lines.push(formatBatchStepDetails(step.details, step.presentation));
|
|
188
|
-
index += 1;
|
|
189
|
-
}
|
|
190
|
-
return lines.join("\n\n");
|
|
191
|
-
}
|
|
192
|
-
async function buildBatchStepPresentation(options) {
|
|
193
|
-
const { artifactManifest, artifactMaxUpdatedAtMs, artifactMinUpdatedAtMs, artifactRequest, buildNestedToolPresentation, cwd, index, item, namespace, networkRoutes, persistentArtifactStore, sessionName } = options;
|
|
194
|
-
const command = isStringArray(item.command) ? item.command : undefined;
|
|
195
|
-
const redactedCommand = command ? redactInvocationArgs(command) : undefined;
|
|
196
|
-
const commandText = formatBatchStepCommand(hasModelFacingArgRedaction(redactedCommand) ? redactedCommand : command, index);
|
|
197
|
-
const lifecycle = extractAgentBrowserLifecycle(item.result);
|
|
198
|
-
if (item.success === false && command?.[0] !== "record") {
|
|
199
|
-
const redactedErrorData = redactBatchStepErrorData(command, item.error);
|
|
200
|
-
const errorText = formatBatchStepError(redactedErrorData);
|
|
201
|
-
const failureCategory = classifyAgentBrowserFailureCategory({
|
|
202
|
-
args: command,
|
|
203
|
-
command: command?.[0],
|
|
204
|
-
errorText,
|
|
205
|
-
});
|
|
206
|
-
const confirmationRequired = detectConfirmationRequired(item.error);
|
|
207
|
-
const nextActions = applyNamespaceToNextActions(mergePresentationNextActions(isWaitTextAssertionCommand(command) ? [buildWaitTextAssertionFailureNextAction(sessionName)] : undefined, buildAgentBrowserNextActions({
|
|
208
|
-
args: command,
|
|
209
|
-
command: command?.[0],
|
|
210
|
-
confirmationId: confirmationRequired?.id,
|
|
211
|
-
failureCategory,
|
|
212
|
-
overlayBlockedClick: isOverlayBlockedClickError(command?.[0], errorText, command),
|
|
213
|
-
resultCategory: "failure",
|
|
214
|
-
sessionName,
|
|
215
|
-
subcommand: command?.[1],
|
|
216
|
-
})), namespace);
|
|
217
|
-
const presentation = {
|
|
218
|
-
content: [{ type: "text", text: errorText }],
|
|
219
|
-
failureCategory,
|
|
220
|
-
nextActions,
|
|
221
|
-
resultCategory: "failure",
|
|
222
|
-
summary: errorText,
|
|
223
|
-
};
|
|
224
|
-
return {
|
|
225
|
-
details: {
|
|
226
|
-
artifactVerification: presentation.artifactVerification,
|
|
227
|
-
artifacts: presentation.artifacts,
|
|
228
|
-
command: redactedCommand,
|
|
229
|
-
commandText,
|
|
230
|
-
data: redactedErrorData,
|
|
231
|
-
failureCategory,
|
|
232
|
-
index,
|
|
233
|
-
lifecycle,
|
|
234
|
-
nextActions,
|
|
235
|
-
resultCategory: "failure",
|
|
236
|
-
success: false,
|
|
237
|
-
summary: errorText,
|
|
238
|
-
text: errorText,
|
|
239
|
-
},
|
|
240
|
-
presentation,
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
const commandInfo = parseCommandInfo(command ?? []);
|
|
244
|
-
const commandInfoWithTokens = command ? { ...commandInfo, commandTokens: command } : commandInfo;
|
|
245
|
-
const networkRouteDiagnostics = commandInfo.command === "network" && commandInfo.subcommand === "requests"
|
|
246
|
-
? buildNetworkRouteDiagnostics(item.result, networkRoutes)
|
|
247
|
-
: undefined;
|
|
248
|
-
const presentation = await buildNestedToolPresentation({
|
|
249
|
-
modelVisible: options.modelVisible,
|
|
250
|
-
artifactManifest,
|
|
251
|
-
artifactMaxUpdatedAtMs,
|
|
252
|
-
artifactMinUpdatedAtMs,
|
|
253
|
-
artifactRequest,
|
|
254
|
-
commandInfo: commandInfoWithTokens,
|
|
255
|
-
cwd,
|
|
256
|
-
args: command,
|
|
257
|
-
envelope: { data: item.result, success: item.success !== false, error: item.error },
|
|
258
|
-
errorText: item.success === false ? formatBatchStepError(redactBatchStepErrorData(command, item.error)) : undefined,
|
|
259
|
-
piCleanupOwnership: options.piCleanupOwnership,
|
|
260
|
-
networkRouteDiagnostics,
|
|
261
|
-
namespace,
|
|
262
|
-
persistentArtifactStore,
|
|
263
|
-
sessionName,
|
|
264
|
-
});
|
|
265
|
-
const fullOutputPaths = getPresentationPaths({
|
|
266
|
-
primaryPath: presentation.fullOutputPath,
|
|
267
|
-
secondaryPaths: presentation.fullOutputPaths,
|
|
268
|
-
});
|
|
269
|
-
const imagePaths = getPresentationPaths({
|
|
270
|
-
primaryPath: presentation.imagePath,
|
|
271
|
-
secondaryPaths: presentation.imagePaths,
|
|
272
|
-
});
|
|
273
|
-
const text = getPresentationText(presentation) || presentation.summary;
|
|
274
|
-
const stepSucceeded = presentation.resultCategory !== "failure";
|
|
275
|
-
const pendingWebMcpMutation = stepSucceeded
|
|
276
|
-
&& commandInfo.command === "webmcp"
|
|
277
|
-
&& ["invoke", "result"].includes(commandInfo.subcommand ?? "")
|
|
278
|
-
&& isRecord(presentation.data)
|
|
279
|
-
&& presentation.data.status === "pending";
|
|
280
|
-
const nextActions = applyNamespaceToNextActions(pendingWebMcpMutation ? buildPendingWebMcpNextActions(sessionName) : presentation.nextActions ?? buildAgentBrowserNextActions({
|
|
281
|
-
artifacts: presentation.artifacts,
|
|
282
|
-
args: command,
|
|
283
|
-
command: command?.[0],
|
|
284
|
-
failureCategory: presentation.failureCategory,
|
|
285
|
-
resultCategory: stepSucceeded ? "success" : "failure",
|
|
286
|
-
savedFilePath: presentation.savedFilePath,
|
|
287
|
-
sessionName,
|
|
288
|
-
subcommand: command?.[1],
|
|
289
|
-
successCategory: presentation.successCategory,
|
|
290
|
-
}), namespace);
|
|
291
|
-
const pageChangeSummary = buildPageChangeSummary({
|
|
292
|
-
artifacts: presentation.artifacts,
|
|
293
|
-
commandInfo: commandInfoWithTokens,
|
|
294
|
-
data: presentation.data,
|
|
295
|
-
nextActions,
|
|
296
|
-
savedFilePath: presentation.savedFilePath,
|
|
297
|
-
summary: presentation.summary,
|
|
298
|
-
});
|
|
299
|
-
return {
|
|
300
|
-
details: {
|
|
301
|
-
artifactVerification: presentation.artifactVerification,
|
|
302
|
-
artifacts: presentation.artifacts,
|
|
303
|
-
command: redactedCommand,
|
|
304
|
-
commandText,
|
|
305
|
-
data: presentation.data,
|
|
306
|
-
failureCategory: stepSucceeded ? undefined : presentation.failureCategory,
|
|
307
|
-
fullOutputPath: fullOutputPaths[0],
|
|
308
|
-
fullOutputPaths: fullOutputPaths.length > 0 ? fullOutputPaths : undefined,
|
|
309
|
-
imagePath: imagePaths[0],
|
|
310
|
-
imagePaths: imagePaths.length > 0 ? imagePaths : undefined,
|
|
311
|
-
imageObservations: presentation.imageObservations,
|
|
312
|
-
index,
|
|
313
|
-
lifecycle,
|
|
314
|
-
networkRouteDiagnostics: presentation.networkRouteDiagnostics,
|
|
315
|
-
nextActions,
|
|
316
|
-
pageChangeSummary,
|
|
317
|
-
resultCategory: stepSucceeded ? "success" : "failure",
|
|
318
|
-
savedFile: presentation.savedFile,
|
|
319
|
-
savedFilePath: presentation.savedFilePath,
|
|
320
|
-
success: stepSucceeded,
|
|
321
|
-
successCategory: stepSucceeded ? classifyPresentationSuccessCategory({ artifactVerification: presentation.artifactVerification, artifacts: presentation.artifacts, savedFile: presentation.savedFile }) : undefined,
|
|
322
|
-
summary: presentation.summary,
|
|
323
|
-
text,
|
|
324
|
-
},
|
|
325
|
-
presentation,
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
async function unverifiedRecordingArtifact(artifact, subcommand) {
|
|
329
|
-
const { recordingState: _recordingState, willExistOnStop: _willExistOnStop, ...terminal } = artifact;
|
|
330
|
-
try {
|
|
331
|
-
const file = await stat(artifact.absolutePath);
|
|
332
|
-
return { ...terminal, exists: file.isFile(), sizeBytes: file.size, status: file.isFile() ? "unverified" : "missing", subcommand };
|
|
333
|
-
}
|
|
334
|
-
catch (error) {
|
|
335
|
-
const missing = error.code === "ENOENT";
|
|
336
|
-
return { ...terminal, exists: missing ? false : undefined, status: missing ? "missing" : "unverified", subcommand };
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
async function coalesceTerminalBatchRecordingArtifacts(steps, sessionName, namespace) {
|
|
340
|
-
const artifacts = [];
|
|
341
|
-
const pendingIndexesBySession = new Map();
|
|
342
|
-
const removedPendingIndexes = new Set();
|
|
343
|
-
for (const step of steps) {
|
|
344
|
-
for (const artifact of step.presentation.artifacts ?? []) {
|
|
345
|
-
const index = artifacts.push(artifact) - 1;
|
|
346
|
-
if (artifact.command !== "record")
|
|
347
|
-
continue;
|
|
348
|
-
const session = artifact.session ? getAgentBrowserSessionIdentityKey(artifact.session, artifact.namespace) : "";
|
|
349
|
-
if (isPendingRecordingArtifact(artifact)) {
|
|
350
|
-
const pendingIndexes = pendingIndexesBySession.get(session) ?? [];
|
|
351
|
-
pendingIndexes.push(index);
|
|
352
|
-
pendingIndexesBySession.set(session, pendingIndexes);
|
|
353
|
-
continue;
|
|
354
|
-
}
|
|
355
|
-
const pendingIndexes = pendingIndexesBySession.get(session) ?? [];
|
|
356
|
-
const matchingIndex = pendingIndexes.map((pendingIndex) => artifacts[pendingIndex].kind).lastIndexOf(artifact.kind);
|
|
357
|
-
if (matchingIndex !== -1)
|
|
358
|
-
removedPendingIndexes.add(pendingIndexes.splice(matchingIndex, 1)[0]);
|
|
359
|
-
if (artifact.kind === "video") {
|
|
360
|
-
// A terminal video also ends its pending sheet; a reported sheet below
|
|
361
|
-
// replaces this unverified row, while legacy restart output may omit it.
|
|
362
|
-
for (const pendingIndex of pendingIndexes) {
|
|
363
|
-
if (artifacts[pendingIndex].kind === "image" && isPendingRecordingArtifact(artifacts[pendingIndex]))
|
|
364
|
-
artifacts[pendingIndex] = await unverifiedRecordingArtifact(artifacts[pendingIndex], artifact.subcommand ?? "stop");
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
const command = step.details.command;
|
|
369
|
-
if (step.details.success !== true || !command || !isCloseCommand(extractUpstreamCommandTokens(command)[0]))
|
|
370
|
-
continue;
|
|
371
|
-
const session = sessionName ? getAgentBrowserSessionIdentityKey(sessionName, namespace) : "";
|
|
372
|
-
for (const pendingIndex of pendingIndexesBySession.get(session) ?? []) {
|
|
373
|
-
const pending = artifacts[pendingIndex];
|
|
374
|
-
if (pending && isPendingRecordingArtifact(pending) && !removedPendingIndexes.has(pendingIndex))
|
|
375
|
-
artifacts[pendingIndex] = await unverifiedRecordingArtifact(pending, "close-abandoned");
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
return artifacts.filter((_, index) => !removedPendingIndexes.has(index));
|
|
379
|
-
}
|
|
380
|
-
export async function buildBatchPresentation(options) {
|
|
381
|
-
const { artifactRequests, buildNestedToolPresentation, cwd, data, namespace, networkRoutes, persistentArtifactStore, sessionName, summary } = options;
|
|
19
|
+
async function collectPresentedSteps(options) {
|
|
382
20
|
const steps = [];
|
|
383
|
-
const
|
|
384
|
-
let
|
|
385
|
-
let
|
|
386
|
-
for (const [index, item] of data.entries()) {
|
|
21
|
+
const protectedPaths = [];
|
|
22
|
+
let manifest = options.artifactManifest;
|
|
23
|
+
let routes = options.networkRoutes;
|
|
24
|
+
for (const [index, item] of options.data.entries()) {
|
|
25
|
+
// Each row updates artifact protection/manifest and route state required by the following row.
|
|
26
|
+
// oxlint-disable-next-line no-await-in-loop
|
|
387
27
|
const step = await buildBatchStepPresentation({
|
|
388
28
|
modelVisible: options.modelVisible,
|
|
389
|
-
artifactManifest:
|
|
29
|
+
artifactManifest: manifest,
|
|
390
30
|
artifactMaxUpdatedAtMs: options.artifactMaxUpdatedAtMs,
|
|
391
31
|
artifactMinUpdatedAtMs: options.artifactMinUpdatedAtMs,
|
|
392
|
-
artifactRequest: artifactRequests?.[index],
|
|
393
|
-
buildNestedToolPresentation,
|
|
394
|
-
cwd,
|
|
32
|
+
artifactRequest: options.artifactRequests?.[index],
|
|
33
|
+
buildNestedToolPresentation: options.buildNestedToolPresentation,
|
|
34
|
+
cwd: options.cwd,
|
|
395
35
|
index,
|
|
396
36
|
item,
|
|
397
37
|
piCleanupOwnership: options.piCleanupOwnership,
|
|
398
|
-
namespace,
|
|
399
|
-
networkRoutes:
|
|
400
|
-
persistentArtifactStore: persistentArtifactStore
|
|
401
|
-
|
|
38
|
+
namespace: options.namespace,
|
|
39
|
+
networkRoutes: routes,
|
|
40
|
+
persistentArtifactStore: options.persistentArtifactStore
|
|
41
|
+
? { ...options.persistentArtifactStore, protectedPaths }
|
|
42
|
+
: undefined,
|
|
43
|
+
sessionName: options.sessionName,
|
|
402
44
|
});
|
|
403
45
|
steps.push(step);
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
46
|
+
manifest = step.presentation.artifactManifest ?? manifest;
|
|
47
|
+
routes = applyNetworkRouteRecords(routes, isStringArray(item.command) ? extractUpstreamCommandTokens(item.command) : undefined, item.success !== false && step.details.success);
|
|
48
|
+
protectedPaths.push(...getPresentationPaths({
|
|
407
49
|
primaryPath: step.presentation.fullOutputPath,
|
|
408
50
|
secondaryPaths: step.presentation.fullOutputPaths,
|
|
409
51
|
}));
|
|
410
52
|
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
53
|
+
return { steps, manifest };
|
|
54
|
+
}
|
|
55
|
+
export async function buildBatchPresentation(options) {
|
|
56
|
+
const { steps, manifest } = await collectPresentedSteps(options);
|
|
57
|
+
const status = summarizeBatchStatus(steps, options.summary);
|
|
58
|
+
const artifacts = await coalesceTerminalBatchRecordingArtifacts(steps, options.sessionName, options.namespace);
|
|
414
59
|
const artifactVerification = buildArtifactVerificationSummary(artifacts);
|
|
60
|
+
const paths = collectBatchOutputPaths(steps);
|
|
61
|
+
const text = formatBatchStatusText(steps, status, options.modelVisible);
|
|
62
|
+
const artifactRetentionSummary = manifest
|
|
63
|
+
? formatSessionArtifactRetentionSummary(manifest)
|
|
64
|
+
: undefined;
|
|
65
|
+
const contentText = addRetentionNotice(text, artifactRetentionSummary, options.artifactManifest, manifest);
|
|
66
|
+
const lifecycleActions = applyNamespaceToNextActions(buildAgentBrowserNextActions({
|
|
67
|
+
artifacts,
|
|
68
|
+
command: "batch",
|
|
69
|
+
resultCategory: status.failure ? "failure" : "success",
|
|
70
|
+
sessionName: options.sessionName,
|
|
71
|
+
}), options.namespace);
|
|
72
|
+
const nextActions = status.failure
|
|
73
|
+
? appendUniqueAgentBrowserNextActions([...(status.failure.failedStep.nextActions ?? [])], lifecycleActions)
|
|
74
|
+
: lifecycleActions;
|
|
75
|
+
return {
|
|
76
|
+
artifactManifest: manifest,
|
|
77
|
+
artifactRetentionSummary,
|
|
78
|
+
artifactVerification,
|
|
79
|
+
artifacts: artifacts.length > 0 ? artifacts : undefined,
|
|
80
|
+
batchFailure: status.failure,
|
|
81
|
+
batchSteps: steps.map((step) => step.details),
|
|
82
|
+
content: options.modelVisible === false
|
|
83
|
+
? []
|
|
84
|
+
: [
|
|
85
|
+
{ type: "text", text: contentText },
|
|
86
|
+
...steps.flatMap((step) => getPresentationImages(step.presentation)),
|
|
87
|
+
],
|
|
88
|
+
failureCategory: status.failure?.failedStep.failureCategory,
|
|
89
|
+
data: serializeBatchData(steps),
|
|
90
|
+
...paths,
|
|
91
|
+
imageObservations: steps.flatMap((step) => step.presentation.imageObservations ?? []),
|
|
92
|
+
nextActions,
|
|
93
|
+
pageChangeSummary: buildBatchPageChangeSummary(steps, artifacts, nextActions, status.summary),
|
|
94
|
+
resultCategory: status.failure ? "failure" : "success",
|
|
95
|
+
successCategory: status.failure
|
|
96
|
+
? undefined
|
|
97
|
+
: classifyPresentationSuccessCategory({ artifactVerification, artifacts }),
|
|
98
|
+
summary: status.summary,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function collectBatchOutputPaths(steps) {
|
|
415
102
|
const fullOutputPaths = steps.flatMap((step) => getPresentationPaths({
|
|
416
103
|
primaryPath: step.presentation.fullOutputPath,
|
|
417
104
|
secondaryPaths: step.presentation.fullOutputPaths,
|
|
@@ -420,73 +107,17 @@ export async function buildBatchPresentation(options) {
|
|
|
420
107
|
primaryPath: step.presentation.imagePath,
|
|
421
108
|
secondaryPaths: step.presentation.imagePaths,
|
|
422
109
|
}));
|
|
423
|
-
const redactedBatchData = steps.map(({ details }) => (details.success
|
|
424
|
-
? { command: details.command, result: details.data, success: true }
|
|
425
|
-
: { command: details.command, error: details.text, ...(details.command?.[0] === "record" ? { result: details.data } : {}), success: false }));
|
|
426
|
-
const unverifiedMutationCount = steps.filter((step) => step.details.pageChangeSummary?.changeType === "mutation" && step.details.pageChangeSummary.observed === false).length;
|
|
427
|
-
const mutationEvidenceText = unverifiedMutationCount > 0
|
|
428
|
-
? `Mutation evidence: ${unverifiedMutationCount} action result${unverifiedMutationCount === 1 ? " proves" : "s prove"} dispatch only, not application state change. Use explicit later assertions or external receipts as postconditions; fixed waits are not postconditions.`
|
|
429
|
-
: undefined;
|
|
430
|
-
const stepText = options.modelVisible === false ? "" : formatBatchStepsText(steps);
|
|
431
|
-
const batchSummary = batchFailure === undefined
|
|
432
|
-
? summary
|
|
433
|
-
: `Batch failed: ${batchFailure.successCount}/${batchFailure.totalCount} succeeded`;
|
|
434
|
-
const failureHeader = batchFailure === undefined
|
|
435
|
-
? undefined
|
|
436
|
-
: [
|
|
437
|
-
batchSummary,
|
|
438
|
-
`First failing step: ${batchFailure.failedStep.index + 1} — ${batchFailure.failedStep.commandText}`,
|
|
439
|
-
batchFailure.failureCount > 1 ? `${batchFailure.failureCount} steps failed. See the per-step results below.` : "See the per-step results below.",
|
|
440
|
-
].join("\n");
|
|
441
|
-
const text = [failureHeader, mutationEvidenceText, stepText].filter((line) => line !== undefined).join("\n\n");
|
|
442
|
-
const artifactRetentionSummary = currentArtifactManifest ? formatSessionArtifactRetentionSummary(currentArtifactManifest) : undefined;
|
|
443
|
-
const contentText = artifactRetentionSummary && manifestHasNewNoticeWorthyEntries(options.artifactManifest, currentArtifactManifest)
|
|
444
|
-
? `${text}\n\n${artifactRetentionSummary}`
|
|
445
|
-
: text;
|
|
446
|
-
const artifactLifecycleActions = applyNamespaceToNextActions(buildAgentBrowserNextActions({ artifacts, command: "batch", resultCategory: batchFailure ? "failure" : "success", sessionName }), namespace);
|
|
447
|
-
const nextActions = batchFailure
|
|
448
|
-
? appendUniqueAgentBrowserNextActions([...(batchFailure.failedStep.nextActions ?? [])], artifactLifecycleActions)
|
|
449
|
-
: artifactLifecycleActions;
|
|
450
|
-
const changedSteps = steps.map((step) => step.details).filter((details) => details.pageChangeSummary !== undefined);
|
|
451
|
-
const observedChangeCount = changedSteps.filter((details) => details.pageChangeSummary?.observed === true).length;
|
|
452
|
-
const pageChangeSummary = artifacts.length > 0
|
|
453
|
-
? buildPageChangeSummary({
|
|
454
|
-
artifacts,
|
|
455
|
-
commandInfo: { command: "batch" },
|
|
456
|
-
data,
|
|
457
|
-
nextActions,
|
|
458
|
-
summary: batchSummary,
|
|
459
|
-
})
|
|
460
|
-
: changedSteps.length > 0
|
|
461
|
-
? {
|
|
462
|
-
changeType: "mutation",
|
|
463
|
-
command: "batch",
|
|
464
|
-
nextActionIds: nextActions?.map((action) => action.id),
|
|
465
|
-
observed: observedChangeCount > 0,
|
|
466
|
-
summary: observedChangeCount > 0
|
|
467
|
-
? `batch → ${observedChangeCount} observed change${observedChangeCount === 1 ? "" : "s"}${unverifiedMutationCount > 0 ? `; ${unverifiedMutationCount} dispatched action${unverifiedMutationCount === 1 ? "" : "s"} unverified` : ""}`
|
|
468
|
-
: `batch → ${unverifiedMutationCount} action${unverifiedMutationCount === 1 ? "" : "s"} dispatched → application change unverified`,
|
|
469
|
-
}
|
|
470
|
-
: undefined;
|
|
471
110
|
return {
|
|
472
|
-
|
|
473
|
-
artifactRetentionSummary,
|
|
474
|
-
artifactVerification,
|
|
475
|
-
artifacts: artifacts.length > 0 ? artifacts : undefined,
|
|
476
|
-
batchFailure,
|
|
477
|
-
batchSteps: steps.map((step) => step.details),
|
|
478
|
-
content: options.modelVisible === false ? [] : [{ type: "text", text: contentText }, ...images],
|
|
479
|
-
failureCategory: batchFailure?.failedStep.failureCategory,
|
|
480
|
-
data: redactedBatchData,
|
|
481
|
-
fullOutputPath: fullOutputPaths[0],
|
|
111
|
+
fullOutputPath: fullOutputPaths.at(0),
|
|
482
112
|
fullOutputPaths: fullOutputPaths.length > 0 ? fullOutputPaths : undefined,
|
|
483
|
-
imagePath: imagePaths
|
|
113
|
+
imagePath: imagePaths.at(0),
|
|
484
114
|
imagePaths: imagePaths.length > 0 ? imagePaths : undefined,
|
|
485
|
-
imageObservations: steps.flatMap(step => step.presentation.imageObservations ?? []),
|
|
486
|
-
nextActions,
|
|
487
|
-
pageChangeSummary,
|
|
488
|
-
resultCategory: batchFailure ? "failure" : "success",
|
|
489
|
-
successCategory: batchFailure ? undefined : classifyPresentationSuccessCategory({ artifactVerification, artifacts }),
|
|
490
|
-
summary: batchSummary,
|
|
491
115
|
};
|
|
492
116
|
}
|
|
117
|
+
function addRetentionNotice(text, notice, original, current) {
|
|
118
|
+
return notice !== undefined &&
|
|
119
|
+
notice.length > 0 &&
|
|
120
|
+
manifestHasNewNoticeWorthyEntries(original, current)
|
|
121
|
+
? `${text}\n\n${notice}`
|
|
122
|
+
: text;
|
|
123
|
+
}
|
|
@@ -4,17 +4,19 @@ import { buildNextToolAction } from "../next-actions.js";
|
|
|
4
4
|
const BROWSER_PROFILE_CONFIG_HINT = [
|
|
5
5
|
"Agent-browser profile/config hint: this looks like a local browser profile or Chrome user-data-dir setup problem, not a page-specific failure.",
|
|
6
6
|
"Do not keep retrying the same open/profile call. Run `profiles` and/or `doctor` through agent_browser, then tell the user whether Chrome/Chromium is installed, which Chrome profile directory names are available, or whether they need to configure a full profile/user-data directory path, a non-default Chromium-compatible `--executable-path`, or remove the profile requirement for public-page browsing.",
|
|
7
|
-
|
|
7
|
+
'Use the top-level `sessionMode: "fresh"` field for launch-scoped profile/debug/provider flags; do not pass `--session-mode` inside args.',
|
|
8
8
|
].join(" ");
|
|
9
9
|
function looksLikeBrowserProfileConfigError(errorText) {
|
|
10
10
|
return /\b(?:No Chrome user data directory found|Cannot resolve profile name|Chrome user data directory|Chrome profile\s+.+?\s+not found|Available profiles|If you meant a directory path)\b/i.test(errorText);
|
|
11
11
|
}
|
|
12
12
|
function isLaunchOrSetupContext(args, commandInfo) {
|
|
13
13
|
const command = commandInfo.command;
|
|
14
|
-
if (command === "profiles" || command === "doctor")
|
|
14
|
+
if (command === "profiles" || command === "doctor") {
|
|
15
15
|
return true;
|
|
16
|
-
|
|
16
|
+
}
|
|
17
|
+
if (command !== undefined && command.length > 0 && isOpenNavigationCommand(command)) {
|
|
17
18
|
return true;
|
|
19
|
+
}
|
|
18
20
|
return (args ? getStartupScopedFlags(args) : []).length > 0;
|
|
19
21
|
}
|
|
20
22
|
function buildBrowserProfileConfigActions(commandInfo) {
|
|
@@ -38,10 +40,12 @@ function buildBrowserProfileConfigActions(commandInfo) {
|
|
|
38
40
|
return actions;
|
|
39
41
|
}
|
|
40
42
|
export function buildBrowserProfileConfigRecovery(options) {
|
|
41
|
-
if (!looksLikeBrowserProfileConfigError(options.errorText))
|
|
43
|
+
if (!looksLikeBrowserProfileConfigError(options.errorText)) {
|
|
42
44
|
return undefined;
|
|
43
|
-
|
|
45
|
+
}
|
|
46
|
+
if (!isLaunchOrSetupContext(options.args, options.commandInfo)) {
|
|
44
47
|
return undefined;
|
|
48
|
+
}
|
|
45
49
|
const actions = buildBrowserProfileConfigActions(options.commandInfo);
|
|
46
50
|
return {
|
|
47
51
|
actions: actions.length > 0 ? actions : undefined,
|