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,220 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { snapshotDefinition, } from "./browser-transcript.js";
|
|
3
|
+
import { browserStringArray } from "./browser-value-parsing.js";
|
|
4
|
+
import { isRecord } from "./parsing.js";
|
|
5
|
+
import { isReadOnlyDiagnosticSessionTargetCommand } from "./command-taxonomy.js";
|
|
6
|
+
import { normalizeSessionTabTarget, extractSessionTabTargetFromBatchResults, isNoActivePageSnapshotFailure, buildNoActivePageRefSnapshotInvalidation, } from "./session-page-observation.js";
|
|
7
|
+
function legacyTarget(value) {
|
|
8
|
+
return normalizeSessionTabTarget({
|
|
9
|
+
url: typeof value.url === "string" ? value.url : undefined,
|
|
10
|
+
title: typeof value.title === "string" ? value.title : undefined,
|
|
11
|
+
targetId: typeof value.targetId === "string" ? value.targetId : undefined,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
function legacySnapshot(value, id) {
|
|
15
|
+
if (!isRecord(value) || !Array.isArray(value.refIds)) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
const refIds = browserStringArray(value.refIds).filter((ref) => /^e\d+$/.test(ref));
|
|
19
|
+
const sourceRefs = isRecord(value.refs) ? value.refs : {};
|
|
20
|
+
return snapshotDefinition({
|
|
21
|
+
snapshotId: typeof value.snapshotId === "string" ? value.snapshotId : id,
|
|
22
|
+
refIds,
|
|
23
|
+
generation: typeof value.generation === "string" ? value.generation : undefined,
|
|
24
|
+
refs: Object.fromEntries(refIds.flatMap((refId) => {
|
|
25
|
+
const ref = sourceRefs[refId];
|
|
26
|
+
if (!isRecord(ref) || typeof ref.name !== "string" || typeof ref.role !== "string") {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
return [
|
|
30
|
+
[
|
|
31
|
+
refId,
|
|
32
|
+
{
|
|
33
|
+
name: ref.name,
|
|
34
|
+
role: ref.role,
|
|
35
|
+
...(typeof ref.isEditable === "boolean" ? { isEditable: ref.isEditable } : {}),
|
|
36
|
+
...(typeof ref.isContentEditable === "boolean"
|
|
37
|
+
? { isContentEditable: ref.isContentEditable }
|
|
38
|
+
: {}),
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
];
|
|
42
|
+
})),
|
|
43
|
+
target: isRecord(value.target) ? legacyTarget(value.target) : undefined,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function snapshotDigest(definition) {
|
|
47
|
+
return createHash("sha256")
|
|
48
|
+
.update(JSON.stringify({
|
|
49
|
+
refs: definition.refs,
|
|
50
|
+
target: definition.target,
|
|
51
|
+
generation: definition.generation,
|
|
52
|
+
}))
|
|
53
|
+
.digest("hex");
|
|
54
|
+
}
|
|
55
|
+
export function canonicalPage(prior, canonical, page) {
|
|
56
|
+
const definition = isRecord(canonical.snapshot) ? canonical.snapshot : undefined;
|
|
57
|
+
const digest = definition !== undefined && Boolean(definition.refs)
|
|
58
|
+
? snapshotDigest(definition)
|
|
59
|
+
: (prior.snapshot?.digest ?? "");
|
|
60
|
+
let snapshot;
|
|
61
|
+
if (page.refs.kind === "replace" || page.refs.kind === "reuse") {
|
|
62
|
+
snapshot = { id: page.refs.snapshotId, digest, usable: true, candidate: false };
|
|
63
|
+
}
|
|
64
|
+
else if (prior.snapshot) {
|
|
65
|
+
snapshot = { ...prior.snapshot, usable: false, candidate: canonical.event.phase === "begin" };
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
target: page.target,
|
|
69
|
+
unknown: page.unknown,
|
|
70
|
+
reopenPending: page.reopenPending,
|
|
71
|
+
snapshot,
|
|
72
|
+
pending: canonical.event.phase === "begin"
|
|
73
|
+
? {
|
|
74
|
+
operationId: canonical.event.operationId,
|
|
75
|
+
toolCallId: canonical.event.toolCallId,
|
|
76
|
+
index: canonical.event.commandIndex,
|
|
77
|
+
}
|
|
78
|
+
: undefined,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function parseInvalidation(value, fallbackSummary) {
|
|
82
|
+
if (!isRecord(value)) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
if (value.reason !== "no-active-page" && value.reason !== "page-transition") {
|
|
86
|
+
throw new Error("Invalid legacy browser ref invalidation.");
|
|
87
|
+
}
|
|
88
|
+
if (typeof value.summary === "string") {
|
|
89
|
+
return { reason: value.reason, summary: value.summary };
|
|
90
|
+
}
|
|
91
|
+
if (fallbackSummary) {
|
|
92
|
+
return {
|
|
93
|
+
reason: value.reason,
|
|
94
|
+
summary: "The prior refs were invalidated; take a fresh snapshot.",
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
throw new Error("Invalid legacy browser ref invalidation summary.");
|
|
98
|
+
}
|
|
99
|
+
function observedInvalidation(ctx) {
|
|
100
|
+
const value = ctx.details.refSnapshotInvalidation;
|
|
101
|
+
if (isRecord(value) &&
|
|
102
|
+
(value.reason === "no-active-page" || value.reason === "page-transition")) {
|
|
103
|
+
return parseInvalidation(value, true);
|
|
104
|
+
}
|
|
105
|
+
let error;
|
|
106
|
+
if (typeof ctx.details.error === "string") {
|
|
107
|
+
error = ctx.details.error;
|
|
108
|
+
}
|
|
109
|
+
else if (typeof ctx.details.summary === "string") {
|
|
110
|
+
error = ctx.details.summary;
|
|
111
|
+
}
|
|
112
|
+
return isNoActivePageSnapshotFailure(ctx.command, error)
|
|
113
|
+
? buildNoActivePageRefSnapshotInvalidation()
|
|
114
|
+
: undefined;
|
|
115
|
+
}
|
|
116
|
+
function snapshotReusable(page, details, digest) {
|
|
117
|
+
return (page.snapshot?.digest === digest &&
|
|
118
|
+
(page.snapshot.usable || page.snapshot.candidate) &&
|
|
119
|
+
(!isRecord(details.refSnapshot) ||
|
|
120
|
+
typeof details.refSnapshot.snapshotId !== "string" ||
|
|
121
|
+
details.refSnapshot.snapshotId === page.snapshot.id));
|
|
122
|
+
}
|
|
123
|
+
/** One legacy entry owns a shallow page draft; previous snapshots and parent views are never mutated. */
|
|
124
|
+
export class LegacyPageConversion {
|
|
125
|
+
ctx;
|
|
126
|
+
page;
|
|
127
|
+
definition;
|
|
128
|
+
constructor(ctx, prior) {
|
|
129
|
+
this.ctx = ctx;
|
|
130
|
+
this.page = { ...prior };
|
|
131
|
+
}
|
|
132
|
+
knownTarget() {
|
|
133
|
+
const { details, command, subcommand } = this.ctx;
|
|
134
|
+
if (!isRecord(details.compiledNetworkSourceLookup) &&
|
|
135
|
+
!isReadOnlyDiagnosticSessionTargetCommand(command, subcommand) &&
|
|
136
|
+
isRecord(details.sessionTabTarget)) {
|
|
137
|
+
this.page.target = legacyTarget(details.sessionTabTarget) ?? this.page.target;
|
|
138
|
+
}
|
|
139
|
+
else if (command === "batch" && !isRecord(details.compiledNetworkSourceLookup)) {
|
|
140
|
+
this.page.target = extractSessionTabTargetFromBatchResults(details.data) ?? this.page.target;
|
|
141
|
+
}
|
|
142
|
+
if (this.page.target) {
|
|
143
|
+
this.page.unknown = undefined;
|
|
144
|
+
}
|
|
145
|
+
if (typeof details.sessionTabReopenPending === "boolean") {
|
|
146
|
+
this.page.reopenPending = details.sessionTabReopenPending;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
knownRefs() {
|
|
150
|
+
const invalidation = observedInvalidation(this.ctx);
|
|
151
|
+
const candidate = invalidation
|
|
152
|
+
? undefined
|
|
153
|
+
: legacySnapshot(this.ctx.details.refSnapshot, `snapshot-${this.ctx.nativeId}`);
|
|
154
|
+
if (candidate) {
|
|
155
|
+
const digest = snapshotDigest(candidate);
|
|
156
|
+
let refs;
|
|
157
|
+
if (snapshotReusable(this.page, this.ctx.details, digest) && this.page.snapshot) {
|
|
158
|
+
refs = { kind: "reuse", snapshotId: this.page.snapshot.id };
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
this.definition = candidate;
|
|
162
|
+
refs = { kind: "replace", snapshotId: candidate.id };
|
|
163
|
+
}
|
|
164
|
+
this.page.snapshot = { id: refs.snapshotId, digest, usable: true, candidate: false };
|
|
165
|
+
return refs;
|
|
166
|
+
}
|
|
167
|
+
if (invalidation) {
|
|
168
|
+
this.disableSnapshot(false);
|
|
169
|
+
return { kind: "invalidate", invalidation };
|
|
170
|
+
}
|
|
171
|
+
return this.page.snapshot?.usable === true
|
|
172
|
+
? { kind: "reuse", snapshotId: this.page.snapshot.id }
|
|
173
|
+
: { kind: "invalidate" };
|
|
174
|
+
}
|
|
175
|
+
disableSnapshot(candidate) {
|
|
176
|
+
if (this.page.snapshot) {
|
|
177
|
+
this.page.snapshot = { ...this.page.snapshot, usable: false, candidate };
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
change(key) {
|
|
181
|
+
const ctx = this.ctx;
|
|
182
|
+
if (ctx.begin) {
|
|
183
|
+
this.page.target = undefined;
|
|
184
|
+
this.page.unknown = true;
|
|
185
|
+
this.page.snapshot = ctx.prior.snapshot
|
|
186
|
+
? { ...ctx.prior.snapshot, usable: false, candidate: true }
|
|
187
|
+
: undefined;
|
|
188
|
+
this.page.pending = {
|
|
189
|
+
toolCallId: ctx.toolCallId,
|
|
190
|
+
operationId: ctx.operationId,
|
|
191
|
+
index: ctx.commandIndex,
|
|
192
|
+
};
|
|
193
|
+
return { key, refs: { kind: "unknown" }, unknown: true };
|
|
194
|
+
}
|
|
195
|
+
if (ctx.details.sessionTabTargetUnknown === true) {
|
|
196
|
+
this.page.target = undefined;
|
|
197
|
+
this.page.unknown = true;
|
|
198
|
+
this.page.pending = undefined;
|
|
199
|
+
this.disableSnapshot(false);
|
|
200
|
+
return {
|
|
201
|
+
key,
|
|
202
|
+
refs: {
|
|
203
|
+
kind: "unknown",
|
|
204
|
+
invalidation: parseInvalidation(ctx.details.refSnapshotInvalidation, false),
|
|
205
|
+
},
|
|
206
|
+
unknown: true,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
this.knownTarget();
|
|
210
|
+
const refs = this.knownRefs();
|
|
211
|
+
this.page.pending = undefined;
|
|
212
|
+
return {
|
|
213
|
+
key,
|
|
214
|
+
target: this.page.target,
|
|
215
|
+
unknown: this.page.unknown,
|
|
216
|
+
reopenPending: this.page.reopenPending,
|
|
217
|
+
refs,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { extractUpstreamCommandTokens } from "./argv-descriptor.js";
|
|
3
|
+
import { getAgentBrowserSessionIdentityKey, isAgentBrowserSessionIdentityKeyInNamespace, } from "./argv-grammar.js";
|
|
4
|
+
import { batchHasSuccessfulCloseAll, getSuccessfulBatchCloseLifecycle } from "./batch-lifecycle.js";
|
|
5
|
+
import { BROWSER_RESULT_TOOLS, BROWSER_TRANSITION_ENTRY, applyArtifactChanges, artifactChanges, browserStateEffects, getBrowserRecord, } from "./browser-transcript.js";
|
|
6
|
+
import { isCloseAllCommand, isCloseCommand } from "./command-taxonomy.js";
|
|
7
|
+
import { isRecord } from "./parsing.js";
|
|
8
|
+
import { isSessionArtifactManifest } from "./results/artifact-manifest.js";
|
|
9
|
+
import { browserStringArray } from "./browser-value-parsing.js";
|
|
10
|
+
import { canonicalPage, LegacyPageConversion } from "./browser-legacy-pages.js";
|
|
11
|
+
export const emptyProjection = () => ({ pages: new Map(), nextIndex: 0 });
|
|
12
|
+
function legacyMessage(entry) {
|
|
13
|
+
if (entry.type === "custom" &&
|
|
14
|
+
entry.customType === BROWSER_TRANSITION_ENTRY &&
|
|
15
|
+
isRecord(entry.data) &&
|
|
16
|
+
isRecord(entry.data.details)) {
|
|
17
|
+
return entry.data;
|
|
18
|
+
}
|
|
19
|
+
const message = entry.type === "message" && isRecord(entry.message) ? entry.message : undefined;
|
|
20
|
+
return isLegacyToolMessage(message) ? message : undefined;
|
|
21
|
+
}
|
|
22
|
+
function isLegacyToolMessage(message) {
|
|
23
|
+
return (message !== undefined &&
|
|
24
|
+
typeof message.toolName === "string" &&
|
|
25
|
+
BROWSER_RESULT_TOOLS.has(message.toolName) &&
|
|
26
|
+
isRecord(message.details) &&
|
|
27
|
+
message.details.browserEventVersion !== 1);
|
|
28
|
+
}
|
|
29
|
+
function applyCanonical(current, parent, canonical) {
|
|
30
|
+
current.manifest = applyArtifactChanges(parent.manifest, canonical.event.artifacts);
|
|
31
|
+
for (const page of canonical.event.pages ?? []) {
|
|
32
|
+
if (page.clear === true) {
|
|
33
|
+
current.pages.delete(page.key);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
current.pages.set(page.key, canonicalPage(current.pages.get(page.key) ?? {}, canonical, page));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function scriptRecord(entry, nativeId, ownerSessionId) {
|
|
40
|
+
if (entry.type !== "custom" ||
|
|
41
|
+
entry.customType !== "agent-browser-script-session" ||
|
|
42
|
+
!isRecord(entry.data)) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
event: {
|
|
47
|
+
version: 1,
|
|
48
|
+
phase: "state",
|
|
49
|
+
operationId: `legacy-${nativeId}`,
|
|
50
|
+
toolCallId: `legacy-${nativeId}`,
|
|
51
|
+
commandIndex: 0,
|
|
52
|
+
isError: entry.data.cleanup !== "closed",
|
|
53
|
+
state: {
|
|
54
|
+
scriptLease: { ...entry.data, ownerSessionId: entry.data.ownerSessionId ?? ownerSessionId },
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function isLegacyBegin(entry, details) {
|
|
60
|
+
return (entry.type === "custom" &&
|
|
61
|
+
details.sessionTabTargetUnknown === true &&
|
|
62
|
+
details.command === undefined &&
|
|
63
|
+
details.exitCode === undefined &&
|
|
64
|
+
details.agentBrowserStarted === undefined);
|
|
65
|
+
}
|
|
66
|
+
function legacyIdentity(details) {
|
|
67
|
+
const sessionName = typeof details.sessionName === "string" ? details.sessionName : undefined;
|
|
68
|
+
const namespace = typeof details.namespace === "string" ? details.namespace : undefined;
|
|
69
|
+
const key = sessionName !== undefined && sessionName.length > 0
|
|
70
|
+
? getAgentBrowserSessionIdentityKey(sessionName, namespace)
|
|
71
|
+
: undefined;
|
|
72
|
+
const tokens = extractUpstreamCommandTokens(browserStringArray(details.args));
|
|
73
|
+
return {
|
|
74
|
+
key,
|
|
75
|
+
namespace,
|
|
76
|
+
tokens,
|
|
77
|
+
command: typeof details.command === "string" ? details.command : tokens[0],
|
|
78
|
+
subcommand: typeof details.subcommand === "string" ? details.subcommand : tokens[1],
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function legacyPrior(key, current) {
|
|
82
|
+
return key === undefined ? {} : (current.pages.get(key) ?? {});
|
|
83
|
+
}
|
|
84
|
+
function operationIdentity(options, current) {
|
|
85
|
+
const prior = legacyPrior(options.key, current);
|
|
86
|
+
const begin = isLegacyBegin(options.entry, options.details);
|
|
87
|
+
const pending = prior.pending?.toolCallId === options.toolCallId ? prior.pending : undefined;
|
|
88
|
+
let phase = "state";
|
|
89
|
+
if (begin) {
|
|
90
|
+
phase = "begin";
|
|
91
|
+
}
|
|
92
|
+
else if (pending) {
|
|
93
|
+
phase = "finish";
|
|
94
|
+
}
|
|
95
|
+
let commandIndex = pending?.index ?? 0;
|
|
96
|
+
if (begin) {
|
|
97
|
+
commandIndex = current.nextIndex;
|
|
98
|
+
current.nextIndex++;
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
prior,
|
|
102
|
+
begin,
|
|
103
|
+
phase,
|
|
104
|
+
commandIndex,
|
|
105
|
+
operationId: pending?.operationId ?? `legacy-${options.nativeId}`,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function context(entry, message, details, current) {
|
|
109
|
+
const nativeId = typeof entry.id === "string" ? entry.id : randomUUID();
|
|
110
|
+
const toolCallId = typeof message.toolCallId === "string" ? message.toolCallId : `legacy-${nativeId}`;
|
|
111
|
+
const identity = legacyIdentity(details);
|
|
112
|
+
const operation = operationIdentity({ entry, details, key: identity.key, toolCallId, nativeId }, current);
|
|
113
|
+
return {
|
|
114
|
+
...identity,
|
|
115
|
+
...operation,
|
|
116
|
+
nativeId,
|
|
117
|
+
details,
|
|
118
|
+
isError: message.isError === true,
|
|
119
|
+
toolCallId,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function closingLifecycle(ctx) {
|
|
123
|
+
const close = getSuccessfulBatchCloseLifecycle(ctx.details.batchSteps);
|
|
124
|
+
const closeAll = ctx.details.closeAllApplied === true ||
|
|
125
|
+
(!ctx.isError && isCloseAllCommand(ctx.tokens)) ||
|
|
126
|
+
batchHasSuccessfulCloseAll(ctx.details.batchSteps);
|
|
127
|
+
return {
|
|
128
|
+
closeAll,
|
|
129
|
+
lifecycleReset: (!ctx.isError && isCloseCommand(ctx.command)) || close !== undefined,
|
|
130
|
+
endsClosed: close?.endsClosed === true,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function closePages(current, ctx) {
|
|
134
|
+
const closing = closingLifecycle(ctx);
|
|
135
|
+
const pages = [];
|
|
136
|
+
if (closing.closeAll) {
|
|
137
|
+
for (const key of current.pages.keys()) {
|
|
138
|
+
if (isAgentBrowserSessionIdentityKeyInNamespace(key, ctx.namespace)) {
|
|
139
|
+
current.pages.delete(key);
|
|
140
|
+
pages.push({ key, clear: true, refs: { kind: "invalidate" } });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
else if (ctx.key !== undefined && closing.lifecycleReset) {
|
|
145
|
+
current.pages.delete(ctx.key);
|
|
146
|
+
pages.push({ key: ctx.key, clear: true, refs: { kind: "invalidate" } });
|
|
147
|
+
}
|
|
148
|
+
return { ...closing, pages };
|
|
149
|
+
}
|
|
150
|
+
function hasPageEffects(ctx) {
|
|
151
|
+
return (ctx.begin ||
|
|
152
|
+
[
|
|
153
|
+
"sessionTabTargetUnknown",
|
|
154
|
+
"sessionTabTarget",
|
|
155
|
+
"sessionTabReopenPending",
|
|
156
|
+
"refSnapshot",
|
|
157
|
+
"refSnapshotInvalidation",
|
|
158
|
+
].some((field) => ctx.details[field] !== undefined) ||
|
|
159
|
+
(ctx.command === "batch" && Array.isArray(ctx.details.data)));
|
|
160
|
+
}
|
|
161
|
+
function stampElectronState(state, ownerSessionId) {
|
|
162
|
+
if (!isRecord(state.electron)) {
|
|
163
|
+
return state;
|
|
164
|
+
}
|
|
165
|
+
const stamp = (value) => isRecord(value) ? { ...value, ownerSessionId: value.ownerSessionId ?? ownerSessionId } : value;
|
|
166
|
+
const cleanup = isRecord(state.electron.cleanup) ? state.electron.cleanup : undefined;
|
|
167
|
+
return {
|
|
168
|
+
...state,
|
|
169
|
+
electron: {
|
|
170
|
+
...state.electron,
|
|
171
|
+
launch: stamp(state.electron.launch),
|
|
172
|
+
...(cleanup
|
|
173
|
+
? {
|
|
174
|
+
cleanup: {
|
|
175
|
+
...cleanup,
|
|
176
|
+
records: Array.isArray(cleanup.records)
|
|
177
|
+
? cleanup.records.map(stamp)
|
|
178
|
+
: cleanup.records,
|
|
179
|
+
results: Array.isArray(cleanup.results)
|
|
180
|
+
? cleanup.results.map((row) => isRecord(row) ? { ...row, record: stamp(row.record) } : row)
|
|
181
|
+
: cleanup.results,
|
|
182
|
+
},
|
|
183
|
+
}
|
|
184
|
+
: {}),
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
function updateManifest(current, parent, details) {
|
|
189
|
+
if (isSessionArtifactManifest(details.artifactManifest) &&
|
|
190
|
+
(!parent.manifest || details.artifactManifest.updatedAtMs >= parent.manifest.updatedAtMs)) {
|
|
191
|
+
current.manifest = details.artifactManifest;
|
|
192
|
+
}
|
|
193
|
+
const changes = artifactChanges(parent.manifest, current.manifest);
|
|
194
|
+
if (!changes) {
|
|
195
|
+
current.manifest = parent.manifest;
|
|
196
|
+
}
|
|
197
|
+
return changes;
|
|
198
|
+
}
|
|
199
|
+
function convertMessage(ctx, parent, current, ownerSessionId) {
|
|
200
|
+
const closing = closePages(current, ctx);
|
|
201
|
+
const pages = closing.pages;
|
|
202
|
+
let definition;
|
|
203
|
+
const suppressPage = (closing.closeAll || closing.lifecycleReset) &&
|
|
204
|
+
(isCloseCommand(ctx.command) || closing.endsClosed);
|
|
205
|
+
if (ctx.key !== undefined && hasPageEffects(ctx) && !suppressPage) {
|
|
206
|
+
const conversion = new LegacyPageConversion(ctx, current.pages.get(ctx.key) ?? {});
|
|
207
|
+
pages.push(conversion.change(ctx.key));
|
|
208
|
+
current.pages.set(ctx.key, conversion.page);
|
|
209
|
+
definition = conversion.definition;
|
|
210
|
+
}
|
|
211
|
+
const artifacts = updateManifest(current, parent, ctx.details);
|
|
212
|
+
return {
|
|
213
|
+
event: {
|
|
214
|
+
version: 1,
|
|
215
|
+
phase: ctx.phase,
|
|
216
|
+
operationId: ctx.operationId,
|
|
217
|
+
toolCallId: ctx.toolCallId,
|
|
218
|
+
commandIndex: ctx.commandIndex,
|
|
219
|
+
isError: ctx.isError,
|
|
220
|
+
state: stampElectronState(browserStateEffects(ctx.details), ownerSessionId),
|
|
221
|
+
pages,
|
|
222
|
+
artifacts,
|
|
223
|
+
},
|
|
224
|
+
...(definition ? { snapshot: definition } : {}),
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
/** Offline only: normalize old receipts along their actual parent ancestry, never physical equality. */
|
|
228
|
+
export function convertLegacyBrowserEntry(entry, parent = emptyProjection(), ownerSessionId) {
|
|
229
|
+
const current = {
|
|
230
|
+
pages: new Map(parent.pages),
|
|
231
|
+
manifest: parent.manifest,
|
|
232
|
+
nextIndex: parent.nextIndex,
|
|
233
|
+
};
|
|
234
|
+
const canonical = getBrowserRecord(entry);
|
|
235
|
+
if (canonical) {
|
|
236
|
+
applyCanonical(current, parent, canonical);
|
|
237
|
+
return { projection: current };
|
|
238
|
+
}
|
|
239
|
+
const script = scriptRecord(entry, typeof entry.id === "string" ? entry.id : randomUUID(), ownerSessionId);
|
|
240
|
+
if (script) {
|
|
241
|
+
return { record: script, projection: current };
|
|
242
|
+
}
|
|
243
|
+
const message = legacyMessage(entry);
|
|
244
|
+
if (!message || !isRecord(message.details)) {
|
|
245
|
+
return { projection: parent };
|
|
246
|
+
}
|
|
247
|
+
return {
|
|
248
|
+
record: convertMessage(context(entry, message, message.details, current), parent, current, ownerSessionId),
|
|
249
|
+
projection: current,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
function archiveParent(value, states, linear) {
|
|
253
|
+
if (typeof value.parentId === "string") {
|
|
254
|
+
return states.get(value.parentId) ?? emptyProjection();
|
|
255
|
+
}
|
|
256
|
+
return Object.hasOwn(value, "parentId") ? emptyProjection() : linear;
|
|
257
|
+
}
|
|
258
|
+
/** Explicit archive conversion; runtime restoration never invokes the legacy decoder. */
|
|
259
|
+
export function convertBrowserEntries(entries, ownerSessionId) {
|
|
260
|
+
const states = new Map();
|
|
261
|
+
let linear = emptyProjection();
|
|
262
|
+
return entries.map((value, index) => {
|
|
263
|
+
if (!isRecord(value)) {
|
|
264
|
+
return value;
|
|
265
|
+
}
|
|
266
|
+
const entry = {
|
|
267
|
+
...value,
|
|
268
|
+
id: typeof value.id === "string" ? value.id : `archive-${index}`,
|
|
269
|
+
parentId: value.parentId ?? null,
|
|
270
|
+
};
|
|
271
|
+
const converted = convertLegacyBrowserEntry(entry, archiveParent(value, states, linear), ownerSessionId);
|
|
272
|
+
states.set(entry.id, converted.projection);
|
|
273
|
+
linear = converted.projection;
|
|
274
|
+
return converted.record
|
|
275
|
+
? {
|
|
276
|
+
...entry,
|
|
277
|
+
...(entry.type === "custom" ? { customType: BROWSER_TRANSITION_ENTRY } : {}),
|
|
278
|
+
data: converted.record,
|
|
279
|
+
}
|
|
280
|
+
: entry;
|
|
281
|
+
});
|
|
282
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|