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,284 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { platform as processPlatform } from "node:process";
|
|
3
|
+
import { spawn as crossSpawn } from "cross-spawn";
|
|
4
|
+
import { appendProcessOutputTail, ProcessStdout } from "./process-stdout.js";
|
|
5
|
+
import { getErrorCode, normalizeProcessError } from "./process-errors.js";
|
|
6
|
+
const MAX_BUFFERED_STDERR_CHARS = 32_000;
|
|
7
|
+
const EXIT_STDIO_GRACE_MS = 100;
|
|
8
|
+
async function terminateSpawnedChild(child, signal) {
|
|
9
|
+
if (processPlatform === "win32" && child.pid !== undefined && child.pid !== 0) {
|
|
10
|
+
// Observe taskkill before completing; keep the shell alive while traversing descendants.
|
|
11
|
+
const killed = await new Promise((resolve) => {
|
|
12
|
+
const killer = spawn("taskkill.exe", ["/PID", String(child.pid), "/T", "/F"], {
|
|
13
|
+
stdio: "ignore",
|
|
14
|
+
});
|
|
15
|
+
killer.once("error", () => resolve(false));
|
|
16
|
+
killer.once("close", (code) => resolve(code === 0));
|
|
17
|
+
});
|
|
18
|
+
if (killed) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
child.kill(signal);
|
|
23
|
+
}
|
|
24
|
+
export function resolveSpawnedChildExitCode(input) {
|
|
25
|
+
// Close -> wrapper timeout -> post-exit fallback -> spawn failure.
|
|
26
|
+
if (input.closeCode !== null && input.closeCode !== undefined) {
|
|
27
|
+
return input.closeCode;
|
|
28
|
+
}
|
|
29
|
+
if (input.timedOut) {
|
|
30
|
+
return 124;
|
|
31
|
+
}
|
|
32
|
+
if (input.useExitFallback && input.exitCode !== null && input.exitCode !== undefined) {
|
|
33
|
+
return input.exitCode;
|
|
34
|
+
}
|
|
35
|
+
return input.spawnError ? 127 : 0;
|
|
36
|
+
}
|
|
37
|
+
function destroySpawnedChildStreams(child) {
|
|
38
|
+
child.stdin.destroy();
|
|
39
|
+
child.stdout.destroy();
|
|
40
|
+
child.stderr.destroy();
|
|
41
|
+
}
|
|
42
|
+
class ChildCompletion {
|
|
43
|
+
complete;
|
|
44
|
+
context;
|
|
45
|
+
exited = false;
|
|
46
|
+
exitCode = null;
|
|
47
|
+
timer;
|
|
48
|
+
completed = false;
|
|
49
|
+
constructor(child, complete, context) {
|
|
50
|
+
this.complete = complete;
|
|
51
|
+
this.context = context;
|
|
52
|
+
child.once("exit", (code) => {
|
|
53
|
+
this.exited = true;
|
|
54
|
+
this.exitCode = code;
|
|
55
|
+
this.timer = setTimeout(() => {
|
|
56
|
+
destroySpawnedChildStreams(child);
|
|
57
|
+
this.finish();
|
|
58
|
+
}, EXIT_STDIO_GRACE_MS);
|
|
59
|
+
this.timer.unref();
|
|
60
|
+
});
|
|
61
|
+
child.once("close", (code) => {
|
|
62
|
+
this.finish(code);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
finish(closeCode) {
|
|
66
|
+
if (this.completed) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
this.completed = true;
|
|
70
|
+
this.clear();
|
|
71
|
+
const context = this.context();
|
|
72
|
+
this.complete(resolveSpawnedChildExitCode({
|
|
73
|
+
closeCode,
|
|
74
|
+
exitCode: this.exitCode,
|
|
75
|
+
useExitFallback: this.exited,
|
|
76
|
+
timedOut: context.timedOut,
|
|
77
|
+
spawnError: context.spawnError,
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
clear() {
|
|
81
|
+
if (this.timer) {
|
|
82
|
+
clearTimeout(this.timer);
|
|
83
|
+
this.timer = undefined;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
class BrowserChild {
|
|
88
|
+
options;
|
|
89
|
+
resolve;
|
|
90
|
+
aborted = false;
|
|
91
|
+
agentBrowserStarted = false;
|
|
92
|
+
settled = false;
|
|
93
|
+
spawnError;
|
|
94
|
+
stderr = "";
|
|
95
|
+
stdout = new ProcessStdout();
|
|
96
|
+
pendingTermination;
|
|
97
|
+
killTimer;
|
|
98
|
+
timeoutTimer;
|
|
99
|
+
abortListener;
|
|
100
|
+
timedOut = false;
|
|
101
|
+
completion;
|
|
102
|
+
child;
|
|
103
|
+
constructor(options, resolve) {
|
|
104
|
+
this.options = options;
|
|
105
|
+
this.resolve = resolve;
|
|
106
|
+
const spawnBrowser = processPlatform === "win32" &&
|
|
107
|
+
(options.stockLauncher === undefined || options.stockLauncher.length === 0)
|
|
108
|
+
? crossSpawn
|
|
109
|
+
: spawn;
|
|
110
|
+
this.child = spawnBrowser(options.stockLauncher ?? "agent-browser", options.args, {
|
|
111
|
+
cwd: options.cwd,
|
|
112
|
+
env: options.env,
|
|
113
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
start() {
|
|
117
|
+
this.observe();
|
|
118
|
+
this.watchBudget();
|
|
119
|
+
this.writeStdin();
|
|
120
|
+
}
|
|
121
|
+
started() {
|
|
122
|
+
this.agentBrowserStarted = true;
|
|
123
|
+
this.options.onStarted();
|
|
124
|
+
}
|
|
125
|
+
observe() {
|
|
126
|
+
const child = this.child;
|
|
127
|
+
if (processPlatform !== "win32") {
|
|
128
|
+
child.once("spawn", () => {
|
|
129
|
+
this.started();
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
child.stdin.on("error", (error) => {
|
|
133
|
+
this.recordStdinError(error);
|
|
134
|
+
});
|
|
135
|
+
child.once("error", (error) => {
|
|
136
|
+
this.spawnError = error;
|
|
137
|
+
this.finish(resolveSpawnedChildExitCode({
|
|
138
|
+
useExitFallback: false,
|
|
139
|
+
timedOut: this.timedOut,
|
|
140
|
+
spawnError: this.spawnError,
|
|
141
|
+
}));
|
|
142
|
+
});
|
|
143
|
+
this.completion = new ChildCompletion(child, (code) => {
|
|
144
|
+
this.finish(code);
|
|
145
|
+
}, () => ({ timedOut: this.timedOut, spawnError: this.spawnError }));
|
|
146
|
+
child.stdout.on("data", (chunk) => {
|
|
147
|
+
this.stdout.queue(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
148
|
+
});
|
|
149
|
+
child.stderr.on("data", (chunk) => {
|
|
150
|
+
this.stderr = appendProcessOutputTail(this.stderr, chunk.toString(), MAX_BUFFERED_STDERR_CHARS);
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
watchBudget() {
|
|
154
|
+
if (this.options.timeoutMs > 0) {
|
|
155
|
+
this.timeoutTimer = setTimeout(() => {
|
|
156
|
+
this.terminate("timeout");
|
|
157
|
+
}, this.options.timeoutMs);
|
|
158
|
+
this.timeoutTimer.unref();
|
|
159
|
+
}
|
|
160
|
+
const signal = this.options.signal;
|
|
161
|
+
if (signal) {
|
|
162
|
+
this.abortListener = () => {
|
|
163
|
+
this.terminate(this.options.deadlineExpired() ? "timeout" : "abort");
|
|
164
|
+
};
|
|
165
|
+
signal.addEventListener("abort", this.abortListener, { once: true });
|
|
166
|
+
if (signal.aborted) {
|
|
167
|
+
this.abortListener();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
terminate(reason) {
|
|
172
|
+
if (this.settled) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (reason === "abort") {
|
|
176
|
+
this.aborted = true;
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
this.timedOut = true;
|
|
180
|
+
}
|
|
181
|
+
if (this.pendingTermination) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
this.pendingTermination = terminateSpawnedChild(this.child, "SIGTERM");
|
|
185
|
+
// Windows taskkill already forces the tree; don't remove its root concurrently.
|
|
186
|
+
if (processPlatform !== "win32") {
|
|
187
|
+
this.killTimer = setTimeout(() => {
|
|
188
|
+
this.pendingTermination = terminateSpawnedChild(this.child, "SIGKILL");
|
|
189
|
+
}, 2_000);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
recordStdinError(error) {
|
|
193
|
+
const stdinError = normalizeProcessError(error);
|
|
194
|
+
const code = getErrorCode(stdinError);
|
|
195
|
+
if (code === "EPIPE" || code === "EOF" || code === "ERR_STREAM_DESTROYED") {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
this.spawnError ??= stdinError;
|
|
199
|
+
}
|
|
200
|
+
writeStdin() {
|
|
201
|
+
if (this.aborted || this.options.signal?.aborted === true) {
|
|
202
|
+
this.child.stdin.destroy();
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
try {
|
|
206
|
+
if (this.options.stdin !== undefined && this.options.stdin.length > 0) {
|
|
207
|
+
this.child.stdin.write(this.options.stdin);
|
|
208
|
+
}
|
|
209
|
+
this.child.stdin.end();
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
this.recordStdinError(error);
|
|
213
|
+
this.child.stdin.destroy();
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
finish(exitCode) {
|
|
217
|
+
if (this.settled) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
this.settled = true;
|
|
221
|
+
if (this.abortListener) {
|
|
222
|
+
this.options.signal?.removeEventListener("abort", this.abortListener);
|
|
223
|
+
this.abortListener = undefined;
|
|
224
|
+
}
|
|
225
|
+
if (this.killTimer) {
|
|
226
|
+
clearTimeout(this.killTimer);
|
|
227
|
+
}
|
|
228
|
+
if (this.timeoutTimer) {
|
|
229
|
+
clearTimeout(this.timeoutTimer);
|
|
230
|
+
}
|
|
231
|
+
this.completion?.clear();
|
|
232
|
+
// The completion path owns spill/termination rejection and always settles the outer operation.
|
|
233
|
+
this.collectResult(exitCode)
|
|
234
|
+
.then(this.resolve)
|
|
235
|
+
.catch((error) => {
|
|
236
|
+
this.spawnError ??= normalizeProcessError(error);
|
|
237
|
+
destroySpawnedChildStreams(this.child);
|
|
238
|
+
this.resolve(this.result(exitCode, ""));
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
async collectResult(exitCode) {
|
|
242
|
+
await this.stdout.drain();
|
|
243
|
+
await this.pendingTermination;
|
|
244
|
+
const output = await this.stdout.finish();
|
|
245
|
+
if (processPlatform === "win32" && !this.spawnError) {
|
|
246
|
+
this.started();
|
|
247
|
+
}
|
|
248
|
+
this.spawnError ??= output.error;
|
|
249
|
+
destroySpawnedChildStreams(this.child);
|
|
250
|
+
return this.result(exitCode, output.stdout, output.stdoutSpillPath);
|
|
251
|
+
}
|
|
252
|
+
result(exitCode, stdout, stdoutSpillPath) {
|
|
253
|
+
return {
|
|
254
|
+
aborted: this.aborted,
|
|
255
|
+
agentBrowserStarted: this.agentBrowserStarted,
|
|
256
|
+
exitCode,
|
|
257
|
+
spawnError: this.spawnError,
|
|
258
|
+
stderr: this.stderr,
|
|
259
|
+
stdout,
|
|
260
|
+
stdoutSpillPath,
|
|
261
|
+
timedOut: this.timedOut,
|
|
262
|
+
timeoutMs: this.timedOut ? this.options.timeoutMs : undefined,
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
export function runBrowserChild(options) {
|
|
267
|
+
return new Promise((resolve) => {
|
|
268
|
+
const error = options.policyError();
|
|
269
|
+
if (error !== undefined && error.length > 0) {
|
|
270
|
+
resolve({
|
|
271
|
+
aborted: false,
|
|
272
|
+
agentBrowserStarted: false,
|
|
273
|
+
exitCode: 1,
|
|
274
|
+
spawnError: new Error(error),
|
|
275
|
+
stderr: "",
|
|
276
|
+
stdout: "",
|
|
277
|
+
timedOut: false,
|
|
278
|
+
});
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
const child = new BrowserChild(options, resolve);
|
|
282
|
+
child.start();
|
|
283
|
+
});
|
|
284
|
+
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
2
|
import { rm } from "node:fs/promises";
|
|
3
|
+
import { getBooleanFlagValue } from "./argv-grammar.js";
|
|
3
4
|
import { writeSecureTempFile } from "./temp.js";
|
|
4
5
|
const isolatedAgentBrowserEnvironment = new AsyncLocalStorage();
|
|
5
6
|
const agentBrowserProcessEnvironment = new AsyncLocalStorage();
|
|
6
7
|
const PROXY_ENV_NAMES = new Set(["ALL_PROXY", "HTTPS_PROXY", "HTTP_PROXY", "NO_PROXY"]);
|
|
7
8
|
export function getAgentBrowserProcessEnvironment(baseEnv = process.env) {
|
|
8
9
|
const isolatedConfig = isolatedAgentBrowserEnvironment.getStore();
|
|
9
|
-
if (isolatedConfig === undefined)
|
|
10
|
-
return { ...baseEnv, ...agentBrowserProcessEnvironment.getStore() };
|
|
10
|
+
if (isolatedConfig === undefined) {
|
|
11
|
+
return { ...baseEnv, ...agentBrowserProcessEnvironment.getStore()?.env };
|
|
12
|
+
}
|
|
11
13
|
return {
|
|
12
14
|
...Object.fromEntries(Object.entries(baseEnv).filter(([name]) => {
|
|
13
15
|
const normalizedName = name.toUpperCase();
|
|
@@ -16,13 +18,27 @@ export function getAgentBrowserProcessEnvironment(baseEnv = process.env) {
|
|
|
16
18
|
AGENT_BROWSER_CONFIG: isolatedConfig,
|
|
17
19
|
};
|
|
18
20
|
}
|
|
19
|
-
export function
|
|
20
|
-
|
|
21
|
+
export function getAgentBrowserProcessArgs(args) {
|
|
22
|
+
if (isolatedAgentBrowserEnvironment.getStore() !== undefined) {
|
|
23
|
+
return [...args];
|
|
24
|
+
}
|
|
25
|
+
const overrides = agentBrowserProcessEnvironment.getStore()?.booleanArgs ?? [];
|
|
26
|
+
const missing = overrides.flatMap(([flag, value]) => getBooleanFlagValue(args, flag) === undefined ? [flag, value] : []);
|
|
27
|
+
return missing.length > 0 ? [...missing, ...args] : [...args];
|
|
28
|
+
}
|
|
29
|
+
export function withAgentBrowserProcessEnvironment(env, run, booleanArgs) {
|
|
30
|
+
const parent = agentBrowserProcessEnvironment.getStore();
|
|
31
|
+
return agentBrowserProcessEnvironment.run({ env: { ...parent?.env, ...env }, booleanArgs: booleanArgs ?? parent?.booleanArgs ?? [] }, run);
|
|
21
32
|
}
|
|
22
33
|
export async function withIsolatedAgentBrowserEnvironment(run) {
|
|
23
|
-
if (isolatedAgentBrowserEnvironment.getStore() !== undefined)
|
|
34
|
+
if (isolatedAgentBrowserEnvironment.getStore() !== undefined) {
|
|
24
35
|
return await run();
|
|
25
|
-
|
|
36
|
+
}
|
|
37
|
+
const path = await writeSecureTempFile({
|
|
38
|
+
content: "{}",
|
|
39
|
+
prefix: "script-config",
|
|
40
|
+
suffix: ".json",
|
|
41
|
+
});
|
|
26
42
|
try {
|
|
27
43
|
return await isolatedAgentBrowserEnvironment.run(path, run);
|
|
28
44
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { inspect } from "node:util";
|
|
2
|
+
import { isRecord } from "./parsing.js";
|
|
3
|
+
/** Read native errno evidence without asserting that an arbitrary caught value is an Error. */
|
|
4
|
+
export function normalizeProcessError(error) {
|
|
5
|
+
if (error instanceof Error) {
|
|
6
|
+
return error;
|
|
7
|
+
}
|
|
8
|
+
if (typeof error === "string") {
|
|
9
|
+
return new Error(error);
|
|
10
|
+
}
|
|
11
|
+
if (typeof error === "number" ||
|
|
12
|
+
typeof error === "boolean" ||
|
|
13
|
+
typeof error === "bigint" ||
|
|
14
|
+
typeof error === "symbol" ||
|
|
15
|
+
error === undefined ||
|
|
16
|
+
error === null) {
|
|
17
|
+
return new Error(String(error));
|
|
18
|
+
}
|
|
19
|
+
return new Error(inspect(error));
|
|
20
|
+
}
|
|
21
|
+
export function getErrorCode(error) {
|
|
22
|
+
return isRecord(error) && typeof error.code === "string" ? error.code : undefined;
|
|
23
|
+
}
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { execFile } from "node:child_process";
|
|
2
2
|
import { dirname, join, win32 } from "node:path";
|
|
3
|
+
export function getCurrentProcessUid() {
|
|
4
|
+
return typeof process.getuid === "function" ? process.getuid() : undefined;
|
|
5
|
+
}
|
|
3
6
|
const WINDOWS_PROCESS_START_IDENTITY_PREFIX = "win32-powershell-ticks-v1:";
|
|
4
7
|
// Native Windows PowerShell startup can exhaust the former five-second probe budget.
|
|
5
8
|
const PROCESS_START_IDENTITY_TIMEOUT_MS = process.platform === "win32" ? 10_000 : 5_000;
|
|
6
9
|
const DEFAULT_WINDOWS_SYSTEM_ROOT = "C:\\Windows";
|
|
7
10
|
export function buildProcessStartIdentityCommand(pid, platform = process.platform) {
|
|
8
|
-
if (!Number.isSafeInteger(pid) || pid <= 0)
|
|
11
|
+
if (!Number.isSafeInteger(pid) || pid <= 0) {
|
|
9
12
|
return undefined;
|
|
13
|
+
}
|
|
10
14
|
const configuredSystemRoot = process.env.SystemRoot;
|
|
11
|
-
const windowsSystemRoot = configuredSystemRoot &&
|
|
15
|
+
const windowsSystemRoot = configuredSystemRoot !== undefined &&
|
|
16
|
+
configuredSystemRoot.length > 0 &&
|
|
17
|
+
win32.isAbsolute(configuredSystemRoot)
|
|
12
18
|
? configuredSystemRoot
|
|
13
19
|
: DEFAULT_WINDOWS_SYSTEM_ROOT;
|
|
14
20
|
return platform === "win32"
|
|
@@ -28,28 +34,38 @@ export function buildProcessStartIdentityCommand(pid, platform = process.platfor
|
|
|
28
34
|
}
|
|
29
35
|
export function buildProcessStartIdentityCommands(pid, platform = process.platform) {
|
|
30
36
|
const primary = buildProcessStartIdentityCommand(pid, platform);
|
|
31
|
-
if (!primary)
|
|
37
|
+
if (!primary) {
|
|
32
38
|
return [];
|
|
39
|
+
}
|
|
33
40
|
return platform === "win32"
|
|
34
41
|
? [primary]
|
|
35
42
|
: [
|
|
36
43
|
primary,
|
|
37
44
|
...(platform === "android"
|
|
38
|
-
? [
|
|
39
|
-
|
|
45
|
+
? [
|
|
46
|
+
{ ...primary, file: "/bin/ps" },
|
|
47
|
+
{ ...primary, file: "/usr/bin/ps" },
|
|
48
|
+
]
|
|
49
|
+
: [
|
|
50
|
+
{ ...primary, file: "/usr/bin/ps" },
|
|
51
|
+
{ ...primary, file: "ps" },
|
|
52
|
+
]),
|
|
40
53
|
];
|
|
41
54
|
}
|
|
42
55
|
export function normalizeProcessStartIdentity(stdout) {
|
|
43
56
|
const trimmed = stdout.trim();
|
|
44
|
-
if (
|
|
57
|
+
if (trimmed.length === 0 || trimmed.includes("\0") || /[\r\n]/.test(trimmed)) {
|
|
45
58
|
return undefined;
|
|
59
|
+
}
|
|
46
60
|
return trimmed.replace(/\s+/g, " ");
|
|
47
61
|
}
|
|
48
62
|
let currentProcessStartIdentityPromise;
|
|
49
63
|
let currentProcessStartIdentity;
|
|
50
64
|
async function executeProcessStartIdentityCommand(command, budget = {}) {
|
|
51
|
-
if (budget.signal?.aborted
|
|
65
|
+
if (budget.signal?.aborted === true ||
|
|
66
|
+
(budget.deadline !== undefined && Date.now() >= budget.deadline)) {
|
|
52
67
|
return undefined;
|
|
68
|
+
}
|
|
53
69
|
const timeout = Math.max(1, Math.min(PROCESS_START_IDENTITY_TIMEOUT_MS, (budget.deadline ?? Infinity) - Date.now()));
|
|
54
70
|
return await new Promise((resolve) => {
|
|
55
71
|
execFile(command.file, command.args, { timeout, signal: budget.signal }, (error, stdout) => {
|
|
@@ -59,33 +75,49 @@ async function executeProcessStartIdentityCommand(command, budget = {}) {
|
|
|
59
75
|
}
|
|
60
76
|
export async function resolveProcessStartIdentityFromCommands(commands, execute = executeProcessStartIdentityCommand) {
|
|
61
77
|
for (const command of commands) {
|
|
78
|
+
// Fallback commands run only after the prior identity probe has failed.
|
|
79
|
+
// oxlint-disable-next-line no-await-in-loop
|
|
62
80
|
const identity = await execute(command);
|
|
63
|
-
if (identity)
|
|
81
|
+
if (identity !== undefined && identity.length > 0) {
|
|
64
82
|
return identity;
|
|
83
|
+
}
|
|
65
84
|
}
|
|
66
85
|
return undefined;
|
|
67
86
|
}
|
|
68
87
|
async function readUncachedProcessStartIdentity(pid, platform, budget) {
|
|
69
|
-
return await resolveProcessStartIdentityFromCommands(buildProcessStartIdentityCommands(pid, platform), command => executeProcessStartIdentityCommand(command, budget));
|
|
88
|
+
return await resolveProcessStartIdentityFromCommands(buildProcessStartIdentityCommands(pid, platform), (command) => executeProcessStartIdentityCommand(command, budget));
|
|
89
|
+
}
|
|
90
|
+
function identityBudgetExpired(budget) {
|
|
91
|
+
return (budget?.signal?.aborted === true ||
|
|
92
|
+
(budget?.deadline !== undefined && Date.now() >= budget.deadline));
|
|
70
93
|
}
|
|
71
94
|
export async function readProcessStartIdentity(pid, platform = process.platform, budget) {
|
|
72
|
-
if (
|
|
95
|
+
if (identityBudgetExpired(budget)) {
|
|
73
96
|
return undefined;
|
|
74
|
-
|
|
97
|
+
}
|
|
98
|
+
if (pid !== process.pid || platform !== process.platform) {
|
|
75
99
|
return await readUncachedProcessStartIdentity(pid, platform, budget);
|
|
76
|
-
|
|
100
|
+
}
|
|
101
|
+
if (currentProcessStartIdentity !== undefined && currentProcessStartIdentity.length > 0) {
|
|
77
102
|
return currentProcessStartIdentity;
|
|
103
|
+
}
|
|
78
104
|
if (budget) {
|
|
79
105
|
const identity = await readUncachedProcessStartIdentity(pid, platform, budget);
|
|
80
|
-
if (identity)
|
|
106
|
+
if (identity !== undefined && identity.length > 0) {
|
|
81
107
|
currentProcessStartIdentity = identity;
|
|
108
|
+
}
|
|
82
109
|
return identity;
|
|
83
110
|
}
|
|
111
|
+
return await readCachedProcessStartIdentity(pid, platform);
|
|
112
|
+
}
|
|
113
|
+
async function readCachedProcessStartIdentity(pid, platform) {
|
|
84
114
|
currentProcessStartIdentityPromise ??= readUncachedProcessStartIdentity(pid, platform).then((identity) => {
|
|
85
|
-
if (
|
|
115
|
+
if (identity === undefined || identity.length === 0) {
|
|
86
116
|
currentProcessStartIdentityPromise = undefined;
|
|
87
|
-
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
88
119
|
currentProcessStartIdentity = identity;
|
|
120
|
+
}
|
|
89
121
|
return identity;
|
|
90
122
|
});
|
|
91
123
|
return await currentProcessStartIdentityPromise;
|