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
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { inspectElectronLaunchStatus } from "../../electron/cleanup.js";
|
|
2
|
+
import { getAgentBrowserProcessEnvironment } from "../../process-environment.js";
|
|
3
|
+
import { buildAgentBrowserNextActions } from "../../results/action-recommendations.js";
|
|
4
|
+
import { buildAgentBrowserResultCategoryDetails } from "../../results/categories.js";
|
|
5
|
+
import { appendUniqueAgentBrowserNextActions } from "../../results/next-actions.js";
|
|
6
|
+
import { redactSensitiveText } from "../../runtime-redaction.js";
|
|
7
|
+
import { getSessionPageStateKey } from "../../session-page-state.js";
|
|
8
|
+
import { buildElectronHostFailureResult, formatElectronTargetLines, redactToolDetails, } from "../browser-run/final-result.js";
|
|
9
|
+
import { buildElectronIdentifiers, buildElectronMismatchNextActions, buildElectronSessionMismatch, formatElectronSessionMismatchText, } from "../browser-run/session-state.js";
|
|
10
|
+
import { selectElectronRecords } from "./branch.js";
|
|
11
|
+
import { collectOwnedElectronManagedSessionTarget } from "./policy.js";
|
|
12
|
+
function pidStatusText(pidAlive) {
|
|
13
|
+
if (pidAlive === undefined) {
|
|
14
|
+
return "";
|
|
15
|
+
}
|
|
16
|
+
return pidAlive ? ", pid alive" : ", pid dead";
|
|
17
|
+
}
|
|
18
|
+
function formatLaunchHeadline(status, record) {
|
|
19
|
+
const sessionName = record?.sessionName;
|
|
20
|
+
const sessionText = sessionName !== undefined && sessionName.length > 0 ? `, sessionName ${sessionName}` : "";
|
|
21
|
+
const historyText = status.cleanupState === "cleaned" ? "; historical cleaned launch record" : "";
|
|
22
|
+
return `- ${status.launchId}: ${record?.appName ?? "Electron launch"}${sessionText}${historyText}; ${status.portAlive ? "debug port alive" : "debug port dead"}${pidStatusText(status.pidAlive)} (port ${status.port})`;
|
|
23
|
+
}
|
|
24
|
+
function formatLaunchStatus(status, record, managedSession) {
|
|
25
|
+
const sessionName = record?.sessionName;
|
|
26
|
+
const lines = [
|
|
27
|
+
formatLaunchHeadline(status, record),
|
|
28
|
+
` Tracked profile path: ${status.userDataDirState}.`,
|
|
29
|
+
` Identifiers: launchId ${status.launchId}; sessionName ${sessionName ?? "not attached"}.`,
|
|
30
|
+
...formatElectronTargetLines(status.targets, 4).map((line) => ` ${line}`),
|
|
31
|
+
];
|
|
32
|
+
if (managedSession?.error !== undefined && managedSession.error.length > 0) {
|
|
33
|
+
lines.push(` Managed session warning: ${managedSession.error}`);
|
|
34
|
+
}
|
|
35
|
+
return lines;
|
|
36
|
+
}
|
|
37
|
+
function formatElectronStatusVisibleText(options) {
|
|
38
|
+
if (options.statuses.length === 0) {
|
|
39
|
+
return "Electron status: no active wrapper-tracked launches.";
|
|
40
|
+
}
|
|
41
|
+
const recordsByLaunchId = new Map(options.records.map((record) => [record.launchId, record]));
|
|
42
|
+
const sessionsByName = new Map(options.managedSessions.map((session) => [session.sessionName, session]));
|
|
43
|
+
const lines = [`Electron status: ${options.statuses.length} wrapper-tracked launch(es).`];
|
|
44
|
+
for (const status of options.statuses) {
|
|
45
|
+
const record = recordsByLaunchId.get(status.launchId);
|
|
46
|
+
const name = record?.sessionName;
|
|
47
|
+
const session = name !== undefined && name.length > 0 ? sessionsByName.get(name) : undefined;
|
|
48
|
+
lines.push(...formatLaunchStatus(status, record, session));
|
|
49
|
+
}
|
|
50
|
+
for (const mismatch of options.mismatches) {
|
|
51
|
+
lines.push("", formatElectronSessionMismatchText(mismatch));
|
|
52
|
+
}
|
|
53
|
+
return lines.join("\n");
|
|
54
|
+
}
|
|
55
|
+
function statusNextActions(options) {
|
|
56
|
+
const base = options.records.flatMap((record) => buildAgentBrowserNextActions({
|
|
57
|
+
electron: {
|
|
58
|
+
launchId: record.launchId,
|
|
59
|
+
sessionName: record.sessionName,
|
|
60
|
+
status: record.cleanupState,
|
|
61
|
+
},
|
|
62
|
+
resultCategory: "success",
|
|
63
|
+
successCategory: "completed",
|
|
64
|
+
}) ?? []);
|
|
65
|
+
const mismatch = options.mismatches.flatMap((row) => {
|
|
66
|
+
const record = options.records.find((candidate) => candidate.launchId === row.launchId);
|
|
67
|
+
return record ? buildElectronMismatchNextActions(record, row.liveTarget) : [];
|
|
68
|
+
});
|
|
69
|
+
return options.mismatches.length > 0
|
|
70
|
+
? appendUniqueAgentBrowserNextActions([...mismatch], base)
|
|
71
|
+
: appendUniqueAgentBrowserNextActions([...base], mismatch);
|
|
72
|
+
}
|
|
73
|
+
function buildElectronStatusResult(options) {
|
|
74
|
+
const nextActions = statusNextActions(options);
|
|
75
|
+
const soleRecord = options.records.length === 1 ? options.records[0] : undefined;
|
|
76
|
+
const details = {
|
|
77
|
+
args: [],
|
|
78
|
+
compiledElectron: options.compiledElectron,
|
|
79
|
+
electron: {
|
|
80
|
+
action: "status",
|
|
81
|
+
identifierList: options.records.length > 1 ? options.records.map(buildElectronIdentifiers) : undefined,
|
|
82
|
+
identifiers: soleRecord ? buildElectronIdentifiers(soleRecord) : undefined,
|
|
83
|
+
launches: options.records,
|
|
84
|
+
managedSession: options.managedSessions.length === 1 ? options.managedSessions[0] : undefined,
|
|
85
|
+
managedSessions: options.managedSessions.length > 0 ? options.managedSessions : undefined,
|
|
86
|
+
sessionMismatch: options.mismatches.length === 1 ? options.mismatches[0] : undefined,
|
|
87
|
+
sessionMismatches: options.mismatches.length > 1 ? options.mismatches : undefined,
|
|
88
|
+
status: "succeeded",
|
|
89
|
+
statuses: options.statuses,
|
|
90
|
+
targets: options.statuses.flatMap((status) => status.targets),
|
|
91
|
+
},
|
|
92
|
+
nextActions: nextActions.length > 0 ? nextActions : undefined,
|
|
93
|
+
...buildAgentBrowserResultCategoryDetails({ args: [], succeeded: true }),
|
|
94
|
+
summary: options.statuses.length === 0
|
|
95
|
+
? "Electron status found no active wrapper-tracked launches."
|
|
96
|
+
: `Electron status inspected ${options.statuses.length} launch(es).`,
|
|
97
|
+
};
|
|
98
|
+
return {
|
|
99
|
+
content: [
|
|
100
|
+
{ type: "text", text: redactSensitiveText(formatElectronStatusVisibleText(options)) },
|
|
101
|
+
],
|
|
102
|
+
details: redactToolDetails(details, []),
|
|
103
|
+
isError: false,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function collectStatusManagedSessions(options, records, timeoutMs) {
|
|
107
|
+
return Promise.all(records
|
|
108
|
+
.filter((record) => typeof record.sessionName === "string")
|
|
109
|
+
.map((record) => {
|
|
110
|
+
const key = getSessionPageStateKey(record.sessionName, record.namespace) ?? record.sessionName;
|
|
111
|
+
const owner = options.ownedManagedSessions.get(key);
|
|
112
|
+
return collectOwnedElectronManagedSessionTarget({
|
|
113
|
+
confirmActions: options.sessionPageState.get(key).confirmActions ??
|
|
114
|
+
getAgentBrowserProcessEnvironment().AGENT_BROWSER_CONFIRM_ACTIONS,
|
|
115
|
+
cwd: options.cwd,
|
|
116
|
+
electronLaunchRecord: record,
|
|
117
|
+
headedManagedAutosaveDisabled: owner?.headedManagedAutosaveDisabled,
|
|
118
|
+
headedManagedAutosaveInterval: owner?.headedManagedAutosaveInterval,
|
|
119
|
+
namespace: record.namespace,
|
|
120
|
+
restoreState: options.managedSessionRestoreState,
|
|
121
|
+
sessionName: record.sessionName,
|
|
122
|
+
signal: options.signal,
|
|
123
|
+
timeoutMs,
|
|
124
|
+
});
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
function statusMismatches(records, statuses, managedSessions) {
|
|
128
|
+
return managedSessions
|
|
129
|
+
.map((session) => {
|
|
130
|
+
const record = records.find((candidate) => candidate.sessionName === session.sessionName &&
|
|
131
|
+
candidate.namespace === session.namespace);
|
|
132
|
+
const status = record
|
|
133
|
+
? statuses.find((candidate) => candidate.launchId === record.launchId)
|
|
134
|
+
: undefined;
|
|
135
|
+
return record && status
|
|
136
|
+
? buildElectronSessionMismatch({
|
|
137
|
+
managedSession: session,
|
|
138
|
+
record,
|
|
139
|
+
statusTargets: status.targets,
|
|
140
|
+
})
|
|
141
|
+
: undefined;
|
|
142
|
+
})
|
|
143
|
+
.filter((mismatch) => mismatch !== undefined);
|
|
144
|
+
}
|
|
145
|
+
export async function inspectElectronHostLaunches(options, compiledElectron, visibleInput) {
|
|
146
|
+
const selection = selectElectronRecords(compiledElectron, options.electronLaunchRecords);
|
|
147
|
+
if (selection.error !== undefined && selection.error.length > 0) {
|
|
148
|
+
return buildElectronHostFailureResult({
|
|
149
|
+
compiledElectron: visibleInput,
|
|
150
|
+
errorText: selection.error,
|
|
151
|
+
failureCategory: "validation-error",
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
const records = selection.records ?? [];
|
|
155
|
+
const statuses = await Promise.all(records.map((record) => inspectElectronLaunchStatus(record)));
|
|
156
|
+
const managedSessions = await collectStatusManagedSessions(options, records, compiledElectron.timeoutMs);
|
|
157
|
+
const mismatches = statusMismatches(records, statuses, managedSessions);
|
|
158
|
+
return buildElectronStatusResult({
|
|
159
|
+
compiledElectron: visibleInput,
|
|
160
|
+
managedSessions,
|
|
161
|
+
mismatches,
|
|
162
|
+
records,
|
|
163
|
+
statuses,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
-
import { getAgentBrowserSessionIdentityKey, isAgentBrowserSessionIdentityKeyInNamespace } from "../argv-grammar.js";
|
|
2
|
+
import { getAgentBrowserSessionIdentityKey, isAgentBrowserSessionIdentityKeyInNamespace, } from "../argv-grammar.js";
|
|
3
3
|
// Serializes managed-session read/modify/write work so overlapping tool calls cannot promote stale state or close an in-use session.
|
|
4
4
|
export class AsyncExecutionQueue {
|
|
5
5
|
tail = Promise.resolve();
|
|
6
6
|
active = new AsyncLocalStorage();
|
|
7
|
-
isCurrent() {
|
|
7
|
+
isCurrent() {
|
|
8
|
+
return this.active.getStore()?.active === true;
|
|
9
|
+
}
|
|
8
10
|
run(work, signal, barrier = Promise.resolve()) {
|
|
9
11
|
if (this.isCurrent()) {
|
|
10
12
|
signal?.throwIfAborted();
|
|
@@ -16,11 +18,16 @@ export class AsyncExecutionQueue {
|
|
|
16
18
|
release = resolve;
|
|
17
19
|
});
|
|
18
20
|
let rejectWaiting;
|
|
19
|
-
const cancelled = new Promise((_resolve, reject) => {
|
|
20
|
-
|
|
21
|
+
const cancelled = new Promise((_resolve, reject) => {
|
|
22
|
+
rejectWaiting = reject;
|
|
23
|
+
});
|
|
24
|
+
const abortWaiting = () => {
|
|
25
|
+
rejectWaiting(signal?.reason);
|
|
26
|
+
};
|
|
21
27
|
signal?.addEventListener("abort", abortWaiting, { once: true });
|
|
22
|
-
if (signal?.aborted)
|
|
28
|
+
if (signal?.aborted === true) {
|
|
23
29
|
abortWaiting();
|
|
30
|
+
}
|
|
24
31
|
const execution = (async () => {
|
|
25
32
|
await Promise.all([previous, barrier]);
|
|
26
33
|
signal?.removeEventListener("abort", abortWaiting);
|
|
@@ -46,8 +53,9 @@ export class KeyedAsyncExecutionQueue {
|
|
|
46
53
|
entries = new Map();
|
|
47
54
|
async run(key, namespace, work, signal) {
|
|
48
55
|
const entry = this.entries.get(key) ?? { queue: new AsyncExecutionQueue(), users: 0 };
|
|
49
|
-
if (entry.queue.isCurrent())
|
|
56
|
+
if (entry.queue.isCurrent()) {
|
|
50
57
|
return work();
|
|
58
|
+
}
|
|
51
59
|
const barrier = this.barriers.get(getAgentBrowserSessionIdentityKey("", namespace)) ?? Promise.resolve();
|
|
52
60
|
entry.users += 1;
|
|
53
61
|
this.entries.set(key, entry);
|
|
@@ -56,8 +64,9 @@ export class KeyedAsyncExecutionQueue {
|
|
|
56
64
|
}
|
|
57
65
|
finally {
|
|
58
66
|
entry.users -= 1;
|
|
59
|
-
if (entry.users === 0 && this.entries.get(key) === entry)
|
|
67
|
+
if (entry.users === 0 && this.entries.get(key) === entry) {
|
|
60
68
|
this.entries.delete(key);
|
|
69
|
+
}
|
|
61
70
|
}
|
|
62
71
|
}
|
|
63
72
|
async runExclusive(namespace, work) {
|
|
@@ -71,7 +80,9 @@ export class KeyedAsyncExecutionQueue {
|
|
|
71
80
|
this.barriers.set(namespaceKey, barrier);
|
|
72
81
|
const drains = [...this.entries]
|
|
73
82
|
.filter(([key]) => isAgentBrowserSessionIdentityKeyInNamespace(key, namespace))
|
|
74
|
-
.map(([, { queue }]) => queue.run(async () =>
|
|
83
|
+
.map(([, { queue }]) => queue.run(async () => {
|
|
84
|
+
// This queued marker only waits for earlier work; it has no browser operation.
|
|
85
|
+
}));
|
|
75
86
|
await previous;
|
|
76
87
|
await Promise.all(drains);
|
|
77
88
|
try {
|
|
@@ -79,8 +90,9 @@ export class KeyedAsyncExecutionQueue {
|
|
|
79
90
|
}
|
|
80
91
|
finally {
|
|
81
92
|
release();
|
|
82
|
-
if (this.barriers.get(namespaceKey) === barrier)
|
|
93
|
+
if (this.barriers.get(namespaceKey) === barrier) {
|
|
83
94
|
this.barriers.delete(namespaceKey);
|
|
95
|
+
}
|
|
84
96
|
}
|
|
85
97
|
}
|
|
86
98
|
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { extractUpstreamCommandTokens, validateToolArgs } from "../runtime.js";
|
|
2
|
+
import { isCloseAllCommand, isCloseCommand } from "../command-taxonomy.js";
|
|
3
|
+
import { canonicalizeExplicitArtifactDestination, getExplicitArtifactDestination, getRecordContactSheetDestination, } from "./browser-run/artifact-paths.js";
|
|
4
|
+
import { parseBatchCommandArgument, parseUserBatchStdin } from "./batch-stdin.js";
|
|
5
|
+
import { normalizeRequestedOutputPath } from "./output-file.js";
|
|
6
|
+
function parseRawArtifactSteps(commands) {
|
|
7
|
+
const steps = [];
|
|
8
|
+
for (const command of commands) {
|
|
9
|
+
if (command === "--bail") {
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
const parsed = parseBatchCommandArgument(command);
|
|
13
|
+
if ((parsed.error !== undefined && parsed.error !== "") || !parsed.step) {
|
|
14
|
+
return {
|
|
15
|
+
batch: true,
|
|
16
|
+
error: `Unsupported batch step ${steps.length + 1}: ${parsed.error ?? "command could not be parsed safely"}`,
|
|
17
|
+
steps,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
steps.push(parsed.step);
|
|
21
|
+
}
|
|
22
|
+
return { batch: true, steps };
|
|
23
|
+
}
|
|
24
|
+
export function getArtifactCommandSteps(args, stdin) {
|
|
25
|
+
const tokens = extractUpstreamCommandTokens([...args]);
|
|
26
|
+
if (tokens[0] !== "batch") {
|
|
27
|
+
return { batch: false, steps: tokens.length > 0 ? [tokens] : [] };
|
|
28
|
+
}
|
|
29
|
+
const parsed = parseRawArtifactSteps(tokens.slice(1));
|
|
30
|
+
if (parsed.error !== undefined && parsed.error !== "") {
|
|
31
|
+
return parsed;
|
|
32
|
+
}
|
|
33
|
+
// Raw native rows exclusively win over stdin, including artifact and lifecycle preflight.
|
|
34
|
+
if (parsed.steps.length > 0) {
|
|
35
|
+
return parsed;
|
|
36
|
+
}
|
|
37
|
+
const input = parseUserBatchStdin(stdin);
|
|
38
|
+
return input.error !== undefined && input.error !== ""
|
|
39
|
+
? { batch: true, error: input.error, steps: [] }
|
|
40
|
+
: { batch: true, steps: input.steps ?? [] };
|
|
41
|
+
}
|
|
42
|
+
class ArtifactPreflight {
|
|
43
|
+
options;
|
|
44
|
+
active = new Set();
|
|
45
|
+
destinations = new Map();
|
|
46
|
+
plan;
|
|
47
|
+
canonicalOutputPath;
|
|
48
|
+
sawClose = false;
|
|
49
|
+
constructor(options) {
|
|
50
|
+
this.options = options;
|
|
51
|
+
this.plan = getArtifactCommandSteps(options.args, options.stdin);
|
|
52
|
+
}
|
|
53
|
+
cleanupOnly() {
|
|
54
|
+
return (this.plan.steps.length > 0 &&
|
|
55
|
+
this.plan.steps.every(([command, subcommand]) => isCloseCommand(command) || (command === "record" && subcommand === "stop")));
|
|
56
|
+
}
|
|
57
|
+
reserveActiveDestinations() {
|
|
58
|
+
for (const reservation of this.options.activeRecordingReservations ?? []) {
|
|
59
|
+
try {
|
|
60
|
+
this.active.add(canonicalizeExplicitArtifactDestination(reservation.cwd, reservation.absolutePath));
|
|
61
|
+
if (reservation.contactSheetPath !== undefined && reservation.contactSheetPath !== "") {
|
|
62
|
+
this.active.add(canonicalizeExplicitArtifactDestination(reservation.cwd, reservation.contactSheetPath));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
if (!this.cleanupOnly()) {
|
|
67
|
+
return error instanceof Error
|
|
68
|
+
? error.message
|
|
69
|
+
: "An active recording destination could not be resolved safely.";
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
validateOutputPath() {
|
|
76
|
+
const path = this.options.outputPath;
|
|
77
|
+
if (path === undefined || path === "") {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
this.canonicalOutputPath = canonicalizeExplicitArtifactDestination(this.options.cwd, normalizeRequestedOutputPath(path));
|
|
82
|
+
if (this.active.has(this.canonicalOutputPath)) {
|
|
83
|
+
return `Unsupported outputPath: ${path} is reserved by an active recording. Stop that recording first or use a distinct path.`;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
return error instanceof Error
|
|
88
|
+
? error.message
|
|
89
|
+
: `outputPath ${path} could not be resolved safely.`;
|
|
90
|
+
}
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
validateBatchStep(step, index) {
|
|
94
|
+
if (!this.plan.batch) {
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
const error = validateToolArgs([...step], { batchStep: true });
|
|
98
|
+
if (error !== undefined && error !== "") {
|
|
99
|
+
return `Unsupported batch step ${index + 1}: ${error}`;
|
|
100
|
+
}
|
|
101
|
+
if (this.sawClose && step[0] === "record" && (step[1] === "start" || step[1] === "restart")) {
|
|
102
|
+
return `Unsupported batch step ${index + 1}: record ${step[1]} cannot follow close, quit, or exit in one upstream batch because upstream can report success without starting a recording. Split the close and recording into separate agent_browser calls.`;
|
|
103
|
+
}
|
|
104
|
+
if (isCloseCommand(step[0])) {
|
|
105
|
+
this.sawClose = true;
|
|
106
|
+
}
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
validateDestination(destination, index) {
|
|
110
|
+
let canonical;
|
|
111
|
+
try {
|
|
112
|
+
canonical = canonicalizeExplicitArtifactDestination(this.options.cwd, destination);
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
return error instanceof Error
|
|
116
|
+
? error.message
|
|
117
|
+
: `Artifact destination ${destination} could not be resolved safely.`;
|
|
118
|
+
}
|
|
119
|
+
if (this.canonicalOutputPath === canonical) {
|
|
120
|
+
return `Unsupported outputPath: ${this.options.outputPath ?? ""} resolves to the same destination as artifact path ${destination}. Use distinct paths so the tool-result JSON cannot overwrite the browser artifact.`;
|
|
121
|
+
}
|
|
122
|
+
if (this.active.has(canonical)) {
|
|
123
|
+
const prefix = this.plan.batch
|
|
124
|
+
? `Unsupported batch artifact destination in step ${index + 1}`
|
|
125
|
+
: "Unsupported artifact destination";
|
|
126
|
+
return `${prefix}: ${destination} is reserved by an active recording. Stop that recording first or use a distinct path.`;
|
|
127
|
+
}
|
|
128
|
+
const prior = this.destinations.get(canonical);
|
|
129
|
+
if (prior !== undefined) {
|
|
130
|
+
return `Unsupported batch artifact destination in step ${index + 1}: ${destination} is already written by step ${prior + 1}. Use distinct paths or split the batch so each artifact can be verified independently.`;
|
|
131
|
+
}
|
|
132
|
+
this.destinations.set(canonical, index);
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
validateStepDestinations(step, index) {
|
|
136
|
+
for (const destination of [
|
|
137
|
+
getExplicitArtifactDestination([...step]),
|
|
138
|
+
getRecordContactSheetDestination([...step]),
|
|
139
|
+
]) {
|
|
140
|
+
if (destination === undefined || destination === "") {
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
const failure = this.validateDestination(destination, index);
|
|
144
|
+
if (failure !== undefined && failure !== "") {
|
|
145
|
+
return failure;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return undefined;
|
|
149
|
+
}
|
|
150
|
+
validateStep(step, index) {
|
|
151
|
+
if (step.length === 0) {
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
const error = this.validateBatchStep(step, index);
|
|
155
|
+
if (error !== undefined && error !== "") {
|
|
156
|
+
return error;
|
|
157
|
+
}
|
|
158
|
+
const destinationFailure = this.validateStepDestinations(step, index);
|
|
159
|
+
if (destinationFailure !== undefined && destinationFailure !== "") {
|
|
160
|
+
return destinationFailure;
|
|
161
|
+
}
|
|
162
|
+
if (this.plan.batch && step[0] === "screenshot" && step.includes("--annotate")) {
|
|
163
|
+
return [
|
|
164
|
+
`Unsupported batch screenshot annotation in step ${index + 1}: put --annotate in top-level args, not inside the batch step.`,
|
|
165
|
+
`Use: { "args": ["--annotate", "batch"], "stdin": "[[\\"screenshot\\",\\"/path/to/image.png\\"]]" }`,
|
|
166
|
+
].join("\n");
|
|
167
|
+
}
|
|
168
|
+
return undefined;
|
|
169
|
+
}
|
|
170
|
+
run() {
|
|
171
|
+
const error = this.plan.error;
|
|
172
|
+
if (error !== undefined && error !== "") {
|
|
173
|
+
return error;
|
|
174
|
+
}
|
|
175
|
+
const activeError = this.reserveActiveDestinations();
|
|
176
|
+
if (activeError !== undefined && activeError !== "") {
|
|
177
|
+
return activeError;
|
|
178
|
+
}
|
|
179
|
+
const outputError = this.validateOutputPath();
|
|
180
|
+
if (outputError !== undefined && outputError !== "") {
|
|
181
|
+
return outputError;
|
|
182
|
+
}
|
|
183
|
+
for (const [index, step] of this.plan.steps.entries()) {
|
|
184
|
+
const failure = this.validateStep(step, index);
|
|
185
|
+
if (failure !== undefined && failure !== "") {
|
|
186
|
+
return failure;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
export function getArtifactPreflightValidationError(options) {
|
|
193
|
+
return new ArtifactPreflight(options).run();
|
|
194
|
+
}
|
|
195
|
+
export function commandClosesAllSessions(args, stdin) {
|
|
196
|
+
const parsed = getArtifactCommandSteps(args, stdin);
|
|
197
|
+
return ((parsed.error === undefined || parsed.error === "") && parsed.steps.some(isCloseAllCommand));
|
|
198
|
+
}
|
|
199
|
+
export function commandTouchesArtifactLifecycle(args, stdin, outputPath) {
|
|
200
|
+
if (outputPath !== undefined && outputPath !== "") {
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
const parsed = getArtifactCommandSteps(args, stdin);
|
|
204
|
+
if (parsed.error !== undefined && parsed.error !== "") {
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
return parsed.steps.some((step) => getExplicitArtifactDestination(step) !== undefined ||
|
|
208
|
+
step[0] === "record" ||
|
|
209
|
+
step[0] === "screenshot" ||
|
|
210
|
+
isCloseCommand(step[0]));
|
|
211
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { retirePendingRecordingManifestEntries } from "../results/artifact-manifest.js";
|
|
2
|
+
import { mergeBrowserRunArtifactManifest } from "./browser-run/artifact-merge.js";
|
|
3
|
+
import { AsyncExecutionQueue } from "./execution-queue.js";
|
|
4
|
+
/** One extension's artifact publication queue and bounded manifest. */
|
|
5
|
+
export class BrowserArtifacts {
|
|
6
|
+
pi;
|
|
7
|
+
queue = new AsyncExecutionQueue();
|
|
8
|
+
manifest;
|
|
9
|
+
constructor(pi) {
|
|
10
|
+
this.pi = pi;
|
|
11
|
+
}
|
|
12
|
+
commit(prior, rendered) {
|
|
13
|
+
this.manifest = mergeBrowserRunArtifactManifest(this.manifest, prior, rendered);
|
|
14
|
+
return this.manifest;
|
|
15
|
+
}
|
|
16
|
+
retireRecording(sessionName, namespace) {
|
|
17
|
+
const previous = this.manifest;
|
|
18
|
+
if (this.manifest) {
|
|
19
|
+
this.manifest = retirePendingRecordingManifestEntries(this.manifest, sessionName, namespace);
|
|
20
|
+
}
|
|
21
|
+
return this.manifest !== previous;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { getSuccessfulBatchCloseLifecycle } from "../batch-lifecycle.js";
|
|
2
|
+
import { getBrowserResultMessage } from "../browser-transcript.js";
|
|
3
|
+
import { extractExplicitNamespace, extractExplicitSessionName, deleteIdentityKeysInNamespace, } from "../argv-grammar.js";
|
|
4
|
+
import { extractUpstreamCommandTokens } from "../runtime.js";
|
|
5
|
+
import { isCloseCommand } from "../command-taxonomy.js";
|
|
6
|
+
import { isSuccessfulNativeConfirmedClose } from "../read-confirmation.js";
|
|
7
|
+
import { isRecord } from "../parsing.js";
|
|
8
|
+
import { getSessionContextKey } from "./browser-run/session-state.js";
|
|
9
|
+
import { getCleanupResultClosedManagedSessionIdentities } from "./extension-electron-ownership.js";
|
|
10
|
+
import { getToolResultArgs, getSuccessfulToolResult, detailsReportCloseAllApplied, isAttachedBrowserInvocation, } from "./extension-resource-replay.js";
|
|
11
|
+
function parseAttachmentRow(entry) {
|
|
12
|
+
const message = getBrowserResultMessage(entry);
|
|
13
|
+
const details = isRecord(message?.details) ? message.details : undefined;
|
|
14
|
+
if (!message || !details) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
const outcome = isRecord(details.managedSessionOutcome)
|
|
18
|
+
? details.managedSessionOutcome
|
|
19
|
+
: undefined;
|
|
20
|
+
const args = getToolResultArgs(details);
|
|
21
|
+
return {
|
|
22
|
+
details,
|
|
23
|
+
args,
|
|
24
|
+
succeeded: getSuccessfulToolResult(details, message),
|
|
25
|
+
batchCloseLifecycle: getSuccessfulBatchCloseLifecycle(details.batchSteps),
|
|
26
|
+
namespace: typeof details.namespace === "string" ? details.namespace : extractExplicitNamespace(args),
|
|
27
|
+
sessionName: typeof details.sessionName === "string"
|
|
28
|
+
? details.sessionName
|
|
29
|
+
: extractExplicitSessionName(args),
|
|
30
|
+
retainedFailedAttachment: details.attachedBrowserSession === true && outcome?.activeAfter === true,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
class AttachmentReplay {
|
|
34
|
+
keys = new Set();
|
|
35
|
+
cleanupElectron(row) {
|
|
36
|
+
const electron = isRecord(row.details.electron) ? row.details.electron : undefined;
|
|
37
|
+
const cleanup = isRecord(electron?.cleanup) ? electron.cleanup : undefined;
|
|
38
|
+
for (const result of Array.isArray(cleanup?.results) ? cleanup.results : []) {
|
|
39
|
+
for (const identity of getCleanupResultClosedManagedSessionIdentities(result, row.namespace)) {
|
|
40
|
+
this.keys.delete(getSessionContextKey(identity.sessionName, identity.namespace) ?? identity.sessionName);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
restoreCloseAll(row) {
|
|
45
|
+
if (!detailsReportCloseAllApplied(row.details, row.succeeded)) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
deleteIdentityKeysInNamespace(this.keys, row.namespace);
|
|
49
|
+
if (row.sessionName !== undefined &&
|
|
50
|
+
row.sessionName !== "" &&
|
|
51
|
+
row.details.attachedBrowserSession === true &&
|
|
52
|
+
row.batchCloseLifecycle?.endsClosed === false) {
|
|
53
|
+
this.keys.add(getSessionContextKey(row.sessionName, row.namespace) ?? row.sessionName);
|
|
54
|
+
}
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
closesAttachment(row) {
|
|
58
|
+
if (row.batchCloseLifecycle?.endsClosed === true) {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
const tokens = extractUpstreamCommandTokens([...row.args]);
|
|
62
|
+
const command = typeof row.details.command === "string" ? row.details.command : tokens[0];
|
|
63
|
+
return (row.succeeded &&
|
|
64
|
+
(isCloseCommand(command) || isSuccessfulNativeConfirmedClose(tokens, row.details.data)));
|
|
65
|
+
}
|
|
66
|
+
canRestore(row) {
|
|
67
|
+
return (row.succeeded || row.retainedFailedAttachment || row.batchCloseLifecycle?.endsClosed === true);
|
|
68
|
+
}
|
|
69
|
+
apply(row) {
|
|
70
|
+
this.cleanupElectron(row);
|
|
71
|
+
if (this.restoreCloseAll(row)) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (!this.canRestore(row)) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (row.sessionName === undefined || row.sessionName === "") {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const key = getSessionContextKey(row.sessionName, row.namespace) ?? row.sessionName;
|
|
81
|
+
if (this.closesAttachment(row)) {
|
|
82
|
+
this.keys.delete(key);
|
|
83
|
+
}
|
|
84
|
+
else if (row.details.attachedBrowserSession === true ||
|
|
85
|
+
isAttachedBrowserInvocation(row.args, {})) {
|
|
86
|
+
this.keys.add(key);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
export function restoreAttachedSessionKeysFromBranch(branch) {
|
|
91
|
+
const replay = new AttachmentReplay();
|
|
92
|
+
for (const entry of branch) {
|
|
93
|
+
const row = parseAttachmentRow(entry);
|
|
94
|
+
if (row) {
|
|
95
|
+
replay.apply(row);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return replay.keys;
|
|
99
|
+
}
|