pi-agent-browser-native 0.9.4 → 0.9.6
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 +48 -0
- package/README.md +60 -812
- package/dist/extensions/agent-browser/index.js +2381 -1706
- package/dist/packaged/lib/browser-session-conversion.js +2810 -0
- package/dist/packaged/lib/config-policy.js +599 -0
- package/dist/packaged/lib/parsing.js +34 -0
- package/dist/packaged/lib/playbook.js +694 -0
- package/dist/packaged/lib/results/snapshot.js +2671 -0
- package/dist/packaged/lib/runtime.js +3027 -0
- package/docs/ARCHITECTURE.md +14 -3
- package/docs/CODE_QUALITY.md +39 -3
- package/docs/COMMAND_REFERENCE.md +22 -22
- package/docs/ELECTRON.md +24 -2
- package/docs/PERFORMANCE.md +243 -0
- package/docs/REFERENCE.md +869 -0
- package/docs/RELEASE.md +9 -9
- package/docs/REQUIREMENTS.md +1 -1
- package/docs/SESSION_STORAGE.md +11 -3
- package/docs/SUPPORT_MATRIX.md +16 -11
- package/docs/TOOL_CONTRACT.md +17 -13
- package/docs/performance/2026-10-12.json +7257 -0
- package/docs/platform-smoke.md +3 -3
- package/package.json +15 -3
- package/scripts/build.mjs +16 -5
- package/scripts/config.mjs +24 -20
- package/scripts/convert-browser-session.mjs +1 -1
- package/scripts/doctor.mjs +2 -2
- package/scripts/platform-smoke/lease-evidence.mjs +2 -4
- package/scripts/platform-smoke/linux-image/Dockerfile +8 -2
- package/scripts/platform-smoke/targets.mjs +1 -5
- 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 -218
- package/dist/extensions/agent-browser/lib/config.js +0 -69
- package/dist/extensions/agent-browser/lib/electron/cdp.js +0 -58
- package/dist/extensions/agent-browser/lib/electron/cleanup.js +0 -308
- 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 -89
- 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 -329
- 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 -18
- package/dist/extensions/agent-browser/lib/input-modes/electron.js +0 -201
- package/dist/extensions/agent-browser/lib/input-modes/job.js +0 -195
- package/dist/extensions/agent-browser/lib/input-modes/lookup-network-evidence.js +0 -104
- 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 -83
- 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 -202
- 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 -179
- 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 -165
- 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 -210
- 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 -171
- 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 -92
- 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 -69
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-data.js +0 -167
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-presentation.js +0 -164
- 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 -165
- 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 -178
- 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 -78
- 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 -207
- 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 -229
- package/dist/extensions/agent-browser/lib/web-search-request.js +0 -108
- 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 -149
- 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
|
@@ -0,0 +1,3027 @@
|
|
|
1
|
+
// dist/extensions/agent-browser/lib/command-capabilities.js
|
|
2
|
+
var ADDITIONAL_COMMAND_TOKENS = [
|
|
3
|
+
"a11y",
|
|
4
|
+
"auth",
|
|
5
|
+
"chat",
|
|
6
|
+
"clipboard",
|
|
7
|
+
"confirm",
|
|
8
|
+
"connect",
|
|
9
|
+
"dashboard",
|
|
10
|
+
"deny",
|
|
11
|
+
"device",
|
|
12
|
+
"dialog",
|
|
13
|
+
"diff",
|
|
14
|
+
"doctor",
|
|
15
|
+
"errors",
|
|
16
|
+
"eval",
|
|
17
|
+
"find",
|
|
18
|
+
"frame",
|
|
19
|
+
"get",
|
|
20
|
+
"highlight",
|
|
21
|
+
"inspect",
|
|
22
|
+
"install",
|
|
23
|
+
"is",
|
|
24
|
+
"mcp",
|
|
25
|
+
"plugin",
|
|
26
|
+
"plugins",
|
|
27
|
+
"profiles",
|
|
28
|
+
"profiler",
|
|
29
|
+
"react",
|
|
30
|
+
"record",
|
|
31
|
+
"removeinitscript",
|
|
32
|
+
"session",
|
|
33
|
+
"set",
|
|
34
|
+
"skills",
|
|
35
|
+
"snapshot",
|
|
36
|
+
"state",
|
|
37
|
+
"stream",
|
|
38
|
+
"trace",
|
|
39
|
+
"upgrade",
|
|
40
|
+
"vitals",
|
|
41
|
+
"wait",
|
|
42
|
+
"web-vitals",
|
|
43
|
+
"webmcp",
|
|
44
|
+
"window"
|
|
45
|
+
];
|
|
46
|
+
var COMMAND_CAPABILITIES = [
|
|
47
|
+
{
|
|
48
|
+
command: "back",
|
|
49
|
+
eligibleForElectronHealthProbe: true,
|
|
50
|
+
eligibleForPageChangeSummary: true,
|
|
51
|
+
invalidatesBatchRefs: true,
|
|
52
|
+
navigationObservable: true,
|
|
53
|
+
triggersPostMutationSnapshot: true
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
command: "batch",
|
|
57
|
+
excludedFromPostCommandCorrection: true
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
command: "check",
|
|
61
|
+
eligibleForElectronHealthProbe: true,
|
|
62
|
+
eligibleForPageChangeSummary: true,
|
|
63
|
+
guardsPageRefs: true,
|
|
64
|
+
invalidatesBatchRefs: true,
|
|
65
|
+
triggersPostMutationSnapshot: true
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
command: "click",
|
|
69
|
+
eligibleForElectronHealthProbe: true,
|
|
70
|
+
eligibleForPageChangeSummary: true,
|
|
71
|
+
guardsPageRefs: true,
|
|
72
|
+
invalidatesBatchRefs: true,
|
|
73
|
+
navigationObservable: true,
|
|
74
|
+
triggersPostMutationSnapshot: true
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
aliases: ["quit", "exit"],
|
|
78
|
+
closesSession: true,
|
|
79
|
+
command: "close",
|
|
80
|
+
excludedFromPinning: true,
|
|
81
|
+
excludedFromPostCommandCorrection: true
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
command: "console",
|
|
85
|
+
readOnlyDiagnosticSessionTarget: true
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
command: "cookies",
|
|
89
|
+
readOnlyDiagnosticSessionTarget: true
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
command: "dblclick",
|
|
93
|
+
eligibleForElectronHealthProbe: true,
|
|
94
|
+
eligibleForPageChangeSummary: true,
|
|
95
|
+
guardsPageRefs: true,
|
|
96
|
+
invalidatesBatchRefs: true,
|
|
97
|
+
navigationObservable: true,
|
|
98
|
+
triggersPostMutationSnapshot: true
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
command: "dialog",
|
|
102
|
+
eligibleForPageChangeSummary: true,
|
|
103
|
+
invalidatesBatchRefs: true,
|
|
104
|
+
triggersPostMutationSnapshot: true
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
command: "diff",
|
|
108
|
+
guardsPageRefs: true
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
command: "download",
|
|
112
|
+
eligibleForPageChangeSummary: true,
|
|
113
|
+
guardsPageRefs: true
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
command: "drag",
|
|
117
|
+
guardsPageRefs: true,
|
|
118
|
+
invalidatesBatchRefs: true
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
command: "errors",
|
|
122
|
+
readOnlyDiagnosticSessionTarget: true
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
command: "eval",
|
|
126
|
+
invalidatesBatchRefs: true,
|
|
127
|
+
navigationObservable: true,
|
|
128
|
+
triggersPostMutationSnapshot: true
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
command: "fill",
|
|
132
|
+
eligibleForElectronHealthProbe: true,
|
|
133
|
+
eligibleForPageChangeSummary: true,
|
|
134
|
+
guardsPageRefs: true,
|
|
135
|
+
triggersPostMutationSnapshot: true
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
command: "find",
|
|
139
|
+
eligibleForElectronHealthProbe: true
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
command: "frame",
|
|
143
|
+
guardsPageRefs: true
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
command: "focus",
|
|
147
|
+
guardsPageRefs: true
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
command: "forward",
|
|
151
|
+
eligibleForElectronHealthProbe: true,
|
|
152
|
+
eligibleForPageChangeSummary: true,
|
|
153
|
+
invalidatesBatchRefs: true,
|
|
154
|
+
navigationObservable: true,
|
|
155
|
+
triggersPostMutationSnapshot: true
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
command: "get",
|
|
159
|
+
guardsPageRefs: true
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
command: "highlight",
|
|
163
|
+
guardsPageRefs: true
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
command: "hover",
|
|
167
|
+
eligibleForPageChangeSummary: true,
|
|
168
|
+
guardsPageRefs: true,
|
|
169
|
+
invalidatesBatchRefs: true,
|
|
170
|
+
triggersPostMutationSnapshot: true
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
command: "is",
|
|
174
|
+
guardsPageRefs: true
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
command: "keydown",
|
|
178
|
+
eligibleForElectronHealthProbe: true,
|
|
179
|
+
eligibleForPageChangeSummary: true,
|
|
180
|
+
invalidatesBatchRefs: true,
|
|
181
|
+
triggersPostMutationSnapshot: true
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
command: "keyboard",
|
|
185
|
+
eligibleForElectronHealthProbe: true,
|
|
186
|
+
eligibleForPageChangeSummary: true,
|
|
187
|
+
invalidatesBatchRefs: true,
|
|
188
|
+
triggersPostMutationSnapshot: true
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
command: "keyup",
|
|
192
|
+
eligibleForElectronHealthProbe: true,
|
|
193
|
+
eligibleForPageChangeSummary: true,
|
|
194
|
+
invalidatesBatchRefs: true,
|
|
195
|
+
triggersPostMutationSnapshot: true
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
command: "mouse",
|
|
199
|
+
eligibleForElectronHealthProbe: true,
|
|
200
|
+
invalidatesBatchRefs: true
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
command: "network",
|
|
204
|
+
readOnlyDiagnosticSessionTarget: true
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
aliases: ["goto", "navigate"],
|
|
208
|
+
command: "open",
|
|
209
|
+
eligibleForPageChangeSummary: true,
|
|
210
|
+
excludedFromPinning: true,
|
|
211
|
+
invalidatesBatchRefs: true,
|
|
212
|
+
openNavigation: true
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
command: "pdf",
|
|
216
|
+
eligibleForPageChangeSummary: true
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
aliases: ["key"],
|
|
220
|
+
command: "press",
|
|
221
|
+
eligibleForElectronHealthProbe: true,
|
|
222
|
+
eligibleForPageChangeSummary: true,
|
|
223
|
+
invalidatesBatchRefs: true,
|
|
224
|
+
triggersPostMutationSnapshot: true
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
command: "pushstate",
|
|
228
|
+
eligibleForPageChangeSummary: true,
|
|
229
|
+
invalidatesBatchRefs: true,
|
|
230
|
+
triggersPostMutationSnapshot: true
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
command: "reload",
|
|
234
|
+
eligibleForElectronHealthProbe: true,
|
|
235
|
+
eligibleForPageChangeSummary: true,
|
|
236
|
+
invalidatesBatchRefs: true,
|
|
237
|
+
navigationObservable: true,
|
|
238
|
+
triggersPostMutationSnapshot: true
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
command: "read",
|
|
242
|
+
readOnlyDiagnosticSessionTarget: true
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
command: "screenshot",
|
|
246
|
+
eligibleForPageChangeSummary: true,
|
|
247
|
+
guardsPageRefs: true
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
command: "scroll",
|
|
251
|
+
eligibleForPageChangeSummary: true,
|
|
252
|
+
guardsPageRefs: true,
|
|
253
|
+
invalidatesBatchRefs: true,
|
|
254
|
+
triggersPostMutationSnapshot: true
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
aliases: ["scrollinto"],
|
|
258
|
+
command: "scrollintoview",
|
|
259
|
+
eligibleForPageChangeSummary: true,
|
|
260
|
+
guardsPageRefs: true,
|
|
261
|
+
invalidatesBatchRefs: true,
|
|
262
|
+
triggersPostMutationSnapshot: true
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
command: "select",
|
|
266
|
+
eligibleForElectronHealthProbe: true,
|
|
267
|
+
eligibleForPageChangeSummary: true,
|
|
268
|
+
guardsPageRefs: true,
|
|
269
|
+
invalidatesBatchRefs: true,
|
|
270
|
+
triggersPostMutationSnapshot: true
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
command: "session",
|
|
274
|
+
excludedFromPinning: true,
|
|
275
|
+
excludedFromPostCommandCorrection: true
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
command: "storage",
|
|
279
|
+
readOnlyDiagnosticSessionTarget: true
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
command: "swipe",
|
|
283
|
+
eligibleForPageChangeSummary: true,
|
|
284
|
+
invalidatesBatchRefs: true,
|
|
285
|
+
triggersPostMutationSnapshot: true
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
command: "tab",
|
|
289
|
+
excludedFromPinning: true,
|
|
290
|
+
excludedFromPostCommandCorrection: true
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
command: "tap",
|
|
294
|
+
eligibleForElectronHealthProbe: true,
|
|
295
|
+
eligibleForPageChangeSummary: true,
|
|
296
|
+
guardsPageRefs: true,
|
|
297
|
+
invalidatesBatchRefs: true,
|
|
298
|
+
triggersPostMutationSnapshot: true
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
command: "type",
|
|
302
|
+
eligibleForElectronHealthProbe: true,
|
|
303
|
+
eligibleForPageChangeSummary: true,
|
|
304
|
+
guardsPageRefs: true,
|
|
305
|
+
invalidatesBatchRefs: true,
|
|
306
|
+
triggersPostMutationSnapshot: true
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
command: "uncheck",
|
|
310
|
+
eligibleForElectronHealthProbe: true,
|
|
311
|
+
eligibleForPageChangeSummary: true,
|
|
312
|
+
guardsPageRefs: true,
|
|
313
|
+
invalidatesBatchRefs: true,
|
|
314
|
+
triggersPostMutationSnapshot: true
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
command: "upload",
|
|
318
|
+
guardsPageRefs: true,
|
|
319
|
+
invalidatesBatchRefs: true
|
|
320
|
+
}
|
|
321
|
+
];
|
|
322
|
+
var COMMAND_CAPABILITY_BY_NAME = /* @__PURE__ */ new Map();
|
|
323
|
+
for (const entry of COMMAND_CAPABILITIES) {
|
|
324
|
+
COMMAND_CAPABILITY_BY_NAME.set(entry.command, entry);
|
|
325
|
+
for (const alias of entry.aliases ?? []) {
|
|
326
|
+
COMMAND_CAPABILITY_BY_NAME.set(alias, entry);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
var KNOWN_COMMAND_TOKENS = /* @__PURE__ */ new Set([
|
|
330
|
+
...COMMAND_CAPABILITY_BY_NAME.keys(),
|
|
331
|
+
...ADDITIONAL_COMMAND_TOKENS
|
|
332
|
+
]);
|
|
333
|
+
function isKnownCommandToken(token) {
|
|
334
|
+
return KNOWN_COMMAND_TOKENS.has(token);
|
|
335
|
+
}
|
|
336
|
+
function getCommandCapability(command) {
|
|
337
|
+
return command === void 0 ? void 0 : COMMAND_CAPABILITY_BY_NAME.get(command);
|
|
338
|
+
}
|
|
339
|
+
function hasCommandCapability(command, capability) {
|
|
340
|
+
return getCommandCapability(command)?.[capability] === true;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// dist/extensions/agent-browser/lib/command-taxonomy.js
|
|
344
|
+
function isCloseCommand(command) {
|
|
345
|
+
return hasCommandCapability(command, "closesSession");
|
|
346
|
+
}
|
|
347
|
+
function isCloseAllCommand(commandTokens) {
|
|
348
|
+
return isCloseCommand(commandTokens[0]) && commandTokens.slice(1).includes("--all");
|
|
349
|
+
}
|
|
350
|
+
function isOpenNavigationCommand(command) {
|
|
351
|
+
return hasCommandCapability(command, "openNavigation");
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// dist/extensions/agent-browser/lib/session-identity.js
|
|
355
|
+
var SESSION_COMPONENT_ALPHANUMERIC = /^[\p{Alphabetic}\p{Number}]$/u;
|
|
356
|
+
function canonicalizeAgentBrowserNamespace(value) {
|
|
357
|
+
if (value === void 0) {
|
|
358
|
+
return void 0;
|
|
359
|
+
}
|
|
360
|
+
let normalized = "";
|
|
361
|
+
let lastWasSeparator = false;
|
|
362
|
+
for (const character of value) {
|
|
363
|
+
if (SESSION_COMPONENT_ALPHANUMERIC.test(character)) {
|
|
364
|
+
normalized += character.toLowerCase();
|
|
365
|
+
lastWasSeparator = false;
|
|
366
|
+
continue;
|
|
367
|
+
}
|
|
368
|
+
if (normalized.length > 0 && !lastWasSeparator) {
|
|
369
|
+
normalized += character === "_" ? "_" : "-";
|
|
370
|
+
lastWasSeparator = true;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
const result = normalized.replace(/[-_]+$/u, "");
|
|
374
|
+
return result.length > 0 ? result : void 0;
|
|
375
|
+
}
|
|
376
|
+
function foldAgentBrowserFilesystemIdentity(value, platform) {
|
|
377
|
+
if (platform !== "darwin" && platform !== "win32") {
|
|
378
|
+
return value;
|
|
379
|
+
}
|
|
380
|
+
return value.normalize("NFC").toLowerCase().toUpperCase().toLowerCase().normalize("NFC");
|
|
381
|
+
}
|
|
382
|
+
function getAgentBrowserSessionIdentityKey(sessionName, namespace, platform = process.platform) {
|
|
383
|
+
const canonicalNamespace = canonicalizeAgentBrowserNamespace(namespace);
|
|
384
|
+
const canonicalSessionName = foldAgentBrowserFilesystemIdentity(sessionName, platform);
|
|
385
|
+
return canonicalNamespace !== void 0 ? `${foldAgentBrowserFilesystemIdentity(canonicalNamespace, platform)}\0${canonicalSessionName}` : canonicalSessionName;
|
|
386
|
+
}
|
|
387
|
+
function isAgentBrowserSessionIdentityKeyInNamespace(identityKey, namespace) {
|
|
388
|
+
const prefix = getAgentBrowserSessionIdentityKey("", namespace);
|
|
389
|
+
return prefix.length > 0 ? identityKey.startsWith(prefix) : !identityKey.includes("\0");
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// dist/extensions/agent-browser/lib/argv-grammar.js
|
|
393
|
+
var GLOBAL_VALUE_FLAGS = [
|
|
394
|
+
"--session",
|
|
395
|
+
"--namespace",
|
|
396
|
+
"--cdp",
|
|
397
|
+
"--config",
|
|
398
|
+
"--profile",
|
|
399
|
+
"--session-name",
|
|
400
|
+
"--restore-save",
|
|
401
|
+
"--restore-check-url",
|
|
402
|
+
"--restore-check-text",
|
|
403
|
+
"--restore-check-fn",
|
|
404
|
+
"--proxy",
|
|
405
|
+
"--proxy-bypass",
|
|
406
|
+
"--ca-cert",
|
|
407
|
+
"--headers",
|
|
408
|
+
"--executable-path",
|
|
409
|
+
"--extension",
|
|
410
|
+
"--init-script",
|
|
411
|
+
"--enable",
|
|
412
|
+
"--provider",
|
|
413
|
+
"-p",
|
|
414
|
+
"--engine",
|
|
415
|
+
"--state",
|
|
416
|
+
"--download-path",
|
|
417
|
+
"--screenshot-dir",
|
|
418
|
+
"--screenshot-format",
|
|
419
|
+
"--screenshot-quality",
|
|
420
|
+
"--color-scheme",
|
|
421
|
+
"--device",
|
|
422
|
+
"--args",
|
|
423
|
+
"--user-agent",
|
|
424
|
+
"--allowed-domains",
|
|
425
|
+
"--action-policy",
|
|
426
|
+
"--confirm-actions",
|
|
427
|
+
"--max-output",
|
|
428
|
+
"--model",
|
|
429
|
+
"--idle-timeout",
|
|
430
|
+
"--input-mode"
|
|
431
|
+
];
|
|
432
|
+
var COMMAND_VALUE_FLAGS = [
|
|
433
|
+
"--allowed-origins",
|
|
434
|
+
"--baseline",
|
|
435
|
+
"--body",
|
|
436
|
+
"--categories",
|
|
437
|
+
"--content",
|
|
438
|
+
"--curl",
|
|
439
|
+
"--depth",
|
|
440
|
+
"-d",
|
|
441
|
+
"--domain",
|
|
442
|
+
"--expires",
|
|
443
|
+
"--filter",
|
|
444
|
+
"--frame",
|
|
445
|
+
"--fn",
|
|
446
|
+
"--label",
|
|
447
|
+
"--load",
|
|
448
|
+
"--method",
|
|
449
|
+
"--name",
|
|
450
|
+
"--older-than",
|
|
451
|
+
"--output",
|
|
452
|
+
"--prefix",
|
|
453
|
+
"--path",
|
|
454
|
+
"--port",
|
|
455
|
+
"--params",
|
|
456
|
+
"--resource-type",
|
|
457
|
+
"--resource-types",
|
|
458
|
+
"--sameSite",
|
|
459
|
+
"--scope",
|
|
460
|
+
"--selector",
|
|
461
|
+
"-s",
|
|
462
|
+
"--status",
|
|
463
|
+
"--tags",
|
|
464
|
+
"--text",
|
|
465
|
+
"--threshold",
|
|
466
|
+
"--timeout",
|
|
467
|
+
"--type",
|
|
468
|
+
"--url",
|
|
469
|
+
"--username",
|
|
470
|
+
"--password",
|
|
471
|
+
"--wait-until"
|
|
472
|
+
];
|
|
473
|
+
var OPTIONAL_GLOBAL_VALUE_FLAGS = /* @__PURE__ */ new Set(["--restore"]);
|
|
474
|
+
var VALUE_FLAGS = /* @__PURE__ */ new Set([
|
|
475
|
+
...GLOBAL_VALUE_FLAGS,
|
|
476
|
+
...COMMAND_VALUE_FLAGS
|
|
477
|
+
]);
|
|
478
|
+
var PREVALIDATED_VALUE_FLAGS = new Set(GLOBAL_VALUE_FLAGS);
|
|
479
|
+
var GLOBAL_VALUE_FLAGS_ALLOWING_DASH_VALUE = /* @__PURE__ */ new Set([
|
|
480
|
+
"--args",
|
|
481
|
+
"--session"
|
|
482
|
+
]);
|
|
483
|
+
var GLOBAL_BOOLEAN_FLAGS_WITH_OPTIONAL_VALUES = /* @__PURE__ */ new Set([
|
|
484
|
+
"--allow-file-access",
|
|
485
|
+
"--annotate",
|
|
486
|
+
"--auto-connect",
|
|
487
|
+
"--confirm-interactive",
|
|
488
|
+
"--content-boundaries",
|
|
489
|
+
"--debug",
|
|
490
|
+
"--headed",
|
|
491
|
+
"--hide-scrollbars",
|
|
492
|
+
"--ignore-https-errors",
|
|
493
|
+
"--json",
|
|
494
|
+
"--no-auto-dialog",
|
|
495
|
+
"--no-ca-cert",
|
|
496
|
+
"--no-pin-tab",
|
|
497
|
+
"--no-webmcp",
|
|
498
|
+
"--offline",
|
|
499
|
+
"--pin-tab",
|
|
500
|
+
"--quick",
|
|
501
|
+
"--fix",
|
|
502
|
+
"--quiet",
|
|
503
|
+
"-q",
|
|
504
|
+
"--verbose",
|
|
505
|
+
"-v",
|
|
506
|
+
"--webgpu"
|
|
507
|
+
]);
|
|
508
|
+
function getBooleanFlagValue(args, flag) {
|
|
509
|
+
let enabled;
|
|
510
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
511
|
+
const token = args[index];
|
|
512
|
+
if (token === flag) {
|
|
513
|
+
enabled = args[index + 1] !== "false";
|
|
514
|
+
if (["true", "false"].includes(args[index + 1] ?? "")) {
|
|
515
|
+
index += 1;
|
|
516
|
+
}
|
|
517
|
+
continue;
|
|
518
|
+
}
|
|
519
|
+
if (PREVALIDATED_VALUE_FLAGS.has(token)) {
|
|
520
|
+
index += 1;
|
|
521
|
+
continue;
|
|
522
|
+
}
|
|
523
|
+
if (GLOBAL_BOOLEAN_FLAGS_WITH_OPTIONAL_VALUES.has(token) && ["true", "false"].includes(args[index + 1] ?? "")) {
|
|
524
|
+
index += 1;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
return enabled;
|
|
528
|
+
}
|
|
529
|
+
function isBooleanFlagEnabled(args, flag) {
|
|
530
|
+
return getBooleanFlagValue(args, flag) ?? false;
|
|
531
|
+
}
|
|
532
|
+
function isUpstreamEnvFlagEnabled(value) {
|
|
533
|
+
return value !== void 0 && !["", "0", "false", "no"].includes(value.toLowerCase());
|
|
534
|
+
}
|
|
535
|
+
function scanUpstreamGlobalFlagOccurrences(args, targetFlag) {
|
|
536
|
+
const occurrences = [];
|
|
537
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
538
|
+
const token = args[index];
|
|
539
|
+
if (token === targetFlag) {
|
|
540
|
+
occurrences.push({ index, value: args[index + 1] });
|
|
541
|
+
index += 1;
|
|
542
|
+
continue;
|
|
543
|
+
}
|
|
544
|
+
if (PREVALIDATED_VALUE_FLAGS.has(token)) {
|
|
545
|
+
index += 1;
|
|
546
|
+
continue;
|
|
547
|
+
}
|
|
548
|
+
if (GLOBAL_BOOLEAN_FLAGS_WITH_OPTIONAL_VALUES.has(token) && ["true", "false"].includes(args[index + 1] ?? "")) {
|
|
549
|
+
index += 1;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
return occurrences;
|
|
553
|
+
}
|
|
554
|
+
function extractExplicitSessionName(args) {
|
|
555
|
+
return scanUpstreamGlobalFlagOccurrences(args, "--session").at(-1)?.value;
|
|
556
|
+
}
|
|
557
|
+
function extractExplicitNamespace(args) {
|
|
558
|
+
return canonicalizeAgentBrowserNamespace(scanUpstreamGlobalFlagOccurrences(args, "--namespace").at(-1)?.value);
|
|
559
|
+
}
|
|
560
|
+
function resolveAgentBrowserNamespace(args, envValue) {
|
|
561
|
+
const occurrences = scanUpstreamGlobalFlagOccurrences(args, "--namespace");
|
|
562
|
+
if (occurrences.length > 0) {
|
|
563
|
+
return canonicalizeAgentBrowserNamespace(occurrences.at(-1)?.value) ?? "";
|
|
564
|
+
}
|
|
565
|
+
return canonicalizeAgentBrowserNamespace(envValue);
|
|
566
|
+
}
|
|
567
|
+
function getFlagName(token) {
|
|
568
|
+
return token.split("=", 1).at(0) ?? token;
|
|
569
|
+
}
|
|
570
|
+
function isNonFlagToken(token) {
|
|
571
|
+
return typeof token === "string" && !token.startsWith("-");
|
|
572
|
+
}
|
|
573
|
+
function hasOnlyBooleanFlags(tokens, allowedFlags) {
|
|
574
|
+
return tokens.every((token) => token.startsWith("-") && allowedFlags.has(getFlagName(token)));
|
|
575
|
+
}
|
|
576
|
+
function hasOnlyOptionFlags(tokens, allowedBooleanFlags, allowedValueFlags) {
|
|
577
|
+
for (let index = 0; index < tokens.length; index += 1) {
|
|
578
|
+
const token = tokens[index];
|
|
579
|
+
if (!token.startsWith("-")) {
|
|
580
|
+
return false;
|
|
581
|
+
}
|
|
582
|
+
const flagName = getFlagName(token);
|
|
583
|
+
if (allowedBooleanFlags.has(flagName)) {
|
|
584
|
+
continue;
|
|
585
|
+
}
|
|
586
|
+
if (!allowedValueFlags.has(flagName)) {
|
|
587
|
+
return false;
|
|
588
|
+
}
|
|
589
|
+
if (token.includes("=")) {
|
|
590
|
+
continue;
|
|
591
|
+
}
|
|
592
|
+
const value = tokens.at(index + 1);
|
|
593
|
+
if (!isNonFlagToken(value)) {
|
|
594
|
+
return false;
|
|
595
|
+
}
|
|
596
|
+
index += 1;
|
|
597
|
+
}
|
|
598
|
+
return true;
|
|
599
|
+
}
|
|
600
|
+
function optionalGlobalValueFlagConsumesNext(flag, nextToken) {
|
|
601
|
+
if (!OPTIONAL_GLOBAL_VALUE_FLAGS.has(flag) || nextToken === void 0 || nextToken.startsWith("-")) {
|
|
602
|
+
return false;
|
|
603
|
+
}
|
|
604
|
+
return !isKnownCommandToken(nextToken);
|
|
605
|
+
}
|
|
606
|
+
function globalFlagWidth(token, next, seenCommand) {
|
|
607
|
+
if (token.startsWith("--restore=")) {
|
|
608
|
+
return 1;
|
|
609
|
+
}
|
|
610
|
+
if (token === "--restore") {
|
|
611
|
+
return !seenCommand && optionalGlobalValueFlagConsumesNext(token, next) ? 2 : 1;
|
|
612
|
+
}
|
|
613
|
+
if (PREVALIDATED_VALUE_FLAGS.has(token)) {
|
|
614
|
+
return 2;
|
|
615
|
+
}
|
|
616
|
+
if (GLOBAL_BOOLEAN_FLAGS_WITH_OPTIONAL_VALUES.has(token)) {
|
|
617
|
+
return ["true", "false"].includes(next ?? "") ? 2 : 1;
|
|
618
|
+
}
|
|
619
|
+
return 0;
|
|
620
|
+
}
|
|
621
|
+
function projectUpstreamGlobalFlags(args) {
|
|
622
|
+
const indices = [];
|
|
623
|
+
const tokens = [];
|
|
624
|
+
let seenCommand = false;
|
|
625
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
626
|
+
const token = args[index];
|
|
627
|
+
const width = globalFlagWidth(token, args[index + 1], seenCommand);
|
|
628
|
+
if (width > 0) {
|
|
629
|
+
index += width - 1;
|
|
630
|
+
continue;
|
|
631
|
+
}
|
|
632
|
+
tokens.push(token);
|
|
633
|
+
indices.push(index);
|
|
634
|
+
if (isKnownCommandToken(token)) {
|
|
635
|
+
seenCommand = true;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
return { indices, tokens };
|
|
639
|
+
}
|
|
640
|
+
function stripUpstreamGlobalFlags(args) {
|
|
641
|
+
return projectUpstreamGlobalFlags(args).tokens;
|
|
642
|
+
}
|
|
643
|
+
function stripSessionlessShapeGlobalFlags(commandTokens) {
|
|
644
|
+
const stripped = [];
|
|
645
|
+
for (let index = 0; index < commandTokens.length; index += 1) {
|
|
646
|
+
const token = commandTokens[index];
|
|
647
|
+
const flagName = getFlagName(token);
|
|
648
|
+
if (token === "--json") {
|
|
649
|
+
continue;
|
|
650
|
+
}
|
|
651
|
+
if ((flagName === "--session" || flagName === "--namespace") && !token.includes("=")) {
|
|
652
|
+
index += 1;
|
|
653
|
+
continue;
|
|
654
|
+
}
|
|
655
|
+
if (token.startsWith("--session=") || token.startsWith("--namespace=")) {
|
|
656
|
+
continue;
|
|
657
|
+
}
|
|
658
|
+
stripped.push(token);
|
|
659
|
+
}
|
|
660
|
+
return stripped;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
// dist/extensions/agent-browser/lib/argv-descriptor.js
|
|
664
|
+
function isBooleanLiteral(token) {
|
|
665
|
+
const normalized = token?.trim().toLowerCase();
|
|
666
|
+
return normalized === "true" || normalized === "false";
|
|
667
|
+
}
|
|
668
|
+
function flagConsumesFollowingToken(token, nextToken) {
|
|
669
|
+
const normalizedToken = token.split("=", 1).at(0) ?? token;
|
|
670
|
+
if (optionalGlobalValueFlagConsumesNext(normalizedToken, nextToken)) {
|
|
671
|
+
return true;
|
|
672
|
+
}
|
|
673
|
+
if (token.includes("=")) {
|
|
674
|
+
return false;
|
|
675
|
+
}
|
|
676
|
+
return VALUE_FLAGS.has(normalizedToken) || GLOBAL_BOOLEAN_FLAGS_WITH_OPTIONAL_VALUES.has(normalizedToken) && isBooleanLiteral(nextToken);
|
|
677
|
+
}
|
|
678
|
+
function findCommandStartIndex(args) {
|
|
679
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
680
|
+
const token = args[index];
|
|
681
|
+
if (token.startsWith("--session=") || token.startsWith("--namespace=") || token.startsWith("--restore=")) {
|
|
682
|
+
continue;
|
|
683
|
+
}
|
|
684
|
+
if (token.startsWith("-")) {
|
|
685
|
+
if (flagConsumesFollowingToken(token, args[index + 1])) {
|
|
686
|
+
index += 1;
|
|
687
|
+
}
|
|
688
|
+
continue;
|
|
689
|
+
}
|
|
690
|
+
return index;
|
|
691
|
+
}
|
|
692
|
+
return void 0;
|
|
693
|
+
}
|
|
694
|
+
function extractCommandTokens(args) {
|
|
695
|
+
const commandStartIndex = findCommandStartIndex(args);
|
|
696
|
+
return commandStartIndex === void 0 ? [] : args.slice(commandStartIndex);
|
|
697
|
+
}
|
|
698
|
+
function extractUpstreamCommandTokens(args) {
|
|
699
|
+
return stripUpstreamGlobalFlags(extractCommandTokens(args));
|
|
700
|
+
}
|
|
701
|
+
function waitDownloadShape(considered, downloadIndex) {
|
|
702
|
+
const next = considered.at(downloadIndex + 1);
|
|
703
|
+
const candidate = next?.token.startsWith("--") === false ? next : void 0;
|
|
704
|
+
return {
|
|
705
|
+
downloadPath: candidate?.token,
|
|
706
|
+
downloadPathIndex: candidate?.index,
|
|
707
|
+
subcommand: considered[downloadIndex].token
|
|
708
|
+
};
|
|
709
|
+
}
|
|
710
|
+
function parseWaitCommandTokens(commandTokens) {
|
|
711
|
+
if (commandTokens[0] !== "wait") {
|
|
712
|
+
return {};
|
|
713
|
+
}
|
|
714
|
+
const considered = commandTokens.slice(1).map((token, offset) => ({ index: offset + 1, token }));
|
|
715
|
+
const timeoutIndex = considered.findIndex((entry) => entry.token === "--timeout");
|
|
716
|
+
if (timeoutIndex >= 0) {
|
|
717
|
+
considered.splice(timeoutIndex, Math.min(2, considered.length - timeoutIndex));
|
|
718
|
+
}
|
|
719
|
+
for (const flags of [
|
|
720
|
+
["--url", "-u"],
|
|
721
|
+
["--load", "-l"],
|
|
722
|
+
["--fn", "-f"],
|
|
723
|
+
["--text", "-t"]
|
|
724
|
+
]) {
|
|
725
|
+
const match = considered.find((entry) => flags.some((flag) => flag === entry.token));
|
|
726
|
+
if (match) {
|
|
727
|
+
return { subcommand: match.token };
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
const downloadIndex = considered.findIndex((entry) => entry.token === "--download" || entry.token === "-d");
|
|
731
|
+
if (downloadIndex >= 0) {
|
|
732
|
+
return waitDownloadShape(considered, downloadIndex);
|
|
733
|
+
}
|
|
734
|
+
return { subcommand: considered[0]?.token };
|
|
735
|
+
}
|
|
736
|
+
function getOpenCommandTarget(commandTokens) {
|
|
737
|
+
for (let index = 1; index < commandTokens.length; index += 1) {
|
|
738
|
+
const token = commandTokens[index];
|
|
739
|
+
if (token === "--init-script" || token === "--enable") {
|
|
740
|
+
index += 1;
|
|
741
|
+
continue;
|
|
742
|
+
}
|
|
743
|
+
if (token.startsWith("--init-script=") || token.startsWith("--enable=")) {
|
|
744
|
+
continue;
|
|
745
|
+
}
|
|
746
|
+
if (token.startsWith("-")) {
|
|
747
|
+
continue;
|
|
748
|
+
}
|
|
749
|
+
return token;
|
|
750
|
+
}
|
|
751
|
+
return void 0;
|
|
752
|
+
}
|
|
753
|
+
function getCommandSubcommand(tokens) {
|
|
754
|
+
if (isOpenNavigationCommand(tokens.at(0))) {
|
|
755
|
+
return getOpenCommandTarget(tokens);
|
|
756
|
+
}
|
|
757
|
+
if (tokens.at(0) === "wait") {
|
|
758
|
+
return parseWaitCommandTokens(tokens).subcommand;
|
|
759
|
+
}
|
|
760
|
+
return tokens.at(1);
|
|
761
|
+
}
|
|
762
|
+
function parseCommandInfoFromTokens(upstreamCommandTokens) {
|
|
763
|
+
const command = upstreamCommandTokens[0];
|
|
764
|
+
return {
|
|
765
|
+
command,
|
|
766
|
+
subcommand: getCommandSubcommand(upstreamCommandTokens)
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
function parseCommandInfo(args) {
|
|
770
|
+
return parseCommandInfoFromTokens(extractUpstreamCommandTokens(args));
|
|
771
|
+
}
|
|
772
|
+
function parseArgvDescriptor(args) {
|
|
773
|
+
const commandTokens = extractCommandTokens(args);
|
|
774
|
+
const upstreamCommandTokens = stripUpstreamGlobalFlags(commandTokens);
|
|
775
|
+
return {
|
|
776
|
+
commandInfo: parseCommandInfoFromTokens(upstreamCommandTokens),
|
|
777
|
+
commandTokens,
|
|
778
|
+
upstreamCommandTokens
|
|
779
|
+
};
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
// dist/extensions/agent-browser/lib/read-command.js
|
|
783
|
+
var READ_VALUE_OPTIONS = /* @__PURE__ */ new Set(["--filter", "--llms", "--timeout"]);
|
|
784
|
+
var READ_BOOLEAN_OPTIONS = /* @__PURE__ */ new Set(["--raw", "--require-md", "--outline", "--json"]);
|
|
785
|
+
function validReadOption(flag, value) {
|
|
786
|
+
if (value === void 0) {
|
|
787
|
+
return false;
|
|
788
|
+
}
|
|
789
|
+
if (flag === "--llms") {
|
|
790
|
+
return ["index", "full"].includes(value);
|
|
791
|
+
}
|
|
792
|
+
if (flag === "--timeout") {
|
|
793
|
+
return /^\+?\d+$/.test(value) && BigInt(value) > 0n && BigInt(value) <= 18446744073709551615n;
|
|
794
|
+
}
|
|
795
|
+
return true;
|
|
796
|
+
}
|
|
797
|
+
function getExplicitReadUrl(commandTokens) {
|
|
798
|
+
if (commandTokens[0] !== "read") {
|
|
799
|
+
return void 0;
|
|
800
|
+
}
|
|
801
|
+
let url;
|
|
802
|
+
const options = /* @__PURE__ */ new Set();
|
|
803
|
+
for (let index = 1; index < commandTokens.length; index += 1) {
|
|
804
|
+
const token = commandTokens[index];
|
|
805
|
+
if (READ_VALUE_OPTIONS.has(token)) {
|
|
806
|
+
if (!validReadOption(token, commandTokens.at(++index))) {
|
|
807
|
+
return null;
|
|
808
|
+
}
|
|
809
|
+
options.add(token);
|
|
810
|
+
} else if (READ_BOOLEAN_OPTIONS.has(token)) {
|
|
811
|
+
options.add(token);
|
|
812
|
+
} else if (token.startsWith("--") || url !== void 0) {
|
|
813
|
+
return null;
|
|
814
|
+
} else {
|
|
815
|
+
url = token;
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
return options.has("--llms") && options.has("--outline") ? null : url;
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
// dist/extensions/agent-browser/lib/parsing.js
|
|
822
|
+
function isRecord(value) {
|
|
823
|
+
return typeof value === "object" && value !== null;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
// dist/extensions/agent-browser/lib/input-modes/shared.js
|
|
827
|
+
function isString(value) {
|
|
828
|
+
return typeof value === "string";
|
|
829
|
+
}
|
|
830
|
+
function isStringArray(value) {
|
|
831
|
+
return Array.isArray(value) && value.every(isString);
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
// dist/extensions/agent-browser/lib/results/text.js
|
|
835
|
+
function stringifyUnknown(value) {
|
|
836
|
+
if (typeof value === "string") {
|
|
837
|
+
return value;
|
|
838
|
+
}
|
|
839
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
840
|
+
return String(value);
|
|
841
|
+
}
|
|
842
|
+
if (value === null || value === void 0) {
|
|
843
|
+
return "";
|
|
844
|
+
}
|
|
845
|
+
try {
|
|
846
|
+
const serialized = JSON.stringify(value, null, 2);
|
|
847
|
+
return typeof serialized === "string" ? serialized : "";
|
|
848
|
+
} catch {
|
|
849
|
+
return stringifyFallback(value);
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
function stringifyFallback(value) {
|
|
853
|
+
if (typeof value === "bigint" || typeof value === "symbol" || typeof value === "function") {
|
|
854
|
+
return String(value);
|
|
855
|
+
}
|
|
856
|
+
return Object.prototype.toString.call(value);
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
// dist/extensions/agent-browser/lib/orchestration/batch-stdin.js
|
|
860
|
+
var BATCH_STDIN_EXAMPLE = ' Example: { "args": ["batch"], "stdin": "[[\\"get\\",\\"title\\"],[\\"get\\",\\"url\\"]]" }';
|
|
861
|
+
var BatchWords = class {
|
|
862
|
+
token = "";
|
|
863
|
+
tokens = [];
|
|
864
|
+
inDoubleQuote = false;
|
|
865
|
+
inSingleQuote = false;
|
|
866
|
+
consumeQuote(character) {
|
|
867
|
+
if (character === '"' && !this.inSingleQuote) {
|
|
868
|
+
this.inDoubleQuote = !this.inDoubleQuote;
|
|
869
|
+
return true;
|
|
870
|
+
}
|
|
871
|
+
if (character === "'" && !this.inDoubleQuote) {
|
|
872
|
+
this.inSingleQuote = !this.inSingleQuote;
|
|
873
|
+
return true;
|
|
874
|
+
}
|
|
875
|
+
return false;
|
|
876
|
+
}
|
|
877
|
+
finishWord() {
|
|
878
|
+
if (this.token.length > 0) {
|
|
879
|
+
this.tokens.push(this.token);
|
|
880
|
+
this.token = "";
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
consume(character, next) {
|
|
884
|
+
if (character === "\\" && !this.inSingleQuote) {
|
|
885
|
+
if (next !== void 0) {
|
|
886
|
+
this.token += next;
|
|
887
|
+
return true;
|
|
888
|
+
}
|
|
889
|
+
return false;
|
|
890
|
+
}
|
|
891
|
+
if (this.consumeQuote(character)) {
|
|
892
|
+
return false;
|
|
893
|
+
}
|
|
894
|
+
if (character === " " && !this.inDoubleQuote && !this.inSingleQuote) {
|
|
895
|
+
this.finishWord();
|
|
896
|
+
} else {
|
|
897
|
+
this.token += character;
|
|
898
|
+
}
|
|
899
|
+
return false;
|
|
900
|
+
}
|
|
901
|
+
finish() {
|
|
902
|
+
this.finishWord();
|
|
903
|
+
return this.tokens.length > 0 ? { step: this.tokens } : { error: "batch command is empty" };
|
|
904
|
+
}
|
|
905
|
+
};
|
|
906
|
+
function parseBatchCommandArgument(command) {
|
|
907
|
+
const words = new BatchWords();
|
|
908
|
+
for (let index = 0; index < command.length; index++) {
|
|
909
|
+
if (words.consume(command[index], command.at(index + 1))) {
|
|
910
|
+
index++;
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
return words.finish();
|
|
914
|
+
}
|
|
915
|
+
function validateUserBatchStep(step, index) {
|
|
916
|
+
if (!Array.isArray(step)) {
|
|
917
|
+
return {
|
|
918
|
+
error: `agent_browser batch stdin step ${index} must be an array of string command tokens.${BATCH_STDIN_EXAMPLE}`,
|
|
919
|
+
ok: false
|
|
920
|
+
};
|
|
921
|
+
}
|
|
922
|
+
if (!isStringArray(step)) {
|
|
923
|
+
const invalidTokenIndex = step.findIndex((token) => typeof token !== "string");
|
|
924
|
+
return {
|
|
925
|
+
error: `agent_browser batch stdin step ${index} token ${invalidTokenIndex} must be a string.${BATCH_STDIN_EXAMPLE}`,
|
|
926
|
+
ok: false
|
|
927
|
+
};
|
|
928
|
+
}
|
|
929
|
+
return { ok: true, step };
|
|
930
|
+
}
|
|
931
|
+
function parseBatchStdinJsonArray(stdin) {
|
|
932
|
+
if (stdin === void 0) {
|
|
933
|
+
return { steps: [] };
|
|
934
|
+
}
|
|
935
|
+
try {
|
|
936
|
+
const parsed = JSON.parse(stdin);
|
|
937
|
+
if (!Array.isArray(parsed)) {
|
|
938
|
+
return {
|
|
939
|
+
error: `agent_browser batch stdin must be a JSON array of command steps.${BATCH_STDIN_EXAMPLE}`
|
|
940
|
+
};
|
|
941
|
+
}
|
|
942
|
+
return { steps: parsed };
|
|
943
|
+
} catch (error) {
|
|
944
|
+
const message = error instanceof Error ? error.message : stringifyUnknown(error);
|
|
945
|
+
return {
|
|
946
|
+
error: `agent_browser batch stdin could not be parsed as JSON: ${message}.${BATCH_STDIN_EXAMPLE}`
|
|
947
|
+
};
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
function parseUserBatchStdin(stdin) {
|
|
951
|
+
const parsed = parseBatchStdinJsonArray(stdin);
|
|
952
|
+
if (parsed.error !== void 0 || parsed.steps === void 0) {
|
|
953
|
+
return parsed.error !== void 0 ? { error: parsed.error } : { steps: [] };
|
|
954
|
+
}
|
|
955
|
+
const steps = [];
|
|
956
|
+
for (const [index, rawStep] of parsed.steps.entries()) {
|
|
957
|
+
const validated = validateUserBatchStep(rawStep, index);
|
|
958
|
+
if (!validated.ok) {
|
|
959
|
+
return { error: validated.error };
|
|
960
|
+
}
|
|
961
|
+
steps.push(validated.step);
|
|
962
|
+
}
|
|
963
|
+
return { steps };
|
|
964
|
+
}
|
|
965
|
+
function getUpstreamEffectiveBatchSteps(commandTokens, stdin) {
|
|
966
|
+
if (commandTokens[0] !== "batch") {
|
|
967
|
+
return [];
|
|
968
|
+
}
|
|
969
|
+
const argumentSteps = commandTokens.slice(1).flatMap((command) => {
|
|
970
|
+
if (command === "--bail") {
|
|
971
|
+
return [];
|
|
972
|
+
}
|
|
973
|
+
const step = parseBatchCommandArgument(command).step;
|
|
974
|
+
return step ? [step] : [];
|
|
975
|
+
});
|
|
976
|
+
if (commandTokens.slice(1).some((token) => token !== "--bail")) {
|
|
977
|
+
return argumentSteps;
|
|
978
|
+
}
|
|
979
|
+
return parseUserBatchStdin(stdin).steps?.filter((step) => step.length > 0) ?? [];
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
// dist/extensions/agent-browser/lib/command-policy.js
|
|
983
|
+
var SESSIONLESS_AUTH_SUBCOMMANDS = /* @__PURE__ */ new Set(["save", "list", "show", "delete", "remove"]);
|
|
984
|
+
var PLUGIN_SESSIONLESS_SUBCOMMANDS = /* @__PURE__ */ new Set(["list", "show", "add", "run"]);
|
|
985
|
+
var EMPTY_BOOLEAN_FLAGS = /* @__PURE__ */ new Set();
|
|
986
|
+
var JSON_BOOLEAN_FLAGS = /* @__PURE__ */ new Set(["--json"]);
|
|
987
|
+
var AUTH_SAVE_BOOLEAN_FLAGS = /* @__PURE__ */ new Set(["--json", "--password-stdin"]);
|
|
988
|
+
var AUTH_SAVE_VALUE_FLAGS = /* @__PURE__ */ new Set([
|
|
989
|
+
"--password",
|
|
990
|
+
"--password-selector",
|
|
991
|
+
"--submit-selector",
|
|
992
|
+
"--url",
|
|
993
|
+
"--username",
|
|
994
|
+
"--username-selector"
|
|
995
|
+
]);
|
|
996
|
+
var DASHBOARD_VALUE_FLAGS = /* @__PURE__ */ new Set(["--allowed-origins", "--port"]);
|
|
997
|
+
var DOCTOR_BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
|
|
998
|
+
"--fix",
|
|
999
|
+
"--headed",
|
|
1000
|
+
"--json",
|
|
1001
|
+
"--offline",
|
|
1002
|
+
"--quick",
|
|
1003
|
+
"--webgpu"
|
|
1004
|
+
]);
|
|
1005
|
+
var INSTALL_BOOLEAN_FLAGS = /* @__PURE__ */ new Set(["--with-deps", "-d"]);
|
|
1006
|
+
var STATE_SESSIONLESS_SUBCOMMANDS = /* @__PURE__ */ new Set(["list", "show", "clear", "clean", "rename"]);
|
|
1007
|
+
var STATE_CLEAN_VALUE_FLAGS = /* @__PURE__ */ new Set(["--older-than"]);
|
|
1008
|
+
var SESSION_ID_VALUE_FLAGS = /* @__PURE__ */ new Set(["--scope", "--prefix"]);
|
|
1009
|
+
function isSessionlessAuthCommand(commandTokens) {
|
|
1010
|
+
const subcommand = commandTokens.at(1);
|
|
1011
|
+
const target = commandTokens.at(2);
|
|
1012
|
+
const rest = commandTokens.slice(3);
|
|
1013
|
+
if (!SESSIONLESS_AUTH_SUBCOMMANDS.has(subcommand ?? "")) {
|
|
1014
|
+
return false;
|
|
1015
|
+
}
|
|
1016
|
+
if (subcommand === "list") {
|
|
1017
|
+
return target === void 0;
|
|
1018
|
+
}
|
|
1019
|
+
if (!isNonFlagToken(target)) {
|
|
1020
|
+
return false;
|
|
1021
|
+
}
|
|
1022
|
+
if (subcommand === "save") {
|
|
1023
|
+
return hasOnlyOptionFlags(rest, AUTH_SAVE_BOOLEAN_FLAGS, AUTH_SAVE_VALUE_FLAGS);
|
|
1024
|
+
}
|
|
1025
|
+
return rest.length === 0;
|
|
1026
|
+
}
|
|
1027
|
+
function isSessionlessDashboardCommand(commandTokens) {
|
|
1028
|
+
const [, subcommand, ...rest] = commandTokens;
|
|
1029
|
+
if (subcommand === "stop") {
|
|
1030
|
+
return rest.length === 0;
|
|
1031
|
+
}
|
|
1032
|
+
return hasOnlyOptionFlags(subcommand === "start" ? rest : commandTokens.slice(1), JSON_BOOLEAN_FLAGS, DASHBOARD_VALUE_FLAGS);
|
|
1033
|
+
}
|
|
1034
|
+
function isSessionlessStateClear(operands) {
|
|
1035
|
+
const firstArg = operands.at(0);
|
|
1036
|
+
const secondArg = operands.at(1);
|
|
1037
|
+
const rest = operands.slice(2);
|
|
1038
|
+
if ((firstArg === "--all" || firstArg === "-a") && secondArg === void 0) {
|
|
1039
|
+
return true;
|
|
1040
|
+
}
|
|
1041
|
+
return isNonFlagToken(firstArg) && (secondArg === void 0 || secondArg === "--all" && rest.length === 0);
|
|
1042
|
+
}
|
|
1043
|
+
function isSessionlessStateCommand(commandTokens) {
|
|
1044
|
+
const subcommand = commandTokens.at(1);
|
|
1045
|
+
const firstArg = commandTokens.at(2);
|
|
1046
|
+
const secondArg = commandTokens.at(3);
|
|
1047
|
+
const rest = commandTokens.slice(4);
|
|
1048
|
+
if (!STATE_SESSIONLESS_SUBCOMMANDS.has(subcommand ?? "")) {
|
|
1049
|
+
return false;
|
|
1050
|
+
}
|
|
1051
|
+
switch (subcommand) {
|
|
1052
|
+
case void 0:
|
|
1053
|
+
return false;
|
|
1054
|
+
case "list":
|
|
1055
|
+
return firstArg === void 0;
|
|
1056
|
+
case "show":
|
|
1057
|
+
return isNonFlagToken(firstArg) && secondArg === void 0;
|
|
1058
|
+
case "rename":
|
|
1059
|
+
return isNonFlagToken(firstArg) && isNonFlagToken(secondArg) && rest.length === 0;
|
|
1060
|
+
case "clean": {
|
|
1061
|
+
const optionTokens = commandTokens.slice(2);
|
|
1062
|
+
return optionTokens.length > 0 && hasOnlyOptionFlags(optionTokens, EMPTY_BOOLEAN_FLAGS, STATE_CLEAN_VALUE_FLAGS);
|
|
1063
|
+
}
|
|
1064
|
+
case "clear":
|
|
1065
|
+
return isSessionlessStateClear(commandTokens.slice(2));
|
|
1066
|
+
default:
|
|
1067
|
+
return false;
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
function isSessionlessPluginCommand(commandTokens) {
|
|
1071
|
+
const subcommand = commandTokens.at(1);
|
|
1072
|
+
if (subcommand === void 0) {
|
|
1073
|
+
return true;
|
|
1074
|
+
}
|
|
1075
|
+
return PLUGIN_SESSIONLESS_SUBCOMMANDS.has(subcommand);
|
|
1076
|
+
}
|
|
1077
|
+
function isSessionlessSessionCommand(commandTokens) {
|
|
1078
|
+
const [, subcommand, ...rest] = commandTokens;
|
|
1079
|
+
if (subcommand === "list" || subcommand === "info") {
|
|
1080
|
+
return rest.length === 0;
|
|
1081
|
+
}
|
|
1082
|
+
if (subcommand === "id") {
|
|
1083
|
+
return hasOnlyOptionFlags(rest, JSON_BOOLEAN_FLAGS, SESSION_ID_VALUE_FLAGS);
|
|
1084
|
+
}
|
|
1085
|
+
return false;
|
|
1086
|
+
}
|
|
1087
|
+
function isSessionlessCommand(commandTokens) {
|
|
1088
|
+
const normalizedTokens = stripSessionlessShapeGlobalFlags(commandTokens);
|
|
1089
|
+
const command = normalizedTokens.at(0);
|
|
1090
|
+
const subcommand = normalizedTokens.at(1);
|
|
1091
|
+
switch (command) {
|
|
1092
|
+
case void 0:
|
|
1093
|
+
return false;
|
|
1094
|
+
case "skills":
|
|
1095
|
+
return ["list", "get", "path"].includes(subcommand ?? "");
|
|
1096
|
+
case "auth":
|
|
1097
|
+
return isSessionlessAuthCommand(normalizedTokens);
|
|
1098
|
+
case "plugin":
|
|
1099
|
+
return isSessionlessPluginCommand(normalizedTokens);
|
|
1100
|
+
case "mcp":
|
|
1101
|
+
return true;
|
|
1102
|
+
case "dashboard":
|
|
1103
|
+
return isSessionlessDashboardCommand(normalizedTokens);
|
|
1104
|
+
case "device":
|
|
1105
|
+
return normalizedTokens.length === 2 && subcommand === "list";
|
|
1106
|
+
case "doctor":
|
|
1107
|
+
return hasOnlyBooleanFlags(normalizedTokens.slice(1), DOCTOR_BOOLEAN_FLAGS);
|
|
1108
|
+
case "install":
|
|
1109
|
+
return hasOnlyBooleanFlags(normalizedTokens.slice(1), INSTALL_BOOLEAN_FLAGS);
|
|
1110
|
+
case "profiles":
|
|
1111
|
+
case "upgrade":
|
|
1112
|
+
return normalizedTokens.length === 1;
|
|
1113
|
+
case "session":
|
|
1114
|
+
return isSessionlessSessionCommand(normalizedTokens);
|
|
1115
|
+
case "state":
|
|
1116
|
+
return isSessionlessStateCommand(normalizedTokens);
|
|
1117
|
+
default:
|
|
1118
|
+
return false;
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
function isBrowserIndependentRead(commandTokens, stdin) {
|
|
1122
|
+
if (commandTokens[0] !== "batch") {
|
|
1123
|
+
return getExplicitReadUrl(commandTokens) !== void 0;
|
|
1124
|
+
}
|
|
1125
|
+
const steps = getUpstreamEffectiveBatchSteps(commandTokens, stdin);
|
|
1126
|
+
return steps.length > 0 && steps.every((step) => getExplicitReadUrl(step) !== void 0);
|
|
1127
|
+
}
|
|
1128
|
+
function needsManagedSession(descriptor, stdin) {
|
|
1129
|
+
return !isSessionlessCommand(descriptor.upstreamCommandTokens) && !isBrowserIndependentRead(descriptor.upstreamCommandTokens, stdin);
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
// dist/extensions/agent-browser/lib/launch-scoped-flags.js
|
|
1133
|
+
var LAUNCH_SCOPED_FLAG_DEFINITIONS = [
|
|
1134
|
+
{
|
|
1135
|
+
flag: "--auto-connect",
|
|
1136
|
+
reason: "attaches to an already-running browser at launch time instead of reusing an existing named session"
|
|
1137
|
+
},
|
|
1138
|
+
{
|
|
1139
|
+
flag: "--allowed-domains",
|
|
1140
|
+
reason: "installs upstream network and WebRTC containment on a fresh controllable browser context"
|
|
1141
|
+
},
|
|
1142
|
+
{
|
|
1143
|
+
flag: "--namespace",
|
|
1144
|
+
reason: "selects the upstream daemon/socket and restore-state namespace before session lookup"
|
|
1145
|
+
},
|
|
1146
|
+
{
|
|
1147
|
+
flag: "--cdp",
|
|
1148
|
+
reason: "selects the browser/CDP endpoint used when an upstream session is launched"
|
|
1149
|
+
},
|
|
1150
|
+
{
|
|
1151
|
+
flag: "--ca-cert",
|
|
1152
|
+
reason: "selects isolated Chromium CA trust and may relaunch the browser"
|
|
1153
|
+
},
|
|
1154
|
+
{
|
|
1155
|
+
flag: "--no-ca-cert",
|
|
1156
|
+
reason: "clears retained isolated Chromium CA trust and may relaunch the browser"
|
|
1157
|
+
},
|
|
1158
|
+
{
|
|
1159
|
+
flag: "--enable",
|
|
1160
|
+
reason: "selects built-in page init scripts before the upstream browser session is launched"
|
|
1161
|
+
},
|
|
1162
|
+
{
|
|
1163
|
+
flag: "--engine",
|
|
1164
|
+
reason: "selects the browser engine used for the upstream launch"
|
|
1165
|
+
},
|
|
1166
|
+
{
|
|
1167
|
+
flag: "--executable-path",
|
|
1168
|
+
reason: "selects the browser executable used for the upstream launch"
|
|
1169
|
+
},
|
|
1170
|
+
{
|
|
1171
|
+
flag: "--webgpu",
|
|
1172
|
+
reason: "selects the platform-specific WebGPU browser launch preset"
|
|
1173
|
+
},
|
|
1174
|
+
{
|
|
1175
|
+
flag: "--no-webmcp",
|
|
1176
|
+
reason: "selects whether locally launched Chrome enables experimental WebMCP support"
|
|
1177
|
+
},
|
|
1178
|
+
{
|
|
1179
|
+
flag: "--init-script",
|
|
1180
|
+
reason: "registers page init scripts before the upstream browser session is launched"
|
|
1181
|
+
},
|
|
1182
|
+
{
|
|
1183
|
+
flag: "--idle-timeout",
|
|
1184
|
+
reason: "configures background browser lifecycle for the launched session"
|
|
1185
|
+
},
|
|
1186
|
+
{
|
|
1187
|
+
flag: "--args",
|
|
1188
|
+
reason: "selects raw Chrome arguments for the browser launch"
|
|
1189
|
+
},
|
|
1190
|
+
{
|
|
1191
|
+
flag: "--user-agent",
|
|
1192
|
+
reason: "selects the browser user agent at launch time"
|
|
1193
|
+
},
|
|
1194
|
+
{
|
|
1195
|
+
flag: "--headed",
|
|
1196
|
+
reason: "selects whether the launched browser has a visible window"
|
|
1197
|
+
},
|
|
1198
|
+
{
|
|
1199
|
+
flag: "--device",
|
|
1200
|
+
reason: "selects the provider device for the upstream launch"
|
|
1201
|
+
},
|
|
1202
|
+
{
|
|
1203
|
+
flag: "--profile",
|
|
1204
|
+
reason: "selects Chrome profile state for the upstream launch"
|
|
1205
|
+
},
|
|
1206
|
+
{
|
|
1207
|
+
flag: "--provider",
|
|
1208
|
+
reason: "selects the upstream browser provider for the launch"
|
|
1209
|
+
},
|
|
1210
|
+
{
|
|
1211
|
+
flag: "-p",
|
|
1212
|
+
reason: "selects the upstream browser provider for the launch"
|
|
1213
|
+
},
|
|
1214
|
+
{
|
|
1215
|
+
flag: "--session-name",
|
|
1216
|
+
reason: "selects upstream saved auth/session state for the launch"
|
|
1217
|
+
},
|
|
1218
|
+
{
|
|
1219
|
+
flag: "--restore",
|
|
1220
|
+
reason: "selects upstream saved auth/session restore state for the launch"
|
|
1221
|
+
},
|
|
1222
|
+
{
|
|
1223
|
+
flag: "--restore-save",
|
|
1224
|
+
reason: "configures upstream restore auto-save policy for the launched session"
|
|
1225
|
+
},
|
|
1226
|
+
{
|
|
1227
|
+
flag: "--restore-check-url",
|
|
1228
|
+
reason: "configures restore validation before the launched session can auto-save"
|
|
1229
|
+
},
|
|
1230
|
+
{
|
|
1231
|
+
flag: "--restore-check-text",
|
|
1232
|
+
reason: "configures restore validation before the launched session can auto-save"
|
|
1233
|
+
},
|
|
1234
|
+
{
|
|
1235
|
+
flag: "--restore-check-fn",
|
|
1236
|
+
reason: "configures restore validation before the launched session can auto-save"
|
|
1237
|
+
},
|
|
1238
|
+
{
|
|
1239
|
+
flag: "--state",
|
|
1240
|
+
reason: "loads persisted upstream browser/auth state at launch time"
|
|
1241
|
+
}
|
|
1242
|
+
];
|
|
1243
|
+
var LAUNCH_SCOPED_FLAGS = LAUNCH_SCOPED_FLAG_DEFINITIONS.map((definition) => definition.flag);
|
|
1244
|
+
var LAUNCH_SCOPED_FLAG_LABEL = LAUNCH_SCOPED_FLAGS.join(", ");
|
|
1245
|
+
function hasLaunchScopedFlagToken(args, flag) {
|
|
1246
|
+
if (flag === "--restore" && args.some((token) => token.startsWith("--restore="))) {
|
|
1247
|
+
return true;
|
|
1248
|
+
}
|
|
1249
|
+
if (!args.includes(flag)) {
|
|
1250
|
+
return false;
|
|
1251
|
+
}
|
|
1252
|
+
if (flag === "--auto-connect") {
|
|
1253
|
+
return isBooleanFlagEnabled(args, flag);
|
|
1254
|
+
}
|
|
1255
|
+
if (flag !== "--state") {
|
|
1256
|
+
return true;
|
|
1257
|
+
}
|
|
1258
|
+
const commandStartIndex = findCommandStartIndex(args);
|
|
1259
|
+
return commandStartIndex === void 0 || args[commandStartIndex] !== "wait" || args.indexOf(flag) < commandStartIndex;
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
// dist/extensions/agent-browser/lib/process-environment.js
|
|
1263
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
1264
|
+
|
|
1265
|
+
// dist/extensions/agent-browser/lib/temp-mutation-queue.js
|
|
1266
|
+
var tempMutationQueue = Promise.resolve();
|
|
1267
|
+
|
|
1268
|
+
// dist/extensions/agent-browser/lib/process-identity.js
|
|
1269
|
+
var PROCESS_START_IDENTITY_TIMEOUT_MS = process.platform === "win32" ? 1e4 : 5e3;
|
|
1270
|
+
|
|
1271
|
+
// dist/extensions/agent-browser/lib/temp-root.js
|
|
1272
|
+
var STALE_TEMP_ROOT_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
|
|
1273
|
+
|
|
1274
|
+
// dist/extensions/agent-browser/lib/temp-artifact-budget.js
|
|
1275
|
+
var DEFAULT_MAX_BYTES = 32 * 1024 * 1024;
|
|
1276
|
+
|
|
1277
|
+
// dist/extensions/agent-browser/lib/process-environment.js
|
|
1278
|
+
var isolatedAgentBrowserEnvironment = new AsyncLocalStorage();
|
|
1279
|
+
var agentBrowserProcessEnvironment = new AsyncLocalStorage();
|
|
1280
|
+
var PROXY_ENV_NAMES = /* @__PURE__ */ new Set(["ALL_PROXY", "HTTPS_PROXY", "HTTP_PROXY", "NO_PROXY"]);
|
|
1281
|
+
function getAgentBrowserProcessEnvironment(baseEnv = process.env) {
|
|
1282
|
+
const isolatedConfig = isolatedAgentBrowserEnvironment.getStore();
|
|
1283
|
+
if (isolatedConfig === void 0) {
|
|
1284
|
+
return { ...baseEnv, ...agentBrowserProcessEnvironment.getStore()?.env };
|
|
1285
|
+
}
|
|
1286
|
+
return {
|
|
1287
|
+
...Object.fromEntries(Object.entries(baseEnv).filter(([name]) => {
|
|
1288
|
+
const normalizedName = name.toUpperCase();
|
|
1289
|
+
return !normalizedName.startsWith("AGENT_BROWSER_") && !PROXY_ENV_NAMES.has(normalizedName);
|
|
1290
|
+
})),
|
|
1291
|
+
AGENT_BROWSER_CONFIG: isolatedConfig
|
|
1292
|
+
};
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
// dist/scripts/agent-browser-target.mjs
|
|
1296
|
+
var TARGET_AGENT_BROWSER_VERSION = "0.38.1";
|
|
1297
|
+
var TARGET_AGENT_BROWSER_VERSION_LABEL = `agent-browser ${TARGET_AGENT_BROWSER_VERSION}`;
|
|
1298
|
+
var MINIMUM_AGENT_BROWSER_VERSION = "0.35.0";
|
|
1299
|
+
var MINIMUM_AGENT_BROWSER_VERSION_LABEL = `agent-browser ${MINIMUM_AGENT_BROWSER_VERSION}`;
|
|
1300
|
+
var SUPPORTED_AGENT_BROWSER_VERSION_LABEL = `${MINIMUM_AGENT_BROWSER_VERSION_LABEL} or newer`;
|
|
1301
|
+
|
|
1302
|
+
// dist/extensions/agent-browser/lib/runtime-args-validation.js
|
|
1303
|
+
var INSPECTION_FLAGS = /* @__PURE__ */ new Set(["--help", "-h", "--version", "-V"]);
|
|
1304
|
+
var SHELL_OPERATOR_TOKENS = /* @__PURE__ */ new Set(["&&", "||", "|", ";", ">", ">>", "<"]);
|
|
1305
|
+
function isPlainTextInspectionArgs(args) {
|
|
1306
|
+
return args.some((token) => INSPECTION_FLAGS.has(token));
|
|
1307
|
+
}
|
|
1308
|
+
function getSingleKeyCommandValidationError(args) {
|
|
1309
|
+
const { commandInfo, upstreamCommandTokens: tokens } = parseArgvDescriptor(args);
|
|
1310
|
+
const command = commandInfo.command;
|
|
1311
|
+
if (!["press", "key", "keydown", "keyup"].includes(command ?? "") || tokens.length === 2) {
|
|
1312
|
+
return;
|
|
1313
|
+
}
|
|
1314
|
+
const label = command === "key" ? "key/press" : command;
|
|
1315
|
+
return `agent-browser ${label ?? ""} accepts exactly one key argument. Do not pass a selector or ref to ${label ?? ""}; focus or click the target first, then run ${command ?? ""} <key> (for example: focus @e1, then press Enter).`;
|
|
1316
|
+
}
|
|
1317
|
+
function getBareMcpValidationError(args) {
|
|
1318
|
+
const { commandInfo, upstreamCommandTokens: tokens } = parseArgvDescriptor(args);
|
|
1319
|
+
if (commandInfo.command !== "mcp" || tokens.includes("--help") || tokens.includes("-h")) {
|
|
1320
|
+
return;
|
|
1321
|
+
}
|
|
1322
|
+
return "agent-browser mcp starts a stdio MCP server for external MCP clients, not a one-shot native agent_browser tool workflow. Use the native agent_browser tool modes directly, or configure an MCP client to launch `agent-browser mcp`. Use `mcp --help` for help.";
|
|
1323
|
+
}
|
|
1324
|
+
function getUnsupportedInlineWaitDownloadError(args) {
|
|
1325
|
+
const descriptor = parseArgvDescriptor(args);
|
|
1326
|
+
if (descriptor.commandInfo.command !== "wait" || !descriptor.upstreamCommandTokens.some((token) => token.startsWith("--download="))) {
|
|
1327
|
+
return;
|
|
1328
|
+
}
|
|
1329
|
+
return `agent-browser ${TARGET_AGENT_BROWSER_VERSION} does not support \`wait --download=<path>\`. Pass the optional path as a separate argument: \`wait --download <path>\` (or \`wait -d <path>\`).`;
|
|
1330
|
+
}
|
|
1331
|
+
function getBareNoSandboxValidationError(args, batchStep) {
|
|
1332
|
+
const tokens = batchStep ? args : stripUpstreamGlobalFlags(args);
|
|
1333
|
+
const command = tokens[0];
|
|
1334
|
+
const leading = command === "--no-sandbox";
|
|
1335
|
+
if (!leading && (!isOpenNavigationCommand(command) || !tokens.slice(1).includes("--no-sandbox"))) {
|
|
1336
|
+
return;
|
|
1337
|
+
}
|
|
1338
|
+
const explanation = leading ? "`--no-sandbox` is not an agent-browser command." : `\`--no-sandbox\` is ignored as an option by \`${command}\`.`;
|
|
1339
|
+
return `${explanation} It is a Chromium launch argument. Put it in top-level \`--args\` and start a fresh session: { args: ["--args", "--no-sandbox", "open", "https://example.com"], sessionMode: "fresh" }. For batch, put --args before batch, not inside a step.`;
|
|
1340
|
+
}
|
|
1341
|
+
function getForbiddenToolTokenError(args) {
|
|
1342
|
+
const shellOperator = args.find((token) => SHELL_OPERATOR_TOKENS.has(token));
|
|
1343
|
+
if (shellOperator !== void 0) {
|
|
1344
|
+
return `Do not pass shell operators like \`${shellOperator}\`. Pass exact agent-browser CLI arguments only.`;
|
|
1345
|
+
}
|
|
1346
|
+
if (args.some((token) => token === "--session-mode" || token.startsWith("--session-mode="))) {
|
|
1347
|
+
return 'Do not pass `--session-mode` in args. Use the top-level agent_browser `sessionMode` field instead, for example { args: ["--profile", "Default", "open", "https://example.com"], sessionMode: "fresh" }.';
|
|
1348
|
+
}
|
|
1349
|
+
return;
|
|
1350
|
+
}
|
|
1351
|
+
function validateToolArgs(args, options = {}) {
|
|
1352
|
+
if (args.length === 0) {
|
|
1353
|
+
return "`args` must contain at least one agent-browser command token.";
|
|
1354
|
+
}
|
|
1355
|
+
const forbidden = getForbiddenToolTokenError(args);
|
|
1356
|
+
if (forbidden !== void 0) {
|
|
1357
|
+
return forbidden;
|
|
1358
|
+
}
|
|
1359
|
+
return getNativeCommandShapeError(args, options.batchStep === true);
|
|
1360
|
+
}
|
|
1361
|
+
function getNativeCommandShapeError(args, batchStep) {
|
|
1362
|
+
const inspection = !batchStep && isPlainTextInspectionArgs(args);
|
|
1363
|
+
const invalidValueFlag = inspection ? void 0 : getInvalidValueFlagDetails(args, !batchStep);
|
|
1364
|
+
if (invalidValueFlag?.reason === "unsupported-assignment") {
|
|
1365
|
+
return formatInvalidValueFlagError(invalidValueFlag, batchStep);
|
|
1366
|
+
}
|
|
1367
|
+
return (inspection ? void 0 : getBareNoSandboxValidationError(args, batchStep)) ?? getBareMcpValidationError(args) ?? getSingleKeyCommandValidationError(args) ?? getUnsupportedInlineWaitDownloadError(args);
|
|
1368
|
+
}
|
|
1369
|
+
function unsupportedAssignment(token, flag, allowRestoreAssignment) {
|
|
1370
|
+
return token.includes("=") && (PREVALIDATED_VALUE_FLAGS.has(flag) || GLOBAL_BOOLEAN_FLAGS_WITH_OPTIONAL_VALUES.has(flag) || !allowRestoreAssignment && flag === "--restore");
|
|
1371
|
+
}
|
|
1372
|
+
function valueFlagProblem(flag, receivedToken) {
|
|
1373
|
+
if (receivedToken === void 0 || flag === "--args" && receivedToken.length === 0) {
|
|
1374
|
+
return "missing-value";
|
|
1375
|
+
}
|
|
1376
|
+
if (receivedToken.startsWith("-") && !GLOBAL_VALUE_FLAGS_ALLOWING_DASH_VALUE.has(flag)) {
|
|
1377
|
+
return "unexpected-flag";
|
|
1378
|
+
}
|
|
1379
|
+
return;
|
|
1380
|
+
}
|
|
1381
|
+
function getInvalidValueFlagDetails(args, allowRestoreAssignment = true) {
|
|
1382
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
1383
|
+
const token = args[index];
|
|
1384
|
+
if (!token.startsWith("-")) {
|
|
1385
|
+
continue;
|
|
1386
|
+
}
|
|
1387
|
+
const flag = token.split("=", 1)[0] ?? token;
|
|
1388
|
+
if (unsupportedAssignment(token, flag, allowRestoreAssignment)) {
|
|
1389
|
+
return { flag, index, reason: "unsupported-assignment" };
|
|
1390
|
+
}
|
|
1391
|
+
if (!PREVALIDATED_VALUE_FLAGS.has(flag)) {
|
|
1392
|
+
continue;
|
|
1393
|
+
}
|
|
1394
|
+
const receivedToken = args.at(index + 1);
|
|
1395
|
+
const reason = valueFlagProblem(flag, receivedToken);
|
|
1396
|
+
if (reason !== void 0) {
|
|
1397
|
+
return reason === "unexpected-flag" ? { flag, index, reason, receivedToken } : { flag, index, reason };
|
|
1398
|
+
}
|
|
1399
|
+
index += 1;
|
|
1400
|
+
}
|
|
1401
|
+
return;
|
|
1402
|
+
}
|
|
1403
|
+
function formatInvalidValueFlagError(details, batchStep = false) {
|
|
1404
|
+
if (details.reason === "unsupported-assignment") {
|
|
1405
|
+
if (batchStep) {
|
|
1406
|
+
return details.flag === "--restore" ? "Global `--restore=<key>` belongs before `batch` in top-level args, not inside a batch step." : `Global \`${details.flag}=<value>\` is not supported inside a batch step. Move \`${details.flag}\` and its value before \`batch\` as separate top-level args.`;
|
|
1407
|
+
}
|
|
1408
|
+
return `agent-browser ${TARGET_AGENT_BROWSER_VERSION} does not support \`${details.flag}=<value>\`. Pass \`${details.flag}\` and its value as separate arguments.`;
|
|
1409
|
+
}
|
|
1410
|
+
if (details.reason === "unexpected-flag" && details.receivedToken !== void 0 && details.receivedToken.length > 0) {
|
|
1411
|
+
return `Flag \`${details.flag}\` requires a value, but received \`${details.receivedToken}\` instead. Pass a non-flag value immediately after \`${details.flag}\`.`;
|
|
1412
|
+
}
|
|
1413
|
+
return `Flag \`${details.flag}\` requires a value immediately after it. Pass a non-flag token like \`${details.flag} demo\`.`;
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
// dist/extensions/agent-browser/lib/runtime-compatibility.js
|
|
1417
|
+
var OPENAI_HOSTS = /* @__PURE__ */ new Set(["chat.com", "chat.openai.com", "chatgpt.com"]);
|
|
1418
|
+
var DEFAULT_USER_AGENT_BY_PLATFORM = {
|
|
1419
|
+
darwin: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36",
|
|
1420
|
+
linux: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36",
|
|
1421
|
+
win32: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36"
|
|
1422
|
+
};
|
|
1423
|
+
var FALLBACK_USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36";
|
|
1424
|
+
function getDefaultHeadlessCompatUserAgent(platform = process.platform) {
|
|
1425
|
+
return DEFAULT_USER_AGENT_BY_PLATFORM[platform] ?? FALLBACK_USER_AGENT;
|
|
1426
|
+
}
|
|
1427
|
+
function hasLaunchOverride(args, env) {
|
|
1428
|
+
const flags = ["--user-agent", "--args", "--cdp", "--provider", "-p"];
|
|
1429
|
+
return flags.some((flag) => args.some((token) => token === flag || token.startsWith(`${flag}=`))) || [
|
|
1430
|
+
env.AGENT_BROWSER_SESSION,
|
|
1431
|
+
env.AGENT_BROWSER_USER_AGENT,
|
|
1432
|
+
env.AGENT_BROWSER_ARGS,
|
|
1433
|
+
env.AGENT_BROWSER_CDP,
|
|
1434
|
+
env.AGENT_BROWSER_PROVIDER
|
|
1435
|
+
].some((value) => value !== void 0);
|
|
1436
|
+
}
|
|
1437
|
+
function hasInteractiveLaunchMode(args, env) {
|
|
1438
|
+
const modes = [
|
|
1439
|
+
["--headed", env.AGENT_BROWSER_HEADED],
|
|
1440
|
+
["--auto-connect", env.AGENT_BROWSER_AUTO_CONNECT]
|
|
1441
|
+
];
|
|
1442
|
+
return modes.some(([flag, value]) => getBooleanFlagValue(args, flag) ?? isUpstreamEnvFlagEnabled(value));
|
|
1443
|
+
}
|
|
1444
|
+
function canUseHeadlessCompatibilityUserAgent(args, env = getAgentBrowserProcessEnvironment()) {
|
|
1445
|
+
if (hasLaunchOverride(args, env)) {
|
|
1446
|
+
return false;
|
|
1447
|
+
}
|
|
1448
|
+
if (hasInteractiveLaunchMode(args, env)) {
|
|
1449
|
+
return false;
|
|
1450
|
+
}
|
|
1451
|
+
const engine = scanUpstreamGlobalFlagOccurrences(args, "--engine").at(-1)?.value ?? env.AGENT_BROWSER_ENGINE;
|
|
1452
|
+
return (engine ?? "chrome") === "chrome" || engine === "";
|
|
1453
|
+
}
|
|
1454
|
+
function parseNavigationUrl(url) {
|
|
1455
|
+
if (url === void 0 || url.length === 0) {
|
|
1456
|
+
return;
|
|
1457
|
+
}
|
|
1458
|
+
try {
|
|
1459
|
+
return new URL(url);
|
|
1460
|
+
} catch {
|
|
1461
|
+
try {
|
|
1462
|
+
return new URL(`https://${url}`);
|
|
1463
|
+
} catch {
|
|
1464
|
+
return;
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
function getCompatibilityWorkaround(args, commandInfo) {
|
|
1469
|
+
if (!isOpenNavigationCommand(commandInfo.command) || !canUseHeadlessCompatibilityUserAgent(args)) {
|
|
1470
|
+
return;
|
|
1471
|
+
}
|
|
1472
|
+
const target = parseNavigationUrl(commandInfo.subcommand);
|
|
1473
|
+
if (!target || !["http:", "https:"].includes(target.protocol)) {
|
|
1474
|
+
return;
|
|
1475
|
+
}
|
|
1476
|
+
const hostname = target.hostname.toLowerCase();
|
|
1477
|
+
if (hostname === "dash.cloudflare.com") {
|
|
1478
|
+
return {
|
|
1479
|
+
id: "cloudflare-headless-user-agent",
|
|
1480
|
+
reason: "Cloudflare Dashboard challenges the default headless Chrome user agent; inject a normal Chrome user agent so authenticated headless browsing reaches the dashboard instead of Turnstile."
|
|
1481
|
+
};
|
|
1482
|
+
}
|
|
1483
|
+
if (!OPENAI_HOSTS.has(hostname)) {
|
|
1484
|
+
return;
|
|
1485
|
+
}
|
|
1486
|
+
return {
|
|
1487
|
+
id: "chatgpt-headless-user-agent",
|
|
1488
|
+
reason: "OpenAI web properties currently challenge the default headless Chrome user agent; inject a normal Chrome user agent to preserve the default headless workflow without requiring headed mode or auto-connect."
|
|
1489
|
+
};
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
// dist/extensions/agent-browser/lib/runtime-session-plan.js
|
|
1493
|
+
function stripExplicitIdentityArgs(args, flag) {
|
|
1494
|
+
const indices = /* @__PURE__ */ new Set();
|
|
1495
|
+
for (const occurrence of scanUpstreamGlobalFlagOccurrences(args, flag)) {
|
|
1496
|
+
indices.add(occurrence.index);
|
|
1497
|
+
indices.add(occurrence.index + 1);
|
|
1498
|
+
}
|
|
1499
|
+
return args.filter((_, index) => !indices.has(index));
|
|
1500
|
+
}
|
|
1501
|
+
function freshSessionRecoveryHint(args, reason) {
|
|
1502
|
+
return {
|
|
1503
|
+
exampleArgs: args,
|
|
1504
|
+
exampleParams: { args, sessionMode: "fresh" },
|
|
1505
|
+
reason,
|
|
1506
|
+
recommendedSessionMode: "fresh"
|
|
1507
|
+
};
|
|
1508
|
+
}
|
|
1509
|
+
function launchFlagsRecoveryReason() {
|
|
1510
|
+
return `Launch-scoped flags (${LAUNCH_SCOPED_FLAG_LABEL}) need a fresh upstream launch once the extension-managed session is already active.`;
|
|
1511
|
+
}
|
|
1512
|
+
function hasExplicitNamespace(args) {
|
|
1513
|
+
return scanUpstreamGlobalFlagOccurrences(args, "--namespace").length > 0;
|
|
1514
|
+
}
|
|
1515
|
+
function requestedNamespace(args) {
|
|
1516
|
+
return hasExplicitNamespace(args) ? extractExplicitNamespace(args) ?? "" : void 0;
|
|
1517
|
+
}
|
|
1518
|
+
function nativeNamespace(args) {
|
|
1519
|
+
return resolveAgentBrowserNamespace(args, getAgentBrowserProcessEnvironment().AGENT_BROWSER_NAMESPACE);
|
|
1520
|
+
}
|
|
1521
|
+
function explicitSessionSelection(args, sessionName, options) {
|
|
1522
|
+
const explicitNamespace = hasExplicitNamespace(args);
|
|
1523
|
+
const managedNamespace = canonicalizeAgentBrowserNamespace(options.managedSessionNamespace);
|
|
1524
|
+
const targetsCurrent = options.managedSessionActive && getAgentBrowserSessionIdentityKey(sessionName, managedNamespace) === getAgentBrowserSessionIdentityKey(options.managedSessionName, managedNamespace);
|
|
1525
|
+
const fallbackNamespace = targetsCurrent ? managedNamespace : nativeNamespace(args);
|
|
1526
|
+
const namespace = explicitNamespace ? requestedNamespace(args) : fallbackNamespace;
|
|
1527
|
+
return {
|
|
1528
|
+
argsToAppend: explicitNamespace ? stripExplicitIdentityArgs(args, "--namespace") : args,
|
|
1529
|
+
prefixArgs: explicitNamespace ? ["--namespace", namespace ?? ""] : [],
|
|
1530
|
+
namespace,
|
|
1531
|
+
sessionName,
|
|
1532
|
+
usedImplicitSession: false
|
|
1533
|
+
};
|
|
1534
|
+
}
|
|
1535
|
+
function namedManagedSelection(args, identity, implicit, command) {
|
|
1536
|
+
const { namespace, sessionName } = identity;
|
|
1537
|
+
return {
|
|
1538
|
+
argsToAppend: hasExplicitNamespace(args) ? stripExplicitIdentityArgs(args, "--namespace") : args,
|
|
1539
|
+
prefixArgs: [
|
|
1540
|
+
...namespace === void 0 ? [] : ["--namespace", namespace],
|
|
1541
|
+
"--session",
|
|
1542
|
+
sessionName
|
|
1543
|
+
],
|
|
1544
|
+
// Empty names retain native namespace reporting without changing the launch prefix.
|
|
1545
|
+
namespace: sessionName.length === 0 && command !== void 0 && !hasExplicitNamespace(args) ? nativeNamespace(args) : namespace,
|
|
1546
|
+
sessionName,
|
|
1547
|
+
managedSessionName: sessionName,
|
|
1548
|
+
usedImplicitSession: implicit
|
|
1549
|
+
};
|
|
1550
|
+
}
|
|
1551
|
+
function implicitSessionSelection(args, options, command) {
|
|
1552
|
+
if (options.managedSessionActive && command.startupScopedFlags.length > 0) {
|
|
1553
|
+
return {
|
|
1554
|
+
argsToAppend: args,
|
|
1555
|
+
prefixArgs: [],
|
|
1556
|
+
namespace: command.command === void 0 ? requestedNamespace(args) : nativeNamespace(args),
|
|
1557
|
+
usedImplicitSession: false,
|
|
1558
|
+
sessionName: extractExplicitSessionName(args),
|
|
1559
|
+
recoveryHint: freshSessionRecoveryHint(args, launchFlagsRecoveryReason()),
|
|
1560
|
+
validationError: [
|
|
1561
|
+
`The current extension-managed agent-browser session is already running, so launch-scoped flags ${command.startupScopedFlags.join(", ")} would be ignored by upstream agent-browser.`,
|
|
1562
|
+
'Retry this call with `sessionMode: "fresh"` to force a fresh upstream launch, or pass an explicit `--session ...` if you want to name the new session yourself.'
|
|
1563
|
+
].join(" ")
|
|
1564
|
+
};
|
|
1565
|
+
}
|
|
1566
|
+
const namespace = hasExplicitNamespace(args) ? requestedNamespace(args) : canonicalizeAgentBrowserNamespace(options.managedSessionNamespace);
|
|
1567
|
+
return namedManagedSelection(args, { sessionName: options.managedSessionName, namespace }, true, command.command);
|
|
1568
|
+
}
|
|
1569
|
+
function unmanagedSessionSelection(args, command) {
|
|
1570
|
+
const explicitNamespace = hasExplicitNamespace(args);
|
|
1571
|
+
const namespace = command !== void 0 && !explicitNamespace ? nativeNamespace(args) : requestedNamespace(args);
|
|
1572
|
+
return {
|
|
1573
|
+
argsToAppend: args,
|
|
1574
|
+
prefixArgs: [],
|
|
1575
|
+
namespace,
|
|
1576
|
+
sessionName: extractExplicitSessionName(args),
|
|
1577
|
+
usedImplicitSession: false
|
|
1578
|
+
};
|
|
1579
|
+
}
|
|
1580
|
+
function selectExecutionSession(args, options, command) {
|
|
1581
|
+
const explicitSession = extractExplicitSessionName(args);
|
|
1582
|
+
if (explicitSession !== void 0 && explicitSession.length > 0) {
|
|
1583
|
+
return explicitSessionSelection(args, explicitSession, options);
|
|
1584
|
+
}
|
|
1585
|
+
if (command.needsManagedSession) {
|
|
1586
|
+
if (options.sessionMode === "auto") {
|
|
1587
|
+
return implicitSessionSelection(args, options, command);
|
|
1588
|
+
}
|
|
1589
|
+
if (command.command !== void 0 && !isCloseCommand(command.command)) {
|
|
1590
|
+
return namedManagedSelection(args, { sessionName: options.freshSessionName, namespace: requestedNamespace(args) }, false, command.command);
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
return unmanagedSessionSelection(args, command.command);
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
// dist/extensions/agent-browser/lib/redaction-fields.js
|
|
1597
|
+
var SENSITIVE_FIELD_NAME_PATTERN = /^(?:[A-Za-z0-9_-]*(?:api[_-]?key|access[_-]?key|private[_-]?key|secret(?:[_-]?(?:key|access[_-]?key))?|token|password|passwd|credentials?|database[_-]?url|db[_-]?url|connection[_-]?string|mongo(?:db)?[_-]?uri|redis[_-]?url)|[A-Za-z0-9]*(?:apiKey|ApiKey|apikey|privateKey|PrivateKey|databaseUrl|DatabaseUrl|dbUrl|DbUrl|connectionString|ConnectionString|mongoUri|MongoUri|mongodbUri|MongodbUri|mongoDbUri|MongoDbUri|redisUrl|RedisUrl|Token|Secret|Password|Credential|Credentials)|auth(?:orization)?|bearer|client(?:_|-)?secret|cookie|id(?:_|-)?token|pass(?:word)?|proxy(?:_|-)?authorization|refresh(?:_|-)?token|sentry(?:_|-)?key|session(?:_|-)?id|set(?:_|-)?cookie|sig(?:nature)?|write(?:_|-)?key|x(?:_|-)?api(?:_|-)?key)$/i;
|
|
1598
|
+
var ENV_SECRET_ASSIGNMENT_PATTERN = /\b((?:export\s+)?([A-Za-z_][A-Za-z0-9_-]*)(\s*[:=]\s*))(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[^\s,;]+)/g;
|
|
1599
|
+
function isSensitiveFieldName(key) {
|
|
1600
|
+
SENSITIVE_FIELD_NAME_PATTERN.lastIndex = 0;
|
|
1601
|
+
return SENSITIVE_FIELD_NAME_PATTERN.test(key);
|
|
1602
|
+
}
|
|
1603
|
+
function isEnvSecretAssignmentKey(key) {
|
|
1604
|
+
if (!isSensitiveFieldName(key)) {
|
|
1605
|
+
return false;
|
|
1606
|
+
}
|
|
1607
|
+
if (key === "password" || key.includes("_") || key.includes("-") || key === key.toUpperCase()) {
|
|
1608
|
+
return true;
|
|
1609
|
+
}
|
|
1610
|
+
return /(?:apiKey|ApiKey|privateKey|PrivateKey|databaseUrl|DatabaseUrl|dbUrl|DbUrl|connectionString|ConnectionString|mongoUri|MongoUri|mongodbUri|MongodbUri|mongoDbUri|MongoDbUri|redisUrl|RedisUrl|Token|Secret|Password|Credential|Credentials)$/.test(key);
|
|
1611
|
+
}
|
|
1612
|
+
function isLineBoundary(text2, index) {
|
|
1613
|
+
return index < 0 || index >= text2.length || text2[index] === "\n" || text2[index] === "\r";
|
|
1614
|
+
}
|
|
1615
|
+
function redactPasswordAssignment(text2, match, prefix, offset) {
|
|
1616
|
+
const end = offset + match.length;
|
|
1617
|
+
if (!isLineBoundary(text2, offset - 1) || !isLineBoundary(text2, end) || /^(?:\[REDACTED\]|%5Bredacted%5D)/i.test(match.slice(prefix.length))) {
|
|
1618
|
+
return match;
|
|
1619
|
+
}
|
|
1620
|
+
const value = match.slice(prefix.length);
|
|
1621
|
+
const boundary = value[0] === '"' || value[0] === "'" ? -1 : value.search(/[&#](?=[A-Za-z_][A-Za-z0-9_-]*\s*=)/);
|
|
1622
|
+
return `${prefix}[REDACTED]${boundary < 0 ? "" : value.slice(boundary)}`;
|
|
1623
|
+
}
|
|
1624
|
+
function redactEnvSecretAssignments(text2) {
|
|
1625
|
+
return text2.replace(
|
|
1626
|
+
ENV_SECRET_ASSIGNMENT_PATTERN,
|
|
1627
|
+
// String.replace supplies match, three captures, then the source offset.
|
|
1628
|
+
(match, prefix, key, _separator, offset) => {
|
|
1629
|
+
if (!isEnvSecretAssignmentKey(key)) {
|
|
1630
|
+
return match;
|
|
1631
|
+
}
|
|
1632
|
+
return key === "password" ? redactPasswordAssignment(text2, match, prefix, offset) : `${prefix}[REDACTED]`;
|
|
1633
|
+
}
|
|
1634
|
+
);
|
|
1635
|
+
}
|
|
1636
|
+
function credentialTrailingPunctuation(credential) {
|
|
1637
|
+
return credential.match(/[,.:;!?]+$/)?.[0] ?? "";
|
|
1638
|
+
}
|
|
1639
|
+
function formatRedactedCredential(label, credential, trailing = "") {
|
|
1640
|
+
return `${label} [REDACTED]${credentialTrailingPunctuation(credential)}${trailing}`;
|
|
1641
|
+
}
|
|
1642
|
+
function redactBearerCredentials(text2) {
|
|
1643
|
+
return text2.replace(
|
|
1644
|
+
/((?:\b([A-Za-z][A-Za-z0-9_-]*)\s*[:=]\s*|(?:^|\s)(?:-H\s*|--header(?:\s+|=)))["']?Bearer)\s+([^\s"',)[\]]+)([),.]?)/gi,
|
|
1645
|
+
// String.replace supplies the match followed by this expression's four captures.
|
|
1646
|
+
(match, label, field, credential, trailing) => {
|
|
1647
|
+
if (field !== void 0 && field.length > 0 && !isSensitiveFieldName(field)) {
|
|
1648
|
+
return match;
|
|
1649
|
+
}
|
|
1650
|
+
return formatRedactedCredential(label, credential, trailing);
|
|
1651
|
+
}
|
|
1652
|
+
).replace(/\b(Bearer)\s+([^\s\\"',)[\]]+)([),.]?)/gi, (match, label, credential, trailing) => {
|
|
1653
|
+
const token = credential.slice(0, credential.length - credentialTrailingPunctuation(credential).length);
|
|
1654
|
+
if (!/^[A-Za-z0-9._~+/-]+=*$/.test(token) || !/[0-9._~+/=-]/.test(token)) {
|
|
1655
|
+
return match;
|
|
1656
|
+
}
|
|
1657
|
+
return formatRedactedCredential(label, credential, trailing);
|
|
1658
|
+
});
|
|
1659
|
+
}
|
|
1660
|
+
function redactStandaloneBasicCredential(text2) {
|
|
1661
|
+
return text2.replace(/\b(Basic)\s+([A-Za-z0-9+/=]{12,})/gi, (match, label, credential) => {
|
|
1662
|
+
if (!/[0-9+/=]/.test(credential)) {
|
|
1663
|
+
return match;
|
|
1664
|
+
}
|
|
1665
|
+
return `${label} [REDACTED]`;
|
|
1666
|
+
});
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1669
|
+
// dist/extensions/agent-browser/lib/redaction-json.js
|
|
1670
|
+
function nextQuotePosition(options) {
|
|
1671
|
+
if (options.char === '"') {
|
|
1672
|
+
return options.index;
|
|
1673
|
+
}
|
|
1674
|
+
return options.char === "\\" ? options.quoteAfterNext : options.quoteAtNext;
|
|
1675
|
+
}
|
|
1676
|
+
function buildJsonBoundaries(text2) {
|
|
1677
|
+
const boundaries = new Int32Array(text2.length + 1).fill(-1);
|
|
1678
|
+
let quoteAtNext = -1;
|
|
1679
|
+
let quoteAfterNext = -1;
|
|
1680
|
+
for (let index = text2.length - 1; index >= 0; index -= 1) {
|
|
1681
|
+
const char = text2[index];
|
|
1682
|
+
switch (char) {
|
|
1683
|
+
case "}":
|
|
1684
|
+
case "]":
|
|
1685
|
+
boundaries[index] = index;
|
|
1686
|
+
break;
|
|
1687
|
+
case '"':
|
|
1688
|
+
boundaries[index] = quoteAtNext < 0 ? -1 : boundaries[quoteAtNext + 1];
|
|
1689
|
+
break;
|
|
1690
|
+
case "{":
|
|
1691
|
+
case "[": {
|
|
1692
|
+
const end = boundaries[index + 1];
|
|
1693
|
+
boundaries[index] = end >= 0 && text2[end] === (char === "{" ? "}" : "]") ? boundaries[end + 1] : -1;
|
|
1694
|
+
break;
|
|
1695
|
+
}
|
|
1696
|
+
default:
|
|
1697
|
+
boundaries[index] = boundaries[index + 1];
|
|
1698
|
+
}
|
|
1699
|
+
const quote = nextQuotePosition({ char, index, quoteAtNext, quoteAfterNext });
|
|
1700
|
+
quoteAfterNext = quoteAtNext;
|
|
1701
|
+
quoteAtNext = quote;
|
|
1702
|
+
}
|
|
1703
|
+
return boundaries;
|
|
1704
|
+
}
|
|
1705
|
+
function createBalancedJsonEndFinder(text2) {
|
|
1706
|
+
let boundaries;
|
|
1707
|
+
return (startIndex) => {
|
|
1708
|
+
const opener = text2[startIndex];
|
|
1709
|
+
if (opener !== "{" && opener !== "[") {
|
|
1710
|
+
return;
|
|
1711
|
+
}
|
|
1712
|
+
boundaries ??= buildJsonBoundaries(text2);
|
|
1713
|
+
const end = boundaries[startIndex + 1];
|
|
1714
|
+
return end >= 0 && text2[end] === (opener === "{" ? "}" : "]") ? end : void 0;
|
|
1715
|
+
};
|
|
1716
|
+
}
|
|
1717
|
+
function parseJsonString(token) {
|
|
1718
|
+
const value = JSON.parse(token);
|
|
1719
|
+
if (typeof value !== "string") {
|
|
1720
|
+
throw new Error("Expected a JSON string token");
|
|
1721
|
+
}
|
|
1722
|
+
return value;
|
|
1723
|
+
}
|
|
1724
|
+
function isSerializedJson(text2) {
|
|
1725
|
+
if (text2 === "[REDACTED]" || !/^\s*[[{"\d\-tfn]/.test(text2)) {
|
|
1726
|
+
return false;
|
|
1727
|
+
}
|
|
1728
|
+
try {
|
|
1729
|
+
JSON.parse(text2);
|
|
1730
|
+
return true;
|
|
1731
|
+
} catch {
|
|
1732
|
+
return false;
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
function findJsonValueEnd(text2, start, findEnd) {
|
|
1736
|
+
const balancedEnd = findEnd(start);
|
|
1737
|
+
if (balancedEnd !== void 0) {
|
|
1738
|
+
return balancedEnd + 1;
|
|
1739
|
+
}
|
|
1740
|
+
if (text2[start] === '"') {
|
|
1741
|
+
const strings = /"(?:\\.|[^"\\])*"/g;
|
|
1742
|
+
strings.lastIndex = start;
|
|
1743
|
+
const fieldValue = strings.exec(text2);
|
|
1744
|
+
if (fieldValue === null) {
|
|
1745
|
+
throw new Error("Expected a validated JSON string field value");
|
|
1746
|
+
}
|
|
1747
|
+
return parseJsonString(fieldValue[0]) === "[REDACTED]" ? void 0 : strings.lastIndex;
|
|
1748
|
+
}
|
|
1749
|
+
let end = start;
|
|
1750
|
+
while (end < text2.length && !/[\s,\]}]/.test(text2[end])) {
|
|
1751
|
+
end += 1;
|
|
1752
|
+
}
|
|
1753
|
+
return end;
|
|
1754
|
+
}
|
|
1755
|
+
function redactSerializedJson(text2, redact) {
|
|
1756
|
+
if (!isSerializedJson(text2)) {
|
|
1757
|
+
return;
|
|
1758
|
+
}
|
|
1759
|
+
let output = "";
|
|
1760
|
+
let cursor = 0;
|
|
1761
|
+
const findEnd = createBalancedJsonEndFinder(text2);
|
|
1762
|
+
const strings = /"(?:\\.|[^"\\])*"/g;
|
|
1763
|
+
let match;
|
|
1764
|
+
while ((match = strings.exec(text2)) !== null) {
|
|
1765
|
+
const end = strings.lastIndex;
|
|
1766
|
+
const value = parseJsonString(match[0]);
|
|
1767
|
+
const redacted = redact(value);
|
|
1768
|
+
if (redacted !== value) {
|
|
1769
|
+
output += text2.slice(cursor, match.index) + JSON.stringify(redacted);
|
|
1770
|
+
cursor = end;
|
|
1771
|
+
}
|
|
1772
|
+
const separator = /^\s*:\s*/.exec(text2.slice(end));
|
|
1773
|
+
if (separator === null || !isSensitiveFieldName(value)) {
|
|
1774
|
+
continue;
|
|
1775
|
+
}
|
|
1776
|
+
const valueStart = end + separator[0].length;
|
|
1777
|
+
const valueEnd = findJsonValueEnd(text2, valueStart, findEnd);
|
|
1778
|
+
if (valueEnd === void 0) {
|
|
1779
|
+
strings.lastIndex = valueStart;
|
|
1780
|
+
strings.exec(text2);
|
|
1781
|
+
continue;
|
|
1782
|
+
}
|
|
1783
|
+
output += text2.slice(cursor, valueStart) + '"[REDACTED]"';
|
|
1784
|
+
cursor = valueEnd;
|
|
1785
|
+
strings.lastIndex = valueEnd;
|
|
1786
|
+
}
|
|
1787
|
+
return output + text2.slice(cursor);
|
|
1788
|
+
}
|
|
1789
|
+
function redactEmbeddedStructuredText(text2, redact) {
|
|
1790
|
+
let output = "";
|
|
1791
|
+
let cursor = 0;
|
|
1792
|
+
const findEnd = createBalancedJsonEndFinder(text2);
|
|
1793
|
+
const openers = /[[{]/g;
|
|
1794
|
+
let match;
|
|
1795
|
+
while ((match = openers.exec(text2)) !== null) {
|
|
1796
|
+
const endIndex = findEnd(match.index);
|
|
1797
|
+
if (endIndex === void 0) {
|
|
1798
|
+
continue;
|
|
1799
|
+
}
|
|
1800
|
+
const candidate = text2.slice(match.index, endIndex + 1);
|
|
1801
|
+
const redacted = redactSerializedJson(candidate, redact) ?? candidate;
|
|
1802
|
+
if (redacted !== candidate) {
|
|
1803
|
+
output += text2.slice(cursor, match.index) + redacted;
|
|
1804
|
+
cursor = endIndex + 1;
|
|
1805
|
+
}
|
|
1806
|
+
openers.lastIndex = endIndex + 1;
|
|
1807
|
+
}
|
|
1808
|
+
return cursor === 0 ? text2 : output + text2.slice(cursor);
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1811
|
+
// dist/extensions/agent-browser/lib/redaction-url.js
|
|
1812
|
+
var SENSITIVE_QUERY_PARAM_PATTERN = /^(?:access(?:_|-)?token|api(?:_|-)?key|auth|authorization|authorization(?:_|-)?session(?:_|-)?id|bearer|client(?:_|-)?secret|code|cookie|id(?:_|-)?token|key|pass(?:word)?|refresh(?:_|-)?token|relay(?:_|-)?state|saml(?:_|-)?request|saml(?:_|-)?response|secret|sentry(?:_|-)?key|session(?:_|-)?id|sig(?:nature)?|token|write(?:_|-)?key)$/i;
|
|
1813
|
+
var AUTH_STATE_QUERY_PARAM_PATTERN = /^(?:nonce|state)$/i;
|
|
1814
|
+
var AUTH_URL_CONTEXT_PATTERN = /(?:^|[./_-])(?:auth|authorize|callback|login|oauth2?|oidc|saml|sso)(?:[./?#_-]|$)/i;
|
|
1815
|
+
function shouldRedactQueryParam(name) {
|
|
1816
|
+
return SENSITIVE_QUERY_PARAM_PATTERN.test(name) || isSensitiveFieldName(name);
|
|
1817
|
+
}
|
|
1818
|
+
function isSensitiveParameter(name, authContext) {
|
|
1819
|
+
return shouldRedactQueryParam(name) || authContext && AUTH_STATE_QUERY_PARAM_PATTERN.test(name);
|
|
1820
|
+
}
|
|
1821
|
+
function redactParameters(params, authContext) {
|
|
1822
|
+
let mutated = false;
|
|
1823
|
+
for (const [name] of params) {
|
|
1824
|
+
if (isSensitiveParameter(name, authContext)) {
|
|
1825
|
+
params.set(name, "[REDACTED]");
|
|
1826
|
+
mutated = true;
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
return mutated;
|
|
1830
|
+
}
|
|
1831
|
+
function getHashParameters(hash) {
|
|
1832
|
+
const text2 = hash.startsWith("#") ? hash.slice(1) : hash;
|
|
1833
|
+
return text2.includes("=") ? new URLSearchParams(text2) : void 0;
|
|
1834
|
+
}
|
|
1835
|
+
function redactUrlToken(token) {
|
|
1836
|
+
let parsed;
|
|
1837
|
+
try {
|
|
1838
|
+
parsed = new URL(token);
|
|
1839
|
+
} catch {
|
|
1840
|
+
return token;
|
|
1841
|
+
}
|
|
1842
|
+
const originalHref = parsed.href;
|
|
1843
|
+
if (parsed.username.length > 0) {
|
|
1844
|
+
parsed.username = "[REDACTED]";
|
|
1845
|
+
}
|
|
1846
|
+
if (parsed.password.length > 0) {
|
|
1847
|
+
parsed.password = "[REDACTED]";
|
|
1848
|
+
}
|
|
1849
|
+
const hashParams = getHashParameters(parsed.hash);
|
|
1850
|
+
const authContext = AUTH_URL_CONTEXT_PATTERN.test(`${parsed.hostname}${parsed.pathname}`) || [...parsed.searchParams.keys(), ...hashParams?.keys() ?? []].some(shouldRedactQueryParam);
|
|
1851
|
+
redactParameters(parsed.searchParams, authContext);
|
|
1852
|
+
if (hashParams && redactParameters(hashParams, authContext)) {
|
|
1853
|
+
parsed.hash = `#${hashParams.toString()}`;
|
|
1854
|
+
}
|
|
1855
|
+
return parsed.href === originalHref ? token : parsed.href;
|
|
1856
|
+
}
|
|
1857
|
+
function decodeParameterName(raw) {
|
|
1858
|
+
try {
|
|
1859
|
+
return decodeURIComponent(raw.replace(/\+/g, " "));
|
|
1860
|
+
} catch {
|
|
1861
|
+
return raw;
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
function redactLooseUrlParameterText(text2) {
|
|
1865
|
+
return text2.replace(/(?<![^\s"'`<>\])}])[^\s"'`<>\])}]*[?#&][^\s"'`<>\])}]*/g, (token) => {
|
|
1866
|
+
const queryNames = [...token.matchAll(/[?#&]([^=&#\s"'`<>\])}]+)=/g)].map((match) => decodeParameterName(match[1]));
|
|
1867
|
+
const authContext = AUTH_URL_CONTEXT_PATTERN.test(token) || queryNames.some(shouldRedactQueryParam);
|
|
1868
|
+
return token.replace(/([?#&])([^=&#\s"'`<>\])}]+)=([^&#\s"'`<>\])}]*)/g, (match, separator, rawName, rawValue) => {
|
|
1869
|
+
if (rawValue === "[REDACTED" || rawValue === "[REDACTED]" || /%5Bredacted%5D/i.test(rawValue)) {
|
|
1870
|
+
return match;
|
|
1871
|
+
}
|
|
1872
|
+
if (!isSensitiveParameter(decodeParameterName(rawName), authContext)) {
|
|
1873
|
+
return match;
|
|
1874
|
+
}
|
|
1875
|
+
return `${separator}${rawName}=[REDACTED]`;
|
|
1876
|
+
});
|
|
1877
|
+
});
|
|
1878
|
+
}
|
|
1879
|
+
function redactLooseUrlUserinfo(text2) {
|
|
1880
|
+
return text2.replace(/\b([A-Za-z][A-Za-z0-9+.-]*:\/\/)([^\s"'`/@]+)@([^\s"'`]+)/g, (match, prefix, userinfo, suffix) => {
|
|
1881
|
+
if (/%5Bredacted%5D/i.test(userinfo)) {
|
|
1882
|
+
return match;
|
|
1883
|
+
}
|
|
1884
|
+
if (userinfo.includes("[REDACTED]")) {
|
|
1885
|
+
return redactLooseUrlParameterText(match);
|
|
1886
|
+
}
|
|
1887
|
+
return redactLooseUrlParameterText(`${prefix}${userinfo.includes(":") ? "[REDACTED]:[REDACTED]" : "[REDACTED]"}@${suffix}`);
|
|
1888
|
+
});
|
|
1889
|
+
}
|
|
1890
|
+
function redactLooseUrls(text2) {
|
|
1891
|
+
const urls = text2.replace(/\b[A-Za-z][A-Za-z0-9+.-]*:\/\/[^\s"'`<>\])]+/g, (match) => redactUrlToken(match));
|
|
1892
|
+
return redactLooseUrlParameterText(redactLooseUrlUserinfo(urls));
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
// dist/extensions/agent-browser/lib/runtime-redaction.js
|
|
1896
|
+
var SENSITIVE_VALUE_FLAGS = /* @__PURE__ */ new Set(["--body", "--headers", "--password", "--proxy"]);
|
|
1897
|
+
function redactSensitiveText(text2) {
|
|
1898
|
+
const serialized = redactSerializedJson(text2, redactSensitiveText);
|
|
1899
|
+
if (serialized !== void 0) {
|
|
1900
|
+
return serialized;
|
|
1901
|
+
}
|
|
1902
|
+
const embedded = redactEmbeddedStructuredText(text2, redactSensitiveText);
|
|
1903
|
+
const credentials = redactStandaloneBasicCredential(redactBearerCredentials(redactLooseUrls(embedded))).replace(/\b(Authorization\s*:\s*Basic)\s+[^\s",]+/gi, "$1 [REDACTED]").replace(/\b(Cookie|Set-Cookie)\s*:\s*[^\n\r"]+/gi, "$1: [REDACTED]");
|
|
1904
|
+
return redactEmbeddedStructuredText(redactEnvSecretAssignments(credentials), redactSensitiveText);
|
|
1905
|
+
}
|
|
1906
|
+
function redactSensitiveValue(value) {
|
|
1907
|
+
if (typeof value === "string") {
|
|
1908
|
+
return redactSensitiveText(value);
|
|
1909
|
+
}
|
|
1910
|
+
if (Array.isArray(value)) {
|
|
1911
|
+
return value.map((item) => redactSensitiveValue(item));
|
|
1912
|
+
}
|
|
1913
|
+
if (!isRecord(value)) {
|
|
1914
|
+
return value;
|
|
1915
|
+
}
|
|
1916
|
+
return Object.fromEntries(Object.entries(value).map(([key, entryValue]) => [
|
|
1917
|
+
key,
|
|
1918
|
+
isSensitiveFieldName(key) ? "[REDACTED]" : redactSensitiveValue(entryValue)
|
|
1919
|
+
]));
|
|
1920
|
+
}
|
|
1921
|
+
function redactFlagTokens(args) {
|
|
1922
|
+
const redacted = [];
|
|
1923
|
+
let pendingValueFlag;
|
|
1924
|
+
for (const token of args) {
|
|
1925
|
+
if (pendingValueFlag !== void 0) {
|
|
1926
|
+
redacted.push(SENSITIVE_VALUE_FLAGS.has(pendingValueFlag) ? "[REDACTED]" : redactUrlToken(token));
|
|
1927
|
+
pendingValueFlag = void 0;
|
|
1928
|
+
continue;
|
|
1929
|
+
}
|
|
1930
|
+
const normalizedToken = token.split("=", 1)[0] ?? token;
|
|
1931
|
+
if (SENSITIVE_VALUE_FLAGS.has(normalizedToken)) {
|
|
1932
|
+
if (token.includes("=")) {
|
|
1933
|
+
redacted.push(`${normalizedToken}=[REDACTED]`);
|
|
1934
|
+
} else {
|
|
1935
|
+
redacted.push(token);
|
|
1936
|
+
pendingValueFlag = normalizedToken;
|
|
1937
|
+
}
|
|
1938
|
+
continue;
|
|
1939
|
+
}
|
|
1940
|
+
redacted.push(redactSensitiveText(redactUrlToken(token)));
|
|
1941
|
+
}
|
|
1942
|
+
return redacted;
|
|
1943
|
+
}
|
|
1944
|
+
function sensitiveOperandIndices(args, start) {
|
|
1945
|
+
const command = args[start];
|
|
1946
|
+
const subcommand = args[start + 1];
|
|
1947
|
+
switch (command) {
|
|
1948
|
+
case "set":
|
|
1949
|
+
return subcommand === "credentials" ? [start + 2, start + 3] : [];
|
|
1950
|
+
case "cookies":
|
|
1951
|
+
return subcommand === "set" && !extractUpstreamCommandTokens(args).slice(2).includes("--curl") ? [start + 3] : [];
|
|
1952
|
+
case "storage":
|
|
1953
|
+
return ["local", "session"].includes(subcommand) && args[start + 2] === "set" ? [start + 4] : [];
|
|
1954
|
+
case "clipboard":
|
|
1955
|
+
return subcommand === "write" ? args.slice(start + 2).map((_, index) => start + 2 + index) : [];
|
|
1956
|
+
default:
|
|
1957
|
+
return [];
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
function redactBatchRows(args) {
|
|
1961
|
+
const batch = projectUpstreamGlobalFlags(args);
|
|
1962
|
+
const replacements = /* @__PURE__ */ new Map();
|
|
1963
|
+
if (batch.tokens[0] !== "batch") {
|
|
1964
|
+
return replacements;
|
|
1965
|
+
}
|
|
1966
|
+
for (let index = 1; index < batch.tokens.length; index++) {
|
|
1967
|
+
if (batch.tokens[index] === "--bail") {
|
|
1968
|
+
continue;
|
|
1969
|
+
}
|
|
1970
|
+
const step = parseBatchCommandArgument(batch.tokens[index]).step;
|
|
1971
|
+
if (!step) {
|
|
1972
|
+
continue;
|
|
1973
|
+
}
|
|
1974
|
+
const safe = redactInvocationArgs(step);
|
|
1975
|
+
if (safe.some((token, offset) => token !== step[offset])) {
|
|
1976
|
+
replacements.set(batch.indices[index], safe.map((token) => `'${token.replaceAll("'", "'\\''")}'`).join(" "));
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
return replacements;
|
|
1980
|
+
}
|
|
1981
|
+
function redactInvocationArgs(args) {
|
|
1982
|
+
const redacted = redactFlagTokens(args);
|
|
1983
|
+
const start = findCommandStartIndex(args);
|
|
1984
|
+
if (start !== void 0) {
|
|
1985
|
+
for (const index of sensitiveOperandIndices(args, start)) {
|
|
1986
|
+
if (index < redacted.length) {
|
|
1987
|
+
redacted[index] = "[REDACTED]";
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
}
|
|
1991
|
+
for (const [index, replacement] of redactBatchRows(args)) {
|
|
1992
|
+
redacted[index] = replacement;
|
|
1993
|
+
}
|
|
1994
|
+
return redacted;
|
|
1995
|
+
}
|
|
1996
|
+
|
|
1997
|
+
// dist/extensions/agent-browser/lib/runtime-timeouts.js
|
|
1998
|
+
var DEFAULT_IMPLICIT_SESSION_IDLE_TIMEOUT_MS = 15 * 60 * 1e3;
|
|
1999
|
+
var DEFAULT_IMPLICIT_SESSION_CLOSE_TIMEOUT_MS = 35e3;
|
|
2000
|
+
function parseTimeoutMs(rawValue, minimumValue) {
|
|
2001
|
+
if (rawValue === void 0) {
|
|
2002
|
+
return;
|
|
2003
|
+
}
|
|
2004
|
+
const normalizedValue = rawValue.trim();
|
|
2005
|
+
if (!/^\d+$/.test(normalizedValue)) {
|
|
2006
|
+
return;
|
|
2007
|
+
}
|
|
2008
|
+
const parsedValue = Number(normalizedValue);
|
|
2009
|
+
if (!Number.isSafeInteger(parsedValue) || parsedValue < minimumValue) {
|
|
2010
|
+
return;
|
|
2011
|
+
}
|
|
2012
|
+
return parsedValue;
|
|
2013
|
+
}
|
|
2014
|
+
function getImplicitSessionIdleTimeoutMs(env = getAgentBrowserProcessEnvironment()) {
|
|
2015
|
+
return parseTimeoutMs(env.PI_AGENT_BROWSER_IMPLICIT_SESSION_IDLE_TIMEOUT_MS, 0) ?? parseTimeoutMs(env.AGENT_BROWSER_IDLE_TIMEOUT_MS, 0) ?? DEFAULT_IMPLICIT_SESSION_IDLE_TIMEOUT_MS;
|
|
2016
|
+
}
|
|
2017
|
+
function getImplicitSessionCloseTimeoutMs(env = getAgentBrowserProcessEnvironment()) {
|
|
2018
|
+
return parseTimeoutMs(env.PI_AGENT_BROWSER_IMPLICIT_SESSION_CLOSE_TIMEOUT_MS, 0) ?? DEFAULT_IMPLICIT_SESSION_CLOSE_TIMEOUT_MS;
|
|
2019
|
+
}
|
|
2020
|
+
|
|
2021
|
+
// dist/extensions/agent-browser/lib/runtime-session-identity.js
|
|
2022
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2023
|
+
import { basename } from "node:path";
|
|
2024
|
+
|
|
2025
|
+
// dist/extensions/agent-browser/lib/owned-managed-session-context.js
|
|
2026
|
+
import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
|
|
2027
|
+
var ownedManagedSessionStorage = new AsyncLocalStorage2();
|
|
2028
|
+
|
|
2029
|
+
// dist/extensions/agent-browser/lib/managed-session-snapshot-records.js
|
|
2030
|
+
var OWNED_RESTORE_SNAPSHOT_RECORD_MAX_BYTES = 16 * 1024;
|
|
2031
|
+
var OWNED_RESTORE_SNAPSHOT_MAX_AGE_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
2032
|
+
|
|
2033
|
+
// dist/extensions/agent-browser/lib/managed-session-restore.js
|
|
2034
|
+
var MANAGED_SESSION_NAME_PREFIX = "piab-";
|
|
2035
|
+
|
|
2036
|
+
// dist/extensions/agent-browser/lib/runtime-session-identity.js
|
|
2037
|
+
function namespaceFields(namespace) {
|
|
2038
|
+
return namespace === void 0 ? {} : { namespace };
|
|
2039
|
+
}
|
|
2040
|
+
function resolveManagedSessionState(options) {
|
|
2041
|
+
const { command, managedSessionName, priorActive, priorSessionName, succeeded } = options;
|
|
2042
|
+
const managedNamespace = canonicalizeAgentBrowserNamespace(options.managedSessionNamespace);
|
|
2043
|
+
const priorNamespace = canonicalizeAgentBrowserNamespace(options.priorNamespace);
|
|
2044
|
+
const priorState = {
|
|
2045
|
+
active: priorActive,
|
|
2046
|
+
...namespaceFields(priorNamespace),
|
|
2047
|
+
sessionName: priorSessionName
|
|
2048
|
+
};
|
|
2049
|
+
if (managedSessionName === void 0 || managedSessionName.length === 0) {
|
|
2050
|
+
return priorState;
|
|
2051
|
+
}
|
|
2052
|
+
if (isCloseCommand(command) && managedSessionName === priorSessionName) {
|
|
2053
|
+
if (managedNamespace !== priorNamespace || !succeeded) {
|
|
2054
|
+
return priorState;
|
|
2055
|
+
}
|
|
2056
|
+
return { active: false, sessionName: priorSessionName };
|
|
2057
|
+
}
|
|
2058
|
+
if (!succeeded) {
|
|
2059
|
+
return priorState;
|
|
2060
|
+
}
|
|
2061
|
+
return {
|
|
2062
|
+
active: true,
|
|
2063
|
+
...namespaceFields(managedNamespace),
|
|
2064
|
+
replacedSessionName: priorActive && priorSessionName !== managedSessionName ? priorSessionName : void 0,
|
|
2065
|
+
sessionName: managedSessionName
|
|
2066
|
+
};
|
|
2067
|
+
}
|
|
2068
|
+
function isRestorableManagedSessionName(sessionName, fallbackSessionName) {
|
|
2069
|
+
return sessionName === fallbackSessionName || sessionName.startsWith(`${fallbackSessionName}-fresh-`);
|
|
2070
|
+
}
|
|
2071
|
+
function getRestorableManagedSessionName(value, fallbackSessionName) {
|
|
2072
|
+
return typeof value === "string" && isRestorableManagedSessionName(value, fallbackSessionName) ? value : void 0;
|
|
2073
|
+
}
|
|
2074
|
+
function createEphemeralSessionSeed() {
|
|
2075
|
+
return randomUUID();
|
|
2076
|
+
}
|
|
2077
|
+
function createImplicitSessionName(sessionId, cwd, ephemeralSeed, platform = process.platform) {
|
|
2078
|
+
const normalizedSessionId = sessionId?.replaceAll("-", "").toLowerCase();
|
|
2079
|
+
const identity = normalizedSessionId !== void 0 && normalizedSessionId.length > 0 ? `session:${normalizedSessionId}:cwd:${cwd}` : `ephemeral:${cwd}:${ephemeralSeed}`;
|
|
2080
|
+
if (platform === "android") {
|
|
2081
|
+
return `${MANAGED_SESSION_NAME_PREFIX}${createHash("sha256").update(identity).digest("hex").slice(0, 20)}`;
|
|
2082
|
+
}
|
|
2083
|
+
const projectSlug = basename(cwd).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 24);
|
|
2084
|
+
const slug = projectSlug.length > 0 ? projectSlug : "project";
|
|
2085
|
+
const cwdHash = createHash("sha256").update(`cwd:${cwd}`).digest("hex").slice(0, 8);
|
|
2086
|
+
const sessionIdentity = normalizedSessionId !== void 0 && normalizedSessionId.length > 0 ? `session:${normalizedSessionId}` : identity;
|
|
2087
|
+
const digest = createHash("sha256").update(sessionIdentity).digest("hex").slice(0, 12);
|
|
2088
|
+
return `${MANAGED_SESSION_NAME_PREFIX}${slug}-${digest}-${cwdHash}`;
|
|
2089
|
+
}
|
|
2090
|
+
function createFreshSessionName(baseSessionName, ephemeralSeed, ordinal) {
|
|
2091
|
+
const suffix = createHash("sha256").update(`fresh:${baseSessionName}:${ephemeralSeed}:${ordinal}`).digest("hex").slice(0, 10);
|
|
2092
|
+
return `${baseSessionName}-fresh-${suffix}`;
|
|
2093
|
+
}
|
|
2094
|
+
|
|
2095
|
+
// dist/extensions/agent-browser/lib/page-target-navigation.js
|
|
2096
|
+
var POSITIONAL_VALUE_FLAGS = /* @__PURE__ */ new Set([...VALUE_FLAGS, "--llms"]);
|
|
2097
|
+
|
|
2098
|
+
// dist/extensions/agent-browser/lib/native-confirmation.js
|
|
2099
|
+
function isSuccessfulNativeConfirmedClose(commandTokens, data) {
|
|
2100
|
+
if (commandTokens[0] !== "confirm" || commandTokens.length !== 2 || !isRecord(data) || data.confirmed !== true || data.action !== "close") {
|
|
2101
|
+
return false;
|
|
2102
|
+
}
|
|
2103
|
+
return isRecord(data.result) && data.result.success === true && isRecord(data.result.data) && data.result.data.closed === true;
|
|
2104
|
+
}
|
|
2105
|
+
|
|
2106
|
+
// dist/extensions/agent-browser/lib/results/confirmation.js
|
|
2107
|
+
var CONFIRMATION_REQUIRED_FIELD_NAMES = [
|
|
2108
|
+
"confirmation_required",
|
|
2109
|
+
"confirmationRequired",
|
|
2110
|
+
"requires_confirmation",
|
|
2111
|
+
"requiresConfirmation"
|
|
2112
|
+
];
|
|
2113
|
+
var CONFIRMATION_REQUIRED_RECORD_FIELD_NAMES = [
|
|
2114
|
+
"confirmation",
|
|
2115
|
+
"pendingConfirmation",
|
|
2116
|
+
"pending_confirmation"
|
|
2117
|
+
];
|
|
2118
|
+
var CONFIRMATION_ID_FIELD_NAMES = ["confirmation_id", "confirmationId", "id"];
|
|
2119
|
+
var CONFIRMATION_ACTION_TEXT_FIELD_NAMES = [
|
|
2120
|
+
"action",
|
|
2121
|
+
"description",
|
|
2122
|
+
"message",
|
|
2123
|
+
"summary"
|
|
2124
|
+
];
|
|
2125
|
+
var CONFIRMATION_REQUIRED_MARKER = "confirmation_required";
|
|
2126
|
+
function getTrimmedStringField(data, fieldNames) {
|
|
2127
|
+
for (const fieldName of fieldNames) {
|
|
2128
|
+
const value = data[fieldName];
|
|
2129
|
+
if (typeof value === "string" && value.trim().length > 0) {
|
|
2130
|
+
return value.trim();
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
return void 0;
|
|
2134
|
+
}
|
|
2135
|
+
function hasConfirmationRequiredMarker(data) {
|
|
2136
|
+
return CONFIRMATION_REQUIRED_FIELD_NAMES.some((fieldName) => data[fieldName] === true) || data.type === CONFIRMATION_REQUIRED_MARKER || data.status === CONFIRMATION_REQUIRED_MARKER || data.kind === CONFIRMATION_REQUIRED_MARKER;
|
|
2137
|
+
}
|
|
2138
|
+
function getNestedConfirmationRecord(data) {
|
|
2139
|
+
for (const fieldName of CONFIRMATION_REQUIRED_RECORD_FIELD_NAMES) {
|
|
2140
|
+
const value = data[fieldName];
|
|
2141
|
+
if (isRecord(value)) {
|
|
2142
|
+
return value;
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2145
|
+
return void 0;
|
|
2146
|
+
}
|
|
2147
|
+
function getConfirmationPayload(data) {
|
|
2148
|
+
return isRecord(data) && data.confirmed === true && isRecord(data.result) && data.result.success === true ? data.result.data : data;
|
|
2149
|
+
}
|
|
2150
|
+
function detectConfirmationRequired(data) {
|
|
2151
|
+
const payload = getConfirmationPayload(data);
|
|
2152
|
+
if (!isRecord(payload)) {
|
|
2153
|
+
return void 0;
|
|
2154
|
+
}
|
|
2155
|
+
const nestedRecord = getNestedConfirmationRecord(payload);
|
|
2156
|
+
const candidateRecords = nestedRecord ? [payload, nestedRecord] : [payload];
|
|
2157
|
+
if (!candidateRecords.some(hasConfirmationRequiredMarker)) {
|
|
2158
|
+
return void 0;
|
|
2159
|
+
}
|
|
2160
|
+
for (const record of candidateRecords) {
|
|
2161
|
+
const id = getTrimmedStringField(record, CONFIRMATION_ID_FIELD_NAMES);
|
|
2162
|
+
if (id === void 0 || id.length === 0) {
|
|
2163
|
+
continue;
|
|
2164
|
+
}
|
|
2165
|
+
return {
|
|
2166
|
+
actionText: getTrimmedStringField(record, CONFIRMATION_ACTION_TEXT_FIELD_NAMES),
|
|
2167
|
+
id
|
|
2168
|
+
};
|
|
2169
|
+
}
|
|
2170
|
+
return void 0;
|
|
2171
|
+
}
|
|
2172
|
+
|
|
2173
|
+
// dist/extensions/agent-browser/lib/batch-lifecycle.js
|
|
2174
|
+
function rowCommand(value, fallback) {
|
|
2175
|
+
return Array.isArray(value) && value.every((token) => typeof token === "string") ? value : fallback;
|
|
2176
|
+
}
|
|
2177
|
+
function rowResult(row) {
|
|
2178
|
+
if (isRecord(row.result)) {
|
|
2179
|
+
return row.result;
|
|
2180
|
+
}
|
|
2181
|
+
return isRecord(row.data) ? row.data : void 0;
|
|
2182
|
+
}
|
|
2183
|
+
function rowBrowserLaunched(row, result) {
|
|
2184
|
+
const lifecycle = isRecord(row.lifecycle) ? row.lifecycle : result?.lifecycle;
|
|
2185
|
+
if (!isRecord(lifecycle) || !isRecord(lifecycle.effectiveLaunch)) {
|
|
2186
|
+
return void 0;
|
|
2187
|
+
}
|
|
2188
|
+
const launched = lifecycle.effectiveLaunch.browserLaunched;
|
|
2189
|
+
return typeof launched === "boolean" ? launched : void 0;
|
|
2190
|
+
}
|
|
2191
|
+
function lifecycleStep(value, fallback) {
|
|
2192
|
+
if (!isRecord(value)) {
|
|
2193
|
+
return void 0;
|
|
2194
|
+
}
|
|
2195
|
+
const result = rowResult(value);
|
|
2196
|
+
const command = rowCommand(value.command, fallback);
|
|
2197
|
+
return {
|
|
2198
|
+
result,
|
|
2199
|
+
succeeded: value.success === true,
|
|
2200
|
+
browserLaunched: rowBrowserLaunched(value, result),
|
|
2201
|
+
tokens: command === void 0 ? void 0 : extractUpstreamCommandTokens(command)
|
|
2202
|
+
};
|
|
2203
|
+
}
|
|
2204
|
+
function batchHasSuccessfulCloseAll(data, fallbackCommands = []) {
|
|
2205
|
+
if (!Array.isArray(data)) {
|
|
2206
|
+
return false;
|
|
2207
|
+
}
|
|
2208
|
+
return data.some((row, index) => {
|
|
2209
|
+
if (!isRecord(row) || row.success !== true) {
|
|
2210
|
+
return false;
|
|
2211
|
+
}
|
|
2212
|
+
const command = rowCommand(row.command, fallbackCommands.at(index));
|
|
2213
|
+
return command !== void 0 && !detectConfirmationRequired(row.result) && isCloseAllCommand(extractUpstreamCommandTokens(command));
|
|
2214
|
+
});
|
|
2215
|
+
}
|
|
2216
|
+
function successfulClose(step) {
|
|
2217
|
+
return step.succeeded && step.tokens !== void 0 && !detectConfirmationRequired(step.result) && (isCloseCommand(step.tokens[0]) || isSuccessfulNativeConfirmedClose(step.tokens, step.result));
|
|
2218
|
+
}
|
|
2219
|
+
function closedState(step) {
|
|
2220
|
+
const result = step.result;
|
|
2221
|
+
const closeData = step.tokens?.[0] === "confirm" && isRecord(result) && isRecord(result.result) ? result.result.data : result;
|
|
2222
|
+
return {
|
|
2223
|
+
endsClosed: true,
|
|
2224
|
+
browserActiveAfterClose: false,
|
|
2225
|
+
recordingClosedAfterBatch: true,
|
|
2226
|
+
statePath: isRecord(closeData) && typeof closeData.statePath === "string" ? closeData.statePath : void 0
|
|
2227
|
+
};
|
|
2228
|
+
}
|
|
2229
|
+
function recordingState(state, step) {
|
|
2230
|
+
const relaunched = step.browserLaunched !== false;
|
|
2231
|
+
const browserActiveAfterClose = state.browserActiveAfterClose || relaunched;
|
|
2232
|
+
let recordingClosedAfterBatch = state.recordingClosedAfterBatch;
|
|
2233
|
+
const subcommand = step.tokens?.[1];
|
|
2234
|
+
if (step.succeeded && subcommand === "stop") {
|
|
2235
|
+
recordingClosedAfterBatch = true;
|
|
2236
|
+
} else if (step.succeeded && browserActiveAfterClose && (subcommand === "start" || subcommand === "restart")) {
|
|
2237
|
+
recordingClosedAfterBatch = false;
|
|
2238
|
+
}
|
|
2239
|
+
return {
|
|
2240
|
+
...state,
|
|
2241
|
+
endsClosed: state.endsClosed && !relaunched,
|
|
2242
|
+
browserActiveAfterClose,
|
|
2243
|
+
recordingClosedAfterBatch
|
|
2244
|
+
};
|
|
2245
|
+
}
|
|
2246
|
+
function advanceClosedState(state, step) {
|
|
2247
|
+
if (step.tokens?.[0] === "record") {
|
|
2248
|
+
return recordingState(state, step);
|
|
2249
|
+
}
|
|
2250
|
+
if (step.browserLaunched === false) {
|
|
2251
|
+
return state;
|
|
2252
|
+
}
|
|
2253
|
+
return {
|
|
2254
|
+
...state,
|
|
2255
|
+
endsClosed: false,
|
|
2256
|
+
browserActiveAfterClose: true,
|
|
2257
|
+
recordingClosedAfterBatch: step.tokens === void 0 ? false : state.recordingClosedAfterBatch
|
|
2258
|
+
};
|
|
2259
|
+
}
|
|
2260
|
+
function getSuccessfulBatchCloseLifecycle(rows, fallbackCommands = []) {
|
|
2261
|
+
if (!Array.isArray(rows)) {
|
|
2262
|
+
return void 0;
|
|
2263
|
+
}
|
|
2264
|
+
let state;
|
|
2265
|
+
for (const [index, row] of rows.entries()) {
|
|
2266
|
+
const step = lifecycleStep(row, fallbackCommands.at(index));
|
|
2267
|
+
if (step === void 0) {
|
|
2268
|
+
continue;
|
|
2269
|
+
}
|
|
2270
|
+
if (successfulClose(step)) {
|
|
2271
|
+
state = closedState(step);
|
|
2272
|
+
} else if (state !== void 0) {
|
|
2273
|
+
state = advanceClosedState(state, step);
|
|
2274
|
+
}
|
|
2275
|
+
}
|
|
2276
|
+
return state === void 0 ? void 0 : {
|
|
2277
|
+
endsClosed: state.endsClosed,
|
|
2278
|
+
recordingClosedAfterBatch: state.recordingClosedAfterBatch,
|
|
2279
|
+
statePath: state.statePath
|
|
2280
|
+
};
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2283
|
+
// dist/extensions/agent-browser/lib/browser-value-parsing.js
|
|
2284
|
+
function isBrowserStringArray(value) {
|
|
2285
|
+
if (!Array.isArray(value)) {
|
|
2286
|
+
return false;
|
|
2287
|
+
}
|
|
2288
|
+
const rows = value;
|
|
2289
|
+
return rows.every((row) => typeof row === "string");
|
|
2290
|
+
}
|
|
2291
|
+
|
|
2292
|
+
// dist/extensions/agent-browser/lib/session-page-observation.js
|
|
2293
|
+
function normalizeComparableUrl(url) {
|
|
2294
|
+
const normalizedUrl = url?.trim();
|
|
2295
|
+
if (normalizedUrl === void 0 || normalizedUrl.length === 0) {
|
|
2296
|
+
return void 0;
|
|
2297
|
+
}
|
|
2298
|
+
try {
|
|
2299
|
+
const parsedUrl = new URL(normalizedUrl);
|
|
2300
|
+
parsedUrl.hash = "";
|
|
2301
|
+
return parsedUrl.toString();
|
|
2302
|
+
} catch {
|
|
2303
|
+
return void 0;
|
|
2304
|
+
}
|
|
2305
|
+
}
|
|
2306
|
+
function trimmedOptionalValue(value) {
|
|
2307
|
+
const trimmed = value?.trim();
|
|
2308
|
+
return trimmed !== void 0 && trimmed.length > 0 ? trimmed : void 0;
|
|
2309
|
+
}
|
|
2310
|
+
function normalizeSessionTabTarget(target) {
|
|
2311
|
+
if (!target) {
|
|
2312
|
+
return void 0;
|
|
2313
|
+
}
|
|
2314
|
+
const url = trimmedOptionalValue(target.url);
|
|
2315
|
+
if (url === void 0 || normalizeComparableUrl(url) === void 0) {
|
|
2316
|
+
return void 0;
|
|
2317
|
+
}
|
|
2318
|
+
const targetId = trimmedOptionalValue(target.targetId);
|
|
2319
|
+
return {
|
|
2320
|
+
...targetId !== void 0 ? { targetId } : {},
|
|
2321
|
+
title: trimmedOptionalValue(target.title),
|
|
2322
|
+
url
|
|
2323
|
+
};
|
|
2324
|
+
}
|
|
2325
|
+
|
|
2326
|
+
// dist/extensions/agent-browser/lib/results/artifact-manifest-validation.js
|
|
2327
|
+
function finiteNonnegative(value) {
|
|
2328
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
2329
|
+
}
|
|
2330
|
+
function safeCount(value) {
|
|
2331
|
+
return finiteNonnegative(value) && Number.isSafeInteger(value);
|
|
2332
|
+
}
|
|
2333
|
+
function optionalStrings(value, keys) {
|
|
2334
|
+
return keys.every((key) => value[key] === void 0 || typeof value[key] === "string");
|
|
2335
|
+
}
|
|
2336
|
+
function nullableStrings(value, keys) {
|
|
2337
|
+
return keys.every((key) => value[key] === null || typeof value[key] === "string");
|
|
2338
|
+
}
|
|
2339
|
+
function nullableNumbers(value, keys) {
|
|
2340
|
+
return keys.every((key) => value[key] === null || finiteNonnegative(value[key]));
|
|
2341
|
+
}
|
|
2342
|
+
function nullableBoolean(value) {
|
|
2343
|
+
return value === null || typeof value === "boolean";
|
|
2344
|
+
}
|
|
2345
|
+
function captureIsValid(value) {
|
|
2346
|
+
return nullableStrings(value, [
|
|
2347
|
+
"startedAt",
|
|
2348
|
+
"endedAt",
|
|
2349
|
+
"firstFrameAt",
|
|
2350
|
+
"lastFrameAt",
|
|
2351
|
+
"timestampSource"
|
|
2352
|
+
]) && nullableNumbers(value, [
|
|
2353
|
+
"durationMs",
|
|
2354
|
+
"firstFrameAfterMs",
|
|
2355
|
+
"lastFrameAfterMs",
|
|
2356
|
+
"averageFps",
|
|
2357
|
+
"maxFrameGapMs"
|
|
2358
|
+
]);
|
|
2359
|
+
}
|
|
2360
|
+
function outputIsValid(value) {
|
|
2361
|
+
return nullableStrings(value, ["durationSource"]) && nullableNumbers(value, [
|
|
2362
|
+
"frames",
|
|
2363
|
+
"fps",
|
|
2364
|
+
"encodedFrames",
|
|
2365
|
+
"durationMs",
|
|
2366
|
+
"heldFrames",
|
|
2367
|
+
"droppedFrames",
|
|
2368
|
+
"skippedFrames"
|
|
2369
|
+
]) && nullableBoolean(value.encoderSucceeded);
|
|
2370
|
+
}
|
|
2371
|
+
function recordingIsValid(value) {
|
|
2372
|
+
if (!isRecord(value) || !isRecord(value.capture) || !isRecord(value.output) || !isRecord(value.file)) {
|
|
2373
|
+
return false;
|
|
2374
|
+
}
|
|
2375
|
+
return recordingScalarsAreValid(value) && captureIsValid(value.capture) && outputIsValid(value.output) && nullableBoolean(value.file.exists) && nullableNumbers(value.file, ["sizeBytes"]);
|
|
2376
|
+
}
|
|
2377
|
+
function recordingScalarsAreValid(value) {
|
|
2378
|
+
return typeof value.warning === "string" && typeof value.path === "string" && nullableStrings(value, ["recordingId", "error"]) && nullableBoolean(value.success) && nullableNumbers(value, ["frames", "capturedFrames", "fps"]);
|
|
2379
|
+
}
|
|
2380
|
+
function optionalNumbersAreValid(value) {
|
|
2381
|
+
return ["evictedAtMs", "recordingStartedAtMs"].every((key) => value[key] === void 0 || typeof value[key] === "number" && Number.isFinite(value[key])) && (value.sizeBytes === void 0 || finiteNonnegative(value.sizeBytes));
|
|
2382
|
+
}
|
|
2383
|
+
function optionalRecordingIsValid(value) {
|
|
2384
|
+
return (value.recordingState === void 0 || value.recordingState === "openRecording") && (value.recording === void 0 || recordingIsValid(value.recording)) && (value.status === void 0 || [
|
|
2385
|
+
"failed",
|
|
2386
|
+
"missing",
|
|
2387
|
+
"pending",
|
|
2388
|
+
"repaired-from-temp",
|
|
2389
|
+
"saved",
|
|
2390
|
+
"stale",
|
|
2391
|
+
"unverified",
|
|
2392
|
+
"upstream-temp-only"
|
|
2393
|
+
].some((status) => status === value.status));
|
|
2394
|
+
}
|
|
2395
|
+
function optionalEvidenceIsValid(value) {
|
|
2396
|
+
return optionalStrings(value, [
|
|
2397
|
+
"absolutePath",
|
|
2398
|
+
"command",
|
|
2399
|
+
"cwd",
|
|
2400
|
+
"extension",
|
|
2401
|
+
"mediaType",
|
|
2402
|
+
"namespace",
|
|
2403
|
+
"requestedPath",
|
|
2404
|
+
"session",
|
|
2405
|
+
"subcommand"
|
|
2406
|
+
]) && (value.exists === void 0 || typeof value.exists === "boolean") && optionalNumbersAreValid(value) && optionalRecordingIsValid(value);
|
|
2407
|
+
}
|
|
2408
|
+
function isManifestEntry(value) {
|
|
2409
|
+
if (!isRecord(value)) {
|
|
2410
|
+
return false;
|
|
2411
|
+
}
|
|
2412
|
+
return typeof value.path === "string" && value.path.trim().length > 0 && typeof value.createdAtMs === "number" && Number.isFinite(value.createdAtMs) && ["evicted", "ephemeral", "live", "missing"].some((state) => state === value.retentionState) && ["explicit-path", "persistent-session", "process-temp"].some((scope) => scope === value.storageScope) && ["download", "file", "har", "image", "pdf", "profile", "trace", "video", "spill"].some((kind) => kind === value.kind) && optionalEvidenceIsValid(value);
|
|
2413
|
+
}
|
|
2414
|
+
function manifestCountsAreValid(value) {
|
|
2415
|
+
return safeCount(value.maxEntries) && value.maxEntries !== 0 && safeCount(value.liveCount) && safeCount(value.evictedCount);
|
|
2416
|
+
}
|
|
2417
|
+
function isSessionArtifactManifest(value) {
|
|
2418
|
+
if (!isRecord(value)) {
|
|
2419
|
+
return false;
|
|
2420
|
+
}
|
|
2421
|
+
return value.version === 1 && Array.isArray(value.entries) && value.entries.every(isManifestEntry) && typeof value.updatedAtMs === "number" && Number.isFinite(value.updatedAtMs) && manifestCountsAreValid(value);
|
|
2422
|
+
}
|
|
2423
|
+
|
|
2424
|
+
// dist/extensions/agent-browser/lib/browser-transcript-contracts.js
|
|
2425
|
+
var BROWSER_TRANSITION_ENTRY = "agent-browser-transition";
|
|
2426
|
+
|
|
2427
|
+
// dist/extensions/agent-browser/lib/browser-transcript-validation.js
|
|
2428
|
+
function invalidEvent() {
|
|
2429
|
+
throw new Error("Invalid browser event; inspect or convert the retained session before browser work.");
|
|
2430
|
+
}
|
|
2431
|
+
function invalidPage() {
|
|
2432
|
+
throw new Error("Invalid browser page disposition; refs cannot be restored.");
|
|
2433
|
+
}
|
|
2434
|
+
function parseInvalidation(value) {
|
|
2435
|
+
if (value === void 0) {
|
|
2436
|
+
return void 0;
|
|
2437
|
+
}
|
|
2438
|
+
if (!isRecord(value) || value.reason !== "page-transition" && value.reason !== "no-active-page" || typeof value.summary !== "string") {
|
|
2439
|
+
return invalidPage();
|
|
2440
|
+
}
|
|
2441
|
+
return { ...value, reason: value.reason, summary: value.summary };
|
|
2442
|
+
}
|
|
2443
|
+
function parseRefs(value) {
|
|
2444
|
+
if (!isRecord(value)) {
|
|
2445
|
+
return invalidPage();
|
|
2446
|
+
}
|
|
2447
|
+
if (value.kind === "reuse" || value.kind === "replace") {
|
|
2448
|
+
if (typeof value.snapshotId !== "string" || value.snapshotId.length === 0) {
|
|
2449
|
+
return invalidPage();
|
|
2450
|
+
}
|
|
2451
|
+
return { ...value, kind: value.kind, snapshotId: value.snapshotId };
|
|
2452
|
+
}
|
|
2453
|
+
if (value.kind !== "unknown" && value.kind !== "invalidate") {
|
|
2454
|
+
return invalidPage();
|
|
2455
|
+
}
|
|
2456
|
+
const invalidation = parseInvalidation(value.invalidation);
|
|
2457
|
+
return { ...value, kind: value.kind, ...invalidation ? { invalidation } : {} };
|
|
2458
|
+
}
|
|
2459
|
+
function decodeBrowserTarget(value) {
|
|
2460
|
+
if (!isRecord(value) || typeof value.url !== "string") {
|
|
2461
|
+
return void 0;
|
|
2462
|
+
}
|
|
2463
|
+
if (value.title !== void 0 && typeof value.title !== "string" || value.targetId !== void 0 && typeof value.targetId !== "string") {
|
|
2464
|
+
return void 0;
|
|
2465
|
+
}
|
|
2466
|
+
const target = { ...value, url: value.url };
|
|
2467
|
+
return normalizeSessionTabTarget(target) === void 0 ? void 0 : target;
|
|
2468
|
+
}
|
|
2469
|
+
function parseBrowserTarget(value) {
|
|
2470
|
+
if (value === void 0) {
|
|
2471
|
+
return void 0;
|
|
2472
|
+
}
|
|
2473
|
+
return decodeBrowserTarget(value) ?? invalidPage();
|
|
2474
|
+
}
|
|
2475
|
+
function pageScalarsValid(value) {
|
|
2476
|
+
return (value.confirmActions === void 0 || value.confirmActions === null || typeof value.confirmActions === "string") && (value.unknown === void 0 || value.unknown === true) && (value.clear === void 0 || value.clear === true);
|
|
2477
|
+
}
|
|
2478
|
+
function pagePolicyValid(value) {
|
|
2479
|
+
return (value.reopenPending === void 0 || typeof value.reopenPending === "boolean") && (value.pinningReason === void 0 || value.pinningReason === "restore" || value.pinningReason === "drift");
|
|
2480
|
+
}
|
|
2481
|
+
function parsePage(value) {
|
|
2482
|
+
if (!isRecord(value) || typeof value.key !== "string" || !pageScalarsValid(value) || !pagePolicyValid(value)) {
|
|
2483
|
+
return invalidPage();
|
|
2484
|
+
}
|
|
2485
|
+
const target = parseBrowserTarget(value.target);
|
|
2486
|
+
return { ...value, key: value.key, refs: parseRefs(value.refs), ...target ? { target } : {} };
|
|
2487
|
+
}
|
|
2488
|
+
function parsePages(value) {
|
|
2489
|
+
if (value === void 0) {
|
|
2490
|
+
return void 0;
|
|
2491
|
+
}
|
|
2492
|
+
if (!Array.isArray(value)) {
|
|
2493
|
+
return invalidPage();
|
|
2494
|
+
}
|
|
2495
|
+
const pages = value;
|
|
2496
|
+
return pages.map(parsePage);
|
|
2497
|
+
}
|
|
2498
|
+
function parseArtifacts(value) {
|
|
2499
|
+
if (value === void 0) {
|
|
2500
|
+
return void 0;
|
|
2501
|
+
}
|
|
2502
|
+
if (!isRecord(value) || !isBrowserStringArray(value.removals)) {
|
|
2503
|
+
throw new Error("Invalid browser artifact changes; inspect the retained journal.");
|
|
2504
|
+
}
|
|
2505
|
+
const manifest = {
|
|
2506
|
+
version: 1,
|
|
2507
|
+
entries: value.upserts,
|
|
2508
|
+
maxEntries: value.maxEntries,
|
|
2509
|
+
updatedAtMs: value.updatedAtMs,
|
|
2510
|
+
liveCount: 0,
|
|
2511
|
+
evictedCount: 0
|
|
2512
|
+
};
|
|
2513
|
+
if (!isSessionArtifactManifest(manifest)) {
|
|
2514
|
+
throw new Error("Invalid browser artifact changes; inspect the retained journal.");
|
|
2515
|
+
}
|
|
2516
|
+
return {
|
|
2517
|
+
...value,
|
|
2518
|
+
upserts: manifest.entries,
|
|
2519
|
+
removals: value.removals,
|
|
2520
|
+
maxEntries: manifest.maxEntries,
|
|
2521
|
+
updatedAtMs: manifest.updatedAtMs
|
|
2522
|
+
};
|
|
2523
|
+
}
|
|
2524
|
+
function eventIdentity(value) {
|
|
2525
|
+
if (typeof value.operationId !== "string" || typeof value.toolCallId !== "string" || typeof value.commandIndex !== "number" || !Number.isSafeInteger(value.commandIndex) || value.commandIndex < 0 || typeof value.isError !== "boolean") {
|
|
2526
|
+
return invalidEvent();
|
|
2527
|
+
}
|
|
2528
|
+
return {
|
|
2529
|
+
operationId: value.operationId,
|
|
2530
|
+
toolCallId: value.toolCallId,
|
|
2531
|
+
commandIndex: value.commandIndex,
|
|
2532
|
+
isError: value.isError
|
|
2533
|
+
};
|
|
2534
|
+
}
|
|
2535
|
+
function parseBrowserEvent(value) {
|
|
2536
|
+
const phase = value.phase;
|
|
2537
|
+
if (phase !== "begin" && phase !== "finish" && phase !== "state") {
|
|
2538
|
+
return invalidEvent();
|
|
2539
|
+
}
|
|
2540
|
+
if (!isRecord(value.state)) {
|
|
2541
|
+
return invalidEvent();
|
|
2542
|
+
}
|
|
2543
|
+
const identity = eventIdentity(value);
|
|
2544
|
+
const pages = parsePages(value.pages);
|
|
2545
|
+
const artifacts = parseArtifacts(value.artifacts);
|
|
2546
|
+
return {
|
|
2547
|
+
...value,
|
|
2548
|
+
...identity,
|
|
2549
|
+
version: 1,
|
|
2550
|
+
phase,
|
|
2551
|
+
state: value.state,
|
|
2552
|
+
...pages ? { pages } : {},
|
|
2553
|
+
...artifacts ? { artifacts } : {}
|
|
2554
|
+
};
|
|
2555
|
+
}
|
|
2556
|
+
|
|
2557
|
+
// dist/extensions/agent-browser/lib/browser-transcript.js
|
|
2558
|
+
var BROWSER_EVENT_VERSION = 1;
|
|
2559
|
+
function getBrowserRecord(entry) {
|
|
2560
|
+
if (!isRecord(entry) || !isRecord(entry.data)) {
|
|
2561
|
+
return void 0;
|
|
2562
|
+
}
|
|
2563
|
+
if (entry.type !== "message" && !(entry.type === "custom" && entry.customType === BROWSER_TRANSITION_ENTRY)) {
|
|
2564
|
+
return void 0;
|
|
2565
|
+
}
|
|
2566
|
+
const event = entry.data.event;
|
|
2567
|
+
if (!isRecord(event) || event.version !== BROWSER_EVENT_VERSION) {
|
|
2568
|
+
return void 0;
|
|
2569
|
+
}
|
|
2570
|
+
return { ...entry.data, event: parseBrowserEvent(event) };
|
|
2571
|
+
}
|
|
2572
|
+
function getBrowserResultMessage(entry) {
|
|
2573
|
+
const record = getBrowserRecord(entry);
|
|
2574
|
+
return record ? {
|
|
2575
|
+
details: record.event.state,
|
|
2576
|
+
isError: typeof record.event.state.nativeSucceeded === "boolean" ? !record.event.state.nativeSucceeded : record.event.isError
|
|
2577
|
+
} : void 0;
|
|
2578
|
+
}
|
|
2579
|
+
|
|
2580
|
+
// dist/extensions/agent-browser/lib/runtime-replay-events.js
|
|
2581
|
+
function text(value) {
|
|
2582
|
+
return typeof value === "string" ? value : void 0;
|
|
2583
|
+
}
|
|
2584
|
+
function cleanupSession(step, record, fallbackNamespace, fallbackSessionName) {
|
|
2585
|
+
if (!isRecord(step) || step.resource !== "managed-session" || step.state !== "removed" && step.state !== "already-gone") {
|
|
2586
|
+
return;
|
|
2587
|
+
}
|
|
2588
|
+
const sessionName = getRestorableManagedSessionName(step.sessionName, fallbackSessionName) ?? getRestorableManagedSessionName(record?.sessionName, fallbackSessionName);
|
|
2589
|
+
if (sessionName === void 0 || sessionName.length === 0) {
|
|
2590
|
+
return;
|
|
2591
|
+
}
|
|
2592
|
+
return { namespace: text(step.namespace) ?? fallbackNamespace, sessionName };
|
|
2593
|
+
}
|
|
2594
|
+
function cleanupSessionsForResult(result, detailsNamespace, fallbackSessionName) {
|
|
2595
|
+
if (!isRecord(result) || !Array.isArray(result.steps)) {
|
|
2596
|
+
return [];
|
|
2597
|
+
}
|
|
2598
|
+
const record = isRecord(result.record) ? result.record : void 0;
|
|
2599
|
+
const namespace = text(record?.namespace) ?? detailsNamespace;
|
|
2600
|
+
const closedSessions = [];
|
|
2601
|
+
for (const step of result.steps) {
|
|
2602
|
+
const identity = cleanupSession(step, record, namespace, fallbackSessionName);
|
|
2603
|
+
if (identity) {
|
|
2604
|
+
closedSessions.push(identity);
|
|
2605
|
+
}
|
|
2606
|
+
}
|
|
2607
|
+
return closedSessions;
|
|
2608
|
+
}
|
|
2609
|
+
function getElectronCleanupClosedManagedSessions(details, fallbackSessionName) {
|
|
2610
|
+
const electron = isRecord(details.electron) ? details.electron : void 0;
|
|
2611
|
+
const cleanup = isRecord(electron?.cleanup) ? electron.cleanup : void 0;
|
|
2612
|
+
const results = Array.isArray(cleanup?.results) ? cleanup.results : [];
|
|
2613
|
+
return results.flatMap((result) => cleanupSessionsForResult(result, text(details.namespace), fallbackSessionName));
|
|
2614
|
+
}
|
|
2615
|
+
function outcomeClosedSession(outcome, sessionName, fallbackSessionName) {
|
|
2616
|
+
if (outcome?.status !== "closed" || outcome.succeeded !== true) {
|
|
2617
|
+
return;
|
|
2618
|
+
}
|
|
2619
|
+
return getRestorableManagedSessionName(outcome.attemptedSessionName, fallbackSessionName) ?? getRestorableManagedSessionName(outcome.currentSessionName, fallbackSessionName) ?? getRestorableManagedSessionName(sessionName, fallbackSessionName);
|
|
2620
|
+
}
|
|
2621
|
+
function selectManagedReplaySession(options) {
|
|
2622
|
+
if (options.closedSessionName !== void 0) {
|
|
2623
|
+
return options.closedSessionName;
|
|
2624
|
+
}
|
|
2625
|
+
const { explicitSessionName, restorableDetailSessionName } = options;
|
|
2626
|
+
if ((explicitSessionName ?? "").length > 0) {
|
|
2627
|
+
return options.closesSession && restorableDetailSessionName === explicitSessionName ? restorableDetailSessionName : void 0;
|
|
2628
|
+
}
|
|
2629
|
+
if (options.usedImplicitSession || options.freshSession) {
|
|
2630
|
+
return (restorableDetailSessionName ?? "").length > 0 ? restorableDetailSessionName : void 0;
|
|
2631
|
+
}
|
|
2632
|
+
return;
|
|
2633
|
+
}
|
|
2634
|
+
function replaySucceeded(options) {
|
|
2635
|
+
const { outcome } = options;
|
|
2636
|
+
const activeCurrent = outcome?.activeAfter === true && outcome.currentSessionName === options.managedSessionName && ["created", "replaced", "unchanged"].includes(text(outcome.status) ?? "");
|
|
2637
|
+
if (activeCurrent || options.nestedBatchRemainsActive) {
|
|
2638
|
+
return true;
|
|
2639
|
+
}
|
|
2640
|
+
if (typeof options.messageIsError === "boolean") {
|
|
2641
|
+
return !options.messageIsError;
|
|
2642
|
+
}
|
|
2643
|
+
return typeof options.exitCode !== "number" || options.exitCode === 0;
|
|
2644
|
+
}
|
|
2645
|
+
function decodeManagedReplayEvent(entry, fallbackSessionName) {
|
|
2646
|
+
const message = getBrowserResultMessage(entry);
|
|
2647
|
+
if (!message || !isRecord(message.details)) {
|
|
2648
|
+
return;
|
|
2649
|
+
}
|
|
2650
|
+
const details = message.details;
|
|
2651
|
+
const args = Array.isArray(details.args) && details.args.every((item) => typeof item === "string") ? details.args : [];
|
|
2652
|
+
if (isPlainTextInspectionArgs(args)) {
|
|
2653
|
+
return;
|
|
2654
|
+
}
|
|
2655
|
+
return decodeLifecycleEvent(details, args, message.isError, fallbackSessionName);
|
|
2656
|
+
}
|
|
2657
|
+
function closeAllApplied(details, args, messageIsError) {
|
|
2658
|
+
return details.closeAllApplied === true || messageIsError !== true && isCloseAllCommand(extractUpstreamCommandTokens(args)) || batchHasSuccessfulCloseAll(details.batchSteps);
|
|
2659
|
+
}
|
|
2660
|
+
function decodeLifecycleEvent(details, args, messageIsError, fallbackSessionName) {
|
|
2661
|
+
const sessionName = text(details.sessionName);
|
|
2662
|
+
const namespace = canonicalizeAgentBrowserNamespace(text(details.namespace));
|
|
2663
|
+
const command = text(details.command) ?? parseCommandInfo(args).command;
|
|
2664
|
+
const lifecycle = getSuccessfulBatchCloseLifecycle(details.batchSteps);
|
|
2665
|
+
const nestedBatchEndsClosed = lifecycle?.endsClosed === true;
|
|
2666
|
+
const nestedBatchRemainsActive = lifecycle?.endsClosed === false;
|
|
2667
|
+
const closesSession = isCloseCommand(command) || nestedBatchEndsClosed;
|
|
2668
|
+
const outcome = isRecord(details.managedSessionOutcome) ? details.managedSessionOutcome : void 0;
|
|
2669
|
+
const closedSessionName = outcomeClosedSession(outcome, sessionName, fallbackSessionName);
|
|
2670
|
+
const outcomeClosed = (closedSessionName ?? "").length > 0;
|
|
2671
|
+
const restorableDetailSessionName = getRestorableManagedSessionName(sessionName, fallbackSessionName);
|
|
2672
|
+
const managedSessionName = selectManagedReplaySession({
|
|
2673
|
+
closedSessionName,
|
|
2674
|
+
explicitSessionName: extractExplicitSessionName(args),
|
|
2675
|
+
restorableDetailSessionName,
|
|
2676
|
+
usedImplicitSession: details.usedImplicitSession === true,
|
|
2677
|
+
freshSession: details.sessionMode === "fresh",
|
|
2678
|
+
closesSession
|
|
2679
|
+
});
|
|
2680
|
+
const succeeded = replaySucceeded({
|
|
2681
|
+
outcome,
|
|
2682
|
+
managedSessionName,
|
|
2683
|
+
nestedBatchRemainsActive,
|
|
2684
|
+
messageIsError,
|
|
2685
|
+
exitCode: details.exitCode
|
|
2686
|
+
});
|
|
2687
|
+
return {
|
|
2688
|
+
cleanupSessions: getElectronCleanupClosedManagedSessions(details, fallbackSessionName),
|
|
2689
|
+
namespace,
|
|
2690
|
+
detailSessionName: sessionName,
|
|
2691
|
+
restoreDisabled: details.managedSessionRestoreDisabled === true,
|
|
2692
|
+
restorableDetailSessionName,
|
|
2693
|
+
closeAllApplied: closeAllApplied(details, args, messageIsError),
|
|
2694
|
+
nestedBatchRemainsActive,
|
|
2695
|
+
managedSessionName,
|
|
2696
|
+
closesSession: closesSession || outcomeClosed,
|
|
2697
|
+
closeSucceeded: nestedBatchEndsClosed || outcomeClosed || succeeded,
|
|
2698
|
+
command,
|
|
2699
|
+
succeeded
|
|
2700
|
+
};
|
|
2701
|
+
}
|
|
2702
|
+
|
|
2703
|
+
// dist/extensions/agent-browser/lib/runtime-session-replay.js
|
|
2704
|
+
var ManagedSessionReplay = class {
|
|
2705
|
+
#fallbackSessionName;
|
|
2706
|
+
#freshSessionRanks = /* @__PURE__ */ new Map();
|
|
2707
|
+
#restoreDisabledIdentities = /* @__PURE__ */ new Map();
|
|
2708
|
+
#state;
|
|
2709
|
+
#activeRestoreRank = 0;
|
|
2710
|
+
#closedSessionName;
|
|
2711
|
+
#freshSessionOrdinal = 0;
|
|
2712
|
+
constructor(fallbackSessionName) {
|
|
2713
|
+
this.#fallbackSessionName = fallbackSessionName;
|
|
2714
|
+
this.#state = { active: false, sessionName: fallbackSessionName };
|
|
2715
|
+
}
|
|
2716
|
+
#rank(sessionName) {
|
|
2717
|
+
if (sessionName === this.#fallbackSessionName) {
|
|
2718
|
+
return 0;
|
|
2719
|
+
}
|
|
2720
|
+
if (!isRestorableManagedSessionName(sessionName, this.#fallbackSessionName)) {
|
|
2721
|
+
return;
|
|
2722
|
+
}
|
|
2723
|
+
const existing = this.#freshSessionRanks.get(sessionName);
|
|
2724
|
+
if (existing !== void 0) {
|
|
2725
|
+
return existing;
|
|
2726
|
+
}
|
|
2727
|
+
const nextRank = this.#freshSessionRanks.size + 1;
|
|
2728
|
+
this.#freshSessionRanks.set(sessionName, nextRank);
|
|
2729
|
+
return nextRank;
|
|
2730
|
+
}
|
|
2731
|
+
#close(identity) {
|
|
2732
|
+
const namespace = canonicalizeAgentBrowserNamespace(identity.namespace);
|
|
2733
|
+
if (this.#rank(identity.sessionName) === void 0 || identity.sessionName !== this.#state.sessionName || namespace !== this.#state.namespace) {
|
|
2734
|
+
return;
|
|
2735
|
+
}
|
|
2736
|
+
this.#state = { active: false, sessionName: this.#state.sessionName };
|
|
2737
|
+
this.#closedSessionName = identity.sessionName;
|
|
2738
|
+
}
|
|
2739
|
+
#closeAll(event) {
|
|
2740
|
+
if (!event.closeAllApplied || !this.#state.active) {
|
|
2741
|
+
return;
|
|
2742
|
+
}
|
|
2743
|
+
const restoredKey = getAgentBrowserSessionIdentityKey(this.#state.sessionName, this.#state.namespace);
|
|
2744
|
+
const sessionName = event.restorableDetailSessionName;
|
|
2745
|
+
const resultKey = sessionName !== void 0 && sessionName.length > 0 ? getAgentBrowserSessionIdentityKey(sessionName, event.namespace) : void 0;
|
|
2746
|
+
const retainsCurrent = event.nestedBatchRemainsActive && resultKey === restoredKey;
|
|
2747
|
+
if (isAgentBrowserSessionIdentityKeyInNamespace(restoredKey, event.namespace) && !retainsCurrent) {
|
|
2748
|
+
this.#close(this.#state);
|
|
2749
|
+
}
|
|
2750
|
+
}
|
|
2751
|
+
#applyCompletion(event, identity, rank) {
|
|
2752
|
+
if (event.closesSession) {
|
|
2753
|
+
if (event.closeSucceeded) {
|
|
2754
|
+
this.#restoreDisabledIdentities.delete(getAgentBrowserSessionIdentityKey(identity.sessionName, identity.namespace));
|
|
2755
|
+
this.#close(identity);
|
|
2756
|
+
}
|
|
2757
|
+
return;
|
|
2758
|
+
}
|
|
2759
|
+
if (event.succeeded && rank < this.#activeRestoreRank) {
|
|
2760
|
+
return;
|
|
2761
|
+
}
|
|
2762
|
+
this.#state = resolveManagedSessionState({
|
|
2763
|
+
command: event.command,
|
|
2764
|
+
managedSessionName: identity.sessionName,
|
|
2765
|
+
managedSessionNamespace: identity.namespace,
|
|
2766
|
+
priorActive: this.#state.active,
|
|
2767
|
+
priorNamespace: this.#state.namespace,
|
|
2768
|
+
priorSessionName: this.#state.sessionName,
|
|
2769
|
+
succeeded: event.succeeded
|
|
2770
|
+
});
|
|
2771
|
+
if (event.succeeded && this.#state.active) {
|
|
2772
|
+
this.#activeRestoreRank = rank;
|
|
2773
|
+
this.#closedSessionName = void 0;
|
|
2774
|
+
}
|
|
2775
|
+
}
|
|
2776
|
+
apply(event) {
|
|
2777
|
+
for (const identity of event.cleanupSessions) {
|
|
2778
|
+
this.#close(identity);
|
|
2779
|
+
}
|
|
2780
|
+
this.#closeAll(event);
|
|
2781
|
+
if (event.restoreDisabled && event.detailSessionName !== void 0) {
|
|
2782
|
+
const identity = { namespace: event.namespace, sessionName: event.detailSessionName };
|
|
2783
|
+
this.#restoreDisabledIdentities.set(getAgentBrowserSessionIdentityKey(identity.sessionName, identity.namespace), identity);
|
|
2784
|
+
}
|
|
2785
|
+
if (event.managedSessionName === void 0 || event.managedSessionName.length === 0) {
|
|
2786
|
+
return;
|
|
2787
|
+
}
|
|
2788
|
+
const rank = this.#rank(event.managedSessionName);
|
|
2789
|
+
if (rank === void 0) {
|
|
2790
|
+
return;
|
|
2791
|
+
}
|
|
2792
|
+
this.#freshSessionOrdinal = Math.max(this.#freshSessionOrdinal, rank);
|
|
2793
|
+
this.#applyCompletion(event, { namespace: event.namespace, sessionName: event.managedSessionName }, rank);
|
|
2794
|
+
}
|
|
2795
|
+
result() {
|
|
2796
|
+
const closedSessionName = this.#closedSessionName;
|
|
2797
|
+
return {
|
|
2798
|
+
...this.#state,
|
|
2799
|
+
...closedSessionName !== void 0 && closedSessionName.length > 0 ? { closedSessionName } : {},
|
|
2800
|
+
freshSessionOrdinal: this.#freshSessionOrdinal,
|
|
2801
|
+
managedSessionRestoreDisabledIdentities: [...this.#restoreDisabledIdentities.values()]
|
|
2802
|
+
};
|
|
2803
|
+
}
|
|
2804
|
+
};
|
|
2805
|
+
function restoreManagedSessionStateFromBranch(branch, fallbackSessionName) {
|
|
2806
|
+
const replay = new ManagedSessionReplay(fallbackSessionName);
|
|
2807
|
+
for (const entry of branch) {
|
|
2808
|
+
const event = decodeManagedReplayEvent(entry, fallbackSessionName);
|
|
2809
|
+
if (event) {
|
|
2810
|
+
replay.apply(event);
|
|
2811
|
+
}
|
|
2812
|
+
}
|
|
2813
|
+
return replay.result();
|
|
2814
|
+
}
|
|
2815
|
+
|
|
2816
|
+
// dist/extensions/agent-browser/lib/runtime-tab-correction.js
|
|
2817
|
+
function normalizeComparableUrl2(url) {
|
|
2818
|
+
const normalizedUrl = url.trim();
|
|
2819
|
+
if (normalizedUrl.length === 0) {
|
|
2820
|
+
return;
|
|
2821
|
+
}
|
|
2822
|
+
try {
|
|
2823
|
+
const parsedUrl = new URL(normalizedUrl);
|
|
2824
|
+
parsedUrl.hash = "";
|
|
2825
|
+
return parsedUrl.toString();
|
|
2826
|
+
} catch {
|
|
2827
|
+
return;
|
|
2828
|
+
}
|
|
2829
|
+
}
|
|
2830
|
+
function normalizeTabSelectionValue(value) {
|
|
2831
|
+
const normalizedValue = value?.trim();
|
|
2832
|
+
return normalizedValue !== void 0 && normalizedValue.length > 0 ? normalizedValue : void 0;
|
|
2833
|
+
}
|
|
2834
|
+
function extractTabSelection(tab) {
|
|
2835
|
+
const tabId = normalizeTabSelectionValue(tab.tabId);
|
|
2836
|
+
if (tabId !== void 0) {
|
|
2837
|
+
return { selectedTab: tabId, selectionKind: "tabId" };
|
|
2838
|
+
}
|
|
2839
|
+
const label = normalizeTabSelectionValue(tab.label);
|
|
2840
|
+
if (label !== void 0) {
|
|
2841
|
+
return { selectedTab: label, selectionKind: "label" };
|
|
2842
|
+
}
|
|
2843
|
+
if (typeof tab.index === "number" && Number.isInteger(tab.index) && tab.index >= 0) {
|
|
2844
|
+
return { selectedTab: String(tab.index), selectionKind: "index" };
|
|
2845
|
+
}
|
|
2846
|
+
return;
|
|
2847
|
+
}
|
|
2848
|
+
function selectMatchingTab(tabs, targetTitle) {
|
|
2849
|
+
const title = typeof targetTitle === "string" ? targetTitle.trim() : "";
|
|
2850
|
+
const titledMatch = title.length === 0 ? void 0 : tabs.find((tab) => typeof tab.title === "string" && tab.title.trim() === title);
|
|
2851
|
+
return {
|
|
2852
|
+
selection: extractTabSelection(titledMatch ?? tabs[0]),
|
|
2853
|
+
targetTitle: title.length > 0 ? title : void 0
|
|
2854
|
+
};
|
|
2855
|
+
}
|
|
2856
|
+
function chooseOpenResultTabCorrection(options) {
|
|
2857
|
+
const normalizedTargetUrl = typeof options.targetUrl === "string" ? normalizeComparableUrl2(options.targetUrl) : void 0;
|
|
2858
|
+
if (normalizedTargetUrl === void 0) {
|
|
2859
|
+
return;
|
|
2860
|
+
}
|
|
2861
|
+
const tabsWithIndices = options.tabs.map((tab, index) => ({
|
|
2862
|
+
...tab,
|
|
2863
|
+
index: typeof tab.index === "number" ? tab.index : index,
|
|
2864
|
+
label: normalizeTabSelectionValue(tab.label),
|
|
2865
|
+
tabId: normalizeTabSelectionValue(tab.tabId)
|
|
2866
|
+
}));
|
|
2867
|
+
const activeTab = tabsWithIndices.find((tab) => tab.active === true) ?? tabsWithIndices.find((tab) => tab.index === options.activeTabIndex);
|
|
2868
|
+
if (activeTab && normalizeComparableUrl2(activeTab.url ?? "") === normalizedTargetUrl) {
|
|
2869
|
+
return;
|
|
2870
|
+
}
|
|
2871
|
+
const matchingTabs = tabsWithIndices.filter((tab) => normalizeComparableUrl2(tab.url ?? "") === normalizedTargetUrl);
|
|
2872
|
+
if (matchingTabs.length === 0) {
|
|
2873
|
+
return;
|
|
2874
|
+
}
|
|
2875
|
+
const { selection, targetTitle } = selectMatchingTab(matchingTabs, options.targetTitle);
|
|
2876
|
+
return selection ? { ...selection, targetTitle, targetUrl: normalizedTargetUrl } : void 0;
|
|
2877
|
+
}
|
|
2878
|
+
|
|
2879
|
+
// dist/extensions/agent-browser/lib/runtime.js
|
|
2880
|
+
function getStartupScopedFlags(args) {
|
|
2881
|
+
return LAUNCH_SCOPED_FLAG_DEFINITIONS.map((definition) => definition.flag).filter((flag) => hasLaunchScopedFlagToken(args, flag));
|
|
2882
|
+
}
|
|
2883
|
+
function withNativeSession(args) {
|
|
2884
|
+
const nativeSession = getAgentBrowserProcessEnvironment().AGENT_BROWSER_SESSION;
|
|
2885
|
+
if (nativeSession !== void 0 && !isPlainTextInspectionArgs(args) && extractExplicitSessionName(args) === void 0) {
|
|
2886
|
+
return ["--session", nativeSession, ...args];
|
|
2887
|
+
}
|
|
2888
|
+
return args;
|
|
2889
|
+
}
|
|
2890
|
+
function jsonPrefix(args) {
|
|
2891
|
+
return getBooleanFlagValue(args, "--json") === void 0 ? ["--json"] : [];
|
|
2892
|
+
}
|
|
2893
|
+
function planningFailure(args) {
|
|
2894
|
+
const invalidValueFlag = getInvalidValueFlagDetails(args);
|
|
2895
|
+
const repeatedFlag = ["--session", "--namespace"].find((flag) => scanUpstreamGlobalFlagOccurrences(args, flag).length > 1);
|
|
2896
|
+
if (!invalidValueFlag && repeatedFlag === void 0) {
|
|
2897
|
+
return;
|
|
2898
|
+
}
|
|
2899
|
+
const validationError = invalidValueFlag ? formatInvalidValueFlagError(invalidValueFlag) : `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.`;
|
|
2900
|
+
const plan = {
|
|
2901
|
+
commandInfo: {},
|
|
2902
|
+
effectiveArgs: jsonPrefix(args),
|
|
2903
|
+
plainTextInspection: false,
|
|
2904
|
+
startupScopedFlags: [],
|
|
2905
|
+
usedImplicitSession: false,
|
|
2906
|
+
validationError
|
|
2907
|
+
};
|
|
2908
|
+
return invalidValueFlag ? { ...plan, invalidValueFlag } : plan;
|
|
2909
|
+
}
|
|
2910
|
+
function effectiveStartupFlags(args, managedNamespace) {
|
|
2911
|
+
const explicitNamespacePresent = scanUpstreamGlobalFlagOccurrences(args, "--namespace").length > 0;
|
|
2912
|
+
const explicitNamespace = extractExplicitNamespace(args);
|
|
2913
|
+
return getStartupScopedFlags(args).filter((flag) => !(flag === "--namespace" && explicitNamespacePresent && explicitNamespace === canonicalizeAgentBrowserNamespace(managedNamespace)));
|
|
2914
|
+
}
|
|
2915
|
+
function targetsActiveManagedSession(selection, options, needsSession) {
|
|
2916
|
+
const { sessionName } = selection;
|
|
2917
|
+
return options.managedSessionActive && needsSession && sessionName !== void 0 && sessionName.length > 0 && getAgentBrowserSessionIdentityKey(sessionName, selection.namespace) === getAgentBrowserSessionIdentityKey(options.managedSessionName, options.managedSessionNamespace);
|
|
2918
|
+
}
|
|
2919
|
+
function activeLaunchRecovery(args, flags, command, prior) {
|
|
2920
|
+
if (flags.length === 0 || isCloseCommand(command) || prior.validationError !== void 0 && prior.validationError.length > 0) {
|
|
2921
|
+
return prior;
|
|
2922
|
+
}
|
|
2923
|
+
const explicitSession = extractExplicitSessionName(args);
|
|
2924
|
+
const explicit = explicitSession !== void 0 && explicitSession.length > 0;
|
|
2925
|
+
const recoveryArgs = explicit ? stripExplicitIdentityArgs(args, "--session") : args;
|
|
2926
|
+
return {
|
|
2927
|
+
recoveryHint: freshSessionRecoveryHint(recoveryArgs, launchFlagsRecoveryReason()),
|
|
2928
|
+
validationError: [
|
|
2929
|
+
`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.`,
|
|
2930
|
+
explicit ? 'Remove the explicit `--session` and retry with `sessionMode: "fresh"` to force a fresh upstream launch.' : 'Retry this call with `sessionMode: "fresh"` to force a fresh upstream launch.'
|
|
2931
|
+
].join(" ")
|
|
2932
|
+
};
|
|
2933
|
+
}
|
|
2934
|
+
function activeCompatibilityPlan(args, requested, existing, prior) {
|
|
2935
|
+
if (!canUseHeadlessCompatibilityUserAgent(args)) {
|
|
2936
|
+
return { ...prior, compatibilityWorkaround: requested };
|
|
2937
|
+
}
|
|
2938
|
+
if (requested && !existing && (prior.validationError === void 0 || prior.validationError.length === 0)) {
|
|
2939
|
+
const sessionName = extractExplicitSessionName(args);
|
|
2940
|
+
const explicit = sessionName !== void 0 && sessionName.length > 0;
|
|
2941
|
+
const recoveryArgs = explicit ? stripExplicitIdentityArgs(args, "--session") : args;
|
|
2942
|
+
return {
|
|
2943
|
+
compatibilityWorkaround: void 0,
|
|
2944
|
+
recoveryHint: freshSessionRecoveryHint(recoveryArgs, "The requested site compatibility user agent is launch-scoped and needs a fresh browser session."),
|
|
2945
|
+
validationError: explicit ? '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.' : '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.'
|
|
2946
|
+
};
|
|
2947
|
+
}
|
|
2948
|
+
return { ...prior, compatibilityWorkaround: requested ?? existing };
|
|
2949
|
+
}
|
|
2950
|
+
function inspectionPlan(args, commandInfo, startupScopedFlags) {
|
|
2951
|
+
const explicitNamespacePresent = scanUpstreamGlobalFlagOccurrences(args, "--namespace").length > 0;
|
|
2952
|
+
return {
|
|
2953
|
+
commandInfo,
|
|
2954
|
+
effectiveArgs: [...args],
|
|
2955
|
+
namespace: explicitNamespacePresent ? extractExplicitNamespace(args) ?? "" : void 0,
|
|
2956
|
+
plainTextInspection: true,
|
|
2957
|
+
startupScopedFlags,
|
|
2958
|
+
usedImplicitSession: false
|
|
2959
|
+
};
|
|
2960
|
+
}
|
|
2961
|
+
function buildExecutionPlan(inputArgs, options) {
|
|
2962
|
+
const args = withNativeSession(inputArgs);
|
|
2963
|
+
const startupScopedFlags = effectiveStartupFlags(args, options.managedSessionNamespace);
|
|
2964
|
+
const descriptor = parseArgvDescriptor(args);
|
|
2965
|
+
const commandInfo = descriptor.commandInfo;
|
|
2966
|
+
if (isPlainTextInspectionArgs(args)) {
|
|
2967
|
+
return inspectionPlan(args, commandInfo, startupScopedFlags);
|
|
2968
|
+
}
|
|
2969
|
+
const failure = planningFailure(args);
|
|
2970
|
+
if (failure) {
|
|
2971
|
+
return failure;
|
|
2972
|
+
}
|
|
2973
|
+
const needsSession = options.browserIndependentReadConfirmation !== true && needsManagedSession(descriptor, options.stdin);
|
|
2974
|
+
const selection = selectExecutionSession(args, options, {
|
|
2975
|
+
command: commandInfo.command,
|
|
2976
|
+
needsManagedSession: needsSession,
|
|
2977
|
+
startupScopedFlags
|
|
2978
|
+
});
|
|
2979
|
+
const activeTarget = targetsActiveManagedSession(selection, options, needsSession);
|
|
2980
|
+
const requested = getCompatibilityWorkaround(args, commandInfo);
|
|
2981
|
+
const recovery = activeTarget ? activeLaunchRecovery(args, startupScopedFlags, commandInfo.command, selection) : selection;
|
|
2982
|
+
const compatibility = activeTarget ? activeCompatibilityPlan(args, requested, options.managedSessionCompatibilityWorkaround, recovery) : { ...recovery, compatibilityWorkaround: requested };
|
|
2983
|
+
const effectiveArgs = [...jsonPrefix(args), ...selection.prefixArgs];
|
|
2984
|
+
if (compatibility.compatibilityWorkaround && !activeTarget) {
|
|
2985
|
+
effectiveArgs.push("--user-agent", getDefaultHeadlessCompatUserAgent());
|
|
2986
|
+
}
|
|
2987
|
+
effectiveArgs.push(...selection.argsToAppend);
|
|
2988
|
+
return {
|
|
2989
|
+
commandInfo,
|
|
2990
|
+
compatibilityWorkaround: compatibility.compatibilityWorkaround,
|
|
2991
|
+
effectiveArgs,
|
|
2992
|
+
managedSessionName: selection.managedSessionName,
|
|
2993
|
+
namespace: selection.namespace,
|
|
2994
|
+
plainTextInspection: false,
|
|
2995
|
+
recoveryHint: compatibility.recoveryHint,
|
|
2996
|
+
sessionName: selection.sessionName,
|
|
2997
|
+
startupScopedFlags,
|
|
2998
|
+
usedImplicitSession: selection.usedImplicitSession,
|
|
2999
|
+
validationError: compatibility.validationError
|
|
3000
|
+
};
|
|
3001
|
+
}
|
|
3002
|
+
export {
|
|
3003
|
+
buildExecutionPlan,
|
|
3004
|
+
canUseHeadlessCompatibilityUserAgent,
|
|
3005
|
+
chooseOpenResultTabCorrection,
|
|
3006
|
+
createEphemeralSessionSeed,
|
|
3007
|
+
createFreshSessionName,
|
|
3008
|
+
createImplicitSessionName,
|
|
3009
|
+
extractCommandTokens,
|
|
3010
|
+
extractUpstreamCommandTokens,
|
|
3011
|
+
findCommandStartIndex,
|
|
3012
|
+
getDefaultHeadlessCompatUserAgent,
|
|
3013
|
+
getImplicitSessionCloseTimeoutMs,
|
|
3014
|
+
getImplicitSessionIdleTimeoutMs,
|
|
3015
|
+
getStartupScopedFlags,
|
|
3016
|
+
isPlainTextInspectionArgs,
|
|
3017
|
+
isRestorableManagedSessionName,
|
|
3018
|
+
parseArgvDescriptor,
|
|
3019
|
+
parseCommandInfo,
|
|
3020
|
+
parseWaitCommandTokens,
|
|
3021
|
+
redactInvocationArgs,
|
|
3022
|
+
redactSensitiveText,
|
|
3023
|
+
redactSensitiveValue,
|
|
3024
|
+
resolveManagedSessionState,
|
|
3025
|
+
restoreManagedSessionStateFromBranch,
|
|
3026
|
+
validateToolArgs
|
|
3027
|
+
};
|