pi-agent-browser-native 0.9.2 → 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 +91 -5
- package/README.md +120 -86
- package/dist/extensions/agent-browser/index.js +43065 -2016
- 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 +113 -49
- 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 -81
- 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 +44 -9
- package/dist/extensions/agent-browser/lib/orchestration/batch-stdin.js +107 -66
- 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 +171 -57
- 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 +204 -108
- 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 -199
- 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 -1114
- 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 -910
- 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 -753
- 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 -816
- 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 -139
- package/dist/extensions/agent-browser/lib/orchestration/operation-paths.js +124 -58
- package/dist/extensions/agent-browser/lib/orchestration/output-file.js +198 -98
- 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 +59 -243
- package/dist/extensions/agent-browser/lib/parsing.js +13 -4
- package/dist/extensions/agent-browser/lib/pi-tool-rendering.js +134 -68
- package/dist/extensions/agent-browser/lib/playbook.js +18 -14
- package/dist/extensions/agent-browser/lib/process-child.js +284 -0
- package/dist/extensions/agent-browser/lib/process-environment.js +22 -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 +146 -537
- 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 +138 -35
- 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 -10
- 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 +93 -66
- 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 -552
- 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 -1019
- 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 +117 -237
- 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 -248
- 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 +123 -123
- 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 -1037
- 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 +188 -324
- 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 +22 -10
- package/docs/CODE_QUALITY.md +242 -0
- package/docs/COMMAND_REFERENCE.md +264 -229
- package/docs/ELECTRON.md +53 -44
- package/docs/RELEASE.md +21 -17
- package/docs/REQUIREMENTS.md +2 -0
- package/docs/SESSION_STORAGE.md +1 -1
- package/docs/SUPPORT_MATRIX.md +84 -77
- package/docs/TOOL_CONTRACT.md +165 -130
- 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
package/dist/extensions/agent-browser/lib/orchestration/browser-run/screenshot-observation.js
CHANGED
|
@@ -1,22 +1,68 @@
|
|
|
1
1
|
import { isRecord } from "../../parsing.js";
|
|
2
2
|
import { LIGHTPANDA_IMAGE_REASON } from "../../results/presentation/common.js";
|
|
3
|
-
import {
|
|
3
|
+
import { getScreenshotCapture } from "./screenshot-capture.js";
|
|
4
|
+
export { getScreenshotCapture } from "./screenshot-capture.js";
|
|
4
5
|
import { runSessionCommandData } from "./session-state.js";
|
|
5
|
-
export function getScreenshotCapture(command) {
|
|
6
|
-
if (command[0] !== "screenshot")
|
|
7
|
-
return { kind: "unknown" };
|
|
8
|
-
if (command.includes("--full") || command.includes("-f"))
|
|
9
|
-
return { kind: "full-page" };
|
|
10
|
-
const positional = getScreenshotPositionalIndices(command);
|
|
11
|
-
const selectorIndex = positional.find(index => index !== getScreenshotPathTokenIndex(command));
|
|
12
|
-
return selectorIndex === undefined ? { kind: "viewport" } : { kind: "element", selector: command[selectorIndex] };
|
|
13
|
-
}
|
|
14
6
|
function finiteRecord(value, keys) {
|
|
15
|
-
return isRecord(value) &&
|
|
7
|
+
return (isRecord(value) &&
|
|
8
|
+
keys.every((key) => typeof value[key] === "number" && Number.isFinite(value[key])));
|
|
9
|
+
}
|
|
10
|
+
function parseSampleIdentity(sample) {
|
|
11
|
+
if ((sample.rendering !== undefined && sample.rendering !== "text") ||
|
|
12
|
+
typeof sample.url !== "string" ||
|
|
13
|
+
(sample.frame !== "main" && sample.frame !== "child")) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
url: sample.url,
|
|
18
|
+
frame: sample.frame,
|
|
19
|
+
...(sample.rendering === "text" ? { rendering: "text" } : {}),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function parseSampleScale(sample) {
|
|
23
|
+
if (typeof sample.childFrameCount !== "number" ||
|
|
24
|
+
!Number.isInteger(sample.childFrameCount) ||
|
|
25
|
+
sample.childFrameCount < 0 ||
|
|
26
|
+
typeof sample.dpr !== "number" ||
|
|
27
|
+
!Number.isFinite(sample.dpr) ||
|
|
28
|
+
sample.dpr <= 0) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
return { dpr: sample.dpr, childFrameCount: sample.childFrameCount };
|
|
32
|
+
}
|
|
33
|
+
function parseSampleMeasurements(value) {
|
|
34
|
+
if (!finiteRecord(value.viewport, ["width", "height"]) ||
|
|
35
|
+
!finiteRecord(value.document, ["width", "height"]) ||
|
|
36
|
+
!finiteRecord(value.scroll, ["x", "y"]) ||
|
|
37
|
+
!finiteRecord(value.visualViewport, ["x", "y", "scale"])) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
if (value.element !== undefined && !finiteRecord(value.element, ["x", "y", "width", "height"])) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
viewport: value.viewport,
|
|
45
|
+
document: value.document,
|
|
46
|
+
scroll: value.scroll,
|
|
47
|
+
visualViewport: value.visualViewport,
|
|
48
|
+
...(value.element !== undefined ? { element: value.element } : {}),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function parseScreenshotSample(value) {
|
|
52
|
+
if (!isRecord(value)) {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
const identity = parseSampleIdentity(value);
|
|
56
|
+
const scale = parseSampleScale(value);
|
|
57
|
+
const measurements = parseSampleMeasurements(value);
|
|
58
|
+
return identity && scale && measurements
|
|
59
|
+
? { ...value, ...identity, ...scale, ...measurements }
|
|
60
|
+
: undefined;
|
|
16
61
|
}
|
|
17
62
|
export async function collectScreenshotSample(options) {
|
|
18
|
-
if (options.command[0] !== "screenshot" || options.signal?.aborted)
|
|
63
|
+
if (options.command[0] !== "screenshot" || options.signal?.aborted === true) {
|
|
19
64
|
return undefined;
|
|
65
|
+
}
|
|
20
66
|
const { selector } = getScreenshotCapture(options.command);
|
|
21
67
|
const script = `(() => {
|
|
22
68
|
const root = document.documentElement, body = document.body, v = window.visualViewport;
|
|
@@ -37,47 +83,124 @@ export async function collectScreenshotSample(options) {
|
|
|
37
83
|
visualViewport: { x: v?.offsetLeft ?? 0, y: v?.offsetTop ?? 0, scale: v?.scale ?? 1 }, element };
|
|
38
84
|
})()`;
|
|
39
85
|
try {
|
|
40
|
-
const data = await runSessionCommandData({
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|| (sample.element !== undefined && !finiteRecord(sample.element, ["x", "y", "width", "height"])))
|
|
48
|
-
return undefined;
|
|
49
|
-
return sample;
|
|
86
|
+
const data = await runSessionCommandData({
|
|
87
|
+
...options,
|
|
88
|
+
args: ["eval", "--stdin"],
|
|
89
|
+
stdin: script,
|
|
90
|
+
timeoutMs: 2_000,
|
|
91
|
+
});
|
|
92
|
+
return parseScreenshotSample(isRecord(data) ? data.result : undefined);
|
|
50
93
|
}
|
|
51
94
|
catch {
|
|
52
95
|
return undefined;
|
|
53
96
|
}
|
|
54
97
|
}
|
|
98
|
+
function getMeasuredCrop(capture, before) {
|
|
99
|
+
if (capture === "viewport") {
|
|
100
|
+
return { ...before.scroll, ...before.viewport };
|
|
101
|
+
}
|
|
102
|
+
if (capture === "full-page") {
|
|
103
|
+
return { x: 0, y: 0, ...before.document };
|
|
104
|
+
}
|
|
105
|
+
if (capture === "element" &&
|
|
106
|
+
before.element &&
|
|
107
|
+
before.childFrameCount === 0 &&
|
|
108
|
+
before.scroll.x === 0 &&
|
|
109
|
+
before.scroll.y === 0) {
|
|
110
|
+
return before.element;
|
|
111
|
+
}
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
function pixelsMatchCrop(crop, pixels, dpr) {
|
|
115
|
+
return (crop.width > 0 &&
|
|
116
|
+
crop.height > 0 &&
|
|
117
|
+
crop.x >= 0 &&
|
|
118
|
+
crop.y >= 0 &&
|
|
119
|
+
Object.values(crop).every(Number.isInteger) &&
|
|
120
|
+
pixels.width === crop.width * dpr &&
|
|
121
|
+
pixels.height === crop.height * dpr);
|
|
122
|
+
}
|
|
123
|
+
function sampleFrameFailure(before) {
|
|
124
|
+
if (before.frame !== "main") {
|
|
125
|
+
return "Probe observed a child frame; its relation to the captured page is unknown.";
|
|
126
|
+
}
|
|
127
|
+
if (before.visualViewport.scale !== 1 ||
|
|
128
|
+
before.visualViewport.x !== 0 ||
|
|
129
|
+
before.visualViewport.y !== 0) {
|
|
130
|
+
return "Visual viewport is zoomed or offset; capture origin is unknown.";
|
|
131
|
+
}
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
134
|
+
function geometrySampleFailure(options) {
|
|
135
|
+
const { before, after } = options;
|
|
136
|
+
if (options.rendering === "text" || before?.rendering === "text" || after?.rendering === "text") {
|
|
137
|
+
return LIGHTPANDA_IMAGE_REASON;
|
|
138
|
+
}
|
|
139
|
+
if (!before || !after) {
|
|
140
|
+
return "Capture was not bracketed by browser geometry samples; coordinates are unknown.";
|
|
141
|
+
}
|
|
142
|
+
if (JSON.stringify(before) !== JSON.stringify(after)) {
|
|
143
|
+
return "Browser geometry changed across capture; no coordinate mapping is asserted.";
|
|
144
|
+
}
|
|
145
|
+
return sampleFrameFailure(before);
|
|
146
|
+
}
|
|
55
147
|
export function buildScreenshotGeometry(options) {
|
|
56
148
|
const { before, after, capture, pixels } = options;
|
|
57
|
-
const unknown = (reason) => ({
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (
|
|
65
|
-
return unknown(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (
|
|
70
|
-
crop = { ...before.scroll, ...before.viewport };
|
|
71
|
-
else if (capture === "full-page")
|
|
72
|
-
crop = { x: 0, y: 0, ...before.document };
|
|
73
|
-
else if (capture === "element" && before.element && before.childFrameCount === 0 && before.scroll.x === 0 && before.scroll.y === 0)
|
|
74
|
-
crop = before.element;
|
|
75
|
-
else
|
|
149
|
+
const unknown = (reason) => ({
|
|
150
|
+
status: "unknown",
|
|
151
|
+
reason,
|
|
152
|
+
before,
|
|
153
|
+
after,
|
|
154
|
+
});
|
|
155
|
+
const sampleFailure = geometrySampleFailure(options);
|
|
156
|
+
if (sampleFailure !== undefined || !before || !after) {
|
|
157
|
+
return unknown(sampleFailure ??
|
|
158
|
+
"Capture was not bracketed by browser geometry samples; coordinates are unknown.");
|
|
159
|
+
}
|
|
160
|
+
const crop = getMeasuredCrop(capture, before);
|
|
161
|
+
if (!crop) {
|
|
76
162
|
return unknown("Element crop/frame provenance is unverified (scrolled page, child frames, non-CSS selector, or ambiguous target).");
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|| pixels.width !== crop.width * before.dpr || pixels.height !== crop.height * before.dpr)
|
|
163
|
+
}
|
|
164
|
+
if (!pixels || !pixelsMatchCrop(crop, pixels, before.dpr)) {
|
|
80
165
|
return unknown("Image dimensions do not establish the sampled CSS crop at this DPR.");
|
|
81
|
-
|
|
82
|
-
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
status: "measured",
|
|
169
|
+
before,
|
|
170
|
+
after,
|
|
171
|
+
crop,
|
|
172
|
+
pixelsPerCssPixel: { x: pixels.width / crop.width, y: pixels.height / crop.height },
|
|
173
|
+
reason: "Matching pre/post samples, not an atomic capture guarantee. Pixels map to CSS document coordinates within crop; native mouse uses current viewport CSS coordinates. Recheck scroll/frame before input.",
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function observationCapture(value) {
|
|
177
|
+
switch (value) {
|
|
178
|
+
case "viewport":
|
|
179
|
+
case "full-page":
|
|
180
|
+
case "element":
|
|
181
|
+
return value;
|
|
182
|
+
default:
|
|
183
|
+
return "unknown";
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
export function annotateScreenshotImageObservations(observations, samples) {
|
|
187
|
+
const images = [];
|
|
188
|
+
for (const image of observations) {
|
|
189
|
+
if (!isRecord(image)) {
|
|
190
|
+
images.push(image);
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
const rendering = image.rendering ?? samples.before?.rendering ?? samples.after?.rendering;
|
|
194
|
+
images.push({
|
|
195
|
+
...image,
|
|
196
|
+
...(rendering !== undefined ? { rendering } : {}),
|
|
197
|
+
geometry: buildScreenshotGeometry({
|
|
198
|
+
rendering: rendering === "text" ? rendering : undefined,
|
|
199
|
+
capture: observationCapture(image.capture),
|
|
200
|
+
pixels: finiteRecord(image.pixels, ["width", "height"]) ? image.pixels : undefined,
|
|
201
|
+
...samples,
|
|
202
|
+
}),
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
return images;
|
|
83
206
|
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { rm } from "node:fs/promises";
|
|
3
|
+
import { parseArgvDescriptor } from "../../argv-descriptor.js";
|
|
4
|
+
import { isBrowserIndependentRead, needsManagedSession } from "../../command-policy.js";
|
|
5
|
+
import { isRecord } from "../../parsing.js";
|
|
6
|
+
import { runAgentBrowserProcess } from "../../process.js";
|
|
7
|
+
import { detectConfirmationRequired } from "../../results/confirmation.js";
|
|
8
|
+
import { parseAgentBrowserEnvelope } from "../../results/envelope.js";
|
|
9
|
+
import { observeNativeWebMcp } from "../../webmcp-observation.js";
|
|
10
|
+
const sessionCommandObservation = new AsyncLocalStorage();
|
|
11
|
+
export function withSessionCommandObservation(observer, run) {
|
|
12
|
+
return sessionCommandObservation.run(observer, run);
|
|
13
|
+
}
|
|
14
|
+
function isNativeParseFailure(envelope) {
|
|
15
|
+
if (envelope?.success !== false ||
|
|
16
|
+
!isRecord(envelope.data) ||
|
|
17
|
+
Object.keys(envelope.data).length !== 1) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
return (typeof envelope.data.type === "string" &&
|
|
21
|
+
[
|
|
22
|
+
"unknown_command",
|
|
23
|
+
"unknown_subcommand",
|
|
24
|
+
"missing_arguments",
|
|
25
|
+
"invalid_value",
|
|
26
|
+
"invalid_session_name",
|
|
27
|
+
].includes(envelope.data.type));
|
|
28
|
+
}
|
|
29
|
+
function isSessionlessLocalCommand(commandTokens) {
|
|
30
|
+
return (commandTokens !== undefined &&
|
|
31
|
+
!needsManagedSession(parseArgvDescriptor(commandTokens)) &&
|
|
32
|
+
!isBrowserIndependentRead(commandTokens));
|
|
33
|
+
}
|
|
34
|
+
export function nativePolicyDefinitelyUnestablished(result, envelope, commandTokens) {
|
|
35
|
+
if (isSessionlessLocalCommand(commandTokens)) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
if (!result.agentBrowserStarted) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
if (result.aborted ||
|
|
42
|
+
result.timedOut ||
|
|
43
|
+
result.spawnError !== undefined ||
|
|
44
|
+
result.exitCode !== 1) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
// Native CLI parse/config failures precede ensure_daemon; a failed executed action does not.
|
|
48
|
+
return (isNativeParseFailure(envelope) ||
|
|
49
|
+
(result.stdout.trim() === "" &&
|
|
50
|
+
/config file not found:|failed to load config from /.test(result.stderr)));
|
|
51
|
+
}
|
|
52
|
+
function processFailureReason(result) {
|
|
53
|
+
if (result.aborted) {
|
|
54
|
+
return "command was aborted";
|
|
55
|
+
}
|
|
56
|
+
if (result.spawnError !== undefined) {
|
|
57
|
+
return "process could not start";
|
|
58
|
+
}
|
|
59
|
+
if (result.exitCode !== 0) {
|
|
60
|
+
return `process exited with code ${result.exitCode}`;
|
|
61
|
+
}
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
function structuredFailureReason(parsed) {
|
|
65
|
+
if ((parsed.parseError?.length ?? 0) > 0) {
|
|
66
|
+
return "returned invalid structured output";
|
|
67
|
+
}
|
|
68
|
+
if (parsed.envelope?.success === false || detectConfirmationRequired(parsed.envelope?.data)) {
|
|
69
|
+
return "reported failure or requires confirmation";
|
|
70
|
+
}
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
async function readSessionCommandResult(options, processResult) {
|
|
74
|
+
options.onProcessResult?.(processResult);
|
|
75
|
+
const parsed = await parseAgentBrowserEnvelope({
|
|
76
|
+
stdout: processResult.stdout,
|
|
77
|
+
stdoutPath: processResult.stdoutSpillPath,
|
|
78
|
+
});
|
|
79
|
+
sessionCommandObservation.getStore()?.observe(options, processResult, parsed.envelope);
|
|
80
|
+
const failure = processFailureReason(processResult) ?? structuredFailureReason(parsed);
|
|
81
|
+
if (failure !== undefined) {
|
|
82
|
+
if (options.throwOnFailure === true) {
|
|
83
|
+
throw new Error(`agent-browser ${failure}`);
|
|
84
|
+
}
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
observeNativeWebMcp(parsed.envelope?.data);
|
|
88
|
+
return parsed.envelope?.data;
|
|
89
|
+
}
|
|
90
|
+
async function removeCommandSpill(path) {
|
|
91
|
+
if (path === undefined || path.length === 0) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
await rm(path, { force: true });
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
// The command result/parse error is authoritative. A private temporary stdout spill
|
|
99
|
+
// is disposable; failing to unlink it must not turn success into failure or mask
|
|
100
|
+
// the original exception. The process temp-root lifecycle also owns stale spills.
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
export async function runSessionCommandData(options) {
|
|
104
|
+
const { args, cwd, env, namespace, pinNamespace, sessionName, signal, stdin, timeoutMs } = options;
|
|
105
|
+
if (sessionName === undefined ||
|
|
106
|
+
sessionName.length === 0 ||
|
|
107
|
+
sessionCommandObservation.getStore()?.allow(options) === false) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const processResult = await runAgentBrowserProcess({
|
|
111
|
+
args: [
|
|
112
|
+
"--json",
|
|
113
|
+
...(namespace !== undefined || pinNamespace === true ? ["--namespace", namespace ?? ""] : []),
|
|
114
|
+
"--session",
|
|
115
|
+
sessionName,
|
|
116
|
+
...args,
|
|
117
|
+
],
|
|
118
|
+
cwd,
|
|
119
|
+
env,
|
|
120
|
+
signal,
|
|
121
|
+
stdin,
|
|
122
|
+
timeoutMs,
|
|
123
|
+
});
|
|
124
|
+
try {
|
|
125
|
+
return await readSessionCommandResult(options, processResult);
|
|
126
|
+
}
|
|
127
|
+
finally {
|
|
128
|
+
await removeCommandSpill(processResult.stdoutSpillPath);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { getAgentBrowserSessionIdentityKey } from "../../argv-grammar.js";
|
|
2
|
+
import { isElectronPostCommandHealthCommand } from "../../command-taxonomy.js";
|
|
3
|
+
import { buildAgentBrowserNextActions } from "../../results/action-recommendations.js";
|
|
4
|
+
import { isAboutBlankUrl, normalizeComparableUrl, } from "../../session-page-state.js";
|
|
5
|
+
import { getGuardedRefUsage } from "./session-state-refs.js";
|
|
6
|
+
export function isLiveElectronRendererTarget(target) {
|
|
7
|
+
const normalizedUrl = normalizeComparableUrl(target.url);
|
|
8
|
+
if (normalizedUrl === undefined ||
|
|
9
|
+
normalizedUrl.length === 0 ||
|
|
10
|
+
normalizedUrl === "about:blank" ||
|
|
11
|
+
normalizedUrl.startsWith("devtools://")) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
return target.type === undefined || target.type === "page" || target.type === "webview";
|
|
15
|
+
}
|
|
16
|
+
export function getLiveElectronRendererTargets(targets) {
|
|
17
|
+
return targets.filter(isLiveElectronRendererTarget);
|
|
18
|
+
}
|
|
19
|
+
export function electronTargetLabel(target) {
|
|
20
|
+
if (!target) {
|
|
21
|
+
return "unknown target";
|
|
22
|
+
}
|
|
23
|
+
return ([target.title, target.url, target.id].find((value) => typeof value === "string" && value.trim().length > 0) ?? "unknown target");
|
|
24
|
+
}
|
|
25
|
+
export function getActiveElectronRecords(records) {
|
|
26
|
+
return [...records.values()].filter((record) => ["active", "dead", "partial", "failed"].includes(record.cleanupState));
|
|
27
|
+
}
|
|
28
|
+
export function findElectronLaunchRecordForSession(sessionName, records, namespace) {
|
|
29
|
+
if (sessionName === undefined || sessionName.length === 0) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const sessionKey = getAgentBrowserSessionIdentityKey(sessionName, namespace);
|
|
33
|
+
return getActiveElectronRecords(records).find((record) => (record.sessionName?.length ?? 0) > 0 &&
|
|
34
|
+
getAgentBrowserSessionIdentityKey(record.sessionName ?? "", record.namespace) === sessionKey);
|
|
35
|
+
}
|
|
36
|
+
function buildElectronReattachNextAction(record, liveTarget) {
|
|
37
|
+
const endpoint = liveTarget?.webSocketDebuggerUrl ?? record.webSocketDebuggerUrl ?? String(record.port);
|
|
38
|
+
return {
|
|
39
|
+
id: "reattach-electron-launch",
|
|
40
|
+
params: { args: ["connect", endpoint], sessionMode: "fresh" },
|
|
41
|
+
reason: "Attach a fresh managed session to the same wrapper-tracked Electron debug endpoint when the current session no longer matches the live renderer.",
|
|
42
|
+
safety: "Creates a new managed browser session; it does not mutate the Electron app. Keep the launchId for later status and cleanup.",
|
|
43
|
+
tool: "agent_browser",
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export function buildElectronLifecycleNextActions(record) {
|
|
47
|
+
return (buildAgentBrowserNextActions({
|
|
48
|
+
electron: {
|
|
49
|
+
launchId: record.launchId,
|
|
50
|
+
sessionName: record.sessionName,
|
|
51
|
+
status: record.cleanupState,
|
|
52
|
+
},
|
|
53
|
+
resultCategory: "success",
|
|
54
|
+
successCategory: "completed",
|
|
55
|
+
}) ?? []);
|
|
56
|
+
}
|
|
57
|
+
export function buildElectronMismatchNextActions(record, liveTarget) {
|
|
58
|
+
const reattachAction = buildElectronReattachNextAction(record, liveTarget);
|
|
59
|
+
const actions = [];
|
|
60
|
+
for (const action of buildElectronLifecycleNextActions(record)) {
|
|
61
|
+
actions.push(action);
|
|
62
|
+
if (action.id === "probe-electron-launch") {
|
|
63
|
+
actions.push(reattachAction);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (!actions.some((action) => action.id === reattachAction.id)) {
|
|
67
|
+
actions.push(reattachAction);
|
|
68
|
+
}
|
|
69
|
+
return actions;
|
|
70
|
+
}
|
|
71
|
+
function getElectronMismatchReason(managedSession, recordSessionName) {
|
|
72
|
+
if (isAboutBlankUrl(managedSession.url)) {
|
|
73
|
+
return "managed-session-about-blank-while-launch-target-live";
|
|
74
|
+
}
|
|
75
|
+
if ((recordSessionName?.length ?? 0) > 0 && recordSessionName !== managedSession.sessionName) {
|
|
76
|
+
return "launch-session-not-current";
|
|
77
|
+
}
|
|
78
|
+
if ((normalizeComparableUrl(managedSession.url)?.length ?? 0) > 0) {
|
|
79
|
+
return "managed-session-target-not-in-launch-status";
|
|
80
|
+
}
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
function describeElectronMismatch(managedSession, record, liveTarget, reason) {
|
|
84
|
+
const managedDescription = managedSession.url ?? managedSession.title ?? managedSession.sessionName;
|
|
85
|
+
const liveDescription = electronTargetLabel(liveTarget);
|
|
86
|
+
return reason === "launch-session-not-current"
|
|
87
|
+
? `Electron session mismatch: current managed session ${managedSession.sessionName} is not the wrapper launch session ${record.sessionName ?? "unknown"}, while launch ${record.launchId} still has live target ${liveDescription}.`
|
|
88
|
+
: `Electron session mismatch: managed session ${managedSession.sessionName} is on ${managedDescription}, but launch ${record.launchId} still has live target ${liveDescription}.`;
|
|
89
|
+
}
|
|
90
|
+
export function buildElectronSessionMismatch(options) {
|
|
91
|
+
const liveTargets = getLiveElectronRendererTargets(options.statusTargets);
|
|
92
|
+
if (liveTargets.length === 0) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const managedUrl = normalizeComparableUrl(options.managedSession.url);
|
|
96
|
+
const matchingLiveTarget = (managedUrl?.length ?? 0) > 0
|
|
97
|
+
? liveTargets.find((target) => normalizeComparableUrl(target.url) === managedUrl)
|
|
98
|
+
: undefined;
|
|
99
|
+
if (matchingLiveTarget) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const liveTarget = liveTargets[0];
|
|
103
|
+
const reason = getElectronMismatchReason(options.managedSession, options.record.sessionName);
|
|
104
|
+
if (reason === undefined) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const nextActions = buildElectronMismatchNextActions(options.record, liveTarget);
|
|
108
|
+
return {
|
|
109
|
+
launchId: options.record.launchId,
|
|
110
|
+
liveTarget,
|
|
111
|
+
managedSession: options.managedSession,
|
|
112
|
+
nextActionIds: nextActions.map((action) => action.id),
|
|
113
|
+
reason,
|
|
114
|
+
sessionName: options.record.sessionName,
|
|
115
|
+
statusTargets: options.statusTargets,
|
|
116
|
+
summary: describeElectronMismatch(options.managedSession, options.record, liveTarget, reason),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
export function formatElectronSessionMismatchText(mismatch) {
|
|
120
|
+
return `${mismatch.summary}\nNext: run electron.status/electron.probe with launchId ${mismatch.launchId}, reattach with the reattach-electron-launch nextAction if needed, or cleanup when finished.`;
|
|
121
|
+
}
|
|
122
|
+
export function shouldInspectElectronPostCommandHealth(command) {
|
|
123
|
+
return isElectronPostCommandHealthCommand(command);
|
|
124
|
+
}
|
|
125
|
+
function getElectronHealthReason(status, targetUrl) {
|
|
126
|
+
if (status.pidAlive === false) {
|
|
127
|
+
return "process-dead";
|
|
128
|
+
}
|
|
129
|
+
if (!status.portAlive) {
|
|
130
|
+
return "debug-port-dead";
|
|
131
|
+
}
|
|
132
|
+
if (isAboutBlankUrl(targetUrl) && getLiveElectronRendererTargets(status.targets).length === 0) {
|
|
133
|
+
return "about-blank-no-live-target";
|
|
134
|
+
}
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
function formatElectronHealthStatus(status) {
|
|
138
|
+
const portText = status.portAlive ? "debug port alive" : "debug port dead";
|
|
139
|
+
if (status.pidAlive === undefined) {
|
|
140
|
+
return portText;
|
|
141
|
+
}
|
|
142
|
+
return `${portText}${status.pidAlive ? ", pid alive" : ", pid dead"}`;
|
|
143
|
+
}
|
|
144
|
+
export function buildElectronPostCommandHealthDiagnostic(options) {
|
|
145
|
+
const reason = getElectronHealthReason(options.status, options.target?.url);
|
|
146
|
+
if (reason === undefined) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const nextActions = buildElectronLifecycleNextActions(options.record);
|
|
150
|
+
const commandText = (options.command?.length ?? 0) > 0 ? `${options.command ?? ""} command` : "command";
|
|
151
|
+
return {
|
|
152
|
+
appName: options.record.appName,
|
|
153
|
+
command: options.command,
|
|
154
|
+
launchId: options.record.launchId,
|
|
155
|
+
nextActionIds: nextActions.map((action) => action.id),
|
|
156
|
+
reason,
|
|
157
|
+
sessionName: options.record.sessionName,
|
|
158
|
+
status: options.status,
|
|
159
|
+
summary: `Electron lifecycle warning: ${commandText} completed, but launch ${options.record.launchId} is no longer healthy (${formatElectronHealthStatus(options.status)}).`,
|
|
160
|
+
target: options.target,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
export function formatElectronPostCommandHealthText(diagnostic) {
|
|
164
|
+
if (!diagnostic) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
const lines = [diagnostic.summary];
|
|
168
|
+
if ((diagnostic.target?.url.length ?? 0) > 0) {
|
|
169
|
+
lines.push(`Current browser session target: ${diagnostic.target?.url ?? ""}.`);
|
|
170
|
+
}
|
|
171
|
+
lines.push(`Status: ${formatElectronHealthStatus(diagnostic.status)}; ${diagnostic.status.targets.length} CDP target(s).`, `Next: run electron.status/electron.probe with launchId ${diagnostic.launchId}, cleanup the wrapper-owned launch if dead, or relaunch the app.`);
|
|
172
|
+
return lines.join("\n");
|
|
173
|
+
}
|
|
174
|
+
export function buildElectronIdentifiers(record) {
|
|
175
|
+
return { appName: record.appName, launchId: record.launchId, sessionName: record.sessionName };
|
|
176
|
+
}
|
|
177
|
+
export function buildElectronRefFreshnessNextActions(sessionName) {
|
|
178
|
+
return [
|
|
179
|
+
{
|
|
180
|
+
id: "refresh-electron-refs-after-rerender",
|
|
181
|
+
params: {
|
|
182
|
+
args: (sessionName?.length ?? 0) > 0
|
|
183
|
+
? ["--session", sessionName ?? "", "snapshot", "-i"]
|
|
184
|
+
: ["snapshot", "-i"],
|
|
185
|
+
},
|
|
186
|
+
reason: "Electron UIs often rerender without changing URL; refresh refs before using old @e handles again.",
|
|
187
|
+
safety: "Read-only snapshot; avoids stale same-URL refs after quick-pick, modal, theme, or editor rerenders.",
|
|
188
|
+
tool: "agent_browser",
|
|
189
|
+
},
|
|
190
|
+
];
|
|
191
|
+
}
|
|
192
|
+
export function buildElectronRefFreshnessDiagnostic(options) {
|
|
193
|
+
if (!options.record || !shouldInspectElectronPostCommandHealth(options.command)) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
if (getGuardedRefUsage(options.commandTokens, options.stdin).length === 0) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const nextActions = buildElectronRefFreshnessNextActions(options.sessionName);
|
|
200
|
+
return {
|
|
201
|
+
command: options.command,
|
|
202
|
+
launchId: options.record.launchId,
|
|
203
|
+
nextActionIds: nextActions.map((action) => action.id),
|
|
204
|
+
sessionName: options.sessionName,
|
|
205
|
+
summary: `Electron ref freshness: ${options.command ?? "mutation"} used page-scoped refs in an Electron UI. Re-run snapshot -i before reusing old @e refs, even if the URL did not change.`,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
export function formatElectronRefFreshnessText(diagnostic) {
|
|
209
|
+
return diagnostic?.summary;
|
|
210
|
+
}
|
package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-observations.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { isNavigationObservableCommandName } from "../../command-taxonomy.js";
|
|
2
|
+
import { isRecord } from "../../parsing.js";
|
|
3
|
+
export function extractStringResultField(data, fieldName) {
|
|
4
|
+
if (typeof data === "string") {
|
|
5
|
+
if (fieldName === "value") {
|
|
6
|
+
return data;
|
|
7
|
+
}
|
|
8
|
+
const text = data.trim();
|
|
9
|
+
return text.length > 0 ? text : undefined;
|
|
10
|
+
}
|
|
11
|
+
if (!isRecord(data) || typeof data[fieldName] !== "string") {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (fieldName === "value") {
|
|
15
|
+
return data[fieldName];
|
|
16
|
+
}
|
|
17
|
+
const text = data[fieldName].trim();
|
|
18
|
+
return text.length > 0 ? text : undefined;
|
|
19
|
+
}
|
|
20
|
+
export function extractNavigationSummaryFromData(data) {
|
|
21
|
+
const result = isRecord(data) && isRecord(data.result) ? data.result : data;
|
|
22
|
+
const title = extractStringResultField(result, "title");
|
|
23
|
+
const url = extractStringResultField(result, "url");
|
|
24
|
+
const urlChanged = isRecord(result) && typeof result.urlChanged === "boolean" ? result.urlChanged : undefined;
|
|
25
|
+
return Boolean(title) || Boolean(url) ? { title, url, urlChanged } : undefined;
|
|
26
|
+
}
|
|
27
|
+
function isConfirmedNavigationWithoutUrl(data) {
|
|
28
|
+
return (isRecord(data) &&
|
|
29
|
+
data.confirmed === true &&
|
|
30
|
+
data.action === "navigate" &&
|
|
31
|
+
isRecord(data.result) &&
|
|
32
|
+
data.result.success === true &&
|
|
33
|
+
extractStringResultField(data.result.data, "url") === undefined);
|
|
34
|
+
}
|
|
35
|
+
export function shouldCaptureNavigationSummary(command, data, subcommand) {
|
|
36
|
+
if (command === "eval") {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
// A completed compound action may navigate without returning a URL (e.g. recording restart).
|
|
40
|
+
if (command === "confirm" && isConfirmedNavigationWithoutUrl(data)) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
return (isNavigationObservableCommandName(command, subcommand) &&
|
|
44
|
+
(!isRecord(data) || (typeof data.title !== "string" && typeof data.url !== "string")));
|
|
45
|
+
}
|
|
46
|
+
export function mergeNavigationSummaryIntoData(data, navigationSummary) {
|
|
47
|
+
return isRecord(data) ? { ...data, navigationSummary } : { navigationSummary, result: data };
|
|
48
|
+
}
|
|
49
|
+
export function buildAboutBlankRecoveryHint() {
|
|
50
|
+
return "agent_browser detected that the active tab became about:blank while this session still had a prior intended tab. Run tab list for this session and re-select the intended tab, or retry with sessionMode=fresh if the tab is gone.";
|
|
51
|
+
}
|
|
52
|
+
export function buildAboutBlankWarning(mismatch) {
|
|
53
|
+
return `Warning: agent_browser detected that this session returned about:blank while the prior intended tab was ${mismatch.targetUrl}. ${mismatch.recoveryApplied ? "The wrapper re-selected the intended tab for the session." : "No matching tab could be re-selected; run tab list for the same session or retry with sessionMode=fresh."}`;
|
|
54
|
+
}
|
|
55
|
+
export function extractBatchResultCommand(item) {
|
|
56
|
+
if (!Array.isArray(item.command)) {
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
const tokens = item.command;
|
|
60
|
+
return tokens.filter((token) => typeof token === "string");
|
|
61
|
+
}
|