pi-agent-browser-native 0.9.5 → 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 +19 -0
- package/README.md +3 -0
- package/dist/extensions/agent-browser/index.js +1214 -583
- 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 +11 -1
- package/docs/CODE_QUALITY.md +11 -0
- package/docs/COMMAND_REFERENCE.md +2 -2
- package/docs/PERFORMANCE.md +243 -0
- package/docs/REFERENCE.md +3 -3
- package/docs/SESSION_STORAGE.md +11 -3
- package/docs/SUPPORT_MATRIX.md +8 -4
- package/docs/TOOL_CONTRACT.md +4 -4
- package/docs/performance/2026-10-12.json +7257 -0
- package/package.json +13 -2
- package/scripts/build.mjs +16 -5
- package/scripts/config.mjs +1 -1
- package/scripts/convert-browser-session.mjs +1 -1
- package/dist/extensions/agent-browser/lib/argv-descriptor.js +0 -123
- package/dist/extensions/agent-browser/lib/argv-grammar.js +0 -320
- package/dist/extensions/agent-browser/lib/bash-guard.js +0 -193
- package/dist/extensions/agent-browser/lib/batch-lifecycle.js +0 -131
- package/dist/extensions/agent-browser/lib/browser-execution-claim-codec.js +0 -61
- package/dist/extensions/agent-browser/lib/browser-execution-claim-storage.js +0 -232
- package/dist/extensions/agent-browser/lib/browser-execution-claims.js +0 -202
- package/dist/extensions/agent-browser/lib/browser-execution-identity.js +0 -77
- package/dist/extensions/agent-browser/lib/browser-journal-branch.js +0 -98
- package/dist/extensions/agent-browser/lib/browser-journal-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/browser-journal-projection.js +0 -221
- package/dist/extensions/agent-browser/lib/browser-journal-reader.js +0 -89
- package/dist/extensions/agent-browser/lib/browser-journal-replay.js +0 -246
- package/dist/extensions/agent-browser/lib/browser-journal.js +0 -148
- package/dist/extensions/agent-browser/lib/browser-legacy-pages.js +0 -220
- package/dist/extensions/agent-browser/lib/browser-legacy-projection.js +0 -282
- package/dist/extensions/agent-browser/lib/browser-legacy-types.js +0 -1
- package/dist/extensions/agent-browser/lib/browser-session-conversion-stream.js +0 -217
- package/dist/extensions/agent-browser/lib/browser-session-conversion.js +0 -126
- package/dist/extensions/agent-browser/lib/browser-transcript-contracts.js +0 -35
- package/dist/extensions/agent-browser/lib/browser-transcript-validation.js +0 -166
- package/dist/extensions/agent-browser/lib/browser-transcript.js +0 -189
- package/dist/extensions/agent-browser/lib/browser-value-parsing.js +0 -15
- package/dist/extensions/agent-browser/lib/command-capabilities.js +0 -340
- package/dist/extensions/agent-browser/lib/command-policy.js +0 -155
- package/dist/extensions/agent-browser/lib/command-taxonomy.js +0 -105
- package/dist/extensions/agent-browser/lib/config-policy.js +0 -450
- package/dist/extensions/agent-browser/lib/config-providers.js +0 -71
- package/dist/extensions/agent-browser/lib/config-validation.js +0 -231
- package/dist/extensions/agent-browser/lib/config.js +0 -69
- package/dist/extensions/agent-browser/lib/electron/cdp.js +0 -62
- package/dist/extensions/agent-browser/lib/electron/cleanup.js +0 -274
- package/dist/extensions/agent-browser/lib/electron/discovery-darwin.js +0 -109
- package/dist/extensions/agent-browser/lib/electron/discovery-desktop.js +0 -136
- package/dist/extensions/agent-browser/lib/electron/discovery-evidence.js +0 -90
- package/dist/extensions/agent-browser/lib/electron/discovery-linux.js +0 -93
- package/dist/extensions/agent-browser/lib/electron/discovery-packages.js +0 -162
- package/dist/extensions/agent-browser/lib/electron/discovery-types.js +0 -2
- package/dist/extensions/agent-browser/lib/electron/discovery.js +0 -217
- package/dist/extensions/agent-browser/lib/electron/launch-monitor.js +0 -102
- package/dist/extensions/agent-browser/lib/electron/launch-process.js +0 -209
- package/dist/extensions/agent-browser/lib/electron/launch-types.js +0 -2
- package/dist/extensions/agent-browser/lib/electron/launch.js +0 -340
- package/dist/extensions/agent-browser/lib/executable-path.js +0 -29
- package/dist/extensions/agent-browser/lib/execution-cwd.js +0 -67
- package/dist/extensions/agent-browser/lib/fs-utils.js +0 -10
- package/dist/extensions/agent-browser/lib/input-modes/electron.js +0 -201
- package/dist/extensions/agent-browser/lib/input-modes/job.js +0 -198
- package/dist/extensions/agent-browser/lib/input-modes/lookup-network-evidence.js +0 -116
- package/dist/extensions/agent-browser/lib/input-modes/lookup-plan.js +0 -132
- package/dist/extensions/agent-browser/lib/input-modes/lookup-redaction.js +0 -57
- package/dist/extensions/agent-browser/lib/input-modes/lookup-source-evidence.js +0 -151
- package/dist/extensions/agent-browser/lib/input-modes/lookup-workspace.js +0 -142
- package/dist/extensions/agent-browser/lib/input-modes/lookups.js +0 -84
- package/dist/extensions/agent-browser/lib/input-modes/params.js +0 -195
- package/dist/extensions/agent-browser/lib/input-modes/qa-analysis.js +0 -268
- package/dist/extensions/agent-browser/lib/input-modes/qa-presentation.js +0 -117
- package/dist/extensions/agent-browser/lib/input-modes/script-child.js +0 -396
- package/dist/extensions/agent-browser/lib/input-modes/script-protocol.js +0 -86
- package/dist/extensions/agent-browser/lib/input-modes/script-types.js +0 -1
- package/dist/extensions/agent-browser/lib/input-modes/script-validation.js +0 -60
- package/dist/extensions/agent-browser/lib/input-modes/script.js +0 -108
- package/dist/extensions/agent-browser/lib/input-modes/semantic-action.js +0 -243
- package/dist/extensions/agent-browser/lib/input-modes/shared.js +0 -48
- package/dist/extensions/agent-browser/lib/input-modes/types.js +0 -65
- package/dist/extensions/agent-browser/lib/json-schema.js +0 -65
- package/dist/extensions/agent-browser/lib/launch-scoped-flags.js +0 -212
- package/dist/extensions/agent-browser/lib/managed-session-policy-lock.js +0 -165
- package/dist/extensions/agent-browser/lib/managed-session-posix-storage.js +0 -58
- package/dist/extensions/agent-browser/lib/managed-session-project-identity.js +0 -244
- package/dist/extensions/agent-browser/lib/managed-session-restore-context.js +0 -84
- package/dist/extensions/agent-browser/lib/managed-session-restore-policy.js +0 -119
- package/dist/extensions/agent-browser/lib/managed-session-restore-state.js +0 -83
- package/dist/extensions/agent-browser/lib/managed-session-restore.js +0 -212
- package/dist/extensions/agent-browser/lib/managed-session-snapshot-records.js +0 -277
- package/dist/extensions/agent-browser/lib/managed-session-snapshots.js +0 -181
- package/dist/extensions/agent-browser/lib/managed-session-storage.js +0 -126
- package/dist/extensions/agent-browser/lib/native-confirmation.js +0 -140
- package/dist/extensions/agent-browser/lib/native-output.js +0 -81
- package/dist/extensions/agent-browser/lib/orchestration/batch-stdin.js +0 -182
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/artifact-merge.js +0 -30
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/artifact-paths.js +0 -188
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/browser-observation-result.js +0 -82
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/click-dispatch.js +0 -406
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/diagnostic-values.js +0 -31
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/diagnostics.js +0 -240
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/electron-observation.js +0 -203
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/electron-text-diagnostics.js +0 -109
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/fill-diagnostics.js +0 -119
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-action-recovery.js +0 -147
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-actions.js +0 -144
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-content.js +0 -123
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-details.js +0 -156
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-electron.js +0 -187
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-evidence.js +0 -39
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-missing-binary.js +0 -89
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-recovery.js +0 -97
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-redaction.js +0 -106
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-timeout.js +0 -110
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result.js +0 -53
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/index.js +0 -224
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/interaction-diagnostics.js +0 -290
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-close.js +0 -167
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-daemon-inspection.js +0 -108
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-daemon-policy.js +0 -174
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/native-helper-observation.js +0 -65
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/observation-types.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/overlay-diagnostics.js +0 -120
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/network-page-filter.js +0 -192
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/scroll-shims.js +0 -225
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-filter-data.js +0 -150
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-filter.js +0 -174
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-rendered-text.js +0 -147
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/wait-timeouts.js +0 -145
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-artifacts.js +0 -159
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-command.js +0 -131
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-daemon.js +0 -93
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-failure.js +0 -42
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-guards.js +0 -242
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-input.js +0 -75
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-observations.js +0 -92
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-page-selection.js +0 -254
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-page-state.js +0 -121
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-refs.js +0 -130
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-resources.js +0 -114
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-semantic.js +0 -121
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-session-plan.js +0 -222
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-timeouts.js +0 -68
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare.js +0 -202
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-analysis.js +0 -191
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-confirmation.js +0 -152
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-diagnostics.js +0 -182
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-electron.js +0 -150
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle-phase-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle-phase.js +0 -115
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle.js +0 -256
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-managed-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-managed.js +0 -256
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-native-phase-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-native-phase.js +0 -93
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-native.js +0 -113
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-navigation-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-navigation.js +0 -316
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-ownership.js +0 -28
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-page-phase-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-page-phase.js +0 -142
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-presentation-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-presentation.js +0 -333
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-publication-phase-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-publication-phase.js +0 -71
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-publication.js +0 -201
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-receipts.js +0 -183
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-refs.js +0 -200
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-tabs.js +0 -142
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output.js +0 -25
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prompt-guards.js +0 -50
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-receipt-reconciliation.js +0 -198
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-recovery-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-recovery-presentation.js +0 -154
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-recovery.js +0 -80
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/screenshot-capture.js +0 -14
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/screenshot-observation.js +0 -206
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-commands.js +0 -130
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-electron.js +0 -212
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-observations.js +0 -61
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-outcomes.js +0 -187
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-refs.js +0 -169
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-tabs.js +0 -228
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state.js +0 -117
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/text-visibility-diagnostics.js +0 -182
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/timeout-diagnostics.js +0 -256
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/timeout-progress.js +0 -108
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/types.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/code-artifact-observation.js +0 -39
- package/dist/extensions/agent-browser/lib/orchestration/code-image-observation.js +0 -119
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/branch.js +0 -93
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/cleanup-result.js +0 -58
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/cleanup.js +0 -78
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/discovery.js +0 -106
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/index.js +0 -60
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/policy.js +0 -86
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-collection.js +0 -68
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-data.js +0 -169
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-presentation.js +0 -182
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe.js +0 -161
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/status.js +0 -167
- package/dist/extensions/agent-browser/lib/orchestration/execution-queue.js +0 -98
- package/dist/extensions/agent-browser/lib/orchestration/extension-artifact-preflight.js +0 -211
- package/dist/extensions/agent-browser/lib/orchestration/extension-artifacts.js +0 -23
- package/dist/extensions/agent-browser/lib/orchestration/extension-attachment-replay.js +0 -99
- package/dist/extensions/agent-browser/lib/orchestration/extension-branch-restore.js +0 -275
- package/dist/extensions/agent-browser/lib/orchestration/extension-code.js +0 -280
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-admission.js +0 -303
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-output.js +0 -36
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-result.js +0 -335
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-run.js +0 -227
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-state.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/extension-electron-ownership.js +0 -204
- package/dist/extensions/agent-browser/lib/orchestration/extension-execution-locks.js +0 -139
- package/dist/extensions/agent-browser/lib/orchestration/extension-execution-queue.js +0 -24
- package/dist/extensions/agent-browser/lib/orchestration/extension-host-coordination.js +0 -98
- package/dist/extensions/agent-browser/lib/orchestration/extension-host-run.js +0 -295
- package/dist/extensions/agent-browser/lib/orchestration/extension-intent-replay.js +0 -41
- package/dist/extensions/agent-browser/lib/orchestration/extension-invocation.js +0 -7
- package/dist/extensions/agent-browser/lib/orchestration/extension-lifecycle.js +0 -102
- package/dist/extensions/agent-browser/lib/orchestration/extension-managed-ownership.js +0 -133
- package/dist/extensions/agent-browser/lib/orchestration/extension-observation.js +0 -120
- package/dist/extensions/agent-browser/lib/orchestration/extension-prompt.js +0 -180
- package/dist/extensions/agent-browser/lib/orchestration/extension-recording.js +0 -290
- package/dist/extensions/agent-browser/lib/orchestration/extension-resource-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/extension-resource-replay.js +0 -269
- package/dist/extensions/agent-browser/lib/orchestration/extension-result-state.js +0 -113
- package/dist/extensions/agent-browser/lib/orchestration/extension-runtime.js +0 -146
- package/dist/extensions/agent-browser/lib/orchestration/extension-script-leases.js +0 -58
- package/dist/extensions/agent-browser/lib/orchestration/extension-tool-boundary.js +0 -62
- package/dist/extensions/agent-browser/lib/orchestration/extension-version-check.js +0 -54
- package/dist/extensions/agent-browser/lib/orchestration/input-plan-types.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/input-plan.js +0 -313
- package/dist/extensions/agent-browser/lib/orchestration/input-redaction.js +0 -62
- package/dist/extensions/agent-browser/lib/orchestration/native-config.js +0 -144
- package/dist/extensions/agent-browser/lib/orchestration/native-root-launch.js +0 -77
- package/dist/extensions/agent-browser/lib/orchestration/native-session-defaults.js +0 -231
- package/dist/extensions/agent-browser/lib/orchestration/operation-paths.js +0 -142
- package/dist/extensions/agent-browser/lib/orchestration/output-file.js +0 -276
- package/dist/extensions/agent-browser/lib/orchestration/script-mode.js +0 -220
- package/dist/extensions/agent-browser/lib/owned-managed-session-context.js +0 -55
- package/dist/extensions/agent-browser/lib/page-target-batch.js +0 -118
- package/dist/extensions/agent-browser/lib/page-target-guards.js +0 -50
- package/dist/extensions/agent-browser/lib/page-target-navigation.js +0 -104
- package/dist/extensions/agent-browser/lib/page-target-validation.js +0 -90
- package/dist/extensions/agent-browser/lib/parsing.js +0 -30
- package/dist/extensions/agent-browser/lib/pi-tool-rendering.js +0 -343
- package/dist/extensions/agent-browser/lib/playbook.js +0 -146
- package/dist/extensions/agent-browser/lib/process-child.js +0 -284
- package/dist/extensions/agent-browser/lib/process-environment.js +0 -48
- package/dist/extensions/agent-browser/lib/process-errors.js +0 -23
- package/dist/extensions/agent-browser/lib/process-identity.js +0 -127
- package/dist/extensions/agent-browser/lib/process-socket-storage.js +0 -256
- package/dist/extensions/agent-browser/lib/process-stdout.js +0 -74
- package/dist/extensions/agent-browser/lib/process.js +0 -216
- package/dist/extensions/agent-browser/lib/prompt-artifacts.js +0 -287
- package/dist/extensions/agent-browser/lib/prompt-policy.js +0 -54
- package/dist/extensions/agent-browser/lib/read-command.js +0 -41
- package/dist/extensions/agent-browser/lib/read-confirmation.js +0 -162
- package/dist/extensions/agent-browser/lib/recording-reservations.js +0 -208
- package/dist/extensions/agent-browser/lib/redaction-fields.js +0 -75
- package/dist/extensions/agent-browser/lib/redaction-json.js +0 -149
- package/dist/extensions/agent-browser/lib/redaction-url.js +0 -88
- package/dist/extensions/agent-browser/lib/results/action-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/results/action-recommendations.js +0 -38
- package/dist/extensions/agent-browser/lib/results/artifact-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/results/artifact-manifest-validation.js +0 -133
- package/dist/extensions/agent-browser/lib/results/artifact-manifest.js +0 -173
- package/dist/extensions/agent-browser/lib/results/artifact-recommendations.js +0 -73
- package/dist/extensions/agent-browser/lib/results/categories.js +0 -152
- package/dist/extensions/agent-browser/lib/results/confirmation.js +0 -75
- package/dist/extensions/agent-browser/lib/results/contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/results/editable-ref-evidence.js +0 -99
- package/dist/extensions/agent-browser/lib/results/electron-recommendations.js +0 -83
- package/dist/extensions/agent-browser/lib/results/envelope-decoding.js +0 -48
- package/dist/extensions/agent-browser/lib/results/envelope.js +0 -198
- package/dist/extensions/agent-browser/lib/results/evidence-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/results/failure-recommendations.js +0 -180
- package/dist/extensions/agent-browser/lib/results/network-routes.js +0 -133
- package/dist/extensions/agent-browser/lib/results/network.js +0 -89
- package/dist/extensions/agent-browser/lib/results/next-actions.js +0 -111
- package/dist/extensions/agent-browser/lib/results/presentation/artifact-files.js +0 -320
- package/dist/extensions/agent-browser/lib/results/presentation/artifact-format.js +0 -138
- package/dist/extensions/agent-browser/lib/results/presentation/artifact-images.js +0 -113
- package/dist/extensions/agent-browser/lib/results/presentation/artifact-verification.js +0 -145
- package/dist/extensions/agent-browser/lib/results/presentation/artifacts.js +0 -165
- package/dist/extensions/agent-browser/lib/results/presentation/batch-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/results/presentation/batch-recording.js +0 -118
- package/dist/extensions/agent-browser/lib/results/presentation/batch-redaction.js +0 -68
- package/dist/extensions/agent-browser/lib/results/presentation/batch-rendering.js +0 -135
- package/dist/extensions/agent-browser/lib/results/presentation/batch-step.js +0 -227
- package/dist/extensions/agent-browser/lib/results/presentation/batch-summary.js +0 -91
- package/dist/extensions/agent-browser/lib/results/presentation/batch.js +0 -123
- package/dist/extensions/agent-browser/lib/results/presentation/browser-profile-recovery.js +0 -54
- package/dist/extensions/agent-browser/lib/results/presentation/command-presenters.js +0 -216
- package/dist/extensions/agent-browser/lib/results/presentation/common.js +0 -81
- package/dist/extensions/agent-browser/lib/results/presentation/content.js +0 -119
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-a11y.js +0 -67
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-health.js +0 -79
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-identity.js +0 -199
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-logs.js +0 -75
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-network-actions.js +0 -216
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-network.js +0 -124
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-redaction.js +0 -64
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-storage.js +0 -209
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-stream.js +0 -69
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-summary.js +0 -222
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostics.js +0 -124
- package/dist/extensions/agent-browser/lib/results/presentation/early-result.js +0 -70
- package/dist/extensions/agent-browser/lib/results/presentation/errors.js +0 -285
- package/dist/extensions/agent-browser/lib/results/presentation/input-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/results/presentation/large-output.js +0 -117
- package/dist/extensions/agent-browser/lib/results/presentation/navigation.js +0 -231
- package/dist/extensions/agent-browser/lib/results/presentation/notices.js +0 -75
- package/dist/extensions/agent-browser/lib/results/presentation/observation-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/results/presentation/observation-rendering.js +0 -127
- package/dist/extensions/agent-browser/lib/results/presentation/outcomes.js +0 -120
- package/dist/extensions/agent-browser/lib/results/presentation/output-completion.js +0 -77
- package/dist/extensions/agent-browser/lib/results/presentation/output-spill.js +0 -51
- package/dist/extensions/agent-browser/lib/results/presentation/registry.js +0 -145
- package/dist/extensions/agent-browser/lib/results/presentation/semantic-action.js +0 -104
- package/dist/extensions/agent-browser/lib/results/presentation/skills.js +0 -183
- package/dist/extensions/agent-browser/lib/results/presentation/source.js +0 -109
- package/dist/extensions/agent-browser/lib/results/presentation.js +0 -19
- package/dist/extensions/agent-browser/lib/results/recommendation-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/results/recording.js +0 -88
- package/dist/extensions/agent-browser/lib/results/recovery-actions.js +0 -118
- package/dist/extensions/agent-browser/lib/results/recovery-next-actions.js +0 -60
- package/dist/extensions/agent-browser/lib/results/selector-recovery-target.js +0 -83
- package/dist/extensions/agent-browser/lib/results/selector-recovery.js +0 -261
- package/dist/extensions/agent-browser/lib/results/snapshot-compact.js +0 -266
- package/dist/extensions/agent-browser/lib/results/snapshot-content.js +0 -32
- package/dist/extensions/agent-browser/lib/results/snapshot-high-value-controls.js +0 -240
- package/dist/extensions/agent-browser/lib/results/snapshot-refs.js +0 -103
- package/dist/extensions/agent-browser/lib/results/snapshot-segments.js +0 -383
- package/dist/extensions/agent-browser/lib/results/snapshot-spill.js +0 -53
- package/dist/extensions/agent-browser/lib/results/snapshot.js +0 -44
- package/dist/extensions/agent-browser/lib/results/text.js +0 -44
- package/dist/extensions/agent-browser/lib/runtime-args-validation.js +0 -133
- package/dist/extensions/agent-browser/lib/runtime-compatibility.js +0 -81
- package/dist/extensions/agent-browser/lib/runtime-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/runtime-redaction.js +0 -118
- package/dist/extensions/agent-browser/lib/runtime-replay-events.js +0 -144
- package/dist/extensions/agent-browser/lib/runtime-session-identity.js +0 -76
- package/dist/extensions/agent-browser/lib/runtime-session-plan.js +0 -114
- package/dist/extensions/agent-browser/lib/runtime-session-replay.js +0 -123
- package/dist/extensions/agent-browser/lib/runtime-tab-correction.js +0 -65
- package/dist/extensions/agent-browser/lib/runtime-timeouts.js +0 -28
- package/dist/extensions/agent-browser/lib/runtime.js +0 -163
- package/dist/extensions/agent-browser/lib/session-identity.js +0 -51
- package/dist/extensions/agent-browser/lib/session-page-observation.js +0 -357
- package/dist/extensions/agent-browser/lib/session-page-state.js +0 -353
- package/dist/extensions/agent-browser/lib/session-page-types.js +0 -1
- package/dist/extensions/agent-browser/lib/string-enum-schema.js +0 -8
- package/dist/extensions/agent-browser/lib/temp-artifact-budget.js +0 -81
- package/dist/extensions/agent-browser/lib/temp-mutation-queue.js +0 -7
- package/dist/extensions/agent-browser/lib/temp-root-ownership.js +0 -234
- package/dist/extensions/agent-browser/lib/temp-root.js +0 -211
- package/dist/extensions/agent-browser/lib/temp.js +0 -91
- package/dist/extensions/agent-browser/lib/tool-surface.js +0 -239
- package/dist/extensions/agent-browser/lib/upstream-version.js +0 -15
- package/dist/extensions/agent-browser/lib/web-search-providers.js +0 -193
- package/dist/extensions/agent-browser/lib/web-search-request.js +0 -102
- package/dist/extensions/agent-browser/lib/web-search-results.js +0 -281
- package/dist/extensions/agent-browser/lib/web-search-schema.js +0 -82
- package/dist/extensions/agent-browser/lib/web-search.js +0 -167
- package/dist/extensions/agent-browser/lib/webmcp-observation.js +0 -35
- package/dist/extensions/agent-browser/lib/windows-stock-launcher.js +0 -96
- package/dist/scripts/agent-browser-target.mjs +0 -23
|
@@ -1,340 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { rm } from "node:fs/promises";
|
|
3
|
-
import { discoverElectronApps, inspectElectronAppPath, inspectElectronExecutablePath, } from "./discovery.js";
|
|
4
|
-
import { createSecureTempDirectory, preserveSecureTempDirectory } from "../temp.js";
|
|
5
|
-
import { stringifyUnknown } from "../results/text.js";
|
|
6
|
-
import { readProcessStartIdentity } from "../process-identity.js";
|
|
7
|
-
import { isElectronLaunchAborted, pollCdpMetadata, pollDevToolsActivePort, } from "./launch-monitor.js";
|
|
8
|
-
import { ElectronLaunchProcess } from "./launch-process.js";
|
|
9
|
-
import { ELECTRON_LAUNCH_RECORD_VERSION, ELECTRON_PROFILE_DIR_PREFIX, } from "./launch-types.js";
|
|
10
|
-
export { ELECTRON_LAUNCH_RECORD_VERSION, ELECTRON_PROFILE_DIR_PREFIX } from "./launch-types.js";
|
|
11
|
-
const DEFAULT_TIMEOUT_MS = 15_000;
|
|
12
|
-
const MAX_TIMEOUT_MS = 120_000;
|
|
13
|
-
const DEFAULT_APP_ARGS = ["--disable-extensions", "--no-first-run", "--no-default-browser-check"];
|
|
14
|
-
function normalizeTimeoutMs(timeoutMs) {
|
|
15
|
-
if (typeof timeoutMs !== "number" || !Number.isSafeInteger(timeoutMs) || timeoutMs <= 0) {
|
|
16
|
-
return DEFAULT_TIMEOUT_MS;
|
|
17
|
-
}
|
|
18
|
-
return Math.min(timeoutMs, MAX_TIMEOUT_MS);
|
|
19
|
-
}
|
|
20
|
-
function normalizeIdentifier(value) {
|
|
21
|
-
const trimmed = value?.trim().toLowerCase();
|
|
22
|
-
return trimmed !== undefined && trimmed.length > 0 ? trimmed : undefined;
|
|
23
|
-
}
|
|
24
|
-
function policyEntryMatchesApp(entry, app) {
|
|
25
|
-
const normalized = normalizeIdentifier(entry);
|
|
26
|
-
if (normalized === undefined) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
const identifiers = [
|
|
30
|
-
app.name,
|
|
31
|
-
app.bundleId,
|
|
32
|
-
app.desktopId,
|
|
33
|
-
app.appPath,
|
|
34
|
-
app.executablePath,
|
|
35
|
-
].filter((value) => typeof value === "string" && value.trim().length > 0);
|
|
36
|
-
return identifiers.some((identifier) => identifier.toLowerCase().includes(normalized));
|
|
37
|
-
}
|
|
38
|
-
function evaluateLaunchPolicy(options, target) {
|
|
39
|
-
const denyEntry = options.deny?.find((entry) => policyEntryMatchesApp(entry, target));
|
|
40
|
-
if (denyEntry !== undefined && denyEntry.length > 0) {
|
|
41
|
-
return {
|
|
42
|
-
entry: denyEntry,
|
|
43
|
-
list: "deny",
|
|
44
|
-
message: `Electron launch blocked by caller deny policy: ${denyEntry}`,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
if (options.allow !== undefined && options.allow.length > 0) {
|
|
48
|
-
const allowEntry = options.allow.find((entry) => policyEntryMatchesApp(entry, target));
|
|
49
|
-
if (allowEntry === undefined || allowEntry.length === 0) {
|
|
50
|
-
return {
|
|
51
|
-
list: "allow",
|
|
52
|
-
message: "Electron launch blocked because the resolved app did not match caller allow policy.",
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return undefined;
|
|
57
|
-
}
|
|
58
|
-
async function resolveLaunchTarget(options) {
|
|
59
|
-
if (options.appPath !== undefined && options.appPath.length > 0) {
|
|
60
|
-
return inspectElectronAppPath(options.appPath);
|
|
61
|
-
}
|
|
62
|
-
if (options.executablePath !== undefined && options.executablePath.length > 0) {
|
|
63
|
-
return inspectElectronExecutablePath(options.executablePath);
|
|
64
|
-
}
|
|
65
|
-
const discovery = await discoverElectronApps({
|
|
66
|
-
maxResults: 200,
|
|
67
|
-
query: options.bundleId ?? options.appName,
|
|
68
|
-
});
|
|
69
|
-
return selectDiscoveredTarget(discovery.apps, options);
|
|
70
|
-
}
|
|
71
|
-
function selectDiscoveredTarget(apps, options) {
|
|
72
|
-
if ((options.bundleId ?? "").length > 0) {
|
|
73
|
-
const bundleId = normalizeIdentifier(options.bundleId);
|
|
74
|
-
return apps.find((app) => normalizeIdentifier(app.bundleId) === bundleId);
|
|
75
|
-
}
|
|
76
|
-
if ((options.appName ?? "").length > 0) {
|
|
77
|
-
const name = normalizeIdentifier(options.appName);
|
|
78
|
-
return apps.find((app) => normalizeIdentifier(app.name) === name) ?? apps.at(0);
|
|
79
|
-
}
|
|
80
|
-
return undefined;
|
|
81
|
-
}
|
|
82
|
-
function targetMatchesType(target, type) {
|
|
83
|
-
return type === undefined || type === "any" || target.type === type;
|
|
84
|
-
}
|
|
85
|
-
function selectConnectArg(port, metadata, type) {
|
|
86
|
-
const targetSocket = metadata.targets.find((target) => targetMatchesType(target, type) &&
|
|
87
|
-
target.webSocketDebuggerUrl !== undefined &&
|
|
88
|
-
target.webSocketDebuggerUrl.length > 0)?.webSocketDebuggerUrl;
|
|
89
|
-
return targetSocket ?? metadata.version.webSocketDebuggerUrl ?? String(port);
|
|
90
|
-
}
|
|
91
|
-
function launchFailureMessage(reason, target, detail) {
|
|
92
|
-
const label = target ? `${target.name} (${target.appPath ?? target.executablePath})` : "target";
|
|
93
|
-
switch (reason) {
|
|
94
|
-
case "aborted":
|
|
95
|
-
return `Electron launch was aborted${target ? ` before ${label} finished starting` : " before the app started"}.`;
|
|
96
|
-
case "non-electron-target":
|
|
97
|
-
return `Electron launch rejected: ${label} does not have the required Electron runtime and app payload evidence.`;
|
|
98
|
-
case "policy-blocked":
|
|
99
|
-
return detail ?? `Electron launch blocked by caller policy for ${label}.`;
|
|
100
|
-
case "single-instance-conflict":
|
|
101
|
-
return `Electron launch did not expose a debug port for ${label}; the app may already be running as a single-instance Electron app. Quit the running app and retry.`;
|
|
102
|
-
case "port-not-found":
|
|
103
|
-
return `Electron launch found a DevToolsActivePort for ${label}, but /json/version never returned a valid CDP payload.`;
|
|
104
|
-
case "spawn-error":
|
|
105
|
-
return `Electron launch failed while starting ${label}${detail !== undefined && detail.length > 0 ? `: ${detail}` : "."}`;
|
|
106
|
-
case "timeout":
|
|
107
|
-
return `Electron launch timed out waiting for DevToolsActivePort for ${label}.`;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
/** Owns one profile and process attempt; only a successful result transfers them to the host. */
|
|
111
|
-
class ElectronLaunchAttempt {
|
|
112
|
-
options;
|
|
113
|
-
target;
|
|
114
|
-
userDataDir;
|
|
115
|
-
process;
|
|
116
|
-
startedAtMs;
|
|
117
|
-
timeoutMs;
|
|
118
|
-
deadlineMs;
|
|
119
|
-
appArgs;
|
|
120
|
-
startIdentity;
|
|
121
|
-
constructor(options, target, userDataDir, timing) {
|
|
122
|
-
this.options = options;
|
|
123
|
-
this.target = target;
|
|
124
|
-
this.userDataDir = userDataDir;
|
|
125
|
-
this.process = new ElectronLaunchProcess(userDataDir);
|
|
126
|
-
this.startedAtMs = timing.startedAtMs;
|
|
127
|
-
this.timeoutMs = timing.timeoutMs;
|
|
128
|
-
this.deadlineMs = timing.startedAtMs + timing.timeoutMs;
|
|
129
|
-
this.appArgs = options.appArgs ?? [];
|
|
130
|
-
}
|
|
131
|
-
diagnostics(observation) {
|
|
132
|
-
return {
|
|
133
|
-
...observation,
|
|
134
|
-
elapsedMs: Math.max(0, Date.now() - this.startedAtMs),
|
|
135
|
-
exitCode: this.process.exitCode,
|
|
136
|
-
exitSignal: this.process.exitSignal,
|
|
137
|
-
outputCaptured: this.process.outputCaptured,
|
|
138
|
-
pid: this.process.child?.pid,
|
|
139
|
-
pidAlive: this.process.child === undefined ? undefined : this.process.pidAlive(),
|
|
140
|
-
port: observation.port ?? observation.devToolsActivePort?.port,
|
|
141
|
-
timeoutMs: this.timeoutMs,
|
|
142
|
-
userDataDir: this.userDataDir,
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
async cleanupProfile(processError) {
|
|
146
|
-
try {
|
|
147
|
-
if (processError !== undefined && processError.length > 0) {
|
|
148
|
-
await preserveSecureTempDirectory(this.userDataDir);
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
await rm(this.userDataDir, { force: true, recursive: true });
|
|
152
|
-
}
|
|
153
|
-
return undefined;
|
|
154
|
-
}
|
|
155
|
-
catch (error) {
|
|
156
|
-
const message = error instanceof Error ? error.message : stringifyUnknown(error);
|
|
157
|
-
return processError !== undefined && processError.length > 0
|
|
158
|
-
? `Profile preservation failed: ${message}`
|
|
159
|
-
: message;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
async fail(reason, detail, observation = {}) {
|
|
163
|
-
const diagnostics = this.diagnostics(observation);
|
|
164
|
-
const processError = await this.process.terminate();
|
|
165
|
-
const output = await this.process.readOutput();
|
|
166
|
-
const profileError = await this.cleanupProfile(processError);
|
|
167
|
-
const cleanupErrors = [processError, this.process.cleanupError, profileError].filter((value) => value !== undefined);
|
|
168
|
-
const cleanupError = cleanupErrors.join("; ");
|
|
169
|
-
return {
|
|
170
|
-
ok: false,
|
|
171
|
-
failure: {
|
|
172
|
-
appArgs: this.appArgs,
|
|
173
|
-
cleanupError: cleanupError.length === 0 ? undefined : cleanupError,
|
|
174
|
-
diagnostics: { ...diagnostics, ...output.evidence },
|
|
175
|
-
error: [launchFailureMessage(reason, this.target, detail), ...output.lines].join("\n"),
|
|
176
|
-
reason,
|
|
177
|
-
target: this.target,
|
|
178
|
-
userDataDir: this.userDataDir,
|
|
179
|
-
},
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
record(port, version) {
|
|
183
|
-
const pid = this.process.child?.pid;
|
|
184
|
-
return {
|
|
185
|
-
appName: this.target.name,
|
|
186
|
-
appPath: this.target.appPath,
|
|
187
|
-
bundleId: this.target.bundleId,
|
|
188
|
-
cleanupState: "active",
|
|
189
|
-
createdAtMs: Date.now(),
|
|
190
|
-
desktopId: this.target.desktopId,
|
|
191
|
-
executablePath: this.target.executablePath,
|
|
192
|
-
launchId: `electron-${randomUUID()}`,
|
|
193
|
-
launchedByWrapper: true,
|
|
194
|
-
packageSource: this.target.packageSource,
|
|
195
|
-
pid,
|
|
196
|
-
platform: this.target.platform,
|
|
197
|
-
port,
|
|
198
|
-
processGroupId: process.platform === "win32" ? undefined : pid,
|
|
199
|
-
startIdentity: this.startIdentity,
|
|
200
|
-
targetType: this.options.targetType,
|
|
201
|
-
userDataDir: this.userDataDir,
|
|
202
|
-
version: ELECTRON_LAUNCH_RECORD_VERSION,
|
|
203
|
-
webSocketDebuggerUrl: version.webSocketDebuggerUrl,
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
async run() {
|
|
207
|
-
const args = [
|
|
208
|
-
...this.appArgs,
|
|
209
|
-
`--user-data-dir=${this.userDataDir}`,
|
|
210
|
-
"--remote-debugging-port=0",
|
|
211
|
-
...DEFAULT_APP_ARGS,
|
|
212
|
-
];
|
|
213
|
-
await this.process.spawn(this.target.executablePath, args, this.options.signal);
|
|
214
|
-
if (this.process.child === undefined) {
|
|
215
|
-
return this.fail(isElectronLaunchAborted(this.options.signal) ? "aborted" : "spawn-error", this.process.spawnError?.message);
|
|
216
|
-
}
|
|
217
|
-
const pid = this.process.child.pid;
|
|
218
|
-
this.startIdentity =
|
|
219
|
-
pid === undefined
|
|
220
|
-
? undefined
|
|
221
|
-
: await readProcessStartIdentity(pid, process.platform, {
|
|
222
|
-
deadline: this.deadlineMs,
|
|
223
|
-
signal: this.options.signal,
|
|
224
|
-
});
|
|
225
|
-
const portResult = await pollDevToolsActivePort({
|
|
226
|
-
deadlineMs: this.deadlineMs,
|
|
227
|
-
getChildExit: this.process.childExit,
|
|
228
|
-
getSpawnError: this.process.childSpawnError,
|
|
229
|
-
signal: this.options.signal,
|
|
230
|
-
userDataDir: this.userDataDir,
|
|
231
|
-
});
|
|
232
|
-
if (portResult.port === undefined) {
|
|
233
|
-
return this.fail(portResult.failure ?? "timeout", portResult.spawnError?.message, {
|
|
234
|
-
devToolsActivePort: portResult.devToolsActivePort,
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
return this.connect(portResult.port, portResult.devToolsActivePort);
|
|
238
|
-
}
|
|
239
|
-
async connect(port, devToolsActivePort) {
|
|
240
|
-
const metadataResult = await pollCdpMetadata(port, this.deadlineMs, this.options.signal);
|
|
241
|
-
if (metadataResult.aborted) {
|
|
242
|
-
return this.fail("aborted", undefined, { devToolsActivePort, port });
|
|
243
|
-
}
|
|
244
|
-
const metadata = metadataResult.metadata;
|
|
245
|
-
if (metadata === undefined) {
|
|
246
|
-
return this.fail("port-not-found", undefined, {
|
|
247
|
-
cdpVersionReached: false,
|
|
248
|
-
devToolsActivePort,
|
|
249
|
-
port,
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
const child = this.process.child;
|
|
253
|
-
if (child === undefined) {
|
|
254
|
-
throw new Error("Electron launch lost its child handle before handoff.");
|
|
255
|
-
}
|
|
256
|
-
return {
|
|
257
|
-
ok: true,
|
|
258
|
-
value: {
|
|
259
|
-
appArgs: this.appArgs,
|
|
260
|
-
child,
|
|
261
|
-
connectArg: selectConnectArg(port, metadata, this.options.targetType),
|
|
262
|
-
record: this.record(port, metadata.version),
|
|
263
|
-
target: this.target,
|
|
264
|
-
targets: metadata.targets,
|
|
265
|
-
version: metadata.version,
|
|
266
|
-
},
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
async function abortedProfileResult(userDataDir, options, target) {
|
|
271
|
-
let cleanupError;
|
|
272
|
-
try {
|
|
273
|
-
await rm(userDataDir, { force: true, recursive: true });
|
|
274
|
-
}
|
|
275
|
-
catch (error) {
|
|
276
|
-
cleanupError = error instanceof Error ? error.message : stringifyUnknown(error);
|
|
277
|
-
}
|
|
278
|
-
return {
|
|
279
|
-
ok: false,
|
|
280
|
-
failure: {
|
|
281
|
-
appArgs: options.appArgs ?? [],
|
|
282
|
-
cleanupError,
|
|
283
|
-
error: launchFailureMessage("aborted", target),
|
|
284
|
-
reason: "aborted",
|
|
285
|
-
target,
|
|
286
|
-
userDataDir,
|
|
287
|
-
},
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
export async function launchElectronApp(options) {
|
|
291
|
-
const appArgs = options.appArgs ?? [];
|
|
292
|
-
if (isElectronLaunchAborted(options.signal)) {
|
|
293
|
-
return {
|
|
294
|
-
ok: false,
|
|
295
|
-
failure: { appArgs, error: launchFailureMessage("aborted", undefined), reason: "aborted" },
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
|
-
const target = await resolveLaunchTarget(options);
|
|
299
|
-
if (isElectronLaunchAborted(options.signal)) {
|
|
300
|
-
return {
|
|
301
|
-
ok: false,
|
|
302
|
-
failure: {
|
|
303
|
-
appArgs,
|
|
304
|
-
error: launchFailureMessage("aborted", target),
|
|
305
|
-
reason: "aborted",
|
|
306
|
-
target,
|
|
307
|
-
},
|
|
308
|
-
};
|
|
309
|
-
}
|
|
310
|
-
if (target === undefined) {
|
|
311
|
-
return {
|
|
312
|
-
ok: false,
|
|
313
|
-
failure: {
|
|
314
|
-
appArgs,
|
|
315
|
-
error: launchFailureMessage("non-electron-target", undefined),
|
|
316
|
-
reason: "non-electron-target",
|
|
317
|
-
},
|
|
318
|
-
};
|
|
319
|
-
}
|
|
320
|
-
const policy = evaluateLaunchPolicy(options, target);
|
|
321
|
-
if (policy !== undefined) {
|
|
322
|
-
return {
|
|
323
|
-
ok: false,
|
|
324
|
-
failure: {
|
|
325
|
-
appArgs,
|
|
326
|
-
error: launchFailureMessage("policy-blocked", target, policy.message),
|
|
327
|
-
policy,
|
|
328
|
-
reason: "policy-blocked",
|
|
329
|
-
target,
|
|
330
|
-
},
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
const timeoutMs = normalizeTimeoutMs(options.timeoutMs);
|
|
334
|
-
const startedAtMs = Date.now();
|
|
335
|
-
const userDataDir = await createSecureTempDirectory(ELECTRON_PROFILE_DIR_PREFIX);
|
|
336
|
-
if (isElectronLaunchAborted(options.signal)) {
|
|
337
|
-
return abortedProfileResult(userDataDir, options, target);
|
|
338
|
-
}
|
|
339
|
-
return new ElectronLaunchAttempt(options, target, userDataDir, { timeoutMs, startedAtMs }).run();
|
|
340
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { constants as fsConstants } from "node:fs";
|
|
2
|
-
import { access, stat } from "node:fs/promises";
|
|
3
|
-
import { delimiter, join } from "node:path";
|
|
4
|
-
async function isExecutableFile(candidate) {
|
|
5
|
-
try {
|
|
6
|
-
await access(candidate, fsConstants.X_OK);
|
|
7
|
-
return (await stat(candidate)).isFile();
|
|
8
|
-
}
|
|
9
|
-
catch {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
export async function executableExistsOnPath(command) {
|
|
14
|
-
const extensions = process.platform === "win32"
|
|
15
|
-
? (process.env.PATHEXT ?? ".EXE;.CMD;.BAT;.COM").split(";").filter(Boolean)
|
|
16
|
-
: [""];
|
|
17
|
-
const candidates = (process.env.PATH ?? "")
|
|
18
|
-
.split(delimiter)
|
|
19
|
-
.filter(Boolean)
|
|
20
|
-
.flatMap((directory) => extensions.map((extension) => join(directory, `${command}${extension}`)));
|
|
21
|
-
for (const candidate of candidates) {
|
|
22
|
-
// Respect PATH/PATHEXT precedence and stop probing after the first executable.
|
|
23
|
-
// oxlint-disable-next-line no-await-in-loop
|
|
24
|
-
if (await isExecutableFile(candidate)) {
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { readFileSync, statSync } from "node:fs";
|
|
2
|
-
import { dirname, isAbsolute, join } from "node:path";
|
|
3
|
-
import { isRecord } from "./parsing.js";
|
|
4
|
-
function isDirectoryOwner(source) {
|
|
5
|
-
if (/^(?:npm:pi-change-working-dir|git:github\.com\/fitchmultz\/pi-change-working-dir(?:\.git)?)(?:@.+)?$/.test(source.source)) {
|
|
6
|
-
return true;
|
|
7
|
-
}
|
|
8
|
-
const directories = [source.baseDir, isAbsolute(source.path) ? dirname(source.path) : undefined];
|
|
9
|
-
return directories.some((directory) => {
|
|
10
|
-
if (directory === undefined || directory.length === 0 || !isAbsolute(directory)) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
try {
|
|
14
|
-
const manifest = JSON.parse(readFileSync(join(directory, "package.json"), "utf8"));
|
|
15
|
-
return isRecord(manifest) && manifest.name === "pi-change-working-dir";
|
|
16
|
-
}
|
|
17
|
-
catch {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
function validateDirectoryReply(result) {
|
|
23
|
-
const invalid = "pi-change-working-dir returned an invalid execution directory. Update the extension and restart Pi.";
|
|
24
|
-
if (!isRecord(result) || Array.isArray(result)) {
|
|
25
|
-
throw new Error(invalid);
|
|
26
|
-
}
|
|
27
|
-
if (result.error !== undefined) {
|
|
28
|
-
throw new Error(typeof result.error === "string" && result.error.length > 0 ? result.error : invalid);
|
|
29
|
-
}
|
|
30
|
-
if (typeof result.cwd !== "string" || !isAbsolute(result.cwd) || result.cwd.includes("\0")) {
|
|
31
|
-
throw new Error(invalid);
|
|
32
|
-
}
|
|
33
|
-
return result.cwd;
|
|
34
|
-
}
|
|
35
|
-
/** The synchronous owner reply is captured before any browser policy, queue, or child await. */
|
|
36
|
-
export function resolveExecutionCwd(pi, ctx) {
|
|
37
|
-
const request = {
|
|
38
|
-
sessionManager: ctx.sessionManager,
|
|
39
|
-
};
|
|
40
|
-
pi.events.emit("pi-change-working-dir:resolve-execution-cwd", request);
|
|
41
|
-
const result = request.result;
|
|
42
|
-
if (result !== undefined) {
|
|
43
|
-
return validateDirectoryReply(result);
|
|
44
|
-
}
|
|
45
|
-
if (pi
|
|
46
|
-
.getAllTools()
|
|
47
|
-
.some((tool) => tool.name === "change_dir" && isDirectoryOwner(tool.sourceInfo)) ||
|
|
48
|
-
pi
|
|
49
|
-
.getCommands()
|
|
50
|
-
.some((command) => /^cwd(?::\d+)?$/.test(command.name) && isDirectoryOwner(command.sourceInfo))) {
|
|
51
|
-
throw new Error("Update pi-change-working-dir and restart Pi to use agent_browser with the selected working directory.");
|
|
52
|
-
}
|
|
53
|
-
return ctx.cwd;
|
|
54
|
-
}
|
|
55
|
-
export function getBrowserCwdError(cwd) {
|
|
56
|
-
try {
|
|
57
|
-
if (statSync(cwd).isDirectory()) {
|
|
58
|
-
return undefined;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
if (!isRecord(error) || (error.code !== "ENOENT" && error.code !== "ENOTDIR")) {
|
|
63
|
-
throw error;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return `Browser launch directory is unavailable: ${cwd}. Restore that directory, or explicitly use sessionMode: "fresh" without --session, or --config from the selected execution directory. The existing browser was left untouched.`;
|
|
67
|
-
}
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import { isRecord } from "../parsing.js";
|
|
2
|
-
import { isStringArray } from "./shared.js";
|
|
3
|
-
import { AGENT_BROWSER_ELECTRON_ACTIONS, AGENT_BROWSER_ELECTRON_HANDOFFS, AGENT_BROWSER_ELECTRON_LIST_FIELDS, AGENT_BROWSER_ELECTRON_PROBE_FIELDS, AGENT_BROWSER_ELECTRON_RESERVED_APP_ARGS, AGENT_BROWSER_ELECTRON_TARGET_TYPES, } from "./types.js";
|
|
4
|
-
function optionalString(input, fieldName) {
|
|
5
|
-
const value = input[fieldName];
|
|
6
|
-
if (value === undefined) {
|
|
7
|
-
return {};
|
|
8
|
-
}
|
|
9
|
-
if (typeof value !== "string" || value.trim().length === 0) {
|
|
10
|
-
return { error: `electron.${fieldName} must be a non-empty string when provided.` };
|
|
11
|
-
}
|
|
12
|
-
return { value: value.trim() };
|
|
13
|
-
}
|
|
14
|
-
function optionalInteger(input, fieldName) {
|
|
15
|
-
const value = input[fieldName];
|
|
16
|
-
if (value === undefined) {
|
|
17
|
-
return {};
|
|
18
|
-
}
|
|
19
|
-
if (typeof value !== "number" || !Number.isInteger(value) || value <= 0) {
|
|
20
|
-
return { error: `electron.${fieldName} must be a positive integer when provided.` };
|
|
21
|
-
}
|
|
22
|
-
return { value };
|
|
23
|
-
}
|
|
24
|
-
function stringArray(value) {
|
|
25
|
-
if (!isStringArray(value)) {
|
|
26
|
-
return undefined;
|
|
27
|
-
}
|
|
28
|
-
return value.map((item) => item.trim());
|
|
29
|
-
}
|
|
30
|
-
function arrayError(input, fieldName) {
|
|
31
|
-
const value = input[fieldName];
|
|
32
|
-
if (value === undefined) {
|
|
33
|
-
return undefined;
|
|
34
|
-
}
|
|
35
|
-
const parsed = stringArray(value);
|
|
36
|
-
return parsed === undefined || parsed.some((item) => item.length === 0)
|
|
37
|
-
? `electron.${fieldName} must be an array of non-empty strings when provided.`
|
|
38
|
-
: undefined;
|
|
39
|
-
}
|
|
40
|
-
function enumError(input, fieldName, values) {
|
|
41
|
-
const value = input[fieldName];
|
|
42
|
-
if (value === undefined) {
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
|
-
return typeof value !== "string" || !values.includes(value)
|
|
46
|
-
? `electron.${fieldName} must be one of: ${values.join(", ")}.`
|
|
47
|
-
: undefined;
|
|
48
|
-
}
|
|
49
|
-
function commonError(input) {
|
|
50
|
-
for (const field of ["query", "appPath", "appName", "bundleId", "executablePath", "launchId"]) {
|
|
51
|
-
const error = optionalString(input, field).error;
|
|
52
|
-
if (error !== undefined) {
|
|
53
|
-
return error;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
for (const field of ["appArgs", "allow", "deny"]) {
|
|
57
|
-
const error = arrayError(input, field);
|
|
58
|
-
if (error !== undefined) {
|
|
59
|
-
return error;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return (enumError(input, "handoff", AGENT_BROWSER_ELECTRON_HANDOFFS) ??
|
|
63
|
-
enumError(input, "targetType", AGENT_BROWSER_ELECTRON_TARGET_TYPES) ??
|
|
64
|
-
numericError(input));
|
|
65
|
-
}
|
|
66
|
-
function numericError(input) {
|
|
67
|
-
for (const field of ["maxResults", "timeoutMs"]) {
|
|
68
|
-
const error = optionalInteger(input, field).error;
|
|
69
|
-
if (error !== undefined) {
|
|
70
|
-
return error;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return input.all !== undefined && input.all !== true
|
|
74
|
-
? "electron.all must be true when provided."
|
|
75
|
-
: undefined;
|
|
76
|
-
}
|
|
77
|
-
function unsupportedField(input, allowed) {
|
|
78
|
-
return Object.keys(input).find((field) => !allowed.includes(field));
|
|
79
|
-
}
|
|
80
|
-
function allowedFieldError(input, action, allowed) {
|
|
81
|
-
const field = unsupportedField(input, allowed);
|
|
82
|
-
return field === undefined ? undefined : `electron.${action} does not support electron.${field}.`;
|
|
83
|
-
}
|
|
84
|
-
function compileLaunch(input) {
|
|
85
|
-
const fieldError = allowedFieldError(input, "launch", [
|
|
86
|
-
"action",
|
|
87
|
-
"allow",
|
|
88
|
-
"appArgs",
|
|
89
|
-
"appName",
|
|
90
|
-
"appPath",
|
|
91
|
-
"bundleId",
|
|
92
|
-
"deny",
|
|
93
|
-
"executablePath",
|
|
94
|
-
"handoff",
|
|
95
|
-
"targetType",
|
|
96
|
-
"timeoutMs",
|
|
97
|
-
]);
|
|
98
|
-
if (fieldError !== undefined) {
|
|
99
|
-
return { error: fieldError };
|
|
100
|
-
}
|
|
101
|
-
const appArgs = stringArray(input.appArgs);
|
|
102
|
-
const reservedArg = appArgs?.find((arg) => arg === "--" ||
|
|
103
|
-
AGENT_BROWSER_ELECTRON_RESERVED_APP_ARGS.some((reserved) => arg === reserved || arg.startsWith(`${reserved}=`)));
|
|
104
|
-
if (reservedArg !== undefined) {
|
|
105
|
-
return { error: `electron.appArgs must not include wrapper-owned launch flag ${reservedArg}.` };
|
|
106
|
-
}
|
|
107
|
-
const providedTargets = ["appPath", "appName", "bundleId", "executablePath"].filter((field) => input[field] !== undefined);
|
|
108
|
-
if (providedTargets.length !== 1) {
|
|
109
|
-
return {
|
|
110
|
-
error: "electron.launch requires exactly one of appPath, appName, bundleId, or executablePath.",
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
return {
|
|
114
|
-
compiled: {
|
|
115
|
-
action: "launch",
|
|
116
|
-
allow: stringArray(input.allow),
|
|
117
|
-
appArgs,
|
|
118
|
-
deny: stringArray(input.deny),
|
|
119
|
-
appName: optionalString(input, "appName").value,
|
|
120
|
-
appPath: optionalString(input, "appPath").value,
|
|
121
|
-
bundleId: optionalString(input, "bundleId").value,
|
|
122
|
-
executablePath: optionalString(input, "executablePath").value,
|
|
123
|
-
handoff: AGENT_BROWSER_ELECTRON_HANDOFFS.find((value) => value === input.handoff) ?? "snapshot",
|
|
124
|
-
targetType: AGENT_BROWSER_ELECTRON_TARGET_TYPES.find((value) => value === input.targetType) ?? "page",
|
|
125
|
-
timeoutMs: optionalInteger(input, "timeoutMs").value,
|
|
126
|
-
},
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
function compileList(input) {
|
|
130
|
-
const field = unsupportedField(input, AGENT_BROWSER_ELECTRON_LIST_FIELDS);
|
|
131
|
-
if (field !== undefined) {
|
|
132
|
-
return { error: `electron.list only supports query and maxResults; remove electron.${field}.` };
|
|
133
|
-
}
|
|
134
|
-
return {
|
|
135
|
-
compiled: {
|
|
136
|
-
action: "list",
|
|
137
|
-
maxResults: optionalInteger(input, "maxResults").value,
|
|
138
|
-
query: optionalString(input, "query").value,
|
|
139
|
-
},
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
function compileProbe(input) {
|
|
143
|
-
const field = unsupportedField(input, AGENT_BROWSER_ELECTRON_PROBE_FIELDS);
|
|
144
|
-
if (field !== undefined) {
|
|
145
|
-
return {
|
|
146
|
-
error: `electron.probe only supports action, launchId, and timeoutMs; remove electron.${field}.`,
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
const launchId = optionalString(input, "launchId").value;
|
|
150
|
-
const timeoutMs = optionalInteger(input, "timeoutMs").value;
|
|
151
|
-
return {
|
|
152
|
-
compiled: {
|
|
153
|
-
action: "probe",
|
|
154
|
-
...(launchId !== undefined ? { launchId } : {}),
|
|
155
|
-
...(timeoutMs !== undefined ? { timeoutMs } : {}),
|
|
156
|
-
},
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
function compileStatusOrCleanup(input, action) {
|
|
160
|
-
const error = allowedFieldError(input, action, ["action", "all", "launchId", "timeoutMs"]);
|
|
161
|
-
if (error !== undefined) {
|
|
162
|
-
return { error };
|
|
163
|
-
}
|
|
164
|
-
if (input.all === true && input.launchId !== undefined) {
|
|
165
|
-
return { error: `electron.${action} accepts launchId or all, not both.` };
|
|
166
|
-
}
|
|
167
|
-
return {
|
|
168
|
-
compiled: {
|
|
169
|
-
action,
|
|
170
|
-
all: input.all === true ? true : undefined,
|
|
171
|
-
launchId: optionalString(input, "launchId").value,
|
|
172
|
-
timeoutMs: optionalInteger(input, "timeoutMs").value,
|
|
173
|
-
},
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
export function compileAgentBrowserElectron(input) {
|
|
177
|
-
if (!isRecord(input)) {
|
|
178
|
-
return { error: "electron must be an object." };
|
|
179
|
-
}
|
|
180
|
-
const action = AGENT_BROWSER_ELECTRON_ACTIONS.find((value) => value === input.action);
|
|
181
|
-
if (action === undefined) {
|
|
182
|
-
return {
|
|
183
|
-
error: `electron.action must be one of: ${AGENT_BROWSER_ELECTRON_ACTIONS.join(", ")}.`,
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
const error = commonError(input);
|
|
187
|
-
if (error !== undefined) {
|
|
188
|
-
return { error };
|
|
189
|
-
}
|
|
190
|
-
switch (action) {
|
|
191
|
-
case "launch":
|
|
192
|
-
return compileLaunch(input);
|
|
193
|
-
case "list":
|
|
194
|
-
return compileList(input);
|
|
195
|
-
case "probe":
|
|
196
|
-
return compileProbe(input);
|
|
197
|
-
case "status":
|
|
198
|
-
case "cleanup":
|
|
199
|
-
return compileStatusOrCleanup(input, action);
|
|
200
|
-
}
|
|
201
|
-
}
|