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,227 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { appendBrowserTransition } from "../browser-transcript.js";
|
|
3
|
-
import { appendBrowserRecord } from "../browser-journal.js";
|
|
4
|
-
import { buildExecutionPlan, createFreshSessionName, redactInvocationArgs } from "../runtime.js";
|
|
5
|
-
import { getAgentBrowserSessionIdentityKey } from "../argv-grammar.js";
|
|
6
|
-
import { parseArgvDescriptor } from "../argv-descriptor.js";
|
|
7
|
-
import { needsManagedSession } from "../command-policy.js";
|
|
8
|
-
import { isRecord } from "../parsing.js";
|
|
9
|
-
import { resolveAgentBrowserSocketDir } from "../process.js";
|
|
10
|
-
import { getAgentBrowserProcessEnvironment } from "../process-environment.js";
|
|
11
|
-
// Static ownership keeps the runner's host peers inside Pi's extension-module mapping.
|
|
12
|
-
import { runAgentBrowserTool } from "./browser-run/index.js";
|
|
13
|
-
import { getSessionContextKey } from "./browser-run/session-state.js";
|
|
14
|
-
import { ELECTRON_POST_COMMAND_STATUS_SETTLE_MS, ELECTRON_PROFILE_ISOLATION_DETAILS, } from "./electron-host/index.js";
|
|
15
|
-
import { browserExecutionFailure } from "./extension-result-state.js";
|
|
16
|
-
import { isAttachedBrowserInvocation } from "./extension-resource-replay.js";
|
|
17
|
-
import { BrowserCommandResult } from "./extension-command-result.js";
|
|
18
|
-
function captureBrowserRunState(runtime) {
|
|
19
|
-
return {
|
|
20
|
-
activeRecordingReservations: runtime.recordings.active,
|
|
21
|
-
artifactManifest: runtime.artifacts.manifest,
|
|
22
|
-
attachedSessionKeys: runtime.sessions.attached,
|
|
23
|
-
closedManagedSessionNames: new Set(),
|
|
24
|
-
electronChildProcesses: runtime.electron.childProcesses,
|
|
25
|
-
electronLaunchRecords: runtime.electron.records,
|
|
26
|
-
ephemeralSessionSeed: runtime.ephemeralSessionSeed,
|
|
27
|
-
freshSessionOrdinal: runtime.managed.freshOrdinal,
|
|
28
|
-
managedSessionActive: runtime.managed.active,
|
|
29
|
-
managedSessionBaseName: runtime.managed.baseName,
|
|
30
|
-
managedSessionCompatibilityWorkaround: runtime.managed.compatibilityWorkaround,
|
|
31
|
-
managedSessionHeadedAutosaveDisabled: runtime.managed.headedAutosaveDisabled,
|
|
32
|
-
managedSessionHeadedAutosaveInterval: runtime.managed.headedAutosaveInterval,
|
|
33
|
-
managedSessionCwd: runtime.managed.cwd,
|
|
34
|
-
managedSessionName: runtime.managed.name,
|
|
35
|
-
managedSessionNamespace: runtime.managed.namespace,
|
|
36
|
-
managedSessionRestoreState: runtime.managed.restore,
|
|
37
|
-
networkRoutesBySession: runtime.sessions.routes,
|
|
38
|
-
ownedManagedSessions: runtime.managed.owned,
|
|
39
|
-
sessionPageState: runtime.sessions.pages.fork(),
|
|
40
|
-
traceOwners: runtime.sessions.traces,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
function selectCommandPlan(state, call) {
|
|
44
|
-
return buildExecutionPlan(call.toolArgs, {
|
|
45
|
-
freshSessionName: createFreshSessionName(state.managedSessionBaseName, state.ephemeralSessionSeed, state.freshSessionOrdinal + 1),
|
|
46
|
-
managedSessionActive: state.managedSessionActive,
|
|
47
|
-
managedSessionCompatibilityWorkaround: state.managedSessionCompatibilityWorkaround,
|
|
48
|
-
managedSessionName: state.managedSessionName,
|
|
49
|
-
managedSessionNamespace: state.managedSessionNamespace,
|
|
50
|
-
sessionMode: call.compiledElectron?.action === "launch" ? "fresh" : (call.params.sessionMode ?? "auto"),
|
|
51
|
-
stdin: call.resolvedInput.toolStdin,
|
|
52
|
-
browserIndependentReadConfirmation: call.readConfirmation?.capabilities?.readRequiresConfirmation === true,
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
function affectsBrowser(plan, call) {
|
|
56
|
-
if (plan.plainTextInspection ||
|
|
57
|
-
(plan.commandInfo.command === "session" && plan.commandInfo.subcommand === "info")) {
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
return (needsManagedSession(parseArgvDescriptor(call.toolArgs), call.resolvedInput.toolStdin) ||
|
|
61
|
-
plan.startupScopedFlags.length > 0);
|
|
62
|
-
}
|
|
63
|
-
function createBeginRecord(call, identity) {
|
|
64
|
-
const wrapperManaged = identity.wrapperManaged;
|
|
65
|
-
return {
|
|
66
|
-
event: {
|
|
67
|
-
version: 1,
|
|
68
|
-
phase: "begin",
|
|
69
|
-
operationId: identity.operationId,
|
|
70
|
-
toolCallId: call.toolCallId,
|
|
71
|
-
commandIndex: call.commandIndex ?? 0,
|
|
72
|
-
isError: true,
|
|
73
|
-
state: {
|
|
74
|
-
args: redactInvocationArgs(call.toolArgs),
|
|
75
|
-
sessionName: identity.plan.sessionName,
|
|
76
|
-
namespace: identity.plan.namespace,
|
|
77
|
-
ownerSessionId: call.ctx.sessionManager.getSessionId(),
|
|
78
|
-
usedImplicitSession: identity.plan.usedImplicitSession,
|
|
79
|
-
wrapperManaged,
|
|
80
|
-
managedSessionCwd: call.browserCwd,
|
|
81
|
-
managedSessionSocketDir: resolveAgentBrowserSocketDir({
|
|
82
|
-
ownedManagedSession: wrapperManaged,
|
|
83
|
-
}),
|
|
84
|
-
},
|
|
85
|
-
pages: [
|
|
86
|
-
{
|
|
87
|
-
key: identity.selectedKey,
|
|
88
|
-
confirmActions: identity.confirmActions ?? null,
|
|
89
|
-
refs: { kind: "unknown" },
|
|
90
|
-
unknown: true,
|
|
91
|
-
},
|
|
92
|
-
],
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
function prepareBrowserCommand(runtime, call, executionSignal) {
|
|
97
|
-
runtime.recordings.flush();
|
|
98
|
-
const generationAtStart = runtime.branch.stateGeneration;
|
|
99
|
-
const browserRunState = captureBrowserRunState(runtime);
|
|
100
|
-
const workingPageState = browserRunState.sessionPageState;
|
|
101
|
-
const priorPages = workingPageState.views();
|
|
102
|
-
const sessionPageStateUpdate = workingPageState.beginUpdate();
|
|
103
|
-
const selectedPlan = selectCommandPlan(browserRunState, call);
|
|
104
|
-
const operationId = randomUUID();
|
|
105
|
-
const selectedKey = getAgentBrowserSessionIdentityKey(selectedPlan.sessionName ?? "default", selectedPlan.namespace);
|
|
106
|
-
browserRunState.confirmationPolicyIdentity = selectedKey;
|
|
107
|
-
const confirmActions = getAgentBrowserProcessEnvironment().AGENT_BROWSER_CONFIRM_ACTIONS;
|
|
108
|
-
workingPageState.setConfirmActions(selectedKey, confirmActions);
|
|
109
|
-
const begin = createBeginRecord(call, {
|
|
110
|
-
plan: selectedPlan,
|
|
111
|
-
operationId,
|
|
112
|
-
selectedKey,
|
|
113
|
-
confirmActions,
|
|
114
|
-
wrapperManaged: selectedPlan.managedSessionName !== undefined || runtime.managed.owned.has(selectedKey),
|
|
115
|
-
});
|
|
116
|
-
return {
|
|
117
|
-
generationAtStart,
|
|
118
|
-
browserRunState,
|
|
119
|
-
workingPageState,
|
|
120
|
-
priorPages,
|
|
121
|
-
sessionPageStateUpdate,
|
|
122
|
-
selectedPlan,
|
|
123
|
-
operationId,
|
|
124
|
-
selectedKey,
|
|
125
|
-
begin,
|
|
126
|
-
browserAffecting: affectsBrowser(selectedPlan, call),
|
|
127
|
-
executionSignal,
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
async function admitBrowserCommand(pi, pages, call, prepared) {
|
|
131
|
-
if (!prepared.browserAffecting) {
|
|
132
|
-
return undefined;
|
|
133
|
-
}
|
|
134
|
-
try {
|
|
135
|
-
if (!(await appendBrowserRecord(call.ctx.sessionManager, () => appendBrowserTransition(pi, prepared.begin), prepared.begin, call.branch)) ||
|
|
136
|
-
!call.branch.isCurrent()) {
|
|
137
|
-
throw new Error("The selected Pi branch changed before browser-command admission.");
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
catch (error) {
|
|
141
|
-
const failure = browserExecutionFailure(new Error("Could not persist browser-state begin; the browser command was not run.", {
|
|
142
|
-
cause: error,
|
|
143
|
-
}), prepared.executionSignal);
|
|
144
|
-
return {
|
|
145
|
-
...failure,
|
|
146
|
-
details: {
|
|
147
|
-
...(isRecord(failure.details) ? failure.details : {}),
|
|
148
|
-
browserStatePersistence: "begin-unconfirmed",
|
|
149
|
-
},
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
pages.applyBrowserRecord(prepared.begin);
|
|
153
|
-
return undefined;
|
|
154
|
-
}
|
|
155
|
-
function captureDispatch(attachedSessionKeys, call, prepared) {
|
|
156
|
-
const electronLaunch = call.resolvedInput.kind === "electron" &&
|
|
157
|
-
call.resolvedInput.compiledElectron.action === "launch";
|
|
158
|
-
const attachedSessionRequested = isAttachedBrowserInvocation(call.toolArgs) || electronLaunch;
|
|
159
|
-
const allocatesFreshManagedSession = call.explicitSessionName === undefined &&
|
|
160
|
-
(call.params.sessionMode === "fresh" || electronLaunch);
|
|
161
|
-
const reusableSessionKey = allocatesFreshManagedSession
|
|
162
|
-
? undefined
|
|
163
|
-
: (getSessionContextKey(prepared.selectedPlan.sessionName, prepared.selectedPlan.namespace) ??
|
|
164
|
-
getSessionContextKey(prepared.browserRunState.managedSessionName, prepared.browserRunState.managedSessionNamespace));
|
|
165
|
-
return {
|
|
166
|
-
initialArtifactManifest: prepared.browserRunState.artifactManifest,
|
|
167
|
-
initialNetworkRoutesBySession: prepared.browserRunState.networkRoutesBySession,
|
|
168
|
-
attachedSessionRequested,
|
|
169
|
-
attachedSessionKnown: reusableSessionKey !== undefined && attachedSessionKeys.has(reusableSessionKey),
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
async function dispatchBrowserCommand(timeouts, call, prepared, dispatch) {
|
|
173
|
-
try {
|
|
174
|
-
return await runAgentBrowserTool({
|
|
175
|
-
daemonInactive: dispatch.daemonInactive,
|
|
176
|
-
ctx: call.ctx,
|
|
177
|
-
cwd: call.browserCwd,
|
|
178
|
-
operationCwd: call.operationCwd,
|
|
179
|
-
electronPostCommandStatusSettleMs: ELECTRON_POST_COMMAND_STATUS_SETTLE_MS,
|
|
180
|
-
electronProfileIsolationDetails: ELECTRON_PROFILE_ISOLATION_DETAILS,
|
|
181
|
-
implicitSessionCloseTimeoutMs: timeouts.close,
|
|
182
|
-
implicitSessionIdleTimeoutMs: timeouts.idle,
|
|
183
|
-
input: call.resolvedInput,
|
|
184
|
-
modelVisible: call.modelVisible,
|
|
185
|
-
onUpdate: call.onUpdate,
|
|
186
|
-
params: call.params,
|
|
187
|
-
establishAttachedBrowserSession: dispatch.attachedSessionRequested && !dispatch.attachedSessionKnown,
|
|
188
|
-
preserveAttachedBrowserSession: dispatch.attachedSessionRequested || dispatch.attachedSessionKnown,
|
|
189
|
-
promptPolicy: call.promptPolicy,
|
|
190
|
-
sessionPageStateUpdate: prepared.sessionPageStateUpdate,
|
|
191
|
-
signal: prepared.executionSignal,
|
|
192
|
-
state: prepared.browserRunState,
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
catch (error) {
|
|
196
|
-
const failure = browserExecutionFailure(error, prepared.executionSignal);
|
|
197
|
-
return {
|
|
198
|
-
...failure,
|
|
199
|
-
details: {
|
|
200
|
-
...prepared.browserRunState.observedBrowserEffects,
|
|
201
|
-
...(isRecord(failure.details) ? failure.details : {}),
|
|
202
|
-
},
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
export async function runBrowserCommand(runtime, call, daemonInactive, executionSignal = call.signal) {
|
|
207
|
-
const prepared = prepareBrowserCommand(runtime, call, executionSignal);
|
|
208
|
-
const admissionFailure = await admitBrowserCommand(runtime.pi, runtime.sessions.pages, call, prepared);
|
|
209
|
-
if (admissionFailure) {
|
|
210
|
-
return admissionFailure;
|
|
211
|
-
}
|
|
212
|
-
const dispatch = captureDispatch(runtime.sessions.attached, call, prepared);
|
|
213
|
-
const result = await dispatchBrowserCommand({ close: runtime.implicitSessionCloseTimeoutMs, idle: runtime.implicitSessionIdleTimeoutMs }, call, prepared, {
|
|
214
|
-
...dispatch,
|
|
215
|
-
daemonInactive,
|
|
216
|
-
});
|
|
217
|
-
const completion = new BrowserCommandResult(runtime, call, prepared, { ...dispatch, result });
|
|
218
|
-
completion.reconcileNativeIdentity();
|
|
219
|
-
completion.reconcileAttachments();
|
|
220
|
-
completion.mergeResultArtifacts();
|
|
221
|
-
completion.adoptRuntime();
|
|
222
|
-
const persistenceFailure = await completion.persistFinish();
|
|
223
|
-
if (persistenceFailure) {
|
|
224
|
-
return persistenceFailure;
|
|
225
|
-
}
|
|
226
|
-
return completion.complete();
|
|
227
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import { isRecord } from "../parsing.js";
|
|
2
|
-
import { findElectronLaunchRecordForSession, getActiveElectronRecords, getSessionContextKey, } from "./browser-run/session-state.js";
|
|
3
|
-
import { untrackOwnedManagedSession } from "./extension-managed-ownership.js";
|
|
4
|
-
export function getTouchedElectronLaunchIds(sessionName, records, namespace) {
|
|
5
|
-
const record = findElectronLaunchRecordForSession(sessionName, records, namespace);
|
|
6
|
-
return record ? new Set([record.launchId]) : undefined;
|
|
7
|
-
}
|
|
8
|
-
/** Branch-visible launches, live cleanup ownership, and their native child handles. */
|
|
9
|
-
export class BrowserElectronResources {
|
|
10
|
-
records = new Map();
|
|
11
|
-
ownedRecords = new Map();
|
|
12
|
-
branchOwnedIds = new Set();
|
|
13
|
-
childProcesses = new Map();
|
|
14
|
-
mergeActive(source, options = {}) {
|
|
15
|
-
const target = this.ownedRecords;
|
|
16
|
-
const branchOwned = this.branchOwnedIds;
|
|
17
|
-
for (const record of getActiveElectronRecords(source)) {
|
|
18
|
-
if (options.ownerSessionId !== undefined &&
|
|
19
|
-
record.ownerSessionId !== options.ownerSessionId) {
|
|
20
|
-
continue;
|
|
21
|
-
}
|
|
22
|
-
const alreadyRuntimeOwned = target.has(record.launchId) && !branchOwned.has(record.launchId);
|
|
23
|
-
target.set(record.launchId, record);
|
|
24
|
-
if (alreadyRuntimeOwned) {
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
if (options.markBranchOwned === true) {
|
|
28
|
-
branchOwned.add(record.launchId);
|
|
29
|
-
}
|
|
30
|
-
else if (options.touchedLaunchIds?.has(record.launchId) === true) {
|
|
31
|
-
branchOwned.delete(record.launchId);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
removeInactive(source, activeRanks, cleanupRanks) {
|
|
36
|
-
const target = this.ownedRecords;
|
|
37
|
-
const branchOwned = this.branchOwnedIds;
|
|
38
|
-
const activeIds = new Set(getActiveElectronRecords(source).map((record) => record.launchId));
|
|
39
|
-
for (const id of new Set([...source.keys(), ...cleanupRanks.keys()])) {
|
|
40
|
-
if (!target.has(id) || !branchOwned.has(id)) {
|
|
41
|
-
continue;
|
|
42
|
-
}
|
|
43
|
-
const active = activeRanks.get(id), cleanup = cleanupRanks.get(id);
|
|
44
|
-
const inactive = source.has(id) && !activeIds.has(id);
|
|
45
|
-
const cleanupIsLatest = cleanup !== undefined && (active === undefined || cleanup > active);
|
|
46
|
-
if (!inactive && !cleanupIsLatest) {
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
target.delete(id);
|
|
50
|
-
branchOwned.delete(id);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
replaceActive(source, cleanedLaunchIds) {
|
|
54
|
-
this.ownedRecords.clear();
|
|
55
|
-
if (cleanedLaunchIds) {
|
|
56
|
-
for (const id of cleanedLaunchIds) {
|
|
57
|
-
this.branchOwnedIds.delete(id);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
this.branchOwnedIds.clear();
|
|
62
|
-
}
|
|
63
|
-
this.mergeActive(source);
|
|
64
|
-
}
|
|
65
|
-
forHostInput(options) {
|
|
66
|
-
if (options.compiledElectron?.action === "cleanup") {
|
|
67
|
-
return new Map([...mergeElectronLaunchRecordMaps(this.records, this.ownedRecords)].filter(([, record]) => record.ownerSessionId === options.ownerSessionId));
|
|
68
|
-
}
|
|
69
|
-
if (options.compiledElectron?.action === "status" ||
|
|
70
|
-
(options.compiledElectron?.action === "probe" &&
|
|
71
|
-
options.compiledElectron.launchId !== undefined &&
|
|
72
|
-
options.compiledElectron.launchId !== "")) {
|
|
73
|
-
return mergeElectronLaunchRecordMaps(this.records, this.ownedRecords);
|
|
74
|
-
}
|
|
75
|
-
return this.records;
|
|
76
|
-
}
|
|
77
|
-
mergeCleanup(results) {
|
|
78
|
-
for (const record of getCleanupResultsElectronRecords(results)) {
|
|
79
|
-
this.records.set(record.launchId, record);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
resetOwnership() {
|
|
83
|
-
this.ownedRecords = new Map();
|
|
84
|
-
this.branchOwnedIds = new Set();
|
|
85
|
-
}
|
|
86
|
-
reset() {
|
|
87
|
-
this.records = new Map();
|
|
88
|
-
this.resetOwnership();
|
|
89
|
-
this.childProcesses = new Map();
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
export function mergeElectronLaunchRecordMaps(...maps) {
|
|
93
|
-
const merged = new Map();
|
|
94
|
-
for (const map of maps) {
|
|
95
|
-
for (const [id, record] of map) {
|
|
96
|
-
merged.set(id, record);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return merged;
|
|
100
|
-
}
|
|
101
|
-
export function shouldSerializeElectronHostInput(compiledElectron) {
|
|
102
|
-
return (compiledElectron?.action === "status" ||
|
|
103
|
-
compiledElectron?.action === "probe" ||
|
|
104
|
-
compiledElectron?.action === "cleanup");
|
|
105
|
-
}
|
|
106
|
-
function cleanupIdentityField(step, record, field, fallback) {
|
|
107
|
-
const value = step[field];
|
|
108
|
-
if (typeof value === "string") {
|
|
109
|
-
return value;
|
|
110
|
-
}
|
|
111
|
-
const retained = record?.[field];
|
|
112
|
-
return typeof retained === "string" ? retained : fallback;
|
|
113
|
-
}
|
|
114
|
-
function isClosedManagedSessionStep(step) {
|
|
115
|
-
return (isRecord(step) &&
|
|
116
|
-
step.resource === "managed-session" &&
|
|
117
|
-
(step.state === "removed" || step.state === "already-gone"));
|
|
118
|
-
}
|
|
119
|
-
export function getCleanupResultClosedManagedSessionIdentities(result, fallbackNamespace) {
|
|
120
|
-
if (!isRecord(result) || !Array.isArray(result.steps)) {
|
|
121
|
-
return [];
|
|
122
|
-
}
|
|
123
|
-
const identities = new Map();
|
|
124
|
-
const record = isRecord(result.record) ? result.record : undefined;
|
|
125
|
-
for (const step of result.steps) {
|
|
126
|
-
if (!isClosedManagedSessionStep(step)) {
|
|
127
|
-
continue;
|
|
128
|
-
}
|
|
129
|
-
const sessionName = cleanupIdentityField(step, record, "sessionName");
|
|
130
|
-
if (sessionName === undefined || sessionName === "") {
|
|
131
|
-
continue;
|
|
132
|
-
}
|
|
133
|
-
const namespace = cleanupIdentityField(step, record, "namespace", fallbackNamespace);
|
|
134
|
-
identities.set(getSessionContextKey(sessionName, namespace) ?? sessionName, {
|
|
135
|
-
namespace,
|
|
136
|
-
sessionName,
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
return [...identities.values()];
|
|
140
|
-
}
|
|
141
|
-
export function getCleanupResultsClosedManagedSessionIdentities(results, fallbackNamespace) {
|
|
142
|
-
const identities = new Map();
|
|
143
|
-
for (const result of results) {
|
|
144
|
-
for (const identity of getCleanupResultClosedManagedSessionIdentities(result, fallbackNamespace)) {
|
|
145
|
-
identities.set(getSessionContextKey(identity.sessionName, identity.namespace) ?? identity.sessionName, identity);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
return [...identities.values()];
|
|
149
|
-
}
|
|
150
|
-
function validElectronRecordIdentity(value) {
|
|
151
|
-
return (value.version === 1 &&
|
|
152
|
-
(value.namespace === undefined || typeof value.namespace === "string") &&
|
|
153
|
-
typeof value.launchId === "string" &&
|
|
154
|
-
typeof value.appName === "string");
|
|
155
|
-
}
|
|
156
|
-
export function isElectronLaunchRecord(value) {
|
|
157
|
-
if (!isRecord(value)) {
|
|
158
|
-
return false;
|
|
159
|
-
}
|
|
160
|
-
return (validElectronRecordIdentity(value) &&
|
|
161
|
-
value.launchedByWrapper === true &&
|
|
162
|
-
typeof value.executablePath === "string" &&
|
|
163
|
-
typeof value.userDataDir === "string" &&
|
|
164
|
-
typeof value.port === "number" &&
|
|
165
|
-
typeof value.createdAtMs === "number");
|
|
166
|
-
}
|
|
167
|
-
export function getCleanupResultsElectronRecords(results) {
|
|
168
|
-
return results
|
|
169
|
-
.map((result) => (isRecord(result) ? result.record : undefined))
|
|
170
|
-
.filter(isElectronLaunchRecord);
|
|
171
|
-
}
|
|
172
|
-
export function getCleanupResultsPreservedUserDataDirs(results) {
|
|
173
|
-
const dirs = new Set();
|
|
174
|
-
for (const result of results) {
|
|
175
|
-
if (!isRecord(result) ||
|
|
176
|
-
!Array.isArray(result.steps) ||
|
|
177
|
-
!isElectronLaunchRecord(result.record)) {
|
|
178
|
-
continue;
|
|
179
|
-
}
|
|
180
|
-
const step = result.steps.find((row) => isRecord(row) && row.resource === "user-data-dir");
|
|
181
|
-
if (!isRecord(step)) {
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
if (step.state === "skipped" || step.state === "failed") {
|
|
185
|
-
dirs.add(result.record.userDataDir);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
return [...dirs];
|
|
189
|
-
}
|
|
190
|
-
export function syncElectronCleanupManagedSessions(sessions, results, fallbackNamespace) {
|
|
191
|
-
for (const identity of getCleanupResultsClosedManagedSessionIdentities(results, fallbackNamespace)) {
|
|
192
|
-
untrackOwnedManagedSession(sessions, identity.sessionName, identity.namespace);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
export function getOffBranchOwnedElectronLaunchRecords(ownedRecords, branchRecords) {
|
|
196
|
-
const activeIds = new Set(getActiveElectronRecords(branchRecords).map((record) => record.launchId));
|
|
197
|
-
const offBranch = new Map();
|
|
198
|
-
for (const record of getActiveElectronRecords(ownedRecords)) {
|
|
199
|
-
if (!activeIds.has(record.launchId)) {
|
|
200
|
-
offBranch.set(record.launchId, record);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
return offBranch;
|
|
204
|
-
}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { buildExecutionPlan, createFreshSessionName, extractUpstreamCommandTokens, } from "../runtime.js";
|
|
2
|
-
import { getAgentBrowserSessionIdentityKey, scanUpstreamGlobalFlagOccurrences, } from "../argv-grammar.js";
|
|
3
|
-
import { getAgentBrowserProcessTimeoutMs } from "../process.js";
|
|
4
|
-
import { getCommandAwareProcessTimeoutMs } from "./browser-run/prepare/wait-timeouts.js";
|
|
5
|
-
import { withAgentBrowserProcessEnvironment } from "../process-environment.js";
|
|
6
|
-
import { buildValidationFailureResult } from "./input-plan.js";
|
|
7
|
-
import { resolveBrowserExecutionIdentity, withBrowserExecutionLocks, } from "../managed-session-policy-lock.js";
|
|
8
|
-
import { getArtifactPreflightValidationError, commandTouchesArtifactLifecycle, } from "./extension-artifact-preflight.js";
|
|
9
|
-
import { browserExecutionFailure } from "./extension-result-state.js";
|
|
10
|
-
import { warnRecordingPersistence } from "./extension-recording.js";
|
|
11
|
-
import { runBrowserCommand } from "./extension-command-run.js";
|
|
12
|
-
class BrowserCommandCoordinator {
|
|
13
|
-
runtime;
|
|
14
|
-
call;
|
|
15
|
-
plan;
|
|
16
|
-
key;
|
|
17
|
-
constructor(runtime, call) {
|
|
18
|
-
this.runtime = runtime;
|
|
19
|
-
this.call = call;
|
|
20
|
-
// Electron's browser identity is known before its host supplies the CDP port.
|
|
21
|
-
this.plan = buildExecutionPlan(call.compiledElectron?.action === "launch" ? ["connect"] : call.toolArgs, {
|
|
22
|
-
freshSessionName: createFreshSessionName(runtime.managed.baseName, runtime.ephemeralSessionSeed, runtime.managed.freshOrdinal + 1),
|
|
23
|
-
managedSessionActive: runtime.managed.active,
|
|
24
|
-
managedSessionCompatibilityWorkaround: runtime.managed.compatibilityWorkaround,
|
|
25
|
-
managedSessionName: runtime.managed.name,
|
|
26
|
-
managedSessionNamespace: runtime.managed.namespace,
|
|
27
|
-
sessionMode: call.compiledElectron?.action === "launch"
|
|
28
|
-
? "fresh"
|
|
29
|
-
: (call.params.sessionMode ?? "auto"),
|
|
30
|
-
stdin: call.resolvedInput.toolStdin,
|
|
31
|
-
});
|
|
32
|
-
this.key = getAgentBrowserSessionIdentityKey(this.plan.sessionName ?? "default", this.plan.namespace);
|
|
33
|
-
}
|
|
34
|
-
launchEnvironment() {
|
|
35
|
-
const owner = this.runtime.managed.owned.get(this.key);
|
|
36
|
-
const explicit = ["--confirm-actions", "--config"].some((flag) => scanUpstreamGlobalFlagOccurrences(this.call.toolArgs, flag).length > 0);
|
|
37
|
-
const retained = this.runtime.sessions.pages.get(this.key).confirmActions;
|
|
38
|
-
return {
|
|
39
|
-
...(owner?.socketDir !== undefined && owner.socketDir !== ""
|
|
40
|
-
? { PI_AGENT_BROWSER_SOCKET_DIR: owner.socketDir }
|
|
41
|
-
: {}),
|
|
42
|
-
AGENT_BROWSER_CONFIRM_ACTIONS: !explicit && retained !== undefined
|
|
43
|
-
? retained
|
|
44
|
-
: this.call.resolvedInput.nativeConfirmActions,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
execute(signal) {
|
|
48
|
-
return this.call.withLaunchDefaults
|
|
49
|
-
? this.call.withLaunchDefaults((inactive) => runBrowserCommand(this.runtime, this.call, inactive, signal), signal)
|
|
50
|
-
: runBrowserCommand(this.runtime, this.call, undefined, signal);
|
|
51
|
-
}
|
|
52
|
-
async preflightAndExecute(signal) {
|
|
53
|
-
const error = getArtifactPreflightValidationError({
|
|
54
|
-
activeRecordingReservations: [...this.runtime.recordings.active.values()],
|
|
55
|
-
args: this.call.toolArgs,
|
|
56
|
-
cwd: this.call.operationCwd,
|
|
57
|
-
outputPath: this.call.outputPath,
|
|
58
|
-
stdin: this.call.resolvedInput.toolStdin,
|
|
59
|
-
});
|
|
60
|
-
if (error === undefined || error === "") {
|
|
61
|
-
return this.execute(signal);
|
|
62
|
-
}
|
|
63
|
-
this.runtime.recordings.flush();
|
|
64
|
-
return warnRecordingPersistence(this.runtime.recordings.dirty, buildValidationFailureResult({
|
|
65
|
-
...this.call.resolvedInput,
|
|
66
|
-
attemptedKind: this.call.resolvedInput.kind,
|
|
67
|
-
kind: "invalid",
|
|
68
|
-
status: "invalid",
|
|
69
|
-
validationError: error,
|
|
70
|
-
}));
|
|
71
|
-
}
|
|
72
|
-
runCommand(signal = this.call.signal) {
|
|
73
|
-
if (!commandTouchesArtifactLifecycle(this.call.toolArgs, this.call.resolvedInput.toolStdin, this.call.outputPath)) {
|
|
74
|
-
return this.execute(signal);
|
|
75
|
-
}
|
|
76
|
-
return this.runtime.artifacts.queue.run(() => this.preflightAndExecute(signal));
|
|
77
|
-
}
|
|
78
|
-
needsIdentityLock() {
|
|
79
|
-
if (this.plan.validationError !== undefined && this.plan.validationError !== "") {
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
return ((this.plan.sessionName !== undefined && this.plan.sessionName !== "") ||
|
|
83
|
-
this.plan.commandInfo.command === "read" ||
|
|
84
|
-
this.call.closesAllSessions);
|
|
85
|
-
}
|
|
86
|
-
replacesManagedSession() {
|
|
87
|
-
return (this.runtime.managed.active &&
|
|
88
|
-
(this.call.params.sessionMode === "fresh" ||
|
|
89
|
-
this.call.compiledElectron?.action === "launch") &&
|
|
90
|
-
(this.call.explicitSessionName === undefined || this.call.explicitSessionName === ""));
|
|
91
|
-
}
|
|
92
|
-
async identities() {
|
|
93
|
-
const identities = [
|
|
94
|
-
await resolveBrowserExecutionIdentity({
|
|
95
|
-
namespace: this.plan.namespace,
|
|
96
|
-
ownedManagedSession: this.plan.managedSessionName !== undefined || this.runtime.managed.owned.has(this.key),
|
|
97
|
-
sessionName: this.call.closesAllSessions ? undefined : (this.plan.sessionName ?? "default"),
|
|
98
|
-
}),
|
|
99
|
-
];
|
|
100
|
-
if (this.replacesManagedSession()) {
|
|
101
|
-
const previous = this.runtime.managed.owned.get(getAgentBrowserSessionIdentityKey(this.runtime.managed.name, this.runtime.managed.namespace));
|
|
102
|
-
identities.push(await resolveBrowserExecutionIdentity({
|
|
103
|
-
namespace: this.runtime.managed.namespace,
|
|
104
|
-
ownedManagedSession: true,
|
|
105
|
-
sessionName: this.runtime.managed.name,
|
|
106
|
-
env: previous?.socketDir !== undefined && previous.socketDir !== ""
|
|
107
|
-
? { AGENT_BROWSER_SOCKET_DIR: previous.socketDir }
|
|
108
|
-
: undefined,
|
|
109
|
-
}));
|
|
110
|
-
}
|
|
111
|
-
return identities;
|
|
112
|
-
}
|
|
113
|
-
deadline() {
|
|
114
|
-
const url = this.runtime.sessions.pages.get(this.key).tabTarget?.url;
|
|
115
|
-
return (Date.now() +
|
|
116
|
-
(this.call.params.timeoutMs ??
|
|
117
|
-
getCommandAwareProcessTimeoutMs(extractUpstreamCommandTokens(this.call.toolArgs), this.call.resolvedInput.toolStdin, url) ??
|
|
118
|
-
getAgentBrowserProcessTimeoutMs()));
|
|
119
|
-
}
|
|
120
|
-
async runLocked() {
|
|
121
|
-
if (!this.needsIdentityLock()) {
|
|
122
|
-
return this.runCommand();
|
|
123
|
-
}
|
|
124
|
-
try {
|
|
125
|
-
const identities = await this.identities();
|
|
126
|
-
return await withBrowserExecutionLocks({ identities, signal: this.call.signal, deadline: this.deadline(), waitOnly: true }, (signal) => this.runCommand(signal));
|
|
127
|
-
}
|
|
128
|
-
catch (error) {
|
|
129
|
-
return browserExecutionFailure(error, this.call.signal);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
run() {
|
|
133
|
-
// Retained settings are resolved inside the identity queue before daemon or page helpers.
|
|
134
|
-
return withAgentBrowserProcessEnvironment(this.launchEnvironment(), () => this.runLocked());
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
export function runWithLaunchDefaults(runtime, call) {
|
|
138
|
-
return new BrowserCommandCoordinator(runtime, call).run();
|
|
139
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { buildExecutionPlan, createFreshSessionName } from "../runtime.js";
|
|
2
|
-
import { runWithLaunchDefaults } from "./extension-execution-locks.js";
|
|
3
|
-
export function runWithinSessionQueue(runtime, call) {
|
|
4
|
-
if (call.closesAllSessions) {
|
|
5
|
-
return runtime.managedSessionExecutionQueue.run(() => {
|
|
6
|
-
const plan = buildExecutionPlan(call.toolArgs, {
|
|
7
|
-
freshSessionName: createFreshSessionName(runtime.managed.baseName, runtime.ephemeralSessionSeed, runtime.managed.freshOrdinal + 1),
|
|
8
|
-
managedSessionActive: runtime.managed.active,
|
|
9
|
-
managedSessionCompatibilityWorkaround: runtime.managed.compatibilityWorkaround,
|
|
10
|
-
managedSessionName: runtime.managed.name,
|
|
11
|
-
managedSessionNamespace: runtime.managed.namespace,
|
|
12
|
-
sessionMode: call.params.sessionMode ?? "auto",
|
|
13
|
-
stdin: call.resolvedInput.toolStdin,
|
|
14
|
-
});
|
|
15
|
-
return runtime.callerOwnedSessionExecutionQueues.runExclusive(plan.namespace, () => runWithLaunchDefaults(runtime, call));
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
if (call.serializeBrowserCommand) {
|
|
19
|
-
return runtime.managedSessionExecutionQueue.run(() => runWithLaunchDefaults(runtime, call), call.signal);
|
|
20
|
-
}
|
|
21
|
-
return call.callerOwnedSessionQueueKey !== undefined && call.callerOwnedSessionQueueKey !== ""
|
|
22
|
-
? runtime.callerOwnedSessionExecutionQueues.run(call.callerOwnedSessionQueueKey, call.callerOwnedSessionNamespace, () => runWithLaunchDefaults(runtime, call), call.signal)
|
|
23
|
-
: runWithLaunchDefaults(runtime, call);
|
|
24
|
-
}
|