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,64 +1,99 @@
|
|
|
1
|
-
const EDITABLE_REF_EVIDENCE_KEYS = [
|
|
1
|
+
const EDITABLE_REF_EVIDENCE_KEYS = [
|
|
2
|
+
"editable",
|
|
3
|
+
"contentEditable",
|
|
4
|
+
"contenteditable",
|
|
5
|
+
"isContentEditable",
|
|
6
|
+
];
|
|
2
7
|
const EDITABLE_FALSE_TEXT_PATTERN = /\b(?:contenteditable|editable)\s*=\s*["']?(?:false|0)["']?/i;
|
|
3
8
|
const EDITABLE_ASSIGNMENT_TEXT_PATTERN = /\b(contenteditable|editable)\s*=\s*("[^"]*"|'[^']*'|[^\s,\]]+)/gi;
|
|
4
9
|
const EDITABLE_BARE_TEXT_PATTERN = /\b(?:contenteditable|editable)\b(?!\s*=)/i;
|
|
5
10
|
function parseEditableEvidenceValue(value) {
|
|
6
|
-
if (typeof value === "boolean")
|
|
11
|
+
if (typeof value === "boolean") {
|
|
7
12
|
return value;
|
|
13
|
+
}
|
|
8
14
|
if (typeof value === "number") {
|
|
9
|
-
if (value === 1)
|
|
15
|
+
if (value === 1) {
|
|
10
16
|
return true;
|
|
11
|
-
|
|
17
|
+
}
|
|
18
|
+
if (value === 0) {
|
|
12
19
|
return false;
|
|
20
|
+
}
|
|
13
21
|
return undefined;
|
|
14
22
|
}
|
|
15
|
-
if (typeof value !== "string")
|
|
23
|
+
if (typeof value !== "string") {
|
|
16
24
|
return undefined;
|
|
17
|
-
|
|
18
|
-
|
|
25
|
+
}
|
|
26
|
+
const normalized = value
|
|
27
|
+
.trim()
|
|
28
|
+
.replace(/^["']|["']$/g, "")
|
|
29
|
+
.toLowerCase();
|
|
30
|
+
if (["false", "0", "no"].includes(normalized)) {
|
|
19
31
|
return false;
|
|
20
|
-
|
|
32
|
+
}
|
|
33
|
+
if (["", "true", "1", "yes", "plaintext-only"].includes(normalized)) {
|
|
21
34
|
return true;
|
|
35
|
+
}
|
|
22
36
|
return undefined;
|
|
23
37
|
}
|
|
24
38
|
function stripLeadingSnapshotAccessibleName(text) {
|
|
25
39
|
return text.replace(/^(\s*[-*]\s+\S+\s+)(?:"[^"]*"|'[^']*')/, "$1");
|
|
26
40
|
}
|
|
27
|
-
function
|
|
28
|
-
if (!text)
|
|
29
|
-
return undefined;
|
|
30
|
-
const markerText = stripLeadingSnapshotAccessibleName(text);
|
|
31
|
-
if (EDITABLE_FALSE_TEXT_PATTERN.test(markerText))
|
|
32
|
-
return false;
|
|
41
|
+
function parseEditableAssignments(markerText) {
|
|
33
42
|
let hasPositiveAssignment = false;
|
|
34
43
|
for (const match of markerText.matchAll(EDITABLE_ASSIGNMENT_TEXT_PATTERN)) {
|
|
35
44
|
const key = match[1]?.toLowerCase();
|
|
36
45
|
const evidence = parseEditableEvidenceValue(match[2]);
|
|
37
|
-
if (evidence === false)
|
|
46
|
+
if (evidence === false) {
|
|
38
47
|
return false;
|
|
48
|
+
}
|
|
39
49
|
if (evidence === true && (key === "contenteditable" || key === "editable")) {
|
|
40
50
|
hasPositiveAssignment = true;
|
|
41
51
|
}
|
|
42
52
|
}
|
|
43
|
-
|
|
44
|
-
|
|
53
|
+
return hasPositiveAssignment ? true : undefined;
|
|
54
|
+
}
|
|
55
|
+
function parseEditableEvidenceText(text) {
|
|
56
|
+
if (text === undefined || text.length === 0) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
const markerText = stripLeadingSnapshotAccessibleName(text);
|
|
60
|
+
if (EDITABLE_FALSE_TEXT_PATTERN.test(markerText)) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
const assignment = parseEditableAssignments(markerText);
|
|
64
|
+
if (assignment !== undefined) {
|
|
65
|
+
return assignment;
|
|
66
|
+
}
|
|
45
67
|
return EDITABLE_BARE_TEXT_PATTERN.test(markerText) ? true : undefined;
|
|
46
68
|
}
|
|
47
|
-
|
|
69
|
+
function getStructuredEditableEvidence(ref) {
|
|
70
|
+
if (!ref) {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
48
73
|
let hasPositiveEvidence = false;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return false;
|
|
54
|
-
if (evidence === true)
|
|
55
|
-
hasPositiveEvidence = true;
|
|
74
|
+
for (const key of EDITABLE_REF_EVIDENCE_KEYS) {
|
|
75
|
+
const evidence = parseEditableEvidenceValue(ref[key]);
|
|
76
|
+
if (evidence === false) {
|
|
77
|
+
return false;
|
|
56
78
|
}
|
|
79
|
+
if (evidence === true) {
|
|
80
|
+
hasPositiveEvidence = true;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return hasPositiveEvidence ? true : undefined;
|
|
84
|
+
}
|
|
85
|
+
export function getEditableRefEvidence(options) {
|
|
86
|
+
const structuredEvidence = getStructuredEditableEvidence(options.ref);
|
|
87
|
+
if (structuredEvidence === false) {
|
|
88
|
+
return false;
|
|
57
89
|
}
|
|
90
|
+
let hasPositiveEvidence = structuredEvidence === true;
|
|
58
91
|
const textEvidence = parseEditableEvidenceText(options.text);
|
|
59
|
-
if (textEvidence === false)
|
|
92
|
+
if (textEvidence === false) {
|
|
60
93
|
return false;
|
|
61
|
-
|
|
94
|
+
}
|
|
95
|
+
if (textEvidence === true) {
|
|
62
96
|
hasPositiveEvidence = true;
|
|
97
|
+
}
|
|
63
98
|
return hasPositiveEvidence ? true : undefined;
|
|
64
99
|
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { buildNextToolAction } from "./next-actions.js";
|
|
2
|
+
function buildElectronToolAction(options) {
|
|
3
|
+
return {
|
|
4
|
+
id: options.id,
|
|
5
|
+
params: { action: options.action, launchId: options.launchId },
|
|
6
|
+
reason: options.reason,
|
|
7
|
+
...(options.safety !== undefined && options.safety.length > 0
|
|
8
|
+
? { safety: options.safety }
|
|
9
|
+
: {}),
|
|
10
|
+
tool: "agent_browser_electron",
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function buildActiveLaunchActions(launchId) {
|
|
14
|
+
return [
|
|
15
|
+
buildElectronToolAction({
|
|
16
|
+
action: "status",
|
|
17
|
+
id: "status-electron-launch",
|
|
18
|
+
launchId,
|
|
19
|
+
reason: "Check the wrapper-tracked Electron launch liveness and current CDP targets without mutating the app.",
|
|
20
|
+
}),
|
|
21
|
+
buildElectronToolAction({
|
|
22
|
+
action: "probe",
|
|
23
|
+
id: "probe-electron-launch",
|
|
24
|
+
launchId,
|
|
25
|
+
reason: "Probe the attached Electron managed session and carry the wrapper launchId for follow-up diagnostics.",
|
|
26
|
+
}),
|
|
27
|
+
buildElectronToolAction({
|
|
28
|
+
action: "cleanup",
|
|
29
|
+
id: "cleanup-electron-launch",
|
|
30
|
+
launchId,
|
|
31
|
+
reason: "Clean the wrapper-owned Electron process and isolated userDataDir when the run is complete.",
|
|
32
|
+
safety: "Only operates on the launchId created by electron.launch; explicit artifacts and manually launched apps remain host-owned.",
|
|
33
|
+
}),
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
function buildElectronSessionActions(sessionName) {
|
|
37
|
+
if (sessionName === undefined || sessionName.length === 0) {
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
40
|
+
return [
|
|
41
|
+
buildNextToolAction({
|
|
42
|
+
args: ["--session", sessionName, "tab", "list"],
|
|
43
|
+
id: "list-electron-tabs",
|
|
44
|
+
reason: "Inspect attached Electron page/webview targets before choosing the active tab.",
|
|
45
|
+
}),
|
|
46
|
+
buildNextToolAction({
|
|
47
|
+
args: ["--session", sessionName, "snapshot", "-i"],
|
|
48
|
+
id: "snapshot-electron-session",
|
|
49
|
+
reason: "Refresh interactive refs for the attached Electron session.",
|
|
50
|
+
safety: "Use current Electron refs only after a fresh snapshot for this session.",
|
|
51
|
+
}),
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
export function buildElectronNextActions(options) {
|
|
55
|
+
const launchId = options.electron?.launchId;
|
|
56
|
+
if (launchId === undefined || launchId.length === 0) {
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
if (options.resultCategory === "success" && options.electron?.status !== "cleaned") {
|
|
60
|
+
return [
|
|
61
|
+
...buildActiveLaunchActions(launchId),
|
|
62
|
+
...buildElectronSessionActions(options.electron?.sessionName),
|
|
63
|
+
];
|
|
64
|
+
}
|
|
65
|
+
if (options.resultCategory === "failure" && options.failureCategory === "cleanup-failed") {
|
|
66
|
+
return [
|
|
67
|
+
buildElectronToolAction({
|
|
68
|
+
action: "status",
|
|
69
|
+
id: "status-electron-launch",
|
|
70
|
+
launchId,
|
|
71
|
+
reason: "Inspect which wrapper-tracked Electron resources remain after partial cleanup.",
|
|
72
|
+
}),
|
|
73
|
+
buildElectronToolAction({
|
|
74
|
+
action: "cleanup",
|
|
75
|
+
id: "retry-electron-cleanup",
|
|
76
|
+
launchId,
|
|
77
|
+
reason: "Retry cleanup for the same wrapper-owned Electron launch after reviewing remaining resources.",
|
|
78
|
+
safety: "Only retry for the same launchId; do not use cleanup for manually launched Electron apps.",
|
|
79
|
+
}),
|
|
80
|
+
];
|
|
81
|
+
}
|
|
82
|
+
return [];
|
|
83
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { isRecord } from "../parsing.js";
|
|
2
|
+
function decodePluginList(value) {
|
|
3
|
+
const keys = Object.keys(value);
|
|
4
|
+
if (keys.length !== 1) {
|
|
5
|
+
return undefined;
|
|
6
|
+
}
|
|
7
|
+
if (keys[0] === "plugins" && Array.isArray(value.plugins)) {
|
|
8
|
+
return { success: true, data: { plugins: value.plugins } };
|
|
9
|
+
}
|
|
10
|
+
if (keys[0] === "plugin" && isRecord(value.plugin) && !Array.isArray(value.plugin)) {
|
|
11
|
+
return { success: true, data: { plugin: value.plugin } };
|
|
12
|
+
}
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
export function decodeAgentBrowserEnvelope(value) {
|
|
16
|
+
if (Array.isArray(value)) {
|
|
17
|
+
return {
|
|
18
|
+
envelope: {
|
|
19
|
+
success: value.every((item) => !isRecord(item) || item.success !== false),
|
|
20
|
+
data: value,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
if (!isRecord(value)) {
|
|
25
|
+
return { parseError: "agent-browser returned JSON, but it was not an object envelope." };
|
|
26
|
+
}
|
|
27
|
+
const plugin = decodePluginList(value);
|
|
28
|
+
if (plugin) {
|
|
29
|
+
return { envelope: plugin };
|
|
30
|
+
}
|
|
31
|
+
if (!("success" in value)) {
|
|
32
|
+
return {
|
|
33
|
+
parseError: "agent-browser returned an invalid JSON envelope: missing boolean success field.",
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
if (typeof value.success !== "boolean") {
|
|
37
|
+
return {
|
|
38
|
+
parseError: "agent-browser returned an invalid JSON envelope: success field must be boolean.",
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
if (!Object.hasOwn(value, "data")) {
|
|
42
|
+
const { success, error, ...topLevelData } = value;
|
|
43
|
+
if (Object.keys(topLevelData).length > 0) {
|
|
44
|
+
return { envelope: { error, success, data: topLevelData } };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return { envelope: { ...value, success: value.success } };
|
|
48
|
+
}
|
|
@@ -1,90 +1,86 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { isRecord } from "../parsing.js";
|
|
3
3
|
import { detectConfirmationRequired } from "./confirmation.js";
|
|
4
|
+
import { decodeAgentBrowserEnvelope } from "./envelope-decoding.js";
|
|
4
5
|
import { stringifyUnknown } from "./text.js";
|
|
5
6
|
function hasStructuredBatchStepFailure(data) {
|
|
6
7
|
return Array.isArray(data) && data.some((item) => isRecord(item) && item.success === false);
|
|
7
8
|
}
|
|
8
9
|
async function readEnvelopeSource(options) {
|
|
9
|
-
if (
|
|
10
|
+
if (options.stdoutPath === undefined || options.stdoutPath.length === 0) {
|
|
10
11
|
return options.stdout;
|
|
11
12
|
}
|
|
12
13
|
try {
|
|
13
14
|
return await readFile(options.stdoutPath, "utf8");
|
|
14
15
|
}
|
|
15
16
|
catch (error) {
|
|
16
|
-
const message = error instanceof Error ? error.message :
|
|
17
|
-
throw new Error(`agent-browser output spill file could not be read: ${message}
|
|
17
|
+
const message = error instanceof Error ? error.message : stringifyUnknown(error);
|
|
18
|
+
throw new Error(`agent-browser output spill file could not be read: ${message}`, {
|
|
19
|
+
cause: error,
|
|
20
|
+
});
|
|
18
21
|
}
|
|
19
22
|
}
|
|
20
23
|
export function extractEnvelopeErrorText(error) {
|
|
21
24
|
if (typeof error === "string") {
|
|
22
|
-
|
|
25
|
+
const trimmed = error.trim();
|
|
26
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
23
27
|
}
|
|
24
28
|
if (typeof error === "number" || typeof error === "boolean") {
|
|
25
29
|
return String(error);
|
|
26
30
|
}
|
|
27
31
|
if (Array.isArray(error)) {
|
|
28
|
-
const parts = error
|
|
32
|
+
const parts = error
|
|
33
|
+
.map((item) => extractEnvelopeErrorText(item) ?? stringifyUnknown(item))
|
|
34
|
+
.filter((item) => item.length > 0);
|
|
29
35
|
return parts.length > 0 ? parts.join("\n") : undefined;
|
|
30
36
|
}
|
|
31
37
|
if (!isRecord(error)) {
|
|
32
|
-
return error
|
|
38
|
+
return error === null || error === undefined ? undefined : stringifyUnknown(error);
|
|
33
39
|
}
|
|
40
|
+
return extractStructuredEnvelopeErrorText(error);
|
|
41
|
+
}
|
|
42
|
+
function extractStructuredEnvelopeErrorText(error) {
|
|
34
43
|
for (const key of ["message", "error", "details", "cause", "stderr"]) {
|
|
35
44
|
const value = extractEnvelopeErrorText(error[key]);
|
|
36
|
-
if (value)
|
|
45
|
+
if ((value ?? "") !== "") {
|
|
37
46
|
return value;
|
|
47
|
+
}
|
|
38
48
|
}
|
|
39
49
|
const fallback = stringifyUnknown(error).trim();
|
|
40
50
|
return fallback.length > 0 && fallback !== "{}" ? fallback : undefined;
|
|
41
51
|
}
|
|
52
|
+
function getEnvelopeOutputMode(options) {
|
|
53
|
+
return typeof options === "string"
|
|
54
|
+
? { plainText: false, textOutput: false }
|
|
55
|
+
: { plainText: options.plainText === true, textOutput: options.textOutput === true };
|
|
56
|
+
}
|
|
42
57
|
export async function parseAgentBrowserEnvelope(options) {
|
|
43
58
|
let stdout;
|
|
44
59
|
try {
|
|
45
60
|
stdout = typeof options === "string" ? options : await readEnvelopeSource(options);
|
|
46
61
|
}
|
|
47
62
|
catch (error) {
|
|
48
|
-
return { parseError: error instanceof Error ? error.message :
|
|
63
|
+
return { parseError: error instanceof Error ? error.message : stringifyUnknown(error) };
|
|
64
|
+
}
|
|
65
|
+
// ponytail: native text has no machine receipts; use JSON mode for structured evidence.
|
|
66
|
+
// JSON-looking page text must never become an envelope, confirmation, or batch row.
|
|
67
|
+
const { plainText, textOutput } = getEnvelopeOutputMode(options);
|
|
68
|
+
if (textOutput) {
|
|
69
|
+
return { envelope: { success: true, data: stdout } };
|
|
49
70
|
}
|
|
50
71
|
const trimmed = stdout.trim();
|
|
51
|
-
const plainText = typeof options !== "string" && options.plainText === true;
|
|
52
72
|
if (trimmed.length === 0 && !plainText) {
|
|
53
73
|
return { parseError: "agent-browser returned no JSON output." };
|
|
54
74
|
}
|
|
55
75
|
try {
|
|
56
76
|
const parsed = JSON.parse(trimmed);
|
|
57
|
-
|
|
58
|
-
return { envelope: { success: parsed.every((item) => !isRecord(item) || item.success !== false), data: parsed } };
|
|
59
|
-
}
|
|
60
|
-
if (!isRecord(parsed)) {
|
|
61
|
-
return { parseError: "agent-browser returned JSON, but it was not an object envelope." };
|
|
62
|
-
}
|
|
63
|
-
const keys = Object.keys(parsed);
|
|
64
|
-
if (keys.length === 1 && keys[0] === "plugins" && Array.isArray(parsed.plugins)) {
|
|
65
|
-
return { envelope: { success: true, data: { plugins: parsed.plugins } } };
|
|
66
|
-
}
|
|
67
|
-
if (keys.length === 1 && keys[0] === "plugin" && isRecord(parsed.plugin) && !Array.isArray(parsed.plugin)) {
|
|
68
|
-
return { envelope: { success: true, data: { plugin: parsed.plugin } } };
|
|
69
|
-
}
|
|
70
|
-
if (!("success" in parsed)) {
|
|
71
|
-
return { parseError: "agent-browser returned an invalid JSON envelope: missing boolean success field." };
|
|
72
|
-
}
|
|
73
|
-
if (typeof parsed.success !== "boolean") {
|
|
74
|
-
return { parseError: "agent-browser returned an invalid JSON envelope: success field must be boolean." };
|
|
75
|
-
}
|
|
76
|
-
if (!Object.hasOwn(parsed, "data")) {
|
|
77
|
-
const { success, error, ...topLevelData } = parsed;
|
|
78
|
-
if (Object.keys(topLevelData).length > 0) {
|
|
79
|
-
return { envelope: { error, success, data: topLevelData } };
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return { envelope: parsed };
|
|
77
|
+
return decodeAgentBrowserEnvelope(parsed);
|
|
83
78
|
}
|
|
84
79
|
catch (error) {
|
|
85
|
-
if (plainText)
|
|
80
|
+
if (plainText) {
|
|
86
81
|
return { envelope: { success: true, data: trimmed } };
|
|
87
|
-
|
|
82
|
+
}
|
|
83
|
+
const message = error instanceof Error ? error.message : stringifyUnknown(error);
|
|
88
84
|
return { parseError: `agent-browser returned invalid JSON: ${message}` };
|
|
89
85
|
}
|
|
90
86
|
}
|
|
@@ -92,14 +88,14 @@ function buildInvocationLabel(options) {
|
|
|
92
88
|
if (options.effectiveArgs && options.effectiveArgs.length > 0) {
|
|
93
89
|
return `agent-browser ${options.effectiveArgs.join(" ")}`;
|
|
94
90
|
}
|
|
95
|
-
if (options.command && options.command.trim().length > 0) {
|
|
91
|
+
if (options.command !== undefined && options.command.trim().length > 0) {
|
|
96
92
|
return `agent-browser ${options.command.trim()}`;
|
|
97
93
|
}
|
|
98
94
|
return "agent-browser";
|
|
99
95
|
}
|
|
100
96
|
function appendWrapperRecoveryHint(message, wrapperRecoveryHint) {
|
|
101
97
|
const hint = wrapperRecoveryHint?.trim();
|
|
102
|
-
return hint ? `${message}\n${hint}` : message;
|
|
98
|
+
return hint !== undefined && hint.length > 0 ? `${message}\n${hint}` : message;
|
|
103
99
|
}
|
|
104
100
|
function buildFailureFallback(options) {
|
|
105
101
|
const invocation = buildInvocationLabel(options);
|
|
@@ -111,7 +107,9 @@ function buildExitCodeFallback(options) {
|
|
|
111
107
|
return appendWrapperRecoveryHint(`${invocation} exited with code ${options.exitCode}.`, options.wrapperRecoveryHint);
|
|
112
108
|
}
|
|
113
109
|
function buildWatchdogTimeoutMessage(options) {
|
|
114
|
-
const timeoutText = options.timeoutMs === undefined
|
|
110
|
+
const timeoutText = options.timeoutMs === undefined
|
|
111
|
+
? "the wrapper watchdog"
|
|
112
|
+
: `the ${options.timeoutMs}ms wrapper watchdog`;
|
|
115
113
|
const ipcTiming = options.timeoutMs !== undefined && options.timeoutMs <= 30_000
|
|
116
114
|
? "before the upstream CLI entered its 30s IPC retry path"
|
|
117
115
|
: "after waiting beyond the upstream CLI's 30s IPC retry window";
|
|
@@ -126,7 +124,7 @@ function isUpstreamIpcReadTimeoutMessage(message) {
|
|
|
126
124
|
function buildUpstreamIpcReadTimeoutMessage() {
|
|
127
125
|
return [
|
|
128
126
|
"agent-browser hit the upstream CLI 30s IPC read timeout while waiting for the daemon response.",
|
|
129
|
-
|
|
127
|
+
'The daemon may still be alive; do not blindly retry a non-idempotent command. Prefer a shorter command, split long waits, or retry with sessionMode: "fresh" after checking tab list.',
|
|
130
128
|
].join(" ");
|
|
131
129
|
}
|
|
132
130
|
function maybeAppendStaleRefHint(message, args) {
|
|
@@ -136,36 +134,65 @@ function maybeAppendStaleRefHint(message, args) {
|
|
|
136
134
|
}
|
|
137
135
|
return [
|
|
138
136
|
message,
|
|
139
|
-
|
|
137
|
+
'This @ref may be stale after navigation, scrolling, or a DOM update. Run `agent_browser` with `{ "args": ["snapshot", "-i"] }` again and retry with a current ref, or use a stable `find` locator.',
|
|
140
138
|
].join("\n");
|
|
141
139
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
if (plainTextInspection)
|
|
145
|
-
return undefined;
|
|
146
|
-
if (timedOut)
|
|
140
|
+
function getTransportErrorText(options) {
|
|
141
|
+
if (options.timedOut === true) {
|
|
147
142
|
return buildWatchdogTimeoutMessage(options);
|
|
148
|
-
|
|
143
|
+
}
|
|
144
|
+
if (options.aborted) {
|
|
149
145
|
return "agent-browser was aborted.";
|
|
150
|
-
if (spawnError)
|
|
151
|
-
return spawnError.message;
|
|
152
|
-
if (parseError)
|
|
153
|
-
return parseError;
|
|
154
|
-
if (envelope?.success === false) {
|
|
155
|
-
const explicitErrorText = extractEnvelopeErrorText(envelope.error);
|
|
156
|
-
if ((hasStructuredBatchStepFailure(envelope.data) || detectConfirmationRequired(envelope.data)) && explicitErrorText === undefined) {
|
|
157
|
-
return undefined;
|
|
158
|
-
}
|
|
159
|
-
const envelopeErrorText = explicitErrorText
|
|
160
|
-
?? extractEnvelopeErrorText(typeof envelope.data === "string" ? envelope.data : isRecord(envelope.data) ? envelope.data.error : undefined);
|
|
161
|
-
if (envelopeErrorText && isUpstreamIpcReadTimeoutMessage(envelopeErrorText)) {
|
|
162
|
-
return buildUpstreamIpcReadTimeoutMessage();
|
|
163
|
-
}
|
|
164
|
-
const fallback = envelopeErrorText ?? (stderr.trim() || buildFailureFallback(options));
|
|
165
|
-
return maybeAppendStaleRefHint(fallback, options.staleRefArgs ?? options.effectiveArgs);
|
|
166
146
|
}
|
|
167
|
-
if (
|
|
168
|
-
return
|
|
147
|
+
if (options.spawnError) {
|
|
148
|
+
return options.spawnError.message;
|
|
149
|
+
}
|
|
150
|
+
if ((options.parseError ?? "") !== "") {
|
|
151
|
+
return options.exitCode !== 0 && options.stderr.trim().length > 0
|
|
152
|
+
? options.stderr.trim()
|
|
153
|
+
: options.parseError;
|
|
154
|
+
}
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
157
|
+
function getEnvelopeDataError(data) {
|
|
158
|
+
if (typeof data === "string") {
|
|
159
|
+
return data;
|
|
160
|
+
}
|
|
161
|
+
return isRecord(data) ? data.error : undefined;
|
|
162
|
+
}
|
|
163
|
+
function getFailedEnvelopeFallback(options, errorText) {
|
|
164
|
+
const stderr = options.stderr.trim();
|
|
165
|
+
return errorText ?? (stderr.length > 0 ? stderr : buildFailureFallback(options));
|
|
166
|
+
}
|
|
167
|
+
function getFailedEnvelopeErrorText(options, envelope) {
|
|
168
|
+
const explicitErrorText = extractEnvelopeErrorText(envelope.error);
|
|
169
|
+
if ((hasStructuredBatchStepFailure(envelope.data) || detectConfirmationRequired(envelope.data)) &&
|
|
170
|
+
explicitErrorText === undefined) {
|
|
171
|
+
return undefined;
|
|
172
|
+
}
|
|
173
|
+
const envelopeErrorText = explicitErrorText ?? extractEnvelopeErrorText(getEnvelopeDataError(envelope.data));
|
|
174
|
+
if (envelopeErrorText !== undefined &&
|
|
175
|
+
envelopeErrorText.length > 0 &&
|
|
176
|
+
isUpstreamIpcReadTimeoutMessage(envelopeErrorText)) {
|
|
177
|
+
return buildUpstreamIpcReadTimeoutMessage();
|
|
178
|
+
}
|
|
179
|
+
const fallback = getFailedEnvelopeFallback(options, envelopeErrorText);
|
|
180
|
+
return maybeAppendStaleRefHint(fallback, options.staleRefArgs ?? options.effectiveArgs);
|
|
181
|
+
}
|
|
182
|
+
export function getAgentBrowserErrorText(options) {
|
|
183
|
+
if (options.plainTextInspection) {
|
|
184
|
+
return undefined;
|
|
185
|
+
}
|
|
186
|
+
const transportErrorText = getTransportErrorText(options);
|
|
187
|
+
if (transportErrorText !== undefined) {
|
|
188
|
+
return transportErrorText;
|
|
189
|
+
}
|
|
190
|
+
if (options.envelope?.success === false) {
|
|
191
|
+
return getFailedEnvelopeErrorText(options, options.envelope);
|
|
192
|
+
}
|
|
193
|
+
if (options.exitCode !== 0) {
|
|
194
|
+
const stderr = options.stderr.trim();
|
|
195
|
+
return stderr.length > 0 ? stderr : buildExitCodeFallback(options);
|
|
169
196
|
}
|
|
170
197
|
return undefined;
|
|
171
198
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|