pi-agent-browser-native 0.9.3 → 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 +77 -5
- package/README.md +103 -81
- package/dist/extensions/agent-browser/index.js +43057 -2031
- 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 +112 -51
- 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 -82
- 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 +43 -9
- package/dist/extensions/agent-browser/lib/orchestration/batch-stdin.js +106 -59
- 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 +164 -60
- 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 +199 -154
- 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 -205
- 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 -1123
- 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 -968
- 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 -765
- 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 -821
- 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 -157
- package/dist/extensions/agent-browser/lib/orchestration/operation-paths.js +124 -58
- package/dist/extensions/agent-browser/lib/orchestration/output-file.js +197 -99
- 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 +55 -246
- package/dist/extensions/agent-browser/lib/parsing.js +13 -4
- package/dist/extensions/agent-browser/lib/pi-tool-rendering.js +133 -68
- package/dist/extensions/agent-browser/lib/playbook.js +16 -12
- package/dist/extensions/agent-browser/lib/process-child.js +284 -0
- package/dist/extensions/agent-browser/lib/process-environment.js +13 -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 +145 -536
- 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 +131 -68
- 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 -13
- 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 +90 -67
- 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 -555
- 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 -1052
- 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 +116 -240
- 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 -261
- 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 +119 -119
- 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 -1041
- 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 +178 -333
- 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 +17 -5
- package/docs/CODE_QUALITY.md +242 -0
- package/docs/COMMAND_REFERENCE.md +251 -220
- package/docs/ELECTRON.md +53 -44
- package/docs/RELEASE.md +18 -15
- package/docs/REQUIREMENTS.md +1 -0
- package/docs/SUPPORT_MATRIX.md +76 -75
- package/docs/TOOL_CONTRACT.md +145 -116
- 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
|
@@ -6,112 +6,215 @@ import { appendBrowserTransition, getBrowserRecord } from "../browser-transcript
|
|
|
6
6
|
import { redactSensitiveText } from "../runtime.js";
|
|
7
7
|
import { attachInlineImage } from "../results/presentation/artifacts.js";
|
|
8
8
|
import { projectAgentBrowserObservation } from "../results/presentation/content.js";
|
|
9
|
-
import { redactPresentationData } from "../results/presentation/
|
|
9
|
+
import { redactPresentationData } from "../results/presentation/diagnostic-redaction.js";
|
|
10
|
+
import { collectCodeArtifactReceipts, collectCodeFileArtifacts, } from "./code-artifact-observation.js";
|
|
11
|
+
import { parseCodeImageObservation } from "./code-image-observation.js";
|
|
10
12
|
// The offline converter retains outstanding isolated-session cleanup facts in canonical events.
|
|
11
13
|
export function getScriptSessionLeasesFromBranch(branch, ownerSessionId) {
|
|
12
14
|
const leases = new Map();
|
|
13
15
|
for (const entry of branch) {
|
|
14
|
-
const lease = getBrowserRecord(entry)?.event.state.scriptLease;
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
continue;
|
|
19
|
-
const { cleanup, closeCommandArgs, launchAttempted, sessionName } = lease;
|
|
20
|
-
if (!isAgentBrowserScriptSessionName(sessionName))
|
|
21
|
-
continue;
|
|
22
|
-
const expected = createAgentBrowserScriptCloseArgs(sessionName);
|
|
23
|
-
if ((cleanup !== "active" && cleanup !== "closed" && cleanup !== "failed") || launchAttempted !== true
|
|
24
|
-
|| !Array.isArray(closeCommandArgs) || closeCommandArgs.length !== expected.length
|
|
25
|
-
|| !closeCommandArgs.every((token, index) => token === expected[index]))
|
|
26
|
-
continue;
|
|
27
|
-
leases.set(sessionName, { cleanup, closeCommandArgs: expected, launchAttempted: true, sessionName, ownerSessionId: typeof lease.ownerSessionId === "string" ? lease.ownerSessionId : undefined });
|
|
16
|
+
const lease = parseScriptLease(getBrowserRecord(entry)?.event.state.scriptLease, ownerSessionId);
|
|
17
|
+
if (lease !== undefined) {
|
|
18
|
+
leases.set(lease.sessionName, lease);
|
|
19
|
+
}
|
|
28
20
|
}
|
|
29
21
|
return leases;
|
|
30
22
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
|
|
23
|
+
function parseScriptLease(value, ownerSessionId) {
|
|
24
|
+
if (!isRecord(value)) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
if (ownerSessionId !== undefined && value.ownerSessionId !== ownerSessionId) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
const { closeCommandArgs, launchAttempted, sessionName } = value;
|
|
31
|
+
const cleanup = ["active", "closed", "failed"].find((state) => state === value.cleanup);
|
|
32
|
+
if (!isAgentBrowserScriptSessionName(sessionName)) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
if (cleanup === undefined) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
const expected = createAgentBrowserScriptCloseArgs(sessionName);
|
|
39
|
+
if (launchAttempted !== true || !matchesCloseCommand(closeCommandArgs, expected)) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
41
42
|
return {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (!presentation.content.some(item => item.type === "image")) {
|
|
73
|
-
throw new Error(presentation.content.filter(item => item.type === "text").map(item => item.text).join("\n") || "The selected image could not be attached.");
|
|
74
|
-
}
|
|
75
|
-
selected.set(id, presentation.content.filter(item => item.type === "image"));
|
|
76
|
-
selectedBytes += file.size;
|
|
43
|
+
cleanup,
|
|
44
|
+
closeCommandArgs: expected,
|
|
45
|
+
launchAttempted: true,
|
|
46
|
+
sessionName,
|
|
47
|
+
ownerSessionId: typeof value.ownerSessionId === "string" ? value.ownerSessionId : undefined,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function matchesCloseCommand(value, expected) {
|
|
51
|
+
return (Array.isArray(value) &&
|
|
52
|
+
value.length === expected.length &&
|
|
53
|
+
value.every((token, index) => token === expected[index]));
|
|
54
|
+
}
|
|
55
|
+
export function appendScriptSessionLease(pi, sessionName, cleanup, ownerSessionId) {
|
|
56
|
+
appendBrowserTransition(pi, {
|
|
57
|
+
event: {
|
|
58
|
+
version: 1,
|
|
59
|
+
phase: "state",
|
|
60
|
+
operationId: randomUUID(),
|
|
61
|
+
toolCallId: "cleanup",
|
|
62
|
+
commandIndex: 0,
|
|
63
|
+
isError: cleanup !== "closed",
|
|
64
|
+
state: {
|
|
65
|
+
scriptLease: {
|
|
66
|
+
cleanup,
|
|
67
|
+
closeCommandArgs: createAgentBrowserScriptCloseArgs(sessionName),
|
|
68
|
+
launchAttempted: true,
|
|
69
|
+
sessionName,
|
|
70
|
+
ownerSessionId,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
77
73
|
},
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
class BrowserCodeOutput {
|
|
77
|
+
images = new Map();
|
|
78
|
+
selected = new Map();
|
|
79
|
+
receipts = new Map();
|
|
80
|
+
fileArtifacts = new Map();
|
|
81
|
+
selectedBytes = 0;
|
|
82
|
+
observe = async (result) => {
|
|
83
|
+
const details = isRecord(result.details) ? result.details : {};
|
|
84
|
+
const observation = projectAgentBrowserObservation(details, result.isError !== true);
|
|
85
|
+
for (const entry of collectCodeArtifactReceipts(observation.artifactVerification)) {
|
|
86
|
+
this.receipts.set(entry.absolutePath ?? entry.path, entry);
|
|
87
|
+
}
|
|
88
|
+
for (const artifact of collectCodeFileArtifacts(observation.artifacts)) {
|
|
89
|
+
this.fileArtifacts.set(artifact.absolutePath, artifact);
|
|
90
|
+
}
|
|
91
|
+
if (observation.imageObservations === undefined) {
|
|
92
|
+
return { ...observation, imageObservations: undefined };
|
|
93
|
+
}
|
|
94
|
+
if (!Array.isArray(observation.imageObservations)) {
|
|
95
|
+
throw new Error("Browser capture returned invalid image observations.");
|
|
96
|
+
}
|
|
97
|
+
const images = await Promise.all(observation.imageObservations.map(async (value) => {
|
|
98
|
+
const image = parseCodeImageObservation(value);
|
|
99
|
+
if (image === undefined) {
|
|
100
|
+
throw new Error("Browser capture returned invalid image observation geometry.");
|
|
85
101
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
102
|
+
const file = await stat(image.path);
|
|
103
|
+
const id = `image-${this.images.size + 1}`;
|
|
104
|
+
this.images.set(id, { observation: image, size: file.size, mtime: file.mtimeMs });
|
|
105
|
+
return { ...image, id };
|
|
106
|
+
}));
|
|
107
|
+
return { ...observation, imageObservations: images };
|
|
108
|
+
};
|
|
109
|
+
resolveImage(value) {
|
|
110
|
+
const id = isRecord(value) && typeof value.id === "string" ? value.id : undefined;
|
|
111
|
+
const image = id !== undefined && id.length > 0 ? this.images.get(id) : undefined;
|
|
112
|
+
if (id === undefined || id.length === 0 || !image) {
|
|
113
|
+
throw new Error("emitImage expects an imageObservations handle returned by browser() in this code call.");
|
|
114
|
+
}
|
|
115
|
+
return { id, image };
|
|
116
|
+
}
|
|
117
|
+
emitImage = async (value) => {
|
|
118
|
+
const { id, image } = this.resolveImage(value);
|
|
119
|
+
if (this.selected.has(id)) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (this.selected.size >= 8 || this.selectedBytes + image.size > 20 * 1_024 * 1_024) {
|
|
123
|
+
throw new Error("Selected images exceed the code output limit (8 images / 20 MiB). Emit fewer images.");
|
|
124
|
+
}
|
|
125
|
+
const file = await stat(image.observation.path);
|
|
126
|
+
if (!file.isFile() || file.size !== image.size || file.mtimeMs !== image.mtime) {
|
|
127
|
+
throw new Error("The selected image changed since capture. Capture it again before emitting it.");
|
|
128
|
+
}
|
|
129
|
+
const presentation = await attachInlineImage({ content: [], summary: "Selected browser image" }, image.observation.path);
|
|
130
|
+
if (!presentation.content.some((item) => item.type === "image")) {
|
|
131
|
+
const reason = presentation.content
|
|
132
|
+
.filter((item) => item.type === "text")
|
|
133
|
+
.map((item) => item.text)
|
|
134
|
+
.join("\n");
|
|
135
|
+
throw new Error(reason.length > 0 ? reason : "The selected image could not be attached.");
|
|
136
|
+
}
|
|
137
|
+
this.selected.set(id, {
|
|
138
|
+
content: presentation.content.filter((item) => item.type === "image"),
|
|
139
|
+
observation: { ...image.observation, id },
|
|
140
|
+
});
|
|
141
|
+
this.selectedBytes += file.size;
|
|
142
|
+
};
|
|
143
|
+
artifactVerification() {
|
|
144
|
+
const artifacts = [...this.receipts.values()];
|
|
145
|
+
if (artifacts.length === 0) {
|
|
146
|
+
return undefined;
|
|
147
|
+
}
|
|
148
|
+
const count = (state) => artifacts.filter((entry) => entry.state === state).length;
|
|
149
|
+
return {
|
|
150
|
+
artifacts,
|
|
151
|
+
missingCount: count("missing"),
|
|
152
|
+
pendingCount: count("pending"),
|
|
153
|
+
unverifiedCount: count("unverified"),
|
|
154
|
+
verifiedCount: count("verified"),
|
|
155
|
+
verified: artifacts.every((entry) => entry.state === "verified"),
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
failureCategory(run, outputError) {
|
|
159
|
+
if (outputError !== undefined) {
|
|
160
|
+
return "validation-error";
|
|
161
|
+
}
|
|
162
|
+
return run.failureCategory ?? (run.rejectedCallCount > 0 ? "validation-error" : undefined);
|
|
163
|
+
}
|
|
164
|
+
observation(run, context, output) {
|
|
165
|
+
const failureCategory = this.failureCategory(run, output.error);
|
|
166
|
+
const success = run.ok && failureCategory === undefined;
|
|
167
|
+
return {
|
|
168
|
+
success,
|
|
169
|
+
resultCategory: success ? "success" : "failure",
|
|
170
|
+
failureCategory,
|
|
171
|
+
data: output.data,
|
|
172
|
+
error: output.error ??
|
|
173
|
+
(run.error !== undefined && run.error.length > 0
|
|
174
|
+
? redactSensitiveText(run.error)
|
|
175
|
+
: undefined),
|
|
176
|
+
...context,
|
|
177
|
+
codeRun: {
|
|
178
|
+
callCount: run.callCount,
|
|
179
|
+
emitCount: run.emitCount,
|
|
180
|
+
failedCallCount: run.steps.filter((step) => !step.ok).length,
|
|
181
|
+
rejectedCallCount: run.rejectedCallCount,
|
|
182
|
+
aborted: run.aborted,
|
|
183
|
+
timedOut: run.timedOut,
|
|
184
|
+
},
|
|
185
|
+
failures: run.failures !== undefined && run.failures.length > 0 ? run.failures : undefined,
|
|
186
|
+
artifactVerification: this.artifactVerification(),
|
|
187
|
+
artifacts: this.fileArtifacts.size > 0 ? [...this.fileArtifacts.values()] : undefined,
|
|
188
|
+
imageObservations: [...this.selected.values()].map((image) => image.observation),
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
finish = async (run, sessionName, namespace) => {
|
|
192
|
+
let data;
|
|
193
|
+
let error;
|
|
194
|
+
try {
|
|
195
|
+
data = redactPresentationData({ command: "code" }, run.data);
|
|
196
|
+
if (data !== undefined &&
|
|
197
|
+
Buffer.byteLength(JSON.stringify(data), "utf8") >
|
|
198
|
+
AGENT_BROWSER_SCRIPT_FINAL_OUTPUT_MAX_BYTES) {
|
|
199
|
+
throw new Error("oversized");
|
|
89
200
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
artifactVerification,
|
|
106
|
-
artifacts: fileArtifacts.size ? [...fileArtifacts.values()] : undefined,
|
|
107
|
-
imageObservations: [...selected.keys()].map(id => ({ ...images.get(id).observation, id })),
|
|
108
|
-
};
|
|
109
|
-
const summary = success ? `Browser code completed (${run.callCount} calls).` : "Browser code failed.";
|
|
110
|
-
return {
|
|
111
|
-
content: [...selected.values()].flat(),
|
|
112
|
-
details: { ...observation, codeSteps: run.steps, summary },
|
|
113
|
-
isError: !success,
|
|
114
|
-
};
|
|
115
|
-
},
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
data = undefined;
|
|
204
|
+
error = "Code output could not be rendered as bounded JSON.";
|
|
205
|
+
}
|
|
206
|
+
const observation = this.observation(run, { sessionName, namespace }, { data, error });
|
|
207
|
+
const success = observation.success === true;
|
|
208
|
+
const summary = success
|
|
209
|
+
? `Browser code completed (${run.callCount} calls).`
|
|
210
|
+
: "Browser code failed.";
|
|
211
|
+
return {
|
|
212
|
+
content: [...this.selected.values()].flatMap((image) => image.content),
|
|
213
|
+
details: { ...observation, codeSteps: run.steps, summary },
|
|
214
|
+
isError: !success,
|
|
215
|
+
};
|
|
116
216
|
};
|
|
117
217
|
}
|
|
218
|
+
export function createBrowserCodeOutput() {
|
|
219
|
+
return new BrowserCodeOutput();
|
|
220
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { canonicalizeAgentBrowserNamespace, extractExplicitSessionName, resolveAgentBrowserNamespace, } from "./argv-grammar.js";
|
|
3
|
+
const ownedManagedSessionStorage = new AsyncLocalStorage();
|
|
4
|
+
export async function withOwnedManagedSessionContext(context, run) {
|
|
5
|
+
return await ownedManagedSessionStorage.run(context, run);
|
|
6
|
+
}
|
|
7
|
+
export function resolveOwnedManagedSessionContext(options) {
|
|
8
|
+
const namespace = canonicalizeAgentBrowserNamespace(options.namespace);
|
|
9
|
+
const currentNamespace = canonicalizeAgentBrowserNamespace(options.currentManagedSessionNamespace);
|
|
10
|
+
const recordedNamespace = canonicalizeAgentBrowserNamespace(options.recordedOwnedSession?.namespace);
|
|
11
|
+
if (options.recordedOwnedSession &&
|
|
12
|
+
options.sessionName === options.recordedOwnedSession.sessionName &&
|
|
13
|
+
namespace === recordedNamespace) {
|
|
14
|
+
return {
|
|
15
|
+
cwd: options.recordedOwnedSession.cwd,
|
|
16
|
+
namespace,
|
|
17
|
+
restoreState: options.restoreState,
|
|
18
|
+
sessionName: options.sessionName,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
if (options.managedSessionName !== undefined && options.managedSessionName.length > 0) {
|
|
22
|
+
return {
|
|
23
|
+
cwd: options.cwd,
|
|
24
|
+
namespace,
|
|
25
|
+
restoreState: options.restoreState,
|
|
26
|
+
sessionName: options.managedSessionName,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
if (options.sessionName !== undefined &&
|
|
30
|
+
options.sessionName.length > 0 &&
|
|
31
|
+
matchesCurrentContext(options, namespace, currentNamespace)) {
|
|
32
|
+
return {
|
|
33
|
+
cwd: options.cwd,
|
|
34
|
+
namespace,
|
|
35
|
+
restoreState: options.restoreState,
|
|
36
|
+
sessionName: options.sessionName,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
function matchesCurrentContext(options, namespace, currentNamespace) {
|
|
42
|
+
return (options.sessionName === options.currentManagedSessionName && namespace === currentNamespace);
|
|
43
|
+
}
|
|
44
|
+
export function ownedContextMatches(sessionName, args) {
|
|
45
|
+
const owned = ownedManagedSessionStorage.getStore();
|
|
46
|
+
return owned &&
|
|
47
|
+
sessionName === owned.sessionName &&
|
|
48
|
+
canonicalizeAgentBrowserNamespace(resolveAgentBrowserNamespace(args, owned.namespace)) ===
|
|
49
|
+
owned.namespace
|
|
50
|
+
? owned
|
|
51
|
+
: undefined;
|
|
52
|
+
}
|
|
53
|
+
export function isOwnedManagedSessionTarget(args) {
|
|
54
|
+
return ownedContextMatches(extractExplicitSessionName(args), args) !== undefined;
|
|
55
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { parseArgvDescriptor } from "./argv-descriptor.js";
|
|
2
|
+
import { parseBatchCommandArgument, parseUserBatchStdin, } from "./orchestration/batch-stdin.js";
|
|
3
|
+
import { BATCH_UNVERIFIED_PAGE_MESSAGE, NON_BAIL_BATCH_NAVIGATION_MESSAGE, getUnverifiedPageError, } from "./page-target-guards.js";
|
|
4
|
+
import { commandMayChangePageTarget, commandVerifiesPageTarget, getResultingPageState, } from "./page-target-navigation.js";
|
|
5
|
+
export const UNSAFE_BATCH_ARGUMENT_MESSAGE = "Batch command arguments could not be inspected. Use batch stdin JSON command arrays instead.";
|
|
6
|
+
export const NESTED_BATCH_ARGUMENT_MESSAGE = "Nested batch commands are not supported. Flatten the batch steps instead.";
|
|
7
|
+
const MAX_NON_BAIL_BATCH_PAGE_STATES = 64;
|
|
8
|
+
function inspectBatchArguments(commands) {
|
|
9
|
+
const steps = [];
|
|
10
|
+
for (const command of commands) {
|
|
11
|
+
const parsed = parseBatchCommandArgument(command);
|
|
12
|
+
if ((parsed.error !== undefined && parsed.error.length > 0) || parsed.step === undefined) {
|
|
13
|
+
return { error: parsed.error ?? UNSAFE_BATCH_ARGUMENT_MESSAGE, steps: [] };
|
|
14
|
+
}
|
|
15
|
+
if (parseArgvDescriptor(parsed.step).commandInfo.command === "batch") {
|
|
16
|
+
return { error: NESTED_BATCH_ARGUMENT_MESSAGE, steps: [] };
|
|
17
|
+
}
|
|
18
|
+
steps.push(parsed.step);
|
|
19
|
+
}
|
|
20
|
+
return { steps };
|
|
21
|
+
}
|
|
22
|
+
export function getBatchCommandSteps(args, stdin) {
|
|
23
|
+
const descriptor = parseArgvDescriptor(args);
|
|
24
|
+
if (descriptor.commandInfo.command !== "batch") {
|
|
25
|
+
return { steps: [] };
|
|
26
|
+
}
|
|
27
|
+
const argumentsToParse = descriptor.upstreamCommandTokens
|
|
28
|
+
.slice(1)
|
|
29
|
+
.filter((command) => command !== "--bail");
|
|
30
|
+
if (argumentsToParse.length > 0) {
|
|
31
|
+
return inspectBatchArguments(argumentsToParse);
|
|
32
|
+
}
|
|
33
|
+
const parsed = parseUserBatchStdin(stdin);
|
|
34
|
+
if (parsed.error !== undefined && parsed.error.length > 0) {
|
|
35
|
+
return { error: parsed.error, steps: [] };
|
|
36
|
+
}
|
|
37
|
+
const steps = (parsed.steps ?? []).filter((step) => step.length > 0);
|
|
38
|
+
return steps.some((step) => parseArgvDescriptor(step).commandInfo.command === "batch")
|
|
39
|
+
? { error: NESTED_BATCH_ARGUMENT_MESSAGE, steps: [] }
|
|
40
|
+
: { steps };
|
|
41
|
+
}
|
|
42
|
+
function deduplicatePossibleBatchPageStates(states) {
|
|
43
|
+
const deduplicated = new Map();
|
|
44
|
+
for (const state of states) {
|
|
45
|
+
const key = `${state.pageUrlUnknown ? "unknown" : "known"}\0${state.currentPageUrl ?? ""}`;
|
|
46
|
+
const existing = deduplicated.get(key);
|
|
47
|
+
deduplicated.set(key, {
|
|
48
|
+
...(existing ?? state),
|
|
49
|
+
retainedAfterFailedNavigation: state.retainedAfterFailedNavigation || existing?.retainedAfterFailedNavigation === true,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return [...deduplicated.values()];
|
|
53
|
+
}
|
|
54
|
+
function possibleStateError(states, step, options) {
|
|
55
|
+
if (options.allowsConfirmation) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
let failedNavigationHazard = false;
|
|
59
|
+
for (const state of states) {
|
|
60
|
+
const error = getUnverifiedPageError({
|
|
61
|
+
...options,
|
|
62
|
+
args: step,
|
|
63
|
+
pageUrlUnknown: state.pageUrlUnknown,
|
|
64
|
+
});
|
|
65
|
+
if (error === undefined || error.length === 0) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (!state.retainedAfterFailedNavigation) {
|
|
69
|
+
return BATCH_UNVERIFIED_PAGE_MESSAGE;
|
|
70
|
+
}
|
|
71
|
+
failedNavigationHazard = true;
|
|
72
|
+
}
|
|
73
|
+
return failedNavigationHazard ? NON_BAIL_BATCH_NAVIGATION_MESSAGE : undefined;
|
|
74
|
+
}
|
|
75
|
+
function advancePossibleStates(states, step, trustedBatchTabSelection, bail) {
|
|
76
|
+
const mayChangePageTarget = commandMayChangePageTarget(step, trustedBatchTabSelection);
|
|
77
|
+
const verifiesPageTarget = commandVerifiesPageTarget(step);
|
|
78
|
+
const nextStates = [];
|
|
79
|
+
for (const state of states) {
|
|
80
|
+
if (nextStates.length >= MAX_NON_BAIL_BATCH_PAGE_STATES) {
|
|
81
|
+
return { states: [], error: NON_BAIL_BATCH_NAVIGATION_MESSAGE };
|
|
82
|
+
}
|
|
83
|
+
nextStates.push({
|
|
84
|
+
...getResultingPageState({ args: step, ...state, trustedBatchTabSelection }),
|
|
85
|
+
retainedAfterFailedNavigation: mayChangePageTarget || verifiesPageTarget ? false : state.retainedAfterFailedNavigation,
|
|
86
|
+
});
|
|
87
|
+
if (!bail && (mayChangePageTarget || (verifiesPageTarget && state.pageUrlUnknown))) {
|
|
88
|
+
nextStates.push({ ...state, retainedAfterFailedNavigation: true });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return { states: deduplicatePossibleBatchPageStates(nextStates) };
|
|
92
|
+
}
|
|
93
|
+
export function validateBatchPageTargets(steps, bail, options) {
|
|
94
|
+
let states = [
|
|
95
|
+
{
|
|
96
|
+
currentPageUrl: options.currentPageUrl,
|
|
97
|
+
pageUrlUnknown: options.pageUrlUnknown ?? false,
|
|
98
|
+
retainedAfterFailedNavigation: false,
|
|
99
|
+
},
|
|
100
|
+
];
|
|
101
|
+
for (const [index, step] of steps.entries()) {
|
|
102
|
+
const trustedBatchTabSelection = options.trustedFirstBatchTabSelection === true && index === 0;
|
|
103
|
+
const error = possibleStateError(states, step, {
|
|
104
|
+
allowUnverifiedPageTransitions: options.allowUnverifiedPageTransitions,
|
|
105
|
+
trustedBatchTabSelection,
|
|
106
|
+
allowsConfirmation: options.allowFirstBatchConfirmation === true && index === 0,
|
|
107
|
+
});
|
|
108
|
+
if (error !== undefined) {
|
|
109
|
+
return error;
|
|
110
|
+
}
|
|
111
|
+
const next = advancePossibleStates(states, step, trustedBatchTabSelection, bail);
|
|
112
|
+
if (next.error !== undefined) {
|
|
113
|
+
return next.error;
|
|
114
|
+
}
|
|
115
|
+
states = next.states;
|
|
116
|
+
}
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { parseArgvDescriptor } from "./argv-descriptor.js";
|
|
2
|
+
import { needsManagedSession } from "./command-policy.js";
|
|
3
|
+
import { isUnverifiedPageTransitionCommand } from "./command-taxonomy.js";
|
|
4
|
+
import { getExplicitNavigationTarget } from "./page-target-navigation.js";
|
|
5
|
+
export const UNVERIFIED_PAGE_MESSAGE = "The active page became unverified after a tab, attachment, history, script, or state-load transition. Run get url or navigate explicitly before page-content inspection.";
|
|
6
|
+
export const BATCH_UNVERIFIED_PAGE_MESSAGE = `${UNVERIFIED_PAGE_MESSAGE} In a batch, put get url after the transition before later content steps, or split the batch at that boundary.`;
|
|
7
|
+
export const NON_BAIL_BATCH_NAVIGATION_MESSAGE = "Batches that change or re-verify the page target before page-content access must use exact batch --bail so a failed step cannot act on an unverified or prior page.";
|
|
8
|
+
export function isRecoveringPageTransitionCommand(command, subcommand) {
|
|
9
|
+
return (command !== "eval" &&
|
|
10
|
+
!(command === "webmcp" && subcommand === "invoke") &&
|
|
11
|
+
isUnverifiedPageTransitionCommand(command, subcommand));
|
|
12
|
+
}
|
|
13
|
+
function canOperateWithoutVerifiedPage(command, subcommand) {
|
|
14
|
+
switch (command) {
|
|
15
|
+
case undefined:
|
|
16
|
+
return false;
|
|
17
|
+
case "close":
|
|
18
|
+
case "exit":
|
|
19
|
+
case "quit":
|
|
20
|
+
return true;
|
|
21
|
+
case "tab":
|
|
22
|
+
return subcommand !== undefined && subcommand !== "new";
|
|
23
|
+
case "get":
|
|
24
|
+
return subcommand === "url";
|
|
25
|
+
case "webmcp":
|
|
26
|
+
return ["result", "cancel"].includes(subcommand ?? "");
|
|
27
|
+
case "record":
|
|
28
|
+
return subcommand === "stop";
|
|
29
|
+
case "dialog":
|
|
30
|
+
return ["status", "accept", "dismiss"].includes(subcommand ?? "");
|
|
31
|
+
default:
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export function getUnverifiedPageError(options) {
|
|
36
|
+
const descriptor = parseArgvDescriptor(options.args);
|
|
37
|
+
if (options.pageUrlUnknown !== true || !needsManagedSession(descriptor)) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
const { command, subcommand } = descriptor.commandInfo;
|
|
41
|
+
if (canOperateWithoutVerifiedPage(command, subcommand)) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
const transitionsPage = options.allowUnverifiedPageTransitions === true &&
|
|
45
|
+
isRecoveringPageTransitionCommand(command, subcommand);
|
|
46
|
+
const trustedTab = options.trustedBatchTabSelection === true && command === "tab";
|
|
47
|
+
return transitionsPage || trustedTab || getExplicitNavigationTarget(options.args) !== undefined
|
|
48
|
+
? undefined
|
|
49
|
+
: UNVERIFIED_PAGE_MESSAGE;
|
|
50
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { parseArgvDescriptor } from "./argv-descriptor.js";
|
|
2
|
+
import { GLOBAL_BOOLEAN_FLAGS_WITH_OPTIONAL_VALUES, VALUE_FLAGS } from "./argv-grammar.js";
|
|
3
|
+
import { isUnverifiedPageTransitionCommand } from "./command-taxonomy.js";
|
|
4
|
+
const EXPLICIT_NAVIGATION_COMMANDS = new Set([
|
|
5
|
+
"a11y",
|
|
6
|
+
"goto",
|
|
7
|
+
"navigate",
|
|
8
|
+
"open",
|
|
9
|
+
"pushstate",
|
|
10
|
+
"visit",
|
|
11
|
+
"vitals",
|
|
12
|
+
"web-vitals",
|
|
13
|
+
]);
|
|
14
|
+
const POSITIONAL_VALUE_FLAGS = new Set([...VALUE_FLAGS, "--llms"]);
|
|
15
|
+
function isPositionalOperand(token) {
|
|
16
|
+
return !token.startsWith("-") || token.includes("/") || token.includes("\\");
|
|
17
|
+
}
|
|
18
|
+
function getPositionalOperands(commandTokens) {
|
|
19
|
+
const values = [];
|
|
20
|
+
for (let index = 1; index < commandTokens.length; index += 1) {
|
|
21
|
+
const token = commandTokens[index];
|
|
22
|
+
if (token.length === 0 || (token.includes("=") && token.startsWith("-"))) {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (POSITIONAL_VALUE_FLAGS.has(token)) {
|
|
26
|
+
index += 1;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (GLOBAL_BOOLEAN_FLAGS_WITH_OPTIONAL_VALUES.has(token)) {
|
|
30
|
+
index += ["true", "false"].includes(commandTokens[index + 1] ?? "") ? 1 : 0;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (isPositionalOperand(token)) {
|
|
34
|
+
values.push(token);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return values;
|
|
38
|
+
}
|
|
39
|
+
export function getExplicitNavigationTarget(args) {
|
|
40
|
+
const descriptor = parseArgvDescriptor(args);
|
|
41
|
+
const positionals = getPositionalOperands(descriptor.upstreamCommandTokens);
|
|
42
|
+
const { command, subcommand } = descriptor.commandInfo;
|
|
43
|
+
if (EXPLICIT_NAVIGATION_COMMANDS.has(command ?? "")) {
|
|
44
|
+
return positionals[0];
|
|
45
|
+
}
|
|
46
|
+
if (command === "tab" && subcommand === "new") {
|
|
47
|
+
return positionals[1];
|
|
48
|
+
}
|
|
49
|
+
if (command === "window" && subcommand === "new") {
|
|
50
|
+
return "about:blank";
|
|
51
|
+
}
|
|
52
|
+
return command === "diff" && subcommand === "url"
|
|
53
|
+
? descriptor.upstreamCommandTokens[3]
|
|
54
|
+
: undefined;
|
|
55
|
+
}
|
|
56
|
+
function getResultingExplicitNavigationTarget(args, currentPageUrl) {
|
|
57
|
+
const target = getExplicitNavigationTarget(args);
|
|
58
|
+
if (target === undefined || parseArgvDescriptor(args).commandInfo.command !== "pushstate") {
|
|
59
|
+
return target;
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
return new URL(target).href;
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
if (currentPageUrl === undefined || currentPageUrl.length === 0) {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
return new URL(target, currentPageUrl).href;
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export function commandMayChangePageTarget(args, trustedBatchTabSelection) {
|
|
77
|
+
const { command, subcommand } = parseArgvDescriptor(args).commandInfo;
|
|
78
|
+
return (getExplicitNavigationTarget(args) !== undefined ||
|
|
79
|
+
(isUnverifiedPageTransitionCommand(command, subcommand) &&
|
|
80
|
+
!(trustedBatchTabSelection && command === "tab")));
|
|
81
|
+
}
|
|
82
|
+
export function commandVerifiesPageTarget(args) {
|
|
83
|
+
const { command, subcommand } = parseArgvDescriptor(args).commandInfo;
|
|
84
|
+
return command === "get" && subcommand === "url";
|
|
85
|
+
}
|
|
86
|
+
export function getResultingPageState(options) {
|
|
87
|
+
const { command, subcommand } = parseArgvDescriptor(options.args).commandInfo;
|
|
88
|
+
if (command === "get" && subcommand === "url") {
|
|
89
|
+
return { currentPageUrl: options.currentPageUrl, pageUrlUnknown: false };
|
|
90
|
+
}
|
|
91
|
+
const rawExplicitTarget = getExplicitNavigationTarget(options.args);
|
|
92
|
+
const explicitTarget = getResultingExplicitNavigationTarget(options.args, options.currentPageUrl);
|
|
93
|
+
if (explicitTarget !== undefined) {
|
|
94
|
+
return { currentPageUrl: explicitTarget, pageUrlUnknown: false };
|
|
95
|
+
}
|
|
96
|
+
if (rawExplicitTarget !== undefined) {
|
|
97
|
+
return { pageUrlUnknown: true };
|
|
98
|
+
}
|
|
99
|
+
if (isUnverifiedPageTransitionCommand(command, subcommand) &&
|
|
100
|
+
!(options.trustedBatchTabSelection && command === "tab")) {
|
|
101
|
+
return { pageUrlUnknown: true };
|
|
102
|
+
}
|
|
103
|
+
return { currentPageUrl: options.currentPageUrl, pageUrlUnknown: options.pageUrlUnknown };
|
|
104
|
+
}
|