pi-agent-browser-native 0.9.3 → 0.9.5
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 +106 -5
- package/README.md +58 -791
- package/dist/extensions/agent-browser/index.js +43101 -2031
- package/dist/extensions/agent-browser/lib/argv-descriptor.js +49 -26
- package/dist/extensions/agent-browser/lib/argv-grammar.js +82 -93
- package/dist/extensions/agent-browser/lib/bash-guard.js +129 -126
- package/dist/extensions/agent-browser/lib/batch-lifecycle.js +112 -51
- package/dist/extensions/agent-browser/lib/browser-execution-claim-codec.js +61 -0
- package/dist/extensions/agent-browser/lib/browser-execution-claim-storage.js +232 -0
- package/dist/extensions/agent-browser/lib/browser-execution-claims.js +202 -0
- package/dist/extensions/agent-browser/lib/browser-execution-identity.js +77 -0
- package/dist/extensions/agent-browser/lib/browser-journal-branch.js +98 -0
- package/dist/extensions/agent-browser/lib/browser-journal-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/browser-journal-projection.js +221 -0
- package/dist/extensions/agent-browser/lib/browser-journal-reader.js +89 -0
- package/dist/extensions/agent-browser/lib/browser-journal-replay.js +246 -0
- package/dist/extensions/agent-browser/lib/browser-journal.js +103 -394
- package/dist/extensions/agent-browser/lib/browser-legacy-pages.js +220 -0
- package/dist/extensions/agent-browser/lib/browser-legacy-projection.js +282 -0
- package/dist/extensions/agent-browser/lib/browser-legacy-types.js +1 -0
- package/dist/extensions/agent-browser/lib/browser-session-conversion-stream.js +217 -0
- package/dist/extensions/agent-browser/lib/browser-session-conversion.js +80 -335
- package/dist/extensions/agent-browser/lib/browser-transcript-contracts.js +35 -0
- package/dist/extensions/agent-browser/lib/browser-transcript-validation.js +166 -0
- package/dist/extensions/agent-browser/lib/browser-transcript.js +137 -82
- package/dist/extensions/agent-browser/lib/browser-value-parsing.js +15 -0
- package/dist/extensions/agent-browser/lib/command-capabilities.js +340 -0
- package/dist/extensions/agent-browser/lib/command-policy.js +107 -88
- package/dist/extensions/agent-browser/lib/command-taxonomy.js +49 -322
- package/dist/extensions/agent-browser/lib/config-policy.js +138 -343
- package/dist/extensions/agent-browser/lib/config-providers.js +71 -0
- package/dist/extensions/agent-browser/lib/config-validation.js +231 -0
- package/dist/extensions/agent-browser/lib/config.js +20 -8
- package/dist/extensions/agent-browser/lib/electron/cdp.js +20 -8
- package/dist/extensions/agent-browser/lib/electron/cleanup.js +128 -83
- 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 +90 -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 +261 -355
- 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/fs-utils.js +1 -9
- package/dist/extensions/agent-browser/lib/input-modes/electron.js +162 -121
- package/dist/extensions/agent-browser/lib/input-modes/job.js +123 -317
- package/dist/extensions/agent-browser/lib/input-modes/lookup-network-evidence.js +116 -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 +58 -412
- package/dist/extensions/agent-browser/lib/input-modes/params.js +86 -40
- package/dist/extensions/agent-browser/lib/input-modes/qa-analysis.js +268 -0
- package/dist/extensions/agent-browser/lib/input-modes/qa-presentation.js +117 -0
- package/dist/extensions/agent-browser/lib/input-modes/script-child.js +396 -0
- package/dist/extensions/agent-browser/lib/input-modes/script-protocol.js +86 -0
- package/dist/extensions/agent-browser/lib/input-modes/script-types.js +1 -0
- package/dist/extensions/agent-browser/lib/input-modes/script-validation.js +60 -0
- package/dist/extensions/agent-browser/lib/input-modes/script.js +60 -409
- package/dist/extensions/agent-browser/lib/input-modes/semantic-action.js +218 -128
- package/dist/extensions/agent-browser/lib/input-modes/shared.js +15 -4
- package/dist/extensions/agent-browser/lib/input-modes/types.js +56 -7
- package/dist/extensions/agent-browser/lib/json-schema.js +22 -10
- package/dist/extensions/agent-browser/lib/launch-scoped-flags.js +17 -5
- package/dist/extensions/agent-browser/lib/managed-session-policy-lock.js +92 -425
- package/dist/extensions/agent-browser/lib/managed-session-posix-storage.js +58 -0
- package/dist/extensions/agent-browser/lib/managed-session-project-identity.js +244 -0
- package/dist/extensions/agent-browser/lib/managed-session-restore-context.js +84 -0
- package/dist/extensions/agent-browser/lib/managed-session-restore-policy.js +119 -0
- package/dist/extensions/agent-browser/lib/managed-session-restore-state.js +83 -0
- package/dist/extensions/agent-browser/lib/managed-session-restore.js +168 -300
- package/dist/extensions/agent-browser/lib/managed-session-snapshot-records.js +277 -0
- package/dist/extensions/agent-browser/lib/managed-session-snapshots.js +128 -305
- package/dist/extensions/agent-browser/lib/managed-session-storage.js +56 -253
- package/dist/extensions/agent-browser/lib/native-confirmation.js +140 -0
- package/dist/extensions/agent-browser/lib/native-output.js +43 -9
- package/dist/extensions/agent-browser/lib/orchestration/batch-stdin.js +106 -59
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/artifact-merge.js +14 -6
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/artifact-paths.js +109 -57
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/browser-observation-result.js +82 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/click-dispatch.js +164 -60
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/diagnostic-values.js +31 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/diagnostics.js +152 -781
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/electron-observation.js +203 -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 +187 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-evidence.js +39 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-missing-binary.js +89 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-recovery.js +97 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-redaction.js +106 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-timeout.js +110 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result.js +41 -538
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/index.js +199 -154
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/interaction-diagnostics.js +290 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-close.js +167 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-daemon-inspection.js +108 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-daemon-policy.js +127 -205
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/native-helper-observation.js +65 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/observation-types.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/overlay-diagnostics.js +120 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/network-page-filter.js +113 -30
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/scroll-shims.js +109 -28
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-filter-data.js +150 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-filter.js +147 -253
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-rendered-text.js +147 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/wait-timeouts.js +59 -24
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-artifacts.js +159 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-command.js +131 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-daemon.js +93 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-failure.js +42 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-guards.js +242 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-input.js +75 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-observations.js +92 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-page-selection.js +254 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-page-state.js +121 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-refs.js +130 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-resources.js +114 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-semantic.js +121 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-session-plan.js +222 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-timeouts.js +68 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare.js +176 -1123
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-analysis.js +191 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-confirmation.js +152 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-diagnostics.js +182 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-electron.js +150 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle-phase-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle-phase.js +115 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle.js +256 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-managed-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-managed.js +256 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-native-phase-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-native-phase.js +93 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-native.js +113 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-navigation-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-navigation.js +316 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-ownership.js +28 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-page-phase-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-page-phase.js +142 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-presentation-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-presentation.js +333 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-publication-phase-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-publication-phase.js +71 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-publication.js +201 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-receipts.js +183 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-refs.js +200 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-tabs.js +142 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output.js +18 -968
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prompt-guards.js +23 -13
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-receipt-reconciliation.js +198 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-recovery-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-recovery-presentation.js +154 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-recovery.js +68 -151
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/screenshot-capture.js +14 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/screenshot-observation.js +169 -46
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-commands.js +130 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-electron.js +212 -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 +169 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-tabs.js +228 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state.js +77 -765
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/text-visibility-diagnostics.js +182 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/timeout-diagnostics.js +256 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/timeout-progress.js +108 -0
- package/dist/extensions/agent-browser/lib/orchestration/code-artifact-observation.js +39 -0
- package/dist/extensions/agent-browser/lib/orchestration/code-image-observation.js +119 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/branch.js +93 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/cleanup-result.js +58 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/cleanup.js +78 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/discovery.js +106 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/index.js +48 -821
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/policy.js +86 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-collection.js +68 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-data.js +169 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-presentation.js +182 -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 +167 -0
- package/dist/extensions/agent-browser/lib/orchestration/execution-queue.js +22 -10
- package/dist/extensions/agent-browser/lib/orchestration/extension-artifact-preflight.js +211 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-artifacts.js +23 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-attachment-replay.js +99 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-branch-restore.js +275 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-code.js +280 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-admission.js +303 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-output.js +36 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-result.js +335 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-run.js +227 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-state.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-electron-ownership.js +204 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-execution-locks.js +139 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-execution-queue.js +24 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-host-coordination.js +98 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-host-run.js +295 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-intent-replay.js +41 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-invocation.js +7 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-lifecycle.js +102 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-managed-ownership.js +133 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-observation.js +120 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-prompt.js +180 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-recording.js +290 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-resource-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-resource-replay.js +269 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-result-state.js +113 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-runtime.js +146 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-script-leases.js +58 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-tool-boundary.js +62 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-version-check.js +54 -0
- package/dist/extensions/agent-browser/lib/orchestration/input-plan-types.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/input-plan.js +261 -185
- package/dist/extensions/agent-browser/lib/orchestration/input-redaction.js +62 -0
- package/dist/extensions/agent-browser/lib/orchestration/native-config.js +144 -0
- package/dist/extensions/agent-browser/lib/orchestration/native-root-launch.js +77 -0
- package/dist/extensions/agent-browser/lib/orchestration/native-session-defaults.js +210 -157
- package/dist/extensions/agent-browser/lib/orchestration/operation-paths.js +124 -58
- package/dist/extensions/agent-browser/lib/orchestration/output-file.js +197 -99
- package/dist/extensions/agent-browser/lib/orchestration/script-mode.js +199 -96
- package/dist/extensions/agent-browser/lib/owned-managed-session-context.js +55 -0
- package/dist/extensions/agent-browser/lib/page-target-batch.js +118 -0
- package/dist/extensions/agent-browser/lib/page-target-guards.js +50 -0
- package/dist/extensions/agent-browser/lib/page-target-navigation.js +104 -0
- package/dist/extensions/agent-browser/lib/page-target-validation.js +55 -246
- package/dist/extensions/agent-browser/lib/parsing.js +13 -4
- package/dist/extensions/agent-browser/lib/pi-tool-rendering.js +133 -68
- package/dist/extensions/agent-browser/lib/playbook.js +16 -12
- package/dist/extensions/agent-browser/lib/process-child.js +284 -0
- package/dist/extensions/agent-browser/lib/process-environment.js +13 -6
- package/dist/extensions/agent-browser/lib/process-errors.js +23 -0
- package/dist/extensions/agent-browser/lib/process-identity.js +47 -15
- package/dist/extensions/agent-browser/lib/process-socket-storage.js +256 -0
- package/dist/extensions/agent-browser/lib/process-stdout.js +74 -0
- package/dist/extensions/agent-browser/lib/process.js +145 -536
- package/dist/extensions/agent-browser/lib/prompt-artifacts.js +287 -0
- package/dist/extensions/agent-browser/lib/prompt-policy.js +15 -194
- package/dist/extensions/agent-browser/lib/read-command.js +41 -0
- package/dist/extensions/agent-browser/lib/read-confirmation.js +131 -68
- package/dist/extensions/agent-browser/lib/recording-reservations.js +118 -45
- package/dist/extensions/agent-browser/lib/redaction-fields.js +75 -0
- package/dist/extensions/agent-browser/lib/redaction-json.js +149 -0
- package/dist/extensions/agent-browser/lib/redaction-url.js +88 -0
- package/dist/extensions/agent-browser/lib/results/action-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/results/action-recommendations.js +28 -271
- package/dist/extensions/agent-browser/lib/results/artifact-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/results/artifact-manifest-validation.js +133 -0
- package/dist/extensions/agent-browser/lib/results/artifact-manifest.js +96 -94
- package/dist/extensions/agent-browser/lib/results/artifact-recommendations.js +73 -0
- package/dist/extensions/agent-browser/lib/results/categories.js +111 -54
- package/dist/extensions/agent-browser/lib/results/confirmation.js +29 -13
- package/dist/extensions/agent-browser/lib/results/editable-ref-evidence.js +62 -27
- package/dist/extensions/agent-browser/lib/results/electron-recommendations.js +83 -0
- package/dist/extensions/agent-browser/lib/results/envelope-decoding.js +48 -0
- package/dist/extensions/agent-browser/lib/results/envelope.js +90 -67
- package/dist/extensions/agent-browser/lib/results/evidence-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/results/failure-recommendations.js +180 -0
- package/dist/extensions/agent-browser/lib/results/network-routes.js +86 -45
- package/dist/extensions/agent-browser/lib/results/network.js +35 -12
- package/dist/extensions/agent-browser/lib/results/next-actions.js +49 -19
- package/dist/extensions/agent-browser/lib/results/presentation/artifact-files.js +320 -0
- package/dist/extensions/agent-browser/lib/results/presentation/artifact-format.js +138 -0
- package/dist/extensions/agent-browser/lib/results/presentation/artifact-images.js +113 -0
- package/dist/extensions/agent-browser/lib/results/presentation/artifact-verification.js +145 -0
- package/dist/extensions/agent-browser/lib/results/presentation/artifacts.js +99 -555
- package/dist/extensions/agent-browser/lib/results/presentation/batch-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/results/presentation/batch-recording.js +118 -0
- package/dist/extensions/agent-browser/lib/results/presentation/batch-redaction.js +68 -0
- package/dist/extensions/agent-browser/lib/results/presentation/batch-rendering.js +135 -0
- package/dist/extensions/agent-browser/lib/results/presentation/batch-step.js +227 -0
- package/dist/extensions/agent-browser/lib/results/presentation/batch-summary.js +91 -0
- package/dist/extensions/agent-browser/lib/results/presentation/batch.js +91 -460
- package/dist/extensions/agent-browser/lib/results/presentation/browser-profile-recovery.js +9 -5
- package/dist/extensions/agent-browser/lib/results/presentation/command-presenters.js +216 -0
- package/dist/extensions/agent-browser/lib/results/presentation/common.js +26 -9
- package/dist/extensions/agent-browser/lib/results/presentation/content.js +86 -29
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-a11y.js +67 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-health.js +79 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-identity.js +199 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-logs.js +75 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-network-actions.js +216 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-network.js +124 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-redaction.js +64 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-storage.js +209 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-stream.js +69 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-summary.js +222 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostics.js +103 -1052
- package/dist/extensions/agent-browser/lib/results/presentation/early-result.js +70 -0
- package/dist/extensions/agent-browser/lib/results/presentation/errors.js +130 -60
- package/dist/extensions/agent-browser/lib/results/presentation/input-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/results/presentation/large-output.js +60 -145
- package/dist/extensions/agent-browser/lib/results/presentation/navigation.js +147 -88
- package/dist/extensions/agent-browser/lib/results/presentation/notices.js +75 -0
- package/dist/extensions/agent-browser/lib/results/presentation/observation-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/results/presentation/observation-rendering.js +127 -0
- package/dist/extensions/agent-browser/lib/results/presentation/outcomes.js +120 -0
- package/dist/extensions/agent-browser/lib/results/presentation/output-completion.js +77 -0
- package/dist/extensions/agent-browser/lib/results/presentation/output-spill.js +51 -0
- package/dist/extensions/agent-browser/lib/results/presentation/registry.js +116 -240
- package/dist/extensions/agent-browser/lib/results/presentation/semantic-action.js +35 -21
- package/dist/extensions/agent-browser/lib/results/presentation/skills.js +109 -73
- package/dist/extensions/agent-browser/lib/results/presentation/source.js +109 -0
- package/dist/extensions/agent-browser/lib/results/presentation.js +17 -261
- package/dist/extensions/agent-browser/lib/results/recommendation-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/results/recording.js +52 -14
- package/dist/extensions/agent-browser/lib/results/recovery-actions.js +14 -5
- package/dist/extensions/agent-browser/lib/results/recovery-next-actions.js +30 -22
- package/dist/extensions/agent-browser/lib/results/selector-recovery-target.js +83 -0
- package/dist/extensions/agent-browser/lib/results/selector-recovery.js +119 -119
- package/dist/extensions/agent-browser/lib/results/snapshot-compact.js +266 -0
- package/dist/extensions/agent-browser/lib/results/snapshot-content.js +32 -0
- package/dist/extensions/agent-browser/lib/results/snapshot-high-value-controls.js +104 -71
- package/dist/extensions/agent-browser/lib/results/snapshot-refs.js +31 -11
- package/dist/extensions/agent-browser/lib/results/snapshot-segments.js +125 -66
- package/dist/extensions/agent-browser/lib/results/snapshot-spill.js +26 -7
- package/dist/extensions/agent-browser/lib/results/snapshot.js +28 -248
- package/dist/extensions/agent-browser/lib/results/text.js +16 -5
- package/dist/extensions/agent-browser/lib/runtime-args-validation.js +133 -0
- package/dist/extensions/agent-browser/lib/runtime-compatibility.js +81 -0
- package/dist/extensions/agent-browser/lib/runtime-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/runtime-redaction.js +118 -0
- package/dist/extensions/agent-browser/lib/runtime-replay-events.js +144 -0
- package/dist/extensions/agent-browser/lib/runtime-session-identity.js +76 -0
- package/dist/extensions/agent-browser/lib/runtime-session-plan.js +114 -0
- package/dist/extensions/agent-browser/lib/runtime-session-replay.js +123 -0
- package/dist/extensions/agent-browser/lib/runtime-tab-correction.js +65 -0
- package/dist/extensions/agent-browser/lib/runtime-timeouts.js +28 -0
- package/dist/extensions/agent-browser/lib/runtime.js +137 -1041
- package/dist/extensions/agent-browser/lib/session-identity.js +51 -0
- package/dist/extensions/agent-browser/lib/session-page-observation.js +357 -0
- package/dist/extensions/agent-browser/lib/session-page-state.js +178 -333
- package/dist/extensions/agent-browser/lib/session-page-types.js +1 -0
- package/dist/extensions/agent-browser/lib/temp-artifact-budget.js +81 -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 +211 -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 +193 -0
- package/dist/extensions/agent-browser/lib/web-search-request.js +102 -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 +124 -614
- 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 +19 -6
- package/docs/CODE_QUALITY.md +267 -0
- package/docs/COMMAND_REFERENCE.md +272 -241
- package/docs/ELECTRON.md +77 -46
- package/docs/REFERENCE.md +869 -0
- package/docs/RELEASE.md +25 -22
- package/docs/REQUIREMENTS.md +2 -1
- package/docs/SUPPORT_MATRIX.md +81 -79
- package/docs/TOOL_CONTRACT.md +158 -125
- package/docs/platform-smoke.md +8 -8
- package/package.json +144 -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 +235 -132
- package/scripts/convert-browser-session.mjs +30 -9
- package/scripts/doctor-sources.mjs +195 -0
- package/scripts/doctor.mjs +94 -249
- 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 +132 -0
- package/scripts/platform-smoke/linux-image/Dockerfile +8 -2
- package/scripts/platform-smoke/suite-checks.mjs +98 -0
- package/scripts/platform-smoke/suite-evidence.mjs +281 -0
- package/scripts/platform-smoke/targets.mjs +154 -472
- package/scripts/platform-smoke.mjs +55 -40
- package/scripts/prepare.mjs +16 -7
|
@@ -1,236 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return { error: "sourceLookup.reactFiberId must be a non-empty string when provided." };
|
|
19
|
-
}
|
|
20
|
-
if (componentName !== undefined && (typeof componentName !== "string" || componentName.trim().length === 0)) {
|
|
21
|
-
return { error: "sourceLookup.componentName must be a non-empty string when provided." };
|
|
22
|
-
}
|
|
23
|
-
if (selector === undefined && reactFiberId === undefined && componentName === undefined) {
|
|
24
|
-
return { error: "sourceLookup requires selector, reactFiberId, or componentName." };
|
|
25
|
-
}
|
|
26
|
-
if (input.includeDomHints !== undefined && typeof input.includeDomHints !== "boolean") {
|
|
27
|
-
return { error: "sourceLookup.includeDomHints must be a boolean when provided." };
|
|
28
|
-
}
|
|
29
|
-
const rawMaxWorkspaceFiles = input.maxWorkspaceFiles;
|
|
30
|
-
if (rawMaxWorkspaceFiles !== undefined && (typeof rawMaxWorkspaceFiles !== "number" || !Number.isInteger(rawMaxWorkspaceFiles) || rawMaxWorkspaceFiles <= 0)) {
|
|
31
|
-
return { error: "sourceLookup.maxWorkspaceFiles must be a positive integer when provided." };
|
|
32
|
-
}
|
|
33
|
-
if (typeof rawMaxWorkspaceFiles === "number" && rawMaxWorkspaceFiles > SOURCE_LOOKUP_MAX_WORKSPACE_FILES) {
|
|
34
|
-
return { error: `sourceLookup.maxWorkspaceFiles must be ${SOURCE_LOOKUP_MAX_WORKSPACE_FILES} or less.` };
|
|
35
|
-
}
|
|
36
|
-
const includeDomHints = input.includeDomHints !== false;
|
|
37
|
-
const maxWorkspaceFiles = rawMaxWorkspaceFiles ?? SOURCE_LOOKUP_DEFAULT_MAX_WORKSPACE_FILES;
|
|
38
|
-
const steps = [];
|
|
39
|
-
if (typeof selector === "string") {
|
|
40
|
-
steps.push({ action: "dom", args: ["is", "visible", selector] });
|
|
41
|
-
if (includeDomHints) {
|
|
42
|
-
steps.push({ action: "dom", args: ["get", "html", selector] });
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (typeof reactFiberId === "string") {
|
|
46
|
-
steps.push({ action: "react", args: ["react", "inspect", reactFiberId] });
|
|
47
|
-
}
|
|
48
|
-
if (typeof componentName === "string") {
|
|
49
|
-
steps.push({ action: "react", args: ["react", "tree"] });
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
compiled: {
|
|
53
|
-
args: ["batch"],
|
|
54
|
-
query: { componentName, includeDomHints, maxWorkspaceFiles, reactFiberId, selector },
|
|
55
|
-
stdin: JSON.stringify(steps.map((step) => step.args)),
|
|
56
|
-
steps,
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
function extractStringField(value, names) {
|
|
61
|
-
for (const name of names) {
|
|
62
|
-
const field = value[name];
|
|
63
|
-
if (typeof field === "string" && field.trim().length > 0)
|
|
64
|
-
return field;
|
|
65
|
-
}
|
|
66
|
-
return undefined;
|
|
67
|
-
}
|
|
68
|
-
function extractNumberField(value, names) {
|
|
69
|
-
for (const name of names) {
|
|
70
|
-
const field = value[name];
|
|
71
|
-
if (typeof field === "number" && Number.isFinite(field))
|
|
72
|
-
return field;
|
|
73
|
-
if (typeof field === "string" && /^\d+$/.test(field))
|
|
74
|
-
return Number(field);
|
|
75
|
-
}
|
|
76
|
-
return undefined;
|
|
77
|
-
}
|
|
78
|
-
function candidateKey(candidate) {
|
|
79
|
-
return [candidate.source, candidate.file ?? "", candidate.line ?? "", candidate.column ?? "", candidate.componentName ?? ""].join(":");
|
|
80
|
-
}
|
|
81
|
-
function addSourceLookupCandidate(candidates, candidate) {
|
|
82
|
-
if (!candidates.some((existing) => candidateKey(existing) === candidateKey(candidate))) {
|
|
83
|
-
candidates.push(candidate);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
function collectSourceCandidatesFromValue(value, source, candidates, evidence, depth = 0) {
|
|
87
|
-
if (depth > 6 || value === undefined || value === null)
|
|
88
|
-
return;
|
|
89
|
-
if (typeof value === "string") {
|
|
90
|
-
const sourcePattern = /([A-Za-z0-9_./@-]+\.(?:tsx|jsx|ts|js))(?:[:#](\d+))?(?:[:#](\d+))?/g;
|
|
91
|
-
for (const match of value.matchAll(sourcePattern)) {
|
|
92
|
-
addSourceLookupCandidate(candidates, {
|
|
93
|
-
column: match[3] ? Number(match[3]) : undefined,
|
|
94
|
-
confidence: source === "react-inspect" ? "high" : "medium",
|
|
95
|
-
evidence,
|
|
96
|
-
file: match[1],
|
|
97
|
-
line: match[2] ? Number(match[2]) : undefined,
|
|
98
|
-
source,
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
if (Array.isArray(value)) {
|
|
104
|
-
for (const item of value)
|
|
105
|
-
collectSourceCandidatesFromValue(item, source, candidates, evidence, depth + 1);
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
if (!isRecord(value))
|
|
109
|
-
return;
|
|
110
|
-
const file = extractStringField(value, ["file", "fileName", "filename", "filePath", "path", "source", "url"]);
|
|
111
|
-
if (file && /\.(?:tsx|jsx|ts|js)(?:$|[:?#])/.test(file)) {
|
|
112
|
-
addSourceLookupCandidate(candidates, {
|
|
113
|
-
column: extractNumberField(value, ["column", "columnNumber", "col"]),
|
|
114
|
-
confidence: source === "react-inspect" ? "high" : "medium",
|
|
115
|
-
evidence,
|
|
116
|
-
file,
|
|
117
|
-
line: extractNumberField(value, ["line", "lineNumber"]),
|
|
118
|
-
source,
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
for (const nested of Object.values(value)) {
|
|
122
|
-
collectSourceCandidatesFromValue(nested, source, candidates, evidence, depth + 1);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
function getHtmlAttributeValue(html, name) {
|
|
126
|
-
const pattern = new RegExp(`${name}=["']([^"']+)["']`, "i");
|
|
127
|
-
return pattern.exec(html)?.[1];
|
|
128
|
-
}
|
|
129
|
-
function collectDomSourceCandidates(html, candidates) {
|
|
130
|
-
if (typeof html !== "string")
|
|
131
|
-
return;
|
|
132
|
-
const file = getHtmlAttributeValue(html, "(?:data-source-file|data-file|data-component-file|data-source)");
|
|
133
|
-
if (file && /\.(?:tsx|jsx|ts|js)$/.test(file)) {
|
|
134
|
-
const line = getHtmlAttributeValue(html, "(?:data-source-line|data-line)");
|
|
135
|
-
const column = getHtmlAttributeValue(html, "(?:data-source-column|data-column)");
|
|
136
|
-
addSourceLookupCandidate(candidates, {
|
|
137
|
-
column: column && /^\d+$/.test(column) ? Number(column) : undefined,
|
|
138
|
-
confidence: "medium",
|
|
139
|
-
evidence: ["selector HTML contained source-like data attributes"],
|
|
140
|
-
file,
|
|
141
|
-
line: line && /^\d+$/.test(line) ? Number(line) : undefined,
|
|
142
|
-
source: "dom-attribute",
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
collectSourceCandidatesFromValue(html, "dom-attribute", candidates, ["selector HTML contained source-like text"]);
|
|
146
|
-
}
|
|
147
|
-
async function walkWorkspaceSourceFiles(root, maxFiles) {
|
|
148
|
-
const files = [];
|
|
149
|
-
async function visit(directory) {
|
|
150
|
-
if (files.length >= maxFiles)
|
|
151
|
-
return;
|
|
152
|
-
let entries;
|
|
153
|
-
try {
|
|
154
|
-
entries = await readdir(directory, { withFileTypes: true });
|
|
155
|
-
}
|
|
156
|
-
catch {
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
for (const entry of entries) {
|
|
160
|
-
if (files.length >= maxFiles)
|
|
161
|
-
return;
|
|
162
|
-
const path = join(directory, entry.name);
|
|
163
|
-
if (entry.isDirectory()) {
|
|
164
|
-
if (!SOURCE_LOOKUP_IGNORED_DIRECTORIES.has(entry.name))
|
|
165
|
-
await visit(path);
|
|
166
|
-
}
|
|
167
|
-
else if (entry.isFile() && SOURCE_LOOKUP_WORKSPACE_EXTENSIONS.has(extname(entry.name))) {
|
|
168
|
-
files.push(path);
|
|
1
|
+
export { compileAgentBrowserNetworkSourceLookup, compileAgentBrowserSourceLookup, } from "./lookup-plan.js";
|
|
2
|
+
export { redactNetworkSourceLookupAnalysis, redactNetworkSourceLookupArgs, redactNetworkSourceLookupSurface, redactNetworkSourceLookupUrl, } from "./lookup-redaction.js";
|
|
3
|
+
function sourceStatus(candidateCount, unsupported) {
|
|
4
|
+
if (candidateCount > 0) {
|
|
5
|
+
return "candidates-found";
|
|
6
|
+
}
|
|
7
|
+
return unsupported ? "unsupported" : "no-candidates";
|
|
8
|
+
}
|
|
9
|
+
function sourceSummary(status, candidateCount, electronWorkspace) {
|
|
10
|
+
switch (status) {
|
|
11
|
+
case "candidates-found":
|
|
12
|
+
return `Source lookup found ${candidateCount} candidate location(s).`;
|
|
13
|
+
case "unsupported":
|
|
14
|
+
return "Source lookup could not inspect React metadata in this session.";
|
|
15
|
+
case "no-candidates":
|
|
16
|
+
if (electronWorkspace !== undefined) {
|
|
17
|
+
return `Source lookup found no candidate locations. The workspace scan was limited to ${electronWorkspace}; packaged Electron app code may live outside that cwd in app resources or app.asar.`;
|
|
169
18
|
}
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
await visit(root);
|
|
173
|
-
return files;
|
|
174
|
-
}
|
|
175
|
-
function escapeRegExp(value) {
|
|
176
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
177
|
-
}
|
|
178
|
-
async function collectWorkspaceComponentCandidates(query, cwd, candidates, limitations) {
|
|
179
|
-
if (!query.componentName)
|
|
180
|
-
return;
|
|
181
|
-
const files = await walkWorkspaceSourceFiles(cwd, query.maxWorkspaceFiles);
|
|
182
|
-
if (files.length >= query.maxWorkspaceFiles) {
|
|
183
|
-
limitations.push(`Workspace source scan stopped at ${query.maxWorkspaceFiles} files.`);
|
|
184
|
-
}
|
|
185
|
-
const componentPattern = new RegExp(`(?:function|class)\\s+${escapeRegExp(query.componentName)}\\b|(?:const|let|var)\\s+${escapeRegExp(query.componentName)}\\s*=|export\\s+default\\s+function\\s+${escapeRegExp(query.componentName)}\\b`);
|
|
186
|
-
for (const file of files) {
|
|
187
|
-
let text;
|
|
188
|
-
try {
|
|
189
|
-
text = await readFile(file, "utf8");
|
|
190
|
-
}
|
|
191
|
-
catch {
|
|
192
|
-
continue;
|
|
193
|
-
}
|
|
194
|
-
const match = componentPattern.exec(text);
|
|
195
|
-
if (!match)
|
|
196
|
-
continue;
|
|
197
|
-
const line = text.slice(0, match.index).split("\n").length;
|
|
198
|
-
addSourceLookupCandidate(candidates, {
|
|
199
|
-
componentName: query.componentName,
|
|
200
|
-
confidence: "low",
|
|
201
|
-
evidence: [`local workspace contains a matching ${query.componentName} declaration`],
|
|
202
|
-
file,
|
|
203
|
-
line,
|
|
204
|
-
source: "workspace-search",
|
|
205
|
-
});
|
|
206
|
-
if (candidates.filter((candidate) => candidate.source === "workspace-search").length >= 10)
|
|
207
|
-
break;
|
|
19
|
+
return "Source lookup found no candidate locations.";
|
|
208
20
|
}
|
|
209
21
|
}
|
|
210
22
|
export async function analyzeSourceLookupResults(data, compiled, cwd, context) {
|
|
211
|
-
const
|
|
212
|
-
const
|
|
23
|
+
const { distinctSourceCandidates, observeSourceCandidates } = await import("./lookup-source-evidence.js");
|
|
24
|
+
const { scanWorkspaceComponent } = await import("./lookup-workspace.js");
|
|
25
|
+
const observed = observeSourceCandidates(data);
|
|
26
|
+
const workspace = await scanWorkspaceComponent(compiled.query, cwd);
|
|
27
|
+
const candidates = distinctSourceCandidates([...observed.candidates, ...workspace.candidates]);
|
|
28
|
+
const status = sourceStatus(candidates.length, observed.unsupported);
|
|
29
|
+
const electronContext = status === "no-candidates" ? context?.electronContext : undefined;
|
|
30
|
+
const workspaceRoot = context?.workspaceRoot ?? cwd;
|
|
213
31
|
const limitations = [
|
|
214
32
|
"Experimental lookup only reports candidates with evidence; it cannot guarantee a DOM node maps to one source file.",
|
|
215
33
|
"React source hints require the page to be opened with --enable react-devtools and source information from the app build.",
|
|
34
|
+
...workspace.limitations,
|
|
216
35
|
];
|
|
217
|
-
let unsupported = false;
|
|
218
|
-
for (const item of items) {
|
|
219
|
-
const command = Array.isArray(item.command) ? item.command : [];
|
|
220
|
-
const result = isRecord(item.result) && "data" in item.result ? item.result.data : item.result;
|
|
221
|
-
if (item.success === false && command[0] === "react")
|
|
222
|
-
unsupported = true;
|
|
223
|
-
if (command[0] === "react" && command[1] === "inspect") {
|
|
224
|
-
collectSourceCandidatesFromValue(result, "react-inspect", candidates, ["react inspect returned source-like metadata"]);
|
|
225
|
-
}
|
|
226
|
-
if (command[0] === "get" && command[1] === "html") {
|
|
227
|
-
collectDomSourceCandidates(result, candidates);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
await collectWorkspaceComponentCandidates(compiled.query, cwd, candidates, limitations);
|
|
231
|
-
const status = candidates.length > 0 ? "candidates-found" : unsupported ? "unsupported" : "no-candidates";
|
|
232
|
-
const electronContext = status === "no-candidates" ? context?.electronContext : undefined;
|
|
233
|
-
const workspaceRoot = context?.workspaceRoot ?? cwd;
|
|
234
36
|
if (electronContext) {
|
|
235
37
|
limitations.push(`Workspace source scan is limited to the captured execution directory: ${workspaceRoot}.`, "Packaged Electron app code may live inside installed app resources or app.asar outside the workspace; the wrapper does not unpack asar files or scan app bundle resources.");
|
|
236
38
|
}
|
|
@@ -239,200 +41,44 @@ export async function analyzeSourceLookupResults(data, compiled, cwd, context) {
|
|
|
239
41
|
electronContext,
|
|
240
42
|
limitations,
|
|
241
43
|
status,
|
|
242
|
-
summary: candidates.length
|
|
243
|
-
? `Source lookup found ${candidates.length} candidate location(s).`
|
|
244
|
-
: unsupported
|
|
245
|
-
? "Source lookup could not inspect React metadata in this session."
|
|
246
|
-
: electronContext
|
|
247
|
-
? `Source lookup found no candidate locations. The workspace scan was limited to ${workspaceRoot}; packaged Electron app code may live outside that cwd in app resources or app.asar.`
|
|
248
|
-
: "Source lookup found no candidate locations.",
|
|
44
|
+
summary: sourceSummary(status, candidates.length, electronContext ? workspaceRoot : undefined),
|
|
249
45
|
workspaceRoot: electronContext ? workspaceRoot : undefined,
|
|
250
46
|
};
|
|
251
47
|
}
|
|
252
|
-
|
|
253
|
-
if (
|
|
254
|
-
return
|
|
255
|
-
const filter = input.filter;
|
|
256
|
-
const requestId = input.requestId;
|
|
257
|
-
const namespace = input.namespace;
|
|
258
|
-
const session = input.session;
|
|
259
|
-
const url = input.url;
|
|
260
|
-
if (filter !== undefined && (typeof filter !== "string" || filter.trim().length === 0))
|
|
261
|
-
return { error: "networkSourceLookup.filter must be a non-empty string when provided." };
|
|
262
|
-
if (requestId !== undefined && (typeof requestId !== "string" || requestId.trim().length === 0))
|
|
263
|
-
return { error: "networkSourceLookup.requestId must be a non-empty string when provided." };
|
|
264
|
-
if (namespace !== undefined && (typeof namespace !== "string" || (namespace !== "" && namespace.trim().length === 0)))
|
|
265
|
-
return { error: "networkSourceLookup.namespace must be a non-empty string or the empty default namespace when provided." };
|
|
266
|
-
if (session !== undefined && (typeof session !== "string" || session.trim().length === 0))
|
|
267
|
-
return { error: "networkSourceLookup.session must be a non-empty string when provided." };
|
|
268
|
-
if (url !== undefined && (typeof url !== "string" || url.trim().length === 0))
|
|
269
|
-
return { error: "networkSourceLookup.url must be a non-empty string when provided." };
|
|
270
|
-
if (filter === undefined && requestId === undefined && url === undefined)
|
|
271
|
-
return { error: "networkSourceLookup requires requestId, filter, or url." };
|
|
272
|
-
const maxWorkspaceFiles = validateLookupMaxWorkspaceFiles(input.maxWorkspaceFiles, "networkSourceLookup.maxWorkspaceFiles");
|
|
273
|
-
if (maxWorkspaceFiles.error)
|
|
274
|
-
return { error: maxWorkspaceFiles.error };
|
|
275
|
-
const steps = [];
|
|
276
|
-
if (typeof requestId === "string") {
|
|
277
|
-
steps.push({ action: "network", args: ["network", "request", requestId] });
|
|
278
|
-
}
|
|
279
|
-
const effectiveFilter = typeof filter === "string" ? filter : typeof url === "string" ? url : undefined;
|
|
280
|
-
if (effectiveFilter) {
|
|
281
|
-
steps.push({ action: "network", args: ["network", "requests", "--filter", effectiveFilter] });
|
|
282
|
-
}
|
|
283
|
-
const args = [...(typeof namespace === "string" ? ["--namespace", namespace] : []), ...(typeof session === "string" ? ["--session", session] : []), "batch"];
|
|
284
|
-
return { compiled: { args, query: { filter, maxWorkspaceFiles: maxWorkspaceFiles.value, namespace, requestId, session, url }, stdin: JSON.stringify(steps.map((step) => step.args)), steps } };
|
|
285
|
-
}
|
|
286
|
-
function getResultPayload(item) {
|
|
287
|
-
return isRecord(item.result) && "data" in item.result ? item.result.data : item.result;
|
|
288
|
-
}
|
|
289
|
-
function networkRequestMatchesQuery(url, queryText) {
|
|
290
|
-
return queryText === undefined || url === undefined || url.includes(queryText) || queryText.includes(url);
|
|
291
|
-
}
|
|
292
|
-
function isFailedNetworkRecord(request) {
|
|
293
|
-
const status = typeof request.status === "number" ? request.status : undefined;
|
|
294
|
-
const error = typeof request.error === "string" ? request.error : undefined;
|
|
295
|
-
return request.failed === true || error !== undefined || (status !== undefined && status >= 400);
|
|
296
|
-
}
|
|
297
|
-
function getFailedNetworkRequests(data, queryText) {
|
|
298
|
-
const failed = [];
|
|
299
|
-
for (const item of getBatchResultItems(data)) {
|
|
300
|
-
const payload = getResultPayload(item);
|
|
301
|
-
const requests = isRecord(payload) && Array.isArray(payload.requests) ? payload.requests : Array.isArray(payload) ? payload : isRecord(payload) ? [payload] : [];
|
|
302
|
-
for (const request of requests) {
|
|
303
|
-
if (!isRecord(request))
|
|
304
|
-
continue;
|
|
305
|
-
const url = typeof request.url === "string" ? request.url : undefined;
|
|
306
|
-
if (!networkRequestMatchesQuery(url, queryText) || !isFailedNetworkRecord(request))
|
|
307
|
-
continue;
|
|
308
|
-
failed.push({
|
|
309
|
-
error: typeof request.error === "string" ? request.error : undefined,
|
|
310
|
-
method: typeof request.method === "string" ? request.method : undefined,
|
|
311
|
-
requestId: typeof request.id === "string" ? request.id : typeof request.requestId === "string" ? request.requestId : undefined,
|
|
312
|
-
status: typeof request.status === "number" ? request.status : undefined,
|
|
313
|
-
url,
|
|
314
|
-
});
|
|
315
|
-
}
|
|
48
|
+
function networkStatus(failedCount, candidateCount) {
|
|
49
|
+
if (failedCount === 0) {
|
|
50
|
+
return "no-failed-requests";
|
|
316
51
|
}
|
|
317
|
-
return failed;
|
|
318
|
-
}
|
|
319
|
-
function addNetworkCandidate(candidates, candidate) {
|
|
320
|
-
const key = [candidate.source, candidate.file ?? "", candidate.line ?? "", candidate.requestUrl ?? ""].join(":");
|
|
321
|
-
if (!candidates.some((existing) => [existing.source, existing.file ?? "", existing.line ?? "", existing.requestUrl ?? ""].join(":") === key))
|
|
322
|
-
candidates.push(candidate);
|
|
52
|
+
return candidateCount > 0 ? "failed-requests-found" : "no-candidates";
|
|
323
53
|
}
|
|
324
|
-
function
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
continue;
|
|
333
|
-
const requestUrl = typeof value.url === "string" ? value.url : undefined;
|
|
334
|
-
const requestId = typeof value.id === "string" ? value.id : typeof value.requestId === "string" ? value.requestId : undefined;
|
|
335
|
-
const correlatesWithFailedRequest = (requestId !== undefined && failedRequestIds.has(requestId)) || (requestUrl !== undefined && failedRequestUrls.has(requestUrl));
|
|
336
|
-
if (!correlatesWithFailedRequest && !isFailedNetworkRecord(value))
|
|
337
|
-
continue;
|
|
338
|
-
for (const field of [value.initiator, value.stack, value.source, value.trace]) {
|
|
339
|
-
const localCandidates = [];
|
|
340
|
-
collectSourceCandidatesFromValue(field, "dom-attribute", localCandidates, ["failed network request included source-like initiator metadata"]);
|
|
341
|
-
for (const candidate of localCandidates) {
|
|
342
|
-
addNetworkCandidate(candidates, { confidence: "medium", evidence: candidate.evidence, file: candidate.file, line: candidate.line, requestUrl, source: "initiator" });
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
}
|
|
54
|
+
function networkSummary(status, failedCount, candidateCount) {
|
|
55
|
+
switch (status) {
|
|
56
|
+
case "no-failed-requests":
|
|
57
|
+
return "Network source lookup found no failed requests.";
|
|
58
|
+
case "failed-requests-found":
|
|
59
|
+
return `Network source lookup found ${failedCount} failed request(s) and ${candidateCount} candidate source hint(s).`;
|
|
60
|
+
case "no-candidates":
|
|
61
|
+
return `Network source lookup found ${failedCount} failed request(s) but no source candidates.`;
|
|
346
62
|
}
|
|
347
63
|
}
|
|
348
|
-
async function
|
|
349
|
-
const
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
}))].slice(0, 8);
|
|
358
|
-
if (needles.length === 0)
|
|
359
|
-
return;
|
|
360
|
-
const files = await walkWorkspaceSourceFiles(cwd, query.maxWorkspaceFiles);
|
|
361
|
-
if (files.length >= query.maxWorkspaceFiles)
|
|
362
|
-
limitations.push(`Workspace source scan stopped at ${query.maxWorkspaceFiles} files.`);
|
|
363
|
-
for (const file of files) {
|
|
364
|
-
let text;
|
|
365
|
-
try {
|
|
366
|
-
text = await readFile(file, "utf8");
|
|
367
|
-
}
|
|
368
|
-
catch {
|
|
369
|
-
continue;
|
|
370
|
-
}
|
|
371
|
-
for (const needle of needles) {
|
|
372
|
-
const index = text.indexOf(needle);
|
|
373
|
-
if (index === -1)
|
|
374
|
-
continue;
|
|
375
|
-
addNetworkCandidate(candidates, { confidence: "low", evidence: [`local workspace contains request URL literal ${needle}`], file, line: text.slice(0, index).split("\n").length, requestUrl: needle, source: "workspace-search" });
|
|
376
|
-
if (candidates.filter((candidate) => candidate.source === "workspace-search").length >= 10)
|
|
377
|
-
return;
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
export function redactNetworkSourceLookupUrl(value) {
|
|
382
|
-
if (!value)
|
|
383
|
-
return value;
|
|
384
|
-
try {
|
|
385
|
-
const isRelative = value.startsWith("/");
|
|
386
|
-
const url = new URL(value, isRelative ? "https://redacted.invalid" : undefined);
|
|
387
|
-
url.username = url.username ? "[REDACTED]" : "";
|
|
388
|
-
url.password = url.password ? "[REDACTED]" : "";
|
|
389
|
-
for (const key of [...url.searchParams.keys()]) {
|
|
390
|
-
url.searchParams.set(key, "[REDACTED]");
|
|
391
|
-
}
|
|
392
|
-
if (/(?:token|secret|password|passwd|pwd|key|auth|session|jwt|credential)/i.test(url.hash)) {
|
|
393
|
-
url.hash = "#[REDACTED]";
|
|
394
|
-
}
|
|
395
|
-
return isRelative ? `${url.pathname}${url.search}${url.hash}` : url.toString();
|
|
396
|
-
}
|
|
397
|
-
catch {
|
|
398
|
-
return redactSensitiveText(value
|
|
399
|
-
.replace(/([a-z][a-z0-9+.-]*:\/\/)\S+:\S+@/gi, "$1[REDACTED]@")
|
|
400
|
-
.replace(/([?&][^=]+)=([^&#\s"'\]]+)/g, "$1=[REDACTED]"));
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
export function redactNetworkSourceLookupArgs(args) {
|
|
404
|
-
return redactInvocationArgs(args).map((arg) => redactNetworkSourceLookupUrl(arg) ?? arg);
|
|
405
|
-
}
|
|
406
|
-
export function redactNetworkSourceLookupSurface(value) {
|
|
407
|
-
if (typeof value === "string")
|
|
408
|
-
return redactNetworkSourceLookupUrl(value) ?? value;
|
|
409
|
-
if (Array.isArray(value))
|
|
410
|
-
return value.map((item) => redactNetworkSourceLookupSurface(item));
|
|
411
|
-
if (!isRecord(value))
|
|
412
|
-
return value;
|
|
413
|
-
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, redactNetworkSourceLookupSurface(item)]));
|
|
414
|
-
}
|
|
415
|
-
export function redactNetworkSourceLookupAnalysis(analysis) {
|
|
64
|
+
export async function analyzeNetworkSourceLookupResults(data, compiled, cwd) {
|
|
65
|
+
const { distinctNetworkCandidates, getFailedNetworkRequests, observeInitiatorCandidates } = await import("./lookup-network-evidence.js");
|
|
66
|
+
const { scanWorkspaceRequests } = await import("./lookup-workspace.js");
|
|
67
|
+
const queryText = compiled.query.filter ?? compiled.query.url;
|
|
68
|
+
const failedRequests = getFailedNetworkRequests(data, queryText);
|
|
69
|
+
const observed = observeInitiatorCandidates(data, failedRequests, queryText);
|
|
70
|
+
const workspace = await scanWorkspaceRequests(compiled.query, failedRequests, cwd);
|
|
71
|
+
const candidates = distinctNetworkCandidates([...observed, ...workspace.candidates]);
|
|
72
|
+
const status = networkStatus(failedRequests.length, candidates.length);
|
|
416
73
|
return {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
74
|
+
candidates,
|
|
75
|
+
failedRequests,
|
|
76
|
+
limitations: [
|
|
77
|
+
"Experimental network source hints report candidates only; failed requests can be triggered indirectly by frameworks, caches, service workers, or third-party scripts.",
|
|
78
|
+
"Initiator/source-map metadata is upstream/browser-build dependent and may be absent.",
|
|
79
|
+
...workspace.limitations,
|
|
80
|
+
],
|
|
81
|
+
status,
|
|
82
|
+
summary: networkSummary(status, failedRequests.length, candidates.length),
|
|
425
83
|
};
|
|
426
84
|
}
|
|
427
|
-
export async function analyzeNetworkSourceLookupResults(data, compiled, cwd) {
|
|
428
|
-
const limitations = [
|
|
429
|
-
"Experimental network source hints report candidates only; failed requests can be triggered indirectly by frameworks, caches, service workers, or third-party scripts.",
|
|
430
|
-
"Initiator/source-map metadata is upstream/browser-build dependent and may be absent.",
|
|
431
|
-
];
|
|
432
|
-
const failedRequests = getFailedNetworkRequests(data, compiled.query.url ?? compiled.query.filter);
|
|
433
|
-
const candidates = [];
|
|
434
|
-
collectInitiatorCandidates(data, failedRequests, candidates);
|
|
435
|
-
await collectWorkspaceRequestCandidates(compiled.query, failedRequests, cwd, candidates, limitations);
|
|
436
|
-
const status = failedRequests.length === 0 ? "no-failed-requests" : candidates.length > 0 ? "failed-requests-found" : "no-candidates";
|
|
437
|
-
return { candidates, failedRequests, limitations, status, summary: failedRequests.length === 0 ? "Network source lookup found no failed requests." : candidates.length > 0 ? `Network source lookup found ${failedRequests.length} failed request(s) and ${candidates.length} candidate source hint(s).` : `Network source lookup found ${failedRequests.length} failed request(s) but no source candidates.` };
|
|
438
|
-
}
|