pi-agent-browser-native 0.9.2 → 0.9.4
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 +91 -5
- package/README.md +120 -86
- package/dist/extensions/agent-browser/index.js +43065 -2016
- package/dist/extensions/agent-browser/lib/argv-descriptor.js +49 -26
- package/dist/extensions/agent-browser/lib/argv-grammar.js +82 -93
- package/dist/extensions/agent-browser/lib/bash-guard.js +129 -126
- package/dist/extensions/agent-browser/lib/batch-lifecycle.js +113 -49
- package/dist/extensions/agent-browser/lib/browser-execution-claim-codec.js +61 -0
- package/dist/extensions/agent-browser/lib/browser-execution-claim-storage.js +232 -0
- package/dist/extensions/agent-browser/lib/browser-execution-claims.js +202 -0
- package/dist/extensions/agent-browser/lib/browser-execution-identity.js +77 -0
- package/dist/extensions/agent-browser/lib/browser-journal-branch.js +98 -0
- package/dist/extensions/agent-browser/lib/browser-journal-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/browser-journal-projection.js +221 -0
- package/dist/extensions/agent-browser/lib/browser-journal-reader.js +89 -0
- package/dist/extensions/agent-browser/lib/browser-journal-replay.js +246 -0
- package/dist/extensions/agent-browser/lib/browser-journal.js +103 -394
- package/dist/extensions/agent-browser/lib/browser-legacy-pages.js +220 -0
- package/dist/extensions/agent-browser/lib/browser-legacy-projection.js +282 -0
- package/dist/extensions/agent-browser/lib/browser-legacy-types.js +1 -0
- package/dist/extensions/agent-browser/lib/browser-session-conversion-stream.js +217 -0
- package/dist/extensions/agent-browser/lib/browser-session-conversion.js +80 -335
- package/dist/extensions/agent-browser/lib/browser-transcript-contracts.js +35 -0
- package/dist/extensions/agent-browser/lib/browser-transcript-validation.js +166 -0
- package/dist/extensions/agent-browser/lib/browser-transcript.js +137 -81
- package/dist/extensions/agent-browser/lib/browser-value-parsing.js +15 -0
- package/dist/extensions/agent-browser/lib/command-capabilities.js +340 -0
- package/dist/extensions/agent-browser/lib/command-policy.js +107 -88
- package/dist/extensions/agent-browser/lib/command-taxonomy.js +49 -322
- package/dist/extensions/agent-browser/lib/config-policy.js +138 -343
- package/dist/extensions/agent-browser/lib/config-providers.js +71 -0
- package/dist/extensions/agent-browser/lib/config-validation.js +218 -0
- package/dist/extensions/agent-browser/lib/config.js +19 -7
- package/dist/extensions/agent-browser/lib/electron/cdp.js +15 -7
- package/dist/extensions/agent-browser/lib/electron/cleanup.js +134 -55
- package/dist/extensions/agent-browser/lib/electron/discovery-darwin.js +109 -0
- package/dist/extensions/agent-browser/lib/electron/discovery-desktop.js +136 -0
- package/dist/extensions/agent-browser/lib/electron/discovery-evidence.js +89 -0
- package/dist/extensions/agent-browser/lib/electron/discovery-linux.js +93 -0
- package/dist/extensions/agent-browser/lib/electron/discovery-packages.js +162 -0
- package/dist/extensions/agent-browser/lib/electron/discovery-types.js +2 -0
- package/dist/extensions/agent-browser/lib/electron/discovery.js +140 -549
- package/dist/extensions/agent-browser/lib/electron/launch-monitor.js +102 -0
- package/dist/extensions/agent-browser/lib/electron/launch-process.js +209 -0
- package/dist/extensions/agent-browser/lib/electron/launch-types.js +2 -0
- package/dist/extensions/agent-browser/lib/electron/launch.js +249 -354
- package/dist/extensions/agent-browser/lib/executable-path.js +21 -12
- package/dist/extensions/agent-browser/lib/execution-cwd.js +35 -18
- package/dist/extensions/agent-browser/lib/input-modes/electron.js +162 -121
- package/dist/extensions/agent-browser/lib/input-modes/job.js +116 -313
- package/dist/extensions/agent-browser/lib/input-modes/lookup-network-evidence.js +104 -0
- package/dist/extensions/agent-browser/lib/input-modes/lookup-plan.js +132 -0
- package/dist/extensions/agent-browser/lib/input-modes/lookup-redaction.js +57 -0
- package/dist/extensions/agent-browser/lib/input-modes/lookup-source-evidence.js +151 -0
- package/dist/extensions/agent-browser/lib/input-modes/lookup-workspace.js +142 -0
- package/dist/extensions/agent-browser/lib/input-modes/lookups.js +57 -412
- package/dist/extensions/agent-browser/lib/input-modes/params.js +63 -17
- package/dist/extensions/agent-browser/lib/input-modes/qa-analysis.js +268 -0
- package/dist/extensions/agent-browser/lib/input-modes/qa-presentation.js +117 -0
- package/dist/extensions/agent-browser/lib/input-modes/script-child.js +396 -0
- package/dist/extensions/agent-browser/lib/input-modes/script-protocol.js +86 -0
- package/dist/extensions/agent-browser/lib/input-modes/script-types.js +1 -0
- package/dist/extensions/agent-browser/lib/input-modes/script-validation.js +60 -0
- package/dist/extensions/agent-browser/lib/input-modes/script.js +60 -409
- package/dist/extensions/agent-browser/lib/input-modes/semantic-action.js +218 -128
- package/dist/extensions/agent-browser/lib/input-modes/shared.js +15 -4
- package/dist/extensions/agent-browser/lib/input-modes/types.js +56 -7
- package/dist/extensions/agent-browser/lib/json-schema.js +22 -10
- package/dist/extensions/agent-browser/lib/launch-scoped-flags.js +17 -5
- package/dist/extensions/agent-browser/lib/managed-session-policy-lock.js +92 -425
- package/dist/extensions/agent-browser/lib/managed-session-posix-storage.js +58 -0
- package/dist/extensions/agent-browser/lib/managed-session-project-identity.js +244 -0
- package/dist/extensions/agent-browser/lib/managed-session-restore-context.js +84 -0
- package/dist/extensions/agent-browser/lib/managed-session-restore-policy.js +119 -0
- package/dist/extensions/agent-browser/lib/managed-session-restore-state.js +83 -0
- package/dist/extensions/agent-browser/lib/managed-session-restore.js +168 -300
- package/dist/extensions/agent-browser/lib/managed-session-snapshot-records.js +277 -0
- package/dist/extensions/agent-browser/lib/managed-session-snapshots.js +128 -305
- package/dist/extensions/agent-browser/lib/managed-session-storage.js +56 -253
- package/dist/extensions/agent-browser/lib/native-confirmation.js +140 -0
- package/dist/extensions/agent-browser/lib/native-output.js +44 -9
- package/dist/extensions/agent-browser/lib/orchestration/batch-stdin.js +107 -66
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/artifact-merge.js +14 -6
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/artifact-paths.js +109 -57
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/browser-observation-result.js +82 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/click-dispatch.js +171 -57
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/diagnostic-values.js +31 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/diagnostics.js +152 -781
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/electron-observation.js +202 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/electron-text-diagnostics.js +109 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/fill-diagnostics.js +119 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-action-recovery.js +147 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-actions.js +144 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-content.js +123 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-details.js +156 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-electron.js +179 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-evidence.js +39 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-missing-binary.js +89 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-recovery.js +97 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-redaction.js +106 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-timeout.js +110 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result.js +41 -538
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/index.js +204 -108
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/interaction-diagnostics.js +290 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-close.js +167 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-daemon-inspection.js +108 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-daemon-policy.js +127 -199
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/native-helper-observation.js +65 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/observation-types.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/overlay-diagnostics.js +120 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/network-page-filter.js +113 -30
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/scroll-shims.js +109 -28
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-filter-data.js +150 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-filter.js +138 -253
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-rendered-text.js +147 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/wait-timeouts.js +59 -24
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-artifacts.js +159 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-command.js +131 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-daemon.js +93 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-failure.js +42 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-guards.js +242 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-input.js +75 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-observations.js +92 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-page-selection.js +254 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-page-state.js +121 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-refs.js +130 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-resources.js +114 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-semantic.js +121 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-session-plan.js +222 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-timeouts.js +68 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare.js +176 -1114
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-analysis.js +191 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-confirmation.js +152 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-diagnostics.js +182 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-electron.js +150 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle-phase-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle-phase.js +115 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle.js +256 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-managed-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-managed.js +256 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-native-phase-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-native-phase.js +93 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-native.js +113 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-navigation-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-navigation.js +316 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-ownership.js +28 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-page-phase-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-page-phase.js +142 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-presentation-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-presentation.js +333 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-publication-phase-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-publication-phase.js +71 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-publication.js +201 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-receipts.js +183 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-refs.js +200 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-tabs.js +142 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output.js +18 -910
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prompt-guards.js +23 -13
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-receipt-reconciliation.js +198 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-recovery-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-recovery-presentation.js +154 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-recovery.js +68 -151
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/screenshot-capture.js +14 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/screenshot-observation.js +169 -46
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-commands.js +130 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-electron.js +210 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-observations.js +61 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-outcomes.js +187 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-refs.js +171 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-tabs.js +228 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state.js +77 -753
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/text-visibility-diagnostics.js +182 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/timeout-diagnostics.js +256 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/timeout-progress.js +108 -0
- package/dist/extensions/agent-browser/lib/orchestration/code-artifact-observation.js +39 -0
- package/dist/extensions/agent-browser/lib/orchestration/code-image-observation.js +119 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/branch.js +92 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/cleanup-result.js +58 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/cleanup.js +78 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/discovery.js +106 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/index.js +48 -816
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/policy.js +86 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-collection.js +69 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-data.js +167 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-presentation.js +164 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe.js +161 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/status.js +165 -0
- package/dist/extensions/agent-browser/lib/orchestration/execution-queue.js +21 -9
- package/dist/extensions/agent-browser/lib/orchestration/extension-artifact-preflight.js +211 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-artifacts.js +23 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-attachment-replay.js +99 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-branch-restore.js +275 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-code.js +280 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-admission.js +303 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-output.js +36 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-result.js +335 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-run.js +227 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-state.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-electron-ownership.js +204 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-execution-locks.js +139 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-execution-queue.js +24 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-host-coordination.js +98 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-host-run.js +295 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-intent-replay.js +41 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-invocation.js +7 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-lifecycle.js +102 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-managed-ownership.js +133 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-observation.js +120 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-prompt.js +180 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-recording.js +290 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-resource-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-resource-replay.js +269 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-result-state.js +113 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-runtime.js +146 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-script-leases.js +58 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-tool-boundary.js +62 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-version-check.js +54 -0
- package/dist/extensions/agent-browser/lib/orchestration/input-plan-types.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/input-plan.js +261 -185
- package/dist/extensions/agent-browser/lib/orchestration/input-redaction.js +62 -0
- package/dist/extensions/agent-browser/lib/orchestration/native-config.js +144 -0
- package/dist/extensions/agent-browser/lib/orchestration/native-root-launch.js +77 -0
- package/dist/extensions/agent-browser/lib/orchestration/native-session-defaults.js +210 -139
- package/dist/extensions/agent-browser/lib/orchestration/operation-paths.js +124 -58
- package/dist/extensions/agent-browser/lib/orchestration/output-file.js +198 -98
- package/dist/extensions/agent-browser/lib/orchestration/script-mode.js +199 -96
- package/dist/extensions/agent-browser/lib/owned-managed-session-context.js +55 -0
- package/dist/extensions/agent-browser/lib/page-target-batch.js +118 -0
- package/dist/extensions/agent-browser/lib/page-target-guards.js +50 -0
- package/dist/extensions/agent-browser/lib/page-target-navigation.js +104 -0
- package/dist/extensions/agent-browser/lib/page-target-validation.js +59 -243
- package/dist/extensions/agent-browser/lib/parsing.js +13 -4
- package/dist/extensions/agent-browser/lib/pi-tool-rendering.js +134 -68
- package/dist/extensions/agent-browser/lib/playbook.js +18 -14
- package/dist/extensions/agent-browser/lib/process-child.js +284 -0
- package/dist/extensions/agent-browser/lib/process-environment.js +22 -6
- package/dist/extensions/agent-browser/lib/process-errors.js +23 -0
- package/dist/extensions/agent-browser/lib/process-identity.js +47 -15
- package/dist/extensions/agent-browser/lib/process-socket-storage.js +256 -0
- package/dist/extensions/agent-browser/lib/process-stdout.js +74 -0
- package/dist/extensions/agent-browser/lib/process.js +146 -537
- package/dist/extensions/agent-browser/lib/prompt-artifacts.js +287 -0
- package/dist/extensions/agent-browser/lib/prompt-policy.js +15 -194
- package/dist/extensions/agent-browser/lib/read-command.js +41 -0
- package/dist/extensions/agent-browser/lib/read-confirmation.js +138 -35
- package/dist/extensions/agent-browser/lib/recording-reservations.js +118 -45
- package/dist/extensions/agent-browser/lib/redaction-fields.js +75 -0
- package/dist/extensions/agent-browser/lib/redaction-json.js +149 -0
- package/dist/extensions/agent-browser/lib/redaction-url.js +88 -0
- package/dist/extensions/agent-browser/lib/results/action-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/results/action-recommendations.js +28 -271
- package/dist/extensions/agent-browser/lib/results/artifact-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/results/artifact-manifest-validation.js +133 -0
- package/dist/extensions/agent-browser/lib/results/artifact-manifest.js +96 -94
- package/dist/extensions/agent-browser/lib/results/artifact-recommendations.js +73 -0
- package/dist/extensions/agent-browser/lib/results/categories.js +111 -54
- package/dist/extensions/agent-browser/lib/results/confirmation.js +29 -10
- package/dist/extensions/agent-browser/lib/results/editable-ref-evidence.js +62 -27
- package/dist/extensions/agent-browser/lib/results/electron-recommendations.js +83 -0
- package/dist/extensions/agent-browser/lib/results/envelope-decoding.js +48 -0
- package/dist/extensions/agent-browser/lib/results/envelope.js +93 -66
- package/dist/extensions/agent-browser/lib/results/evidence-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/results/failure-recommendations.js +180 -0
- package/dist/extensions/agent-browser/lib/results/network-routes.js +86 -45
- package/dist/extensions/agent-browser/lib/results/network.js +35 -12
- package/dist/extensions/agent-browser/lib/results/next-actions.js +49 -19
- package/dist/extensions/agent-browser/lib/results/presentation/artifact-files.js +320 -0
- package/dist/extensions/agent-browser/lib/results/presentation/artifact-format.js +138 -0
- package/dist/extensions/agent-browser/lib/results/presentation/artifact-images.js +113 -0
- package/dist/extensions/agent-browser/lib/results/presentation/artifact-verification.js +145 -0
- package/dist/extensions/agent-browser/lib/results/presentation/artifacts.js +99 -552
- package/dist/extensions/agent-browser/lib/results/presentation/batch-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/results/presentation/batch-recording.js +118 -0
- package/dist/extensions/agent-browser/lib/results/presentation/batch-redaction.js +68 -0
- package/dist/extensions/agent-browser/lib/results/presentation/batch-rendering.js +135 -0
- package/dist/extensions/agent-browser/lib/results/presentation/batch-step.js +227 -0
- package/dist/extensions/agent-browser/lib/results/presentation/batch-summary.js +91 -0
- package/dist/extensions/agent-browser/lib/results/presentation/batch.js +91 -460
- package/dist/extensions/agent-browser/lib/results/presentation/browser-profile-recovery.js +9 -5
- package/dist/extensions/agent-browser/lib/results/presentation/command-presenters.js +216 -0
- package/dist/extensions/agent-browser/lib/results/presentation/common.js +26 -9
- package/dist/extensions/agent-browser/lib/results/presentation/content.js +86 -29
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-a11y.js +67 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-health.js +79 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-identity.js +199 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-logs.js +75 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-network-actions.js +216 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-network.js +124 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-redaction.js +64 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-storage.js +209 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-stream.js +69 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-summary.js +222 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostics.js +103 -1019
- package/dist/extensions/agent-browser/lib/results/presentation/early-result.js +70 -0
- package/dist/extensions/agent-browser/lib/results/presentation/errors.js +130 -60
- package/dist/extensions/agent-browser/lib/results/presentation/input-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/results/presentation/large-output.js +60 -145
- package/dist/extensions/agent-browser/lib/results/presentation/navigation.js +147 -88
- package/dist/extensions/agent-browser/lib/results/presentation/notices.js +75 -0
- package/dist/extensions/agent-browser/lib/results/presentation/observation-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/results/presentation/observation-rendering.js +127 -0
- package/dist/extensions/agent-browser/lib/results/presentation/outcomes.js +120 -0
- package/dist/extensions/agent-browser/lib/results/presentation/output-completion.js +77 -0
- package/dist/extensions/agent-browser/lib/results/presentation/output-spill.js +51 -0
- package/dist/extensions/agent-browser/lib/results/presentation/registry.js +117 -237
- package/dist/extensions/agent-browser/lib/results/presentation/semantic-action.js +35 -21
- package/dist/extensions/agent-browser/lib/results/presentation/skills.js +104 -73
- package/dist/extensions/agent-browser/lib/results/presentation/source.js +109 -0
- package/dist/extensions/agent-browser/lib/results/presentation.js +17 -248
- package/dist/extensions/agent-browser/lib/results/recommendation-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/results/recording.js +52 -14
- package/dist/extensions/agent-browser/lib/results/recovery-actions.js +14 -5
- package/dist/extensions/agent-browser/lib/results/recovery-next-actions.js +30 -22
- package/dist/extensions/agent-browser/lib/results/selector-recovery-target.js +83 -0
- package/dist/extensions/agent-browser/lib/results/selector-recovery.js +123 -123
- package/dist/extensions/agent-browser/lib/results/snapshot-compact.js +266 -0
- package/dist/extensions/agent-browser/lib/results/snapshot-content.js +32 -0
- package/dist/extensions/agent-browser/lib/results/snapshot-high-value-controls.js +104 -71
- package/dist/extensions/agent-browser/lib/results/snapshot-refs.js +31 -11
- package/dist/extensions/agent-browser/lib/results/snapshot-segments.js +125 -66
- package/dist/extensions/agent-browser/lib/results/snapshot-spill.js +26 -7
- package/dist/extensions/agent-browser/lib/results/snapshot.js +28 -248
- package/dist/extensions/agent-browser/lib/results/text.js +16 -5
- package/dist/extensions/agent-browser/lib/runtime-args-validation.js +133 -0
- package/dist/extensions/agent-browser/lib/runtime-compatibility.js +81 -0
- package/dist/extensions/agent-browser/lib/runtime-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/runtime-redaction.js +118 -0
- package/dist/extensions/agent-browser/lib/runtime-replay-events.js +144 -0
- package/dist/extensions/agent-browser/lib/runtime-session-identity.js +76 -0
- package/dist/extensions/agent-browser/lib/runtime-session-plan.js +114 -0
- package/dist/extensions/agent-browser/lib/runtime-session-replay.js +123 -0
- package/dist/extensions/agent-browser/lib/runtime-tab-correction.js +65 -0
- package/dist/extensions/agent-browser/lib/runtime-timeouts.js +28 -0
- package/dist/extensions/agent-browser/lib/runtime.js +137 -1037
- package/dist/extensions/agent-browser/lib/session-identity.js +51 -0
- package/dist/extensions/agent-browser/lib/session-page-observation.js +357 -0
- package/dist/extensions/agent-browser/lib/session-page-state.js +188 -324
- package/dist/extensions/agent-browser/lib/session-page-types.js +1 -0
- package/dist/extensions/agent-browser/lib/temp-artifact-budget.js +78 -0
- package/dist/extensions/agent-browser/lib/temp-mutation-queue.js +7 -0
- package/dist/extensions/agent-browser/lib/temp-root-ownership.js +234 -0
- package/dist/extensions/agent-browser/lib/temp-root.js +207 -0
- package/dist/extensions/agent-browser/lib/temp.js +33 -446
- package/dist/extensions/agent-browser/lib/tool-surface.js +94 -24
- package/dist/extensions/agent-browser/lib/upstream-version.js +3 -2
- package/dist/extensions/agent-browser/lib/web-search-providers.js +229 -0
- package/dist/extensions/agent-browser/lib/web-search-request.js +108 -0
- package/dist/extensions/agent-browser/lib/web-search-results.js +281 -0
- package/dist/extensions/agent-browser/lib/web-search-schema.js +82 -0
- package/dist/extensions/agent-browser/lib/web-search.js +109 -617
- package/dist/extensions/agent-browser/lib/webmcp-observation.js +13 -6
- package/dist/extensions/agent-browser/lib/windows-stock-launcher.js +63 -37
- package/dist/extensions/agent-browser/script-worker.js +80 -43
- package/dist/scripts/agent-browser-target.mjs +4 -2
- package/docs/ARCHITECTURE.md +22 -10
- package/docs/CODE_QUALITY.md +242 -0
- package/docs/COMMAND_REFERENCE.md +264 -229
- package/docs/ELECTRON.md +53 -44
- package/docs/RELEASE.md +21 -17
- package/docs/REQUIREMENTS.md +2 -0
- package/docs/SESSION_STORAGE.md +1 -1
- package/docs/SUPPORT_MATRIX.md +84 -77
- package/docs/TOOL_CONTRACT.md +165 -130
- package/docs/platform-smoke.md +5 -5
- package/package.json +143 -120
- package/scripts/agent-browser-capability-baseline.mjs +361 -957
- package/scripts/agent-browser-target.mjs +6 -2
- package/scripts/build.mjs +37 -8
- package/scripts/capability-core-commands.mjs +193 -0
- package/scripts/capability-options.mjs +283 -0
- package/scripts/capability-samples.mjs +133 -0
- package/scripts/capability-section.mjs +11 -0
- package/scripts/config.mjs +213 -114
- package/scripts/convert-browser-session.mjs +30 -9
- package/scripts/doctor-sources.mjs +195 -0
- package/scripts/doctor.mjs +92 -247
- package/scripts/platform-smoke/artifacts.mjs +38 -11
- package/scripts/platform-smoke/commands.mjs +104 -0
- package/scripts/platform-smoke/crabbox-runner.mjs +167 -80
- package/scripts/platform-smoke/doctor-support.mjs +157 -0
- package/scripts/platform-smoke/doctor-windows.mjs +230 -0
- package/scripts/platform-smoke/doctor.mjs +212 -320
- package/scripts/platform-smoke/lease-evidence.mjs +134 -0
- package/scripts/platform-smoke/suite-checks.mjs +98 -0
- package/scripts/platform-smoke/suite-evidence.mjs +281 -0
- package/scripts/platform-smoke/targets.mjs +158 -472
- package/scripts/platform-smoke.mjs +55 -40
- package/scripts/prepare.mjs +16 -7
|
@@ -1,92 +1,126 @@
|
|
|
1
1
|
import { projectUpstreamGlobalFlags } from "../argv-grammar.js";
|
|
2
|
+
import { isStringArray } from "../input-modes/shared.js";
|
|
3
|
+
import { stringifyUnknown } from "../results/text.js";
|
|
2
4
|
/** Bare open's native launch action drops prior launch options. URL reads lazily launch without navigating. */
|
|
3
5
|
export function normalizeUrlLessOpen(args, stdin, batchStep = false) {
|
|
4
|
-
const { tokens, indices } = batchStep
|
|
5
|
-
|
|
6
|
+
const { tokens, indices } = batchStep
|
|
7
|
+
? { tokens: args, indices: args.map((_, index) => index) }
|
|
8
|
+
: projectUpstreamGlobalFlags(args);
|
|
9
|
+
if (tokens[0] === "open" && !tokens.slice(1).some((token) => !token.startsWith("--"))) {
|
|
6
10
|
const index = indices[0];
|
|
7
11
|
return { args: [...args.slice(0, index), "get", "url", ...args.slice(index + 1)], stdin };
|
|
8
12
|
}
|
|
9
|
-
if (tokens[0] !== "batch")
|
|
13
|
+
if (tokens[0] !== "batch") {
|
|
10
14
|
return { args, stdin };
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return
|
|
14
|
-
});
|
|
15
|
-
if (tokens.slice(1).some(token => token !== "--bail")) {
|
|
16
|
-
let normalized = args;
|
|
17
|
-
for (const { index, step } of rawSteps) {
|
|
18
|
-
const row = normalizeUrlLessOpen(step, undefined, true).args;
|
|
19
|
-
if (row === step)
|
|
20
|
-
continue;
|
|
21
|
-
if (normalized === args)
|
|
22
|
-
normalized = [...args];
|
|
23
|
-
normalized[index] = row.map(token => `'${token.replaceAll("'", "'\\''")}'`).join(" ");
|
|
24
|
-
}
|
|
25
|
-
return { args: normalized, stdin };
|
|
15
|
+
}
|
|
16
|
+
if (tokens.slice(1).some((token) => token !== "--bail")) {
|
|
17
|
+
return { args: normalizeRawBatchRows(args, tokens, indices), stdin };
|
|
26
18
|
}
|
|
27
19
|
const steps = parseUserBatchStdin(stdin).steps;
|
|
28
|
-
if (
|
|
20
|
+
if (steps === undefined || steps.length === 0) {
|
|
29
21
|
return { args, stdin };
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
}
|
|
23
|
+
const normalized = steps.map((step) => normalizeUrlLessOpen(step, undefined, true).args);
|
|
24
|
+
return {
|
|
25
|
+
args,
|
|
26
|
+
stdin: normalized.some((step, index) => step !== steps[index])
|
|
27
|
+
? JSON.stringify(normalized)
|
|
28
|
+
: stdin,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function normalizeRawBatchRows(args, tokens, indices) {
|
|
32
|
+
let normalized;
|
|
33
|
+
for (const [offset, token] of tokens.slice(1).entries()) {
|
|
34
|
+
if (token === "--bail") {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
const step = parseBatchCommandArgument(token).step;
|
|
38
|
+
if (step === undefined) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const row = normalizeUrlLessOpen(step, undefined, true).args;
|
|
42
|
+
if (row === step) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
normalized ??= [...args];
|
|
46
|
+
normalized[indices[offset + 1]] = row
|
|
47
|
+
.map((word) => `'${word.replaceAll("'", "'\\''")}'`)
|
|
48
|
+
.join(" ");
|
|
49
|
+
}
|
|
50
|
+
return normalized ?? args;
|
|
32
51
|
}
|
|
33
52
|
const BATCH_STDIN_EXAMPLE = ' Example: { "args": ["batch"], "stdin": "[[\\"get\\",\\"title\\"],[\\"get\\",\\"url\\"]]" }';
|
|
34
|
-
//
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (next !== undefined) {
|
|
45
|
-
token += next;
|
|
46
|
-
index += 1;
|
|
47
|
-
}
|
|
53
|
+
// Mirrors upstream commands::shell_words_split for policy inspection.
|
|
54
|
+
class BatchWords {
|
|
55
|
+
token = "";
|
|
56
|
+
tokens = [];
|
|
57
|
+
inDoubleQuote = false;
|
|
58
|
+
inSingleQuote = false;
|
|
59
|
+
consumeQuote(character) {
|
|
60
|
+
if (character === '"' && !this.inSingleQuote) {
|
|
61
|
+
this.inDoubleQuote = !this.inDoubleQuote;
|
|
62
|
+
return true;
|
|
48
63
|
}
|
|
49
|
-
|
|
50
|
-
|
|
64
|
+
if (character === "'" && !this.inDoubleQuote) {
|
|
65
|
+
this.inSingleQuote = !this.inSingleQuote;
|
|
66
|
+
return true;
|
|
51
67
|
}
|
|
52
|
-
|
|
53
|
-
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
finishWord() {
|
|
71
|
+
if (this.token.length > 0) {
|
|
72
|
+
this.tokens.push(this.token);
|
|
73
|
+
this.token = "";
|
|
54
74
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
75
|
+
}
|
|
76
|
+
consume(character, next) {
|
|
77
|
+
if (character === "\\" && !this.inSingleQuote) {
|
|
78
|
+
if (next !== undefined) {
|
|
79
|
+
this.token += next;
|
|
80
|
+
return true;
|
|
59
81
|
}
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
if (this.consumeQuote(character)) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
if (character === " " && !this.inDoubleQuote && !this.inSingleQuote) {
|
|
88
|
+
this.finishWord();
|
|
60
89
|
}
|
|
61
90
|
else {
|
|
62
|
-
token += character;
|
|
91
|
+
this.token += character;
|
|
92
|
+
}
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
finish() {
|
|
96
|
+
this.finishWord();
|
|
97
|
+
return this.tokens.length > 0 ? { step: this.tokens } : { error: "batch command is empty" };
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
export function parseBatchCommandArgument(command) {
|
|
101
|
+
const words = new BatchWords();
|
|
102
|
+
for (let index = 0; index < command.length; index++) {
|
|
103
|
+
if (words.consume(command[index], command.at(index + 1))) {
|
|
104
|
+
index++;
|
|
63
105
|
}
|
|
64
106
|
}
|
|
65
|
-
|
|
66
|
-
tokens.push(token);
|
|
67
|
-
return tokens.length > 0 ? { step: tokens } : { error: "batch command is empty" };
|
|
107
|
+
return words.finish();
|
|
68
108
|
}
|
|
69
109
|
function validateUserBatchStep(step, index) {
|
|
70
110
|
if (!Array.isArray(step)) {
|
|
71
111
|
return {
|
|
72
|
-
error: `agent_browser batch stdin step ${index} must be
|
|
112
|
+
error: `agent_browser batch stdin step ${index} must be an array of string command tokens.${BATCH_STDIN_EXAMPLE}`,
|
|
73
113
|
ok: false,
|
|
74
114
|
};
|
|
75
115
|
}
|
|
76
|
-
if (step
|
|
77
|
-
|
|
78
|
-
error: `agent_browser batch stdin step ${index} must not be empty.${BATCH_STDIN_EXAMPLE}`,
|
|
79
|
-
ok: false,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
const invalidTokenIndex = step.findIndex((token) => typeof token !== "string");
|
|
83
|
-
if (invalidTokenIndex !== -1) {
|
|
116
|
+
if (!isStringArray(step)) {
|
|
117
|
+
const invalidTokenIndex = step.findIndex((token) => typeof token !== "string");
|
|
84
118
|
return {
|
|
85
119
|
error: `agent_browser batch stdin step ${index} token ${invalidTokenIndex} must be a string.${BATCH_STDIN_EXAMPLE}`,
|
|
86
120
|
ok: false,
|
|
87
121
|
};
|
|
88
122
|
}
|
|
89
|
-
return { ok: true, step
|
|
123
|
+
return { ok: true, step };
|
|
90
124
|
}
|
|
91
125
|
export function parseBatchStdinJsonArray(stdin) {
|
|
92
126
|
if (stdin === undefined) {
|
|
@@ -95,19 +129,23 @@ export function parseBatchStdinJsonArray(stdin) {
|
|
|
95
129
|
try {
|
|
96
130
|
const parsed = JSON.parse(stdin);
|
|
97
131
|
if (!Array.isArray(parsed)) {
|
|
98
|
-
return {
|
|
132
|
+
return {
|
|
133
|
+
error: `agent_browser batch stdin must be a JSON array of command steps.${BATCH_STDIN_EXAMPLE}`,
|
|
134
|
+
};
|
|
99
135
|
}
|
|
100
136
|
return { steps: parsed };
|
|
101
137
|
}
|
|
102
138
|
catch (error) {
|
|
103
|
-
const message = error instanceof Error ? error.message :
|
|
104
|
-
return {
|
|
139
|
+
const message = error instanceof Error ? error.message : stringifyUnknown(error);
|
|
140
|
+
return {
|
|
141
|
+
error: `agent_browser batch stdin could not be parsed as JSON: ${message}.${BATCH_STDIN_EXAMPLE}`,
|
|
142
|
+
};
|
|
105
143
|
}
|
|
106
144
|
}
|
|
107
145
|
export function parseUserBatchStdin(stdin) {
|
|
108
146
|
const parsed = parseBatchStdinJsonArray(stdin);
|
|
109
|
-
if (parsed.error || parsed.steps === undefined) {
|
|
110
|
-
return parsed.error ? { error: parsed.error } : { steps: [] };
|
|
147
|
+
if (parsed.error !== undefined || parsed.steps === undefined) {
|
|
148
|
+
return parsed.error !== undefined ? { error: parsed.error } : { steps: [] };
|
|
111
149
|
}
|
|
112
150
|
const steps = [];
|
|
113
151
|
for (const [index, rawStep] of parsed.steps.entries()) {
|
|
@@ -127,15 +165,18 @@ export function parseUserBatchStdin(stdin) {
|
|
|
127
165
|
* ignored.
|
|
128
166
|
*/
|
|
129
167
|
export function getUpstreamEffectiveBatchSteps(commandTokens, stdin) {
|
|
130
|
-
if (commandTokens[0] !== "batch")
|
|
168
|
+
if (commandTokens[0] !== "batch") {
|
|
131
169
|
return [];
|
|
170
|
+
}
|
|
132
171
|
const argumentSteps = commandTokens.slice(1).flatMap((command) => {
|
|
133
|
-
if (command === "--bail")
|
|
172
|
+
if (command === "--bail") {
|
|
134
173
|
return [];
|
|
174
|
+
}
|
|
135
175
|
const step = parseBatchCommandArgument(command).step;
|
|
136
176
|
return step ? [step] : [];
|
|
137
177
|
});
|
|
138
|
-
if (
|
|
178
|
+
if (commandTokens.slice(1).some((token) => token !== "--bail")) {
|
|
139
179
|
return argumentSteps;
|
|
140
|
-
|
|
180
|
+
}
|
|
181
|
+
return parseUserBatchStdin(stdin).steps?.filter((step) => step.length > 0) ?? [];
|
|
141
182
|
}
|
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
import { getSessionArtifactManifestEntryKey, isPendingRecordingCommand, mergeSessionArtifactManifest } from "../../results/artifact-manifest.js";
|
|
1
|
+
import { getSessionArtifactManifestEntryKey, isPendingRecordingCommand, mergeSessionArtifactManifest, } from "../../results/artifact-manifest.js";
|
|
2
2
|
export function mergeBrowserRunArtifactManifest(current, initial, updated) {
|
|
3
|
-
if (!updated || updated === initial)
|
|
3
|
+
if (!updated || updated === initial) {
|
|
4
4
|
return current;
|
|
5
|
-
|
|
5
|
+
}
|
|
6
|
+
if (current === initial) {
|
|
6
7
|
return updated;
|
|
8
|
+
}
|
|
7
9
|
const initialEntries = new Map((initial?.entries ?? []).map((entry) => [getSessionArtifactManifestEntryKey(entry), entry]));
|
|
8
10
|
const changedEntries = updated.entries
|
|
9
11
|
.map((entry, index) => ({ entry, index }))
|
|
10
12
|
.filter(({ entry }) => initialEntries.get(getSessionArtifactManifestEntryKey(entry)) !== entry)
|
|
11
|
-
.sort((left, right) =>
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
.sort((left, right) => {
|
|
14
|
+
const timestampOrder = left.entry.createdAtMs - right.entry.createdAtMs;
|
|
15
|
+
if (timestampOrder !== 0 && !Number.isNaN(timestampOrder)) {
|
|
16
|
+
return timestampOrder;
|
|
17
|
+
}
|
|
18
|
+
const pendingOrder = Number(isPendingRecordingCommand(left.entry.command, left.entry.subcommand, left.entry.kind)) -
|
|
19
|
+
Number(isPendingRecordingCommand(right.entry.command, right.entry.subcommand, right.entry.kind));
|
|
20
|
+
return pendingOrder !== 0 ? pendingOrder : left.index - right.index;
|
|
21
|
+
})
|
|
14
22
|
.map(({ entry }) => entry);
|
|
15
23
|
return changedEntries.length === 0
|
|
16
24
|
? current
|
|
@@ -2,22 +2,29 @@ import { lstatSync, readlinkSync, realpathSync, statSync } from "node:fs";
|
|
|
2
2
|
import { basename, dirname, extname, join, resolve } from "node:path";
|
|
3
3
|
import { foldAgentBrowserFilesystemIdentity } from "../../argv-grammar.js";
|
|
4
4
|
import { parseWaitCommandTokens } from "../../argv-descriptor.js";
|
|
5
|
-
import { getRecordCommandOperandIndices, getRecordCommandOperands } from "../../command-taxonomy.js";
|
|
5
|
+
import { getRecordCommandOperandIndices, getRecordCommandOperands, } from "../../command-taxonomy.js";
|
|
6
6
|
const SCREENSHOT_IMAGE_EXTENSIONS = [".jpeg", ".jpg", ".png", ".webp"];
|
|
7
7
|
function isSingleScreenshotPathToken(token) {
|
|
8
8
|
const explicitlyRelative = token.startsWith("./") || token.startsWith("../");
|
|
9
|
-
if (token.startsWith("#") ||
|
|
9
|
+
if (token.startsWith("#") ||
|
|
10
|
+
token.startsWith("@") ||
|
|
11
|
+
(token.startsWith(".") && !explicitlyRelative && !token.includes("/"))) {
|
|
10
12
|
return false;
|
|
11
|
-
|
|
13
|
+
}
|
|
14
|
+
return (explicitlyRelative ||
|
|
15
|
+
token.includes("/") ||
|
|
16
|
+
SCREENSHOT_IMAGE_EXTENSIONS.some((extension) => token.endsWith(extension)));
|
|
12
17
|
}
|
|
13
18
|
export function getScreenshotPositionalIndices(commandTokens) {
|
|
14
|
-
if (commandTokens[0] !== "screenshot")
|
|
19
|
+
if (commandTokens[0] !== "screenshot") {
|
|
15
20
|
return [];
|
|
21
|
+
}
|
|
16
22
|
const positionalIndices = [];
|
|
17
23
|
for (let index = 1; index < commandTokens.length; index += 1) {
|
|
18
24
|
const token = commandTokens[index];
|
|
19
|
-
if (token === "--full" || token === "-f" || token === "--if-changed")
|
|
25
|
+
if (token === "--full" || token === "-f" || token === "--if-changed") {
|
|
20
26
|
continue;
|
|
27
|
+
}
|
|
21
28
|
if (token === "--threshold") {
|
|
22
29
|
index += 1;
|
|
23
30
|
continue;
|
|
@@ -28,8 +35,9 @@ export function getScreenshotPositionalIndices(commandTokens) {
|
|
|
28
35
|
}
|
|
29
36
|
export function getScreenshotPathTokenIndex(commandTokens) {
|
|
30
37
|
const positionalIndices = getScreenshotPositionalIndices(commandTokens);
|
|
31
|
-
if (positionalIndices.length === 0)
|
|
38
|
+
if (positionalIndices.length === 0) {
|
|
32
39
|
return undefined;
|
|
40
|
+
}
|
|
33
41
|
const candidateIndex = positionalIndices.length >= 2 ? positionalIndices[1] : positionalIndices[0];
|
|
34
42
|
const candidate = commandTokens[candidateIndex];
|
|
35
43
|
if (positionalIndices.length >= 2 || isSingleScreenshotPathToken(candidate)) {
|
|
@@ -37,64 +45,93 @@ export function getScreenshotPathTokenIndex(commandTokens) {
|
|
|
37
45
|
}
|
|
38
46
|
return undefined;
|
|
39
47
|
}
|
|
40
|
-
const DIFF_SCREENSHOT_VALUE_FLAGS = new Set([
|
|
48
|
+
const DIFF_SCREENSHOT_VALUE_FLAGS = new Set([
|
|
49
|
+
"-b",
|
|
50
|
+
"--baseline",
|
|
51
|
+
"-o",
|
|
52
|
+
"--output",
|
|
53
|
+
"-s",
|
|
54
|
+
"--selector",
|
|
55
|
+
"-t",
|
|
56
|
+
"--threshold",
|
|
57
|
+
]);
|
|
41
58
|
export function getDiffFilePathIndices(commandTokens) {
|
|
42
|
-
if (commandTokens[0] !== "diff" || !["snapshot", "screenshot"].includes(commandTokens[1]))
|
|
59
|
+
if (commandTokens[0] !== "diff" || !["snapshot", "screenshot"].includes(commandTokens[1])) {
|
|
43
60
|
return {};
|
|
44
|
-
|
|
61
|
+
}
|
|
62
|
+
const valueFlags = commandTokens[1] === "screenshot"
|
|
63
|
+
? DIFF_SCREENSHOT_VALUE_FLAGS
|
|
64
|
+
: new Set(["-b", "--baseline", "-s", "--selector", "-d", "--depth"]);
|
|
45
65
|
const paths = {};
|
|
46
66
|
for (let index = 2; index < commandTokens.length; index += 1) {
|
|
47
67
|
const token = commandTokens[index];
|
|
48
|
-
if (!valueFlags.has(token))
|
|
68
|
+
if (!valueFlags.has(token)) {
|
|
49
69
|
continue;
|
|
50
|
-
|
|
51
|
-
|
|
70
|
+
}
|
|
71
|
+
const value = commandTokens.at(index + 1);
|
|
72
|
+
if (value === undefined) {
|
|
52
73
|
return {};
|
|
53
|
-
|
|
74
|
+
}
|
|
75
|
+
if (["-o", "--output"].includes(token)) {
|
|
54
76
|
paths.output = index + 1;
|
|
55
|
-
|
|
77
|
+
}
|
|
78
|
+
if (["-b", "--baseline"].includes(token)) {
|
|
56
79
|
paths.baseline = index + 1;
|
|
80
|
+
}
|
|
57
81
|
index += 1;
|
|
58
82
|
}
|
|
59
83
|
return paths;
|
|
60
84
|
}
|
|
85
|
+
function canonicalFileIdentity(path, platform) {
|
|
86
|
+
try {
|
|
87
|
+
const stats = statSync(path, { bigint: true });
|
|
88
|
+
if (stats.ino > 0n) {
|
|
89
|
+
return `inode:${stats.dev}:${stats.ino}`;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
// The destination does not exist yet; canonical ancestry still catches aliases.
|
|
94
|
+
}
|
|
95
|
+
return foldAgentBrowserFilesystemIdentity(path, platform);
|
|
96
|
+
}
|
|
97
|
+
function readSymlinkTarget(path) {
|
|
98
|
+
try {
|
|
99
|
+
return lstatSync(path).isSymbolicLink()
|
|
100
|
+
? resolve(dirname(path), readlinkSync(path))
|
|
101
|
+
: undefined;
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
// Missing ancestry is resolved by walking to the next existing parent.
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
61
108
|
function canonicalizeArtifactPath(absolutePath, platform, seenSymlinks) {
|
|
62
109
|
let cursor = absolutePath;
|
|
63
110
|
const suffix = [];
|
|
64
111
|
while (true) {
|
|
65
112
|
try {
|
|
66
113
|
const canonicalPath = join(realpathSync.native(cursor), ...suffix);
|
|
67
|
-
|
|
68
|
-
const stats = statSync(canonicalPath, { bigint: true });
|
|
69
|
-
if (stats.ino > 0n)
|
|
70
|
-
return `inode:${stats.dev}:${stats.ino}`;
|
|
71
|
-
}
|
|
72
|
-
catch {
|
|
73
|
-
// The destination does not exist yet; canonical ancestry still catches aliases.
|
|
74
|
-
}
|
|
75
|
-
return foldAgentBrowserFilesystemIdentity(canonicalPath, platform);
|
|
114
|
+
return canonicalFileIdentity(canonicalPath, platform);
|
|
76
115
|
}
|
|
77
116
|
catch {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
117
|
+
// Resolve missing destinations through their existing ancestry below.
|
|
118
|
+
}
|
|
119
|
+
const symlinkTarget = readSymlinkTarget(cursor);
|
|
120
|
+
if (symlinkTarget !== undefined && symlinkTarget !== "") {
|
|
121
|
+
if (seenSymlinks.has(cursor)) {
|
|
122
|
+
throw new Error(`Artifact destination contains a symlink loop: ${absolutePath}`);
|
|
82
123
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (seenSymlinks.has(cursor))
|
|
86
|
-
throw new Error(`Artifact destination contains a symlink loop: ${absolutePath}`);
|
|
87
|
-
if (seenSymlinks.size >= 32)
|
|
88
|
-
throw new Error(`Artifact destination has too many symlink hops: ${absolutePath}`);
|
|
89
|
-
seenSymlinks.add(cursor);
|
|
90
|
-
return canonicalizeArtifactPath(join(symlinkTarget, ...suffix), platform, seenSymlinks);
|
|
124
|
+
if (seenSymlinks.size >= 32) {
|
|
125
|
+
throw new Error(`Artifact destination has too many symlink hops: ${absolutePath}`);
|
|
91
126
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
127
|
+
return canonicalizeArtifactPath(join(symlinkTarget, ...suffix), platform, new Set([...seenSymlinks, cursor]));
|
|
128
|
+
}
|
|
129
|
+
const parent = dirname(cursor);
|
|
130
|
+
if (parent === cursor) {
|
|
131
|
+
return foldAgentBrowserFilesystemIdentity(absolutePath, platform);
|
|
97
132
|
}
|
|
133
|
+
suffix.unshift(basename(cursor));
|
|
134
|
+
cursor = parent;
|
|
98
135
|
}
|
|
99
136
|
}
|
|
100
137
|
export function canonicalizeExplicitArtifactDestination(cwd, destination, platform = process.platform) {
|
|
@@ -102,33 +139,48 @@ export function canonicalizeExplicitArtifactDestination(cwd, destination, platfo
|
|
|
102
139
|
}
|
|
103
140
|
export function getRecordContactSheetDestination(commandTokens) {
|
|
104
141
|
const path = getRecordCommandOperands(commandTokens).path;
|
|
105
|
-
if (
|
|
142
|
+
if (path === undefined ||
|
|
143
|
+
path === "" ||
|
|
144
|
+
!commandTokens.some((token) => token === "--contact-sheet" || token === "--contact-sheet-threshold")) {
|
|
106
145
|
return undefined;
|
|
146
|
+
}
|
|
107
147
|
const extension = extname(path);
|
|
108
|
-
return extension ? `${path.slice(0, -extension.length)}.contact-sheet.png` : undefined;
|
|
148
|
+
return extension !== "" ? `${path.slice(0, -extension.length)}.contact-sheet.png` : undefined;
|
|
149
|
+
}
|
|
150
|
+
function getCompoundArtifactDestinationIndex(commandTokens) {
|
|
151
|
+
const [command, subcommand] = commandTokens;
|
|
152
|
+
if (command === "state" && subcommand === "save") {
|
|
153
|
+
return 2;
|
|
154
|
+
}
|
|
155
|
+
if (command === "diff" && subcommand === "screenshot") {
|
|
156
|
+
return getDiffFilePathIndices(commandTokens).output;
|
|
157
|
+
}
|
|
158
|
+
if (command === "network" && subcommand === "har" && commandTokens[2] === "stop") {
|
|
159
|
+
return 3;
|
|
160
|
+
}
|
|
161
|
+
if (["trace", "profiler"].includes(command) && subcommand === "stop") {
|
|
162
|
+
return 2;
|
|
163
|
+
}
|
|
164
|
+
return undefined;
|
|
109
165
|
}
|
|
110
166
|
export function getExplicitArtifactDestinationIndex(commandTokens) {
|
|
111
167
|
const command = commandTokens[0];
|
|
112
|
-
|
|
113
|
-
if (command === "screenshot")
|
|
168
|
+
if (command === "screenshot") {
|
|
114
169
|
return getScreenshotPathTokenIndex(commandTokens);
|
|
115
|
-
|
|
170
|
+
}
|
|
171
|
+
if (command === "download") {
|
|
116
172
|
return 2;
|
|
117
|
-
|
|
173
|
+
}
|
|
174
|
+
if (command === "pdf") {
|
|
118
175
|
return 1;
|
|
119
|
-
|
|
176
|
+
}
|
|
177
|
+
if (command === "wait") {
|
|
120
178
|
return parseWaitCommandTokens(commandTokens).downloadPathIndex;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
if (command === "diff" && subcommand === "screenshot")
|
|
124
|
-
return getDiffFilePathIndices(commandTokens).output;
|
|
125
|
-
if (command === "network" && subcommand === "har" && commandTokens[2] === "stop")
|
|
126
|
-
return 3;
|
|
127
|
-
if ((command === "trace" || command === "profiler") && subcommand === "stop")
|
|
128
|
-
return 2;
|
|
129
|
-
if (command === "record")
|
|
179
|
+
}
|
|
180
|
+
if (command === "record") {
|
|
130
181
|
return getRecordCommandOperandIndices(commandTokens)[0];
|
|
131
|
-
|
|
182
|
+
}
|
|
183
|
+
return getCompoundArtifactDestinationIndex(commandTokens);
|
|
132
184
|
}
|
|
133
185
|
export function getExplicitArtifactDestination(commandTokens) {
|
|
134
186
|
const index = getExplicitArtifactDestinationIndex(commandTokens);
|
package/dist/extensions/agent-browser/lib/orchestration/browser-run/browser-observation-result.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { isBooleanFlagEnabled } from "../../argv-grammar.js";
|
|
2
|
+
import { isRecord } from "../../parsing.js";
|
|
3
|
+
import { redactSensitiveValue } from "../../runtime-redaction.js";
|
|
4
|
+
import { getNativeWebMcpCatalog } from "../../webmcp-observation.js";
|
|
5
|
+
import { formatWebMcpCatalogUpdate } from "../../results/presentation/common.js";
|
|
6
|
+
import { getSessionContextKey } from "./session-state.js";
|
|
7
|
+
function appendCatalogNotice(result, catalog, data, args) {
|
|
8
|
+
if (isBooleanFlagEnabled(args, "--json") ||
|
|
9
|
+
JSON.stringify(getNativeWebMcpCatalog(data)) === JSON.stringify(catalog)) {
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
12
|
+
const notice = formatWebMcpCatalogUpdate(catalog);
|
|
13
|
+
const content = [...result.content];
|
|
14
|
+
const first = content.at(0);
|
|
15
|
+
if (first?.type === "text") {
|
|
16
|
+
content[0] = { ...first, text: `${first.text}\n\n${notice}` };
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
content.push({ type: "text", text: notice });
|
|
20
|
+
}
|
|
21
|
+
return { ...result, content };
|
|
22
|
+
}
|
|
23
|
+
function addCatalog(result, catalog, args) {
|
|
24
|
+
if (!catalog) {
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
const redacted = redactSensitiveValue(catalog);
|
|
28
|
+
if (!isRecord(redacted)) {
|
|
29
|
+
throw new Error("Browser catalog redaction did not preserve its object shape.");
|
|
30
|
+
}
|
|
31
|
+
const details = isRecord(result.details) ? result.details : undefined;
|
|
32
|
+
return appendCatalogNotice({ ...result, details: { ...details, webMcpCatalog: redacted } }, redacted, details?.data, args);
|
|
33
|
+
}
|
|
34
|
+
function addFailureError(result) {
|
|
35
|
+
const details = isRecord(result.details) ? result.details : undefined;
|
|
36
|
+
if (result.isError !== true || details?.error !== undefined) {
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
...result,
|
|
41
|
+
details: {
|
|
42
|
+
...details,
|
|
43
|
+
error: details?.validationError ??
|
|
44
|
+
details?.summary ??
|
|
45
|
+
result.content
|
|
46
|
+
.filter((part) => part.type === "text")
|
|
47
|
+
.map((part) => part.text)
|
|
48
|
+
.join("\n"),
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function addPendingPageState(result, state) {
|
|
53
|
+
const details = isRecord(result.details) ? result.details : undefined;
|
|
54
|
+
const key = getSessionContextKey(typeof details?.sessionName === "string" ? details.sessionName : undefined, typeof details?.namespace === "string" ? details.namespace : undefined);
|
|
55
|
+
const page = state.sessionPageState.get(key);
|
|
56
|
+
if (page.tabReopenPending === undefined) {
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
...result,
|
|
61
|
+
details: {
|
|
62
|
+
...details,
|
|
63
|
+
sessionTabReopenPending: page.tabReopenPending,
|
|
64
|
+
...(page.refSnapshotInvalidation
|
|
65
|
+
? { refSnapshotInvalidation: page.refSnapshotInvalidation }
|
|
66
|
+
: {}),
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export function projectBrowserObservationResult(options) {
|
|
71
|
+
let result = options.result;
|
|
72
|
+
const details = isRecord(result.details) ? result.details : undefined;
|
|
73
|
+
const confirmation = options.state.observedBrowserEffects?.readConfirmation;
|
|
74
|
+
if (details?.readConfirmation === undefined && Boolean(confirmation)) {
|
|
75
|
+
result = { ...result, details: { ...details, readConfirmation: confirmation } };
|
|
76
|
+
}
|
|
77
|
+
result = addFailureError(addCatalog(result, options.catalog, options.args));
|
|
78
|
+
if (options.modelVisible === false) {
|
|
79
|
+
result = { ...result, content: [] };
|
|
80
|
+
}
|
|
81
|
+
return addPendingPageState(result, options.state);
|
|
82
|
+
}
|