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,65 +0,0 @@
|
|
|
1
|
-
function normalizeComparableUrl(url) {
|
|
2
|
-
const normalizedUrl = url.trim();
|
|
3
|
-
if (normalizedUrl.length === 0) {
|
|
4
|
-
return;
|
|
5
|
-
}
|
|
6
|
-
try {
|
|
7
|
-
const parsedUrl = new URL(normalizedUrl);
|
|
8
|
-
parsedUrl.hash = "";
|
|
9
|
-
return parsedUrl.toString();
|
|
10
|
-
}
|
|
11
|
-
catch {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
function normalizeTabSelectionValue(value) {
|
|
16
|
-
const normalizedValue = value?.trim();
|
|
17
|
-
return normalizedValue !== undefined && normalizedValue.length > 0 ? normalizedValue : undefined;
|
|
18
|
-
}
|
|
19
|
-
function extractTabSelection(tab) {
|
|
20
|
-
const tabId = normalizeTabSelectionValue(tab.tabId);
|
|
21
|
-
if (tabId !== undefined) {
|
|
22
|
-
return { selectedTab: tabId, selectionKind: "tabId" };
|
|
23
|
-
}
|
|
24
|
-
const label = normalizeTabSelectionValue(tab.label);
|
|
25
|
-
if (label !== undefined) {
|
|
26
|
-
return { selectedTab: label, selectionKind: "label" };
|
|
27
|
-
}
|
|
28
|
-
if (typeof tab.index === "number" && Number.isInteger(tab.index) && tab.index >= 0) {
|
|
29
|
-
return { selectedTab: String(tab.index), selectionKind: "index" };
|
|
30
|
-
}
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
function selectMatchingTab(tabs, targetTitle) {
|
|
34
|
-
const title = typeof targetTitle === "string" ? targetTitle.trim() : "";
|
|
35
|
-
const titledMatch = title.length === 0
|
|
36
|
-
? undefined
|
|
37
|
-
: tabs.find((tab) => typeof tab.title === "string" && tab.title.trim() === title);
|
|
38
|
-
return {
|
|
39
|
-
selection: extractTabSelection(titledMatch ?? tabs[0]),
|
|
40
|
-
targetTitle: title.length > 0 ? title : undefined,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
export function chooseOpenResultTabCorrection(options) {
|
|
44
|
-
const normalizedTargetUrl = typeof options.targetUrl === "string" ? normalizeComparableUrl(options.targetUrl) : undefined;
|
|
45
|
-
if (normalizedTargetUrl === undefined) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const tabsWithIndices = options.tabs.map((tab, index) => ({
|
|
49
|
-
...tab,
|
|
50
|
-
index: typeof tab.index === "number" ? tab.index : index,
|
|
51
|
-
label: normalizeTabSelectionValue(tab.label),
|
|
52
|
-
tabId: normalizeTabSelectionValue(tab.tabId),
|
|
53
|
-
}));
|
|
54
|
-
const activeTab = tabsWithIndices.find((tab) => tab.active === true) ??
|
|
55
|
-
tabsWithIndices.find((tab) => tab.index === options.activeTabIndex);
|
|
56
|
-
if (activeTab && normalizeComparableUrl(activeTab.url ?? "") === normalizedTargetUrl) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const matchingTabs = tabsWithIndices.filter((tab) => normalizeComparableUrl(tab.url ?? "") === normalizedTargetUrl);
|
|
60
|
-
if (matchingTabs.length === 0) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
const { selection, targetTitle } = selectMatchingTab(matchingTabs, options.targetTitle);
|
|
64
|
-
return selection ? { ...selection, targetTitle, targetUrl: normalizedTargetUrl } : undefined;
|
|
65
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { getAgentBrowserProcessEnvironment } from "./process-environment.js";
|
|
2
|
-
const DEFAULT_IMPLICIT_SESSION_IDLE_TIMEOUT_MS = 15 * 60 * 1000;
|
|
3
|
-
// Native close includes a five-second Chrome exit grace after protocol shutdown.
|
|
4
|
-
// Use the normal CLI watchdog budget rather than interrupting that grace.
|
|
5
|
-
const DEFAULT_IMPLICIT_SESSION_CLOSE_TIMEOUT_MS = 35_000;
|
|
6
|
-
function parseTimeoutMs(rawValue, minimumValue) {
|
|
7
|
-
if (rawValue === undefined) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
const normalizedValue = rawValue.trim();
|
|
11
|
-
if (!/^\d+$/.test(normalizedValue)) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
const parsedValue = Number(normalizedValue);
|
|
15
|
-
if (!Number.isSafeInteger(parsedValue) || parsedValue < minimumValue) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
return parsedValue;
|
|
19
|
-
}
|
|
20
|
-
export function getImplicitSessionIdleTimeoutMs(env = getAgentBrowserProcessEnvironment()) {
|
|
21
|
-
return (parseTimeoutMs(env.PI_AGENT_BROWSER_IMPLICIT_SESSION_IDLE_TIMEOUT_MS, 0) ??
|
|
22
|
-
parseTimeoutMs(env.AGENT_BROWSER_IDLE_TIMEOUT_MS, 0) ??
|
|
23
|
-
DEFAULT_IMPLICIT_SESSION_IDLE_TIMEOUT_MS);
|
|
24
|
-
}
|
|
25
|
-
export function getImplicitSessionCloseTimeoutMs(env = getAgentBrowserProcessEnvironment()) {
|
|
26
|
-
return (parseTimeoutMs(env.PI_AGENT_BROWSER_IMPLICIT_SESSION_CLOSE_TIMEOUT_MS, 0) ??
|
|
27
|
-
DEFAULT_IMPLICIT_SESSION_CLOSE_TIMEOUT_MS);
|
|
28
|
-
}
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { parseArgvDescriptor } from "./argv-descriptor.js";
|
|
2
|
-
import { canonicalizeAgentBrowserNamespace, extractExplicitNamespace, extractExplicitSessionName, getAgentBrowserSessionIdentityKey, getBooleanFlagValue, scanUpstreamGlobalFlagOccurrences, } from "./argv-grammar.js";
|
|
3
|
-
import { needsManagedSession } from "./command-policy.js";
|
|
4
|
-
import { isCloseCommand } from "./command-taxonomy.js";
|
|
5
|
-
import { hasLaunchScopedFlagToken, LAUNCH_SCOPED_FLAG_DEFINITIONS } from "./launch-scoped-flags.js";
|
|
6
|
-
import { getAgentBrowserProcessEnvironment } from "./process-environment.js";
|
|
7
|
-
import { formatInvalidValueFlagError, getInvalidValueFlagDetails, isPlainTextInspectionArgs, } from "./runtime-args-validation.js";
|
|
8
|
-
import { canUseHeadlessCompatibilityUserAgent, getCompatibilityWorkaround, getDefaultHeadlessCompatUserAgent, } from "./runtime-compatibility.js";
|
|
9
|
-
import { freshSessionRecoveryHint, launchFlagsRecoveryReason, selectExecutionSession, stripExplicitIdentityArgs, } from "./runtime-session-plan.js";
|
|
10
|
-
export { extractCommandTokens, extractUpstreamCommandTokens, findCommandStartIndex, parseArgvDescriptor, parseCommandInfo, parseWaitCommandTokens, } from "./argv-descriptor.js";
|
|
11
|
-
export { redactSensitiveText, redactSensitiveValue, redactInvocationArgs, } from "./runtime-redaction.js";
|
|
12
|
-
export { getImplicitSessionIdleTimeoutMs, getImplicitSessionCloseTimeoutMs, } from "./runtime-timeouts.js";
|
|
13
|
-
export { isPlainTextInspectionArgs, validateToolArgs } from "./runtime-args-validation.js";
|
|
14
|
-
export { canUseHeadlessCompatibilityUserAgent, getDefaultHeadlessCompatUserAgent, } from "./runtime-compatibility.js";
|
|
15
|
-
export { createEphemeralSessionSeed, createImplicitSessionName, createFreshSessionName, isRestorableManagedSessionName, resolveManagedSessionState, } from "./runtime-session-identity.js";
|
|
16
|
-
export { restoreManagedSessionStateFromBranch } from "./runtime-session-replay.js";
|
|
17
|
-
export { chooseOpenResultTabCorrection } from "./runtime-tab-correction.js";
|
|
18
|
-
export function getStartupScopedFlags(args) {
|
|
19
|
-
return LAUNCH_SCOPED_FLAG_DEFINITIONS.map((definition) => definition.flag).filter((flag) => hasLaunchScopedFlagToken(args, flag));
|
|
20
|
-
}
|
|
21
|
-
function withNativeSession(args) {
|
|
22
|
-
const nativeSession = getAgentBrowserProcessEnvironment().AGENT_BROWSER_SESSION;
|
|
23
|
-
if (nativeSession !== undefined &&
|
|
24
|
-
!isPlainTextInspectionArgs(args) &&
|
|
25
|
-
extractExplicitSessionName(args) === undefined) {
|
|
26
|
-
return ["--session", nativeSession, ...args];
|
|
27
|
-
}
|
|
28
|
-
return args;
|
|
29
|
-
}
|
|
30
|
-
function jsonPrefix(args) {
|
|
31
|
-
return getBooleanFlagValue(args, "--json") === undefined ? ["--json"] : [];
|
|
32
|
-
}
|
|
33
|
-
function planningFailure(args) {
|
|
34
|
-
const invalidValueFlag = getInvalidValueFlagDetails(args);
|
|
35
|
-
const repeatedFlag = ["--session", "--namespace"].find((flag) => scanUpstreamGlobalFlagOccurrences(args, flag).length > 1);
|
|
36
|
-
if (!invalidValueFlag && repeatedFlag === undefined) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const validationError = invalidValueFlag
|
|
40
|
-
? formatInvalidValueFlagError(invalidValueFlag)
|
|
41
|
-
: `Multiple ${repeatedFlag ?? ""} flags are not supported. Pass a single ${repeatedFlag ?? ""} value; upstream uses the last occurrence while this wrapper would otherwise mis-attribute managed-session ownership.`;
|
|
42
|
-
const plan = {
|
|
43
|
-
commandInfo: {},
|
|
44
|
-
effectiveArgs: jsonPrefix(args),
|
|
45
|
-
plainTextInspection: false,
|
|
46
|
-
startupScopedFlags: [],
|
|
47
|
-
usedImplicitSession: false,
|
|
48
|
-
validationError,
|
|
49
|
-
};
|
|
50
|
-
return invalidValueFlag ? { ...plan, invalidValueFlag } : plan;
|
|
51
|
-
}
|
|
52
|
-
function effectiveStartupFlags(args, managedNamespace) {
|
|
53
|
-
const explicitNamespacePresent = scanUpstreamGlobalFlagOccurrences(args, "--namespace").length > 0;
|
|
54
|
-
const explicitNamespace = extractExplicitNamespace(args);
|
|
55
|
-
return getStartupScopedFlags(args).filter((flag) => !(flag === "--namespace" &&
|
|
56
|
-
explicitNamespacePresent &&
|
|
57
|
-
explicitNamespace === canonicalizeAgentBrowserNamespace(managedNamespace)));
|
|
58
|
-
}
|
|
59
|
-
function targetsActiveManagedSession(selection, options, needsSession) {
|
|
60
|
-
const { sessionName } = selection;
|
|
61
|
-
return (options.managedSessionActive &&
|
|
62
|
-
needsSession &&
|
|
63
|
-
sessionName !== undefined &&
|
|
64
|
-
sessionName.length > 0 &&
|
|
65
|
-
getAgentBrowserSessionIdentityKey(sessionName, selection.namespace) ===
|
|
66
|
-
getAgentBrowserSessionIdentityKey(options.managedSessionName, options.managedSessionNamespace));
|
|
67
|
-
}
|
|
68
|
-
function activeLaunchRecovery(args, flags, command, prior) {
|
|
69
|
-
if (flags.length === 0 ||
|
|
70
|
-
isCloseCommand(command) ||
|
|
71
|
-
(prior.validationError !== undefined && prior.validationError.length > 0)) {
|
|
72
|
-
return prior;
|
|
73
|
-
}
|
|
74
|
-
const explicitSession = extractExplicitSessionName(args);
|
|
75
|
-
const explicit = explicitSession !== undefined && explicitSession.length > 0;
|
|
76
|
-
const recoveryArgs = explicit ? stripExplicitIdentityArgs(args, "--session") : args;
|
|
77
|
-
return {
|
|
78
|
-
recoveryHint: freshSessionRecoveryHint(recoveryArgs, launchFlagsRecoveryReason()),
|
|
79
|
-
validationError: [
|
|
80
|
-
`The current extension-managed agent-browser session is already running, so launch-scoped flags ${flags.join(", ")} would replace or be ignored by upstream agent-browser.`,
|
|
81
|
-
explicit
|
|
82
|
-
? 'Remove the explicit `--session` and retry with `sessionMode: "fresh"` to force a fresh upstream launch.'
|
|
83
|
-
: 'Retry this call with `sessionMode: "fresh"` to force a fresh upstream launch.',
|
|
84
|
-
].join(" "),
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
function activeCompatibilityPlan(args, requested, existing, prior) {
|
|
88
|
-
if (!canUseHeadlessCompatibilityUserAgent(args)) {
|
|
89
|
-
return { ...prior, compatibilityWorkaround: requested };
|
|
90
|
-
}
|
|
91
|
-
if (requested &&
|
|
92
|
-
!existing &&
|
|
93
|
-
(prior.validationError === undefined || prior.validationError.length === 0)) {
|
|
94
|
-
const sessionName = extractExplicitSessionName(args);
|
|
95
|
-
const explicit = sessionName !== undefined && sessionName.length > 0;
|
|
96
|
-
const recoveryArgs = explicit ? stripExplicitIdentityArgs(args, "--session") : args;
|
|
97
|
-
return {
|
|
98
|
-
compatibilityWorkaround: undefined,
|
|
99
|
-
recoveryHint: freshSessionRecoveryHint(recoveryArgs, "The requested site compatibility user agent is launch-scoped and needs a fresh browser session."),
|
|
100
|
-
validationError: explicit
|
|
101
|
-
? 'The current extension-managed agent-browser session is already running without the user agent required by this site. Remove the explicit `--session` and retry with `sessionMode: "fresh"` so the compatibility user agent is applied at launch.'
|
|
102
|
-
: 'The current extension-managed agent-browser session is already running without the user agent required by this site. Retry this call with `sessionMode: "fresh"` so the compatibility user agent is applied at launch.',
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
return { ...prior, compatibilityWorkaround: requested ?? existing };
|
|
106
|
-
}
|
|
107
|
-
function inspectionPlan(args, commandInfo, startupScopedFlags) {
|
|
108
|
-
const explicitNamespacePresent = scanUpstreamGlobalFlagOccurrences(args, "--namespace").length > 0;
|
|
109
|
-
return {
|
|
110
|
-
commandInfo,
|
|
111
|
-
effectiveArgs: [...args],
|
|
112
|
-
namespace: explicitNamespacePresent ? (extractExplicitNamespace(args) ?? "") : undefined,
|
|
113
|
-
plainTextInspection: true,
|
|
114
|
-
startupScopedFlags,
|
|
115
|
-
usedImplicitSession: false,
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
export function buildExecutionPlan(inputArgs, options) {
|
|
119
|
-
const args = withNativeSession(inputArgs);
|
|
120
|
-
const startupScopedFlags = effectiveStartupFlags(args, options.managedSessionNamespace);
|
|
121
|
-
const descriptor = parseArgvDescriptor(args);
|
|
122
|
-
const commandInfo = descriptor.commandInfo;
|
|
123
|
-
if (isPlainTextInspectionArgs(args)) {
|
|
124
|
-
return inspectionPlan(args, commandInfo, startupScopedFlags);
|
|
125
|
-
}
|
|
126
|
-
const failure = planningFailure(args);
|
|
127
|
-
if (failure) {
|
|
128
|
-
return failure;
|
|
129
|
-
}
|
|
130
|
-
const needsSession = options.browserIndependentReadConfirmation !== true &&
|
|
131
|
-
needsManagedSession(descriptor, options.stdin);
|
|
132
|
-
const selection = selectExecutionSession(args, options, {
|
|
133
|
-
command: commandInfo.command,
|
|
134
|
-
needsManagedSession: needsSession,
|
|
135
|
-
startupScopedFlags,
|
|
136
|
-
});
|
|
137
|
-
const activeTarget = targetsActiveManagedSession(selection, options, needsSession);
|
|
138
|
-
const requested = getCompatibilityWorkaround(args, commandInfo);
|
|
139
|
-
const recovery = activeTarget
|
|
140
|
-
? activeLaunchRecovery(args, startupScopedFlags, commandInfo.command, selection)
|
|
141
|
-
: selection;
|
|
142
|
-
const compatibility = activeTarget
|
|
143
|
-
? activeCompatibilityPlan(args, requested, options.managedSessionCompatibilityWorkaround, recovery)
|
|
144
|
-
: { ...recovery, compatibilityWorkaround: requested };
|
|
145
|
-
const effectiveArgs = [...jsonPrefix(args), ...selection.prefixArgs];
|
|
146
|
-
if (compatibility.compatibilityWorkaround && !activeTarget) {
|
|
147
|
-
effectiveArgs.push("--user-agent", getDefaultHeadlessCompatUserAgent());
|
|
148
|
-
}
|
|
149
|
-
effectiveArgs.push(...selection.argsToAppend);
|
|
150
|
-
return {
|
|
151
|
-
commandInfo,
|
|
152
|
-
compatibilityWorkaround: compatibility.compatibilityWorkaround,
|
|
153
|
-
effectiveArgs,
|
|
154
|
-
managedSessionName: selection.managedSessionName,
|
|
155
|
-
namespace: selection.namespace,
|
|
156
|
-
plainTextInspection: false,
|
|
157
|
-
recoveryHint: compatibility.recoveryHint,
|
|
158
|
-
sessionName: selection.sessionName,
|
|
159
|
-
startupScopedFlags,
|
|
160
|
-
usedImplicitSession: selection.usedImplicitSession,
|
|
161
|
-
validationError: compatibility.validationError,
|
|
162
|
-
};
|
|
163
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
const SESSION_COMPONENT_ALPHANUMERIC = /^[\p{Alphabetic}\p{Number}]$/u;
|
|
2
|
-
/** Mirror upstream sanitize_session_component for namespace/socket/state identity. */
|
|
3
|
-
export function canonicalizeAgentBrowserNamespace(value) {
|
|
4
|
-
if (value === undefined) {
|
|
5
|
-
return undefined;
|
|
6
|
-
}
|
|
7
|
-
let normalized = "";
|
|
8
|
-
let lastWasSeparator = false;
|
|
9
|
-
for (const character of value) {
|
|
10
|
-
if (SESSION_COMPONENT_ALPHANUMERIC.test(character)) {
|
|
11
|
-
normalized += character.toLowerCase();
|
|
12
|
-
lastWasSeparator = false;
|
|
13
|
-
continue;
|
|
14
|
-
}
|
|
15
|
-
if (normalized.length > 0 && !lastWasSeparator) {
|
|
16
|
-
normalized += character === "_" ? "_" : "-";
|
|
17
|
-
lastWasSeparator = true;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
const result = normalized.replace(/[-_]+$/u, "");
|
|
21
|
-
return result.length > 0 ? result : undefined;
|
|
22
|
-
}
|
|
23
|
-
export function foldAgentBrowserFilesystemIdentity(value, platform) {
|
|
24
|
-
if (platform !== "darwin" && platform !== "win32") {
|
|
25
|
-
return value;
|
|
26
|
-
}
|
|
27
|
-
// APFS aliases include full Unicode folds such as ß/SS and ς/Σ, not just ASCII case.
|
|
28
|
-
return value.normalize("NFC").toLowerCase().toUpperCase().toLowerCase().normalize("NFC");
|
|
29
|
-
}
|
|
30
|
-
export function getAgentBrowserSessionIdentityKey(sessionName, namespace, platform = process.platform) {
|
|
31
|
-
const canonicalNamespace = canonicalizeAgentBrowserNamespace(namespace);
|
|
32
|
-
const canonicalSessionName = foldAgentBrowserFilesystemIdentity(sessionName, platform);
|
|
33
|
-
return canonicalNamespace !== undefined
|
|
34
|
-
? `${foldAgentBrowserFilesystemIdentity(canonicalNamespace, platform)}\0${canonicalSessionName}`
|
|
35
|
-
: canonicalSessionName;
|
|
36
|
-
}
|
|
37
|
-
export function isAgentBrowserSessionIdentityKeyInNamespace(identityKey, namespace) {
|
|
38
|
-
const prefix = getAgentBrowserSessionIdentityKey("", namespace);
|
|
39
|
-
return prefix.length > 0 ? identityKey.startsWith(prefix) : !identityKey.includes("\0");
|
|
40
|
-
}
|
|
41
|
-
/** Namespace close retires keys in the caller's ownership index, not a copy. */
|
|
42
|
-
export function deleteIdentityKeysInNamespace(
|
|
43
|
-
// Caller-owned identity indexes deliberately mutate under the namespace execution barrier.
|
|
44
|
-
// oxlint-disable-next-line typescript/prefer-readonly-parameter-types
|
|
45
|
-
entries, namespace) {
|
|
46
|
-
for (const key of entries.keys()) {
|
|
47
|
-
if (isAgentBrowserSessionIdentityKeyInNamespace(key, namespace)) {
|
|
48
|
-
entries.delete(key);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,357 +0,0 @@
|
|
|
1
|
-
import { browserStringArray } from "./browser-value-parsing.js";
|
|
2
|
-
import { extractUpstreamCommandTokens } from "./argv-descriptor.js";
|
|
3
|
-
import { getAgentBrowserSessionIdentityKey } from "./argv-grammar.js";
|
|
4
|
-
import { isCloseCommand, isOpenNavigationCommand, isReadOnlyDiagnosticSessionTargetCommand, isRecordPageTransitionCommand, isUnverifiedPageTransitionCommand, isWebMcpPageMutationCommand, isWindowOrDiffPageTransitionCommand, } from "./command-taxonomy.js";
|
|
5
|
-
import { isRecord } from "./parsing.js";
|
|
6
|
-
import { detectConfirmationRequired } from "./results/confirmation.js";
|
|
7
|
-
import { isSuccessfulNativeConfirmedClose } from "./read-confirmation.js";
|
|
8
|
-
import { getEditableRefEvidence } from "./results/editable-ref-evidence.js";
|
|
9
|
-
import { enrichSnapshotRefEntries, getFullSnapshotData, getSnapshotRefEntries, } from "./results/snapshot-refs.js";
|
|
10
|
-
import { parseSnapshotLines } from "./results/snapshot-segments.js";
|
|
11
|
-
export function normalizeComparableUrl(url) {
|
|
12
|
-
const normalizedUrl = url?.trim();
|
|
13
|
-
if (normalizedUrl === undefined || normalizedUrl.length === 0) {
|
|
14
|
-
return undefined;
|
|
15
|
-
}
|
|
16
|
-
try {
|
|
17
|
-
const parsedUrl = new URL(normalizedUrl);
|
|
18
|
-
parsedUrl.hash = "";
|
|
19
|
-
return parsedUrl.toString();
|
|
20
|
-
}
|
|
21
|
-
catch {
|
|
22
|
-
return undefined;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function trimmedOptionalValue(value) {
|
|
26
|
-
const trimmed = value?.trim();
|
|
27
|
-
return trimmed !== undefined && trimmed.length > 0 ? trimmed : undefined;
|
|
28
|
-
}
|
|
29
|
-
export function normalizeSessionTabTarget(target) {
|
|
30
|
-
if (!target) {
|
|
31
|
-
return undefined;
|
|
32
|
-
}
|
|
33
|
-
const url = trimmedOptionalValue(target.url);
|
|
34
|
-
if (url === undefined || normalizeComparableUrl(url) === undefined) {
|
|
35
|
-
return undefined;
|
|
36
|
-
}
|
|
37
|
-
const targetId = trimmedOptionalValue(target.targetId);
|
|
38
|
-
return {
|
|
39
|
-
...(targetId !== undefined ? { targetId } : {}),
|
|
40
|
-
title: trimmedOptionalValue(target.title),
|
|
41
|
-
url,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
export function isAboutBlankUrl(url) {
|
|
45
|
-
return normalizeComparableUrl(url) === "about:blank";
|
|
46
|
-
}
|
|
47
|
-
export function isAboutBlankSessionTabTarget(target) {
|
|
48
|
-
return isAboutBlankUrl(target?.url);
|
|
49
|
-
}
|
|
50
|
-
export function commandExplicitlyTargetsAboutBlank(commandTokens) {
|
|
51
|
-
return ((commandTokens[0] === "window" && commandTokens[1] === "new") ||
|
|
52
|
-
commandTokens.some((token) => isAboutBlankUrl(token)));
|
|
53
|
-
}
|
|
54
|
-
export function targetsMatch(left, right) {
|
|
55
|
-
if (!left || !right) {
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
return normalizeComparableUrl(left.url) === normalizeComparableUrl(right.url);
|
|
59
|
-
}
|
|
60
|
-
function extractStringResultField(data, fieldName) {
|
|
61
|
-
if (typeof data === "string") {
|
|
62
|
-
if (fieldName === "value") {
|
|
63
|
-
return data;
|
|
64
|
-
}
|
|
65
|
-
const text = data.trim();
|
|
66
|
-
return text.length > 0 ? text : undefined;
|
|
67
|
-
}
|
|
68
|
-
if (!isRecord(data) || typeof data[fieldName] !== "string") {
|
|
69
|
-
return undefined;
|
|
70
|
-
}
|
|
71
|
-
if (fieldName === "value") {
|
|
72
|
-
return data[fieldName];
|
|
73
|
-
}
|
|
74
|
-
const text = data[fieldName].trim();
|
|
75
|
-
return text.length > 0 ? text : undefined;
|
|
76
|
-
}
|
|
77
|
-
function extractSessionTabTargetFromData(data) {
|
|
78
|
-
const directTarget = normalizeSessionTabTarget({
|
|
79
|
-
targetId: isRecord(data) && typeof data.targetId === "string" ? data.targetId : undefined,
|
|
80
|
-
title: extractStringResultField(data, "title"),
|
|
81
|
-
url: extractStringResultField(data, "url"),
|
|
82
|
-
});
|
|
83
|
-
if (directTarget) {
|
|
84
|
-
return directTarget;
|
|
85
|
-
}
|
|
86
|
-
if (isRecord(data) && typeof data.origin === "string") {
|
|
87
|
-
return normalizeSessionTabTarget({ url: data.origin });
|
|
88
|
-
}
|
|
89
|
-
return undefined;
|
|
90
|
-
}
|
|
91
|
-
function extractBatchResultCommand(item) {
|
|
92
|
-
return browserStringArray(item.command);
|
|
93
|
-
}
|
|
94
|
-
function confirmedNavigationResult(command, data) {
|
|
95
|
-
if (command === "confirm" &&
|
|
96
|
-
isRecord(data) &&
|
|
97
|
-
data.confirmed === true &&
|
|
98
|
-
(data.action === "navigate" || data.action === "url") &&
|
|
99
|
-
isRecord(data.result) &&
|
|
100
|
-
data.result.success === true &&
|
|
101
|
-
!detectConfirmationRequired(data)) {
|
|
102
|
-
return data.result;
|
|
103
|
-
}
|
|
104
|
-
return undefined;
|
|
105
|
-
}
|
|
106
|
-
export function extractSessionTabTargetFromCommandData(commandTokens, data) {
|
|
107
|
-
const [command, subcommand] = commandTokens;
|
|
108
|
-
const confirmed = confirmedNavigationResult(command, data);
|
|
109
|
-
if (confirmed) {
|
|
110
|
-
return extractSessionTabTargetFromData(confirmed.data);
|
|
111
|
-
}
|
|
112
|
-
if (command === "get" && subcommand === "url") {
|
|
113
|
-
return normalizeSessionTabTarget({
|
|
114
|
-
url: extractStringResultField(data, "url") ?? extractStringResultField(data, "result"),
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
return isReadOnlyDiagnosticSessionTargetCommand(command, subcommand)
|
|
118
|
-
? undefined
|
|
119
|
-
: extractSessionTabTargetFromData(data);
|
|
120
|
-
}
|
|
121
|
-
class BatchTargetObservation {
|
|
122
|
-
target;
|
|
123
|
-
pendingTitle;
|
|
124
|
-
observe(item) {
|
|
125
|
-
if (detectConfirmationRequired(item.result)) {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
// Only this native row can describe the active tab's identity.
|
|
129
|
-
if (this.target?.targetId !== undefined && this.target.targetId.length > 0) {
|
|
130
|
-
this.target = normalizeSessionTabTarget({ title: this.target.title, url: this.target.url });
|
|
131
|
-
}
|
|
132
|
-
const tokens = extractUpstreamCommandTokens(extractBatchResultCommand(item));
|
|
133
|
-
this.invalidateTransition(tokens);
|
|
134
|
-
if (item.success === false) {
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
this.observeResult(tokens, item.result);
|
|
138
|
-
}
|
|
139
|
-
invalidateTransition(tokens) {
|
|
140
|
-
const [name, subcommand] = tokens;
|
|
141
|
-
if (isOpenNavigationCommand(name) ||
|
|
142
|
-
isUnverifiedPageTransitionCommand(name, subcommand) ||
|
|
143
|
-
(name === "click" && tokens.includes("--new-tab"))) {
|
|
144
|
-
this.target = undefined;
|
|
145
|
-
this.pendingTitle = undefined;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
observeResult(tokens, result) {
|
|
149
|
-
const [name, subcommand] = tokens;
|
|
150
|
-
if (isCloseCommand(name) || isSuccessfulNativeConfirmedClose(tokens, result)) {
|
|
151
|
-
this.target = undefined;
|
|
152
|
-
this.pendingTitle = undefined;
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
if (name === "get" && subcommand === "title") {
|
|
156
|
-
this.pendingTitle = extractStringResultField(result, "title");
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
if (name === "get" && subcommand === "url") {
|
|
160
|
-
const target = normalizeSessionTabTarget({
|
|
161
|
-
title: this.pendingTitle,
|
|
162
|
-
url: extractStringResultField(result, "url"),
|
|
163
|
-
});
|
|
164
|
-
if (target) {
|
|
165
|
-
this.target = target;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
const target = extractSessionTabTargetFromCommandData(tokens.slice(0, 2), result);
|
|
170
|
-
if (target) {
|
|
171
|
-
this.target = target;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
this.pendingTitle = undefined;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
export function extractSessionTabTargetFromBatchResults(data) {
|
|
178
|
-
if (!Array.isArray(data)) {
|
|
179
|
-
return undefined;
|
|
180
|
-
}
|
|
181
|
-
const observation = new BatchTargetObservation();
|
|
182
|
-
for (const item of data) {
|
|
183
|
-
if (isRecord(item)) {
|
|
184
|
-
observation.observe(item);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
return observation.target;
|
|
188
|
-
}
|
|
189
|
-
export function deriveSessionTabTarget(options) {
|
|
190
|
-
if (isCloseCommand(options.command)) {
|
|
191
|
-
return undefined;
|
|
192
|
-
}
|
|
193
|
-
const commandDataTarget = extractSessionTabTargetFromCommandData([options.command, options.subcommand].filter((token) => token !== undefined), options.data);
|
|
194
|
-
const observedTarget = normalizeSessionTabTarget(options.navigationSummary) ??
|
|
195
|
-
extractSessionTabTargetFromBatchResults(options.data) ??
|
|
196
|
-
commandDataTarget;
|
|
197
|
-
if (observedTarget || !isUnverifiedPageTransitionCommand(options.command, options.subcommand)) {
|
|
198
|
-
return observedTarget ?? options.previousTarget;
|
|
199
|
-
}
|
|
200
|
-
return undefined;
|
|
201
|
-
}
|
|
202
|
-
function extractRefSnapshotRefs(data) {
|
|
203
|
-
if (!isRecord(data) || !isRecord(data.refs)) {
|
|
204
|
-
return undefined;
|
|
205
|
-
}
|
|
206
|
-
const snapshotLines = typeof data.snapshot === "string" ? parseSnapshotLines(data.snapshot) : [];
|
|
207
|
-
const lineByRef = new Map(snapshotLines.flatMap((line) => line.ref !== undefined && line.ref.length > 0 ? [[line.ref, line.raw]] : []));
|
|
208
|
-
const entries = enrichSnapshotRefEntries(getSnapshotRefEntries(data), snapshotLines);
|
|
209
|
-
const refs = Object.fromEntries(entries.flatMap((entry) => {
|
|
210
|
-
if (!/^e\d+$/.test(entry.id) || entry.role.length === 0) {
|
|
211
|
-
return [];
|
|
212
|
-
}
|
|
213
|
-
const isContentEditable = getEditableRefEvidence({
|
|
214
|
-
ref: entry.refData,
|
|
215
|
-
text: lineByRef.get(entry.id),
|
|
216
|
-
});
|
|
217
|
-
return [
|
|
218
|
-
[
|
|
219
|
-
entry.id,
|
|
220
|
-
{
|
|
221
|
-
...(isContentEditable === true ? { isContentEditable: true } : {}),
|
|
222
|
-
...(entry.isEditable !== undefined ? { isEditable: entry.isEditable } : {}),
|
|
223
|
-
name: entry.name,
|
|
224
|
-
role: entry.role,
|
|
225
|
-
},
|
|
226
|
-
],
|
|
227
|
-
];
|
|
228
|
-
}));
|
|
229
|
-
return Object.keys(refs).length > 0 ? refs : undefined;
|
|
230
|
-
}
|
|
231
|
-
export function extractRefSnapshotFromData(value) {
|
|
232
|
-
if (detectConfirmationRequired(value)) {
|
|
233
|
-
return undefined;
|
|
234
|
-
}
|
|
235
|
-
const data = getFullSnapshotData(value);
|
|
236
|
-
if (!data) {
|
|
237
|
-
return undefined;
|
|
238
|
-
}
|
|
239
|
-
const refs = extractRefSnapshotRefs(data);
|
|
240
|
-
return {
|
|
241
|
-
refIds: isRecord(data.refs)
|
|
242
|
-
? Object.keys(data.refs).filter((refId) => /^e\d+$/.test(refId))
|
|
243
|
-
: [],
|
|
244
|
-
...(refs ? { refs } : {}),
|
|
245
|
-
target: extractSessionTabTargetFromData(data),
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
function getBatchResultFailureText(item) {
|
|
249
|
-
const result = isRecord(item.result) ? item.result : undefined;
|
|
250
|
-
const parts = [
|
|
251
|
-
item.error,
|
|
252
|
-
result?.error,
|
|
253
|
-
typeof item.result === "string" ? item.result : undefined,
|
|
254
|
-
].filter((part) => typeof part === "string" && part.trim().length > 0);
|
|
255
|
-
return parts.length > 0 ? parts.join("\n") : undefined;
|
|
256
|
-
}
|
|
257
|
-
export function buildNoActivePageRefSnapshotInvalidation() {
|
|
258
|
-
return {
|
|
259
|
-
reason: "no-active-page",
|
|
260
|
-
summary: "The latest snapshot for this session reported No active page. Old page-scoped refs are invalid until snapshot -i succeeds.",
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
export function buildPageTransitionRefSnapshotInvalidation(summary) {
|
|
264
|
-
return {
|
|
265
|
-
reason: "page-transition",
|
|
266
|
-
summary: summary ??
|
|
267
|
-
"Recording starts and URL-bearing restarts conservatively invalidate earlier page-scoped refs. Run snapshot -i before using refs; this is not evidence of a page change.",
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
export function getCommandRefSnapshotInvalidation(commandTokens) {
|
|
271
|
-
if (isRecordPageTransitionCommand(commandTokens)) {
|
|
272
|
-
return buildPageTransitionRefSnapshotInvalidation();
|
|
273
|
-
}
|
|
274
|
-
if (isWindowOrDiffPageTransitionCommand(commandTokens[0], commandTokens[1])) {
|
|
275
|
-
return buildPageTransitionRefSnapshotInvalidation("A window new or diff url command replaced or navigated the active page and invalidated prior refs. Run snapshot -i before using page-scoped refs.");
|
|
276
|
-
}
|
|
277
|
-
if (isWebMcpPageMutationCommand(commandTokens)) {
|
|
278
|
-
return buildPageTransitionRefSnapshotInvalidation("A WebMCP invoke, result, or cancel command can mutate, rerender, or navigate the page, so the prior snapshot refs were invalidated. Run snapshot -i before using page-scoped refs.");
|
|
279
|
-
}
|
|
280
|
-
return undefined;
|
|
281
|
-
}
|
|
282
|
-
export function isNoActivePageSnapshotFailure(command, text) {
|
|
283
|
-
return command === "snapshot" && /\bno active page\b/i.test(text ?? "");
|
|
284
|
-
}
|
|
285
|
-
function batchResultClosed(item, tokens) {
|
|
286
|
-
return (item.success !== false &&
|
|
287
|
-
!detectConfirmationRequired(item.result) &&
|
|
288
|
-
(isCloseCommand(tokens[0]) || isSuccessfulNativeConfirmedClose(tokens, item.result)));
|
|
289
|
-
}
|
|
290
|
-
function nextBatchRefState(item, previous) {
|
|
291
|
-
const tokens = extractUpstreamCommandTokens(extractBatchResultCommand(item));
|
|
292
|
-
if (batchResultClosed(item, tokens)) {
|
|
293
|
-
return undefined;
|
|
294
|
-
}
|
|
295
|
-
const invalidation = getCommandRefSnapshotInvalidation(tokens);
|
|
296
|
-
if (invalidation) {
|
|
297
|
-
return { invalidation };
|
|
298
|
-
}
|
|
299
|
-
if (tokens[0] !== "snapshot") {
|
|
300
|
-
return previous;
|
|
301
|
-
}
|
|
302
|
-
if (item.success === false) {
|
|
303
|
-
return isNoActivePageSnapshotFailure(tokens[0], getBatchResultFailureText(item))
|
|
304
|
-
? { invalidation: buildNoActivePageRefSnapshotInvalidation() }
|
|
305
|
-
: previous;
|
|
306
|
-
}
|
|
307
|
-
const snapshot = extractRefSnapshotFromData(item.result);
|
|
308
|
-
if (snapshot) {
|
|
309
|
-
return { snapshot };
|
|
310
|
-
}
|
|
311
|
-
if (isRecord(item.result) && isRecord(item.result.snapshot)) {
|
|
312
|
-
return { refreshArgs: tokens.filter((token) => token !== "--delta" && token !== "--full") };
|
|
313
|
-
}
|
|
314
|
-
return previous;
|
|
315
|
-
}
|
|
316
|
-
export function extractLatestRefSnapshotStateFromBatchResults(data) {
|
|
317
|
-
if (!Array.isArray(data)) {
|
|
318
|
-
return undefined;
|
|
319
|
-
}
|
|
320
|
-
let latest;
|
|
321
|
-
for (const item of data) {
|
|
322
|
-
if (isRecord(item)) {
|
|
323
|
-
latest = nextBatchRefState(item, latest);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
return latest;
|
|
327
|
-
}
|
|
328
|
-
export function shouldApplyTabTargetUpdate(current, unknownOrder, updateOrder) {
|
|
329
|
-
return updateOrder >= Math.max(current?.order ?? 0, unknownOrder ?? 0);
|
|
330
|
-
}
|
|
331
|
-
export function shouldApplyRefStateUpdate(options) {
|
|
332
|
-
const currentOrder = Math.max(options.currentSnapshot?.order ?? 0, options.currentInvalidation?.order ?? 0);
|
|
333
|
-
return options.updateOrder >= currentOrder;
|
|
334
|
-
}
|
|
335
|
-
export function stripRefSnapshotOrder(snapshot) {
|
|
336
|
-
return snapshot
|
|
337
|
-
? {
|
|
338
|
-
...(snapshot.snapshotId !== undefined && snapshot.snapshotId.length > 0
|
|
339
|
-
? { snapshotId: snapshot.snapshotId }
|
|
340
|
-
: {}),
|
|
341
|
-
...(snapshot.generation !== undefined && snapshot.generation.length > 0
|
|
342
|
-
? { generation: snapshot.generation }
|
|
343
|
-
: {}),
|
|
344
|
-
refIds: snapshot.refIds,
|
|
345
|
-
...(snapshot.refs ? { refs: snapshot.refs } : {}),
|
|
346
|
-
target: snapshot.target,
|
|
347
|
-
}
|
|
348
|
-
: undefined;
|
|
349
|
-
}
|
|
350
|
-
export function stripRefSnapshotInvalidationOrder(invalidation) {
|
|
351
|
-
return invalidation ? { reason: invalidation.reason, summary: invalidation.summary } : undefined;
|
|
352
|
-
}
|
|
353
|
-
export function getSessionPageStateKey(sessionName, namespace) {
|
|
354
|
-
return sessionName !== undefined && sessionName.length > 0
|
|
355
|
-
? getAgentBrowserSessionIdentityKey(sessionName, namespace)
|
|
356
|
-
: undefined;
|
|
357
|
-
}
|