pi-agent-browser-native 0.9.4 → 0.9.6
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 +48 -0
- package/README.md +60 -812
- package/dist/extensions/agent-browser/index.js +2381 -1706
- package/dist/packaged/lib/browser-session-conversion.js +2810 -0
- package/dist/packaged/lib/config-policy.js +599 -0
- package/dist/packaged/lib/parsing.js +34 -0
- package/dist/packaged/lib/playbook.js +694 -0
- package/dist/packaged/lib/results/snapshot.js +2671 -0
- package/dist/packaged/lib/runtime.js +3027 -0
- package/docs/ARCHITECTURE.md +14 -3
- package/docs/CODE_QUALITY.md +39 -3
- package/docs/COMMAND_REFERENCE.md +22 -22
- package/docs/ELECTRON.md +24 -2
- package/docs/PERFORMANCE.md +243 -0
- package/docs/REFERENCE.md +869 -0
- package/docs/RELEASE.md +9 -9
- package/docs/REQUIREMENTS.md +1 -1
- package/docs/SESSION_STORAGE.md +11 -3
- package/docs/SUPPORT_MATRIX.md +16 -11
- package/docs/TOOL_CONTRACT.md +17 -13
- package/docs/performance/2026-10-12.json +7257 -0
- package/docs/platform-smoke.md +3 -3
- package/package.json +15 -3
- package/scripts/build.mjs +16 -5
- package/scripts/config.mjs +24 -20
- package/scripts/convert-browser-session.mjs +1 -1
- package/scripts/doctor.mjs +2 -2
- package/scripts/platform-smoke/lease-evidence.mjs +2 -4
- package/scripts/platform-smoke/linux-image/Dockerfile +8 -2
- package/scripts/platform-smoke/targets.mjs +1 -5
- package/dist/extensions/agent-browser/lib/argv-descriptor.js +0 -123
- package/dist/extensions/agent-browser/lib/argv-grammar.js +0 -320
- package/dist/extensions/agent-browser/lib/bash-guard.js +0 -193
- package/dist/extensions/agent-browser/lib/batch-lifecycle.js +0 -131
- package/dist/extensions/agent-browser/lib/browser-execution-claim-codec.js +0 -61
- package/dist/extensions/agent-browser/lib/browser-execution-claim-storage.js +0 -232
- package/dist/extensions/agent-browser/lib/browser-execution-claims.js +0 -202
- package/dist/extensions/agent-browser/lib/browser-execution-identity.js +0 -77
- package/dist/extensions/agent-browser/lib/browser-journal-branch.js +0 -98
- package/dist/extensions/agent-browser/lib/browser-journal-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/browser-journal-projection.js +0 -221
- package/dist/extensions/agent-browser/lib/browser-journal-reader.js +0 -89
- package/dist/extensions/agent-browser/lib/browser-journal-replay.js +0 -246
- package/dist/extensions/agent-browser/lib/browser-journal.js +0 -148
- package/dist/extensions/agent-browser/lib/browser-legacy-pages.js +0 -220
- package/dist/extensions/agent-browser/lib/browser-legacy-projection.js +0 -282
- package/dist/extensions/agent-browser/lib/browser-legacy-types.js +0 -1
- package/dist/extensions/agent-browser/lib/browser-session-conversion-stream.js +0 -217
- package/dist/extensions/agent-browser/lib/browser-session-conversion.js +0 -126
- package/dist/extensions/agent-browser/lib/browser-transcript-contracts.js +0 -35
- package/dist/extensions/agent-browser/lib/browser-transcript-validation.js +0 -166
- package/dist/extensions/agent-browser/lib/browser-transcript.js +0 -189
- package/dist/extensions/agent-browser/lib/browser-value-parsing.js +0 -15
- package/dist/extensions/agent-browser/lib/command-capabilities.js +0 -340
- package/dist/extensions/agent-browser/lib/command-policy.js +0 -155
- package/dist/extensions/agent-browser/lib/command-taxonomy.js +0 -105
- package/dist/extensions/agent-browser/lib/config-policy.js +0 -450
- package/dist/extensions/agent-browser/lib/config-providers.js +0 -71
- package/dist/extensions/agent-browser/lib/config-validation.js +0 -218
- package/dist/extensions/agent-browser/lib/config.js +0 -69
- package/dist/extensions/agent-browser/lib/electron/cdp.js +0 -58
- package/dist/extensions/agent-browser/lib/electron/cleanup.js +0 -308
- package/dist/extensions/agent-browser/lib/electron/discovery-darwin.js +0 -109
- package/dist/extensions/agent-browser/lib/electron/discovery-desktop.js +0 -136
- package/dist/extensions/agent-browser/lib/electron/discovery-evidence.js +0 -89
- package/dist/extensions/agent-browser/lib/electron/discovery-linux.js +0 -93
- package/dist/extensions/agent-browser/lib/electron/discovery-packages.js +0 -162
- package/dist/extensions/agent-browser/lib/electron/discovery-types.js +0 -2
- package/dist/extensions/agent-browser/lib/electron/discovery.js +0 -217
- package/dist/extensions/agent-browser/lib/electron/launch-monitor.js +0 -102
- package/dist/extensions/agent-browser/lib/electron/launch-process.js +0 -209
- package/dist/extensions/agent-browser/lib/electron/launch-types.js +0 -2
- package/dist/extensions/agent-browser/lib/electron/launch.js +0 -329
- package/dist/extensions/agent-browser/lib/executable-path.js +0 -29
- package/dist/extensions/agent-browser/lib/execution-cwd.js +0 -67
- package/dist/extensions/agent-browser/lib/fs-utils.js +0 -18
- package/dist/extensions/agent-browser/lib/input-modes/electron.js +0 -201
- package/dist/extensions/agent-browser/lib/input-modes/job.js +0 -195
- package/dist/extensions/agent-browser/lib/input-modes/lookup-network-evidence.js +0 -104
- package/dist/extensions/agent-browser/lib/input-modes/lookup-plan.js +0 -132
- package/dist/extensions/agent-browser/lib/input-modes/lookup-redaction.js +0 -57
- package/dist/extensions/agent-browser/lib/input-modes/lookup-source-evidence.js +0 -151
- package/dist/extensions/agent-browser/lib/input-modes/lookup-workspace.js +0 -142
- package/dist/extensions/agent-browser/lib/input-modes/lookups.js +0 -83
- package/dist/extensions/agent-browser/lib/input-modes/params.js +0 -195
- package/dist/extensions/agent-browser/lib/input-modes/qa-analysis.js +0 -268
- package/dist/extensions/agent-browser/lib/input-modes/qa-presentation.js +0 -117
- package/dist/extensions/agent-browser/lib/input-modes/script-child.js +0 -396
- package/dist/extensions/agent-browser/lib/input-modes/script-protocol.js +0 -86
- package/dist/extensions/agent-browser/lib/input-modes/script-types.js +0 -1
- package/dist/extensions/agent-browser/lib/input-modes/script-validation.js +0 -60
- package/dist/extensions/agent-browser/lib/input-modes/script.js +0 -108
- package/dist/extensions/agent-browser/lib/input-modes/semantic-action.js +0 -243
- package/dist/extensions/agent-browser/lib/input-modes/shared.js +0 -48
- package/dist/extensions/agent-browser/lib/input-modes/types.js +0 -65
- package/dist/extensions/agent-browser/lib/json-schema.js +0 -65
- package/dist/extensions/agent-browser/lib/launch-scoped-flags.js +0 -212
- package/dist/extensions/agent-browser/lib/managed-session-policy-lock.js +0 -165
- package/dist/extensions/agent-browser/lib/managed-session-posix-storage.js +0 -58
- package/dist/extensions/agent-browser/lib/managed-session-project-identity.js +0 -244
- package/dist/extensions/agent-browser/lib/managed-session-restore-context.js +0 -84
- package/dist/extensions/agent-browser/lib/managed-session-restore-policy.js +0 -119
- package/dist/extensions/agent-browser/lib/managed-session-restore-state.js +0 -83
- package/dist/extensions/agent-browser/lib/managed-session-restore.js +0 -212
- package/dist/extensions/agent-browser/lib/managed-session-snapshot-records.js +0 -277
- package/dist/extensions/agent-browser/lib/managed-session-snapshots.js +0 -181
- package/dist/extensions/agent-browser/lib/managed-session-storage.js +0 -126
- package/dist/extensions/agent-browser/lib/native-confirmation.js +0 -140
- package/dist/extensions/agent-browser/lib/native-output.js +0 -81
- package/dist/extensions/agent-browser/lib/orchestration/batch-stdin.js +0 -182
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/artifact-merge.js +0 -30
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/artifact-paths.js +0 -188
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/browser-observation-result.js +0 -82
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/click-dispatch.js +0 -406
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/diagnostic-values.js +0 -31
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/diagnostics.js +0 -240
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/electron-observation.js +0 -202
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/electron-text-diagnostics.js +0 -109
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/fill-diagnostics.js +0 -119
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-action-recovery.js +0 -147
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-actions.js +0 -144
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-content.js +0 -123
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-details.js +0 -156
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-electron.js +0 -179
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-evidence.js +0 -39
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-missing-binary.js +0 -89
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-recovery.js +0 -97
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-redaction.js +0 -106
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-timeout.js +0 -110
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result.js +0 -53
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/index.js +0 -224
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/interaction-diagnostics.js +0 -290
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-close.js +0 -167
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-daemon-inspection.js +0 -108
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-daemon-policy.js +0 -174
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/native-helper-observation.js +0 -65
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/observation-types.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/overlay-diagnostics.js +0 -120
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/network-page-filter.js +0 -192
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/scroll-shims.js +0 -225
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-filter-data.js +0 -150
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-filter.js +0 -165
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-rendered-text.js +0 -147
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/wait-timeouts.js +0 -145
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-artifacts.js +0 -159
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-command.js +0 -131
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-daemon.js +0 -93
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-failure.js +0 -42
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-guards.js +0 -242
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-input.js +0 -75
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-observations.js +0 -92
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-page-selection.js +0 -254
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-page-state.js +0 -121
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-refs.js +0 -130
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-resources.js +0 -114
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-semantic.js +0 -121
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-session-plan.js +0 -222
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-timeouts.js +0 -68
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare.js +0 -202
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-analysis.js +0 -191
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-confirmation.js +0 -152
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-diagnostics.js +0 -182
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-electron.js +0 -150
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle-phase-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle-phase.js +0 -115
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle.js +0 -256
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-managed-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-managed.js +0 -256
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-native-phase-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-native-phase.js +0 -93
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-native.js +0 -113
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-navigation-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-navigation.js +0 -316
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-ownership.js +0 -28
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-page-phase-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-page-phase.js +0 -142
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-presentation-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-presentation.js +0 -333
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-publication-phase-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-publication-phase.js +0 -71
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-publication.js +0 -201
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-receipts.js +0 -183
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-refs.js +0 -200
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-tabs.js +0 -142
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output.js +0 -25
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prompt-guards.js +0 -50
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-receipt-reconciliation.js +0 -198
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-recovery-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-recovery-presentation.js +0 -154
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-recovery.js +0 -80
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/screenshot-capture.js +0 -14
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/screenshot-observation.js +0 -206
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-commands.js +0 -130
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-electron.js +0 -210
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-observations.js +0 -61
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-outcomes.js +0 -187
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-refs.js +0 -171
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-tabs.js +0 -228
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state.js +0 -117
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/text-visibility-diagnostics.js +0 -182
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/timeout-diagnostics.js +0 -256
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/timeout-progress.js +0 -108
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/types.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/code-artifact-observation.js +0 -39
- package/dist/extensions/agent-browser/lib/orchestration/code-image-observation.js +0 -119
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/branch.js +0 -92
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/cleanup-result.js +0 -58
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/cleanup.js +0 -78
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/discovery.js +0 -106
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/index.js +0 -60
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/policy.js +0 -86
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-collection.js +0 -69
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-data.js +0 -167
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-presentation.js +0 -164
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe.js +0 -161
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/status.js +0 -165
- package/dist/extensions/agent-browser/lib/orchestration/execution-queue.js +0 -98
- package/dist/extensions/agent-browser/lib/orchestration/extension-artifact-preflight.js +0 -211
- package/dist/extensions/agent-browser/lib/orchestration/extension-artifacts.js +0 -23
- package/dist/extensions/agent-browser/lib/orchestration/extension-attachment-replay.js +0 -99
- package/dist/extensions/agent-browser/lib/orchestration/extension-branch-restore.js +0 -275
- package/dist/extensions/agent-browser/lib/orchestration/extension-code.js +0 -280
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-admission.js +0 -303
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-output.js +0 -36
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-result.js +0 -335
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-run.js +0 -227
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-state.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/extension-electron-ownership.js +0 -204
- package/dist/extensions/agent-browser/lib/orchestration/extension-execution-locks.js +0 -139
- package/dist/extensions/agent-browser/lib/orchestration/extension-execution-queue.js +0 -24
- package/dist/extensions/agent-browser/lib/orchestration/extension-host-coordination.js +0 -98
- package/dist/extensions/agent-browser/lib/orchestration/extension-host-run.js +0 -295
- package/dist/extensions/agent-browser/lib/orchestration/extension-intent-replay.js +0 -41
- package/dist/extensions/agent-browser/lib/orchestration/extension-invocation.js +0 -7
- package/dist/extensions/agent-browser/lib/orchestration/extension-lifecycle.js +0 -102
- package/dist/extensions/agent-browser/lib/orchestration/extension-managed-ownership.js +0 -133
- package/dist/extensions/agent-browser/lib/orchestration/extension-observation.js +0 -120
- package/dist/extensions/agent-browser/lib/orchestration/extension-prompt.js +0 -180
- package/dist/extensions/agent-browser/lib/orchestration/extension-recording.js +0 -290
- package/dist/extensions/agent-browser/lib/orchestration/extension-resource-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/extension-resource-replay.js +0 -269
- package/dist/extensions/agent-browser/lib/orchestration/extension-result-state.js +0 -113
- package/dist/extensions/agent-browser/lib/orchestration/extension-runtime.js +0 -146
- package/dist/extensions/agent-browser/lib/orchestration/extension-script-leases.js +0 -58
- package/dist/extensions/agent-browser/lib/orchestration/extension-tool-boundary.js +0 -62
- package/dist/extensions/agent-browser/lib/orchestration/extension-version-check.js +0 -54
- package/dist/extensions/agent-browser/lib/orchestration/input-plan-types.js +0 -1
- package/dist/extensions/agent-browser/lib/orchestration/input-plan.js +0 -313
- package/dist/extensions/agent-browser/lib/orchestration/input-redaction.js +0 -62
- package/dist/extensions/agent-browser/lib/orchestration/native-config.js +0 -144
- package/dist/extensions/agent-browser/lib/orchestration/native-root-launch.js +0 -77
- package/dist/extensions/agent-browser/lib/orchestration/native-session-defaults.js +0 -231
- package/dist/extensions/agent-browser/lib/orchestration/operation-paths.js +0 -142
- package/dist/extensions/agent-browser/lib/orchestration/output-file.js +0 -276
- package/dist/extensions/agent-browser/lib/orchestration/script-mode.js +0 -220
- package/dist/extensions/agent-browser/lib/owned-managed-session-context.js +0 -55
- package/dist/extensions/agent-browser/lib/page-target-batch.js +0 -118
- package/dist/extensions/agent-browser/lib/page-target-guards.js +0 -50
- package/dist/extensions/agent-browser/lib/page-target-navigation.js +0 -104
- package/dist/extensions/agent-browser/lib/page-target-validation.js +0 -90
- package/dist/extensions/agent-browser/lib/parsing.js +0 -30
- package/dist/extensions/agent-browser/lib/pi-tool-rendering.js +0 -343
- package/dist/extensions/agent-browser/lib/playbook.js +0 -146
- package/dist/extensions/agent-browser/lib/process-child.js +0 -284
- package/dist/extensions/agent-browser/lib/process-environment.js +0 -48
- package/dist/extensions/agent-browser/lib/process-errors.js +0 -23
- package/dist/extensions/agent-browser/lib/process-identity.js +0 -127
- package/dist/extensions/agent-browser/lib/process-socket-storage.js +0 -256
- package/dist/extensions/agent-browser/lib/process-stdout.js +0 -74
- package/dist/extensions/agent-browser/lib/process.js +0 -216
- package/dist/extensions/agent-browser/lib/prompt-artifacts.js +0 -287
- package/dist/extensions/agent-browser/lib/prompt-policy.js +0 -54
- package/dist/extensions/agent-browser/lib/read-command.js +0 -41
- package/dist/extensions/agent-browser/lib/read-confirmation.js +0 -162
- package/dist/extensions/agent-browser/lib/recording-reservations.js +0 -208
- package/dist/extensions/agent-browser/lib/redaction-fields.js +0 -75
- package/dist/extensions/agent-browser/lib/redaction-json.js +0 -149
- package/dist/extensions/agent-browser/lib/redaction-url.js +0 -88
- package/dist/extensions/agent-browser/lib/results/action-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/results/action-recommendations.js +0 -38
- package/dist/extensions/agent-browser/lib/results/artifact-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/results/artifact-manifest-validation.js +0 -133
- package/dist/extensions/agent-browser/lib/results/artifact-manifest.js +0 -173
- package/dist/extensions/agent-browser/lib/results/artifact-recommendations.js +0 -73
- package/dist/extensions/agent-browser/lib/results/categories.js +0 -152
- package/dist/extensions/agent-browser/lib/results/confirmation.js +0 -75
- package/dist/extensions/agent-browser/lib/results/contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/results/editable-ref-evidence.js +0 -99
- package/dist/extensions/agent-browser/lib/results/electron-recommendations.js +0 -83
- package/dist/extensions/agent-browser/lib/results/envelope-decoding.js +0 -48
- package/dist/extensions/agent-browser/lib/results/envelope.js +0 -198
- package/dist/extensions/agent-browser/lib/results/evidence-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/results/failure-recommendations.js +0 -180
- package/dist/extensions/agent-browser/lib/results/network-routes.js +0 -133
- package/dist/extensions/agent-browser/lib/results/network.js +0 -89
- package/dist/extensions/agent-browser/lib/results/next-actions.js +0 -111
- package/dist/extensions/agent-browser/lib/results/presentation/artifact-files.js +0 -320
- package/dist/extensions/agent-browser/lib/results/presentation/artifact-format.js +0 -138
- package/dist/extensions/agent-browser/lib/results/presentation/artifact-images.js +0 -113
- package/dist/extensions/agent-browser/lib/results/presentation/artifact-verification.js +0 -145
- package/dist/extensions/agent-browser/lib/results/presentation/artifacts.js +0 -165
- package/dist/extensions/agent-browser/lib/results/presentation/batch-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/results/presentation/batch-recording.js +0 -118
- package/dist/extensions/agent-browser/lib/results/presentation/batch-redaction.js +0 -68
- package/dist/extensions/agent-browser/lib/results/presentation/batch-rendering.js +0 -135
- package/dist/extensions/agent-browser/lib/results/presentation/batch-step.js +0 -227
- package/dist/extensions/agent-browser/lib/results/presentation/batch-summary.js +0 -91
- package/dist/extensions/agent-browser/lib/results/presentation/batch.js +0 -123
- package/dist/extensions/agent-browser/lib/results/presentation/browser-profile-recovery.js +0 -54
- package/dist/extensions/agent-browser/lib/results/presentation/command-presenters.js +0 -216
- package/dist/extensions/agent-browser/lib/results/presentation/common.js +0 -81
- package/dist/extensions/agent-browser/lib/results/presentation/content.js +0 -119
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-a11y.js +0 -67
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-health.js +0 -79
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-identity.js +0 -199
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-logs.js +0 -75
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-network-actions.js +0 -216
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-network.js +0 -124
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-redaction.js +0 -64
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-storage.js +0 -209
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-stream.js +0 -69
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-summary.js +0 -222
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostics.js +0 -124
- package/dist/extensions/agent-browser/lib/results/presentation/early-result.js +0 -70
- package/dist/extensions/agent-browser/lib/results/presentation/errors.js +0 -285
- package/dist/extensions/agent-browser/lib/results/presentation/input-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/results/presentation/large-output.js +0 -117
- package/dist/extensions/agent-browser/lib/results/presentation/navigation.js +0 -231
- package/dist/extensions/agent-browser/lib/results/presentation/notices.js +0 -75
- package/dist/extensions/agent-browser/lib/results/presentation/observation-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/results/presentation/observation-rendering.js +0 -127
- package/dist/extensions/agent-browser/lib/results/presentation/outcomes.js +0 -120
- package/dist/extensions/agent-browser/lib/results/presentation/output-completion.js +0 -77
- package/dist/extensions/agent-browser/lib/results/presentation/output-spill.js +0 -51
- package/dist/extensions/agent-browser/lib/results/presentation/registry.js +0 -145
- package/dist/extensions/agent-browser/lib/results/presentation/semantic-action.js +0 -104
- package/dist/extensions/agent-browser/lib/results/presentation/skills.js +0 -178
- package/dist/extensions/agent-browser/lib/results/presentation/source.js +0 -109
- package/dist/extensions/agent-browser/lib/results/presentation.js +0 -19
- package/dist/extensions/agent-browser/lib/results/recommendation-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/results/recording.js +0 -88
- package/dist/extensions/agent-browser/lib/results/recovery-actions.js +0 -118
- package/dist/extensions/agent-browser/lib/results/recovery-next-actions.js +0 -60
- package/dist/extensions/agent-browser/lib/results/selector-recovery-target.js +0 -83
- package/dist/extensions/agent-browser/lib/results/selector-recovery.js +0 -261
- package/dist/extensions/agent-browser/lib/results/snapshot-compact.js +0 -266
- package/dist/extensions/agent-browser/lib/results/snapshot-content.js +0 -32
- package/dist/extensions/agent-browser/lib/results/snapshot-high-value-controls.js +0 -240
- package/dist/extensions/agent-browser/lib/results/snapshot-refs.js +0 -103
- package/dist/extensions/agent-browser/lib/results/snapshot-segments.js +0 -383
- package/dist/extensions/agent-browser/lib/results/snapshot-spill.js +0 -53
- package/dist/extensions/agent-browser/lib/results/snapshot.js +0 -44
- package/dist/extensions/agent-browser/lib/results/text.js +0 -44
- package/dist/extensions/agent-browser/lib/runtime-args-validation.js +0 -133
- package/dist/extensions/agent-browser/lib/runtime-compatibility.js +0 -81
- package/dist/extensions/agent-browser/lib/runtime-contracts.js +0 -1
- package/dist/extensions/agent-browser/lib/runtime-redaction.js +0 -118
- package/dist/extensions/agent-browser/lib/runtime-replay-events.js +0 -144
- package/dist/extensions/agent-browser/lib/runtime-session-identity.js +0 -76
- package/dist/extensions/agent-browser/lib/runtime-session-plan.js +0 -114
- package/dist/extensions/agent-browser/lib/runtime-session-replay.js +0 -123
- package/dist/extensions/agent-browser/lib/runtime-tab-correction.js +0 -65
- package/dist/extensions/agent-browser/lib/runtime-timeouts.js +0 -28
- package/dist/extensions/agent-browser/lib/runtime.js +0 -163
- package/dist/extensions/agent-browser/lib/session-identity.js +0 -51
- package/dist/extensions/agent-browser/lib/session-page-observation.js +0 -357
- package/dist/extensions/agent-browser/lib/session-page-state.js +0 -353
- package/dist/extensions/agent-browser/lib/session-page-types.js +0 -1
- package/dist/extensions/agent-browser/lib/string-enum-schema.js +0 -8
- package/dist/extensions/agent-browser/lib/temp-artifact-budget.js +0 -78
- package/dist/extensions/agent-browser/lib/temp-mutation-queue.js +0 -7
- package/dist/extensions/agent-browser/lib/temp-root-ownership.js +0 -234
- package/dist/extensions/agent-browser/lib/temp-root.js +0 -207
- package/dist/extensions/agent-browser/lib/temp.js +0 -91
- package/dist/extensions/agent-browser/lib/tool-surface.js +0 -239
- package/dist/extensions/agent-browser/lib/upstream-version.js +0 -15
- package/dist/extensions/agent-browser/lib/web-search-providers.js +0 -229
- package/dist/extensions/agent-browser/lib/web-search-request.js +0 -108
- package/dist/extensions/agent-browser/lib/web-search-results.js +0 -281
- package/dist/extensions/agent-browser/lib/web-search-schema.js +0 -82
- package/dist/extensions/agent-browser/lib/web-search.js +0 -149
- package/dist/extensions/agent-browser/lib/webmcp-observation.js +0 -35
- package/dist/extensions/agent-browser/lib/windows-stock-launcher.js +0 -96
- package/dist/scripts/agent-browser-target.mjs +0 -23
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { constants, openSync, closeSync, fstatSync } from "node:fs";
|
|
2
|
-
import { open, stat } from "node:fs/promises";
|
|
3
|
-
import { BROWSER_TRANSITION_ENTRY } from "./browser-transcript-contracts.js";
|
|
4
|
-
import { isRecord } from "./parsing.js";
|
|
5
|
-
import { journalRanges, projectJson, readRange } from "./browser-journal-reader.js";
|
|
6
|
-
export { journalRanges, projectJson, readRange, scanJournalMetadata, } from "./browser-journal-reader.js";
|
|
7
|
-
export { readBrowserEntries } from "./browser-journal-replay.js";
|
|
8
|
-
/** A filename is not durability evidence on official Pi before its first conversation. */
|
|
9
|
-
export function requirePublishedBrowserJournal(manager) {
|
|
10
|
-
const path = manager.getSessionFile();
|
|
11
|
-
if (path === undefined || path.length === 0) {
|
|
12
|
-
throw new Error("Browser code requires a published Pi conversation; relaunch without --no-session.");
|
|
13
|
-
}
|
|
14
|
-
let fd;
|
|
15
|
-
try {
|
|
16
|
-
fd = openSync(path, constants.O_RDONLY);
|
|
17
|
-
const entry = fstatSync(fd);
|
|
18
|
-
if (!entry.isFile() || entry.size === 0) {
|
|
19
|
-
throw new Error("Pi conversation has not been published yet.");
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
catch (error) {
|
|
23
|
-
throw new Error("Browser work requires an actually published Pi conversation before dispatch; send a user message first.", { cause: error });
|
|
24
|
-
}
|
|
25
|
-
finally {
|
|
26
|
-
if (fd !== undefined) {
|
|
27
|
-
closeSync(fd);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
/** Observation-only artifact receipts are optional until Pi publishes its journal. */
|
|
32
|
-
export function hasPublishedBrowserJournal(manager) {
|
|
33
|
-
try {
|
|
34
|
-
requirePublishedBrowserJournal(manager);
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
catch {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
export { captureBrowserBranch } from "./browser-journal-branch.js";
|
|
42
|
-
const RECEIPT_FIELDS = [
|
|
43
|
-
["type"],
|
|
44
|
-
["id"],
|
|
45
|
-
["customType"],
|
|
46
|
-
...["version", "operationId", "phase", "toolCallId", "commandIndex"].map((field) => [
|
|
47
|
-
"data",
|
|
48
|
-
"event",
|
|
49
|
-
field,
|
|
50
|
-
]),
|
|
51
|
-
];
|
|
52
|
-
function matchesReceipt(value, receipt) {
|
|
53
|
-
if (value.id !== receipt.nativeId ||
|
|
54
|
-
value.type !== "custom" ||
|
|
55
|
-
value.customType !== BROWSER_TRANSITION_ENTRY ||
|
|
56
|
-
!isRecord(value.data) ||
|
|
57
|
-
!isRecord(value.data.event)) {
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
const event = value.data.event;
|
|
61
|
-
const expected = receipt.expected.event;
|
|
62
|
-
const identity = {
|
|
63
|
-
operationId: expected.operationId,
|
|
64
|
-
phase: expected.phase,
|
|
65
|
-
toolCallId: expected.toolCallId,
|
|
66
|
-
commandIndex: expected.commandIndex,
|
|
67
|
-
};
|
|
68
|
-
return (event.version === 1 &&
|
|
69
|
-
Object.entries(identity).every(([key, fieldValue]) => event[key] === fieldValue));
|
|
70
|
-
}
|
|
71
|
-
async function countPublishedReceipts(file, journal, receipt) {
|
|
72
|
-
let matches = 0;
|
|
73
|
-
for await (const range of journalRanges(file, journal.after.size, false, journal.start)) {
|
|
74
|
-
const value = await projectJson(readRange(file, range), RECEIPT_FIELDS);
|
|
75
|
-
if (!value) {
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
78
|
-
if (value.type === "session" && value.id !== journal.sessionId) {
|
|
79
|
-
throw new Error("Pi repaired journal identity differs from the active session.");
|
|
80
|
-
}
|
|
81
|
-
if (matchesReceipt(value, receipt)) {
|
|
82
|
-
matches++;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return matches;
|
|
86
|
-
}
|
|
87
|
-
function appendToBranch(manager, append, branch) {
|
|
88
|
-
append();
|
|
89
|
-
if (branch.anchorId === null) {
|
|
90
|
-
branch.anchorId = manager.getLeafId();
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
async function verifyAppend(file, path, before, receipt) {
|
|
94
|
-
const after = await file.stat();
|
|
95
|
-
const sameFile = after.dev === before.dev && after.ino === before.ino;
|
|
96
|
-
if (!after.isFile() || (sameFile && after.size <= before.size)) {
|
|
97
|
-
throw new Error("Pi did not publish the browser event.");
|
|
98
|
-
}
|
|
99
|
-
const matches = await countPublishedReceipts(file, { after, start: sameFile ? before.size : 0, sessionId: receipt.sessionId }, receipt);
|
|
100
|
-
const current = await stat(path);
|
|
101
|
-
if (matches !== 1 ||
|
|
102
|
-
current.dev !== after.dev ||
|
|
103
|
-
current.ino !== after.ino ||
|
|
104
|
-
current.size < after.size) {
|
|
105
|
-
throw new Error("Pi browser append has no matching published journal receipt.");
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
async function appendPublishedRecord(manager, path, operation) {
|
|
109
|
-
const beforeFile = await open(path, constants.O_RDONLY);
|
|
110
|
-
let file;
|
|
111
|
-
try {
|
|
112
|
-
const before = await beforeFile.stat();
|
|
113
|
-
// Native navigation changes the leaf before its awaited session_tree handlers.
|
|
114
|
-
if (!operation.branch.isCurrent()) {
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
appendToBranch(manager, operation.append, operation.branch);
|
|
118
|
-
const nativeId = manager.getLeafId();
|
|
119
|
-
// Native repair may flush several records or replace the file. Reopen and frame the actual journal.
|
|
120
|
-
file = await open(path, constants.O_RDONLY);
|
|
121
|
-
await verifyAppend(file, path, before, {
|
|
122
|
-
nativeId,
|
|
123
|
-
expected: operation.expected,
|
|
124
|
-
sessionId: manager.getHeader()?.id ?? manager.getSessionId(),
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
finally {
|
|
128
|
-
await file?.close();
|
|
129
|
-
await beforeFile.close();
|
|
130
|
-
}
|
|
131
|
-
return operation.branch.isCurrent();
|
|
132
|
-
}
|
|
133
|
-
/** A withdrawn branch returns false; required publication faults still throw. */
|
|
134
|
-
export async function appendBrowserRecord(manager, append, expected, branch) {
|
|
135
|
-
if ((manager.getSessionFile() ?? "").length === 0) {
|
|
136
|
-
if (!branch.isCurrent()) {
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
|
-
appendToBranch(manager, append, branch);
|
|
140
|
-
return branch.isCurrent();
|
|
141
|
-
}
|
|
142
|
-
requirePublishedBrowserJournal(manager);
|
|
143
|
-
const path = manager.getSessionFile();
|
|
144
|
-
if (path === undefined || path.length === 0) {
|
|
145
|
-
throw new Error("Pi conversation has no published journal locator.");
|
|
146
|
-
}
|
|
147
|
-
return appendPublishedRecord(manager, path, { append, expected, branch });
|
|
148
|
-
}
|
|
@@ -1,220 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,282 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|