pi-agent-browser-native 0.9.5 → 0.9.7
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 +114 -1
- package/README.md +17 -6
- package/dist/extensions/agent-browser/index.js +2482 -925
- package/dist/packaged/lib/browser-session-conversion.js +2946 -0
- package/dist/packaged/lib/config-policy.js +599 -0
- package/dist/packaged/lib/parsing.js +34 -0
- package/dist/packaged/lib/playbook.js +728 -0
- package/dist/packaged/lib/results/snapshot.js +2800 -0
- package/dist/packaged/lib/runtime.js +3075 -0
- package/docs/ARCHITECTURE.md +29 -10
- package/docs/CODE_QUALITY.md +32 -5
- package/docs/COMMAND_REFERENCE.md +156 -40
- package/docs/ELECTRON.md +1 -1
- package/docs/PERFORMANCE.md +252 -0
- package/docs/REFERENCE.md +15 -15
- package/docs/RELEASE.md +41 -18
- package/docs/REQUIREMENTS.md +6 -0
- package/docs/SESSION_STORAGE.md +13 -5
- package/docs/SUPPORT_MATRIX.md +31 -25
- package/docs/TOOL_CONTRACT.md +41 -18
- package/docs/performance/2026-10-12.json +7257 -0
- package/docs/platform-smoke.md +18 -14
- package/package.json +18 -4
- package/platform-smoke.config.mjs +3 -2
- package/scripts/agent-browser-capability-baseline.mjs +16 -2
- package/scripts/agent-browser-target.mjs +1 -1
- package/scripts/build.mjs +16 -5
- package/scripts/capability-options.mjs +20 -0
- package/scripts/capability-samples.mjs +23 -10
- package/scripts/config.mjs +1 -1
- package/scripts/convert-browser-session.mjs +1 -1
- package/scripts/platform-smoke/commands.mjs +30 -4
- package/scripts/platform-smoke/doctor-support.mjs +11 -2
- package/scripts/platform-smoke/doctor-windows.mjs +1 -1
- package/scripts/platform-smoke/doctor.mjs +26 -11
- package/scripts/platform-smoke/linux-image/Dockerfile +6 -3
- package/scripts/platform-smoke/platform-build-windows.ps1 +23 -3
- package/scripts/platform-smoke/suite-checks.mjs +11 -1
- package/scripts/platform-smoke/targets.mjs +4 -3
- package/scripts/platform-smoke.mjs +68 -25
- package/dist/extensions/agent-browser/lib/argv-descriptor.js +0 -123
- package/dist/extensions/agent-browser/lib/argv-grammar.js +0 -320
- package/dist/extensions/agent-browser/lib/bash-guard.js +0 -193
- package/dist/extensions/agent-browser/lib/batch-lifecycle.js +0 -131
- package/dist/extensions/agent-browser/lib/browser-execution-claim-codec.js +0 -61
- package/dist/extensions/agent-browser/lib/browser-execution-claim-storage.js +0 -232
- package/dist/extensions/agent-browser/lib/browser-execution-claims.js +0 -202
- package/dist/extensions/agent-browser/lib/browser-execution-identity.js +0 -77
- package/dist/extensions/agent-browser/lib/browser-journal-branch.js +0 -98
- package/dist/extensions/agent-browser/lib/browser-journal-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/browser-journal-projection.js +0 -221
- package/dist/extensions/agent-browser/lib/browser-journal-reader.js +0 -89
- package/dist/extensions/agent-browser/lib/browser-journal-replay.js +0 -246
- package/dist/extensions/agent-browser/lib/browser-journal.js +0 -148
- package/dist/extensions/agent-browser/lib/browser-legacy-pages.js +0 -220
- package/dist/extensions/agent-browser/lib/browser-legacy-projection.js +0 -282
- package/dist/extensions/agent-browser/lib/browser-legacy-types.js +0 -1
- package/dist/extensions/agent-browser/lib/browser-session-conversion-stream.js +0 -217
- package/dist/extensions/agent-browser/lib/browser-session-conversion.js +0 -126
- package/dist/extensions/agent-browser/lib/browser-transcript-contracts.js +0 -35
- package/dist/extensions/agent-browser/lib/browser-transcript-validation.js +0 -166
- package/dist/extensions/agent-browser/lib/browser-transcript.js +0 -189
- package/dist/extensions/agent-browser/lib/browser-value-parsing.js +0 -15
- package/dist/extensions/agent-browser/lib/command-capabilities.js +0 -340
- package/dist/extensions/agent-browser/lib/command-policy.js +0 -155
- package/dist/extensions/agent-browser/lib/command-taxonomy.js +0 -105
- package/dist/extensions/agent-browser/lib/config-policy.js +0 -450
- package/dist/extensions/agent-browser/lib/config-providers.js +0 -71
- package/dist/extensions/agent-browser/lib/config-validation.js +0 -231
- package/dist/extensions/agent-browser/lib/config.js +0 -69
- package/dist/extensions/agent-browser/lib/electron/cdp.js +0 -62
- package/dist/extensions/agent-browser/lib/electron/cleanup.js +0 -274
- package/dist/extensions/agent-browser/lib/electron/discovery-darwin.js +0 -109
- package/dist/extensions/agent-browser/lib/electron/discovery-desktop.js +0 -136
- package/dist/extensions/agent-browser/lib/electron/discovery-evidence.js +0 -90
- package/dist/extensions/agent-browser/lib/electron/discovery-linux.js +0 -93
- package/dist/extensions/agent-browser/lib/electron/discovery-packages.js +0 -162
- package/dist/extensions/agent-browser/lib/electron/discovery-types.js +0 -2
- package/dist/extensions/agent-browser/lib/electron/discovery.js +0 -217
- package/dist/extensions/agent-browser/lib/electron/launch-monitor.js +0 -102
- package/dist/extensions/agent-browser/lib/electron/launch-process.js +0 -209
- package/dist/extensions/agent-browser/lib/electron/launch-types.js +0 -2
- package/dist/extensions/agent-browser/lib/electron/launch.js +0 -340
- package/dist/extensions/agent-browser/lib/executable-path.js +0 -29
- package/dist/extensions/agent-browser/lib/execution-cwd.js +0 -67
- package/dist/extensions/agent-browser/lib/fs-utils.js +0 -10
- package/dist/extensions/agent-browser/lib/input-modes/electron.js +0 -201
- package/dist/extensions/agent-browser/lib/input-modes/job.js +0 -198
- package/dist/extensions/agent-browser/lib/input-modes/lookup-network-evidence.js +0 -116
- package/dist/extensions/agent-browser/lib/input-modes/lookup-plan.js +0 -132
- package/dist/extensions/agent-browser/lib/input-modes/lookup-redaction.js +0 -57
- package/dist/extensions/agent-browser/lib/input-modes/lookup-source-evidence.js +0 -151
- package/dist/extensions/agent-browser/lib/input-modes/lookup-workspace.js +0 -142
- package/dist/extensions/agent-browser/lib/input-modes/lookups.js +0 -84
- package/dist/extensions/agent-browser/lib/input-modes/params.js +0 -195
- package/dist/extensions/agent-browser/lib/input-modes/qa-analysis.js +0 -268
- package/dist/extensions/agent-browser/lib/input-modes/qa-presentation.js +0 -117
- package/dist/extensions/agent-browser/lib/input-modes/script-child.js +0 -396
- package/dist/extensions/agent-browser/lib/input-modes/script-protocol.js +0 -86
- package/dist/extensions/agent-browser/lib/input-modes/script-types.js +0 -1
- package/dist/extensions/agent-browser/lib/input-modes/script-validation.js +0 -60
- package/dist/extensions/agent-browser/lib/input-modes/script.js +0 -108
- package/dist/extensions/agent-browser/lib/input-modes/semantic-action.js +0 -243
- package/dist/extensions/agent-browser/lib/input-modes/shared.js +0 -48
- package/dist/extensions/agent-browser/lib/input-modes/types.js +0 -65
- package/dist/extensions/agent-browser/lib/json-schema.js +0 -65
- package/dist/extensions/agent-browser/lib/launch-scoped-flags.js +0 -212
- package/dist/extensions/agent-browser/lib/managed-session-policy-lock.js +0 -165
- package/dist/extensions/agent-browser/lib/managed-session-posix-storage.js +0 -58
- package/dist/extensions/agent-browser/lib/managed-session-project-identity.js +0 -244
- package/dist/extensions/agent-browser/lib/managed-session-restore-context.js +0 -84
- package/dist/extensions/agent-browser/lib/managed-session-restore-policy.js +0 -119
- package/dist/extensions/agent-browser/lib/managed-session-restore-state.js +0 -83
- package/dist/extensions/agent-browser/lib/managed-session-restore.js +0 -212
- package/dist/extensions/agent-browser/lib/managed-session-snapshot-records.js +0 -277
- package/dist/extensions/agent-browser/lib/managed-session-snapshots.js +0 -181
- package/dist/extensions/agent-browser/lib/managed-session-storage.js +0 -126
- package/dist/extensions/agent-browser/lib/native-confirmation.js +0 -140
- package/dist/extensions/agent-browser/lib/native-output.js +0 -81
- package/dist/extensions/agent-browser/lib/orchestration/batch-stdin.js +0 -182
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/artifact-merge.js +0 -30
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/artifact-paths.js +0 -188
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/browser-observation-result.js +0 -82
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/click-dispatch.js +0 -406
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/diagnostic-values.js +0 -31
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/diagnostics.js +0 -240
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/electron-observation.js +0 -203
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/electron-text-diagnostics.js +0 -109
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/fill-diagnostics.js +0 -119
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-action-recovery.js +0 -147
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-actions.js +0 -144
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-content.js +0 -123
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-details.js +0 -156
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-electron.js +0 -187
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-evidence.js +0 -39
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-missing-binary.js +0 -89
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-recovery.js +0 -97
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-redaction.js +0 -106
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-timeout.js +0 -110
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result.js +0 -53
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/index.js +0 -224
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/interaction-diagnostics.js +0 -290
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-close.js +0 -167
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-daemon-inspection.js +0 -108
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-daemon-policy.js +0 -174
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/native-helper-observation.js +0 -65
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/observation-types.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/overlay-diagnostics.js +0 -120
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/network-page-filter.js +0 -192
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/scroll-shims.js +0 -225
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-filter-data.js +0 -150
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-filter.js +0 -174
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-rendered-text.js +0 -147
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/wait-timeouts.js +0 -145
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-artifacts.js +0 -159
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-command.js +0 -131
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-daemon.js +0 -93
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-failure.js +0 -42
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-guards.js +0 -242
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-input.js +0 -75
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-observations.js +0 -92
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-page-selection.js +0 -254
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-page-state.js +0 -121
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-refs.js +0 -130
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-resources.js +0 -114
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-semantic.js +0 -121
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-session-plan.js +0 -222
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-timeouts.js +0 -68
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare.js +0 -202
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-analysis.js +0 -191
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-confirmation.js +0 -152
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-diagnostics.js +0 -182
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-electron.js +0 -150
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle-phase-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle-phase.js +0 -115
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle.js +0 -256
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-managed-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-managed.js +0 -256
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-native-phase-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-native-phase.js +0 -93
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-native.js +0 -113
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-navigation-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-navigation.js +0 -316
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-ownership.js +0 -28
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-page-phase-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-page-phase.js +0 -142
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-presentation-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-presentation.js +0 -333
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-publication-phase-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-publication-phase.js +0 -71
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-publication.js +0 -201
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-receipts.js +0 -183
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-refs.js +0 -200
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-tabs.js +0 -142
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output.js +0 -25
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prompt-guards.js +0 -50
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-receipt-reconciliation.js +0 -198
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-recovery-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-recovery-presentation.js +0 -154
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-recovery.js +0 -80
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/screenshot-capture.js +0 -14
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/screenshot-observation.js +0 -206
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-commands.js +0 -130
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-electron.js +0 -212
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-observations.js +0 -61
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-outcomes.js +0 -187
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-refs.js +0 -169
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-tabs.js +0 -228
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state.js +0 -117
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/text-visibility-diagnostics.js +0 -182
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/timeout-diagnostics.js +0 -256
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/timeout-progress.js +0 -108
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/types.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/code-artifact-observation.js +0 -39
- package/dist/extensions/agent-browser/lib/orchestration/code-image-observation.js +0 -119
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/branch.js +0 -93
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/cleanup-result.js +0 -58
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/cleanup.js +0 -78
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/discovery.js +0 -106
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/index.js +0 -60
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/policy.js +0 -86
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-collection.js +0 -68
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-data.js +0 -169
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-presentation.js +0 -182
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe.js +0 -161
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/status.js +0 -167
- package/dist/extensions/agent-browser/lib/orchestration/execution-queue.js +0 -98
- package/dist/extensions/agent-browser/lib/orchestration/extension-artifact-preflight.js +0 -211
- package/dist/extensions/agent-browser/lib/orchestration/extension-artifacts.js +0 -23
- package/dist/extensions/agent-browser/lib/orchestration/extension-attachment-replay.js +0 -99
- package/dist/extensions/agent-browser/lib/orchestration/extension-branch-restore.js +0 -275
- package/dist/extensions/agent-browser/lib/orchestration/extension-code.js +0 -280
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-admission.js +0 -303
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-output.js +0 -36
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-result.js +0 -335
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-run.js +0 -227
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-state.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/extension-electron-ownership.js +0 -204
- package/dist/extensions/agent-browser/lib/orchestration/extension-execution-locks.js +0 -139
- package/dist/extensions/agent-browser/lib/orchestration/extension-execution-queue.js +0 -24
- package/dist/extensions/agent-browser/lib/orchestration/extension-host-coordination.js +0 -98
- package/dist/extensions/agent-browser/lib/orchestration/extension-host-run.js +0 -295
- package/dist/extensions/agent-browser/lib/orchestration/extension-intent-replay.js +0 -41
- package/dist/extensions/agent-browser/lib/orchestration/extension-invocation.js +0 -7
- package/dist/extensions/agent-browser/lib/orchestration/extension-lifecycle.js +0 -102
- package/dist/extensions/agent-browser/lib/orchestration/extension-managed-ownership.js +0 -133
- package/dist/extensions/agent-browser/lib/orchestration/extension-observation.js +0 -120
- package/dist/extensions/agent-browser/lib/orchestration/extension-prompt.js +0 -180
- package/dist/extensions/agent-browser/lib/orchestration/extension-recording.js +0 -290
- package/dist/extensions/agent-browser/lib/orchestration/extension-resource-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/extension-resource-replay.js +0 -269
- package/dist/extensions/agent-browser/lib/orchestration/extension-result-state.js +0 -113
- package/dist/extensions/agent-browser/lib/orchestration/extension-runtime.js +0 -146
- package/dist/extensions/agent-browser/lib/orchestration/extension-script-leases.js +0 -58
- package/dist/extensions/agent-browser/lib/orchestration/extension-tool-boundary.js +0 -62
- package/dist/extensions/agent-browser/lib/orchestration/extension-version-check.js +0 -54
- package/dist/extensions/agent-browser/lib/orchestration/input-plan-types.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/input-plan.js +0 -313
- package/dist/extensions/agent-browser/lib/orchestration/input-redaction.js +0 -62
- package/dist/extensions/agent-browser/lib/orchestration/native-config.js +0 -144
- package/dist/extensions/agent-browser/lib/orchestration/native-root-launch.js +0 -77
- package/dist/extensions/agent-browser/lib/orchestration/native-session-defaults.js +0 -231
- package/dist/extensions/agent-browser/lib/orchestration/operation-paths.js +0 -142
- package/dist/extensions/agent-browser/lib/orchestration/output-file.js +0 -276
- package/dist/extensions/agent-browser/lib/orchestration/script-mode.js +0 -220
- package/dist/extensions/agent-browser/lib/owned-managed-session-context.js +0 -55
- package/dist/extensions/agent-browser/lib/page-target-batch.js +0 -118
- package/dist/extensions/agent-browser/lib/page-target-guards.js +0 -50
- package/dist/extensions/agent-browser/lib/page-target-navigation.js +0 -104
- package/dist/extensions/agent-browser/lib/page-target-validation.js +0 -90
- package/dist/extensions/agent-browser/lib/parsing.js +0 -30
- package/dist/extensions/agent-browser/lib/pi-tool-rendering.js +0 -343
- package/dist/extensions/agent-browser/lib/playbook.js +0 -146
- package/dist/extensions/agent-browser/lib/process-child.js +0 -284
- package/dist/extensions/agent-browser/lib/process-environment.js +0 -48
- package/dist/extensions/agent-browser/lib/process-errors.js +0 -23
- package/dist/extensions/agent-browser/lib/process-identity.js +0 -127
- package/dist/extensions/agent-browser/lib/process-socket-storage.js +0 -256
- package/dist/extensions/agent-browser/lib/process-stdout.js +0 -74
- package/dist/extensions/agent-browser/lib/process.js +0 -216
- package/dist/extensions/agent-browser/lib/prompt-artifacts.js +0 -287
- package/dist/extensions/agent-browser/lib/prompt-policy.js +0 -54
- package/dist/extensions/agent-browser/lib/read-command.js +0 -41
- package/dist/extensions/agent-browser/lib/read-confirmation.js +0 -162
- package/dist/extensions/agent-browser/lib/recording-reservations.js +0 -208
- package/dist/extensions/agent-browser/lib/redaction-fields.js +0 -75
- package/dist/extensions/agent-browser/lib/redaction-json.js +0 -149
- package/dist/extensions/agent-browser/lib/redaction-url.js +0 -88
- package/dist/extensions/agent-browser/lib/results/action-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/results/action-recommendations.js +0 -38
- package/dist/extensions/agent-browser/lib/results/artifact-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/results/artifact-manifest-validation.js +0 -133
- package/dist/extensions/agent-browser/lib/results/artifact-manifest.js +0 -173
- package/dist/extensions/agent-browser/lib/results/artifact-recommendations.js +0 -73
- package/dist/extensions/agent-browser/lib/results/categories.js +0 -152
- package/dist/extensions/agent-browser/lib/results/confirmation.js +0 -75
- package/dist/extensions/agent-browser/lib/results/contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/results/editable-ref-evidence.js +0 -99
- package/dist/extensions/agent-browser/lib/results/electron-recommendations.js +0 -83
- package/dist/extensions/agent-browser/lib/results/envelope-decoding.js +0 -48
- package/dist/extensions/agent-browser/lib/results/envelope.js +0 -198
- package/dist/extensions/agent-browser/lib/results/evidence-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/results/failure-recommendations.js +0 -180
- package/dist/extensions/agent-browser/lib/results/network-routes.js +0 -133
- package/dist/extensions/agent-browser/lib/results/network.js +0 -89
- package/dist/extensions/agent-browser/lib/results/next-actions.js +0 -111
- package/dist/extensions/agent-browser/lib/results/presentation/artifact-files.js +0 -320
- package/dist/extensions/agent-browser/lib/results/presentation/artifact-format.js +0 -138
- package/dist/extensions/agent-browser/lib/results/presentation/artifact-images.js +0 -113
- package/dist/extensions/agent-browser/lib/results/presentation/artifact-verification.js +0 -145
- package/dist/extensions/agent-browser/lib/results/presentation/artifacts.js +0 -165
- package/dist/extensions/agent-browser/lib/results/presentation/batch-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/results/presentation/batch-recording.js +0 -118
- package/dist/extensions/agent-browser/lib/results/presentation/batch-redaction.js +0 -68
- package/dist/extensions/agent-browser/lib/results/presentation/batch-rendering.js +0 -135
- package/dist/extensions/agent-browser/lib/results/presentation/batch-step.js +0 -227
- package/dist/extensions/agent-browser/lib/results/presentation/batch-summary.js +0 -91
- package/dist/extensions/agent-browser/lib/results/presentation/batch.js +0 -123
- package/dist/extensions/agent-browser/lib/results/presentation/browser-profile-recovery.js +0 -54
- package/dist/extensions/agent-browser/lib/results/presentation/command-presenters.js +0 -216
- package/dist/extensions/agent-browser/lib/results/presentation/common.js +0 -81
- package/dist/extensions/agent-browser/lib/results/presentation/content.js +0 -119
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-a11y.js +0 -67
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-health.js +0 -79
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-identity.js +0 -199
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-logs.js +0 -75
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-network-actions.js +0 -216
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-network.js +0 -124
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-redaction.js +0 -64
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-storage.js +0 -209
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-stream.js +0 -69
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-summary.js +0 -222
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostics.js +0 -124
- package/dist/extensions/agent-browser/lib/results/presentation/early-result.js +0 -70
- package/dist/extensions/agent-browser/lib/results/presentation/errors.js +0 -285
- package/dist/extensions/agent-browser/lib/results/presentation/input-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/results/presentation/large-output.js +0 -117
- package/dist/extensions/agent-browser/lib/results/presentation/navigation.js +0 -231
- package/dist/extensions/agent-browser/lib/results/presentation/notices.js +0 -75
- package/dist/extensions/agent-browser/lib/results/presentation/observation-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/results/presentation/observation-rendering.js +0 -127
- package/dist/extensions/agent-browser/lib/results/presentation/outcomes.js +0 -120
- package/dist/extensions/agent-browser/lib/results/presentation/output-completion.js +0 -77
- package/dist/extensions/agent-browser/lib/results/presentation/output-spill.js +0 -51
- package/dist/extensions/agent-browser/lib/results/presentation/registry.js +0 -145
- package/dist/extensions/agent-browser/lib/results/presentation/semantic-action.js +0 -104
- package/dist/extensions/agent-browser/lib/results/presentation/skills.js +0 -183
- package/dist/extensions/agent-browser/lib/results/presentation/source.js +0 -109
- package/dist/extensions/agent-browser/lib/results/presentation.js +0 -19
- package/dist/extensions/agent-browser/lib/results/recommendation-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/results/recording.js +0 -88
- package/dist/extensions/agent-browser/lib/results/recovery-actions.js +0 -118
- package/dist/extensions/agent-browser/lib/results/recovery-next-actions.js +0 -60
- package/dist/extensions/agent-browser/lib/results/selector-recovery-target.js +0 -83
- package/dist/extensions/agent-browser/lib/results/selector-recovery.js +0 -261
- package/dist/extensions/agent-browser/lib/results/snapshot-compact.js +0 -266
- package/dist/extensions/agent-browser/lib/results/snapshot-content.js +0 -32
- package/dist/extensions/agent-browser/lib/results/snapshot-high-value-controls.js +0 -240
- package/dist/extensions/agent-browser/lib/results/snapshot-refs.js +0 -103
- package/dist/extensions/agent-browser/lib/results/snapshot-segments.js +0 -383
- package/dist/extensions/agent-browser/lib/results/snapshot-spill.js +0 -53
- package/dist/extensions/agent-browser/lib/results/snapshot.js +0 -44
- package/dist/extensions/agent-browser/lib/results/text.js +0 -44
- package/dist/extensions/agent-browser/lib/runtime-args-validation.js +0 -133
- package/dist/extensions/agent-browser/lib/runtime-compatibility.js +0 -81
- package/dist/extensions/agent-browser/lib/runtime-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/runtime-redaction.js +0 -118
- package/dist/extensions/agent-browser/lib/runtime-replay-events.js +0 -144
- package/dist/extensions/agent-browser/lib/runtime-session-identity.js +0 -76
- package/dist/extensions/agent-browser/lib/runtime-session-plan.js +0 -114
- package/dist/extensions/agent-browser/lib/runtime-session-replay.js +0 -123
- package/dist/extensions/agent-browser/lib/runtime-tab-correction.js +0 -65
- package/dist/extensions/agent-browser/lib/runtime-timeouts.js +0 -28
- package/dist/extensions/agent-browser/lib/runtime.js +0 -163
- package/dist/extensions/agent-browser/lib/session-identity.js +0 -51
- package/dist/extensions/agent-browser/lib/session-page-observation.js +0 -357
- package/dist/extensions/agent-browser/lib/session-page-state.js +0 -353
- package/dist/extensions/agent-browser/lib/session-page-types.js +0 -1
- package/dist/extensions/agent-browser/lib/string-enum-schema.js +0 -8
- package/dist/extensions/agent-browser/lib/temp-artifact-budget.js +0 -81
- package/dist/extensions/agent-browser/lib/temp-mutation-queue.js +0 -7
- package/dist/extensions/agent-browser/lib/temp-root-ownership.js +0 -234
- package/dist/extensions/agent-browser/lib/temp-root.js +0 -211
- package/dist/extensions/agent-browser/lib/temp.js +0 -91
- package/dist/extensions/agent-browser/lib/tool-surface.js +0 -239
- package/dist/extensions/agent-browser/lib/upstream-version.js +0 -15
- package/dist/extensions/agent-browser/lib/web-search-providers.js +0 -193
- package/dist/extensions/agent-browser/lib/web-search-request.js +0 -102
- package/dist/extensions/agent-browser/lib/web-search-results.js +0 -281
- package/dist/extensions/agent-browser/lib/web-search-schema.js +0 -82
- package/dist/extensions/agent-browser/lib/web-search.js +0 -167
- package/dist/extensions/agent-browser/lib/webmcp-observation.js +0 -35
- package/dist/extensions/agent-browser/lib/windows-stock-launcher.js +0 -96
- package/dist/scripts/agent-browser-target.mjs +0 -23
|
@@ -1,406 +0,0 @@
|
|
|
1
|
-
import { isRecord, parseRefId } from "../../parsing.js";
|
|
2
|
-
import { redactSensitiveText } from "../../runtime-redaction.js";
|
|
3
|
-
import { withOptionalSessionArgs, } from "../../results/next-actions.js";
|
|
4
|
-
import { runSessionCommandData } from "./session-state.js";
|
|
5
|
-
import { getAgentBrowserProcessTimeoutMs } from "../../process.js";
|
|
6
|
-
import { getAgentBrowserProcessEnvironment } from "../../process-environment.js";
|
|
7
|
-
const CLICK_DISPATCH_MARKER_PREFIX = "__piAgentBrowserClickDispatchProbe_";
|
|
8
|
-
const CLICK_DISPATCH_CLEANUP_TIMEOUT_MS = 2_000;
|
|
9
|
-
const ACCESSIBLE_REF_CLICK_DISPATCH_ROLES = new Set([
|
|
10
|
-
"button",
|
|
11
|
-
"checkbox",
|
|
12
|
-
"menuitem",
|
|
13
|
-
"radio",
|
|
14
|
-
"switch",
|
|
15
|
-
"tab",
|
|
16
|
-
]);
|
|
17
|
-
function normalizeAccessibleName(name) {
|
|
18
|
-
return name.replace(/\s+/g, " ").trim().toLowerCase();
|
|
19
|
-
}
|
|
20
|
-
function getClickDispatchProbeTarget(commandTokens, refSnapshot) {
|
|
21
|
-
if (commandTokens[0] !== "click" || commandTokens.includes("--new-tab")) {
|
|
22
|
-
return undefined;
|
|
23
|
-
}
|
|
24
|
-
const selector = commandTokens.slice(1).find((token) => token !== "--human");
|
|
25
|
-
if (selector === undefined || selector === "" || selector.startsWith("-")) {
|
|
26
|
-
return undefined;
|
|
27
|
-
}
|
|
28
|
-
const refId = parseRefId(selector);
|
|
29
|
-
if (refId !== undefined && refId !== "") {
|
|
30
|
-
return getAccessibleProbeTarget(refId, refSnapshot);
|
|
31
|
-
}
|
|
32
|
-
if (selector.startsWith("xpath=")) {
|
|
33
|
-
return { kind: "xpath", selector: selector.slice("xpath=".length) };
|
|
34
|
-
}
|
|
35
|
-
return undefined;
|
|
36
|
-
}
|
|
37
|
-
function getAccessibleProbeTarget(refId, refSnapshot) {
|
|
38
|
-
const refs = refSnapshot?.refs ?? {};
|
|
39
|
-
const ref = refs[refId];
|
|
40
|
-
if (!ref || !ACCESSIBLE_REF_CLICK_DISPATCH_ROLES.has(ref.role)) {
|
|
41
|
-
return undefined;
|
|
42
|
-
}
|
|
43
|
-
const matchingRefs = Object.values(refs).filter((candidate) => candidate !== undefined &&
|
|
44
|
-
candidate.role.toLowerCase() === ref.role.toLowerCase() &&
|
|
45
|
-
normalizeAccessibleName(candidate.name) === normalizeAccessibleName(ref.name));
|
|
46
|
-
return matchingRefs.length === 1
|
|
47
|
-
? { kind: "accessible", name: ref.name, refId, role: ref.role }
|
|
48
|
-
: undefined;
|
|
49
|
-
}
|
|
50
|
-
function getEvalResultRecord(data) {
|
|
51
|
-
return isRecord(data) && isRecord(data.result) ? data.result : undefined;
|
|
52
|
-
}
|
|
53
|
-
function getClickDispatchIdentityAttribute(probe) {
|
|
54
|
-
return `data-pi-click-dispatch-${probe.marker.toLowerCase()}`;
|
|
55
|
-
}
|
|
56
|
-
function buildClickTargetResolutionScript(target) {
|
|
57
|
-
if (target.kind === "selector") {
|
|
58
|
-
return `(() => { try { return document.querySelector(${JSON.stringify(target.selector)}); } catch { return null; } })()`;
|
|
59
|
-
}
|
|
60
|
-
if (target.kind === "xpath") {
|
|
61
|
-
return `(() => { try { return document.evaluate(${JSON.stringify(target.selector)}, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; } catch { return null; } })()`;
|
|
62
|
-
}
|
|
63
|
-
return `(() => {
|
|
64
|
-
const normalize = (value) => String(value ?? "").replace(/\\s+/g, " ").trim();
|
|
65
|
-
const expectedRole = ${JSON.stringify(target.role)};
|
|
66
|
-
const expectedName = normalize(${JSON.stringify(target.name)});
|
|
67
|
-
const inferRole = (element) => {
|
|
68
|
-
const explicit = element.getAttribute("role");
|
|
69
|
-
if (explicit) return explicit;
|
|
70
|
-
const tagName = element.tagName.toLowerCase();
|
|
71
|
-
if (tagName === "button" || tagName === "select" || tagName === "textarea") return tagName;
|
|
72
|
-
if (tagName === "a" && element.hasAttribute("href")) return "link";
|
|
73
|
-
if (tagName === "input") {
|
|
74
|
-
const type = (element.getAttribute("type") || "text").toLowerCase();
|
|
75
|
-
if (["button", "submit", "reset", "image"].includes(type)) return "button";
|
|
76
|
-
if (type === "checkbox") return "checkbox";
|
|
77
|
-
if (type === "radio") return "radio";
|
|
78
|
-
return "textbox";
|
|
79
|
-
}
|
|
80
|
-
return "";
|
|
81
|
-
};
|
|
82
|
-
const inferName = (element) => normalize(element.getAttribute("aria-label") || element.getAttribute("title") || element.value || element.textContent || "");
|
|
83
|
-
const isVisible = (element) => {
|
|
84
|
-
const style = window.getComputedStyle(element);
|
|
85
|
-
if (style.display === "none" || style.visibility === "hidden" || Number(style.opacity) === 0) return false;
|
|
86
|
-
return element.getClientRects().length > 0;
|
|
87
|
-
};
|
|
88
|
-
const candidates = Array.from(document.querySelectorAll("button,a[href],input,select,textarea,summary,[role],[onclick],[tabindex]")).filter((element) => inferRole(element) === expectedRole && inferName(element) === expectedName && isVisible(element));
|
|
89
|
-
return candidates.length === 1 ? candidates[0] : null;
|
|
90
|
-
})()`;
|
|
91
|
-
}
|
|
92
|
-
function buildClickDispatchProbeInstallScript(probe, timeoutMs) {
|
|
93
|
-
return `(() => {
|
|
94
|
-
const marker = ${JSON.stringify(probe.marker)};
|
|
95
|
-
const element = ${buildClickTargetResolutionScript(probe.target)};
|
|
96
|
-
if (!element) return { status: "target-not-found", marker };
|
|
97
|
-
const cssEscape = (value) => {
|
|
98
|
-
if (window.CSS && typeof window.CSS.escape === "function") return window.CSS.escape(value);
|
|
99
|
-
return String(value).replace(/[^a-zA-Z0-9_-]/g, "\\$&");
|
|
100
|
-
};
|
|
101
|
-
const getSelector = (node) => {
|
|
102
|
-
if (!(node instanceof Element)) return undefined;
|
|
103
|
-
if (node.id) return "#" + cssEscape(node.id);
|
|
104
|
-
const testId = node.getAttribute("data-testid") || node.getAttribute("data-test-id");
|
|
105
|
-
if (testId) return '[data-testid="' + cssEscape(testId) + '"]';
|
|
106
|
-
const parts = [];
|
|
107
|
-
let current = node;
|
|
108
|
-
while (current && current !== document.body && parts.length < 4) {
|
|
109
|
-
const tag = current.tagName.toLowerCase();
|
|
110
|
-
const parent = current.parentElement;
|
|
111
|
-
if (!parent) break;
|
|
112
|
-
const siblings = Array.from(parent.children).filter((child) => child.tagName === current.tagName);
|
|
113
|
-
const index = siblings.indexOf(current) + 1;
|
|
114
|
-
parts.unshift(siblings.length > 1 ? tag + ':nth-of-type(' + index + ')' : tag);
|
|
115
|
-
current = parent;
|
|
116
|
-
}
|
|
117
|
-
return parts.length > 0 ? parts.join(" > ") : undefined;
|
|
118
|
-
};
|
|
119
|
-
const rectInfo = (rect) => ({ bottom: rect.bottom, left: rect.left, right: rect.right, top: rect.top });
|
|
120
|
-
const targetRect = element ? element.getBoundingClientRect() : undefined;
|
|
121
|
-
const targetOutsideViewport = targetRect ? targetRect.bottom < 0 || targetRect.right < 0 || targetRect.top > window.innerHeight || targetRect.left > window.innerWidth : undefined;
|
|
122
|
-
let nearestScrollContainer;
|
|
123
|
-
if (element && targetRect) {
|
|
124
|
-
for (let current = element.parentElement; current && current !== document.body; current = current.parentElement) {
|
|
125
|
-
if (current.scrollHeight > current.clientHeight + 1 || current.scrollWidth > current.clientWidth + 1) {
|
|
126
|
-
const containerRect = current.getBoundingClientRect();
|
|
127
|
-
nearestScrollContainer = {
|
|
128
|
-
selector: getSelector(current),
|
|
129
|
-
tagName: current.tagName.toLowerCase(),
|
|
130
|
-
targetOutsideContainer: targetRect.bottom < containerRect.top || targetRect.top > containerRect.bottom || targetRect.right < containerRect.left || targetRect.left > containerRect.right,
|
|
131
|
-
targetOutsideViewport,
|
|
132
|
-
rect: rectInfo(containerRect),
|
|
133
|
-
scrollLeft: current.scrollLeft,
|
|
134
|
-
scrollTop: current.scrollTop,
|
|
135
|
-
};
|
|
136
|
-
break;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
const state = { events: [], target: { tagName: element.tagName.toLowerCase(), nearestScrollContainer, rect: rectInfo(targetRect), targetOutsideViewport } };
|
|
141
|
-
const eventTypes = ["pointerdown", "mousedown", "pointerup", "mouseup", "click"];
|
|
142
|
-
const listeners = eventTypes.map((type) => {
|
|
143
|
-
const listener = (event) => {
|
|
144
|
-
const path = typeof event.composedPath === "function" ? event.composedPath() : [];
|
|
145
|
-
const eventTarget = event.target;
|
|
146
|
-
const targetMatched = path.includes(element) || eventTarget === element || (eventTarget instanceof Node && element.contains(eventTarget));
|
|
147
|
-
state.events.push({ type: event.type, isTrusted: event.isTrusted === true, targetMatched });
|
|
148
|
-
};
|
|
149
|
-
document.addEventListener(type, listener, true);
|
|
150
|
-
return [type, listener];
|
|
151
|
-
});
|
|
152
|
-
const identityAttribute = ${JSON.stringify(getClickDispatchIdentityAttribute(probe))};
|
|
153
|
-
state.removeIdentityMarker = () => element.removeAttribute(identityAttribute);
|
|
154
|
-
let cleanupTimer;
|
|
155
|
-
state.cleanup = () => {
|
|
156
|
-
clearTimeout(cleanupTimer);
|
|
157
|
-
state.removeIdentityMarker();
|
|
158
|
-
listeners.forEach(([type, listener]) => document.removeEventListener(type, listener, true));
|
|
159
|
-
try { delete window[marker]; } catch {}
|
|
160
|
-
};
|
|
161
|
-
// A native pending decision can forbid cleanup eval; expire without another command.
|
|
162
|
-
cleanupTimer = setTimeout(state.cleanup, ${timeoutMs + CLICK_DISPATCH_CLEANUP_TIMEOUT_MS});
|
|
163
|
-
window[marker] = state;
|
|
164
|
-
element.setAttribute(identityAttribute, marker);
|
|
165
|
-
return { status: "installed", marker, target: state.target };
|
|
166
|
-
})()`;
|
|
167
|
-
}
|
|
168
|
-
function buildClickDispatchProbeCheckScript(probe) {
|
|
169
|
-
return `(() => {
|
|
170
|
-
const marker = ${JSON.stringify(probe.marker)};
|
|
171
|
-
const state = window[marker];
|
|
172
|
-
const finish = (payload) => {
|
|
173
|
-
if (state && typeof state.cleanup === "function") state.cleanup();
|
|
174
|
-
try { delete window[marker]; } catch {}
|
|
175
|
-
return payload;
|
|
176
|
-
};
|
|
177
|
-
if (!state || !Array.isArray(state.events)) return finish({ status: "probe-missing", nativeEventCount: 0 });
|
|
178
|
-
const nativeEventCount = state.events.filter((event) => event && event.isTrusted === true && event.targetMatched === true).length;
|
|
179
|
-
if (nativeEventCount > 0) return finish({ status: "native-event-observed", nativeEventCount, target: state.target });
|
|
180
|
-
return finish({ status: "no-native-event-observed", nativeEventCount, target: state.target });
|
|
181
|
-
})()`;
|
|
182
|
-
}
|
|
183
|
-
function buildClickDispatchProbeCleanupScript(probe) {
|
|
184
|
-
return `(() => {
|
|
185
|
-
const marker = ${JSON.stringify(probe.marker)};
|
|
186
|
-
const state = window[marker];
|
|
187
|
-
if (state && typeof state.cleanup === "function") state.cleanup();
|
|
188
|
-
try { delete window[marker]; } catch {}
|
|
189
|
-
return { status: "cleaned-up" };
|
|
190
|
-
})()`;
|
|
191
|
-
}
|
|
192
|
-
function redactClickDispatchTarget(target) {
|
|
193
|
-
if (target.kind === "selector" || target.kind === "xpath") {
|
|
194
|
-
return { ...target, selector: redactSensitiveText(target.selector) };
|
|
195
|
-
}
|
|
196
|
-
return { ...target, name: redactSensitiveText(target.name) };
|
|
197
|
-
}
|
|
198
|
-
export function formatClickDispatchDiagnosticText(diagnostic) {
|
|
199
|
-
return `Click dispatch diagnostic: ${diagnostic.summary}`;
|
|
200
|
-
}
|
|
201
|
-
export function buildClickDispatchNextActions(options) {
|
|
202
|
-
const retryArgs = options.commandTokens[0] === "click" || options.commandTokens[0] === "find"
|
|
203
|
-
? options.commandTokens
|
|
204
|
-
: ["click", ...options.commandTokens];
|
|
205
|
-
const actions = [
|
|
206
|
-
{
|
|
207
|
-
id: "inspect-click-dispatch-miss",
|
|
208
|
-
params: { args: withOptionalSessionArgs(options.sessionName, ["snapshot", "-i"]) },
|
|
209
|
-
reason: "Refresh interactive refs and verify the intended click target before retrying upstream click.",
|
|
210
|
-
safety: "Read-only snapshot; the wrapper does not replay clicks in-page when upstream reports success without DOM events.",
|
|
211
|
-
tool: "agent_browser",
|
|
212
|
-
},
|
|
213
|
-
];
|
|
214
|
-
if (options.diagnostic?.scrollContainer) {
|
|
215
|
-
actions.push({
|
|
216
|
-
id: "scroll-target-into-view-after-dispatch-miss",
|
|
217
|
-
params: {
|
|
218
|
-
args: withOptionalSessionArgs(options.sessionName, ["scrollintoview", retryArgs.at(1)].filter((item) => typeof item === "string")),
|
|
219
|
-
},
|
|
220
|
-
reason: options.diagnostic.scrollContainer.selector !== undefined &&
|
|
221
|
-
options.diagnostic.scrollContainer.selector !== ""
|
|
222
|
-
? `The target may be outside nested scroll container ${options.diagnostic.scrollContainer.selector}; scroll the target into view before retrying the click.`
|
|
223
|
-
: "The target may be inside an offscreen nested scroll container; scroll the target into view before retrying the click.",
|
|
224
|
-
safety: "Use only for the same current page and target; run snapshot -i again if the page rerendered.",
|
|
225
|
-
tool: "agent_browser",
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
actions.push({
|
|
229
|
-
id: "retry-click-after-dispatch-miss",
|
|
230
|
-
params: { args: withOptionalSessionArgs(options.sessionName, retryArgs) },
|
|
231
|
-
reason: "Retry the same upstream click after confirming the target is visible; do not assume the prior success mutated the page.",
|
|
232
|
-
safety: "Only retry when the target is still intended; use page-change evidence or a fresh snapshot before continuing the workflow.",
|
|
233
|
-
tool: "agent_browser",
|
|
234
|
-
});
|
|
235
|
-
return actions;
|
|
236
|
-
}
|
|
237
|
-
function nativeProbeSelector(target) {
|
|
238
|
-
if (target.kind === "accessible") {
|
|
239
|
-
return `@${target.refId}`;
|
|
240
|
-
}
|
|
241
|
-
return target.kind === "xpath" ? `xpath=${target.selector}` : target.selector;
|
|
242
|
-
}
|
|
243
|
-
async function verifyClickDispatchProbeIdentity(options, probe) {
|
|
244
|
-
const identity = await runSessionCommandData({
|
|
245
|
-
args: [
|
|
246
|
-
"get",
|
|
247
|
-
"attr",
|
|
248
|
-
nativeProbeSelector(probe.target),
|
|
249
|
-
getClickDispatchIdentityAttribute(probe),
|
|
250
|
-
],
|
|
251
|
-
cwd: options.cwd,
|
|
252
|
-
namespace: options.namespace,
|
|
253
|
-
sessionName: options.sessionName,
|
|
254
|
-
signal: options.signal,
|
|
255
|
-
});
|
|
256
|
-
if (!isRecord(identity) || identity.value !== probe.marker) {
|
|
257
|
-
return false;
|
|
258
|
-
}
|
|
259
|
-
const removed = await runSessionCommandData({
|
|
260
|
-
args: ["eval", "--stdin"],
|
|
261
|
-
cwd: options.cwd,
|
|
262
|
-
namespace: options.namespace,
|
|
263
|
-
sessionName: options.sessionName,
|
|
264
|
-
signal: options.signal,
|
|
265
|
-
stdin: `(() => {
|
|
266
|
-
const state = window[${JSON.stringify(probe.marker)}];
|
|
267
|
-
if (!state || typeof state.removeIdentityMarker !== "function") return { status: "probe-missing" };
|
|
268
|
-
state.removeIdentityMarker();
|
|
269
|
-
return { status: "identity-marker-removed" };
|
|
270
|
-
})()`,
|
|
271
|
-
});
|
|
272
|
-
return getEvalResultRecord(removed)?.status === "identity-marker-removed";
|
|
273
|
-
}
|
|
274
|
-
function canPrepareClickDispatchProbe(options) {
|
|
275
|
-
if ((options.sessionName ?? "") === "" ||
|
|
276
|
-
options.commandTokens[0] !== "click" ||
|
|
277
|
-
options.commandTokens.includes("--new-tab")) {
|
|
278
|
-
return false;
|
|
279
|
-
}
|
|
280
|
-
// This optional diagnostic must not require approving a fresh eval on every click retry.
|
|
281
|
-
if (getAgentBrowserProcessEnvironment()
|
|
282
|
-
.AGENT_BROWSER_CONFIRM_ACTIONS?.split(",")
|
|
283
|
-
.some((action) => action.trim().toLowerCase() === "evaluate") === true) {
|
|
284
|
-
return false;
|
|
285
|
-
}
|
|
286
|
-
return true;
|
|
287
|
-
}
|
|
288
|
-
export async function prepareClickDispatchProbe(options) {
|
|
289
|
-
if (!canPrepareClickDispatchProbe(options)) {
|
|
290
|
-
return undefined;
|
|
291
|
-
}
|
|
292
|
-
const target = getClickDispatchProbeTarget(options.commandTokens, options.refSnapshot);
|
|
293
|
-
if (!target) {
|
|
294
|
-
return undefined;
|
|
295
|
-
}
|
|
296
|
-
const probe = {
|
|
297
|
-
marker: `${CLICK_DISPATCH_MARKER_PREFIX}${Date.now().toString(36)}_${Math.random().toString(36).slice(2)}`,
|
|
298
|
-
target,
|
|
299
|
-
};
|
|
300
|
-
let prepared = false;
|
|
301
|
-
try {
|
|
302
|
-
const installData = await runSessionCommandData({
|
|
303
|
-
args: ["eval", "--stdin"],
|
|
304
|
-
cwd: options.cwd,
|
|
305
|
-
namespace: options.namespace,
|
|
306
|
-
sessionName: options.sessionName,
|
|
307
|
-
signal: options.signal,
|
|
308
|
-
stdin: buildClickDispatchProbeInstallScript(probe, options.timeoutMs ?? getAgentBrowserProcessTimeoutMs()),
|
|
309
|
-
});
|
|
310
|
-
if (getEvalResultRecord(installData)?.status !== "installed") {
|
|
311
|
-
return undefined;
|
|
312
|
-
}
|
|
313
|
-
// Name matching and in-page XPath only find candidates. Native resolution
|
|
314
|
-
// must prove identity, including frame scope, before missing events mean failure.
|
|
315
|
-
if (!(await verifyClickDispatchProbeIdentity(options, probe))) {
|
|
316
|
-
return undefined;
|
|
317
|
-
}
|
|
318
|
-
prepared = options.signal?.aborted !== true;
|
|
319
|
-
return prepared ? probe : undefined;
|
|
320
|
-
}
|
|
321
|
-
finally {
|
|
322
|
-
// Even a lost/aborted install response may have left listeners in-page.
|
|
323
|
-
if (!prepared) {
|
|
324
|
-
await cleanupClickDispatchProbe({ ...options, probe });
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
function optionalBoolean(value, key) {
|
|
329
|
-
return typeof value?.[key] === "boolean" ? value[key] : undefined;
|
|
330
|
-
}
|
|
331
|
-
function nearestScrollContainer(target) {
|
|
332
|
-
return isRecord(target?.nearestScrollContainer) ? target.nearestScrollContainer : undefined;
|
|
333
|
-
}
|
|
334
|
-
function getClickDispatchScrollContainerDiagnostic(result) {
|
|
335
|
-
const target = isRecord(result.target) ? result.target : undefined;
|
|
336
|
-
const scrollContainer = nearestScrollContainer(target);
|
|
337
|
-
const targetOutsideViewport = optionalBoolean(target, "targetOutsideViewport");
|
|
338
|
-
const targetOutsideContainer = optionalBoolean(scrollContainer, "targetOutsideContainer");
|
|
339
|
-
if (!scrollContainer && targetOutsideViewport !== true) {
|
|
340
|
-
return undefined;
|
|
341
|
-
}
|
|
342
|
-
if (targetOutsideContainer !== true && targetOutsideViewport !== true) {
|
|
343
|
-
return undefined;
|
|
344
|
-
}
|
|
345
|
-
const selector = typeof scrollContainer?.selector === "string"
|
|
346
|
-
? redactSensitiveText(scrollContainer.selector)
|
|
347
|
-
: undefined;
|
|
348
|
-
const summary = describeClickScrollContainer(selector);
|
|
349
|
-
return { selector, summary, targetOutsideContainer, targetOutsideViewport };
|
|
350
|
-
}
|
|
351
|
-
function describeClickScrollContainer(selector) {
|
|
352
|
-
return selector !== undefined && selector !== ""
|
|
353
|
-
? `Target appears outside nested scroll container ${selector}; use scrollintoview on the target or scroll that container before retrying.`
|
|
354
|
-
: "Target appears outside the viewport or a nested scroll container; use scrollintoview on the target before retrying.";
|
|
355
|
-
}
|
|
356
|
-
export async function collectClickDispatchDiagnostic(options) {
|
|
357
|
-
if (!options.probe || (options.sessionName ?? "") === "") {
|
|
358
|
-
return undefined;
|
|
359
|
-
}
|
|
360
|
-
const data = await runSessionCommandData({
|
|
361
|
-
args: ["eval", "--stdin"],
|
|
362
|
-
cwd: options.cwd,
|
|
363
|
-
namespace: options.namespace,
|
|
364
|
-
sessionName: options.sessionName,
|
|
365
|
-
signal: options.signal,
|
|
366
|
-
stdin: buildClickDispatchProbeCheckScript(options.probe),
|
|
367
|
-
});
|
|
368
|
-
const result = getEvalResultRecord(data);
|
|
369
|
-
if (!result) {
|
|
370
|
-
return undefined;
|
|
371
|
-
}
|
|
372
|
-
options.probe.cleaned = true;
|
|
373
|
-
const status = typeof result.status === "string" ? result.status : undefined;
|
|
374
|
-
if (status !== "no-native-event-observed") {
|
|
375
|
-
return undefined;
|
|
376
|
-
}
|
|
377
|
-
const nativeEventCount = typeof result.nativeEventCount === "number" ? result.nativeEventCount : 0;
|
|
378
|
-
const scrollContainer = getClickDispatchScrollContainerDiagnostic(result);
|
|
379
|
-
const targetLabel = "no trusted DOM event reached the selected element";
|
|
380
|
-
const summary = scrollContainer
|
|
381
|
-
? `Upstream click reported success but ${targetLabel}. ${scrollContainer.summary}`
|
|
382
|
-
: `Upstream click reported success but ${targetLabel}. Gather evidence with snapshot or page-change checks, then retry upstream click or report the workflow issue; the wrapper does not replay clicks in-page.`;
|
|
383
|
-
return {
|
|
384
|
-
nativeEventCount,
|
|
385
|
-
reason: "native-click-produced-no-target-dom-event",
|
|
386
|
-
...(scrollContainer ? { scrollContainer } : {}),
|
|
387
|
-
status,
|
|
388
|
-
summary,
|
|
389
|
-
target: redactClickDispatchTarget(options.probe.target),
|
|
390
|
-
};
|
|
391
|
-
}
|
|
392
|
-
export async function cleanupClickDispatchProbe(options) {
|
|
393
|
-
if (!options.probe || options.probe.cleaned === true || (options.sessionName ?? "") === "") {
|
|
394
|
-
return;
|
|
395
|
-
}
|
|
396
|
-
await runSessionCommandData({
|
|
397
|
-
args: ["eval", "--stdin"],
|
|
398
|
-
cwd: options.cwd,
|
|
399
|
-
namespace: options.namespace,
|
|
400
|
-
sessionName: options.sessionName,
|
|
401
|
-
stdin: buildClickDispatchProbeCleanupScript(options.probe),
|
|
402
|
-
timeoutMs: CLICK_DISPATCH_CLEANUP_TIMEOUT_MS,
|
|
403
|
-
}).catch(() => {
|
|
404
|
-
// Probe expiry also removes listeners; cleanup failure must not replace the caller's result.
|
|
405
|
-
});
|
|
406
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { isRecord } from "../../parsing.js";
|
|
2
|
-
import { stringifyUnknown } from "../../results/text.js";
|
|
3
|
-
export function diagnosticResultRecord(data) {
|
|
4
|
-
const result = isRecord(data) && isRecord(data.result) ? data.result : data;
|
|
5
|
-
return isRecord(result) ? result : undefined;
|
|
6
|
-
}
|
|
7
|
-
export function rawStringField(data, field) {
|
|
8
|
-
const value = data[field];
|
|
9
|
-
return typeof value === "string" ? value : undefined;
|
|
10
|
-
}
|
|
11
|
-
export function rawNumberField(data, field) {
|
|
12
|
-
const value = data[field];
|
|
13
|
-
return typeof value === "number" ? value : undefined;
|
|
14
|
-
}
|
|
15
|
-
export function diagnosticErrorText(error) {
|
|
16
|
-
if (error instanceof Error) {
|
|
17
|
-
return error.message;
|
|
18
|
-
}
|
|
19
|
-
switch (typeof error) {
|
|
20
|
-
case "object":
|
|
21
|
-
return error === null ? "null" : stringifyUnknown(error);
|
|
22
|
-
case "string":
|
|
23
|
-
case "number":
|
|
24
|
-
case "bigint":
|
|
25
|
-
case "boolean":
|
|
26
|
-
case "undefined":
|
|
27
|
-
case "symbol":
|
|
28
|
-
case "function":
|
|
29
|
-
return String(error);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
import { stat } from "node:fs/promises";
|
|
2
|
-
import { setTimeout as sleepMs } from "node:timers/promises";
|
|
3
|
-
import { isAbsolute, resolve } from "node:path";
|
|
4
|
-
import { isCloseCommand } from "../../command-taxonomy.js";
|
|
5
|
-
import { executableExistsOnPath } from "../../executable-path.js";
|
|
6
|
-
import { formatSessionArtifactRetentionSummary } from "../../results/artifact-manifest.js";
|
|
7
|
-
import { buildVisibleRefFallbackDiagnosticFromSnapshot, getVisibleRefFallbackTarget, } from "../../results/selector-recovery.js";
|
|
8
|
-
import { isAboutBlankUrl, normalizeComparableUrl, } from "../../session-page-state.js";
|
|
9
|
-
import { isRecord } from "../../parsing.js";
|
|
10
|
-
import { extractNavigationSummaryFromData, extractStringResultField, runSessionCommandData, } from "./session-state.js";
|
|
11
|
-
export { redactTimeoutPartialProgress } from "./timeout-progress.js";
|
|
12
|
-
export { sleepMs };
|
|
13
|
-
function comparePriorNavigationUrl(priorUrl, url) {
|
|
14
|
-
return priorUrl !== undefined && priorUrl !== ""
|
|
15
|
-
? normalizeComparableUrl(priorUrl) !== normalizeComparableUrl(url)
|
|
16
|
-
: undefined;
|
|
17
|
-
}
|
|
18
|
-
function reusableNavigationTitle(options, url) {
|
|
19
|
-
const prior = options.priorTarget;
|
|
20
|
-
return options.reusePriorTitle !== false &&
|
|
21
|
-
prior !== undefined &&
|
|
22
|
-
prior.title !== undefined &&
|
|
23
|
-
prior.title !== "" &&
|
|
24
|
-
normalizeComparableUrl(prior.url) === normalizeComparableUrl(url)
|
|
25
|
-
? prior.title
|
|
26
|
-
: undefined;
|
|
27
|
-
}
|
|
28
|
-
export async function collectNavigationSummary(options) {
|
|
29
|
-
const url = extractStringResultField(await runSessionCommandData({
|
|
30
|
-
args: ["get", "url"],
|
|
31
|
-
cwd: options.cwd,
|
|
32
|
-
namespace: options.namespace,
|
|
33
|
-
sessionName: options.sessionName,
|
|
34
|
-
signal: options.signal,
|
|
35
|
-
}), "url");
|
|
36
|
-
if (url === undefined || url === "" || !/^[a-z][a-z0-9+.-]*:/i.test(url)) {
|
|
37
|
-
return undefined;
|
|
38
|
-
}
|
|
39
|
-
const urlChanged = comparePriorNavigationUrl(options.priorTarget?.url, url);
|
|
40
|
-
if (isAboutBlankUrl(url)) {
|
|
41
|
-
return { url, ...(urlChanged !== undefined ? { urlChanged } : {}) };
|
|
42
|
-
}
|
|
43
|
-
// Reuse the title already observed for this exact URL instead of spending a second probe. Titles can
|
|
44
|
-
// change without a URL change on SPAs, but this summary is only a "last observed" page label; the URL
|
|
45
|
-
// stays live-probed on every call.
|
|
46
|
-
const priorTitle = reusableNavigationTitle(options, url);
|
|
47
|
-
if (priorTitle !== undefined) {
|
|
48
|
-
return { title: priorTitle, url, urlChanged: false };
|
|
49
|
-
}
|
|
50
|
-
const title = extractStringResultField(await runSessionCommandData({
|
|
51
|
-
args: ["get", "title"],
|
|
52
|
-
cwd: options.cwd,
|
|
53
|
-
namespace: options.namespace,
|
|
54
|
-
sessionName: options.sessionName,
|
|
55
|
-
signal: options.signal,
|
|
56
|
-
}), "title");
|
|
57
|
-
return { title, url, ...(urlChanged !== undefined ? { urlChanged } : {}) };
|
|
58
|
-
}
|
|
59
|
-
export { collectScrollPositionSnapshot, buildUnsupportedScrollIntoViewRecovery, buildScrollNoopDiagnostic, buildScrollNoopNextActions, formatScrollNoopDiagnosticText, collectComboboxFocusDiagnostic, buildComboboxFocusNextActions, formatComboboxFocusDiagnosticText, } from "./interaction-diagnostics.js";
|
|
60
|
-
function getRecordStartLikeCommand(command, commandTokens) {
|
|
61
|
-
if (command !== "record") {
|
|
62
|
-
return undefined;
|
|
63
|
-
}
|
|
64
|
-
const subcommand = commandTokens[1]?.toLowerCase();
|
|
65
|
-
if (subcommand === "start") {
|
|
66
|
-
return "record start";
|
|
67
|
-
}
|
|
68
|
-
if (subcommand === "restart") {
|
|
69
|
-
return "record restart";
|
|
70
|
-
}
|
|
71
|
-
return undefined;
|
|
72
|
-
}
|
|
73
|
-
export async function collectRecordingDependencyWarning(options) {
|
|
74
|
-
if (!options.succeeded) {
|
|
75
|
-
return undefined;
|
|
76
|
-
}
|
|
77
|
-
const recordCommand = getRecordStartLikeCommand(options.command, options.commandTokens);
|
|
78
|
-
if (recordCommand === undefined) {
|
|
79
|
-
return undefined;
|
|
80
|
-
}
|
|
81
|
-
if (await executableExistsOnPath("ffmpeg")) {
|
|
82
|
-
return undefined;
|
|
83
|
-
}
|
|
84
|
-
return {
|
|
85
|
-
command: recordCommand,
|
|
86
|
-
dependency: "ffmpeg",
|
|
87
|
-
message: `${recordCommand} reported a pending recording, but ffmpeg is not on PATH. Its output is unverified; install ffmpeg before starting a new recording.`,
|
|
88
|
-
reason: "ffmpeg-missing-for-recording",
|
|
89
|
-
recommendations: [
|
|
90
|
-
"Install ffmpeg before recording; on macOS with Homebrew, brew install ffmpeg or brew install ffmpeg-full.",
|
|
91
|
-
"Stop this recording, check the result, and start a new recording after ensuring Pi can find ffmpeg on PATH.",
|
|
92
|
-
],
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
export function formatRecordingDependencyWarningText(warning) {
|
|
96
|
-
if (!warning) {
|
|
97
|
-
return undefined;
|
|
98
|
-
}
|
|
99
|
-
return [
|
|
100
|
-
"Recording dependency warning: ffmpeg not found on PATH.",
|
|
101
|
-
`Reason: ${warning.message}`,
|
|
102
|
-
...warning.recommendations.map((recommendation) => `- ${recommendation}`),
|
|
103
|
-
].join("\n");
|
|
104
|
-
}
|
|
105
|
-
export { formatOverlayBlockerText, buildOverlayBlockerNextActions, collectSnapshotOverlayBlockerDiagnostic, collectOverlayBlockerDiagnostic, } from "./overlay-diagnostics.js";
|
|
106
|
-
export { collectSelectorTextVisibilityDiagnostics, formatSelectorTextVisibilityText, buildSelectorTextVisibilityNextActions, } from "./text-visibility-diagnostics.js";
|
|
107
|
-
export { getSourceLookupElectronContext, buildSourceLookupElectronNextActions, collectElectronBroadGetTextScopeDiagnostics, formatElectronBroadGetTextScopeText, buildElectronBroadGetTextScopeNextActions, } from "./electron-text-diagnostics.js";
|
|
108
|
-
function looksLikeFunctionEvalStdin(stdin) {
|
|
109
|
-
const trimmed = stdin?.trim();
|
|
110
|
-
if (trimmed === undefined || trimmed === "") {
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
return (/^(?:async\s+)?function\b/.test(trimmed) ||
|
|
114
|
-
/^(?:async\s*)?\([^)]*\)\s*=>/.test(trimmed) ||
|
|
115
|
-
/^(?:async\s+)?[A-Za-z_$][\w$]*\s*=>/.test(trimmed));
|
|
116
|
-
}
|
|
117
|
-
function isPlainEmptyObject(value) {
|
|
118
|
-
if (!isRecord(value) || Array.isArray(value)) {
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
const prototype = Object.getPrototypeOf(value);
|
|
122
|
-
return (prototype === Object.prototype || prototype === null) && Object.keys(value).length === 0;
|
|
123
|
-
}
|
|
124
|
-
export function getEvalStdinHint(options) {
|
|
125
|
-
if (options.command !== "eval" ||
|
|
126
|
-
!looksLikeFunctionEvalStdin(options.stdin) ||
|
|
127
|
-
!isRecord(options.data)) {
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
const result = options.data.result;
|
|
131
|
-
if (!isPlainEmptyObject(result)) {
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
return {
|
|
135
|
-
reason: "eval --stdin received a function-shaped snippet and the upstream JSON result was an empty object, which often means the function itself was returned or serialized instead of invoked.",
|
|
136
|
-
suggestion: "Pass a plain expression such as `({ title: document.title })`, or invoke the function explicitly, for example `(() => ({ title: document.title }))()`.",
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
export function formatEvalStdinHintText(hint) {
|
|
140
|
-
return hint ? `Eval stdin hint: ${hint.reason} ${hint.suggestion}` : undefined;
|
|
141
|
-
}
|
|
142
|
-
function localEvalPageUrl(options) {
|
|
143
|
-
const pageUrl = options.pageUrl?.trim() ??
|
|
144
|
-
options.navigationSummary?.url?.trim() ??
|
|
145
|
-
extractNavigationSummaryFromData(options.data)?.url;
|
|
146
|
-
return pageUrl !== undefined && pageUrl !== "" && /^file:/i.test(pageUrl) ? pageUrl : undefined;
|
|
147
|
-
}
|
|
148
|
-
export function getEvalResultWarning(options) {
|
|
149
|
-
const trimmed = options.stdin?.trim();
|
|
150
|
-
if (options.command !== "eval" ||
|
|
151
|
-
trimmed === undefined ||
|
|
152
|
-
trimmed === "" ||
|
|
153
|
-
!isRecord(options.data) ||
|
|
154
|
-
options.data.result !== null ||
|
|
155
|
-
/^(?:null|undefined)$/i.test(trimmed) ||
|
|
156
|
-
localEvalPageUrl(options) === undefined) {
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
return {
|
|
160
|
-
reason: "eval --stdin returned null on a file:// page; upstream may not expose full DOM semantics for local fixtures.",
|
|
161
|
-
suggestion: "Treat this as inconclusive verification. Use snapshot -i, get text on current @refs, screenshot evidence, or a reachable http(s) fixture before concluding DOM state.",
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
export function formatEvalResultWarningText(warning) {
|
|
165
|
-
return warning ? `Eval result warning: ${warning.reason} ${warning.suggestion}` : undefined;
|
|
166
|
-
}
|
|
167
|
-
async function collectExistingExplicitArtifactPaths(entries, cwd) {
|
|
168
|
-
const explicitArtifactPaths = [];
|
|
169
|
-
const seenPaths = new Set();
|
|
170
|
-
for (const entry of entries) {
|
|
171
|
-
if (explicitArtifactPaths.length >= 10) {
|
|
172
|
-
break;
|
|
173
|
-
}
|
|
174
|
-
const displayPath = entry.path;
|
|
175
|
-
if (seenPaths.has(displayPath)) {
|
|
176
|
-
continue;
|
|
177
|
-
}
|
|
178
|
-
const absolutePath = entry.absolutePath ?? (isAbsolute(entry.path) ? entry.path : resolve(cwd, entry.path));
|
|
179
|
-
try {
|
|
180
|
-
// The first ten existing distinct display paths are selected in manifest order.
|
|
181
|
-
// oxlint-disable-next-line no-await-in-loop
|
|
182
|
-
await stat(absolutePath);
|
|
183
|
-
}
|
|
184
|
-
catch {
|
|
185
|
-
continue;
|
|
186
|
-
}
|
|
187
|
-
seenPaths.add(displayPath);
|
|
188
|
-
explicitArtifactPaths.push(displayPath);
|
|
189
|
-
}
|
|
190
|
-
return explicitArtifactPaths;
|
|
191
|
-
}
|
|
192
|
-
export async function getArtifactCleanupGuidance(options) {
|
|
193
|
-
if (!options.succeeded || !isCloseCommand(options.command) || !options.manifest) {
|
|
194
|
-
return undefined;
|
|
195
|
-
}
|
|
196
|
-
const explicitEntries = options.manifest.entries.filter((entry) => entry.storageScope === "explicit-path");
|
|
197
|
-
if (explicitEntries.length === 0) {
|
|
198
|
-
return undefined;
|
|
199
|
-
}
|
|
200
|
-
const explicitArtifactPaths = await collectExistingExplicitArtifactPaths(explicitEntries, options.cwd);
|
|
201
|
-
if (explicitArtifactPaths.length === 0) {
|
|
202
|
-
return undefined;
|
|
203
|
-
}
|
|
204
|
-
return {
|
|
205
|
-
explicitArtifactPaths,
|
|
206
|
-
note: "Closing the browser session does not delete explicit screenshots, downloads, PDFs, traces, HAR files, or recordings; clean existing paths with host file tools when no longer needed.",
|
|
207
|
-
owner: "host-file-tools",
|
|
208
|
-
summary: formatSessionArtifactRetentionSummary(options.manifest),
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
export function formatArtifactCleanupGuidanceText(guidance) {
|
|
212
|
-
if (!guidance || guidance.explicitArtifactPaths.length === 0) {
|
|
213
|
-
return undefined;
|
|
214
|
-
}
|
|
215
|
-
const explicitCount = guidance.explicitArtifactPaths.length;
|
|
216
|
-
return `Artifact lifecycle: ${explicitCount} explicit artifact${explicitCount === 1 ? "" : "s"} remain${explicitCount === 1 ? "s" : ""}; expand or inspect details.artifactCleanup.explicitArtifactPaths for paths. Browser close does not delete explicit screenshots, downloads, PDFs, traces, HAR files, or recordings; use host file tools for cleanup.`;
|
|
217
|
-
}
|
|
218
|
-
export { collectElectronManagedSessionTarget, collectQaAttachedTarget, formatQaAttachedTargetText, validateQaAttachedPrecondition, collectElectronHandoff, } from "./electron-observation.js";
|
|
219
|
-
export { collectFillVerificationDiagnostic, buildFillVerificationNextActions, formatFillVerificationText, } from "./fill-diagnostics.js";
|
|
220
|
-
export async function collectVisibleRefFallbackDiagnostic(options) {
|
|
221
|
-
if (options.sessionName === undefined || options.sessionName === "") {
|
|
222
|
-
return undefined;
|
|
223
|
-
}
|
|
224
|
-
const target = getVisibleRefFallbackTarget({
|
|
225
|
-
commandTokens: options.commandTokens,
|
|
226
|
-
compiledSemanticAction: options.compiledSemanticAction,
|
|
227
|
-
});
|
|
228
|
-
if (!target) {
|
|
229
|
-
return undefined;
|
|
230
|
-
}
|
|
231
|
-
const snapshotData = await runSessionCommandData({
|
|
232
|
-
args: ["snapshot", "-i"],
|
|
233
|
-
cwd: options.cwd,
|
|
234
|
-
namespace: options.namespace,
|
|
235
|
-
sessionName: options.sessionName,
|
|
236
|
-
signal: options.signal,
|
|
237
|
-
});
|
|
238
|
-
return buildVisibleRefFallbackDiagnosticFromSnapshot({ snapshotData, target });
|
|
239
|
-
}
|
|
240
|
-
export { collectTimeoutPartialProgress, formatTimeoutPartialProgressText, } from "./timeout-diagnostics.js";
|