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
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { setTimeout as sleepMs } from "node:timers/promises";
|
|
2
|
+
import { boundElectronProbeString } from "../../electron/cdp.js";
|
|
3
|
+
import { buildNextToolAction, withOptionalSessionArgs } from "../../results/next-actions.js";
|
|
4
|
+
import { extractRefSnapshotFromData } from "../../session-page-state.js";
|
|
5
|
+
import { extractStringResultField, runSessionCommandData } from "./session-state.js";
|
|
6
|
+
import { diagnosticErrorText } from "./diagnostic-values.js";
|
|
7
|
+
function boundedSessionResult(data, field, limit) {
|
|
8
|
+
return boundElectronProbeString(extractStringResultField(data, "result") ?? extractStringResultField(data, field), limit);
|
|
9
|
+
}
|
|
10
|
+
async function collectManagedSessionCommandData(options) {
|
|
11
|
+
try {
|
|
12
|
+
return { data: await runSessionCommandData({ ...options, pinNamespace: true }) };
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
return { error: diagnosticErrorText(error) };
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
async function collectElectronManagedSessionUrl(options) {
|
|
19
|
+
const urlResult = await collectManagedSessionCommandData({ ...options, args: ["get", "url"] });
|
|
20
|
+
const url = boundElectronProbeString(extractStringResultField(urlResult.data, "result") ??
|
|
21
|
+
extractStringResultField(urlResult.data, "url"), 300);
|
|
22
|
+
return urlResult.error !== undefined && urlResult.error !== ""
|
|
23
|
+
? { error: urlResult.error }
|
|
24
|
+
: { url };
|
|
25
|
+
}
|
|
26
|
+
export async function collectElectronManagedSessionTarget(options) {
|
|
27
|
+
if (options.sessionName === undefined || options.sessionName === "") {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
const request = { ...options, sessionName: options.sessionName };
|
|
31
|
+
const urlResult = await collectManagedSessionCommandData({ ...request, args: ["get", "url"] });
|
|
32
|
+
const url = boundedSessionResult(urlResult.data, "url", 300);
|
|
33
|
+
if ((urlResult.error ?? "") !== "" || url === undefined || url === "") {
|
|
34
|
+
return {
|
|
35
|
+
error: urlResult.error ?? "get url returned no active page URL.",
|
|
36
|
+
sessionName: options.sessionName,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const titleResult = await collectManagedSessionCommandData({
|
|
40
|
+
...request,
|
|
41
|
+
args: ["get", "title"],
|
|
42
|
+
});
|
|
43
|
+
const title = boundedSessionResult(titleResult.data, "title", 160);
|
|
44
|
+
return {
|
|
45
|
+
sessionName: options.sessionName,
|
|
46
|
+
title,
|
|
47
|
+
url,
|
|
48
|
+
...(titleResult.error !== undefined && titleResult.error !== ""
|
|
49
|
+
? { error: titleResult.error }
|
|
50
|
+
: {}),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export async function collectQaAttachedTarget(options) {
|
|
54
|
+
if (options.sessionName === undefined || options.sessionName === "") {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
const target = options.currentTarget;
|
|
58
|
+
if (target && ((target.title ?? "") !== "" || target.url !== "")) {
|
|
59
|
+
return {
|
|
60
|
+
sessionName: options.sessionName,
|
|
61
|
+
title: target.title,
|
|
62
|
+
url: target.url,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return collectElectronManagedSessionTarget({
|
|
66
|
+
cwd: options.cwd,
|
|
67
|
+
namespace: options.namespace,
|
|
68
|
+
sessionName: options.sessionName,
|
|
69
|
+
signal: options.signal,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
export function formatQaAttachedTargetText(target) {
|
|
73
|
+
return target
|
|
74
|
+
? ["QA attached target:", target.sessionName, target.title, target.url]
|
|
75
|
+
.filter((part) => typeof part === "string" && part.length > 0)
|
|
76
|
+
.join(" — ")
|
|
77
|
+
: undefined;
|
|
78
|
+
}
|
|
79
|
+
function buildQaAttachedRecoveryNextActions(sessionName) {
|
|
80
|
+
return [
|
|
81
|
+
buildNextToolAction({
|
|
82
|
+
args: withOptionalSessionArgs(sessionName, ["tab", "list"]),
|
|
83
|
+
id: "list-tabs-before-qa-attached",
|
|
84
|
+
reason: "Inspect the connected session tabs before retrying qa.attached.",
|
|
85
|
+
safety: "Read-only tab listing for the attached session.",
|
|
86
|
+
}),
|
|
87
|
+
buildNextToolAction({
|
|
88
|
+
args: withOptionalSessionArgs(sessionName, ["snapshot", "-i"]),
|
|
89
|
+
id: "snapshot-before-qa-attached",
|
|
90
|
+
reason: "Capture interactive refs on the active page before retrying qa.attached.",
|
|
91
|
+
safety: "Read-only snapshot; confirms a renderable page is selected.",
|
|
92
|
+
}),
|
|
93
|
+
];
|
|
94
|
+
}
|
|
95
|
+
export async function validateQaAttachedPrecondition(options) {
|
|
96
|
+
if (options.sessionName === undefined || options.sessionName === "") {
|
|
97
|
+
return {
|
|
98
|
+
error: "qa.attached requires an active attached session with a resolvable session name.",
|
|
99
|
+
nextActions: buildQaAttachedRecoveryNextActions(options.sessionName),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
const urlProbe = await collectElectronManagedSessionUrl({
|
|
103
|
+
...options,
|
|
104
|
+
sessionName: options.sessionName,
|
|
105
|
+
});
|
|
106
|
+
if (urlProbe.error !== undefined && urlProbe.error !== "") {
|
|
107
|
+
return {
|
|
108
|
+
error: `qa.attached could not read the attached session URL: ${urlProbe.error}. Run tab list or snapshot -i before retrying qa.attached.`,
|
|
109
|
+
nextActions: buildQaAttachedRecoveryNextActions(options.sessionName),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
const url = urlProbe.url?.trim();
|
|
113
|
+
return url === undefined || url === ""
|
|
114
|
+
? {
|
|
115
|
+
error: "qa.attached requires an attached session with a readable page URL. Run tab list, select a stable tab, then snapshot -i before retrying.",
|
|
116
|
+
nextActions: buildQaAttachedRecoveryNextActions(options.sessionName),
|
|
117
|
+
}
|
|
118
|
+
: undefined;
|
|
119
|
+
}
|
|
120
|
+
async function verifyHandoffUrl(options) {
|
|
121
|
+
const urlData = await runSessionCommandData({
|
|
122
|
+
args: ["get", "url"],
|
|
123
|
+
cwd: options.cwd,
|
|
124
|
+
namespace: options.namespace,
|
|
125
|
+
sessionName: options.sessionName,
|
|
126
|
+
signal: options.signal,
|
|
127
|
+
throwOnFailure: true,
|
|
128
|
+
});
|
|
129
|
+
if (options.signal?.aborted ?? false) {
|
|
130
|
+
throw new Error("Electron handoff was aborted.");
|
|
131
|
+
}
|
|
132
|
+
const url = extractStringResultField(urlData, "result") ?? extractStringResultField(urlData, "url");
|
|
133
|
+
if (url === undefined || url === "") {
|
|
134
|
+
throw new Error("Electron handoff get url returned no active page URL.");
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
async function collectHandoffTabs(options) {
|
|
138
|
+
const tabs = await runSessionCommandData({
|
|
139
|
+
args: ["tab", "list"],
|
|
140
|
+
cwd: options.cwd,
|
|
141
|
+
namespace: options.namespace,
|
|
142
|
+
sessionName: options.sessionName,
|
|
143
|
+
signal: options.signal,
|
|
144
|
+
throwOnFailure: true,
|
|
145
|
+
});
|
|
146
|
+
if (options.signal?.aborted ?? false) {
|
|
147
|
+
throw new Error("Electron handoff was aborted.");
|
|
148
|
+
}
|
|
149
|
+
return tabs;
|
|
150
|
+
}
|
|
151
|
+
async function collectHandoffSnapshot(options) {
|
|
152
|
+
let snapshot = await runSessionCommandData({
|
|
153
|
+
args: ["snapshot", "-i"],
|
|
154
|
+
cwd: options.cwd,
|
|
155
|
+
namespace: options.namespace,
|
|
156
|
+
sessionName: options.sessionName,
|
|
157
|
+
signal: options.signal,
|
|
158
|
+
throwOnFailure: true,
|
|
159
|
+
});
|
|
160
|
+
let refSnapshot = extractRefSnapshotFromData(snapshot);
|
|
161
|
+
let snapshotRetryCount = 0;
|
|
162
|
+
while (needsSnapshotRetry(refSnapshot) && snapshotRetryCount < 2) {
|
|
163
|
+
if (options.signal?.aborted ?? false) {
|
|
164
|
+
throw new Error("Electron handoff was aborted.");
|
|
165
|
+
}
|
|
166
|
+
snapshotRetryCount += 1;
|
|
167
|
+
// Renderer startup must settle before retrying the native snapshot.
|
|
168
|
+
// oxlint-disable-next-line no-await-in-loop
|
|
169
|
+
await sleepMs(250);
|
|
170
|
+
if (options.signal?.aborted ?? false) {
|
|
171
|
+
throw new Error("Electron handoff was aborted.");
|
|
172
|
+
}
|
|
173
|
+
// Each retry uses the prior snapshot result and the same session identity.
|
|
174
|
+
// oxlint-disable-next-line no-await-in-loop
|
|
175
|
+
snapshot = await runSessionCommandData({
|
|
176
|
+
args: ["snapshot", "-i"],
|
|
177
|
+
cwd: options.cwd,
|
|
178
|
+
namespace: options.namespace,
|
|
179
|
+
sessionName: options.sessionName,
|
|
180
|
+
signal: options.signal,
|
|
181
|
+
throwOnFailure: true,
|
|
182
|
+
});
|
|
183
|
+
refSnapshot = extractRefSnapshotFromData(snapshot);
|
|
184
|
+
}
|
|
185
|
+
return { refSnapshot, snapshot, ...(snapshotRetryCount > 0 ? { snapshotRetryCount } : {}) };
|
|
186
|
+
}
|
|
187
|
+
function needsSnapshotRetry(snapshot) {
|
|
188
|
+
return snapshot === undefined || snapshot.refIds.length === 0;
|
|
189
|
+
}
|
|
190
|
+
export async function collectElectronHandoff(options) {
|
|
191
|
+
if (options.handoff === "connect") {
|
|
192
|
+
return { handoff: "connect" };
|
|
193
|
+
}
|
|
194
|
+
if (options.signal?.aborted ?? false) {
|
|
195
|
+
throw new Error("Electron handoff was aborted.");
|
|
196
|
+
}
|
|
197
|
+
await verifyHandoffUrl(options);
|
|
198
|
+
const tabs = await collectHandoffTabs(options);
|
|
199
|
+
return options.handoff === "tabs"
|
|
200
|
+
? { handoff: "tabs", tabs }
|
|
201
|
+
: { handoff: "snapshot", ...(await collectHandoffSnapshot(options)), tabs };
|
|
202
|
+
}
|
package/dist/extensions/agent-browser/lib/orchestration/browser-run/electron-text-diagnostics.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { withOptionalSessionArgs } from "../../results/next-actions.js";
|
|
2
|
+
import { findElectronLaunchRecordForSession } from "./session-state.js";
|
|
3
|
+
import { getSuccessfulGetTextSelectors, selectorMayExposeSensitiveLiteral, } from "./text-visibility-diagnostics.js";
|
|
4
|
+
const BROAD_TEXT_SELECTORS = new Set([
|
|
5
|
+
"body",
|
|
6
|
+
"html",
|
|
7
|
+
":root",
|
|
8
|
+
"*",
|
|
9
|
+
"main",
|
|
10
|
+
"div",
|
|
11
|
+
"section",
|
|
12
|
+
"article",
|
|
13
|
+
]);
|
|
14
|
+
function isBroadGetTextSelector(selector) {
|
|
15
|
+
if (selector === undefined ||
|
|
16
|
+
selector === "" ||
|
|
17
|
+
/^@e\d+$/.test(selector) ||
|
|
18
|
+
selectorMayExposeSensitiveLiteral(selector)) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
const normalized = selector.trim().replace(/\s+/g, " ").toLowerCase();
|
|
22
|
+
return (BROAD_TEXT_SELECTORS.has(normalized) ||
|
|
23
|
+
/^\[role=(?:"application"|'application'|application)\]$/i.test(normalized));
|
|
24
|
+
}
|
|
25
|
+
export function getSourceLookupElectronContext(options) {
|
|
26
|
+
const record = findElectronLaunchRecordForSession(options.sessionName, options.electronLaunchRecords, options.namespace);
|
|
27
|
+
if (!record) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
const url = options.currentTarget?.url ?? options.priorTarget?.url;
|
|
31
|
+
return {
|
|
32
|
+
appName: record.appName,
|
|
33
|
+
appPath: record.appPath,
|
|
34
|
+
executablePath: record.executablePath,
|
|
35
|
+
launchId: record.launchId,
|
|
36
|
+
sessionName: record.sessionName ?? options.sessionName,
|
|
37
|
+
url,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export function buildSourceLookupElectronNextActions(sourceLookup) {
|
|
41
|
+
if (sourceLookup?.status !== "no-candidates" || !sourceLookup.electronContext) {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
const actions = [];
|
|
45
|
+
const { launchId, sessionName } = sourceLookup.electronContext;
|
|
46
|
+
const hasSession = sessionName !== undefined && sessionName !== "";
|
|
47
|
+
if (hasSession) {
|
|
48
|
+
actions.push({
|
|
49
|
+
id: "snapshot-electron-session",
|
|
50
|
+
params: { args: withOptionalSessionArgs(sessionName, ["snapshot", "-i"]) },
|
|
51
|
+
reason: "Refresh interactive refs in the attached Electron session before retrying source lookup with a narrower target.",
|
|
52
|
+
safety: "Read-only snapshot; no app mutation.",
|
|
53
|
+
tool: "agent_browser",
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (launchId !== undefined && launchId !== "") {
|
|
57
|
+
actions.push({
|
|
58
|
+
id: "probe-electron-launch",
|
|
59
|
+
params: { action: "probe", launchId },
|
|
60
|
+
reason: "Collect bounded wrapper/session context for the packaged Electron launch after sourceLookup found no candidates.",
|
|
61
|
+
safety: "Read-only probe of title, URL, focus, tabs, and compact snapshot metadata.",
|
|
62
|
+
tool: "agent_browser_electron",
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
if (hasSession) {
|
|
66
|
+
actions.push({
|
|
67
|
+
id: "list-electron-tabs",
|
|
68
|
+
params: { args: withOptionalSessionArgs(sessionName, ["tab", "list"]) },
|
|
69
|
+
reason: "Check current Electron tabs/targets before choosing a narrower selector or @ref.",
|
|
70
|
+
safety: "Read-only tab listing.",
|
|
71
|
+
tool: "agent_browser",
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return actions;
|
|
75
|
+
}
|
|
76
|
+
export function collectElectronBroadGetTextScopeDiagnostics(options) {
|
|
77
|
+
const context = getSourceLookupElectronContext(options);
|
|
78
|
+
if (!context) {
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
const electronContext = {
|
|
82
|
+
launchId: context.launchId,
|
|
83
|
+
sessionName: context.sessionName,
|
|
84
|
+
url: context.url,
|
|
85
|
+
};
|
|
86
|
+
return getSuccessfulGetTextSelectors(options)
|
|
87
|
+
.filter(isBroadGetTextSelector)
|
|
88
|
+
.map((selector) => ({
|
|
89
|
+
electronContext,
|
|
90
|
+
selector,
|
|
91
|
+
summary: `Broad Electron get text selector warning: selector ${JSON.stringify(selector)} may read the entire app shell; prefer snapshot -i and a current @ref or a narrower panel selector.`,
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
export function formatElectronBroadGetTextScopeText(diagnostics) {
|
|
95
|
+
return diagnostics.length > 0
|
|
96
|
+
? diagnostics.map((diagnostic) => diagnostic.summary).join("\n")
|
|
97
|
+
: undefined;
|
|
98
|
+
}
|
|
99
|
+
export function buildElectronBroadGetTextScopeNextActions(options) {
|
|
100
|
+
return options.diagnostics.map((diagnostic, index) => ({
|
|
101
|
+
id: index === 0
|
|
102
|
+
? "snapshot-for-electron-text-scope"
|
|
103
|
+
: `snapshot-for-electron-text-scope-${index + 1}`,
|
|
104
|
+
params: { args: withOptionalSessionArgs(options.sessionName, ["snapshot", "-i"]) },
|
|
105
|
+
reason: `Refresh Electron refs before trusting broad get text selector ${JSON.stringify(diagnostic.selector)}.`,
|
|
106
|
+
safety: "Read-only snapshot; prefer a current @ref or narrower selector before extracting app-shell text.",
|
|
107
|
+
tool: "agent_browser",
|
|
108
|
+
}));
|
|
109
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { boundElectronProbeString } from "../../electron/cdp.js";
|
|
2
|
+
import { isRecord } from "../../parsing.js";
|
|
3
|
+
import { withOptionalSessionArgs } from "../../results/next-actions.js";
|
|
4
|
+
import { runSessionCommandData } from "./session-state.js";
|
|
5
|
+
const ELECTRON_FILL_VERIFICATION_TIMEOUT_MS = 2_000;
|
|
6
|
+
function getTopLevelFillInvocation(commandTokens) {
|
|
7
|
+
if (commandTokens[0] !== "fill" || commandTokens.length < 3) {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
const selector = commandTokens.at(1);
|
|
11
|
+
const expected = commandTokens.slice(2).join(" ");
|
|
12
|
+
if (selector === undefined || selector === "" || expected.length === 0) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
const refId = selector.match(/^@?(e\d+)$/)?.at(1);
|
|
16
|
+
return { expected, ...(refId !== undefined && refId !== "" ? { refId } : {}), selector };
|
|
17
|
+
}
|
|
18
|
+
function shouldVerifyContenteditableFill(fill, refSnapshot) {
|
|
19
|
+
if (fill.refId === undefined || fill.refId === "") {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
const ref = refSnapshot?.refs?.[fill.refId];
|
|
23
|
+
return (ref !== undefined &&
|
|
24
|
+
ref.isContentEditable === true &&
|
|
25
|
+
(ref.role === "generic" || ref.role === "unknown" || ref.role === "textbox"));
|
|
26
|
+
}
|
|
27
|
+
export function buildFillVerificationNextActions(diagnostic, sessionName) {
|
|
28
|
+
return [
|
|
29
|
+
{
|
|
30
|
+
id: "inspect-after-fill-verification",
|
|
31
|
+
params: { args: withOptionalSessionArgs(sessionName, ["snapshot", "-i"]) },
|
|
32
|
+
reason: "Refresh the UI after a fill that reported success but did not appear to update the target.",
|
|
33
|
+
safety: "Read-only snapshot; use current refs before retrying.",
|
|
34
|
+
tool: "agent_browser",
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: "verify-filled-value",
|
|
38
|
+
params: {
|
|
39
|
+
args: withOptionalSessionArgs(sessionName, ["get", diagnostic.method, diagnostic.selector]),
|
|
40
|
+
},
|
|
41
|
+
reason: `Check the target ${diagnostic.method} directly before submitting or creating files.`,
|
|
42
|
+
safety: "Read-only check; selector may still be stale if the UI rerendered.",
|
|
43
|
+
tool: "agent_browser",
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
function extractFillVerificationValue(data) {
|
|
48
|
+
if (typeof data === "string") {
|
|
49
|
+
return data;
|
|
50
|
+
}
|
|
51
|
+
if (!isRecord(data)) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
if (typeof data.value === "string") {
|
|
55
|
+
return data.value;
|
|
56
|
+
}
|
|
57
|
+
return typeof data.result === "string" ? data.result : undefined;
|
|
58
|
+
}
|
|
59
|
+
function buildFillMismatch(fill, actual, method, sessionName) {
|
|
60
|
+
const reason = method === "text" ? "contenteditable-fill-mismatch" : "value-fill-mismatch";
|
|
61
|
+
const actualPreview = actual.length > 0
|
|
62
|
+
? `"${boundElectronProbeString(actual, 80) ?? "undefined"}"`
|
|
63
|
+
: `an empty ${method}`;
|
|
64
|
+
const diagnostic = {
|
|
65
|
+
actual: actual.length > 0 ? boundElectronProbeString(actual, 160) : "",
|
|
66
|
+
expected: boundElectronProbeString(fill.expected, 160) ?? fill.expected,
|
|
67
|
+
method,
|
|
68
|
+
nextActionIds: [],
|
|
69
|
+
reason,
|
|
70
|
+
selector: fill.selector,
|
|
71
|
+
status: "mismatch",
|
|
72
|
+
summary: `Fill verification warning: fill ${fill.selector} reported success, but get ${method} returned ${actualPreview}.`,
|
|
73
|
+
};
|
|
74
|
+
return {
|
|
75
|
+
...diagnostic,
|
|
76
|
+
nextActionIds: buildFillVerificationNextActions(diagnostic, sessionName).map((action) => action.id),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export async function collectFillVerificationDiagnostic(options) {
|
|
80
|
+
const fill = getTopLevelFillInvocation(options.commandTokens);
|
|
81
|
+
if (!fill || options.sessionName === undefined || options.sessionName === "") {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
const contenteditable = shouldVerifyContenteditableFill(fill, options.refSnapshot);
|
|
85
|
+
if (!contenteditable && options.forceValueVerification !== true) {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
const method = contenteditable ? "text" : "value";
|
|
89
|
+
let valueData;
|
|
90
|
+
try {
|
|
91
|
+
valueData = await runSessionCommandData({
|
|
92
|
+
args: ["get", method, fill.selector],
|
|
93
|
+
cwd: options.cwd,
|
|
94
|
+
namespace: options.namespace,
|
|
95
|
+
sessionName: options.sessionName,
|
|
96
|
+
signal: options.signal,
|
|
97
|
+
timeoutMs: ELECTRON_FILL_VERIFICATION_TIMEOUT_MS,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
const actual = extractFillVerificationValue(valueData);
|
|
104
|
+
return actual === undefined || actual === fill.expected
|
|
105
|
+
? undefined
|
|
106
|
+
: buildFillMismatch(fill, actual, method, options.sessionName);
|
|
107
|
+
}
|
|
108
|
+
export function formatFillVerificationText(diagnostic) {
|
|
109
|
+
if (!diagnostic) {
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
112
|
+
const actual = diagnostic.actual !== undefined
|
|
113
|
+
? `actual "${diagnostic.actual}"`
|
|
114
|
+
: `actual ${diagnostic.method} unavailable`;
|
|
115
|
+
const recovery = diagnostic.reason === "contenteditable-fill-mismatch"
|
|
116
|
+
? "Contenteditable fill may append or prepend instead of replacing. Re-run snapshot -i, then prefer focus/click plus keyboard shortcut selection or direct keyboard insertion only after verifying the editor state."
|
|
117
|
+
: "Re-run snapshot -i, then prefer click/focus plus keyboard type for custom quick-input controls before submitting.";
|
|
118
|
+
return `${diagnostic.summary}\nExpected: "${diagnostic.expected}"; ${actual}.\nNext: ${recovery}`;
|
|
119
|
+
}
|
package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-action-recovery.js
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { getCompiledSemanticActionCommandIndex, getCompiledSemanticActionSessionPrefix, isCompiledSemanticActionFindCommand, } from "../../input-modes/semantic-action.js";
|
|
2
|
+
import { appendUniqueAgentBrowserNextActions, isStandaloneSnapshotNextAction, } from "../../results/next-actions.js";
|
|
3
|
+
import { buildConnectedSessionNextActions, buildNoActivePageNextActions, buildPendingWebMcpNextActions, buildSessionAwareStaleRefNextActions, buildSessionTabRecoveryNextActions, } from "../../results/recovery-next-actions.js";
|
|
4
|
+
import { buildRichInputRecoveryNextActions, buildVisibleRefFallbackNextActions, } from "../../results/selector-recovery.js";
|
|
5
|
+
import { redactInvocationArgs } from "../../runtime-redaction.js";
|
|
6
|
+
function tabRecovery(options) {
|
|
7
|
+
if (options.aboutBlankSessionMismatch) {
|
|
8
|
+
return [
|
|
9
|
+
...buildSessionTabRecoveryNextActions({
|
|
10
|
+
kind: "about-blank",
|
|
11
|
+
recoveryApplied: options.aboutBlankSessionMismatch.recoveryApplied,
|
|
12
|
+
sessionName: options.executionPlan.sessionName,
|
|
13
|
+
tabCorrection: options.aboutBlankSessionMismatch.recoveryApplied
|
|
14
|
+
? options.sessionTabCorrection
|
|
15
|
+
: undefined,
|
|
16
|
+
target: {
|
|
17
|
+
title: options.aboutBlankSessionMismatch.targetTitle,
|
|
18
|
+
url: options.aboutBlankSessionMismatch.targetUrl,
|
|
19
|
+
},
|
|
20
|
+
}),
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
if (options.categoryDetails.resultCategory === "success" &&
|
|
24
|
+
(options.sessionTabCorrection || options.openResultTabCorrection)) {
|
|
25
|
+
return [
|
|
26
|
+
...buildSessionTabRecoveryNextActions({
|
|
27
|
+
kind: "tab-drift",
|
|
28
|
+
recoveryApplied: true,
|
|
29
|
+
sessionName: options.executionPlan.sessionName,
|
|
30
|
+
tabCorrection: options.sessionTabCorrection ?? options.openResultTabCorrection,
|
|
31
|
+
target: options.currentSessionTabTarget ?? options.priorSessionTabTarget,
|
|
32
|
+
}),
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
function connectionRecovery(options) {
|
|
38
|
+
const actions = [];
|
|
39
|
+
if (options.categoryDetails.resultCategory === "success" &&
|
|
40
|
+
options.executionPlan.commandInfo.command === "connect" &&
|
|
41
|
+
!options.electronLaunchRecord) {
|
|
42
|
+
actions.push(...buildConnectedSessionNextActions(options.executionPlan.sessionName));
|
|
43
|
+
}
|
|
44
|
+
if (options.noActivePageSnapshotFailure) {
|
|
45
|
+
actions.push(...buildNoActivePageNextActions(options.executionPlan.sessionName));
|
|
46
|
+
}
|
|
47
|
+
return actions;
|
|
48
|
+
}
|
|
49
|
+
export function buildPageRecoveryActions(options) {
|
|
50
|
+
let actions = [...(options.presentation.nextActions ?? [])];
|
|
51
|
+
if (options.unsettledWebMcpMutation === true && options.currentSessionTabTargetUnknown === true) {
|
|
52
|
+
actions = actions.filter((action) => !isStandaloneSnapshotNextAction(action));
|
|
53
|
+
appendUniqueAgentBrowserNextActions(actions, buildPendingWebMcpNextActions(options.executionPlan.sessionName));
|
|
54
|
+
}
|
|
55
|
+
appendUniqueAgentBrowserNextActions(actions, connectionRecovery(options));
|
|
56
|
+
appendUniqueAgentBrowserNextActions(actions, tabRecovery(options));
|
|
57
|
+
if (options.aboutBlankSessionMismatch?.recoveryApplied === false) {
|
|
58
|
+
actions = actions.filter((action) => !isStandaloneSnapshotNextAction(action));
|
|
59
|
+
}
|
|
60
|
+
if (options.categoryDetails.failureCategory === "stale-ref") {
|
|
61
|
+
actions = [...buildSessionAwareStaleRefNextActions(options.executionPlan.sessionName)];
|
|
62
|
+
}
|
|
63
|
+
return actions;
|
|
64
|
+
}
|
|
65
|
+
export function buildSelectorRecoveryActions(options) {
|
|
66
|
+
const actions = [];
|
|
67
|
+
if (options.visibleRefFallbackDiagnostic) {
|
|
68
|
+
actions.push(...buildVisibleRefFallbackNextActions({
|
|
69
|
+
diagnostic: options.visibleRefFallbackDiagnostic,
|
|
70
|
+
sessionName: options.visibleRefFallbackSessionName,
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
if (options.richInputRecoveryDiagnostic) {
|
|
74
|
+
actions.push(...buildRichInputRecoveryNextActions({
|
|
75
|
+
diagnostic: options.richInputRecoveryDiagnostic,
|
|
76
|
+
sessionName: options.visibleRefFallbackSessionName,
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
return actions;
|
|
80
|
+
}
|
|
81
|
+
export function buildSemanticActionCandidateActions(compiled) {
|
|
82
|
+
const commandIndex = getCompiledSemanticActionCommandIndex(compiled);
|
|
83
|
+
if (commandIndex < 0 || compiled.args[commandIndex] !== "find") {
|
|
84
|
+
return [];
|
|
85
|
+
}
|
|
86
|
+
const locator = compiled.args[commandIndex + 1];
|
|
87
|
+
const value = compiled.args.at(commandIndex + 2);
|
|
88
|
+
if (value === undefined ||
|
|
89
|
+
value.length === 0 ||
|
|
90
|
+
locator !== "text" ||
|
|
91
|
+
compiled.action !== "click") {
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
const sessionPrefix = getCompiledSemanticActionSessionPrefix(compiled);
|
|
95
|
+
return [
|
|
96
|
+
{
|
|
97
|
+
id: "try-button-name-candidate",
|
|
98
|
+
params: {
|
|
99
|
+
args: redactInvocationArgs([
|
|
100
|
+
...sessionPrefix,
|
|
101
|
+
"find",
|
|
102
|
+
"role",
|
|
103
|
+
"button",
|
|
104
|
+
compiled.action,
|
|
105
|
+
"--name",
|
|
106
|
+
value,
|
|
107
|
+
]),
|
|
108
|
+
},
|
|
109
|
+
reason: "Retry against a button with the same accessible name when text lookup misses.",
|
|
110
|
+
safety: "Candidate locator fallback only; inspect the page if multiple elements could match the same accessible name.",
|
|
111
|
+
tool: "agent_browser",
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
id: "try-link-name-candidate",
|
|
115
|
+
params: {
|
|
116
|
+
args: redactInvocationArgs([
|
|
117
|
+
...sessionPrefix,
|
|
118
|
+
"find",
|
|
119
|
+
"role",
|
|
120
|
+
"link",
|
|
121
|
+
compiled.action,
|
|
122
|
+
"--name",
|
|
123
|
+
value,
|
|
124
|
+
]),
|
|
125
|
+
},
|
|
126
|
+
reason: "Retry against a link with the same accessible name when text lookup misses.",
|
|
127
|
+
safety: "Candidate locator fallback only; inspect the page if multiple elements could match the same accessible name.",
|
|
128
|
+
tool: "agent_browser",
|
|
129
|
+
},
|
|
130
|
+
];
|
|
131
|
+
}
|
|
132
|
+
export function buildStaleSemanticRetry(options) {
|
|
133
|
+
if (options.categoryDetails.failureCategory !== "stale-ref" ||
|
|
134
|
+
!options.redactedCompiledSemanticAction ||
|
|
135
|
+
!isCompiledSemanticActionFindCommand(options.compiledSemanticAction)) {
|
|
136
|
+
return [];
|
|
137
|
+
}
|
|
138
|
+
return [
|
|
139
|
+
{
|
|
140
|
+
id: "retry-semantic-action-after-stale-ref",
|
|
141
|
+
params: { args: options.redactedCompiledSemanticAction.args },
|
|
142
|
+
reason: "Retry the same semantic target via its compiled find command after the upstream stale-ref failure proves the prior action did not execute.",
|
|
143
|
+
safety: "Use only for the same intended target; direct stale @refs still require a fresh snapshot or stable locator before retrying.",
|
|
144
|
+
tool: "agent_browser",
|
|
145
|
+
},
|
|
146
|
+
];
|
|
147
|
+
}
|